Minimal DWS Execution Contract
- Use only
dws; for structured reading add--format json, and judge by the actual return. - Call known commands directly; if parameters/constraints/security are unclear, check the leaf narrow Schema. Only if the Schema is unavailable, read the known leaf Help once;
unknown flagcorrect once with the same leaf Help.unknown commandDo not check Help: prefer the explicit suggestion in the error, then the explicit compatible entry in the loaded Skill/reference; if neither exists, report drift and stop, full Catalog is forbidden. For low-frequency references, do not default to Help; root/parent/product Help is forbidden. After discovery, you must execute or explain the blockage. - Do not guess commands/flags/fields/IDs/accounts/business facts; IDs come from actual returns. For zero hits/multiple candidates/unclear type on the target, disambiguate first; use contract defaults only for optional time/display scope, and stop when required information is missing.
- Parse/read/write use the same profile, IDs do not cross organizations. For multiple accounts, use only the unique
isOrgCurrent=true; otherwise the user specifies, and selecting the first item, most recent login, or most recently used account is forbidden. - Do not output/record tokens, refresh tokens, appSecret, webhook tokens; do not ask for them when authentication is already injected.
- Writing must match explicit intent; confirmation is subject to the final Runtime gate/Schema, and only after confirmation add
--yes。 - After writing, verify the result; do not claim success based on the exit code. Exit must be the final reply, distinguishing completed, partial, blocked, pending confirmation, and failed; preserve existing data and
complete/hasMore/stopReason/failures。 - Display timestamps in the session time zone, and preserve the original values when necessary.
- For authentication/permission/profile/confirmation/unknown errors, only read
dingtalk-sharedthe corresponding reference; guessing alternative commands continuously is forbidden.
The "unique" in the automatic list below refers only to a single-page match;+resolve-space/+wiki-new-doc does not assume authoritative unique resolution before writing; resolve according to the Golden Route and then use the real workspaceId.
Shortcuts (preferred when there is no dedicated script/recipe)
The following shortcuts enter both the public catalog and the Runtime Schema. Route according to this skill/recipe; when matched, Shortcut takes precedence over atomic commands. For parameters, check only dws schema --cli-path "wiki +<shortcut>" --compact --jq '{cli_path,parameters,constraints,confirmation}' -f json; when only the published result is needed and available, check --jq '{cli_path,outcomes:.result.outcomes,pagination}', and for field level check again data_schema; do not infer missing ones from Help/examples. Only if the Schema is unavailable, read the known leaf Help once;unknown flag correct once with the same leaf Help.unknown command Help is forbidden: error suggestion → explicit entry in the loaded Skill/reference; if neither exists, report drift. Full Catalog/root/parent/product Help is forbidden; omit only for mapping, interface, or provenance auditing --compact. Only when neither the existing routes nor the reference can locate a low-frequency capability, use dws shortcut list --service wiki --format json discovery.
| Shortcut | Risk | Applicable scenario |
|---|---|---|
dws wiki +resolve-space |
read | Search knowledge spaces by name and resolve the unique spaceId in a single result (read-only) |
dws wiki +wiki-new-doc |
write | Create a new document node under the knowledge base with the specified name (resolve workspaceId by single name search) |
Golden Route
| User intent | Only recommended entry | Key boundary |
|---|---|---|
| Resolve the unique knowledge base by name | +space-list --type <orgWikiSpace|myWikiSpace> --limit 50 --page-all then exact-match the name |
First clarify the organization/personal scope; the result's requestedType must equal the requested scope; only autoPageComplete=true and when there is exactly one item with the same name in the full set, take the workspaceId |
| Search or list knowledge bases | +space-search --query <关键词> / +space-list [--type orgWikiSpace|myWikiSpace] |
When the user requests all, add --page-all; personal knowledge bases must have explicit semantics |
| Discover DingTalk Drive storage spaces for Drive | dws wiki space list --type <orgSpace|mySpace> --format json |
managed read-only prerequisite; after returning spaceId/rootFolderId, switch back to Drive, and do not enter Wiki node/member routing |
| View details for a known workspace | dws wiki +space-get --workspace <ID或URL> |
Do not search again for a known ID |
| Create or delete a knowledge base | +space-create --name <名称> / +delete-space --workspace <ID> |
Creation reads back and verifies the space type; only spaceTypeVerified=true allows asserting the type. Deleting an entire space is a high-risk operation |
| Browse or search nodes in a library | +node-list --workspace <ID> [--folder <ID>] / +node-search --workspace <ID> --query <词> |
Listing directories and keyword search are separate; add for both a complete list and complete search results --page-all |
| View node metadata | dws wiki +node-get --node <ID或URL> |
Body read/write then switches to Doc |
| Create a node in a known workspace | +node-create --workspace <ID> --name <名称> [--type <类型>] |
Supports adoc/axls/able/appt/adraw/amind/folder; after creation, verify ID, workspace, name, type, and explicit parent folder |
| Create a new empty document when only the knowledge base name is available | First use the full +space-list unique resolution, then +node-create --workspace <ID> --name <标题> --type adoc |
Do not use single-page +wiki-new-doc to guess the space; the body goes through Doc separately |
| Create a document in a new knowledge base using a local file, then move it to "My Documents" | +space-create → doc +import --file <相对路径> --workspace <新workspaceId> → +move-to-drive --workspace <新workspaceId> --node <导入nodeId> |
The document must first actually be imported into the new knowledge base before being moved out; first querying is prohibited mySpace, and doc +create creating in the personal domain and then using drive +move to impersonate this flow are prohibited |
| Copy, move into a knowledge base, or move an online Wiki node out to "My Documents" | +node-copy / +move / +move-to-drive |
"Wiki node → My Documents" always uses +move-to-drive, and when the source workspace is known, --workspace may be passed as a pre-write ownership assertion; do not switch to mySpace/rootFolderId + drive +move |
| Place a standalone regular attachment on the knowledge base homepage | dws drive upload --file <本地文件> --workspace <ID> --format json |
Do not add --convert; for subdirectories add --folder <目录nodeId>. Attachments within the body switch to Doc media, and converting online documents switches to Doc import |
| Delete a node in a library | +node-delete --workspace <ID> --node <ID> |
Verify ownership before deletion and confirm |
| List, add, modify, or remove knowledge base members | member list / +member-add / +member-update / +member-remove |
Write 1-30 users; add/modify must specify a role, removal does not pass a role; for multiple types, per-member roles, or notifications, use native member |
| Set the knowledge base space sharing scope | dws wiki permission set-share-scope --workspace <ID> --visibility <PRIVATE|ORGANIZATION|PUBLIC> |
[Dangerous] Applies to the entire space and its inherited nodes that are not broken; turning off PRIVATE will erase the original levels of inherited nodes that are not broken, and the space must be reconfigured if it needs to be public again; PUBLIC only supports READER/DOWNLOADER; the response body already echoes the write result |
| View knowledge base activity | +feed-list --workspace <ID> [--exclude-file] |
For all activity add --page-all; compare the two result sets only when the user explicitly requests verification of the filtering effect, and the unfiltered result must actually contain that file event |
Current shortest path
- Known workspaceId (including this round's creation receipt): directly execute the space/node/member/feed target command, do not resolve again, and do not pass the name to
--workspaceWhen the user additionally requests “lookup by name,” still complete that lookup step; having an existing ID does not mean an explicit request can be omitted. - Only a knowledge base name is available: first clarify whether the scope is organizational or personal, and verify the full name according to the corresponding Golden Route branch; if the scope is unknown, disambiguate first, and do not scan both scopes at the same time and guess.
+space-searchIt is only used for quickly browsing candidates; the current+resolve-space/+wiki-new-docdoes not expose paging completion evidence for name search, so it is not used as authoritative unique resolution or written into the Golden Route.- Known nodeId/URL: metadata is directly
+node-get; for body content, switch directly to Doc without first doing list/search. - The nodeId returned after creating a node is passed directly to Doc; do not relocate it via a same-name search. The
nodeIdof the created folder is the subsequent--folder, and the receiptfolderIdis its parent directory;+node-copy/+movefor the “home page of this library” uses the current workspace and omits--folderseparately.+move-to-drive。 - “Local file → New knowledge base → My Documents” is an ordered cross-product flow: after creating the space returns a workspaceId, you must
doc +import --workspaceobtain the nodeId in the library, thenwiki +move-to-drive --workspace; at no step may you create early in the personal domain or substitute a move from the Drive root directory. - When move/copy/delete already includes prechecks or read-back, the Agent does not repeatedly assemble atomic commands.
- File operations for ordinary “document spaces/My Documents” follow Drive according to storage intent; but when the source object is already determined to be an online node in a Wiki workspace and the goal is to move it out to “My Documents,” that is a clear exception: use
wiki +move-to-drivedirectly, do not querymySpace, and do not calldrive +move. Only when an ordinary Drive node lacks spaceId/rootFolderId should managedwiki space list --type orgSpace|mySpacebe used to discover the space.
Key result semantics
+space-list/+node-list/+node-search/+feed-listdefaults to a single page; for a full request, explicitly add--page-all, and checkautoPageComplete/autoPageStopReason/pagesFetchedand the pagination metadata.+space-listThe top-levelrequestedTypeis the type scope of this server-side query; the entry-levelspaceTypeappears only when the server actually returns it, and cannot be forged with the request value. Before using absence from a list to prove that a space does not exist, both correct scope andautoPageComplete=true。+space-createmust be satisfied at the same time. Only whenspaceTypeVerified=trueis returned canspaceTypebe used; if type verification fails, the already created workspaceId is retained, and it is forbidden to retry creation or guess the type by name.+space-search/+node-searchMissing the business array is not zero hits; only an explicit empty array may be used to report an empty result.- Organizational name resolution must complete the list and be uniquely and exactly same-named; personal name resolution must have exactly one entry in a native success receipt and be exactly same-named, without requiring automatic pagination fields. Empty/malformed responses, 0 entries, multiple entries, name mismatch, or incomplete organizational pagination all stop.
+space-search、+resolve-spaceA single-page result cannot prove global uniqueness; the unique candidate on the first page must not be used directly for writing.+node-list/+node-search/+node-getpreserves the server-sideextension/type/hasChildrenand normalizesparentFolderId; a missing field means the server did not provide it, and the type or hierarchy cannot be inferred by name.- Creating a node must verify the new ID, workspace, name, type, and explicit parent folder; copying must first read the source node, then prove that the new ID differs from the source ID and that the copy enters the target workspace/folder.
+move/+move-to-drivereturnssource/target, the before-and-after workspace, and the target domain; moving to My Documents also usesmyWikiSpacescoped list to verify the target workspace. Deletion must havesuccess=true。- The member list server has no continuation cursor and a maximum of 50; results within the limit must not be claimed as complete; member writes only have final-state response evidence, and no precise read-back may be fabricated.
partial_failure, incomplete pagination, or unknown write effects are all not success.
Parameters and security boundaries
- workspaceId, nodeId, folderId, and userId are not interchangeable; names cannot be used as IDs.
- Write operations are confirmed only by the exact leaf Runtime determination; when a specific space/node/member, action, and impact have been explicitly authorized, the first formal execution directly includes
--yes, otherwise confirm first. Reconfirm when parameters change; do not use failures lacking--yesas probes. wiki member list --limitdefaults to 30, range 1-50; do not use member--page-allor raise the limit. Member write--usersis 1-30, roles onlyMANAGER|EDITOR|DOWNLOADER|READER。+node-create --typedetermines the content product; after creation adoc→Doc, axls→Sheet, able→AITable.- Profile/organization remains consistent during space resolution, node operations, and verification.
Load on demand
When Golden Route parameters are sufficient, do not read reference; otherwise read at most one:
| Trigger conditions | Reference |
|---|---|
| Document space, knowledge base, Drive/Doc boundaries unclear | intent-guide |
| Node types, copy, move, move out, or delete details | node-ops |
| Member roles, limits, and verification semantics | members |
| Pagination, space, dynamics, sharing scope, and low-frequency errors | wiki reference |
| Short cross-product creation/body writing flow | lite-recipes |
Shortest error path
- Empty response, missing collection, zero/multiple candidates, or incomplete pagination: stop subsequent writes and return evidence;
+resolve-space resolved=truealso cannot replace pagination completion evidence for the full space list. - workspace/node attribution inconsistent: stop, do not try another ID or profile.
- Write response lacks a new ID or
success=true: effect unknown; perform a targeted read-back by name/ID, do not blindly replay. unknown flagonly queries the current leaf Help;unknown commandqueries the Wiki Shortcut list only once.- When body, normal storage, or Base records are misrouted, switch back to the corresponding product; do not probe approximate commands within Wiki.
Cross-product boundaries
- Clear knowledge base containers, members, in-library hierarchy, and dynamics → Wiki.
- Body read/write/export after locking onto an adoc node in the library → Doc; axls content → Sheet; able records/fields → AITable.
- Normal files, folders, storage search, transfer, and organization of "My Documents/Document Space" → Drive; if the source is known to be a Wiki online node and the action is "move out to My Documents", use Wiki
+move-to-drive。 - Drive storage space discovery may reuse managed
wiki space list --type orgSpace|mySpace; the result is spaceId/rootFolderId, and it must not be handed to Wiki node/member. Knowledge baseorgWikiSpace/myWikiSpacestill returns workspaceId. - Wiki node move in/move out uses
+move/+move-to-drive; do not treat workspaceId as a normal Drive folderId.