@cloud411716/fancy-webnovel 1.0.18 → 1.0.20

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.
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { existsSync } from 'fs';
9
9
  import { join } from 'path';
10
- import { notify, askWithoutAcknowledgement } from '../../infra.js';
10
+ import { notify } from '../../infra.js';
11
11
  import { initProject } from './init-project.js';
12
12
 
13
13
  // inject is declared in the root index.js; only apply() is imported by index.js
@@ -23,6 +23,7 @@ function isValidPath(p) {
23
23
  const bootstrap = {
24
24
  askPath() {
25
25
  return {
26
+ id: 'path',
26
27
  question: '📂 请输入项目根路径(输入 . 代表当前路径)',
27
28
  };
28
29
  },
@@ -76,8 +77,9 @@ export function apply(ctx) {
76
77
  let projectRoot = rawInput;
77
78
 
78
79
  if (!projectRoot) {
79
- const result = await askWithoutAcknowledgement(ctx, session, {
80
+ const result = await ctx.userQuestions.ask({
80
81
  questions: [bootstrap.askPath()],
82
+ agent: invocation.agent,
81
83
  signal,
82
84
  });
83
85
  projectRoot = result.answers[0]?.custom?.trim() ?? '';
@@ -104,7 +106,7 @@ export function apply(ctx) {
104
106
  }
105
107
 
106
108
  // ---------- confirm ----------
107
- const confirm = await askWithoutAcknowledgement(ctx, session, {
109
+ const confirm = await ctx.userQuestions.ask({
108
110
  questions: [{
109
111
  id: 'confirm',
110
112
  question: bootstrap.notify({ type: 'confirm', projectRoot }),
@@ -112,6 +114,7 @@ export function apply(ctx) {
112
114
  hideCustomInput: true,
113
115
  options: bootstrap.confirmOptions(),
114
116
  }],
117
+ agent: invocation.agent,
115
118
  signal,
116
119
  });
117
120
  const ans = confirm.answers[0];
@@ -122,10 +125,6 @@ export function apply(ctx) {
122
125
  }
123
126
 
124
127
  // ---------- init (in-process, no subprocess) ----------
125
- // Yield to the event loop so DSH's "问卷已答" acknowledgement
126
- // is flushed to the UI before we append our own messages.
127
- await Promise.resolve();
128
-
129
128
  const result = await initProject(projectRoot);
130
129
 
131
130
  if (result.ok) {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { existsSync } from 'fs';
9
9
  import { join } from 'path';
10
- import { notify, llmFollowup, StatusLine, askWithoutAcknowledgement } from '../../infra.js';
10
+ import { notify, llmFollowup, StatusLine } from '../../infra.js';
11
11
  import { runScans } from './scraper.js';
12
12
  import * as qidian from './platforms/qidian.js';
13
13
  import * as fanqie from './platforms/fanqie.js';
@@ -135,8 +135,9 @@ export function apply(ctx) {
135
135
  // ---------- platform selection ----------
136
136
  notify(session, scan.platformList());
137
137
 
138
- const platformResult = await askWithoutAcknowledgement(ctx, session, {
138
+ const platformResult = await ctx.userQuestions.ask({
139
139
  questions: [scan.askPlatform()],
140
+ agent: invocation.agent,
140
141
  signal,
141
142
  });
142
143
  const answer = platformResult.answers[0]?.custom?.trim();
@@ -153,8 +154,9 @@ export function apply(ctx) {
153
154
  const platform = row[1];
154
155
 
155
156
  // ---------- rank selection (multi-select) ----------
156
- const rankResult = await askWithoutAcknowledgement(ctx, session, {
157
+ const rankResult = await ctx.userQuestions.ask({
157
158
  questions: [scan.askRankList(platform)],
159
+ agent: invocation.agent,
158
160
  signal,
159
161
  });
160
162
  const selected = rankResult.answers[0]?.selected ?? [];
package/index.js CHANGED
@@ -8,12 +8,9 @@
8
8
  * Architecture:
9
9
  * - All scrapers run IN-PROCESS (no subprocess).
10
10
  * DSH manages the lifecycle via ctx.effect() and AbortSignal.
11
- * Progress is reported via ctx.events (fancy/scan:* events).
12
11
  * - HTTP fetching uses Node.js native fetch (portable across all DSH UIs).
13
12
  * - File operations use Node.js fs (project roots may be outside workspace).
14
13
  * - ctx.timer (via ctx.timeout()) handles all delays/timeouts.
15
- * - askWithoutAcknowledgement() wraps ctx.userQuestions.ask() to suppress
16
- * the DSH "问卷已答" tool-result acknowledgement.
17
14
  *
18
15
  * Required Cordis services: commands, userQuestions, timer
19
16
  * (all are part of dsh-base, so this plugin works on dsh-tui, dsh-web, dsh-desktop).
package/infra.js CHANGED
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * Provides:
5
5
  * notify(session, text) — append a user-facing message to the session log
6
- * llmFollowup(invocation,prompt) — hand a prompt to the LLM as a user message
7
- * askWithoutAcknowledgement(ctx, session, options) — ctx.userQuestions.ask() wrapper
8
- * that suppresses the DSH "问卷已答" tool-result acknowledgement
6
+ * llmFollowup(invocation,prompt) — hand a prompt to the LLM as a user message
9
7
  * StatusLine(session) — in-place updatable status bar via surfaceOp replace
10
- * scanProgress(ctx, phase, data) — emit structured scan progress events
8
+ * scanProgress(ctx, phase, data) — emit structured scan progress events
11
9
  * sleep(ctx, ms) — DSH-native promise delay via ctx.timeout()
12
10
  *
13
11
  * All fancy-* plugins import from this file.
@@ -34,48 +32,6 @@ export function notify(session, text) {
34
32
  );
35
33
  }
36
34
 
37
- // --------------------------------------------------------------------------
38
- // askWithoutAcknowledgement — ctx.userQuestions.ask() wrapper that suppresses
39
- // the DSH "问卷已答" tool-result acknowledgement by replacing the tool result
40
- // event in the session log with an empty one.
41
- // --------------------------------------------------------------------------
42
-
43
- /**
44
- * Wrapper around ctx.userQuestions.ask() that suppresses the DSH "问卷已答"
45
- * tool-result acknowledgement.
46
- *
47
- * After ctx.userQuestions.ask() resolves, DSH appends a tool/result event to the
48
- * session log. This function locates that event and replaces its content with
49
- * an empty array using session's surfaceOp replace — the event stays in the log
50
- * (so sequence is stable) but renders nothing.
51
- *
52
- * @param {object} ctx - Cordis plugin context (has userQuestions service)
53
- * @param {object} session - DSH Session object
54
- * @param {object} options - same shape as ctx.userQuestions.ask() options
55
- * @param {AbortSignal} [options.signal]
56
- * @param {object[]} options.questions
57
- * @returns {Promise<{ answers: object[] }>} the raw result from userQuestions
58
- */
59
- export async function askWithoutAcknowledgement(ctx, session, options) {
60
- const logLenBefore = session.log.length;
61
- const result = await ctx.userQuestions.ask(options);
62
-
63
- // DSH appended a tool/result event after userQuestions resolved.
64
- // Find it and replace its content with empty so nothing renders.
65
- if (session.log.length > logLenBefore) {
66
- const lastEvent = session.log[session.log.length - 1];
67
- if (lastEvent.type === 'tool/result') {
68
- session.append(
69
- 'tool/result',
70
- { message: { content: [] }, source: { kind: 'user' } },
71
- { surfaceOp: { op: 'replace', start: lastEvent.seq, end: lastEvent.seq } }
72
- );
73
- }
74
- }
75
-
76
- return result;
77
- }
78
-
79
35
  // --------------------------------------------------------------------------
80
36
  // StatusLine — in-place updatable status bar using session surfaceOp replace
81
37
  // --------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -9,7 +9,6 @@
9
9
  "files": [
10
10
  "index.js",
11
11
  "infra.js",
12
- "events.js",
13
12
  "cordis.patch.yml",
14
13
  "commands/"
15
14
  ],