dingtalk-drive
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese钉盘
DingTalk Drive
<!-- DWS_RUNTIME_CONTRACT_START -->
<!-- DWS_RUNTIME_CONTRACT_START -->
最小 DWS 执行契约
Minimal DWS Execution Contract
- 只用 ;结构化读取加
dws,按真实返回判断。--format json - 已知命令直调;参数/约束/安全不明查 leaf 窄 Schema。Schema 不可用才读已知 leaf Help 一次;用同 leaf Help 修正一次。
unknown flag不查 Help:优先错误中的明确 suggestion,其次已加载 Skill/reference 中的明确兼容入口;均无则报漂移并停,禁全 Catalog。低频 reference 不默认 Help,禁 root/parent/product Help。发现后必须执行或说明阻塞。unknown command - 不猜命令/flag/字段/ID/账号/业务事实;ID 来自真实返回。目标零命中/多候选/类型不明先消歧;仅可选时间/展示范围用契约默认,缺必需信息即停。
- 解析/读/写同一 profile,ID 不跨组织。多账号只用唯一 ;否则用户指定,禁止选择第一项、最近登录或最近使用账号。
isOrgCurrent=true - 不输出/记录 token、refresh token、appSecret、webhook token;已注入认证时不索要。
- 写须符合明确意图;确认以最终 Runtime gate/Schema 为准,确认后才加 。
--yes - 写后验证结果,不凭退出码宣称成功。退出须最终答复,区分完成、部分、阻塞、待确认、失败;保留已有数据及 。
complete/hasMore/stopReason/failures - 时间戳按会话时区展示,必要时保留原值。
- 认证/权限/profile/confirmation/未知错误只读 对应 reference,禁连续猜替代命令。
dingtalk-shared
- Use only ; add
dwsfor structured reads and judge by actual returns.--format json - Call known commands directly; when parameters/constraints/safety are unclear, consult the leaf narrow Schema. Only if the Schema is unavailable, read the known leaf Help once; can be corrected once with the same leaf Help. For
unknown flag, do not consult Help: first use the explicit suggestion in the error, then any clear compatible entry in the loaded Skill/reference; if neither exists, report drift and stop. Full Catalog is forbidden. Low-frequency references do not default to Help; root/parent/product Help is forbidden. Once found, you must execute it or explain the blocker.unknown command - Do not guess commands/flags/fields/IDs/accounts/business facts; IDs come from real returns. If the target has zero hits/multiple candidates/ambiguous type, disambiguate first; use contract defaults only for optional time/display scope; stop if required information is missing.
- Parse/read/write with the same profile; IDs do not cross organizations. With multiple accounts, use only the unique account; otherwise the user must specify. Never choose the first item, the most recently logged-in account, or the most recently used account.
isOrgCurrent=true - Do not output/record token, refresh token, appSecret, or webhook token; if authentication is already injected, do not ask for it.
- Writes must match explicit intent; confirmation is determined by the final Runtime gate/Schema; add only after confirmation.
--yes - Verify results after writes; never claim success based solely on the exit code. Exit with a final answer that distinguishes completed, partial, blocked, pending confirmation, and failed; preserve existing data and .
complete/hasMore/stopReason/failures - Display timestamps in the session timezone, preserving original values when necessary.
- For authentication/permission/profile/confirmation/unknown errors, only read the corresponding reference; do not keep guessing alternative commands.
dingtalk-shared
Shortcut 发现(按需)
Shortcut Discovery (On Demand)
driveresultdata_schemaunknown flagunknown command仅当现有路由和 reference 都无法定位低频能力时,才执行 做最后回退;不要为已知高频意图加载完整 Shortcut Catalog 或产品级 Schema。
<!-- VISIBLE_SHORTCUTS_END -->dws shortcut list --service drive --format jsondriveresultdata_schemaunknown flagunknown commandOnly when current routes and references cannot locate a low-frequency capability, run as a last resort; do not load the full Shortcut Catalog or product-level Schema for known high-frequency intents.
<!-- VISIBLE_SHORTCUTS_END -->dws shortcut list --service drive --format jsonGolden Route
Golden Route
| 用户意图 | 唯一推荐入口 | 关键边界 |
|---|---|---|
| 全局按名称或关键词找文件 | | 需要完整搜索时自动翻页;只需首批结果时可不加 |
| 浏览根目录或已知文件夹 | | 需要完整浏览时自动翻页;只需首批结果时可不加 |
| 发现钉盘企业空间或“我的文件”空间 | | Drive 只读前置;orgSpace 按 nextToken 续页,取 spaceId/rootFolderId 后回到 Drive |
| <!-- dws-intent: drive.recent.documents -->查看最近访问/编辑文档列表 | | 1=最近编辑;默认最近访问;无主题、人物、方向或动作条件时直接使用 |
| 查看节点类型和元数据 | | 按需加 stats/publish/cover,不为普通列表强制调用 |
| 下载普通文件 | | 当前 shortcut 接受 ID;在线文档用 |
| 只要临时下载地址不落盘 | | Agent 沙箱/外部系统自行下载时用;与 |
| 上传普通文件到钉盘或知识库 | | 默认进钉盘;指定 workspace 时成为知识库/文档空间中的独立文件节点;folder 与 node、workspace 与 space-id 分别互斥 |
| 管理普通文件全局评论 | | 复用 Doc/Sheet 新评论链路;旧 |
| 创建文件夹 | | Shortcut 已提交并读回 |
| 创建普通文件的独立副本 | | 经用户授权后执行;已知是普通文件时不试 |
| 复制在线文档节点 | | 普通钉盘文件会被拒绝;Base 结构复制走 AITable |
| 移动节点 | | 破坏性变更,按 Runtime confirmation |
| 重命名节点 | | 写后检查最终名称 |
| 比较本地与钉盘文件夹 | | 只读;默认精确 MD5,不先拉取或推送 |
| 钉盘文件夹拉到本地 | | 安全默认不覆盖;先以相同参数 |
| 本地文件夹推到钉盘 | | 安全默认不覆盖;先 dry-run;不会删除远端多余文件 |
| 双向补齐文件夹 | | 先 dry-run;冲突策略必须显式保留 |
普通文件副本规则:复用已有可靠回执中的节点类型和源 ID;类型不明时先 inspect,不用失败的 copy 探测类型。下载成功后,按用户授权的目标位置新建上传;确认返回的新节点 ID 与源 ID 不同,并按任务要求核对名称、大小或内容。只给出操作说明不算已创建副本;该路径不承诺复制权限、版本历史或其他在线协作元数据。
| User Intent | Unique Recommended Entry | Key Boundaries |
|---|---|---|
| Find files globally by name or keyword | | Auto-paginate when a full search is needed; omit |
| Browse root directory or a known folder | | Auto-paginate when full browsing is needed; omit |
| Discover a DingTalk Drive org space or “My Files” space | | Drive read-only prerequisite; orgSpace paginates by nextToken; return to Drive after taking spaceId/rootFolderId |
| <!-- dws-intent: drive.recent.documents -->View recently accessed/edited document list | | 1=recently edited; default is recently accessed; use directly when there are no topic, person, direction, or action conditions |
| View node type and metadata | | Add stats/publish/cover as needed; do not force for ordinary lists |
| Download an ordinary file | | Current shortcut accepts an ID; for online documents use |
| Get only a temporary download URL without writing to disk | | Use when the Agent sandbox/external system downloads itself; mutually exclusive with disk-writing parameters such as |
| Upload an ordinary file to DingTalk Drive or knowledge base | | Defaults to DingTalk Drive; with |
| Manage global comments on ordinary files | | Reuses the new Doc/Sheet comment chain; old |
| Create a folder | | Shortcut is submitted and read back |
| Create an independent copy of an ordinary file | | Execute after user authorization; do not try |
| Copy an online document node | | Ordinary DingTalk Drive files are rejected; Base struct copy goes through AITable |
| Move a node | | Destructive change; follow Runtime confirmation |
| Rename a node | | Check the final name after writing |
| Compare local and DingTalk Drive folders | | Read-only; exact MD5 by default; no pull or push first |
| Pull a DingTalk Drive folder to local | | Safe default: no overwrite; first run |
| Push a local folder to DingTalk Drive | | Safe default: no overwrite; dry-run first; will not delete extra remote files |
| Two-way reconcile folders | | dry-run first; conflict policy must be explicitly retained |
Ordinary file copy rule: reuse the node type and source ID from a reliable existing receipt; if the type is unclear, inspect first—do not use a failed copy to probe the type. After a successful download, create a new upload at the user-authorized target location; confirm the returned new node ID differs from the source ID, and verify name, size, or content as required by the task. Merely providing operation instructions does not count as creating a copy; this path does not promise copying permissions, version history, or other online collaboration metadata.
低频入口
Low-Frequency Entry Points
- 删除已确认节点:;恢复:
dws drive +delete --node <dentryUuid>;版本:+recycle-list/+recycle-restore。+version-history/+version-get/+version-download/+version-revert - 收藏:;公开状态:
+star-*(+publish-get/+publish-unset不进入 Agent 路由);统计/封面用+publish-set;快捷方式用+inspect。+create-shortcut - 目录树只用有界 逐层遍历。
+list
兼容别名不选路:→,→,→。
+info+inspect+find-file+search+search-docsdoc +search- Delete a confirmed node: ; restore:
dws drive +delete --node <dentryUuid>; versions:+recycle-list/+recycle-restore.+version-history/+version-get/+version-download/+version-revert - Star: ; publishing state:
+star-*(+publish-get/+publish-unsetis not on the Agent route); stats/cover use+publish-set; shortcuts use+inspect.+create-shortcut - Directory trees are traversed only with bounded , level by level.
+list
Compatibility aliases do not affect routing: →, →, →.
+info+inspect+find-file+search+search-docsdoc +search当前最短路径
Current Shortest Path
- 已知 dentryUuid:直接执行 inspect/download/list/move/rename,禁止先 search;仅确认是受支持的在线文档节点后才执行 copy。
- 任务若明确要求“在新知识库用本地文件建在线文档,再移到我的文档”,不属于 Drive 根目录整理:禁止预查 ,禁止
mySpace/rootFolderId后doc +create;应由 Wiki 创建空间,Docdrive +move,再 Wiki+import --workspace <新workspaceId>。+move-to-drive --workspace <新workspaceId> - 当前命令需要定位空间且缺少目标 ID 时:先明确企业空间 或“我的文件”
orgSpace,用mySpace发现空间;dws wiki space list --type <类型> --format json在orgSpace非空时以nextToken续页,--cursor <nextToken>固定单条且不分页。按后续命令取真实 spaceId 或 rootFolderId 后立即回到 Drive;已知这些 ID 时不做空间发现。mySpace - 只有名称:→ 唯一候选的 nodeId → 目标命令;不得自动选择第一项。
+search - 只有文件夹层级:从最近的已知 folder ID 开始 ,不要从根目录无界递归。
+list - 上传普通文件:单条 ;知识库/文档空间目标显式加
+upload,不要退回 upload-info + 手写 HTTP + commit。转换为在线文档走 Doc--workspace,插入正文附件走 Doc+import。+media-insert - 导出后上传:首次就指定最终本地文件名,直接复用回执
doc +export,首次正式localPath带已获授权的drive +upload;禁止上传后再 rename。--yes - copy/move/rename/create-folder 已内置写后读取时,不再由 Agent重复执行 。
+inspect - 已知 nodeId 的重命名直接 ,不先 Catalog、Help 或 search;ALIDOC 的逻辑标题由 shortcut 内部文档读回验证。
+rename - 文件夹方向已明确时直接 ,不先 status;写操作先用完全相同参数 dry-run,再正式执行。
status/pull/push/sync - 搜索结果 后按业务动词重路由:结构复制/删除/Base 内操作走 AITable。结构复制按当前 leaf 提供源 Base ID 和真实
type=able;缺少目标 ID 时停止,不猜根 ID或发明--target-folder-id。--target-root - 只保证 dentryUuid;只有 URL 时先用
+inspect/+download/+list解析并核对dws drive info --node <URL> --format json(即 dentryUuid)。result.fileId - 返回
drive info时,将extension=dlink保存为快捷方式入口 ID,先用result.fileId读取dws doc info --node <result.fileId> --format json。内容读取、编辑、导出和类型路由改用目标linkSourceInfo;目标仍为 dlink 时逐跳解析并记录已访问 ID,解析失败、字段缺失或 ID 重复即停。用户明确移动、重命名或删除快捷方式入口本身时仍使用最初的linkSourceInfo.nodeId。result.fileId
最短路径不省略类型检查、确认、传输验证或写后校验。
- With a known dentryUuid: run inspect/download/list/move/rename directly; never search first; run copy only after confirming the node is a supported online document node.
- If the task explicitly asks to create an online document from a local file in a new knowledge base, then move it to My Documents, it is not a Drive root-directory cleanup: do not pre-query , and do not use
mySpace/rootFolderIdfollowed bydoc +create; instead, let Wiki create the space, then Docdrive +move, then Wiki+import --workspace <new workspaceId>.+move-to-drive --workspace <new workspaceId> - When the current command needs to locate a space and lacks a target ID: first determine whether it is an org space or “My Files”
orgSpace, and discover the space withmySpace; continue paginating orgSpace withdws wiki space list --type <type> --format jsonwhen--cursor <nextToken>is non-empty, while mySpace is always a single entry and not paginated. Take the real spaceId or rootFolderId for the subsequent command and immediately return to Drive; do not discover spaces when these IDs are already known.nextToken - Name only: → the unique candidate's nodeId → target command; never automatically select the first item.
+search - Folder hierarchy only: start from the nearest known folder ID; do not do unbounded recursion from the root.
+list - Upload an ordinary file: a single ; explicitly add
+uploadfor a knowledge base/document space target; do not fall back to upload-info + handwritten HTTP + commit. To convert to an online document, use Doc--workspace; to insert a body attachment, use Doc+import.+media-insert - Upload after export: specify the final local file name in the first , directly reuse the
doc +exportreceipt, and run the first formallocalPathwith the pre-authorizeddrive +upload; do not rename after upload.--yes - When copy/move/rename/create-folder already include a post-write read-back, the Agent must not run again.
+inspect - Rename a known nodeId directly with ; don't start with Catalog, Help, or search; ALIDOC logical titles are verified by the shortcut's internal document read-back.
+rename - When the folder direction is clear, go directly to ; don't run status first. For write operations, first dry-run with identical parameters, then execute formally.
status/pull/push/sync - After a search result with , reroute by business verb: struct copy/delete/Base-internal operations go to AITable. For struct copy, provide the source Base ID and the real
type=ableper the current leaf; stop if the target ID is missing; do not guess a root ID or invent--target-folder-id.--target-root - only guarantee a dentryUuid; when only a URL is available, first parse and verify
+inspect/+download/+list(i.e., dentryUuid) withresult.fileId.dws drive info --node <URL> --format json - When returns
drive info, saveextension=dlinkas the shortcut entry ID and first readresult.fileIdwithlinkSourceInfo. Content reads, edits, exports, and type routing then use the targetdws doc info --node <result.fileId> --format json; if the target is still a dlink, resolve hop by hop and record visited IDs, stopping on resolution failure, missing fields, or repeated IDs. Use the originallinkSourceInfo.nodeIdwhen the user explicitly moves, renames, or deletes the shortcut entry itself.result.fileId
The shortest path does not omit type checks, confirmation, transfer verification, or post-write validation.
关键结果语义
Key Result Semantics
- 的完整查询统一使用
+list/+search/+recent,并检查集合、完整性和截断状态;只需首批结果时可不加--page-all --max-pages <N> --max-items <N>。缺少集合不能当空结果,多候选禁止默认第一项。--page-all - 验证相对路径存在且 sizeBytes > 0;
+download检查最终 nodeId 和完整名称。普通 Drive 目标必须校验读回大小;指定+upload时必须验证 workspaceId,并兼容--workspace将完整名称拆为doc/get_document_info且不返回大小的真实契约;若返回大小仍必须与本地一致。只有源端与结果都提供可比哈希时才核对 checksum;缺失时保留现有证据,不虚构端到端校验和。name + extension - copy/move/rename/create-folder 检查 和读回;
ok/outcome不是完成。partial_success - status 检查分类集合;pull/push/sync 检查 summary 和逐项结果,failed/unknown 必须保留。
- 分页未结束时返回 continuation;目录树或大列表必须有最大深度、页数和条目数。
- 同一查询续页时,若 nextCursor 重复且没有新增节点,停止继续翻页,保留已取得结果并报告分页未完成,不将重复结果计作新增。
- 未知写入效果先 inspect/list 回读,不盲目重放写操作。
- Full queries of uniformly use
+list/+search/+recentand check collection, completeness, and truncation state; omit--page-all --max-pages <N> --max-items <N>when only the first batch is needed. A missing collection must not be treated as an empty result; multiple candidates must not default to the first item.--page-all - verifies the relative path exists and
+download;sizeBytes > 0checks the final nodeId and full name. Normal Drive targets must validate the read-back size; when+uploadis specified, verify the workspaceId and tolerate the real contract of--workspace, which splits the full name intodoc/get_document_infoand does not return size; if it does return size, it must match the local file. Only compare checksums when both the source and result provide comparable hashes; if missing, preserve existing evidence and do not fabricate end-to-end checksums.name + extension - copy/move/rename/create-folder check and read-back;
ok/outcomeis not completion.partial_success - status checks categorized result sets; pull/push/sync check the summary and per-item results; /
failedmust be preserved.unknown - Return a continuation when pagination is not finished; directory trees or large lists must have max depth, page count, and item count.
- When continuing pagination on the same query, if repeats and no new nodes are added, stop further paging, keep the acquired results, and report pagination as incomplete; do not count duplicate results as new.
nextCursor - If a write effect is unknown, read back via inspect/list first; do not blindly replay writes.
参数与安全边界
Parameters and Safety Boundaries
- 、
--node使用 dentryUuid/fileId,不使用数字型 dentryId;回收站 restore 使用 recycleItemId。--folder - 最大 50,
+list --limit最大 30;超过时分页,不以非法参数反复试错。+search --limit - 写操作只按精确 leaf Runtime 判定确认;已明确授权具体对象、动作与影响时,首次正式执行直接带 ,否则先确认。预览不带,参数变化重新确认;禁止用缺少
--yes的失败探测。--yes - 普通文件覆盖前确认真实类型和原名称;adoc/axls/able 不按普通文件覆盖。
- 单文件 Shortcut 的本地输入输出使用 cwd 相对路径且禁止 ;文件夹
..按 leaf 契约使用绝对status/pull/push/sync。--local-folder - 文件夹同步默认精确 MD5;仅在用户接受时间戳近似时用 ,且不会删除任一侧多余文件。
--quick - 参数不确定时只查一次精确 leaf Schema;禁止产品级 Schema。
- and
--nodeuse dentryUuid/fileId, not numeric dentryId; recycle bin restore uses--folder.recycleItemId - has a maximum of 50;
+list --limithas a maximum of 30. Exceed by paging, not by repeatedly trying invalid parameters.+search --limit - Write operations determine confirmation only by the exact leaf Runtime; when a specific object, action, and impact are clearly authorized, include on the first formal execution; otherwise confirm first. Do not include it for previews; reconfirm when parameters change; never use a failure caused by a missing
--yesas a probe.--yes - Before overwriting an ordinary file, confirm the real type and original name; /
adoc/axlsare not overwritten as ordinary files.able - Single-file Shortcut local input/output uses cwd-relative paths and forbids ; folder
..uses absolutestatus/pull/push/syncper the leaf contract.--local-folder - Folder sync defaults to exact MD5; use only when the user accepts timestamp approximation, and it will not delete extra files on either side.
--quick - When uncertain about parameters, check the exact leaf Schema once; product-level Schema is forbidden.
按需加载
On-Demand Loading
Golden Route 参数足够时禁止读取 reference。其余最多读取一个精确 reference:
| 触发条件 | Reference |
|---|---|
| URL、文件类型或跨产品边界 | intent-guide |
| 文件夹比较、拉取、推送或双向同步 | folder-sync |
| 低频权限、版本、回收站、公开状态 | drive reference 的对应章节 |
| 文档查询、导入和模板保形流程 | lite-recipes |
When Golden Route parameters are sufficient, reading references is forbidden. Otherwise, read at most one exact reference:
| Trigger condition | Reference |
|---|---|
| URL, file type, or cross-product boundary | intent-guide |
| Folder compare, pull, push, or two-way sync | folder-sync |
| Low-frequency permissions, versions, recycle bin, publishing state | corresponding section in drive reference |
| Document queries, import, and template-preserving workflows | lite-recipes |
错误最短路径
Error Shortest Path
- 零/多候选、类型不明或分页不完整:停止写入,返回候选或 continuation;分页读取可在有效游标和预算内继续。
- :只查一次当前 leaf Help;
unknown flag:只查一次 Drive shortcut 清单。unknown command - 普通下载遇到在线文档类型:切 ,不重复尝试 Drive download。
doc +export - 传输中断:保留本地临时状态或 checkpoint;先判断能否续传。
- 写入效果未知:按 nodeId 回读;无法证明时报告 unknown。
- 已知是普通文件且需要独立副本时,直接按 Golden Route 的 download→upload 执行,不以 失败作为前置探测。若仍收到普通文件 copy 不支持的错误,不重试或宣称已完成;确认授权与目标后按副本规则继续。AITable 结构复制缺少或无法验证目标文件夹时停止,不猜 ID 或创建测试文件夹。
+copy
- Zero/multiple candidates, unclear type, or incomplete pagination: stop writing and return candidates or continuation; paginated reads may continue within a valid cursor and budget.
- : check the current leaf Help once;
unknown flag: check the Drive shortcut list once.unknown command - An ordinary download hits an online document type: switch to ; do not retry Drive download.
doc +export - Transfer interrupted: preserve local temporary state or checkpoint; first determine whether resumption is possible.
- Unknown write effect: read back by nodeId; report if it cannot be proven.
unknown - When the node is known to be an ordinary file and an independent copy is needed, execute the Golden Route download→upload directly; do not use a failed as a prerequisite probe. If an error still says copy is unsupported for ordinary files, do not retry or claim completion; confirm authorization and target, then continue according to the copy rule. Stop AITable struct copy when the target folder is missing or cannot be verified; do not guess IDs or create test folders.
+copy
跨产品边界
Cross-Product Boundaries
- 普通文件/文件夹及在线文档节点的存储管理 → Drive;把文件作为附件放进某篇文档正文走 Doc ,其他正文/内容分别走 Doc、Sheet、AITable。
+media-insert - able 外层移动/重命名走 Drive;结构复制、Base 删除()及 Base 内操作走 AITable。
+base-delete - 明确知识库 workspace 层级 → Wiki;泛称“文档空间/我的文档”通常走 Drive,但“Wiki 库内节点移出到我的文档”固定由 Wiki 完成,Drive 不预查
+move-to-drive、不接管该移动。mySpace - 钉盘存储空间发现例外地复用 managed ;只取真实 spaceId/rootFolderId 后回到 Drive。spaceId 用于空间参数,rootFolderId 才可作为空间根目录 folder;
dws wiki space list --type orgSpace|mySpace返回 workspaceId,不能混入 Drive 参数。orgWikiSpace/myWikiSpace - Word/Markdown/Text 转在线文档用 ;Drive upload 只保留原文件。
doc +import
- Storage management of ordinary files/folders and online document nodes → Drive; putting a file as an attachment in a document body uses Doc ; other body/content paths use Doc, Sheet, and AITable respectively.
+media-insert - Outer move/rename of uses Drive; struct copy, Base deletion (
able), and Base-internal operations use AITable.+base-delete - Explicit knowledge base workspace hierarchy → Wiki; generic “Document Space/My Documents” usually goes through Drive, but “move a node out of a Wiki library to My Documents” is always completed by Wiki ; Drive does not pre-query
+move-to-driveor take over that move.mySpace - DingTalk Drive storage space discovery exceptionally reuses managed ; take the real spaceId/rootFolderId and return to Drive. spaceId is used as the space parameter; only rootFolderId can be used as the space root folder.
dws wiki space list --type orgSpace|mySpacereturn workspaceId and must not be mixed into Drive parameters.orgWikiSpace/myWikiSpace - Convert Word/Markdown/Text to online documents with ; Drive upload keeps only the original file.
doc +import