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,172 @@
1
+ import { invoiceValidationError } from './errors.js';
2
+ export const OUTPUT_FORMATS = ['json', 'markdown'];
3
+ /** 支持 markdown 渲染的 operation 及其固定视图(渲染档自带字段口径)。 */
4
+ const MARKDOWN_VIEWS = {
5
+ 'invoice.list': 'summary',
6
+ 'invoice.enterprise.list': 'summary',
7
+ 'invoice.get': 'detail',
8
+ };
9
+ export const MARKDOWN_OPERATIONS = new Set(Object.keys(MARKDOWN_VIEWS));
10
+ export function normalizeFormat(value) {
11
+ if (value === undefined || value === null || value === '')
12
+ return undefined;
13
+ const format = String(value).trim();
14
+ if (!OUTPUT_FORMATS.includes(format)) {
15
+ throw invoiceValidationError('format_invalid', `--format 只支持 ${OUTPUT_FORMATS.join(' / ')}`);
16
+ }
17
+ return format;
18
+ }
19
+ /** 该 operation 在 markdown 档下使用的语义视图。 */
20
+ export function markdownViewFor(operation) {
21
+ const view = MARKDOWN_VIEWS[operation];
22
+ if (!view) {
23
+ throw invoiceValidationError('format_unsupported', `${operation} 不支持 --format markdown(仅 ${[...MARKDOWN_OPERATIONS].join('、')})`);
24
+ }
25
+ return view;
26
+ }
27
+ export function assertMarkdownSupported(operation, format) {
28
+ if (format === 'markdown')
29
+ markdownViewFor(operation);
30
+ }
31
+ function text(value) {
32
+ if (value === undefined || value === null)
33
+ return '';
34
+ return String(value).replace(/^\uFEFF/u, '').trim();
35
+ }
36
+ /** markdown 表格里不能出现裸 `|` 和换行,否则列会错位。 */
37
+ function cell(value, fallback = '—') {
38
+ const raw = text(value);
39
+ if (!raw)
40
+ return fallback;
41
+ return raw.replace(/\|/gu, '\\|').replace(/\r?\n/gu, ' ');
42
+ }
43
+ /** 金额统一带千分位与两位小数;非数值原样返回,缺值给 `—`。 */
44
+ function money(value) {
45
+ const raw = text(value);
46
+ if (!raw)
47
+ return '—';
48
+ const num = Number(raw);
49
+ if (!Number.isFinite(num))
50
+ return raw;
51
+ const [int, frac = ''] = Math.abs(num).toFixed(2).split('.');
52
+ return `${num < 0 ? '-' : ''}¥${int.replace(/\B(?=(\d{3})+(?!\d))/gu, ',')}.${frac}`;
53
+ }
54
+ function shortType(value) {
55
+ const raw = text(value);
56
+ if (!raw)
57
+ return '—';
58
+ if (raw.includes('专用'))
59
+ return '专票';
60
+ if (raw.includes('普通'))
61
+ return '普票';
62
+ return raw;
63
+ }
64
+ function scopeLabel(scope) {
65
+ if (scope === 'enterprise')
66
+ return '企业票夹';
67
+ if (scope === 'personal')
68
+ return '个人票夹';
69
+ return '票夹';
70
+ }
71
+ function reimCell(item) {
72
+ const requests = Array.isArray(item.reimRequests) ? item.reimRequests.filter(Boolean) : [];
73
+ if (!requests.length)
74
+ return '未挂单';
75
+ return `已挂单→${requests.map((name) => text(name)).join('、')}`;
76
+ }
77
+ function linkCell(record) {
78
+ const number = text(record.number);
79
+ const url = text(record.detailUrl);
80
+ if (!number)
81
+ return '—';
82
+ return url ? `[${number}](${url})` : number;
83
+ }
84
+ function renderList(operation, data) {
85
+ const items = Array.isArray(data.items) ? data.items : [];
86
+ const lines = [];
87
+ const scope = operation === 'invoice.enterprise.list' ? 'enterprise' : data.scope;
88
+ const head = [`**${scopeLabel(scope)} · 共 ${text(data.total) || items.length} 张 · 合计 ${money(data.totalAmount)}**`];
89
+ const pageNote = `本页 ${items.length} 条${data.hasMore ? ',还有更多' : ''}`;
90
+ lines.push(`${head[0]}(${pageNote})`);
91
+ if (data.totalAmountExcludingTax !== undefined) {
92
+ lines.push(`不含税合计 ${money(data.totalAmountExcludingTax)}`);
93
+ }
94
+ lines.push('');
95
+ lines.push('| # | 发票号码 | 开票日期 | 票种 | 价税合计 | 购方 | 销方 | 报销 |');
96
+ lines.push('| --- | --- | --- | --- | --- | --- | --- | --- |');
97
+ if (!items.length) {
98
+ lines.push('| — | — | — | — | — | — | — | — |');
99
+ return lines.join('\n');
100
+ }
101
+ items.forEach((item, index) => {
102
+ const record = item && typeof item === 'object' ? item : {};
103
+ lines.push([
104
+ '',
105
+ index + 1,
106
+ linkCell(record),
107
+ cell(record.date),
108
+ shortType(record.typeName),
109
+ money(record.total),
110
+ cell(record.buyer),
111
+ cell(record.payer),
112
+ cell(reimCell(record), '未挂单'),
113
+ '',
114
+ ].join(' | ').trim());
115
+ });
116
+ return lines.join('\n');
117
+ }
118
+ function renderDetail(data) {
119
+ const items = Array.isArray(data.items) ? data.items : [];
120
+ if (!items.length)
121
+ return '未查到发票详情。';
122
+ return items.map((item) => {
123
+ const record = item && typeof item === 'object' ? item : {};
124
+ const numberCell = linkCell(record);
125
+ const title = numberCell === '—' ? (text(record.fid) || '发票') : numberCell;
126
+ const lines = [];
127
+ // 号码本身即详情页入口(title 已带链接),不再单列一行 [打开详情]。
128
+ lines.push(`**${title}** · ${cell(record.typeName, '未知票种')}`);
129
+ lines.push('');
130
+ lines.push('| 项目 | 值 |');
131
+ lines.push('| --- | --- |');
132
+ const rows = [
133
+ // 发票号码/代码放在首两行:票面标识必须出现在「项目」列里,便于核对与复制;
134
+ // 号码带 detailUrl 超链接,点击直达 E10 发票详情页。
135
+ // 数电票(全电发票)没有发票代码,空值按 — 显示,不要伪造。
136
+ ['发票号码', numberCell],
137
+ ['发票代码', cell(record.code)],
138
+ ['开票日期', cell(record.date)],
139
+ ['不含税金额', money(record.amount)],
140
+ ['税额', money(record.taxAmount)],
141
+ ['价税合计', money(record.total)],
142
+ ['销方', cell(record.payer)],
143
+ ['购方', cell(record.buyer)],
144
+ ['费用说明', cell(record.expenseNote)],
145
+ ['开票人', cell(record.issuer)],
146
+ ['查验标记', checkStateText(record.checkState)],
147
+ ['报销', reimCell(record)],
148
+ ['附件', attachmentText(record.attachments)],
149
+ ];
150
+ for (const [label, value] of rows)
151
+ lines.push(`| ${label} | ${value} |`);
152
+ return lines.join('\n');
153
+ }).join('\n\n---\n\n');
154
+ }
155
+ /** `checkState` 是查验标记(0=未做过查验登记),措辞必须与票面 valid 区分开。 */
156
+ function checkStateText(value) {
157
+ if (value === undefined || value === null)
158
+ return '—';
159
+ return Number(value) === 0 ? '未查验(0)' : `已查验(${text(value)})`;
160
+ }
161
+ function attachmentText(attachments) {
162
+ const list = Array.isArray(attachments) ? attachments : [];
163
+ if (!list.length)
164
+ return '无';
165
+ return `${list.length} 个:${list.map((entry) => text(entry?.name) || text(entry?.id) || '未命名').join('、')}`;
166
+ }
167
+ /** 渲染入口:按 operation 选择模板。data 必须是投影后的语义视图。 */
168
+ export function renderInvoiceMarkdown(operation, data) {
169
+ const view = markdownViewFor(operation);
170
+ const body = view === 'detail' ? renderDetail(data) : renderList(operation, data);
171
+ return `${body}\n`;
172
+ }
@@ -16,12 +16,12 @@ export class InvoiceAddPrepareOperation {
16
16
  scope,
17
17
  fingerprint: objectFingerprint(info),
18
18
  identity: identityFingerprint(info),
19
- preview: addPreview(info, scope),
19
+ preview: addPreview(info, scope, session.baseUrl),
20
20
  });
