@cloud411716/fancy-webnovel 0.1.68 → 0.1.70

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
@@ -23,32 +23,6 @@ export function notify(session, text) {
23
23
  });
24
24
  }
25
25
 
26
- // --------------------------------------------------------------------------
27
- // notifyReplaceable — 同步追加消息,返回 SessionEvent(用于后续原地 replace)
28
- // --------------------------------------------------------------------------
29
-
30
- export function notifyReplaceable(session, text) {
31
- const ev = session.append(
32
- 'user/message',
33
- { content: [{ type: 'text', text: String(text) }], source: { kind: 'user' } },
34
- { surfaceOp: 'append' }
35
- );
36
- console.error('[notifyReplaceable] seq=', ev.seq, 'type=', ev.type);
37
- return ev;
38
- }
39
-
40
- // --------------------------------------------------------------------------
41
- // replaceMessage — 原地替换指定 seq 的消息内容
42
- // --------------------------------------------------------------------------
43
-
44
- export function replaceMessage(session, seq, text) {
45
- session.append(
46
- 'user/message',
47
- { content: [{ type: 'text', text: String(text) }], source: { kind: 'user' } },
48
- { surfaceOp: { op: 'replace', start: seq, end: seq }, sourceEventSeqs: [seq] }
49
- );
50
- }
51
-
52
26
  // --------------------------------------------------------------------------
53
27
  // llmFollowup
54
28
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
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, llmFollowup, spawnScript, notifyReplaceable, replaceMessage } from '../../infra.js';
7
+ import { notify, llmFollowup, spawnScript } from '../../infra.js';
8
8
  import { scan, PLATFORM_TABLE, platformLabel } from './templates.js';
9
9
 
10
10
  export const inject = ['commands', 'userQuestions'];
@@ -20,6 +20,26 @@ 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: 验证 ctx.get('sessions') 是否可访问 ───────────────────────
24
+ {
25
+ const sessions = ctx.get('sessions');
26
+ notify(session, `[TEST] ctx.get('sessions') = ${sessions ? 'AVAILABLE' : 'UNDEFINED'}`);
27
+ if (sessions) {
28
+ const s = sessions.active;
29
+ notify(session, `[TEST] sessions.active = ${s ? s.id : 'UNDEFINED'}`);
30
+ if (s) {
31
+ // 追加一个 fake tool/call,看 status bar 是否出现进度
32
+ s.append('tool/call', {
33
+ callId: 'test-call-1',
34
+ name: 'fancy-scan/progress',
35
+ arguments: JSON.stringify({ platform: 'test', length: 'test' }),
36
+ });
37
+ notify(session, '[TEST] 追加了 fake tool/call 事件');
38
+ }
39
+ }
40
+ }
41
+ // ─── TEST 结束 ───────────────────────────────────────────────────────
42
+
23
43
  // 获取项目根
24
44
  let projectRoot = rawInput ? rawInput.split(/\s+/)[0] : '';
25
45
  if (!projectRoot) projectRoot = process.cwd();
@@ -92,26 +112,12 @@ export async function apply(ctx) {
92
112
 
93
113
  notify(session, scan.notify({ type: 'collecting', platform, length }));
94
114
 
95
- // 原地 spinner:追加一条消息,后续每 400ms原地更新
96
- const FRAMES = '⠋⠙⠹⠸⠴⠦⠧⠇⠏';
97
- let frame = 0;
98
- const spinnerEv = notifyReplaceable(session, `⏳ ${FRAMES[frame]} 采集中...`);
99
- const spinnerSeq = spinnerEv.seq;
100
-
101
- const scriptResult = await new Promise(async (resolve) => {
102
- const ticker = setInterval(() => {
103
- frame++;
104
- replaceMessage(session, spinnerSeq, `⏳ ${FRAMES[frame % FRAMES.length]} 采集中...`);
105
- }, 400);
106
-
107
- const result = await spawnScript('node',
108
- [join(SCAN_SCRIPTS_DIR, 'run-scan.js'),
109
- '--project-root', projectRoot, '--platform', platform, '--length', length],
110
- { timeout: 120000 }
111
- );
112
- clearInterval(ticker);
113
- resolve(result);
114
- });
115
+ const scriptResult = await spawnScript(
116
+ 'node',
117
+ [join(SCAN_SCRIPTS_DIR, 'run-scan.js'),
118
+ '--project-root', projectRoot, '--platform', platform, '--length', length],
119
+ { timeout: 120000 }
120
+ );
115
121
 
116
122
  if (!scriptResult.ok) {
117
123
  const err = (typeof scriptResult.error === 'object' && scriptResult.error !== null)