weaver-work-cli 0.1.7 → 0.1.20

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 (264) hide show
  1. package/README.md +11 -11
  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 +432 -0
  14. package/dist/core/state.js +26 -0
  15. package/dist/internal/e10/auth/commands.js +2 -2
  16. package/dist/internal/e10/auth/session.js +14 -0
  17. package/dist/internal/e10/auth/xiaoe.js +116 -51
  18. package/dist/internal/e10/request-runtime.js +5 -0
  19. package/dist/internal/skills/install.js +148 -28
  20. package/dist/internal/skills/reader.js +12 -9
  21. package/dist/shortcuts/blog/continuation.js +74 -0
  22. package/dist/shortcuts/blog/errors.js +60 -0
  23. package/dist/shortcuts/blog/host.js +175 -0
  24. package/dist/shortcuts/blog/index.js +324 -0
  25. package/dist/shortcuts/blog/manifest.js +415 -0
  26. package/dist/shortcuts/blog/operations/comment.js +125 -0
  27. package/dist/shortcuts/blog/operations/comments.js +31 -0
  28. package/dist/shortcuts/blog/operations/edit.js +131 -0
  29. package/dist/shortcuts/blog/operations/export.js +46 -0
  30. package/dist/shortcuts/blog/operations/like.js +80 -0
  31. package/dist/shortcuts/blog/operations/publish.js +157 -0
  32. package/dist/shortcuts/blog/operations/query-user.js +58 -0
  33. package/dist/shortcuts/blog/operations/query.js +96 -0
  34. package/dist/shortcuts/blog/operations/registry.js +54 -0
  35. package/dist/shortcuts/blog/operations/remind.js +176 -0
  36. package/dist/shortcuts/blog/operations/shared.js +330 -0
  37. package/dist/shortcuts/blog/operations/types.js +16 -0
  38. package/dist/shortcuts/blog/operations.js +9 -0
  39. package/dist/shortcuts/caizhilian/continuation.js +70 -0
  40. package/dist/shortcuts/caizhilian/errors.js +53 -0
  41. package/dist/shortcuts/caizhilian/host.js +190 -0
  42. package/dist/shortcuts/caizhilian/index.js +186 -0
  43. package/dist/shortcuts/caizhilian/manifest.js +42 -0
  44. package/dist/shortcuts/caizhilian/operations/api.js +801 -0
  45. package/dist/shortcuts/caizhilian/operations/confirm.js +75 -0
  46. package/dist/shortcuts/caizhilian/operations/files.js +306 -0
  47. package/dist/shortcuts/caizhilian/operations/form.js +170 -0
  48. package/dist/shortcuts/caizhilian/operations/handlers/collab.js +611 -0
  49. package/dist/shortcuts/caizhilian/operations/handlers/document.js +890 -0
  50. package/dist/shortcuts/caizhilian/operations/handlers/file-collection.js +346 -0
  51. package/dist/shortcuts/caizhilian/operations/handlers/file-upload.js +192 -0
  52. package/dist/shortcuts/caizhilian/operations/handlers/fileops.js +570 -0
  53. package/dist/shortcuts/caizhilian/operations/handlers/folder.js +969 -0
  54. package/dist/shortcuts/caizhilian/operations/handlers/search.js +318 -0
  55. package/dist/shortcuts/caizhilian/operations/handlers/setting-attach.js +294 -0
  56. package/dist/shortcuts/caizhilian/operations/handlers/setting-backup.js +423 -0
  57. package/dist/shortcuts/caizhilian/operations/handlers/setting-encrypt.js +238 -0
  58. package/dist/shortcuts/caizhilian/operations/handlers/setting-storage.js +364 -0
  59. package/dist/shortcuts/caizhilian/operations/handlers/system.js +106 -0
  60. package/dist/shortcuts/caizhilian/operations/registry.js +151 -0
  61. package/dist/shortcuts/caizhilian/operations/shared.js +408 -0
  62. package/dist/shortcuts/caizhilian/operations/specs.js +623 -0
  63. package/dist/shortcuts/caizhilian/operations/types.js +57 -0
  64. package/dist/shortcuts/caizhilian/operations.js +21 -0
  65. package/dist/shortcuts/contract/continuation.js +70 -0
  66. package/dist/shortcuts/contract/errors.js +62 -0
  67. package/dist/shortcuts/contract/host.js +205 -0
  68. package/dist/shortcuts/contract/index.js +318 -0
  69. package/dist/shortcuts/contract/manifest.js +596 -0
  70. package/dist/shortcuts/contract/operations/clause-reference.js +78 -0
  71. package/dist/shortcuts/contract/operations/form-info.js +371 -0
  72. package/dist/shortcuts/contract/operations/read.js +118 -0
  73. package/dist/shortcuts/contract/operations/registry.js +43 -0
  74. package/dist/shortcuts/contract/operations/request.js +300 -0
  75. package/dist/shortcuts/contract/operations/shared.js +133 -0
  76. package/dist/shortcuts/contract/operations/subject.js +157 -0
  77. package/dist/shortcuts/contract/operations/template.js +81 -0
  78. package/dist/shortcuts/contract/operations/types.js +7 -0
  79. package/dist/shortcuts/contract/operations/workflow.js +52 -0
  80. package/dist/shortcuts/contract/operations/write.js +131 -0
  81. package/dist/shortcuts/contract/operations.js +8 -0
  82. package/dist/shortcuts/hrm/index.js +83 -2
  83. package/dist/shortcuts/hrm/operations/employee.js +160 -30
  84. package/dist/shortcuts/hrm/operations/org.js +17 -3
  85. package/dist/shortcuts/hrm/operations/position.js +18 -2
  86. package/dist/shortcuts/index.js +5 -1
  87. package/dist/shortcuts/invoice/index.js +74 -36
  88. package/dist/shortcuts/invoice/manifest.js +674 -4
  89. package/dist/shortcuts/invoice/markdown.js +172 -0
  90. package/dist/shortcuts/invoice/operations/add.js +3 -3
  91. package/dist/shortcuts/invoice/operations/delete.js +2 -2
  92. package/dist/shortcuts/invoice/operations/get.js +10 -2
  93. package/dist/shortcuts/invoice/operations/import.js +2 -2
  94. package/dist/shortcuts/invoice/operations/registry.js +8 -1
  95. package/dist/shortcuts/invoice/operations/reim-auto.js +719 -0
  96. package/dist/shortcuts/invoice/operations/reim.js +85 -2
  97. package/dist/shortcuts/invoice/operations/shared.js +75 -8
  98. package/dist/shortcuts/invoice/operations/update.js +2 -2
  99. package/dist/shortcuts/invoice/operations/upload-and-validate.js +93 -0
  100. package/dist/shortcuts/invoice/operations/validate-preview.js +2 -1
  101. package/dist/shortcuts/invoice/projection.js +328 -0
  102. package/dist/shortcuts/meeting/host.js +18 -1
  103. package/dist/shortcuts/meeting/manifest.js +30 -18
  104. package/dist/shortcuts/meeting/operations/eb/catalog.js +390 -0
  105. package/dist/shortcuts/meeting/operations/eb/conflict.js +389 -0
  106. package/dist/shortcuts/meeting/operations/eb/factory.js +389 -0
  107. package/dist/shortcuts/meeting/operations/eb/index.js +22 -0
  108. package/dist/shortcuts/meeting/operations/env.js +8 -1
  109. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  110. package/dist/shortcuts/meeting/operations/signs.js +216 -2
  111. package/dist/shortcuts/workflow/endpoints.js +2 -1
  112. package/dist/shortcuts/workflow/errors.js +8 -2
  113. package/dist/shortcuts/workflow/host.js +6 -3
  114. package/dist/shortcuts/workflow/operations/form.js +931 -533
  115. package/dist/shortcuts/workflow/operations/read.js +462 -81
  116. package/dist/shortcuts/workflow/operations/shared.js +44 -0
  117. package/dist/shortcuts/workflow/operations/write.js +760 -56
  118. package/dist/shortcuts/workflow/operations.js +36 -10
  119. package/docs/_catalog.md +6 -0
  120. package/docs/agent-invoice.md +5 -1
  121. package/docs/agent-io-channel-design.md +468 -0
  122. package/docs/agent-skill-install.md +9 -4
  123. package/docs/blog.md +123 -0
  124. package/docs/caizhilian.md +304 -0
  125. package/docs/contract.md +91 -0
  126. package/docs/e10-auth.md +2 -2
  127. package/docs/hrm.md +19 -9
  128. package/docs/invoice.md +5 -1
  129. package/docs/meeting.md +1 -1
  130. package/docs/operation-manual.md +15 -3
  131. package/docs/skill-review-2026-09-19.md +2 -2
  132. package/package.json +2 -2
  133. package/scripts/package-skill.mjs +33 -20
  134. package/skill-template/business-info.json +113 -14
  135. package/skill-template/domains/blog.md +24 -0
  136. package/skill-template/domains/caizhilian.md +22 -0
  137. package/skill-template/domains/jinchengda.md +23 -0
  138. package/skill-template/domains/meeting.md +1 -1
  139. package/skill-template/domains/workflow.md +1 -1
  140. package/skill-template/skill-template.md +1 -1
  141. package/skills/weaver-e10-blog/SKILL.md +111 -0
  142. package/skills/weaver-e10-blog/references/blog-comment.md +51 -0
  143. package/skills/weaver-e10-blog/references/blog-comments.md +39 -0
  144. package/skills/weaver-e10-blog/references/blog-default-permission.md +38 -0
  145. package/skills/weaver-e10-blog/references/blog-disabled-capabilities.md +11 -0
  146. package/skills/weaver-e10-blog/references/blog-edit.md +51 -0
  147. package/skills/weaver-e10-blog/references/blog-export.md +42 -0
  148. package/skills/weaver-e10-blog/references/blog-like.md +50 -0
  149. package/skills/weaver-e10-blog/references/blog-publish.md +52 -0
  150. package/skills/weaver-e10-blog/references/blog-query-user.md +45 -0
  151. package/skills/weaver-e10-blog/references/blog-query.md +49 -0
  152. package/skills/weaver-e10-blog/references/blog-remind.md +51 -0
  153. package/skills/weaver-e10-blog/references/blog-resolve-users.md +38 -0
  154. package/skills/weaver-e10-blog/references/source-manifest.json +1540 -0
  155. package/skills/weaver-e10-caizhilian/SKILL.md +216 -0
  156. package/skills/weaver-e10-caizhilian/references/agent-entry.md +106 -0
  157. package/skills/weaver-e10-caizhilian/references/collaboration.md +112 -0
  158. package/skills/weaver-e10-caizhilian/references/document.md +111 -0
  159. package/skills/weaver-e10-caizhilian/references/file-collection.md +136 -0
  160. package/skills/weaver-e10-caizhilian/references/file-upload.md +309 -0
  161. package/skills/weaver-e10-caizhilian/references/files.md +120 -0
  162. package/skills/weaver-e10-caizhilian/references/folder.md +118 -0
  163. package/skills/weaver-e10-caizhilian/references/org-browser.md +104 -0
  164. package/skills/weaver-e10-caizhilian/references/setting-attach.md +410 -0
  165. package/skills/weaver-e10-caizhilian/references/setting-backup.md +372 -0
  166. package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +399 -0
  167. package/skills/weaver-e10-caizhilian/references/setting-storage.md +603 -0
  168. package/skills/weaver-e10-caizhilian/references/source-manifest.json +5079 -0
  169. package/skills/weaver-e10-caizhilian/references/withheld.md +93 -0
  170. package/skills/weaver-e10-caizhilian/references/write-protocol.md +120 -0
  171. package/skills/weaver-e10-calendar/SKILL.md +4 -3
  172. package/skills/weaver-e10-ebuilder-form/SKILL.md +4 -9
  173. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +0 -9
  174. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -5
  175. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +1 -5
  176. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +1 -5
  177. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +1 -5
  178. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -5
  179. package/skills/weaver-e10-esb/SKILL.md +2 -2
  180. package/skills/weaver-e10-esb/references/source-manifest.json +9 -9
  181. package/skills/weaver-e10-hrm/SKILL.md +54 -6
  182. package/skills/weaver-e10-hrm/references/employee.md +89 -15
  183. package/skills/weaver-e10-hrm/references/org.md +7 -4
  184. package/skills/weaver-e10-hrm/references/position.md +14 -7
  185. package/skills/weaver-e10-hrm/references/source-manifest.json +1 -1
  186. package/skills/weaver-e10-jinchengda/SKILL.md +166 -0
  187. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +82 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +69 -0
  189. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +78 -0
  190. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +27 -0
  191. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +71 -0
  192. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +94 -0
  193. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +89 -0
  194. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +77 -0
  195. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +66 -0
  196. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +94 -0
  197. package/skills/weaver-e10-jinchengda/references/source-manifest.json +259 -0
  198. package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -11
  199. package/skills/weaver-e10-jucailin/SKILL.md +4 -3
  200. package/skills/weaver-e10-mail/SKILL.md +4 -11
  201. package/skills/weaver-e10-meeting/SKILL.md +66 -32
  202. package/skills/weaver-e10-meeting/references/meeting-change.md +5 -2
  203. package/skills/weaver-e10-meeting/references/meeting-create.md +2 -1
  204. package/skills/weaver-e10-meeting/references/meeting-eb.md +114 -0
  205. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +9 -8
  206. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +35 -7
  207. package/skills/weaver-e10-meeting/references/meeting-update.md +1 -1
  208. package/skills/weaver-e10-okr/SKILL.md +6 -11
  209. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  210. package/skills/weaver-e10-plan/SKILL.md +3 -3
  211. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +1 -1
  212. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +1 -1
  213. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  214. package/skills/weaver-e10-qiyecheng/SKILL.md +4 -10
  215. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  216. package/skills/weaver-e10-shared/SKILL.md +36 -25
  217. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +10 -31
  218. package/skills/weaver-e10-shared/references/json-output-contract.md +20 -11
  219. package/skills/weaver-e10-shijingran/SKILL.md +2 -1
  220. package/skills/weaver-e10-shijingran/references/source-manifest.json +9 -9
  221. package/skills/weaver-e10-skill-maker/SKILL.md +4 -10
  222. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +5 -3
  223. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +12 -27
  224. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +17 -5
  225. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +4 -27
  226. package/skills/weaver-e10-wenshuding/SKILL.md +5 -16
  227. package/skills/weaver-e10-wenshuding/references/source-manifest.json +7 -7
  228. package/skills/weaver-e10-workflow/SKILL.md +32 -37
  229. package/skills/weaver-e10-workflow/references/source-manifest.json +40 -77
  230. package/skills/weaver-e10-workflow/references/workflow-batch.md +90 -29
  231. package/skills/weaver-e10-workflow/references/workflow-create.md +79 -109
  232. package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -9
  233. package/skills/weaver-e10-workflow/references/workflow-operate.md +2 -2
  234. package/skills/weaver-e10-workflow/references/workflow-query.md +37 -20
  235. package/skills/weaver-e10-workflow/references/workflow-share.md +18 -2
  236. package/skills/weaver-e10-workflow/references/workflow-view.md +4 -4
  237. package/skills/weaver-e10-yepiaotong/SKILL.md +75 -39
  238. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +22 -1
  239. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +3 -1
  240. package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +5 -5
  241. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +135 -0
  242. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +15 -3
  243. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  244. package/skills/weaver-e10-yepiaotong/references/invoice-summarize.py +217 -0
  245. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +88 -0
  246. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +7 -2
  247. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +90 -10
  248. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -0
  249. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +70 -49
  250. package/skills/weaver-e10-yepiaotong/references/reim-fast-path.md +119 -0
  251. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +55 -36
  252. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +4 -0
  253. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +149 -0
  254. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +125 -5
  255. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +430 -63
  256. package/skills/weaver-e10-yimiaoban/SKILL.md +4 -12
  257. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
  258. package/skills/weaver-e10-ziguanjia/SKILL.md +2 -1
  259. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +3 -3
  260. package/tools/weaver-skill-detector-1.0.13/SKILL.md +9 -9
  261. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +3 -3
  262. package/tools/weaver-skill-detector-1.0.13/scripts/__pycache__/validate_skill.cpython-313.pyc +0 -0
  263. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +98 -91
  264. package/scripts/sync-connector-skills.mjs +0 -172
