@yangda611/dsh-scriptor 8.4.4 → 8.4.7
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/README.md +8 -8
- package/lib/client.js +53 -53
- package/lib/index.js +171 -82
- package/lib/preset.js +0 -7
- package/package.json +1 -1
- package/skills/novel-director/SKILL.md +2 -0
- package/skills/novel-inspiration/SKILL.md +2 -1
package/lib/index.js
CHANGED
|
@@ -10635,6 +10635,10 @@ var require_saxes = __commonJS({
|
|
|
10635
10635
|
}
|
|
10636
10636
|
});
|
|
10637
10637
|
|
|
10638
|
+
// src/index.ts
|
|
10639
|
+
import * as skillFilesystem from "@deepseek-ai/dsh-skill-filesystem";
|
|
10640
|
+
import { fileURLToPath } from "node:url";
|
|
10641
|
+
|
|
10638
10642
|
// ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.9.0/node_modules/@deepseek-ai/cosmokit/lib/index.js
|
|
10639
10643
|
function isNullable(value) {
|
|
10640
10644
|
return value === null || value === void 0;
|
|
@@ -29106,6 +29110,7 @@ var MEMORY_CATALOG_SOURCE = "plugin:webnovel-memory-catalog";
|
|
|
29106
29110
|
var AUTHOR_SAVE_SOURCE = "plugin:webnovel";
|
|
29107
29111
|
var EDITOR_REQUEST_SOURCE = "plugin:webnovel-editor";
|
|
29108
29112
|
var DRAFT_LENGTH_SOURCE = "plugin:webnovel-draft-length";
|
|
29113
|
+
var ORPHAN_REPAIR_SOURCE = "plugin:webnovel-orphan";
|
|
29109
29114
|
function isMemoryCatalogSource(source2) {
|
|
29110
29115
|
if (source2.kind === MEMORY_CATALOG_SOURCE) return true;
|
|
29111
29116
|
return String(source2.kind) === "runtime-context" && "form" in source2 && source2.form === "snapshot" && "sections" in source2 && Array.isArray(source2.sections) && source2.sections.some((section) => section?.name === "webnovel.memory");
|
|
@@ -29336,68 +29341,100 @@ function writingAssignmentOf(agent) {
|
|
|
29336
29341
|
}
|
|
29337
29342
|
return void 0;
|
|
29338
29343
|
}
|
|
29344
|
+
var attachedDelegations = /* @__PURE__ */ new WeakMap();
|
|
29345
|
+
var liveDelegationDisposes = /* @__PURE__ */ new Set();
|
|
29346
|
+
async function disposeAllDelegations() {
|
|
29347
|
+
const disposals = [...liveDelegationDisposes];
|
|
29348
|
+
liveDelegationDisposes.clear();
|
|
29349
|
+
await Promise.all(disposals.map(async (dispose) => {
|
|
29350
|
+
try {
|
|
29351
|
+
await dispose();
|
|
29352
|
+
} catch {
|
|
29353
|
+
}
|
|
29354
|
+
}));
|
|
29355
|
+
}
|
|
29339
29356
|
function attachWritingDelegationToAgent(agent) {
|
|
29357
|
+
const existing = attachedDelegations.get(agent);
|
|
29358
|
+
if (existing !== void 0) return existing;
|
|
29340
29359
|
const context = agent.ctx;
|
|
29341
29360
|
if (typeof context?.inject !== "function") return void 0;
|
|
29342
|
-
|
|
29343
|
-
|
|
29344
|
-
|
|
29345
|
-
|
|
29346
|
-
|
|
29347
|
-
|
|
29348
|
-
|
|
29349
|
-
|
|
29350
|
-
|
|
29351
|
-
|
|
29352
|
-
|
|
29353
|
-
|
|
29354
|
-
|
|
29355
|
-
native
|
|
29356
|
-
|
|
29357
|
-
|
|
29358
|
-
|
|
29359
|
-
|
|
29360
|
-
|
|
29361
|
-
|
|
29362
|
-
parameters
|
|
29363
|
-
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
|
|
29367
|
-
|
|
29368
|
-
|
|
29361
|
+
let fiber;
|
|
29362
|
+
try {
|
|
29363
|
+
fiber = context.inject(["tools"], (scope2) => {
|
|
29364
|
+
const host2 = scope2;
|
|
29365
|
+
if (typeof host2.effect !== "function" || typeof host2.tools !== "object" || host2.tools === null) return;
|
|
29366
|
+
scope2.effect(function* () {
|
|
29367
|
+
let native;
|
|
29368
|
+
let off;
|
|
29369
|
+
let updating = false;
|
|
29370
|
+
const refresh = () => {
|
|
29371
|
+
if (updating) return;
|
|
29372
|
+
const current = scope2.tools.get("subagent", agent);
|
|
29373
|
+
const registered = scope2.tools.get(WRITING_DELEGATE_TOOL, agent);
|
|
29374
|
+
if (current === native && registered) return;
|
|
29375
|
+
updating = true;
|
|
29376
|
+
try {
|
|
29377
|
+
off?.();
|
|
29378
|
+
off = void 0;
|
|
29379
|
+
native = current;
|
|
29380
|
+
if (!current) return;
|
|
29381
|
+
const parameters = current.parameters;
|
|
29382
|
+
off = scope2.tools.register({
|
|
29383
|
+
...current,
|
|
29384
|
+
name: WRITING_DELEGATE_TOOL,
|
|
29385
|
+
description: "\u59D4\u6D3E\u5C0F\u8BF4\u751F\u4EA7\u4EFB\u52A1\uFF0C\u6309 role \u7ED1\u5B9A\u8BE5\u5B9E\u4F8B\u7684\u89C4\u7EA6\u548C\u6743\u9650\u3002drafting \u4E3A\u8D77\u8349\uFF0Cpolish \u4E3A\u6DA6\u8272\uFF0Crevision \u4E3A\u6539\u7A3F\u3002review \u4E3A\u5BA1\u8BFB\uFF0Csettle \u4E3A\u6C89\u6DC0\u5BF9\u8D26\u3002screenplay \u4E3A\u7535\u5F71\u5267\u672C\u6539\u7F16\uFF0Cshortdrama \u4E3A\u77ED\u5267\u7BA1\u7EBF\u3002\u660E\u786E\u76EE\u6807\u4E66\u548C\u7AE0\u8282\u65F6\u586B\u5199 bookId\u3001chapter\uFF0C\u4F9B\u8FDB\u5EA6\u5F52\u5C5E\uFF1B\u672A\u660E\u786E\u65F6\u4E0D\u8981\u731C\u586B\u3002\u666E\u901A\u7814\u7A76\u548C\u5DE5\u5177\u4EFB\u52A1\u4F7F\u7528 subagent\u3002\n" + current.description,
|
|
29386
|
+
parameters: {
|
|
29387
|
+
...current.parameters,
|
|
29388
|
+
properties: {
|
|
29389
|
+
...parameters.properties,
|
|
29390
|
+
role: { type: "string", enum: [...WRITING_ROLES] },
|
|
29391
|
+
bookId: { type: "string", description: "\u5DF2\u660E\u786E\u7684\u76EE\u6807\u4E66id\uFF1B\u4EC5\u7528\u4E8E\u4EFB\u52A1\u5F52\u5C5E" },
|
|
29392
|
+
chapter: { type: "integer", minimum: 1, description: "\u5DF2\u660E\u786E\u7684\u5168\u4E66\u7AE0\u53F7\uFF1B\u4EC5\u7528\u4E8E\u4EFB\u52A1\u5F52\u5C5E" }
|
|
29393
|
+
},
|
|
29394
|
+
required: [...parameters.required ?? [], "role"]
|
|
29369
29395
|
},
|
|
29370
|
-
|
|
29371
|
-
|
|
29372
|
-
|
|
29373
|
-
|
|
29374
|
-
|
|
29375
|
-
throw new Error("\
|
|
29376
|
-
|
|
29377
|
-
|
|
29378
|
-
const assignment = { ...typeof bookId2 === "string" ? { bookId: bookId2.trim() } : {}, ...typeof chapter2 === "number" ? { chapter: chapter2 } : {} };
|
|
29379
|
-
const attribution = Object.keys(assignment).length ? `<!-- scriptor-assignment:v1:${JSON.stringify(assignment)} -->
|
|
29396
|
+
execute(args, exec) {
|
|
29397
|
+
const { role: role2, bookId: bookId2, chapter: chapter2, ...task } = args;
|
|
29398
|
+
if (!isRole(role2) || typeof task["prompt"] !== "string" || exec.agent !== agent) {
|
|
29399
|
+
throw new Error("\u5199\u4F5C\u59D4\u6D3E\u987B\u6307\u5B9A\u6709\u6548 role\u3001\u4EFB\u52A1 prompt \u548C\u5F53\u524D\u4E3B\u63A7\u3002");
|
|
29400
|
+
}
|
|
29401
|
+
if (bookId2 !== void 0 && (typeof bookId2 !== "string" || !bookId2.trim() || bookId2.length > 256 || /[\r\n<>]/.test(bookId2)) || chapter2 !== void 0 && (typeof chapter2 !== "number" || !Number.isSafeInteger(chapter2) || chapter2 < 1)) throw new Error("\u59D4\u6D3E\u7684\u4E66id\u6216\u7AE0\u53F7\u65E0\u6548");
|
|
29402
|
+
const assignment = { ...typeof bookId2 === "string" ? { bookId: bookId2.trim() } : {}, ...typeof chapter2 === "number" ? { chapter: chapter2 } : {} };
|
|
29403
|
+
const attribution = Object.keys(assignment).length ? `<!-- scriptor-assignment:v1:${JSON.stringify(assignment)} -->
|
|
29380
29404
|
` : "";
|
|
29381
|
-
|
|
29382
|
-
|
|
29383
|
-
|
|
29384
|
-
|
|
29385
|
-
|
|
29386
|
-
|
|
29387
|
-
|
|
29388
|
-
|
|
29389
|
-
|
|
29390
|
-
|
|
29391
|
-
|
|
29392
|
-
|
|
29393
|
-
|
|
29394
|
-
|
|
29395
|
-
|
|
29405
|
+
return creationRole.run({ parent: agent, role: role2, ...assignment }, () => current.execute({
|
|
29406
|
+
...task,
|
|
29407
|
+
prompt: marker(role2) + attribution + task["prompt"]
|
|
29408
|
+
}, exec));
|
|
29409
|
+
}
|
|
29410
|
+
});
|
|
29411
|
+
} finally {
|
|
29412
|
+
updating = false;
|
|
29413
|
+
}
|
|
29414
|
+
};
|
|
29415
|
+
yield () => {
|
|
29416
|
+
off?.();
|
|
29417
|
+
};
|
|
29418
|
+
yield scope2.on("tools/change", refresh);
|
|
29419
|
+
refresh();
|
|
29420
|
+
});
|
|
29396
29421
|
});
|
|
29397
|
-
}
|
|
29398
|
-
|
|
29399
|
-
|
|
29422
|
+
} catch {
|
|
29423
|
+
return void 0;
|
|
29424
|
+
}
|
|
29425
|
+
if (fiber === void 0 || typeof fiber.dispose !== "function") return void 0;
|
|
29426
|
+
const disposeFiber = fiber.dispose.bind(fiber);
|
|
29427
|
+
let disposed = false;
|
|
29428
|
+
const dispose = async () => {
|
|
29429
|
+
if (disposed) return;
|
|
29430
|
+
disposed = true;
|
|
29431
|
+
attachedDelegations.delete(agent);
|
|
29432
|
+
liveDelegationDisposes.delete(dispose);
|
|
29433
|
+
await disposeFiber();
|
|
29400
29434
|
};
|
|
29435
|
+
attachedDelegations.set(agent, dispose);
|
|
29436
|
+
liveDelegationDisposes.add(dispose);
|
|
29437
|
+
return dispose;
|
|
29401
29438
|
}
|
|
29402
29439
|
|
|
29403
29440
|
// src/agent-mode.ts
|
|
@@ -29412,9 +29449,6 @@ function writingCapabilityOf(agent) {
|
|
|
29412
29449
|
return void 0;
|
|
29413
29450
|
}
|
|
29414
29451
|
}
|
|
29415
|
-
function isWritingAgent(agent) {
|
|
29416
|
-
return writingCapabilityOf(agent) !== void 0;
|
|
29417
|
-
}
|
|
29418
29452
|
|
|
29419
29453
|
// src/status-context.ts
|
|
29420
29454
|
import { createUserMessage as createUserMessage2 } from "@deepseek-ai/dsh-llm";
|
|
@@ -32866,7 +32900,7 @@ function createNovelTools(deps) {
|
|
|
32866
32900
|
},
|
|
32867
32901
|
{
|
|
32868
32902
|
name: "novel_create_book",
|
|
32869
|
-
description: "\u65B0\u5EFA\u4E00\u90E8\u957F\u7BC7\u5C0F\u8BF4\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\u3001\u6838\u5FC3\u521B\u610F\u4E0E\u9898\u6750\u76EE\u6807\u8BFB\u8005\u660E\u786E\uFF0C\u5176\u4F59\u53EF\u7559\u767D\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u95EE\u4F5C\u8005\u4E09\u4E2A\u95EE\u9898\u518D\u8C03\uFF0C\u7F3A\u4EFB\u4F55\u4E00\u4E2A\u90FD\u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF08\u5E02\u573A\uFF09\uFF0C\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF08\u8F93\u51FA\u5F62\u6001\uFF09\uFF0C\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF08\u76EE\u6807\u603B\u5B57\u6570\uFF0C\u6C49\u5B57\u6570\uFF09\u3002\u4E09\u4E2A\u503C\u7F3A\u4E00\u4E0D\u53EF\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u201C\u5C31\u6309\u9ED8\u8BA4\u6765\u201D\u624D\u4F20\u9ED8\u8BA4\uFF08\u4E2D\u6587 / \u5C0F\u8BF4 / 100\u4E07\u5B57\uFF09\uFF0C\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u6084\u6084\u5EFA\u4E66\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF0C\u9009\u597D\u540E\u4E0D\u7528\u5728\u804A\u5929\u91CC\u518D\u95EE\u3002",
|
|
32903
|
+
description: "\u65B0\u5EFA\u4E00\u90E8\u957F\u7BC7\u5C0F\u8BF4\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\u3001\u6838\u5FC3\u521B\u610F\u4E0E\u9898\u6750\u76EE\u6807\u8BFB\u8005\u660E\u786E\uFF0C\u5176\u4F59\u53EF\u7559\u767D\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u95EE\u4F5C\u8005\u4E09\u4E2A\u95EE\u9898\u518D\u8C03\uFF0C\u7F3A\u4EFB\u4F55\u4E00\u4E2A\u90FD\u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF08\u5E02\u573A\uFF09\uFF0C\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF08\u8F93\u51FA\u5F62\u6001\uFF09\uFF0C\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF08\u76EE\u6807\u603B\u5B57\u6570\uFF0C\u6C49\u5B57\u6570\uFF09\u3002\u4E09\u4E2A\u503C\u7F3A\u4E00\u4E0D\u53EF\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u201C\u5C31\u6309\u9ED8\u8BA4\u6765\u201D\u624D\u4F20\u9ED8\u8BA4\uFF08\u4E2D\u6587 / \u5C0F\u8BF4 / 100\u4E07\u5B57\uFF09\uFF0C\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u6084\u6084\u5EFA\u4E66\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF0C\u9009\u597D\u540E\u4E0D\u7528\u5728\u804A\u5929\u91CC\u518D\u95EE\u3002\u5EFA\u4E66\u53EA\u80FD\u8C03\u672C\u5DE5\u5177\uFF0C\u7981\u6B62\u7528\u6587\u4EF6\u5DE5\u5177\u624B\u5199\u4E66\u7C4D\u4FE1\u606F\u3001\u5927\u7EB2\u6216\u7AE0\u8282\u6587\u4EF6\u6765\u5192\u5145\u5EFA\u4E66\u3002\u5982\u679C\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u672C\u5DE5\u5177\uFF0C\u660E\u786E\u544A\u8BC9\u4F5C\u8005\u6CA1\u6709\u5EFA\u4E66\u5DE5\u5177\uFF0C\u4E0D\u8981\u624B\u5199\u4E66\u7A3F\u6587\u4EF6\u3002",
|
|
32870
32904
|
parameters: {
|
|
32871
32905
|
type: "object",
|
|
32872
32906
|
properties: {
|
|
@@ -35924,6 +35958,36 @@ function fieldLabel(text5) {
|
|
|
35924
35958
|
const version = typeof fields["\u7248\u672C"] === "number" || typeof fields["\u7248\u672C"] === "string" ? fields["\u7248\u672C"] : null;
|
|
35925
35959
|
return { badge, version };
|
|
35926
35960
|
}
|
|
35961
|
+
var ORPHAN_SIGNALS = ["\u4E66\u7C4D\u4FE1\u606F.json", "\u6545\u4E8B\u5927\u7EB2.md", "\u5927\u7EB2.md"];
|
|
35962
|
+
function orphanSignals(dir) {
|
|
35963
|
+
let entries;
|
|
35964
|
+
try {
|
|
35965
|
+
entries = fs62.readdirSync(dir);
|
|
35966
|
+
} catch {
|
|
35967
|
+
return void 0;
|
|
35968
|
+
}
|
|
35969
|
+
const found = entries.filter((name3) => ORPHAN_SIGNALS.includes(name3) || /^第.+章/.test(name3)).sort();
|
|
35970
|
+
return found.length > 0 ? found : void 0;
|
|
35971
|
+
}
|
|
35972
|
+
function scanOrphanDrafts(workspace, bookNames) {
|
|
35973
|
+
const orphans = [];
|
|
35974
|
+
const scanLevel = (parent, prefix, skip) => {
|
|
35975
|
+
let entries;
|
|
35976
|
+
try {
|
|
35977
|
+
entries = fs62.readdirSync(parent, { withFileTypes: true });
|
|
35978
|
+
} catch {
|
|
35979
|
+
return;
|
|
35980
|
+
}
|
|
35981
|
+
for (const entry of entries) {
|
|
35982
|
+
if (!entry.isDirectory() || skip.has(entry.name)) continue;
|
|
35983
|
+
const signals = orphanSignals(path73.join(parent, entry.name));
|
|
35984
|
+
if (signals !== void 0) orphans.push({ name: entry.name, path: prefix + entry.name, detail: `\u542B ${signals.join("\u3001")}` });
|
|
35985
|
+
}
|
|
35986
|
+
};
|
|
35987
|
+
scanLevel(workspace, "", /* @__PURE__ */ new Set([...bookNames, "\u4E66\u623F"]));
|
|
35988
|
+
scanLevel(path73.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
|
|
35989
|
+
return orphans;
|
|
35990
|
+
}
|
|
35927
35991
|
var StudyService = class {
|
|
35928
35992
|
workspace;
|
|
35929
35993
|
constructor(workspace) {
|
|
@@ -35960,7 +36024,8 @@ var StudyService = class {
|
|
|
35960
36024
|
} catch (error) {
|
|
35961
36025
|
if (error.code !== "ENOENT" && !(error instanceof AuthorDocumentError && error.code === "not-found")) sharedError = error instanceof Error ? error.message : "\u5171\u4EAB\u8D44\u6599\u4E0D\u53EF\u8BBF\u95EE";
|
|
35962
36026
|
}
|
|
35963
|
-
|
|
36027
|
+
const orphans = scanOrphanDrafts(this.workspace, new Set(scanned.map((book) => book.name)));
|
|
36028
|
+
return { workspace: this.workspace, books, shared, ...sharedError ? { sharedError } : {}, orphans };
|
|
35964
36029
|
}
|
|
35965
36030
|
/** 建书向导(8.4.4):读待建书草稿——书房面板点选的答案,novel_create_book 找不到参数时作后备。 */
|
|
35966
36031
|
readOnboarding() {
|
|
@@ -36766,7 +36831,7 @@ function agentList(registry2) {
|
|
|
36766
36831
|
return [];
|
|
36767
36832
|
}
|
|
36768
36833
|
var STUDY_API_PATH = "/api/webnovel/study/";
|
|
36769
|
-
var METHODS = ["shelf", "tree", "read", "resolve", "search", "chapters", "graph", "graph-view", "graph-preview", "graph-control", "book-inspection", "workflow", "save", "notify", "retry-commit", "index-status", "index-control", "ask", "ask-cancel", "suggestions", "onboarding"];
|
|
36834
|
+
var METHODS = ["shelf", "tree", "read", "resolve", "search", "chapters", "graph", "graph-view", "graph-preview", "graph-control", "book-inspection", "workflow", "save", "notify", "retry-commit", "index-status", "index-control", "ask", "ask-cancel", "suggestions", "onboarding", "orphan-repair"];
|
|
36770
36835
|
function graphReaderRequest(input) {
|
|
36771
36836
|
const result = {};
|
|
36772
36837
|
for (const key of ["person", "query", "cluster", "relation", "groupField", "evidenceId"]) if (input[key] !== void 0) {
|
|
@@ -37083,6 +37148,19 @@ function createStudyHandler(runtime, indexing, workflow = new WorkflowObserver()
|
|
|
37083
37148
|
else throw new AuthorDocumentError("invalid-document", "\u672A\u77E5\u7684\u5411\u5BFC\u64CD\u4F5C");
|
|
37084
37149
|
break;
|
|
37085
37150
|
}
|
|
37151
|
+
case "orphan-repair": {
|
|
37152
|
+
const relPath = stringOf(input, "path");
|
|
37153
|
+
const orphan = (service.shelf().orphans ?? []).find((item) => item.path === relPath);
|
|
37154
|
+
if (!orphan) throw new AuthorDocumentError("not-found", "\u6CA1\u6709\u627E\u5230\u8FD9\u4E2A\u672A\u6309\u89C4\u8303\u5EFA\u7ACB\u7684\u4E66\u7A3F\u76EE\u5F55\uFF0C\u8BF7\u5237\u65B0\u4E66\u623F\u540E\u91CD\u8BD5");
|
|
37155
|
+
const message = `\u4E66\u623F\u53D1\u73B0\u672A\u6309\u89C4\u8303\u5EFA\u7ACB\u7684\u4E66\u7A3F\u76EE\u5F55\u300A${orphan.name}\u300B\uFF08${orphan.path}\uFF0C${orphan.detail}\uFF09\uFF0C\u7F3A\u4F5C\u54C1\u5951\u7EA6\uFF08\u4F5C\u54C1\u5951\u7EA6/\u5951\u7EA6.md\uFF09\uFF0C\u6240\u4EE5\u6CA1\u51FA\u73B0\u5728\u300C\u6211\u7684\u4F5C\u54C1\u300D\u91CC\u3002\u8BF7\u7528 novel_create_book \u91CD\u65B0\u5EFA\u4E66\uFF08\u4E66\u540D\u3001\u5E02\u573A\u3001\u8F93\u51FA\u5F62\u6001\u3001\u76EE\u6807\u603B\u5B57\u6570\u5148\u95EE\u4F5C\u8005\uFF0C\u4E66\u623F\u5411\u5BFC\u5DF2\u4FDD\u5B58\u7684\u9009\u62E9\u76F4\u63A5\u7528\uFF09\uFF0C\u518D\u628A\u5DF2\u6709\u5185\u5BB9\uFF08\u5927\u7EB2\u3001\u7AE0\u8282\uFF09\u6309\u89C4\u8303\u8FC1\u8FDB\u65B0\u4E66\u4ED3\uFF1B\u8FC1\u5B8C\u544A\u8BC9\u4F5C\u8005\u4E66\u5DF2\u51FA\u73B0\u5728\u300C\u6211\u7684\u4F5C\u54C1\u300D\u91CC\u3002\u5982\u679C\u5DF2\u6709\u5185\u5BB9\u4E0D\u503C\u5F97\u8FC1\uFF0C\u4E5F\u8BF7\u660E\u786E\u544A\u8BC9\u4F5C\u8005\uFF0C\u4E0D\u8981\u624B\u5199\u6587\u4EF6\u5192\u5145\u5EFA\u4E66\u3002`;
|
|
37156
|
+
try {
|
|
37157
|
+
agent.followup(createUserMessage3({ content: [{ type: "text", text: message }], source: { kind: ORPHAN_REPAIR_SOURCE } }));
|
|
37158
|
+
} catch {
|
|
37159
|
+
throw new Error("\u4E3B\u63A7\u6CA1\u6709\u6536\u5230\u8BF7\u6C42");
|
|
37160
|
+
}
|
|
37161
|
+
value = { requested: true, path: orphan.path };
|
|
37162
|
+
break;
|
|
37163
|
+
}
|
|
37086
37164
|
default:
|
|
37087
37165
|
return reply(404, { ok: false, code: "not-found", error: "\u672A\u77E5\u4E66\u623F\u64CD\u4F5C" });
|
|
37088
37166
|
}
|
|
@@ -37131,7 +37209,7 @@ function attachStudyWeb(ctx, indexing, editorRequests = new EditorRequestHub())
|
|
|
37131
37209
|
observation[Symbol.dispose]();
|
|
37132
37210
|
}
|
|
37133
37211
|
};
|
|
37134
|
-
const handler = createStudyHandler(scope2, indexing, workflow, editorRequests, (
|
|
37212
|
+
const handler = createStudyHandler(scope2, indexing, workflow, editorRequests, () => true, readChild);
|
|
37135
37213
|
for (const method of METHODS) {
|
|
37136
37214
|
scope2.connection.fetch.register({ path: STUDY_API_PATH + method, methods: ["POST"], requestBody: "streaming", fetch: handler });
|
|
37137
37215
|
}
|
|
@@ -38854,6 +38932,16 @@ function apply(ctx, entry) {
|
|
|
38854
38932
|
}
|
|
38855
38933
|
};
|
|
38856
38934
|
if (typeof ctx.provide === "function") ctx.provide("webnovelHost", writingHost);
|
|
38935
|
+
step(ctx, "webnovel:bundled-skills", () => {
|
|
38936
|
+
const fiber = typeof ctx.plugin === "function" ? ctx.plugin(skillFilesystem, {
|
|
38937
|
+
providerName: "webnovel-bundled",
|
|
38938
|
+
includeDefaultRoots: true,
|
|
38939
|
+
bundledSkillDir: fileURLToPath(new URL("../skills/", import.meta.url))
|
|
38940
|
+
}) : void 0;
|
|
38941
|
+
return () => {
|
|
38942
|
+
void fiber?.dispose?.();
|
|
38943
|
+
};
|
|
38944
|
+
});
|
|
38857
38945
|
const installedAgents = /* @__PURE__ */ new Map();
|
|
38858
38946
|
const installedModes = /* @__PURE__ */ new Map();
|
|
38859
38947
|
const installedRoles = /* @__PURE__ */ new Map();
|
|
@@ -38898,7 +38986,7 @@ function apply(ctx, entry) {
|
|
|
38898
38986
|
const registry2 = typeof ctx.get === "function" ? ctx.get("workspaceRegistry") : void 0;
|
|
38899
38987
|
return [
|
|
38900
38988
|
...(typeof registry2?.list === "function" ? registry2.list() : []).flatMap((workspace) => workspace.path ? [workspace.path] : []),
|
|
38901
|
-
...[...installedAgents.values()].filter((agent) => isMainAgent(agent)
|
|
38989
|
+
...[...installedAgents.values()].filter((agent) => isMainAgent(agent)).flatMap((agent) => {
|
|
38902
38990
|
const root = agentWorkspaceRoot(agent);
|
|
38903
38991
|
return root ? [root] : [];
|
|
38904
38992
|
})
|
|
@@ -38909,7 +38997,7 @@ function apply(ctx, entry) {
|
|
|
38909
38997
|
const roots = agentRoots(registry2);
|
|
38910
38998
|
const candidates = roots.length > 0 ? roots : agentList(registry2);
|
|
38911
38999
|
const agent = candidates.find((candidate) => (candidate.id === notice.sessionId || candidate.session?.header?.id === notice.sessionId) && registry2?.get(candidate.id) === candidate);
|
|
38912
|
-
if (!agent || !isMainAgent(agent) || !
|
|
39000
|
+
if (!agent || !isMainAgent(agent) || !agent.session?.header || typeof agent.followup !== "function") return false;
|
|
38913
39001
|
if (bookRootOfBookIdFor(book.bookId, agent) !== book.root) return false;
|
|
38914
39002
|
return notifySaved(agent, indexFailureMessage(book, notice)).notification === "delivered";
|
|
38915
39003
|
}
|
|
@@ -38985,7 +39073,6 @@ function apply(ctx, entry) {
|
|
|
38985
39073
|
};
|
|
38986
39074
|
}
|
|
38987
39075
|
function registerToolsInto(agent) {
|
|
38988
|
-
if (!isWritingAgent(agent)) return false;
|
|
38989
39076
|
if (toolKit === void 0) return false;
|
|
38990
39077
|
if (agentToolOffs.has(agent.id)) return true;
|
|
38991
39078
|
const registry2 = agentCtxGet(agent, "tools");
|
|
@@ -39024,7 +39111,6 @@ function apply(ctx, entry) {
|
|
|
39024
39111
|
agentRestrictOffs.clear();
|
|
39025
39112
|
}
|
|
39026
39113
|
function restrictNovelToolsInto(agent) {
|
|
39027
|
-
if (!isWritingAgent(agent) && writingRoleOf(agent) === void 0) return false;
|
|
39028
39114
|
if (toolKit === void 0) return false;
|
|
39029
39115
|
if (agentRestrictOffs.has(agent.id)) return true;
|
|
39030
39116
|
const tools = agentCtxGet(agent, "tools");
|
|
@@ -39111,25 +39197,26 @@ function apply(ctx, entry) {
|
|
|
39111
39197
|
const attached = [];
|
|
39112
39198
|
attachments.set(agentId, attached);
|
|
39113
39199
|
const rootOf = () => agentWorkspaceRoot(agent);
|
|
39114
|
-
if (
|
|
39200
|
+
if (!isSubagent) {
|
|
39115
39201
|
const workspace = rootOf();
|
|
39116
39202
|
if (workspace) indexing.addWorkspace(workspace);
|
|
39117
|
-
try {
|
|
39118
|
-
const offPersona = attachPersonaToAgent(agentCtx, void 0, { logger: ctx.logger });
|
|
39119
|
-
if (offPersona !== void 0) attached.push(offPersona);
|
|
39120
|
-
} catch (err) {
|
|
39121
|
-
ctx.logger.warn(`[webnovel-bundle] persona \u6302\u8F7D\u5931\u8D25\uFF08${agentId}\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
39122
|
-
}
|
|
39123
|
-
try {
|
|
39124
|
-
const offStatus = attachStatusToAgent(agentCtx, { workspaceRoot: rootOf });
|
|
39125
|
-
if (offStatus !== void 0) attached.push(offStatus);
|
|
39126
|
-
} catch (err) {
|
|
39127
|
-
ctx.logger.warn(`[webnovel-bundle] \u72B6\u6001\u6CE8\u5165\u6302\u8F7D\u5931\u8D25\uFF08${agentId}\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
39128
|
-
}
|
|
39129
39203
|
registerToolsInto(agent);
|
|
39130
|
-
|
|
39131
|
-
if (
|
|
39132
|
-
|
|
39204
|
+
attachWritingDelegationToAgent(agent);
|
|
39205
|
+
if (capability !== void 0) {
|
|
39206
|
+
try {
|
|
39207
|
+
const offPersona = attachPersonaToAgent(agentCtx, void 0, { logger: ctx.logger });
|
|
39208
|
+
if (offPersona !== void 0) attached.push(offPersona);
|
|
39209
|
+
} catch (err) {
|
|
39210
|
+
ctx.logger.warn(`[webnovel-bundle] persona \u6302\u8F7D\u5931\u8D25\uFF08${agentId}\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
39211
|
+
}
|
|
39212
|
+
try {
|
|
39213
|
+
const offStatus = attachStatusToAgent(agentCtx, { workspaceRoot: rootOf });
|
|
39214
|
+
if (offStatus !== void 0) attached.push(offStatus);
|
|
39215
|
+
} catch (err) {
|
|
39216
|
+
ctx.logger.warn(`[webnovel-bundle] \u72B6\u6001\u6CE8\u5165\u6302\u8F7D\u5931\u8D25\uFF08${agentId}\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
39217
|
+
}
|
|
39218
|
+
}
|
|
39219
|
+
} else {
|
|
39133
39220
|
restrictNovelToolsInto(agent);
|
|
39134
39221
|
const offWorker = role2 === void 0 ? void 0 : attachWorkerPolicyToAgent(agent, role2);
|
|
39135
39222
|
if (offWorker !== void 0) attached.push(offWorker);
|
|
@@ -39221,6 +39308,7 @@ function apply(ctx, entry) {
|
|
|
39221
39308
|
await Promise.all([...installedAgents.values()].map((agent) => detachAgent(agent)));
|
|
39222
39309
|
await Promise.all(detachJobs);
|
|
39223
39310
|
disposeAllAgentTools();
|
|
39311
|
+
await disposeAllDelegations();
|
|
39224
39312
|
await agentsReg.fiber?.dispose?.();
|
|
39225
39313
|
await presetReg.fiber?.dispose?.();
|
|
39226
39314
|
};
|
|
@@ -39246,6 +39334,7 @@ function apply(ctx, entry) {
|
|
|
39246
39334
|
if (!toolsReg.reactive) registerAllInstalled(ctx);
|
|
39247
39335
|
return () => {
|
|
39248
39336
|
disposeAllAgentTools();
|
|
39337
|
+
void disposeAllDelegations();
|
|
39249
39338
|
void toolsReg.fiber?.dispose?.();
|
|
39250
39339
|
};
|
|
39251
39340
|
});
|
package/lib/preset.js
CHANGED
|
@@ -2,19 +2,12 @@ import { createRequire as __createRequire } from 'node:module'
|
|
|
2
2
|
const require = __createRequire(import.meta.url)
|
|
3
3
|
|
|
4
4
|
// src/preset.ts
|
|
5
|
-
import * as skillFilesystem from "@deepseek-ai/dsh-skill-filesystem";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
5
|
var name = "scriptor-writing-preset";
|
|
8
6
|
var inject = ["skills", "webnovelHost"];
|
|
9
7
|
function apply(ctx) {
|
|
10
8
|
const capability = { mode: "writing", disposed: false };
|
|
11
9
|
ctx.provide("webnovelWriting", capability);
|
|
12
10
|
const host = ctx.webnovelHost;
|
|
13
|
-
ctx.plugin(skillFilesystem, {
|
|
14
|
-
providerName: "webnovel-bundled",
|
|
15
|
-
includeDefaultRoots: true,
|
|
16
|
-
bundledSkillDir: fileURLToPath(new URL("../skills/", import.meta.url))
|
|
17
|
-
});
|
|
18
11
|
const changed = async () => {
|
|
19
12
|
try {
|
|
20
13
|
ctx.root.emit("webnovel/writing-capability-updated");
|
package/package.json
CHANGED
|
@@ -235,6 +235,8 @@ user-invocable: false
|
|
|
235
235
|
|
|
236
236
|
小说生产任务使用 `novel_delegate`,保留原生委派参数,必须按下表传 `role`。运行时只向该实例注入对应规约和工具权限;普通研究、工具诊断仍使用原生 `subagent`,不会因标题提到写作而受到这些限制。
|
|
237
237
|
|
|
238
|
+
工具自查节制:确认插件或工具状态时,不要反复调用 `plugin_manager` 的只读查询(list_plugins/list_bundles)——每次调用都要重新走 danger-full-access 审批,会卡在审批循环里。一次调用后用结果;版本信息优先读插件包内文件。
|
|
239
|
+
|
|
238
240
|
| 任务 | role | 子代理交付权限 |
|
|
239
241
|
| --- | --- | --- |
|
|
240
242
|
| 正文起草 | `drafting` | 原生读写与搜索;起草篇幅调整规则 |
|
|
@@ -31,12 +31,13 @@ user-invocable: false
|
|
|
31
31
|
3. **呈报确认**:七要素整理为构想草案,用通用写工具落 `<工作范围>/书房/构想/<书名或代称>.md`,再呈作者;获明确同意后调 `novel_create_book`,七个要素字段一个不缺地给全,`concept.状态` 必须为「已确认」。
|
|
32
32
|
|
|
33
33
|
**建书前先定市场、输出形态与目标总字数**(调 `novel_create_book` 之前,**三项放在同一条消息里一次问完**,各给选项,大白话,别用术语;**三项是硬关卡**:缺任何一项工具都会直接拒绝,不许用默认值悄悄建书——默认值只在作者明确说“就按默认来”时才用):
|
|
34
|
+
- **先查书房面板的答案再问**:问之前先用读工具看 `<工作范围>/书房/构想/_待建书.json`(书房面板“新建书”向导保存的答案)。三项都在文件里就直接用文件里的值,**不要在聊天里再问一遍**;缺哪项只问缺的那项;问的时候预选值用文件里已有的值,**不要用下面技能内置的默认值(长篇·100万字)当预选**。文件不存在或三项不全时,才按下面三项一次问完。建书成功后这个文件会被消费删除,下一本书重新选。
|
|
34
35
|
- 市场——“这个项目面向海外还是中文市场?”:1. 中文(★推荐,默认)——给国内观众,用中文题材库(赘婿、战神、霸总等);2. 海外——给海外观众,用海外题材库(狼人、亿万富翁、黑手党等);3. 自己有想法,手动输入。作者不选默认 `中文`。
|
|
35
36
|
- 输出形态——“要出短剧、电影剧本还是小说?”:1. 小说(★推荐,默认)——长篇小说,走原来的写章流程;2. 短剧——一集一集的短剧,走分集大纲 → 单集剧本 → 审读;3. 电影剧本——一部电影的剧本,走故事稿 → 分场大纲 → 剧本草稿 → 审读;4. 自己有想法,手动输入。作者不选默认 `小说`。
|
|
36
37
|
- 目标总字数——“这本书目标写多少字?”:1. 短篇·5万字;2. 中篇·30万字;3. 长篇·100万字(★推荐,默认);4. 超长篇·200万字;5. 自己有想法,手动输入具体数字。作者不选默认 `100万字`。这个数写进作品契约 frontmatter(`目标总字数`),用来规划篇幅;每章的字数另在定调时商定(`章节篇幅`),不是同一个数。
|
|
37
38
|
- **书房面板也能点**:作者可以在书房面板点“新建书”,三项点选卡片点三下就保存好;选好后聊天里不用再问,直接调 `novel_create_book` 即可(工具会读取面板保存的选择)。作者在面板选好后,不要在聊天里重复问。
|
|
38
39
|
- 三项一旦写入作品契约 frontmatter(`市场` / `输出形态` / `目标总字数`),建书后不再静默改写;作者之后想改,走契约修订流程。旧书没有这些字段时按默认值(中文 / 小说)处理,目标总字数缺失时不自动补写。
|
|
39
|
-
4. **跃迁**:建书由工具完成——书仓脚手架、构想快照冻结、书id 写入契约、`vol:` 首次提交(草稿区不入库),设计面跃迁为「作品定调」。**建书不自动切书**:拿 `novel_create_book` 返回的 `bookId` 调 `novel_select_book` 落定当前书,再向作者说明去向——**默认走快速开写**(《定调设计》路径 A:一次起草、作者过目确认);只有作者明确说要逐部细聊、深度定制时,才走深度定制(《定调设计》路径 B
|
|
40
|
+
4. **跃迁**:建书由工具完成——书仓脚手架、构想快照冻结、书id 写入契约、`vol:` 首次提交(草稿区不入库),设计面跃迁为「作品定调」。**建书不自动切书**:拿 `novel_create_book` 返回的 `bookId` 调 `novel_select_book` 落定当前书,再向作者说明去向——**默认走快速开写**(《定调设计》路径 A:一次起草、作者过目确认);只有作者明确说要逐部细聊、深度定制时,才走深度定制(《定调设计》路径 B:逐部细聊)。**建书只能调 `novel_create_book`,禁止用文件工具手写书籍信息、大纲或章节文件来冒充建书;没有建书工具时,明确告诉作者没有建书工具,不要手写书稿文件。**
|
|
40
41
|
|
|
41
42
|
## 工具
|
|
42
43
|
|