21
21
  return {
22
22
  status: 'AWAITING_CONFIRMATION',
23
23
  data: {
24
- preview: addPreview(info, scope),
24
+ preview: addPreview(info, scope, session.baseUrl),
25
25
  normalizedInfo: info,
26
26
  continuation: continuationToken,
27
27
  expiresInSeconds: 600,
@@ -94,7 +94,7 @@ export class InvoiceAddApplyOperation {
94
94
  throw invoicePartialError('新增后回查的票面身份字段不一致', {
95
95
  fid,
96
96
  result: added,
97
- detail: preview(savedInfo),
97
+ detail: preview(savedInfo, session.baseUrl),
98
98
  workflow: workflow('invoice.add', 'VERIFYING'),
99
99
  }, { stage: 'readback' });
100
100
  }
@@ -4,10 +4,10 @@ export class InvoiceDeletePrepareOperation {
4
4
  name = 'invoice.delete.prepare';
5
5
  async execute(input, { host, continuation }) {
6
6
  const scope = normalizeScope(input.scope || 'personal');
7
+ const session = await host.getSession();
7
8
  const result = await getDetail(input, host);
8
9
  const info = detailInfo(result);
9
- const item = preview(info);
10
- const session = await host.getSession();
10
+ const item = preview(info, session.baseUrl);
11
11
  const continuationToken = await continuation.issue({
12
12
  operation: 'invoice.delete.apply',
13
13
  workflow: workflow('invoice.delete', 'AWAITING_CONFIRMATION'),
@@ -1,7 +1,15 @@
1
- import { getDetail } from './shared.js';
1
+ import { getDetail, invoiceDetailUrl } from './shared.js';
2
2
  export class InvoiceGetOperation {
3
3
  name = 'invoice.get';
4
4
  async execute(input, { host }) {
5
- return { status: 'COMPLETE', data: await getDetail(input, host) };
5
+ const session = await host.getSession();
6
+ const result = await getDetail(input, host);
7
+ const infos = Array.isArray(result?.infos) ? result.infos : [];
8
+ for (const item of infos) {
9
+ const fid = item?.info?.fid ?? item?.info?.id;
10
+ if (fid)
11
+ item.detailUrl = invoiceDetailUrl(session.baseUrl, String(fid));
12
+ }
13
+ return { status: 'COMPLETE', data: result };
6
14
  }
7
15
  }
@@ -131,7 +131,7 @@ export class InvoiceImportApplyOperation {
131
131
  }
132
132
  if (failed.length) {
133
133
  throw invoicePartialError('文件导入部分成功,禁止自动重试整个文件', {
134
- succeeded: verified.map((item) => ({ fid: item.fid, preview: preview(item.info) })),
134
+ succeeded: verified.map((item) => ({ fid: item.fid, preview: preview(item.info, session.baseUrl) })),
135
135
  failed,
136
136
  result,
137
137
  workflow: workflow('invoice.import', 'VERIFYING'),
@@ -140,7 +140,7 @@ export class InvoiceImportApplyOperation {
140
140
  return {
141
141
  status: 'COMPLETE',
142
142
  data: {
143
- imported: verified.map((item) => ({ fid: item.fid, preview: preview(item.info) })),
143
+ imported: verified.map((item) => ({ fid: item.fid, preview: preview(item.info, session.baseUrl) })),
144
144
  validationRequested: lease.options.validate,
145
145
  validationSkipped: !lease.options.validate,
146
146
  syncToOa: lease.options.syncToOa,
@@ -9,9 +9,11 @@ import { InvoiceImportApplyOperation, InvoiceImportPrepareOperation } from './im
9
9
  import { InvoiceIssuingMakeApplyOperation, InvoiceIssuingMakePrepareOperation } from './issuing.js';
10
10
  import { InvoiceListOperation } from './list.js';
11
11
  import { InvoiceOcrPreviewOperation } from './ocr-preview.js';
12
- import { InvoiceReimEmployeeSuperiorsOperation, InvoiceReimFieldSearchOperation, InvoiceReimFileOcrPreviewOperation, InvoiceReimFlowCreateApplyOperation, InvoiceReimFlowCreatePrepareOperation, InvoiceReimFlowUpdateApplyOperation, InvoiceReimFlowUpdatePrepareOperation, InvoiceReimFormStructureOperation, InvoiceReimRequestsListOperation, InvoiceReimRowInfoOperation, InvoiceReimWorkflowResolveOperation, } from './reim.js';
12
+ import { InvoiceReimEmployeeSuperiorsOperation, InvoiceReimFieldSearchOperation, InvoiceReimFileOcrPreviewOperation, InvoiceReimFlowCreateApplyOperation, InvoiceReimFlowCreatePrepareOperation, InvoiceReimFlowUpdateApplyOperation, InvoiceReimFlowUpdatePrepareOperation, InvoiceReimFormStructureOperation, InvoiceReimRequestsListOperation, InvoiceReimRowInfoBatchOperation, InvoiceReimRowInfoOperation, InvoiceReimWorkflowResolveOperation, } from './reim.js';
13
+ import { InvoiceReimCandidatesListOperation, InvoiceReimFlowCreateAutoPrepareOperation, InvoiceReimTemplateBuildOperation, } from './reim-auto.js';
13
14
  import { InvoiceUpdateApplyOperation, InvoiceUpdatePrepareOperation } from './update.js';
14
15
  import { InvoiceUploadOperation } from './upload.js';
16
+ import { InvoiceUploadAndValidateOperation } from './upload-and-validate.js';
15
17
  import { InvoiceValidatePreviewOperation } from './validate-preview.js';
16
18
  function buildRegistry() {
17
19
  const registry = new Map();
@@ -22,6 +24,7 @@ function buildRegistry() {
22
24
  new InvoiceUploadOperation(),
23
25
  new InvoiceOcrPreviewOperation(),
24
26
  new InvoiceValidatePreviewOperation(),
27
+ new InvoiceUploadAndValidateOperation(),
25
28
  new InvoiceImportPrepareOperation(),
26
29
  new InvoiceImportApplyOperation(),
27
30
  new InvoiceAddPrepareOperation(),
@@ -35,8 +38,12 @@ function buildRegistry() {
35
38
  new InvoiceReimFileOcrPreviewOperation(),
36
39
  new InvoiceReimRequestsListOperation(),
37
40
  new InvoiceReimWorkflowResolveOperation(),
41
+ new InvoiceReimCandidatesListOperation(),
42
+ new InvoiceReimTemplateBuildOperation(),
43
+ new InvoiceReimFlowCreateAutoPrepareOperation(),
38
44
  new InvoiceReimFormStructureOperation(),
39
45
  new InvoiceReimRowInfoOperation(),
46
+ new InvoiceReimRowInfoBatchOperation(),
40
47
  new InvoiceReimEmployeeSuperiorsOperation(),
41
48
  new InvoiceReimFieldSearchOperation(),
42
49
  new InvoiceReimFlowCreatePrepareOperation(),