@@ -1,4 +1,6 @@
1
+ import { caizhilianShortcut } from './caizhilian/index.js';
1
2
  import { projectShortcut } from './project/index.js';
3
+ import { blogShortcut } from './blog/index.js';
2
4
  import { archiveShortcut } from './archive/index.js';
3
5
  import { calendarShortcut } from './calendar/index.js';
4
6
  import { ehrShortcut } from './ehr/index.js';
@@ -32,5 +34,7 @@ export const builtinShortcuts = [
32
34
  assetShortcut,
33
35
  imShortcut,
34
36
  projectShortcut,
35
- workflowShortcut
37
+ workflowShortcut,
38
+ blogShortcut,
39
+ caizhilianShortcut
36
40
  ];
@@ -4,6 +4,8 @@ import { createInvoiceContinuationSigner } from './continuation.js';
4
4
  import { createInvoiceHost } from './host.js';
5
5
  import { invoiceManifest } from './manifest.js';
6
6
  import { executeInvoiceOperation } from './operations.js';
7
+ import { normalizeFields, normalizeView, formatFrom, assertProjectionSupported, applyInvoiceProjection, } from './projection.js';
8
+ import { renderInvoiceMarkdown } from './markdown.js';
7
9
  import { invoiceValidationError } from './errors.js';
