helixlife-expert-cli 0.1.0

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 (523) hide show
  1. package/README.md +159 -0
  2. package/cli/bin/helixlife-expert.js +3 -0
  3. package/cli/dist/core/api/client.d.ts +31 -0
  4. package/cli/dist/core/api/client.d.ts.map +1 -0
  5. package/cli/dist/core/api/client.js +183 -0
  6. package/cli/dist/core/api/client.js.map +1 -0
  7. package/cli/dist/core/api/http.d.ts +3 -0
  8. package/cli/dist/core/api/http.d.ts.map +1 -0
  9. package/cli/dist/core/api/http.js +22 -0
  10. package/cli/dist/core/api/http.js.map +1 -0
  11. package/cli/dist/core/api/response.d.ts +48 -0
  12. package/cli/dist/core/api/response.d.ts.map +1 -0
  13. package/cli/dist/core/api/response.js +84 -0
  14. package/cli/dist/core/api/response.js.map +1 -0
  15. package/cli/dist/core/api/sse.d.ts +6 -0
  16. package/cli/dist/core/api/sse.d.ts.map +1 -0
  17. package/cli/dist/core/api/sse.js +60 -0
  18. package/cli/dist/core/api/sse.js.map +1 -0
  19. package/cli/dist/core/auth/index.d.ts +35 -0
  20. package/cli/dist/core/auth/index.d.ts.map +1 -0
  21. package/cli/dist/core/auth/index.js +150 -0
  22. package/cli/dist/core/auth/index.js.map +1 -0
  23. package/cli/dist/core/env-config.d.ts +16 -0
  24. package/cli/dist/core/env-config.d.ts.map +1 -0
  25. package/cli/dist/core/env-config.js +80 -0
  26. package/cli/dist/core/env-config.js.map +1 -0
  27. package/cli/dist/core/errors.d.ts +20 -0
  28. package/cli/dist/core/errors.d.ts.map +1 -0
  29. package/cli/dist/core/errors.js +28 -0
  30. package/cli/dist/core/errors.js.map +1 -0
  31. package/cli/dist/core/index.d.ts +16 -0
  32. package/cli/dist/core/index.d.ts.map +1 -0
  33. package/cli/dist/core/index.js +16 -0
  34. package/cli/dist/core/index.js.map +1 -0
  35. package/cli/dist/core/interactive.d.ts +18 -0
  36. package/cli/dist/core/interactive.d.ts.map +1 -0
  37. package/cli/dist/core/interactive.js +74 -0
  38. package/cli/dist/core/interactive.js.map +1 -0
  39. package/cli/dist/core/output/index.d.ts +29 -0
  40. package/cli/dist/core/output/index.d.ts.map +1 -0
  41. package/cli/dist/core/output/index.js +153 -0
  42. package/cli/dist/core/output/index.js.map +1 -0
  43. package/cli/dist/core/parse.d.ts +9 -0
  44. package/cli/dist/core/parse.d.ts.map +1 -0
  45. package/cli/dist/core/parse.js +31 -0
  46. package/cli/dist/core/parse.js.map +1 -0
  47. package/cli/dist/core/paths.d.ts +21 -0
  48. package/cli/dist/core/paths.d.ts.map +1 -0
  49. package/cli/dist/core/paths.js +65 -0
  50. package/cli/dist/core/paths.js.map +1 -0
  51. package/cli/dist/core/sse-utils.d.ts +49 -0
  52. package/cli/dist/core/sse-utils.d.ts.map +1 -0
  53. package/cli/dist/core/sse-utils.js +181 -0
  54. package/cli/dist/core/sse-utils.js.map +1 -0
  55. package/cli/dist/core/terminal.d.ts +2 -0
  56. package/cli/dist/core/terminal.d.ts.map +1 -0
  57. package/cli/dist/core/terminal.js +6 -0
  58. package/cli/dist/core/terminal.js.map +1 -0
  59. package/cli/dist/core/token/index.d.ts +5 -0
  60. package/cli/dist/core/token/index.d.ts.map +1 -0
  61. package/cli/dist/core/token/index.js +26 -0
  62. package/cli/dist/core/token/index.js.map +1 -0
  63. package/cli/dist/core/types/config.d.ts +8 -0
  64. package/cli/dist/core/types/config.d.ts.map +1 -0
  65. package/cli/dist/core/types/config.js +30 -0
  66. package/cli/dist/core/types/config.js.map +1 -0
  67. package/cli/dist/core/version.d.ts +2 -0
  68. package/cli/dist/core/version.d.ts.map +1 -0
  69. package/cli/dist/core/version.js +10 -0
  70. package/cli/dist/core/version.js.map +1 -0
  71. package/cli/dist/index.d.ts +2 -0
  72. package/cli/dist/index.d.ts.map +1 -0
  73. package/cli/dist/index.js +23 -0
  74. package/cli/dist/index.js.map +1 -0
  75. package/cli/dist/modules/analysis/constants.d.ts +3 -0
  76. package/cli/dist/modules/analysis/constants.d.ts.map +1 -0
  77. package/cli/dist/modules/analysis/constants.js +3 -0
  78. package/cli/dist/modules/analysis/constants.js.map +1 -0
  79. package/cli/dist/modules/analysis/index.d.ts +3 -0
  80. package/cli/dist/modules/analysis/index.d.ts.map +1 -0
  81. package/cli/dist/modules/analysis/index.js +23 -0
  82. package/cli/dist/modules/analysis/index.js.map +1 -0
  83. package/cli/dist/modules/auth/index.d.ts +3 -0
  84. package/cli/dist/modules/auth/index.d.ts.map +1 -0
  85. package/cli/dist/modules/auth/index.js +76 -0
  86. package/cli/dist/modules/auth/index.js.map +1 -0
  87. package/cli/dist/modules/expert-scaffold.d.ts +27 -0
  88. package/cli/dist/modules/expert-scaffold.d.ts.map +1 -0
  89. package/cli/dist/modules/expert-scaffold.js +25 -0
  90. package/cli/dist/modules/expert-scaffold.js.map +1 -0
  91. package/cli/dist/modules/fund/clinical/apps.d.ts +19 -0
  92. package/cli/dist/modules/fund/clinical/apps.d.ts.map +1 -0
  93. package/cli/dist/modules/fund/clinical/apps.js +14 -0
  94. package/cli/dist/modules/fund/clinical/apps.js.map +1 -0
  95. package/cli/dist/modules/fund/clinical/command-utils.d.ts +4 -0
  96. package/cli/dist/modules/fund/clinical/command-utils.d.ts.map +1 -0
  97. package/cli/dist/modules/fund/clinical/command-utils.js +40 -0
  98. package/cli/dist/modules/fund/clinical/command-utils.js.map +1 -0
  99. package/cli/dist/modules/fund/clinical/commands/article-create.d.ts +9 -0
  100. package/cli/dist/modules/fund/clinical/commands/article-create.d.ts.map +1 -0
  101. package/cli/dist/modules/fund/clinical/commands/article-create.js +99 -0
  102. package/cli/dist/modules/fund/clinical/commands/article-create.js.map +1 -0
  103. package/cli/dist/modules/fund/clinical/commands/article-download.d.ts +30 -0
  104. package/cli/dist/modules/fund/clinical/commands/article-download.d.ts.map +1 -0
  105. package/cli/dist/modules/fund/clinical/commands/article-download.js +153 -0
  106. package/cli/dist/modules/fund/clinical/commands/article-download.js.map +1 -0
  107. package/cli/dist/modules/fund/clinical/commands/four-elements-create.d.ts +7 -0
  108. package/cli/dist/modules/fund/clinical/commands/four-elements-create.d.ts.map +1 -0
  109. package/cli/dist/modules/fund/clinical/commands/four-elements-create.js +81 -0
  110. package/cli/dist/modules/fund/clinical/commands/four-elements-create.js.map +1 -0
  111. package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.d.ts +7 -0
  112. package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.d.ts.map +1 -0
  113. package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.js +76 -0
  114. package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.js.map +1 -0
  115. package/cli/dist/modules/fund/clinical/commands/four-elements-update.d.ts +16 -0
  116. package/cli/dist/modules/fund/clinical/commands/four-elements-update.d.ts.map +1 -0
  117. package/cli/dist/modules/fund/clinical/commands/four-elements-update.js +108 -0
  118. package/cli/dist/modules/fund/clinical/commands/four-elements-update.js.map +1 -0
  119. package/cli/dist/modules/fund/clinical/commands/sample-size.d.ts +14 -0
  120. package/cli/dist/modules/fund/clinical/commands/sample-size.d.ts.map +1 -0
  121. package/cli/dist/modules/fund/clinical/commands/sample-size.js +164 -0
  122. package/cli/dist/modules/fund/clinical/commands/sample-size.js.map +1 -0
  123. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.d.ts +25 -0
  124. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.d.ts.map +1 -0
  125. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.js +228 -0
  126. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.js.map +1 -0
  127. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.d.ts +45 -0
  128. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.d.ts.map +1 -0
  129. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.js +211 -0
  130. package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.js.map +1 -0
  131. package/cli/dist/modules/fund/clinical/constants.d.ts +85 -0
  132. package/cli/dist/modules/fund/clinical/constants.d.ts.map +1 -0
  133. package/cli/dist/modules/fund/clinical/constants.js +161 -0
  134. package/cli/dist/modules/fund/clinical/constants.js.map +1 -0
  135. package/cli/dist/modules/fund/clinical/form-rules.d.ts +56 -0
  136. package/cli/dist/modules/fund/clinical/form-rules.d.ts.map +1 -0
  137. package/cli/dist/modules/fund/clinical/form-rules.js +542 -0
  138. package/cli/dist/modules/fund/clinical/form-rules.js.map +1 -0
  139. package/cli/dist/modules/fund/clinical/four-elements.d.ts +46 -0
  140. package/cli/dist/modules/fund/clinical/four-elements.d.ts.map +1 -0
  141. package/cli/dist/modules/fund/clinical/four-elements.js +190 -0
  142. package/cli/dist/modules/fund/clinical/four-elements.js.map +1 -0
  143. package/cli/dist/modules/fund/clinical/index.d.ts +3 -0
  144. package/cli/dist/modules/fund/clinical/index.d.ts.map +1 -0
  145. package/cli/dist/modules/fund/clinical/index.js +176 -0
  146. package/cli/dist/modules/fund/clinical/index.js.map +1 -0
  147. package/cli/dist/modules/fund/clinical/parameters.d.ts +51 -0
  148. package/cli/dist/modules/fund/clinical/parameters.d.ts.map +1 -0
  149. package/cli/dist/modules/fund/clinical/parameters.js +145 -0
  150. package/cli/dist/modules/fund/clinical/parameters.js.map +1 -0
  151. package/cli/dist/modules/fund/clinical/sample-size.d.ts +130 -0
  152. package/cli/dist/modules/fund/clinical/sample-size.d.ts.map +1 -0
  153. package/cli/dist/modules/fund/clinical/sample-size.js +356 -0
  154. package/cli/dist/modules/fund/clinical/sample-size.js.map +1 -0
  155. package/cli/dist/modules/fund/clinical/session-cache.d.ts +25 -0
  156. package/cli/dist/modules/fund/clinical/session-cache.d.ts.map +1 -0
  157. package/cli/dist/modules/fund/clinical/session-cache.js +100 -0
  158. package/cli/dist/modules/fund/clinical/session-cache.js.map +1 -0
  159. package/cli/dist/modules/fund/clinical/sse-utils.d.ts +22 -0
  160. package/cli/dist/modules/fund/clinical/sse-utils.d.ts.map +1 -0
  161. package/cli/dist/modules/fund/clinical/sse-utils.js +80 -0
  162. package/cli/dist/modules/fund/clinical/sse-utils.js.map +1 -0
  163. package/cli/dist/modules/fund/constants.d.ts +3 -0
  164. package/cli/dist/modules/fund/constants.d.ts.map +1 -0
  165. package/cli/dist/modules/fund/constants.js +3 -0
  166. package/cli/dist/modules/fund/constants.js.map +1 -0
  167. package/cli/dist/modules/fund/index.d.ts +3 -0
  168. package/cli/dist/modules/fund/index.d.ts.map +1 -0
  169. package/cli/dist/modules/fund/index.js +28 -0
  170. package/cli/dist/modules/fund/index.js.map +1 -0
  171. package/cli/dist/modules/fund/nsfc/apps.d.ts +54 -0
  172. package/cli/dist/modules/fund/nsfc/apps.d.ts.map +1 -0
  173. package/cli/dist/modules/fund/nsfc/apps.js +76 -0
  174. package/cli/dist/modules/fund/nsfc/apps.js.map +1 -0
  175. package/cli/dist/modules/fund/nsfc/article-cache.d.ts +14 -0
  176. package/cli/dist/modules/fund/nsfc/article-cache.d.ts.map +1 -0
  177. package/cli/dist/modules/fund/nsfc/article-cache.js +79 -0
  178. package/cli/dist/modules/fund/nsfc/article-cache.js.map +1 -0
  179. package/cli/dist/modules/fund/nsfc/commands/article-create.d.ts +8 -0
  180. package/cli/dist/modules/fund/nsfc/commands/article-create.d.ts.map +1 -0
  181. package/cli/dist/modules/fund/nsfc/commands/article-create.js +108 -0
  182. package/cli/dist/modules/fund/nsfc/commands/article-create.js.map +1 -0
  183. package/cli/dist/modules/fund/nsfc/commands/article-download.d.ts +42 -0
  184. package/cli/dist/modules/fund/nsfc/commands/article-download.d.ts.map +1 -0
  185. package/cli/dist/modules/fund/nsfc/commands/article-download.js +189 -0
  186. package/cli/dist/modules/fund/nsfc/commands/article-download.js.map +1 -0
  187. package/cli/dist/modules/fund/nsfc/commands/format-convert.d.ts +9 -0
  188. package/cli/dist/modules/fund/nsfc/commands/format-convert.d.ts.map +1 -0
  189. package/cli/dist/modules/fund/nsfc/commands/format-convert.js +98 -0
  190. package/cli/dist/modules/fund/nsfc/commands/format-convert.js.map +1 -0
  191. package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.d.ts +12 -0
  192. package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.d.ts.map +1 -0
  193. package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.js +351 -0
  194. package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.js.map +1 -0
  195. package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.d.ts +21 -0
  196. package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.d.ts.map +1 -0
  197. package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.js +197 -0
  198. package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.js.map +1 -0
  199. package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.d.ts +9 -0
  200. package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.d.ts.map +1 -0
  201. package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.js +120 -0
  202. package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.js.map +1 -0
  203. package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.d.ts +11 -0
  204. package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.d.ts.map +1 -0
  205. package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.js +125 -0
  206. package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.js.map +1 -0
  207. package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.d.ts +11 -0
  208. package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.d.ts.map +1 -0
  209. package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.js +109 -0
  210. package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.js.map +1 -0
  211. package/cli/dist/modules/fund/nsfc/commands/outline-confirm.d.ts +9 -0
  212. package/cli/dist/modules/fund/nsfc/commands/outline-confirm.d.ts.map +1 -0
  213. package/cli/dist/modules/fund/nsfc/commands/outline-confirm.js +64 -0
  214. package/cli/dist/modules/fund/nsfc/commands/outline-confirm.js.map +1 -0
  215. package/cli/dist/modules/fund/nsfc/commands/outline-create.d.ts +8 -0
  216. package/cli/dist/modules/fund/nsfc/commands/outline-create.d.ts.map +1 -0
  217. package/cli/dist/modules/fund/nsfc/commands/outline-create.js +103 -0
  218. package/cli/dist/modules/fund/nsfc/commands/outline-create.js.map +1 -0
  219. package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.d.ts +9 -0
  220. package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.d.ts.map +1 -0
  221. package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.js +176 -0
  222. package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.js.map +1 -0
  223. package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.d.ts +9 -0
  224. package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.d.ts.map +1 -0
  225. package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.js +190 -0
  226. package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.js.map +1 -0
  227. package/cli/dist/modules/fund/nsfc/constants.d.ts +96 -0
  228. package/cli/dist/modules/fund/nsfc/constants.d.ts.map +1 -0
  229. package/cli/dist/modules/fund/nsfc/constants.js +156 -0
  230. package/cli/dist/modules/fund/nsfc/constants.js.map +1 -0
  231. package/cli/dist/modules/fund/nsfc/graph-render.d.ts +25 -0
  232. package/cli/dist/modules/fund/nsfc/graph-render.d.ts.map +1 -0
  233. package/cli/dist/modules/fund/nsfc/graph-render.js +212 -0
  234. package/cli/dist/modules/fund/nsfc/graph-render.js.map +1 -0
  235. package/cli/dist/modules/fund/nsfc/index.d.ts +4 -0
  236. package/cli/dist/modules/fund/nsfc/index.d.ts.map +1 -0
  237. package/cli/dist/modules/fund/nsfc/index.js +238 -0
  238. package/cli/dist/modules/fund/nsfc/index.js.map +1 -0
  239. package/cli/dist/modules/fund/nsfc/mermaid-render.d.ts +18 -0
  240. package/cli/dist/modules/fund/nsfc/mermaid-render.d.ts.map +1 -0
  241. package/cli/dist/modules/fund/nsfc/mermaid-render.js +47 -0
  242. package/cli/dist/modules/fund/nsfc/mermaid-render.js.map +1 -0
  243. package/cli/dist/modules/fund/nsfc/parse-hypothesis.d.ts +76 -0
  244. package/cli/dist/modules/fund/nsfc/parse-hypothesis.d.ts.map +1 -0
  245. package/cli/dist/modules/fund/nsfc/parse-hypothesis.js +278 -0
  246. package/cli/dist/modules/fund/nsfc/parse-hypothesis.js.map +1 -0
  247. package/cli/dist/modules/fund/nsfc/parse-outline.d.ts +23 -0
  248. package/cli/dist/modules/fund/nsfc/parse-outline.d.ts.map +1 -0
  249. package/cli/dist/modules/fund/nsfc/parse-outline.js +91 -0
  250. package/cli/dist/modules/fund/nsfc/parse-outline.js.map +1 -0
  251. package/cli/dist/modules/fund/nsfc/png-watermark.d.ts +24 -0
  252. package/cli/dist/modules/fund/nsfc/png-watermark.d.ts.map +1 -0
  253. package/cli/dist/modules/fund/nsfc/png-watermark.js +78 -0
  254. package/cli/dist/modules/fund/nsfc/png-watermark.js.map +1 -0
  255. package/cli/dist/modules/fund/nsfc/prompt-hypothesis.d.ts +20 -0
  256. package/cli/dist/modules/fund/nsfc/prompt-hypothesis.d.ts.map +1 -0
  257. package/cli/dist/modules/fund/nsfc/prompt-hypothesis.js +107 -0
  258. package/cli/dist/modules/fund/nsfc/prompt-hypothesis.js.map +1 -0
  259. package/cli/dist/modules/fund/nsfc/prompt-step2.d.ts +18 -0
  260. package/cli/dist/modules/fund/nsfc/prompt-step2.d.ts.map +1 -0
  261. package/cli/dist/modules/fund/nsfc/prompt-step2.js +107 -0
  262. package/cli/dist/modules/fund/nsfc/prompt-step2.js.map +1 -0
  263. package/cli/dist/modules/fund/nsfc/request-body.d.ts +47 -0
  264. package/cli/dist/modules/fund/nsfc/request-body.d.ts.map +1 -0
  265. package/cli/dist/modules/fund/nsfc/request-body.js +38 -0
  266. package/cli/dist/modules/fund/nsfc/request-body.js.map +1 -0
  267. package/cli/dist/modules/fund/nsfc/session-cache.d.ts +48 -0
  268. package/cli/dist/modules/fund/nsfc/session-cache.d.ts.map +1 -0
  269. package/cli/dist/modules/fund/nsfc/session-cache.js +90 -0
  270. package/cli/dist/modules/fund/nsfc/session-cache.js.map +1 -0
  271. package/cli/dist/modules/fund/nsfc/sse-utils.d.ts +22 -0
  272. package/cli/dist/modules/fund/nsfc/sse-utils.d.ts.map +1 -0
  273. package/cli/dist/modules/fund/nsfc/sse-utils.js +81 -0
  274. package/cli/dist/modules/fund/nsfc/sse-utils.js.map +1 -0
  275. package/cli/dist/modules/fund/nsfc/upload.d.ts +3 -0
  276. package/cli/dist/modules/fund/nsfc/upload.d.ts.map +1 -0
  277. package/cli/dist/modules/fund/nsfc/upload.js +59 -0
  278. package/cli/dist/modules/fund/nsfc/upload.js.map +1 -0
  279. package/cli/dist/modules/fund/nsfc/validate.d.ts +30 -0
  280. package/cli/dist/modules/fund/nsfc/validate.d.ts.map +1 -0
  281. package/cli/dist/modules/fund/nsfc/validate.js +91 -0
  282. package/cli/dist/modules/fund/nsfc/validate.js.map +1 -0
  283. package/cli/dist/modules/literature/commands/workflow-list.d.ts +5 -0
  284. package/cli/dist/modules/literature/commands/workflow-list.d.ts.map +1 -0
  285. package/cli/dist/modules/literature/commands/workflow-list.js +9 -0
  286. package/cli/dist/modules/literature/commands/workflow-list.js.map +1 -0
  287. package/cli/dist/modules/literature/commands/workflow-params.d.ts +6 -0
  288. package/cli/dist/modules/literature/commands/workflow-params.d.ts.map +1 -0
  289. package/cli/dist/modules/literature/commands/workflow-params.js +9 -0
  290. package/cli/dist/modules/literature/commands/workflow-params.js.map +1 -0
  291. package/cli/dist/modules/literature/commands/workflow-run.d.ts +7 -0
  292. package/cli/dist/modules/literature/commands/workflow-run.d.ts.map +1 -0
  293. package/cli/dist/modules/literature/commands/workflow-run.js +10 -0
  294. package/cli/dist/modules/literature/commands/workflow-run.js.map +1 -0
  295. package/cli/dist/modules/literature/constants.d.ts +20 -0
  296. package/cli/dist/modules/literature/constants.d.ts.map +1 -0
  297. package/cli/dist/modules/literature/constants.js +56 -0
  298. package/cli/dist/modules/literature/constants.js.map +1 -0
  299. package/cli/dist/modules/literature/index.d.ts +3 -0
  300. package/cli/dist/modules/literature/index.d.ts.map +1 -0
  301. package/cli/dist/modules/literature/index.js +63 -0
  302. package/cli/dist/modules/literature/index.js.map +1 -0
  303. package/cli/dist/modules/meta/analysis.d.ts +127 -0
  304. package/cli/dist/modules/meta/analysis.d.ts.map +1 -0
  305. package/cli/dist/modules/meta/analysis.js +1165 -0
  306. package/cli/dist/modules/meta/analysis.js.map +1 -0
  307. package/cli/dist/modules/meta/api.d.ts +11 -0
  308. package/cli/dist/modules/meta/api.d.ts.map +1 -0
  309. package/cli/dist/modules/meta/api.js +40 -0
  310. package/cli/dist/modules/meta/api.js.map +1 -0
  311. package/cli/dist/modules/meta/commands.d.ts +3 -0
  312. package/cli/dist/modules/meta/commands.d.ts.map +1 -0
  313. package/cli/dist/modules/meta/commands.js +1185 -0
  314. package/cli/dist/modules/meta/commands.js.map +1 -0
  315. package/cli/dist/modules/meta/constants.d.ts +8 -0
  316. package/cli/dist/modules/meta/constants.d.ts.map +1 -0
  317. package/cli/dist/modules/meta/constants.js +9 -0
  318. package/cli/dist/modules/meta/constants.js.map +1 -0
  319. package/cli/dist/modules/meta/extraction.d.ts +206 -0
  320. package/cli/dist/modules/meta/extraction.d.ts.map +1 -0
  321. package/cli/dist/modules/meta/extraction.js +1248 -0
  322. package/cli/dist/modules/meta/extraction.js.map +1 -0
  323. package/cli/dist/modules/meta/index.d.ts +3 -0
  324. package/cli/dist/modules/meta/index.d.ts.map +1 -0
  325. package/cli/dist/modules/meta/index.js +19 -0
  326. package/cli/dist/modules/meta/index.js.map +1 -0
  327. package/cli/dist/modules/meta/node.d.ts +70 -0
  328. package/cli/dist/modules/meta/node.d.ts.map +1 -0
  329. package/cli/dist/modules/meta/node.js +167 -0
  330. package/cli/dist/modules/meta/node.js.map +1 -0
  331. package/cli/dist/modules/meta/plot-params.d.ts +82 -0
  332. package/cli/dist/modules/meta/plot-params.d.ts.map +1 -0
  333. package/cli/dist/modules/meta/plot-params.js +1179 -0
  334. package/cli/dist/modules/meta/plot-params.js.map +1 -0
  335. package/cli/dist/modules/meta/prisma-flow-docx.d.ts +23 -0
  336. package/cli/dist/modules/meta/prisma-flow-docx.d.ts.map +1 -0
  337. package/cli/dist/modules/meta/prisma-flow-docx.js +302 -0
  338. package/cli/dist/modules/meta/prisma-flow-docx.js.map +1 -0
  339. package/cli/dist/modules/meta/retrieve.d.ts +113 -0
  340. package/cli/dist/modules/meta/retrieve.d.ts.map +1 -0
  341. package/cli/dist/modules/meta/retrieve.js +913 -0
  342. package/cli/dist/modules/meta/retrieve.js.map +1 -0
  343. package/cli/dist/modules/meta/screening.d.ts +179 -0
  344. package/cli/dist/modules/meta/screening.d.ts.map +1 -0
  345. package/cli/dist/modules/meta/screening.js +1255 -0
  346. package/cli/dist/modules/meta/screening.js.map +1 -0
  347. package/cli/dist/modules/meta/topic.d.ts +110 -0
  348. package/cli/dist/modules/meta/topic.d.ts.map +1 -0
  349. package/cli/dist/modules/meta/topic.js +865 -0
  350. package/cli/dist/modules/meta/topic.js.map +1 -0
  351. package/cli/dist/modules/meta/types.d.ts +49 -0
  352. package/cli/dist/modules/meta/types.d.ts.map +1 -0
  353. package/cli/dist/modules/meta/types.js +2 -0
  354. package/cli/dist/modules/meta/types.js.map +1 -0
  355. package/cli/dist/modules/meta/workflow.d.ts +154 -0
  356. package/cli/dist/modules/meta/workflow.d.ts.map +1 -0
  357. package/cli/dist/modules/meta/workflow.js +956 -0
  358. package/cli/dist/modules/meta/workflow.js.map +1 -0
  359. package/cli/dist/modules/meta/writing.d.ts +83 -0
  360. package/cli/dist/modules/meta/writing.d.ts.map +1 -0
  361. package/cli/dist/modules/meta/writing.js +1077 -0
  362. package/cli/dist/modules/meta/writing.js.map +1 -0
  363. package/cli/dist/modules/proposal/artifacts.d.ts +18 -0
  364. package/cli/dist/modules/proposal/artifacts.d.ts.map +1 -0
  365. package/cli/dist/modules/proposal/artifacts.js +43 -0
  366. package/cli/dist/modules/proposal/artifacts.js.map +1 -0
  367. package/cli/dist/modules/proposal/commands/basic-create.d.ts +22 -0
  368. package/cli/dist/modules/proposal/commands/basic-create.d.ts.map +1 -0
  369. package/cli/dist/modules/proposal/commands/basic-create.js +81 -0
  370. package/cli/dist/modules/proposal/commands/basic-create.js.map +1 -0
  371. package/cli/dist/modules/proposal/commands/basic-result.d.ts +24 -0
  372. package/cli/dist/modules/proposal/commands/basic-result.d.ts.map +1 -0
  373. package/cli/dist/modules/proposal/commands/basic-result.js +96 -0
  374. package/cli/dist/modules/proposal/commands/basic-result.js.map +1 -0
  375. package/cli/dist/modules/proposal/commands/bioinfo-params.d.ts +5 -0
  376. package/cli/dist/modules/proposal/commands/bioinfo-params.d.ts.map +1 -0
  377. package/cli/dist/modules/proposal/commands/bioinfo-params.js +9 -0
  378. package/cli/dist/modules/proposal/commands/bioinfo-params.js.map +1 -0
  379. package/cli/dist/modules/proposal/commands/bioinfo-run.d.ts +6 -0
  380. package/cli/dist/modules/proposal/commands/bioinfo-run.d.ts.map +1 -0
  381. package/cli/dist/modules/proposal/commands/bioinfo-run.js +10 -0
  382. package/cli/dist/modules/proposal/commands/bioinfo-run.js.map +1 -0
  383. package/cli/dist/modules/proposal/commands/clinical-list.d.ts +5 -0
  384. package/cli/dist/modules/proposal/commands/clinical-list.d.ts.map +1 -0
  385. package/cli/dist/modules/proposal/commands/clinical-list.js +9 -0
  386. package/cli/dist/modules/proposal/commands/clinical-list.js.map +1 -0
  387. package/cli/dist/modules/proposal/commands/clinical-params.d.ts +6 -0
  388. package/cli/dist/modules/proposal/commands/clinical-params.d.ts.map +1 -0
  389. package/cli/dist/modules/proposal/commands/clinical-params.js +9 -0
  390. package/cli/dist/modules/proposal/commands/clinical-params.js.map +1 -0
  391. package/cli/dist/modules/proposal/commands/clinical-run.d.ts +7 -0
  392. package/cli/dist/modules/proposal/commands/clinical-run.d.ts.map +1 -0
  393. package/cli/dist/modules/proposal/commands/clinical-run.js +10 -0
  394. package/cli/dist/modules/proposal/commands/clinical-run.js.map +1 -0
  395. package/cli/dist/modules/proposal/constants.d.ts +34 -0
  396. package/cli/dist/modules/proposal/constants.d.ts.map +1 -0
  397. package/cli/dist/modules/proposal/constants.js +75 -0
  398. package/cli/dist/modules/proposal/constants.js.map +1 -0
  399. package/cli/dist/modules/proposal/index.d.ts +3 -0
  400. package/cli/dist/modules/proposal/index.d.ts.map +1 -0
  401. package/cli/dist/modules/proposal/index.js +95 -0
  402. package/cli/dist/modules/proposal/index.js.map +1 -0
  403. package/cli/dist/modules/proposal/newidea-env.d.ts +28 -0
  404. package/cli/dist/modules/proposal/newidea-env.d.ts.map +1 -0
  405. package/cli/dist/modules/proposal/newidea-env.js +69 -0
  406. package/cli/dist/modules/proposal/newidea-env.js.map +1 -0
  407. package/cli/dist/modules/proposal/newidea-runner.d.ts +25 -0
  408. package/cli/dist/modules/proposal/newidea-runner.d.ts.map +1 -0
  409. package/cli/dist/modules/proposal/newidea-runner.js +158 -0
  410. package/cli/dist/modules/proposal/newidea-runner.js.map +1 -0
  411. package/cli/dist/modules/proposal/parse.d.ts +25 -0
  412. package/cli/dist/modules/proposal/parse.d.ts.map +1 -0
  413. package/cli/dist/modules/proposal/parse.js +173 -0
  414. package/cli/dist/modules/proposal/parse.js.map +1 -0
  415. package/cli/dist/modules/sci/apps.d.ts +48 -0
  416. package/cli/dist/modules/sci/apps.d.ts.map +1 -0
  417. package/cli/dist/modules/sci/apps.js +43 -0
  418. package/cli/dist/modules/sci/apps.js.map +1 -0
  419. package/cli/dist/modules/sci/article-cache.d.ts +32 -0
  420. package/cli/dist/modules/sci/article-cache.d.ts.map +1 -0
  421. package/cli/dist/modules/sci/article-cache.js +163 -0
  422. package/cli/dist/modules/sci/article-cache.js.map +1 -0
  423. package/cli/dist/modules/sci/article-validate.d.ts +11 -0
  424. package/cli/dist/modules/sci/article-validate.d.ts.map +1 -0
  425. package/cli/dist/modules/sci/article-validate.js +43 -0
  426. package/cli/dist/modules/sci/article-validate.js.map +1 -0
  427. package/cli/dist/modules/sci/commands/article-create.d.ts +46 -0
  428. package/cli/dist/modules/sci/commands/article-create.d.ts.map +1 -0
  429. package/cli/dist/modules/sci/commands/article-create.js +315 -0
  430. package/cli/dist/modules/sci/commands/article-create.js.map +1 -0
  431. package/cli/dist/modules/sci/commands/article-download.d.ts +50 -0
  432. package/cli/dist/modules/sci/commands/article-download.d.ts.map +1 -0
  433. package/cli/dist/modules/sci/commands/article-download.js +281 -0
  434. package/cli/dist/modules/sci/commands/article-download.js.map +1 -0
  435. package/cli/dist/modules/sci/commands/outline.d.ts +36 -0
  436. package/cli/dist/modules/sci/commands/outline.d.ts.map +1 -0
  437. package/cli/dist/modules/sci/commands/outline.js +491 -0
  438. package/cli/dist/modules/sci/commands/outline.js.map +1 -0
  439. package/cli/dist/modules/sci/commands/template.d.ts +9 -0
  440. package/cli/dist/modules/sci/commands/template.d.ts.map +1 -0
  441. package/cli/dist/modules/sci/commands/template.js +12 -0
  442. package/cli/dist/modules/sci/commands/template.js.map +1 -0
  443. package/cli/dist/modules/sci/commands.d.ts +3 -0
  444. package/cli/dist/modules/sci/commands.d.ts.map +1 -0
  445. package/cli/dist/modules/sci/commands.js +108 -0
  446. package/cli/dist/modules/sci/commands.js.map +1 -0
  447. package/cli/dist/modules/sci/constants.d.ts +117 -0
  448. package/cli/dist/modules/sci/constants.d.ts.map +1 -0
  449. package/cli/dist/modules/sci/constants.js +152 -0
  450. package/cli/dist/modules/sci/constants.js.map +1 -0
  451. package/cli/dist/modules/sci/content-source.d.ts +18 -0
  452. package/cli/dist/modules/sci/content-source.d.ts.map +1 -0
  453. package/cli/dist/modules/sci/content-source.js +54 -0
  454. package/cli/dist/modules/sci/content-source.js.map +1 -0
  455. package/cli/dist/modules/sci/index.d.ts +3 -0
  456. package/cli/dist/modules/sci/index.d.ts.map +1 -0
  457. package/cli/dist/modules/sci/index.js +19 -0
  458. package/cli/dist/modules/sci/index.js.map +1 -0
  459. package/cli/dist/modules/sci/outline-transform.d.ts +16 -0
  460. package/cli/dist/modules/sci/outline-transform.d.ts.map +1 -0
  461. package/cli/dist/modules/sci/outline-transform.js +67 -0
  462. package/cli/dist/modules/sci/outline-transform.js.map +1 -0
  463. package/cli/dist/modules/sci/precheck-cache.d.ts +23 -0
  464. package/cli/dist/modules/sci/precheck-cache.d.ts.map +1 -0
  465. package/cli/dist/modules/sci/precheck-cache.js +141 -0
  466. package/cli/dist/modules/sci/precheck-cache.js.map +1 -0
  467. package/cli/dist/modules/sci/prompt-article.d.ts +12 -0
  468. package/cli/dist/modules/sci/prompt-article.d.ts.map +1 -0
  469. package/cli/dist/modules/sci/prompt-article.js +37 -0
  470. package/cli/dist/modules/sci/prompt-article.js.map +1 -0
  471. package/cli/dist/modules/sci/prompt-precheck.d.ts +16 -0
  472. package/cli/dist/modules/sci/prompt-precheck.d.ts.map +1 -0
  473. package/cli/dist/modules/sci/prompt-precheck.js +61 -0
  474. package/cli/dist/modules/sci/prompt-precheck.js.map +1 -0
  475. package/cli/dist/modules/sci/sse-utils.d.ts +50 -0
  476. package/cli/dist/modules/sci/sse-utils.d.ts.map +1 -0
  477. package/cli/dist/modules/sci/sse-utils.js +207 -0
  478. package/cli/dist/modules/sci/sse-utils.js.map +1 -0
  479. package/cli/dist/modules/shared/result-wrapper.d.ts +71 -0
  480. package/cli/dist/modules/shared/result-wrapper.d.ts.map +1 -0
  481. package/cli/dist/modules/shared/result-wrapper.js +95 -0
  482. package/cli/dist/modules/shared/result-wrapper.js.map +1 -0
  483. package/cli/dist/modules/shared/workflow-app/api.d.ts +6 -0
  484. package/cli/dist/modules/shared/workflow-app/api.d.ts.map +1 -0
  485. package/cli/dist/modules/shared/workflow-app/api.js +31 -0
  486. package/cli/dist/modules/shared/workflow-app/api.js.map +1 -0
  487. package/cli/dist/modules/shared/workflow-app/command.d.ts +30 -0
  488. package/cli/dist/modules/shared/workflow-app/command.d.ts.map +1 -0
  489. package/cli/dist/modules/shared/workflow-app/command.js +183 -0
  490. package/cli/dist/modules/shared/workflow-app/command.js.map +1 -0
  491. package/cli/dist/modules/shared/workflow-app/constants.d.ts +12 -0
  492. package/cli/dist/modules/shared/workflow-app/constants.d.ts.map +1 -0
  493. package/cli/dist/modules/shared/workflow-app/constants.js +21 -0
  494. package/cli/dist/modules/shared/workflow-app/constants.js.map +1 -0
  495. package/cli/dist/modules/shared/workflow-app/form.d.ts +21 -0
  496. package/cli/dist/modules/shared/workflow-app/form.d.ts.map +1 -0
  497. package/cli/dist/modules/shared/workflow-app/form.js +123 -0
  498. package/cli/dist/modules/shared/workflow-app/form.js.map +1 -0
  499. package/cli/dist/modules/shared/workflow-app/index.d.ts +8 -0
  500. package/cli/dist/modules/shared/workflow-app/index.d.ts.map +1 -0
  501. package/cli/dist/modules/shared/workflow-app/index.js +7 -0
  502. package/cli/dist/modules/shared/workflow-app/index.js.map +1 -0
  503. package/cli/dist/modules/shared/workflow-app/run.d.ts +15 -0
  504. package/cli/dist/modules/shared/workflow-app/run.d.ts.map +1 -0
  505. package/cli/dist/modules/shared/workflow-app/run.js +71 -0
  506. package/cli/dist/modules/shared/workflow-app/run.js.map +1 -0
  507. package/cli/dist/modules/shared/workflow-app/types.d.ts +74 -0
  508. package/cli/dist/modules/shared/workflow-app/types.d.ts.map +1 -0
  509. package/cli/dist/modules/shared/workflow-app/types.js +3 -0
  510. package/cli/dist/modules/shared/workflow-app/types.js.map +1 -0
  511. package/cli/dist/modules/site-configs.d.ts +4 -0
  512. package/cli/dist/modules/site-configs.d.ts.map +1 -0
  513. package/cli/dist/modules/site-configs.js +21 -0
  514. package/cli/dist/modules/site-configs.js.map +1 -0
  515. package/cli/dist/modules/upgrade/index.d.ts +6 -0
  516. package/cli/dist/modules/upgrade/index.d.ts.map +1 -0
  517. package/cli/dist/modules/upgrade/index.js +105 -0
  518. package/cli/dist/modules/upgrade/index.js.map +1 -0
  519. package/cli/dist/program.d.ts +3 -0
  520. package/cli/dist/program.d.ts.map +1 -0
  521. package/cli/dist/program.js +69 -0
  522. package/cli/dist/program.js.map +1 -0
  523. package/package.json +37 -0
