@cloud411716/fancy-webnovel 0.1.75 → 0.1.76

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.
package/infra.js CHANGED
@@ -66,3 +66,17 @@ export function spawnScript(cmd, args, { timeout = 30000, cwd } = {}) {
66
66
  proc.on('error', (err) => resolve({ ok: false, output: '', error: err.message }));
67
67
  });
68
68
  }
69
+
70
+ // --------------------------------------------------------------------------
71
+ // activity — Activity Line 计时器(显示 Running… + 实时计时)
72
+ // 调用 startActivity() 返回 stop 函数,进入新阶段时先 stop 再 start
73
+ // --------------------------------------------------------------------------
74
+
75
+ /**
76
+ * @param {import('@deepseek-ai/dsh-session').Session} session
77
+ * @returns {() => void} stop — 调用后停止计时
78
+ */
79
+ export function startActivity(session) {
80
+ session.append('turn/start', { source: 'fancy-plugin' });
81
+ return () => session.append('turn/end', { source: 'fancy-plugin' });
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -4,7 +4,7 @@
4
4
  import { fileURLToPath } from 'url';
5
5
  import { dirname, join } from 'path';
6
6
  import { existsSync } from 'fs';
7
- import { notify, spawnScript } from '../../infra.js';
7
+ import { notify, spawnScript, startActivity } from '../../infra.js';
8
8
  import { bootstrap } from './templates.js';
9
9
 
10
10
  export const inject = ['commands', 'userQuestions'];
@@ -79,7 +79,9 @@ export async function apply(ctx) {
79
79
  }
80
80
 
81
81
  notify(session, bootstrap.notify({ type: 'initializing', projectRoot }));
82
+ const stopActivity = startActivity(session);
82
83
  const result = await spawnScript('node', [join(SCRIPTS_DIR, 'init.js'), projectRoot], { timeout: 30000 });
84
+ stopActivity();
83
85
 
84
86
  if (result.ok) {
85
87
  notify(session, bootstrap.notify({ type: 'success' }));
@@ -4,7 +4,7 @@
4
4
  import { fileURLToPath } from 'url';
5
5
  import { dirname, join } from 'path';
6
6
  import { existsSync } from 'fs';
7
- import { notify, llmFollowup, spawnScript } from '../../infra.js';
7
+ import { notify, llmFollowup, spawnScript, startActivity } from '../../infra.js';
8
8
  import { scan, PLATFORM_TABLE, platformLabel } from './templates.js';
9
9
 
10
10
  export const inject = ['commands', 'userQuestions'];
@@ -20,23 +20,6 @@ export async function apply(ctx) {
20
20
  const session = invocation.agent.session;
21
21
  const rawInput = invocation.rawInput ? invocation.rawInput.trim() : '';
22
22
 
23
- // ─── TEST: 验证直接用 invocation.agent.session 追加事件 ─────────────────
24
- {
25
- // invocation.agent.session 就是 Session 对象,直接 append
26
- const s = invocation.agent.session;
27
- notify(session, `[TEST] session.id = ${s?.id ?? 'UNDEFINED'}`);
28
- if (s) {
29
- // 追加一个 fake tool/call,看 status bar 是否出现进度
30
- s.append('tool/call', {
31
- callId: 'test-call-1',
32
- name: 'fancy-scan/progress',
33
- arguments: JSON.stringify({ platform: 'test', length: 'test' }),
34
- });
35
- notify(session, '[TEST] session.append(tool/call) 成功');
36
- }
37
- }
38
- // ─── TEST 结束 ───────────────────────────────────────────────────────
39
-
40
23
  // 获取项目根
41
24
  let projectRoot = rawInput ? rawInput.split(/\s+/)[0] : '';
42
25
  if (!projectRoot) projectRoot = process.cwd();
@@ -109,17 +92,14 @@ export async function apply(ctx) {
109
92
 
110
93
  notify(session, scan.notify({ type: 'collecting', platform, length }));
111
94
 
112
- // 开始计时
113
- session.append('turn/start', { source: 'fancy-scan' });
114
-
95
+ const stopActivity = startActivity(session);
115
96
  const scriptResult = await spawnScript(
116
97
  'node',
117
98
  [join(SCAN_SCRIPTS_DIR, 'run-scan.js'),
118
99
  '--project-root', projectRoot, '--platform', platform, '--length', length],
119
100
  { timeout: 120000 }
120
101
  );
121
-
122
- session.append('turn/end', { source: 'fancy-scan' });
102
+ stopActivity();
123
103
 
124
104
  if (!scriptResult.ok) {
125
105
  const err = (typeof scriptResult.error === 'object' && scriptResult.error !== null)