8
10
  function asOptions(value) {
9
11
  return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
@@ -57,6 +59,32 @@ function withJsonInputOptions(command) {
57
59
  .option('--input-json <json>', 'inline JSON input object');
58
60
  return command;
59
61
  }
62
+ /**
63
+ * 输出投影选项:让调用方一次拿到可读结果,而不必再写脚本解析完整 envelope。
64
+ * `--view summary` 只对 list 类 operation 生效、`--view detail` 只对 invoice.get 生效(见 projection.ts);
65
+ * `--fields` 对所有 operation 生效;`--format markdown` 是渲染档,直接出表格文本(见 markdown.ts)。
66
+ */
67
+ function withOutputOptions(command) {
68
+ command
69
+ .option('--view <mode>', 'output view: full (default), summary (list ops) or detail (invoice.get)')
70
+ .option('--format <mode>', 'output format: json (default) or markdown (human-readable text)')
71
+ .option('--fields <paths>', 'comma-separated dot paths to keep, e.g. number,detailUrl');
72
+ return command;
73
+ }
74
+ function withInvoiceOptions(command) {
75
+ return withOutputOptions(withJsonInputOptions(command));
76
+ }
77
+ function projectionFrom(options) {
78
+ const opts = asOptions(options);
79
+ const view = normalizeView(opts.view);
80
+ const fields = normalizeFields(opts.fields);
81
+ const format = formatFrom(opts.format);
82
+ return {
83
+ ...(view ? { view } : {}),
84
+ ...(fields ? { fields } : {}),
85
+ ...(format ? { format } : {}),
86
+ };
87
+ }
60
88
  function intOption(value) {
61
89
  if (value === undefined || value === null || value === '')
62
90
  return undefined;
@@ -68,13 +96,13 @@ function stringOption(value) {
68
96
  return undefined;
69
97
  return String(value);
70
98
  }
71
- function successEnvelope(operation, result) {
99
+ function successEnvelope(operation, result, meta) {
72
100
  return {
73
101
  schemaVersion: 1,
74
102
  ok: true,
75
103
  operation,
76
104
  data: result.data,
77
- meta: { status: result.status },
105
+ meta: { status: result.status, ...(meta ?? {}) },
78
106
  warnings: [],
79
107
  };
80
108
  }
@@ -87,13 +115,23 @@ function failureEnvelope(error) {
87
115
  error: toErrorEnvelope(error),
88
116
  };
89
117
  }
90
- async function executeAndPrint(ctx, operation, input) {
118
+ async function executeAndPrint(ctx, operation, input, projection = {}) {
91
119
  try {
120
+ assertProjectionSupported(operation, projection);
92
121
  const result = await executeInvoiceOperation(operation, input, {
93
122
  host: createInvoiceHost(ctx),
94
123
  continuation: createInvoiceContinuationSigner(ctx),
95
124
  });
96
- ctx.output.write(successEnvelope(operation, result), { json: true });
125
+ const projected = applyInvoiceProjection(operation, result.data, projection);
126
+ if (projection.format === 'markdown') {
127
+ // 渲染档输出的是文本,不是 envelope:与 --json 混用会让调用方误判输出契约,直接拦住。
128
+ if (ctx.getGlobalOptions().json) {
129
+ throw invoiceValidationError('input_conflict', '--format markdown 与 --json 互斥:markdown 是渲染档(文本),不是 JSON。去掉 --json 再试');
130
+ }
131
+ process.stdout.write(renderInvoiceMarkdown(operation, projected.data));
132
+ return;
133
+ }
134
+ ctx.output.write(successEnvelope(operation, { status: result.status, data: projected.data }, projected.meta), { json: true });
97
135
  }
98
136
  catch (error) {
99
137
  console.error(JSON.stringify(failureEnvelope(error), null, 2));
@@ -111,13 +149,13 @@ export const invoiceShortcut = {
111
149
  .action(action((ctx) => {
112
150
  ctx.output.write(invoiceManifest, { json: true });
113
151
  }));
114
- withJsonInputOptions(invoice.command('run')
152
+ withInvoiceOptions(invoice.command('run')
115
153
  .description('Run an invoice operation with JSON input')
116
154
  .argument('<operation>', 'operation name, e.g. invoice.list'))
117
155
  .action(action(async (ctx, operation, options) => {
118
- await executeAndPrint(ctx, String(operation), await inputFrom(options));
156
+ await executeAndPrint(ctx, String(operation), await inputFrom(options), projectionFrom(options));
119
157
  }));
120
- withJsonInputOptions(invoice.command('list')
158
+ withInvoiceOptions(invoice.command('list')
121
159
  .description('List personal invoice folder entries')
122
160
  .option('--content <keyword>', 'keyword search')
123
161
  .option('--page-size <size>', 'page size')
@@ -130,10 +168,10 @@ export const invoiceShortcut = {
130
168
  page_size: intOption(opts.pageSize),
131
169
  start_pos: intOption(opts.startPos),
132
170
  sreim: stringOption(opts.sreim),
133
- }));
171
+ }), projectionFrom(options));
134
172
  }));
135
173
  const enterprise = invoice.command('enterprise').description('Enterprise invoice folder commands');
136
- withJsonInputOptions(enterprise.command('list')
174
+ withInvoiceOptions(enterprise.command('list')
137
175
  .description('List enterprise invoice folder entries')
138
176
  .option('--content <keyword>', 'keyword search')
139
177
  .option('--page-size <size>', 'page size')
@@ -146,9 +184,9 @@ export const invoiceShortcut = {
146
184
  page_size: intOption(opts.pageSize),
147
185
  start_pos: intOption(opts.startPos),
148
186
  sreim: stringOption(opts.sreim),
149
- }));
187
+ }), projectionFrom(options));
150
188
  }));
