weaver-work-cli 0.1.73 → 0.1.76

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 (363) hide show
  1. package/README.md +37 -1
  2. package/dist/chunks/{archive-THZV4ND4.js → archive-ENBSUMHV.js} +14 -9
  3. package/dist/chunks/{archive-oa-PQ23OLEV.js → archive-oa-7BFPQ6M5.js} +10 -7
  4. package/dist/chunks/{asset-RGPROZYH.js → asset-V5SUD3PW.js} +10 -7
  5. package/dist/chunks/{asset-idle-Z2PDX7NA.js → asset-idle-3CEL7WFX.js} +7 -4
  6. package/dist/chunks/{attachment-content-R3RPVOYE.js → attachment-content-24RL44SE.js} +3 -3
  7. package/dist/chunks/{blog-7U3QZPIF.js → blog-FLI4SS3P.js} +10 -7
  8. package/dist/chunks/{caizhilian-3AB42GCV.js → caizhilian-7WCTKCCP.js} +10 -7
  9. package/dist/chunks/{calendar-KINM64E4.js → calendar-G726HUUH.js} +10 -7
  10. package/dist/chunks/chunk-257JXJGD.js +30 -0
  11. package/dist/chunks/chunk-2BZ7TY4M.js +49 -0
  12. package/dist/chunks/{chunk-4BXR6CNB.js → chunk-2KW7AI6P.js} +2 -2
  13. package/dist/chunks/{chunk-WM33BSIL.js → chunk-2QCCXPNU.js} +1 -1
  14. package/dist/chunks/chunk-2UV4IZIT.js +473 -0
  15. package/dist/chunks/{chunk-R3MK2RBN.js → chunk-5E2FDXBU.js} +1 -1
  16. package/dist/chunks/{chunk-DRUND2PJ.js → chunk-5QUTQHXF.js} +225 -152
  17. package/dist/chunks/chunk-7DE3VMZD.js +35 -0
  18. package/dist/chunks/{chunk-PAFOLIYQ.js → chunk-AZC53XSQ.js} +1 -1
  19. package/dist/chunks/{chunk-6HT73VOI.js → chunk-BWFCTE43.js} +2 -2
  20. package/dist/chunks/{chunk-4YXAK6OA.js → chunk-FEZK536Z.js} +12 -7
  21. package/dist/chunks/{chunk-IU6UB2TD.js → chunk-FPWCCRKT.js} +48 -6
  22. package/dist/chunks/{chunk-LLCMOZ5L.js → chunk-H6N6U2D6.js} +11 -11
  23. package/dist/chunks/{chunk-54ST55IJ.js → chunk-JJONWB5N.js} +11 -1
  24. package/dist/chunks/{chunk-GWJLAF6B.js → chunk-JWF2R6EQ.js} +0 -462
  25. package/dist/chunks/chunk-KINXYJXM.js +205 -0
  26. package/dist/chunks/{chunk-F4HM25K4.js → chunk-KJA7CRES.js} +1 -1
  27. package/dist/chunks/chunk-L5SCNJKX.js +1166 -0
  28. package/dist/chunks/{chunk-TV46Q4NY.js → chunk-MS7MKBGJ.js} +74 -68
  29. package/dist/chunks/{chunk-XZBYRYWX.js → chunk-NZQRW4KL.js} +2 -2
  30. package/dist/chunks/chunk-OJ4JPD25.js +428 -0
  31. package/dist/chunks/chunk-OVTCWLNQ.js +1346 -0
  32. package/dist/chunks/{chunk-NUP4RYZK.js → chunk-PMRNIGKZ.js} +2 -2
  33. package/dist/chunks/{chunk-2CHGUYMG.js → chunk-Q7RXCK2Y.js} +4 -4
  34. package/dist/chunks/{chunk-AMAPQVBT.js → chunk-QVKRNL7L.js} +286 -305
  35. package/dist/chunks/{chunk-7QFVXP2X.js → chunk-R4PN3OFK.js} +8 -7
  36. package/dist/chunks/{chunk-L7TYG5SN.js → chunk-RVEKGVZU.js} +2 -2
  37. package/dist/chunks/{chunk-2XED2FKY.js → chunk-SQFKBWTR.js} +38 -36
  38. package/dist/chunks/chunk-SU6IJD6D.js +49 -0
  39. package/dist/chunks/{chunk-IBSJJGXL.js → chunk-T7HVQ2WP.js} +2 -2
  40. package/dist/chunks/{chunk-ZWLWXHJC.js → chunk-TBCKK6LH.js} +2 -2
  41. package/dist/chunks/{chunk-JMJBPP4B.js → chunk-UDBQJLQF.js} +2 -2
  42. package/dist/chunks/chunk-UUJK76HV.js +209 -0
  43. package/dist/chunks/{chunk-4I26YMBY.js → chunk-WHI6YAUE.js} +7 -3
  44. package/dist/chunks/{chunk-BWYVS62Z.js → chunk-WJQJ7YEX.js} +4 -4
  45. package/dist/chunks/{chunk-GAMGDNTF.js → chunk-XNN5PZTI.js} +1 -1
  46. package/dist/chunks/chunk-Y3C6MDL7.js +28 -0
  47. package/dist/chunks/chunk-ZM7RN2IM.js +38 -0
  48. package/dist/chunks/cli-DFLV57LO.js +226 -0
  49. package/dist/chunks/commands-J52MJ6NF.js +70 -0
  50. package/dist/chunks/{conflict-VPAR7E6F.js → conflict-72Q6DM4I.js} +2 -2
  51. package/dist/chunks/{contract-DDXAO2DZ.js → contract-IRNRQ5FY.js} +12446 -5964
  52. package/dist/chunks/{cowork-34QCHMDD.js → cowork-GZDODGKF.js} +11 -8
  53. package/dist/chunks/{create-flow-52PU2OBI.js → create-flow-UGTDI7SP.js} +6 -6
  54. package/dist/chunks/{data-CLQ62QGD.js → data-HTQZRPPI.js} +6 -3
  55. package/dist/chunks/{ebuilder-form-W5R7Q22S.js → ebuilder-form-GHNIZ7ET.js} +9 -6
  56. package/dist/chunks/{ehr-LCNAVMK5.js → ehr-PHIBBUIG.js} +23 -16
  57. package/dist/chunks/{entry-mode-6Z3ZV3DE.js → entry-mode-5WOXFE67.js} +3 -3
  58. package/dist/chunks/{env-RDKWAARB.js → env-H4ALHESA.js} +2 -2
  59. package/dist/chunks/{esb-ANKPUU65.js → esb-ATRKVHCD.js} +10 -7
  60. package/dist/chunks/{factory-434B7RAT.js → factory-COX6AVK7.js} +1 -1
  61. package/dist/chunks/{fna-AKBSG5HI.js → fna-IKYI3SST.js} +13 -8
  62. package/dist/chunks/{group-chat-PROTW22R.js → group-chat-ZIWQQO4G.js} +3 -3
  63. package/dist/chunks/{host-5R2SNFWD.js → host-6UOXYOOY.js} +6 -3
  64. package/dist/chunks/{host-7FJW4E7R.js → host-EJSJSLVK.js} +6 -3
  65. package/dist/chunks/{host-WO4L5G5I.js → host-EYNLB6S4.js} +6 -3
  66. package/dist/chunks/{host-PDJAKCT7.js → host-OT4KNR3G.js} +6 -3
  67. package/dist/chunks/{host-CGXUFQO4.js → host-UY4LQPN4.js} +6 -3
  68. package/dist/chunks/{host-XIYG4F4B.js → host-XXGDQM7D.js} +6 -3
  69. package/dist/chunks/{hrm-WGODDTEH.js → hrm-5JQ7QZ6A.js} +8 -5
  70. package/dist/chunks/{im-YKTKAJU3.js → im-2YJW3EI5.js} +7 -4
  71. package/dist/chunks/{invoice-PVYCCCVM.js → invoice-37HR6L3W.js} +956 -566
  72. package/dist/chunks/{jiuchuanhui-RKOQW7BY.js → jiuchuanhui-KBWUZ7WT.js} +17 -10
  73. package/dist/chunks/{lazy-dispatch-DW45AFQ5.js → lazy-dispatch-MZ3EZYDL.js} +22 -8
  74. package/dist/chunks/{mail-BNB5S4NW.js → mail-YBKUM6HM.js} +11 -8
  75. package/dist/chunks/{meeting-O2KDJH66.js → meeting-XE6CTXYA.js} +22 -18
  76. package/dist/chunks/{minute-doc-JUCG56GY.js → minute-doc-4BA2R5EA.js} +4 -4
  77. package/dist/chunks/{okr-LWFGWOE7.js → okr-HW7IULIR.js} +10 -7
  78. package/dist/chunks/{operations-532PN5OB.js → operations-4P2UYVLH.js} +7 -4
  79. package/dist/chunks/{performance-7W5COCFU.js → performance-PM2G6L3E.js} +6 -3
  80. package/dist/chunks/{plan-ZVY3IYTL.js → plan-3YYGZ7ZM.js} +10 -7
  81. package/dist/chunks/{project-SA62B7MH.js → project-XREEXFU2.js} +10 -7
  82. package/dist/chunks/{reception-NGIONPQ3.js → reception-7G3J2MA6.js} +8 -4
  83. package/dist/chunks/{recruit-stage-WOSN6MGP.js → recruit-stage-TSQWOGQD.js} +199 -74
  84. package/dist/chunks/register-SQOPIR2G.js +16 -0
  85. package/dist/chunks/{registry-N7P3W2RD.js → registry-3VTB3KLV.js} +7 -4
  86. package/dist/chunks/registry-7UDUWYB5.js +30 -0
  87. package/dist/chunks/{registry-R72GWXOG.js → registry-F4YFZLOD.js} +7 -3
  88. package/dist/chunks/{room-recommend-KCGIVUFR.js → room-recommend-FO3HLPNB.js} +4 -4
  89. package/dist/chunks/root-YZG2TS5W.js +16 -0
  90. package/dist/chunks/{schedule-6UP27HQ4.js → schedule-DHNNOHVS.js} +4 -4
  91. package/dist/chunks/{smart-extract-DDOQSPRB.js → smart-extract-T5Z4AULN.js} +15 -7
  92. package/dist/chunks/update-AV5VOXGY.js +13 -0
  93. package/dist/chunks/{workflow-V5ALD6QZ.js → workflow-MAGCHWYZ.js} +15 -10
  94. package/dist/cli.js +40 -0
  95. package/dist/cmd/action.js +3 -1
  96. package/dist/cmd/doctor/index.js +1 -1
  97. package/dist/cmd/e10/index.js +1 -1
  98. package/dist/cmd/identity/index.js +5 -8
  99. package/dist/cmd/index.js +2 -0
  100. package/dist/cmd/setup/index.js +1 -1
  101. package/dist/cmd/update/index.js +38 -0
  102. package/dist/core/manifest-view.js +1 -1
  103. package/dist/core/output.js +8 -1
  104. package/dist/core/runtime-agent.js +13 -0
  105. package/dist/core/update-notice.js +23 -0
  106. package/dist/index.js +105 -198
  107. package/dist/internal/e10/auth/agent-host-key.js +16 -0
  108. package/dist/internal/e10/auth/agent-hosts.js +45 -9
  109. package/dist/internal/e10/auth/commands.js +66 -36
  110. package/dist/internal/e10/auth/session.js +30 -15
  111. package/dist/internal/e10/auth/xiaoe.js +4 -20
  112. package/dist/internal/e10/auth-recovery.js +44 -4
  113. package/dist/internal/e10/context.js +5 -2
  114. package/dist/internal/update/bootstrap.js +96 -0
  115. package/dist/internal/update/npm.js +78 -0
  116. package/dist/internal/update/service.js +252 -0
  117. package/dist/internal/update/store.js +135 -0
  118. package/dist/shortcuts/archive/index.js +2 -2
  119. package/dist/shortcuts/archive/manifest.js +1 -0
  120. package/dist/shortcuts/archive/operations/search.js +3 -1
  121. package/dist/shortcuts/archive-oa/index.js +1 -1
  122. package/dist/shortcuts/asset/index.js +1 -1
  123. package/dist/shortcuts/asset-idle/index.js +1 -1
  124. package/dist/shortcuts/blog/index.js +1 -1
  125. package/dist/shortcuts/caizhilian/index.js +1 -1
  126. package/dist/shortcuts/calendar/index.js +1 -1
  127. package/dist/shortcuts/contract/data/bi-config.js +156 -0
  128. package/dist/shortcuts/contract/data/collection-ledger-html.js +189 -0
  129. package/dist/shortcuts/contract/data/collection-node-catalog.js +226 -0
  130. package/dist/shortcuts/contract/data/metric-catalog.js +154 -20
  131. package/dist/shortcuts/contract/data/report-renderers.js +414 -0
  132. package/dist/shortcuts/contract/data/report-spec.js +132 -0
  133. package/dist/shortcuts/contract/error-actions.js +114 -0
  134. package/dist/shortcuts/contract/host.js +12 -3
  135. package/dist/shortcuts/contract/index.js +17 -1
  136. package/dist/shortcuts/contract/manifest.js +398 -3
  137. package/dist/shortcuts/contract/ooxml/docx-table.js +48 -0
  138. package/dist/shortcuts/contract/operations/bi-preview.js +131 -0
  139. package/dist/shortcuts/contract/operations/bizreview-report.js +496 -0
  140. package/dist/shortcuts/contract/operations/collection-node.js +229 -0
  141. package/dist/shortcuts/contract/operations/docx-slots.js +735 -16
  142. package/dist/shortcuts/contract/operations/draft-build.js +940 -0
  143. package/dist/shortcuts/contract/operations/draft-submit.js +229 -0
  144. package/dist/shortcuts/contract/operations/first-screen.js +3 -2
  145. package/dist/shortcuts/contract/operations/generated-submit.js +175 -0
  146. package/dist/shortcuts/contract/operations/ledger-report.js +233 -0
  147. package/dist/shortcuts/contract/operations/ledger-stat.js +1400 -0
  148. package/dist/shortcuts/contract/operations/ledger.js +4 -1
  149. package/dist/shortcuts/contract/operations/metrics.js +9 -3
  150. package/dist/shortcuts/contract/operations/ops-draft.js +527 -0
  151. package/dist/shortcuts/contract/operations/page.js +9 -0
  152. package/dist/shortcuts/contract/operations/quote-submit.js +55 -229
  153. package/dist/shortcuts/contract/operations/registry.js +20 -0
  154. package/dist/shortcuts/contract/operations/sign-launch.js +256 -0
  155. package/dist/shortcuts/contract/operations/viewlink.js +334 -0
  156. package/dist/shortcuts/cowork/index.js +2 -2
  157. package/dist/shortcuts/ebuilder-form/index.js +1 -1
  158. package/dist/shortcuts/ehr/index.js +2 -2
  159. package/dist/shortcuts/ehr/manifest.js +1 -1
  160. package/dist/shortcuts/ehr/operations/recruit-position.js +7 -2
  161. package/dist/shortcuts/ehr/operations/recruit-write.js +7 -6
  162. package/dist/shortcuts/ehr/operations/recruit.js +318 -248
  163. package/dist/shortcuts/ehr/operations/shared.js +22 -2
  164. package/dist/shortcuts/esb/index.js +1 -1
  165. package/dist/shortcuts/fna/index.js +1 -1
  166. package/dist/shortcuts/fna/manifest.js +1 -0
  167. package/dist/shortcuts/fna/operations/expense-chart.js +3 -1
  168. package/dist/shortcuts/hrm/index.js +1 -1
  169. package/dist/shortcuts/invoice/business-response.js +13 -0
  170. package/dist/shortcuts/invoice/calendar.js +24 -0
  171. package/dist/shortcuts/invoice/host.js +26 -15
  172. package/dist/shortcuts/invoice/index.js +3 -3
  173. package/dist/shortcuts/invoice/invoice-record.js +7 -2
  174. package/dist/shortcuts/invoice/manifest.js +179 -155
  175. package/dist/shortcuts/invoice/operations/get.js +9 -3
  176. package/dist/shortcuts/invoice/operations/issuing-red-requests.js +138 -0
  177. package/dist/shortcuts/invoice/operations/registry.js +4 -5
  178. package/dist/shortcuts/invoice/operations/reim-auto.js +40 -2
  179. package/dist/shortcuts/invoice/operations/reim-customer-projects.js +79 -0
  180. package/dist/shortcuts/invoice/operations/reim-customer.js +79 -30
  181. package/dist/shortcuts/invoice/operations/reim-relation.js +0 -146
  182. package/dist/shortcuts/invoice/operations/reim.js +2 -126
  183. package/dist/shortcuts/invoice/operations/shared.js +15 -17
  184. package/dist/shortcuts/invoice/preapproval-enrichment.js +180 -0
  185. package/dist/shortcuts/invoice/projection.js +14 -0
  186. package/dist/shortcuts/invoice/read-enrichment.js +123 -0
  187. package/dist/shortcuts/jiuchuanhui/index.js +2 -2
  188. package/dist/shortcuts/jiuchuanhui/manifest.js +3 -0
  189. package/dist/shortcuts/mail/index.js +2 -2
  190. package/dist/shortcuts/meeting/index.js +1 -1
  191. package/dist/shortcuts/meeting/manifest.js +1 -0
  192. package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -3
  193. package/dist/shortcuts/meeting/operations/eb/conflict.js +3 -1
  194. package/dist/shortcuts/meeting/operations/eb/create-flow.js +10 -9
  195. package/dist/shortcuts/meeting/operations/eb/factory.js +2 -0
  196. package/dist/shortcuts/meeting/operations/eb/member-expand.js +3 -2
  197. package/dist/shortcuts/meeting/operations/invitation-publish.js +3 -3
  198. package/dist/shortcuts/meeting/operations/invitation.js +4 -4
  199. package/dist/shortcuts/meeting/operations/link.js +3 -1
  200. package/dist/shortcuts/okr/index.js +1 -1
  201. package/dist/shortcuts/performance/index.js +1 -1
  202. package/dist/shortcuts/plan/index.js +1 -1
  203. package/dist/shortcuts/project/index.js +1 -1
  204. package/dist/shortcuts/reception/manifest.js +2 -2
  205. package/dist/shortcuts/recruit-stage/context.js +10 -2
  206. package/dist/shortcuts/recruit-stage/index.js +16 -3
  207. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +1 -1
  208. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +1 -1
  209. package/dist/shortcuts/recruit-stage/operations/jd-create.js +17 -8
  210. package/dist/shortcuts/recruit-stage/operations/list.js +1 -1
  211. package/dist/shortcuts/recruit-stage/operations/resume-import.js +178 -35
  212. package/dist/shortcuts/recruit-stage/operations/search.js +2 -2
  213. package/dist/shortcuts/recruit-stage/operations/shortlist.js +4 -2
  214. package/dist/shortcuts/recruit-stage/shared.js +27 -53
  215. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  216. package/dist/shortcuts/smart-extract/operations/fill.js +7 -2
  217. package/dist/shortcuts/smart-extract/operations/validate.js +4 -1
  218. package/dist/shortcuts/workflow/index.js +2 -2
  219. package/dist/shortcuts/workflow/manifest.js +1 -0
  220. package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +4 -1
  221. package/dist/shortcuts/workflow/operations/deepRead.js +23 -2
  222. package/dist/shortcuts/workflow/operations/form.js +8 -2
  223. package/docs/agent-invoice.md +28 -2
  224. package/docs/contract.md +6 -1
  225. package/docs/e10-auth.md +25 -7
  226. package/docs/invoice.md +60 -9
  227. package/docs/operation-manual.md +15 -0
  228. package/package.json +2 -2
  229. package/skill-template/business-info.json +28 -0
  230. package/skill-template/domains/jinchengda.md +13 -1
  231. package/skill-template/domains/yepiaotong.md +36 -7
  232. package/skills/weaver-e10-archive-oa/references/source-manifest.json +3 -3
  233. package/skills/weaver-e10-caizhilian/references/auth-and-install.md +2 -1
  234. package/skills/weaver-e10-caizhilian/references/source-manifest.json +3 -3
  235. package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
  236. package/skills/weaver-e10-jinchengda/SKILL.md +90 -32
  237. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +45 -0
  238. package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +68 -0
  239. package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +216 -0
  240. package/skills/weaver-e10-jinchengda/references/contract-clause-negotiate.md +215 -0
  241. package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +113 -0
  242. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +19 -3
  243. package/skills/weaver-e10-jinchengda/references/contract-decisions.md +114 -0
  244. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -44
  245. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +1 -1
  246. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +1 -1
  247. package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +200 -0
  248. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -1
  249. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +138 -3
  250. package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +158 -0
  251. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +3 -1
  252. package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +139 -0
  253. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +2 -2
  254. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +10 -3
  255. package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +106 -0
  256. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
  257. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +176 -56
  258. package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +123 -0
  259. package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +410 -0
  260. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  261. package/skills/weaver-e10-jinchengda/references/contract-viewlink.md +110 -0
  262. package/skills/weaver-e10-jinchengda/references/orchestration.md +38 -24
  263. package/skills/weaver-e10-meeting/SKILL.md +13 -0
  264. package/skills/weaver-e10-okr/SKILL.md +11 -0
  265. package/skills/weaver-e10-okr/references/source-manifest.json +7 -6
  266. package/skills/weaver-e10-performance/SKILL.md +131 -39
  267. package/skills/weaver-e10-performance/agents/openai.yaml +48 -17
  268. package/skills/weaver-e10-performance/references/default-assembly.md +3 -0
  269. package/skills/weaver-e10-performance/references/extraction-guide.md +17 -3
  270. package/skills/weaver-e10-performance/references/flow-assess.md +38 -5
  271. package/skills/weaver-e10-performance/references/scheme-setting-page.md +20 -3
  272. package/skills/weaver-e10-performance/scripts/assemble_scheme.py +461 -0
  273. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +41 -0
  274. package/skills/weaver-e10-plan/SKILL.md +10 -0
  275. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  276. package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
  277. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  278. package/skills/weaver-e10-recruit-stage/SKILL.md +230 -202
  279. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +74 -46
  280. package/skills/weaver-e10-recruit-stage/lib/interview-conflict.mjs +3 -0
  281. package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +201 -36
  282. package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +336 -27
  283. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +3 -0
  284. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +15 -1
  285. package/skills/weaver-e10-recruit-stage/lib/report-attachment.mjs +38 -0
  286. package/skills/weaver-e10-recruit-stage/lib/xiaoe-session.mjs +5 -1
  287. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +4 -0
  288. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +4 -0
  289. package/skills/weaver-e10-recruit-stage/references/position-templates.md +12 -8
  290. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +20 -18
  291. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +11 -7
  292. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +5 -1
  293. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +4 -0
  294. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +8 -4
  295. package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +6 -1
  296. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +7 -3
  297. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +32 -25
  298. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +4 -0
  299. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -0
  300. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +5 -1
  301. package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +4 -0
  302. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +16 -10
  303. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +6 -2
  304. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +148 -40
  305. package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +5 -1
  306. package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +32 -8
  307. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +4 -0
  308. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +8 -4
  309. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +6 -2
  310. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +41 -41
  311. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +7 -3
  312. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +7 -3
  313. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +8 -4
  314. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +5 -1
  315. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +5 -1
  316. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +5 -1
  317. package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +41 -28
  318. package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +23 -26
  319. package/skills/weaver-e10-recruit-stage/templates/match-report.html +44 -36
  320. package/skills/weaver-e10-shared/SKILL.md +40 -5
  321. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +11 -1
  322. package/skills/weaver-e10-shared/references/json-output-contract.md +144 -8
  323. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +11 -0
  324. package/skills/weaver-e10-shijingran/references/source-manifest.json +3 -3
  325. package/skills/weaver-e10-wenshuding/references/source-manifest.json +3 -3
  326. package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
  327. package/skills/weaver-e10-yepiaotong/SKILL.md +133 -61
  328. package/skills/weaver-e10-yepiaotong/references/invoice-add.md +3 -1
  329. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +18 -2
  330. package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +3 -3
  331. package/skills/weaver-e10-yepiaotong/references/invoice-download.md +1 -1
  332. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +13 -1
  333. package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +3 -1
  334. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +6 -4
  335. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +42 -45
  336. package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +1 -1
  337. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +18 -2
  338. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +14 -1
  339. package/skills/weaver-e10-yepiaotong/references/invoice-red-workflow.md +96 -0
  340. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +56 -369
  341. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +16 -6
  342. package/skills/weaver-e10-yepiaotong/references/name-fuzzy-search.md +38 -0
  343. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +163 -646
  344. package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +90 -44
  345. package/skills/weaver-e10-yepiaotong/references/reim-eligibility-rules.md +85 -0
  346. package/skills/weaver-e10-yepiaotong/references/reim-fill-validation.md +61 -0
  347. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +91 -280
  348. package/skills/weaver-e10-yepiaotong/references/reim-preapproval-rules.md +98 -0
  349. package/skills/weaver-e10-yepiaotong/references/reim-travel-invoice-matching.md +48 -0
  350. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +234 -695
  351. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +395 -204
  352. package/skills/weaver-e10-yepiaotong/references/travel-application-fill.md +84 -0
  353. package/skills/weaver-e10-yepiaotong/references/workflow-direct-fill.md +165 -0
  354. package/skills/weaver-e10-yepiaotong.zip +0 -0
  355. package/dist/chunks/chunk-ICP53R52.js +0 -2849
  356. package/dist/chunks/registry-RIQ67ZT7.js +0 -27
  357. package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
  358. package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
  359. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +0 -93
  360. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +0 -774
  361. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +0 -111
  362. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +0 -360
  363. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +0 -167
