@cloud411716/fancy-webnovel 1.0.45 → 1.0.46
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.
|
@@ -84,9 +84,9 @@ export function apply(ctx) {
|
|
|
84
84
|
if (!projectRoot) {
|
|
85
85
|
let result;
|
|
86
86
|
try {
|
|
87
|
-
// Note: not passing agent parameter to avoid scopeTarget issues in dsh-web
|
|
88
87
|
result = await ctx.userQuestions.ask({
|
|
89
88
|
questions: [bootstrap.askPath()],
|
|
89
|
+
agent: invocation.agent,
|
|
90
90
|
signal,
|
|
91
91
|
});
|
|
92
92
|
} catch (err) {
|
|
@@ -98,6 +98,10 @@ export function apply(ctx) {
|
|
|
98
98
|
}
|
|
99
99
|
throw err;
|
|
100
100
|
}
|
|
101
|
+
// Handle case where user skipped or X'd the question
|
|
102
|
+
if (!result?.answers?.[0]) {
|
|
103
|
+
return notify(session, 'error', bootstrap.notify({ type: 'cancelled' }));
|
|
104
|
+
}
|
|
101
105
|
projectRoot = result.answers[0]?.custom?.trim() ?? '';
|
|
102
106
|
}
|
|
103
107
|
|
|
@@ -121,7 +125,6 @@ export function apply(ctx) {
|
|
|
121
125
|
// ---------- confirm ----------
|
|
122
126
|
let confirm;
|
|
123
127
|
try {
|
|
124
|
-
// Note: not passing agent parameter to avoid scopeTarget issues in dsh-web
|
|
125
128
|
confirm = await ctx.userQuestions.ask({
|
|
126
129
|
questions: [{
|
|
127
130
|
id: 'confirm',
|
|
@@ -130,6 +133,7 @@ export function apply(ctx) {
|
|
|
130
133
|
hideCustomInput: true,
|
|
131
134
|
options: bootstrap.confirmOptions(),
|
|
132
135
|
}],
|
|
136
|
+
agent: invocation.agent,
|
|
133
137
|
signal,
|
|
134
138
|
});
|
|
135
139
|
} catch (err) {
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* 因为项目根由用户指定,不一定在 DSH workspace 内。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { mkdirSync, writeFileSync, existsSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
|
|
9
12
|
const DIRS = [
|
|
10
13
|
'设定/角色', '设定/势力', '设定/物品', '设定/地点',
|
|
11
14
|
'大纲', '正文', '故事档案', '对标', '拆文库',
|
|
@@ -19,9 +22,6 @@ const DIRS = [
|
|
|
19
22
|
* @returns {Promise<{ ok: boolean, error?: string }>}
|
|
20
23
|
*/
|
|
21
24
|
export async function initProject(projectRoot) {
|
|
22
|
-
const { mkdirSync, writeFileSync, existsSync } = await import('fs');
|
|
23
|
-
const { join } = await import('path');
|
|
24
|
-
|
|
25
25
|
// Validate
|
|
26
26
|
if (!projectRoot || typeof projectRoot !== 'string') {
|
|
27
27
|
return { ok: false, error: '无效的项目根路径' };
|
package/commands/scan/index.js
CHANGED
|
@@ -31,6 +31,12 @@ function platformLabel(platform) {
|
|
|
31
31
|
return row ? row[2] : platform;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const SCRAPERS = { qidian, fanqie, jinjiang, qimao };
|
|
35
|
+
|
|
36
|
+
// ASCII spinner sequence for live progress feedback during scraping
|
|
37
|
+
const SPINNER = ['|', '/', '—', '\\'];
|
|
38
|
+
let _spinnerIdx = 0;
|
|
39
|
+
|
|
34
40
|
const scan = {
|
|
35
41
|
platformList() {
|
|
36
42
|
return (
|
|
@@ -40,7 +46,7 @@ const scan = {
|
|
|
40
46
|
},
|
|
41
47
|
|
|
42
48
|
askPlatform() {
|
|
43
|
-
return { question: '📊 请选择要扫的平台(输入编号 1-4):' };
|
|
49
|
+
return { id: 'platform', question: '📊 请选择要扫的平台(输入编号 1-4):' };
|
|
44
50
|
},
|
|
45
51
|
|
|
46
52
|
rankOptions(platform) {
|
|
@@ -114,12 +120,6 @@ const scan = {
|
|
|
114
120
|
},
|
|
115
121
|
};
|
|
116
122
|
|
|
117
|
-
const SCRAPERS = { qidian, fanqie, jinjiang, qimao };
|
|
118
|
-
|
|
119
|
-
// ASCII spinner sequence for live progress feedback during scraping
|
|
120
|
-
const SPINNER = ['|', '/', '—', '\\'];
|
|
121
|
-
let _spinnerIdx = 0;
|
|
122
|
-
|
|
123
123
|
/**
|
|
124
124
|
* @param {object} ctx - Cordis plugin context
|
|
125
125
|
*/
|
|
@@ -140,13 +140,13 @@ export function apply(ctx) {
|
|
|
140
140
|
// ---------- platform selection ----------
|
|
141
141
|
let platformResult;
|
|
142
142
|
try {
|
|
143
|
-
// Note: not passing agent parameter to avoid scopeTarget issues in dsh-web
|
|
144
143
|
platformResult = await ctx.userQuestions.ask({
|
|
145
144
|
questions: [{
|
|
146
145
|
id: 'platform',
|
|
147
146
|
...scan.askPlatform(),
|
|
148
147
|
question: `${scan.platformList()}\n\n请选择要扫的平台(输入编号 1-4):`,
|
|
149
148
|
}],
|
|
149
|
+
agent: invocation.agent,
|
|
150
150
|
signal,
|
|
151
151
|
});
|
|
152
152
|
} catch (err) {
|
|
@@ -160,6 +160,10 @@ export function apply(ctx) {
|
|
|
160
160
|
// Re-throw unexpected errors
|
|
161
161
|
throw err;
|
|
162
162
|
}
|
|
163
|
+
// Handle case where user skipped or X'd the question
|
|
164
|
+
if (!platformResult?.answers?.[0]) {
|
|
165
|
+
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
166
|
+
}
|
|
163
167
|
const answer = platformResult.answers[0]?.custom?.trim();
|
|
164
168
|
if (!answer) {
|
|
165
169
|
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
@@ -174,9 +178,9 @@ export function apply(ctx) {
|
|
|
174
178
|
// ---------- rank selection (multi-select) ----------
|
|
175
179
|
let rankResult;
|
|
176
180
|
try {
|
|
177
|
-
// Note: not passing agent parameter to avoid scopeTarget issues in dsh-web
|
|
178
181
|
rankResult = await ctx.userQuestions.ask({
|
|
179
182
|
questions: [scan.askRankList(platform)],
|
|
183
|
+
agent: invocation.agent,
|
|
180
184
|
signal,
|
|
181
185
|
});
|
|
182
186
|
} catch (err) {
|
|
@@ -188,6 +192,10 @@ export function apply(ctx) {
|
|
|
188
192
|
}
|
|
189
193
|
throw err;
|
|
190
194
|
}
|
|
195
|
+
// Handle case where user skipped or X'd the question
|
|
196
|
+
if (!rankResult?.answers?.[0]) {
|
|
197
|
+
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
198
|
+
}
|
|
191
199
|
const selected = rankResult.answers[0]?.selected ?? [];
|
|
192
200
|
const custom = rankResult.answers[0]?.custom?.trim();
|
|
193
201
|
|