151
- withJsonInputOptions(invoice.command('get')
189
+ withInvoiceOptions(invoice.command('get')
152
190
  .description('Get invoice detail by fid or number')
153
191
  .option('--fid <fid>', 'invoice fid')
154
192
  .option('--number <number>', 'invoice number'))
@@ -157,9 +195,9 @@ export const invoiceShortcut = {
157
195
  await executeAndPrint(ctx, 'invoice.get', await inputFrom(options, {
158
196
  fid: opts.fid,
159
197
  number: opts.number,
160
- }));
198
+ }), projectionFrom(options));
161
199
  }));
162
- withJsonInputOptions(invoice.command('upload')
200
+ withInvoiceOptions(invoice.command('upload')
163
201
  .description('Upload an invoice file for OCR')
164
202
  .option('--file <path>', 'local invoice file')
165
203
  .option('--url <url>', 'server-accessible file URL'))
@@ -168,10 +206,10 @@ export const invoiceShortcut = {
168
206
  await executeAndPrint(ctx, 'invoice.upload', await inputFrom(options, {
169
207
  file: opts.file,
170
208
  url: opts.url,
171
- }));
209
+ }), projectionFrom(options));
172
210
  }));
173
211
  const ocr = invoice.command('ocr').description('Invoice OCR commands');
