weaver-work-cli 0.1.5 → 0.1.7

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 (225) hide show
  1. package/README.md +14 -9
  2. package/dist/cmd/skills/index.js +60 -0
  3. package/dist/internal/e10/auth/commands.js +48 -32
  4. package/dist/internal/e10/auth/session.js +44 -3
  5. package/dist/internal/e10/auth/xiaoe.js +363 -11
  6. package/dist/internal/e10/context.js +4 -2
  7. package/dist/internal/skills/detector.js +42 -0
  8. package/dist/internal/skills/install.js +50 -3
  9. package/dist/shortcuts/archive/render/search-format.js +12 -3
  10. package/dist/shortcuts/ebuilder-form/continuation.js +70 -0
  11. package/dist/shortcuts/ebuilder-form/errors.js +54 -0
  12. package/dist/shortcuts/ebuilder-form/host.js +1238 -0
  13. package/dist/shortcuts/ebuilder-form/index.js +108 -0
  14. package/dist/shortcuts/ebuilder-form/manifest.js +347 -0
  15. package/dist/shortcuts/ebuilder-form/operations/read.js +157 -0
  16. package/dist/shortcuts/ebuilder-form/operations/registry.js +56 -0
  17. package/dist/shortcuts/ebuilder-form/operations/shared.js +132 -0
  18. package/dist/shortcuts/ebuilder-form/operations/types.js +19 -0
  19. package/dist/shortcuts/ebuilder-form/operations/write.js +277 -0
  20. package/dist/shortcuts/ebuilder-form/operations.js +8 -0
  21. package/dist/shortcuts/ehr/operations/salary.js +2 -140
  22. package/dist/shortcuts/im/continuation.js +70 -0
  23. package/dist/shortcuts/{yimiaoban → im}/errors.js +14 -14
  24. package/dist/shortcuts/{yimiaoban → im}/host.js +26 -26
  25. package/dist/shortcuts/{yimiaoban → im}/index.js +42 -42
  26. package/dist/shortcuts/{yimiaoban → im}/manifest.js +7 -6
  27. package/dist/shortcuts/{yimiaoban → im}/operations/file-user.js +54 -41
  28. package/dist/shortcuts/{yimiaoban → im}/operations/group-read.js +46 -44
  29. package/dist/shortcuts/{yimiaoban → im}/operations/group-write.js +113 -66
  30. package/dist/shortcuts/{yimiaoban → im}/operations/msg-sync.js +164 -141
  31. package/dist/shortcuts/{yimiaoban → im}/operations/msg-write.js +47 -47
  32. package/dist/shortcuts/{yimiaoban → im}/operations/person.js +10 -10
  33. package/dist/shortcuts/{yimiaoban → im}/operations/registry.js +10 -8
  34. package/dist/shortcuts/{yimiaoban → im}/operations/session.js +82 -83
  35. package/dist/shortcuts/im/operations/shared.js +442 -0
  36. package/dist/shortcuts/{yimiaoban → im}/operations/types.js +1 -1
  37. package/dist/shortcuts/im/operations/user-remind.js +201 -0
  38. package/dist/shortcuts/{yimiaoban → im}/operations/write-util.js +7 -7
  39. package/dist/shortcuts/{yimiaoban → im}/operations.js +3 -3
  40. package/dist/shortcuts/index.js +10 -2
  41. package/dist/shortcuts/invoice/manifest.js +113 -10
  42. package/dist/shortcuts/invoice/operations/import.js +39 -14
  43. package/dist/shortcuts/invoice/operations/reim.js +38 -18
  44. package/dist/shortcuts/invoice/operations/shared.js +35 -6
  45. package/dist/shortcuts/jiuchuanhui/manifest.js +3 -3
  46. package/dist/shortcuts/jiuchuanhui/operations/registry.js +2 -2
  47. package/dist/shortcuts/{yimiaoban → okr}/continuation.js +10 -10
  48. package/dist/shortcuts/okr/errors.js +70 -0
  49. package/dist/shortcuts/okr/host.js +169 -0
  50. package/dist/shortcuts/okr/index.js +155 -0
  51. package/dist/shortcuts/okr/manifest.js +70 -0
  52. package/dist/shortcuts/okr/operations/link.js +305 -0
  53. package/dist/shortcuts/okr/operations/read.js +481 -0
  54. package/dist/shortcuts/okr/operations/registry.js +31 -0
  55. package/dist/shortcuts/okr/operations/shared.js +381 -0
  56. package/dist/shortcuts/okr/operations/types.js +88 -0
  57. package/dist/shortcuts/okr/operations/write.js +838 -0
  58. package/dist/shortcuts/okr/operations.js +8 -0
  59. package/dist/shortcuts/project/continuation.js +70 -0
  60. package/dist/shortcuts/project/errors.js +53 -0
  61. package/dist/shortcuts/project/host.js +160 -0
  62. package/dist/shortcuts/project/index.js +106 -0
  63. package/dist/shortcuts/project/manifest.js +36 -0
  64. package/dist/shortcuts/project/operations/read.js +551 -0
  65. package/dist/shortcuts/project/operations/registry.js +31 -0
  66. package/dist/shortcuts/project/operations/shared.js +68 -0
  67. package/dist/shortcuts/project/operations/types.js +39 -0
  68. package/dist/shortcuts/project/operations/write.js +266 -0
  69. package/dist/shortcuts/project/operations.js +8 -0
  70. package/dist/shortcuts/workflow/continuation.js +508 -0
  71. package/dist/shortcuts/workflow/endpoints.js +149 -0
  72. package/dist/shortcuts/workflow/errors.js +112 -0
  73. package/dist/shortcuts/workflow/host.js +224 -0
  74. package/dist/shortcuts/workflow/index.js +116 -0
  75. package/dist/shortcuts/workflow/manifest.js +30 -0
  76. package/dist/shortcuts/workflow/operations/form.js +4159 -0
  77. package/dist/shortcuts/workflow/operations/read.js +3778 -0
  78. package/dist/shortcuts/workflow/operations/registry.js +33 -0
  79. package/dist/shortcuts/workflow/operations/shared.js +167 -0
  80. package/dist/shortcuts/workflow/operations/types.js +44 -0
  81. package/dist/shortcuts/workflow/operations/write.js +1991 -0
  82. package/dist/shortcuts/workflow/operations.js +119 -0
  83. package/dist/shortcuts/workflow/state.js +182 -0
  84. package/docs/SKILL.md +5 -3
  85. package/docs/_catalog.md +10 -1
  86. package/docs/agent-invoice.md +2 -2
  87. package/docs/agent-skill-install.md +2 -2
  88. package/docs/e10-auth.md +3 -1
  89. package/docs/ebuilder-form.md +38 -0
  90. package/docs/im.md +104 -0
  91. package/docs/invoice.md +5 -5
  92. package/docs/okr.md +122 -0
  93. package/docs/operation-manual.md +10 -7
  94. package/docs/project.md +69 -0
  95. package/docs/skill-review-2026-09-19.md +68 -0
  96. package/package.json +3 -2
  97. package/scripts/package-skill.mjs +38 -11
  98. package/scripts/sync-connector-skills.mjs +172 -0
  99. package/skill-template/business-info.json +357 -16
  100. package/skill-template/domains/ebuilder-form.md +5 -0
  101. package/skill-template/domains/okr.md +18 -0
  102. package/skill-template/domains/shijingran.md +3 -0
  103. package/skill-template/domains/skill-maker.md +4 -4
  104. package/skill-template/domains/workflow.md +22 -0
  105. package/skill-template/domains/yepiaotong.md +4 -2
  106. package/skill-template/domains/yimiaoban.md +13 -10
  107. package/skill-template/product.json +5 -0
  108. package/skill-template/skill-template.md +1 -0
  109. package/skills/weaver-e10-calendar/SKILL.md +5 -1
  110. package/skills/weaver-e10-calendar/references/calendar-query.md +7 -0
  111. package/skills/weaver-e10-calendar/references/source-manifest.json +314 -32
  112. package/skills/weaver-e10-ebuilder-form/SKILL.md +123 -0
  113. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +90 -0
  114. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +86 -0
  115. package/skills/weaver-e10-ebuilder-form/references/disabled-capabilities.md +50 -0
  116. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +100 -0
  117. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +91 -0
  118. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +74 -0
  119. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +86 -0
  120. package/skills/weaver-e10-ebuilder-form/references/source-manifest.json +107 -0
  121. package/skills/weaver-e10-esb/SKILL.md +1 -1
  122. package/skills/weaver-e10-esb/references/source-manifest.json +15 -14
  123. package/skills/weaver-e10-hrm/SKILL.md +1 -1
  124. package/skills/weaver-e10-hrm/references/source-manifest.json +357 -38
  125. package/skills/weaver-e10-jiuchuanhui/SKILL.md +22 -4
  126. package/skills/weaver-e10-jiuchuanhui/references/clue.md +4 -2
  127. package/skills/weaver-e10-jiuchuanhui/references/contact.md +1 -1
  128. package/skills/weaver-e10-jiuchuanhui/references/customer.md +3 -3
  129. package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +1 -1
  130. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +10 -10
  131. package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +3 -3
  132. package/skills/weaver-e10-jiuchuanhui/references/sale.md +7 -7
  133. package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +3 -3
  134. package/skills/weaver-e10-jucailin/SKILL.md +2 -2
  135. package/skills/weaver-e10-mail/SKILL.md +22 -6
  136. package/skills/weaver-e10-meeting/SKILL.md +22 -1
  137. package/skills/weaver-e10-okr/SKILL.md +139 -0
  138. package/skills/weaver-e10-okr/references/okr-align.md +59 -0
  139. package/skills/weaver-e10-okr/references/okr-keyresult.md +68 -0
  140. package/skills/weaver-e10-okr/references/okr-link-routing.md +67 -0
  141. package/skills/weaver-e10-okr/references/okr-query.md +105 -0
  142. package/skills/weaver-e10-okr/references/okr-write.md +94 -0
  143. package/skills/weaver-e10-okr/references/source-manifest.json +672 -0
  144. package/skills/weaver-e10-plan/SKILL.md +3 -3
  145. package/skills/weaver-e10-plan/references/plan-report-write.md +1 -1
  146. package/skills/weaver-e10-plan/references/source-manifest.json +20 -20
  147. package/skills/weaver-e10-qiyecheng/SKILL.md +21 -1
  148. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +17 -17
  149. package/skills/weaver-e10-shared/SKILL.md +79 -11
  150. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +41 -8
  151. package/skills/weaver-e10-shared/references/non-interactive-environment.md +78 -0
  152. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +39 -0
  153. package/skills/weaver-e10-shijingran/SKILL.md +83 -0
  154. package/skills/weaver-e10-shijingran/references/field-resolution.md +105 -0
  155. package/skills/weaver-e10-shijingran/references/operations.md +154 -0
  156. package/skills/weaver-e10-shijingran/references/source-manifest.json +1380 -0
  157. package/skills/weaver-e10-shijingran/references/write-operations.md +90 -0
  158. package/skills/weaver-e10-skill-maker/SKILL.md +26 -9
  159. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +39 -8
  160. package/skills/weaver-e10-skill-maker/references/detector-validation.md +25 -8
  161. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +66 -5
  162. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +86 -0
  163. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +59 -5
  164. package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +16 -8
  165. package/skills/weaver-e10-wenshuding/SKILL.md +28 -4
  166. package/skills/weaver-e10-wenshuding/references/archive-search.md +14 -0
  167. package/skills/weaver-e10-wenshuding/references/source-manifest.json +27 -26
  168. package/skills/weaver-e10-workflow/SKILL.md +250 -0
  169. package/skills/weaver-e10-workflow/references/source-manifest.json +1062 -0
  170. package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +96 -0
  171. package/skills/weaver-e10-workflow/references/workflow-batch.md +275 -0
  172. package/skills/weaver-e10-workflow/references/workflow-create.md +182 -0
  173. package/skills/weaver-e10-workflow/references/workflow-edit.md +106 -0
  174. package/skills/weaver-e10-workflow/references/workflow-memory.md +165 -0
  175. package/skills/weaver-e10-workflow/references/workflow-operate.md +153 -0
  176. package/skills/weaver-e10-workflow/references/workflow-query.md +821 -0
  177. package/skills/weaver-e10-workflow/references/workflow-share.md +117 -0
  178. package/skills/weaver-e10-workflow/references/workflow-view.md +189 -0
  179. package/skills/weaver-e10-yepiaotong/SKILL.md +28 -28
  180. package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +11 -5
  181. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +14 -8
  182. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +9 -43
  183. package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +8 -0
  184. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +13 -17
  185. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +6 -7
  186. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +2 -2
  187. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1155 -553
  188. package/skills/weaver-e10-yimiaoban/SKILL.md +56 -38
  189. package/skills/weaver-e10-yimiaoban/references/ding-write.md +8 -8
  190. package/skills/weaver-e10-yimiaoban/references/error-codes.md +16 -0
  191. package/skills/weaver-e10-yimiaoban/references/field-resolution.md +10 -10
  192. package/skills/weaver-e10-yimiaoban/references/file-user-i18n.md +12 -12
  193. package/skills/weaver-e10-yimiaoban/references/group-read.md +16 -16
  194. package/skills/weaver-e10-yimiaoban/references/group-write.md +17 -15
  195. package/skills/weaver-e10-yimiaoban/references/msg-read.md +21 -17
  196. package/skills/weaver-e10-yimiaoban/references/msg-write.md +10 -10
  197. package/skills/weaver-e10-yimiaoban/references/person.md +6 -6
  198. package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +15 -11
  199. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +11 -10
  200. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +2164 -154
  201. package/skills/weaver-e10-yimiaoban/references/user-remind.md +75 -0
  202. package/skills/weaver-e10-ziguanjia/SKILL.md +4 -2
  203. package/skills/weaver-e10-ziguanjia/references/source-manifest.json +99 -29
  204. package/tools/weaver-skill-detector-1.0.13/SKILL.md +253 -0
  205. package/tools/weaver-skill-detector-1.0.13/_meta.json +6 -0
  206. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +298 -0
  207. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +4190 -0
  208. package/dist/shortcuts/yimiaoban/operations/shared.js +0 -236
  209. package/docs/yimiaoban.md +0 -86
  210. package/skills/weaver-e10-calendar/product.json +0 -8
  211. package/skills/weaver-e10-esb/product.json +0 -8
  212. package/skills/weaver-e10-hrm/product.json +0 -8
  213. package/skills/weaver-e10-jiuchuanhui/product.json +0 -8
  214. package/skills/weaver-e10-jucailin/product.json +0 -8
  215. package/skills/weaver-e10-mail/product.json +0 -8
  216. package/skills/weaver-e10-meeting/product.json +0 -8
  217. package/skills/weaver-e10-plan/product.json +0 -8
  218. package/skills/weaver-e10-qiyecheng/product.json +0 -8
  219. package/skills/weaver-e10-skill-maker/product.json +0 -8
  220. package/skills/weaver-e10-wenshuding/product.json +0 -8
  221. package/skills/weaver-e10-yepiaotong/product.json +0 -8
  222. package/skills/weaver-e10-yepiaotong/references/invoice-red.md +0 -261
  223. package/skills/weaver-e10-yimiaoban/product.json +0 -8
  224. package/skills/weaver-e10-ziguanjia/product.json +0 -8
  225. /package/dist/shortcuts/{yimiaoban → im}/operations/msg-parse.js +0 -0
