@yangda611/dsh-scriptor 8.4.10 → 8.4.11

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.
Files changed (40) hide show
  1. package/README.md +9 -9
  2. package/lib/cli.js +299 -14
  3. package/lib/client.js +53 -53
  4. package/lib/graph.js +1 -1
  5. package/lib/index.js +1293 -491
  6. package/lib/reranking.js +2 -2
  7. package/lib/retrieval.js +2 -2
  8. package/lib/scenes.js +1 -1
  9. package/package.json +1 -1
  10. package/presets/writing.patch.yml +3 -3
  11. package/skills/novel-design/SKILL.md +8 -9
  12. package/skills/novel-director/SKILL.md +20 -6
  13. package/skills/novel-drafting/SKILL.md +5 -14
  14. package/skills/novel-inspiration/SKILL.md +4 -2
  15. package/skills/novel-outline/SKILL.md +4 -4
  16. package/skills/novel-polish/SKILL.md +1 -1
  17. package/skills/novel-polish//345/267/245/345/272/217/1-/350/241/250/350/276/276/346/270/205/347/220/206.md +1 -1
  18. package/skills/novel-polish//345/267/245/345/272/217/2-/350/212/202/345/245/217/344/270/216/351/207/215/345/241/221.md +5 -5
  19. package/skills/novel-review/SKILL.md +1 -1
  20. package/skills/novel-review//345/272/225/346/234/254//345/205/250/351/207/217/345/256/241/350/257/273.md +2 -2
  21. package/skills/novel-review//345/272/225/346/234/254//347/253/240/350/212/202/347/273/223/346/236/204/345/256/241/350/257/273.md +2 -2
  22. package/skills/novel-review//345/272/225/346/234/254//350/212/202/345/245/217/344/270/216/345/274/240/345/212/233/345/256/241/350/257/273.md +2 -2
  23. package/skills/novel-revision//345/272/225/346/234/254//346/224/271/347/250/277/347/253/240/347/250/213.md +1 -1
  24. package/skills/novel-screenplay/SKILL.md +22 -5
  25. package/skills/novel-screenplay//345/267/245/345/272/217/1-/346/225/205/344/272/213/347/250/277/344/270/216/344/272/272/347/211/251/345/260/217/344/274/240.md +20 -0
  26. package/skills/novel-screenplay//345/267/245/345/272/217/2-/345/210/206/345/234/272/345/244/247/347/272/262/344/270/216/344/270/211/345/271/225/350/212/202/346/213/215.md +23 -0
  27. package/skills/novel-screenplay//345/267/245/345/272/217/3-/350/247/206/350/247/211/345/212/250/344/275/234/344/270/216/346/275/234/345/217/260/350/257/215/345/257/271/347/231/275.md +21 -0
  28. package/skills/novel-screenplay//345/267/245/345/272/217/4-/345/211/247/346/234/254/347/262/276/344/277/256/344/270/216/346/224/271/347/250/277.md +16 -0
  29. package/skills/novel-screenplay//345/272/225/346/234/254//345/205/250/351/207/217/345/256/241/350/257/273.md +18 -20
  30. package/skills/novel-settle/SKILL.md +10 -6
  31. package/skills/novel-shortdrama/SKILL.md +29 -15
  32. package/skills/novel-shortdrama//345/217/202/350/200/203//344/277/235/346/212/244/346/200/247/345/217/215/344/276/213/351/233/206.md +19 -0
  33. package/skills/novel-shortdrama//345/217/202/350/200/203//345/217/260/350/257/215/344/270/203/347/273/264/350/257/212/346/226/255.md +19 -0
  34. package/skills/novel-shortdrama//345/217/202/350/200/203//345/274/200/347/257/207/351/222/251/345/255/220/344/270/216/346/226/255/347/253/240/345/205/254/345/274/217.md +44 -0
  35. package/skills/novel-shortdrama//345/217/202/350/200/203//346/203/205/347/273/252/346/265/201/345/215/225/345/205/203/351/223/276/344/270/216/345/276/200/350/277/224/346/263/225.md +31 -0
  36. package/skills/novel-shortdrama//345/217/202/350/200/203//346/210/217/345/211/247/345/267/245/350/211/272/345/261/202.md +40 -0
  37. package/skills/novel-shortdrama//345/217/202/350/200/203//351/242/230/346/235/220/344/270/216/347/210/275/347/202/271/351/200/237/346/237/245.md +23 -0
  38. package/skills/novel-shortdrama//345/267/245/345/272/217//345/210/206/351/233/206/345/244/247/347/272/262.md +26 -23
  39. package/skills/novel-shortdrama//345/267/245/345/272/217//345/215/225/351/233/206/345/211/247/346/234/254.md +29 -22
  40. package/skills/novel-shortdrama//345/272/225/346/234/254//347/237/255/345/211/247/345/256/241/350/257/273.md +34 -41