174
- withJsonInputOptions(ocr.command('preview')
212
+ withInvoiceOptions(ocr.command('preview')
175
213
  .description('Preview OCR result without saving an invoice')
176
214
  .option('--file <path>', 'local invoice file')
177
215
  .option('--url <url>', 'server-accessible file URL'))
@@ -180,10 +218,10 @@ export const invoiceShortcut = {
180
218
  await executeAndPrint(ctx, 'invoice.ocr.preview', await inputFrom(options, {
181
219
  file: opts.file,
182
220
  url: opts.url,
183
- }));
221
+ }), projectionFrom(options));
184
222
  }));
185
223
  const validate = invoice.command('validate').description('Invoice validation commands');
186
- withJsonInputOptions(validate.command('preview')
224
+ withInvoiceOptions(validate.command('preview')
187
225
  .description('Validate an existing invoice without saving validation result')
188
226
  .option('--fid <fid>', 'invoice fid')
189
227
  .option('--scope <scope>', 'personal or enterprise'))
@@ -192,10 +230,10 @@ export const invoiceShortcut = {
192
230
  await executeAndPrint(ctx, 'invoice.validate.preview', await inputFrom(options, {
193
231
  fid: opts.fid,
194
232
  scope: opts.scope,
195
- }));
233
+ }), projectionFrom(options));
196
234
  }));
