helixlife-v5-cli 1.2.7 → 1.2.9

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 (46) hide show
  1. package/README.md +33 -58
  2. package/helix-cli.js +7 -2
  3. package/lib/.cli.runtime.generated.json +10 -1
  4. package/lib/automation-file-chooser-guard.js +182 -0
  5. package/lib/automation-overlay.init.js +332 -68
  6. package/lib/browser-css-cache-guard.init-page.js +49 -0
  7. package/lib/browser-window-maximize.init-page.js +64 -0
  8. package/lib/cli.js +316 -14
  9. package/lib/helix-reload-bypass-cache.run-code.js +7 -0
  10. package/lib/helix-styles-guard.js +77 -0
  11. package/lib/hide-nested-skills.js +120 -0
  12. package/lib/native-mode-patch.js +288 -0
  13. package/lib/postinstall.js +39 -0
  14. package/lib/profile-lock-guard.js +187 -0
  15. package/lib/runtime-config.js +90 -0
  16. package/lib/token-file.js +189 -0
  17. package/lib/visual-page-wrap.js +311 -0
  18. package/lib/visual.js +255 -86
  19. package/package.json +9 -21
  20. package/scripts/README.md +81 -0
  21. package/scripts/{analysis-detail-upload-file.js → analysis/detail-upload-file.js} +1 -1
  22. package/scripts/{jigsaw-inspect-dom.js → analysis/jigsaw-inspect-dom.js} +15 -15
  23. package/scripts/{jigsaw-verify-enumerate.js → analysis/jigsaw-verify-enumerate.js} +1 -1
  24. package/scripts/common/.gitkeep +0 -0
  25. package/scripts/{chrome-pdf-enumerate-a11y.js → edu/chrome-pdf-enumerate-a11y.js} +1 -1
  26. package/scripts/{chrome-pdf-goto-page.js → edu/chrome-pdf-goto-page.js} +1 -1
  27. package/scripts/{chrome-pdf-zoom-out.js → edu/chrome-pdf-zoom-out.js} +1 -1
  28. package/scripts/{hover-partial-chapter-match.js → edu/hover-partial-chapter-match.js} +1 -1
  29. package/scripts/maintainer/strip-extra-skills.ps1 +27 -0
  30. package/scripts/workbench/jova/outline-edit-root-title.js +33 -0
  31. package/scripts/workbench/jova/outline-keyword-edit.js +122 -0
  32. package/scripts/workbench/jova/outline-ops.js +344 -0
  33. package/scripts/workbench/jova/outline-probe-hover.js +56 -0
  34. package/scripts/workbench/jova/proofread-ai-rewrite-section.js +94 -0
  35. package/scripts/workbench/jova/proofread-ops.js +261 -0
  36. package/scripts/workbench/jova/writing-ops.js +376 -0
  37. package/scripts/workbench/jova/writing-proofread-abstract.js +103 -0
  38. package/lib/cli.runtime.config.json +0 -5
  39. package/references/vip.helixlife.cn.site-ops.md +0 -1469
  40. package/scripts/workbench-jova-outline-regenerate-node.js +0 -173
  41. package/scripts/workbench-jova-proofread-section.js +0 -262
  42. package/scripts/workbench-jova-writing-tool.js +0 -308
  43. /package/scripts/{analysis-detail-upload-both.js → analysis/detail-upload-both.js} +0 -0
  44. /package/scripts/{jigsaw-verify-bio-tools.js → analysis/jigsaw-verify-bio-tools.js} +0 -0
  45. /package/scripts/{jigsaw-verify-drag-tool.js → analysis/jigsaw-verify-drag-tool.js} +0 -0
  46. /package/scripts/{jigsaw-verify-reference-lines.js → analysis/jigsaw-verify-reference-lines.js} +0 -0