package/lib/index.js CHANGED
@@ -113,17 +113,17 @@ var require_visit = __commonJS({
113
113
  visit.BREAK = BREAK;
114
114
  visit.SKIP = SKIP;
115
115
  visit.REMOVE = REMOVE;
116
- function visit_(key, node, visitor, path81) {
117
- const ctrl = callVisitor(key, node, visitor, path81);
116
+ function visit_(key, node, visitor, path82) {
117
+ const ctrl = callVisitor(key, node, visitor, path82);
118
118
  if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
119
- replaceNode(key, path81, ctrl);
120
- return visit_(key, ctrl, visitor, path81);
119
+ replaceNode(key, path82, ctrl);
120
+ return visit_(key, ctrl, visitor, path82);
121
121
  }
122
122
  if (typeof ctrl !== "symbol") {
123
123
  if (identity4.isCollection(node)) {
124
- path81 = Object.freeze(path81.concat(node));
124
+ path82 = Object.freeze(path82.concat(node));
125
125
  for (let i = 0; i < node.items.length; ++i) {
126
- const ci = visit_(i, node.items[i], visitor, path81);
126
+ const ci = visit_(i, node.items[i], visitor, path82);
127
127
  if (typeof ci === "number")
128
128
  i = ci - 1;
129
129
  else if (ci === BREAK)
@@ -134,13 +134,13 @@ var require_visit = __commonJS({
134
134
  }
135
135
  }
136
136
  } else if (identity4.isPair(node)) {
137
- path81 = Object.freeze(path81.concat(node));
138
- const ck = visit_("key", node.key, visitor, path81);
137
+ path82 = Object.freeze(path82.concat(node));
138
+ const ck = visit_("key", node.key, visitor, path82);
139
139
  if (ck === BREAK)
140
140
  return BREAK;
141
141
  else if (ck === REMOVE)
142
142
  node.key = null;
143
- const cv = visit_("value", node.value, visitor, path81);
143
+ const cv = visit_("value", node.value, visitor, path82);
144
144
  if (cv === BREAK)
145
145
  return BREAK;
146
146
  else if (cv === REMOVE)
@@ -161,17 +161,17 @@ var require_visit = __commonJS({
161
161
  visitAsync.BREAK = BREAK;
162
162
  visitAsync.SKIP = SKIP;
163
163
  visitAsync.REMOVE = REMOVE;
164
- async function visitAsync_(key, node, visitor, path81) {
165
- const ctrl = await callVisitor(key, node, visitor, path81);
164
+ async function visitAsync_(key, node, visitor, path82) {
165
+ const ctrl = await callVisitor(key, node, visitor, path82);
166
166
  if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
167
- replaceNode(key, path81, ctrl);
168
- return visitAsync_(key, ctrl, visitor, path81);
167
+ replaceNode(key, path82, ctrl);
168
+ return visitAsync_(key, ctrl, visitor, path82);
169
169
  }
170
170
  if (typeof ctrl !== "symbol") {
171
171
  if (identity4.isCollection(node)) {
172
- path81 = Object.freeze(path81.concat(node));
172
+ path82 = Object.freeze(path82.concat(node));
173
173
  for (let i = 0; i < node.items.length; ++i) {
174
- const ci = await visitAsync_(i, node.items[i], visitor, path81);
174
+ const ci = await visitAsync_(i, node.items[i], visitor, path82);
175
175
  if (typeof ci === "number")
176
176
  i = ci - 1;
177
177
  else if (ci === BREAK)
@@ -182,13 +182,13 @@ var require_visit = __commonJS({
182
182
  }
183
183
  }
184
184
  } else if (identity4.isPair(node)) {
185
- path81 = Object.freeze(path81.concat(node));
186
- const ck = await visitAsync_("key", node.key, visitor, path81);
185
+ path82 = Object.freeze(path82.concat(node));
186
+ const ck = await visitAsync_("key", node.key, visitor, path82);
187
187
  if (ck === BREAK)
188
188
  return BREAK;
189
189
  else if (ck === REMOVE)
190
190
  node.key = null;
191
- const cv = await visitAsync_("value", node.value, visitor, path81);
191
+ const cv = await visitAsync_("value", node.value, visitor, path82);
192
192
  if (cv === BREAK)
193
193
  return BREAK;
194
194
  else if (cv === REMOVE)
@@ -215,23 +215,23 @@ var require_visit = __commonJS({
215
215
  }
216
216
  return visitor;
217
217
  }
218
- function callVisitor(key, node, visitor, path81) {
218
+ function callVisitor(key, node, visitor, path82) {
219
219
  if (typeof visitor === "function")
220
- return visitor(key, node, path81);
220
+ return visitor(key, node, path82);
221
221
  if (identity4.isMap(node))
222
- return visitor.Map?.(key, node, path81);
222
+ return visitor.Map?.(key, node, path82);
223
223
  if (identity4.isSeq(node))
224
- return visitor.Seq?.(key, node, path81);
224
+ return visitor.Seq?.(key, node, path82);
225
225
  if (identity4.isPair(node))
226
- return visitor.Pair?.(key, node, path81);
226
+ return visitor.Pair?.(key, node, path82);
227
227
  if (identity4.isScalar(node))
228
- return visitor.Scalar?.(key, node, path81);
228
+ return visitor.Scalar?.(key, node, path82);
229
229
  if (identity4.isAlias(node))
230
- return visitor.Alias?.(key, node, path81);
230
+ return visitor.Alias?.(key, node, path82);
231
231
  return void 0;
232
232
  }
233
- function replaceNode(key, path81, node) {
234
- const parent = path81[path81.length - 1];
233
+ function replaceNode(key, path82, node) {
234
+ const parent = path82[path82.length - 1];
235
235
  if (identity4.isCollection(parent)) {
236
236
  parent.items[key] = node;
237
237
  } else if (identity4.isPair(parent)) {
@@ -841,10 +841,10 @@ var require_Collection = __commonJS({
841
841
  var createNode = require_createNode();
842
842
  var identity4 = require_identity();
843
843
  var Node = require_Node();
844
- function collectionFromPath(schema, path81, value) {
844
+ function collectionFromPath(schema, path82, value) {
845
845
  let v = value;
846
- for (let i = path81.length - 1; i >= 0; --i) {
847
- const k = path81[i];
846
+ for (let i = path82.length - 1; i >= 0; --i) {
847
+ const k = path82[i];
848
848
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
849
849
  const a = [];
850
850
  a[k] = v;
@@ -863,7 +863,7 @@ var require_Collection = __commonJS({
863
863
  sourceObjects: /* @__PURE__ */ new Map()
864
864
  });
865
865
  }
866
- var isEmptyPath = (path81) => path81 == null || typeof path81 === "object" && !!path81[Symbol.iterator]().next().done;
866
+ var isEmptyPath = (path82) => path82 == null || typeof path82 === "object" && !!path82[Symbol.iterator]().next().done;
867
867
  var Collection = class extends Node.NodeBase {
868
868
  constructor(type, schema) {
869
869
  super(type);
@@ -893,11 +893,11 @@ var require_Collection = __commonJS({
893
893
  * be a Pair instance or a `{ key, value }` object, which may not have a key
894
894
  * that already exists in the map.
895
895
  */
896
- addIn(path81, value) {
897
- if (isEmptyPath(path81))
896
+ addIn(path82, value) {
897
+ if (isEmptyPath(path82))
898
898
  this.add(value);
899
899
  else {
900
- const [key, ...rest] = path81;
900
+ const [key, ...rest] = path82;
901
901
  const node = this.get(key, true);
902
902
  if (identity4.isCollection(node))
903
903
  node.addIn(rest, value);
@@ -911,8 +911,8 @@ var require_Collection = __commonJS({
911
911
  * Removes a value from the collection.
912
912
  * @returns `true` if the item was found and removed.
913
913
  */
914
- deleteIn(path81) {
915
- const [key, ...rest] = path81;
914
+ deleteIn(path82) {
915
+ const [key, ...rest] = path82;
916
916
  if (rest.length === 0)
917
917
  return this.delete(key);
918
918
  const node = this.get(key, true);
@@ -926,8 +926,8 @@ var require_Collection = __commonJS({
926
926
  * scalar values from their surrounding node; to disable set `keepScalar` to
927
927
  * `true` (collections are always returned intact).
928
928
  */
929
- getIn(path81, keepScalar) {
930
- const [key, ...rest] = path81;
929
+ getIn(path82, keepScalar) {
930
+ const [key, ...rest] = path82;
931
931
  const node = this.get(key, true);
932
932
  if (rest.length === 0)
933
933
  return !keepScalar && identity4.isScalar(node) ? node.value : node;
@@ -945,8 +945,8 @@ var require_Collection = __commonJS({
945
945
  /**
946
946
  * Checks if the collection includes a value with the key `key`.
947
947
  */
948
- hasIn(path81) {
949
- const [key, ...rest] = path81;
948
+ hasIn(path82) {
949
+ const [key, ...rest] = path82;
950
950
  if (rest.length === 0)
951
951
  return this.has(key);
952
952
  const node = this.get(key, true);
@@ -956,8 +956,8 @@ var require_Collection = __commonJS({
956
956
  * Sets a value in this collection. For `!!set`, `value` needs to be a
957
957
  * boolean to add/remove the item from the set.
958
958
  */
959
- setIn(path81, value) {
960
- const [key, ...rest] = path81;
959
+ setIn(path82, value) {
960
+ const [key, ...rest] = path82;
961
961
  if (rest.length === 0) {
962
962
  this.set(key, value);
963
963
  } else {
@@ -3472,9 +3472,9 @@ var require_Document = __commonJS({
3472
3472
  this.contents.add(value);
3473
3473
  }
3474
3474
  /** Adds a value to the document. */
3475
- addIn(path81, value) {
3475
+ addIn(path82, value) {
3476
3476
  if (assertCollection(this.contents))
3477
- this.contents.addIn(path81, value);
3477
+ this.contents.addIn(path82, value);
3478
3478
  }
3479
3479
  /**
3480
3480
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3549,14 +3549,14 @@ var require_Document = __commonJS({
3549
3549
  * Removes a value from the document.
3550
3550
  * @returns `true` if the item was found and removed.
3551
3551
  */
3552
- deleteIn(path81) {
3553
- if (Collection.isEmptyPath(path81)) {
3552
+ deleteIn(path82) {
3553
+ if (Collection.isEmptyPath(path82)) {
3554
3554
  if (this.contents == null)
3555
3555
  return false;
3556
3556
  this.contents = null;
3557
3557
  return true;
3558
3558
  }
3559
- return assertCollection(this.contents) ? this.contents.deleteIn(path81) : false;
3559
+ return assertCollection(this.contents) ? this.contents.deleteIn(path82) : false;
3560
3560
  }
3561
3561
  /**
3562
3562
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3571,10 +3571,10 @@ var require_Document = __commonJS({
3571
3571
  * scalar values from their surrounding node; to disable set `keepScalar` to
3572
3572
  * `true` (collections are always returned intact).
3573
3573
  */
3574
- getIn(path81, keepScalar) {
3575
- if (Collection.isEmptyPath(path81))
3574
+ getIn(path82, keepScalar) {
3575
+ if (Collection.isEmptyPath(path82))
3576
3576
  return !keepScalar && identity4.isScalar(this.contents) ? this.contents.value : this.contents;
3577
- return identity4.isCollection(this.contents) ? this.contents.getIn(path81, keepScalar) : void 0;
3577
+ return identity4.isCollection(this.contents) ? this.contents.getIn(path82, keepScalar) : void 0;
3578
3578
  }
3579
3579
  /**
3580
3580
  * Checks if the document includes a value with the key `key`.
@@ -3585,10 +3585,10 @@ var require_Document = __commonJS({
3585
3585
  /**
3586
3586
  * Checks if the document includes a value at `path`.
3587
3587
  */
3588
- hasIn(path81) {
3589
- if (Collection.isEmptyPath(path81))
3588
+ hasIn(path82) {
3589
+ if (Collection.isEmptyPath(path82))
3590
3590
  return this.contents !== void 0;
3591
- return identity4.isCollection(this.contents) ? this.contents.hasIn(path81) : false;
3591
+ return identity4.isCollection(this.contents) ? this.contents.hasIn(path82) : false;
3592
3592
  }
3593
3593
  /**
3594
3594
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3605,13 +3605,13 @@ var require_Document = __commonJS({
3605
3605
  * Sets a value in this document. For `!!set`, `value` needs to be a
3606
3606
  * boolean to add/remove the item from the set.
3607
3607
  */
3608
- setIn(path81, value) {
3609
- if (Collection.isEmptyPath(path81)) {
3608
+ setIn(path82, value) {
3609
+ if (Collection.isEmptyPath(path82)) {
3610
3610
  this.contents = value;
3611
3611
  } else if (this.contents == null) {
3612
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path81), value);
3612
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path82), value);
3613
3613
  } else if (assertCollection(this.contents)) {
3614
- this.contents.setIn(path81, value);
3614
+ this.contents.setIn(path82, value);
3615
3615
  }
3616
3616
  }
3617
3617
  /**
@@ -5571,9 +5571,9 @@ var require_cst_visit = __commonJS({
5571
5571
  visit.BREAK = BREAK;
5572
5572
  visit.SKIP = SKIP;
5573
5573
  visit.REMOVE = REMOVE;
5574
- visit.itemAtPath = (cst, path81) => {
5574
+ visit.itemAtPath = (cst, path82) => {
5575
5575
  let item = cst;
5576
- for (const [field, index] of path81) {
5576
+ for (const [field, index] of path82) {
5577
5577
  const tok = item?.[field];
5578
5578
  if (tok && "items" in tok) {
5579
5579
  item = tok.items[index];
@@ -5582,23 +5582,23 @@ var require_cst_visit = __commonJS({
5582
5582
  }
5583
5583
  return item;
5584
5584
  };
5585
- visit.parentCollection = (cst, path81) => {
5586
- const parent = visit.itemAtPath(cst, path81.slice(0, -1));
5587
- const field = path81[path81.length - 1][0];
5585
+ visit.parentCollection = (cst, path82) => {
5586
+ const parent = visit.itemAtPath(cst, path82.slice(0, -1));
5587
+ const field = path82[path82.length - 1][0];
5588
5588
  const coll = parent?.[field];
5589
5589
  if (coll && "items" in coll)
5590
5590
  return coll;
5591
5591
  throw new Error("Parent collection not found");
5592
5592
  };
5593
- function _visit(path81, item, visitor) {
5594
- let ctrl = visitor(item, path81);
5593
+ function _visit(path82, item, visitor) {
5594
+ let ctrl = visitor(item, path82);
5595
5595
  if (typeof ctrl === "symbol")
5596
5596
  return ctrl;
5597
5597
  for (const field of ["key", "value"]) {
5598
5598
  const token = item[field];
5599
5599
  if (token && "items" in token) {
5600
5600
  for (let i = 0; i < token.items.length; ++i) {
5601
- const ci = _visit(Object.freeze(path81.concat([[field, i]])), token.items[i], visitor);
5601
+ const ci = _visit(Object.freeze(path82.concat([[field, i]])), token.items[i], visitor);
5602
5602
  if (typeof ci === "number")
5603
5603
  i = ci - 1;
5604
5604
  else if (ci === BREAK)
@@ -5609,10 +5609,10 @@ var require_cst_visit = __commonJS({
5609
5609
  }
5610
5610
  }
5611
5611
  if (typeof ctrl === "function" && field === "key")
5612
- ctrl = ctrl(item, path81);
5612
+ ctrl = ctrl(item, path82);
5613
5613
  }
5614
5614
  }
5615
- return typeof ctrl === "function" ? ctrl(item, path81) : ctrl;
5615
+ return typeof ctrl === "function" ? ctrl(item, path82) : ctrl;
5616
5616
  }
5617
5617
  exports.visit = visit;
5618
5618
  }
@@ -6914,14 +6914,14 @@ var require_parser = __commonJS({
6914
6914
  case "scalar":
6915
6915
  case "single-quoted-scalar":
6916
6916
  case "double-quoted-scalar": {
6917
- const fs68 = this.flowScalar(this.type);
6917
+ const fs69 = this.flowScalar(this.type);
6918
6918
  if (atNextItem || it.value) {
6919
- map.items.push({ start, key: fs68, sep: [] });
6919
+ map.items.push({ start, key: fs69, sep: [] });
6920
6920
  this.onKeyLine = true;
6921
6921
  } else if (it.sep) {
6922
- this.stack.push(fs68);
6922
+ this.stack.push(fs69);
6923
6923
  } else {
6924
- Object.assign(it, { key: fs68, sep: [] });
6924
+ Object.assign(it, { key: fs69, sep: [] });
6925
6925
  this.onKeyLine = true;
6926
6926
  }
6927
6927
  return;
@@ -7049,13 +7049,13 @@ var require_parser = __commonJS({
7049
7049
  case "scalar":
7050
7050
  case "single-quoted-scalar":
7051
7051
  case "double-quoted-scalar": {
7052
- const fs68 = this.flowScalar(this.type);
7052
+ const fs69 = this.flowScalar(this.type);
7053
7053
  if (!it || it.value)
7054
- fc.items.push({ start: [], key: fs68, sep: [] });
7054
+ fc.items.push({ start: [], key: fs69, sep: [] });
7055
7055
  else if (it.sep)
7056
- this.stack.push(fs68);
7056
+ this.stack.push(fs69);
7057
7057
  else
7058
- Object.assign(it, { key: fs68, sep: [] });
7058
+ Object.assign(it, { key: fs69, sep: [] });
7059
7059
  return;
7060
7060
  }
7061
7061
  case "flow-map-end":
@@ -7421,7 +7421,7 @@ var require_pend = __commonJS({
7421
7421
  // ../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js
7422
7422
  var require_fd_slicer = __commonJS({
7423
7423
  "../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js"(exports) {
7424
- var fs68 = __require("fs");
7424
+ var fs69 = __require("fs");
7425
7425
  var util = __require("util");
7426
7426
  var stream = __require("stream");
7427
7427
  var Readable = stream.Readable;
@@ -7441,7 +7441,7 @@ var require_fd_slicer = __commonJS({
7441
7441
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
7442
7442
  var self = this;
7443
7443
  self.pend.go(function(cb) {
7444
- fs68.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
7444
+ fs69.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
7445
7445
  cb();
7446
7446
  callback(err, bytesRead, buffer2);
7447
7447
  });
@@ -7458,7 +7458,7 @@ var require_fd_slicer = __commonJS({
7458
7458
  self.refCount -= 1;
7459
7459
  if (self.refCount < 0) throw new Error("invalid unref");
7460
7460
  if (self.refCount > 0) return;
7461
- fs68.close(self.fd, onCloseDone);
7461
+ fs69.close(self.fd, onCloseDone);
7462
7462
  function onCloseDone(err) {
7463
7463
  if (err) {
7464
7464
  self.emit("error", err);
@@ -7490,7 +7490,7 @@ var require_fd_slicer = __commonJS({
7490
7490
  }
7491
7491
  self.context.pend.go(function(cb) {
7492
7492
  var buffer = Buffer.allocUnsafe(toRead);
7493
- fs68.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
7493
+ fs69.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
7494
7494
  if (err) {
7495
7495
  self.destroy(err);
7496
7496
  } else if (bytesRead === 0) {
@@ -7850,7 +7850,7 @@ var require_crc32 = __commonJS({
7850
7850
  // ../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js
7851
7851
  var require_yauzl = __commonJS({
7852
7852
  "../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js"(exports) {
7853
- var fs68 = __require("fs");
7853
+ var fs69 = __require("fs");
7854
7854
  var zlib = __require("zlib");
7855
7855
  var fd_slicer = require_fd_slicer();
7856
7856
  var util = __require("util");
@@ -7875,9 +7875,9 @@ var require_yauzl = __commonJS({
7875
7875
  exports.Entry = Entry;
7876
7876
  exports.LocalFileHeader = LocalFileHeader;
7877
7877
  exports.RandomAccessReader = RandomAccessReader;
7878
- function openPromise(path81, options2) {
7878
+ function openPromise(path82, options2) {
7879
7879
  return new Promise((resolve22, reject) => {
7880
- open(path81, { ...options2, lazyEntries: true }, function(err, zipfile) {
7880
+ open(path82, { ...options2, lazyEntries: true }, function(err, zipfile) {
7881
7881
  if (err) return reject(err);
7882
7882
  resolve22(zipfile);
7883
7883
  });
@@ -7907,7 +7907,7 @@ var require_yauzl = __commonJS({
7907
7907
  });
7908
7908
  });
7909
7909
  }
7910
- function open(path81, options2, callback) {
7910
+ function open(path82, options2, callback) {
7911
7911
  if (typeof options2 === "function") {
7912
7912
  callback = options2;
7913
7913
  options2 = null;
@@ -7919,10 +7919,10 @@ var require_yauzl = __commonJS({
7919
7919
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
7920
7920
  if (options2.strictFileNames == null) options2.strictFileNames = false;
7921
7921
  if (callback == null) callback = defaultCallback;
7922
- fs68.open(path81, "r", function(err, fd) {
7922
+ fs69.open(path82, "r", function(err, fd) {
7923
7923
  if (err) return callback(err);
7924
7924
  fromFd(fd, options2, function(err2, zipfile) {
7925
- if (err2) fs68.close(fd, defaultCallback);
7925
+ if (err2) fs69.close(fd, defaultCallback);
7926
7926
  callback(err2, zipfile);
7927
7927
  });
7928
7928
  });
@@ -7939,7 +7939,7 @@ var require_yauzl = __commonJS({
7939
7939
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
7940
7940
  if (options2.strictFileNames == null) options2.strictFileNames = false;
7941
7941
  if (callback == null) callback = defaultCallback;
7942
- fs68.fstat(fd, function(err, stats) {
7942
+ fs69.fstat(fd, function(err, stats) {
7943
7943
  if (err) return callback(err);
7944
7944
  var reader = new fd_slicer.FdSlicer(fd);
7945
7945
  fromRandomAccessReader(reader, stats.size, options2, callback);
@@ -11105,17 +11105,17 @@ Schema.prototype.volatile = function volatile() {
11105
11105
  };
11106
11106
  var resolvers = {};
11107
11107
  var checkedVolatile = /* @__PURE__ */ Symbol("checked-volatile-schema");
11108
- function validateVolatileSchema(schema, path81 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
11108
+ function validateVolatileSchema(schema, path82 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
11109
11109
  const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
11110
11110
  if (states.has(blocked)) return;
11111
11111
  states.add(blocked);
11112
11112
  seen.set(schema, states);
11113
- if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path: path81 });
11113
+ if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path: path82 });
11114
11114
  const nested = blocked || !!schema.meta?.volatile;
11115
- if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path81, key], nested, seen);
11116
- if (schema.sKey) validateVolatileSchema(schema.sKey, [...path81, "<key>"], true, seen);
11117
- if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path81, "*"], true, seen);
11118
- if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path81, String(index)], true, seen);
11115
+ if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path82, key], nested, seen);
11116
+ if (schema.sKey) validateVolatileSchema(schema.sKey, [...path82, "<key>"], true, seen);
11117
+ if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path82, "*"], true, seen);
11118
+ if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path82, String(index)], true, seen);
11119
11119
  }
11120
11120
  Schema.extend = function extend(type, resolve22) {
11121
11121
  resolvers[type] = resolve22;
@@ -20429,7 +20429,7 @@ function validateStoryDraft(story) {
20429
20429
  if (story.\u5173\u952E\u8F6C\u6298.length === 0) errors.push("\u6CA1\u6709\u5173\u952E\u8F6C\u6298");
20430
20430
  if (story.\u7ED3\u5C3E.trim() === "") errors.push("\u300C\u7ED3\u5C3E\u300D\u4E3A\u7A7A");
20431
20431
  for (const c of story.\u4EBA\u7269) {
20432
- if (!/动机|想要|想|目标|害怕|怕|非.*不可|渴望|执念/.test(c.\u5C0F\u4F20)) {
20432
+ if (!/动机|想要|想|目标|害怕|怕|非.*不可|渴望|执念|旨在|必须|为了|保住|查明|洗清|掩盖|夺回|守护|阻止|复仇/.test(c.\u5C0F\u4F20)) {
20433
20433
  warnings.push(`\u4EBA\u7269\u300C${c.\u59D3\u540D}\u300D\u7684\u5C0F\u4F20\u91CC\u6CA1\u5199\u6E05\u52A8\u673A\uFF08\u60F3\u8981\u4EC0\u4E48\u3001\u4E3A\u4EC0\u4E48\u975E\u8981\u4E0D\u53EF\uFF09\uFF0C\u5267\u672C\u7EE7\u627F\u4E0D\u4E86\u8FD9\u4E2A\u4EBA\u7269\u7684\u6DF1\u5EA6`);
20434
20434
  }
20435
20435
  }
@@ -21647,8 +21647,8 @@ var EPISODE_SETTING_RE = /^场景环境[::]\s*(.+?)\s*$/;
21647
21647
  var EPISODE_SOUND_RE = /^【环境声[::](.+)】$/;
21648
21648
  var EPISODE_SUBTITLE_RE = /^【字幕[::](.+)】$/;
21649
21649
  var EPISODE_DIALOGUE_RE = /^([^::((]{1,15}?)(?:[((]([^))]+)[))])?[::](.+)$/;
21650
- var EPISODE_BEAT_OPEN_RE = /^-\s*开场冲突:\s*第\s*(\d+)\s*秒/;
21651
- var EPISODE_BEAT_HOOK_RE = /^-\s*结尾钩子:\s*第\s*(\d+)\s*秒/;
21650
+ var EPISODE_BEAT_OPEN_RE = /^-\s*开场冲突[::]\s*(?:第\s*)?(\d+)\s*(?:秒|s)/i;
21651
+ var EPISODE_BEAT_HOOK_RE = /^-\s*结尾钩子[::]\s*(?:第\s*)?(\d+)\s*(?:秒|s)/i;
21652
21652
  function parseShotTimecode(raw, where, problems) {
21653
21653
  const value = raw.trim();
21654
21654
  if (value === "\u2014" || value === "") return { \u5F00\u59CB\u79D2: null, \u7ED3\u675F\u79D2: null };
@@ -21714,8 +21714,9 @@ function parseEpisodeScript(text5) {
21714
21714
  if (\u753B\u5E45 !== "\u7AD6\u5C4F" && \u753B\u5E45 !== "\u6A2A\u5C4F") problems.push(`\u5355\u96C6\u5267\u672C\u7F3A\u5C11\u6216\u5199\u9519\u753B\u5E45\uFF08\u5E94\u4E3A \u7AD6\u5C4F \u6216 \u6A2A\u5C4F\uFF09\uFF1A${\u753B\u5E45raw ?? "\u65E0"}`);
21715
21715
  const \u65F6\u957Fraw = episodeMetaValue(lines, "\u65F6\u957F");
21716
21716
  const \u65F6\u957F\u79D2 = \u65F6\u957Fraw === void 0 ? NaN : Number(/(\d+)/.exec(\u65F6\u957Fraw)?.[1]);
21717
- const \u94A9\u5B50\u7C7B\u578B = episodeMetaValue(lines, "\u94A9\u5B50\u7C7B\u578B");
21718
- if (\u94A9\u5B50\u7C7B\u578B !== "\u8EAB\u4EFD" && \u94A9\u5B50\u7C7B\u578B !== "\u60C5\u611F" && \u94A9\u5B50\u7C7B\u578B !== "\u987F\u609F") problems.push(`\u5355\u96C6\u5267\u672C\u7F3A\u5C11\u6216\u5199\u9519\u94A9\u5B50\u7C7B\u578B\uFF08\u8EAB\u4EFD/\u60C5\u611F/\u987F\u609F\uFF09\uFF1A${\u94A9\u5B50\u7C7B\u578B ?? "\u65E0"}`);
21717
+ const rawHook = episodeMetaValue(lines, "\u94A9\u5B50\u7C7B\u578B");
21718
+ const \u94A9\u5B50\u7C7B\u578B = rawHook === void 0 ? void 0 : rawHook.replace(/钩$/, "").trim();
21719
+ if (\u94A9\u5B50\u7C7B\u578B !== "\u8EAB\u4EFD" && \u94A9\u5B50\u7C7B\u578B !== "\u60C5\u611F" && \u94A9\u5B50\u7C7B\u578B !== "\u987F\u609F") problems.push(`\u5355\u96C6\u5267\u672C\u7F3A\u5C11\u6216\u5199\u9519\u94A9\u5B50\u7C7B\u578B\uFF08\u8EAB\u4EFD/\u60C5\u611F/\u987F\u609F\uFF09\uFF1A${rawHook ?? "\u65E0"}`);
21719
21720
  const \u6838\u5FC3\u60F3\u6CD5 = episodeMetaValue(lines, "\u6838\u5FC3\u60F3\u6CD5") ?? "";
21720
21721
  const \u723D\u70B9 = episodeMetaValue(lines, "\u723D\u70B9") ?? "";
21721
21722
  const \u7ED3\u5C3E\u60AC\u5FF5 = episodeMetaValue(lines, "\u7ED3\u5C3E\u60AC\u5FF5") ?? "";
@@ -21816,7 +21817,7 @@ function parseEpisodeScript(text5) {
21816
21817
  const twist = /^-\s*反转[::]\s*(.+?)\s*$/.exec(line);
21817
21818
  if (twist) {
21818
21819
  const value = twist[1].trim();
21819
- \u53CD\u8F6C\u79D2 = value === "\u65E0" ? [] : [...value.matchAll(/第\s*(\d+)\s*秒/g)].map((m) => Number(m[1]));
21820
+ \u53CD\u8F6C\u79D2 = value === "\u65E0" ? [] : [...value.matchAll(/(?:第\s*)?(\d+)\s*(?:秒|s)/gi)].map((m) => Number(m[1]));
21820
21821
  continue;
21821
21822
  }
21822
21823
  continue;
@@ -21953,6 +21954,223 @@ function parseEpisodeScript(text5) {
21953
21954
  return { ok: true, problems, episode };
21954
21955
  }
21955
21956
 
21957
+ // ../core/src/shortdrama/episode-checks.ts
21958
+ var REDLINE_RE = /断肢|开膛|破肚|身首异处|凌迟|活埋|注射死刑|吸毒|制毒|自杀方法|下蛊害人|蛊毒害人|真实的国家机关/;
21959
+ var OPEN_BAN_RE = /拉窗帘|太阳升起|醒过来|闹钟响|起床洗漱|开车上班|喝咖啡闲聊|悠闲的清晨|阳光明媚的早晨/;
21960
+ var WEAK_MICRO_ACT_RE = /眼神微动|眼神微闪|目光微闪|目光微动|微微一怔|若有所思|陷入沉思|嘴角微扬|嘴角微勾|推了半寸|移了半寸/;
21961
+ var STRONG_ACT_MARKERS = /砸|摔|甩|拍|踹|踢|扇|掀|撞|掐|抓|拽|扯|泼|烧|点燃|撕|跪|瘫|倒地|跌|扔|抛|夺|抢|掏出|抽出|拔出|按住|挡|躲|冲上|扑|抱住|拖|绑|堵住|捂|翻过|推翻|推开|推倒|举|亮出|亮明|逼近|踉跄|后退|转身|起身|站起|碎|裂|滚落|滑落|溅|冒出|涨红|攥|捏|摁|特写|推给|滑到|递/;
21962
+ var JARGON_RIDDLE_RE = /法则缝隙|气运锚点|因果闭环|维度坍缩|高维投影|底层逻辑闭环|赋能矩阵/;
21963
+ var PLAIN_GROUNDING_RE = /就是|赔|钱|万|亿|块|命|破产|坐牢|退婚|滚出|抵押|合同|房子|股权|死|活/;
21964
+ var ABSTRACT_EMOTION_CUE_RE = /^[((]?\s*(?:开心|难过|生气|愤怒|悲伤|伤心|高兴|邪魅|伤感|激动)\s*[))]?$/;
21965
+ var COMMON_TYPOS_RE = /竞然|迫不急待|按耐不住|走头无路|一愁莫展|再接再励|出奇不意/;
21966
+ function netChars(text5) {
21967
+ return Array.from(text5.replace(/[\s,。!?;:、“”‘’()()【】\[\]《》—…·\-]/g, "")).length;
21968
+ }
21969
+ function stripShotTag(text5) {
21970
+ return text5.replace(/^△\s*【镜头\d+[^】]*】\s*/, "").replace(/^△\s*/, "").trim();
21971
+ }
21972
+ function extractCraftUnits(script) {
21973
+ const epTag = `\u96C6${String(script.\u96C6).padStart(3, "0")}`;
21974
+ const units = [];
21975
+ for (const scene of script.\u573A\u666F) {
21976
+ const loc = `${epTag}/\u573A${String(scene.\u573A).padStart(2, "0")}`;
21977
+ if (scene.\u955C\u5934 && scene.\u955C\u5934.length > 0) {
21978
+ for (const shot of scene.\u955C\u5934) {
21979
+ const shotLoc = `${loc}/\u955C${String(shot.\u955C\u5934\u53F7).padStart(2, "0")}`;
21980
+ for (const line of shot.\u63CF\u5199) {
21981
+ if (line.trim() !== "") {
21982
+ units.push({ kind: "action", location: shotLoc, text: line.trim(), shotInterleaved: true });
21983
+ }
21984
+ }
21985
+ for (const line of shot.\u53F0\u8BCD) {
21986
+ if (line.\u53F0\u8BCD.trim() !== "") {
21987
+ units.push({
21988
+ kind: "dialogue",
21989
+ location: shotLoc,
21990
+ text: line.\u53F0\u8BCD.trim(),
21991
+ shotInterleaved: true,
21992
+ ...line.\u62EC\u53F7\u63D0\u793A ? { cue: line.\u62EC\u53F7\u63D0\u793A } : {}
21993
+ });
21994
+ }
21995
+ }
21996
+ }
21997
+ } else {
21998
+ const env = (scene.\u573A\u666F\u73AF\u5883 ?? scene.\u52A8\u4F5C).trim();
21999
+ if (env !== "") {
22000
+ units.push({ kind: "action", location: loc, text: env, shotInterleaved: false });
22001
+ }
22002
+ for (const line of scene.\u53F0\u8BCD) {
22003
+ if (line.\u53F0\u8BCD.trim() !== "") {
22004
+ units.push({
22005
+ kind: "dialogue",
22006
+ location: loc,
22007
+ text: line.\u53F0\u8BCD.trim(),
22008
+ shotInterleaved: false,
22009
+ ...line.\u62EC\u53F7\u63D0\u793A ? { cue: line.\u62EC\u53F7\u63D0\u793A } : {}
22010
+ });
22011
+ }
22012
+ }
22013
+ }
22014
+ }
22015
+ return units;
22016
+ }
22017
+ function pushFinding(list, \u8BC1\u636E\u4F4D\u7F6E, \u4E25\u91CD\u7A0B\u5EA6, \u662F\u5426\u5EFA\u8BAE\u963B\u65AD, \u95EE\u9898\u8BF4\u660E, \u4FEE\u6539\u5EFA\u8BAE) {
22018
+ list.push({
22019
+ \u6A21\u5757\u540D: "\u77ED\u5267\u5BA1\u8BFB",
22020
+ \u8BC1\u636E\u4F4D\u7F6E,
22021
+ \u4E25\u91CD\u7A0B\u5EA6,
22022
+ \u662F\u5426\u5EFA\u8BAE\u963B\u65AD,
22023
+ \u95EE\u9898\u8BF4\u660E,
22024
+ \u4FEE\u6539\u5EFA\u8BAE,
22025
+ \u5EFA\u8BAE\u8FD4\u56DE\u8282\u70B9: "\u5355\u96C6\u5267\u672C",
22026
+ \u5904\u7F6E\u72B6\u6001: "\u5F85\u5904\u7406"
22027
+ });
22028
+ }
22029
+ function checkEpisodeCraft(script) {
22030
+ const findings = [];
22031
+ const units = extractCraftUnits(script);
22032
+ if (units.length === 0) return findings;
22033
+ const epTag = `\u96C6${String(script.\u96C6).padStart(3, "0")}`;
22034
+ const fullText = units.map((u) => u.text).join("\n");
22035
+ const redline = REDLINE_RE.exec(fullText);
22036
+ if (redline !== null) {
22037
+ pushFinding(
22038
+ findings,
22039
+ epTag,
22040
+ "\u9AD8",
22041
+ true,
22042
+ `\u5408\u89C4\u7EA2\u7EBF\uFF08E10\uFF09\uFF1A\u547D\u4E2D\u77ED\u5267\u5E73\u53F0\u9AD8\u5371\u8FDD\u7981\u8BCD\u300C${redline[0]}\u300D\u3002`,
22043
+ "\u5220\u9664\u6216\u66FF\u6362\u4E3A\u5408\u6CD5\u53EF\u62CD\u7684\u5177\u4F53\u620F\u5267\u51B2\u7A81\u7EC6\u8282\u3002"
22044
+ );
22045
+ }
22046
+ const headText = units.slice(0, 3).map((u) => u.text).join(" ");
22047
+ const openBan = OPEN_BAN_RE.exec(headText);
22048
+ if (openBan !== null) {
22049
+ pushFinding(
22050
+ findings,
22051
+ units[0].location,
22052
+ "\u4E2D",
22053
+ false,
22054
+ `\u5F00\u7BC7\u5E9F\u955C\u5934\uFF08E5\uFF09\uFF1A\u5F00\u7BC7\u524D 3 \u62CD\u51FA\u73B0\u6162\u70ED\u65E5\u5E38\u94FA\u57AB\u300C${openBan[0]}\u300D\uFF0C\u5BB9\u6613\u9519\u5931\u9EC4\u91D1 3 \u79D2\u7559\u5B58\u3002`,
22055
+ "\u780D\u6389\u8D77\u5E8A/\u51FA\u95E8/\u559D\u5496\u5561\u94FA\u57AB\uFF0C\u9996\u955C\u76F4\u63A5\u5207\u5165\u51B2\u7A81\u6216\u5012\u8BA1\u65F6\u6B7B\u7EBF\u52A8\u4F5C\u3002"
22056
+ );
22057
+ }
22058
+ let consecutiveDlgLines = 0;
22059
+ let consecutiveDlgChars = 0;
22060
+ let dryRunWarned = false;
22061
+ let densityWarned = false;
22062
+ let totalDlgChars = 0;
22063
+ let totalActChars = 0;
22064
+ for (let i = 0; i < units.length; i += 1) {
22065
+ const unit = units[i];
22066
+ const typo = COMMON_TYPOS_RE.exec(unit.text);
22067
+ if (typo !== null) {
22068
+ pushFinding(
22069
+ findings,
22070
+ unit.location,
22071
+ "\u4F4E",
22072
+ false,
22073
+ `\u9AD8\u9891\u540C\u97F3\u9519\u522B\u5B57\uFF08E22\uFF09\uFF1A\u7591\u4F3C\u9519\u522B\u5B57\u300C${typo[0]}\u300D\u3002`,
22074
+ "\u6838\u5BF9\u5E76\u4FEE\u6B63\u7528\u5B57\uFF08\u5982\u7ADF\u7136/\u8FEB\u4E0D\u53CA\u5F85/\u6309\u637A\u4E0D\u4F4F/\u8D70\u6295\u65E0\u8DEF/\u4E00\u7B79\u83AB\u5C55/\u518D\u63A5\u518D\u5389/\u51FA\u5176\u4E0D\u610F\uFF09\u3002"
22075
+ );
22076
+ }
22077
+ if (unit.kind === "action") {
22078
+ consecutiveDlgLines = 0;
22079
+ consecutiveDlgChars = 0;
22080
+ const cleanAct = stripShotTag(unit.text);
22081
+ const actLen = netChars(cleanAct);
22082
+ totalActChars += actLen;
22083
+ if (actLen > 45) {
22084
+ pushFinding(
22085
+ findings,
22086
+ unit.location,
22087
+ "\u4F4E",
22088
+ false,
22089
+ `\u52A8\u4F5C\u63CF\u5199\u8FC7\u957F\uFF08E20\uFF09\uFF1A\u5355\u6761\u52A8\u4F5C\u63CF\u5199\u51C0\u5B57\u6570\u4E3A ${actLen} \u5B57\uFF0C\u8D85\u51FA\u5355\u955C\u53EF\u8BFB\u5EFA\u8BAE\uFF0840\u201345 \u5B57\uFF09\u3002`,
22090
+ "\u62C6\u5206\u4E3A\u4E24\u4E2A\u77ED\u4FC3\u53EF\u62CD\u7684\u955C\u5934\u62CD\uFF0C\u6216\u780D\u6389\u975E\u89C6\u89C9\u5FC3\u7406\u8D58\u8BED\u3002"
22091
+ );
22092
+ }
22093
+ if (WEAK_MICRO_ACT_RE.test(cleanAct) && !STRONG_ACT_MARKERS.test(cleanAct)) {
22094
+ pushFinding(
22095
+ findings,
22096
+ unit.location,
22097
+ "\u4F4E",
22098
+ false,
22099
+ `\u65E0\u6548\u5FAE\u52A8\u4F5C\uFF08E26\uFF09\uFF1A\u52A8\u4F5C\u63CF\u5199\u300C${cleanAct}\u300D\u4EC5\u4F9D\u8D56\u865A\u5FAE\u795E\u6001\uFF0C\u7F3A\u4E4F\u53EF\u89C1\u7269\u7406\u52A8\u4F5C\u652F\u6491\u3002`,
22100
+ "\u8865\u4E00\u4E2A\u8089\u773C\u53EF\u89C1\u7684\u5F3A\u7269\u7406\u52A8\u4F5C\u6807\u8BB0\uFF08\u7838/\u6454/\u6309/\u4EAE\u724C/\u8F6C\u8EAB/\u6454\uFF09\uFF0C\u6216\u6539\u4E3A\u5177\u4F53\u624B\u5934\u52A8\u4F5C\u3002"
22101
+ );
22102
+ }
22103
+ continue;
22104
+ }
22105
+ consecutiveDlgLines += 1;
22106
+ const dlgLen = netChars(unit.text);
22107
+ consecutiveDlgChars += dlgLen;
22108
+ totalDlgChars += dlgLen;
22109
+ if (!dryRunWarned && unit.shotInterleaved && consecutiveDlgLines > 6) {
22110
+ dryRunWarned = true;
22111
+ pushFinding(
22112
+ findings,
22113
+ unit.location,
22114
+ "\u4E2D",
22115
+ false,
22116
+ `\u5E72\u804A\u65AD\u5C42\uFF08E24\uFF09\uFF1A\u5DF2\u8FDE\u7EED\u51FA\u73B0 ${consecutiveDlgLines} \u53E5\u7EAF\u5BF9\u767D\u800C\u65E0\u89C6\u89C9\u52A8\u4F5C \u25B3 \u63D2\u5165\uFF0C\u753B\u9762\u6613\u6CA6\u4E3A\u7AD9\u6869\u5E7F\u64AD\u5267\u3002`,
22117
+ "\u6BCF 2\u20134 \u53E5\u5BF9\u767D\u7A7F\u63D2 1 \u6761\u53EF\u89C1\u7269\u7406\u52A8\u4F5C\u3001\u795E\u6001\u53CD\u5E94\u7279\u5199\u6216\u7269\u8BC1\u64CD\u4F5C\u955C\u5934\u3002"
22118
+ );
22119
+ }
22120
+ if (!densityWarned && consecutiveDlgChars > 95) {
22121
+ densityWarned = true;
22122
+ pushFinding(
22123
+ findings,
22124
+ unit.location,
22125
+ "\u4F4E",
22126
+ false,
22127
+ `15 \u79D2\u7A97\u53E3\u53F0\u8BCD\u8FC7\u5BC6\uFF08E19\uFF09\uFF1A\u8FDE\u7EED\u5BF9\u767D\u5DF2\u8FBE ${consecutiveDlgChars} \u5B57\uFF08\u8D85\u51FA 15 \u79D2\u7A97\u53E3\u53C2\u8003\u5BB9\u91CF\uFF09\uFF0C\u5EFA\u8BAE\u63D2\u5165\u52A8\u4F5C\u505C\u987F\u6362\u6C14\u3002`,
22128
+ "\u5728\u4E2D\u95F4\u5207\u5165\u4E00\u6761\u5BF9\u624B\u53CD\u5E94\u6216\u9053\u5177\u52A8\u4F5C\u6253\u65AD\u53E3\u64AD\u611F\u3002"
22129
+ );
22130
+ }
22131
+ if (unit.cue && ABSTRACT_EMOTION_CUE_RE.test(unit.cue.trim())) {
22132
+ pushFinding(
22133
+ findings,
22134
+ unit.location,
22135
+ "\u4F4E",
22136
+ false,
22137
+ `\u8868\u6F14\u8BED\u6C14\u8FC7\u4E8E\u62BD\u8C61\uFF08E18a\uFF09\uFF1A\u62EC\u53F7\u63D0\u793A\u300C${unit.cue}\u300D\u53EA\u6709\u62BD\u8C61\u60C5\u7EEA\u6807\u7B7E\uFF0C\u4E0D\u5229\u4E8E\u6F14\u5458\u4E0E\u58F0\u97F3\u6307\u5BFC\u843D\u5730\u3002`,
22138
+ "\u6539\u5199\u4E3A\u53EF\u8868\u6F14\u7684\u58F0\u5B66\u4E0E\u8EAB\u4F53\u63D0\u793A\uFF08\u5982\u201C\u538B\u4F4E\u58F0\u97F3\u3001\u7B11\u610F\u4E0D\u8FBE\u773C\u5E95\u201D\u6216\u8BED\u901F/\u97F3\u91CF/\u5C3E\u97F3\u63CF\u8FF0\uFF09\u3002"
22139
+ );
22140
+ }
22141
+ const riddle = JARGON_RIDDLE_RE.exec(unit.text);
22142
+ if (riddle !== null) {
22143
+ const nextDlg = units.slice(i + 1, i + 3).find((u) => u.kind === "dialogue")?.text ?? "";
22144
+ if (!PLAIN_GROUNDING_RE.test(unit.text) && !PLAIN_GROUNDING_RE.test(nextDlg)) {
22145
+ pushFinding(
22146
+ findings,
22147
+ unit.location,
22148
+ "\u4F4E",
22149
+ false,
22150
+ `\u9ED1\u8BDD\u672A\u4F5C\u5927\u767D\u8BDD\u6362\u7B97\uFF08E25\uFF09\uFF1A\u53F0\u8BCD\u51FA\u73B0\u62BD\u8C61\u8BBE\u5B9A\u8BCD\u300C${riddle[0]}\u300D\uFF0C\u4E14\u540C\u8F6E\u6216\u4E0B\u4E00\u53E5\u672A\u76F4\u7ED9\u767D\u8BDD\u5229\u5BB3\u7ED3\u8BBA\u3002`,
22151
+ "\u5F53\u53E5\u6216\u7D27\u63A5\u4E0B\u4E00\u53E5\u7528\u5927\u767D\u8BDD\u70B9\u900F\u503C\u591A\u5C11\u94B1\u3001\u72AF\u4EC0\u4E48\u7F6A\u6216\u8C01\u8F93\u8C01\u8D62\u3002"
22152
+ );
22153
+ }
22154
+ }
22155
+ }
22156
+ const hasInterleavedShots = units.some((u) => u.shotInterleaved);
22157
+ const dlgCount = units.filter((u) => u.kind === "dialogue").length;
22158
+ if (hasInterleavedShots && dlgCount >= 6 && totalDlgChars + totalActChars > 0) {
22159
+ const ratio = totalDlgChars / (totalDlgChars + totalActChars);
22160
+ if (ratio > 0.72) {
22161
+ pushFinding(
22162
+ findings,
22163
+ epTag,
22164
+ "\u4F4E",
22165
+ false,
22166
+ `\u89C6\u542C\u52A8\u4F5C\u5360\u6BD4\u504F\u4F4E\uFF08E21\uFF09\uFF1A\u672C\u96C6\u5BF9\u767D\u5B57\u6570\u5360\u6BD4 ${(ratio * 100).toFixed(0)}%\uFF08\u9AD8\u4E8E 70% \u53C2\u8003\u7EBF\uFF09\uFF0C\u89C6\u542C\u8C03\u5EA6\u7565\u5355\u8584\u3002`,
22167
+ "\u5220\u51CF\u53E3\u6C34\u590D\u8FF0\u53E5\uFF0C\u5C06\u5FC3\u7406\u51B2\u7A81\u6539\u7528\u8EAB\u4EFD\u53CD\u5DEE\u5FD9\u6D3B\u6216\u7269\u8BC1\u5BF9\u6297\u955C\u5934\u6F14\u51FA\u3002"
22168
+ );
22169
+ }
22170
+ }
22171
+ return findings;
22172
+ }
22173
+
21956
22174
  // ../core/src/shortdrama/review.ts
21957
22175
  function epNo(\u96C6) {
21958
22176
  return `\u96C6${String(\u96C6).padStart(3, "0")}`;
@@ -21992,10 +22210,10 @@ function reviewShortDramaEpisode(input) {
21992
22210
  if (n2 > MAX_DIALOGUE_CHARS) {
21993
22211
  push2(
21994
22212
  `${ep}/${sceneNo(scene.\u573A)}`,
21995
- "\u4E2D",
22213
+ "\u4F4E",
21996
22214
  false,
21997
22215
  `${line.\u89D2\u8272}\u7684\u53F0\u8BCD ${n2} \u5B57\uFF0C\u8D85\u8FC7\u5355\u53E5 ${MAX_DIALOGUE_CHARS} \u5B57\u4E0A\u9650\uFF1A\u300C${line.\u53F0\u8BCD}\u300D\u3002`,
21998
- "\u62C6\u6210\u4E24\u53E5\u77ED\u53F0\u8BCD\uFF0C\u6216\u6539\u6210\u52A8\u4F5C\u884C\uFF08\u5BF9\u767D\u5373\u884C\u52A8\uFF0C\u77ED\u53E5\u624D\u6709\u529B\uFF09\u3002",
22216
+ \u5267\u672C.\u753B\u5E45 === "\u6A2A\u5C4F" ? "\u6A2A\u5C4F\u5141\u8BB8\u66F4\u81EA\u7136\u7684\u6F5C\u53F0\u8BCD\u4E0E\u957F\u5BF9\u767D\uFF0C\u4EC5\u4F5C\u53C2\u8003\uFF1B\u82E5\u53E3\u64AD\u504F\u957F\u518D\u9002\u5F53\u62C6\u5206\u3002" : "\u7AD6\u5C4F\u53F0\u8BCD\u5B9C\u77ED\u4FC3\u6709\u529B\uFF0C\u53EF\u6309\u9700\u8981\u62C6\u6210\u4E24\u53E5\u77ED\u53F0\u8BCD\u6216\u7528\u52A8\u4F5C\u620F\u627F\u63A5\uFF08\u6B64\u9879\u4EC5\u5EFA\u8BAE\uFF0C\u4E0D\u963B\u65AD\u5B9A\u7A3F\uFF09\u3002",
21999
22217
  "\u5355\u96C6\u5267\u672C"
22000
22218
  );
22001
22219
  }
@@ -22027,6 +22245,7 @@ function reviewShortDramaEpisode(input) {
22027
22245
  if (\u5267\u672C.\u7ED3\u5C3E\u60AC\u5FF5.trim() !== \u5927\u7EB2.\u7ED3\u5C3E\u60AC\u5FF5.trim()) {
22028
22246
  push2(ep, "\u9AD8", true, "\u7ED3\u5C3E\u60AC\u5FF5\u4E0E\u5927\u7EB2\u4E0D\u4E00\u81F4\uFF1A\u5FC5\u987B\u5207\u5728\u540C\u4E00\u4E2A\u95EE\u9898\u4E0A\u3002", "\u4EE5\u5927\u7EB2\u4E3A\u51C6\u6539\u5267\u672C\u7ED3\u5C3E\uFF0C\u6216\u56DE\u5206\u96C6\u5927\u7EB2\u6539\u60AC\u5FF5\u3002", "\u5206\u96C6\u5927\u7EB2");
22029
22247
  }
22248
+ findings.push(...checkEpisodeCraft(\u5267\u672C));
22030
22249
  return findings;
22031
22250
  }
22032
22251
 
@@ -22486,6 +22705,12 @@ var \u6750\u6599\u9884\u7B97 = {
22486
22705
  \u65F6\u95F4\u7EBF\u6700\u8FD1\u6761\u6570: 20,
22487
22706
  \u6587\u98CE\u6700\u8FD1\u6761\u6570: 5
22488
22707
  };
22708
+ var \u9AD8\u8D28\u91CF\u6750\u6599\u9884\u7B97 = {
22709
+ \u4E0A\u4E00\u7AE0\u672B\u5C3E\u5B57\u6570: 8e3,
22710
+ \u6700\u8FD1\u7AE0\u6458\u8981\u6570: 12,
22711
+ \u65F6\u95F4\u7EBF\u6700\u8FD1\u6761\u6570: 60,
22712
+ \u6587\u98CE\u6700\u8FD1\u6761\u6570: 20
22713
+ };
22489
22714
 
22490
22715
  // ../core/src/assembly/supplements.ts
22491
22716
  import * as path42 from "node:path";
@@ -22728,6 +22953,28 @@ function collectWorldbookRels(body) {
22728
22953
  }
22729
22954
  return rels;
22730
22955
  }
22956
+ function listWorldbookFiles(bookRoot) {
22957
+ const wbRoot = resolveInsideBook3(bookRoot, "\u4E16\u754C\u4E66");
22958
+ if (wbRoot === null || !fs38.existsSync(wbRoot)) return [];
22959
+ const out = [];
22960
+ const visit = (absDir, relPrefix) => {
22961
+ let entries;
22962
+ try {
22963
+ entries = fs38.readdirSync(absDir, { withFileTypes: true });
22964
+ } catch {
22965
+ return;
22966
+ }
22967
+ for (const entry of entries) {
22968
+ if (entry.isSymbolicLink()) continue;
22969
+ const rel = `${relPrefix}/${entry.name}`;
22970
+ const abs = path43.join(absDir, entry.name);
22971
+ if (entry.isDirectory()) visit(abs, rel);
22972
+ else if (entry.isFile() && entry.name.endsWith(".md")) out.push(rel);
22973
+ }
22974
+ };
22975
+ visit(wbRoot, "\u4E16\u754C\u4E66");
22976
+ return out.sort((a, b) => a.localeCompare(b, "zh"));
22977
+ }
22731
22978
  function sliceFile(bookRoot, rel) {
22732
22979
  const abs = resolveInsideBook3(bookRoot, rel);
22733
22980
  if (abs === null) return { text: "", missing: true };
@@ -22795,6 +23042,7 @@ function renderLedgerEntry(entry) {
22795
23042
  return lines.join("\n");
22796
23043
  }
22797
23044
  function computeBaseMaterials(bookRoot, input) {
23045
+ const budget = input.\u8D28\u91CF\u6A21\u5F0F === true ? \u9AD8\u8D28\u91CF\u6750\u6599\u9884\u7B97 : \u6750\u6599\u9884\u7B97;
22798
23046
  const dir = paths.\u6750\u6599\u5305\u76EE\u5F55(input.\u5377, input.\u7AE0\u540D);
22799
23047
  const confirmedRel = paths.\u786E\u8BA4\u7EC6\u7EB2(input.\u5377, input.\u7AE0, input.\u7AE0\u540D);
22800
23048
  const confirmedText = readText8(bookRoot, confirmedRel);
@@ -22837,8 +23085,20 @@ function computeBaseMaterials(bookRoot, input) {
22837
23085
  const outlineBody = confirmedDoc.data.body.trim();
22838
23086
  if (outlineBody === "") gaps.push("\u786E\u8BA4\u7EC6\u7EB2\u6B63\u6587\u4E3A\u7A7A");
22839
23087
  const hardLines = parsed.constraints.filter((c) => c.mark === "\u786C").map((c) => c.line);
22840
- const worldRels = collectWorldbookRels(`${outlineBody}
23088
+ const explicitWorldRels = collectWorldbookRels(`${outlineBody}
22841
23089
  ${sourceLines3.join("\n")}`);
23090
+ const worldRelSet = new Set(explicitWorldRels);
23091
+ const worldRels = [...explicitWorldRels];
23092
+ if (input.\u8D28\u91CF\u6A21\u5F0F === true) {
23093
+ for (const rel of listWorldbookFiles(bookRoot)) {
23094
+ if (worldRelSet.has(rel)) continue;
23095
+ const stem = path43.posix.basename(rel, ".md");
23096
+ if (stem.length >= 2 && outlineBody.includes(stem)) {
23097
+ worldRelSet.add(rel);
23098
+ worldRels.push(rel);
23099
+ }
23100
+ }
23101
+ }
22842
23102
  const worldSlices = [];
22843
23103
  for (const rel of worldRels) {
22844
23104
  const sliced = sliceFile(bookRoot, rel);
@@ -22866,6 +23126,7 @@ ${worldText || "\uFF08\u672C\u7AE0\u8FB9\u754C\u5185\u65E0\u5DF2\u751F\u6548\u4E
22866
23126
  let \u8854\u63A5\u5B8C\u6574 = "\u5B8C\u6574";
22867
23127
  const chapters = listChapters(bookRoot).filter((k) => k.\u7AE0 > 0);
22868
23128
  const prev = chapters.find((k) => k.\u7AE0 === input.\u7AE0 - 1) ?? null;
23129
+ let prevBodyText = "";
22869
23130
  if (prev !== null && prev.\u5377 < input.\u5377) {
22870
23131
  const prevVolSummaryRel = paths.\u5377\u6458\u8981(prev.\u5377);
22871
23132
  const prevVolSummary = readText8(bookRoot, prevVolSummaryRel);
@@ -22888,12 +23149,13 @@ ${bodyOnly(prevVolSummary)}`);
22888
23149
  \u8854\u63A5Parts.push("\uFF08\u65E0\u4E0A\u4E00\u7AE0\u5B9A\u7A3F\uFF09");
22889
23150
  \u8854\u63A5\u5B8C\u6574 = "\u7A7A";
22890
23151
  } else {
22891
- \u8854\u63A5Parts.push(tailByParagraph(bodyOnly(prevText), \u6750\u6599\u9884\u7B97.\u4E0A\u4E00\u7AE0\u672B\u5C3E\u5B57\u6570));
23152
+ prevBodyText = bodyOnly(prevText);
23153
+ \u8854\u63A5Parts.push(tailByParagraph(prevBodyText, budget.\u4E0A\u4E00\u7AE0\u672B\u5C3E\u5B57\u6570));
22892
23154
  \u8854\u63A5Sources.push(prevRel);
22893
23155
  }
22894
23156
  }
22895
23157
  const summaries = [];
22896
- for (let no = input.\u7AE0 - \u6750\u6599\u9884\u7B97.\u6700\u8FD1\u7AE0\u6458\u8981\u6570; no < input.\u7AE0; no += 1) {
23158
+ for (let no = input.\u7AE0 - budget.\u6700\u8FD1\u7AE0\u6458\u8981\u6570; no < input.\u7AE0; no += 1) {
22897
23159
  if (no <= 0) continue;
22898
23160
  const ck = chapters.find((k) => k.\u7AE0 === no);
22899
23161
  if (ck === void 0) continue;
@@ -22923,7 +23185,7 @@ ${content}`);
22923
23185
  return ch === null || ch <= input.\u7AE0;
22924
23186
  });
22925
23187
  const tlExcluded = tlEntriesAll.length - tlEntries.length;
22926
- const recent = tlEntries.slice(-\u6750\u6599\u9884\u7B97.\u65F6\u95F4\u7EBF\u6700\u8FD1\u6761\u6570);
23188
+ const recent = tlEntries.slice(-budget.\u65F6\u95F4\u7EBF\u6700\u8FD1\u6761\u6570);
22927
23189
  const terms2 = \u65F6\u7A7A.split(/[,,、;;。!!??\s]+/).map((t2) => t2.trim()).filter((t2) => t2.length >= 2);
22928
23190
  const hits = tlEntries.filter((e) => {
22929
23191
  const content = renderTimelineContent(e);
@@ -22972,14 +23234,36 @@ ${content}`);
22972
23234
  const \u5951\u7EA6Body = \u5951\u7EA6 === null ? null : bodyOnly(\u5951\u7EA6);
22973
23235
  const \u5377\u7EB2Body = \u5377\u7EB2 === null ? null : bodyOnly(\u5377\u7EB2);
22974
23236
  const \u5951\u7EA6\u7981\u533A = \u5951\u7EA6Body === null ? null : extractSection(\u5951\u7EA6Body, "\u521B\u4F5C\u7981\u533A\u4E0E\u4E0D\u53EF\u59A5\u534F\u9879");
23237
+ const contractTitles = input.\u8D28\u91CF\u6A21\u5F0F === true ? ["\u9898\u6750\u4E0E\u8BFB\u8005\u5B9A\u4F4D", "\u6838\u5FC3\u770B\u70B9\u4E0E\u5DEE\u5F02\u5316", "\u9605\u8BFB\u4F53\u9A8C\u4E0E\u60C5\u7EEA\u627F\u8BFA", "\u4E3B\u89D2\u539F\u5219\u4E0E\u5173\u7CFB\u8FB9\u754C", "\u53D9\u4E8B\u65B9\u5F0F\u4E0E\u6587\u98CE\u57FA\u8C03"] : ["\u53D9\u4E8B\u65B9\u5F0F\u4E0E\u6587\u98CE\u57FA\u8C03"];
22975
23238
  const \u6682\u5B9AParts = [];
22976
- for (const title of ["\u53D9\u4E8B\u65B9\u5F0F\u4E0E\u6587\u98CE\u57FA\u8C03"]) {
23239
+ for (const title of contractTitles) {
22977
23240
  const section = \u5951\u7EA6Body === null ? null : extractSection(\u5951\u7EA6Body, title);
22978
23241
  if (section !== null && section !== "") \u6682\u5B9AParts.push(`### \u5951\u7EA6\xB7${title}
22979
23242
 
22980
23243
  ${section}`);
22981
23244
  }
22982
23245
  const \u5377\u7EB2\u53C2\u8003 = findVolumeReferences(\u5377\u7EB2, input.\u5377, input.\u7AE0\u540D);
23246
+ if (input.\u8D28\u91CF\u6A21\u5F0F === true) {
23247
+ const \u9AA8\u67B6Raw = readText8(bookRoot, paths.\u6545\u4E8B\u9AA8\u67B6());
23248
+ const \u9AA8\u67B6Body = \u9AA8\u67B6Raw === null ? "" : bodyOnly(\u9AA8\u67B6Raw);
23249
+ if (\u9AA8\u67B6Body !== "") {
23250
+ \u6682\u5B9AParts.push(`### \u4E0A\u5C42\xB7\u6545\u4E8B\u9AA8\u67B6\u6458\u8981
23251
+
23252
+ ${Array.from(\u9AA8\u67B6Body).slice(0, 1800).join("")}`);
23253
+ }
23254
+ const \u5E03\u5C40Raw = readText8(bookRoot, paths.\u5206\u5377\u5E03\u5C40());
23255
+ const \u5E03\u5C40Body = \u5E03\u5C40Raw === null ? "" : bodyOnly(\u5E03\u5C40Raw);
23256
+ if (\u5E03\u5C40Body !== "") {
23257
+ \u6682\u5B9AParts.push(`### \u4E0A\u5C42\xB7\u5206\u5377\u5E03\u5C40\u6458\u8981
23258
+
23259
+ ${Array.from(\u5E03\u5C40Body).slice(0, 1500).join("")}`);
23260
+ }
23261
+ if (\u5377\u7EB2\u53C2\u8003.\u81EA\u52A8\u5B9A\u4F4D === "\u672A\u547D\u4E2D" && \u5377\u7EB2Body !== null && \u5377\u7EB2Body !== "") {
23262
+ \u6682\u5B9AParts.push(`### \u672C\u5377\u5927\u7EB2\u6982\u89C8\uFF08\u672A\u9010\u7AE0\u7CBE\u786E\u70B9\u540D\uFF0C\u4F9B\u8FDE\u7EED\u63A8\u6F14\u53C2\u8003\uFF09
23263
+
23264
+ ${Array.from(\u5377\u7EB2Body).slice(0, 2200).join("")}`);
23265
+ }
23266
+ }
22983
23267
  const \u6682\u5B9A\u884C = [\u5951\u7EA6Body ?? "", \u5377\u7EB2Body ?? ""].join("\n").split("\n").filter((line) => line.includes("\u3014\u6682\u5B9A\u3015") || line.includes("\u3014\u7559\u767D\u3015"));
22984
23268
  if (\u6682\u5B9A\u884C.length > 0) \u6682\u5B9AParts.push(["### \u6682\u5B9A\u4E0E\u7559\u767D", "", ...\u6682\u5B9A\u884C].join("\n"));
22985
23269
  const \u6682\u5B9ABody = \u6682\u5B9AParts.join("\n\n") || "\uFF08\u65E0\uFF09";
@@ -23014,7 +23298,8 @@ ${section}`);
23014
23298
  \u6587\u98CE\u95EE\u9898.push(`${indexRel}:\u672C\u4E66\u8BB0\u5FC6\u7D22\u5F15\u7F3A\u5931\uFF0C\u5DF2\u4FDD\u7559\u53EF\u8BFB\u6587\u98CE\u6761\u76EE\uFF0C\u4E0D\u80FD\u89C6\u4E3A\u5B8C\u6574\u6750\u6599`);
23015
23299
  }
23016
23300
  const named = styleEntries.filter((e) => outlineBody.includes(`[[${e.\u540D\u79F0}]]`) || outlineBody.includes(e.\u540D\u79F0));
23017
- const chosen = named.length > 0 ? named : styleEntries.slice(-\u6750\u6599\u9884\u7B97.\u6587\u98CE\u6700\u8FD1\u6761\u6570);
23301
+ const recentStyles = styleEntries.slice(-budget.\u6587\u98CE\u6700\u8FD1\u6761\u6570);
23302
+ const chosen = input.\u8D28\u91CF\u6A21\u5F0F === true ? [...named, ...recentStyles.filter((e) => !named.some((n2) => n2.\u540D\u79F0 === e.\u540D\u79F0))] : named.length > 0 ? named : recentStyles;
23018
23303
  const selected = chosen;
23019
23304
  if (selected.length > 0) {
23020
23305
  \u6587\u98CEParts.push(["### \u6761\u76EE\u6B63\u6587", "", ...selected.map((e) => `## ${e.\u540D\u79F0}
@@ -29272,37 +29557,23 @@ var savePolicy = `\u3010\u8349\u7A3F\u4FDD\u5B58\u3011
29272
29557
  \u5B8C\u6574\u7A3F\u6B63\u6587\u6709\u4FEE\u6539\u65F6\u53E6\u5B58\u7A3F<N+1>.md\uFF0C\u7236\u7248\u672C\u6307\u5411\u6E90\u7A3F\uFF0C\u65E7\u5B8C\u6574\u7A3F\u6B63\u6587\u4E0D\u8986\u76D6\u3002
29273
29558
  \u4EC5\u4E3A\u6B63\u786E\u4EA4\u4ED8\u800C\u8C03\u6574\u89D2\u8272\u3001\u9009\u5B9A\u6807\u8BB0\u65F6\uFF0C\u4FDD\u7559\u6B63\u6587\u53CA\u5176\u4F59\u5143\u6570\u636E\uFF0C\u4E0D\u4F2A\u9020\u65B0\u7248\u672C\u3002
29274
29559
  \u62A5\u544A\u51C6\u786E\u4EA4\u4ED8\u8DEF\u5F84\u3001\u65B0\u5199\u6216\u590D\u7528\u3001\u7EDF\u8BA1\u6765\u6E90\u53CA\u672A\u51B3\u9879\u3002\u7BC7\u5E45\u8FBE\u6807\u4E0D\u4EE3\u8868\u5BA1\u8BFB\u901A\u8FC7\u3002`;
29275
- var longWriteRecovery = `\u3010\u957F\u6587\u672C\u5199\u5165\u6062\u590D\u3011
29276
- \u65B0\u6587\u4EF6\u8D85\u8FC7 400 \u5B57\u7B26\u65F6\uFF0C\u9996\u6B21\u4FDD\u5B58\u5C31\u5206\u6BB5\u3002
29277
- \u5148 read \u76EE\u6807\uFF0C\u786E\u8BA4\u4E0D\u5B58\u5728\uFF1B\u5176\u4ED6\u8BFB\u53D6\u9519\u8BEF\u5373\u505C\u3002
29278
- \u5148 write \u6B63\u786E\u5934\u90E8\u548C\u672C\u4EFB\u52A1\u521B\u5EFA\u7684\u552F\u4E00\u968F\u673A ASCII \u5C3E\u6807\u8BB0\u3002
29279
- \u9996\u6B21 write \u7684\u5185\u5BB9\u4E5F\u9650 400 \u5B57\u7B26\u3002
29280
- \u6BCF\u6B21 edit \u53EA\u66FF\u6362\u5C3E\u6807\u8BB0\uFF0Cnew_string \u542B\u6807\u8BB0\u9650 400 \u5B57\u7B26\u3002
29281
- \u6BCF\u6BB5\u6210\u529F\u540E\u624D\u63D0\u4EA4\u4E0B\u4E00\u6BB5\uFF0C\u4E0D\u5E76\u884C\u6539\u540C\u4E00\u6587\u4EF6\u3002
29282
- \u672B\u6BB5\u4E5F\u9650 400 \u5B57\u7B26\uFF0C\u66FF\u6362\u65F6\u79FB\u9664\u6807\u8BB0\u3002
29283
- read \u6587\u4EF6\u672B\u5C3E\uFF0C\u786E\u8BA4\u6807\u8BB0\u5DF2\u79FB\u9664\u3001\u4EA4\u4ED8\u5B8C\u6574\u3002
29284
- \u9519\u8BEF\u4FE1\u606F\uFF1AUnterminated string in JSON\u3002
29285
- \u9519\u8BEF\u4FE1\u606F\uFF1AMalformed response\u3002
29286
- \u51FA\u73B0\u4EFB\u4E00\u9519\u8BEF\uFF0C\u5148 read \u76EE\u6807\u3002
29287
- \u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u76F8\u540C\u7684\u957F\u53C2\u6570\u3002
29288
- edit \u5931\u8D25\u540E\u5148 read\uFF0C\u53EA\u5728\u5DF2\u5199\u672B\u5C3E\u4E0E\u672C\u4EFB\u52A1\u6807\u8BB0\u660E\u786E\u65F6\u7EED\u5199\u3002
29289
- \u76EE\u6807\u5DF2\u6709\u5185\u5BB9\u4E14\u65E0\u672C\u4EFB\u52A1\u6807\u8BB0\u65F6\uFF0C\u505C\u6B62\u5E76\u62A5\u544A\u4E3B\u63A7\u3002
29290
- \u65E0\u6CD5\u786E\u8BA4\u7EED\u5199\u8FB9\u754C\u65F6\uFF0C\u505C\u6B62\uFF1B\u4E0D\u5F97\u8986\u76D6\u6216\u731C\u8865\u3002
29291
- \u6B64\u65B9\u6CD5\u4EC5\u6784\u5EFA\u65B0\u6587\u672C\uFF0C\u4E0D\u6539\u5DF2\u6709\u6B63\u6587\u3002`;
29560
+ var longWriteRecovery = `\u3010\u957F\u6587\u672C\u5199\u5165\u4E0E\u5F02\u5E38\u5904\u7406\u3011
29561
+ \u6B63\u5E38\u5199\u5165\u8BF7\u76F4\u63A5\u4E00\u6B21\u63D0\u4EA4\u5B8C\u6574\u6B63\u6587\u6216\u5267\u672C\uFF0C\u4FDD\u6301\u53D9\u4E8B\u8BED\u6D41\u3001\u5BF9\u767D\u4EA4\u950B\u4E0E\u620F\u5267\u8282\u594F\u7684\u5B8C\u6574\u8FDE\u8D2F\uFF0C\u4E0D\u8981\u4EBA\u4E3A\u5207\u6210 400 \u5B57\u788E\u7247\u3002
29562
+ \u4EC5\u5F53\u5DE5\u5177\u8FD4\u56DE\u300CUnterminated string in JSON\u300D\u6216\u300CMalformed response\u300D\u7B49\u53C2\u6570\u622A\u65AD\u9519\u8BEF\u65F6\uFF0C\u624D\u542F\u7528\u5206\u6BB5\u6062\u590D\uFF1A
29563
+ 1. \u5148 read \u76EE\u6807\uFF0C\u786E\u8BA4\u5DF2\u5199\u672B\u5C3E\u4E0E\u8FB9\u754C\uFF1B\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u76F8\u540C\u7684\u957F\u53C2\u6570\u3002
29564
+ 2. \u6309\u81EA\u7136\u573A\u666F\u6216\u5927\u6BB5\u843D\u987A\u5E8F\u8FFD\u52A0\uFF08\u4F7F\u7528\u968F\u673A ASCII \u5C3E\u6807\u8BB0\u5E76\u9010\u6BB5 edit \u66FF\u6362\uFF09\uFF0C\u672B\u6BB5\u79FB\u9664\u6807\u8BB0\u5E76\u56DE\u8BFB\u786E\u8BA4\u5B8C\u6574\u3002
29565
+ 3. \u76EE\u6807\u5DF2\u6709\u5185\u5BB9\u4E14\u7EED\u5199\u8FB9\u754C\u4E0D\u660E\u65F6\u505C\u6B62\u5E76\u62A5\u544A\u4E3B\u63A7\uFF0C\u4E0D\u5F97\u8986\u76D6\u6216\u731C\u8865\u3002`;
29292
29566
  var rolePolicies = {
29293
29567
  drafting: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6B63\u6587\u8D77\u8349\u3011
29294
- \u7B2C\u4E00\u4EFD\u5B8C\u6574\u7A3F\u4EE5\u5DF2\u786E\u8BA4\u7684\u5951\u7EA6\u7BC7\u5E45\u533A\u95F4\u4E3A\u76EE\u6807\u3002\u672A\u914D\u7F6E\u3001\u672A\u786E\u8BA4\u6216\u914D\u7F6E\u9519\u8BEF\u65F6\u5982\u5B9E\u8BF4\u660E\uFF0C\u4E0D\u7F16\u9020\u8303\u56F4\u3002
29295
- \u4E2D\u9014\u68C0\u67E5\u53EF\u9009\uFF1A\u5728\u81EA\u7136\u60C5\u8282\u8282\u70B9\u4FDD\u5B58\u540C\u76EE\u5F55\u7A3F<N>.\u8D77\u8349\u4E2D.txt\uFF0C\u4F9D\u636E\u7D2F\u8BA1\u5B57\u6570\u7EE7\u7EED\u5199\u4F5C\u3002
29296
- \u6682\u5B58\u4E0D\u662F\u5B8C\u6574\u7A3F\uFF0C\u4E0D\u5360\u7A3F\u53F7\uFF0C\u672A\u8FBE\u5230\u6574\u7AE0\u4E0B\u9650\u4E0D\u662F\u95EE\u9898\u3002\u6682\u5B58\u4FDD\u7559\u4F9B\u6062\u590D\uFF0C\u4E0D\u5F53\u6210\u6B63\u5F0F\u4EA4\u4ED8\u3002
29568
+ \u56F4\u7ED5\u4EBA\u7269\u6B32\u671B\u3001\u538B\u529B\u5347\u7EA7\u4E0E\u5177\u4F53\u573A\u666F\u7EC6\u8282\u5C55\u5F00\u53D9\u4E8B\uFF0C\u7528\u52A8\u4F5C\u3001\u5BF9\u767D\u548C\u611F\u5B98\u7EC6\u8282\u628A\u620F\u6F14\u51FA\u6765\uFF0C\u907F\u514D\u7A7A\u6D1E\u6982\u62EC\u548C\u5957\u8BDD\u5806\u780C\u3002
29569
+ \u7B2C\u4E00\u4EFD\u5B8C\u6574\u7A3F\u4EE5\u5951\u7EA6\u7BC7\u5E45\u533A\u95F4\u4E3A\u76EE\u6807\uFF1B\u672A\u914D\u7F6E\u6216\u672A\u786E\u8BA4\u65F6\u4E0D\u7F16\u9020\u8303\u56F4\u3002
29570
+ \u4E2D\u9014\u68C0\u67E5\u53EF\u9009\uFF1A\u9700\u8981\u65F6\u53EF\u4FDD\u5B58\u540C\u76EE\u5F55\u7A3F<N>.\u8D77\u8349\u4E2D.txt\u3002
29297
29571
  \u5B8C\u6210\u540E\u4FDD\u5B58\u6B63\u5F0F\u7A3F<N>.md\uFF0C\u5E26\u9F50 frontmatter \u548C\u300C## \u8349\u7A3F\u5019\u9009\u4E8B\u5B9E\u300D\u3002
29298
- \u9996\u4EFD\u5B8C\u6574\u7A3F\u5728\u8303\u56F4\u5185\u5C31\u7ED3\u675F\uFF1B\u8D8A\u754C\u6700\u591A\u505A\u4E00\u8F6E\u4EC5\u4E3A\u7BC7\u5E45\u7684\u8C03\u6574\uFF0C\u4E5F\u53EF\u4FDD\u7559\u73B0\u7A3F\u8BF4\u660E\u539F\u56E0\u3002
29299
- \u8C03\u6574\u4FDD\u62A4\u5DF2\u786E\u8BA4\u4E8B\u5B9E\u3001\u91CD\u8981\u9009\u62E9\u3001\u4EA4\u6613\u6761\u4EF6\u3001\u52A8\u4F5C\u56E0\u679C\u548C\u6709\u529F\u80FD\u7EC6\u8282\uFF0C\u4E0D\u673A\u68B0\u586B\u5145\u6216\u5220\u53E5\u3002
29300
- \u4FEE\u6B63\u7A3F\u65B0\u589E\u7A3F\u53F7\u548C\u7236\u7248\u672C\uFF0C\u6700\u7EC8\u4EA4\u4ED8\u7A3F\u9009\u5B9A\u4E3A true\uFF0C\u65E7\u9009\u5B9A\u6807\u8BB0\u6E05\u4E3A false\u3002
29301
- \u6700\u591A\u4E00\u6B21\u7BC7\u5E45\u8C03\u6574\u540E\u7ED3\u675F\u8D77\u8349\uFF0C\u4ECD\u8D8A\u754C\u4E5F\u5982\u5B9E\u4EA4\u63A5\u3002\u65E7\u7A3F\u6807\u8BB0\u7F16\u8F91\u7684\u56DE\u6267\u4E0D\u89E6\u53D1\u989D\u5916\u8C03\u6574\u3002`,
29572
+ \u9996\u4EFD\u5B8C\u6574\u7A3F\u5728\u8303\u56F4\u5185\u5C31\u7ED3\u675F\uFF1B\u8D8A\u754C\u65F6\u6700\u591A\u4E00\u6B21\u7BC7\u5E45\u8C03\u6574\uFF08\u4FDD\u62A4\u56E0\u679C\u3001\u5BF9\u767D\u950B\u8292\u4E0E\u6838\u5FC3\u7EC6\u8282\uFF0C\u4E0D\u673A\u68B0\u6CE8\u6C34\u6216\u786C\u5220\uFF09\uFF0C\u4ECD\u8D8A\u754C\u5982\u5B9E\u4EA4\u63A5\u3002`,
29302
29573
  polish: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6DA6\u8272\u3011
29303
- \u53EA\u6539\u6709\u660E\u786E\u95EE\u9898\u7684\u8868\u8FBE\uFF0C\u4FDD\u62A4\u4E8B\u5B9E\u3001\u542B\u4E49\u3001\u4FE1\u606F\u6765\u6E90\u548C\u786E\u5B9A\u7A0B\u5EA6\uFF0C\u4E0D\u4E3A\u63A5\u8FD1\u76EE\u6807\u5B57\u6570\u8FFD\u52A0\u538B\u7F29\u3002
29304
- \u5019\u9009\u4E8B\u5B9E\u6BB5\u539F\u6837\u4FDD\u7559\u3002\u6BCF\u6279\u6709\u5B9E\u9645\u4FEE\u6539\u624D\u7559\u65B0\u7A3F\uFF0C\u65E0\u4FEE\u6539\u590D\u7528\u6E90\u7A3F\u5E76\u7EE7\u7EED\u68C0\u67E5\u540E\u7EED\u6279\u6B21\uFF0C\u4E0D\u5F3A\u5236\u751F\u6210\u4E24\u7248\u3002
29305
- \u4FDD\u771F\u98CE\u9669\u4E0D\u6E05\u7A7A\uFF1B\u6709\u672A\u51B3\u98CE\u9669\u7684\u7A3F\u4E0D\u63D0\u5347\u4E3A\u5F85\u5BA1\u7A3F\u3002\u5177\u4F53\u6279\u6B21\u4E0E\u4EA4\u4ED8\u5143\u6570\u636E\u6309\u4E3B\u63A7\u63D0\u4F9B\u7684\u5DE5\u5E8F\u6267\u884C\u3002`,
29574
+ \u4FDD\u62A4\u6838\u5FC3\u5267\u60C5\u4E8B\u5B9E\u3001\u56E0\u679C\u903B\u8F91\u4E0E\u4FE1\u606F\u8FB9\u754C\u4E0D\u53D8\uFF1B\u5728\u6B64\u524D\u63D0\u4E0B\uFF0C\u653E\u624B\u63D0\u5347\u753B\u9762\u8D28\u611F\u3001\u53E5\u6BB5\u547C\u5438\u3001\u5BF9\u767D\u6F5C\u53F0\u8BCD\u4E0E\u4EBA\u7269\u58F0\u97F3\u8FA8\u8BC6\u5EA6\u3002
29575
+ \u628A\u5E72\u762A\u7684\u6982\u62EC\u5F0F\u53D9\u8FF0\u3001\u91CD\u590D\u5FC3\u7406\u72EC\u767D\u548C\u5178\u578B AI \u5957\u8BDD\u6539\u5199\u4E3A\u751F\u52A8\u514B\u5236\u7684\u52A8\u4F5C\u4E0E\u4EA4\u950B\uFF0C\u4F46\u4FDD\u7559\u539F\u7A3F\u771F\u6B63\u6709\u6548\u7684\u72EC\u7279\u8868\u8FBE\u3002
29576
+ \u5019\u9009\u4E8B\u5B9E\u6BB5\u539F\u6837\u4FDD\u7559\u3002\u6BCF\u6279\u6709\u5B9E\u9645\u4FEE\u6539\u624D\u7559\u65B0\u7248\uFF0C\u65E0\u95EE\u9898\u5219\u590D\u7528\u6E90\u7A3F\u5E76\u7EE7\u7EED\u68C0\u67E5\u540E\u7EED\u6279\u6B21\u3002\u5177\u4F53\u6279\u6B21\u4E0E\u4EA4\u4ED8\u5143\u6570\u636E\u6309\u4E3B\u63A7\u63D0\u4F9B\u7684\u5DE5\u5E8F\u6267\u884C\u3002`,
29306
29577
  revision: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6539\u7A3F\u3011
29307
29578
  \u6539\u7A3F\u53EA\u6309\u5DF2\u6388\u6743\u5904\u7F6E\u8FD4\u56DE\u6574\u7A3F\u65B0\u7248\u53CA\u300C\u53D1\u73B0\u9879\u2192\u6539\u52A8\u300D\u6620\u5C04\uFF0C\u4E0D\u76F4\u63A5\u5199\u6587\u4EF6\uFF0C\u7531\u4E3B\u63A7\u6279\u91CF\u843D\u5B9E\u3002`,
29308
29579
  review: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u5BA1\u8BFB\u3011
@@ -29310,21 +29581,17 @@ var rolePolicies = {
29310
29581
  settle: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6C89\u6DC0\u5BF9\u8D26\u3011
29311
29582
  \u6C89\u6DC0\u5BF9\u8D26\u53EA\u8BFB\u4E0D\u5199\uFF0C\u6309\u4EFB\u52A1\u5E95\u672C\u8FD4\u56DE\u5019\u9009\uFF1B\u8BA1\u5212\u3001\u63A8\u6D4B\u548C\u4EBA\u7269\u8BC1\u8A00\u4E0D\u5192\u5145\u5DF2\u53D1\u751F\u4E8B\u5B9E\uFF0C\u4E0D\u76F4\u63A5\u4FEE\u6539\u8D26\u672C\u3002`,
29312
29583
  screenplay: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u7535\u5F71\u5267\u672C\u6539\u7F16\u3011
29313
- \u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u7535\u5F71\u5267\u672C\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002
29314
- \u5267\u672C\u6309\u6545\u4E8B\u7A3F\u3001\u5206\u573A\u5927\u7EB2\u3001\u5267\u672C\u8349\u7A3F\u3001\u5BA1\u8BFB\u56DB\u6B65\u63A8\u8FDB\u3002
29315
- \u4E2D\u95F4\u7A3F\u653E\u8349\u7A3F\u533A/\u5267\u672C/\uFF0C\u6587\u4EF6\u540D\u4F9D\u6B21\u4E3A\u6545\u4E8B\u7A3F.md\u3001\u5206\u573A\u5927\u7EB2.md\u3001\u5267\u672C\u8349\u7A3F.md\u3002
29316
- \u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u7535\u5F71/\u5267\u672C.md\u3002
29317
- \u573A\u666F\u6807\u9898\u5199\u4E3A\u201C\u573A\u53F7 INT./EXT. \u5730\u70B9 - \u65F6\u95F4\u201D\u3002
29318
- \u52A8\u4F5C\u884C\u7528\u73B0\u5728\u65F6\uFF0C\u53EA\u5199\u53EF\u89C1\u6216\u53EF\u542C\u5185\u5BB9\u3002
29584
+ \u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u7535\u5F71\u5267\u672C\u65F6\u8D70\u672C\u7BA1\u7EBF\uFF0C\u6CE8\u91CD\u89C6\u89C9\u5316\u52A8\u4F5C\u3001\u6F5C\u53F0\u8BCD\u5BF9\u767D\u4E0E\u4E09\u5E55\u620F\u5267\u5F20\u529B\u3002
29585
+ \u5267\u672C\u6309\u6545\u4E8B\u7A3F\u3001\u5206\u573A\u5927\u7EB2\u3001\u5267\u672C\u8349\u7A3F\u3001\u5BA1\u8BFB\u63A8\u8FDB\uFF1B\u4E2D\u95F4\u7A3F\u653E\u8349\u7A3F\u533A/\u5267\u672C/\uFF0C\u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u7535\u5F71/\u5267\u672C.md\u3002
29586
+ \u573A\u666F\u6807\u9898\u5199\u4E3A\u201C\u573A\u53F7 INT./EXT. \u5730\u70B9 - \u65F6\u95F4\u201D\uFF0C\u52A8\u4F5C\u884C\u7528\u73B0\u5728\u65F6\uFF0C\u53EA\u5199\u53EF\u89C1\u6216\u53EF\u542C\u5185\u5BB9\u3002
29319
29587
  \u89D2\u8272\u540D\u5168\u5927\u5199\uFF0C\u540E\u63A5\u53F0\u8BCD\u548C\u62EC\u53F7\u63D0\u793A\uFF1B\u505C\u987F\u53EA\u7528 (pause)\uFF0C\u4E0D\u7528 (beat)\u3002
29320
29588
  \u97F3\u6548\u5199\u8FDB\u52A8\u4F5C\u884C\uFF0C\u4E0D\u7528 SFX:/MUSIC: \u72EC\u5360\u884C\uFF1B\u97F3\u4E50\u4E0E\u955C\u5934\u63D0\u793A\u4E0D\u8FDB\u7F16\u5267\u5C42\u3002
29321
- \u5BA1\u8BFB\u4E09\u6A21\u5757\u8DD1\u5B8C\u518D\u5B9A\u7A3F\uFF0C\u4EFB\u4E00\u9AD8\u7EA7\u522B\u53D1\u73B0\u9879\u5373\u963B\u65AD\uFF0C\u4E0D\u628A\u5F85\u5199\u5360\u4F4D\u5F53\u6210\u7A3F\u3002`,
29589
+ \u5BA1\u8BFB\u65E0\u9AD8\u7EA7\u522B\u963B\u65AD\u9879\u4E14\u65E0\u3010\u5F85\u5199\u3011\u5360\u4F4D\u540E\u518D\u5B9A\u7A3F\u3002`,
29322
29590
  shortdrama: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u77ED\u5267\u7BA1\u7EBF\u3011
29323
- \u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002\u6309\u5206\u96C6\u94A9\u5B50/\u723D\u70B9\u5927\u7EB2\u2192\u5355\u96C6\u5267\u672C\u2192\u5BA1\u8BFB\u8D70\uFF0C\u6BCF\u96C6\u4E00\u4E2A\u6838\u5FC3\u60F3\u6CD5\uFF1B\u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u77ED\u5267/\u96C6001.md \u8D77\u3002
29324
- \u7AD6\u5C4F\u4E0E\u6A2A\u5C4F\u8282\u594F\u5206\u5F00\uFF0C\u4E0D\u6DF7\u7528\u3002\u7AD6\u5C4F\u6BCF\u96C6 60\u2013120 \u79D2\uFF0C5 \u79D2\u5185\u8D77\u51B2\u7A81\u3002
29325
- \u6BCF 20\u201330 \u79D2\u5B89\u6392\u53CD\u8F6C\uFF0C\u7ED3\u5C3E 5\u201310 \u79D2\u7559\u60AC\u5FF5\u3002
29326
- \u6A2A\u5C4F\u6BCF\u96C6 10\u201320 \u5206\u949F\uFF0C\u5177\u5907\u8D77\u627F\u8F6C\u5408\u3002
29327
- \u6BCF\u96C6\u8DD1\u8282\u62CD\u68C0\u67E5\u5668\uFF0C\u4E0D\u901A\u8FC7\u7684\u96C6\u4E0D\u8FDB\u5B9A\u7A3F\u3002\u53F0\u8BCD\u8981\u77ED\uFF08\u4E00\u884C\u7EA6 <12 \u5B57\uFF09\uFF0C\u53F0\u8BCD\u5373\u884C\u52A8\u3002`
29591
+ \u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002\u4E00\u96C6\u56F4\u7ED5\u4E00\u4E2A\u6838\u5FC3\u60F3\u6CD5\u5199\u900F\uFF0C\u4EBA\u7269\u4EA4\u950B\u950B\u5229\u3001\u6F5C\u53F0\u8BCD\u4E0E\u53CD\u5E94\u5177\u4F53\uFF0C\u4E0D\u8981\u5199\u6210\u5E72\u762A\u53E3\u53F7\u3002
29592
+ \u7AD6\u5C4F 60\u2013120 \u79D2\uFF082\u20134 \u573A\uFF0C3\u20135 \u79D2\u8FDB\u51B2\u7A81\u3001\u7ED3\u5C3E\u7559\u94A9\u5B50\uFF09\uFF1B\u6A2A\u5C4F 10\u201320 \u5206\u949F\uFF08\u6CE8\u91CD\u8D77\u627F\u8F6C\u5408\u3001\u94FA\u57AB\u4E0E\u60C5\u7EEA\u5F20\u529B\uFF09\u3002
29593
+ \u4F7F\u7528\u65B0\u7248\u5206\u955C\u683C\u5F0F\uFF08\u573A\u5934\u300C\u96C6-\u573A \u65E5/\u591C\uFF0F\u5185/\u5916 \u5730\u70B9\u300D\u3001\u4EBA\u7269\u884C\u3001\u573A\u666F\u73AF\u5883\u3001\u25B3\u3010\u955C\u5934NN\uFF5C\u2026\u3011\u3001\u5BF9\u767D\u3001\u6DE1\u51FA\u4E0E\u8282\u62CD\u8868\uFF09\uFF0C\u505C\u987F\u53EA\u7528 (pause)\u3002
29594
+ \u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u77ED\u5267/\u96C6001.md \u8D77\uFF0C\u6BCF\u96C6\u8FC7\u8282\u62CD\u68C0\u67E5\u4E0E\u5BA1\u8BFB\u540E\u5165\u6863\u3002`
29328
29595
  };
29329
29596
  function workerPolicyFor(role2) {
29330
29597
  const canWrite = role2 === "drafting" || role2 === "polish" || role2 === "screenplay" || role2 === "shortdrama";
@@ -29404,18 +29671,22 @@ var NOVEL_TOOL_NAMES = [
29404
29671
  "novel_note_pending",
29405
29672
  "novel_get_book_progress",
29406
29673
  "novel_editor_suggest",
29407
- // 影视剧扩展(muse-dev 阶段 2 电影剧本 / 阶段 3 短剧)
29674
+ "novel_authorize_batch",
29675
+ // 影视剧扩展(muse-dev 阶段 2 电影剧本 / 阶段 3 短剧 + 半自动落盘/定稿闭环)
29408
29676
  "novel_screenplay_check_contract",
29409
29677
  "novel_screenplay_validate_story",
29410
29678
  "novel_screenplay_build_outline",
29411
29679
  "novel_screenplay_build_draft",
29412
29680
  "novel_screenplay_review",
29413
29681
  "novel_screenplay_render",
29682
+ "novel_screenplay_save_draft",
29683
+ "novel_screenplay_settle",
29414
29684
  "novel_shortdrama_plan_episodes",
29415
29685
  "novel_shortdrama_render_episode",
29416
29686
  "novel_shortdrama_check_beats",
29417
29687
  "novel_shortdrama_review_episode",
29418
- "novel_shortdrama_settle_episode"
29688
+ "novel_shortdrama_settle_episode",
29689
+ "novel_shortdrama_save_script"
29419
29690
  ];
29420
29691
  var WRITING_DELEGATE_TOOL = "novel_delegate";
29421
29692
  var NOVEL_CONDITIONAL_TOOL_NAMES = [WRITING_DELEGATE_TOOL];
@@ -29680,7 +29951,7 @@ function attachStatusToAgent(agentCtx, deps) {
29680
29951
  }
29681
29952
  }
29682
29953
 
29683
- // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-prompt@0.2.2-rc.1_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-ll_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
29954
+ // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
29684
29955
  import { Service } from "@deepseek-ai/cordis";
29685
29956
 
29686
29957
  // ../../node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.2-rc.1_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-scope/lib/index.js
@@ -29900,7 +30171,7 @@ function scopeTarget(base, key) {
29900
30171
  return carrier;
29901
30172
  }
29902
30173
 
29903
- // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-prompt@0.2.2-rc.1_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-ll_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
30174
+ // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
29904
30175
  var SECTION_ORDERS = {
29905
30176
  HARNESS_IDENTITY: -1e3,
29906
30177
  DEPLOYMENT_PERSONA_PREFIX: 0,
@@ -30426,6 +30697,124 @@ function createReferenceTools(deps) {
30426
30697
  ].map(actionTool);
30427
30698
  }
30428
30699
 
30700
+ // src/screenplay-tools.ts
30701
+ import * as fs55 from "node:fs";
30702
+ import * as path67 from "node:path";
30703
+
30704
+ // src/approval-snapshot.ts
30705
+ import * as fs53 from "node:fs";
30706
+ import * as path65 from "node:path";
30707
+ import { createHash as createHash19 } from "node:crypto";
30708
+ function captureApprovalFiles(root, relatives, request) {
30709
+ try {
30710
+ const files = [];
30711
+ const visit = (relative12) => {
30712
+ const target = authorDocumentPath(root, relative12);
30713
+ try {
30714
+ const stat = fs53.statSync(target);
30715
+ if (stat.isDirectory()) {
30716
+ const names = fs53.readdirSync(target).sort();
30717
+ files.push([relative12 + "/", JSON.stringify(names)]);
30718
+ for (const name3 of names) visit(path65.posix.join(relative12, name3));
30719
+ } else if (stat.isFile()) {
30720
+ files.push([relative12, createHash19("sha256").update(fs53.readFileSync(target)).digest("hex")]);
30721
+ } else throw new Error(`\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1A${relative12}`);
30722
+ } catch (error) {
30723
+ if (error.code === "ENOENT") {
30724
+ files.push([relative12, null]);
30725
+ return;
30726
+ }
30727
+ throw error;
30728
+ }
30729
+ };
30730
+ for (const relative12 of [...new Set(relatives)].sort()) visit(relative12);
30731
+ return { ok: true, fingerprint: createHash19("sha256").update(JSON.stringify([canonicalizePath(root), request, files])).digest("hex") };
30732
+ } catch (error) {
30733
+ return { ok: false, reason: `\u65E0\u6CD5\u6838\u5BF9\u4F5C\u8005\u88C1\u51B3\u5185\u5BB9\uFF1A${error instanceof Error ? error.message : String(error)}` };
30734
+ }
30735
+ }
30736
+
30737
+ // src/tool-failure.ts
30738
+ var NEXT_STEP = {
30739
+ "invalid-argument": "\u6309 reason \u4FEE\u6B63\u53C2\u6570\u540E\u91CD\u65B0\u8C03\u7528\u3002",
30740
+ "book-not-found": "\u8C03\u7528 novel_select_book \u6838\u5BF9\u4E66\u76EE\u548C\u4E66id\uFF0C\u518D\u91CD\u65B0\u8C03\u7528\u3002",
30741
+ "book-locked": "\u7B49\u51E0\u79D2\u540E\u91CD\u8BD5\u4E00\u6B21\u3002\u4ECD\u7136\u5931\u8D25\u65F6\uFF0C\u8BF7\u4F5C\u8005\u68C0\u67E5\u662F\u5426\u5F00\u7740\u5176\u4ED6\u5199\u4F5C\u7A97\u53E3\u3002",
30742
+ "lock-interrupted": "\u7B49 30 \u79D2\u540E\u91CD\u8BD5\u4E00\u6B21\u3002\u786E\u8BA4\u6301\u6709\u8FDB\u7A0B\u9000\u51FA\u7684 acquire.lock \u4F1A\u81EA\u52A8\u56DE\u6536\uFF1B\u5F52\u5C5E\u4E0D\u660E\u65F6\uFF0C\u8BF7\u4F5C\u8005\u6838\u5BF9\u5E76\u786E\u8BA4\u6CA1\u6709\u5176\u4ED6\u5199\u4F5C\u7A97\u53E3\u540E\u518D\u6E05\u7406\u3002",
30743
+ "runtime-link": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u8BF7\u4F5C\u8005\u6838\u5BF9 reason \u4E2D\u7684\u8FD0\u884C\u8DEF\u5F84\uFF0C\u4FDD\u7559\u8BC1\u636E\uFF0C\u4E0D\u8981\u7528\u94FE\u63A5\u66FF\u4EE3\u4E66\u4ED3\u8FD0\u884C\u76EE\u5F55\u3002",
30744
+ "transaction-conflict": "\u5148\u628A\u9694\u79BB\u4E8B\u52A1\u7684\u5907\u4EFD\u548C\u5F53\u524D\u6587\u4EF6\u5448\u62A5\u4F5C\u8005\u3002\u5904\u7406\u51B2\u7A81\u540E\u518D\u5199\u5165\uFF0C\u76EE\u6807\u672A\u77E5\u65F6\u6682\u505C\u6240\u6709\u5199\u5165\u3002",
30745
+ "author-declined": "\u4E0D\u8981\u91CD\u65B0\u8C03\u7528\u672C\u5DE5\u5177\u3002\u5148\u95EE\u4F5C\u8005\u8981\u6539\u4EC0\u4E48\uFF0C\u518D\u6309\u56DE\u7B54\u56DE\u5230\u5BF9\u5E94\u8282\u70B9\u3002",
30746
+ "author-cancelled": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u7B49\u4F5C\u8005\u660E\u786E\u6279\u51C6\u540E\uFF0C\u518D\u8C03\u7528\u672C\u5DE5\u5177\u3002",
30747
+ "approval-stale": "\u65E7\u6279\u51C6\u5DF2\u5931\u6548\u3002\u91CD\u65B0\u5448\u62A5\u4F5C\u8005\uFF0C\u83B7\u5F97\u65B0\u7684\u6279\u51C6\u540E\u518D\u8C03\u7528\u3002",
30748
+ "source-conflict": "\u4E0D\u8981\u7528\u76F8\u540C\u53C2\u6570\u91CD\u8BD5\u3002\u628A\u51B2\u7A81\u539F\u6587\u5448\u62A5\u4F5C\u8005\uFF0C\u7531\u4F5C\u8005\u51B3\u5B9A\u4FDD\u7559\u54EA\u4E00\u4EFD\u3002",
30749
+ "parse-error": "\u6309 reason \u6307\u51FA\u7684\u4F4D\u7F6E\u4FEE\u6B63\u5185\u5BB9\uFF0C\u518D\u91CD\u65B0\u8C03\u7528\u4E00\u6B21\u3002\u4ECD\u7136\u5931\u8D25\u65F6\uFF0C\u628A reason \u539F\u6587\u544A\u8BC9\u4F5C\u8005\u3002",
30750
+ "host-unavailable": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u8BF7\u4F5C\u8005\u91CD\u542F\u5DE5\u4F5C\u53F0\uFF0C\u6216\u6838\u5BF9 DSH \u7248\u672C\u662F\u5426\u4E0E\u63D2\u4EF6\u914D\u5957\u3002",
30751
+ "partial-commit": "\u6587\u4EF6\u5DF2\u5199\u5165\u4F46\u8FD8\u6CA1\u6709\u63D0\u4EA4\u3002\u7528\u76F8\u540C\u53C2\u6570\u91CD\u65B0\u8C03\u7528\u672C\u5DE5\u5177\u5373\u53EF\u8865\u63D0\u4EA4\u3002",
30752
+ internal: "\u4E0D\u8981\u7528\u76F8\u540C\u53C2\u6570\u53CD\u590D\u91CD\u8BD5\u3002\u628A reason \u539F\u6587\u544A\u8BC9\u4F5C\u8005\u3002"
30753
+ };
30754
+ function toolFailure(code, reason, next = NEXT_STEP[code]) {
30755
+ return { ok: false, code, reason, next };
30756
+ }
30757
+ function notApproved(reason) {
30758
+ return /取消|abort/i.test(reason) ? toolFailure("author-cancelled", `\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF08${reason}\uFF09\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165`) : toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A${reason}`);
30759
+ }
30760
+ function errorText3(error) {
30761
+ return error instanceof Error ? error.message : String(error);
30762
+ }
30763
+ function expectedFailure(error) {
30764
+ const seen = /* @__PURE__ */ new Set();
30765
+ for (let current = error; current instanceof Error && !seen.has(current); current = current.cause) {
30766
+ seen.add(current);
30767
+ if (current instanceof BookLockError || current instanceof TransactionConflictError) return toolFailure(current.code, errorText3(error));
30768
+ if (current instanceof SettlementParseError) return toolFailure("parse-error", errorText3(error));
30769
+ }
30770
+ return void 0;
30771
+ }
30772
+ function failureFrom(error, prefix = "") {
30773
+ const known = expectedFailure(error);
30774
+ const reason = `${prefix}${errorText3(error)}`;
30775
+ return known === void 0 ? toolFailure(classifyReason(reason), reason) : { ...known, reason };
30776
+ }
30777
+ var RULES2 = [
30778
+ ["lock-interrupted", /锁获取曾中断|acquire\.lock/],
30779
+ ["book-locked", /书仓写入锁定中|书仓.*锁定/],
30780
+ ["partial-commit", /提交失败|未形成提交|已落盘但未提交/],
30781
+ ["author-declined", /未获作者批准|作者.{0,4}(驳回|拒绝)/],
30782
+ ["author-cancelled", /裁决.{0,2}取消|作者关闭了裁决|作者已取消/],
30783
+ ["approval-stale", /等待作者裁决期间|旧批准/],
30784
+ ["source-conflict", /冲突|已隔离|只增不改|已被另行修改/],
30785
+ ["host-unavailable", /裁决窗口|工作范围未就绪|未配置|不可用|尚未就绪/],
30786
+ ["book-not-found", /书id|bookId|书目/],
30787
+ ["parse-error", /解析失败|未分类正文|无法解析|第 \d+ 行:/],
30788
+ ["invalid-argument", /必须|不能为空|不得|非法|不合法|必填|为空|缺少|不存在|过长|超过|不支持|须/]
30789
+ ];
30790
+ function classifyReason(reason) {
30791
+ for (const [code, pattern2] of RULES2) if (pattern2.test(reason)) return code;
30792
+ return "internal";
30793
+ }
30794
+ function normalizeFailure(result) {
30795
+ if (result === null || typeof result !== "object") return result;
30796
+ const value = result;
30797
+ if (value["ok"] !== false) return result;
30798
+ let reason = typeof value["reason"] === "string" ? value["reason"] : void 0;
30799
+ if (reason === void 0 || reason.trim() === "") {
30800
+ reason = chineseReason(value["\u539F\u56E0"]) ?? chineseReason(value["\u95EE\u9898"]);
30801
+ }
30802
+ if (reason === void 0 || reason.trim() === "") return result;
30803
+ const known = typeof value["code"] === "string" && value["code"] in NEXT_STEP ? value["code"] : void 0;
30804
+ const code = typeof value["code"] === "string" ? value["code"] : classifyReason(reason);
30805
+ const next = typeof value["next"] === "string" && value["next"] !== "" ? value["next"] : NEXT_STEP[known ?? (code in NEXT_STEP ? code : classifyReason(reason))];
30806
+ return { ...value, reason, code, next };
30807
+ }
30808
+ function chineseReason(field) {
30809
+ if (typeof field === "string" && field.trim() !== "") return field;
30810
+ if (Array.isArray(field) && field.length > 0) return field.map(String).join("\uFF1B");
30811
+ return void 0;
30812
+ }
30813
+ var FAILURE_FIELDS = {
30814
+ code: { type: "string", description: "\u5931\u8D25\u7C7B\u522B\uFF08\u5982 invalid-argument\u3001book-locked\u3001author-declined\uFF09\uFF0C\u6210\u529F\u65F6\u4E0D\u8FD4\u56DE" },
30815
+ next: { type: "string", description: "\u5931\u8D25\u540E\u7684\u4E0B\u4E00\u6B65\uFF0C\u6210\u529F\u65F6\u4E0D\u8FD4\u56DE" }
30816
+ };
30817
+
30429
30818
  // ../review/src/finding.ts
30430
30819
  function makeFinding(partial) {
30431
30820
  const \u5904\u7F6E\u72B6\u6001 = partial.\u5904\u7F6E\u72B6\u6001 ?? "\u5F85\u5904\u7406";
@@ -30656,8 +31045,8 @@ function registerDefaultChecks() {
30656
31045
  }
30657
31046
 
30658
31047
  // ../review/src/run.ts
30659
- import * as fs53 from "node:fs";
30660
- import * as path65 from "node:path";
31048
+ import * as fs54 from "node:fs";
31049
+ import * as path66 from "node:path";
30661
31050
 
30662
31051
  // ../review/src/film-drama.ts
30663
31052
  var \u5267\u672C\u5BF9\u767D\u5BA1\u8BFB\u540D = "\u5267\u672C\u5BF9\u767D\u5BA1\u8BFB";
@@ -30862,7 +31251,7 @@ function computeEpisodeFindings(input) {
30862
31251
  // ../review/src/run.ts
30863
31252
  function readText11(root, rel) {
30864
31253
  try {
30865
- return fs53.readFileSync(path65.join(root, rel), "utf-8");
31254
+ return fs54.readFileSync(path66.join(root, rel), "utf-8");
30866
31255
  } catch {
30867
31256
  return null;
30868
31257
  }
@@ -31321,12 +31710,12 @@ function createScreenplayTools(deps = {}) {
31321
31710
  },
31322
31711
  render: (_args, value) => renderOutput(value)
31323
31712
  },
31324
- execute: (args) => {
31713
+ execute: (args, exec) => {
31325
31714
  let \u5E02\u573A = enumArg(args, "\u5E02\u573A");
31326
31715
  let \u8F93\u51FA\u5F62\u6001 = enumArg(args, "\u8F93\u51FA\u5F62\u6001");
31327
31716
  const bookId2 = enumArg(args, "bookId");
31328
31717
  if (bookId2 !== void 0 && deps.bookRootOfBookId !== void 0 && deps.readContractFields !== void 0) {
31329
- const root = deps.bookRootOfBookId(bookId2);
31718
+ const root = deps.bookRootOfBookId(bookId2, exec?.agent);
31330
31719
  const fields = root === void 0 ? void 0 : deps.readContractFields(root);
31331
31720
  if (typeof fields?.\u5E02\u573A === "string") \u5E02\u573A = fields.\u5E02\u573A;
31332
31721
  if (typeof fields?.\u8F93\u51FA\u5F62\u6001 === "string") \u8F93\u51FA\u5F62\u6001 = fields.\u8F93\u51FA\u5F62\u6001;
@@ -31529,129 +31918,234 @@ function createScreenplayTools(deps = {}) {
31529
31918
  \u539F\u56E0: []
31530
31919
  };
31531
31920
  }
31532
- }
31533
- ];
31534
- }
31535
-
31536
- // src/shortdrama-tools.ts
31537
- import * as fs55 from "node:fs";
31538
- import * as path67 from "node:path";
31539
-
31540
- // src/approval-snapshot.ts
31541
- import * as fs54 from "node:fs";
31542
- import * as path66 from "node:path";
31543
- import { createHash as createHash19 } from "node:crypto";
31544
- function captureApprovalFiles(root, relatives, request) {
31545
- try {
31546
- const files = [];
31547
- const visit = (relative12) => {
31548
- const target = authorDocumentPath(root, relative12);
31549
- try {
31550
- const stat = fs54.statSync(target);
31551
- if (stat.isDirectory()) {
31552
- const names = fs54.readdirSync(target).sort();
31553
- files.push([relative12 + "/", JSON.stringify(names)]);
31554
- for (const name3 of names) visit(path66.posix.join(relative12, name3));
31555
- } else if (stat.isFile()) {
31556
- files.push([relative12, createHash19("sha256").update(fs54.readFileSync(target)).digest("hex")]);
31557
- } else throw new Error(`\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1A${relative12}`);
31558
- } catch (error) {
31559
- if (error.code === "ENOENT") {
31560
- files.push([relative12, null]);
31561
- return;
31921
+ },
31922
+ {
31923
+ name: "novel_screenplay_save_draft",
31924
+ description: "\u4FDD\u5B58\u7535\u5F71\u5267\u672C\u8349\u7A3F\u533A\u6587\u4EF6\uFF08\u6545\u4E8B\u7A3F.md / \u5206\u573A\u5927\u7EB2.md / \u5267\u672C\u8349\u7A3F.md\uFF09\u5230\u8349\u7A3F\u533A/\u5267\u672C/\uFF0C\u6821\u9A8C\u7ED3\u6784\u540E\u539F\u5B50\u843D\u76D8\u5E76\u8BFB\u56DE\u6838\u9A8C\uFF0C\u514D\u53BB\u5206\u6BB5\u624B\u5199\u7F16\u8F91\u3002",
31925
+ parameters: {
31926
+ type: "object",
31927
+ properties: {
31928
+ bookId: { type: "string", description: "\u5F53\u524D\u7535\u5F71\u5267\u672C\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" },
31929
+ \u7C7B\u578B: { type: "string", enum: ["\u6545\u4E8B\u7A3F", "\u5206\u573A\u5927\u7EB2", "\u5267\u672C\u8349\u7A3F"], description: "\u8349\u7A3F\u5DE5\u4EF6\u7C7B\u578B" },
31930
+ \u6B63\u6587: { type: "string", description: "\u5B8C\u6574 Markdown \u6B63\u6587" }
31931
+ },
31932
+ required: ["bookId", "\u7C7B\u578B", "\u6B63\u6587"]
31933
+ },
31934
+ output: {
31935
+ schema: {
31936
+ type: "object",
31937
+ properties: {
31938
+ ok: { type: "boolean" },
31939
+ path: { type: "string" },
31940
+ saved: { type: "boolean" },
31941
+ \u8B66\u544A: { type: "array", items: { type: "string" } },
31942
+ message: { type: "string" },
31943
+ reason: { type: "string" }
31944
+ },
31945
+ required: ["ok"]
31946
+ },
31947
+ render: (_args, value) => renderOutput(value)
31948
+ },
31949
+ execute: async (args, exec) => {
31950
+ const bookId2 = enumArg(args, "bookId");
31951
+ if (!bookId2 || !deps.bookRootOfBookId) return toolFailure("book-not-found", "bookId \u5FC5\u586B\uFF0C\u8BF7\u5148\u6838\u5BF9\u5F53\u524D\u4E66\u76EE\u3002");
31952
+ const bookRoot = deps.bookRootOfBookId(bookId2, exec?.agent);
31953
+ if (!bookRoot) return toolFailure("book-not-found", `\u4E66id\u4E0D\u5B58\u5728\u6216\u4E0D\u552F\u4E00\uFF1A${bookId2}`);
31954
+ if (readExistingContract(bookRoot).fields["\u8F93\u51FA\u5F62\u6001"] !== "\u7535\u5F71\u5267\u672C") {
31955
+ return toolFailure("invalid-argument", "\u4F5C\u54C1\u5951\u7EA6\u7684\u8F93\u51FA\u5F62\u6001\u5FC5\u987B\u662F\u7535\u5F71\u5267\u672C\uFF0C\u4E0D\u80FD\u4FDD\u5B58\u7535\u5F71\u5267\u672C\u8349\u7A3F\u3002");
31956
+ }
31957
+ if (!deps.writeDraft) return toolFailure("host-unavailable", "\u5F53\u524D\u73AF\u5883\u672A\u6302\u8F7D\u4E66\u4ED3\u5199\u5165\u901A\u9053\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u5267\u672C\u8349\u7A3F\u3002");
31958
+ const kind2 = enumArg(args, "\u7C7B\u578B");
31959
+ if (kind2 !== "\u6545\u4E8B\u7A3F" && kind2 !== "\u5206\u573A\u5927\u7EB2" && kind2 !== "\u5267\u672C\u8349\u7A3F") {
31960
+ return toolFailure("invalid-argument", `\u7C7B\u578B\u5FC5\u987B\u662F \u6545\u4E8B\u7A3F / \u5206\u573A\u5927\u7EB2 / \u5267\u672C\u8349\u7A3F\uFF08\u6536\u5230\uFF1A${String(args["\u7C7B\u578B"] ?? "\u672A\u4F20")}\uFF09`);
31961
+ }
31962
+ const content = textArg(args, "\u6B63\u6587");
31963
+ if (content.trim() === "") return toolFailure("invalid-argument", "\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A\u3002");
31964
+ const warnings = [];
31965
+ if (kind2 === "\u6545\u4E8B\u7A3F") {
31966
+ const parsed = parseStoryDraft(content);
31967
+ if (parsed.story === void 0) return { ...toolFailure("parse-error", `\u6545\u4E8B\u7A3F\u683C\u5F0F\u6709\u8BEF\uFF1A${parsed.problems.join("\uFF1B")}`), saved: false };
31968
+ const v = validateStoryDraft(parsed.story);
31969
+ if (v.errors.length > 0) return { ...toolFailure("parse-error", `\u6545\u4E8B\u7A3F\u6821\u9A8C\u5931\u8D25\uFF1A${v.errors.join("\uFF1B")}`), saved: false };
31970
+ warnings.push(...v.warnings);
31971
+ } else if (kind2 === "\u5206\u573A\u5927\u7EB2") {
31972
+ const parsed = parseSceneOutline(content);
31973
+ if (parsed.outline === void 0) return { ...toolFailure("parse-error", `\u5206\u573A\u5927\u7EB2\u683C\u5F0F\u6709\u8BEF\uFF1A${parsed.problems.join("\uFF1B")}`), saved: false };
31974
+ const v = validateSceneOutline(parsed.outline);
31975
+ if (v.errors.length > 0) return { ...toolFailure("parse-error", `\u5206\u573A\u5927\u7EB2\u6821\u9A8C\u5931\u8D25\uFF1A${v.errors.join("\uFF1B")}`), saved: false };
31976
+ warnings.push(...v.warnings);
31977
+ } else {
31978
+ const parsed = parseScreenplay(content);
31979
+ if (parsed.draft === void 0) return { ...toolFailure("parse-error", `\u5267\u672C\u8349\u7A3F\u683C\u5F0F\u6709\u8BEF\uFF1A${parsed.problems.join("\uFF1B")}`), saved: false };
31980
+ warnings.push(...validateScreenplay(parsed.draft).map((f) => `${f.\u6A21\u5757\u540D}\u3014${f.\u4E25\u91CD\u7A0B\u5EA6}\u3015${f.\u8BC1\u636E\u4F4D\u7F6E}\uFF1A${f.\u95EE\u9898\u8BF4\u660E}`));
31981
+ }
31982
+ const draftRel = `\u8349\u7A3F\u533A/\u5267\u672C/${kind2}.md`;
31983
+ const access = gateFileAccess(bookRoot, draftRel);
31984
+ if (!access.allow || access.zone !== "\u8349\u7A3F\u533A") {
31985
+ return { ...toolFailure("runtime-link", `\u5267\u672C\u8349\u7A3F\u76EE\u6807\u5FC5\u987B\u7559\u5728\u8349\u7A3F\u533A\uFF1A${access.allow ? draftRel : access.reason}`), saved: false };
31986
+ }
31987
+ const normalized = content.endsWith("\n") ? content : `${content}
31988
+ `;
31989
+ try {
31990
+ exec?.signal?.throwIfAborted();
31991
+ await deps.writeDraft(bookRoot, { relPath: draftRel, content: normalized }, exec);
31992
+ if (fs55.readFileSync(path67.join(bookRoot, draftRel), "utf8") !== normalized) {
31993
+ return { ...toolFailure("internal", "\u5267\u672C\u8349\u7A3F\u4FDD\u5B58\u540E\u8BFB\u56DE\u6B63\u6587\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u6838\u5BF9\u6587\u4EF6\u3002"), saved: false };
31994
+ }
31995
+ return { ok: true, path: draftRel, saved: true, \u8B66\u544A: warnings, message: `\u7535\u5F71\u5267\u672C\u300C${kind2}\u300D\u5DF2\u4FDD\u5B58\u81F3 ${draftRel}\u3002` };
31996
+ } catch (error) {
31997
+ if (exec?.signal?.aborted) throw error;
31998
+ return { ...failureFrom(error, "\u4FDD\u5B58\u7535\u5F71\u5267\u672C\u8349\u7A3F\u5931\u8D25\uFF1A"), saved: false };
31562
31999
  }
31563
- throw error;
31564
32000
  }
31565
- };
31566
- for (const relative12 of [...new Set(relatives)].sort()) visit(relative12);
31567
- return { ok: true, fingerprint: createHash19("sha256").update(JSON.stringify([canonicalizePath(root), request, files])).digest("hex") };
31568
- } catch (error) {
31569
- return { ok: false, reason: `\u65E0\u6CD5\u6838\u5BF9\u4F5C\u8005\u88C1\u51B3\u5185\u5BB9\uFF1A${error instanceof Error ? error.message : String(error)}` };
31570
- }
31571
- }
31572
-
31573
- // src/tool-failure.ts
31574
- var NEXT_STEP = {
31575
- "invalid-argument": "\u6309 reason \u4FEE\u6B63\u53C2\u6570\u540E\u91CD\u65B0\u8C03\u7528\u3002",
31576
- "book-not-found": "\u8C03\u7528 novel_select_book \u6838\u5BF9\u4E66\u76EE\u548C\u4E66id\uFF0C\u518D\u91CD\u65B0\u8C03\u7528\u3002",
31577
- "book-locked": "\u7B49\u51E0\u79D2\u540E\u91CD\u8BD5\u4E00\u6B21\u3002\u4ECD\u7136\u5931\u8D25\u65F6\uFF0C\u8BF7\u4F5C\u8005\u68C0\u67E5\u662F\u5426\u5F00\u7740\u5176\u4ED6\u5199\u4F5C\u7A97\u53E3\u3002",
31578
- "lock-interrupted": "\u7B49 30 \u79D2\u540E\u91CD\u8BD5\u4E00\u6B21\u3002\u786E\u8BA4\u6301\u6709\u8FDB\u7A0B\u9000\u51FA\u7684 acquire.lock \u4F1A\u81EA\u52A8\u56DE\u6536\uFF1B\u5F52\u5C5E\u4E0D\u660E\u65F6\uFF0C\u8BF7\u4F5C\u8005\u6838\u5BF9\u5E76\u786E\u8BA4\u6CA1\u6709\u5176\u4ED6\u5199\u4F5C\u7A97\u53E3\u540E\u518D\u6E05\u7406\u3002",
31579
- "runtime-link": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u8BF7\u4F5C\u8005\u6838\u5BF9 reason \u4E2D\u7684\u8FD0\u884C\u8DEF\u5F84\uFF0C\u4FDD\u7559\u8BC1\u636E\uFF0C\u4E0D\u8981\u7528\u94FE\u63A5\u66FF\u4EE3\u4E66\u4ED3\u8FD0\u884C\u76EE\u5F55\u3002",
31580
- "transaction-conflict": "\u5148\u628A\u9694\u79BB\u4E8B\u52A1\u7684\u5907\u4EFD\u548C\u5F53\u524D\u6587\u4EF6\u5448\u62A5\u4F5C\u8005\u3002\u5904\u7406\u51B2\u7A81\u540E\u518D\u5199\u5165\uFF0C\u76EE\u6807\u672A\u77E5\u65F6\u6682\u505C\u6240\u6709\u5199\u5165\u3002",
31581
- "author-declined": "\u4E0D\u8981\u91CD\u65B0\u8C03\u7528\u672C\u5DE5\u5177\u3002\u5148\u95EE\u4F5C\u8005\u8981\u6539\u4EC0\u4E48\uFF0C\u518D\u6309\u56DE\u7B54\u56DE\u5230\u5BF9\u5E94\u8282\u70B9\u3002",
31582
- "author-cancelled": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u7B49\u4F5C\u8005\u660E\u786E\u6279\u51C6\u540E\uFF0C\u518D\u8C03\u7528\u672C\u5DE5\u5177\u3002",
31583
- "approval-stale": "\u65E7\u6279\u51C6\u5DF2\u5931\u6548\u3002\u91CD\u65B0\u5448\u62A5\u4F5C\u8005\uFF0C\u83B7\u5F97\u65B0\u7684\u6279\u51C6\u540E\u518D\u8C03\u7528\u3002",
31584
- "source-conflict": "\u4E0D\u8981\u7528\u76F8\u540C\u53C2\u6570\u91CD\u8BD5\u3002\u628A\u51B2\u7A81\u539F\u6587\u5448\u62A5\u4F5C\u8005\uFF0C\u7531\u4F5C\u8005\u51B3\u5B9A\u4FDD\u7559\u54EA\u4E00\u4EFD\u3002",
31585
- "parse-error": "\u6309 reason \u6307\u51FA\u7684\u4F4D\u7F6E\u4FEE\u6B63\u5185\u5BB9\uFF0C\u518D\u91CD\u65B0\u8C03\u7528\u4E00\u6B21\u3002\u4ECD\u7136\u5931\u8D25\u65F6\uFF0C\u628A reason \u539F\u6587\u544A\u8BC9\u4F5C\u8005\u3002",
31586
- "host-unavailable": "\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u8BF7\u4F5C\u8005\u91CD\u542F\u5DE5\u4F5C\u53F0\uFF0C\u6216\u6838\u5BF9 DSH \u7248\u672C\u662F\u5426\u4E0E\u63D2\u4EF6\u914D\u5957\u3002",
31587
- "partial-commit": "\u6587\u4EF6\u5DF2\u5199\u5165\u4F46\u8FD8\u6CA1\u6709\u63D0\u4EA4\u3002\u7528\u76F8\u540C\u53C2\u6570\u91CD\u65B0\u8C03\u7528\u672C\u5DE5\u5177\u5373\u53EF\u8865\u63D0\u4EA4\u3002",
31588
- internal: "\u4E0D\u8981\u7528\u76F8\u540C\u53C2\u6570\u53CD\u590D\u91CD\u8BD5\u3002\u628A reason \u539F\u6587\u544A\u8BC9\u4F5C\u8005\u3002"
31589
- };
31590
- function toolFailure(code, reason, next = NEXT_STEP[code]) {
31591
- return { ok: false, code, reason, next };
31592
- }
31593
- function notApproved(reason) {
31594
- return /取消|abort/i.test(reason) ? toolFailure("author-cancelled", `\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF08${reason}\uFF09\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165`) : toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A${reason}`);
31595
- }
31596
- function errorText3(error) {
31597
- return error instanceof Error ? error.message : String(error);
31598
- }
31599
- function expectedFailure(error) {
31600
- const seen = /* @__PURE__ */ new Set();
31601
- for (let current = error; current instanceof Error && !seen.has(current); current = current.cause) {
31602
- seen.add(current);
31603
- if (current instanceof BookLockError || current instanceof TransactionConflictError) return toolFailure(current.code, errorText3(error));
31604
- if (current instanceof SettlementParseError) return toolFailure("parse-error", errorText3(error));
31605
- }
31606
- return void 0;
31607
- }
31608
- function failureFrom(error, prefix = "") {
31609
- const known = expectedFailure(error);
31610
- const reason = `${prefix}${errorText3(error)}`;
31611
- return known === void 0 ? toolFailure(classifyReason(reason), reason) : { ...known, reason };
31612
- }
31613
- var RULES2 = [
31614
- ["lock-interrupted", /锁获取曾中断|acquire\.lock/],
31615
- ["book-locked", /书仓写入锁定中|书仓.*锁定/],
31616
- ["partial-commit", /提交失败|未形成提交|已落盘但未提交/],
31617
- ["author-declined", /未获作者批准|作者.{0,4}(驳回|拒绝)/],
31618
- ["author-cancelled", /裁决.{0,2}取消|作者关闭了裁决|作者已取消/],
31619
- ["approval-stale", /等待作者裁决期间|旧批准/],
31620
- ["source-conflict", /冲突|已隔离|只增不改|已被另行修改/],
31621
- ["host-unavailable", /裁决窗口|工作范围未就绪|未配置|不可用|尚未就绪/],
31622
- ["book-not-found", /书id|bookId|书目/],
31623
- ["parse-error", /解析失败|未分类正文|无法解析|第 \d+ 行:/],
31624
- ["invalid-argument", /必须|不能为空|不得|非法|不合法|必填|为空|缺少|不存在|过长|超过|不支持|须/]
31625
- ];
31626
- function classifyReason(reason) {
31627
- for (const [code, pattern2] of RULES2) if (pattern2.test(reason)) return code;
31628
- return "internal";
31629
- }
31630
- function normalizeFailure(result) {
31631
- if (result === null || typeof result !== "object") return result;
31632
- const value = result;
31633
- if (value["ok"] !== false) return result;
31634
- let reason = typeof value["reason"] === "string" ? value["reason"] : void 0;
31635
- if (reason === void 0 || reason.trim() === "") {
31636
- reason = chineseReason(value["\u539F\u56E0"]) ?? chineseReason(value["\u95EE\u9898"]);
31637
- }
31638
- if (reason === void 0 || reason.trim() === "") return result;
31639
- const known = typeof value["code"] === "string" && value["code"] in NEXT_STEP ? value["code"] : void 0;
31640
- const code = typeof value["code"] === "string" ? value["code"] : classifyReason(reason);
31641
- const next = typeof value["next"] === "string" && value["next"] !== "" ? value["next"] : NEXT_STEP[known ?? (code in NEXT_STEP ? code : classifyReason(reason))];
31642
- return { ...value, reason, code, next };
31643
- }
31644
- function chineseReason(field) {
31645
- if (typeof field === "string" && field.trim() !== "") return field;
31646
- if (Array.isArray(field) && field.length > 0) return field.map(String).join("\uFF1B");
31647
- return void 0;
32001
+ },
32002
+ {
32003
+ name: "novel_screenplay_settle",
32004
+ description: "\u7535\u5F71\u5267\u672C\u5B9A\u7A3F\u5165\u6863\uFF1A\u6821\u9A8C\u8349\u7A3F\u533A/\u5267\u672C/\u5267\u672C\u8349\u7A3F.md \u65E0\u9AD8\u7EA7\u522B\u963B\u65AD\u9879\u540E\uFF0C\u7ECF\u4F5C\u8005\u6279\u51C6\uFF08\u6216\u6279\u91CF\u6258\u7BA1\u6388\u6743\uFF09\u539F\u5B50\u5199\u5165\u771F\u6E90 \u5267\u672C/\u7535\u5F71/\u5267\u672C.md \u5E76\u6267\u884C\u5355\u6B21 ch: Git \u63D0\u4EA4\u3002",
32005
+ parameters: {
32006
+ type: "object",
32007
+ properties: {
32008
+ bookId: { type: "string", description: "\u5F53\u524D\u7535\u5F71\u5267\u672C\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" },
32009
+ summary: { type: "string", description: "\u63D0\u4EA4\u6458\u8981\uFF08\u5982 \u7535\u5F71\u5267\u672C\u5B9A\u7A3F\uFF09" },
32010
+ \u7247\u957F: { type: "string", enum: ["\u957F\u7247", "\u77ED\u7247"], description: "\u957F\u7247\u6216\u77ED\u7247\uFF0C\u9ED8\u8BA4 \u957F\u7247" }
32011
+ },
32012
+ required: ["bookId", "summary"]
32013
+ },
32014
+ output: {
32015
+ schema: {
32016
+ type: "object",
32017
+ properties: {
32018
+ ok: { type: "boolean" },
32019
+ path: { type: "string" },
32020
+ draftPath: { type: "string" },
32021
+ alreadyCommitted: { type: "boolean" },
32022
+ message: { type: "string" },
32023
+ reason: { type: "string" }
32024
+ },
32025
+ required: ["ok"]
32026
+ },
32027
+ render: (_args, value) => renderOutput(value)
32028
+ },
32029
+ execute: async (args, exec) => {
32030
+ const bookId2 = enumArg(args, "bookId");
32031
+ if (!bookId2 || !deps.bookRootOfBookId) return toolFailure("book-not-found", "bookId \u5FC5\u586B\uFF0C\u8BF7\u5148\u6838\u5BF9\u5F53\u524D\u4E66\u76EE\u3002");
32032
+ const bookRoot = deps.bookRootOfBookId(bookId2, exec?.agent);
32033
+ if (!bookRoot) return toolFailure("book-not-found", `\u4E66id\u4E0D\u5B58\u5728\u6216\u4E0D\u552F\u4E00\uFF1A${bookId2}`);
32034
+ if (readExistingContract(bookRoot).fields["\u8F93\u51FA\u5F62\u6001"] !== "\u7535\u5F71\u5267\u672C") {
32035
+ return toolFailure("invalid-argument", "\u4F5C\u54C1\u5951\u7EA6\u7684\u8F93\u51FA\u5F62\u6001\u5FC5\u987B\u662F\u7535\u5F71\u5267\u672C\uFF0C\u4E0D\u80FD\u8D70\u7535\u5F71\u5267\u672C\u5B9A\u7A3F\u3002");
32036
+ }
32037
+ const mode = deps.automationMode?.() ?? "manual";
32038
+ const batchMatch = mode !== "manual" ? deps.batchStore?.match(bookRoot, exec, "screenplay") : void 0;
32039
+ if (!batchMatch && !deps.askFn) return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002");
32040
+ const summary = textArg(args, "summary").trim();
32041
+ if (summary === "") return toolFailure("invalid-argument", "summary \u4E0D\u80FD\u4E3A\u7A7A\u3002");
32042
+ const draftRel = "\u8349\u7A3F\u533A/\u5267\u672C/\u5267\u672C\u8349\u7A3F.md";
32043
+ const outlineRel = "\u8349\u7A3F\u533A/\u5267\u672C/\u5206\u573A\u5927\u7EB2.md";
32044
+ const finalRel = screenplayFinalPath();
32045
+ let draftAbs;
32046
+ let finalAbs;
32047
+ try {
32048
+ draftAbs = authorDocumentPath(bookRoot, draftRel);
32049
+ finalAbs = authorDocumentPath(bookRoot, finalRel);
32050
+ } catch (error) {
32051
+ if (error instanceof AuthorDocumentError && error.code === "invalid-path") {
32052
+ return toolFailure("runtime-link", `\u5267\u672C\u8DEF\u5F84\u4E0D\u5F97\u7ECF\u8FC7\u76EE\u5F55\u94FE\u63A5\uFF1A${error.message}`);
32053
+ }
32054
+ return failureFrom(error, "\u5267\u672C\u8DEF\u5F84\u6821\u9A8C\u5931\u8D25\uFF1A");
32055
+ }
32056
+ let draftText;
32057
+ try {
32058
+ draftText = fs55.readFileSync(draftAbs, "utf8");
32059
+ } catch (error) {
32060
+ if (error.code === "ENOENT") {
32061
+ return toolFailure("invalid-argument", `\u5267\u672C\u8349\u7A3F\u4E0D\u5B58\u5728\uFF1A${draftRel}\uFF0C\u8BF7\u5148\u8C03\u7528 novel_screenplay_save_draft \u4FDD\u5B58\u5267\u672C\u8349\u7A3F\u3002`);
32062
+ }
32063
+ return failureFrom(error, "\u8BFB\u53D6\u5267\u672C\u8349\u7A3F\u5931\u8D25\uFF1A");
32064
+ }
32065
+ const parsedDraft = parseScreenplay(draftText);
32066
+ if (parsedDraft.draft === void 0) {
32067
+ return toolFailure("parse-error", `\u5267\u672C\u8349\u7A3F\u89E3\u6790\u5931\u8D25\uFF08${draftRel}\uFF09\uFF1A${parsedDraft.problems.join("\uFF1B")}`);
32068
+ }
32069
+ let outlineText = "";
32070
+ let parsedOutline;
32071
+ try {
32072
+ const outlineAbs = authorDocumentPath(bookRoot, outlineRel);
32073
+ if (fs55.existsSync(outlineAbs)) {
32074
+ outlineText = fs55.readFileSync(outlineAbs, "utf8");
32075
+ parsedOutline = parseSceneOutline(outlineText);
32076
+ }
32077
+ } catch {
32078
+ }
32079
+ const \u7247\u957F = enumArg(args, "\u7247\u957F") === "\u77ED\u7247" ? "\u77ED\u7247" : "\u957F\u7247";
32080
+ const review = computeScreenplayFindings({
32081
+ \u5267\u672C\u8349\u7A3F: parsedDraft.draft,
32082
+ \u5267\u672C\u8349\u7A3F\u6587\u672C: draftText,
32083
+ ...parsedOutline?.outline !== void 0 ? { \u5206\u573A\u5927\u7EB2: parsedOutline.outline, \u5206\u573A\u5927\u7EB2\u6587\u672C: outlineText } : {},
32084
+ \u7247\u957F
32085
+ });
32086
+ if (review.\u662F\u5426\u963B\u65AD) {
32087
+ const blockers = review.findings.filter((f) => f.\u4E25\u91CD\u7A0B\u5EA6 === "\u9AD8").map((f) => `${f.\u8BC1\u636E\u4F4D\u7F6E}\uFF1A${f.\u95EE\u9898\u8BF4\u660E}`).join("\uFF1B");
32088
+ return toolFailure("invalid-argument", `\u5267\u672C\u8349\u7A3F\u5B58\u5728\u963B\u65AD\u9879\uFF0C\u4E0D\u80FD\u5B9A\u7A3F\uFF1A${blockers}`);
32089
+ }
32090
+ if (fs55.existsSync(finalAbs) && fs55.readFileSync(finalAbs, "utf8") !== draftText) {
32091
+ return toolFailure("source-conflict", `\u5B9A\u7A3F\u53EA\u589E\u4E0D\u6539\uFF1A\u76EE\u6807 ${finalRel} \u5DF2\u5B58\u5728\u4E14\u5185\u5BB9\u4E0D\u540C\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002`);
32092
+ }
32093
+ const approvalFiles = [draftRel, finalRel, paths.\u5951\u7EA6()];
32094
+ const approvalReq = { bookId: bookId2, summary, \u7247\u957F };
32095
+ const before = captureApprovalFiles(bookRoot, approvalFiles, approvalReq);
32096
+ if (!before.ok) return before;
32097
+ let approvalRecordLine;
32098
+ if (batchMatch) {
32099
+ approvalRecordLine = `\u88C1\u51B3\u8BB0\u5F55\uFF1A${batchMatch.\u88C1\u51B3\u8BB0\u5F55}`;
32100
+ } else {
32101
+ const decision = await askAuthor(
32102
+ deps.askFn,
32103
+ "\u5B9A\u7A3F\u5165\u6863",
32104
+ { \u8303\u56F4: finalRel, \u6458\u8981: `\u7535\u5F71\u5267\u672C\u300A${parsedDraft.draft.\u6807\u9898}\u300B\uFF08${parsedDraft.draft.\u573A.length} \u573A\uFF0C\u4F30\u7B97 ${estimatePages(parsedDraft.draft)} \u9875\uFF09\uFF5C${summary}` },
32105
+ { agent: exec?.agent, signal: exec?.signal }
32106
+ );
32107
+ if (!decision.ok) return notApproved(decision.reason);
32108
+ if (exec?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002");
32109
+ if (decision.\u51B3\u5B9A !== "\u5DF2\u6279\u51C6") return toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005${decision.\u51B3\u5B9A}\uFF0C\u7535\u5F71\u5267\u672C\u6CA1\u6709\u5165\u6863\u3002`);
32110
+ approvalRecordLine = `\u88C1\u51B3\u8BB0\u5F55\uFF1A\u4F5C\u8005\u4E8E ${(/* @__PURE__ */ new Date()).toISOString()} \u6279\u51C6\u5B9A\u7A3F\u5165\u6863\uFF08kind=${decision.kind}, \u51B3\u5B9A=${decision.\u51B3\u5B9A}\uFF09`;
32111
+ }
32112
+ const provenance2 = deps.provenanceOf?.(exec, [finalRel]);
32113
+ return withBookWrite(bookRoot, () => {
32114
+ if (exec?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002");
32115
+ const after = captureApprovalFiles(bookRoot, approvalFiles, approvalReq);
32116
+ if (!after.ok || after.fingerprint !== before.fingerprint) {
32117
+ return toolFailure("approval-stale", "\u5267\u672C\u8349\u7A3F\u6216\u5951\u7EA6\u5728\u7B49\u5F85\u88C1\u51B3\u671F\u95F4\u5DF2\u53D8\u5316\uFF0C\u65E7\u6279\u51C6\u4E0D\u53EF\u4F7F\u7528\u3002");
32118
+ }
32119
+ const res = archiveChapter({
32120
+ bookRoot,
32121
+ files: [{ \u76EE\u6807: finalRel, \u5185\u5BB9: draftText, sha256: draftHashOf(draftText) }],
32122
+ summary,
32123
+ lines: [
32124
+ `\u7535\u5F71\u5267\u672C\u5B9A\u7A3F\uFF1A${parsedDraft.draft.\u6807\u9898}`,
32125
+ `\u6765\u6E90\u8349\u7A3F\uFF1A${draftRel}`,
32126
+ `\u573A\u6B21\uFF1A${parsedDraft.draft.\u573A.length} \u573A\uFF08${\u7247\u957F}\uFF09`,
32127
+ approvalRecordLine
32128
+ ],
32129
+ provenance: provenance2
32130
+ });
32131
+ if (!res.ok) return { ok: false, reason: res.reason };
32132
+ return {
32133
+ ok: true,
32134
+ path: finalRel,
32135
+ draftPath: draftRel,
32136
+ alreadyCommitted: res.alreadyCommitted === true,
32137
+ ...batchMatch ? { batchId: batchMatch.batchId } : {},
32138
+ message: res.alreadyCommitted === true ? `\u7535\u5F71\u5267\u672C\u6B64\u524D\u5DF2\u6838\u5B9E\u5B9A\u7A3F\u5165\u6863\uFF08${res.message}\uFF09\uFF1A${finalRel}` : `\u7535\u5F71\u5267\u672C\u5B9A\u7A3F\u5B8C\u6210\uFF08${res.message}\uFF09\uFF0C\u5DF2\u5165\u6863\uFF1A${res.dests.join("\u3001")}`
32139
+ };
32140
+ }, provenance2);
32141
+ }
32142
+ }
32143
+ ];
31648
32144
  }
31649
- var FAILURE_FIELDS = {
31650
- code: { type: "string", description: "\u5931\u8D25\u7C7B\u522B\uFF08\u5982 invalid-argument\u3001book-locked\u3001author-declined\uFF09\uFF0C\u6210\u529F\u65F6\u4E0D\u8FD4\u56DE" },
31651
- next: { type: "string", description: "\u5931\u8D25\u540E\u7684\u4E0B\u4E00\u6B65\uFF0C\u6210\u529F\u65F6\u4E0D\u8FD4\u56DE" }
31652
- };
31653
32145
 
31654
32146
  // src/shortdrama-tools.ts
32147
+ import * as fs56 from "node:fs";
32148
+ import * as path68 from "node:path";
31655
32149
  function asRecord2(value, name3) {
31656
32150
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
31657
32151
  throw new Error(`${name3} \u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61`);
@@ -31973,6 +32467,36 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31973
32467
  render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
31974
32468
  },
31975
32469
  execute: () => toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165")
32470
+ },
32471
+ {
32472
+ name: "novel_shortdrama_save_script",
32473
+ description: "\u76F4\u63A5\u4FDD\u5B58\u77ED\u5267\u5355\u96C6 Markdown \u5267\u672C\u6587\u672C\u5230\u8349\u7A3F\u533A\uFF08\u514D\u53BB\u9010\u53E5\u62FC\u5D4C\u5957 JSON\uFF0C\u63D0\u5347\u521B\u4F5C\u8FDE\u8D2F\u6027\uFF09\u3002\u6821\u9A8C\u683C\u5F0F\u4E0E\u96C6\u53F7\u540E\u539F\u5B50\u5199\u5165\u8349\u7A3F\u533A/\u5267\u672C/\u77ED\u5267/\u96C6NNN.md\uFF0C\u8BFB\u56DE\u6838\u9A8C\u4E00\u81F4\u8FD4\u56DE saved=true\u3002",
32474
+ parameters: {
32475
+ type: "object",
32476
+ properties: {
32477
+ bookId: { type: "string", description: "\u5F53\u524D\u77ED\u5267\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" },
32478
+ \u96C6: { type: "integer", description: "\u96C6\u53F7\uFF0C1\u2013100\uFF08\u987B\u4E0E\u6B63\u6587 # \u96C6NNN\uFF1A\u6807\u9898 \u4E00\u81F4\uFF09" },
32479
+ \u6B63\u6587: { type: "string", description: "\u7B26\u5408\u77ED\u5267\u683C\u5F0F\u7684\u5355\u96C6\u5B8C\u6574 Markdown \u5267\u672C\u6587\u672C\uFF08\u542B\u96C6\u5143\u6570\u636E\u30011-1 \u65E5\uFF0F\u5185 \u5730\u70B9 \u573A\u5934\u3001\u955C\u5934\u5757\u3001\u5BF9\u767D\u3001\u6DE1\u51FA\u4E0E\u8282\u62CD\u8868\uFF09" }
32480
+ },
32481
+ required: ["bookId", "\u96C6", "\u6B63\u6587"]
32482
+ },
32483
+ output: {
32484
+ schema: {
32485
+ type: "object",
32486
+ properties: {
32487
+ ok: { type: "boolean" },
32488
+ path: { type: "string" },
32489
+ finalPath: { type: "string" },
32490
+ saved: { type: "boolean" },
32491
+ \u8B66\u544A: { type: "array", items: { type: "string" } },
32492
+ message: { type: "string" },
32493
+ reason: { type: "string" }
32494
+ },
32495
+ required: ["ok"]
32496
+ },
32497
+ render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
32498
+ },
32499
+ execute: () => toolFailure("host-unavailable", "\u5F53\u524D\u73AF\u5883\u672A\u6302\u8F7D\u4E66\u4ED3\u5199\u5165\u901A\u9053\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u77ED\u5267\u8349\u7A3F")
31976
32500
  }
31977
32501
  ];
31978
32502
  function resolveShortdramaBook(deps, rawBookId, exec, action) {
@@ -31985,10 +32509,11 @@ function resolveShortdramaBook(deps, rawBookId, exec, action) {
31985
32509
  }
31986
32510
  return { ok: true, bookId: bookId2, bookRoot };
31987
32511
  }
31988
- function episodeReviewSummary(bookRoot, \u96C6, draftText) {
32512
+ function episodeReviewSummary(bookRoot, \u96C6, draftText, canonicalText) {
31989
32513
  const record4 = loadEpisodeReviewRecord(bookRoot, \u96C6);
31990
32514
  if (record4 === null) return `\u672A\u627E\u5230\u5BA1\u8BFB\u8BB0\u5F55\uFF08${paths.\u77ED\u5267\u5BA1\u6838\u8BB0\u5F55(\u96C6)}\uFF09`;
31991
- if (record4.\u5BA1\u7A3F\u54C8\u5E0C !== draftHashOf(draftText)) return "\u5BA1\u8BFB\u8BB0\u5F55\u5DF2\u8FC7\u671F\uFF08\u5F53\u524D\u8349\u7A3F\u4E0E\u88AB\u5BA1\u7A3F\u4EF6\u54C8\u5E0C\u4E0D\u4E00\u81F4\uFF09";
32515
+ const validHashes = [draftHashOf(draftText), ...canonicalText ? [draftHashOf(canonicalText)] : []];
32516
+ if (record4.\u5BA1\u7A3F\u54C8\u5E0C === void 0 || !validHashes.includes(record4.\u5BA1\u7A3F\u54C8\u5E0C)) return "\u5BA1\u8BFB\u8BB0\u5F55\u5DF2\u8FC7\u671F\uFF08\u5F53\u524D\u8349\u7A3F\u4E0E\u88AB\u5BA1\u7A3F\u4EF6\u54C8\u5E0C\u4E0D\u4E00\u81F4\uFF09";
31992
32517
  const pendingModules = Object.entries(record4.\u6A21\u5757).filter(([, state]) => !state.\u5B8C\u6210 || state.\u5F85\u56DE\u5199 === true).map(([name3]) => name3);
31993
32518
  if (!record4.\u5B8C\u6210 || Object.keys(record4.\u6A21\u5757).length === 0 || pendingModules.length > 0) {
31994
32519
  return pendingModules.length > 0 ? `\u5BA1\u8BFB\u672A\u5B8C\u6210\uFF08\u5F85\u5B8C\u6210\u6A21\u5757\uFF1A${pendingModules.join("\u3001")}\uFF09` : "\u5BA1\u8BFB\u5C1A\u672A\u5168\u90E8\u5B8C\u6210";
@@ -32008,7 +32533,6 @@ function resolvePlainBookFile(bookRoot, relPath) {
32008
32533
  }
32009
32534
  }
32010
32535
  async function executeSettleEpisode(deps, args, exec) {
32011
- if (!deps.askFn) return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
32012
32536
  let resolved;
32013
32537
  try {
32014
32538
  resolved = resolveShortdramaBook(deps, args["bookId"], exec, "\u8D70\u77ED\u5267\u5B9A\u7A3F");
@@ -32022,6 +32546,9 @@ async function executeSettleEpisode(deps, args, exec) {
32022
32546
  return toolFailure("invalid-argument", `\u96C6\u5FC5\u987B\u662F 1\u2013100 \u7684\u6574\u6570\uFF08\u6536\u5230\uFF1A${String(rawEp ?? "\u672A\u4F20")}\uFF09`);
32023
32547
  }
32024
32548
  const \u96C6 = rawEp;
32549
+ const mode = deps.automationMode?.() ?? "manual";
32550
+ const batchMatch = mode !== "manual" ? deps.batchStore?.match(bookRoot, exec, "episode", \u96C6) : void 0;
32551
+ if (!batchMatch && !deps.askFn) return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
32025
32552
  const summary = typeof args["summary"] === "string" ? args["summary"].trim() : "";
32026
32553
  if (summary === "") {
32027
32554
  return toolFailure("invalid-argument", "summary \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u586B\u5199\u672C\u6B21\u5B9A\u7A3F\u63D0\u4EA4\u6458\u8981\uFF08\u5982\u300C\u96C6001 \u5B9A\u7A3F\u300D\uFF09\u3002");
@@ -32038,10 +32565,10 @@ async function executeSettleEpisode(deps, args, exec) {
32038
32565
  if (!finalPathCheck.ok) return finalPathCheck;
32039
32566
  let draftText;
32040
32567
  try {
32041
- draftText = fs55.readFileSync(draftPathCheck.absPath, "utf8");
32568
+ draftText = fs56.readFileSync(draftPathCheck.absPath, "utf8");
32042
32569
  } catch (error) {
32043
32570
  if (error.code === "ENOENT") {
32044
- return toolFailure("invalid-argument", `\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u4E0D\u5B58\u5728\uFF1A${draftRel}\uFF0C\u8BF7\u5148\u8C03\u7528 novel_shortdrama_render_episode \u4FDD\u5B58\u8349\u7A3F\u3002`);
32571
+ return toolFailure("invalid-argument", `\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u4E0D\u5B58\u5728\uFF1A${draftRel}\uFF0C\u8BF7\u5148\u8C03\u7528 novel_shortdrama_render_episode \u6216 novel_shortdrama_save_script \u4FDD\u5B58\u8349\u7A3F\u3002`);
32045
32572
  }
32046
32573
  return failureFrom(error, "\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u8BFB\u53D6\u5931\u8D25\uFF1A");
32047
32574
  }
@@ -32052,8 +32579,8 @@ async function executeSettleEpisode(deps, args, exec) {
32052
32579
  if (parsed.episode.\u96C6 !== \u96C6) {
32053
32580
  return toolFailure("invalid-argument", `\u8349\u7A3F\u96C6\u53F7\u4E0D\u4E00\u81F4\uFF1A\u671F\u671B\u96C6${\u96C6}\uFF0C\u6587\u4EF6\u5185\u4E3A\u96C6${parsed.episode.\u96C6}`);
32054
32581
  }
32055
- if (fs55.existsSync(finalPathCheck.absPath)) {
32056
- const existingFinal = fs55.readFileSync(finalPathCheck.absPath, "utf8");
32582
+ if (fs56.existsSync(finalPathCheck.absPath)) {
32583
+ const existingFinal = fs56.readFileSync(finalPathCheck.absPath, "utf8");
32057
32584
  if (existingFinal !== draftText) {
32058
32585
  return toolFailure("source-conflict", `\u5B9A\u7A3F\u53EA\u589E\u4E0D\u6539\uFF1A\u76EE\u6807 ${finalRel} \u5DF2\u5B58\u5728\u4E14\u5185\u5BB9\u4E0D\u540C\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u3002\u8BF7\u628A\u51B2\u7A81\u5448\u62A5\u4F5C\u8005\u3002`);
32059
32586
  }
@@ -32063,22 +32590,28 @@ async function executeSettleEpisode(deps, args, exec) {
32063
32590
  const before = captureApprovalFiles(bookRoot, approvalFiles, approvalReq);
32064
32591
  if (!before.ok) return before;
32065
32592
  const ep = parsed.episode;
32066
- const reviewStatus = episodeReviewSummary(bookRoot, \u96C6, draftText);
32593
+ const reviewStatus = episodeReviewSummary(bookRoot, \u96C6, draftText, renderEpisodeScript(ep).\u5185\u5BB9);
32067
32594
  const approvalSummary = [
32068
32595
  `\u96C6${episodeNo(\u96C6)}\uFF1A${ep.\u6807\u9898}\uFF08${ep.\u753B\u5E45}\uFF0C${ep.\u65F6\u957F\u79D2} \u79D2\uFF0C${ep.\u573A\u666F.length} \u573A\uFF0C\u53F0\u8BCD ${totalDialogueChars(ep.\u573A\u666F)} \u5B57\uFF09`,
32069
32596
  `\u6765\u6E90\u8349\u7A3F\uFF1A${draftRel}`,
32070
32597
  `\u5BA1\u8BFB\u72B6\u6001\uFF1A${reviewStatus}`,
32071
32598
  `\u63D0\u4EA4\u6458\u8981\uFF1A${summary}`
32072
32599
  ].join("\uFF5C");
32073
- const decision = await askAuthor(
32074
- deps.askFn,
32075
- "\u5B9A\u7A3F\u5165\u6863",
32076
- { \u8303\u56F4: finalRel, \u6458\u8981: approvalSummary },
32077
- { agent: exec?.agent, signal: exec?.signal }
32078
- );
32079
- if (!decision.ok) return notApproved(decision.reason);
32080
- if (exec?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
32081
- if (decision.\u51B3\u5B9A !== "\u5DF2\u6279\u51C6") return toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005${decision.\u51B3\u5B9A}\uFF0C\u672C\u96C6\u6CA1\u6709\u5165\u6863`);
32600
+ let approvalRecordLine;
32601
+ if (batchMatch) {
32602
+ approvalRecordLine = `\u88C1\u51B3\u8BB0\u5F55\uFF1A${batchMatch.\u88C1\u51B3\u8BB0\u5F55}`;
32603
+ } else {
32604
+ const decision = await askAuthor(
32605
+ deps.askFn,
32606
+ "\u5B9A\u7A3F\u5165\u6863",
32607
+ { \u8303\u56F4: finalRel, \u6458\u8981: approvalSummary },
32608
+ { agent: exec?.agent, signal: exec?.signal }
32609
+ );
32610
+ if (!decision.ok) return notApproved(decision.reason);
32611
+ if (exec?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
32612
+ if (decision.\u51B3\u5B9A !== "\u5DF2\u6279\u51C6") return toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005${decision.\u51B3\u5B9A}\uFF0C\u672C\u96C6\u6CA1\u6709\u5165\u6863`);
32613
+ approvalRecordLine = `\u88C1\u51B3\u8BB0\u5F55\uFF1A\u4F5C\u8005\u4E8E ${(/* @__PURE__ */ new Date()).toISOString()} \u6279\u51C6\u5B9A\u7A3F\u5165\u6863\uFF08kind=${decision.kind}, \u51B3\u5B9A=${decision.\u51B3\u5B9A}\uFF09`;
32614
+ }
32082
32615
  const provenance2 = deps.provenanceOf?.(exec, [finalRel]);
32083
32616
  return withBookWrite(bookRoot, () => {
32084
32617
  if (exec?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
@@ -32099,7 +32632,7 @@ async function executeSettleEpisode(deps, args, exec) {
32099
32632
  `\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\uFF1A\u96C6${episodeNo(\u96C6)} ${ep.\u6807\u9898}`,
32100
32633
  `\u6765\u6E90\u8349\u7A3F\uFF1A${draftRel}`,
32101
32634
  `\u5BA1\u8BFB\u72B6\u6001\uFF1A${reviewStatus}`,
32102
- `\u88C1\u51B3\u8BB0\u5F55\uFF1A\u4F5C\u8005\u4E8E ${(/* @__PURE__ */ new Date()).toISOString()} \u6279\u51C6\u5B9A\u7A3F\u5165\u6863\uFF08kind=${decision.kind}, \u51B3\u5B9A=${decision.\u51B3\u5B9A}\uFF09`
32635
+ approvalRecordLine
32103
32636
  ],
32104
32637
  provenance: provenance2
32105
32638
  });
@@ -32112,6 +32645,7 @@ async function executeSettleEpisode(deps, args, exec) {
32112
32645
  \u6807\u9898: ep.\u6807\u9898,
32113
32646
  alreadyCommitted: res.alreadyCommitted === true,
32114
32647
  \u5BA1\u8BFB\u72B6\u6001: reviewStatus,
32648
+ ...batchMatch ? { batchId: batchMatch.batchId } : {},
32115
32649
  message: res.alreadyCommitted === true ? `\u672C\u96C6\u6B64\u524D\u5DF2\u6838\u5B9E\u5B9A\u7A3F\u5165\u6863\uFF08${res.message}\uFF09\uFF0C\u65E0\u9700\u91CD\u590D\u63D0\u4EA4\uFF1A${finalRel}` : `\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\u5B8C\u6210\uFF08${res.message}\uFF09\uFF0C\u5DF2\u5165\u6863\uFF1A${res.dests.join("\u3001")}`
32116
32650
  };
32117
32651
  } catch (error) {
@@ -32119,6 +32653,52 @@ async function executeSettleEpisode(deps, args, exec) {
32119
32653
  }
32120
32654
  }, provenance2);
32121
32655
  }
32656
+ async function executeSaveScript(deps, args, exec) {
32657
+ try {
32658
+ const resolved = resolveShortdramaBook(deps, args["bookId"], exec, "\u4FDD\u5B58\u77ED\u5267\u8349\u7A3F");
32659
+ if (!resolved.ok) return resolved;
32660
+ const { bookRoot: root } = resolved;
32661
+ const rawEp = args["\u96C6"];
32662
+ if (typeof rawEp !== "number" || !Number.isSafeInteger(rawEp) || rawEp < 1 || rawEp > 100) {
32663
+ return toolFailure("invalid-argument", `\u96C6\u5FC5\u987B\u662F 1\u2013100 \u7684\u6574\u6570\uFF08\u6536\u5230\uFF1A${String(rawEp ?? "\u672A\u4F20")}\uFF09`);
32664
+ }
32665
+ const rawText = typeof args["\u6B63\u6587"] === "string" ? args["\u6B63\u6587"].trim() : "";
32666
+ if (rawText === "") {
32667
+ return toolFailure("invalid-argument", "\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u4F20\u5165\u5355\u96C6\u5267\u672C Markdown \u5168\u6587\u3002");
32668
+ }
32669
+ const parsed = parseEpisodeScript(rawText);
32670
+ if (!parsed.ok || parsed.episode === void 0) {
32671
+ return { ...toolFailure("parse-error", `\u77ED\u5267\u683C\u5F0F\u6821\u9A8C\u672A\u901A\u8FC7\uFF1A${parsed.problems.join("\uFF1B")}`), saved: false };
32672
+ }
32673
+ if (parsed.episode.\u96C6 !== rawEp) {
32674
+ return { ...toolFailure("invalid-argument", `\u96C6\u53F7\u4E0D\u4E00\u81F4\uFF1A\u53C2\u6570\u4E3A\u96C6${rawEp}\uFF0C\u6B63\u6587\u6807\u9898\u4E3A\u96C6${parsed.episode.\u96C6}`), saved: false };
32675
+ }
32676
+ const rendered = renderEpisodeScript(parsed.episode);
32677
+ const draftPath = `\u8349\u7A3F\u533A/${rendered.path}`;
32678
+ const access = gateFileAccess(root, draftPath);
32679
+ if (!access.allow || access.zone !== "\u8349\u7A3F\u533A") {
32680
+ return toolFailure("runtime-link", `\u77ED\u5267\u8349\u7A3F\u76EE\u6807\u5FC5\u987B\u7559\u5728\u8349\u7A3F\u533A\uFF0C\u8BF7\u6838\u5BF9\u76EE\u5F55\u94FE\u63A5\uFF1A${access.allow ? draftPath : access.reason}`);
32681
+ }
32682
+ const normalized = rawText.endsWith("\n") ? rawText : `${rawText}
32683
+ `;
32684
+ exec?.signal?.throwIfAborted();
32685
+ await deps.writeDraft(root, { relPath: draftPath, content: normalized }, exec);
32686
+ if (fs56.readFileSync(path68.join(root, draftPath), "utf8") !== normalized) {
32687
+ return { ...toolFailure("internal", "\u77ED\u5267\u8349\u7A3F\u4FDD\u5B58\u540E\u8BFB\u56DE\u6B63\u6587\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u6838\u5BF9\u5B9E\u9645\u6587\u4EF6\u540E\u518D\u7EE7\u7EED\u3002"), saved: false };
32688
+ }
32689
+ return {
32690
+ ok: true,
32691
+ path: draftPath,
32692
+ finalPath: rendered.path,
32693
+ saved: true,
32694
+ \u8B66\u544A: rendered.\u8B66\u544A,
32695
+ message: `\u77ED\u5267\u7B2C ${rawEp} \u96C6\u8349\u7A3F\u5DF2\u4FDD\u5B58\uFF08${draftPath}\uFF09\uFF0C\u5C1A\u5F85\u8282\u62CD\u68C0\u67E5\u3001\u5BA1\u8BFB\u4E0E\u5B9A\u7A3F\u5165\u6863\u3002`
32696
+ };
32697
+ } catch (error) {
32698
+ if (exec?.signal?.aborted) throw error;
32699
+ return { ...failureFrom(error, "\u77ED\u5267\u8349\u7A3F\u4FDD\u5B58\u5931\u8D25\uFF1A"), saved: false };
32700
+ }
32701
+ }
32122
32702
  function createShortdramaTools(deps) {
32123
32703
  return SHORTDRAMA_TOOL_DEFINITIONS.map((tool) => {
32124
32704
  if (tool.name === "novel_shortdrama_settle_episode") {
@@ -32127,6 +32707,12 @@ function createShortdramaTools(deps) {
32127
32707
  execute: (args, exec) => executeSettleEpisode(deps, args, exec)
32128
32708
  };
32129
32709
  }
32710
+ if (tool.name === "novel_shortdrama_save_script") {
32711
+ return {
32712
+ ...tool,
32713
+ execute: (args, exec) => executeSaveScript(deps, args, exec)
32714
+ };
32715
+ }
32130
32716
  if (tool.name !== "novel_shortdrama_render_episode") return tool;
32131
32717
  const parameters = tool.parameters;
32132
32718
  return {
@@ -32148,7 +32734,7 @@ function createShortdramaTools(deps) {
32148
32734
  if (!access.allow || access.zone !== "\u8349\u7A3F\u533A") return toolFailure("runtime-link", `\u77ED\u5267\u8349\u7A3F\u76EE\u6807\u5FC5\u987B\u7559\u5728\u8349\u7A3F\u533A\uFF0C\u8BF7\u6838\u5BF9\u76EE\u5F55\u94FE\u63A5\uFF1A${access.allow ? draftPath : access.reason}`);
32149
32735
  exec?.signal?.throwIfAborted();
32150
32736
  await deps.writeDraft(root, { relPath: draftPath, content: rendered.\u5185\u5BB9 }, exec);
32151
- if (fs55.readFileSync(path67.join(root, draftPath), "utf8") !== rendered.\u5185\u5BB9) {
32737
+ if (fs56.readFileSync(path68.join(root, draftPath), "utf8") !== rendered.\u5185\u5BB9) {
32152
32738
  return { ...toolFailure("internal", "\u77ED\u5267\u8349\u7A3F\u4FDD\u5B58\u540E\u8BFB\u56DE\u6B63\u6587\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u6838\u5BF9\u5B9E\u9645\u6587\u4EF6\u540E\u518D\u7EE7\u7EED\u3002"), saved: false };
32153
32739
  }
32154
32740
  return { ok: true, ...rendered, path: draftPath, finalPath: rendered.path, saved: true, message: "\u77ED\u5267\u8349\u7A3F\u5DF2\u4FDD\u5B58\u5E76\u8BFB\u56DE\u6838\u9A8C\uFF0C\u5C1A\u5F85\u8282\u62CD\u68C0\u67E5\u3001\u5BA1\u8BFB\u548C\u4F5C\u8005\u786E\u8BA4\u3002" };
@@ -32161,6 +32747,90 @@ function createShortdramaTools(deps) {
32161
32747
  });
32162
32748
  }
32163
32749
 
32750
+ // src/batch-approval.ts
32751
+ import { randomUUID as randomUUID8 } from "node:crypto";
32752
+ var DEFAULT_BATCH_TTL_MS = 4 * 60 * 60 * 1e3;
32753
+ function sessionKeyOf(exec) {
32754
+ return exec?.agent?.session?.header?.id ?? exec?.agent?.id ?? "default-session";
32755
+ }
32756
+ function storeKey(bookRoot, sessionKey) {
32757
+ return `${canonicalizePath(bookRoot)}::${sessionKey}`;
32758
+ }
32759
+ var BatchApprovalStore = class {
32760
+ grants = /* @__PURE__ */ new Map();
32761
+ async authorize(params) {
32762
+ if (!params.askFn) {
32763
+ return { ok: false, code: "host-unavailable", reason: "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672A\u6388\u4E88\u6279\u91CF\u6258\u7BA1\u3002" };
32764
+ }
32765
+ const decision = await askAuthor(
32766
+ params.askFn,
32767
+ "\u5B9A\u7A3F\u5165\u6863",
32768
+ {
32769
+ \u8303\u56F4: `\u6279\u91CF\u6258\u7BA1\uFF08${params.\u8303\u56F4}\uFF09`,
32770
+ \u6458\u8981: params.\u6458\u8981
32771
+ },
32772
+ { agent: params.exec?.agent, signal: params.exec?.signal }
32773
+ );
32774
+ if (params.exec?.signal?.aborted) {
32775
+ return { ok: false, code: "author-cancelled", reason: "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u672A\u6388\u4E88\u6279\u91CF\u6258\u7BA1\u3002" };
32776
+ }
32777
+ if (!decision.ok) {
32778
+ return { ok: false, code: classifyReason(decision.reason), reason: decision.reason };
32779
+ }
32780
+ if (decision.\u51B3\u5B9A !== "\u5DF2\u6279\u51C6") {
32781
+ return { ok: false, code: "author-declined", reason: `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005${decision.\u51B3\u5B9A}\uFF0C\u672A\u6388\u4E88\u6279\u91CF\u6258\u7BA1\u3002` };
32782
+ }
32783
+ const sessionKey = sessionKeyOf(params.exec);
32784
+ const normalizedRoot = canonicalizePath(params.bookRoot);
32785
+ const now = Date.now();
32786
+ const grant = {
32787
+ batchId: randomUUID8().slice(0, 8),
32788
+ bookRoot: normalizedRoot,
32789
+ sessionKey,
32790
+ \u8303\u56F4: params.\u8303\u56F4,
32791
+ targetType: params.targetType ?? "all",
32792
+ ...params.\u8D77\u53F7 === void 0 ? {} : { \u8D77\u53F7: params.\u8D77\u53F7 },
32793
+ ...params.\u6B62\u53F7 === void 0 ? {} : { \u6B62\u53F7: params.\u6B62\u53F7 },
32794
+ authorizedAt: new Date(now).toISOString(),
32795
+ kind: decision.kind,
32796
+ \u51B3\u5B9A: decision.\u51B3\u5B9A,
32797
+ expiresAt: now + DEFAULT_BATCH_TTL_MS
32798
+ };
32799
+ this.grants.set(storeKey(normalizedRoot, sessionKey), grant);
32800
+ return { ok: true, grant };
32801
+ }
32802
+ match(bookRoot, exec, targetType, itemNumber) {
32803
+ const key = storeKey(bookRoot, sessionKeyOf(exec));
32804
+ const grant = this.grants.get(key);
32805
+ if (grant === void 0) return void 0;
32806
+ if (Date.now() > grant.expiresAt) {
32807
+ this.grants.delete(key);
32808
+ return void 0;
32809
+ }
32810
+ if (grant.targetType !== "all" && grant.targetType !== targetType) return void 0;
32811
+ if (itemNumber !== void 0) {
32812
+ if (grant.\u8D77\u53F7 !== void 0 && itemNumber < grant.\u8D77\u53F7) return void 0;
32813
+ if (grant.\u6B62\u53F7 !== void 0 && itemNumber > grant.\u6B62\u53F7) return void 0;
32814
+ }
32815
+ return {
32816
+ batchId: grant.batchId,
32817
+ \u8303\u56F4: grant.\u8303\u56F4,
32818
+ \u88C1\u51B3\u8BB0\u5F55: `\u4F5C\u8005\u4E8E ${grant.authorizedAt} \u6279\u91CF\u6279\u51C6\u5B9A\u7A3F\u6258\u7BA1\uFF08batch=${grant.batchId}, \u8303\u56F4=${grant.\u8303\u56F4}, kind=${grant.kind}, \u51B3\u5B9A=${grant.\u51B3\u5B9A}\uFF09`
32819
+ };
32820
+ }
32821
+ clear(bookRoot, exec) {
32822
+ this.grants.delete(storeKey(bookRoot, sessionKeyOf(exec)));
32823
+ }
32824
+ hasAnyForSession(exec) {
32825
+ const key = sessionKeyOf(exec);
32826
+ const now = Date.now();
32827
+ for (const grant of this.grants.values()) {
32828
+ if (grant.sessionKey === key && now <= grant.expiresAt) return true;
32829
+ }
32830
+ return false;
32831
+ }
32832
+ };
32833
+
32164
32834
  // src/story-status.ts
32165
32835
  function readStoryStatus(bookRoot) {
32166
32836
  const selection = selectCurrentVolume(bookRoot);
@@ -32264,8 +32934,8 @@ var MAINTENANCE_OUTPUT = {
32264
32934
  };
32265
32935
 
32266
32936
  // src/book-upgrade-tools.ts
32267
- import fs56 from "node:fs";
32268
- import path68 from "node:path";
32937
+ import fs57 from "node:fs";
32938
+ import path69 from "node:path";
32269
32939
  import { validateJsonSchemaValue as validateJsonSchemaValue2 } from "@deepseek-ai/dsh-tools";
32270
32940
 
32271
32941
  // src/book-upgrade-output.ts
@@ -32345,8 +33015,8 @@ var BOOK_UPGRADE_WRITE_OUTPUT = {
32345
33015
  var marker2 = { maintenance: "book-upgrade" };
32346
33016
  var cancelled = () => ({ ...marker2, ...toolFailure("author-cancelled", "\u4E66\u4ED3\u5347\u7EA7\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF0C\u672C\u6B21\u4E0D\u7EE7\u7EED\u5199\u5165\u3002") });
32347
33017
  var identity2 = (root) => {
32348
- const real = fs56.realpathSync.native(root);
32349
- return process.platform === "win32" ? path68.resolve(real).toLowerCase() : path68.resolve(real);
33018
+ const real = fs57.realpathSync.native(root);
33019
+ return process.platform === "win32" ? path69.resolve(real).toLowerCase() : path69.resolve(real);
32350
33020
  };
32351
33021
  function provenance(exec) {
32352
33022
  if (exec === void 0) return void 0;
@@ -32500,7 +33170,7 @@ function createBookUpgradeTools(deps) {
32500
33170
  }
32501
33171
 
32502
33172
  // src/novel-tools.ts
32503
- import * as fs60 from "node:fs";
33173
+ import * as fs61 from "node:fs";
32504
33174
  import * as nodePath3 from "node:path";
32505
33175
 
32506
33176
  // src/design-commit-result.ts
@@ -32966,14 +33636,14 @@ function onboardingMissing(answers) {
32966
33636
  }
32967
33637
 
32968
33638
  // src/study/onboarding-store.ts
32969
- import * as fs57 from "node:fs";
32970
- import * as path69 from "node:path";
33639
+ import * as fs58 from "node:fs";
33640
+ import * as path70 from "node:path";
32971
33641
  function onboardingDraftPath(workspaceRoot) {
32972
- return path69.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
33642
+ return path70.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
32973
33643
  }
32974
33644
  function readOnboardingDraft(workspaceRoot) {
32975
33645
  try {
32976
- const raw = fs57.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
33646
+ const raw = fs58.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
32977
33647
  return validateOnboardingAnswers(JSON.parse(raw));
32978
33648
  } catch {
32979
33649
  return {};
@@ -32981,27 +33651,27 @@ function readOnboardingDraft(workspaceRoot) {
32981
33651
  }
32982
33652
  function saveOnboardingDraft(workspaceRoot, answers) {
32983
33653
  const target = onboardingDraftPath(workspaceRoot);
32984
- fs57.mkdirSync(path69.dirname(target), { recursive: true });
32985
- fs57.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
33654
+ fs58.mkdirSync(path70.dirname(target), { recursive: true });
33655
+ fs58.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
32986
33656
  }
32987
33657
  function consumeOnboardingDraft(workspaceRoot) {
32988
33658
  try {
32989
- fs57.unlinkSync(onboardingDraftPath(workspaceRoot));
33659
+ fs58.unlinkSync(onboardingDraftPath(workspaceRoot));
32990
33660
  } catch {
32991
33661
  }
32992
33662
  }
32993
33663
 
32994
33664
  // ../drafting/src/context.ts
32995
- import * as fs58 from "node:fs";
32996
- import * as path70 from "node:path";
32997
-
32998
- // ../drafting/src/write.ts
32999
33665
  import * as fs59 from "node:fs";
33000
33666
  import * as path71 from "node:path";
33667
+
33668
+ // ../drafting/src/write.ts
33669
+ import * as fs60 from "node:fs";
33670
+ import * as path72 from "node:path";
33001
33671
  var DRAFT_KEYS = ["\u8EAB\u4EFD", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u6765\u6E90\u5FEB\u7167", "\u89D2\u8272", "\u9009\u5B9A"];
33002
33672
  function readText12(root, rel) {
33003
33673
  try {
33004
- return fs59.readFileSync(path71.join(root, rel), "utf-8");
33674
+ return fs60.readFileSync(path72.join(root, rel), "utf-8");
33005
33675
  } catch {
33006
33676
  return null;
33007
33677
  }
@@ -33010,9 +33680,9 @@ function draftDir(key) {
33010
33680
  return paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D);
33011
33681
  }
33012
33682
  function listDraftFiles(bookRoot, key) {
33013
- const abs = path71.join(bookRoot, draftDir(key));
33014
- if (!fs59.existsSync(abs) || !fs59.statSync(abs).isDirectory()) return [];
33015
- return fs59.readdirSync(abs).filter((f) => f.endsWith(".md")).sort((a, b) => a.localeCompare(b, "zh"));
33683
+ const abs = path72.join(bookRoot, draftDir(key));
33684
+ if (!fs60.existsSync(abs) || !fs60.statSync(abs).isDirectory()) return [];
33685
+ return fs60.readdirSync(abs).filter((f) => f.endsWith(".md")).sort((a, b) => a.localeCompare(b, "zh"));
33016
33686
  }
33017
33687
  function parseDraftNo(file) {
33018
33688
  const m = /^稿(\d+)\.md$/.exec(file);
@@ -33021,7 +33691,7 @@ function parseDraftNo(file) {
33021
33691
  function latestVersion(bookRoot, key) {
33022
33692
  let max = null;
33023
33693
  for (const file of listDraftFiles(bookRoot, key)) {
33024
- const text5 = readText12(bookRoot, path71.posix.join(draftDir(key), file));
33694
+ const text5 = readText12(bookRoot, path72.posix.join(draftDir(key), file));
33025
33695
  if (text5 === null) continue;
33026
33696
  const doc = parseDocument(text5);
33027
33697
  if (!doc.ok) continue;
@@ -33048,7 +33718,7 @@ function selectDraftLocked(bookRoot, input) {
33048
33718
  const files = listDraftFiles(bookRoot, input);
33049
33719
  if (!files.includes(target)) return { ok: false, reason: `\u8349\u7A3F\u4E0D\u5B58\u5728:${target}` };
33050
33720
  for (const file of files) {
33051
- const rel = path71.posix.join(dir, file);
33721
+ const rel = path72.posix.join(dir, file);
33052
33722
  const text5 = readText12(bookRoot, rel);
33053
33723
  if (text5 === null) continue;
33054
33724
  const doc = parseDocument(text5);
@@ -33072,7 +33742,7 @@ function writeDraftLocked(bookRoot, input) {
33072
33742
  const parent = latestVersion(bookRoot, key);
33073
33743
  const ver = parent === null ? initialVersion("\u5199\u7A3F") : bumpVersion(parent, "\u5199\u7A3F");
33074
33744
  const file = nextFileName(bookRoot, key);
33075
- const relPath = path71.posix.join(draftDir(key), file);
33745
+ const relPath = path72.posix.join(draftDir(key), file);
33076
33746
  const fields = applyVersionFields(
33077
33747
  {
33078
33748
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -33104,7 +33774,7 @@ function importAuthorDraftLocked(bookRoot, input) {
33104
33774
  const explicitParent = input.\u7236\u7248\u672C ?? latestVersion(bookRoot, key);
33105
33775
  const ver = explicitParent === null ? initialVersion("\u4F5C\u8005\u7A3F\u5BFC\u5165") : bumpVersion(explicitParent, "\u4F5C\u8005\u7A3F\u5BFC\u5165");
33106
33776
  const file = nextFileName(bookRoot, key);
33107
- const relPath = path71.posix.join(draftDir(key), file);
33777
+ const relPath = path72.posix.join(draftDir(key), file);
33108
33778
  const fields = applyVersionFields(
33109
33779
  {
33110
33780
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -33135,6 +33805,7 @@ function provenanceOf(ctx, targets) {
33135
33805
  }
33136
33806
  var NOVEL_TEST_TOOL_NAMES = ["novel_seed_min_design"];
33137
33807
  function createNovelTools(deps) {
33808
+ const batchStore = new BatchApprovalStore();
33138
33809
  async function writeNative(root, op, exec) {
33139
33810
  if (deps.nativeWrite === void 0) throw new Error("DSH \u539F\u751F write \u4E0D\u53EF\u7528\uFF0C\u62D2\u7EDD\u65E0\u7248\u672C\u4FDD\u62A4\u7684\u5199\u5165");
33140
33811
  updateOperationTargets(root, void 0, [op.relPath]);
@@ -33260,14 +33931,14 @@ function createNovelTools(deps) {
33260
33931
  },
33261
33932
  {
33262
33933
  name: "novel_create_book",
33263
- 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\u3002\u5E02\u573A\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF1F\u8F93\u51FA\u5F62\u6001\uFF1A\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF1F\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF09\uFF1A\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF1F\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",
33934
+ description: "\u65B0\u5EFA\u4F5C\u54C1\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\uFF08\u652F\u6301\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u3001\u5C0F\u8BF4\uFF09\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\uFF08\u672A\u5B9A\u5904\u53EF\u586B\u7559\u767D\uFF09\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u9700\u660E\u786E\u5E02\u573A\uFF08\u4E2D\u6587/\u6D77\u5916\uFF09\u4E0E\u8F93\u51FA\u5F62\u6001\uFF08\u77ED\u5267/\u7535\u5F71\u5267\u672C/\u5C0F\u8BF4\uFF09\uFF1B\u77ED\u5267\u4E0E\u7535\u5F71\u5267\u672C\u53EF\u7701\u7565\u76EE\u6807\u603B\u5B57\u6570\uFF08\u5DE5\u5177\u81EA\u52A8\u6309\u5F62\u6001\u6298\u7B97\uFF09\uFF0C\u5C0F\u8BF4\u9700\u660E\u786E\u76EE\u6807\u603B\u5B57\u6570\u3002\u82E5\u4E66\u623F\u9762\u677F\u300C\u65B0\u5EFA\u4E66\u300D\u5411\u5BFC\u5DF2\u4FDD\u5B58 _\u5F85\u5EFA\u4E66.json\uFF0C\u76F4\u63A5\u6CBF\u7528\u5176\u503C\uFF0C\u4E0D\u8981\u91CD\u590D\u8BE2\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",
33264
33935
  parameters: {
33265
33936
  type: "object",
33266
33937
  properties: {
33267
- bookName: { type: "string", description: "\u5C0F\u8BF4\u4E66\u540D\uFF08\u4E0D\u53EF\u542B\u8DEF\u5F84\u5B57\u7B26\u4E0E\u4FDD\u7559\u5B57\uFF09" },
33268
- \u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\uFF08\u6D77\u5916\u9898\u6750\u5E93\uFF09\u6216\u4E2D\u6587\uFF08\u4E2D\u6587\u9898\u6750\u5E93\uFF09\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20\u4E2D\u6587\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33269
- \u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20\u5C0F\u8BF4\u3002\u77ED\u5267\u8D70\u6309\u96C6\u6D41\u6C34\u7EBF\uFF0C\u7535\u5F71\u5267\u672C\u8D70\u5267\u672C\u6D41\u6C34\u7EBF\uFF0C\u5C0F\u8BF4\u8D70\u539F\u957F\u7BC7\u6D41\u6C34\u7EBF\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33270
- \u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF09\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20 1000000\uFF08\u957F\u7BC7\uFF09\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33938
+ bookName: { type: "string", description: "\u4F5C\u54C1\u4E66\u540D\uFF08\u4E0D\u53EF\u542B\u8DEF\u5F84\u5B57\u7B26\u4E0E\u4FDD\u7559\u5B57\uFF09" },
33939
+ \u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\uFF08\u6D77\u5916\u9898\u6750\u5E93\uFF09\u6216\u4E2D\u6587\uFF08\u4E2D\u6587\u9898\u6750\u5E93\uFF09\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33940
+ \u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\u3002\u77ED\u5267\u8D70\u6309\u96C6\u6D41\u6C34\u7EBF\uFF0C\u7535\u5F71\u5267\u672C\u8D70\u5267\u672C\u6D41\u6C34\u7EBF\uFF0C\u5C0F\u8BF4\u8D70\u957F\u7BC7\u6D41\u6C34\u7EBF\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33941
+ \u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF1B\u77ED\u5267\u4E0E\u7535\u5F71\u5267\u672C\u53EF\u7701\u7565\u81EA\u52A8\u6298\u7B97\uFF1B\u5C0F\u8BF4\u9700\u786E\u8BA4\uFF09\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
33271
33942
  concept: {
33272
33943
  type: "object",
33273
33944
  description: "\u4F5C\u54C1\u6784\u60F3\u4E03\u8981\u7D20\uFF08\u72B6\u6001\u5FC5\u987B\u4E3A\u5DF2\u786E\u8BA4\uFF09",
@@ -33280,9 +33951,9 @@ function createNovelTools(deps) {
33280
33951
  \u6838\u5FC3\u770B\u70B9: { type: "string" },
33281
33952
  \u5DEE\u5F02\u5316\u65B9\u5411: { type: "string" },
33282
33953
  \u660E\u786E\u4E0D\u8981\u4EC0\u4E48: { type: "string" },
33283
- \u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\u6216\u4E2D\u6587\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" },
33284
- \u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" },
33285
- \u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF09\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" }
33954
+ \u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\u6216\u4E2D\u6587" },
33955
+ \u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4" },
33956
+ \u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF09" }
33286
33957
  },
33287
33958
  required: ["\u72B6\u6001", "\u6838\u5FC3\u521B\u610F", "\u9898\u6750\u4E0E\u76EE\u6807\u8BFB\u8005", "\u4E3B\u89D2\u6838\u5FC3\u6B32\u671B", "\u4E3B\u8981\u51B2\u7A81", "\u6838\u5FC3\u770B\u70B9", "\u5DEE\u5F02\u5316\u65B9\u5411", "\u660E\u786E\u4E0D\u8981\u4EC0\u4E48"]
33288
33959
  }
@@ -33312,13 +33983,17 @@ function createNovelTools(deps) {
33312
33983
  const \u5E02\u573A = args["\u5E02\u573A"] ?? concept.\u5E02\u573A ?? draft.\u5E02\u573A;
33313
33984
  const \u8F93\u51FA\u5F62\u6001 = args["\u8F93\u51FA\u5F62\u6001"] ?? concept.\u8F93\u51FA\u5F62\u6001 ?? draft.\u8F93\u51FA\u5F62\u6001;
33314
33985
  const rawWords = args["\u76EE\u6807\u603B\u5B57\u6570"] ?? concept.\u76EE\u6807\u603B\u5B57\u6570 ?? draft.\u76EE\u6807\u603B\u5B57\u6570;
33315
- const \u76EE\u6807\u603B\u5B57\u6570 = typeof rawWords === "string" ? Number(rawWords) : rawWords;
33986
+ let \u76EE\u6807\u603B\u5B57\u6570 = typeof rawWords === "string" ? Number(rawWords) : rawWords;
33987
+ if (\u76EE\u6807\u603B\u5B57\u6570 === void 0 && (\u8F93\u51FA\u5F62\u6001 === "\u77ED\u5267" || \u8F93\u51FA\u5F62\u6001 === "\u7535\u5F71\u5267\u672C")) {
33988
+ \u76EE\u6807\u603B\u5B57\u6570 = \u8F93\u51FA\u5F62\u6001 === "\u77ED\u5267" ? 1e5 : 5e4;
33989
+ }
33316
33990
  const missing = onboardingMissing({ \u5E02\u573A, \u8F93\u51FA\u5F62\u6001, \u76EE\u6807\u603B\u5B57\u6570 });
33317
33991
  if (missing.length > 0) {
33992
+ const draftHint = Object.keys(draft).length > 0 ? `\uFF08\u5411\u5BFC\u8349\u7A3F\u5DF2\u6709\uFF1A${JSON.stringify(draft)}\uFF09` : "";
33318
33993
  return toolFailure(
33319
33994
  "invalid-argument",
33320
- `\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u786E\u8BA4${missing.join("\u3001")}\uFF0C\u7F3A\u4E86\u4E0D\u80FD\u5EFA\u4E66\u3002`,
33321
- `\u5148\u95EE\u4F5C\u8005\uFF0C\u540C\u4E00\u6761\u6D88\u606F\u4E00\u6B21\u95EE\u5B8C\uFF0C\u5404\u7ED9\u9009\u9879\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF1B\u9009\u597D\u540E\u76F4\u63A5\u91CD\u8C03\u672C\u5DE5\u5177\u3002\u5E02\u573A\u2014\u2014\u201C\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF1F\u201D\uFF081. \u4E2D\u6587\u2605\u63A8\u8350 2. \u6D77\u5916 3. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\uFF09\uFF1B\u8F93\u51FA\u5F62\u6001\u2014\u2014\u201C\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF1F\u201D\uFF081. \u5C0F\u8BF4\u2605\u63A8\u8350 2. \u77ED\u5267 3. \u7535\u5F71\u5267\u672C 4. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\uFF09\uFF1B\u76EE\u6807\u603B\u5B57\u6570\u2014\u2014\u201C\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF1F\u201D\uFF081. \u77ED\u7BC7\xB75\u4E07\u5B57 2. \u4E2D\u7BC7\xB730\u4E07\u5B57 3. \u957F\u7BC7\xB7100\u4E07\u5B57\u2605\u63A8\u8350 4. \u8D85\u957F\u7BC7\xB7200\u4E07\u5B57\uFF09\uFF1B\u53E6\u53EF\u9009\uFF1A5. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\u5177\u4F53\u6570\u5B57\u3002\u62FF\u5230\u7B54\u6848\u518D\u8C03 novel_create_book\uFF0C\u628A\u503C\u4F20\u8FDB\u6765\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\u3002\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u76F4\u63A5\u5EFA\u4E66\u3002`
33995
+ `\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u786E\u8BA4${missing.join("\u3001")}\uFF0C\u7F3A\u4E86\u4E0D\u80FD\u5EFA\u4E66\u3002${draftHint}`,
33996
+ `\u5148\u95EE\u4F5C\u8005\uFF0C\u540C\u4E00\u6761\u6D88\u606F\u4E00\u6B21\u95EE\u5B8C\u7F3A\u5931\u9879${draftHint}\uFF1B\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\u3002\u5E02\u573A\uFF081. \u4E2D\u6587 2. \u6D77\u5916\uFF09\uFF1B\u8F93\u51FA\u5F62\u6001\uFF081. \u77ED\u5267 2. \u7535\u5F71\u5267\u672C 3. \u5C0F\u8BF4\uFF09\uFF1B\u76EE\u6807\u603B\u5B57\u6570\uFF08\u4EC5\u5C0F\u8BF4\u5FC5\u586B\uFF1A1. \u77ED\u7BC7\xB75\u4E07\u5B57 2. \u4E2D\u7BC7\xB730\u4E07\u5B57 3. \u957F\u7BC7\xB7100\u4E07\u5B57 4. \u8D85\u957F\u7BC7\xB7200\u4E07\u5B57\uFF0C\u6216\u76F4\u63A5\u8F93\u6570\u5B57\uFF09\u3002\u62FF\u5230\u7B54\u6848\u518D\u8C03 novel_create_book\u3002`
33322
33997
  );
33323
33998
  }
33324
33999
  if (\u5E02\u573A !== void 0 && !isMarketValue(\u5E02\u573A)) return toolFailure("invalid-argument", `\u5E02\u573A\u53D6\u503C\u975E\u6CD5\uFF1A${String(\u5E02\u573A)}\uFF0C\u53EA\u63A5\u53D7 \u6D77\u5916 / \u4E2D\u6587`);
@@ -33440,7 +34115,7 @@ function createNovelTools(deps) {
33440
34115
  paths.\u5377\u7EB2(\u5377),
33441
34116
  paths.\u8BA1\u5212\u65F6\u95F4\u7EBF(\u5377),
33442
34117
  paths.\u8FD1\u671F\u7A97\u53E3(\u5377)
33443
- ].filter((p) => fs60.existsSync(nodePath3.join(bookRoot, p)));
34118
+ ].filter((p) => fs61.existsSync(nodePath3.join(bookRoot, p)));
33444
34119
  const commit = commitConfirmed({ bookRoot, paths: seedPaths, prefix: "design", summary: "\u6700\u5C0F\u8BBE\u8BA1\u9AA8\u67B6", provenance: provenanceOf(sessionContext, seedPaths) });
33445
34120
  if (!commit.ok) {
33446
34121
  return { ok: false, reason: `\u6700\u5C0F\u8BBE\u8BA1\u5DF2\u5199\u5165\u4F46\u63D0\u4EA4\u5931\u8D25\uFF08\u91CD\u8DD1\u672C\u5DE5\u5177\u5373\u53EF\u8865\u63D0\u4EA4\uFF09\uFF1A${commit.reason}` };
@@ -33770,20 +34445,33 @@ function createNovelTools(deps) {
33770
34445
  render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
33771
34446
  },
33772
34447
  execute: async (args, sessionContext) => {
33773
- if (!deps.askFn) return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
34448
+ const mode = deps.automationMode?.() ?? "manual";
34449
+ if (!deps.askFn && (mode === "manual" || !batchStore.hasAnyForSession(sessionContext))) {
34450
+ return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
34451
+ }
33774
34452
  const book = resolveBook(args, sessionContext);
33775
34453
  if (!book.ok) return book;
33776
34454
  const bookRoot = book.bookRoot;
33777
34455
  const keyResult = chapterKeyOf(args);
33778
34456
  if (!keyResult.ok) return keyResult;
33779
34457
  const key = keyResult.key;
34458
+ const batchMatch = mode !== "manual" ? batchStore.match(bookRoot, sessionContext, "chapter", key.\u7AE0) : void 0;
34459
+ if (!batchMatch && !deps.askFn) return toolFailure("host-unavailable", "\u88C1\u51B3\u901A\u9053\u4E0D\u53EF\u7528\uFF1A\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
33780
34460
  const approvalFiles = [paths.\u5F85\u5B9A\u7A3F\u5305\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D), paths.\u5951\u7EA6()];
33781
34461
  const before = captureApprovalFiles(bookRoot, approvalFiles, args);
33782
34462
  if (!before.ok) return before;
33783
- const decision = await askAuthor(deps.askFn, "\u5B9A\u7A3F\u5165\u6863", { \u8303\u56F4: `\u5377${key.\u5377.toString().padStart(2, "0")}/${key.\u7AE0\u540D}` }, { agent: sessionContext?.agent, signal: sessionContext?.signal });
33784
- if (!decision.ok) return notApproved(decision.reason);
33785
- if (sessionContext?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
33786
- const \u88C1\u51B3 = decision.\u51B3\u5B9A === "\u5DF2\u6279\u51C6" ? "\u5DF2\u6279\u51C6" : "\u5DF2\u9000\u56DE";
34463
+ let \u88C1\u51B3;
34464
+ let \u88C1\u51B3\u8BB0\u5F55\u6587\u672C;
34465
+ if (batchMatch) {
34466
+ \u88C1\u51B3 = "\u5DF2\u6279\u51C6";
34467
+ \u88C1\u51B3\u8BB0\u5F55\u6587\u672C = batchMatch.\u88C1\u51B3\u8BB0\u5F55;
34468
+ } else {
34469
+ const decision = await askAuthor(deps.askFn, "\u5B9A\u7A3F\u5165\u6863", { \u8303\u56F4: `\u5377${key.\u5377.toString().padStart(2, "0")}/${key.\u7AE0\u540D}` }, { agent: sessionContext?.agent, signal: sessionContext?.signal });
34470
+ if (!decision.ok) return notApproved(decision.reason);
34471
+ if (sessionContext?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
34472
+ \u88C1\u51B3 = decision.\u51B3\u5B9A === "\u5DF2\u6279\u51C6" ? "\u5DF2\u6279\u51C6" : "\u5DF2\u9000\u56DE";
34473
+ \u88C1\u51B3\u8BB0\u5F55\u6587\u672C = `\u4F5C\u8005\u4E8E ${(/* @__PURE__ */ new Date()).toISOString()} \u6279\u51C6\u5B9A\u7A3F\u5165\u6863\uFF08kind=${decision.kind}, \u51B3\u5B9A=${decision.\u51B3\u5B9A}\uFF09`;
34474
+ }
33787
34475
  return withBookWrite(bookRoot, () => {
33788
34476
  if (sessionContext?.signal?.aborted) return toolFailure("author-cancelled", "\u4F5C\u8005\u88C1\u51B3\u5DF2\u53D6\u6D88\uFF08\u4F1A\u8BDD\u5DF2\u4E2D\u6B62\uFF09\uFF0C\u6CA1\u6709\u505A\u51FA\u51B3\u5B9A\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165");
33789
34477
  const currentBook = resolveBook(args, sessionContext);
@@ -33792,7 +34480,7 @@ function createNovelTools(deps) {
33792
34480
  if (!current.ok || current.fingerprint !== before.fingerprint) return toolFailure("approval-stale", "\u5F85\u5B9A\u7A3F\u5305\u5728\u7B49\u5F85\u4F5C\u8005\u88C1\u51B3\u671F\u95F4\u5DF2\u53D8\u5316\uFF0C\u65E7\u6279\u51C6\u4E0D\u53EF\u4F7F\u7528");
33793
34481
  const decisionWrite = writeSettlementDecision(bookRoot, key, \u88C1\u51B3);
33794
34482
  if (\u88C1\u51B3 !== "\u5DF2\u6279\u51C6") {
33795
- return toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005${decision.\u51B3\u5B9A}\uFF0C\u672C\u7AE0\u6CA1\u6709\u5165\u6863`);
34483
+ return toolFailure("author-declined", `\u672A\u83B7\u4F5C\u8005\u6279\u51C6\uFF1A\u4F5C\u8005\u9000\u56DE\uFF0C\u672C\u7AE0\u6CA1\u6709\u5165\u6863`);
33796
34484
  }
33797
34485
  if (!decisionWrite.ok) return { ok: false, reason: decisionWrite.reason };
33798
34486
  try {
@@ -33800,11 +34488,15 @@ function createNovelTools(deps) {
33800
34488
  bookRoot,
33801
34489
  packageDir: paths.\u5F85\u5B9A\u7A3F\u5305\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D),
33802
34490
  summary: String(args["summary"]).trim(),
33803
- settlement: { \u7AE0\u8282: key, \u6279\u51C6: true, \u88C1\u51B3\u8BB0\u5F55: `\u4F5C\u8005\u4E8E ${(/* @__PURE__ */ new Date()).toISOString()} \u6279\u51C6\u5B9A\u7A3F\u5165\u6863\uFF08kind=${decision.kind}, \u51B3\u5B9A=${decision.\u51B3\u5B9A}\uFF09` },
34491
+ settlement: { \u7AE0\u8282: key, \u6279\u51C6: true, \u88C1\u51B3\u8BB0\u5F55: \u88C1\u51B3\u8BB0\u5F55\u6587\u672C },
33804
34492
  provenance: provenanceOf(sessionContext)
33805
34493
  });
33806
34494
  if (!res.ok) return { ok: false, reason: res.reason };
33807
- return { ok: true, message: `\u5B9A\u7A3F\u6C89\u6DC0\u5B8C\u6210\uFF08${res.message}\uFF09\uFF0C\u5165\u6863\uFF1A${res.dests.join("\u3001")}` };
34495
+ return {
34496
+ ok: true,
34497
+ ...batchMatch ? { batchId: batchMatch.batchId } : {},
34498
+ message: `\u5B9A\u7A3F\u6C89\u6DC0\u5B8C\u6210\uFF08${res.message}\uFF09\uFF0C\u5165\u6863\uFF1A${res.dests.join("\u3001")}`
34499
+ };
33808
34500
  } catch (err) {
33809
34501
  return failureFrom(err, `\u5B9A\u7A3F\u6C89\u6DC0\u5931\u8D25\uFF1A`);
33810
34502
  }
@@ -34036,7 +34728,7 @@ function createNovelTools(deps) {
34036
34728
  const rel = paths.\u8FD1\u671F\u7A97\u53E3(\u5377);
34037
34729
  let text5 = "";
34038
34730
  try {
34039
- text5 = fs60.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
34731
+ text5 = fs61.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
34040
34732
  } catch {
34041
34733
  text5 = "";
34042
34734
  }
@@ -34230,6 +34922,7 @@ function createNovelTools(deps) {
34230
34922
  \u5377,
34231
34923
  \u7AE0,
34232
34924
  \u7AE0\u540D,
34925
+ \u8D28\u91CF\u6A21\u5F0F: true,
34233
34926
  ...Array.isArray(args["\u8865\u5145\u64CD\u4F5C"]) ? { \u8865\u5145\u64CD\u4F5C: args["\u8865\u5145\u64CD\u4F5C"] } : {},
34234
34927
  ...typeof args["\u6750\u6599\u6E05\u5355\u54C8\u5E0C"] === "string" ? { \u6750\u6599\u6E05\u5355\u54C8\u5E0C: args["\u6750\u6599\u6E05\u5355\u54C8\u5E0C"] } : {}
34235
34928
  };
@@ -34732,7 +35425,7 @@ function createNovelTools(deps) {
34732
35425
  const res = archiveRetconRequest({ bookRoot, chapter: \u5B9A\u7A3F\u76F8\u5BF9, request, provenance: provenanceOf(sessionContext) }, (plannedPackageDir) => {
34733
35426
  let \u66F4\u6B63\u540E\u5168\u6587;
34734
35427
  try {
34735
- const src = fs60.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
35428
+ const src = fs61.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
34736
35429
  const doc = parseDocument(src);
34737
35430
  if (!doc.ok) return { ok: false, reason: `\u5B9A\u7A3F\u7AE0\u89E3\u6790\u5931\u8D25\uFF1A${doc.detail}` };
34738
35431
  const parent = extractVersionFields(doc.data.fields).\u7248\u672C;
@@ -34760,19 +35453,19 @@ function createNovelTools(deps) {
34760
35453
  const value = optionalText(f);
34761
35454
  return value === null ? [] : [[\u5019\u9009\u6587\u4EF6[f], value]];
34762
35455
  }));
34763
- if (fs60.existsSync(\u5305\u7EDD\u5BF9)) {
34764
- for (const name3 of fs60.readdirSync(\u5305\u7EDD\u5BF9)) {
35456
+ if (fs61.existsSync(\u5305\u7EDD\u5BF9)) {
35457
+ for (const name3 of fs61.readdirSync(\u5305\u7EDD\u5BF9)) {
34765
35458
  const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
34766
- const stat = fs60.lstatSync(file);
34767
- if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs60.readFileSync(file, "utf8") !== contents.get(name3)) {
35459
+ const stat = fs61.lstatSync(file);
35460
+ if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs61.readFileSync(file, "utf8") !== contents.get(name3)) {
34768
35461
  return { ok: false, reason: "\u8865\u507F\u5305\u5019\u9009\u51B2\u7A81\uFF0C\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6838\u5BF9\u540E\u5904\u7406" };
34769
35462
  }
34770
35463
  }
34771
35464
  }
34772
- fs60.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
35465
+ fs61.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
34773
35466
  for (const [name3, value] of contents) {
34774
35467
  const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
34775
- if (!fs60.existsSync(file)) fs60.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
35468
+ if (!fs61.existsSync(file)) fs61.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
34776
35469
  }
34777
35470
  packageDir = \u5305\u76F8\u5BF9;
34778
35471
  }
@@ -34793,7 +35486,7 @@ function createNovelTools(deps) {
34793
35486
  retconFiles.push({ \u76EE\u6807: \u6458\u8981\u76F8\u5BF9, \u5185\u5BB9: request.\u66F4\u6B63\u540E\u7AE0\u6458\u8981 });
34794
35487
  } else {
34795
35488
  try {
34796
- const \u6458\u8981\u73B0\u6587 = fs60.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
35489
+ const \u6458\u8981\u73B0\u6587 = fs61.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
34797
35490
  retconFiles.push({
34798
35491
  \u76EE\u6807: \u6458\u8981\u76F8\u5BF9,
34799
35492
  \u5185\u5BB9: `> \u3014\u6458\u8981\u8FC7\u671F\u3015\u5B9A\u7A3F\u6B63\u6587\u5DF2\u7ECF\u5403\u4E66\u8865\u507F\u66F4\u6B63,\u672C\u6458\u8981\u5F85\u91CD\u505A(\u5173\u8054\u63D0\u6848 ${String(args["\u63D0\u6848\u7F16\u53F7"] ?? "\uFF08\u672A\u767B\u8BB0\uFF09")})
@@ -35068,14 +35761,89 @@ ${\u6458\u8981\u73B0\u6587}`
35068
35761
  render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
35069
35762
  },
35070
35763
  execute: (args, sessionContext) => acceptEditorSuggestion(deps.editorRequests, sessionContext?.agent, args)
35764
+ },
35765
+ {
35766
+ name: "novel_authorize_batch",
35767
+ description: "\u534A\u81EA\u52A8\u4E24\u6B65\u8D70\u6388\u6743\u5165\u53E3\uFF1A\u5F39\u51FA\u4E00\u6B21\u4F5C\u8005\u88C1\u51B3\u5361\uFF0C\u8BF7\u4F5C\u8005\u786E\u8BA4\u672C\u6279\u6B21\u8BBE\u8BA1/\u89C4\u5212\u65B9\u5411\u5E76\u6279\u51C6\u540E\u7EED\u6279\u91CF\u751F\u6210\u4E0E\u5B9A\u7A3F\u5165\u6863\uFF08\u5982 \u96C6001\u2013\u96C6005 / \u7B2C1\u20133\u7AE0 / \u7535\u5F71\u5267\u672C\u5168\u7247\uFF09\u3002\u6279\u51C6\u540E\uFF0C\u672C\u4F1A\u8BDD\u5185\u8BE5\u8303\u56F4\u5185\u7684 novel_settle_chapter / novel_shortdrama_settle_episode / novel_screenplay_settle \u5C06\u81EA\u52A8\u63A8\u8FDB\uFF0C\u4E0D\u518D\u9010\u7AE0\u9010\u96C6\u5F39\u7A97\u3002",
35768
+ parameters: {
35769
+ type: "object",
35770
+ properties: {
35771
+ bookId: { type: "string", description: "\u4E66id\uFF08\u5FC5\u586B\uFF09" },
35772
+ \u8303\u56F4: { type: "string", description: "\u672C\u6B21\u6279\u51C6\u7684\u8303\u56F4\u8BF4\u660E\uFF08\u5982\u300C\u96C6001\u2013\u96C6005\u300D\u300C\u7B2C1\u20133\u7AE0\u300D\u300C\u7535\u5F71\u5267\u672C\u5168\u7247\u300D\uFF09" },
35773
+ \u6458\u8981: { type: "string", description: "\u5DF2\u5448\u62A5\u7684\u8BBE\u8BA1\u4E0E\u5927\u7EB2\u6838\u5FC3\u6458\u8981\uFF0C\u5C55\u793A\u5728\u88C1\u51B3\u5361\u4F9B\u4F5C\u8005\u4E00\u6B21\u786E\u8BA4" },
35774
+ \u76EE\u6807\u7C7B\u578B: { type: "string", enum: ["chapter", "episode", "screenplay", "all"], description: "\u6258\u7BA1\u76EE\u6807\u7C7B\u578B\uFF0C\u9ED8\u8BA4 all" },
35775
+ \u8D77\u53F7: { type: "integer", minimum: 1, description: "\u53EF\u9009\u8D77\u59CB\u7AE0\u53F7\u6216\u96C6\u53F7" },
35776
+ \u6B62\u53F7: { type: "integer", minimum: 1, description: "\u53EF\u9009\u7ED3\u675F\u7AE0\u53F7\u6216\u96C6\u53F7" }
35777
+ },
35778
+ required: ["bookId", "\u8303\u56F4", "\u6458\u8981"]
35779
+ },
35780
+ output: {
35781
+ schema: {
35782
+ type: "object",
35783
+ properties: {
35784
+ ok: { type: "boolean" },
35785
+ batchId: { type: "string" },
35786
+ \u8303\u56F4: { type: "string" },
35787
+ automationMode: { type: "string" },
35788
+ message: { type: "string" },
35789
+ reason: { type: "string" }
35790
+ },
35791
+ required: ["ok"]
35792
+ },
35793
+ render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
35794
+ },
35795
+ execute: async (args, sessionContext) => {
35796
+ const book = resolveBook(args, sessionContext);
35797
+ if (!book.ok) return book;
35798
+ const \u8303\u56F4 = String(args["\u8303\u56F4"] ?? "").trim();
35799
+ const \u6458\u8981 = String(args["\u6458\u8981"] ?? "").trim();
35800
+ if (\u8303\u56F4 === "" || \u6458\u8981 === "") return toolFailure("invalid-argument", "\u8303\u56F4\u4E0E\u6458\u8981\u4E0D\u80FD\u4E3A\u7A7A\u3002");
35801
+ const mode = deps.automationMode?.() ?? "semi-auto";
35802
+ if (mode === "manual") {
35803
+ return toolFailure("invalid-argument", "\u5F53\u524D\u504F\u597D\u4E3A\u300C\u4E25\u683C\u9010\u9879\u786E\u8BA4\uFF08manual\uFF09\u300D\uFF0C\u4E0D\u652F\u6301\u6279\u91CF\u6258\u7BA1\uFF1B\u8BF7\u9010\u7AE0/\u9010\u96C6\u88C1\u51B3\uFF0C\u6216\u5728\u63D2\u4EF6\u8BBE\u7F6E\u5207\u6362\u4E3A\u534A\u81EA\u52A8\u4E24\u6B65\u8D70\u3002");
35804
+ }
35805
+ const targetType = ["chapter", "episode", "screenplay", "all"].includes(String(args["\u76EE\u6807\u7C7B\u578B"])) ? String(args["\u76EE\u6807\u7C7B\u578B"]) : "all";
35806
+ const \u8D77\u53F7 = typeof args["\u8D77\u53F7"] === "number" && Number.isSafeInteger(args["\u8D77\u53F7"]) ? args["\u8D77\u53F7"] : void 0;
35807
+ const \u6B62\u53F7 = typeof args["\u6B62\u53F7"] === "number" && Number.isSafeInteger(args["\u6B62\u53F7"]) ? args["\u6B62\u53F7"] : void 0;
35808
+ const granted = await batchStore.authorize({
35809
+ askFn: deps.askFn,
35810
+ bookRoot: book.bookRoot,
35811
+ \u8303\u56F4,
35812
+ \u6458\u8981,
35813
+ targetType,
35814
+ \u8D77\u53F7,
35815
+ \u6B62\u53F7,
35816
+ exec: sessionContext
35817
+ });
35818
+ if (!granted.ok) return toolFailure(granted.code, granted.reason);
35819
+ return {
35820
+ ok: true,
35821
+ batchId: granted.grant.batchId,
35822
+ \u8303\u56F4,
35823
+ automationMode: mode,
35824
+ message: `\u4F5C\u8005\u5DF2\u6279\u51C6\u6279\u91CF\u6258\u7BA1\uFF08${\u8303\u56F4}\uFF0Cbatch=${granted.grant.batchId}\uFF09\u3002\u73B0\u5728\u8BF7\u76F4\u63A5\u8FDE\u7EED\u5B8C\u6210\u672C\u6279\u89C4\u5212\u3001\u8D77\u8349/\u5267\u672C\u3001\u7CBE\u4FEE\u4E0E\u5B9A\u7A3F\u5165\u6863\uFF0C\u4E2D\u9014\u4E0D\u518D\u9010\u4E2A\u5F39\u7A97\u8BE2\u95EE\u3002`
35825
+ };
35826
+ }
35071
35827
  }
35072
35828
  ];
35073
35829
  tools.push(
35074
35830
  ...createScreenplayTools({
35075
35831
  bookRootOfBookId: deps.bookRootOfBookId,
35076
- readContractFields: (bookRoot) => readExistingContract(bookRoot).fields
35832
+ readContractFields: (bookRoot) => readExistingContract(bookRoot).fields,
35833
+ writeDraft: writeNative,
35834
+ askFn: deps.askFn,
35835
+ provenanceOf,
35836
+ automationMode: deps.automationMode,
35837
+ batchStore
35077
35838
  }),
35078
- ...createShortdramaTools({ bookRootOfBookId: deps.bookRootOfBookId, writeDraft: writeNative, askFn: deps.askFn, provenanceOf })
35839
+ ...createShortdramaTools({
35840
+ bookRootOfBookId: deps.bookRootOfBookId,
35841
+ writeDraft: writeNative,
35842
+ askFn: deps.askFn,
35843
+ provenanceOf,
35844
+ automationMode: deps.automationMode,
35845
+ batchStore
35846
+ })
35079
35847
  );
35080
35848
  const locked = /* @__PURE__ */ new Set([
35081
35849
  "novel_new_outline_draft",
@@ -35096,9 +35864,16 @@ ${\u6458\u8981\u73B0\u6587}`
35096
35864
  "novel_record_proposal",
35097
35865
  "novel_resolve_proposal",
35098
35866
  "novel_note_pending",
35099
- "novel_shortdrama_render_episode"
35867
+ "novel_shortdrama_render_episode",
35868
+ "novel_shortdrama_save_script",
35869
+ "novel_screenplay_save_draft"
35870
+ ]);
35871
+ const nativeTools = /* @__PURE__ */ new Set([
35872
+ ...NATIVE_DESIGN_TOOLS,
35873
+ "novel_shortdrama_render_episode",
35874
+ "novel_shortdrama_save_script",
35875
+ "novel_screenplay_save_draft"
35100
35876
  ]);
35101
- const nativeTools = /* @__PURE__ */ new Set([...NATIVE_DESIGN_TOOLS, "novel_shortdrama_render_episode"]);
35102
35877
  const registered = deps.testTools === true ? tools : tools.filter((tool) => !NOVEL_TEST_TOOL_NAMES.includes(tool.name));
35103
35878
  const guarded = registered.map((tool) => {
35104
35879
  if (!locked.has(tool.name)) return tool;
@@ -35254,8 +36029,8 @@ function finishDesignCommit(bookRoot, writtenPaths, args, defaultSummary, chapte
35254
36029
  import { boundContextSummary, createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
35255
36030
 
35256
36031
  // src/study/service.ts
35257
- import * as fs63 from "node:fs";
35258
- import * as path74 from "node:path";
36032
+ import * as fs64 from "node:fs";
36033
+ import * as path75 from "node:path";
35259
36034
 
35260
36035
  // ../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
35261
36036
  var Diff = class {
@@ -35357,16 +36132,16 @@ var Diff = class {
35357
36132
  }
35358
36133
  }
35359
36134
  }
35360
- addToPath(path81, added, removed, oldPosInc, options2) {
35361
- const last = path81.lastComponent;
36135
+ addToPath(path82, added, removed, oldPosInc, options2) {
36136
+ const last = path82.lastComponent;
35362
36137
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
35363
36138
  return {
35364
- oldPos: path81.oldPos + oldPosInc,
36139
+ oldPos: path82.oldPos + oldPosInc,
35365
36140
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
35366
36141
  };
35367
36142
  } else {
35368
36143
  return {
35369
- oldPos: path81.oldPos + oldPosInc,
36144
+ oldPos: path82.oldPos + oldPosInc,
35370
36145
  lastComponent: { count: 1, added, removed, previousComponent: last }
35371
36146
  };
35372
36147
  }
@@ -35557,7 +36332,7 @@ var text4 = (value) => typeof value === "string" ? value : "";
35557
36332
  var terms = (value) => Array.isArray(value) ? value.flatMap(terms) : typeof value === "string" ? value.split(/[、,,;]/).map((item) => item.trim()).filter(Boolean) : [];
35558
36333
  var wiki = (body) => [...body.matchAll(/\[\[([^\]\n]+)\]\]/g)].map((match) => match[1].split("|")[0].trim());
35559
36334
  var identity3 = (name3) => name3.trim().replace(/[\s「」『』【】()()::,,。!?!?]/g, "").toLowerCase();
35560
- var kindOf = (path81, declared) => typeof declared === "string" && declared.trim() ? { \u4EBA\u7269\u6863\u6848: "\u4EBA\u7269", \u4EBA\u7269\u5173\u7CFB: "\u5173\u7CFB", \u7EC4\u7EC7\u4E0E\u9635\u8425: "\u7EC4\u7EC7", \u5730\u70B9\u4E0E\u7A7A\u95F4: "\u5730\u70B9" }[declared.trim()] ?? declared.trim() : path81.includes("/\u4EBA\u7269\u6863\u6848/") ? "\u4EBA\u7269" : path81.includes("/\u4EBA\u7269\u5173\u7CFB/") ? "\u5173\u7CFB" : path81.includes("/\u7EC4\u7EC7\u4E0E\u9635\u8425/") ? "\u7EC4\u7EC7" : path81.includes("/\u5730\u70B9\u4E0E\u7A7A\u95F4/") ? "\u5730\u70B9" : "\u8BBE\u5B9A";
36335
+ var kindOf = (path82, declared) => typeof declared === "string" && declared.trim() ? { \u4EBA\u7269\u6863\u6848: "\u4EBA\u7269", \u4EBA\u7269\u5173\u7CFB: "\u5173\u7CFB", \u7EC4\u7EC7\u4E0E\u9635\u8425: "\u7EC4\u7EC7", \u5730\u70B9\u4E0E\u7A7A\u95F4: "\u5730\u70B9" }[declared.trim()] ?? declared.trim() : path82.includes("/\u4EBA\u7269\u6863\u6848/") ? "\u4EBA\u7269" : path82.includes("/\u4EBA\u7269\u5173\u7CFB/") ? "\u5173\u7CFB" : path82.includes("/\u7EC4\u7EC7\u4E0E\u9635\u8425/") ? "\u7EC4\u7EC7" : path82.includes("/\u5730\u70B9\u4E0E\u7A7A\u95F4/") ? "\u5730\u70B9" : "\u8BBE\u5B9A";
35561
36336
  function readStoryGraph(source2) {
35562
36337
  const records = [], edges = [], events = [];
35563
36338
  const warnings = [];
@@ -35589,7 +36364,7 @@ function readStoryGraph(source2) {
35589
36364
  aliases.set(name3, values);
35590
36365
  };
35591
36366
  const strings = (fields) => Object.fromEntries(Object.entries(fields).filter((pair) => typeof pair[1] === "string"));
35592
- const fromFields = (id, label2, kind2, path81, line, fields, body) => ({
36367
+ const fromFields = (id, label2, kind2, path82, line, fields, body) => ({
35593
36368
  id,
35594
36369
  label: label2,
35595
36370
  kind: kind2,
@@ -35598,23 +36373,23 @@ function readStoryGraph(source2) {
35598
36373
  chapter: chapter(fields["\u8D77\u59CB\u7AE0"]) ?? chapter(fields["\u751F\u6548\u7AE0"]) ?? chapter(fields["\u7AE0\u53F7"]) ?? entryChapterNo({ \u5B57\u6BB5: strings(fields) }) ?? void 0,
35599
36374
  endChapter: chapter(fields["\u5931\u6548\u7AE0"]),
35600
36375
  revealChapter: chapter(fields["\u62AB\u9732\u7AE0"]) ?? chapter(fields["\u63ED\u793A\u7AE0"]),
35601
- source: { space: "book:" + source2.bookId, path: path81 },
36376
+ source: { space: "book:" + source2.bookId, path: path82 },
35602
36377
  line,
35603
36378
  preview: body.trim().slice(0, 600),
35604
36379
  // Expose authored scalar/list field names as grouping choices without
35605
36380
  // guessing whether 宗门/血脉/师承 means faction, family or another identity.
35606
36381
  affiliations: (id.startsWith("world:") ? Object.entries(fields) : []).filter(([field, value]) => !["\u540D\u79F0", "\u7C7B\u578B", "\u6027\u8D28", "\u72B6\u6001", "\u6765\u6E90", "\u6765\u6E90\u5F15\u7528", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u7AE0\u53F7", "\u8D77\u59CB\u7AE0", "\u751F\u6548\u7AE0", "\u5931\u6548\u7AE0", "\u62AB\u9732\u7AE0", "\u63ED\u793A\u7AE0", "\u522B\u540D", "\u5173\u7CFB", "\u5173\u7CFB\u7C7B\u578B", "\u5173\u7CFB\u53CC\u65B9", "\u4E3B\u4F53", "\u5BA2\u4F53"].includes(field) && (typeof value === "string" && !/[\r\n]/.test(value) && value.length <= 128 || Array.isArray(value) && value.length <= 24 && value.every((item) => typeof item === "string" && item.length <= 128 && !/[\r\n]/.test(item)))).flatMap(([field, value]) => terms(value).map((label3) => ({ field, label: label3 })))
35607
36382
  });
35608
- const scan = (path81, depth = 0) => {
36383
+ const scan = (path82, depth = 0) => {
35609
36384
  if (depth > 12) {
35610
- warnings.push({ path: path81, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
36385
+ warnings.push({ path: path82, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
35611
36386
  return;
35612
36387
  }
35613
36388
  let entries;
35614
36389
  try {
35615
- entries = source2.list(path81);
36390
+ entries = source2.list(path82);
35616
36391
  } catch (error) {
35617
- if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
36392
+ if (error.code !== "not-found") warnings.push({ path: path82, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
35618
36393
  return;
35619
36394
  }
35620
36395
  for (const entry of entries) {
@@ -35705,26 +36480,26 @@ function readStoryGraph(source2) {
35705
36480
  };
35706
36481
  scan("\u4E16\u754C\u4E66");
35707
36482
  for (const category of LEDGER_NAMES) {
35708
- const path81 = "\u8D26\u672C/" + category + ".md";
36483
+ const path82 = "\u8D26\u672C/" + category + ".md";
35709
36484
  let raw;
35710
36485
  try {
35711
- raw = source2.read(path81);
36486
+ raw = source2.read(path82);
35712
36487
  } catch (error) {
35713
- if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
36488
+ if (error.code !== "not-found") warnings.push({ path: path82, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
35714
36489
  continue;
35715
36490
  }
35716
36491
  const ranges2 = createEvidenceRanges(raw);
35717
- sourceHashes[path81] = ranges2.hash;
35718
- const parsed = parseLedgerHistory(raw, category, path81);
36492
+ sourceHashes[path82] = ranges2.hash;
36493
+ const parsed = parseLedgerHistory(raw, category, path82);
35719
36494
  if (!parsed.ok) {
35720
- warnings.push({ path: path81, message: parsed.reason });
36495
+ warnings.push({ path: path82, message: parsed.reason });
35721
36496
  continue;
35722
36497
  }
35723
36498
  for (const [index, entry] of parsed.entries.entries()) {
35724
- const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path81 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
36499
+ const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path82 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
35725
36500
  const content = category === "\u65F6\u95F4\u7EBF" ? renderTimelineContent(entry) : entry.\u6B63\u6587;
35726
36501
  const evidenceId = id + ":" + entry.\u884C\u53F7;
35727
- const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path81, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
36502
+ const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path82, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
35728
36503
  const recordChapter2 = entryChapterNo(entry) ?? void 0;
35729
36504
  const storyTime = category === "\u65F6\u95F4\u7EBF" ? timelineStoryTime(entry) : void 0;
35730
36505
  const record4 = { ...base, recordChapter: recordChapter2, storyTime, historyBasis: recordChapter2 ? "recorded" : "unknown", evidenceId };
@@ -35745,11 +36520,11 @@ function readStoryGraph(source2) {
35745
36520
  links.push({ record: record4, targets: wiki(content), pair: false });
35746
36521
  }
35747
36522
  }
35748
- const resolve22 = (target, path81) => {
36523
+ const resolve22 = (target, path82) => {
35749
36524
  const name3 = target.replace(/^\[\[|\]\]$/g, "").replace(/@\d+$/, "").replace(/\\/g, "/");
35750
36525
  const found = aliases.get(name3);
35751
36526
  if (found?.size === 1) return [...found][0];
35752
- warnings.push({ path: path81, message: found?.size ? "\u540C\u540D\u6216\u522B\u540D\u4E0D\u552F\u4E00\uFF0C\u672A\u5408\u5E76\uFF1A" + name3 : "\u5F15\u7528\u672A\u627E\u5230\u5BF9\u5E94\u5B9E\u4F53\uFF1A" + name3 });
36527
+ warnings.push({ path: path82, message: found?.size ? "\u540C\u540D\u6216\u522B\u540D\u4E0D\u552F\u4E00\uFF0C\u672A\u5408\u5E76\uFF1A" + name3 : "\u5F15\u7528\u672A\u627E\u5230\u5BF9\u5E94\u5B9E\u4F53\uFF1A" + name3 });
35753
36528
  return void 0;
35754
36529
  };
35755
36530
  for (const item of links) {
@@ -35773,32 +36548,32 @@ function readStoryGraph(source2) {
35773
36548
  const currentBound = (items) => items.map((item) => item.currentOnlyAt === void 0 ? item : { ...item, currentOnlyAt: maxChapter });
35774
36549
  const withChapters = evidence.map((item) => {
35775
36550
  const references = terms(item.fields["\u6765\u6E90"]).map((value) => normalizeNodeKey(value.replace(/^\[\[|\]\]$/g, "").split("|")[0].replace(/@[^/@]+$/, ""))).filter((value) => !!value && /^定稿\/卷\d+\/\d{4}-[^/]+\.md$/.test(value));
35776
- return { ...item, relatedChapters: [...new Set(references)].map((path81) => ({ space: item.source.space, path: path81 })) };
36551
+ return { ...item, relatedChapters: [...new Set(references)].map((path82) => ({ space: item.source.space, path: path82 })) };
35777
36552
  });
35778
36553
  return { bookId: source2.bookId, bookName: source2.bookName, maxChapter, records: currentBound(records), edges: currentBound(edges), events, warnings, evidence: withChapters, entities, sourceHashes, fingerprint: fingerprint2, format: format2 };
35779
36554
  }
35780
36555
 
35781
36556
  // src/study/graph-source.ts
35782
- import * as fs61 from "node:fs";
35783
- import * as path72 from "node:path";
36557
+ import * as fs62 from "node:fs";
36558
+ import * as path73 from "node:path";
35784
36559
  import { createHash as createHash20 } from "node:crypto";
35785
36560
  function readGraphFile(base, relative12) {
35786
36561
  validateAuthorRelativePath(relative12);
35787
- const file = path72.join(base, relative12);
36562
+ const file = path73.join(base, relative12);
35788
36563
  const checkPhysical = () => {
35789
- if (stripDevicePrefix(fs61.realpathSync.native(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
36564
+ if (stripDevicePrefix(fs62.realpathSync.native(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
35790
36565
  };
35791
36566
  checkPhysical();
35792
- const initial = fs61.lstatSync(file);
36567
+ const initial = fs62.lstatSync(file);
35793
36568
  if (!initial.isFile() || initial.isSymbolicLink() || initial.nlink !== 1) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u662F\u72EC\u7ACB\u7684\u666E\u901A\u6587\u4EF6");
35794
36569
  if (initial.size > 4 * 1024 * 1024) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u8D85\u8FC74MiB\uFF0C\u672A\u622A\u65AD\u8BFB\u53D6");
35795
- const descriptor = fs61.openSync(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
36570
+ const descriptor = fs62.openSync(file, fs62.constants.O_RDONLY | (fs62.constants.O_NOFOLLOW ?? 0));
35796
36571
  try {
35797
- const opened = fs61.fstatSync(descriptor);
36572
+ const opened = fs62.fstatSync(descriptor);
35798
36573
  if (opened.dev !== initial.dev || opened.ino !== initial.ino || opened.nlink !== 1) throw new AuthorDocumentError("conflict", "\u56FE\u8C31\u6765\u6E90\u5728\u6253\u5F00\u65F6\u88AB\u66FF\u6362");
35799
- const bytes = fs61.readFileSync(descriptor);
36574
+ const bytes = fs62.readFileSync(descriptor);
35800
36575
  checkPhysical();
35801
- const current = fs61.lstatSync(file), finished = fs61.fstatSync(descriptor);
36576
+ const current = fs62.lstatSync(file), finished = fs62.fstatSync(descriptor);
35802
36577
  if (!current.isFile() || current.nlink !== 1 || current.dev !== opened.dev || current.ino !== opened.ino || finished.size !== opened.size || finished.mtimeMs !== opened.mtimeMs || finished.ctimeMs !== opened.ctimeMs) throw new AuthorDocumentError("conflict", "\u56FE\u8C31\u6765\u6E90\u5728\u8BFB\u53D6\u671F\u95F4\u5DF2\u53D8\u5316");
35803
36578
  if (bytes.length > 4 * 1024 * 1024 || bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5927\u5C0F\u6216\u6587\u672C\u683C\u5F0F\u4E0D\u53D7\u652F\u6301");
35804
36579
  try {
@@ -35807,26 +36582,26 @@ function readGraphFile(base, relative12) {
35807
36582
  throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u4F7F\u7528UTF-8");
35808
36583
  }
35809
36584
  } finally {
35810
- fs61.closeSync(descriptor);
36585
+ fs62.closeSync(descriptor);
35811
36586
  }
35812
36587
  }
35813
36588
  async function readGraphFileAsync(base, relative12, signal) {
35814
36589
  signal?.throwIfAborted();
35815
36590
  validateAuthorRelativePath(relative12);
35816
- const file = path72.join(base, relative12);
36591
+ const file = path73.join(base, relative12);
35817
36592
  const checkPhysical = async () => {
35818
- if (stripDevicePrefix(await fs61.promises.realpath(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
36593
+ if (stripDevicePrefix(await fs62.promises.realpath(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
35819
36594
  };
35820
36595
  await checkPhysical();
35821
- const initial = await fs61.promises.lstat(file);
36596
+ const initial = await fs62.promises.lstat(file);
35822
36597
  if (!initial.isFile() || initial.isSymbolicLink() || initial.nlink !== 1 || initial.size > 4 * 1024 * 1024) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u672C\u6587\u4EF6");
35823
- const handle = await fs61.promises.open(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
36598
+ const handle = await fs62.promises.open(file, fs62.constants.O_RDONLY | (fs62.constants.O_NOFOLLOW ?? 0));
35824
36599
  try {
35825
36600
  const opened = await handle.stat();
35826
36601
  if (opened.dev !== initial.dev || opened.ino !== initial.ino || opened.nlink !== 1) throw new AuthorDocumentError("conflict", "\u56FE\u8C31\u6765\u6E90\u5728\u6253\u5F00\u65F6\u88AB\u66FF\u6362");
35827
36602
  const bytes = await handle.readFile({ signal });
35828
36603
  await checkPhysical();
35829
- const current = await fs61.promises.lstat(file), finished = await handle.stat();
36604
+ const current = await fs62.promises.lstat(file), finished = await handle.stat();
35830
36605
  if (!current.isFile() || current.nlink !== 1 || current.dev !== opened.dev || current.ino !== opened.ino || finished.size !== opened.size || finished.mtimeMs !== opened.mtimeMs || finished.ctimeMs !== opened.ctimeMs) throw new AuthorDocumentError("conflict", "\u56FE\u8C31\u6765\u6E90\u5728\u8BFB\u53D6\u671F\u95F4\u5DF2\u53D8\u5316");
35831
36606
  if (bytes.length > 4 * 1024 * 1024 || bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5927\u5C0F\u6216\u6587\u672C\u683C\u5F0F\u4E0D\u53D7\u652F\u6301");
35832
36607
  try {
@@ -35846,12 +36621,12 @@ async function scanGraphFiles(root, space, signal) {
35846
36621
  if (depth > 12) return;
35847
36622
  try {
35848
36623
  const directory = authorDocumentPath(root, relative12, true);
35849
- const entries = await fs61.promises.readdir(directory, { withFileTypes: true });
36624
+ const entries = await fs62.promises.readdir(directory, { withFileTypes: true });
35850
36625
  const rows = entries.filter((item) => !item.name.startsWith(".") && item.name !== "node_modules").map((item) => ({
35851
36626
  name: item.name,
35852
36627
  directory: item.isDirectory(),
35853
36628
  draft: false,
35854
- ref: { space, path: path72.posix.join(relative12, item.name) },
36629
+ ref: { space, path: path73.posix.join(relative12, item.name) },
35855
36630
  ...item.isSymbolicLink() || !item.isFile() && !item.isDirectory() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
35856
36631
  }));
35857
36632
  directories.set(relative12, rows);
@@ -36076,10 +36851,10 @@ function overlayExtractions(graph, extractions) {
36076
36851
  }
36077
36852
 
36078
36853
  // src/indexing/graph-storage.ts
36079
- import * as fs62 from "node:fs";
36080
- import * as path73 from "node:path";
36854
+ import * as fs63 from "node:fs";
36855
+ import * as path74 from "node:path";
36081
36856
  import { createRequire as createRequire2 } from "node:module";
36082
- import { createHash as createHash21, randomUUID as randomUUID8 } from "node:crypto";
36857
+ import { createHash as createHash21, randomUUID as randomUUID9 } from "node:crypto";
36083
36858
  var APPLICATION_ID2 = 1465272113;
36084
36859
  var CACHE_NAME = "story-graph.sqlite";
36085
36860
  var STATE_NAME = "story-graph-state.json";
@@ -36099,24 +36874,24 @@ function initialGraphState(bookId2) {
36099
36874
  }
36100
36875
  function graphFile(root, name3) {
36101
36876
  if (!/^(?:story-graph\.sqlite(?:-(?:journal|wal|shm))?|story-graph-state\.json|story-graph\.worker\.lock)$/.test(name3)) throw new Error("\u56FE\u8C31\u8FD0\u884C\u6587\u4EF6\u540D\u65E0\u6548");
36102
- const runtime = path73.join(root, ".webnovel");
36103
- for (const [target, directory] of [[runtime, true], [path73.join(runtime, name3), false]]) {
36877
+ const runtime = path74.join(root, ".webnovel");
36878
+ for (const [target, directory] of [[runtime, true], [path74.join(runtime, name3), false]]) {
36104
36879
  try {
36105
- const stat = fs62.lstatSync(target);
36880
+ const stat = fs63.lstatSync(target);
36106
36881
  if (stat.isSymbolicLink() || (directory ? !stat.isDirectory() : !stat.isFile() || stat.nlink !== 1)) throw new Error("\u56FE\u8C31\u7F13\u5B58\u4F4D\u7F6E\u88AB\u94FE\u63A5\u6216\u5176\u4ED6\u6587\u4EF6\u5360\u7528\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
36107
36882
  } catch (error) {
36108
36883
  if (error.code !== "ENOENT") throw error;
36109
36884
  }
36110
36885
  }
36111
- return path73.join(runtime, name3);
36886
+ return path74.join(runtime, name3);
36112
36887
  }
36113
36888
  function readGraphState(root, bookId2) {
36114
36889
  const file = graphFile(root, STATE_NAME);
36115
- if (!fs62.existsSync(file)) return initialGraphState(bookId2);
36116
- if (fs62.statSync(file).size > 32768) throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u8FC7\u5927\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
36890
+ if (!fs63.existsSync(file)) return initialGraphState(bookId2);
36891
+ if (fs63.statSync(file).size > 32768) throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u8FC7\u5927\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
36117
36892
  let value;
36118
36893
  try {
36119
- value = JSON.parse(fs62.readFileSync(file, "utf8"));
36894
+ value = JSON.parse(fs63.readFileSync(file, "utf8"));
36120
36895
  } catch {
36121
36896
  throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
36122
36897
  }
@@ -36124,14 +36899,14 @@ function readGraphState(root, bookId2) {
36124
36899
  return value;
36125
36900
  }
36126
36901
  function writeGraphState(root, state) {
36127
- const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID8()}.tmp`;
36902
+ const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID9()}.tmp`;
36128
36903
  try {
36129
- fs62.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
36904
+ fs63.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
36130
36905
  graphFile(root, STATE_NAME);
36131
- fs62.renameSync(temporary, file);
36906
+ fs63.renameSync(temporary, file);
36132
36907
  } finally {
36133
36908
  try {
36134
- fs62.unlinkSync(temporary);
36909
+ fs63.unlinkSync(temporary);
36135
36910
  } catch {
36136
36911
  }
36137
36912
  }
@@ -36145,11 +36920,11 @@ function changeGraphState(root, bookId2, update) {
36145
36920
  }
36146
36921
  function acquireGraphLease(root) {
36147
36922
  return withBookLockAsync(root, async () => {
36148
- const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID8();
36149
- if (fs62.existsSync(file)) {
36923
+ const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID9();
36924
+ if (fs63.existsSync(file)) {
36150
36925
  let pid;
36151
36926
  try {
36152
- pid = JSON.parse(fs62.readFileSync(file, "utf8")).pid;
36927
+ pid = JSON.parse(fs63.readFileSync(file, "utf8")).pid;
36153
36928
  } catch {
36154
36929
  throw new Error("\u56FE\u8C31\u4EFB\u52A1\u9501\u65E0\u6CD5\u89E3\u6790\uFF0C\u672A\u6E05\u7406\u539F\u6587\u4EF6");
36155
36930
  }
@@ -36161,12 +36936,12 @@ function acquireGraphLease(root) {
36161
36936
  dead2 = error.code === "ESRCH";
36162
36937
  }
36163
36938
  if (!dead2) throw new Error("\u53E6\u4E00\u56FE\u8C31\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C");
36164
- fs62.unlinkSync(graphFile(root, "story-graph.worker.lock"));
36939
+ fs63.unlinkSync(graphFile(root, "story-graph.worker.lock"));
36165
36940
  }
36166
- fs62.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
36941
+ fs63.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
36167
36942
  return () => {
36168
36943
  try {
36169
- if (JSON.parse(fs62.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs62.unlinkSync(file);
36944
+ if (JSON.parse(fs63.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs63.unlinkSync(file);
36170
36945
  } catch {
36171
36946
  }
36172
36947
  };
@@ -36174,20 +36949,20 @@ function acquireGraphLease(root) {
36174
36949
  }
36175
36950
  function graphCacheSignature(root) {
36176
36951
  const file = graphFile(root, CACHE_NAME);
36177
- return fs62.existsSync(file) ? createHash21("sha256").update(fs62.readFileSync(file)).digest("hex") : "missing";
36952
+ return fs63.existsSync(file) ? createHash21("sha256").update(fs63.readFileSync(file)).digest("hex") : "missing";
36178
36953
  }
36179
36954
  function cacheHeader(file) {
36180
- const header2 = Buffer.alloc(100), handle = fs62.openSync(file, "r");
36955
+ const header2 = Buffer.alloc(100), handle = fs63.openSync(file, "r");
36181
36956
  try {
36182
- fs62.readSync(handle, header2, 0, 100, 0);
36957
+ fs63.readSync(handle, header2, 0, 100, 0);
36183
36958
  } finally {
36184
- fs62.closeSync(handle);
36959
+ fs63.closeSync(handle);
36185
36960
  }
36186
36961
  return header2;
36187
36962
  }
36188
36963
  function replaceGraphCache(root, bookId2) {
36189
36964
  const file = graphFile(root, CACHE_NAME);
36190
- if (!fs62.existsSync(file)) return;
36965
+ if (!fs63.existsSync(file)) return;
36191
36966
  const header2 = cacheHeader(file);
36192
36967
  if (header2.subarray(0, 16).toString() !== "SQLite format 3\0" || header2.readUInt32BE(68) !== APPLICATION_ID2) throw new Error("\u8BE5\u4F4D\u7F6E\u4E0D\u662F\u53EF\u786E\u8BA4\u7684\u56FE\u8C31\u7F13\u5B58\uFF0C\u672A\u79FB\u52A8\u539F\u6587\u4EF6");
36193
36968
  let db;
@@ -36203,16 +36978,16 @@ function replaceGraphCache(root, bookId2) {
36203
36978
  } catch {
36204
36979
  }
36205
36980
  }
36206
- const suffix = `.replaced-${randomUUID8()}`, moved = [];
36981
+ const suffix = `.replaced-${randomUUID9()}`, moved = [];
36207
36982
  try {
36208
36983
  for (const ending of ["", "-journal", "-wal", "-shm"]) {
36209
36984
  const source2 = graphFile(root, CACHE_NAME + ending), target = source2 + suffix;
36210
- if (!fs62.existsSync(source2)) continue;
36211
- fs62.renameSync(source2, target);
36985
+ if (!fs63.existsSync(source2)) continue;
36986
+ fs63.renameSync(source2, target);
36212
36987
  moved.push([source2, target]);
36213
36988
  }
36214
36989
  } catch (error) {
36215
- for (const [source2, target] of moved.reverse()) if (!fs62.existsSync(source2)) fs62.renameSync(target, source2);
36990
+ for (const [source2, target] of moved.reverse()) if (!fs63.existsSync(source2)) fs63.renameSync(target, source2);
36216
36991
  throw error;
36217
36992
  }
36218
36993
  }
@@ -36233,7 +37008,7 @@ function readGraphCache(root, bookId2) {
36233
37008
  let db;
36234
37009
  try {
36235
37010
  const file = graphFile(root, CACHE_NAME);
36236
- if (!fs62.existsSync(file)) return { status: "missing", extractions: [] };
37011
+ if (!fs63.existsSync(file)) return { status: "missing", extractions: [] };
36237
37012
  const header2 = cacheHeader(file);
36238
37013
  if (header2.subarray(0, 16).toString() !== "SQLite format 3\0" || header2.readUInt32BE(68) !== APPLICATION_ID2) throw new Error("\u8BE5\u4F4D\u7F6E\u4E0D\u662F\u53EF\u786E\u8BA4\u7684\u56FE\u8C31\u7F13\u5B58\uFF0C\u672A\u6253\u5F00\u539F\u6587\u4EF6");
36239
37014
  if (header2[18] !== 1 || header2[19] !== 1) throw new Error("\u56FE\u8C31\u7F13\u5B58\u4F7F\u7528\u4E86\u5176\u4ED6\u65E5\u5FD7\u6A21\u5F0F\uFF0C\u8BF7\u663E\u5F0F\u91CD\u5EFA\uFF1B\u8BFB\u53D6\u672A\u521B\u5EFA\u8F85\u52A9\u6587\u4EF6");
@@ -36255,7 +37030,7 @@ function readGraphCache(root, bookId2) {
36255
37030
  }
36256
37031
  }
36257
37032
  function saveGraphCache(root, graph, extraction) {
36258
- const filename = graphFile(root, CACHE_NAME), exists3 = fs62.existsSync(filename);
37033
+ const filename = graphFile(root, CACHE_NAME), exists3 = fs63.existsSync(filename);
36259
37034
  if (exists3) {
36260
37035
  const header2 = cacheHeader(filename);
36261
37036
  if (header2.subarray(0, 16).toString() !== "SQLite format 3\0" || header2.readUInt32BE(68) !== APPLICATION_ID2 || header2[18] !== 1 || header2[19] !== 1) throw new Error("\u56FE\u8C31\u7F13\u5B58\u4E0D\u53EF\u5199\uFF0C\u539F\u6587\u4EF6\u5DF2\u4FDD\u7559");
@@ -36304,9 +37079,9 @@ function routeForDocument(ref2) {
36304
37079
  return "\u6821\u51C6\u4F5C\u54C1\u73B0\u72B6\uFF0C\u518D\u6309\u4FEE\u6539\u5185\u5BB9\u9009\u62E9\u5BF9\u5E94\u8282\u70B9";
36305
37080
  }
36306
37081
  function textOf(target) {
36307
- if (!fs63.existsSync(target) || !fs63.statSync(target).isFile()) throw new AuthorDocumentError("not-found", "\u6587\u4EF6\u4E0D\u5B58\u5728");
36308
- if (fs63.statSync(target).size > MAX_DOCUMENT_BYTES2) throw new AuthorDocumentError("read-only", "\u6587\u4EF6\u8D85\u8FC7 4 MiB\uFF0C\u4E0D\u80FD\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\uFF1B\u5185\u5BB9\u672A\u622A\u65AD");
36309
- const bytes = fs63.readFileSync(target);
37082
+ if (!fs64.existsSync(target) || !fs64.statSync(target).isFile()) throw new AuthorDocumentError("not-found", "\u6587\u4EF6\u4E0D\u5B58\u5728");
37083
+ if (fs64.statSync(target).size > MAX_DOCUMENT_BYTES2) throw new AuthorDocumentError("read-only", "\u6587\u4EF6\u8D85\u8FC7 4 MiB\uFF0C\u4E0D\u80FD\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\uFF1B\u5185\u5BB9\u672A\u622A\u65AD");
37084
+ const bytes = fs64.readFileSync(target);
36310
37085
  if (bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u8BE5\u6587\u4EF6\u4E0D\u662F\u6587\u672C\u6587\u4EF6");
36311
37086
  try {
36312
37087
  return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -36326,7 +37101,7 @@ var ORPHAN_SIGNALS = ["\u4E66\u7C4D\u4FE1\u606F.json", "\u6545\u4E8B\u5927\u7EB2
36326
37101
  function orphanSignals(dir) {
36327
37102
  let entries;
36328
37103
  try {
36329
- entries = fs63.readdirSync(dir);
37104
+ entries = fs64.readdirSync(dir);
36330
37105
  } catch {
36331
37106
  return void 0;
36332
37107
  }
@@ -36338,18 +37113,18 @@ function scanOrphanDrafts(workspace, bookNames) {
36338
37113
  const scanLevel = (parent, prefix, skip) => {
36339
37114
  let entries;
36340
37115
  try {
36341
- entries = fs63.readdirSync(parent, { withFileTypes: true });
37116
+ entries = fs64.readdirSync(parent, { withFileTypes: true });
36342
37117
  } catch {
36343
37118
  return;
36344
37119
  }
36345
37120
  for (const entry of entries) {
36346
37121
  if (!entry.isDirectory() || skip.has(entry.name)) continue;
36347
- const signals = orphanSignals(path74.join(parent, entry.name));
37122
+ const signals = orphanSignals(path75.join(parent, entry.name));
36348
37123
  if (signals !== void 0) orphans.push({ name: entry.name, path: prefix + entry.name, detail: `\u542B ${signals.join("\u3001")}` });
36349
37124
  }
36350
37125
  };
36351
37126
  scanLevel(workspace, "", /* @__PURE__ */ new Set([...bookNames, "\u4E66\u623F"]));
36352
- scanLevel(path74.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
37127
+ scanLevel(path75.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
36353
37128
  return orphans;
36354
37129
  }
36355
37130
  var StudyService = class {
@@ -36357,19 +37132,19 @@ var StudyService = class {
36357
37132
  constructor(workspace) {
36358
37133
  if (!isFullyQualifiedPath(workspace)) throw new AuthorDocumentError("invalid-path", "\u5DE5\u4F5C\u8303\u56F4\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
36359
37134
  this.workspace = canonicalizePath(workspace);
36360
- if (!fs63.existsSync(this.workspace) || !fs63.statSync(this.workspace).isDirectory()) throw new AuthorDocumentError("not-found", "\u5DE5\u4F5C\u8303\u56F4\u76EE\u5F55\u4E0D\u5B58\u5728");
37135
+ if (!fs64.existsSync(this.workspace) || !fs64.statSync(this.workspace).isDirectory()) throw new AuthorDocumentError("not-found", "\u5DE5\u4F5C\u8303\u56F4\u76EE\u5F55\u4E0D\u5B58\u5728");
36361
37136
  }
36362
37137
  source(space) {
36363
37138
  if (space === "shared") {
36364
37139
  const root2 = authorDocumentPath(this.workspace, "\u4E66\u623F");
36365
- if (!fs63.existsSync(root2)) throw new AuthorDocumentError("not-found", "\u5F53\u524D\u5DE5\u4F5C\u8303\u56F4\u5C1A\u65E0\u5171\u4EAB\u8D44\u6599");
36366
- if (fs63.existsSync(path74.join(root2, paths.\u5951\u7EA6()))) throw new AuthorDocumentError("read-only", "\u5171\u4EAB\u76EE\u5F55\u4E0E\u4E66\u4ED3\u91CD\u53E0\uFF0C\u8BF7\u901A\u8FC7\u4E66\u76EE\u5165\u53E3\u8BBF\u95EE\uFF1B\u5171\u4EAB\u5199\u5165\u5DF2\u5173\u95ED");
37140
+ if (!fs64.existsSync(root2)) throw new AuthorDocumentError("not-found", "\u5F53\u524D\u5DE5\u4F5C\u8303\u56F4\u5C1A\u65E0\u5171\u4EAB\u8D44\u6599");
37141
+ if (fs64.existsSync(path75.join(root2, paths.\u5951\u7EA6()))) throw new AuthorDocumentError("read-only", "\u5171\u4EAB\u76EE\u5F55\u4E0E\u4E66\u4ED3\u91CD\u53E0\uFF0C\u8BF7\u901A\u8FC7\u4E66\u76EE\u5165\u53E3\u8BBF\u95EE\uFF1B\u5171\u4EAB\u5199\u5165\u5DF2\u5173\u95ED");
36367
37142
  return { root: root2, owner: "\u5171\u4EAB\u8D44\u6599" };
36368
37143
  }
36369
37144
  const books = scanWorkspaceBooks(this.workspace).filter((book2) => book2.bookId && "book:" + book2.bookId === space);
36370
37145
  if (books.length !== 1) throw new AuthorDocumentError("not-found", "\u4E66\u76EE\u4E0D\u5B58\u5728\u6216\u4E66id\u4E0D\u552F\u4E00");
36371
37146
  const book = books[0];
36372
- const root = authorDocumentPath(this.workspace, path74.relative(this.workspace, book.root));
37147
+ const root = authorDocumentPath(this.workspace, path75.relative(this.workspace, book.root));
36373
37148
  return { root, owner: book.name, bookId: book.bookId };
36374
37149
  }
36375
37150
  shelf() {
@@ -36384,7 +37159,7 @@ var StudyService = class {
36384
37159
  let shared = false;
36385
37160
  let sharedError;
36386
37161
  try {
36387
- shared = fs63.statSync(this.source("shared").root).isDirectory();
37162
+ shared = fs64.statSync(this.source("shared").root).isDirectory();
36388
37163
  } catch (error) {
36389
37164
  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";
36390
37165
  }
@@ -36425,12 +37200,12 @@ var StudyService = class {
36425
37200
  // once for tree badges and a second time for the evidence itself.
36426
37201
  list: (relative12) => {
36427
37202
  const directory = authorDocumentPath(source2.root, relative12, true);
36428
- if (!fs63.existsSync(directory)) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36429
- return fs63.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => ({
37203
+ if (!fs64.existsSync(directory)) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
37204
+ return fs64.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => ({
36430
37205
  name: entry.name,
36431
37206
  directory: entry.isDirectory(),
36432
37207
  draft: false,
36433
- ref: { space, path: path74.posix.join(relative12, entry.name) },
37208
+ ref: { space, path: path75.posix.join(relative12, entry.name) },
36434
37209
  ...entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
36435
37210
  }));
36436
37211
  },
@@ -36500,13 +37275,13 @@ var StudyService = class {
36500
37275
  }
36501
37276
  treeAt(source2, ref2) {
36502
37277
  const directory = authorDocumentPath(source2.root, ref2.path, true);
36503
- if (!fs63.existsSync(directory) || !fs63.statSync(directory).isDirectory()) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36504
- return fs63.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => {
36505
- const relative12 = path74.posix.join(ref2.path, entry.name);
37278
+ if (!fs64.existsSync(directory) || !fs64.statSync(directory).isDirectory()) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
37279
+ return fs64.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => {
37280
+ const relative12 = path75.posix.join(ref2.path, entry.name);
36506
37281
  const item = { ref: { space: ref2.space, path: relative12 }, name: entry.name, directory: entry.isDirectory(), draft: ref2.space !== "shared" && relative12.startsWith("\u8349\u7A3F\u533A") };
36507
37282
  try {
36508
37283
  const target = authorDocumentPath(source2.root, relative12);
36509
- const info = fs63.statSync(target);
37284
+ const info = fs64.statSync(target);
36510
37285
  if (!info.isDirectory() && !info.isFile()) return { ...item, error: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B" };
36511
37286
  const badge = info.isFile() && entry.name.endsWith(".md") && info.size <= MAX_DOCUMENT_BYTES2 ? fieldLabel(textOf(target)).badge : void 0;
36512
37287
  return { ...item, absolutePath: target, directory: info.isDirectory(), ...badge ? { badge } : {} };
@@ -36524,7 +37299,7 @@ var StudyService = class {
36524
37299
  read(ref2) {
36525
37300
  const source2 = this.source(ref2.space);
36526
37301
  const absolutePath = authorDocumentPath(source2.root, ref2.path);
36527
- ref2 = { ...ref2, path: path74.relative(canonicalizePath(source2.root), absolutePath).split(path74.sep).join("/") };
37302
+ ref2 = { ...ref2, path: path75.relative(canonicalizePath(source2.root), absolutePath).split(path75.sep).join("/") };
36528
37303
  const text5 = textOf(absolutePath);
36529
37304
  const parsed = parseDocument(text5);
36530
37305
  const metadata2 = fieldLabel(text5);
@@ -36532,7 +37307,7 @@ var StudyService = class {
36532
37307
  return {
36533
37308
  ref: ref2,
36534
37309
  owner: source2.owner,
36535
- name: path74.basename(ref2.path),
37310
+ name: path75.basename(ref2.path),
36536
37311
  absolutePath,
36537
37312
  body: parsed.ok ? parsed.data.body : text5,
36538
37313
  hash: documentHash(text5),
@@ -36551,14 +37326,14 @@ var StudyService = class {
36551
37326
  return null;
36552
37327
  }
36553
37328
  }
36554
- absolutePath = path74.resolve(this.workspace, absolutePath);
37329
+ absolutePath = path75.resolve(this.workspace, absolutePath);
36555
37330
  }
36556
37331
  const spaces = this.shelf().books.filter((book) => !book.error).map((book) => book.id);
36557
37332
  spaces.push("shared");
36558
37333
  for (const space of spaces) {
36559
37334
  try {
36560
37335
  const source2 = this.source(space);
36561
- const relative12 = path74.relative(source2.root, absolutePath).split(path74.sep).join("/");
37336
+ const relative12 = path75.relative(source2.root, absolutePath).split(path75.sep).join("/");
36562
37337
  return this.read({ space, path: relative12 });
36563
37338
  } catch {
36564
37339
  }
@@ -36571,7 +37346,7 @@ var StudyService = class {
36571
37346
  const scanned = scanWorkspaceBooks(this.workspace);
36572
37347
  const spaces = scanned.filter((book) => book.bookId && scanned.filter((other) => other.bookId === book.bookId).length === 1).map((book) => "book:" + book.bookId);
36573
37348
  try {
36574
- if (fs63.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
37349
+ if (fs64.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
36575
37350
  } catch {
36576
37351
  }
36577
37352
  const term = query.trim().toLocaleLowerCase();
@@ -36638,7 +37413,7 @@ var StudyService = class {
36638
37413
  const status = deriveChapterFacts(facts);
36639
37414
  const pending = findPendingReviewDraft(source2.root, key);
36640
37415
  const candidates = [paths.\u5B9A\u7A3F\u7AE0(key.\u5377, key.\u7AE0, key.\u7AE0\u540D), ...pending ? [pending.relPath] : [], paths.\u786E\u8BA4\u7EC6\u7EB2(key.\u5377, key.\u7AE0, key.\u7AE0\u540D), paths.\u5019\u9009\u7EC6\u7EB2(key.\u5377, key.\u7AE0\u540D)];
36641
- const relative12 = candidates.find((candidate) => fs63.existsSync(path74.join(source2.root, candidate)));
37416
+ const relative12 = candidates.find((candidate) => fs64.existsSync(path75.join(source2.root, candidate)));
36642
37417
  return { volume: key.\u5377, chapter: key.\u7AE0, title: key.\u7AE0\u540D, status: status.\u5EFA\u8BAE.\u73AF\u8282, finalized: facts.\u5DF2\u5B9A\u7A3F, ...relative12 ? { source: { space, path: relative12 } } : {} };
36643
37418
  })
36644
37419
  };
@@ -37586,8 +38361,8 @@ function brandString(value) {
37586
38361
  }
37587
38362
 
37588
38363
  // src/native-write.ts
37589
- import { randomUUID as randomUUID9 } from "node:crypto";
37590
- import * as path75 from "node:path";
38364
+ import { randomUUID as randomUUID10 } from "node:crypto";
38365
+ import * as path76 from "node:path";
37591
38366
  import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
37592
38367
  function nativeToolRuntime(ctx) {
37593
38368
  const pipeline = new ToolExecutionPipeline(ctx);
@@ -37618,8 +38393,8 @@ function createNativeWriteBridge(runtime) {
37618
38393
  exec.signal.throwIfAborted();
37619
38394
  const target = resolveInsideBook(root, op.relPath);
37620
38395
  if (!target.ok) throw new Error("\u539F\u751F\u5199\u5165\u76EE\u6807\u4E0D\u5728\u4E66\u4ED3\u5185");
37621
- const file = path75.resolve(root, target.relPath);
37622
- const callId = brandString(`webnovel-write-${randomUUID9()}`);
38396
+ const file = path76.resolve(root, target.relPath);
38397
+ const callId = brandString(`webnovel-write-${randomUUID10()}`);
37623
38398
  pending.set(callId, { parent: exec.token, agent: exec.agent, file, content: op.content });
37624
38399
  try {
37625
38400
  const result = await runtime.execute({
@@ -37642,10 +38417,10 @@ function createNativeWriteBridge(runtime) {
37642
38417
  }
37643
38418
 
37644
38419
  // src/indexing/manager.ts
37645
- import * as fs64 from "node:fs";
38420
+ import * as fs65 from "node:fs";
37646
38421
 
37647
38422
  // src/indexing/git.ts
37648
- import * as path76 from "node:path";
38423
+ import * as path77 from "node:path";
37649
38424
  import { execFile } from "node:child_process";
37650
38425
  async function git(root, args) {
37651
38426
  return new Promise((resolve22) => execFile("git", ["--literal-pathspecs", "-C", root, ...args], {
@@ -37671,8 +38446,8 @@ async function bookGitWatchPaths(root) {
37671
38446
  git(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"])
37672
38447
  ]);
37673
38448
  return [...new Set(directories.filter((value) => !!value?.trim()).flatMap((value) => {
37674
- const directory = path76.resolve(root, value.trim());
37675
- return [directory, path76.join(directory, "refs")];
38449
+ const directory = path77.resolve(root, value.trim());
38450
+ return [directory, path77.join(directory, "refs")];
37676
38451
  }))];
37677
38452
  }
37678
38453
 
@@ -38079,7 +38854,7 @@ var BookIndexManager = class {
38079
38854
  for (const directory of await bookGitWatchPaths(record4.book.root)) {
38080
38855
  if (this.closing) return;
38081
38856
  try {
38082
- const watcher = fs64.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
38857
+ const watcher = fs65.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
38083
38858
  const name3 = filename?.toString().replaceAll("\\", "/");
38084
38859
  if (directory.endsWith("refs") || !name3 || /^(HEAD|packed-refs|refs)(\/|$)/.test(name3)) {
38085
38860
  this.scheduleProbe(record4);
@@ -38453,7 +39228,7 @@ function indexFailureMessage(book, notice) {
38453
39228
  }
38454
39229
 
38455
39230
  // src/reference/host.ts
38456
- import * as path77 from "node:path";
39231
+ import * as path78 from "node:path";
38457
39232
  import { BlockAssembler, createUserMessage as createUserMessage4 } from "@deepseek-ai/dsh-llm";
38458
39233
  var ReferenceHost = class {
38459
39234
  constructor(access) {
@@ -38471,26 +39246,26 @@ var ReferenceHost = class {
38471
39246
  async readFile(agent, workspace, filename, signal) {
38472
39247
  const active = AbortSignal.any([this.shutdown.signal, ...signal ? [signal] : []]);
38473
39248
  active.throwIfAborted();
38474
- const fs68 = this.access.fs(agent);
38475
- if (!fs68) throw new ReferenceError2("fs-unavailable", "DSH \u6587\u4EF6\u670D\u52A1\u4E0D\u53EF\u7528");
38476
- if (!path77.isAbsolute(filename)) throw new ReferenceError2("source-path", "\u8BF7\u9009\u62E9\u539F\u6587\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");
38477
- const mapped = fs68.processPathFromHostPath(filename), workspacePath = fs68.processPathFromHostPath(workspace);
39249
+ const fs69 = this.access.fs(agent);
39250
+ if (!fs69) throw new ReferenceError2("fs-unavailable", "DSH \u6587\u4EF6\u670D\u52A1\u4E0D\u53EF\u7528");
39251
+ if (!path78.isAbsolute(filename)) throw new ReferenceError2("source-path", "\u8BF7\u9009\u62E9\u539F\u6587\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");
39252
+ const mapped = fs69.processPathFromHostPath(filename), workspacePath = fs69.processPathFromHostPath(workspace);
38478
39253
  if (!mapped || !workspacePath) throw new ReferenceError2("fs-world", "\u8BE5\u6587\u4EF6\u6216\u5DE5\u4F5C\u8303\u56F4\u65E0\u6CD5\u6620\u5C04\u5230\u5F53\u524D\u6267\u884C\u73AF\u5883\uFF1B\u672A\u56DE\u9000\u5230\u5176\u4ED6\u6587\u4EF6\u7CFB\u7EDF\u8BFB\u53D6");
38479
- const info = await fs68.lstat(mapped, void 0, active);
39254
+ const info = await fs69.lstat(mapped, void 0, active);
38480
39255
  if (info?.type !== "file") throw new ReferenceError2("source-type", "\u539F\u6587\u5FC5\u987B\u662F\u660E\u786E\u9009\u5B9A\u7684\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u63A5\u53D7\u76EE\u5F55\u6216\u94FE\u63A5");
38481
- let ancestor = path77.dirname(mapped);
38482
- while (path77.dirname(ancestor) !== ancestor) {
38483
- if ((await fs68.lstat(ancestor, void 0, active))?.type !== "directory") throw new ReferenceError2("source-type", "\u539F\u6587\u7684\u7956\u5148\u76EE\u5F55\u5305\u542B\u94FE\u63A5\u6216\u4E0D\u53EF\u8BBF\u95EE\u8DEF\u5F84");
38484
- ancestor = path77.dirname(ancestor);
38485
- }
38486
- const target = await fs68.resolve(mapped, { signal: active });
38487
- const library = await fs68.resolve(path77.join(workspacePath, "\u4E66\u623F/\u53C2\u8003\u4E66"), { signal: active });
38488
- if (fs68.contains(library, target)) throw new ReferenceError2("source-path", "\u539F\u6587\u4EF6\u4E0D\u80FD\u4F4D\u4E8E\u5F85\u6E05\u9664\u7684\u53D7\u7BA1\u53C2\u8003\u5E93\u5185");
38489
- const before = await fs68.stat(target, active);
39256
+ let ancestor = path78.dirname(mapped);
39257
+ while (path78.dirname(ancestor) !== ancestor) {
39258
+ if ((await fs69.lstat(ancestor, void 0, active))?.type !== "directory") throw new ReferenceError2("source-type", "\u539F\u6587\u7684\u7956\u5148\u76EE\u5F55\u5305\u542B\u94FE\u63A5\u6216\u4E0D\u53EF\u8BBF\u95EE\u8DEF\u5F84");
39259
+ ancestor = path78.dirname(ancestor);
39260
+ }
39261
+ const target = await fs69.resolve(mapped, { signal: active });
39262
+ const library = await fs69.resolve(path78.join(workspacePath, "\u4E66\u623F/\u53C2\u8003\u4E66"), { signal: active });
39263
+ if (fs69.contains(library, target)) throw new ReferenceError2("source-path", "\u539F\u6587\u4EF6\u4E0D\u80FD\u4F4D\u4E8E\u5F85\u6E05\u9664\u7684\u53D7\u7BA1\u53C2\u8003\u5E93\u5185");
39264
+ const before = await fs69.stat(target, active);
38490
39265
  if (before?.type !== "file" || before.size !== void 0 && before.size > REFERENCE_LIMITS.sourceBytes) throw new ReferenceError2("source-limit", "\u6E90\u6587\u4EF6\u4E0D\u53EF\u8BFB\u6216\u8D85\u8FC7 64 MiB");
38491
- const bytes = await fs68.readBytes(target, active, REFERENCE_LIMITS.sourceBytes);
38492
- const afterTarget = await fs68.resolve(mapped, { signal: active }), after = await fs68.stat(afterTarget, active);
38493
- const afterPath = await fs68.lstat(mapped, void 0, active);
39266
+ const bytes = await fs69.readBytes(target, active, REFERENCE_LIMITS.sourceBytes);
39267
+ const afterTarget = await fs69.resolve(mapped, { signal: active }), after = await fs69.stat(afterTarget, active);
39268
+ const afterPath = await fs69.lstat(mapped, void 0, active);
38494
39269
  if (afterTarget.targetKey !== target.targetKey || after?.version !== before.version || afterPath?.version !== info.version || afterPath.type !== "file") throw new ReferenceError2("source-changed", "\u6E90\u6587\u4EF6\u5728\u8BFB\u53D6\u671F\u95F4\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u68C0");
38495
39270
  active.throwIfAborted();
38496
39271
  return bytes;
@@ -38552,7 +39327,9 @@ var ReferenceHost = class {
38552
39327
  var WEBNOVEL_SETTINGS_NAMESPACE = "webnovel";
38553
39328
  var VISUAL_MODES = ["workflow", "graph", "chapters"];
38554
39329
  var GRAPH_PERSPECTIVES = ["author", "reader"];
39330
+ var AUTOMATION_MODES = ["semi-auto", "auto", "manual"];
38555
39331
  var DEFAULT_WEBNOVEL_PREFERENCES = {
39332
+ automationMode: "semi-auto",
38556
39333
  autoIndexOnCommit: false,
38557
39334
  showVisualTab: true,
38558
39335
  showLayoutSwap: true,
@@ -38573,6 +39350,9 @@ function isVisualMode(value) {
38573
39350
  function isGraphPerspective(value) {
38574
39351
  return typeof value === "string" && GRAPH_PERSPECTIVES.includes(value);
38575
39352
  }
39353
+ function isAutomationMode(value) {
39354
+ return typeof value === "string" && AUTOMATION_MODES.includes(value);
39355
+ }
38576
39356
  function hasExplicitAutoIndex(raw) {
38577
39357
  return isRecord(raw) && typeof raw.autoIndexOnCommit === "boolean";
38578
39358
  }
@@ -38580,6 +39360,7 @@ function normalizeWebnovelPreferences(raw) {
38580
39360
  const source2 = isRecord(raw) ? raw : {};
38581
39361
  const bool = (key) => typeof source2[key] === "boolean" ? source2[key] : DEFAULT_WEBNOVEL_PREFERENCES[key];
38582
39362
  return {
39363
+ automationMode: isAutomationMode(source2.automationMode) ? source2.automationMode : DEFAULT_WEBNOVEL_PREFERENCES.automationMode,
38583
39364
  autoIndexOnCommit: bool("autoIndexOnCommit"),
38584
39365
  showVisualTab: bool("showVisualTab"),
38585
39366
  showLayoutSwap: bool("showLayoutSwap"),
@@ -38598,6 +39379,7 @@ function validateWebnovelPreferences(raw) {
38598
39379
  }
38599
39380
  if (raw.defaultVisualMode !== void 0 && !isVisualMode(raw.defaultVisualMode)) throw new Error("\u9ED8\u8BA4\u53EF\u89C6\u5316\u5B50\u89C6\u56FE\u65E0\u6548");
38600
39381
  if (raw.defaultGraphPerspective !== void 0 && !isGraphPerspective(raw.defaultGraphPerspective)) throw new Error("\u4EBA\u7269\u5173\u7CFB\u9ED8\u8BA4\u89C6\u89D2\u65E0\u6548");
39382
+ if (raw.automationMode !== void 0 && !isAutomationMode(raw.automationMode)) throw new Error("\u521B\u4F5C\u6D41\u7A0B\u81EA\u52A8\u5316\u6A21\u5F0F\u65E0\u6548");
38601
39383
  return raw;
38602
39384
  }
38603
39385
 
@@ -38636,8 +39418,8 @@ function createIndexAutoPreference(settings, fallback) {
38636
39418
  }
38637
39419
 
38638
39420
  // src/scripts/deterministic-checks.ts
38639
- import * as fs65 from "node:fs";
38640
- import * as path78 from "node:path";
39421
+ import * as fs66 from "node:fs";
39422
+ import * as path79 from "node:path";
38641
39423
  function parseArgs(argv) {
38642
39424
  const values = /* @__PURE__ */ new Map();
38643
39425
  for (let i = 0; i < argv.length; i += 1) {
@@ -38667,8 +39449,8 @@ function runChecksCli(argv) {
38667
39449
  console.error(`\u524D\u7F6E\u53C2\u6570\u9519\u8BEF\uFF1A${err instanceof Error ? err.message : String(err)}`);
38668
39450
  return 1;
38669
39451
  }
38670
- if (!fs65.existsSync(args.book) || !fs65.statSync(args.book).isDirectory()) {
38671
- console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path78.resolve(args.book)}`);
39452
+ if (!fs66.existsSync(args.book) || !fs66.statSync(args.book).isDirectory()) {
39453
+ console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path79.resolve(args.book)}`);
38672
39454
  return 1;
38673
39455
  }
38674
39456
  try {
@@ -38702,8 +39484,8 @@ function runChecksCli(argv) {
38702
39484
  }
38703
39485
 
38704
39486
  // src/scripts/draft-length-cli.ts
38705
- import * as fs66 from "node:fs";
38706
- import * as path79 from "node:path";
39487
+ import * as fs67 from "node:fs";
39488
+ import * as path80 from "node:path";
38707
39489
  function unverified(reason, exitCode) {
38708
39490
  console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", \u7EDF\u8BA1\u72B6\u6001: "\u672A\u6838\u9A8C", \u539F\u56E0: reason }, null, 2));
38709
39491
  return exitCode;
@@ -38724,14 +39506,14 @@ function draftLengthCli(argv) {
38724
39506
  return unverified("\u987B\u6307\u5B9A\u4E66\u4ED3\u7EDD\u5BF9\u8DEF\u5F84\u53CA\u6B63\u5F0F\u7A3F\u4EF6\u7684\u4ED3\u5185\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u4F7F\u7528\u6682\u5B58\u7A3F", 1);
38725
39507
  }
38726
39508
  try {
38727
- if (!fs66.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
39509
+ if (!fs67.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
38728
39510
  const resolved = resolveInsideBook(book, requested);
38729
39511
  if (!resolved.ok) return unverified(resolved.reason, 1);
38730
39512
  const target = draftLengthTarget(resolved.relPath);
38731
39513
  if (target?.\u6587\u672C\u9636\u6BB5 !== "\u8349\u7A3F\u6587\u4EF6") return unverified("\u5B9E\u9645\u76EE\u6807\u4E0D\u662F\u89C4\u8303\u5B8C\u6574\u7A3F", 1);
38732
- const file = path79.join(book, resolved.relPath);
38733
- if (!fs66.statSync(file).isFile()) return unverified("\u7A3F\u4EF6\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6", 1);
38734
- const text5 = fs66.readFileSync(file, "utf8");
39514
+ const file = path80.join(book, resolved.relPath);
39515
+ if (!fs67.statSync(file).isFile()) return unverified("\u7A3F\u4EF6\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6", 1);
39516
+ const text5 = fs67.readFileSync(file, "utf8");
38735
39517
  const result = draftLengthFeedback(target, text5, readChapterLength(book));
38736
39518
  console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", ...result }, null, 2));
38737
39519
  return result.\u7EDF\u8BA1\u72B6\u6001 === "\u5DF2\u7EDF\u8BA1" ? 0 : 1;
@@ -38797,7 +39579,7 @@ function materialsCli(argv) {
38797
39579
  return 1;
38798
39580
  }
38799
39581
  try {
38800
- const c = computeMaterials(book, { \u5377, \u7AE0, \u7AE0\u540D });
39582
+ const c = computeMaterials(book, { \u5377, \u7AE0, \u7AE0\u540D, \u8D28\u91CF\u6A21\u5F0F: true });
38801
39583
  console.log(JSON.stringify({
38802
39584
  ok: c.ok,
38803
39585
  \u72B6\u6001: c.\u72B6\u6001,
@@ -38950,8 +39732,8 @@ function exportCli(argv) {
38950
39732
  }
38951
39733
 
38952
39734
  // src/scripts/screenplay-export-cli.ts
38953
- import * as fs67 from "node:fs";
38954
- import * as path80 from "node:path";
39735
+ import * as fs68 from "node:fs";
39736
+ import * as path81 from "node:path";
38955
39737
  function argValue5(argv, name3) {
38956
39738
  const i = argv.indexOf(`--${name3}`);
38957
39739
  return i === -1 ? void 0 : argv[i + 1];
@@ -39012,12 +39794,12 @@ function screenplayExportCli(argv) {
39012
39794
  const \u5206\u955C\u5934raw = argValue5(argv, "\u5206\u955C\u5934")?.trim();
39013
39795
  let \u5206\u955C\u5934\u8868;
39014
39796
  if (\u5206\u955C\u5934raw !== void 0) {
39015
- const shotPath = path80.isAbsolute(\u5206\u955C\u5934raw) ? \u5206\u955C\u5934raw : path80.join(book, \u5206\u955C\u5934raw);
39016
- if (!fs67.existsSync(shotPath) || !fs67.statSync(shotPath).isFile()) {
39797
+ const shotPath = path81.isAbsolute(\u5206\u955C\u5934raw) ? \u5206\u955C\u5934raw : path81.join(book, \u5206\u955C\u5934raw);
39798
+ if (!fs68.existsSync(shotPath) || !fs68.statSync(shotPath).isFile()) {
39017
39799
  console.error(`\u5206\u955C\u5934\u8868\u4E0D\u5B58\u5728\uFF1A${shotPath}`);
39018
39800
  return 1;
39019
39801
  }
39020
- const parsed = parseShotListTable(fs67.readFileSync(shotPath, "utf-8"));
39802
+ const parsed = parseShotListTable(fs68.readFileSync(shotPath, "utf-8"));
39021
39803
  if (!parsed.ok || parsed.shotList === void 0) {
39022
39804
  console.error(`\u5206\u955C\u5934\u8868\u89E3\u6790\u5931\u8D25\uFF1A${parsed.problems.join("\uFF1B")}`);
39023
39805
  return 1;
@@ -39027,13 +39809,13 @@ function screenplayExportCli(argv) {
39027
39809
  const \u603B\u7EB2raw = argValue5(argv, "\u603B\u7EB2")?.trim();
39028
39810
  let \u603B\u7EB2;
39029
39811
  if (\u603B\u7EB2raw !== void 0) {
39030
- const biblePath = path80.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path80.join(book, \u603B\u7EB2raw);
39031
- if (!fs67.existsSync(biblePath) || !fs67.statSync(biblePath).isFile()) {
39812
+ const biblePath = path81.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path81.join(book, \u603B\u7EB2raw);
39813
+ if (!fs68.existsSync(biblePath) || !fs68.statSync(biblePath).isFile()) {
39032
39814
  console.error(`\u603B\u7EB2\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${biblePath}`);
39033
39815
  return 1;
39034
39816
  }
39035
39817
  try {
39036
- const parsedBible = JSON.parse(fs67.readFileSync(biblePath, "utf-8"));
39818
+ const parsedBible = JSON.parse(fs68.readFileSync(biblePath, "utf-8"));
39037
39819
  if (typeof parsedBible !== "object" || parsedBible === null || Array.isArray(parsedBible)) {
39038
39820
  console.error("\u603B\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A\u603B\u7EB2 JSON \u987B\u4E3A\u5BF9\u8C61\uFF08StoryBibleInput \u4E03\u8282\uFF09");
39039
39821
  return 1;
@@ -39131,6 +39913,7 @@ function volumeSummaryCli(argv) {
39131
39913
  // src/index.ts
39132
39914
  var name2 = "webnovel-bundle";
39133
39915
  var PreferenceSchema = Schema.object({
39916
+ automationMode: Schema.union([...AUTOMATION_MODES]).default(DEFAULT_WEBNOVEL_PREFERENCES.automationMode).description("\u521B\u4F5C\u6D41\u7A0B \xB7 \u81EA\u52A8\u5316\u6A21\u5F0F\uFF08semi-auto=\u534A\u81EA\u52A8\u4E24\u6B65\u8D70\uFF0Cauto=\u5168\u81EA\u52A8\u6258\u7BA1\uFF0Cmanual=\u4E25\u683C\u9010\u9879\u786E\u8BA4\uFF09"),
39134
39917
  autoIndexOnCommit: Schema.boolean().description("\u68C0\u7D22 \xB7 \u63D0\u4EA4\u540E\u81EA\u52A8\u66F4\u65B0\u5B9A\u7A3F\u7D22\u5F15"),
39135
39918
  showVisualTab: Schema.boolean().default(DEFAULT_WEBNOVEL_PREFERENCES.showVisualTab).description("\u53EF\u89C6\u5316 \xB7 \u5BF9\u8BDD\u533A\u6807\u7B7E"),
39136
39919
  showLayoutSwap: Schema.boolean().default(DEFAULT_WEBNOVEL_PREFERENCES.showLayoutSwap).description("\u5DE5\u4F5C\u53F0 \xB7 \u5E03\u5C40\u4E92\u6362\u6309\u94AE"),
@@ -39404,6 +40187,23 @@ function apply(ctx, entry) {
39404
40187
  });
39405
40188
  const editorRequests = new EditorRequestHub();
39406
40189
  attachStudyWeb(ctx, indexing, editorRequests);
40190
+ const readAutomationMode = () => {
40191
+ try {
40192
+ const settings = ctxGet(ctx, "settings");
40193
+ const doc = settings?.describe?.().find((item) => item.ns === WEBNOVEL_SETTINGS_NAMESPACE);
40194
+ if (doc?.value !== void 0) return normalizeWebnovelPreferences(doc.value).automationMode;
40195
+ } catch {
40196
+ }
40197
+ if (entry && typeof entry.get === "function") {
40198
+ try {
40199
+ return normalizeWebnovelPreferences(entry.get()).automationMode;
40200
+ } catch {
40201
+ }
40202
+ } else if (entry !== void 0) {
40203
+ return normalizeWebnovelPreferences(entry).automationMode;
40204
+ }
40205
+ return DEFAULT_WEBNOVEL_PREFERENCES.automationMode;
40206
+ };
39407
40207
  function ensureToolKit(scope2) {
39408
40208
  if (toolKit !== void 0) return;
39409
40209
  const questions = ctxGet(scope2, "userQuestions");
@@ -39421,6 +40221,7 @@ function apply(ctx, entry) {
39421
40221
  workspaceRoot: (agent) => agentWorkspaceRoot(agent),
39422
40222
  bookRootOfBookId: (bookId2, agent) => bookRootOfBookIdFor(bookId2, agent),
39423
40223
  askFn,
40224
+ automationMode: readAutomationMode,
39424
40225
  nativeWrite: bridge?.write,
39425
40226
  // 测试/走查专用工具(seed 占位设计)只在显式开启时注册,作者环境看不到
39426
40227
  testTools: process.env["WEBNOVEL_TEST_TOOLS"] === "1",
@@ -39712,6 +40513,7 @@ function apply(ctx, entry) {
39712
40513
  void indexing.refresh();
39713
40514
  }
39714
40515
  export {
40516
+ AUTOMATION_MODES,
39715
40517
  Config,
39716
40518
  DEFAULT_WEBNOVEL_PREFERENCES,
39717
40519
  NOVEL_CONDITIONAL_TOOL_NAMES,