197
235
  const importCommand = invoice.command('import').description('Invoice file import commands');
198
- withJsonInputOptions(importCommand.command('prepare')
236
+ withInvoiceOptions(importCommand.command('prepare')
199
237
  .description('Prepare a confirmed invoice file import')
200
238
  .option('--file <path>', 'local invoice file')
201
239
  .option('--validate', 'request validation before import')
@@ -208,9 +246,9 @@ export const invoiceShortcut = {
208
246
  file: opts.file,
209
247
  validate: typeof opts.validate === 'boolean' ? opts.validate : undefined,
210
248
  syncToOa: typeof opts.syncToOa === 'boolean' ? opts.syncToOa : undefined,
211
- }));
249
+ }), projectionFrom(options));
212
250
  }));
213
- withJsonInputOptions(importCommand.command('apply')
251
+ withInvoiceOptions(importCommand.command('apply')
214
252
  .description('Apply a prepared invoice file import')
215
253
  .option('--file <path>', 'local invoice file')
216
254
  .option('--continuation <token>', 'continuation token from prepare')
@@ -221,17 +259,17 @@ export const invoiceShortcut = {
221
259
  file: opts.file,
222
260
  continuation: opts.continuation,
223
261
  confirm: opts.yes === true ? true : undefined,
224
- }));
262
+ }), projectionFrom(options));
225
263
  }));
