weaver-work-cli 0.1.44 → 0.1.46

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 (241) hide show
  1. package/README.md +9 -5
  2. package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
  3. package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
  4. package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
  5. package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
  6. package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-MCXQBD6N.js} +3 -3
  7. package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
  8. package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
  9. package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
  10. package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
  11. package/dist/chunks/{chunk-FAZTGX7S.js → chunk-4RWS2YYL.js} +5 -5
  12. package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-6AXKWFKG.js} +32 -12
  13. package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
  14. package/dist/chunks/{chunk-QVSWRLLU.js → chunk-6V5ZPKHV.js} +56 -12
  15. package/dist/chunks/chunk-762M5XJS.js +215 -0
  16. package/dist/chunks/{chunk-PC7VKEB5.js → chunk-76H3IKH6.js} +178 -37
  17. package/dist/chunks/{chunk-FRZKBMSW.js → chunk-AD46OMQK.js} +239 -41
  18. package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
  19. package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
  20. package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
  21. package/dist/chunks/{chunk-CWYGFU5B.js → chunk-GSZTA43P.js} +2 -2
  22. package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
  23. package/dist/chunks/{chunk-N4M2DDFE.js → chunk-IP4CWQCF.js} +11 -11
  24. package/dist/chunks/{chunk-GAMZLAG2.js → chunk-IRMIEDXN.js} +1 -1
  25. package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
  26. package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-JFAWZX53.js} +134 -13
  27. package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
  28. package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-OXHHJWNC.js} +1 -1
  29. package/dist/chunks/chunk-P5GQRWDC.js +60 -0
  30. package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
  31. package/dist/chunks/{chunk-OF4S23UB.js → chunk-PSOMGA3U.js} +4 -4
  32. package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
  33. package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
  34. package/dist/chunks/{chunk-XHK4MDR5.js → chunk-UFIFZ4YC.js} +48 -14
  35. package/dist/chunks/chunk-VRPH24IC.js +76 -0
  36. package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
  37. package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
  38. package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-H7EHQXYY.js} +2 -2
  39. package/dist/chunks/continuation-GW6PRWK3.js +12 -0
  40. package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
  41. package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
  42. package/dist/chunks/{create-flow-J22BO65E.js → create-flow-VRVJEOBX.js} +6 -6
  43. package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
  44. package/dist/chunks/{ehr-GSTGAIY3.js → ehr-SH2LM3NK.js} +648 -88
  45. package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
  46. package/dist/chunks/{env-BX3VRFS7.js → env-66FPSJDV.js} +2 -2
  47. package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
  48. package/dist/chunks/{factory-PETTFME6.js → factory-UH2TZBVA.js} +1 -1
  49. package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
  50. package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-CAKMMV7K.js} +3 -3
  51. package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
  52. package/dist/chunks/host-7NTIBSPK.js +25 -0
  53. package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
  54. package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
  55. package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
  56. package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
  57. package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
  58. package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
  59. package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
  60. package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
  61. package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-DD6ULZ3I.js} +4 -4
  62. package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
  63. package/dist/chunks/{meeting-FEVPZ67S.js → meeting-VTBFW4HI.js} +12 -12
  64. package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
  65. package/dist/chunks/operations-J7PUIVWZ.js +15 -0
  66. package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
  67. package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
  68. package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
  69. package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-CAKZTUA7.js} +1343 -178
  70. package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
  71. package/dist/chunks/{registry-IM5G23LS.js → registry-JVQBLFQ5.js} +10 -10
  72. package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
  73. package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
  74. package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-5U55FMXZ.js} +6 -4
  75. package/dist/chunks/{schedule-ESZIBAUO.js → schedule-IDETODCA.js} +4 -4
  76. package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
  77. package/dist/cmd/action.js +14 -10
  78. package/dist/index.js +30 -30
  79. package/dist/internal/e10/auth/commands.js +32 -0
  80. package/dist/internal/e10/auth/error-log.js +156 -26
  81. package/dist/internal/e10/auth/xiaoe.js +176 -13
  82. package/dist/internal/e10/context.js +12 -1
  83. package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
  84. package/dist/shortcuts/archive/operations/flow-url.js +182 -22
  85. package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
  86. package/dist/shortcuts/archive/operations/prelib.js +33 -4
  87. package/dist/shortcuts/archive/operations/shared.js +52 -0
  88. package/dist/shortcuts/contract/host.js +111 -4
  89. package/dist/shortcuts/contract/index.js +19 -0
  90. package/dist/shortcuts/contract/manifest.js +125 -0
  91. package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
  92. package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
  93. package/dist/shortcuts/contract/operations/customer.js +192 -0
  94. package/dist/shortcuts/contract/operations/file-download.js +75 -0
  95. package/dist/shortcuts/contract/operations/flow.js +44 -2
  96. package/dist/shortcuts/contract/operations/form-info.js +162 -62
  97. package/dist/shortcuts/contract/operations/registry.js +8 -0
  98. package/dist/shortcuts/contract/operations/review.js +116 -1
  99. package/dist/shortcuts/contract/operations/summary.js +177 -0
  100. package/dist/shortcuts/contract/operations/upload.js +64 -4
  101. package/dist/shortcuts/contract/upload-cache.js +104 -0
  102. package/dist/shortcuts/ehr/host.js +2 -2
  103. package/dist/shortcuts/ehr/index.js +14 -3
  104. package/dist/shortcuts/ehr/manifest.js +5 -1
  105. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +44 -12
  106. package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
  107. package/dist/shortcuts/ehr/operations/recruit-position.js +146 -43
  108. package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
  109. package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
  110. package/dist/shortcuts/ehr/operations/recruit-write.js +154 -36
  111. package/dist/shortcuts/ehr/operations/recruit.js +196 -12
  112. package/dist/shortcuts/ehr/operations/registry.js +4 -0
  113. package/dist/shortcuts/ehr/operations.js +24 -0
  114. package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
  115. package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
  116. package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
  117. package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
  118. package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
  119. package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
  120. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
  121. package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
  122. package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
  123. package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
  124. package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
  125. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
  126. package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
  127. package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
  128. package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
  129. package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
  130. package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
  131. package/dist/shortcuts/hrm/operations/employee.js +29 -1
  132. package/dist/shortcuts/meeting/operations/eb/create-flow.js +274 -75
  133. package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
  134. package/dist/shortcuts/meeting/operations/eb/factory.js +63 -11
  135. package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
  136. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +38 -7
  137. package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
  138. package/dist/shortcuts/meeting/operations/invitation.js +27 -4
  139. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  140. package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
  141. package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
  142. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +356 -29
  143. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +36 -10
  144. package/dist/shortcuts/recruit-stage/operations/jd-create.js +309 -67
  145. package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
  146. package/dist/shortcuts/recruit-stage/operations/resume-import.js +310 -17
  147. package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
  148. package/dist/shortcuts/recruit-stage/shared.js +221 -24
  149. package/dist/shortcuts/workflow/index.js +2 -0
  150. package/dist/shortcuts/workflow/operations/read.js +8 -3
  151. package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
  152. package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
  153. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
  154. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
  155. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
  157. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
  158. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
  159. package/docs/contract.md +1 -0
  160. package/docs/e10-auth.md +4 -2
  161. package/docs/todo-smart-convert/data-contract.md +7 -0
  162. package/package.json +1 -1
  163. package/skill-template/domains/jinchengda.md +2 -0
  164. package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
  165. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
  166. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
  167. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
  168. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
  169. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
  170. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
  171. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
  172. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
  173. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
  174. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
  175. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
  176. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
  177. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
  178. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
  179. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
  180. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
  181. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
  182. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
  183. package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
  184. package/skills/weaver-e10-jucailin/SKILL.md +12 -3
  185. package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
  186. package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
  187. package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
  188. package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
  189. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
  190. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
  191. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
  192. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
  193. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
  194. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
  195. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
  196. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
  197. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
  198. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
  199. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
  200. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
  201. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
  202. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
  203. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
  204. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
  205. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
  206. package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
  207. package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
  208. package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -91
  209. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
  210. package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
  211. package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
  212. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
  213. package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
  214. package/skills/weaver-e10-jucailin/references/recruit-write.md +55 -11
  215. package/skills/weaver-e10-meeting/SKILL.md +103 -11
  216. package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
  217. package/skills/weaver-e10-recruit-stage/SKILL.md +19 -11
  218. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -8
  219. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
  220. package/skills/weaver-e10-recruit-stage/references/position-templates.md +23 -2
  221. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
  222. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -18
  223. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
  224. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +11 -1
  225. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
  226. package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
  227. package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
  228. package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
  229. package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
  230. package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
  231. package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
  232. package/skills/weaver-e10-workflow/SKILL.md +19 -17
  233. package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
  234. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
  235. package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
  236. package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
  237. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
  238. package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
  239. package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
  240. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
  241. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