@@ -0,0 +1,414 @@
1
+ /**
2
+ * 报表渲染层(2026-11-28):五类积木,一套视觉规范。
3
+ *
4
+ * 约定:
5
+ * - 纯字符串拼接,无 JS、无外链;图表是内联 SVG(打印 / file:// 都稳定);
6
+ * - 金额一律「元 + 2 位小数 + 千分位」,率值只带一层 `%`,计数不带后缀;
7
+ * - 率值同比用**百分点**(25.58% vs 87.37% 说「跌 61.79 个百分点」,不是跌 70.72%);
8
+ * - `null` 一律显示「—」,绝不补 0。
9
+ */
10
+ const INK = '#0f172a';
11
+ const MUTED = '#64748b';
12
+ const LINE = '#e2e8f0';
13
+ const ACCENT = '#2563eb';
14
+ const ACCENT_SOFT = '#c7d2fe';
15
+ const UP = '#047857';
16
+ const DOWN = '#b91c1c';
17
+ export const REPORT_STYLE = `
18
+ :root{--ink:${INK};--muted:${MUTED};--line:${LINE};--accent:${ACCENT};--up:${UP};--down:${DOWN}}
19
+ .rp *{box-sizing:border-box}
20
+ .rp{margin:0;padding:32px 20px 56px;background:#f6f8fb;color:var(--ink);
21
+ font:14px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
22
+ font-variant-numeric:tabular-nums;-webkit-font-smoothing:antialiased}
23
+ .rp .wrap{max-width:1040px;margin:0 auto}
24
+ .rp .hd{display:flex;flex-wrap:wrap;align-items:flex-end;gap:12px;margin-bottom:20px}
25
+ .rp .hd h1{flex:1 1 auto;margin:0;font-size:22px;font-weight:650;letter-spacing:-.01em}
26
+ .rp .pill{display:inline-flex;align-items:center;gap:6px;padding:5px 12px;border-radius:999px;
27
+ background:#fff;border:1px solid var(--line);font-size:12.5px;color:var(--muted)}
28
+ .rp .meta{font-size:12.5px;color:var(--muted);margin-bottom:20px}
29
+ .rp .card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:20px 22px 22px;
30
+ margin-bottom:16px;box-shadow:0 1px 2px rgba(15,23,42,.04)}
31
+ .rp .card h2{margin:0 0 4px;font-size:15px;font-weight:650}
32
+ .rp .card .hint{margin:0 0 16px;font-size:12.5px;color:var(--muted)}
33
+ .rp .kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px}
34
+ .rp .kpi{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fcfdff}
35
+ .rp .kpi .k{font-size:12.5px;color:var(--muted);margin-bottom:6px}
36
+ .rp .kpi .n{font-size:24px;font-weight:650;line-height:1.15;letter-spacing:-.02em;white-space:nowrap}
37
+ .rp .kpi .d{margin-top:8px;font-size:12px;color:var(--muted)}
38
+ .rp .chip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:999px;font-size:11.5px;font-weight:600}
39
+ .rp .chip.up{color:var(--up);background:#ecfdf5}
40
+ .rp .chip.down{color:var(--down);background:#fef2f2}
41
+ .rp .chip.flat{color:var(--muted);background:#f1f5f9}
42
+ .rp table{width:100%;border-collapse:separate;border-spacing:0;font-size:13px}
43
+ .rp thead th{text-align:right;font-weight:600;font-size:12px;color:var(--muted);
44
+ padding:0 10px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
45
+ .rp thead th:first-child{text-align:left}
46
+ .rp tbody td{text-align:right;padding:9px 10px;border-bottom:1px solid #f1f5f9;white-space:nowrap}
47
+ .rp tbody td:first-child{text-align:left;color:var(--muted)}
48
+ .rp tbody tr:last-child td{border-bottom:none}
49
+ .rp tbody tr:hover td{background:#f8fafc}
50
+ .rp .strong{font-weight:600;color:var(--ink)}
51
+ .rp .na{color:#cbd5e1}
52
+ .rp .trend{font-size:11.5px;font-weight:600;margin-left:2px}
53
+ .rp .trend.up{color:var(--up)}
54
+ .rp .trend.down{color:var(--down)}
55
+ .rp .trend.flat{color:var(--muted)}
56
+ .rp .chart{width:100%;height:auto;display:block}
57
+ .rp .legend{display:flex;flex-wrap:wrap;gap:16px;font-size:12px;color:var(--muted);margin-top:10px}
58
+ .rp .legend span{display:inline-flex;align-items:center;gap:6px}
59
+ .rp .swatch{width:10px;height:10px;border-radius:3px;display:inline-block}
60
+ .rp .rank{display:flex;flex-direction:column;gap:9px}
61
+ .rp .rank-row{display:grid;grid-template-columns:170px 1fr 128px;align-items:center;gap:12px}
62
+ .rp .rank-name{font-size:12.5px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
63
+ .rp .rank-track{background:#f1f5f9;border-radius:6px;height:18px;overflow:hidden}
64
+ .rp .rank-fill{height:100%;background:var(--accent);border-radius:6px}
65
+ .rp .rank-val{text-align:right;font-size:12.5px;font-weight:600}
66
+ .rp .notes{margin:0;padding-left:18px;font-size:12.5px;color:#475569}
67
+ .rp .notes li{margin-bottom:6px}
68
+ .rp .notes li:last-child{margin-bottom:0}
69
+ .rp .warn{border:1px solid #fed7aa;background:#fff7ed;color:#9a3412;border-radius:12px;padding:12px 16px;
70
+ font-size:12.5px;margin-bottom:16px}
71
+ .rp .warn b{font-weight:650}
72
+ .rp .foot{margin-top:22px;text-align:center;font-size:12px;color:#94a3b8}
73
+ @media print{.rp{background:#fff;padding:0}.rp .card{box-shadow:none;break-inside:avoid}}
74
+ `;
75
+ // ---------------------------------------------------------------- 格式化
76
+ function str(value) {
77
+ return typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';
78
+ }
79
+ /** 只用于纯文本位置,接口原文不二次转义。 */
80
+ export function esc(value) {
81
+ return str(value)
82
+ .replace(/&/gu, '&')
83
+ .replace(/</gu, '&lt;')
84
+ .replace(/>/gu, '&gt;')
85
+ .replace(/"/gu, '&quot;');
86
+ }
87
+ export function formatMoney(value) {
88
+ if (value === null || value === undefined || !Number.isFinite(value))
89
+ return '—';
90
+ const fixed = Number(value).toFixed(2);
91
+ const [integer, decimal] = fixed.split('.');
92
+ const sign = integer.startsWith('-') ? '-' : '';
93
+ const digits = sign ? integer.slice(1) : integer;
94
+ return `${sign}${digits.replace(/\B(?=(\d{3})+(?!\d))/gu, ',')}.${decimal}`;
95
+ }
96
+ export function formatPercent(value) {
97
+ if (value === null || value === undefined || !Number.isFinite(value))
98
+ return '—';
99
+ return `${Number(value).toFixed(2)}%`;
100
+ }
101
+ export function formatCount(value) {
102
+ if (value === null || value === undefined || !Number.isFinite(value))
103
+ return '—';
104
+ return String(Math.round(Number(value)));
105
+ }
106
+ export function formatYoy(pct) {
107
+ if (pct === null || pct === undefined || !Number.isFinite(pct))
108
+ return { text: '同比 —', cls: 'flat' };
109
+ const rounded = Number(Number(pct).toFixed(2));
110
+ if (rounded === 0)
111
+ return { text: '同比 0.00%', cls: 'flat' };
112
+ return { text: `同比 ${rounded > 0 ? '↑' : '↓'} ${Math.abs(rounded).toFixed(2)}%`, cls: rounded > 0 ? 'up' : 'down' };
113
+ }
114
+ export function formatPointDelta(delta) {
115
+ if (delta === null || delta === undefined || !Number.isFinite(delta))
116
+ return { text: '同比 —', cls: 'flat' };
117
+ const rounded = Number(Number(delta).toFixed(2));
118
+ if (rounded === 0)
119
+ return { text: '同比 0.00 个百分点', cls: 'flat' };
120
+ return {
121
+ text: `同比 ${rounded > 0 ? '↑' : '↓'} ${Math.abs(rounded).toFixed(2)} 个百分点`,
122
+ cls: rounded > 0 ? 'up' : 'down',
123
+ };
124
+ }
125
+ function yoyText(aggregation, current, previous, pct) {
126
+ if (aggregation === 'ratio') {
127
+ if (current === null || previous === null)
128
+ return { text: '同比 —', cls: 'flat' };
129
+ return formatPointDelta(current - previous);
130
+ }
131
+ return formatYoy(pct);
132
+ }
133
+ /** 单位:header 用于表头/提示,suffix 用于 KPI(率值不带 suffix,避免 `%%`)。 */
134
+ export function unitOf(aggregation) {
135
+ if (aggregation === 'ratio')
136
+ return { header: '%', value: (v) => formatPercent(v), suffix: '' };
137
+ if (aggregation === 'countDistinct')
138
+ return { header: '家', value: (v) => formatCount(v), suffix: '' };
139
+ return { header: '元', value: (v) => formatMoney(v), suffix: ' 元' };
140
+ }
141
+ /** 坐标轴刻度:按原值加千分位,不折万/亿(口径手册禁止万元折算)。 */
142
+ function axisTick(value) {
143
+ const rounded = Math.round(value);
144
+ const sign = rounded < 0 ? '-' : '';
145
+ return `${sign}${String(Math.abs(rounded)).replace(/\B(?=(\d{3})+(?!\d))/gu, ',')}`;
146
+ }
147
+ function metricOf(data, key) {
148
+ const found = data.metrics.find((metric) => metric.key === key);
149
+ if (!found)
150
+ throw new Error(`指标 ${key} 不在统计数据里`);
151
+ return found;
152
+ }
153
+ function bucketLabel(row) {
154
+ return str(row.month) || str(row.key) || '—';
155
+ }
156
+ function dimensionLabel(data) {
157
+ const dimension = data.window.dimension ?? 'month';
158
+ const grain = data.window.grain ?? 'month';
159
+ if (dimension === 'customer')
160
+ return '客户';
161
+ if (dimension === 'salesman')
162
+ return '销售经理';
163
+ if (dimension === 'date') {
164
+ if (grain === 'day')
165
+ return '日期(签约日)';
166
+ if (grain === 'year')
167
+ return '年度(签约日)';
168
+ return '月份(签约日)';
169
+ }
170
+ return '月份(业绩年月)';
171
+ }
172
+ // ---------------------------------------------------------------- SVG 基础
173
+ const CHART_W = 960;
174
+ const CHART_H = 260;
175
+ const PAD = { top: 14, right: 18, bottom: 30, left: 68 };
176
+ function chartFrame(maxValue, rateMode) {
177
+ const innerW = CHART_W - PAD.left - PAD.right;
178
+ const innerH = CHART_H - PAD.top - PAD.bottom;
179
+ const top = rateMode ? 100 : maxValue || 1;
180
+ const y = (value) => PAD.top + innerH - (value / top) * innerH;
181
+ const ticks = [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
182
+ const value = top * ratio;
183
+ return { y: y(value), label: rateMode ? `${Math.round(value)}%` : axisTick(value) };
184
+ });
185
+ return { y, ticks, innerW, innerH };
186
+ }
187
+ function gridSvg(ticks) {
188
+ return ticks.map((tick) => `
189
+ <line x1="${PAD.left}" y1="${tick.y.toFixed(1)}" x2="${CHART_W - PAD.right}" y2="${tick.y.toFixed(1)}"
190
+ stroke="${LINE}" stroke-width="1" ${tick.label === '0' || tick.label === '0%' ? '' : 'stroke-dasharray="3 4"'} />
191
+ <text x="${PAD.left - 10}" y="${(tick.y + 3.5).toFixed(1)}" text-anchor="end" font-size="10.5" fill="${MUTED}">${esc(tick.label)}</text>`).join('');
192
+ }
193
+ function axisLabels(rows, innerW, rotate) {
194
+ const band = innerW / Math.max(rows.length, 1);
195
+ return rows.map((row, index) => {
196
+ const cx = PAD.left + band * index + band / 2;
197
+ const label = rotate ? bucketLabel(row) : bucketLabel(row).slice(-2);
198
+ return `<text x="${cx.toFixed(1)}" y="${CHART_H - 8}" text-anchor="${rotate ? 'end' : 'middle'}"
199
+ font-size="10.5" fill="${MUTED}"${rotate ? ` transform="rotate(-28 ${cx.toFixed(1)} ${CHART_H - 8})"` : ''}>${esc(label)}</text>`;
200
+ }).join('');
201
+ }
202
+ // ---------------------------------------------------------------- 积木:KPI
203
+ export function renderKpi(data, block) {
204
+ const keys = block.metrics ?? data.metrics.map((metric) => metric.key);
205
+ const compareMode = block.compare ?? data.window.compare;
206
+ const cards = keys.map((key) => {
207
+ const metric = metricOf(data, key);
208
+ const unit = unitOf(metric.aggregation);
209
+ const compareEntry = data.compare[key] ?? { current: null, previous: null, delta: null, pct: null };
210
+ const current = data.totals[key] ?? compareEntry.current ?? null;
211
+ const previous = data.previousTotals[key] ?? compareEntry.previous ?? null;
212
+ const incomplete = (data.incompleteMetrics ?? []).includes(key);
213
+ const yoyInfo = compareMode === 'yoy'
214
+ ? yoyText(metric.aggregation, current, previous, compareEntry.pct ?? null)
215
+ : null;
216
+ const missing = current === null;
217
+ const valueText = missing ? (incomplete ? '不完整' : '—') : `${unit.value(current)}${unit.suffix}`;
218
+ const chip = missing
219
+ ? '<span class="chip flat">不可用</span>'
220
+ : yoyInfo
221
+ ? `<span class="chip ${yoyInfo.cls}">${esc(yoyInfo.text.replace('同比 ', ''))}</span>`
222
+ : '';
223
+ const previousLine = compareMode === 'yoy' && previous !== null && !missing
224
+ ? `<div class="d">去年 ${esc(unit.value(previous))}${esc(unit.suffix)}</div>`
225
+ : '';
226
+ return `<div class="kpi">
227
+ <div class="k">${esc(metric.label)}</div>
228
+ <div class="n">${esc(valueText)}</div>
229
+ <div class="d">${chip}</div>
230
+ ${previousLine}
231
+ </div>`;
232
+ }).join('');
233
+ return `<section class="card">
234
+ <h2>${esc(block.title ?? '总览')}</h2>
235
+ <p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)} 合计${compareMode === 'yoy' ? ',同比为「去年同期」对比' : ''}</p>
236
+ <div class="kpis">${cards}</div>
237
+ </section>`;
238
+ }
239
+ // ---------------------------------------------------------------- 积木:双柱
240
+ export function renderGroupedBar(data, block) {
241
+ const key = block.metric ?? data.metrics.find((metric) => metric.aggregation === 'sum')?.key;
242
+ if (!key)
243
+ throw new Error('grouped-bar 需要一个数值口径');
244
+ const metric = metricOf(data, key);
245
+ const unit = unitOf(metric.aggregation);
246
+ const compareMode = (block.compare ?? data.window.compare) === 'yoy';
247
+ const values = data.series.map((row) => {
248
+ const current = row.values[key] ?? null;
249
+ const previous = compareMode ? row.previousYear?.values?.[key] ?? null : null;
250
+ return { current: current === null ? 0 : Number(current), previous: previous === null ? null : Number(previous) };
251
+ });
252
+ const maxValue = Math.max(...values.flatMap((item) => [item.current, item.previous ?? 0]), 1);
253
+ const { y, ticks, innerW, innerH } = chartFrame(maxValue, false);
254
+ const band = innerW / Math.max(values.length, 1);
255
+ const barW = Math.min(26, band * 0.26);
256
+ const bars = values.map((item, index) => {
257
+ const cx = PAD.left + band * index + band / 2;
258
+ const currentX = compareMode ? cx - barW - 1 : cx - barW / 2;
259
+ const currentH = Math.max(item.current > 0 ? 2 : 0, innerH - (y(item.current) - PAD.top));
260
+ const currentRect = `<rect x="${currentX.toFixed(1)}" y="${(PAD.top + innerH - currentH).toFixed(1)}" width="${barW.toFixed(1)}" height="${currentH.toFixed(1)}" rx="3" fill="${ACCENT}" />`;
261
+ let previousRect = '';
262
+ if (item.previous !== null) {
263
+ const previousH = Math.max(item.previous > 0 ? 2 : 0, innerH - (y(item.previous) - PAD.top));
264
+ previousRect = `<rect x="${(cx + 1).toFixed(1)}" y="${(PAD.top + innerH - previousH).toFixed(1)}" width="${barW.toFixed(1)}" height="${previousH.toFixed(1)}" rx="3" fill="${ACCENT_SOFT}" />`;
265
+ }
266
+ return `<g><title>${esc(bucketLabel(data.series[index]))}|本期 ${esc(unit.value(item.current))}${item.previous === null ? '' : `|去年 ${esc(unit.value(item.previous))}`}</title>${previousRect}${currentRect}</g>`;
267
+ }).join('');
268
+ return `<section class="card">
269
+ <h2>${esc(block.title ?? `${metric.label} · 按月`)}</h2>
270
+ <p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)}${compareMode ? ' 与去年同期对比' : ''},单位:${unit.header === '家' ? '家' : '元'}</p>
271
+ <svg class="chart" viewBox="0 0 ${CHART_W} ${CHART_H}" role="img" aria-label="${esc(metric.label)}按月柱状图">
272
+ ${gridSvg(ticks)}${bars}${axisLabels(data.series, innerW, data.series.length > 14)}
273
+ </svg>
274
+ <div class="legend">
275
+ <span><i class="swatch" style="background:${ACCENT}"></i>本期</span>
276
+ ${compareMode ? `<span><i class="swatch" style="background:${ACCENT_SOFT}"></i>去年同期</span>` : ''}
277
+ </div>
278
+ </section>`;
279
+ }
280
+ // ---------------------------------------------------------------- 积木:折线
281
+ export function renderLine(data, block) {
282
+ const key = block.metric ?? data.metrics.find((metric) => metric.aggregation === 'ratio')?.key;
283
+ if (!key)
284
+ throw new Error('line 需要一个率值/趋势口径');
285
+ const metric = metricOf(data, key);
286
+ const rateMode = metric.aggregation === 'ratio';
287
+ const compareMode = (block.compare ?? data.window.compare) === 'yoy';
288
+ const { y, ticks, innerW } = chartFrame(rateMode ? 100 : 0, rateMode);
289
+ const band = innerW / Math.max(data.series.length, 1);
290
+ const pointsOf = (source) => data.series.map((row, index) => {
291
+ const container = source === 'current' ? row.values : (row.previousYear?.values ?? null);
292
+ const raw = container ? container[key] : null;
293
+ if (raw === null || raw === undefined)
294
+ return null;
295
+ return {
296
+ x: PAD.left + band * index + band / 2,
297
+ y: y(Number(raw)),
298
+ label: `${bucketLabel(row)}・${unitOf(metric.aggregation).value(Number(raw))}`,
299
+ };
300
+ });
301
+ const pathOf = (points, color, dashed) => {
302
+ let path = '';
303
+ let open = false;
304
+ for (const point of points) {
305
+ if (!point) {
306
+ open = false;
307
+ continue;
308
+ }
309
+ path += `${open ? 'L' : 'M'}${point.x.toFixed(1)} ${point.y.toFixed(1)} `;
310
+ open = true;
311
+ }
312
+ return path
313
+ ? `<path d="${path.trim()}" fill="none" stroke="${color}" stroke-width="${dashed ? 1.8 : 2.4}"
314
+ stroke-linecap="round" ${dashed ? 'stroke-dasharray="5 5"' : ''} />`
315
+ : '';
316
+ };
317
+ const dotsOf = (points, color) => points.filter(Boolean).map((point) => `<circle cx="${point.x.toFixed(1)}" cy="${point.y.toFixed(1)}" r="3.2"
318
+ fill="#fff" stroke="${color}" stroke-width="2"><title>${esc(point.label)}</title></circle>`).join('');
319
+ const current = pointsOf('current');
320
+ const previous = compareMode ? pointsOf('previous') : [];
321
+ return `<section class="card">
322
+ <h2>${esc(block.title ?? `${metric.label} · 走势`)}</h2>
323
+ <p class="hint">${rateMode ? '分母为 0 的月份不绘制(不补 0、不画 100%)' : '缺失值不连线'}</p>
324
+ <svg class="chart" viewBox="0 0 ${CHART_W} ${CHART_H}" role="img" aria-label="${esc(metric.label)}走势图">
325
+ ${gridSvg(ticks)}
326
+ ${compareMode ? pathOf(previous, '#94a3b8', true) : ''}
327
+ ${pathOf(current, ACCENT, false)}
328
+ ${compareMode ? dotsOf(previous, '#94a3b8') : ''}
329
+ ${dotsOf(current, ACCENT)}
330
+ ${axisLabels(data.series, innerW, data.series.length > 14)}
331
+ </svg>
332
+ <div class="legend">
333
+ <span><i class="swatch" style="background:${ACCENT}"></i>本期</span>
334
+ ${compareMode ? '<span><i class="swatch" style="background:#94a3b8"></i>去年同期(虚线)</span>' : ''}
335
+ </div>
336
+ </section>`;
337
+ }
338
+ // ---------------------------------------------------------------- 积木:排行
339
+ export function renderHbar(data, block) {
340
+ const key = block.metric ?? data.metrics.find((metric) => metric.aggregation === 'sum')?.key;
341
+ if (!key)
342
+ throw new Error('hbar 需要一个可比大小的口径');
343
+ const metric = metricOf(data, key);
344
+ const unit = unitOf(metric.aggregation);
345
+ const limit = block.limit ?? 10;
346
+ const sortDesc = (block.sort ?? 'desc') === 'desc';
347
+ const rows = data.series
348
+ .map((row) => ({ label: bucketLabel(row), value: row.values[key] ?? null }))
349
+ .filter((row) => row.value !== null)
350
+ .sort((a, b) => (sortDesc ? Number(b.value) - Number(a.value) : Number(a.value) - Number(b.value)))
351
+ .slice(0, limit);
352
+ const max = Math.max(...rows.map((row) => Math.abs(Number(row.value))), 1);
353
+ const bars = rows.map((row) => {
354
+ const width = Math.max(1, Math.round((Math.abs(Number(row.value)) / max) * 100));
355
+ return `<div class="rank-row">
356
+ <div class="rank-name" title="${esc(row.label)}">${esc(row.label)}</div>
357
+ <div class="rank-track"><div class="rank-fill" style="width:${width}%"></div></div>
358
+ <div class="rank-val">${esc(unit.value(Number(row.value)))}${esc(unit.suffix)}</div>
359
+ </div>`;
360
+ }).join('');
361
+ const omitted = data.series.length - rows.length;
362
+ return `<section class="card">
363
+ <h2>${esc(block.title ?? `${metric.label} · ${dimensionLabel(data)}排行`)}</h2>
364
+ <p class="hint">按${esc(dimensionLabel(data))}聚合,${sortDesc ? '从高到低' : '从低到高'}取前 ${limit}${omitted > 0 ? `(共 ${data.series.length} 项,其余 ${omitted} 项未展示)` : ''}</p>
365
+ <div class="rank">${bars || '<div class="hint">无数据</div>'}</div>
366
+ </section>`;
367
+ }
368
+ // ---------------------------------------------------------------- 积木:明细表
369
+ export function renderTable(data, block) {
370
+ const keys = block.metrics ?? data.metrics.map((metric) => metric.key);
371
+ const compareMode = (block.compare ?? data.window.compare) === 'yoy';
372
+ // 分类维度可能返回成千上万个分组;允许显式 limit 收窄(默认全量,保持明细语义)
373
+ const rows = typeof block.limit === 'number' ? data.series.slice(0, block.limit) : data.series;
374
+ const omitted = data.series.length - rows.length;
375
+ const head = keys.map((key) => {
376
+ const unit = unitOf(metricOf(data, key).aggregation);
377
+ const suffix = unit.header === '元' ? '(元)' : unit.header === '%' ? '(%)' : `(${unit.header})`;
378
+ return `<th>${esc(metricOf(data, key).label)}${suffix}</th>`;
379
+ }).join('');
380
+ const body = rows.map((row) => {
381
+ const cells = keys.map((key) => {
382
+ const metric = metricOf(data, key);
383
+ const unit = unitOf(metric.aggregation);
384
+ const current = row.values[key] ?? null;
385
+ const previous = row.previousYear?.values?.[key] ?? null;
386
+ const yoyInfo = compareMode
387
+ ? yoyText(metric.aggregation, current, previous, row.yoy?.[key] ?? null)
388
+ : null;
389
+ const valueHtml = current === null
390
+ ? '<span class="na">—</span>'
391
+ : `<span class="strong">${unit.value(Number(current))}</span>`;
392
+ const delta = compareMode && yoyInfo && current !== null && yoyInfo.text !== '同比 —'
393
+ ? ` <span class="trend ${yoyInfo.cls}">${esc(yoyInfo.text.replace('同比 ', ''))}</span>`
394
+ : '';
395
+ return `<td>${valueHtml}${delta}</td>`;
396
+ }).join('');
397
+ return `<tr><td>${esc(bucketLabel(row))}</td>${cells}</tr>`;
398
+ }).join('');
399
+ return `<section class="card">
400
+ <h2>${esc(block.title ?? `${dimensionLabel(data)}明细`)}</h2>
401
+ <p class="hint">每格为本期值${compareMode ? ' + 同比;率值的同比为「百分点」,金额/户数为相对百分比' : ''}${omitted > 0 ? `;本表展示前 ${rows.length} 项,其余 ${omitted} 项未列出(如需完整清单请用 stat 的 out 落盘)` : ''}</p>
402
+ <table>
403
+ <thead><tr><th>${esc(dimensionLabel(data))}</th>${head}</tr></thead>
404
+ <tbody>${body || `<tr><td colspan="${keys.length + 1}">无数据</td></tr>`}</tbody>
405
+ </table>
406
+ </section>`;
407
+ }
408
+ export const RENDERERS = {
409
+ kpi: renderKpi,
410
+ 'grouped-bar': renderGroupedBar,
411
+ line: renderLine,
412
+ hbar: renderHbar,
413
+ table: renderTable,
414
+ };
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 报表视图层(2026-11-28):声明式 spec + 白名单校验 + 默认决策表。
3
+ *
4
+ * 背景:报表原先是「一份写死的 HTML 骨架」。口径一多就崩(KPI 塞不下、量纲混装、
5
+ * 分类排名没有形态),但如果改成"每次现场生成",口径与样式就会漂移——我们已经踩过
6
+ * `25.58%%`、合计多算 26,805.08、率值同比写成相对百分比这三个坑。
7
+ *
8
+ * 分层:
9
+ * 口径层 data/metric-catalog.ts 指标定义/单位/聚合(单一事实源)
10
+ * 视图层 本文件 spec(放哪些积木、按什么排序)
11
+ * 渲染层 report-renderers.ts 5 类积木,视觉规范统一
12
+ * 编排层 ledger-report.ts stat 结果 + spec → HTML
13
+ *
14
+ * 原则:
15
+ * - 图型只由「维度 / 是否时间序列 / 是否对比 / 量纲」决定,与具体口径无关,
16
+ * 所以口径增长不会导致模板数量线性膨胀;
17
+ * - spec 只允许白名单内的 kind 与 metric,**不认识就报错,不猜、不静默降级**;
18
+ * - 默认 spec 由决策表生成,调用方只在需要时覆写。
19
+ */
20
+ /** 已实现的积木(白名单)。`stacked` 构成图需要双维度数据与构成口径,暂不提供。 */
21
+ export const BLOCK_KINDS = ['kpi', 'grouped-bar', 'line', 'hbar', 'table'];
22
+ /** 校验错误:统一用可读中文,调用方(operation)负责包成 CLI 错误。 */
23
+ export class ReportSpecError extends Error {
24
+ code;
25
+ constructor(code, message) {
26
+ super(message);
27
+ this.name = 'ReportSpecError';
28
+ this.code = code;
29
+ }
30
+ }
31
+ function aggregationOf(data, key) {
32
+ return data.metrics.find((metric) => metric.key === key)?.aggregation;
33
+ }
34
+ /**
35
+ * 校验 spec:kind 白名单、metric 必须存在于本次统计、量纲不得混装、图类只允许单指标。
36
+ *
37
+ * 量纲规则(硬约束):一张图只能一个量纲;`receiptRate`(%)不能与 `signedAmount`(元)
38
+ * 同图——双轴会让人误读"率值和金额可比大小"。
39
+ */
40
+ export function validateSpec(spec, data) {
41
+ if (!spec || !Array.isArray(spec.blocks) || spec.blocks.length === 0) {
42
+ throw new ReportSpecError('spec_blocks_required', 'spec.blocks 不能为空');
43
+ }
44
+ const known = new Set(data.metrics.map((metric) => metric.key));
45
+ const seenKpi = spec.blocks.filter((block) => block.kind === 'kpi').length;
46
+ if (seenKpi > 1)
47
+ throw new ReportSpecError('spec_duplicate_kpi', 'kpi 积木只能有一个');
48
+ const blocks = spec.blocks.map((raw, index) => {
49
+ const where = `spec.blocks[${index}]`;
50
+ if (!raw || typeof raw !== 'object')
51
+ throw new ReportSpecError('spec_block_invalid', `${where} 必须是对象`);
52
+ if (!BLOCK_KINDS.includes(raw.kind)) {
53
+ throw new ReportSpecError('spec_kind_unsupported', `${where}.kind 不支持「${String(raw.kind)}」;可用:${BLOCK_KINDS.join(' / ')}`);
54
+ }
55
+ const block = { ...raw };
56
+ const checkMetric = (key, label) => {
57
+ if (typeof key !== 'string' || !key) {
58
+ throw new ReportSpecError('spec_metric_required', `${where}.${label} 必须是非空口径键`);
59
+ }
60
+ if (!known.has(key)) {
61
+ throw new ReportSpecError('spec_metric_unknown', `${where}.${label} 的口径「${key}」不在本次统计里;可用:${[...known].join('、')}`);
62
+ }
63
+ return key;
64
+ };
65
+ if (block.kind === 'kpi' || block.kind === 'table') {
66
+ if (block.metrics !== undefined) {
67
+ if (!Array.isArray(block.metrics) || block.metrics.length === 0) {
68
+ throw new ReportSpecError('spec_metric_required', `${where}.metrics 必须是非空数组`);
69
+ }
70
+ block.metrics = block.metrics.map((key) => checkMetric(key, 'metrics[]'));
71
+ }
72
+ }
73
+ else {
74
+ // 图类:单指标 + 不允许跨量纲
75
+ if (block.metric !== undefined)
76
+ checkMetric(block.metric, 'metric');
77
+ if (block.metrics !== undefined && block.metrics.length > 1) {
78
+ throw new ReportSpecError('spec_single_metric', `${where}:图类积木只接受一个 metric`);
79
+ }
80
+ }
81
+ if (block.compare !== undefined && !['yoy', 'none'].includes(block.compare)) {
82
+ throw new ReportSpecError('spec_compare_invalid', `${where}.compare 只支持 yoy / none`);
83
+ }
84
+ if (block.limit !== undefined && (!Number.isInteger(block.limit) || block.limit <= 0 || block.limit > 200)) {
85
+ throw new ReportSpecError('spec_limit_invalid', `${where}.limit 必须是 1~200 的整数`);
86
+ }
87
+ if (block.sort !== undefined && !['desc', 'asc'].includes(block.sort)) {
88
+ throw new ReportSpecError('spec_sort_invalid', `${where}.sort 只支持 desc / asc`);
89
+ }
90
+ return block;
91
+ });
92
+ return { ...spec, blocks };
93
+ }
94
+ function firstMetricOf(data, aggregation) {
95
+ return data.metrics.find((metric) => metric.aggregation === aggregation)?.key;
96
+ }
97
+ /**
98
+ * 默认决策表(按数据形态选积木,不按口径名硬编码):
99
+ *
100
+ * | 数据维度 | 积木组合 |
101
+ * |---|---|
102
+ * | 时间序列(month) | kpi(≤4) + grouped-bar(首个金额口径) + line(率值口径,若有) + table(全部) |
103
+ * | 分类维度(customer/salesman) | kpi(≤4) + hbar(首个金额口径, Top10) + table(全部) |
104
+ *
105
+ * KPI 最多 4 个:超过时其余口径只在明细表出现(避免卡片挤成一片)。
106
+ */
107
+ export function defaultSpec(data) {
108
+ const dimension = data.window.dimension ?? 'month';
109
+ const compare = data.window.compare;
110
+ // 时间类维度(签订日期 / 业绩年月)走「双柱 + 折线」;分类维度走「排行」
111
+ const isTime = dimension === 'date' || dimension === 'month';
112
+ const blocks = [];
113
+ const kpiMetrics = data.metrics.slice(0, 4).map((metric) => metric.key);
114
+ if (kpiMetrics.length)
115
+ blocks.push({ kind: 'kpi', metrics: kpiMetrics });
116
+ const amount = firstMetricOf(data, 'sum');
117
+ const rate = firstMetricOf(data, 'ratio');
118
+ const count = firstMetricOf(data, 'countDistinct');
119
+ if (isTime) {
120
+ if (amount)
121
+ blocks.push({ kind: 'grouped-bar', metric: amount });
122
+ if (rate)
123
+ blocks.push({ kind: 'line', metric: rate });
124
+ }
125
+ else {
126
+ const rankMetric = amount ?? count;
127
+ if (rankMetric)
128
+ blocks.push({ kind: 'hbar', metric: rankMetric, limit: 10, sort: 'desc' });
129
+ }
130
+ blocks.push({ kind: 'table', metrics: data.metrics.map((metric) => metric.key) });
131
+ return { blocks };
132
+ }