@cloud411716/fancy-webnovel 4.0.3 → 4.1.0
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/lib/scraper-utils.js +11 -7
- package/lib/task-list.js +359 -0
- package/package.json +3 -2
- package/plugins/fancy-analyze/index.js +31 -3
- package/plugins/fancy-bootstrap/index.js +16 -3
- package/plugins/fancy-db/index.js +30 -3
- package/plugins/fancy-douyin/index.js +27 -8
- package/plugins/fancy-export/index.js +14 -3
- package/plugins/fancy-import/index.js +22 -3
- package/plugins/fancy-material/index.js +38 -14
- package/plugins/fancy-project/index.js +19 -3
- package/plugins/fancy-scan/index.js +301 -6
- package/plugins/fancy-scan/scripts/run-scan.js +14 -0
- package/plugins/fancy-scan/scripts/scrapers/fanqie-rank-scraper.js +163 -15
- package/plugins/fancy-scan/templates/platforms.js +20 -6
- package/plugins/fancy-scan/templates.js +10 -2
- package/plugins/fancy-scan/vision.js +388 -0
- package/plugins/fancy-story-builder/index.js +13 -3
- package/plugins/fancy-topic/index.js +37 -7
|
@@ -14,6 +14,7 @@ import path from 'path';
|
|
|
14
14
|
import { RecordId } from 'surrealdb';
|
|
15
15
|
|
|
16
16
|
import { askUserQuestion, llmFollowup, notify, spawnScript } from '#infra';
|
|
17
|
+
import { registerCommandWithTasks } from '#task-list';
|
|
17
18
|
import { readJsonFile, resolveWorkspace } from '#workspace';
|
|
18
19
|
import { connectMaterial, ensureMaterialDatabase } from '#material-db';
|
|
19
20
|
import { deployMaterialTools } from '../fancy-material/tool-deploy.js';
|
|
@@ -262,7 +263,7 @@ function retryPrompt(target, detail) {
|
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
async function analyzeNote(ctx, invocation, session, {
|
|
265
|
-
root, note, screenshots, target, materialTools, paths,
|
|
266
|
+
root, note, screenshots, target, materialTools, paths, taskList,
|
|
266
267
|
}) {
|
|
267
268
|
const prompt = analysisPrompt({
|
|
268
269
|
accountUrl: note.account_url,
|
|
@@ -334,7 +335,7 @@ async function analyzeNote(ctx, invocation, session, {
|
|
|
334
335
|
return { ok: false, error: '素材没有通过校验:' + detail };
|
|
335
336
|
}
|
|
336
337
|
|
|
337
|
-
async function runCrawl(ctx, invocation, session) {
|
|
338
|
+
async function runCrawl(ctx, invocation, session, taskList) {
|
|
338
339
|
const root = workspaceOf(session);
|
|
339
340
|
const paths = ensureDouyinDir(root);
|
|
340
341
|
const accounts = readAccounts(root);
|
|
@@ -358,6 +359,8 @@ async function runCrawl(ctx, invocation, session) {
|
|
|
358
359
|
return notify(session, 'error', '❌ 启动 Chrome 失败:' + started.error);
|
|
359
360
|
}
|
|
360
361
|
const browser = { cdp: started.cdp, mode: started.mode };
|
|
362
|
+
taskList.advance(1);
|
|
363
|
+
taskList.watchTurns(invocation);
|
|
361
364
|
|
|
362
365
|
try {
|
|
363
366
|
const runDir = path.join(paths.output, stampOfNow());
|
|
@@ -396,6 +399,7 @@ async function runCrawl(ctx, invocation, session) {
|
|
|
396
399
|
scannedAccounts += 1;
|
|
397
400
|
const notes = Array.isArray(scan.json.notes) ? scan.json.notes : [];
|
|
398
401
|
foundNotes += notes.length;
|
|
402
|
+
taskList.advance(2);
|
|
399
403
|
for (const card of notes) {
|
|
400
404
|
if (abortRequested(invocation)) { aborted = true; break outer; }
|
|
401
405
|
const noteId = noteIdFromUrl(card.href);
|
|
@@ -429,6 +433,8 @@ async function runCrawl(ctx, invocation, session) {
|
|
|
429
433
|
processedNotes += 1;
|
|
430
434
|
note.account_url = account.url;
|
|
431
435
|
const target = path.join(noteDir, 'materials.jsonl');
|
|
436
|
+
taskList.advance(3);
|
|
437
|
+
taskList.progress(`LLM 整理图文素材(${note.title || noteId})`);
|
|
432
438
|
const analyzed = await analyzeNote(ctx, invocation, session, {
|
|
433
439
|
root,
|
|
434
440
|
note,
|
|
@@ -436,6 +442,7 @@ async function runCrawl(ctx, invocation, session) {
|
|
|
436
442
|
target,
|
|
437
443
|
materialTools,
|
|
438
444
|
paths,
|
|
445
|
+
taskList,
|
|
439
446
|
});
|
|
440
447
|
if (!analyzed.ok) {
|
|
441
448
|
failures.push({ id: noteId, url: card.href, reason: analyzed.error });
|
|
@@ -462,6 +469,7 @@ async function runCrawl(ctx, invocation, session) {
|
|
|
462
469
|
}
|
|
463
470
|
}
|
|
464
471
|
|
|
472
|
+
taskList.advance(4);
|
|
465
473
|
return notify(session, (aborted || failures.length) ? 'error' : 'success', summaryText({
|
|
466
474
|
accounts: accounts.length,
|
|
467
475
|
scannedAccounts,
|
|
@@ -502,9 +510,10 @@ async function runList(session) {
|
|
|
502
510
|
return notify(session, 'success', accountListText(root));
|
|
503
511
|
}
|
|
504
512
|
|
|
505
|
-
async function runRemove(session, selector) {
|
|
513
|
+
async function runRemove(session, selector, taskList) {
|
|
506
514
|
const root = workspaceOf(session);
|
|
507
515
|
try {
|
|
516
|
+
taskList.advance(1);
|
|
508
517
|
const result = removeAccount(root, selector);
|
|
509
518
|
return notify(session, 'success', '✅ 已删除账号:' + result.url);
|
|
510
519
|
} catch (err) {
|
|
@@ -512,12 +521,22 @@ async function runRemove(session, selector) {
|
|
|
512
521
|
}
|
|
513
522
|
}
|
|
514
523
|
|
|
524
|
+
function douyinTaskTitles(invocation) {
|
|
525
|
+
const tokens = String(invocation.rawInput || '').trim().split(/\s+/).filter(Boolean);
|
|
526
|
+
const command = (tokens[0] || '').toLowerCase();
|
|
527
|
+
if (command === 'help' || command === '?') return ['显示抖音采集帮助'];
|
|
528
|
+
if (command === 'add') return ['解析主页地址', '保存账号'];
|
|
529
|
+
if (command === 'list') return ['读取账号列表'];
|
|
530
|
+
if (command === 'remove') return ['解析目标账号', '删除账号'];
|
|
531
|
+
return ['检查浏览器与素材库', '扫描账号主页', '采集笔记图片', 'LLM 整理图文素材', '写入素材库'];
|
|
532
|
+
}
|
|
533
|
+
|
|
515
534
|
export async function apply(ctx) {
|
|
516
|
-
ctx
|
|
535
|
+
registerCommandWithTasks(ctx, {
|
|
517
536
|
name: 'fancy-douyin',
|
|
518
537
|
description: '🎬 抖音图文采集 ( usage: /fancy-douyin [add <主页> | list | remove <序号|地址> | help] )',
|
|
519
538
|
input: { hint: '[add <主页> | list | remove <序号|地址> | help]' },
|
|
520
|
-
handler: async (invocation) => {
|
|
539
|
+
handler: async (invocation, taskList) => {
|
|
521
540
|
const session = invocation.agent.session;
|
|
522
541
|
const raw = String(invocation.rawInput || '').trim();
|
|
523
542
|
const tokens = raw.split(/\s+/).filter(Boolean);
|
|
@@ -537,15 +556,15 @@ export async function apply(ctx) {
|
|
|
537
556
|
}
|
|
538
557
|
if (command === 'remove') {
|
|
539
558
|
if (tokens.length < 2) return notify(session, 'error', '用法:/fancy-douyin remove <序号|主页地址>');
|
|
540
|
-
return await runRemove(session, tokens.slice(1).join(' '));
|
|
559
|
+
return await runRemove(session, tokens.slice(1).join(' '), taskList);
|
|
541
560
|
}
|
|
542
561
|
if (command) {
|
|
543
562
|
return notify(session, 'error', '未知子命令:' + command + '\n运行 /fancy-douyin help 查看用法。');
|
|
544
563
|
}
|
|
545
|
-
return await runCrawl(ctx, invocation, session);
|
|
564
|
+
return await runCrawl(ctx, invocation, session, taskList);
|
|
546
565
|
} catch (err) {
|
|
547
566
|
return notify(session, 'error', '❌ 抖音命令失败:' + (err && err.message ? err.message : String(err)));
|
|
548
567
|
}
|
|
549
568
|
},
|
|
550
|
-
});
|
|
569
|
+
}, douyinTaskTitles);
|
|
551
570
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { notify } from '#infra';
|
|
10
|
+
import { registerCommandWithTasks } from '#task-list';
|
|
10
11
|
import { openStoryGraph } from '../fancy-story-builder/storydb/client.js';
|
|
11
12
|
import { exportStoryGraph } from './exporter.js';
|
|
12
13
|
import { resolveProject } from '../../lib/projects.js';
|
|
@@ -25,12 +26,19 @@ function cwdOf(session) {
|
|
|
25
26
|
return session && session.header && session.header.cwd ? session.header.cwd : null;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
function exportTaskTitles(invocation) {
|
|
30
|
+
if (String(invocation.rawInput || '').trim().toLowerCase() === 'help') {
|
|
31
|
+
return ['显示导出帮助'];
|
|
32
|
+
}
|
|
33
|
+
return ['解析当前项目', '读取故事图', '导出 Markdown', '汇总导出结果'];
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
export async function apply(ctx) {
|
|
29
|
-
ctx
|
|
37
|
+
registerCommandWithTasks(ctx, {
|
|
30
38
|
name: 'fancy-export',
|
|
31
39
|
description: '📖 故事导出 ( usage: /fancy-export | help )',
|
|
32
40
|
input: { hint: '.' },
|
|
33
|
-
handler: async (invocation) => {
|
|
41
|
+
handler: async (invocation, tasks) => {
|
|
34
42
|
const session = invocation.agent.session;
|
|
35
43
|
const raw = String(invocation.rawInput || '').trim().toLowerCase();
|
|
36
44
|
if (raw === 'help') return notify(session, 'success', helpText());
|
|
@@ -45,10 +53,13 @@ export async function apply(ctx) {
|
|
|
45
53
|
return notify(session, 'error', '❌ ' + (err && err.message ? err.message : String(err)));
|
|
46
54
|
}
|
|
47
55
|
|
|
56
|
+
tasks.advance(1);
|
|
48
57
|
let sdb = null;
|
|
49
58
|
try {
|
|
50
59
|
sdb = await openStoryGraph(project.dir, { project });
|
|
60
|
+
tasks.advance(2);
|
|
51
61
|
const result = await exportStoryGraph(sdb, project.dir);
|
|
62
|
+
tasks.advance(3);
|
|
52
63
|
return notify(session, 'success', [
|
|
53
64
|
'✅ 已导出到 ' + result.dir,
|
|
54
65
|
'文件:' + result.files + ' 个 · 细纲:' + result.outlines + ' 章 · 正文:' + result.chapters + ' 章',
|
|
@@ -59,5 +70,5 @@ export async function apply(ctx) {
|
|
|
59
70
|
if (sdb) await sdb.close();
|
|
60
71
|
}
|
|
61
72
|
},
|
|
62
|
-
});
|
|
73
|
+
}, exportTaskTitles);
|
|
63
74
|
}
|
|
@@ -26,6 +26,7 @@ import path from 'node:path';
|
|
|
26
26
|
import { fileURLToPath } from 'node:url';
|
|
27
27
|
|
|
28
28
|
import { llmFollowup, notify, spawnScript } from '#infra';
|
|
29
|
+
import { registerCommandWithTasks } from '#task-list';
|
|
29
30
|
import { readDeployedConfig, ensureSetupId } from '#story-builder/index.js';
|
|
30
31
|
import { phaseScriptFiles } from '#story-builder/deploy-manifest.js';
|
|
31
32
|
import { makeWaitForTurn } from '#story-builder/writing-driver.js';
|
|
@@ -263,14 +264,27 @@ function importStamp() {
|
|
|
263
264
|
/**
|
|
264
265
|
* 导入阶段的命令入口。
|
|
265
266
|
*/
|
|
267
|
+
function importTaskTitles(invocation) {
|
|
268
|
+
if (String(invocation.rawInput || '').trim().toLowerCase() === 'help') {
|
|
269
|
+
return ['显示导入帮助'];
|
|
270
|
+
}
|
|
271
|
+
return [
|
|
272
|
+
'校验旧稿源与项目状态',
|
|
273
|
+
'扫描并切分章节',
|
|
274
|
+
'部署导入脚本与模板',
|
|
275
|
+
'逐轮反推设定与关系',
|
|
276
|
+
'汇总导入结果',
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
|
|
266
280
|
export async function apply(ctx) {
|
|
267
|
-
ctx
|
|
281
|
+
registerCommandWithTasks(ctx, {
|
|
268
282
|
name: 'fancy-import',
|
|
269
283
|
description: '📥 旧稿导入 ( usage: /fancy-import <旧稿目录或文件> | help )',
|
|
270
284
|
input: {
|
|
271
285
|
hint: '旧稿目录或文件'
|
|
272
286
|
},
|
|
273
|
-
handler: async (invocation) => {
|
|
287
|
+
handler: async (invocation, tasks) => {
|
|
274
288
|
const session = invocation.agent.session;
|
|
275
289
|
const { signal } = invocation;
|
|
276
290
|
|
|
@@ -316,12 +330,14 @@ export async function apply(ctx) {
|
|
|
316
330
|
}
|
|
317
331
|
|
|
318
332
|
// 2. 扫描(确定性:切章保标题 + 统计实际规模)
|
|
333
|
+
tasks.advance(1);
|
|
319
334
|
const scan = scanSource(sourcePath);
|
|
320
335
|
if (!scan.ok) {
|
|
321
336
|
return notify(session, 'error', importTemplates.notify({ type: 'no_source', err: scan.error }));
|
|
322
337
|
}
|
|
323
338
|
|
|
324
339
|
// 3. 部署导入要用的脚本 / 模板
|
|
340
|
+
tasks.advance(2);
|
|
325
341
|
const deploy = deployImportFiles(projectRoot);
|
|
326
342
|
if (!deploy.ok) {
|
|
327
343
|
return notify(session, 'error', importTemplates.notify({
|
|
@@ -382,6 +398,8 @@ export async function apply(ctx) {
|
|
|
382
398
|
projectRoot,
|
|
383
399
|
};
|
|
384
400
|
|
|
401
|
+
tasks.advance(3);
|
|
402
|
+
tasks.watchTurns(invocation);
|
|
385
403
|
const report = await runImportStage({
|
|
386
404
|
projectRoot,
|
|
387
405
|
dirs,
|
|
@@ -457,6 +475,7 @@ export async function apply(ctx) {
|
|
|
457
475
|
backupDir: writeRes.backupDir
|
|
458
476
|
});
|
|
459
477
|
writeImportReport(dirs, reportMd);
|
|
478
|
+
tasks.advance(4);
|
|
460
479
|
|
|
461
480
|
const progressSummary = progressNotes.length
|
|
462
481
|
? '导入进度:' + progressNotes.slice(-3).join(';')
|
|
@@ -487,7 +506,7 @@ export async function apply(ctx) {
|
|
|
487
506
|
extra: [progressSummary, overwriteNote].filter(Boolean).join('\n\n')
|
|
488
507
|
}));
|
|
489
508
|
}
|
|
490
|
-
});
|
|
509
|
+
}, importTaskTitles);
|
|
491
510
|
}
|
|
492
511
|
|
|
493
512
|
// ============================================================
|
|
@@ -13,6 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import { fileURLToPath } from 'url';
|
|
14
14
|
|
|
15
15
|
import { askUserQuestion, llmFollowup, notify, spawnScript } from '#infra';
|
|
16
|
+
import { registerCommandWithTasks } from '#task-list';
|
|
16
17
|
import {
|
|
17
18
|
localIsoString,
|
|
18
19
|
readSecrets,
|
|
@@ -290,7 +291,7 @@ function batchIdOfNow() {
|
|
|
290
291
|
return 'material-' + (stamp || String(Date.now()));
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
async function runImport(ctx, invocation, session, rawPath) {
|
|
294
|
+
async function runImport(ctx, invocation, session, rawPath, taskList) {
|
|
294
295
|
const root = workspaceOf(session);
|
|
295
296
|
const { input, file } = resolveInputFile(rawPath, session, root);
|
|
296
297
|
if (!input || !file) {
|
|
@@ -303,11 +304,13 @@ async function runImport(ctx, invocation, session, rawPath) {
|
|
|
303
304
|
return notify(session, 'error', '❌ 未找到素材文件,或目标不是普通文件:' + file);
|
|
304
305
|
}
|
|
305
306
|
|
|
307
|
+
taskList.advance(1);
|
|
306
308
|
const checked = await checkFile(file);
|
|
307
309
|
if (checked.code !== 0) {
|
|
308
310
|
return notify(session, 'error', validationFailedText({ file, detail: scriptDetail(checked) }));
|
|
309
311
|
}
|
|
310
312
|
|
|
313
|
+
taskList.advance(2);
|
|
311
314
|
await ensureMaterialDatabase(root);
|
|
312
315
|
const database = materialDatabaseName(readWorkspace(root));
|
|
313
316
|
let importedText;
|
|
@@ -327,9 +330,10 @@ async function runImport(ctx, invocation, session, rawPath) {
|
|
|
327
330
|
}));
|
|
328
331
|
}
|
|
329
332
|
|
|
330
|
-
async function runInit(ctx, invocation, session) {
|
|
333
|
+
async function runInit(ctx, invocation, session, taskList) {
|
|
331
334
|
const root = workspaceOf(session);
|
|
332
335
|
const result = await ensureMaterialDatabase(root);
|
|
336
|
+
taskList.advance(1);
|
|
333
337
|
const tools = deployMaterialTools(root);
|
|
334
338
|
if (!tools.ok) {
|
|
335
339
|
return notify(session, 'error', [
|
|
@@ -352,7 +356,7 @@ async function runInit(ctx, invocation, session) {
|
|
|
352
356
|
].join('\n'));
|
|
353
357
|
}
|
|
354
358
|
|
|
355
|
-
async function runRemove(ctx, invocation, session) {
|
|
359
|
+
async function runRemove(ctx, invocation, session, taskList) {
|
|
356
360
|
const root = workspaceOf(session);
|
|
357
361
|
const asked = await askUserQuestion(ctx, invocation, [{
|
|
358
362
|
id: 'confirm_material_remove',
|
|
@@ -368,6 +372,7 @@ async function runRemove(ctx, invocation, session) {
|
|
|
368
372
|
}
|
|
369
373
|
const selected = asked.answer?.answers?.[0]?.selected?.[0];
|
|
370
374
|
if (selected !== '删除素材库') return notify(session, 'success', '操作已取消。');
|
|
375
|
+
taskList.advance(1);
|
|
371
376
|
const result = await removeMaterialDatabase(root);
|
|
372
377
|
return notify(session, 'success', [
|
|
373
378
|
'✅ 已删除素材库:' + result.database,
|
|
@@ -375,14 +380,15 @@ async function runRemove(ctx, invocation, session) {
|
|
|
375
380
|
].join('\n'));
|
|
376
381
|
}
|
|
377
382
|
|
|
378
|
-
async function runExport(ctx, invocation, session) {
|
|
383
|
+
async function runExport(ctx, invocation, session, taskList) {
|
|
379
384
|
const root = workspaceOf(session);
|
|
385
|
+
taskList.advance(1);
|
|
380
386
|
await ensureMaterialDatabase(root);
|
|
381
387
|
const result = await exportMaterials(root);
|
|
382
388
|
return notify(session, 'success', exportResultText(result));
|
|
383
389
|
}
|
|
384
390
|
|
|
385
|
-
async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
391
|
+
async function runGenerate(ctx, invocation, session, focusRaw = '', taskList) {
|
|
386
392
|
const root = workspaceOf(session);
|
|
387
393
|
const focus = resolveFocus(focusRaw);
|
|
388
394
|
if (focusRaw && !focus.kinds.length) {
|
|
@@ -413,6 +419,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
|
413
419
|
}
|
|
414
420
|
|
|
415
421
|
const config = generationConfig();
|
|
422
|
+
taskList.advance(1);
|
|
416
423
|
await ensureMaterialDatabase(root);
|
|
417
424
|
const tools = deployMaterialTools(root);
|
|
418
425
|
if (!tools.ok) {
|
|
@@ -493,6 +500,9 @@ async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
|
493
500
|
},
|
|
494
501
|
});
|
|
495
502
|
|
|
503
|
+
taskList.advance(2);
|
|
504
|
+
taskList.watchTurns(invocation);
|
|
505
|
+
|
|
496
506
|
const completed = [];
|
|
497
507
|
const incomplete = [];
|
|
498
508
|
let importedTotal = 0;
|
|
@@ -505,6 +515,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
|
505
515
|
|
|
506
516
|
for (let index = 0; index < pending.length; index += 1) {
|
|
507
517
|
const item = pending[index];
|
|
518
|
+
taskList.progress(`分批生成并导入素材(${index + 1}/${pending.length}:${item.label})`);
|
|
508
519
|
item.status = 'running';
|
|
509
520
|
let stalled = 0;
|
|
510
521
|
let lastReason = '';
|
|
@@ -738,6 +749,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
|
738
749
|
: ((incomplete.length || notStarted.length || fatal || stopReason) ? 'incomplete' : 'complete');
|
|
739
750
|
report.stop_reason = stopReason;
|
|
740
751
|
saveProgress();
|
|
752
|
+
taskList.advance(3);
|
|
741
753
|
|
|
742
754
|
return notify(session, (aborted || incomplete.length || notStarted.length || stopReason) ? 'error' : 'success', generationRunText({
|
|
743
755
|
database,
|
|
@@ -757,12 +769,24 @@ async function runGenerate(ctx, invocation, session, focusRaw = '') {
|
|
|
757
769
|
}));
|
|
758
770
|
}
|
|
759
771
|
|
|
772
|
+
function materialTaskTitles(invocation) {
|
|
773
|
+
const tokens = String(invocation.rawInput || '').trim().split(/\s+/).filter(Boolean);
|
|
774
|
+
const command = (tokens[0] || '').toLowerCase();
|
|
775
|
+
if (command === 'help' || command === '?') return ['显示素材库帮助'];
|
|
776
|
+
if (command === 'prompt') return ['读取题材列表', '渲染素材提示词'];
|
|
777
|
+
if (command === 'import') return ['校验素材文件', '校验 JSONL 行', '写入素材库'];
|
|
778
|
+
if (command === 'export') return ['读取素材库', '导出 JSONL'];
|
|
779
|
+
if (command === 'init') return ['检查素材库', '初始化 schema 并部署查询脚本'];
|
|
780
|
+
if (command === 'remove') return ['确认删除范围', '删除素材库数据'];
|
|
781
|
+
return ['解析素材类型与工作区', '读取题材与已有素材索引', '分批生成并导入素材', '汇总生成结果'];
|
|
782
|
+
}
|
|
783
|
+
|
|
760
784
|
export async function apply(ctx) {
|
|
761
|
-
ctx
|
|
785
|
+
registerCommandWithTasks(ctx, {
|
|
762
786
|
name: 'fancy-material',
|
|
763
787
|
description: '🧩 素材库 ( usage: /fancy-material [素材类型] | import <文件> | init | remove | prompt | export | help )',
|
|
764
788
|
input: { hint: '[素材类型] | import <文件> | init | remove | prompt | export' },
|
|
765
|
-
handler: async (invocation) => {
|
|
789
|
+
handler: async (invocation, taskList) => {
|
|
766
790
|
const session = invocation.agent.session;
|
|
767
791
|
const raw = String(invocation.rawInput || '').trim();
|
|
768
792
|
const tokens = raw.split(/\s+/).filter(Boolean);
|
|
@@ -794,28 +818,28 @@ export async function apply(ctx) {
|
|
|
794
818
|
}
|
|
795
819
|
|
|
796
820
|
try {
|
|
797
|
-
if (!command) return await runGenerate(ctx, invocation, session, '');
|
|
821
|
+
if (!command) return await runGenerate(ctx, invocation, session, '', taskList);
|
|
798
822
|
if (command === 'import') {
|
|
799
823
|
if (tokens.length < 2) return notify(session, 'error', '用法:/fancy-material import <文件.jsonl>');
|
|
800
|
-
return await runImport(ctx, invocation, session, tokens.slice(1).join(' '));
|
|
824
|
+
return await runImport(ctx, invocation, session, tokens.slice(1).join(' '), taskList);
|
|
801
825
|
}
|
|
802
826
|
if (command === 'export') {
|
|
803
827
|
if (tokens.length > 1) return notify(session, 'error', '用法:/fancy-material export(不接受额外参数)');
|
|
804
|
-
return await runExport(ctx, invocation, session);
|
|
828
|
+
return await runExport(ctx, invocation, session, taskList);
|
|
805
829
|
}
|
|
806
830
|
if (command === 'init') {
|
|
807
831
|
if (tokens.length > 1) return notify(session, 'error', '用法:/fancy-material init(不接受额外参数)');
|
|
808
|
-
return await runInit(ctx, invocation, session);
|
|
832
|
+
return await runInit(ctx, invocation, session, taskList);
|
|
809
833
|
}
|
|
810
834
|
if (command === 'remove') {
|
|
811
835
|
if (tokens.length > 1) return notify(session, 'error', '用法:/fancy-material remove(不接受额外参数)');
|
|
812
|
-
return await runRemove(ctx, invocation, session);
|
|
836
|
+
return await runRemove(ctx, invocation, session, taskList);
|
|
813
837
|
}
|
|
814
838
|
// 其它参数视为素材类型重点,例如 /fancy-material 地名
|
|
815
|
-
return await runGenerate(ctx, invocation, session, raw);
|
|
839
|
+
return await runGenerate(ctx, invocation, session, raw, taskList);
|
|
816
840
|
} catch (err) {
|
|
817
841
|
return notify(session, 'error', '❌ ' + (err && err.message ? err.message : String(err)));
|
|
818
842
|
}
|
|
819
843
|
},
|
|
820
|
-
});
|
|
844
|
+
}, materialTaskTitles);
|
|
821
845
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { notify } from '#infra';
|
|
15
|
+
import { registerCommandWithTasks } from '#task-list';
|
|
15
16
|
import { resolveWorkspace } from '#workspace';
|
|
16
17
|
import {
|
|
17
18
|
findProjects,
|
|
@@ -48,12 +49,24 @@ function formatProject(project) {
|
|
|
48
49
|
].join('\n');
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
function projectTaskTitles(invocation) {
|
|
53
|
+
const tokens = String(invocation.rawInput || '').trim().split(/\s+/).filter(Boolean);
|
|
54
|
+
const command = (tokens[0] || 'list').toLowerCase();
|
|
55
|
+
if (command === 'help' || command === '?') return ['显示项目帮助'];
|
|
56
|
+
if (command === 'use') return ['解析子命令与参数', '切换当前项目', '输出结果'];
|
|
57
|
+
if (command === 'rename') return ['解析子命令与参数', '更新项目名称', '输出结果'];
|
|
58
|
+
if (['list', 'find', 'id', 'name', 'info'].includes(command)) {
|
|
59
|
+
return ['解析子命令与参数', '读取工作区项目数据', '输出查询结果'];
|
|
60
|
+
}
|
|
61
|
+
return ['解析子命令与参数', '输出错误提示'];
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
export async function apply(ctx) {
|
|
52
|
-
ctx
|
|
65
|
+
registerCommandWithTasks(ctx, {
|
|
53
66
|
name: 'fancy-project',
|
|
54
67
|
description: '📚 项目管理与小说名↔UUID 查询 ( usage: /fancy-project list|find|id|name|info|use|rename | help )',
|
|
55
68
|
input: { hint: '.' },
|
|
56
|
-
handler: async (invocation) => {
|
|
69
|
+
handler: async (invocation, tasks) => {
|
|
57
70
|
const session = invocation.agent.session;
|
|
58
71
|
const raw = String(invocation.rawInput || '').trim();
|
|
59
72
|
const tokens = raw.split(/\s+/).filter(Boolean);
|
|
@@ -68,6 +81,7 @@ export async function apply(ctx) {
|
|
|
68
81
|
return notify(session, 'error', '❌ ' + (err && err.message ? err.message : String(err)));
|
|
69
82
|
}
|
|
70
83
|
|
|
84
|
+
tasks.advance(1);
|
|
71
85
|
try {
|
|
72
86
|
if (command === 'list') {
|
|
73
87
|
const projects = await listProjects(root);
|
|
@@ -110,6 +124,7 @@ export async function apply(ctx) {
|
|
|
110
124
|
const key = tokens.slice(1).join(' ').trim();
|
|
111
125
|
if (!key) return notify(session, 'error', '用法:/fancy-project use <小说名|UUID>');
|
|
112
126
|
const project = await setProjectActive(root, key);
|
|
127
|
+
tasks.advance(2);
|
|
113
128
|
return notify(session, 'success', '✅ 当前项目:《' + project.name + '》\n' + project.project_id);
|
|
114
129
|
}
|
|
115
130
|
|
|
@@ -121,6 +136,7 @@ export async function apply(ctx) {
|
|
|
121
136
|
const selector = rest.shift();
|
|
122
137
|
const newTitle = rest.join(' ').trim();
|
|
123
138
|
const project = await renameProject(root, selector, newTitle);
|
|
139
|
+
tasks.advance(2);
|
|
124
140
|
return notify(session, 'success', '✅ 项目已重命名:《' + project.name + '》\n项目 UUID 保持不变:' + project.project_id);
|
|
125
141
|
}
|
|
126
142
|
|
|
@@ -129,5 +145,5 @@ export async function apply(ctx) {
|
|
|
129
145
|
return notify(session, 'error', '❌ ' + (err && err.message ? err.message : String(err)));
|
|
130
146
|
}
|
|
131
147
|
},
|
|
132
|
-
});
|
|
148
|
+
}, projectTaskTitles);
|
|
133
149
|
}
|