@@ -0,0 +1,315 @@
1
+ import { helixlifeError, helixlifeErrorCode, isInteractiveTerminal, printOutput, createFormatLogger, ApiClient, extractSseText, assertWorkflowSucceeded, } from "../../../core/index.js";
2
+ import { resolveMarkdownContent, resolveTextOrFile, } from "../content-source.js";
3
+ import { getSciArticleAppIds, getSciTemplateLabel, parseSciTemplateType, SCI_ARTICLE_WAIT_HINT, SCI_EXECUTE_API_PATH, } from "../constants.js";
4
+ import { resolveSciArticleSelection, } from "../prompt-article.js";
5
+ import { extractReferences, formatElapsedHint, pickWebsiteWorkflowOutputText, } from "../sse-utils.js";
6
+ import { buildSciExecuteBody } from "../apps.js";
7
+ import { clearSciArticleCache, saveSciArticleCache, } from "../article-cache.js";
8
+ import { assertSciArticleComplete, isCompleteSciArticleMarkdown, } from "../article-validate.js";
9
+ import { wrapWorkbenchResult } from "../../shared/result-wrapper.js";
10
+ import { appendFileSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
13
+ /**
14
+ * 诊断用:设置 HELIX_SCI_DEBUG=1 时把全文 SSE 的事件类型计数与
15
+ * workflow_finished 全量 payload 落盘,用于定位偶发空正文真因。
16
+ * 行为中性:未设置环境变量时完全无副作用。
17
+ */
18
+ const SCI_DEBUG_ENABLED = Boolean(process.env.HELIX_SCI_DEBUG);
19
+ const SCI_DEBUG_FILE = process.env.HELIX_SCI_DEBUG_FILE ||
20
+ join(tmpdir(), "helixlife-sci-debug.log");
21
+ function sciDebugLog(entry) {
22
+ if (!SCI_DEBUG_ENABLED) {
23
+ return;
24
+ }
25
+ try {
26
+ appendFileSync(SCI_DEBUG_FILE, `${JSON.stringify({ ts: new Date().toISOString(), ...entry })}\n`, "utf8");
27
+ }
28
+ catch {
29
+ /* 诊断失败不影响主流程 */
30
+ }
31
+ }
32
+ // ============================================================
33
+ // 工具函数(导出供单测)
34
+ // ============================================================
35
+ /** 检查是否为有效 Markdown(提纲格式:至少含 # 标题) */
36
+ export function isValidOutlineMarkdown(text) {
37
+ const trimmed = text.trim();
38
+ return trimmed.length > 0 && /^#{1,6}\s+\S/.test(trimmed);
39
+ }
40
+ /** 从提纲 Markdown 提取首个标题文本(对齐官网 outline_title) */
41
+ export function extractOutlineTitle(outline) {
42
+ const match = outline.trim().match(/^#{1,6}\s+(.+)$/m);
43
+ return match?.[1]?.trim() ?? "";
44
+ }
45
+ /** 解析模板类型 */
46
+ function resolveTemplate(template) {
47
+ return parseSciTemplateType(template ?? "basic");
48
+ }
49
+ /**
50
+ * 组装全文 execute inputs(对齐官网 Writing.getParams SCI existing)
51
+ * keywords ≈ outlineParams.query(existing 常为空,不用 results 冒充)
52
+ */
53
+ export function buildSciArticleInputs(options) {
54
+ return {
55
+ outline: options.outline,
56
+ language: options.language,
57
+ methods: options.methods,
58
+ results: options.results,
59
+ keywords: "",
60
+ _bibliography: 0,
61
+ MethodAndResult: options.methodAndResult ?? "",
62
+ outline_title: extractOutlineTitle(options.outline),
63
+ };
64
+ }
65
+ /**
66
+ * 标题段规范化:官网 title 工作流前强制写入 "# "
67
+ */
68
+ export function normalizeSciTitleSection(text) {
69
+ const trimmed = text.trim();
70
+ if (!trimmed) {
71
+ return "";
72
+ }
73
+ if (/^#\s/.test(trimmed)) {
74
+ return trimmed;
75
+ }
76
+ return `# ${trimmed}`;
77
+ }
78
+ /**
79
+ * 合并 title + body 各段(官网 list.join("\\n"))
80
+ */
81
+ export function assembleSciArticleMarkdown(sections) {
82
+ return sections
83
+ .map((section) => section.trim())
84
+ .filter(Boolean)
85
+ .join("\n");
86
+ }
87
+ /** 解析 Step1 方法/结果:内联或 *-file,非空才通过 */
88
+ async function resolveMethodsAndResults(options) {
89
+ const methods = await resolveTextOrFile({
90
+ text: options.methods,
91
+ file: options.methodsFile,
92
+ label: "methods",
93
+ });
94
+ const results = await resolveTextOrFile({
95
+ text: options.results,
96
+ file: options.resultsFile,
97
+ label: "results",
98
+ });
99
+ if (!methods || !results) {
100
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "缺少 methods/results:请传 --methods/--results 或 --methods-file/--results-file(取步骤①返回值)");
101
+ }
102
+ return { methods, results };
103
+ }
104
+ // 批量调用 SSE 流式生成 SCI 全文(与官网 batchFetchWorkflows + Writing.onMessage 对齐)
105
+ async function batchStreamSciArticle(appIds, orderId, parentOrderId, outline, language, methods, results, methodAndResult, format) {
106
+ const client = new ApiClient();
107
+ const streamToStdout = format !== "json";
108
+ const sectionTexts = [];
109
+ const allOutputs = [];
110
+ let lastWorkflowRunId;
111
+ let lastElapsedTime;
112
+ let totalElapsedTime = 0;
113
+ // 全文生成耗时长:一次性提示,不做百分比假进度(避免 Agent 订阅/轮询冲突)
114
+ process.stderr.write(`${SCI_ARTICLE_WAIT_HINT}\n`);
115
+ const inputs = buildSciArticleInputs({
116
+ outline,
117
+ language,
118
+ methods,
119
+ results,
120
+ methodAndResult,
121
+ });
122
+ for (let i = 0; i < appIds.length; i++) {
123
+ const appId = appIds[i];
124
+ const isTitleApp = i === 0;
125
+ if (streamToStdout) {
126
+ process.stderr.write(`\n[${i + 1}/${appIds.length}] 正在生成${isTitleApp ? "标题" : "正文"}...\n`);
127
+ }
128
+ const executeBody = buildSciExecuteBody({
129
+ // 官网 existing:query 多为 outlineParams.query(常空),results 在 inputs
130
+ query: "",
131
+ inputs,
132
+ appId,
133
+ appName: "全文",
134
+ appType: 1,
135
+ index: 1,
136
+ orderId,
137
+ // 官网 Writing extraParams.end=true 同时传给所有 app
138
+ end: true,
139
+ count: appIds.length,
140
+ parentOrderId,
141
+ });
142
+ const chunks = [];
143
+ let overrideText;
144
+ let elapsedTime;
145
+ const eventCounts = {};
146
+ let sawWorkflowFinished = false;
147
+ await new Promise((resolve, reject) => {
148
+ client
149
+ .requestSse(SCI_EXECUTE_API_PATH, { method: "POST", body: executeBody }, (payload) => {
150
+ const evt = typeof payload.event === "string" ? payload.event : "unknown";
151
+ eventCounts[evt] = (eventCounts[evt] ?? 0) + 1;
152
+ assertWorkflowSucceeded(payload, "全文生成失败,请稍后重试", [
153
+ "workflow_finished",
154
+ ]);
155
+ const chunk = extractSseText(payload, { nested: true });
156
+ if (chunk) {
157
+ chunks.push(chunk);
158
+ if (streamToStdout) {
159
+ process.stdout.write(chunk);
160
+ }
161
+ }
162
+ if (payload.event === "workflow_finished") {
163
+ sawWorkflowFinished = true;
164
+ const data = payload.data;
165
+ if (typeof data === "object" && data !== null) {
166
+ const record = data;
167
+ if (typeof record.elapsed_time === "number") {
168
+ elapsedTime = record.elapsed_time;
169
+ lastElapsedTime = elapsedTime;
170
+ totalElapsedTime += elapsedTime;
171
+ }
172
+ if (typeof record.outputs === "object" && record.outputs) {
173
+ const outputs = record.outputs;
174
+ allOutputs.push(outputs);
175
+ // 对齐官网 Object.values(outputs)[0]
176
+ const finishedText = pickWebsiteWorkflowOutputText(outputs);
177
+ if (finishedText) {
178
+ overrideText = finishedText;
179
+ if (streamToStdout && chunks.length === 0) {
180
+ process.stdout.write(finishedText);
181
+ }
182
+ }
183
+ }
184
+ sciDebugLog({
185
+ phase: "workflow_finished",
186
+ appIndex: i,
187
+ isTitleApp,
188
+ appId,
189
+ status: record.status,
190
+ elapsedTime: record.elapsed_time,
191
+ outputsKeys: typeof record.outputs === "object" && record.outputs
192
+ ? Object.keys(record.outputs)
193
+ : null,
194
+ data: record,
195
+ });
196
+ }
197
+ if (typeof payload.workflow_run_id === "string") {
198
+ lastWorkflowRunId = payload.workflow_run_id;
199
+ }
200
+ }
201
+ })
202
+ .then(resolve)
203
+ .catch((err) => {
204
+ sciDebugLog({
205
+ phase: "sse_error",
206
+ appIndex: i,
207
+ isTitleApp,
208
+ appId,
209
+ eventCounts,
210
+ sawWorkflowFinished,
211
+ error: err instanceof Error ? err.message : String(err),
212
+ });
213
+ reject(err);
214
+ });
215
+ });
216
+ const streamed = chunks.join("").trim();
217
+ const finished = (overrideText ?? "").trim();
218
+ let sectionText = finished || streamed;
219
+ // 避免短 result 覆盖长流式正文
220
+ if (finished &&
221
+ streamed &&
222
+ streamed.length > finished.length * 2 &&
223
+ streamed.length - finished.length > 500) {
224
+ sectionText = streamed;
225
+ }
226
+ if (isTitleApp) {
227
+ sectionText = normalizeSciTitleSection(sectionText);
228
+ }
229
+ sciDebugLog({
230
+ phase: "section_done",
231
+ appIndex: i,
232
+ isTitleApp,
233
+ appId,
234
+ eventCounts,
235
+ sawWorkflowFinished,
236
+ streamedLen: streamed.length,
237
+ finishedLen: finished.length,
238
+ sectionTextLen: sectionText.length,
239
+ sectionHead: sectionText.slice(0, 120),
240
+ });
241
+ sectionTexts.push(sectionText);
242
+ }
243
+ assertSciArticleComplete(sectionTexts);
244
+ const article = assembleSciArticleMarkdown(sectionTexts);
245
+ const allReferences = [];
246
+ for (const outputs of allOutputs) {
247
+ const refs = extractReferences(outputs);
248
+ allReferences.push(...refs);
249
+ }
250
+ if (!isCompleteSciArticleMarkdown(article)) {
251
+ throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, "全文生成不完整:正文为空或过短(仅有标题不能视为成功),请重试 outline confirm create");
252
+ }
253
+ return {
254
+ article,
255
+ references: allReferences,
256
+ workflowRunId: lastWorkflowRunId,
257
+ elapsedTime: lastElapsedTime ?? totalElapsedTime,
258
+ };
259
+ }
260
+ // ============================================================
261
+ // 主入口:确认提纲并生成全文(Step2)
262
+ // ============================================================
263
+ export async function runCreateSciArticle(options = {}) {
264
+ const format = options.format ?? "markdown";
265
+ const interactive = isInteractiveTerminal() && !options.yes && options.format !== "json";
266
+ const log = createFormatLogger(format);
267
+ const template = resolveTemplate(options.template);
268
+ const outline = await resolveMarkdownContent(options, "请通过 --content、--file 或 --stdin 提供提纲 Markdown 内容");
269
+ if (!isValidOutlineMarkdown(outline)) {
270
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "提纲内容格式无效,应为 Markdown 格式(以 # 标题开头)");
271
+ }
272
+ if (!options.orderId?.trim()) {
273
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "缺少 orderId,请先执行 outline create 获取订单 ID");
274
+ }
275
+ // 直接复用步骤① 提纲订单(对齐官网首次生成 needRefreshOrder=false 路径);
276
+ // 不新建订单、不切换订单号(全文接口仅在结束时返回内容,切单只会丢弃进行中的生成)
277
+ const orderId = options.orderId.trim();
278
+ const { methods, results } = await resolveMethodsAndResults(options);
279
+ const methodAndResult = options.methodAndResult?.trim() ?? "";
280
+ const selection = await resolveSciArticleSelection({ language: options.language }, interactive);
281
+ const { language } = selection;
282
+ const appIds = getSciArticleAppIds(template);
283
+ // 生成前清理该订单可能残留的脏缓存(历史仅标题假成功)
284
+ await clearSciArticleCache(orderId);
285
+ const stream = await batchStreamSciArticle(appIds, orderId, null, outline, language, methods, results, methodAndResult, format);
286
+ const result = {
287
+ orderId,
288
+ template,
289
+ language,
290
+ article: stream.article,
291
+ references: stream.references,
292
+ workflowRunId: stream.workflowRunId,
293
+ elapsedTime: stream.elapsedTime,
294
+ };
295
+ const cacheReady = await saveSciArticleCache({
296
+ orderId,
297
+ template,
298
+ language,
299
+ article: stream.article,
300
+ references: stream.references,
301
+ workflowRunId: stream.workflowRunId,
302
+ });
303
+ if (format === "json") {
304
+ printOutput(wrapWorkbenchResult(result, { step: "article", subType: "sci" }, {
305
+ orderId,
306
+ workflowRunId: stream.workflowRunId,
307
+ cacheReady,
308
+ }), "json");
309
+ return;
310
+ }
311
+ const elapsedHint = formatElapsedHint(stream.elapsedTime);
312
+ log(`\n---\n模板:${getSciTemplateLabel(template)} | 语言:${language} | 参考文献 ${stream.references.length} 条${elapsedHint}`);
313
+ log("\n✅ 确认提纲并生成全文(Step2)完成。\n");
314
+ }
315
+ //# sourceMappingURL=article-create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article-create.js","sourceRoot":"","sources":["../../../../src/modules/sci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,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,WAAW,CACT,mBAAmB,CACjB,MAAM,EACN,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EACnC;YACE,OAAO;YACP,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,UAAU;SACX,CACF,EACD,MAAM,CACP,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1D,GAAG,CACD,aAAa,mBAAmB,CAAC,QAAQ,CAAC,SAAS,QAAQ,WAAW,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CACjH,CAAC;IACF,GAAG,CAAC,2BAA2B,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type OutputFormat } from "../../../core/index.js";
2
+ import { type SciArticleDownloadResult, type SciLanguage } from "../constants.js";
3
+ export type { SciArticleDownloadResult } from "../constants.js";
4
+ export interface DownloadSciArticleOptions {
5
+ orderId?: string;
6
+ file?: string;
7
+ references?: string[];
8
+ referencesFile?: string;
9
+ language?: string;
10
+ output?: string;
11
+ produceId?: string;
12
+ format?: OutputFormat;
13
+ emitOutput?: boolean;
14
+ }
15
+ /**
16
+ * 将标题候选收成安全导出 basename(不含扩展名)。
17
+ * 对齐官网:整题作文件名、不截断;CLI 仅替换 Windows 非法字符以便 writeFile。
18
+ */
19
+ export declare function toSciExportBasename(titleCandidate: string): string;
20
+ /**
21
+ * 从全文 Markdown 提取论文标题(对齐官网 getTitleFromArticle)
22
+ * 优先首个 H1(恰好一个 `#`);兼容「标题:」前缀;否则取首个非 ATX 标题段落;空则「未命名」
23
+ */
24
+ export declare function extractSciArticleTitle(markdown: string): string;
25
+ /**
26
+ * 专供导出文件名:只信任严格 H1;无 H1 或正文泄漏 →「未命名」
27
+ */
28
+ export declare function extractSciExportTitle(markdown: string): string;
29
+ /**
30
+ * 若 Markdown 开头缺少 H1 标题,则注入 `# ${title}`(防御旧缓存 / 残缺正文)
31
+ * 注入标题经 toSciExportBasename,避免整篇正文写进 H1。
32
+ */
33
+ export declare function ensureSciArticleTitleHeading(markdown: string, title?: string): {
34
+ markdown: string;
35
+ title: string;
36
+ };
37
+ export declare function resolveSciArticleDownloadLanguage(explicitLanguage: string | undefined, cachedLanguage?: string): SciLanguage;
38
+ export declare function appendReferencesToMarkdown(article: string, references: string[], language?: string): string;
39
+ export declare function downloadSciArticleDocx(markdown: string, options?: Pick<DownloadSciArticleOptions, "produceId">): Promise<{
40
+ buffer: Buffer;
41
+ contentType: string | null;
42
+ filename?: string;
43
+ }>;
44
+ /**
45
+ * 确定全文 docx 输出路径:默认 / -o 目录时用论文标题命名(对齐官网 saveAs)
46
+ * 文件名只吃 toSciExportBasename,禁止正文泄漏进路径。
47
+ */
48
+ export declare function resolveArticleDownloadPath(outputOption: string | undefined, articleTitle: string): string;
49
+ export declare function runDownloadSciArticle(options?: DownloadSciArticleOptions): Promise<SciArticleDownloadResult>;
50
+ //# sourceMappingURL=article-download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article-download.d.ts","sourceRoot":"","sources":["../../../../src/modules/sci/commands/article-download.ts"],"names":[],"mappings":"AAGA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGhE,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAA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// SCI 全文导出(Step3):命中步骤② 系统临时目录缓存 → 追加参考文献 → 输出 MD + Word
2
+ import { readFile, writeFile } from "node:fs/promises";
3
+ import { extname, join } from "node:path";
4
+ import { ApiClient, getDefaultNewideaBaseUrl, helixlifeError, helixlifeErrorCode, getUserDownloadsDir, printOutput, resolveUserPath, sanitizeFilename, } from "../../../core/index.js";
5
+ import { SCI_ARTICLE_CONTENT_PRODUCER, SCI_DOCX_CONVERT_API_PATH, } from "../constants.js";
6
+ import { loadSciArticleCache, popSciArticleCache } from "../article-cache.js";
7
+ const DEFAULT_SCI_ARTICLE_TITLE = "未命名";
8
+ /** 检测行首「标题:」/「Title:」类前缀(对齐官网语义,避免正文中含「标题」误伤) */
9
+ function checkIsTitleLabel(text) {
10
+ return /^(?:项目名称|标题|Title)\s*[::]?/.test(text);
11
+ }
12
+ /** 从「标题: xxx」提取标题正文(对齐官网 extractTitle) */
13
+ function extractLabeledTitle(text) {
14
+ const match = text.match(/^(?:项目名称|标题|Title)\s*[::]?\s*\*{0,2}([^*]+)\*{0,2}/);
15
+ return match?.[1]?.trim() || "";
16
+ }
17
+ /**
18
+ * 候选是否像正文(禁止当文件名)。
19
+ * 对齐官网:不因长度否决;仅空串 / 换行 / `##` 等多段泄漏(MD 特有防护)。
20
+ */
21
+ function looksLikeArticleBody(text) {
22
+ if (!text.trim()) {
23
+ return true;
24
+ }
25
+ if (/[\r\n]/.test(text)) {
26
+ return true;
27
+ }
28
+ if (text.includes("##") || /\n#{1,6}/.test(text)) {
29
+ return true;
30
+ }
31
+ return false;
32
+ }
33
+ /**
34
+ * 将标题候选收成安全导出 basename(不含扩展名)。
35
+ * 对齐官网:整题作文件名、不截断;CLI 仅替换 Windows 非法字符以便 writeFile。
36
+ */
37
+ export function toSciExportBasename(titleCandidate) {
38
+ const raw = titleCandidate.trim();
39
+ if (!raw || looksLikeArticleBody(raw)) {
40
+ return DEFAULT_SCI_ARTICLE_TITLE;
41
+ }
42
+ const sanitized = sanitizeFilename(raw, { maxLength: null });
43
+ // sanitizeFilename 可能带扩展名;导出 basename 只要 stem
44
+ return (sanitized.replace(/\.[A-Za-z0-9]{1,8}$/, "") || DEFAULT_SCI_ARTICLE_TITLE);
45
+ }
46
+ /**
47
+ * 从全文 Markdown 提取论文标题(对齐官网 getTitleFromArticle)
48
+ * 优先首个 H1(恰好一个 `#`);兼容「标题:」前缀;否则取首个非 ATX 标题段落;空则「未命名」
49
+ */
50
+ export function extractSciArticleTitle(markdown) {
51
+ const lines = markdown.split(/\r?\n/);
52
+ for (const raw of lines) {
53
+ const line = raw.trim();
54
+ if (!line) {
55
+ continue;
56
+ }
57
+ // 恰好 H1:`# title`,排除 `##` / `###`
58
+ const h1Match = line.match(/^#(?!#)\s+(.+)$/);
59
+ if (h1Match) {
60
+ const heading = h1Match[1].trim();
61
+ if (checkIsTitleLabel(heading)) {
62
+ return (extractLabeledTitle(heading) || heading || DEFAULT_SCI_ARTICLE_TITLE);
63
+ }
64
+ return heading || DEFAULT_SCI_ARTICLE_TITLE;
65
+ }
66
+ // 跳过二级及以下标题,避免把「## 摘要」当成文件名
67
+ if (/^#{2,6}\s+/.test(line)) {
68
+ continue;
69
+ }
70
+ if (checkIsTitleLabel(line)) {
71
+ const labeled = extractLabeledTitle(line);
72
+ if (labeled) {
73
+ return labeled;
74
+ }
75
+ }
76
+ // 非 ATX 标题的首个非空行(官网 else if nodeText)
77
+ return line;
78
+ }
79
+ return DEFAULT_SCI_ARTICLE_TITLE;
80
+ }
81
+ /**
82
+ * 专供导出文件名:只信任严格 H1;无 H1 或正文泄漏 →「未命名」
83
+ */
84
+ export function extractSciExportTitle(markdown) {
85
+ const lines = markdown.split(/\r?\n/);
86
+ for (const raw of lines) {
87
+ const line = raw.trim();
88
+ if (!line) {
89
+ continue;
90
+ }
91
+ const h1Match = line.match(/^#(?!#)\s+(.+)$/);
92
+ if (h1Match) {
93
+ let heading = h1Match[1].trim();
94
+ if (checkIsTitleLabel(heading)) {
95
+ heading = extractLabeledTitle(heading) || heading;
96
+ }
97
+ return toSciExportBasename(heading);
98
+ }
99
+ }
100
+ return DEFAULT_SCI_ARTICLE_TITLE;
101
+ }
102
+ /**
103
+ * 若 Markdown 开头缺少 H1 标题,则注入 `# ${title}`(防御旧缓存 / 残缺正文)
104
+ * 注入标题经 toSciExportBasename,避免整篇正文写进 H1。
105
+ */
106
+ export function ensureSciArticleTitleHeading(markdown, title) {
107
+ const rawTitle = (title?.trim() || extractSciArticleTitle(markdown)).trim() ||
108
+ DEFAULT_SCI_ARTICLE_TITLE;
109
+ // 正文 H1 保留完整题目;文件名截断由 toSciExportBasename / extractSciExportTitle 负责
110
+ const resolvedTitle = looksLikeArticleBody(rawTitle)
111
+ ? DEFAULT_SCI_ARTICLE_TITLE
112
+ : rawTitle;
113
+ const trimmed = markdown.trimStart();
114
+ if (/^#(?!#)\s+\S/.test(trimmed)) {
115
+ return {
116
+ markdown,
117
+ title: extractSciExportTitle(markdown) || toSciExportBasename(resolvedTitle),
118
+ };
119
+ }
120
+ return {
121
+ markdown: `# ${resolvedTitle}\n\n${markdown.trimStart()}`,
122
+ title: toSciExportBasename(resolvedTitle),
123
+ };
124
+ }
125
+ // 解析参考文献列表:CLI 参数或 JSON 文件
126
+ async function resolveReferences(options) {
127
+ if (options.references?.length) {
128
+ return options.references;
129
+ }
130
+ if (options.referencesFile) {
131
+ try {
132
+ const raw = await readFile(resolveUserPath(options.referencesFile), "utf8");
133
+ const parsed = JSON.parse(raw);
134
+ if (Array.isArray(parsed)) {
135
+ return parsed.filter((item) => typeof item === "string");
136
+ }
137
+ }
138
+ catch {
139
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `无法读取参考文献文件: ${options.referencesFile}`);
140
+ }
141
+ }
142
+ return [];
143
+ }
144
+ // 解析步骤③ 参考文献标题语言:显式 --language 优先,否则缓存,否则中文
145
+ export function resolveSciArticleDownloadLanguage(explicitLanguage, cachedLanguage) {
146
+ return (explicitLanguage?.trim() ||
147
+ cachedLanguage?.trim() ||
148
+ "中文");
149
+ }
150
+ // 将参考文献追加到正文 Markdown(原始引文格式,全量保留)
151
+ export function appendReferencesToMarkdown(article, references, language) {
152
+ if (!references.length) {
153
+ return `${article.trim()}\n`;
154
+ }
155
+ const heading = language === "英文" ? "## References" : "## 参考文献";
156
+ const body = references
157
+ .map((line) => line.trim())
158
+ .filter(Boolean)
159
+ .join("\n");
160
+ return `${article.trim()}\n\n${heading}\n\n${body}\n`;
161
+ }
162
+ // 组装全文 markdown 转 docx 的 multipart 表单(原始引文格式,csl_key 留空)
163
+ function buildArticleDownloadFormData(markdown, produceId) {
164
+ const form = new FormData();
165
+ const blob = new Blob([markdown], { type: "text/plain" });
166
+ form.append("data", blob, "blob");
167
+ form.append("is_aigc", "true");
168
+ form.append("content_producer", SCI_ARTICLE_CONTENT_PRODUCER);
169
+ form.append("produce_id", produceId || "");
170
+ form.append("csl_key", "");
171
+ return form;
172
+ }
173
+ // 调用 PaaS 接口将全文 Markdown 转为 docx
174
+ export async function downloadSciArticleDocx(markdown, options = {}) {
175
+ const client = new ApiClient();
176
+ const form = buildArticleDownloadFormData(markdown, options.produceId ?? "");
177
+ return client.requestBinary(SCI_DOCX_CONVERT_API_PATH, {
178
+ method: "POST",
179
+ baseUrl: getDefaultNewideaBaseUrl(),
180
+ body: form,
181
+ });
182
+ }
183
+ /**
184
+ * 确定全文 docx 输出路径:默认 / -o 目录时用论文标题命名(对齐官网 saveAs)
185
+ * 文件名只吃 toSciExportBasename,禁止正文泄漏进路径。
186
+ */
187
+ export function resolveArticleDownloadPath(outputOption, articleTitle) {
188
+ const safeName = `${toSciExportBasename(articleTitle)}.docx`;
189
+ if (outputOption) {
190
+ const resolved = resolveUserPath(outputOption);
191
+ if (extname(resolved)) {
192
+ return resolved;
193
+ }
194
+ return join(resolved, safeName);
195
+ }
196
+ return join(getUserDownloadsDir(), safeName);
197
+ }
198
+ // 由 docx 路径推导配套 MD 路径(同目录同名,扩展名替换为 .md)
199
+ function resolveArticleMarkdownPath(docxPath) {
200
+ const ext = extname(docxPath);
201
+ if (ext) {
202
+ return docxPath.slice(0, docxPath.length - ext.length) + ".md";
203
+ }
204
+ return `${docxPath}.md`;
205
+ }
206
+ // 执行全文下载:读取 Markdown → 追加参考文献 → 同时输出 MD 与 docx
207
+ export async function runDownloadSciArticle(options = {}) {
208
+ const explicitProvided = Boolean(options.file);
209
+ if (options.orderId && explicitProvided) {
210
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "--order-id 与 --file 互斥,请二选一");
211
+ }
212
+ let article;
213
+ let references;
214
+ let produceId = options.produceId ?? "";
215
+ let language = "中文";
216
+ if (options.orderId) {
217
+ const cached = await loadSciArticleCache(options.orderId);
218
+ if (!cached) {
219
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `订单 ${options.orderId} 的全文缓存缺失或已清理,请重新执行步骤② 或通过 --file <path> 显式提供全文 Markdown`);
220
+ }
221
+ article = cached.article;
222
+ references = cached.references;
223
+ if (!options.produceId && cached.workflowRunId) {
224
+ produceId = cached.workflowRunId;
225
+ }
226
+ language = resolveSciArticleDownloadLanguage(options.language, cached.language);
227
+ }
228
+ else if (options.file) {
229
+ try {
230
+ article = await readFile(resolveUserPath(options.file), "utf8");
231
+ }
232
+ catch {
233
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `无法读取全文文件: ${options.file}`);
234
+ }
235
+ references = await resolveReferences(options);
236
+ language = resolveSciArticleDownloadLanguage(options.language);
237
+ }
238
+ else {
239
+ throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "请通过 --order-id 命中步骤② 缓存,或通过 --file <path> 显式提供全文 Markdown");
240
+ }
241
+ const withTitle = ensureSciArticleTitleHeading(article);
242
+ const markdown = appendReferencesToMarkdown(withTitle.markdown, references, language);
243
+ const articleTitle = extractSciExportTitle(markdown);
244
+ const { buffer, contentType } = await downloadSciArticleDocx(markdown, {
245
+ produceId,
246
+ });
247
+ const docxPath = resolveArticleDownloadPath(options.output, articleTitle);
248
+ await writeFile(docxPath, buffer);
249
+ const mdPath = resolveArticleMarkdownPath(docxPath);
250
+ const mdBuffer = Buffer.from(markdown, "utf8");
251
+ await writeFile(mdPath, mdBuffer);
252
+ if (options.orderId) {
253
+ try {
254
+ await popSciArticleCache(options.orderId);
255
+ }
256
+ catch (error) {
257
+ console.warn(`[sci-cache] 清理失败 orderId=${options.orderId}: ${error.message}`);
258
+ }
259
+ }
260
+ const filename = `${toSciExportBasename(articleTitle)}.docx`;
261
+ const result = {
262
+ mdPath,
263
+ mdSize: mdBuffer.byteLength,
264
+ docxPath,
265
+ docxSize: buffer.byteLength,
266
+ contentType,
267
+ filename,
268
+ };
269
+ const emitOutput = options.emitOutput !== false;
270
+ if (!emitOutput) {
271
+ return result;
272
+ }
273
+ if (options.format === "json") {
274
+ printOutput(result, "json");
275
+ return result;
276
+ }
277
+ console.log(`全文 Markdown 已保存: ${mdPath} (${result.mdSize} 字节)`);
278
+ console.log(`全文 Word 已保存: ${docxPath} (${result.docxSize} 字节)`);
279
+ return result;
280
+ }
281
+ //# sourceMappingURL=article-download.js.map