weaver-work-cli 0.1.8 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +25 -17
  2. package/dist/cmd/action.js +76 -0
  3. package/dist/cmd/index.js +2 -0
  4. package/dist/cmd/refs/index.js +103 -0
  5. package/dist/cmd/register.js +31 -0
  6. package/dist/cmd/root.js +1 -0
  7. package/dist/cmd/setup/index.js +25 -5
  8. package/dist/cmd/skills/index.js +37 -5
  9. package/dist/core/connector.js +54 -0
  10. package/dist/core/context.js +2 -1
  11. package/dist/core/input.js +48 -0
  12. package/dist/core/output.js +298 -3
  13. package/dist/core/refs.js +435 -0
  14. package/dist/core/state.js +26 -0
  15. package/dist/internal/e10/auth/commands.js +34 -19
  16. package/dist/internal/e10/auth/session.js +74 -2
  17. package/dist/internal/e10/auth/xiaoe.js +359 -94
  18. package/dist/internal/e10/context.js +18 -6
  19. package/dist/internal/e10/request-runtime.js +8 -1
  20. package/dist/internal/skills/install.js +148 -28
  21. package/dist/internal/skills/reader.js +12 -9
  22. package/dist/shortcuts/blog/continuation.js +74 -0
  23. package/dist/shortcuts/blog/errors.js +60 -0
  24. package/dist/shortcuts/blog/host.js +175 -0
  25. package/dist/shortcuts/blog/index.js +324 -0
  26. package/dist/shortcuts/blog/manifest.js +415 -0
  27. package/dist/shortcuts/blog/operations/comment.js +125 -0
  28. package/dist/shortcuts/blog/operations/comments.js +31 -0
  29. package/dist/shortcuts/blog/operations/edit.js +131 -0
  30. package/dist/shortcuts/blog/operations/export.js +46 -0
  31. package/dist/shortcuts/blog/operations/like.js +80 -0
  32. package/dist/shortcuts/blog/operations/publish.js +157 -0
  33. package/dist/shortcuts/blog/operations/query-user.js +58 -0
  34. package/dist/shortcuts/blog/operations/query.js +96 -0
  35. package/dist/shortcuts/blog/operations/registry.js +54 -0
  36. package/dist/shortcuts/blog/operations/remind.js +176 -0
  37. package/dist/shortcuts/blog/operations/shared.js +330 -0
  38. package/dist/shortcuts/blog/operations/types.js +16 -0
  39. package/dist/shortcuts/blog/operations.js +9 -0
  40. package/dist/shortcuts/caizhilian/continuation.js +70 -0
  41. package/dist/shortcuts/caizhilian/errors.js +53 -0
  42. package/dist/shortcuts/caizhilian/host.js +190 -0
  43. package/dist/shortcuts/caizhilian/index.js +186 -0
  44. package/dist/shortcuts/caizhilian/manifest.js +42 -0
  45. package/dist/shortcuts/caizhilian/operations/api.js +801 -0
  46. package/dist/shortcuts/caizhilian/operations/confirm.js +75 -0
  47. package/dist/shortcuts/caizhilian/operations/files.js +306 -0
  48. package/dist/shortcuts/caizhilian/operations/form.js +170 -0
  49. package/dist/shortcuts/caizhilian/operations/handlers/collab.js +611 -0
  50. package/dist/shortcuts/caizhilian/operations/handlers/document.js +890 -0
  51. package/dist/shortcuts/caizhilian/operations/handlers/file-collection.js +1227 -0
  52. package/dist/shortcuts/caizhilian/operations/handlers/file-upload.js +192 -0
  53. package/dist/shortcuts/caizhilian/operations/handlers/fileops.js +570 -0
  54. package/dist/shortcuts/caizhilian/operations/handlers/folder.js +1024 -0
  55. package/dist/shortcuts/caizhilian/operations/handlers/search.js +318 -0
  56. package/dist/shortcuts/caizhilian/operations/handlers/setting-attach.js +294 -0
  57. package/dist/shortcuts/caizhilian/operations/handlers/setting-backup.js +423 -0
  58. package/dist/shortcuts/caizhilian/operations/handlers/setting-encrypt.js +238 -0
  59. package/dist/shortcuts/caizhilian/operations/handlers/setting-storage.js +364 -0
  60. package/dist/shortcuts/caizhilian/operations/handlers/system.js +106 -0
  61. package/dist/shortcuts/caizhilian/operations/registry.js +151 -0
  62. package/dist/shortcuts/caizhilian/operations/shared.js +408 -0
  63. package/dist/shortcuts/caizhilian/operations/specs.js +698 -0
  64. package/dist/shortcuts/caizhilian/operations/types.js +57 -0
  65. package/dist/shortcuts/caizhilian/operations.js +21 -0
  66. package/dist/shortcuts/contract/continuation.js +70 -0
  67. package/dist/shortcuts/contract/errors.js +62 -0
  68. package/dist/shortcuts/contract/host.js +205 -0
  69. package/dist/shortcuts/contract/index.js +318 -0
  70. package/dist/shortcuts/contract/manifest.js +596 -0
  71. package/dist/shortcuts/contract/operations/clause-reference.js +78 -0
  72. package/dist/shortcuts/contract/operations/form-info.js +371 -0
  73. package/dist/shortcuts/contract/operations/read.js +118 -0
  74. package/dist/shortcuts/contract/operations/registry.js +43 -0
  75. package/dist/shortcuts/contract/operations/request.js +300 -0
  76. package/dist/shortcuts/contract/operations/shared.js +133 -0
  77. package/dist/shortcuts/contract/operations/subject.js +157 -0
  78. package/dist/shortcuts/contract/operations/template.js +81 -0
  79. package/dist/shortcuts/contract/operations/types.js +7 -0
  80. package/dist/shortcuts/contract/operations/workflow.js +52 -0
  81. package/dist/shortcuts/contract/operations/write.js +131 -0
  82. package/dist/shortcuts/contract/operations.js +8 -0
  83. package/dist/shortcuts/hrm/index.js +83 -2
  84. package/dist/shortcuts/hrm/manifest.js +16 -9
  85. package/dist/shortcuts/hrm/operations/employee.js +160 -30
  86. package/dist/shortcuts/hrm/operations/org.js +17 -3
  87. package/dist/shortcuts/hrm/operations/position.js +18 -2
  88. package/dist/shortcuts/hrm/operations/registry.js +2 -0
  89. package/dist/shortcuts/hrm/operations/resolve.js +449 -0
  90. package/dist/shortcuts/index.js +5 -1
  91. package/dist/shortcuts/invoice/index.js +74 -36
  92. package/dist/shortcuts/invoice/manifest.js +674 -4
  93. package/dist/shortcuts/invoice/markdown.js +172 -0
  94. package/dist/shortcuts/invoice/operations/add.js +3 -3
  95. package/dist/shortcuts/invoice/operations/delete.js +2 -2
  96. package/dist/shortcuts/invoice/operations/get.js +10 -2
  97. package/dist/shortcuts/invoice/operations/import.js +2 -2
  98. package/dist/shortcuts/invoice/operations/registry.js +8 -1
  99. package/dist/shortcuts/invoice/operations/reim-auto.js +719 -0
  100. package/dist/shortcuts/invoice/operations/reim.js +85 -2
  101. package/dist/shortcuts/invoice/operations/shared.js +75 -8
  102. package/dist/shortcuts/invoice/operations/update.js +2 -2
  103. package/dist/shortcuts/invoice/operations/upload-and-validate.js +93 -0
  104. package/dist/shortcuts/invoice/operations/validate-preview.js +2 -1
  105. package/dist/shortcuts/invoice/projection.js +328 -0
  106. package/dist/shortcuts/meeting/host.js +18 -1
  107. package/dist/shortcuts/meeting/manifest.js +30 -18
  108. package/dist/shortcuts/meeting/operations/eb/catalog.js +390 -0
  109. package/dist/shortcuts/meeting/operations/eb/conflict.js +389 -0
  110. package/dist/shortcuts/meeting/operations/eb/factory.js +389 -0
  111. package/dist/shortcuts/meeting/operations/eb/index.js +22 -0
  112. package/dist/shortcuts/meeting/operations/env.js +8 -1
  113. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  114. package/dist/shortcuts/meeting/operations/signs.js +216 -2
  115. package/dist/shortcuts/workflow/endpoints.js +2 -1
  116. package/dist/shortcuts/workflow/errors.js +8 -2
  117. package/dist/shortcuts/workflow/host.js +11 -4
  118. package/dist/shortcuts/workflow/operations/form.js +1016 -590
  119. package/dist/shortcuts/workflow/operations/read.js +913 -231
  120. package/dist/shortcuts/workflow/operations/shared.js +21 -0
  121. package/dist/shortcuts/workflow/operations/write.js +750 -52
  122. package/dist/shortcuts/workflow/operations.js +36 -10
  123. package/docs/_catalog.md +6 -0
  124. package/docs/agent-invoice.md +5 -1
  125. package/docs/agent-io-channel-design.md +468 -0
  126. package/docs/agent-skill-install.md +9 -4
  127. package/docs/blog.md +123 -0
  128. package/docs/caizhilian.md +304 -0
  129. package/docs/contract.md +91 -0
  130. package/docs/e10-auth.md +4 -2
  131. package/docs/hrm.md +53 -11
  132. package/docs/invoice.md +5 -1
  133. package/docs/meeting.md +1 -1
  134. package/docs/operation-manual.md +15 -3
  135. package/docs/skill-review-2026-09-19.md +2 -2
  136. package/package.json +1 -1
  137. package/scripts/package-skill.mjs +32 -20
  138. package/scripts/xiaoe_env.py +118 -0
  139. package/skill-template/business-info.json +113 -14
  140. package/skill-template/domains/blog.md +24 -0
  141. package/skill-template/domains/caizhilian.md +22 -0
  142. package/skill-template/domains/hrm.md +2 -1
  143. package/skill-template/domains/jinchengda.md +23 -0
  144. package/skill-template/domains/meeting.md +1 -1
  145. package/skill-template/domains/workflow.md +1 -1
  146. package/skill-template/skill-template.md +1 -1
  147. package/skills/weaver-e10-blog/SKILL.md +111 -0
  148. package/skills/weaver-e10-blog/references/blog-comment.md +51 -0
  149. package/skills/weaver-e10-blog/references/blog-comments.md +39 -0
  150. package/skills/weaver-e10-blog/references/blog-default-permission.md +38 -0
  151. package/skills/weaver-e10-blog/references/blog-disabled-capabilities.md +11 -0
  152. package/skills/weaver-e10-blog/references/blog-edit.md +51 -0
  153. package/skills/weaver-e10-blog/references/blog-export.md +42 -0
  154. package/skills/weaver-e10-blog/references/blog-like.md +50 -0
  155. package/skills/weaver-e10-blog/references/blog-publish.md +52 -0
  156. package/skills/weaver-e10-blog/references/blog-query-user.md +45 -0
  157. package/skills/weaver-e10-blog/references/blog-query.md +49 -0
  158. package/skills/weaver-e10-blog/references/blog-remind.md +51 -0
  159. package/skills/weaver-e10-blog/references/blog-resolve-users.md +38 -0
  160. package/skills/weaver-e10-blog/references/source-manifest.json +1540 -0
  161. package/skills/weaver-e10-caizhilian/SKILL.md +217 -0
  162. package/skills/weaver-e10-caizhilian/references/agent-entry.md +106 -0
  163. package/skills/weaver-e10-caizhilian/references/collaboration.md +112 -0
  164. package/skills/weaver-e10-caizhilian/references/document.md +111 -0
  165. package/skills/weaver-e10-caizhilian/references/file-collection.md +173 -0
  166. package/skills/weaver-e10-caizhilian/references/file-upload.md +309 -0
  167. package/skills/weaver-e10-caizhilian/references/files.md +120 -0
  168. package/skills/weaver-e10-caizhilian/references/folder.md +122 -0
  169. package/skills/weaver-e10-caizhilian/references/org-browser.md +104 -0
  170. package/skills/weaver-e10-caizhilian/references/setting-attach.md +440 -0
  171. package/skills/weaver-e10-caizhilian/references/setting-backup.md +372 -0
  172. package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +399 -0
  173. package/skills/weaver-e10-caizhilian/references/setting-storage.md +603 -0
  174. package/skills/weaver-e10-caizhilian/references/source-manifest.json +5694 -0
  175. package/skills/weaver-e10-caizhilian/references/withheld.md +93 -0
  176. package/skills/weaver-e10-caizhilian/references/write-protocol.md +120 -0
  177. package/skills/weaver-e10-calendar/SKILL.md +4 -3
  178. package/skills/weaver-e10-ebuilder-form/SKILL.md +4 -9
  179. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +0 -9
  180. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -5
  181. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +1 -5
  182. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +1 -5
  183. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +1 -5
  184. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -5
  185. package/skills/weaver-e10-esb/SKILL.md +2 -2
  186. package/skills/weaver-e10-esb/references/source-manifest.json +9 -9
  187. package/skills/weaver-e10-hrm/SKILL.md +104 -9
  188. package/skills/weaver-e10-hrm/references/employee.md +89 -15
  189. package/skills/weaver-e10-hrm/references/org.md +114 -5
  190. package/skills/weaver-e10-hrm/references/position.md +14 -7
  191. package/skills/weaver-e10-hrm/references/source-manifest.json +1 -1
  192. package/skills/weaver-e10-jinchengda/SKILL.md +167 -0
  193. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +82 -0
  194. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +69 -0
  195. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +78 -0
  196. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +27 -0
  197. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +71 -0
  198. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +94 -0
  199. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +89 -0
  200. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +77 -0
  201. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +66 -0
  202. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +94 -0
  203. package/skills/weaver-e10-jinchengda/references/source-manifest.json +259 -0
  204. package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -11
  205. package/skills/weaver-e10-jucailin/SKILL.md +4 -3
  206. package/skills/weaver-e10-mail/SKILL.md +4 -11
  207. package/skills/weaver-e10-meeting/SKILL.md +66 -32
  208. package/skills/weaver-e10-meeting/references/meeting-change.md +5 -2
  209. package/skills/weaver-e10-meeting/references/meeting-create.md +2 -1
  210. package/skills/weaver-e10-meeting/references/meeting-eb.md +114 -0
  211. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +9 -8
  212. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +35 -7
  213. package/skills/weaver-e10-meeting/references/meeting-update.md +1 -1
  214. package/skills/weaver-e10-okr/SKILL.md +6 -11
  215. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  216. package/skills/weaver-e10-plan/SKILL.md +3 -3
  217. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +1 -1
  218. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +1 -1
  219. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  220. package/skills/weaver-e10-qiyecheng/SKILL.md +4 -10
  221. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  222. package/skills/weaver-e10-shared/SKILL.md +42 -34
  223. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +16 -43
  224. package/skills/weaver-e10-shared/references/json-output-contract.md +20 -11
  225. package/skills/weaver-e10-shared/references/non-interactive-environment.md +21 -14
  226. package/skills/weaver-e10-shijingran/SKILL.md +2 -1
  227. package/skills/weaver-e10-shijingran/references/source-manifest.json +9 -9
  228. package/skills/weaver-e10-skill-maker/SKILL.md +4 -10
  229. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +5 -3
  230. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +12 -27
  231. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +17 -5
  232. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +4 -27
  233. package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +1 -1
  234. package/skills/weaver-e10-wenshuding/SKILL.md +5 -16
  235. package/skills/weaver-e10-wenshuding/references/source-manifest.json +7 -7
  236. package/skills/weaver-e10-workflow/SKILL.md +41 -46
  237. package/skills/weaver-e10-workflow/references/source-manifest.json +39 -75
  238. package/skills/weaver-e10-workflow/references/workflow-batch.md +90 -29
  239. package/skills/weaver-e10-workflow/references/workflow-create.md +83 -109
  240. package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -9
  241. package/skills/weaver-e10-workflow/references/workflow-operate.md +2 -2
  242. package/skills/weaver-e10-workflow/references/workflow-query.md +40 -27
  243. package/skills/weaver-e10-workflow/references/workflow-share.md +18 -2
  244. package/skills/weaver-e10-workflow/references/workflow-view.md +3 -4
  245. package/skills/weaver-e10-yepiaotong/SKILL.md +74 -39
  246. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +22 -1
  247. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +3 -1
  248. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +135 -0
  249. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +15 -3
  250. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  251. package/skills/weaver-e10-yepiaotong/references/invoice-summarize.py +217 -0
  252. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +88 -0
  253. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +7 -2
  254. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +89 -9
  255. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -0
  256. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +70 -49
  257. package/skills/weaver-e10-yepiaotong/references/reim-fast-path.md +119 -0
  258. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +55 -36
  259. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +4 -0
  260. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +149 -0
  261. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +125 -5
  262. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +430 -63
  263. package/skills/weaver-e10-yimiaoban/SKILL.md +4 -12
  264. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
  265. package/skills/weaver-e10-ziguanjia/SKILL.md +2 -1
  266. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +3 -3
  267. package/tools/weaver-skill-detector-1.0.13/SKILL.md +9 -9
  268. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +3 -3
  269. package/tools/weaver-skill-detector-1.0.13/scripts/__pycache__/validate_skill.cpython-313.pyc +0 -0
  270. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +98 -91
  271. package/scripts/sync-connector-skills.mjs +0 -172
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: weaver-file-collection
3
+ description: "泛微E10采知连文件服务 FTP/SFTP 文件采集技能。用于选择仅采集文件或采集到档案、按需选择全宗、查询或创建 FTP/SFTP 资源、检索并校验已有动作流、动态新建动作流、创建或维护采集任务,以及校验、扫描、运行和查看文件级结果。"
4
+ license: Proprietary
5
+ compatibility: 泛微E10采知连配套使用,内部可自由使用与修改,禁止对外分发
6
+ metadata:
7
+ maintainer: unknown
8
+ type: capability
9
+ version: 1.0.0
10
+ updated: 2026-08-19
11
+ tags: [文件采集, FTP, SFTP, 动作流, 采集任务, 全宗, 档案]
12
+ ---
13
+
14
+ # 文件采集 FTP/SFTP
15
+
16
+ 本 Skill 通过 `scripts/collection_cli_tool.py` 管理文件采集生命周期。正式 API 请求、动作流设计物化和任务 Payload 均由脚本生成,不手写正式结构。
17
+
18
+ ## 前置依赖
19
+
20
+ ### 认证前置(必须)
21
+
22
+ 本模块通过 CLI 托管的认证获取凭证(base_url + Cookie + eteamsid + User-Agent),凭证契约见共享规则 [`../../weaver-e10-shared/SKILL.md`](../../weaver-e10-shared/SKILL.md),不依赖手动配置文件,Agent 不得自己读取或输出凭证。
23
+
24
+ **使用前必须确保**:
25
+ 1. CLI 已安装:`weaver-work-cli --version` 能正常输出版本号
26
+ 2. 已完成登录:`weaver-work-cli auth status` 显示已登录
27
+
28
+ **首次登录**:
29
+ ```text
30
+ # OAuth2.0 浏览器授权(推荐)
31
+ weaver-work-cli auth login
32
+
33
+ # 或手动写入 ETEAMSID(从浏览器 DevTools 复制)
34
+ weaver-work-cli auth set --eteamsid "PCACCOUNT_xxx"
35
+ ```
36
+
37
+ **凭证过期处理**:操作返回认证错误时,提示用户通过 `weaver-work-cli auth login` 或 `weaver-work-cli auth set` 重新登录。
38
+
39
+ ## First Move
40
+
41
+ 1. 读取 `rule-index.md`。
42
+ 2. 确认 CLI 已完成登录(`weaver-work-cli auth status` 显示已登录)。
43
+ 3. 任务分支和阶段门禁读取 `task-workflow.md`。
44
+ 4. 动作流检索、检测与动态创建读取 `action-flow.md`。
45
+ 5. 只有用户选择采集到档案时,才读取 `fonds-selection.md`。
46
+ 6. 宿主执行还必须读取 `host-executor-prompt.md` 和 `host-platform-integration.md`。
47
+
48
+ ## Hard Rules
49
+
50
+ - 认证凭证统一由 CLI 托管(`weaver-work-cli auth ...`);不得写死域名或输出 Cookie。
51
+ - `init-session` 后先执行 `choose-file-only` 或 `choose-archive`。仅归档分支查询和确认全宗;仅文件分支不得要求或写入 `fondsId`。
52
+ - 新建任务前选择已有或新建 FTP/SFTP 资源,再选择已有或新建动作流。
53
+ - 新建任务时先确定是否维持原目录结构;该值必须原样传给动作流 inspect/create 和 `save-task`。维持模式使用动态 `folderId` 动作流,非维持模式使用固定目录动作流,二者不得混用。
54
+ - `search-action-flows` 的候选仅用于展示。用户确认 ID 后必须执行 `inspect-action-flow`,回读应用、活动版本和设计并通过兼容性检测,才能生成关联凭据。
55
+ - `create-action-flow` 使用 `file_collection_action_flow_design.v1` 动态创建;禁止上传、迁入或依赖固定动作流包。
56
+ - 标准 `create-action-flow` 由 CLI 生成仅文件/归档两种完整草稿;普通执行不得让 Agent 手写触发字段或设计文件,`--design-file` 仅用于明确的高级定制。
57
+ - 标准 `create-ftp-resource` 在未传 `systemPk` 时自动生成连接器元数据并创建 FTP 连接器;不得通过失败重试发现确定性参数。
58
+ - 初始化后的命令携带同一 `chatId`;阶段会原子保存,重复初始化恢复进度,只有显式 `--restart` 才重新开始。
59
+ - `save-task` 和 `update-task-workflow` 只接受 `inspect-action-flow` 或 `create-action-flow` 生成的 `file_collection_workflow_selection.v1` 文件。归档凭据还必须绑定归档兼容检测,并携带已确认全宗。
60
+ - 默认任务名按 UTC+8 生成 `文件采集(yyyyMMdd HHmmss)`。
61
+ - `scan` 默认增量;只有用户明确要求全量时使用 `--full-coll`。
62
+ - `run` 只证明启动。只有 `file_collection_result.v1` 为 `collection_succeeded`、`file_collection_ok=true` 且失败数为 0,才能报告采集成功。
63
+ - 用户可见输出不展示长 ID、完整 Cookie、明文 FTP 密码或大段请求体。
64
+
65
+ ## Workflow
66
+
67
+ 1. 确认 CLI 已完成登录(`weaver-work-cli auth status`),然后执行 init-session --chat-id <chatId>。
68
+ 2. 执行 `choose-file-only --phase collection_target_selection`;或执行 `choose-archive`,再调用全宗工具、`normalize-fonds` 和 `confirm-fonds`。
69
+ 3. 执行 `choose-new-task` 或 `choose-existing-task`。已有任务的全宗更新仅适用于归档分支。
70
+ 4. 新建任务时执行 `choose-existing-resource` 或 `create-new-resource`;标准新建直接调用 `create-ftp-resource`,缺少 `systemPk` 时 CLI 内部创建连接器并返回 `taskSourceId`。
71
+ 5. 确定 `retainDirStruct=0|1`;执行 `choose-existing-workflow` 后 `search-action-flows`、用户确认、`inspect-action-flow --retain-dir-struct <0|1>`;或执行 `create-new-workflow` 后直接调用标准 `create-action-flow --retain-dir-struct <0|1> [--archive]`。
72
+ 6. 用相同目录选项和关联凭据执行 `save-task --retain-dir-struct <0|1> --source-id ... --workflow-selection-file ...`;归档分支额外传全宗确认文件。
73
+ 7. 依次执行 `check-storage`、`scan --wait`、`run`;需要等待文件级结果时使用 `run --wait` 或 `run-progress`。
74
+
75
+ ## References
76
+
77
+ | Need | Read |
78
+ | --- | --- |
79
+ | 规则与 owner | `rule-index.md` |
80
+ | 认证 | `auth-and-session.md` |
81
+ | 主流程 | `task-workflow.md` |
82
+ | 动作流合同 | `action-flow.md` |
83
+ | 可选全宗 | `fonds-selection.md` |
84
+ | API 路由 | `api_docs.md` |
85
+ | API 端点 | `api-endpoints.md` |
86
+ | Payload | `api-payloads.md` |
87
+ | 宿主提示词 | `host-executor-prompt.md` |
88
+ | 宿主集成 | `host-platform-integration.md` |
89
+
90
+ # API Endpoints
91
+
92
+ ## Connector And Resource
93
+
94
+ | Operation | Method | Path |
95
+ | --- | --- | --- |
96
+ | Save connector | POST | `/api/bs/esb/setting/systemPool/save` |
97
+ | Query connectors | GET | `/api/bs/esb/setting/connector/getConnectorListPage` |
98
+ | Query resources | GET | `/api/bs/esb/setting/resource/getResourceListPage` |
99
+ | Save FTP/SFTP resource | POST | `/api/bs/esb/setting/resource/ftp/save` |
100
+
101
+ The selected resource `id` becomes `taskSourceId`.
102
+
103
+ ## Action Flow
104
+
105
+ | Operation | Method | Path |
106
+ | --- | --- | --- |
107
+ | Search applications | POST | `/api/bs/esb/setting/application/getApplicationListPage` |
108
+ | Read application | GET | `/api/bs/esb/setting/application/getAppById/{appId}` |
109
+ | Read versions | GET | `/api/bs/esb/setting/application/version/versionList/{appId}` |
110
+ | Read design | GET | `/api/bs/esb/setting/flow/design/getDesignBySceneId/{sceneId}` |
111
+ | Create application | POST | `/api/bs/esb/setting/application/save` |
112
+ | Register optional variable | POST | `/api/bs/esb/setting/application/variable/addVariable` |
113
+ | Check design | POST | `/api/bs/esb/setting/flow/design/check` |
114
+ | Save design | POST | `/api/bs/esb/setting/flow/design/saveDesign` |
115
+ | Enable application | GET | `/api/bs/esb/setting/application/startUseApp/{appId}` |
116
+
117
+ Search results are not association credentials. Inspect or create must complete full read-back validation.
118
+
119
+ ## File Collection Task
120
+
121
+ | Operation | Method | Path | Result |
122
+ | --- | --- | --- | --- |
123
+ | List tasks | GET | `/api/file/coll/taskTable` | candidates |
124
+ | Read form | GET | `/api/file/coll/taskForm` | task form |
125
+ | Save task | POST | `/api/file/coll/save` | task ID |
126
+ | Save as | POST | `/api/file/coll/saveAs` | copied task |
127
+ | Check storage | GET | `/api/file/coll/checkStorageConnect` | connection result |
128
+ | Scan | POST | `/api/file/coll/scan` | runtime ID |
129
+ | Scan progress | GET | `/api/file/coll/scan/progress` | scan state |
130
+ | Run or pause | POST | `/api/file/coll/run` | accepted state |
131
+ | Run progress | GET | `/api/file/coll/run/progress` | execution state |
132
+ | Detail | GET | `/api/file/coll/detailTable` | successful or failed rows |
133
+ | Cancel | POST | `/api/file/coll/cancel` | cancelled task |
134
+ | Delete | POST | `/api/file/coll/delete` | boolean result |
135
+
136
+ `scan` is 默认增量 and sends `fullColl=false`; `--full-coll` is explicit. `finish=true` is not file success. Read `detailType=true` and `detailType=false`, then normalize `file_collection_result.v1`.
137
+
138
+ ## CLI 操作
139
+
140
+ ### 新建采集任务
141
+
142
+ 使用 `caizhilian.file-collection.task.save.prepare/apply` 创建新的采集任务:
143
+
144
+ **参数**:
145
+ - `source_id`(必填):FTP/SFTP 资源 ID
146
+ - `workflow_id`(必填):动作流 ID
147
+ - `task_name`(可选):任务名称,不传时自动生成
148
+ - `retain_dir_struct`(可选):是否维持原目录结构,默认 true
149
+ - `task_file_path`(可选):采集路径,默认 /
150
+
151
+ **示例**:
152
+
153
+ Windows PowerShell:
154
+ ```powershell
155
+ weaver-work-cli --json caizhilian run caizhilian.file-collection.task.save.prepare --input-json '{"source_id":"123","workflow_id":"456","task_name":"测试采集任务"}'
156
+ ```
157
+
158
+ macOS/Linux(bash/zsh):
159
+ ```bash
160
+ weaver-work-cli --json caizhilian run caizhilian.file-collection.task.save.prepare --input-json '{"source_id":"123","workflow_id":"456","task_name":"测试采集任务"}'
161
+ ```
162
+
163
+ ### 其他操作
164
+
165
+ | 操作 | CLI 命令 |
166
+ | --- | --- |
167
+ | 列出任务 | `caizhilian.file-collection.task.list` |
168
+ | 查看任务详情 | `caizhilian.file-collection.task.form` |
169
+ | 检查存储连接 | `caizhilian.file-collection.storage.check` |
170
+ | 扫描任务 | `caizhilian.file-collection.scan.prepare/apply` |
171
+ | 运行任务 | `caizhilian.file-collection.run.prepare/apply` |
172
+ | 取消任务 | `caizhilian.file-collection.cancel.prepare/apply` |
173
+ | 删除任务 | `caizhilian.file-collection.delete.prepare/apply` |
@@ -0,0 +1,309 @@
1
+ ---
2
+ name: weaver-file-upload
3
+ description: >-
4
+ Upload local files to the Weaver E10/eTeams file service with a bundled
5
+ single-file Node CLI through the recorded preUploadCheck and module/upload
6
+ protocol. Supports server-side second-hit, common streaming upload, chunked
7
+ upload, terminal fileId validation, safe metadata, and session-isolated
8
+ receipts. Use for Weaver file upload, attachment pre-upload, large-file
9
+ chunk upload, second upload, or when another workflow needs a verified
10
+ Weaver fileId from an absolute local path. Login is an explicit provider or
11
+ standalone-browser choice with no automatic fallback.
12
+ ---
13
+
14
+ # Weaver File Upload
15
+
16
+ This Skill owns one transaction: turn one absolute local file path into one
17
+ business-verified Weaver `fileId`. Binding that file to a form, document,
18
+ message, or other business object belongs to the caller.
19
+
20
+ The delivery includes `dist/weaver-file-upload.js`, a single Node.js bundle
21
+ containing the upload owner, large-integer JSON handling, WebSocket transport,
22
+ and standalone Chrome/CDP login. It requires Node.js 18.20.0 or newer, does not
23
+ run npm install, and does not download a platform executable on first use.
24
+
25
+ ## Runtime Routing
26
+
27
+ - In a Harness with native Weaver session injection, execute the bundle through
28
+ the host Skill runner and select `weaver-e10-login`. Do not start standalone
29
+ browser login or read `.env.local` in that mode.
30
+ - Otherwise execute the bundle directly and pass `--login-mode
31
+ weaver-e10-login|standalone` to `login` and `upload`.
32
+ - Provider mode calls only the public `e10-login whoami` contract. Standalone
33
+ mode owns its browser, validator, session, and cleanup. Failure never switches
34
+ to the other identity source.
35
+
36
+ ## First Move
37
+
38
+ Resolve `SKILL_ROOT` from this file and request the complete machine contract:
39
+
40
+ ```text
41
+ node "$SKILL_ROOT/dist/weaver-file-upload.js" contract \
42
+ --chat-id '<chatId>'
43
+ ```
44
+
45
+ Use `agent_callable_interface_contract.v1`; do not guess flags or learn them
46
+ through repeated help calls. All flags follow the command. Before requesting
47
+ missing upload inputs, show the contract's complete required, conditionally
48
+ required, and optional lists with their purposes. Reuse an existing host
49
+ attachment path instead of asking for it again.
50
+
51
+ ## Workflow
52
+
53
+ ```text
54
+ contract
55
+ -> prepare absolute file + context
56
+ -> explicit provider | standalone login
57
+ -> current-user upload authorization
58
+ -> preUploadCheck
59
+ -> second | common | chunk
60
+ -> terminal non-empty fileId
61
+ -> secret-free 0600 receipt
62
+ ```
63
+
64
+ Standalone login without a saved domain returns `status=requires_input`,
65
+ `channel=agent_conversation`, and `resumeArgument=--base-url`. Ask for the
66
+ non-secret OA/E10 root address in the current conversation, then resume:
67
+
68
+ ```text
69
+ node "$SKILL_ROOT/dist/weaver-file-upload.js" login \
70
+ --chat-id '<chatId>' --login-mode standalone \
71
+ --base-url 'https://<runtime-host>'
72
+ ```
73
+
74
+ Provider validation:
75
+
76
+ ```text
77
+ node "$SKILL_ROOT/dist/weaver-file-upload.js" login \
78
+ --chat-id '<chatId>' --login-mode weaver-e10-login
79
+ ```
80
+
81
+ ## Hard Rules
82
+
83
+ - `--file` and `--context-file` are absolute paths. `--chat-id` isolates
84
+ receipts under `runs/<chatId>/`, or the resolved private state root.
85
+ - `--module` is mandatory and comes from real caller business context. Never
86
+ guess `workflow`, `document`, or another module.
87
+ - `upload` requires `--user-confirmed` from the current user request. The CLI
88
+ rejects a missing confirmation before file, authentication, or network work.
89
+ - Context cannot override protocol-owned fields. File and chunk bodies remain
90
+ streaming; the complete large file is never buffered in memory.
91
+ - Never print or persist Cookie, ETEAMSID, token, Authorization, ticket,
92
+ password, signed URL, multipart body, or raw server response.
93
+ - HTTP 200 and `endChunk=true` are insufficient. Success requires a non-empty
94
+ terminal `fileId`; any nonzero server size must match the local file.
95
+ - A transport failure after an upload POST is
96
+ `execution_state=unknown`, is not retry-safe, and is never replayed
97
+ automatically.
98
+ - Use `receipt_ref` and `receipt_sha256` as terminal evidence.
99
+
100
+ ## Resources
101
+
102
+ | Need | Read |
103
+ | --- | --- |
104
+ | Protocol, strategy, results, recovery | `references/file-upload-operation-contract.md` |
105
+ | Required and optional parameters | `references/file-upload-input-parameters.md` |
106
+ | Machine invocation contract | `references/file-upload-cli-contract.json` |
107
+ | Rule ownership | `references/file-upload-rule-index.md` |
108
+ | Host executor behavior | `references/file-upload-host-executor-prompt.md` |
109
+ | Host integration | `references/file-upload-host-platform-integration.md` |
110
+ | Source, tests, and packaging | `references/file-upload-maintenance.md` |
111
+
112
+ <!-- weaver-domain-login:v1 -->
113
+ ## 域名与登录方式
114
+
115
+ - **不得写死域名**;构建和打包时不保存业务域名。
116
+ - 运行时必须由用户显式选择方式 1(`weaver-e10-login`)或方式 2(本
117
+ Skill 独立浏览器登录);不得因认证失败自动切换。
118
+ - 方式 1 只调用 Provider 的公开 `whoami`,缺失或未登录时停止,不回退。
119
+ - 方式 2 首次缺少域名时由 Agent 在当前对话中询问,再以 `--base-url`
120
+ 恢复;CLI 不读取 stdin,也不打开交互终端。
121
+ - 方式 2 的核心流程可独立安装和运行,不依赖任何其他 Skill;Provider
122
+ 不打入 bundle。
123
+ <!-- /weaver-domain-login:v1 -->
124
+
125
+ <!-- weaver-browser-login-capture:v1 -->
126
+ ## 登录与会话
127
+
128
+ - 方式 2 使用本 Skill 的专用 Chrome + CDP,只打开运行时根地址;用户自然
129
+ 完成密码、验证码、SSO 或 MFA。
130
+ - Cookie 候选必须通过真实、无副作用的业务接口
131
+ `POST /api/baseserver/layout/teamsCheck` 和非空
132
+ `currentUser.employeeId` 校验。
133
+ - 会话只原子写入权限为 `0600` 的 `.env.local`;不得输出 Cookie、session id、token、ticket 或密码。
134
+ - 页面 target 失效时重新选择 page target。所有退出路径先调用
135
+ `Browser.close`,再按本次 owned Profile/PID 定向清理,不关闭用户浏览器。
136
+ - 合同位于 `references/file-upload-browser-login-contract.json`。
137
+ <!-- /weaver-browser-login-capture:v1 -->
138
+ # Weaver File Upload Operation Contract
139
+
140
+ ## Scope
141
+
142
+ The public product is one verified Weaver file-service object. Business-specific
143
+ attachment ordering, form binding, editor nodes, messages, and document changes
144
+ remain downstream operations.
145
+
146
+ ```text
147
+ local regular file
148
+ -> POST /api/file/preUploadCheck?sf_request_type=ajax
149
+ -> uploadType=second | common | chunk
150
+ -> optional POST /api/file/module/upload?sf_request_type=ajax
151
+ -> terminal non-empty fileid/fileId
152
+ ```
153
+
154
+ ## Public Actions
155
+
156
+ | Action | Side effect | Login | Success evidence |
157
+ | --- | --- | --- | --- |
158
+ | `contract` | private local contract artifact | no | `agent_callable_interface_contract.v1` |
159
+ | `prepare` | local reads only | no | path, size, hashes, module, safe context summary |
160
+ | `login` | standalone mode starts one owned Chrome | explicit choice | validated runtime session |
161
+ | `upload` | creates or resolves remote file object | yes | terminal file ID, size check, private receipt |
162
+
163
+ Every command writes one JSON object. A nonzero exit means the action did not
164
+ reach a verified result.
165
+
166
+ ## Canonical Invocation
167
+
168
+ All flags follow the command:
169
+
170
+ ```text
171
+ node "<skill_root>/dist/weaver-file-upload.js" contract \
172
+ --chat-id '<chatId>'
173
+
174
+ node "<skill_root>/dist/weaver-file-upload.js" prepare \
175
+ --chat-id '<chatId>' --file '<absoluteFilePath>' --module '<module>' \
176
+ [--context-file '<absoluteJsonObjectPath>']
177
+
178
+ node "<skill_root>/dist/weaver-file-upload.js" login \
179
+ --chat-id '<chatId>' \
180
+ --login-mode '<weaver-e10-login|standalone>' \
181
+ [--base-url '<runtimeRootUrl>']
182
+
183
+ node "<skill_root>/dist/weaver-file-upload.js" upload \
184
+ --chat-id '<chatId>' \
185
+ --login-mode '<weaver-e10-login|standalone>' \
186
+ --user-confirmed --file '<absoluteFilePath>' --module '<module>' \
187
+ [--context-file '<absoluteJsonObjectPath>']
188
+ ```
189
+
190
+ Call `contract` before the first upload and use its materialized commands.
191
+ `--base-url` is valid only for `login` in standalone mode.
192
+
193
+ ## Input Contract
194
+
195
+ - `chatId`: 1-128 ASCII letters, digits, dot, underscore, or hyphen.
196
+ - `file`: absolute path to a readable regular, non-symlink file.
197
+ - `module`: 1-64 ASCII letters, digits, dot, underscore, or hyphen.
198
+ - `context-file`: optional absolute path to a UTF-8 JSON object up to 64 KiB.
199
+ Object keys cannot override protocol fields; nested unsafe object keys and
200
+ nesting deeper than 12 levels are rejected.
201
+ - `timeout`: optional positive seconds up to 3600.
202
+ - `provider-timeout`: optional positive seconds up to 3600.
203
+ - `user-confirmed`: mandatory for `upload` and valid only for the current user
204
+ request and file.
205
+ - `login-mode`: `weaver-e10-login` or `standalone`. Failure never changes it.
206
+
207
+ Reserved fields are published by `references/file-upload-cli-contract.json`. Known optional
208
+ context fields and their purposes are in `references/file-upload-input-parameters.md`.
209
+
210
+ ## Upload Strategies
211
+
212
+ Every file-bearing multipart request emits a sanitized quoted `filename`
213
+ fallback and an RFC 5987 `filename*=UTF-8''...` value. The extended value
214
+ percent-encodes UTF-8 bytes and the reserved characters `'`, `(`, `)`, and
215
+ `*`, including filenames that combine Chinese text, spaces, and those
216
+ characters.
217
+
218
+ ### `second`
219
+
220
+ The preflight already returns an existing file object, so no upload body is
221
+ sent. The file ID is resolved from direct data, `uploadModuleDto`,
222
+ `imUploadInfoDto`, or their `fileObj`. A returned nonzero size must equal the
223
+ local size.
224
+
225
+ ### `common`
226
+
227
+ Require `preUploadId`, then stream the complete file once to
228
+ `/api/file/module/upload`. The file is not loaded into one in-memory byte array.
229
+ The response must contain a terminal file ID.
230
+
231
+ ### `chunk`
232
+
233
+ Require `preUploadId` and a positive `chunkDto.chunkSize`, interpreted as MiB.
234
+ Calculate local chunk count; if the server supplies `chunkCount`, it must match.
235
+ Send zero-based slices with exact `uploadShardSize`, `chunk`, and `chunks`.
236
+ Intermediate responses must be explicitly nonterminal. The final response must
237
+ contain the terminal file ID.
238
+
239
+ Unknown or empty upload types stop before an upload body is sent.
240
+
241
+ ## Business Validation
242
+
243
+ - HTTP status is exactly 200 and redirects are rejected.
244
+ - HTML and non-object JSON responses are rejected.
245
+ - `status=false`, `success=false`, `fail=true`, or a non-success code is a
246
+ business failure.
247
+ - Preflight data is an object; network branches include `preUploadId`.
248
+ - Final file ID is nonempty; returned nonzero size equals local size.
249
+ - `endChunk=true` without a file ID is not terminal success.
250
+
251
+ Responses are bounded to 4 MiB. Raw responses, credentials, signed URLs, and
252
+ multipart bodies are neither returned nor saved.
253
+
254
+ ## Result Contract
255
+
256
+ Successful upload returns `weaver_file_upload_result.v1`:
257
+
258
+ ```json
259
+ {
260
+ "status": "completed",
261
+ "business_verified": true,
262
+ "upload_type": "second|common|chunk",
263
+ "file": {
264
+ "file_id": "...",
265
+ "name": "...",
266
+ "size": 123,
267
+ "mime_type": "...",
268
+ "extension": "...",
269
+ "is_image": false
270
+ },
271
+ "integrity": {"md5": "...", "sha256": "..."},
272
+ "request_evidence": {
273
+ "module": "...",
274
+ "context_keys": [],
275
+ "context_sha256": "...",
276
+ "environment_identity_sha256": "...",
277
+ "login_mode": "weaver-e10-login|standalone",
278
+ "automatic_fallback": false
279
+ },
280
+ "receipt_ref": "/absolute/private/path.json",
281
+ "receipt_sha256": "..."
282
+ }
283
+ ```
284
+
285
+ Downstream consumers use only the normalized file object and receipt evidence.
286
+
287
+ ## Authentication Boundary
288
+
289
+ Provider mode resolves only `e10-login whoami`. Its raw output remains in the
290
+ child process boundary. The Node adapter bounds stdout, drains stderr, validates
291
+ domain/session/identity fields, and calls the same business validator before
292
+ use.
293
+
294
+ Standalone mode resolves a runtime root from explicit input, environment, or
295
+ this Skill's `.env.local`. Missing domain returns an Agent-conversation handoff.
296
+ It launches an isolated Chrome, reads `DevToolsActivePort`, obtains same-origin
297
+ cookies through CDP, and requires `ETEAMSID` plus a successful side-effect-free
298
+ `teamsCheck` identity. It then atomically writes a `0600` session and closes the
299
+ owned browser and process tree.
300
+
301
+ ## Failure And Recovery
302
+
303
+ - Local validation and preflight rejection have no upload side effect.
304
+ - A network error after common/chunk POST dispatch returns
305
+ `TRANSPORT_RESULT_UNKNOWN`, `execution_state=unknown`, and `retry_safe=false`.
306
+ - Do not replay an outcome-unknown upload. A later user-authorized attempt begins
307
+ with a new `preUploadCheck` and is a separate transaction.
308
+ - Missing terminal ID, early terminal chunk, inconsistent count, or size mismatch
309
+ is a hard failure with safe diagnostics only.
@@ -0,0 +1,120 @@
1
+ # 采知连文件类操作:附件、封面、文档比对
2
+
3
+ ## 何时使用
4
+
5
+ - 用户要给某篇文档**上传/替换附件**,或把附件**下载到本地**(含转 PDF 版本)。
6
+ - 用户要给文档**设置封面图片**、只上传封面图片拿 `file_id`,或**移除封面**。
7
+ - 用户要做**文档比对**:找可比对的文档、列出文档下可比对的文件对象、上传本地文件参与比对、提交左右两个文件拿比对链接。
8
+
9
+ > 文件类操作会读写用户本地磁盘,并把本地文件内容上传到 E10。**任何涉及附件、图片的上传/下载,都必须先向用户展示文件路径、文件名、大小,并取得明确确认后再执行**;文件内容不得进入大模型上下文。
10
+
11
+ ## 输入要点
12
+
13
+ ### 附件(attachment)
14
+
15
+ | operation | risk | 必填 | 可选 |
16
+ | --- | --- | --- | --- |
17
+ | `caizhilian.attachment.upload.prepare` / `.apply` | read-before-write / read-with-upload | `file_path`、`doc_id` | `folder_id` |
18
+ | `caizhilian.attachment.replace.prepare` / `.apply` | read-before-write / read-with-upload | `file_path`、`doc_id`、`attachment_id`、`folder_id` | 无 |
19
+ | `caizhilian.attachment.download` | local-file-write | `attachment_id`、`doc_id` | `save_path` |
20
+ | `caizhilian.attachment.download-as-pdf` | local-file-write | `attachment_id`、`doc_id` | `save_path` |
21
+
22
+ - `upload` 是新增附件;`replace` 走源 `reUpload`,**保留原附件 ID**(旧文件版本被顶替),所以 `attachment_id` 与 `folder_id` 都是必填,必须先用 `caizhilian.document.get` 或 `caizhilian.compare.list-file-objects` 拿到真实附件 ID。
23
+ - `download` 的 `save_path` 可以是**完整文件路径**,也可以是以 `/` 或 `\` 结尾的**目录**(目录时文件名取自响应头 `content-disposition`,已过滤路径穿越字符)。
24
+ - 未传 `save_path` 且没有配置默认下载目录时直接报 `no_save_path`(源 `assets/config.json` 的 `http.download.default_dir` 为空,CLI 侧不提供默认目录),必须让用户给出保存位置。
25
+ - `download-as-pdf` 会先调 `/api/file/download/toPdf?fileId=<attachment_id>` 预检,服务端返回不支持时报 `pdf_not_supported`;支持时带 `downloadToPdf=true` 下载 PDF 版本。
26
+ - 下载单文件上限 **100MB**,超限报 `file_too_large`;下载/上传超时 **120 秒**(普通接口 12 秒)。
27
+ - 同名文件已存在时按源的 `rename` 策略自动改名为 `名称(1).扩展名`、`名称(2).扩展名`……**不覆盖**已有文件。
28
+
29
+ ### 封面(cover)
30
+
31
+ | operation | risk | 必填 | 说明 |
32
+ | --- | --- | --- | --- |
33
+ | `caizhilian.cover.upload.prepare` / `.apply` | read-before-write / read-with-upload | `file_path` | 只上传图片拿 `file_id`,**不改任何文档** |
34
+ | `caizhilian.cover.set.prepare` / `.apply` | read-before-write / read-with-upload | `doc_id`、`file_path` | 上传图片后把 `coverPictureId` 写到文档基础字段 |
35
+ | `caizhilian.cover.remove.prepare` / `.apply` | read-before-write / high-risk-write | `doc_id` | 把 `coverPictureId` 置空 |
36
+
37
+ - 封面图片扩展名白名单(源 `IMAGE_ALLOWED_EXT`):`.bmp`、`.gif`、`.jpeg`、`.jpg`、`.png`、`.webp`;不在白名单报 `file_type_not_allowed`。
38
+ - `cover.set` 是**两步服务端写入**(先上传、再改文档字段),中途失败可能出现「图片已上传但封面未生效」,此时不要自动重放,先 `document.get` 回查。
39
+
40
+ ### 文档比对(compare)
41
+
42
+ | operation | risk | 必填 | 可选 |
43
+ | --- | --- | --- | --- |
44
+ | `caizhilian.compare.search-documents` | read | 无 | `name`、`author`、`creator`、`create_time`、`folder`、`page_no`(1)、`page_size`(20) |
45
+ | `caizhilian.compare.list-file-objects` | read | `doc_id` | 无 |
46
+ | `caizhilian.compare.upload-file.prepare` / `.apply` | read-before-write / read-with-upload | `file_path` | 无 |
47
+ | `caizhilian.compare.submit.prepare` / `.apply` | read-before-write / external-artifact | `left_file_id`、`right_file_id` | 无 |
48
+
49
+ - 典型链路:`search-documents` 或 `list-file-objects` 拿到左右两侧的 `file_id` → (本地文件则 `upload-file` 拿 `file_id`)→ `submit` 得到 `compare_link`。
50
+ - `submit` 的 13 个比对选项在源里**全部固定为 0**,CLI 1:1 沿用,不暴露给用户配置。
51
+ - `compare_link` 是**外部制品**:CLI 只返回链接,不代下载、不代打开。
52
+
53
+ ## 命令
54
+
55
+ Windows PowerShell:
56
+
57
+ ```powershell
58
+ weaver-work-cli --json caizhilian run caizhilian.attachment.upload.prepare --input-json '{"doc_id":"1234567890","file_path":"C:\\data\\合同.pdf"}'
59
+ weaver-work-cli --json caizhilian run caizhilian.attachment.upload.apply --input-json '{"doc_id":"1234567890","file_path":"C:\\data\\合同.pdf"}' --continuation TOKEN --yes
60
+ weaver-work-cli --json caizhilian run caizhilian.attachment.replace.prepare --input-json '{"doc_id":"1234567890","attachment_id":"888","folder_id":"456","file_path":"C:\\data\\合同v2.pdf"}'
61
+ weaver-work-cli --json caizhilian run caizhilian.attachment.download --input-json '{"doc_id":"1234567890","attachment_id":"888","save_path":"C:\\data\\out\\合同.pdf"}'
62
+ weaver-work-cli --json caizhilian run caizhilian.attachment.download-as-pdf --input-json '{"doc_id":"1234567890","attachment_id":"888","save_path":"C:\\data\\out"}'
63
+ weaver-work-cli --json caizhilian run caizhilian.cover.set.prepare --input-json '{"doc_id":"1234567890","file_path":"C:\\data\\cover.png"}'
64
+ weaver-work-cli --json caizhilian run caizhilian.cover.remove.prepare --input-json '{"doc_id":"1234567890"}'
65
+ weaver-work-cli --json caizhilian run caizhilian.compare.list-file-objects --input-json '{"doc_id":"1234567890"}'
66
+ weaver-work-cli --json caizhilian run caizhilian.compare.submit.prepare --input-json '{"left_file_id":"888","right_file_id":"999"}'
67
+ ```
68
+
69
+ macOS/Linux(bash/zsh):
70
+
71
+ ```bash
72
+ weaver-work-cli --json caizhilian run caizhilian.attachment.upload.prepare --input-json '{"doc_id":"1234567890","file_path":"/tmp/data/contract.pdf"}'
73
+ weaver-work-cli --json caizhilian run caizhilian.attachment.upload.apply --input-json '{"doc_id":"1234567890","file_path":"/tmp/data/contract.pdf"}' --continuation TOKEN --yes
74
+ weaver-work-cli --json caizhilian run caizhilian.attachment.replace.prepare --input-json '{"doc_id":"1234567890","attachment_id":"888","folder_id":"456","file_path":"/tmp/data/contract-v2.pdf"}'
75
+ weaver-work-cli --json caizhilian run caizhilian.attachment.download --input-json '{"doc_id":"1234567890","attachment_id":"888","save_path":"/tmp/data/out/contract.pdf"}'
76
+ weaver-work-cli --json caizhilian run caizhilian.attachment.download-as-pdf --input-json '{"doc_id":"1234567890","attachment_id":"888","save_path":"/tmp/data/out/"}'
77
+ weaver-work-cli --json caizhilian run caizhilian.cover.set.prepare --input-json '{"doc_id":"1234567890","file_path":"/tmp/data/cover.png"}'
78
+ weaver-work-cli --json caizhilian run caizhilian.cover.remove.prepare --input-json '{"doc_id":"1234567890"}'
79
+ weaver-work-cli --json caizhilian run caizhilian.compare.list-file-objects --input-json '{"doc_id":"1234567890"}'
80
+ weaver-work-cli --json caizhilian run caizhilian.compare.submit.prepare --input-json '{"left_file_id":"888","right_file_id":"999"}'
81
+ ```
82
+
83
+ ## 输出处理
84
+
85
+ - **prepare 返回**:`data` 含本地文件预览 `{ file_name, file_size, file_md5, ext_name }` + `upload` 预览块(`path`、`extra_body`、`allowed_ext`、`required_permission`、`deferred_to_apply: true`),外加 `continuation`、`expires_in_ms`、`hint`,`meta.status = "PREPARED"`。向用户摘要时必须写清「哪个文件、多大、传到哪篇文档/做什么」。
86
+ - **上传类 apply 返回**:`{ file_id, name, size, ext_name, ... }`(`attachment.upload` 额外把源的 `uploadTime` 改名为 `upload_time` 放在最后;`attachment.replace` 与 `document.replace-content` 额外带 `version`(新版本号))。命中服务端 MD5 秒传时不会真正传文件,但返回结构一致。
87
+ - **下载类返回**:`{ file_path, file_name, file_size }`,`meta` 带 `{ doc_id, attachment_id }`。回复用户时给出**绝对路径 + 文件大小**,并提示已存在同名文件时被自动改名。
88
+ - `cover.upload.apply` 返回 `{ file_id, name, size, ext_name }`;`cover.set.apply` 返回 `{ doc_id, file_id, name }`;`cover.remove.apply` 返回 `{ doc_id, cover_picture_id }`(`cover_picture_id` 为删除后的空串)。
89
+ - `compare.list-file-objects` 返回 `{ attachments: [{ docId, file_id, ext_name, file_name, size, updateTime }] }`,其中 `file_id` 就是 `compare.submit` 需要的 ID;用 Markdown 表格摘要「文件名/类型/大小/更新时间」。
90
+ - `compare.search-documents` 与 `document.search` 同构(`{ page_no, page_size, has_next, documents[] }`),参见 `document.md`。
91
+ - `compare.submit.apply` 返回 `{ compare_link }`,把链接原样交给用户,不要尝试抓取链接内容。
92
+
93
+ ## 注意
94
+
95
+ - **附件、图片属于用户私有数据**:上传前必须让用户确认文件路径与目标文档;下载前必须确认保存位置。文件二进制内容**不得读入大模型上下文**,只能引用路径、文件名、大小、MD5 这类元数据。
96
+ - 用户只说「把那个文件传上去」时,**必须先取得明确确认**(哪个文件、传到哪篇文档),不要自行猜测路径或复用上一次的路径。
97
+ - `attachment.replace` 会顶替原附件内容且**不可撤销**,确认摘要里必须写明被替换的 `attachment_id` 与文件名。
98
+ - `cover.remove` 是 high-risk-write:封面移除后需要重新上传才能恢复,确认摘要要说明后果。
99
+ - prepare 之后如果本地文件被改动(MD5 或大小变化),apply 会报 `file_changed`,必须重新 prepare——不要试图绕过。
100
+ - 上传/下载是**长耗时操作**(120 秒超时):一次只跑一个,不要并发批量上传;批量建文档请用 `document.create-by-upload`(见 `document.md`)。
101
+ - `compare.upload-file` 上传前会走比对模块的上传凭证权限校验(合约中以 `permissions` 标记为 `compare.upload`);校验失败时原样转述错误,不要重试或改用其他接口绕行。
102
+ - 下载会写本地磁盘,属于 CLI 的 local-file-write 能力:只在用户指定的目录内写入,不要自作主张落到仓库工作区或系统目录。
103
+
104
+ ## 失败处理
105
+
106
+ | error.subtype | 触发场景 | 处理 |
107
+ | --- | --- | --- |
108
+ | `file_not_found` | 路径不存在或不是文件 | 让用户确认路径,不要猜 |
109
+ | `file_unreadable` | 文件被占用或无读权限 | 提示关闭占用程序后重试一次 |
110
+ | `file_path_invalid` | `file_path` 为空 | 补齐后重试 |
111
+ | `file_type_not_allowed` | 扩展名不在白名单(封面图片、Office 建文档、替换正文各有白名单) | 转述支持的扩展名清单给用户 |
112
+ | `file_too_large` | 下载内容超过 100MB | 告知上限,建议改用 E10 页面下载 |
113
+ | `no_save_path` | 下载未给 `save_path` 且无默认目录 | 向用户索要保存路径 |
114
+ | `pdf_not_supported` | 该附件不支持转 PDF | 改用 `attachment.download` 下原文件 |
115
+ | `file_changed` | prepare 后本地文件被修改 | 重新 prepare |
116
+ | `upload_precheck_invalid` | 预上传检查响应缺 `preUploadId`/`uploadType` | 停止,把 message 交给用户 |
117
+ | `permission_denied` | 预上传检查返回无 `upload` 权限 | 转述给用户,不要重试 |
118
+ | `field_required` | `doc_id` / `attachment_id` / `folder_id` 为空 | 先用只读操作补齐真实 ID |
119
+ | `plan_changed` / `continuation_*` | 请求体指纹或票据校验失败 | 见 `write-protocol.md` |
120
+ | `partial/write_uncertain` | 上传/改字段结果不确定 | 立即停止,最多补一次 `document.get` 或 `compare.list-file-objects` 只读回查,禁止重放 |