weaver-work-cli 0.1.71 → 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 (324) hide show
  1. package/README.md +37 -1
  2. package/dist/chunks/{archive-5P33NAUN.js → archive-OZJ6PYUR.js} +14 -9
  3. package/dist/chunks/{archive-oa-YTY5D7DG.js → archive-oa-BHL5RK2F.js} +10 -7
  4. package/dist/chunks/{asset-3Q5MFQBX.js → asset-HKRFRQR2.js} +10 -7
  5. package/dist/chunks/{asset-idle-PQPNYIS7.js → asset-idle-GGIR4KE7.js} +7 -4
  6. package/dist/chunks/{attachment-content-7CN7JB6B.js → attachment-content-4OV65NK5.js} +3 -3
  7. package/dist/chunks/{blog-MFHHK6ZR.js → blog-HYDP4DV3.js} +10 -7
  8. package/dist/chunks/{caizhilian-OZ435AYW.js → caizhilian-JS4RQZ6Z.js} +10 -7
  9. package/dist/chunks/{calendar-TNJXS5UC.js → calendar-SWRY4DIT.js} +10 -7
  10. package/dist/chunks/chunk-257JXJGD.js +30 -0
  11. package/dist/chunks/{chunk-FRMDHZSN.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-X2C5CGGM.js → chunk-4FCBEWNB.js} +74 -68
  15. package/dist/chunks/{chunk-YN5SD4TX.js → chunk-5D2V7ZAN.js} +2 -2
  16. package/dist/chunks/{chunk-UPVAQJKS.js → chunk-5QUTQHXF.js} +282 -158
  17. package/dist/chunks/{chunk-SKWKCLJX.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-VMVMEIL3.js → chunk-BSR5TM7U.js} +4 -4
  21. package/dist/chunks/{chunk-EJLP63UO.js → chunk-ERZY6GYL.js} +7 -3
  22. package/dist/chunks/{chunk-OFCF23FY.js → chunk-FEZK536Z.js} +25 -9
  23. package/dist/chunks/{chunk-Q3EXRNB4.js → chunk-I6NOHKEK.js} +1 -1
  24. package/dist/chunks/{chunk-OZ7CJC7W.js → chunk-J7FAAHWH.js} +2 -2
  25. package/dist/chunks/{chunk-6MMSLE6K.js → chunk-JJONWB5N.js} +16 -2
  26. package/dist/chunks/chunk-JOY3HZXL.js +467 -0
  27. package/dist/chunks/{chunk-2DNCKZRX.js → chunk-JWF2R6EQ.js} +0 -462
  28. package/dist/chunks/{chunk-ICNUOWLL.js → chunk-KEA4XQPO.js} +4 -4
  29. package/dist/chunks/chunk-KINXYJXM.js +205 -0
  30. package/dist/chunks/{chunk-VJWVB55R.js → chunk-KWJEICD4.js} +2 -2
  31. package/dist/chunks/{chunk-P3AFNAJ6.js → chunk-LJI4N6FV.js} +1 -1
  32. package/dist/chunks/{chunk-DRJYPXKC.js → chunk-MXCRKXOP.js} +48 -6
  33. package/dist/chunks/{chunk-OPTJ6IF7.js → chunk-NWYHCZTY.js} +1 -1
  34. package/dist/chunks/chunk-OJ4JPD25.js +428 -0
  35. package/dist/chunks/{chunk-B4NINGP2.js → chunk-OQCK5SAU.js} +2 -2
  36. package/dist/chunks/chunk-PG5YSNYY.js +1166 -0
  37. package/dist/chunks/{chunk-LU2SPJYY.js → chunk-QJWVYOOV.js} +2 -2
  38. package/dist/chunks/{chunk-SUWR5QEG.js → chunk-QVKRNL7L.js} +287 -305
  39. package/dist/chunks/chunk-SU6IJD6D.js +49 -0
  40. package/dist/chunks/{chunk-MD5RXRI3.js → chunk-TA2RBUTH.js} +2 -2
  41. package/dist/chunks/{chunk-SSS75WXW.js → chunk-U6Y32KEV.js} +2 -2
  42. package/dist/chunks/chunk-UUJK76HV.js +209 -0
  43. package/dist/chunks/{chunk-GB2MCJPG.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-G7ZM2VOX.js → chunk-ZUB4M4N3.js} +38 -36
  47. package/dist/chunks/{chunk-XLSJC6JZ.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-Y4PXZ2YQ.js → conflict-5BKCDV2F.js} +2 -2
  51. package/dist/chunks/{contract-C3BGUMBM.js → contract-WI23OXVC.js} +12446 -5964
  52. package/dist/chunks/{cowork-2AWG4QLA.js → cowork-DZBBVNMQ.js} +11 -8
  53. package/dist/chunks/{create-flow-LOUOK46Z.js → create-flow-7ZRBRKX7.js} +6 -6
  54. package/dist/chunks/{data-BSFYMXVO.js → data-PAZVE6QE.js} +6 -3
  55. package/dist/chunks/{ebuilder-form-LAAMTD2Y.js → ebuilder-form-5SQXIGXN.js} +9 -6
  56. package/dist/chunks/{ehr-36KEX5SH.js → ehr-CX5F4ZAU.js} +27 -19
  57. package/dist/chunks/{entry-mode-6N2IGCS4.js → entry-mode-I2BYNONZ.js} +3 -3
  58. package/dist/chunks/{env-QYLS3EB3.js → env-ZAQZ7EHN.js} +2 -2
  59. package/dist/chunks/{esb-PTYS3E67.js → esb-DQTXDIBF.js} +10 -7
  60. package/dist/chunks/{factory-LPFPKZ4T.js → factory-XRI6KZ7H.js} +1 -1
  61. package/dist/chunks/{fna-JNHCLRDE.js → fna-FK6HQVJL.js} +13 -8
  62. package/dist/chunks/{group-chat-QP2WX4QJ.js → group-chat-MLWNYM2P.js} +3 -3
  63. package/dist/chunks/{host-C2BLBIID.js → host-3EPREGXS.js} +6 -3
  64. package/dist/chunks/{host-QXFKQXNX.js → host-J74JGYAW.js} +6 -3
  65. package/dist/chunks/{host-57LSRSE7.js → host-KUMU3DDK.js} +6 -3
  66. package/dist/chunks/{host-7BVR7CQ3.js → host-MEC4VQZA.js} +6 -3
  67. package/dist/chunks/{host-NS36QFLR.js → host-T6NNQGVZ.js} +6 -3
  68. package/dist/chunks/{host-K2ZKNXME.js → host-VI7Q45PM.js} +6 -3
  69. package/dist/chunks/{hrm-FSGO4NSH.js → hrm-KKVAW4P5.js} +8 -5
  70. package/dist/chunks/{im-2BFGS2XO.js → im-47CIWQNL.js} +7 -4
  71. package/dist/chunks/{invoice-JKLTTHSZ.js → invoice-CDYRBNIG.js} +21 -16
  72. package/dist/chunks/{jiuchuanhui-PTABJE7V.js → jiuchuanhui-M7QTRHZK.js} +17 -10
  73. package/dist/chunks/{lazy-dispatch-YN2ZP3CS.js → lazy-dispatch-FKQJZFI5.js} +22 -8
  74. package/dist/chunks/{mail-YNO7ZZUK.js → mail-NRBS5N6Y.js} +11 -8
  75. package/dist/chunks/{meeting-NIDHDBCB.js → meeting-WC5LD3IO.js} +22 -18
  76. package/dist/chunks/{minute-doc-G3QAT7DE.js → minute-doc-OQUMDTKG.js} +4 -4
  77. package/dist/chunks/{okr-QC52G6AJ.js → okr-EHKSKMPL.js} +10 -7
  78. package/dist/chunks/{operations-MQV32ITT.js → operations-V5VM5MS2.js} +7 -4
  79. package/dist/chunks/{performance-3MQ3AHDQ.js → performance-ZJADXJPN.js} +6 -3
  80. package/dist/chunks/{plan-ISINIEPY.js → plan-OTDNBDJ7.js} +10 -7
  81. package/dist/chunks/{project-IJ6DVKT7.js → project-4XVBQ3HX.js} +10 -7
  82. package/dist/chunks/{reception-3H5LUG2I.js → reception-3FAHOOH7.js} +118 -45
  83. package/dist/chunks/{recruit-stage-MIOJXP6W.js → recruit-stage-3WTVWW2K.js} +1056 -191
  84. package/dist/chunks/register-SQOPIR2G.js +16 -0
  85. package/dist/chunks/{registry-3S7AVMXR.js → registry-F4YFZLOD.js} +7 -3
  86. package/dist/chunks/registry-NBTBXR4L.js +30 -0
  87. package/dist/chunks/{registry-NHHKOEU3.js → registry-TJGCVRCW.js} +7 -4
  88. package/dist/chunks/{room-recommend-IOKBJVYP.js → room-recommend-KL62XB2Y.js} +4 -4
  89. package/dist/chunks/root-YZG2TS5W.js +16 -0
  90. package/dist/chunks/{schedule-IB6EUARH.js → schedule-XOISYUPB.js} +4 -4
  91. package/dist/chunks/{smart-extract-N2TK3CEF.js → smart-extract-UYGNV3BM.js} +15 -7
  92. package/dist/chunks/update-AV5VOXGY.js +13 -0
  93. package/dist/chunks/{workflow-RINBAL2M.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 +12 -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 +11 -5
  161. package/dist/shortcuts/ehr/operations/recruit-short-cache.js +6 -2
  162. package/dist/shortcuts/ehr/operations/recruit-write.js +10 -9
  163. package/dist/shortcuts/ehr/operations/recruit.js +390 -196
  164. package/dist/shortcuts/ehr/operations/shared.js +51 -0
  165. package/dist/shortcuts/esb/index.js +1 -1
  166. package/dist/shortcuts/fna/index.js +1 -1
  167. package/dist/shortcuts/fna/manifest.js +1 -0
  168. package/dist/shortcuts/fna/operations/expense-chart.js +3 -1
  169. package/dist/shortcuts/hrm/index.js +1 -1
  170. package/dist/shortcuts/invoice/index.js +1 -1
  171. package/dist/shortcuts/jiuchuanhui/index.js +2 -2
  172. package/dist/shortcuts/jiuchuanhui/manifest.js +3 -0
  173. package/dist/shortcuts/mail/index.js +2 -2
  174. package/dist/shortcuts/meeting/index.js +1 -1
  175. package/dist/shortcuts/meeting/manifest.js +1 -0
  176. package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -3
  177. package/dist/shortcuts/meeting/operations/eb/conflict.js +3 -1
  178. package/dist/shortcuts/meeting/operations/eb/create-flow.js +10 -9
  179. package/dist/shortcuts/meeting/operations/eb/factory.js +2 -0
  180. package/dist/shortcuts/meeting/operations/eb/member-expand.js +3 -2
  181. package/dist/shortcuts/meeting/operations/invitation-publish.js +3 -3
  182. package/dist/shortcuts/meeting/operations/invitation.js +4 -4
  183. package/dist/shortcuts/meeting/operations/link.js +3 -1
  184. package/dist/shortcuts/okr/index.js +1 -1
  185. package/dist/shortcuts/performance/index.js +1 -1
  186. package/dist/shortcuts/plan/index.js +1 -1
  187. package/dist/shortcuts/project/index.js +1 -1
  188. package/dist/shortcuts/reception/constants.js +22 -0
  189. package/dist/shortcuts/reception/index.js +4 -0
  190. package/dist/shortcuts/reception/manifest.js +16 -2
  191. package/dist/shortcuts/reception/operations/doc.js +24 -11
  192. package/dist/shortcuts/reception/operations/docrender.js +18 -1
  193. package/dist/shortcuts/reception/operations/render-assets.js +93 -22
  194. package/dist/shortcuts/recruit-stage/context.js +22 -8
  195. package/dist/shortcuts/recruit-stage/index.js +16 -3
  196. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +20 -11
  197. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +1 -1
  198. package/dist/shortcuts/recruit-stage/operations/jd-create.js +467 -26
  199. package/dist/shortcuts/recruit-stage/operations/list.js +73 -2
  200. package/dist/shortcuts/recruit-stage/operations/profile.js +13 -5
  201. package/dist/shortcuts/recruit-stage/operations/registry.js +18 -2
  202. package/dist/shortcuts/recruit-stage/operations/resume-import.js +363 -54
  203. package/dist/shortcuts/recruit-stage/operations/search.js +80 -16
  204. package/dist/shortcuts/recruit-stage/operations/shortlist.js +124 -0
  205. package/dist/shortcuts/recruit-stage/shared.js +174 -56
  206. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  207. package/dist/shortcuts/smart-extract/operations/fill.js +7 -2
  208. package/dist/shortcuts/smart-extract/operations/validate.js +4 -1
  209. package/dist/shortcuts/workflow/index.js +2 -2
  210. package/dist/shortcuts/workflow/manifest.js +1 -0
  211. package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +4 -1
  212. package/dist/shortcuts/workflow/operations/deepRead.js +23 -2
  213. package/dist/shortcuts/workflow/operations/form.js +44 -4
  214. package/docs/contract.md +6 -1
  215. package/docs/e10-auth.md +25 -7
  216. package/docs/operation-manual.md +15 -0
  217. package/package.json +2 -2
  218. package/scripts/pysite/__pycache__/sitecustomize.cpython-314.pyc +0 -0
  219. package/skill-template/business-info.json +28 -0
  220. package/skill-template/domains/jinchengda.md +13 -1
  221. package/skills/weaver-e10-archive-oa/references/source-manifest.json +3 -3
  222. package/skills/weaver-e10-caizhilian/references/auth-and-install.md +2 -1
  223. package/skills/weaver-e10-caizhilian/references/source-manifest.json +3 -3
  224. package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
  225. package/skills/weaver-e10-jinchengda/SKILL.md +90 -32
  226. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +45 -0
  227. package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +68 -0
  228. package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +216 -0
  229. package/skills/weaver-e10-jinchengda/references/contract-clause-negotiate.md +215 -0
  230. package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +113 -0
  231. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +19 -3
  232. package/skills/weaver-e10-jinchengda/references/contract-decisions.md +114 -0
  233. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -44
  234. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +1 -1
  235. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +1 -1
  236. package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +200 -0
  237. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -1
  238. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +138 -3
  239. package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +158 -0
  240. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +3 -1
  241. package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +139 -0
  242. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +2 -2
  243. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +10 -3
  244. package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +106 -0
  245. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
  246. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +176 -56
  247. package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +123 -0
  248. package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +410 -0
  249. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  250. package/skills/weaver-e10-jinchengda/references/contract-viewlink.md +110 -0
  251. package/skills/weaver-e10-jinchengda/references/orchestration.md +38 -24
  252. package/skills/weaver-e10-jucailin/SKILL.md +7 -3
  253. package/skills/weaver-e10-jucailin/references/recruit-output-links.md +33 -0
  254. package/skills/weaver-e10-jucailin/references/recruit-write.md +2 -0
  255. package/skills/weaver-e10-meeting/SKILL.md +13 -0
  256. package/skills/weaver-e10-okr/SKILL.md +11 -0
  257. package/skills/weaver-e10-okr/references/source-manifest.json +7 -6
  258. package/skills/weaver-e10-performance/SKILL.md +131 -39
  259. package/skills/weaver-e10-performance/agents/openai.yaml +48 -17
  260. package/skills/weaver-e10-performance/references/default-assembly.md +3 -0
  261. package/skills/weaver-e10-performance/references/extraction-guide.md +17 -3
  262. package/skills/weaver-e10-performance/references/flow-assess.md +38 -5
  263. package/skills/weaver-e10-performance/references/scheme-setting-page.md +20 -3
  264. package/skills/weaver-e10-performance/scripts/assemble_scheme.py +461 -0
  265. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +41 -0
  266. package/skills/weaver-e10-plan/SKILL.md +10 -0
  267. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  268. package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
  269. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  270. package/skills/weaver-e10-reception-flow/SKILL.md +97 -41
  271. package/skills/weaver-e10-reception-flow/references/guide.md +3 -1
  272. package/skills/weaver-e10-recruit-stage/SKILL.md +533 -137
  273. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +103 -62
  274. package/skills/weaver-e10-recruit-stage/lib/interview-conflict.mjs +282 -0
  275. package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +331 -0
  276. package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +865 -0
  277. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +162 -11
  278. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +15 -1
  279. package/skills/weaver-e10-recruit-stage/lib/report-attachment.mjs +38 -0
  280. package/skills/weaver-e10-recruit-stage/lib/xiaoe-session.mjs +5 -1
  281. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +6 -2
  282. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +4 -0
  283. package/skills/weaver-e10-recruit-stage/references/position-templates.md +26 -21
  284. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +33 -27
  285. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +11 -7
  286. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +5 -1
  287. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +5 -1
  288. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +22 -5
  289. package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +42 -0
  290. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +11 -7
  291. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +87 -50
  292. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +4 -0
  293. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -0
  294. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +48 -3
  295. package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +45 -0
  296. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +17 -11
  297. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +8 -4
  298. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +162 -31
  299. package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +55 -0
  300. package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +75 -0
  301. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +4 -0
  302. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +12 -8
  303. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +8 -4
  304. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +80 -46
  305. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +11 -7
  306. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +12 -8
  307. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +10 -6
  308. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +15 -11
  309. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +7 -3
  310. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +7 -3
  311. package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +119 -0
  312. package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +322 -0
  313. package/skills/weaver-e10-recruit-stage/templates/match-report.html +166 -76
  314. package/skills/weaver-e10-shared/SKILL.md +40 -5
  315. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +11 -1
  316. package/skills/weaver-e10-shared/references/json-output-contract.md +144 -8
  317. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +11 -0
  318. package/skills/weaver-e10-shijingran/references/source-manifest.json +3 -3
  319. package/skills/weaver-e10-wenshuding/references/source-manifest.json +3 -3
  320. package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
  321. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +5 -5
  322. package/dist/chunks/chunk-MZVQKQP5.js +0 -2849
  323. package/dist/chunks/registry-3GQRYP2R.js +0 -27
  324. package/skills/weaver-e10-jucailin/references/source-manifest.json +0 -152
@@ -0,0 +1,865 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * recruit-shortlist.mjs —— 简历检索与人岗匹配的**唯一执行入口**(2026-11-28 新增)
4
+ *
5
+ * 设计目标:让智能体「一条命令、一次就对」,不再手写复合 PowerShell、不再逐条调 CLI。
6
+ *
7
+ * node lib/recruit-shortlist.mjs fetch --keyword "Java开发" --limit 5 --out-dir <产物目录>
8
+ * node lib/recruit-shortlist.mjs build --data <evidence.json> --out-html <报告.html>
9
+ *
10
+ * 为什么这样调用是安全的(对应 §2.1 纪律,均已实测):
11
+ * · 无 JSON 内联 —— PowerShell 会剥离参数内双引号,纯 ASCII 也失败;
12
+ * · 无引号嵌套 / 无 `[Type]::Method()` / 无多语句拼接 —— 否则工具层解析失败,整批作废;
13
+ * · 无 `$var` 存命令名 —— 否则被安全校验拦为「无法静态识别动态命令名」;
14
+ * · 中文作普通参数值实测无损(码点逐字一致),故 --keyword 可直接传中文。
15
+ *
16
+ * 内部纪律:
17
+ * · 调 CLI 一律 `execFile(process.execPath, [dist/index.js, ...])`,**不调 .cmd/.ps1**
18
+ * (Node 20+ 因 CVE-2024-27980 对 .cmd 报 EINVAL);
19
+ * · operation 参数一律写临时 UTF-8 文件经 --input 传入,不经 shell;
20
+ * · `shortlist` 需 CLI ≥ 0.1.71(2026-11-28 实测 0.1.71 可直接用,非 0.1.72);返回 operation_unknown 时**自动降级**为
21
+ * candidate.search + 并发 candidate.profile,不报错、不中断(降级时 search 只认 pageSize);
22
+ * · 校验内建:build 会编译模板内联脚本并核对注入数据,返回机器可判定的 checks。
23
+ */
24
+ import { execFile } from "node:child_process";
25
+ import { promisify } from "node:util";
26
+ import { mkdtemp, writeFile, readFile, rm, mkdir, stat } from "node:fs/promises";
27
+ import { existsSync, readFileSync } from "node:fs";
28
+ import os from "node:os";
29
+ import path from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import { publishReport } from "./report-attachment.mjs";
32
+
33
+ const execFileAsync = promisify(execFile);
34
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
35
+ const SKILL_DIR = path.resolve(HERE, "..");
36
+ const TEMPLATE = path.join(SKILL_DIR, "templates", "candidate-evidence.html");
37
+ const PLACEHOLDER = "__EVIDENCE_DATA_PLACEHOLDER__";
38
+ // 合规:不得把任何具体系统地址写成默认值(客户下载后会误连他方系统)。
39
+ // baseUrl 只来自 ① --base-url ② CLI 回包 ③ 会话 hostname;都拿不到就报错让调用方显式给。
40
+ const DEFAULT_BASE_URL = "";
41
+ const CLI_REL = path.join("weaver-work-cli", "dist", "index.js");
42
+
43
+ /* ══════════════════════ CLI 入口探测(照 recruit-write-helper.mjs 的已验证模式)══════════════════════ */
44
+
45
+ function firstExisting(paths) {
46
+ for (const p of paths) {
47
+ if (!p) continue;
48
+ try { if (existsSync(p)) return p; } catch { /* 忽略不可读路径,继续下一个候选 */ }
49
+ }
50
+ return null;
51
+ }
52
+
53
+ /** 从 PATH 里的 weaver-work-cli shim 反推真实 dist/index.js */
54
+ function fromPathShim() {
55
+ const sep = process.platform === "win32" ? ";" : ":";
56
+ const dirs = String(process.env.PATH || "").split(sep).filter(Boolean);
57
+ const names = process.platform === "win32"
58
+ ? ["weaver-work-cli.cmd", "weaver-work-cli.ps1", "weaver-work-cli"]
59
+ : ["weaver-work-cli"];
60
+ for (const d of dirs) {
61
+ for (const n of names) {
62
+ const shim = path.join(d, n);
63
+ if (!existsSync(shim)) continue;
64
+ // shim 同级或上级的 node_modules 里找
65
+ const cands = [
66
+ path.join(d, "node_modules", CLI_REL),
67
+ path.join(d, "..", "lib", "node_modules", CLI_REL),
68
+ path.join(d, "..", "node_modules", CLI_REL),
69
+ ];
70
+ const hit = firstExisting(cands);
71
+ if (hit) return hit;
72
+ // .cmd 内容形如 "%~dp0node.exe" "%~dp0node_modules/weaver-work-cli/dist/index.js"
73
+ try {
74
+ const body = readFileSync(shim, "utf8");
75
+ const m = body.match(/node_modules[\\/]+weaver-work-cli[\\/]+dist[\\/]+index\.js/);
76
+ if (m) {
77
+ const abs = path.resolve(d, m[0].replace(/\\/g, path.sep));
78
+ if (existsSync(abs)) return abs;
79
+ }
80
+ } catch { /* 读不了就跳过 */ }
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+
86
+ /** npm 全局根(POSIX 标准位置 + 当前 node 自身旁) */
87
+ function fromGlobalRoots() {
88
+ const out = [];
89
+ const home = os.homedir();
90
+ if (process.platform === "win32") {
91
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
92
+ out.push(path.join(appData, "npm", "node_modules", CLI_REL));
93
+ } else {
94
+ out.push("/usr/local/lib/node_modules/" + CLI_REL);
95
+ out.push("/usr/lib/node_modules/" + CLI_REL);
96
+ out.push(path.join(home, ".npm-global", "lib", "node_modules", CLI_REL));
97
+ }
98
+ const execDir = path.dirname(process.execPath);
99
+ out.push(path.join(execDir, "node_modules", CLI_REL));
100
+ out.push(path.join(execDir, "lib", "node_modules", CLI_REL));
101
+ return firstExisting(out);
102
+ }
103
+
104
+ /** 从技能包位置向上找(源码仓 / 已安装包里自带 node_modules 时命中) */
105
+ function fromSkillTree() {
106
+ const out = [];
107
+ let dir = HERE;
108
+ for (let i = 0; i < 8; i++) {
109
+ out.push(path.join(dir, "node_modules", CLI_REL));
110
+ const up = path.dirname(dir);
111
+ if (up === dir) break;
112
+ dir = up;
113
+ }
114
+ return firstExisting(out);
115
+ }
116
+
117
+ function resolveCliEntry(explicit) {
118
+ const candidates = [
119
+ () => explicit || "", // ⓪ --cli 显式指定(测试/非常规部署)
120
+ () => process.env.WEAVER_WORK_CLI_ENTRY || "", // ① 环境变量
121
+ fromSkillTree, // ② 技能树内
122
+ fromGlobalRoots, // ③ 全局包
123
+ fromPathShim, // ④ PATH shim 反推
124
+ ];
125
+ for (const cand of candidates) {
126
+ let p = "";
127
+ try { p = cand(); } catch { continue; }
128
+ if (p && existsSync(p)) return p;
129
+ }
130
+ return null;
131
+ }
132
+
133
+ /* ══════════════════════ CLI 调用(参数走临时文件,不经 shell)══════════════════════ */
134
+
135
+ async function runOp(cliEntry, operation, payload, timeout = 180000) {
136
+ const dir = await mkdtemp(path.join(os.tmpdir(), "rsl-"));
137
+ const tmp = path.join(dir, "in.json");
138
+ try {
139
+ await writeFile(tmp, JSON.stringify(payload), "utf8");
140
+ const cliProfile = String(process.env.RECRUIT_CLI_PROFILE || "").trim();
141
+ const args = [cliEntry, "--json"];
142
+ if (cliProfile) args.push("--profile", cliProfile);
143
+ args.push("recruit-stage", "run", operation, "--input", tmp, "--allow-file-input");
144
+ let stdout = "";
145
+ try {
146
+ const r = await execFileAsync(process.execPath, args, {
147
+ encoding: "utf8", maxBuffer: 64 * 1024 * 1024, timeout, windowsHide: true,
148
+ });
149
+ stdout = r.stdout || "";
150
+ } catch (e) {
151
+ // CLI 失败时错误 JSON 可能在 stdout 或 stderr,都要尝试解析
152
+ stdout = String((e && e.stdout) || "") || String((e && e.stderr) || "");
153
+ if (!stdout.trim()) throw new Error(`${operation} 无输出:${String((e && e.message) || e).slice(0, 200)}`);
154
+ }
155
+ const raw = stdout.trim();
156
+ let data;
157
+ try { data = JSON.parse(raw); }
158
+ catch { throw new Error(`${operation} 返回非 JSON:${raw.slice(0, 200)}`); }
159
+ if (data.ok === false) {
160
+ const err = data.error || {};
161
+ const e = new Error(`${operation} 失败:${err.message || data.message || "未知"}`);
162
+ e.subtype = err.subtype || "";
163
+ e.type = err.type || "";
164
+ throw e;
165
+ }
166
+ return data;
167
+ } finally {
168
+ await rm(dir, { recursive: true, force: true }).catch(() => {});
169
+ }
170
+ }
171
+
172
+ /* ══════════════════════ 档案精简与素材裁剪 ══════════════════════ */
173
+
174
+ const range = (a, b) => {
175
+ if (!a && !b) return "—";
176
+ if (a && b) return `${String(a).slice(0, 7)} ~ ${String(b).slice(0, 7)}`;
177
+ return `${String(a || "—").slice(0, 7)} 起`;
178
+ };
179
+ const cut = (s, n) => {
180
+ const t = String(s == null ? "" : s).replace(/\s+/g, " ").trim();
181
+ return t.length > n ? t.slice(0, n) + "…" : t;
182
+ };
183
+
184
+ /** profile 回执 → 报告契约所需的候选人骨架(AI 只需补 level/verdict/evidence/risk) */
185
+ function toCandidate(prof, searchRow) {
186
+ const basic = prof?.basic || {};
187
+ const rawMain = prof?.rawMain || {};
188
+ const works = (prof?.workExperience || []).map((w) => ({
189
+ co: w.co_name || "—",
190
+ pos: w.work_position || "",
191
+ range: range(w.start_end_date_0, w.start_end_date_1),
192
+ desc: w.work_desc || "",
193
+ }));
194
+ const projs = (prof?.projectExperience || []).map((p) => ({
195
+ name: p.pj_name || "—",
196
+ range: range(p.pj_date_0, p.pj_date_1),
197
+ desc: p.pj_introduction || "",
198
+ }));
199
+ const latest = works[0] || {};
200
+ return {
201
+ talentId: prof?.talentId || searchRow?.talentId || "",
202
+ name: basic.name || searchRow?.name || "",
203
+ degree: basic.degree || "—",
204
+ college: basic.college || "—",
205
+ pos: basic.current_position || latest.pos || basic.intend_position || "—",
206
+ industry: basic.current_industry || "—",
207
+ // 供 AI 评估用、但不进报告卡片的辅助字段
208
+ _meta: {
209
+ expectSalary: basic.expect_salary || "",
210
+ location: basic.location_area || "",
211
+ workYears: rawMain.work_exp || "",
212
+ graduateDate: basic.graduate_date || "",
213
+ intendPosition: basic.intend_position || "",
214
+ recruitStatus: basic.recruit_status || "",
215
+ channel: basic.channel || searchRow?.channel || "",
216
+ selfDesc: cut(basic.self_desc || "", 300),
217
+ createTime: searchRow?.createTime || "",
218
+ },
219
+ works,
220
+ projs,
221
+ // ↓ 这四个字段由 AI 依据原文填写,脚本不臆造
222
+ level: "",
223
+ verdict: "",
224
+ evidence: "",
225
+ risk: "",
226
+ };
227
+ }
228
+
229
+ /** stdout 紧凑素材:让 AI 一次拿够评估依据,无需再读文件(控制在约 8KB 内) */
230
+ function compactForStdout(c) {
231
+ return {
232
+ name: c.name, degree: c.degree, college: c.college, pos: c.pos,
233
+ meta: c._meta,
234
+ works: c.works.slice(0, 3).map((w) => ({ co: w.co, pos: w.pos, range: w.range, desc: cut(w.desc, 150) })),
235
+ projs: c.projs.slice(0, 4).map((p) => ({ name: p.name, range: p.range, desc: cut(p.desc, 150) })),
236
+ moreWorks: Math.max(0, c.works.length - 3),
237
+ moreProjs: Math.max(0, c.projs.length - 4),
238
+ };
239
+ }
240
+
241
+ /* ══════════════════════ stdout 输出预算与分级裁剪(2026-11-28)══════════════════════
242
+ * 背景:简历字段数不可控——实测自我评价最长 832 字、单段工作描述 379 字、项目最多 5 条;
243
+ * 10 人原始档案合计 20.4KB(其中 rawMain 冗余占 25%)。字段多的批次一旦全量回显,
244
+ * 会撑大上下文、拖慢推理。故 stdout 采用「总预算 + 逐级裁剪」:默认给足细节,
245
+ * 超预算自动降档,任何批次都有硬上限。
246
+ *
247
+ * 🔴 分级只裁细节,不动判断依据:
248
+ * L0 完整 desc 150 / selfDesc 300 / works 3 / projs 4
249
+ * L1 缩描述 desc 100 / selfDesc 150 / works 3 / projs 3
250
+ * L2 缩条数 desc 70 / selfDesc 80 / works 2 / projs 2
251
+ * L3 砍自评 desc 45 / selfDesc 0 / works 2 / projs 2
252
+ * L4 极限 desc 30 / selfDesc 0 / works 1 / projs 1(仍保留公司名与职位名)
253
+ * --brief 只回决策摘要,不给描述(需读 draft 补证据,最省体积)
254
+ *
255
+ * 🔴 永不裁剪(人岗判断必需):姓名 / 学历 / 院校 / 当前职位 / 公司名 / 职位名 / 起止时间 /
256
+ * projs 名称与时间 / meta 的薪资·地点·年限·毕业时间·意向职位·状态·渠道。
257
+ * 🔴 draft 始终完整落盘(含全文描述),stdout 裁掉的内容随时可从 evidence_draft.json 补读,
258
+ * 故裁剪只省上下文,不丢信息。
259
+ */
260
+ const OUTPUT_LEVELS = [
261
+ { tag: 'L0 完整', desc: 150, selfDesc: 300, works: 3, projs: 4 },
262
+ { tag: 'L1 缩描述', desc: 100, selfDesc: 150, works: 3, projs: 3 },
263
+ { tag: 'L2 缩条数', desc: 70, selfDesc: 80, works: 2, projs: 2 },
264
+ { tag: 'L3 砍自评', desc: 45, selfDesc: 0, works: 2, projs: 2 },
265
+ { tag: 'L4 极限', desc: 30, selfDesc: 0, works: 1, projs: 1 },
266
+ ];
267
+
268
+ /** 默认 stdout 预算(字符):实测 10 人 L0 档约 8.1KB,9KB 可容纳多数批次停在 L0/L1;字段特别多时才降档 */
269
+ const DEFAULT_MAX_OUTPUT = 9216;
270
+
271
+ function compactOne(c, cfg) {
272
+ const meta = { ...c._meta };
273
+ if (cfg.selfDesc <= 0) delete meta.selfDesc;
274
+ else if (meta.selfDesc) meta.selfDesc = cut(meta.selfDesc, cfg.selfDesc);
275
+ const out = {
276
+ talentId: c.talentId,
277
+ name: c.name, degree: c.degree, college: c.college, pos: c.pos, industry: c.industry,
278
+ meta,
279
+ works: c.works.slice(0, cfg.works).map((w) => ({ co: w.co, pos: w.pos, range: w.range, desc: cut(w.desc, cfg.desc) })),
280
+ projs: c.projs.slice(0, cfg.projs).map((p) => ({ name: p.name, range: p.range, desc: cut(p.desc, cfg.desc) })),
281
+ };
282
+ const mw = c.works.length - cfg.works;
283
+ const mp = c.projs.length - cfg.projs;
284
+ if (mw > 0) out.moreWorks = mw;
285
+ if (mp > 0) out.moreProjs = mp;
286
+ if (c._precision === true) out.precision = true;
287
+ return out;
288
+ }
289
+
290
+ // --brief:stdout 只回决策必需的摘要,完整 works/projs 留在 draft 文件里按需读。
291
+ // 实测一次 10 人的完整素材约 20KB,摘要模式降到约 2KB,省的是阅读时间而不是网络时间。
292
+ function briefForStdout(c) {
293
+ const m = c._meta || {};
294
+ return {
295
+ talentId: c.talentId,
296
+ name: c.name,
297
+ degree: c.degree,
298
+ college: c.college,
299
+ pos: c.pos,
300
+ industry: c.industry,
301
+ workYears: m.workYears || "",
302
+ expectSalary: m.expectSalary || "",
303
+ location: m.location || "",
304
+ worksBrief: c.works.slice(0, 3).map((w) => [w.co, w.pos, w.range].filter(Boolean).join(" / ")),
305
+ projNames: c.projs.slice(0, 4).map((p) => p.name),
306
+ precision: c._precision === true,
307
+ };
308
+ }
309
+
310
+ /* ══════════════════════ fetch --position-id:职位候选人前 N + 并发档案 ══════════════════════ */
311
+
312
+ /**
313
+ * 按 positionId 直接取「该职位投递候选人前 N 条」,再并发拉档案。
314
+ * 为什么单独做:`recruit-stage.list type=candidate all:true` 会翻页 16~17 秒;
315
+ * 只取前 limit 条(不 all)约 4.8 秒,配合并发档案可把「职位匹配」从 25 秒级压到 7 秒级。
316
+ * 注意:本路径只取前 limit 条,不做全量翻页;total 返回的是本批行数,不是职位候选人总数。
317
+ */
318
+ async function cmdFetchByPosition(a) {
319
+ const t0 = Date.now();
320
+ const positionId = String(a["position-id"] || "").trim();
321
+ if (!positionId) throw new Error("--position-id 不能为空");
322
+ const limit = Math.min(10, Math.max(1, Number(a.limit || 5)));
323
+ const concurrency = Math.min(10, Math.max(1, Number(a.concurrency || 10)));
324
+ const outDir = a["out-dir"] || path.join(os.tmpdir(), "recruit-shortlist-out");
325
+ const brief = a.brief === true || String(a.brief || "") === "true";
326
+ const cliEntry = resolveCliEntry(a.cli);
327
+ if (!cliEntry) throw new Error("未找到 weaver-work-cli 的 dist/index.js。请确认 CLI 已安装,或用 --cli / 环境变量 WEAVER_WORK_CLI_ENTRY 指定入口。");
328
+
329
+ const timing = {};
330
+ const errors = [];
331
+ let rows = [];
332
+ let candidates = [];
333
+ const t = Date.now();
334
+ // 不传 all:只取第一页前 limit 条;这是本路径的提速关键,禁止改成 all:true。
335
+ const listRes = await runOp(cliEntry, "recruit-stage.list", { type: "candidate", positionId, pageSize: limit });
336
+ timing.listMs = Date.now() - t;
337
+ const d = listRes.data || {};
338
+ const envHost = String(d.env || "");
339
+ const envBase = String(d.baseUrl || "");
340
+ rows = (d.rows || []).slice(0, limit);
341
+ const total = Number(d.total) || rows.length;
342
+
343
+ const tp = Date.now();
344
+ for (let i = 0; i < rows.length; i += concurrency) {
345
+ const batch = rows.slice(i, i + concurrency);
346
+ const settled = await Promise.allSettled(
347
+ batch.map((r) => runOp(cliEntry, "recruit-stage.candidate.profile", { talentId: r.talent_id })),
348
+ );
349
+ settled.forEach((s, idx) => {
350
+ const src = batch[idx] || {};
351
+ if (s.status === "fulfilled") {
352
+ candidates.push(toCandidate((s.value || {}).data, {
353
+ talentId: src.talent_id,
354
+ name: src.candidate_name,
355
+ channel: src.resume_channel,
356
+ createTime: src.create_time,
357
+ }));
358
+ } else {
359
+ const reason = s.reason || {};
360
+ errors.push({ stage: "profile", talentId: src.talent_id || null, name: src.candidate_name || null, message: String(reason.message || reason) });
361
+ }
362
+ });
363
+ }
364
+ timing.profilesMs = Date.now() - tp;
365
+ timing.totalMs = Date.now() - t0;
366
+
367
+ if (!candidates.length) {
368
+ console.log(JSON.stringify({
369
+ ok: false, reason: "no_match", positionId, total,
370
+ hint: rows.length ? "职位有候选人行但档案全部拉取失败,见 errors" : "该职位下暂无候选人;可改用 --keyword 从人才库检索",
371
+ errors,
372
+ }));
373
+ return 1;
374
+ }
375
+
376
+ // env 只有 hostname(无协议/端口),不能反推 baseUrl;优先用 CLI 回传的完整 baseUrl。
377
+ const baseUrl = a["base-url"] || envBase || (envHost ? `https://${envHost}` : DEFAULT_BASE_URL);
378
+ if (!baseUrl) {
379
+ console.log(JSON.stringify({ ok: false, reason: "no_base_url", hint: "无法确定系统地址:请显式传 --base-url <你的E10地址> 后重试" }));
380
+ return 1;
381
+ }
382
+ const position = a.position || a["position-name"] || positionId;
383
+ const draft = {
384
+ position,
385
+ baseUrl,
386
+ generatedAt: new Date().toLocaleString("zh-CN", { hour12: false }).replace(/\//g, "-"),
387
+ keyword: "",
388
+ positionId,
389
+ total,
390
+ totalNote: "本命令只取该职位前 limit 条,total 是本批行数,不是职位候选人总数",
391
+ shown: candidates.length,
392
+ candidates,
393
+ };
394
+ await mkdir(outDir, { recursive: true });
395
+ const draftPath = path.join(outDir, "evidence_draft.json");
396
+ await writeFile(draftPath, JSON.stringify(draft, null, 2), "utf8");
397
+
398
+ const payload = {
399
+ ok: true,
400
+ via: "list+profile",
401
+ cliEntry,
402
+ position,
403
+ positionId,
404
+ total,
405
+ totalNote: draft.totalNote,
406
+ shown: candidates.length,
407
+ draftPath,
408
+ baseUrl,
409
+ timing,
410
+ ...(errors.length ? { errors } : {}),
411
+ candidates: brief ? candidates.map(briefForStdout) : candidates,
412
+ nextStep: "为每人补 level(high|mid|low)/verdict/evidence/risk 后执行 build 生成报告",
413
+ };
414
+ console.log(JSON.stringify(payload));
415
+ return 0;
416
+ }
417
+
418
+ /* ══════════════════════ fetch:搜索 + 档案(含自动降级)══════════════════════ */
419
+
420
+ async function cmdFetch(a) {
421
+ const t0 = Date.now();
422
+ const keyword = String(a.keyword || "").trim();
423
+ if (!keyword) throw new Error("--keyword 必填");
424
+ const limit = Math.min(10, Math.max(1, Number(a.limit || 5))); // 2026-11-29 提速:匹配默认 5 人,用户明确指定才放大
425
+ const concurrency = Math.min(10, Math.max(1, Number(a.concurrency || 10))); // 2026-11-29 提速:档案并发默认 10
426
+ const outDir = a["out-dir"] || path.join(os.tmpdir(), "recruit-shortlist-out");
427
+ // --precision:精确探针关键词(通常为「行业+职能」合成词,如「制造业解决方案」)。
428
+ // 非空时与主关键词并发发出,用于补回只在合成词下才命中的高精度人选。
429
+ const precision = String(a.precision || "").trim();
430
+ // --brief:stdout 只回摘要(姓名/岗位/学历/年限/公司岗位列表),完整素材见 draft 文件
431
+ const brief = a.brief === true || String(a.brief || "") === "true";
432
+ // --no-fill:精确探针命中但主力池没有的人,**不补拉 profile**,改用检索行构最小骨架并标记待补档。
433
+ // 省的是那 1.2 秒补档案(实测 precisionFillMs 1115~1330ms),代价是该候选人没有工作/项目经历,
434
+ // 不足以支撑评分依据——仅在「只要名单、不要评估」或极致速度场景使用。
435
+ const noFill = a["no-fill"] === true || String(a["no-fill"] || "") === "true";
436
+ const cliEntry = resolveCliEntry(a.cli);
437
+ if (!cliEntry) {
438
+ throw new Error("未找到 weaver-work-cli 的 dist/index.js。请确认 CLI 已安装,或用 --cli / 环境变量 WEAVER_WORK_CLI_ENTRY 指定入口。");
439
+ }
440
+
441
+ const timing = {};
442
+ let via = "shortlist";
443
+ let total = 0;
444
+ let searchNote = "";
445
+ let envHost = "";
446
+ let envBase = "";
447
+ let rows = [];
448
+ let candidates = [];
449
+ let precisionRows = [];
450
+ let precisionHit = 0;
451
+ let needProfileCount = 0;
452
+ let overflowCount = 0; // precision 补充后超出 limit 被截掉的人数(0 表示未截)
453
+ const errors = [];
454
+
455
+ // ── 路径 A:CLI ≥ 0.1.72,一次调用完成搜索 + 并发档案 ──
456
+ let t = Date.now();
457
+ let degraded = false;
458
+ // shortlist 回包的 candidates 是扁平档案(非完整 profile 结构),统一在此整形,
459
+ // 主池与 --precision 探针共用同一套字段映射,避免两处口径漂移。
460
+ const slimToCandidate = (c, src) => ({
461
+ talentId: c.talentId || (src && src.talentId) || "",
462
+ name: c.name || (src && src.name) || "",
463
+ degree: c.degree || "—",
464
+ college: c.college || "—",
465
+ pos: c.current_position || c.intend_position || "—",
466
+ industry: c.current_industry || "—",
467
+ _meta: {
468
+ expectSalary: c.expect_salary || "",
469
+ location: c.location_area || "",
470
+ workYears: c.work_exp || "",
471
+ graduateDate: c.graduate_date || "",
472
+ intendPosition: c.intend_position || "",
473
+ recruitStatus: c.recruit_status || "",
474
+ channel: (src && src.channel) || "",
475
+ selfDesc: "",
476
+ createTime: (src && src.createTime) || "",
477
+ },
478
+ works: (c.workExperience || []).map((w) => ({
479
+ co: w.co_name || "—", pos: w.work_position || "",
480
+ range: range(w.start_end_date_0, w.start_end_date_1), desc: w.work_desc || "",
481
+ })),
482
+ projs: (c.projectExperience || []).map((p) => ({
483
+ name: p.pj_name || "—", range: range(p.pj_date_0, p.pj_date_1), desc: p.pj_introduction || "",
484
+ })),
485
+ level: "", verdict: "", evidence: "", risk: "",
486
+ });
487
+
488
+ try {
489
+ // 🔴 双探针并发(2026-11-28 实测定稿,2026-11-28 二次优化):--precision 与主力池**同为 shortlist**。
490
+ // · 两个探针各自完成「搜索 + 并发拉档案」,第二轮自带档案,**无需再补 profile**。
491
+ // · 实测:search+补档 3406ms(补档 1095ms 纯浪费)→ 双 shortlist 并发约 2.3 秒,省 1.1 秒。
492
+ // · 两个探针耗时完全重叠,不是相加;串行做则要 4 秒以上。
493
+ const probeTasks = [runOp(cliEntry, "recruit-stage.candidate.shortlist", { keyword, limit, concurrency })];
494
+ if (precision) probeTasks.push(runOp(cliEntry, "recruit-stage.candidate.shortlist", { keyword: precision, limit, concurrency }));
495
+ const probes = await Promise.allSettled(probeTasks);
496
+ if (probes[0].status !== "fulfilled") throw probes[0].reason;
497
+ const res = probes[0].value;
498
+ timing.shortlistMs = Date.now() - t;
499
+ timing.probesMs = timing.shortlistMs;
500
+ if (precision) {
501
+ if (probes[1] && probes[1].status === "fulfilled") {
502
+ const pd = probes[1].value.data || {};
503
+ const pRows = pd.listRows || [];
504
+ precisionRows = (pd.candidates || []).map((c, i) => slimToCandidate(c, pRows[i]));
505
+ } else {
506
+ const rr = (probes[1] && probes[1].reason) || {};
507
+ errors.push({ stage: "precision-probe", message: String(rr.message || rr || "精确探针失败,已忽略") });
508
+ }
509
+ }
510
+ const d = res.data || {};
511
+ total = Number(d.total) || 0;
512
+ envHost = String(d.env || "");
513
+ envBase = String(d.baseUrl || "");
514
+ searchNote = String(d.searchNote || "");
515
+ rows = d.listRows || [];
516
+ // shortlist 回包的 candidates 已是精简档案(非完整 profile 结构),
517
+ // 故不走 toCandidate,直接在此整形为报告契约所需的候选人骨架。
518
+ candidates = (d.candidates || []).map((c, i) => slimToCandidate(c, rows[i]));
519
+
520
+ // ── 双探针合并:精确探针命中优先前移;池里没有的补一次 profile(实测通常仅 1 人)──
521
+ if (precision && precisionRows.length) {
522
+ precisionHit = precisionRows.length;
523
+ const precIds = new Set(precisionRows.map((r) => r.talentId).filter(Boolean));
524
+ const have = new Set(candidates.map((c) => c.talentId).filter(Boolean));
525
+ const lacks = precisionRows.filter((r) => r.talentId && !have.has(r.talentId));
526
+ // 🔴 2026-11-28 修正:--precision 已改为 shortlist,precisionRows 元素本身就是完整候选对象
527
+ // (自带 works/projs)。此处直接并入即可,**禁止再发 profile 请求**——
528
+ // 实测旧写法白花 1.1 秒补档(precisionFillMs 1095~1120ms),档案本来就有。
529
+ if (lacks.length && lacks[0] && Array.isArray(lacks[0].works)) {
530
+ for (const r of lacks) candidates.push({ ...r, _precision: true });
531
+ timing.precisionFillMs = 0;
532
+ } else if (lacks.length && noFill) {
533
+ // --no-fill:不拉档案,用检索行构最小骨架(字段缺省为「—」,_needProfile 供下游识别)
534
+ needProfileCount = lacks.length;
535
+ for (const r of lacks) {
536
+ candidates.push({
537
+ talentId: r.talentId || "",
538
+ name: r.name || "",
539
+ degree: "—",
540
+ college: "—",
541
+ pos: "—",
542
+ industry: "—",
543
+ _meta: {
544
+ expectSalary: "", location: "", workYears: "", graduateDate: "", intendPosition: "",
545
+ recruitStatus: r.status || "", channel: r.channel || "", selfDesc: "", createTime: r.createTime || "",
546
+ },
547
+ works: [],
548
+ projs: [],
549
+ level: "", verdict: "", evidence: "", risk: "",
550
+ _precision: true,
551
+ _needProfile: true,
552
+ });
553
+ }
554
+ timing.precisionFillMs = 0;
555
+ } else if (lacks.length) {
556
+ const tFill = Date.now();
557
+ const fills = await Promise.allSettled(
558
+ lacks.map((r) => runOp(cliEntry, "recruit-stage.candidate.profile", { talentId: r.talentId })),
559
+ );
560
+ timing.precisionFillMs = Date.now() - tFill;
561
+ fills.forEach((s2, idx) => {
562
+ const src = lacks[idx] || {};
563
+ if (s2.status === "fulfilled") candidates.push(toCandidate((s2.value || {}).data, src));
564
+ else {
565
+ const reason = s2.reason || {};
566
+ errors.push({ stage: "precision-profile", talentId: src.talentId || null, name: src.name || null, message: String(reason.message || reason) });
567
+ }
568
+ });
569
+ }
570
+ for (const c of candidates) if (precIds.has(c.talentId)) c._precision = true;
571
+ // 稳定排序:精确探针命中在前,其余保持原有相对顺序
572
+ candidates.sort((x, y) => (y._precision ? 1 : 0) - (x._precision ? 1 : 0));
573
+ // 🔴 截断到 limit(2026-11-28 修):precision 补充会让人数超过 limit——实测 --limit 10 + precision
574
+ // 返回 20 人,20 人 × L0 档约 17KB 必然超预算,于是全被压到 L4 极限档(描述 30 字、
575
+ // 工作与项目各 1 条),反而写不出有效证据。故 limit 是**总人数上限(含 precision 补充)**:
576
+ // sort 已把 precision 命中者排前,截断后正好「精确优先 + 主力池补足」。
577
+ overflowCount = Math.max(0, candidates.length - limit);
578
+ if (candidates.length > limit) candidates = candidates.slice(0, limit);
579
+ }
580
+ for (const e of (d.errors || [])) errors.push({ stage: "shortlist", ...e });
581
+ } catch (e) {
582
+ // ── 路径 B:旧版 CLI 自动降级(不报错、不中断)──
583
+ if (e.subtype !== "operation_unknown") throw e;
584
+ degraded = true;
585
+ via = "fallback(search+profile)";
586
+
587
+ t = Date.now();
588
+ // 🔴 search 只认 pageSize,传 limit 会报 unknown_argument(实测教训)
589
+ const sres = await runOp(cliEntry, "recruit-stage.candidate.search", { keyword, pageSize: limit });
590
+ timing.searchMs = Date.now() - t;
591
+ const sd = sres.data || {};
592
+ total = Number(sd.total) || 0;
593
+ envHost = String(sd.env || "");
594
+ envBase = String(sd.baseUrl || "");
595
+ searchNote = String(sd.searchNote || "");
596
+ rows = (sd.rows || []).slice(0, limit);
597
+
598
+ t = Date.now();
599
+ for (let i = 0; i < rows.length; i += concurrency) {
600
+ const batch = rows.slice(i, i + concurrency);
601
+ const settled = await Promise.allSettled(
602
+ batch.map((r) => runOp(cliEntry, "recruit-stage.candidate.profile", { talentId: r.talentId })),
603
+ );
604
+ settled.forEach((s, idx) => {
605
+ const src = batch[idx] || {};
606
+ if (s.status === "fulfilled") {
607
+ candidates.push(toCandidate((s.value || {}).data, src));
608
+ } else {
609
+ const reason = s.reason || {};
610
+ errors.push({ stage: "profile", talentId: src.talentId || null, name: src.name || null, message: String(reason.message || reason) });
611
+ }
612
+ });
613
+ }
614
+ timing.profilesMs = Date.now() - t;
615
+ }
616
+
617
+ if (!candidates.length) {
618
+ console.log(JSON.stringify({
619
+ ok: false, reason: "no_match", keyword, total, via, cliEntry,
620
+ hint: total > 0 ? "命中但档案全部拉取失败,见 errors" : "关键词零命中:换核心岗位词再试(最多两轮),仍为 0 则如实说明无匹配",
621
+ errors,
622
+ }));
623
+ return 1;
624
+ }
625
+
626
+ const baseUrl = a["base-url"] || envBase || (envHost ? `https://${envHost}` : DEFAULT_BASE_URL);
627
+ if (!baseUrl) {
628
+ console.log(JSON.stringify({ ok: false, reason: "no_base_url", hint: "无法确定系统地址:请显式传 --base-url <你的E10地址> 后重试" }));
629
+ return 1;
630
+ }
631
+ const draft = {
632
+ position: a.position || keyword,
633
+ baseUrl,
634
+ generatedAt: new Date().toLocaleString("zh-CN", { hour12: false }).replace(/\//g, "-"),
635
+ keyword,
636
+ total,
637
+ shown: candidates.length,
638
+ ...(precision ? { precision, precisionHit } : {}),
639
+ ...(overflowCount > 0 ? { overflowDropped: overflowCount } : {}),
640
+ ...(searchNote ? { searchNote } : {}),
641
+ candidates,
642
+ };
643
+
644
+ await mkdir(outDir, { recursive: true });
645
+ const draftPath = path.join(outDir, "evidence_draft.json");
646
+ await writeFile(draftPath, JSON.stringify(draft, null, 2), "utf8");
647
+
648
+ // ── stdout 预算控制:默认 L0 给足细节,超预算逐级降档,字段多的批次也有硬上限 ──
649
+ const budget = Math.min(51200, Math.max(2048, Number(a["max-output"] || DEFAULT_MAX_OUTPUT)));
650
+ timing.totalMs = Date.now() - t0;
651
+ const makeEnvelope = (list, info) => ({
652
+ ok: true,
653
+ via, // shortlist | fallback(search+profile)
654
+ degraded, // true 表示当前 CLI 版本旧于 0.1.72,已自动降级
655
+ cliEntry, // 实际选中的 CLI 入口:排查「走的是全局包还是源码仓」必看
656
+ keyword,
657
+ total, // 服务端关键词命中总数(不是本次取回数)
658
+ shown: candidates.length,
659
+ draftPath, // 完整档案(含全文描述),需要细节时读这里
660
+ baseUrl,
661
+ timing,
662
+ ...(precision ? { precision, precisionHit } : {}),
663
+ ...(needProfileCount ? { needProfile: needProfileCount, needProfileHint: "以下候选人未补档案(--no-fill),仅有姓名/岗位/渠道,评分依据不足,需在结论中标注「档案待补」" } : {}),
664
+ ...(errors.length ? { errors } : {}),
665
+ candidates: list,
666
+ output: { // 本次实际档位:AI 据此知道自己拿到的是哪一级细节
667
+ budgetChars: budget,
668
+ chars: info.chars,
669
+ level: info.level,
670
+ descChars: info.descChars,
671
+ selfDescChars: info.selfDescChars,
672
+ worksShown: info.worksShown,
673
+ projsShown: info.projsShown,
674
+ draftHasFullData: true,
675
+ ...(info.trimmed ? { trimmed: true, requestedCount: info.requestedCount, deliveredCount: info.deliveredCount } : {}),
676
+ ...(info.over ? {
677
+ overBudget: true,
678
+ hint: `已达极限档仍超预算:减小 --limit(当前 ${candidates.length} 人)或放宽 --max-output`,
679
+ } : {}),
680
+ },
681
+ nextStep: brief
682
+ ? `需要完整素材时读 ${draftPath} 的 candidates 数组(含 works/projs 全文);为每人补 level(high|mid|low)/verdict/evidence/risk 后执行 build 生成报告`
683
+ : "为每人补 level(high|mid|low)/verdict/evidence/risk 四个字段(证据只引 works/projs 原文,缺字段写「—」,不补造),写入 evidence.json 后执行 build 子命令生成报告",
684
+ });
685
+ let payload;
686
+ if (brief) {
687
+ const list = candidates.map(briefForStdout);
688
+ const meta = { chars: 0, level: 'brief 摘要', descChars: 0, selfDescChars: 0, worksShown: 3, projsShown: 4 };
689
+ const chars = JSON.stringify(makeEnvelope(list, meta)).length;
690
+ payload = makeEnvelope(list, { ...meta, chars, over: chars > budget });
691
+ } else {
692
+ const lastCfg = OUTPUT_LEVELS[OUTPUT_LEVELS.length - 1];
693
+ for (let lv = 0; lv < OUTPUT_LEVELS.length; lv += 1) {
694
+ const cfg = OUTPUT_LEVELS[lv];
695
+ const list = candidates.map((c) => compactOne(c, cfg));
696
+ const base = { chars: 0, level: cfg.tag, descChars: cfg.desc, selfDescChars: cfg.selfDesc, worksShown: cfg.works, projsShown: cfg.projs };
697
+ const chars = JSON.stringify(makeEnvelope(list, base)).length;
698
+ payload = makeEnvelope(list, { ...base, chars });
699
+ if (chars <= budget) break;
700
+ }
701
+ // 🔴 极限档仍超预算:说明「字段多 + 人数多」双重叠加。此时优先牺牲覆盖度(少给几个人),
702
+ // 而不是把字段继续压到无法写证据——少给的人会在 trimmed 里如实告知,AI 可据此说明或调小 --limit。
703
+ if (payload.output.chars > budget && candidates.length > 1) {
704
+ let n = candidates.length;
705
+ while (n > 1) {
706
+ n = Math.max(1, Math.floor(n * 0.8));
707
+ const list = candidates.slice(0, n).map((c) => compactOne(c, lastCfg));
708
+ const base = { chars: 0, level: lastCfg.tag, descChars: lastCfg.desc, selfDescChars: lastCfg.selfDesc, worksShown: lastCfg.works, projsShown: lastCfg.projs, trimmed: true, requestedCount: candidates.length, deliveredCount: n };
709
+ const chars = JSON.stringify(makeEnvelope(list, base)).length;
710
+ payload = makeEnvelope(list, { ...base, chars });
711
+ if (chars <= budget || n === 1) break;
712
+ }
713
+ }
714
+ }
715
+ console.log(JSON.stringify(payload));
716
+ return 0;
717
+ }
718
+
719
+ /* ══════════════════════ build:注入模板 + 内建自校验 ══════════════════════ */
720
+
721
+ function mergeMissingFromDraft(data, dataPath) {
722
+ try {
723
+ const draftPath = path.join(path.dirname(dataPath), "evidence_draft.json");
724
+ if (!existsSync(draftPath)) return data;
725
+ const draft = JSON.parse(readFileSync(draftPath, "utf8").replace(/^\uFEFF/, ""));
726
+ const byId = new Map((draft.candidates || []).map((c) => [String(c.talentId || ""), c]));
727
+ for (const c of data.candidates || []) {
728
+ const src = byId.get(String(c.talentId || ""));
729
+ if (!src) continue;
730
+ for (const k of ["works", "projs"]) {
731
+ if (!Array.isArray(c[k]) || c[k].length === 0) c[k] = src[k];
732
+ }
733
+ for (const k of ["degree", "college", "pos", "industry", "_meta"]) {
734
+ const cur = c[k];
735
+ if ((Array.isArray(cur) && cur.length === 0) || (!Array.isArray(cur) && !String(cur || "").trim())) {
736
+ if (src[k] !== undefined) c[k] = src[k];
737
+ }
738
+ }
739
+ }
740
+ } catch { /* 合并失败不影响原有数据 */ }
741
+ return data;
742
+ }
743
+
744
+ async function cmdBuild(a) {
745
+ const t0 = Date.now();
746
+ if (!a.data) throw new Error("--data 必填");
747
+ if (!a["out-html"]) throw new Error("--out-html 必填");
748
+ const tplPath = a.template || TEMPLATE;
749
+ if (!existsSync(tplPath)) throw new Error(`模板缺失:${tplPath}`);
750
+
751
+ const dataRaw = (await readFile(a.data, "utf8")).replace(/^\uFEFF/, "");
752
+ let data;
753
+ try { data = JSON.parse(dataRaw); }
754
+ catch (e) { throw new Error(`--data 不是合法 JSON:${String(e.message).slice(0, 150)}`); }
755
+
756
+ // AI 补评估字段时容易只保留 verdict/evidence、把 works/projs 丢掉;
757
+ // 同目录若有 fetch 落盘的 evidence_draft.json,按 talentId 自动补回原始档案片段,避免报告里「工作经历/项目经验 —」。
758
+ data = mergeMissingFromDraft(data, path.resolve(a.data));
759
+
760
+ const tpl = await readFile(tplPath, "utf8");
761
+ if (!tpl.includes(PLACEHOLDER)) throw new Error("模板缺少注入占位符 __EVIDENCE_DATA_PLACEHOLDER__");
762
+
763
+ // 防 </script> 提前闭合:JSON 里的 < 统一转义
764
+ const payload = JSON.stringify(data).replace(/</g, "\\u003c");
765
+ const html = tpl.replace(PLACEHOLDER, payload);
766
+ const outHtml = path.resolve(a["out-html"]);
767
+ await mkdir(path.dirname(outHtml), { recursive: true });
768
+ await writeFile(outHtml, html, "utf8");
769
+ const bytes = (await stat(outHtml)).size;
770
+ // 仅附件模式:只校验/返回绝对 htmlPath,不启动服务;present_files 负责上传。
771
+ let reportError = "";
772
+ try {
773
+ publishReport(outHtml);
774
+ } catch (e) {
775
+ reportError = String(e?.message || e);
776
+ }
777
+
778
+ // ── 内建自校验:让智能体读到 checks 全绿即可直接交付,无需第二轮确认 ──
779
+ const scripts = [...html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/gi)].map((m) => m[1]);
780
+ let syntaxOk = true;
781
+ let syntaxErr = "";
782
+ for (const s of scripts) {
783
+ try { new Function(s); } catch (e) { syntaxOk = false; syntaxErr = String(e.message).slice(0, 160); }
784
+ }
785
+ const cs = data.candidates || [];
786
+ const checks = {
787
+ placeholderReplaced: !html.includes(PLACEHOLDER),
788
+ scriptBlocks: scripts.length,
789
+ syntaxOk,
790
+ ...(syntaxErr ? { syntaxErr } : {}),
791
+ candidateCount: cs.length,
792
+ allHaveTalentId: cs.length > 0 && cs.every((c) => !!c.talentId),
793
+ allHaveName: cs.length > 0 && cs.every((c) => !!c.name),
794
+ // AI 评估字段是否已填(未填则报告里结论为空,必须提示)
795
+ withVerdict: cs.filter((c) => String(c.verdict || "").trim()).length,
796
+ withEvidence: cs.filter((c) => String(c.evidence || "").trim()).length,
797
+ withLevel: cs.filter((c) => ["high", "mid", "low"].includes(String(c.level || ""))).length,
798
+ withWorks: cs.filter((c) => Array.isArray(c.works) && c.works.length > 0).length,
799
+ withProjs: cs.filter((c) => Array.isArray(c.projs) && c.projs.length > 0).length,
800
+ bytes,
801
+ };
802
+ checks.allGreen = Boolean(
803
+ checks.placeholderReplaced && checks.syntaxOk && checks.candidateCount > 0
804
+ && checks.allHaveTalentId && checks.allHaveName
805
+ && checks.withVerdict === cs.length && checks.withEvidence === cs.length && checks.withLevel === cs.length
806
+ );
807
+
808
+ console.log(JSON.stringify({
809
+ ok: true,
810
+ htmlPath: outHtml,
811
+ ...(reportError ? { reportError } : {}),
812
+ checks,
813
+ timing: { buildMs: Date.now() - t0 },
814
+ ...(checks.allGreen ? {} : {
815
+ hint: "checks.allGreen=false:请补齐每个候选人的 level/verdict/evidence/risk 后重新 build;语法或占位符异常则检查 --data 与模板",
816
+ }),
817
+ ...((checks.withWorks === 0 || checks.withProjs === 0) ? {
818
+ profileHint: "有候选人的 work/proj 为空:先确认 evidence_draft.json 是否在同目录,或把 fetch 的 works/projs 原样保留到 --data;报告里的「—」只应出现在档案确实没有该段经历时",
819
+ } : {}),
820
+ }));
821
+ return checks.allGreen ? 0 : 0; // 校验未全绿不算执行失败,由 checks 表达
822
+ }
823
+
824
+ /* ══════════════════════ argv 解析与入口 ══════════════════════ */
825
+
826
+ function parseArgv(argv) {
827
+ const out = { _: [] };
828
+ for (let i = 0; i < argv.length; i++) {
829
+ const cur = argv[i];
830
+ if (cur.startsWith("--")) {
831
+ const key = cur.slice(2);
832
+ const next = argv[i + 1];
833
+ if (next === undefined || next.startsWith("--")) { out[key] = true; }
834
+ else { out[key] = next; i++; }
835
+ } else out._.push(cur);
836
+ }
837
+ return out;
838
+ }
839
+
840
+ const USAGE = [
841
+ "用法:",
842
+ " node lib/recruit-shortlist.mjs fetch --keyword <关键词> [--precision <精确探针词>] [--limit 5] [--concurrency 10] [--brief] [--no-fill] [--max-output 6144] [--out-dir <目录>] [--position <岗位名>] [--base-url <url>] [--cli <dist/index.js>]",
843
+ " node lib/recruit-shortlist.mjs fetch --position-id <职位id> [--limit 5] [--concurrency 10] [--brief] [--out-dir <目录>] [--position <岗位名>] [--base-url <url>] [--cli <dist/index.js>]",
844
+ " --precision 与 --keyword 并发发出,捞回只在合成词下命中的高精度人选(推荐传「行业+职能」)",
845
+ " --brief stdout 只回摘要(姓名/岗位/学历/年限/公司岗位列表),完整素材见 draft 文件",
846
+ " --no-fill 精确探针命中的人不补拉档案(省约 1.2 秒),改用检索行骨架并标 needProfile;评分依据会缺失",
847
+ " --position-id 按职位取投递候选人前 N 条(不翻全页),再并发拉档案;与 --keyword 二选一",
848
+ " node lib/recruit-shortlist.mjs build --data <evidence.json> --out-html <报告.html> [--template <html>]",
849
+ ].join("\n");
850
+
851
+ const argv = parseArgv(process.argv.slice(2));
852
+ const cmd = argv._[0];
853
+ try {
854
+ if (cmd === "fetch" && argv["position-id"]) process.exitCode = await cmdFetchByPosition(argv);
855
+ else if (cmd === "fetch") process.exitCode = await cmdFetch(argv);
856
+ else if (cmd === "build") process.exitCode = await cmdBuild(argv);
857
+ else { console.error(USAGE); process.exitCode = 2; }
858
+ } catch (e) {
859
+ console.log(JSON.stringify({ ok: false, error: String((e && e.message) || e).slice(0, 400), subtype: (e && e.subtype) || "" }));
860
+ process.exitCode = 2;
861
+ }
862
+
863
+
864
+
865
+