@@ -0,0 +1,165 @@
1
+ /**
2
+ * 批量简历导入的本地文件枚举(2026-11-06)。
3
+ *
4
+ * 职责边界:
5
+ * - 只做「把用户给的文件夹 / zip 包变成待处理文件清单」,不解析简历内容;
6
+ * - 解压走 Node 内置 zlib(不引第三方依赖,不调系统 unzip),Windows/macOS/Linux 一致;
7
+ * - 文件名编码:zip 通用标志位 bit 11 = UTF-8,否则按 GBK 尝试(Windows 中文系统常见);
8
+ * - 路径安全:拒绝绝对路径与 `..`(zip-slip),跳过 `__MACOSX/` 与目录项。
9
+ */
10
+ import { mkdtempSync, readdirSync, readFileSync, statSync, mkdirSync, writeFileSync } from 'node:fs';
11
+ import { tmpdir } from 'node:os';
12
+ import { basename, dirname, extname, join, resolve } from 'node:path';
13
+ import { inflateRawSync } from 'node:zlib';
14
+ export const RESUME_EXTS = new Set(['.pdf', '.doc', '.docx', '.rtf', '.txt', '.wps']);
15
+ function decodeName(bytes, utf8Flag) {
16
+ if (utf8Flag)
17
+ return bytes.toString('utf8');
18
+ try {
19
+ return new TextDecoder('gbk').decode(bytes);
20
+ }
21
+ catch {
22
+ return bytes.toString('utf8');
23
+ }
24
+ }
25
+ /** 解压 zip 到系统临时目录,返回目录路径。只支持 store/deflate(覆盖常规压缩方式)。 */
26
+ export function extractZip(zipPath) {
27
+ const buf = readFileSync(zipPath);
28
+ let eocd = -1;
29
+ const floor = Math.max(0, buf.length - 22 - 65535);
30
+ for (let i = buf.length - 22; i >= floor; i--) {
31
+ if (buf.readUInt32LE(i) === 0x06054b50) {
32
+ eocd = i;
33
+ break;
34
+ }
35
+ }
36
+ if (eocd < 0)
37
+ throw new Error('不是有效的 zip 文件(找不到中央目录结尾标记)');
38
+ const count = buf.readUInt16LE(eocd + 10);
39
+ let off = buf.readUInt32LE(eocd + 16);
40
+ if (count === 0xffff || off === 0xffffffff) {
41
+ throw new Error('暂不支持 ZIP64(超大压缩包),请拆分成多个普通 zip 后重试');
42
+ }
43
+ const dest = mkdtempSync(join(tmpdir(), 'e10-resume-'));
44
+ let written = 0;
45
+ for (let i = 0; i < count; i++) {
46
+ if (off + 46 > buf.length || buf.readUInt32LE(off) !== 0x02014b50)
47
+ break;
48
+ const flags = buf.readUInt16LE(off + 8);
49
+ const method = buf.readUInt16LE(off + 10);
50
+ const compSize = buf.readUInt32LE(off + 20);
51
+ const nameLen = buf.readUInt16LE(off + 28);
52
+ const extraLen = buf.readUInt16LE(off + 30);
53
+ const commentLen = buf.readUInt16LE(off + 32);
54
+ const localOff = buf.readUInt32LE(off + 42);
55
+ const rawName = buf.subarray(off + 46, off + 46 + nameLen);
56
+ const name = decodeName(rawName, (flags & 0x800) !== 0);
57
+ off += 46 + nameLen + extraLen + commentLen;
58
+ if (!name || name.endsWith('/') || name.startsWith('__MACOSX/'))
59
+ continue;
60
+ const rawParts = name.replace(/\\/g, '/').split('/');
61
+ // zip-slip 防护:路径里出现 .. 直接丢弃整个条目(不做"剥离后落盘",避免歧义)
62
+ if (rawParts.some((s) => s === '..'))
63
+ continue;
64
+ const parts = rawParts.filter((s) => s && s !== '.' && !/^[a-zA-Z]:$/.test(s));
65
+ if (!parts.length)
66
+ continue;
67
+ if (method !== 0 && method !== 8)
68
+ continue; // 只处理 store/deflate
69
+ const lNameLen = buf.readUInt16LE(localOff + 26);
70
+ const lExtraLen = buf.readUInt16LE(localOff + 28);
71
+ const dataStart = localOff + 30 + lNameLen + lExtraLen;
72
+ if (dataStart + compSize > buf.length)
73
+ continue;
74
+ const raw = buf.subarray(dataStart, dataStart + compSize);
75
+ let out;
76
+ try {
77
+ out = method === 0 ? raw : inflateRawSync(raw);
78
+ }
79
+ catch {
80
+ continue; // 单个条目损坏不影响其他文件
81
+ }
82
+ const target = join(dest, ...parts);
83
+ mkdirSync(dirname(target), { recursive: true });
84
+ writeFileSync(target, out);
85
+ written++;
86
+ }
87
+ if (!written)
88
+ throw new Error('zip 内没有可读取的文件(可能为空包或使用了不支持的压缩方式)');
89
+ return dest;
90
+ }
91
+ function walk(dir, root, out, warnings, depth) {
92
+ if (depth > 4)
93
+ return;
94
+ let entries;
95
+ try {
96
+ entries = readdirSync(dir);
97
+ }
98
+ catch (e) {
99
+ warnings.push(`目录不可读:${dir}(${e?.message || '未知原因'})`);
100
+ return;
101
+ }
102
+ for (const name of entries) {
103
+ const p = join(dir, name);
104
+ let st;
105
+ try {
106
+ st = statSync(p);
107
+ }
108
+ catch {
109
+ continue;
110
+ }
111
+ if (st.isDirectory()) {
112
+ if (name === '__MACOSX' || name.startsWith('.'))
113
+ continue;
114
+ walk(p, root, out, warnings, depth + 1);
115
+ continue;
116
+ }
117
+ if (!RESUME_EXTS.has(extname(name).toLowerCase()))
118
+ continue;
119
+ out.push({ path: p, name, size: st.size });
120
+ }
121
+ }
122
+ /** 扫描文件夹或 zip,返回按文件名排序的简历文件清单。 */
123
+ export function scanResumeSource(source) {
124
+ const warnings = [];
125
+ const abs = resolve(source);
126
+ let st;
127
+ try {
128
+ st = statSync(abs);
129
+ }
130
+ catch {
131
+ throw new Error(`路径不存在或不可读:${source}`);
132
+ }
133
+ let root = abs;
134
+ let tempDir;
135
+ if (st.isFile()) {
136
+ if (extname(abs).toLowerCase() !== '.zip') {
137
+ throw new Error('source 只支持文件夹或 .zip 压缩包');
138
+ }
139
+ tempDir = extractZip(abs);
140
+ root = tempDir;
141
+ }
142
+ else if (!st.isDirectory()) {
143
+ throw new Error('source 只支持文件夹或 .zip 压缩包');
144
+ }
145
+ const files = [];
146
+ walk(root, root, files, warnings, 0);
147
+ files.sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN'));
148
+ return { root, files, warnings, tempDir };
149
+ }
150
+ /** 为某个简历文件找同名结构化 JSON(同目录或指定目录)。 */
151
+ export function findStructuredJson(file, structuredDir) {
152
+ const base = basename(file.name, extname(file.name));
153
+ const candidates = [
154
+ join(dirname(file.path), base + '.json'),
155
+ ...(structuredDir ? [join(resolve(structuredDir), base + '.json')] : []),
156
+ ];
157
+ for (const c of candidates) {
158
+ try {
159
+ if (statSync(c).isFile())
160
+ return c;
161
+ }
162
+ catch { /* 继续找下一个 */ }
163
+ }
164
+ return null;
165
+ }