226
264
  const add = invoice.command('add').description('Manual invoice add commands');
227
- withJsonInputOptions(add.command('prepare')
265
+ withInvoiceOptions(add.command('prepare')
228
266
  .description('Prepare a confirmed manual invoice add')
229
267
  .option('--scope <scope>', 'personal or enterprise'))
230
268
  .action(action(async (ctx, options) => {
231
269
  const opts = asOptions(options);
232
- await executeAndPrint(ctx, 'invoice.add.prepare', await inputFrom(options, { scope: opts.scope }));
270
+ await executeAndPrint(ctx, 'invoice.add.prepare', await inputFrom(options, { scope: opts.scope }), projectionFrom(options));
233
271
  }));
234
- withJsonInputOptions(add.command('apply')
272
+ withInvoiceOptions(add.command('apply')
235
273
  .description('Apply a prepared manual invoice add')
236
274
  .option('--continuation <token>', 'continuation token from prepare')
237
275
  .option('--yes', 'confirm the write operation'))
@@ -240,10 +278,10 @@ export const invoiceShortcut = {
240
278
  await executeAndPrint(ctx, 'invoice.add.apply', await inputFrom(options, {
241
279
  continuation: opts.continuation,
242
280
  confirm: opts.yes === true ? true : undefined,
243
- }));
281
+ }), projectionFrom(options));
244
282
  }));