@@ -1,173 +0,0 @@
1
- /**
2
- * 综述工作台(jova)· 确认提纲页 · 节点 AI 重新生成
3
- *
4
- * 典型场景:用户说「扩写前言」「扩写摘要」「精简结论」「润色 1. xxx」等。
5
- *
6
- * 流程:
7
- * 悬停提纲节点 → 编辑 → 填写「用户需求」→「一键生成」
8
- * → 等待「生成结果」→「替换原文」→ Popconfirm「确 定」→「保 存」
9
- *
10
- * Agent 调用约定(严格遵守):
11
- * 1) 无论节点标题是「前言」「摘要」「结论」或任意提纲节名,一律复用本脚本,禁止新建同类脚本。
12
- * 2) 将用户原话传入 HELIX_INTENT 后执行 run-code(勿依赖脚本内默认 intent):
13
- * PowerShell: $env:HELIX_INTENT='扩写摘要'; helixlife-v5-cli run-code --filename=scripts/workbench-jova-outline-regenerate-node.js
14
- * Bash: HELIX_INTENT='扩写摘要' helixlife-v5-cli run-code --filename=scripts/workbench-jova-outline-regenerate-node.js
15
- * 3) 也可显式拆分:HELIX_NODE_TITLE + HELIX_USER_REQUIREMENT(同时设置时优先于 HELIX_INTENT)
16
- *
17
- * intent / HELIX_INTENT 解析规则(<动词><节点标题>,动词与标题间可有可无空格):
18
- * 「扩写前言」 → nodeTitle=前言, userRequirement=扩写
19
- * 「扩写摘要」 → nodeTitle=摘要, userRequirement=扩写
20
- * 「精简结论」 → nodeTitle=结论, userRequirement=精简
21
- * 「润色 1. xxx」 → nodeTitle=1. xxx, userRequirement=润色
22
- * 无法解析时整句作为 userRequirement,nodeTitle 回退为「前言」
23
- */
24
- async page => {
25
- const intent = (process.env.HELIX_INTENT || '').trim();
26
-
27
- const nodeTitleOverride = process.env.HELIX_NODE_TITLE?.trim() || null;
28
- const userRequirementOverride = process.env.HELIX_USER_REQUIREMENT?.trim() || null;
29
-
30
- const VERBS = ['扩写', '精简', '改写', '润色', '重写', '优化'];
31
-
32
- function parseIntent(raw) {
33
- const normalized = raw.replace(/[::]\s*$/, '').trim();
34
- for (const verb of VERBS) {
35
- if (normalized.startsWith(verb)) {
36
- const title = normalized.slice(verb.length).trim();
37
- if (title) return { nodeTitle: title, userRequirement: verb };
38
- }
39
- }
40
- return { nodeTitle: '前言', userRequirement: normalized || raw };
41
- }
42
-
43
- if (!intent && !nodeTitleOverride) {
44
- return {
45
- ok: false,
46
- reason:
47
- '缺少 HELIX_INTENT(用户原话,如「扩写摘要」)或 HELIX_NODE_TITLE。禁止直接 run-code 而不传意图——否则会误操作默认节点。',
48
- hint: "PowerShell: $env:HELIX_INTENT='扩写摘要'; helixlife-v5-cli run-code --filename=scripts/workbench-jova-outline-regenerate-node.js",
49
- };
50
- }
51
-
52
- const parsed = intent ? parseIntent(intent) : { nodeTitle: '', userRequirement: '' };
53
- const nodeTitle = nodeTitleOverride ?? parsed.nodeTitle;
54
- const userRequirement = userRequirementOverride ?? parsed.userRequirement;
55
-
56
- if (!nodeTitle || !userRequirement) {
57
- return {
58
- ok: false,
59
- reason: '无法解析节点或动词。请传 HELIX_INTENT(如「扩写摘要」)或同时传 HELIX_NODE_TITLE + HELIX_USER_REQUIREMENT。',
60
- intent,
61
- nodeTitle,
62
- userRequirement,
63
- };
64
- }
65
-
66
- const main = page.locator('main');
67
-
68
- if (!page.url().includes('/workbench/jova/outline')) {
69
- return {
70
- ok: false,
71
- reason: '当前不在综述工作台确认提纲页 /workbench/jova/outline',
72
- intent,
73
- nodeTitle,
74
- userRequirement,
75
- };
76
- }
77
-
78
- async function resetEditingState() {
79
- const closeIcons = main.getByRole('img', { name: 'close' });
80
- for (let i = 0; i < (await closeIcons.count()); i++) {
81
- const icon = closeIcons.nth(i);
82
- if (await icon.isVisible()) {
83
- await icon.click();
84
- await page.waitForTimeout(400);
85
- }
86
- }
87
- const cancelReplace = main.getByRole('button', { name: '取 消' });
88
- if ((await cancelReplace.count()) > 0 && (await cancelReplace.first().isVisible())) {
89
- await cancelReplace.first().click();
90
- await page.waitForTimeout(400);
91
- }
92
- const saveBtn = main.getByRole('button', { name: '保 存' });
93
- if ((await saveBtn.count()) > 0 && (await saveBtn.first().isVisible())) {
94
- await saveBtn.first().click();
95
- await page.waitForTimeout(400);
96
- }
97
- }
98
-
99
- function outlineNode(title) {
100
- const base = title.replace(/[::]\s*$/, '');
101
- const titleRe = new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[::]?$`);
102
- return main
103
- .locator('[aria-label*="操作区"]')
104
- .filter({
105
- has: page.locator(':scope > *').first().filter({ hasText: titleRe }),
106
- })
107
- .first();
108
- }
109
-
110
- await resetEditingState();
111
-
112
- const opArea = outlineNode(nodeTitle);
113
- if ((await opArea.count()) === 0) {
114
- return {
115
- ok: false,
116
- reason: `未找到提纲节点「${nodeTitle}」`,
117
- intent,
118
- nodeTitle,
119
- userRequirement,
120
- };
121
- }
122
-
123
- // 1. 悬停 → 编辑
124
- await opArea.hover();
125
- await page.waitForTimeout(400);
126
- await opArea.getByRole('button', { name: '编辑' }).click();
127
-
128
- // 2. 右侧「重新生成」面板
129
- const regenTitle = main.getByText('重新生成', { exact: true });
130
- await regenTitle.waitFor({ state: 'visible', timeout: 10000 });
131
-
132
- const userReqBox = main.getByRole('textbox', { name: '用户需求' });
133
- await userReqBox.waitFor({ state: 'visible', timeout: 5000 });
134
- await userReqBox.fill(userRequirement);
135
-
136
- // 3. 一键生成 → 等待「替换原文」可用
137
- await main.getByRole('button', { name: '一键生成' }).click();
138
- const replaceBtn = main.getByRole('button', { name: '替换原文' });
139
- await replaceBtn.waitFor({ state: 'visible', timeout: 120000 });
140
- await page.waitForTimeout(800);
141
-
142
- // 4. 替换原文 → Popconfirm「是否将本次生成结果替换原文?」→ 确 定
143
- await replaceBtn.click();
144
- const confirmPrompt = main.getByText('是否将本次生成结果替换原文?', { exact: true });
145
- await confirmPrompt.waitFor({ state: 'visible', timeout: 10000 });
146
- await main.getByRole('button', { name: '确 定' }).click();
147
- await page.waitForTimeout(800);
148
-
149
- // 5. 左侧内联编辑器「保 存」
150
- const saveBtn = main.getByRole('button', { name: '保 存' });
151
- await saveBtn.waitFor({ state: 'visible', timeout: 10000 });
152
- const inlineEditor = saveBtn.locator('xpath=ancestor::li[1]//textarea | ancestor::li[1]//input[@type="text"] | ancestor::li[1]//*[@role="textbox"]').first();
153
- const editorText = (await inlineEditor.inputValue().catch(() => '')) || (await inlineEditor.textContent().catch(() => '')) || '';
154
-
155
- await saveBtn.click();
156
- await page.waitForTimeout(1000);
157
-
158
- const panelClosed = !(await regenTitle.isVisible().catch(() => false));
159
- const nodePresent = (await outlineNode(nodeTitle).count()) > 0;
160
- const contentApplied = editorText.includes(nodeTitle) || editorText.length > 0;
161
-
162
- return {
163
- ok: nodePresent && panelClosed && contentApplied,
164
- intent,
165
- nodeTitle,
166
- userRequirement,
167
- panelClosed,
168
- nodePresent,
169
- contentApplied,
170
- editorTextLength: editorText.length,
171
- url: page.url(),
172
- };
173
- }
@@ -1,262 +0,0 @@
1
- /**
2
- * 综述工作台(jova)· 初稿校对页 · 章节校对 / AI 改写
3
- *
4
- * Agent 调用约定(严格遵守):
5
- *
6
- * 1) 用户只说「校对 <章节>」、未指明操作时:
7
- * action = null → 仅滚动定位 → 悬停 → 点「点击本段进入编辑校对」或「重新编辑」
8
- * → 返回 needsUserChoice,由 Agent 询问用户选「确认校对」或「AI 改写」
9
- * → 禁止自动点「确认校对」
10
- *
11
- * 2) 用户明确说「确认校对」:action = 'confirm'
12
- *
13
- * 3) 用户明确说「AI 改写」:
14
- * action = 'ai_rewrite' → 点「AI 改写」→(有额外需求则填写)→「一键重写」→ 等待生成
15
- * → 返回 needsReplaceChoice,提醒用户是否替换原文,禁止自动点「替换原文」
16
- *
17
- * 4) 用户明确同意替换原文:action = 'replace'
18
- *
19
- * 用法:
20
- * helixlife-v5-cli run-code --filename=scripts/workbench-jova-proofread-section.js
21
- */
22
- async page => {
23
- const intent = '校对 1. 乳腺癌分子分型体系及其分子特征';
24
- const action = null; // null | 'confirm' | 'ai_rewrite' | 'replace'
25
- const extraRequirement = ''; // 仅 ai_rewrite 时可选
26
-
27
- const main = page.locator('main');
28
-
29
- function parseIntent(raw) {
30
- const m = raw.match(/^校对\s*(.+)$/);
31
- return { sectionTitle: (m ? m[1] : raw).trim() };
32
- }
33
-
34
- const { sectionTitle } = parseIntent(intent);
35
-
36
- if (!page.url().includes('/workbench/jova/proofread')) {
37
- return {
38
- ok: false,
39
- reason: '当前不在综述工作台初稿校对页 /workbench/jova/proofread',
40
- intent,
41
- sectionTitle,
42
- };
43
- }
44
-
45
- async function dismissPopconfirmOnly() {
46
- const cancel = main.getByRole('button', { name: '取 消' });
47
- if ((await cancel.count()) > 0 && (await cancel.first().isVisible())) {
48
- await cancel.first().click();
49
- await page.waitForTimeout(300);
50
- }
51
- }
52
-
53
- function sectionHeading(title) {
54
- return main.getByRole('heading', { name: title, exact: true }).first();
55
- }
56
-
57
- function sectionBlock(title) {
58
- return sectionHeading(title).locator('xpath=ancestor::div[contains(@class,"group")][1]');
59
- }
60
-
61
- async function navigateToSection(title) {
62
- const toc = main.locator('[class*="cursor-pointer"]').getByText(title, { exact: true });
63
- if ((await toc.count()) > 0) {
64
- await toc.first().click({ timeout: 3000 }).catch(() => {});
65
- await page.waitForTimeout(500);
66
- }
67
- const heading = sectionHeading(title);
68
- if ((await heading.count()) === 0) {
69
- return { ok: false, reason: `未找到章节「${title}」` };
70
- }
71
- await heading.scrollIntoViewIfNeeded();
72
- await page.waitForTimeout(400);
73
- return { ok: true };
74
- }
75
-
76
- async function detectProofreadStatus(block) {
77
- const pending = block.getByText('请校对本段内容', { exact: true });
78
- const done = block.getByText('本段完成校对', { exact: true });
79
- if ((await pending.count()) > 0) return 'pending';
80
- if ((await done.count()) > 0) return 'done';
81
- return 'completed_or_editing';
82
- }
83
-
84
- async function clickEnterEdit(block) {
85
- const enterLabels = [
86
- '点击本段进入编辑校对',
87
- '点击本段进行校对',
88
- '点击本段进行编辑校对',
89
- ];
90
- for (const label of enterLabels) {
91
- const btn = block.getByText(label, { exact: true });
92
- if ((await btn.count()) > 0 && (await btn.first().isVisible())) {
93
- await btn.first().click();
94
- return true;
95
- }
96
- }
97
- return false;
98
- }
99
-
100
- async function openSectionEdit(title) {
101
- const nav = await navigateToSection(title);
102
- if (!nav.ok) return nav;
103
-
104
- const block = sectionBlock(title);
105
-
106
- if ((await block.getByRole('button', { name: '确认校对' }).count()) > 0) {
107
- return { ok: true, proofreadStatus: 'already_editing' };
108
- }
109
-
110
- const proofreadStatus = await detectProofreadStatus(block);
111
-
112
- if (proofreadStatus === 'pending') {
113
- await block.getByText('请校对本段内容', { exact: true }).first().hover();
114
- await page.waitForTimeout(600);
115
- if (!(await clickEnterEdit(block))) {
116
- return { ok: false, reason: '未找到「点击本段进入编辑校对」入口', proofreadStatus };
117
- }
118
- } else if (proofreadStatus === 'done') {
119
- await block.getByText('本段完成校对', { exact: true }).first().hover();
120
- await page.waitForTimeout(600);
121
- const reEdit = block.getByText('重新编辑', { exact: true });
122
- if ((await reEdit.count()) === 0 || !(await reEdit.first().isVisible())) {
123
- return { ok: false, reason: '未找到「重新编辑」入口', proofreadStatus };
124
- }
125
- await reEdit.first().click();
126
- } else {
127
- await block.hover();
128
- await page.waitForTimeout(600);
129
- const reEdit = block.getByText('重新编辑', { exact: true });
130
- if ((await reEdit.count()) > 0 && (await reEdit.first().isVisible())) {
131
- await reEdit.first().click();
132
- } else if (await clickEnterEdit(block)) {
133
- // ok
134
- } else {
135
- return { ok: false, reason: '无法进入编辑模式(未找到入口)', proofreadStatus };
136
- }
137
- }
138
-
139
- await block.getByRole('button', { name: '确认校对' }).waitFor({ state: 'visible', timeout: 10000 });
140
- await page.waitForTimeout(400);
141
- return { ok: true, proofreadStatus };
142
- }
143
-
144
- async function confirmProofread(title) {
145
- const block = sectionBlock(title);
146
- await block.getByRole('button', { name: '确认校对' }).click();
147
- await page.waitForTimeout(1000);
148
- return { ok: true };
149
- }
150
-
151
- async function waitReplaceReady(timeoutMs = 120000) {
152
- const replaceBtn = main.getByRole('button', { name: '替换原文' });
153
- await replaceBtn.waitFor({ state: 'visible', timeout: timeoutMs });
154
- const deadline = Date.now() + timeoutMs;
155
- while (Date.now() < deadline) {
156
- if (await replaceBtn.isEnabled()) return replaceBtn;
157
- await page.waitForTimeout(1000);
158
- }
159
- throw new Error('等待「替换原文」可点击超时');
160
- }
161
-
162
- async function aiRewriteGenerate(title, extra) {
163
- const block = sectionBlock(title);
164
- await block.getByRole('button', { name: /AI\s*改写/ }).click();
165
- await main.getByText('原文内容', { exact: true }).waitFor({ state: 'visible', timeout: 10000 });
166
-
167
- if (extra) {
168
- const extraBox = main.getByRole('textbox', { name: '额外需求' });
169
- if ((await extraBox.count()) > 0) await extraBox.fill(extra);
170
- }
171
-
172
- await main.getByRole('button', { name: '一键重写' }).click();
173
- await waitReplaceReady();
174
-
175
- return { ok: true, generated: true, replaceReady: true };
176
- }
177
-
178
- async function aiRewriteReplace() {
179
- const replaceBtn = main.getByRole('button', { name: '替换原文' });
180
- await replaceBtn.click();
181
- await main.getByText('是否将本次生成结果替换原文?', { exact: true }).waitFor({ state: 'visible', timeout: 10000 });
182
- await main.getByRole('button', { name: '确 定' }).click();
183
- await page.waitForTimeout(1000);
184
- return { ok: true, replaced: true };
185
- }
186
-
187
- await dismissPopconfirmOnly();
188
-
189
- const needOpenEdit = action === null || action === '' || action === undefined || action === 'confirm' || action === 'ai_rewrite';
190
- let opened = { ok: true, proofreadStatus: 'already_editing' };
191
-
192
- if (needOpenEdit && action !== 'replace') {
193
- opened = await openSectionEdit(sectionTitle);
194
- if (!opened.ok) return { ok: false, intent, sectionTitle, ...opened };
195
- }
196
-
197
- if (action === null || action === undefined || action === '') {
198
- return {
199
- ok: true,
200
- needsUserChoice: true,
201
- intent,
202
- sectionTitle,
203
- proofreadStatus: opened.proofreadStatus,
204
- availableActions: ['confirm', 'ai_rewrite'],
205
- message: '已进入该段编辑模式。请选择:① 确认校对(直接完成本段校对)② AI 改写(AI 重新生成内容)',
206
- url: page.url(),
207
- };
208
- }
209
-
210
- if (action === 'confirm') {
211
- await confirmProofread(sectionTitle);
212
- const block = sectionBlock(sectionTitle);
213
- const afterStatus = await detectProofreadStatus(block);
214
- return {
215
- ok: true,
216
- intent,
217
- sectionTitle,
218
- action,
219
- proofreadStatusBefore: opened.proofreadStatus,
220
- proofreadStatusAfter: afterStatus,
221
- message: '本段已确认校对完成。',
222
- url: page.url(),
223
- };
224
- }
225
-
226
- if (action === 'ai_rewrite') {
227
- const generated = await aiRewriteGenerate(sectionTitle, extraRequirement);
228
- return {
229
- ok: generated.ok,
230
- intent,
231
- sectionTitle,
232
- action,
233
- extraRequirement: extraRequirement || null,
234
- generated: true,
235
- needsReplaceChoice: true,
236
- availableActions: ['replace'],
237
- message:
238
- 'AI 改写结果已生成。请在右侧查看「生成结果」,确认无误后告知我「替换原文」以应用;若不满意可直接在页面调整或重新生成。',
239
- url: page.url(),
240
- };
241
- }
242
-
243
- if (action === 'replace') {
244
- const replaced = await aiRewriteReplace();
245
- return {
246
- ok: replaced.ok,
247
- intent,
248
- sectionTitle,
249
- action,
250
- replaced: true,
251
- message: '已替换原文。如需完成本段校对,请明确告知「确认校对」。',
252
- url: page.url(),
253
- };
254
- }
255
-
256
- return {
257
- ok: false,
258
- reason: `未知 action「${action}」,应为 null | confirm | ai_rewrite | replace`,
259
- intent,
260
- sectionTitle,
261
- };
262
- }