@@ -0,0 +1,105 @@
1
+ # 目标查询与详情(okr-query)
2
+
3
+ 只读 operation 清单:`okr.list`、`okr.get`、`okr.kr.list`、`okr.comment.list`、`okr.viewlink`、`okr.detail.link`。全部不需要确认,也不会写入数据。
4
+
5
+ ## `okr.list` — 分页查询目标
6
+
7
+ 标准版与 ebuilder 链路共用同一个 operation,入参一致,请求体按链路自动转换。
8
+
9
+ | 字段 | 类型 | 说明 |
10
+ | --- | --- | --- |
11
+ | `query_scope` | `self` / `all` | `self`=本人对应周期(默认),`all`=按条件跨人检索 |
12
+ | `period_type` | `"1"`/`"2"`/`"3"`/`"4"` | 1-年度 2-季度 3-月度 4-自定义;`query_scope=self` 时必填 |
13
+ | `period_range` | string | 年度/季度为 `yyyy`,月度为 `yyyy-MM`,自定义为 `开始日期,结束日期` |
14
+ | `period_quarter` | `"1"`..`"4"` | `period_type=2` 时必填 |
15
+ | `name` | string | 目标名称关键字(**仅标准版链路**,模糊匹配) |
16
+ | `principalid` | 人员 ID | 责任人筛选(人员 ID 由 weaver-e10-hrm 解析) |
17
+ | `status` | string | 状态码,英文逗号拼接(**仅标准版链路**) |
18
+ | `match` | `and` / `or` | 多条件关系,默认 `and`(仅标准版链路) |
19
+ | `page_no` / `page_size` | integer | 默认 1 / 10;`page_size` 最大 100 |
20
+
21
+ 返回:
22
+
23
+ - `link`、`queryScope`、`period`、`page`(含 `total`/`hasNext`)、`count`。
24
+ - `goals[]`:统一结构的目标数组(`goalId`、`name`、`principalid`、`principalName`、`periodType`、`periodTypeLabel`、`periodRange`、`periodStart`、`periodEnd`、`status`、`statusLabel`、`progress`、`detailUrl` 等)。
25
+ - `table`:**固定四列**表格(目标名称、目标责任人名称、目标周期类型、目标周期范围),`table.markdown` 中的目标名称是可点击的**绝对地址**链接。
26
+
27
+ 链路差异:
28
+
29
+ - **标准版**:`query_scope=self` 固定传 `condtype=1`/`subcondtype=1`/`status=1`;`query_scope=all` 传 `condtype=4`/`subcondtype=6`,支持 `name`/`principalid`/`status`。
30
+ - **ebuilder**:只传 `creator`(self 时)/`principalid` + 周期筛选字段;**不支持按名称或状态筛选**,传入 `name` 或 `status` 会返回 `validation/link_filter_unsupported`。
31
+
32
+ 便捷入口:`weaver-work-cli okr list --period-type 3 --period-range 2026-09 --page-size 10`。
33
+
34
+ ## `okr.get` — 目标详情
35
+
36
+ | 字段 | 类型 | 说明 |
37
+ | --- | --- | --- |
38
+ | `id` | 目标 ID | 必填 |
39
+ | `include_comment_count` | boolean | 默认 `true`,仅标准版链路生效 |
40
+
41
+ 返回 `link`、`goalId`、`goal`(统一结构)、`raw`(原始响应),以及标准版链路下的评论提示。
42
+
43
+ **评论规则**:标准版链路会额外查询评论总条数,但**详情绝不直接输出评论正文**:
44
+
45
+ - 总数 > 0 → 只返回 `commentSummary.totalCount` 与提示「该目标下共有 N 条评论,是否需要查看评论内容?」,正文必须由用户确认后再调 `okr.comment.list`。
46
+ - 总数 = 0 → 完全忽略评论模块,不输出任何评论相关文字。
47
+ - 评论接口不可用 → 记入 `meta.notes`(`comment_count_unavailable`)。
48
+ - ebuilder 链路 → 不查询评论接口,`meta.notes` 说明 `comment_api_unsupported_on_eb_link`。
49
+
50
+ ## `okr.kr.list` — 关键成果列表(仅 ebuilder)
51
+
52
+ | 字段 | 类型 | 说明 |
53
+ | --- | --- | --- |
54
+ | `object_id` | 目标 ID | 必填 |
55
+ | `page_no` / `page_size` | integer | 默认 1 / 10 |
56
+
57
+ 标准版链路没有独立的关键成果分页接口,调用会返回 `policy/link_unsupported`;标准版请改用 `okr.get` 的 `goal.keyresultList` 或 `okr.list` 的 `goals[].keyresultList`。
58
+
59
+ ## `okr.comment.list` — 目标评论(仅标准版)
60
+
61
+ | 字段 | 类型 | 说明 |
62
+ | --- | --- | --- |
63
+ | `target_id` | 目标 ID | 必填 |
64
+ | `page_no` / `page_size` | integer | 默认 1 / 10 |
65
+
66
+ **只有在用户明确要求查看评论内容后才可调用**(`okr.get` 只给提示不给正文)。ebuilder 链路没有评论接口,调用会返回 `policy/link_unsupported`。
67
+
68
+ ## `okr.viewlink` / `okr.detail.link` — 详情页链接
69
+
70
+ - `okr.viewlink`:`ids`(目标 ID 数组或英文逗号拼接字符串)必填,`anchor` 可选(链接展示文案)。逐条返回 `goalId`、`path`(站内相对路径)、`url`(绝对地址)、`anchor`。任一 id 链接不可用时整体返回 `status=VIEWLINK_UNAVAILABLE`、`available=false` 并给出 `warnings`。
71
+ - `okr.detail.link`:返回当前链路的地址模板(`pathTemplate` / `urlTemplate`)与 eb 表单 id 解析来源。
72
+
73
+ ## 调用示例
74
+
75
+ 标准版本人月度目标:
76
+
77
+ Windows PowerShell:
78
+
79
+ ```powershell
80
+ weaver-work-cli --json okr run okr.list --input-json '{"query_scope":"self","period_type":"3","period_range":"2026-09","page_size":10}'
81
+ ```
82
+
83
+ macOS/Linux(bash/zsh):
84
+
85
+ ```bash
86
+ printf '%s\n' '{"query_scope":"self","period_type":"3","period_range":"2026-09","page_size":10}' | weaver-work-cli --json okr run okr.list --input -
87
+ ```
88
+
89
+ 跨人检索(标准版):
90
+
91
+ ```text
92
+ weaver-work-cli --json okr run okr.list --input-json '{"query_scope":"all","name":"10月份","principalid":"<人员ID>"}'
93
+ ```
94
+
95
+ 查询详情:
96
+
97
+ ```text
98
+ weaver-work-cli --json okr get --id <目标ID>
99
+ ```
100
+
101
+ ## 注意
102
+
103
+ - 返回的 `table.markdown` 可能较长,给用户只渲染表格与数量摘要,不要整段回贴 `raw`。
104
+ - `principalid`/`status` 等筛选字段传错类型会被 schema 直接拒绝,错误形状见 stderr JSON。
105
+ - 列表默认只查一页,需要更多数据时按 `page.hasNext` 递增 `page_no`,不要一次性把 `page_size` 调到 100 以上。
@@ -0,0 +1,94 @@
1
+ # 新建与编辑目标(okr-write)
2
+
3
+ 新建目标与编辑目标都拆成 `prepare -> apply` 两个 operation,四个 operation 都属于高风险写入,必须经用户明确确认。
4
+
5
+ | operation | 风险 | 作用 |
6
+ | --- | --- | --- |
7
+ | `okr.create.prepare` | read-before-write | 归一化输入、补默认值、生成预览与 continuation,**不写入** |
8
+ | `okr.create.apply` | high-risk-write | 提交新建目标 |
9
+ | `okr.update.prepare` | read-before-write | 先查询当前目标详情并合并修改,生成预览与 continuation,**不写入** |
10
+ | `okr.update.apply` | high-risk-write | 提交编辑目标 |
11
+
12
+ ## 入参字段
13
+
14
+ `prepare` 与对应 `apply` 使用同一组业务字段;`apply` 额外要求 `confirm=true` 与 `continuation`,编辑类 `apply` 还要求显式传 `id`。
15
+
16
+ | 字段 | 类型 | 说明 |
17
+ | --- | --- | --- |
18
+ | `name` | string | 目标名称(新建必填) |
19
+ | `period_type` | `"1"`..`"4"` | 周期类型(新建必填) |
20
+ | `period_range` | string | 周期范围(新建必填,格式随类型变化) |
21
+ | `period_quarter` | `"1"`..`"4"` | `period_type=2` 必填 |
22
+ | `principalid` | 人员 ID | 责任人,默认当前登录用户 |
23
+ | `partners` | 人员 ID 或数组 | 参与人,英文逗号拼接或数组 |
24
+ | `scope_id` | `"1"` / `"2"` | 1-个人目标(默认) 2-部门目标 |
25
+ | `scope_data_id` | 部门 ID | 标准版链路 `scope_id=2` 必填 |
26
+ | `principal_dept` | 部门 ID | ebuilder 链路 `scope_id=2` 必填 |
27
+ | `parent_id` | 目标 ID | 上级目标 |
28
+ | `category_id` | string | 目标分类 id |
29
+ | `remark` | string | 目标描述 |
30
+ | `progress` | number | 进度 0-100(ebuilder 新建默认 0) |
31
+ | `status` | `"0"` / `"1"` | **标准版**:0-保存草稿(新建默认) 1-正式提交 |
32
+ | `m_status` | `"1"`..`"5"` | **ebuilder**:1-进行中(新建默认) 2-已完成 3-已撤销 4-审批中 5-未开始 |
33
+ | `wb_state` | `"1"`..`"3"` | **ebuilder** 紧急状态:1-正常 2-紧急 3-非常紧急 |
34
+ | `keyresult_list` | array | 随目标一起创建的关键成果(**仅标准版**),元素 `{name, principalid?, weight?, target_value?}` |
35
+ | `confirm` | `true` | 仅 `apply`,必须为 `true` |
36
+ | `continuation` | string | 仅 `apply`,取自 `prepare` 返回 |
37
+
38
+ 非本链路的字段会被忽略并记入 `meta.notes`(如标准版链路的 `m_status`/`wb_state`/`principal_dept`,ebuilder 链路的 `keyresult_list`)。
39
+
40
+ ## 关键业务规则
41
+
42
+ - **标准版新建默认草稿**:未传 `status` 时新建默认 `status=0`,不会直接提交为正式目标。
43
+ - **标准版编辑必须显式传 `status`**:`update.prepare` 不传 `status` 会返回 `validation/status_required`,避免把正式目标静默回退为草稿。
44
+ - **编辑为全量合并**:`update.prepare` 先通过详情接口取回当前目标,再合并用户修改;只读字段(如 `creator`、`img_url`)不回写。
45
+ - **ebuilder 新建默认值**:`m_status=1`、`progress=0`。
46
+ - **部门目标**:标准版要 `scope_data_id`,ebuilder 要 `principal_dept`,缺失时 prepare 阶段直接阻断。
47
+ - **人员 ID**:必须传人员 ID,传姓名会返回 `validation/person_id_invalid` 并指向 weaver-e10-hrm。
48
+
49
+ ## 确认链
50
+
51
+ 1. 调 `okr.create.prepare` / `okr.update.prepare`,向用户展示 `preview`(含目标名称、级别、周期、责任人、参与人、状态等)与 `expiresInSeconds`。
52
+ 2. 用户明确同意后调 `okr.create.apply` / `okr.update.apply`,传 `confirm=true` 与 prepare 返回的 `continuation`。
53
+ 3. continuation 绑定 `baseUrl`/`profile`/`userId`,10 分钟有效;登录上下文变化会返回 `validation/context_mismatch`,写入内容指纹变化会返回 `validation/target_changed`,两种情况都必须重新 prepare。
54
+
55
+ `apply` 成功后返回 `status=COMPLETE`、`goalId`、`path` 与 `detailUrl`(可点击的绝对地址)。
56
+
57
+ ## 失败处理
58
+
59
+ - 写入请求发出后连接中断 → `partial/write_uncertain`,**禁止自动重试**,先调 `okr.get` 复核目标是否已落库。
60
+ - `validation/context_mismatch`、`validation/target_changed` → 重新执行 prepare,不要复用旧 continuation。
61
+ - `validation/scope_data_id_required`、`validation/principal_dept_required`、`validation/period_quarter_invalid` → 补齐参数后重新 prepare。
62
+
63
+ ## 调用示例
64
+
65
+ 新建个人月度目标:
66
+
67
+ Windows PowerShell:
68
+
69
+ ```powershell
70
+ weaver-work-cli --json okr run okr.create.prepare --input-json '{"name":"2026年9月目标","period_type":"3","period_range":"2026-09"}'
71
+ ```
72
+
73
+ macOS/Linux(bash/zsh):
74
+
75
+ ```bash
76
+ printf '%s\n' '{"name":"2026年9月目标","period_type":"3","period_range":"2026-09"}' | weaver-work-cli --json okr run okr.create.prepare --input -
77
+ ```
78
+
79
+ 用户在对话中确认后提交:
80
+
81
+ ```text
82
+ weaver-work-cli --json okr run okr.create.apply --input-json '{"confirm":true,"continuation":"<prepare 返回的 continuation>"}'
83
+ ```
84
+
85
+ 编辑已有目标(标准版必须带 `status`):
86
+
87
+ ```text
88
+ weaver-work-cli --json okr run okr.update.prepare --input-json '{"id":"<目标ID>","name":"2026年9月目标(修订)","status":"0"}'
89
+ ```
90
+
91
+ ## 注意
92
+
93
+ - 禁止手工构造或跨任务复用 continuation;`confirm=true` 只在用户明确确认后传入。
94
+ - `preview` 是给用户看的确认摘要,不是真实请求体;不要用 `preview` 去推测接口字段名。