@cloud411716/fancy-webnovel 1.0.17 → 1.0.19

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.
@@ -78,6 +78,7 @@ export function apply(ctx) {
78
78
  if (!projectRoot) {
79
79
  const result = await ctx.userQuestions.ask({
80
80
  questions: [bootstrap.askPath()],
81
+ agent: invocation.agent,
81
82
  signal,
82
83
  });
83
84
  projectRoot = result.answers[0]?.custom?.trim() ?? '';
@@ -112,6 +113,7 @@ export function apply(ctx) {
112
113
  hideCustomInput: true,
113
114
  options: bootstrap.confirmOptions(),
114
115
  }],
116
+ agent: invocation.agent,
115
117
  signal,
116
118
  });
117
119
  const ans = confirm.answers[0];
@@ -122,10 +124,6 @@ export function apply(ctx) {
122
124
  }
123
125
 
124
126
  // ---------- 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
127
  const result = await initProject(projectRoot);
130
128
 
131
129
  if (result.ok) {
@@ -137,6 +137,7 @@ export function apply(ctx) {
137
137
 
138
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();
@@ -155,6 +156,7 @@ export function apply(ctx) {
155
156
  // ---------- rank selection (multi-select) ----------
156
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,11 @@
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
14
  *
16
- * Required Cordis services: commands, userQuestions, timer, tools
15
+ * Required Cordis services: commands, userQuestions, timer
17
16
  * (all are part of dsh-base, so this plugin works on dsh-tui, dsh-web, dsh-desktop).
18
17
  *
19
18
  * IMPORTANT: This plugin needs `danger-full-access` sandbox mode because it
@@ -21,7 +20,6 @@
21
20
  * specifies). Declare this in the profile's cordis.patch.yml.
22
21
  */
23
22
 
24
- import { defineTool } from '@deepseek-ai/dsh-tools';
25
23
  import { apply as applyBootstrap } from './commands/bootstrap/index.js';
26
24
  import { apply as applyScan } from './commands/scan/index.js';
27
25
 
@@ -29,75 +27,15 @@ import { apply as applyScan } from './commands/scan/index.js';
29
27
  * Services this plugin requires from the Cordis context.
30
28
  * All are provided by dsh-base, so this works on every DSH UI.
31
29
  */
32
- export const inject = ['commands', 'userQuestions', 'timer', 'tools'];
30
+ export const inject = ['commands', 'userQuestions', 'timer'];
33
31
 
34
32
  /**
35
33
  * Called once when the plugin is loaded into a Cordis context (fiber).
36
- * Registers slash commands and overrides the builtin ask_user_question tool
37
- * to suppress the "问卷已答" tool-result message.
34
+ * Registers slash commands; actual logic lives in per-command modules.
38
35
  *
39
36
  * @param {object} ctx - Cordis plugin context
40
37
  */
41
38
  export function apply(ctx) {
42
- // Override the builtin ask_user_question tool so it returns null instead
43
- // of { answers: [...] }, preventing DSH from appending a tool/result event
44
- // (which renders as "问卷已答" in the web UI). ctx.userQuestions.ask()
45
- // still works normally — only the tool result acknowledgement is suppressed.
46
- ctx.tools.register(defineTool({
47
- name: 'ask_user_question',
48
- description: 'Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. Send one or more questions, each with a stable id that will be echoed in the answer.',
49
- parameters: {
50
- questions: {
51
- type: 'array',
52
- required: true,
53
- description: 'Questions to ask the user before continuing.',
54
- items: {
55
- type: 'object',
56
- additionalProperties: true,
57
- properties: {
58
- id: { type: 'string', required: true, description: 'Stable id for this question; echoed in the answer.' },
59
- question: { type: 'string', required: true, description: 'The specific question to ask the user.' },
60
- header: { type: 'string', description: 'Optional short heading for the question.' },
61
- options: {
62
- type: 'array',
63
- description: 'Optional choices to show the user.',
64
- items: {
65
- type: 'object',
66
- additionalProperties: true,
67
- properties: {
68
- label: { type: 'string', required: true, description: 'Short user-facing option label.' },
69
- description: { type: 'string', description: 'One sentence explaining the option.' },
70
- },
71
- },
72
- },
73
- multi_select: { type: 'boolean' },
74
- hideCustomInput: { type: 'boolean' },
75
- },
76
- },
77
- },
78
- },
79
- output: {
80
- schema: { type: 'null' },
81
- render() { return []; },
82
- },
83
- async execute(args, exec) {
84
- await ctx.userQuestions.ask({
85
- questions: args.questions.map((q) => ({
86
- id: q.id,
87
- question: q.question,
88
- ...q.header !== undefined ? { header: q.header } : {},
89
- ...q.options !== undefined ? { options: q.options } : {},
90
- ...q.multi_select !== undefined ? { multiSelect: q.multi_select } : {},
91
- ...q.hideCustomInput !== undefined ? { hideCustomInput: q.hideCustomInput } : {},
92
- })),
93
- ...exec.agent !== undefined ? { agent: exec.agent } : {},
94
- signal: exec.signal,
95
- });
96
- // Return null to suppress the tool-result acknowledgement ("问卷已答").
97
- return null;
98
- },
99
- }));
100
-
101
39
  applyBootstrap(ctx);
102
40
  applyScan(ctx);
103
41
  }
package/infra.js CHANGED
@@ -2,11 +2,11 @@
2
2
  * infra.js — DSH Plugin Core Infrastructure
3
3
  *
4
4
  * Provides:
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
- * StatusLine(session) — in-place updatable status bar via surfaceOp replace
8
- * scanProgress(ctx, phase, data)— emit structured scan progress events
9
- * sleep(ctx, ms) — DSH-native promise delay via ctx.timeout()
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
+ * StatusLine(session) — in-place updatable status bar via surfaceOp replace
8
+ * scanProgress(ctx, phase, data) — emit structured scan progress events
9
+ * sleep(ctx, ms) — DSH-native promise delay via ctx.timeout()
10
10
  *
11
11
  * All fancy-* plugins import from this file.
12
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
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
  ],