245
283
  const update = invoice.command('update').description('Invoice update commands');
246
- withJsonInputOptions(update.command('prepare')
284
+ withInvoiceOptions(update.command('prepare')
247
285
  .description('Prepare an invoice update')
248
286
  .option('--fid <fid>', 'invoice fid')
249
287
  .option('--scope <scope>', 'personal or enterprise'))
@@ -252,9 +290,9 @@ export const invoiceShortcut = {
252
290
  await executeAndPrint(ctx, 'invoice.update.prepare', await inputFrom(options, {
253
291
  fid: opts.fid,
254
292
  scope: opts.scope,
255
- }));
293
+ }), projectionFrom(options));
256
294
  }));
257
- withJsonInputOptions(update.command('apply')
295
+ withInvoiceOptions(update.command('apply')
258
296
  .description('Apply a prepared invoice update')
259
297
  .option('--continuation <token>', 'continuation token from prepare')
260
298
  .option('--yes', 'confirm the write operation'))
@@ -263,9 +301,9 @@ export const invoiceShortcut = {
263
301
  await executeAndPrint(ctx, 'invoice.update.apply', await inputFrom(options, {
264
302
  continuation: opts.continuation,
265
303
  confirm: opts.yes === true ? true : undefined,
266
- }));
304
+ }), projectionFrom(options));
267
305
  }));
268
- withJsonInputOptions(invoice.command('download')
306
+ withInvoiceOptions(invoice.command('download')
269
307
  .description('Download an invoice attachment after verifying ownership')
270
308
  .option('--fid <fid>', 'invoice fid')
271
309
  .option('--file-id <id>', 'invoice file id')
@@ -276,10 +314,10 @@ export const invoiceShortcut = {
276
314
  fid: opts.fid,
277
315
  fileId: opts.fileId,
278
316
  output: opts.output,
279
- }));
317
+ }), projectionFrom(options));
280
318
  }));
281
319
  const del = invoice.command('delete').description('Invoice delete commands');
282
- withJsonInputOptions(del.command('prepare')
320
+ withInvoiceOptions(del.command('prepare')
283
321
  .description('Prepare an invoice soft delete')
284
322
  .option('--fid <fid>', 'invoice fid')
285
323
  .option('--scope <scope>', 'personal or enterprise'))
@@ -288,9 +326,9 @@ export const invoiceShortcut = {
288
326
  await executeAndPrint(ctx, 'invoice.delete.prepare', await inputFrom(options, {
289
327
  fid: opts.fid,
290
328
  scope: opts.scope,
291
- }));
329
+ }), projectionFrom(options));
292
330
  }));
293
- withJsonInputOptions(del.command('apply')
331
+ withInvoiceOptions(del.command('apply')
294
332
  .description('Apply a prepared invoice soft delete')
295
333
  .option('--continuation <token>', 'continuation token from prepare')
296
334
  .option('--yes', 'confirm the write operation'))
@@ -299,7 +337,7 @@ export const invoiceShortcut = {
299
337
  await executeAndPrint(ctx, 'invoice.delete.apply', await inputFrom(options, {
300
338
  continuation: opts.continuation,
301
339
  confirm: opts.yes === true ? true : undefined,
302
- }));
340
+ }), projectionFrom(options));
303
341
  }));
304
342
  },
305
343
  };