weaver-work-cli 0.1.73 → 0.1.75

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 (310) hide show
  1. package/README.md +37 -1
  2. package/dist/chunks/{archive-THZV4ND4.js → archive-OZJ6PYUR.js} +14 -9
  3. package/dist/chunks/{archive-oa-PQ23OLEV.js → archive-oa-BHL5RK2F.js} +10 -7
  4. package/dist/chunks/{asset-RGPROZYH.js → asset-HKRFRQR2.js} +10 -7
  5. package/dist/chunks/{asset-idle-Z2PDX7NA.js → asset-idle-GGIR4KE7.js} +7 -4
  6. package/dist/chunks/{attachment-content-R3RPVOYE.js → attachment-content-4OV65NK5.js} +3 -3
  7. package/dist/chunks/{blog-7U3QZPIF.js → blog-HYDP4DV3.js} +10 -7
  8. package/dist/chunks/{caizhilian-3AB42GCV.js → caizhilian-JS4RQZ6Z.js} +10 -7
  9. package/dist/chunks/{calendar-KINM64E4.js → calendar-SWRY4DIT.js} +10 -7
  10. package/dist/chunks/chunk-257JXJGD.js +30 -0
  11. package/dist/chunks/{chunk-LLCMOZ5L.js → chunk-2AUFKU2D.js} +11 -11
  12. package/dist/chunks/chunk-2BZ7TY4M.js +49 -0
  13. package/dist/chunks/{chunk-WM33BSIL.js → chunk-2QCCXPNU.js} +1 -1
  14. package/dist/chunks/{chunk-TV46Q4NY.js → chunk-4FCBEWNB.js} +74 -68
  15. package/dist/chunks/{chunk-NUP4RYZK.js → chunk-5D2V7ZAN.js} +2 -2
  16. package/dist/chunks/{chunk-DRUND2PJ.js → chunk-5QUTQHXF.js} +225 -152
  17. package/dist/chunks/{chunk-4BXR6CNB.js → chunk-5ZJGPEIB.js} +2 -2
  18. package/dist/chunks/chunk-7DE3VMZD.js +35 -0
  19. package/dist/chunks/chunk-BNKUHN4N.js +1346 -0
  20. package/dist/chunks/{chunk-2CHGUYMG.js → chunk-BSR5TM7U.js} +4 -4
  21. package/dist/chunks/{chunk-4I26YMBY.js → chunk-ERZY6GYL.js} +7 -3
  22. package/dist/chunks/{chunk-4YXAK6OA.js → chunk-FEZK536Z.js} +12 -7
  23. package/dist/chunks/{chunk-F4HM25K4.js → chunk-I6NOHKEK.js} +1 -1
  24. package/dist/chunks/{chunk-JMJBPP4B.js → chunk-J7FAAHWH.js} +2 -2
  25. package/dist/chunks/{chunk-54ST55IJ.js → chunk-JJONWB5N.js} +11 -1
  26. package/dist/chunks/chunk-JOY3HZXL.js +467 -0
  27. package/dist/chunks/{chunk-GWJLAF6B.js → chunk-JWF2R6EQ.js} +0 -462
  28. package/dist/chunks/{chunk-BWYVS62Z.js → chunk-KEA4XQPO.js} +4 -4
  29. package/dist/chunks/chunk-KINXYJXM.js +205 -0
  30. package/dist/chunks/{chunk-IBSJJGXL.js → chunk-KWJEICD4.js} +2 -2
  31. package/dist/chunks/{chunk-GAMGDNTF.js → chunk-LJI4N6FV.js} +1 -1
  32. package/dist/chunks/{chunk-IU6UB2TD.js → chunk-MXCRKXOP.js} +48 -6
  33. package/dist/chunks/{chunk-PAFOLIYQ.js → chunk-NWYHCZTY.js} +1 -1
  34. package/dist/chunks/chunk-OJ4JPD25.js +428 -0
  35. package/dist/chunks/{chunk-L7TYG5SN.js → chunk-OQCK5SAU.js} +2 -2
  36. package/dist/chunks/chunk-PG5YSNYY.js +1166 -0
  37. package/dist/chunks/{chunk-XZBYRYWX.js → chunk-QJWVYOOV.js} +2 -2
  38. package/dist/chunks/{chunk-AMAPQVBT.js → chunk-QVKRNL7L.js} +286 -305
  39. package/dist/chunks/chunk-SU6IJD6D.js +49 -0
  40. package/dist/chunks/{chunk-ZWLWXHJC.js → chunk-TA2RBUTH.js} +2 -2
  41. package/dist/chunks/{chunk-6HT73VOI.js → chunk-U6Y32KEV.js} +2 -2
  42. package/dist/chunks/chunk-UUJK76HV.js +209 -0
  43. package/dist/chunks/{chunk-R3MK2RBN.js → chunk-VOMDD2C5.js} +1 -1
  44. package/dist/chunks/chunk-Y3C6MDL7.js +28 -0
  45. package/dist/chunks/chunk-ZM7RN2IM.js +38 -0
  46. package/dist/chunks/{chunk-2XED2FKY.js → chunk-ZUB4M4N3.js} +38 -36
  47. package/dist/chunks/{chunk-7QFVXP2X.js → chunk-ZWIMLT6P.js} +8 -7
  48. package/dist/chunks/cli-FULPXIKJ.js +226 -0
  49. package/dist/chunks/commands-BNWFNTD3.js +70 -0
  50. package/dist/chunks/{conflict-VPAR7E6F.js → conflict-5BKCDV2F.js} +2 -2
  51. package/dist/chunks/{contract-DDXAO2DZ.js → contract-WI23OXVC.js} +12446 -5964
  52. package/dist/chunks/{cowork-34QCHMDD.js → cowork-DZBBVNMQ.js} +11 -8
  53. package/dist/chunks/{create-flow-52PU2OBI.js → create-flow-7ZRBRKX7.js} +6 -6
  54. package/dist/chunks/{data-CLQ62QGD.js → data-PAZVE6QE.js} +6 -3
  55. package/dist/chunks/{ebuilder-form-W5R7Q22S.js → ebuilder-form-5SQXIGXN.js} +9 -6
  56. package/dist/chunks/{ehr-LCNAVMK5.js → ehr-CX5F4ZAU.js} +23 -16
  57. package/dist/chunks/{entry-mode-6Z3ZV3DE.js → entry-mode-I2BYNONZ.js} +3 -3
  58. package/dist/chunks/{env-RDKWAARB.js → env-ZAQZ7EHN.js} +2 -2
  59. package/dist/chunks/{esb-ANKPUU65.js → esb-DQTXDIBF.js} +10 -7
  60. package/dist/chunks/{factory-434B7RAT.js → factory-XRI6KZ7H.js} +1 -1
  61. package/dist/chunks/{fna-AKBSG5HI.js → fna-FK6HQVJL.js} +13 -8
  62. package/dist/chunks/{group-chat-PROTW22R.js → group-chat-MLWNYM2P.js} +3 -3
  63. package/dist/chunks/{host-WO4L5G5I.js → host-3EPREGXS.js} +6 -3
  64. package/dist/chunks/{host-XIYG4F4B.js → host-J74JGYAW.js} +6 -3
  65. package/dist/chunks/{host-7FJW4E7R.js → host-KUMU3DDK.js} +6 -3
  66. package/dist/chunks/{host-5R2SNFWD.js → host-MEC4VQZA.js} +6 -3
  67. package/dist/chunks/{host-PDJAKCT7.js → host-T6NNQGVZ.js} +6 -3
  68. package/dist/chunks/{host-CGXUFQO4.js → host-VI7Q45PM.js} +6 -3
  69. package/dist/chunks/{hrm-WGODDTEH.js → hrm-KKVAW4P5.js} +8 -5
  70. package/dist/chunks/{im-YKTKAJU3.js → im-47CIWQNL.js} +7 -4
  71. package/dist/chunks/{invoice-PVYCCCVM.js → invoice-CDYRBNIG.js} +21 -16
  72. package/dist/chunks/{jiuchuanhui-RKOQW7BY.js → jiuchuanhui-M7QTRHZK.js} +17 -10
  73. package/dist/chunks/{lazy-dispatch-DW45AFQ5.js → lazy-dispatch-FKQJZFI5.js} +22 -8
  74. package/dist/chunks/{mail-BNB5S4NW.js → mail-NRBS5N6Y.js} +11 -8
  75. package/dist/chunks/{meeting-O2KDJH66.js → meeting-WC5LD3IO.js} +22 -18
  76. package/dist/chunks/{minute-doc-JUCG56GY.js → minute-doc-OQUMDTKG.js} +4 -4
  77. package/dist/chunks/{okr-LWFGWOE7.js → okr-EHKSKMPL.js} +10 -7
  78. package/dist/chunks/{operations-532PN5OB.js → operations-V5VM5MS2.js} +7 -4
  79. package/dist/chunks/{performance-7W5COCFU.js → performance-ZJADXJPN.js} +6 -3
  80. package/dist/chunks/{plan-ZVY3IYTL.js → plan-OTDNBDJ7.js} +10 -7
  81. package/dist/chunks/{project-SA62B7MH.js → project-4XVBQ3HX.js} +10 -7
  82. package/dist/chunks/{reception-NGIONPQ3.js → reception-3FAHOOH7.js} +8 -4
  83. package/dist/chunks/{recruit-stage-WOSN6MGP.js → recruit-stage-3WTVWW2K.js} +199 -74
  84. package/dist/chunks/register-SQOPIR2G.js +16 -0
  85. package/dist/chunks/{registry-R72GWXOG.js → registry-F4YFZLOD.js} +7 -3
  86. package/dist/chunks/registry-NBTBXR4L.js +30 -0
  87. package/dist/chunks/{registry-N7P3W2RD.js → registry-TJGCVRCW.js} +7 -4
  88. package/dist/chunks/{room-recommend-KCGIVUFR.js → room-recommend-KL62XB2Y.js} +4 -4
  89. package/dist/chunks/root-YZG2TS5W.js +16 -0
  90. package/dist/chunks/{schedule-6UP27HQ4.js → schedule-XOISYUPB.js} +4 -4
  91. package/dist/chunks/{smart-extract-DDOQSPRB.js → smart-extract-UYGNV3BM.js} +15 -7
  92. package/dist/chunks/update-AV5VOXGY.js +13 -0
  93. package/dist/chunks/{workflow-V5ALD6QZ.js → workflow-V54LJPXL.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/index.js +1 -1
  170. package/dist/shortcuts/jiuchuanhui/index.js +2 -2
  171. package/dist/shortcuts/jiuchuanhui/manifest.js +3 -0
  172. package/dist/shortcuts/mail/index.js +2 -2
  173. package/dist/shortcuts/meeting/index.js +1 -1
  174. package/dist/shortcuts/meeting/manifest.js +1 -0
  175. package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -3
  176. package/dist/shortcuts/meeting/operations/eb/conflict.js +3 -1
  177. package/dist/shortcuts/meeting/operations/eb/create-flow.js +10 -9
  178. package/dist/shortcuts/meeting/operations/eb/factory.js +2 -0
  179. package/dist/shortcuts/meeting/operations/eb/member-expand.js +3 -2
  180. package/dist/shortcuts/meeting/operations/invitation-publish.js +3 -3
  181. package/dist/shortcuts/meeting/operations/invitation.js +4 -4
  182. package/dist/shortcuts/meeting/operations/link.js +3 -1
  183. package/dist/shortcuts/okr/index.js +1 -1
  184. package/dist/shortcuts/performance/index.js +1 -1
  185. package/dist/shortcuts/plan/index.js +1 -1
  186. package/dist/shortcuts/project/index.js +1 -1
  187. package/dist/shortcuts/reception/manifest.js +2 -2
  188. package/dist/shortcuts/recruit-stage/context.js +10 -2
  189. package/dist/shortcuts/recruit-stage/index.js +16 -3
  190. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +1 -1
  191. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +1 -1
  192. package/dist/shortcuts/recruit-stage/operations/jd-create.js +17 -8
  193. package/dist/shortcuts/recruit-stage/operations/list.js +1 -1
  194. package/dist/shortcuts/recruit-stage/operations/resume-import.js +178 -35
  195. package/dist/shortcuts/recruit-stage/operations/search.js +2 -2
  196. package/dist/shortcuts/recruit-stage/operations/shortlist.js +4 -2
  197. package/dist/shortcuts/recruit-stage/shared.js +27 -53
  198. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  199. package/dist/shortcuts/smart-extract/operations/fill.js +7 -2
  200. package/dist/shortcuts/smart-extract/operations/validate.js +4 -1
  201. package/dist/shortcuts/workflow/index.js +2 -2
  202. package/dist/shortcuts/workflow/manifest.js +1 -0
  203. package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +4 -1
  204. package/dist/shortcuts/workflow/operations/deepRead.js +23 -2
  205. package/dist/shortcuts/workflow/operations/form.js +8 -2
  206. package/docs/contract.md +6 -1
  207. package/docs/e10-auth.md +25 -7
  208. package/docs/operation-manual.md +15 -0
  209. package/package.json +2 -2
  210. package/scripts/pysite/__pycache__/sitecustomize.cpython-314.pyc +0 -0
  211. package/skill-template/business-info.json +28 -0
  212. package/skill-template/domains/jinchengda.md +13 -1
  213. package/skills/weaver-e10-archive-oa/references/source-manifest.json +3 -3
  214. package/skills/weaver-e10-caizhilian/references/auth-and-install.md +2 -1
  215. package/skills/weaver-e10-caizhilian/references/source-manifest.json +3 -3
  216. package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
  217. package/skills/weaver-e10-jinchengda/SKILL.md +90 -32
  218. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +45 -0
  219. package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +68 -0
  220. package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +216 -0
  221. package/skills/weaver-e10-jinchengda/references/contract-clause-negotiate.md +215 -0
  222. package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +113 -0
  223. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +19 -3
  224. package/skills/weaver-e10-jinchengda/references/contract-decisions.md +114 -0
  225. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -44
  226. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +1 -1
  227. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +1 -1
  228. package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +200 -0
  229. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -1
  230. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +138 -3
  231. package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +158 -0
  232. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +3 -1
  233. package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +139 -0
  234. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +2 -2
  235. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +10 -3
  236. package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +106 -0
  237. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
  238. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +176 -56
  239. package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +123 -0
  240. package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +410 -0
  241. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  242. package/skills/weaver-e10-jinchengda/references/contract-viewlink.md +110 -0
  243. package/skills/weaver-e10-jinchengda/references/orchestration.md +38 -24
  244. package/skills/weaver-e10-meeting/SKILL.md +13 -0
  245. package/skills/weaver-e10-okr/SKILL.md +11 -0
  246. package/skills/weaver-e10-okr/references/source-manifest.json +7 -6
  247. package/skills/weaver-e10-performance/SKILL.md +131 -39
  248. package/skills/weaver-e10-performance/agents/openai.yaml +48 -17
  249. package/skills/weaver-e10-performance/references/default-assembly.md +3 -0
  250. package/skills/weaver-e10-performance/references/extraction-guide.md +17 -3
  251. package/skills/weaver-e10-performance/references/flow-assess.md +38 -5
  252. package/skills/weaver-e10-performance/references/scheme-setting-page.md +20 -3
  253. package/skills/weaver-e10-performance/scripts/assemble_scheme.py +461 -0
  254. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +41 -0
  255. package/skills/weaver-e10-plan/SKILL.md +10 -0
  256. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  257. package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
  258. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  259. package/skills/weaver-e10-recruit-stage/SKILL.md +188 -169
  260. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +55 -37
  261. package/skills/weaver-e10-recruit-stage/lib/interview-conflict.mjs +3 -0
  262. package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +168 -35
  263. package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +175 -7
  264. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +3 -0
  265. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +15 -1
  266. package/skills/weaver-e10-recruit-stage/lib/report-attachment.mjs +38 -0
  267. package/skills/weaver-e10-recruit-stage/lib/xiaoe-session.mjs +5 -1
  268. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +4 -0
  269. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +4 -0
  270. package/skills/weaver-e10-recruit-stage/references/position-templates.md +12 -8
  271. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +16 -11
  272. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +10 -6
  273. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +5 -1
  274. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +4 -0
  275. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +7 -3
  276. package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +6 -1
  277. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +7 -3
  278. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +31 -23
  279. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +4 -0
  280. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -0
  281. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +5 -1
  282. package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +4 -0
  283. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +16 -10
  284. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +6 -2
  285. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +147 -34
  286. package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +4 -0
  287. package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +16 -4
  288. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +4 -0
  289. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +8 -4
  290. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +6 -2
  291. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +24 -15
  292. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +7 -3
  293. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +7 -3
  294. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +8 -4
  295. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +5 -1
  296. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +5 -1
  297. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +5 -1
  298. package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +41 -28
  299. package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +23 -26
  300. package/skills/weaver-e10-recruit-stage/templates/match-report.html +32 -30
  301. package/skills/weaver-e10-shared/SKILL.md +40 -5
  302. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +11 -1
  303. package/skills/weaver-e10-shared/references/json-output-contract.md +144 -8
  304. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +11 -0
  305. package/skills/weaver-e10-shijingran/references/source-manifest.json +3 -3
  306. package/skills/weaver-e10-wenshuding/references/source-manifest.json +3 -3
  307. package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
  308. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +5 -5
  309. package/dist/chunks/chunk-ICP53R52.js +0 -2849
  310. package/dist/chunks/registry-RIQ67ZT7.js +0 -27
@@ -0,0 +1,252 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { readFileSync, realpathSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { basename, dirname, join, resolve } from 'node:path';
5
+ import { setTimeout as delay } from 'node:timers/promises';
6
+ import { isXiaoEHostEnvironment } from '../../core/runtime-agent.js';
7
+ import { compareVersions, findNpmCli, npmRunner } from './npm.js';
8
+ import { UPDATE_INTERVAL_MS, UpdateStore } from './store.js';
9
+ const NAME = 'weaver-work-cli';
10
+ const CHECK_TIMEOUT_MS = 3_000;
11
+ const INSTALL_TIMEOUT_MS = 120_000;
12
+ export class UpdateService {
13
+ options;
14
+ store;
15
+ now;
16
+ skipReason;
17
+ isNpmInstallation;
18
+ env;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.env = options.env;
22
+ this.now = options.now || Date.now;
23
+ this.store = new UpdateStore(options.home || this.env.WEAVER_WORK_CLI_HOME || this.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli'), realpathSync(options.packageRoot));
24
+ this.isNpmInstallation = basename(dirname(this.store.packageRoot)) === 'node_modules'
25
+ && basename(this.store.packageRoot) === NAME;
26
+ if (isXiaoEHostEnvironment(this.env, options))
27
+ this.skipReason = 'xiaoe_host_managed';
28
+ else if (['off', '0', 'false'].includes((this.env.WEAVER_WORK_CLI_UPDATE || '').toLowerCase()))
29
+ this.skipReason = 'disabled';
30
+ else if (!this.isNpmInstallation) {
31
+ this.skipReason = 'development_or_link';
32
+ }
33
+ }
34
+ runner() {
35
+ if (this.options.runNpm)
36
+ return this.options.runNpm;
37
+ const cli = findNpmCli(this.env);
38
+ if (!cli)
39
+ throw new Error('未找到当前 Node.js 可用的 npm,未执行更新。');
40
+ return npmRunner(cli, this.env, homedir());
41
+ }
42
+ async installation(run, timeout) {
43
+ let config;
44
+ try {
45
+ config = JSON.parse(await run(['config', 'list', '--json'], timeout));
46
+ }
47
+ catch {
48
+ throw new Error('无法读取 npm 安装配置,请检查 npm 是否可用。');
49
+ }
50
+ if (typeof config.prefix !== 'string' || typeof config.registry !== 'string')
51
+ throw new Error('无法识别 npm 安装配置。');
52
+ const prefix = resolve(config.prefix);
53
+ const expected = process.platform === 'win32'
54
+ ? join(prefix, 'node_modules', NAME)
55
+ : join(prefix, 'lib', 'node_modules', NAME);
56
+ let matches = false;
57
+ try {
58
+ matches = realpathSync(expected) === this.store.packageRoot;
59
+ }
60
+ catch { /* Not this installation. */ }
61
+ if (!matches)
62
+ throw new Error('当前 CLI 不是此 npm 管理的全局安装,未执行更新。请使用原安装方式维护。');
63
+ const registry = new URL(config.registry);
64
+ if (!['https:', 'http:'].includes(registry.protocol) || registry.username || registry.password) {
65
+ throw new Error('npm registry 配置不可用于更新。');
66
+ }
67
+ return { prefix, registry: registry.href };
68
+ }
69
+ status() {
70
+ if (this.skipReason)
71
+ return { currentVersion: this.options.currentVersion, skipped: this.skipReason };
72
+ const state = this.store.read();
73
+ return {
74
+ currentVersion: this.options.currentVersion,
75
+ latestVersion: state.latestVersion,
76
+ lastAttemptAt: state.lastAttemptAt,
77
+ nextCheckAt: state.lastAttemptAt ? state.lastAttemptAt + UPDATE_INTERVAL_MS : undefined,
78
+ pending: this.validPending(state) ? state.pending : undefined,
79
+ };
80
+ }
81
+ validPending(state) {
82
+ return typeof state.pending?.version === 'string'
83
+ && typeof state.pending.token === 'string'
84
+ && /^[a-f0-9-]{36}$/.test(state.pending.token)
85
+ && compareVersions(state.pending.version, this.options.currentVersion) === 1;
86
+ }
87
+ async check(force = false) {
88
+ if (this.skipReason)
89
+ return this.status();
90
+ const now = this.now();
91
+ const due = (state) => !Number.isFinite(state.lastAttemptAt)
92
+ || now < state.lastAttemptAt
93
+ || now - state.lastAttemptAt >= UPDATE_INTERVAL_MS;
94
+ if (!force && !due(this.store.read()))
95
+ return { ...this.status(), cached: true };
96
+ const unlock = this.store.lock('check');
97
+ if (!unlock)
98
+ return { ...this.status(), checking: true };
99
+ try {
100
+ const state = this.store.read();
101
+ if (!force && !due(state))
102
+ return { ...this.status(), cached: true };
103
+ // Persist BEFORE spawning npm: timeout, process death and network failures also get a cooldown.
104
+ state.lastAttemptAt = now;
105
+ this.store.write(state);
106
+ try {
107
+ const run = this.runner();
108
+ const started = Date.now();
109
+ const install = await this.installation(run, 1_200);
110
+ const timeout = Math.max(1, CHECK_TIMEOUT_MS - (Date.now() - started));
111
+ const latest = JSON.parse(await run([
112
+ 'view', NAME, 'version', '--json', '--registry', install.registry,
113
+ '--fetch-retries=0', `--fetch-timeout=${timeout}`,
114
+ ], timeout));
115
+ if (typeof latest !== 'string' || compareVersions(latest, this.options.currentVersion) === undefined) {
116
+ throw new Error('npm 返回的版本号无效。');
117
+ }
118
+ state.latestVersion = latest;
119
+ state.prefix = install.prefix;
120
+ state.registry = install.registry;
121
+ if (compareVersions(latest, this.options.currentVersion) === 1) {
122
+ if (!this.validPending(state) || state.pending.version !== latest) {
123
+ state.pending = { version: latest, token: randomUUID() };
124
+ }
125
+ }
126
+ else
127
+ delete state.pending;
128
+ this.store.write(state);
129
+ return { ...this.status(), checked: true };
130
+ }
131
+ catch {
132
+ // No npm output or credentials are included in this diagnostic.
133
+ return { ...this.status(), checked: false, message: '版本检查未完成,请检查网络、npm 配置及当前 CLI 是否为 npm 全局安装;业务命令继续执行。' };
134
+ }
135
+ }
136
+ finally {
137
+ unlock();
138
+ }
139
+ }
140
+ /** Claim a reminder once per version per day, across processes and Agent sessions. */
141
+ notice(force = false) {
142
+ if (this.skipReason)
143
+ return undefined;
144
+ const cached = this.store.read();
145
+ if (!this.validPending(cached))
146
+ return undefined;
147
+ const now = this.now();
148
+ const ready = (state) => this.validPending(state)
149
+ && (force || (!(state.pending.deferredUntil > now)
150
+ && !(state.pending.notifiedAt > now - UPDATE_INTERVAL_MS)));
151
+ if (!ready(cached))
152
+ return undefined;
153
+ const unlock = this.store.lock('check');
154
+ if (!unlock)
155
+ return undefined;
156
+ try {
157
+ const state = this.store.read();
158
+ if (!ready(state))
159
+ return undefined;
160
+ state.pending.notifiedAt = now;
161
+ this.store.write(state);
162
+ const pending = state.pending;
163
+ return {
164
+ type: 'cli_update_available', currentVersion: this.options.currentVersion, latestVersion: pending.version,
165
+ message: `CLI 当前版本 ${this.options.currentVersion},发现新版 ${pending.version}。请调用宿主的提问/确认工具询问用户是否更新;确认后才执行 commands.update,选择稍后则执行 commands.later。本次业务继续执行,无需重跑。`,
166
+ requiresConfirmation: true, hostAction: 'ask_user', confirmationToken: pending.token,
167
+ commands: {
168
+ update: [NAME, 'update', 'apply', '--confirm', pending.token],
169
+ later: [NAME, 'update', 'defer', '--confirm', pending.token],
170
+ },
171
+ };
172
+ }
173
+ finally {
174
+ unlock();
175
+ }
176
+ }
177
+ defer(token) {
178
+ this.assertEnabled();
179
+ const unlock = this.store.lock('check');
180
+ if (!unlock)
181
+ throw new Error('版本检查正在进行,请稍后重试。');
182
+ try {
183
+ const state = this.confirmedState(token);
184
+ state.pending.deferredUntil = this.now() + UPDATE_INTERVAL_MS;
185
+ this.store.write(state);
186
+ return { deferredUntil: state.pending.deferredUntil, version: state.pending.version };
187
+ }
188
+ finally {
189
+ unlock();
190
+ }
191
+ }
192
+ assertEnabled() {
193
+ if (this.skipReason)
194
+ throw new Error(`当前安装不执行 CLI 自更新(${this.skipReason})。`);
195
+ }
196
+ confirmedState(token) {
197
+ const state = this.store.read();
198
+ if (!token || !this.validPending(state) || state.pending.token !== token) {
199
+ throw new Error('更新确认已失效,请先运行 weaver-work-cli update check,再向用户确认指定版本。');
200
+ }
201
+ return state;
202
+ }
203
+ async apply(token, waitMs = 30_000) {
204
+ this.assertEnabled();
205
+ // An explicit token is required even in non-interactive shells. No default "yes".
206
+ this.confirmedState(token);
207
+ const gate = this.store.lock('gate');
208
+ if (!gate)
209
+ throw new Error('另一更新或命令启动正在进行,请稍后重试。');
210
+ const unlockCheck = this.store.lock('check');
211
+ if (!unlockCheck) {
212
+ gate();
213
+ throw new Error('版本检查正在进行,请稍后重试。');
214
+ }
215
+ try {
216
+ const state = this.confirmedState(token);
217
+ const run = this.runner();
218
+ const install = await this.installation(run, 3_000);
219
+ if (install.prefix !== state.prefix || install.registry !== state.registry) {
220
+ throw new Error('npm 安装位置或源已变化,请重新检查并确认更新。');
221
+ }
222
+ const deadline = Date.now() + waitMs;
223
+ while (this.store.activeProcesses().length) {
224
+ if (Date.now() >= deadline)
225
+ throw new Error('仍有业务命令运行,未修改 CLI 安装。请等待结束后重试更新。');
226
+ await delay(100);
227
+ }
228
+ const version = state.pending.version;
229
+ const before = JSON.parse(readFileSync(join(this.store.packageRoot, 'package.json'), 'utf8'));
230
+ if (before.name !== NAME || before.version !== this.options.currentVersion) {
231
+ throw new Error('CLI 安装已被其他程序修改,请重新检查版本后再确认更新。');
232
+ }
233
+ // Pin the user-confirmed version, target this installation, never sudo or replay business.
234
+ await run([
235
+ 'install', '--global', '--prefix', install.prefix, `${NAME}@${version}`,
236
+ '--registry', install.registry, '--no-audit', '--no-fund', '--fetch-retries=0',
237
+ ], INSTALL_TIMEOUT_MS);
238
+ const installed = JSON.parse(readFileSync(join(this.store.packageRoot, 'package.json'), 'utf8'));
239
+ if (installed.name !== NAME || installed.version !== version)
240
+ throw new Error('安装结果与已确认版本不符,请使用原安装方式修复 CLI。');
241
+ // Keep metadata only. No runtime copies, historical packages or rollback directories.
242
+ delete state.pending;
243
+ state.lastAttemptAt = this.now();
244
+ this.store.write(state);
245
+ return { updated: true, version, packageRoot: this.store.packageRoot, restartRequired: true };
246
+ }
247
+ finally {
248
+ unlockCheck();
249
+ gate();
250
+ }
251
+ }
252
+ }
@@ -0,0 +1,135 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { existsSync, mkdirSync, openSync, closeSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ export const UPDATE_INTERVAL_MS = 24 * 60 * 60_000;
5
+ function alive(pid) {
6
+ if (!Number.isSafeInteger(pid) || pid <= 0)
7
+ return false;
8
+ try {
9
+ process.kill(pid, 0);
10
+ return true;
11
+ }
12
+ catch (error) {
13
+ return error.code !== 'ESRCH';
14
+ }
15
+ }
16
+ export class UpdateStore {
17
+ packageRoot;
18
+ dir;
19
+ statePath;
20
+ constructor(home, packageRoot) {
21
+ this.packageRoot = packageRoot;
22
+ const installation = createHash('sha256').update(packageRoot).digest('hex').slice(0, 24);
23
+ this.dir = join(home, 'state', 'updates', installation);
24
+ this.statePath = join(this.dir, 'state.json');
25
+ }
26
+ read() {
27
+ try {
28
+ const value = JSON.parse(readFileSync(this.statePath, 'utf8'));
29
+ if (value?.schemaVersion === 1 && typeof value === 'object')
30
+ return value;
31
+ }
32
+ catch { /* Missing or corrupt cache is treated as a first check. */ }
33
+ return { schemaVersion: 1 };
34
+ }
35
+ write(state) {
36
+ mkdirSync(this.dir, { recursive: true });
37
+ const temp = join(this.dir, `state-${process.pid}-${randomUUID()}.tmp`);
38
+ try {
39
+ writeFileSync(temp, JSON.stringify(state) + '\n', { mode: 0o600, flag: 'wx' });
40
+ renameSync(temp, this.statePath);
41
+ }
42
+ finally {
43
+ try {
44
+ unlinkSync(temp);
45
+ }
46
+ catch { /* Already renamed. */ }
47
+ }
48
+ }
49
+ /** Never wait for another checker. A dead process's lock is reclaimable. */
50
+ lock(name) {
51
+ mkdirSync(this.dir, { recursive: true });
52
+ const path = join(this.dir, `${name}.lock`);
53
+ const token = randomUUID();
54
+ for (let attempt = 0; attempt < 2; attempt += 1) {
55
+ try {
56
+ const fd = openSync(path, 'wx', 0o600);
57
+ try {
58
+ writeFileSync(fd, JSON.stringify({ pid: process.pid, token }));
59
+ }
60
+ finally {
61
+ closeSync(fd);
62
+ }
63
+ return () => {
64
+ try {
65
+ if (JSON.parse(readFileSync(path, 'utf8')).token === token)
66
+ unlinkSync(path);
67
+ }
68
+ catch { /* Cleanup must not change a business result. */ }
69
+ };
70
+ }
71
+ catch (error) {
72
+ if (error.code !== 'EEXIST')
73
+ throw error;
74
+ try {
75
+ const raw = readFileSync(path, 'utf8');
76
+ let stale = false;
77
+ try {
78
+ stale = !alive(JSON.parse(raw).pid);
79
+ }
80
+ catch {
81
+ stale = Date.now() - statSync(path).mtimeMs > 30_000;
82
+ }
83
+ if (!stale)
84
+ return undefined;
85
+ if (readFileSync(path, 'utf8') === raw)
86
+ unlinkSync(path);
87
+ }
88
+ catch {
89
+ return undefined;
90
+ }
91
+ }
92
+ }
93
+ return undefined;
94
+ }
95
+ /** Register under the same gate held by an installer, before loading runtime chunks. */
96
+ enter() {
97
+ const unlock = this.lock('gate');
98
+ if (!unlock)
99
+ return undefined;
100
+ try {
101
+ const dir = join(this.dir, 'active');
102
+ mkdirSync(dir, { recursive: true });
103
+ const path = join(dir, `${process.pid}-${randomUUID()}`);
104
+ writeFileSync(path, '', { flag: 'wx', mode: 0o600 });
105
+ const release = () => { try {
106
+ unlinkSync(path);
107
+ }
108
+ catch { /* Already released. */ } };
109
+ return release;
110
+ }
111
+ finally {
112
+ unlock();
113
+ }
114
+ }
115
+ activeProcesses() {
116
+ const dir = join(this.dir, 'active');
117
+ if (!existsSync(dir))
118
+ return [];
119
+ const active = new Set();
120
+ for (const entry of readdirSync(dir)) {
121
+ const pid = Number(entry.split('-')[0]);
122
+ if (pid === process.pid)
123
+ continue;
124
+ if (alive(pid))
125
+ active.add(pid);
126
+ else {
127
+ try {
128
+ unlinkSync(join(dir, entry));
129
+ }
130
+ catch { /* Another cleaner won. */ }
131
+ }
132
+ }
133
+ return [...active];
134
+ }
135
+ }
@@ -102,7 +102,7 @@ async function executeAndPrint(ctx, operation, input) {
102
102
  }
103
103
  catch (error) {
104
104
  reportPlatformError(error);
105
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
105
+ ctx.output.error(failureEnvelope(error));
106
106
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
107
107
  }
108
108
  }
@@ -144,7 +144,7 @@ async function executeSearchPrint(ctx, input, format, outputPath) {
144
144
  }
145
145
  catch (error) {
146
146
  reportPlatformError(error);
147
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
147
+ ctx.output.error(failureEnvelope(error));
148
148
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
149
149
  }
150
150
  }
@@ -4,6 +4,7 @@ export const archiveOperations = archiveOperationDefinitions().map((definition)
4
4
  name: definition.name,
5
5
  resource: definition.resource,
6
6
  summary: definition.summary,
7
+ ...(definition.notes ? { notes: definition.notes } : {}),
7
8
  ...(definition.capability ? { capability: definition.capability } : {}),
8
9
  risk: definition.risk,
9
10
  ...(definition.requiresConfirmation ? { requiresConfirmation: true } : {}),
@@ -19,7 +19,9 @@ const searchRun = {
19
19
  resource: 'search',
20
20
  method: 'run',
21
21
  action: 'archive.search.run',
22
- summary: '按关键词全文检索档案(可借档案列表),支持分页;每行除原始字段外会附带 level/fonds/category/dateLabel/dateValue/viewPath 展示字段,结果行的 id 与 formId 用于加入借阅车、发起借阅或拼接 archiveView 链接',
22
+ summary: '按关键词全文检索档案(可借档案列表),支持分页;结果行带展示字段与 id/formId,可直接加入借阅车或发起借阅。',
23
+ notes: '每行除原始字段外会附带 level/fonds/category/dateLabel/dateValue/viewPath 展示字段;'
24
+ + '结果行的 id 与 formId 用于加入借阅车、发起借阅或拼接 archiveView 链接。',
23
25
  capability: 'search',
24
26
  risk: READ,
25
27
  inputSchema: schemaOf({
@@ -119,7 +119,7 @@ async function executeAndPrint(ctx, operation, input) {
119
119
  }
120
120
  catch (error) {
121
121
  reportPlatformError(error);
122
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
122
+ ctx.output.error(failureEnvelope(error));
123
123
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
124
124
  }
125
125
  }
@@ -88,7 +88,7 @@ async function executeAndPrint(ctx, operation, input) {
88
88
  }
89
89
  catch (error) {
90
90
  reportPlatformError(error);
91
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
91
+ ctx.output.error(failureEnvelope(error));
92
92
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
93
93
  }
94
94
  }
@@ -86,7 +86,7 @@ async function executeAndPrint(ctx, operation, input) {
86
86
  }
87
87
  catch (error) {
88
88
  reportPlatformError(error);
89
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
89
+ ctx.output.error(failureEnvelope(error));
90
90
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
91
91
  }
92
92
  }
@@ -104,7 +104,7 @@ async function executeAndPrint(ctx, operation, input) {
104
104
  }
105
105
  catch (error) {
106
106
  reportPlatformError(error);
107
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
107
+ ctx.output.error(failureEnvelope(error));
108
108
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
109
109
  }
110
110
  }
@@ -91,7 +91,7 @@ async function executeAndPrint(ctx, operation, input) {
91
91
  }
92
92
  catch (error) {
93
93
  reportPlatformError(error);
94
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
94
+ ctx.output.error(failureEnvelope(error));
95
95
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
96
96
  }
97
97
  }
@@ -86,7 +86,7 @@ async function executeAndPrint(ctx, operation, input) {
86
86
  }
87
87
  catch (error) {
88
88
  reportPlatformError(error);
89
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
89
+ ctx.output.error(failureEnvelope(error));
90
90
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
91
91
  }
92
92
  }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * BI 组件配置构造(2026-11-28):把「口径 + 期间 + 人员 + 维度」翻译成
3
+ * `POST /api/analyze/designer/bi/component/chart/previewData` 的 `config`。
4
+ *
5
+ * 为什么需要它:台账明细接口是逐行分页(200 行/页、每页 2 个请求)。实测
6
+ * 「吴洋洋 2026 年 11 个月 × 2 个指标」用明细要 ~790 个请求 / 62 秒,
7
+ * 用 BI 聚合只需 **1 个请求**。几十万行级别的统计必须走这条路。
8
+ *
9
+ * 实测结论(2026-11-28,本机 e-cology 环境):
10
+ * - 每个 measure / dimension **必须带 `shortKey`**,否则响应行键为空串(只有值没有标签);
11
+ * - `aggregator` 支持 `SUM` / `COUNT` / `DISTINCTCOUNT`;`COUNT_DISTINCT` 不支持;
12
+ * - `dimensions` 为空时返回单行汇总(适合取窗口合计);
13
+ * - 分组结果**不补 0**:没有数据的月份整行不返回,调用方必须按请求区间补零;
14
+ * - 行键 = 各 measure/dimension 的 `shortKey`,值一律是字符串。
15
+ *
16
+ * ⛔ 本文件只做「配置拼装」,不发请求;认证与发送在 `contract.ledger.bi`。
17
+ */
18
+ export const BI_DEFAULT_DATASET_APP_ID = '846297243998732291';
19
+ /** shortKey 只允许字母数字下划线(会作为 JSON 行键返回,也用于本地映射)。 */
20
+ export function sanitizeShortKey(value) {
21
+ const cleaned = String(value).replace(/[^A-Za-z0-9_]/gu, '_');
22
+ return cleaned || 'k';
23
+ }
24
+ function conditionEntry(cond, index) {
25
+ if (!cond.fieldId) {
26
+ throw new Error(`条件「${cond.field}」缺少字段 ID,无法生成 BI 条件`);
27
+ }
28
+ const fieldId = cond.fieldId;
29
+ return {
30
+ isParent: false,
31
+ parentNode: 'f1',
32
+ id: fieldId,
33
+ fieldName: `field_${fieldId}`,
34
+ fieldType: 'String',
35
+ text: cond.field,
36
+ objId: cond.objId ?? undefined,
37
+ compType: 'Text',
38
+ type: 'condition',
39
+ conditions: {
40
+ func: cond.operator,
41
+ value: cond.value,
42
+ type: '',
43
+ isEsb: false,
44
+ },
45
+ multiSelect: 'false',
46
+ formInfo: { fieldId },
47
+ module: 'ebuilderform',
48
+ mainField: true,
49
+ subTableId: '',
50
+ dbFieldType: 'STRING',
51
+ key: `c${index + 1}`,
52
+ isEdit: '0',
53
+ config: { fieldId },
54
+ };
55
+ }
56
+ function measureEntry(measure, objId) {
57
+ const fieldId = measure.fieldId;
58
+ const dbFieldType = measure.dbFieldType ?? 'NUMBER';
59
+ return {
60
+ id: fieldId,
61
+ name: `field_${fieldId}`,
62
+ text: measure.text,
63
+ columnName: measure.dataKey,
64
+ dbFieldType,
65
+ compType: measure.compType ?? (dbFieldType === 'NUMBER' ? 'Money' : 'Text'),
66
+ type: dbFieldType === 'NUMBER' ? 'Number' : 'String',
67
+ aggregator: measure.aggregator,
68
+ shortKey: measure.shortKey,
69
+ formInfo: { fieldId },
70
+ objId,
71
+ config: { dataKey: measure.dataKey },
72
+ };
73
+ }
74
+ function dimensionEntry(dimension, objId) {
75
+ const fieldId = dimension.fieldId;
76
+ return {
77
+ id: fieldId,
78
+ name: `field_${fieldId}`,
79
+ text: dimension.text,
80
+ columnName: dimension.dataKey,
81
+ dbFieldType: dimension.dbFieldType ?? 'STRING',
82
+ compType: dimension.compType ?? 'Text',
83
+ type: 'String',
84
+ shortKey: dimension.shortKey,
85
+ formInfo: { fieldId },
86
+ objId,
87
+ config: { dataKey: dimension.dataKey },
88
+ };
89
+ }
90
+ /** 组装 previewData 的 `config`(对象形态;调用方按需 JSON.stringify)。 */
91
+ export function buildBiConfig(input) {
92
+ if (!input.objId)
93
+ throw new Error('buildBiConfig:objId 必填(= 台账表单 objId)');
94
+ if (!input.measures.length)
95
+ throw new Error('buildBiConfig:至少一个 measure');
96
+ const objId = input.objId;
97
+ const rootKey = 'f1';
98
+ const leaf = (cond, index, parentNode) => {
99
+ const entry = conditionEntry(cond, index);
100
+ entry.objId = objId;
101
+ entry.parentNode = parentNode;
102
+ return entry;
103
+ };
104
+ const datas = input.conditions.map((cond, index) => leaf(cond, index, rootKey));
105
+ // 或组:根 AND 之下挂 relationship=0 的子组(子组内部 OR)
106
+ (input.orGroups ?? []).forEach((group, groupIndex) => {
107
+ if (!group.length)
108
+ return;
109
+ const groupKey = `g${groupIndex + 1}`;
110
+ datas.push({
111
+ key: groupKey,
112
+ relationship: '0',
113
+ isParent: true,
114
+ parentNode: rootKey,
115
+ datas: group.map((cond, index) => leaf(cond, index, groupKey)),
116
+ });
117
+ });
118
+ return {
119
+ type: 'Bar',
120
+ // 实测:不传 shortKey=true 时响应行键为空串,取不到维度标签
121
+ shortKey: true,
122
+ dataset: {
123
+ sourceType: 'LOGIC',
124
+ id: objId,
125
+ groupId: 'weaver-ebuilder-form-service',
126
+ appId: input.datasetAppId ?? BI_DEFAULT_DATASET_APP_ID,
127
+ servicePath: 'analyze/designer',
128
+ text: input.datasetText ?? objId,
129
+ dataSetNameLabelId: '-1',
130
+ type: 'LOGIC',
131
+ },
132
+ filter: {
133
+ key: rootKey,
134
+ relationship: '1',
135
+ isParent: true,
136
+ isNewFilter: true,
137
+ parentNode: '',
138
+ version: 1,
139
+ datas,
140
+ },
141
+ measures: input.measures.map((measure) => measureEntry(measure, objId)),
142
+ dimensions: input.dimensions.map((dimension) => dimensionEntry(dimension, objId)),
143
+ tools: false,
144
+ precision: 2,
145
+ };
146
+ }
147
+ /** BI 行里的值都是字符串,可能带千分位;统一转数值。 */
148
+ export function biNumber(value) {
149
+ if (typeof value === 'number')
150
+ return Number.isFinite(value) ? value : 0;
151
+ if (value === null || value === undefined)
152
+ return 0;
153
+ const text = String(value).replace(/[,,\s]/gu, '');
154
+ const parsed = Number(text);
155
+ return Number.isFinite(parsed) ? parsed : 0;
156
+ }