@yangda611/dsh-scriptor 8.4.8 → 8.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/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, path80) {
117
- const ctrl = callVisitor(key, node, visitor, path80);
116
+ function visit_(key, node, visitor, path81) {
117
+ const ctrl = callVisitor(key, node, visitor, path81);
118
118
  if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
119
- replaceNode(key, path80, ctrl);
120
- return visit_(key, ctrl, visitor, path80);
119
+ replaceNode(key, path81, ctrl);
120
+ return visit_(key, ctrl, visitor, path81);
121
121
  }
122
122
  if (typeof ctrl !== "symbol") {
123
123
  if (identity4.isCollection(node)) {
124
- path80 = Object.freeze(path80.concat(node));
124
+ path81 = Object.freeze(path81.concat(node));
125
125
  for (let i = 0; i < node.items.length; ++i) {
126
- const ci = visit_(i, node.items[i], visitor, path80);
126
+ const ci = visit_(i, node.items[i], visitor, path81);
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
- path80 = Object.freeze(path80.concat(node));
138
- const ck = visit_("key", node.key, visitor, path80);
137
+ path81 = Object.freeze(path81.concat(node));
138
+ const ck = visit_("key", node.key, visitor, path81);
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, path80);
143
+ const cv = visit_("value", node.value, visitor, path81);
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, path80) {
165
- const ctrl = await callVisitor(key, node, visitor, path80);
164
+ async function visitAsync_(key, node, visitor, path81) {
165
+ const ctrl = await callVisitor(key, node, visitor, path81);
166
166
  if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
167
- replaceNode(key, path80, ctrl);
168
- return visitAsync_(key, ctrl, visitor, path80);
167
+ replaceNode(key, path81, ctrl);
168
+ return visitAsync_(key, ctrl, visitor, path81);
169
169
  }
170
170
  if (typeof ctrl !== "symbol") {
171
171
  if (identity4.isCollection(node)) {
172
- path80 = Object.freeze(path80.concat(node));
172
+ path81 = Object.freeze(path81.concat(node));
173
173
  for (let i = 0; i < node.items.length; ++i) {
174
- const ci = await visitAsync_(i, node.items[i], visitor, path80);
174
+ const ci = await visitAsync_(i, node.items[i], visitor, path81);
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
- path80 = Object.freeze(path80.concat(node));
186
- const ck = await visitAsync_("key", node.key, visitor, path80);
185
+ path81 = Object.freeze(path81.concat(node));
186
+ const ck = await visitAsync_("key", node.key, visitor, path81);
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, path80);
191
+ const cv = await visitAsync_("value", node.value, visitor, path81);
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, path80) {
218
+ function callVisitor(key, node, visitor, path81) {
219
219
  if (typeof visitor === "function")
220
- return visitor(key, node, path80);
220
+ return visitor(key, node, path81);
221
221
  if (identity4.isMap(node))
222
- return visitor.Map?.(key, node, path80);
222
+ return visitor.Map?.(key, node, path81);
223
223
  if (identity4.isSeq(node))
224
- return visitor.Seq?.(key, node, path80);
224
+ return visitor.Seq?.(key, node, path81);
225
225
  if (identity4.isPair(node))
226
- return visitor.Pair?.(key, node, path80);
226
+ return visitor.Pair?.(key, node, path81);
227
227
  if (identity4.isScalar(node))
228
- return visitor.Scalar?.(key, node, path80);
228
+ return visitor.Scalar?.(key, node, path81);
229
229
  if (identity4.isAlias(node))
230
- return visitor.Alias?.(key, node, path80);
230
+ return visitor.Alias?.(key, node, path81);
231
231
  return void 0;
232
232
  }
233
- function replaceNode(key, path80, node) {
234
- const parent = path80[path80.length - 1];
233
+ function replaceNode(key, path81, node) {
234
+ const parent = path81[path81.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, path80, value) {
844
+ function collectionFromPath(schema, path81, value) {
845
845
  let v = value;
846
- for (let i = path80.length - 1; i >= 0; --i) {
847
- const k = path80[i];
846
+ for (let i = path81.length - 1; i >= 0; --i) {
847
+ const k = path81[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 = (path80) => path80 == null || typeof path80 === "object" && !!path80[Symbol.iterator]().next().done;
866
+ var isEmptyPath = (path81) => path81 == null || typeof path81 === "object" && !!path81[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(path80, value) {
897
- if (isEmptyPath(path80))
896
+ addIn(path81, value) {
897
+ if (isEmptyPath(path81))
898
898
  this.add(value);
899
899
  else {
900
- const [key, ...rest] = path80;
900
+ const [key, ...rest] = path81;
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(path80) {
915
- const [key, ...rest] = path80;
914
+ deleteIn(path81) {
915
+ const [key, ...rest] = path81;
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(path80, keepScalar) {
930
- const [key, ...rest] = path80;
929
+ getIn(path81, keepScalar) {
930
+ const [key, ...rest] = path81;
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(path80) {
949
- const [key, ...rest] = path80;
948
+ hasIn(path81) {
949
+ const [key, ...rest] = path81;
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(path80, value) {
960
- const [key, ...rest] = path80;
959
+ setIn(path81, value) {
960
+ const [key, ...rest] = path81;
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(path80, value) {
3475
+ addIn(path81, value) {
3476
3476
  if (assertCollection(this.contents))
3477
- this.contents.addIn(path80, value);
3477
+ this.contents.addIn(path81, 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(path80) {
3553
- if (Collection.isEmptyPath(path80)) {
3552
+ deleteIn(path81) {
3553
+ if (Collection.isEmptyPath(path81)) {
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(path80) : false;
3559
+ return assertCollection(this.contents) ? this.contents.deleteIn(path81) : 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(path80, keepScalar) {
3575
- if (Collection.isEmptyPath(path80))
3574
+ getIn(path81, keepScalar) {
3575
+ if (Collection.isEmptyPath(path81))
3576
3576
  return !keepScalar && identity4.isScalar(this.contents) ? this.contents.value : this.contents;
3577
- return identity4.isCollection(this.contents) ? this.contents.getIn(path80, keepScalar) : void 0;
3577
+ return identity4.isCollection(this.contents) ? this.contents.getIn(path81, 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(path80) {
3589
- if (Collection.isEmptyPath(path80))
3588
+ hasIn(path81) {
3589
+ if (Collection.isEmptyPath(path81))
3590
3590
  return this.contents !== void 0;
3591
- return identity4.isCollection(this.contents) ? this.contents.hasIn(path80) : false;
3591
+ return identity4.isCollection(this.contents) ? this.contents.hasIn(path81) : 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(path80, value) {
3609
- if (Collection.isEmptyPath(path80)) {
3608
+ setIn(path81, value) {
3609
+ if (Collection.isEmptyPath(path81)) {
3610
3610
  this.contents = value;
3611
3611
  } else if (this.contents == null) {
3612
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path80), value);
3612
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path81), value);
3613
3613
  } else if (assertCollection(this.contents)) {
3614
- this.contents.setIn(path80, value);
3614
+ this.contents.setIn(path81, 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, path80) => {
5574
+ visit.itemAtPath = (cst, path81) => {
5575
5575
  let item = cst;
5576
- for (const [field, index] of path80) {
5576
+ for (const [field, index] of path81) {
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, path80) => {
5586
- const parent = visit.itemAtPath(cst, path80.slice(0, -1));
5587
- const field = path80[path80.length - 1][0];
5585
+ visit.parentCollection = (cst, path81) => {
5586
+ const parent = visit.itemAtPath(cst, path81.slice(0, -1));
5587
+ const field = path81[path81.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(path80, item, visitor) {
5594
- let ctrl = visitor(item, path80);
5593
+ function _visit(path81, item, visitor) {
5594
+ let ctrl = visitor(item, path81);
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(path80.concat([[field, i]])), token.items[i], visitor);
5601
+ const ci = _visit(Object.freeze(path81.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, path80);
5612
+ ctrl = ctrl(item, path81);
5613
5613
  }
5614
5614
  }
5615
- return typeof ctrl === "function" ? ctrl(item, path80) : ctrl;
5615
+ return typeof ctrl === "function" ? ctrl(item, path81) : 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 fs67 = this.flowScalar(this.type);
6917
+ const fs68 = this.flowScalar(this.type);
6918
6918
  if (atNextItem || it.value) {
6919
- map.items.push({ start, key: fs67, sep: [] });
6919
+ map.items.push({ start, key: fs68, sep: [] });
6920
6920
  this.onKeyLine = true;
6921
6921
  } else if (it.sep) {
6922
- this.stack.push(fs67);
6922
+ this.stack.push(fs68);
6923
6923
  } else {
6924
- Object.assign(it, { key: fs67, sep: [] });
6924
+ Object.assign(it, { key: fs68, 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 fs67 = this.flowScalar(this.type);
7052
+ const fs68 = this.flowScalar(this.type);
7053
7053
  if (!it || it.value)
7054
- fc.items.push({ start: [], key: fs67, sep: [] });
7054
+ fc.items.push({ start: [], key: fs68, sep: [] });
7055
7055
  else if (it.sep)
7056
- this.stack.push(fs67);
7056
+ this.stack.push(fs68);
7057
7057
  else
7058
- Object.assign(it, { key: fs67, sep: [] });
7058
+ Object.assign(it, { key: fs68, 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 fs67 = __require("fs");
7424
+ var fs68 = __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
- fs67.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
7444
+ fs68.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
- fs67.close(self.fd, onCloseDone);
7461
+ fs68.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
- fs67.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
7493
+ fs68.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 fs67 = __require("fs");
7853
+ var fs68 = __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(path80, options2) {
7878
+ function openPromise(path81, options2) {
7879
7879
  return new Promise((resolve22, reject) => {
7880
- open(path80, { ...options2, lazyEntries: true }, function(err, zipfile) {
7880
+ open(path81, { ...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(path80, options2, callback) {
7910
+ function open(path81, 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
- fs67.open(path80, "r", function(err, fd) {
7922
+ fs68.open(path81, "r", function(err, fd) {
7923
7923
  if (err) return callback(err);
7924
7924
  fromFd(fd, options2, function(err2, zipfile) {
7925
- if (err2) fs67.close(fd, defaultCallback);
7925
+ if (err2) fs68.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
- fs67.fstat(fd, function(err, stats) {
7942
+ fs68.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, path80 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
11108
+ function validateVolatileSchema(schema, path81 = [], 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: path80 });
11113
+ if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path: path81 });
11114
11114
  const nested = blocked || !!schema.meta?.volatile;
11115
- if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path80, key], nested, seen);
11116
- if (schema.sKey) validateVolatileSchema(schema.sKey, [...path80, "<key>"], true, seen);
11117
- if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path80, "*"], true, seen);
11118
- if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path80, String(index)], true, seen);
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);
11119
11119
  }
11120
11120
  Schema.extend = function extend(type, resolve22) {
11121
11121
  resolvers[type] = resolve22;
@@ -14515,7 +14515,8 @@ function trueSourceTool(relPath) {
14515
14515
  [/^大纲\/卷规划\/[^/]+\/(卷纲|计划时间线|卷摘要)\.md$/, "novel_confirm_volume_outline"],
14516
14516
  [/^世界书\//, "novel_confirm_worldbook_entry\uFF08\u8BBE\u8BA1\u6761\u76EE\uFF09\uFF1B\u5DF2\u5165\u6863\u4E8B\u5B9E\u66F4\u6B63\u8D70 novel_apply_retcon"],
14517
14517
  [/^账本\//, "novel_settle_chapter\uFF08\u65B0\u589E\u6C89\u6DC0\uFF09\uFF1B\u5DF2\u5165\u6863\u6761\u76EE\u66F4\u6B63\u8D70 novel_apply_retcon"],
14518
- [/^本书记忆\//, "novel_record_memory\uFF08\u672C\u4E66\u8303\u56F4\uFF09\uFF1B\u5B9A\u7A3F\u5019\u9009\u968F novel_settle_chapter \u6C89\u6DC0"]
14518
+ [/^本书记忆\//, "novel_record_memory\uFF08\u672C\u4E66\u8303\u56F4\uFF09\uFF1B\u5B9A\u7A3F\u5019\u9009\u968F novel_settle_chapter \u6C89\u6DC0"],
14519
+ [/^剧本\/短剧\//, "novel_shortdrama_settle_episode\uFF08\u5B9A\u7A3F\u5165\u6863\uFF09\uFF1B\u8349\u7A3F\u8BF7\u7528 novel_shortdrama_render_episode"]
14519
14520
  ];
14520
14521
  const tool = rules.find(([pattern2]) => pattern2.test(relPath))?.[1];
14521
14522
  return tool === void 0 ? "\u8BF7\u6539\u7528\u5BF9\u5E94\u7684\u4E13\u7528\u5DE5\u5177\u3002" : `\u8BF7\u6539\u7528 ${tool}\u3002`;
@@ -14784,7 +14785,7 @@ function formatCommitMessage(input) {
14784
14785
 
14785
14786
  // ../core/src/commit/paths.ts
14786
14787
  import * as path16 from "node:path";
14787
- var ALLOWED_TOP = /* @__PURE__ */ new Set(["\u5B9A\u7A3F", "\u5927\u7EB2", "\u4E16\u754C\u4E66", "\u8D26\u672C", "\u672C\u4E66\u8BB0\u5FC6", "\u4F5C\u54C1\u5951\u7EA6", "\u6784\u60F3"]);
14788
+ var ALLOWED_TOP = /* @__PURE__ */ new Set(["\u5B9A\u7A3F", "\u5267\u672C", "\u5927\u7EB2", "\u4E16\u754C\u4E66", "\u8D26\u672C", "\u672C\u4E66\u8BB0\u5FC6", "\u4F5C\u54C1\u5951\u7EA6", "\u6784\u60F3"]);
14788
14789
  var REJECT_TOP = /* @__PURE__ */ new Set(["\u77E5\u8BC6\u5E93", "profiles", "books", "\u8349\u7A3F\u533A"]);
14789
14790
  function toPosix(rel) {
14790
14791
  return rel.split(/[\\/]/).join("/");
@@ -21021,11 +21022,19 @@ function screenplayFinalPath() {
21021
21022
  }
21022
21023
 
21023
21024
  // ../core/src/shortdrama/types.ts
21025
+ var SHORTDRAMA_ORIENTATIONS = ["\u7AD6\u5C4F", "\u6A2A\u5C4F"];
21026
+ var HOOK_TYPES = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
21024
21027
  var HOOK_ROTATION = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
21025
21028
  function hookTypeForEpisode(\u96C6) {
21026
21029
  if (!Number.isSafeInteger(\u96C6) || \u96C6 < 1) throw new Error(`\u96C6\u53F7\u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230\uFF1A${String(\u96C6)}\uFF09`);
21027
21030
  return HOOK_ROTATION[(\u96C6 - 1) % HOOK_ROTATION.length];
21028
21031
  }
21032
+ function isHookType(value) {
21033
+ return typeof value === "string" && HOOK_TYPES.includes(value);
21034
+ }
21035
+ function isShortDramaOrientation(value) {
21036
+ return typeof value === "string" && SHORTDRAMA_ORIENTATIONS.includes(value);
21037
+ }
21029
21038
 
21030
21039
  // ../core/src/shortdrama/templates.ts
21031
21040
  var SHORTDRAMA_SOURCES = {
@@ -21392,7 +21401,74 @@ function isBeatMark(mark) {
21392
21401
  function fail3(message) {
21393
21402
  throw new Error(`\u5355\u96C6\u5267\u672C\u6E32\u67D3\u5931\u8D25\uFF1A${message}`);
21394
21403
  }
21404
+ function requireRecord(value, field) {
21405
+ if (value === null || typeof value !== "object" || Array.isArray(value)) fail3(`${field}\u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61`);
21406
+ return value;
21407
+ }
21408
+ function requireArray(value, field) {
21409
+ if (!Array.isArray(value)) fail3(`${field}\u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4`);
21410
+ return value;
21411
+ }
21412
+ function requireString(value, field) {
21413
+ if (typeof value !== "string") fail3(`${field}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
21414
+ }
21415
+ function requireNumber(value, field) {
21416
+ if (typeof value !== "number") fail3(`${field}\u5FC5\u987B\u662F\u6570\u5B57`);
21417
+ }
21418
+ function requireStringArray(value, field) {
21419
+ for (const [index, item] of requireArray(value, field).entries()) requireString(item, `${field}[${index}]`);
21420
+ }
21421
+ function validateLines(value, field) {
21422
+ for (const [index, item] of requireArray(value, field).entries()) {
21423
+ const where = `${field}[${index}]`;
21424
+ const line = requireRecord(item, where);
21425
+ requireString(line["\u89D2\u8272"], `${where}.\u89D2\u8272`);
21426
+ requireString(line["\u53F0\u8BCD"], `${where}.\u53F0\u8BCD`);
21427
+ if (line["\u62EC\u53F7\u63D0\u793A"] !== void 0) requireString(line["\u62EC\u53F7\u63D0\u793A"], `${where}.\u62EC\u53F7\u63D0\u793A`);
21428
+ }
21429
+ }
21430
+ function validateStructure(input) {
21431
+ const value = requireRecord(input, "\u53C2\u6570");
21432
+ for (const field of ["\u6807\u9898", "\u6838\u5FC3\u60F3\u6CD5", "\u723D\u70B9", "\u7ED3\u5C3E\u60AC\u5FF5"]) requireString(value[field], field);
21433
+ if (!isShortDramaOrientation(value["\u753B\u5E45"])) fail3("\u753B\u5E45\u5FC5\u987B\u662F\u7AD6\u5C4F\u6216\u6A2A\u5C4F");
21434
+ if (!isHookType(value["\u94A9\u5B50\u7C7B\u578B"])) fail3("\u94A9\u5B50\u7C7B\u578B\u5FC5\u987B\u662F\u8EAB\u4EFD\u3001\u60C5\u611F\u6216\u987F\u609F");
21435
+ for (const field of ["\u5F00\u573A\u51B2\u7A81\u79D2", "\u7ED3\u5C3E\u94A9\u5B50\u79D2"]) requireNumber(value[field], field);
21436
+ for (const [index, second] of requireArray(value["\u53CD\u8F6C\u79D2"], "\u53CD\u8F6C\u79D2").entries()) requireNumber(second, `\u53CD\u8F6C\u79D2[${index}]`);
21437
+ for (const [index, item] of requireArray(value["\u573A\u666F"], "\u573A\u666F").entries()) {
21438
+ const where = `\u573A\u666F[${index}]`;
21439
+ const scene = requireRecord(item, where);
21440
+ for (const field of ["\u5730\u70B9", "\u65F6\u95F4", "\u52A8\u4F5C"]) requireString(scene[field], `${where}.${field}`);
21441
+ if (scene["\u5185\u5916"] !== "\u5185" && scene["\u5185\u5916"] !== "\u5916") fail3(`${where}.\u5185\u5916\u5FC5\u987B\u662F\u5185\u6216\u5916`);
21442
+ validateLines(scene["\u53F0\u8BCD"], `${where}.\u53F0\u8BCD`);
21443
+ if (scene["\u573A\u666F\u73AF\u5883"] !== void 0) requireString(scene["\u573A\u666F\u73AF\u5883"], `${where}.\u573A\u666F\u73AF\u5883`);
21444
+ if (scene["\u4EBA\u7269"] !== void 0) {
21445
+ for (const [personIndex, personItem] of requireArray(scene["\u4EBA\u7269"], `${where}.\u4EBA\u7269`).entries()) {
21446
+ const personWhere = `${where}.\u4EBA\u7269[${personIndex}]`;
21447
+ const person = requireRecord(personItem, personWhere);
21448
+ requireString(person["\u89D2\u8272"], `${personWhere}.\u89D2\u8272`);
21449
+ if (person["\u5F62\u8C61\u6807\u8BC6"] !== void 0) requireString(person["\u5F62\u8C61\u6807\u8BC6"], `${personWhere}.\u5F62\u8C61\u6807\u8BC6`);
21450
+ }
21451
+ }
21452
+ if (scene["\u955C\u5934"] !== void 0) {
21453
+ for (const [shotIndex, shotItem] of requireArray(scene["\u955C\u5934"], `${where}.\u955C\u5934`).entries()) {
21454
+ const shotWhere = `${where}.\u955C\u5934[${shotIndex}]`;
21455
+ const shot = requireRecord(shotItem, shotWhere);
21456
+ requireNumber(shot["\u955C\u5934\u53F7"], `${shotWhere}.\u955C\u5934\u53F7`);
21457
+ for (const field of ["\u5F00\u59CB\u79D2", "\u7ED3\u675F\u79D2"]) {
21458
+ if (shot[field] !== null) requireNumber(shot[field], `${shotWhere}.${field}\uFF08\u672A\u77E5\u65F6\u586B null\uFF09`);
21459
+ }
21460
+ for (const field of ["\u666F\u522B", "\u89D2\u5EA6", "\u8FD0\u955C"]) requireString(shot[field], `${shotWhere}.${field}`);
21461
+ requireStringArray(shot["\u63CF\u5199"], `${shotWhere}.\u63CF\u5199`);
21462
+ validateLines(shot["\u53F0\u8BCD"], `${shotWhere}.\u53F0\u8BCD`);
21463
+ for (const field of ["\u73AF\u5883\u58F0", "\u5B57\u5E55"]) {
21464
+ if (shot[field] !== void 0) requireStringArray(shot[field], `${shotWhere}.${field}`);
21465
+ }
21466
+ }
21467
+ }
21468
+ }
21469
+ }
21395
21470
  function validate(input) {
21471
+ validateStructure(input);
21396
21472
  const warnings = [];
21397
21473
  const template = RHYTHM_TEMPLATES[input.\u753B\u5E45];
21398
21474
  if (!Number.isSafeInteger(input.\u96C6) || input.\u96C6 < 1 || input.\u96C6 > 100) {
@@ -29338,7 +29414,8 @@ var NOVEL_TOOL_NAMES = [
29338
29414
  "novel_shortdrama_plan_episodes",
29339
29415
  "novel_shortdrama_render_episode",
29340
29416
  "novel_shortdrama_check_beats",
29341
- "novel_shortdrama_review_episode"
29417
+ "novel_shortdrama_review_episode",
29418
+ "novel_shortdrama_settle_episode"
29342
29419
  ];
29343
29420
  var WRITING_DELEGATE_TOOL = "novel_delegate";
29344
29421
  var NOVEL_CONDITIONAL_TOOL_NAMES = [WRITING_DELEGATE_TOOL];
@@ -29603,7 +29680,7 @@ function attachStatusToAgent(agentCtx, deps) {
29603
29680
  }
29604
29681
  }
29605
29682
 
29606
- // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
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
29607
29684
  import { Service } from "@deepseek-ai/cordis";
29608
29685
 
29609
29686
  // ../../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
@@ -29823,7 +29900,7 @@ function scopeTarget(base, key) {
29823
29900
  return carrier;
29824
29901
  }
29825
29902
 
29826
- // ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
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
29827
29904
  var SECTION_ORDERS = {
29828
29905
  HARNESS_IDENTITY: -1e3,
29829
29906
  DEPLOYMENT_PERSONA_PREFIX: 0,
@@ -31456,6 +31533,43 @@ function createScreenplayTools(deps = {}) {
31456
31533
  ];
31457
31534
  }
31458
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;
31562
+ }
31563
+ throw error;
31564
+ }
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
+
31459
31573
  // src/tool-failure.ts
31460
31574
  var NEXT_STEP = {
31461
31575
  "invalid-argument": "\u6309 reason \u4FEE\u6B63\u53C2\u6570\u540E\u91CD\u65B0\u8C03\u7528\u3002",
@@ -31476,6 +31590,9 @@ var NEXT_STEP = {
31476
31590
  function toolFailure(code, reason, next = NEXT_STEP[code]) {
31477
31591
  return { ok: false, code, reason, next };
31478
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
+ }
31479
31596
  function errorText3(error) {
31480
31597
  return error instanceof Error ? error.message : String(error);
31481
31598
  }
@@ -31607,7 +31724,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31607
31724
  },
31608
31725
  {
31609
31726
  name: "novel_shortdrama_render_episode",
31610
- description: "\u77ED\u5267\u5355\u96C6\u5267\u672C\u6E32\u67D3\uFF1A\u7F16\u5267\u5C42\u5206\u573A\u666F\u683C\u5F0F\uFF08\u573A\u53F7. \u5730\u70B9 \u65F6\u95F4 \u5185/\u5916 + \u52A8\u4F5C\u884C + \u8BF4\u8BDD\u4EBA\uFF1A\u53F0\u8BCD\uFF0C\u505C\u987F\u53EA\u7528 (pause)\uFF09\u3002\u8FD4\u56DE\u5B9A\u7A3F\u8DEF\u5F84\uFF08\u5267\u672C/\u77ED\u5267/\u96C6001.md \u8D77\uFF09\u4E0E\u6B63\u6587\uFF1B\u53F0\u8BCD\u8D85\u957F\u53EA\u62A5\u8B66\u544A\u3001\u4E0D\u4E22\u7A3F\u3002\u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\u65F6\u7528\u3002",
31727
+ description: "\u77ED\u5267\u5355\u96C6\u5267\u672C\u6E32\u67D3\u9884\u89C8\uFF1A\u8FD4\u56DE\u6B63\u6587\u4E0E\u672A\u6765\u5B9A\u7A3F\u8DEF\u5F84\uFF0Csaved=false \u8868\u793A\u5C1A\u672A\u4FDD\u5B58\u3002\u53F0\u8BCD\u8D85\u957F\u53EA\u62A5\u8B66\u544A\u3001\u4E0D\u4E22\u7A3F\u3002",
31611
31728
  parameters: {
31612
31729
  type: "object",
31613
31730
  properties: {
@@ -31668,7 +31785,10 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31668
31785
  type: "object",
31669
31786
  properties: {
31670
31787
  ok: { type: "boolean" },
31671
- path: { type: "string", description: "\u5B9A\u7A3F\u8DEF\u5F84\uFF0C\u5982 \u5267\u672C/\u77ED\u5267/\u96C6001.md" },
31788
+ path: { type: "string", description: "saved=true \u65F6\u4E3A\u5B9E\u9645\u8349\u7A3F\u8DEF\u5F84\uFF1B\u7EAF\u6E32\u67D3\u9884\u89C8\u53EA\u8FD4\u56DE\u672A\u6765\u5B9A\u7A3F\u8DEF\u5F84" },
31789
+ finalPath: { type: "string", description: "\u672A\u6765\u5B9A\u7A3F\u8DEF\u5F84\uFF1B\u4E0D\u8868\u793A\u5DF2\u7ECF\u5B9A\u7A3F" },
31790
+ saved: { type: "boolean", description: "\u5B9E\u9645\u6587\u4EF6\u8BFB\u56DE\u4E00\u81F4\u65F6\u624D\u4E3A true" },
31791
+ message: { type: "string" },
31672
31792
  \u5185\u5BB9: { type: "string" },
31673
31793
  \u8B66\u544A: { type: "array" },
31674
31794
  reason: { type: "string" }
@@ -31680,7 +31800,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31680
31800
  execute: (args) => run(() => {
31681
31801
  const input = asRecord2(args, "\u53C2\u6570");
31682
31802
  const rendered = renderEpisodeScript(input);
31683
- return { ok: true, ...rendered };
31803
+ return { ok: true, ...rendered, finalPath: rendered.path, saved: false, message: "\u4EC5\u6E32\u67D3\u9884\u89C8\uFF0C\u5C1A\u672A\u4FDD\u5B58\u6587\u4EF6\u3002" };
31684
31804
  })
31685
31805
  },
31686
31806
  {
@@ -31821,40 +31941,224 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31821
31941
  \u5F85\u56DE\u5199\u6A21\u5757: ["\u77ED\u5267\u5BA1\u8BFB\uFF08\u8BED\u4E49\uFF09"]
31822
31942
  };
31823
31943
  })
31944
+ },
31945
+ {
31946
+ name: "novel_shortdrama_settle_episode",
31947
+ description: "\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\u5165\u6863\uFF1A\u5FC5\u4F20 bookId\u3001\u96C6\uFF081\u2013100\uFF09\u548C summary\u3002\u6838\u5BF9\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\u3001\u6821\u9A8C\u8349\u7A3F\u533A/\u5267\u672C/\u77ED\u5267/\u96C6NNN.md \u4E14\u68C0\u67E5\u5206\u96C6\u5BA1\u8BFB\u8BB0\u5F55\u72B6\u6001\u540E\uFF0C\u5F39\u51FA\u4F5C\u8005\u88C1\u51B3\u7A97\u53E3\uFF1B\u4EC5\u5728\u4F5C\u8005\u660E\u786E\u6279\u51C6\u540E\u5C06\u5355\u96C6\u5267\u672C\u539F\u5B50\u5199\u5165 \u5267\u672C/\u77ED\u5267/\u96C6NNN.md \u5E76\u505A\u5355\u6B21 ch: Git \u63D0\u4EA4\u3002\u5B9A\u7A3F\u53EA\u589E\u4E0D\u6539\uFF1B\u672A\u83B7\u6279\u51C6\u4E25\u7981\u5165\u6863\u3002",
31948
+ parameters: {
31949
+ type: "object",
31950
+ properties: {
31951
+ bookId: { type: "string", description: "\u5F53\u524D\u77ED\u5267\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" },
31952
+ \u96C6: { type: "integer", description: "\u96C6\u53F7\uFF0C1\u2013100" },
31953
+ summary: { type: "string", description: "\u63D0\u4EA4\u6458\u8981\uFF08\u5982 \u96C6001 \u7B49\u4E86\u4E09\u5E74\u7684\u9762\uFF09" }
31954
+ },
31955
+ required: ["bookId", "\u96C6", "summary"]
31956
+ },
31957
+ output: {
31958
+ schema: {
31959
+ type: "object",
31960
+ properties: {
31961
+ ok: { type: "boolean", description: "\u662F\u5426\u6210\u529F" },
31962
+ path: { type: "string", description: "\u5DF2\u5B9A\u7A3F\u5267\u672C\u8DEF\u5F84\uFF08\u5267\u672C/\u77ED\u5267/\u96C6NNN.md\uFF09" },
31963
+ draftPath: { type: "string", description: "\u6765\u6E90\u8349\u7A3F\u8DEF\u5F84\uFF08\u8349\u7A3F\u533A/\u5267\u672C/\u77ED\u5267/\u96C6NNN.md\uFF09" },
31964
+ \u96C6: { type: "integer", description: "\u96C6\u53F7" },
31965
+ \u6807\u9898: { type: "string", description: "\u672C\u96C6\u6807\u9898" },
31966
+ alreadyCommitted: { type: "boolean", description: "\u662F\u5426\u6B64\u524D\u5DF2\u6838\u5B9E\u540C\u4E00\u63D0\u4EA4\uFF0C\u672A\u91CD\u590D\u5199\u5165" },
31967
+ \u5BA1\u8BFB\u72B6\u6001: { type: "string", description: "\u672C\u96C6\u5206\u96C6\u5BA1\u8BFB\u8BB0\u5F55\u6838\u5BF9\u7ED3\u679C" },
31968
+ message: { type: "string", description: "\u7ED3\u679C\u8BF4\u660E\uFF08\u542B\u5165\u6863\u53BB\u5904\uFF09" },
31969
+ reason: { type: "string", description: "\u5931\u8D25\u539F\u56E0" }
31970
+ },
31971
+ required: ["ok"]
31972
+ },
31973
+ render: (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 2) }]
31974
+ },
31975
+ 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")
31824
31976
  }
31825
31977
  ];
31826
-
31827
- // src/approval-snapshot.ts
31828
- import * as fs54 from "node:fs";
31829
- import * as path66 from "node:path";
31830
- import { createHash as createHash19 } from "node:crypto";
31831
- function captureApprovalFiles(root, relatives, request) {
31978
+ function resolveShortdramaBook(deps, rawBookId, exec, action) {
31979
+ const bookId2 = typeof rawBookId === "string" ? rawBookId.trim() : "";
31980
+ if (bookId2 === "") return toolFailure("book-not-found", "bookId \u5FC5\u586B\uFF0C\u8BF7\u5148\u6838\u5BF9\u5F53\u524D\u77ED\u5267\u4E66\u76EE\u3002");
31981
+ const bookRoot = deps.bookRootOfBookId(bookId2, exec?.agent);
31982
+ if (bookRoot === void 0) return toolFailure("book-not-found", `\u4E66id\u4E0D\u5B58\u5728\u6216\u4E0D\u552F\u4E00\uFF1A${bookId2}`);
31983
+ if (readExistingContract(bookRoot).fields["\u8F93\u51FA\u5F62\u6001"] !== "\u77ED\u5267") {
31984
+ return toolFailure("invalid-argument", `\u4F5C\u54C1\u5951\u7EA6\u7684\u8F93\u51FA\u5F62\u6001\u5FC5\u987B\u662F\u77ED\u5267\uFF0C\u4E0D\u80FD${action}\u3002`);
31985
+ }
31986
+ return { ok: true, bookId: bookId2, bookRoot };
31987
+ }
31988
+ function episodeReviewSummary(bookRoot, \u96C6, draftText) {
31989
+ const record4 = loadEpisodeReviewRecord(bookRoot, \u96C6);
31990
+ 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";
31992
+ const pendingModules = Object.entries(record4.\u6A21\u5757).filter(([, state]) => !state.\u5B8C\u6210 || state.\u5F85\u56DE\u5199 === true).map(([name3]) => name3);
31993
+ if (!record4.\u5B8C\u6210 || Object.keys(record4.\u6A21\u5757).length === 0 || pendingModules.length > 0) {
31994
+ 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";
31995
+ }
31996
+ const pendingFindings = record4.\u95EE\u9898.filter((item) => !item.\u5904\u7F6E\u72B6\u6001 || item.\u5904\u7F6E\u72B6\u6001 === "\u5F85\u5904\u7406").length;
31997
+ if (pendingFindings > 0) return `\u5BA1\u8BFB\u5DF2\u56DE\u5199\uFF0C\u4ECD\u6709 ${pendingFindings} \u9879\u53D1\u73B0\u9879\u5F85\u5904\u7F6E`;
31998
+ return "\u5BA1\u8BFB\u901A\u8FC7\uFF08\u6A21\u5757\u9F50\u5168\u4E14\u96F6\u9879\u5F85\u5904\u7F6E\uFF09";
31999
+ }
32000
+ function resolvePlainBookFile(bookRoot, relPath) {
31832
32001
  try {
31833
- const files = [];
31834
- const visit = (relative12) => {
31835
- const target = authorDocumentPath(root, relative12);
31836
- try {
31837
- const stat = fs54.statSync(target);
31838
- if (stat.isDirectory()) {
31839
- const names = fs54.readdirSync(target).sort();
31840
- files.push([relative12 + "/", JSON.stringify(names)]);
31841
- for (const name3 of names) visit(path66.posix.join(relative12, name3));
31842
- } else if (stat.isFile()) {
31843
- files.push([relative12, createHash19("sha256").update(fs54.readFileSync(target)).digest("hex")]);
31844
- } else throw new Error(`\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1A${relative12}`);
31845
- } catch (error) {
31846
- if (error.code === "ENOENT") {
31847
- files.push([relative12, null]);
31848
- return;
32002
+ return { ok: true, absPath: authorDocumentPath(bookRoot, relPath) };
32003
+ } catch (error) {
32004
+ if (error instanceof AuthorDocumentError && error.code === "invalid-path") {
32005
+ return toolFailure("runtime-link", `\u77ED\u5267\u8DEF\u5F84\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\u4E14\u4E0D\u5F97\u7ECF\u8FC7\u94FE\u63A5\uFF1A${relPath}\uFF08${error.message}\uFF09`);
32006
+ }
32007
+ return failureFrom(error, "\u77ED\u5267\u8DEF\u5F84\u6821\u9A8C\u5931\u8D25\uFF1A");
32008
+ }
32009
+ }
32010
+ 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
+ let resolved;
32013
+ try {
32014
+ resolved = resolveShortdramaBook(deps, args["bookId"], exec, "\u8D70\u77ED\u5267\u5B9A\u7A3F");
32015
+ } catch (error) {
32016
+ return failureFrom(error, "\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\u5931\u8D25\uFF1A");
32017
+ }
32018
+ if (!resolved.ok) return resolved;
32019
+ const { bookId: bookId2, bookRoot } = resolved;
32020
+ const rawEp = args["\u96C6"];
32021
+ if (typeof rawEp !== "number" || !Number.isSafeInteger(rawEp) || rawEp < 1 || rawEp > 100) {
32022
+ return toolFailure("invalid-argument", `\u96C6\u5FC5\u987B\u662F 1\u2013100 \u7684\u6574\u6570\uFF08\u6536\u5230\uFF1A${String(rawEp ?? "\u672A\u4F20")}\uFF09`);
32023
+ }
32024
+ const \u96C6 = rawEp;
32025
+ const summary = typeof args["summary"] === "string" ? args["summary"].trim() : "";
32026
+ if (summary === "") {
32027
+ 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");
32028
+ }
32029
+ const finalRel = paths.\u77ED\u5267\u96C6(\u96C6);
32030
+ const draftRel = `\u8349\u7A3F\u533A/${finalRel}`;
32031
+ const draftAccess = gateFileAccess(bookRoot, draftRel);
32032
+ if (!draftAccess.allow || draftAccess.zone !== "\u8349\u7A3F\u533A") {
32033
+ return toolFailure("runtime-link", `\u77ED\u5267\u8349\u7A3F\u5FC5\u987B\u7559\u5728\u8349\u7A3F\u533A\uFF0C\u8BF7\u6838\u5BF9\u76EE\u5F55\u94FE\u63A5\uFF1A${draftAccess.allow ? draftRel : draftAccess.reason}`);
32034
+ }
32035
+ const draftPathCheck = resolvePlainBookFile(bookRoot, draftRel);
32036
+ if (!draftPathCheck.ok) return draftPathCheck;
32037
+ const finalPathCheck = resolvePlainBookFile(bookRoot, finalRel);
32038
+ if (!finalPathCheck.ok) return finalPathCheck;
32039
+ let draftText;
32040
+ try {
32041
+ draftText = fs55.readFileSync(draftPathCheck.absPath, "utf8");
32042
+ } catch (error) {
32043
+ 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`);
32045
+ }
32046
+ return failureFrom(error, "\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u8BFB\u53D6\u5931\u8D25\uFF1A");
32047
+ }
32048
+ const parsed = parseEpisodeScript(draftText);
32049
+ if (!parsed.ok || parsed.episode === void 0) {
32050
+ return toolFailure("parse-error", `\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u89E3\u6790\u5931\u8D25\uFF08${draftRel}\uFF09\uFF1A${parsed.problems.join("\uFF1B")}`);
32051
+ }
32052
+ if (parsed.episode.\u96C6 !== \u96C6) {
32053
+ 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
+ }
32055
+ if (fs55.existsSync(finalPathCheck.absPath)) {
32056
+ const existingFinal = fs55.readFileSync(finalPathCheck.absPath, "utf8");
32057
+ if (existingFinal !== draftText) {
32058
+ 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
+ }
32060
+ }
32061
+ const approvalFiles = [draftRel, finalRel, paths.\u5951\u7EA6(), paths.\u77ED\u5267\u5BA1\u6838\u8BB0\u5F55(\u96C6)];
32062
+ const approvalReq = { bookId: bookId2, \u96C6, summary };
32063
+ const before = captureApprovalFiles(bookRoot, approvalFiles, approvalReq);
32064
+ if (!before.ok) return before;
32065
+ const ep = parsed.episode;
32066
+ const reviewStatus = episodeReviewSummary(bookRoot, \u96C6, draftText);
32067
+ const approvalSummary = [
32068
+ `\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
+ `\u6765\u6E90\u8349\u7A3F\uFF1A${draftRel}`,
32070
+ `\u5BA1\u8BFB\u72B6\u6001\uFF1A${reviewStatus}`,
32071
+ `\u63D0\u4EA4\u6458\u8981\uFF1A${summary}`
32072
+ ].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`);
32082
+ const provenance2 = deps.provenanceOf?.(exec, [finalRel]);
32083
+ return withBookWrite(bookRoot, () => {
32084
+ 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");
32085
+ const current = resolveShortdramaBook(deps, bookId2, exec, "\u8D70\u77ED\u5267\u5B9A\u7A3F");
32086
+ if (!current.ok || current.bookRoot !== bookRoot) {
32087
+ return toolFailure("approval-stale", "\u7B49\u5F85\u4F5C\u8005\u88C1\u51B3\u671F\u95F4\u4E66id\u6216\u5F52\u5C5E\u5DF2\u53D8\u5316\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165", "\u8C03\u7528 novel_select_book \u6838\u5BF9\u4E66\u76EE\uFF0C\u518D\u91CD\u65B0\u5448\u62A5\u4F5C\u8005\u3002");
32088
+ }
32089
+ const after = captureApprovalFiles(bookRoot, approvalFiles, approvalReq);
32090
+ if (!after.ok || after.fingerprint !== before.fingerprint) {
32091
+ return toolFailure("approval-stale", "\u77ED\u5267\u5355\u96C6\u8349\u7A3F\u6216\u5BA1\u8BFB\u72B6\u6001\u5728\u7B49\u5F85\u4F5C\u8005\u88C1\u51B3\u671F\u95F4\u5DF2\u53D8\u5316\uFF0C\u65E7\u6279\u51C6\u4E0D\u53EF\u4F7F\u7528");
32092
+ }
32093
+ try {
32094
+ const res = archiveChapter({
32095
+ bookRoot,
32096
+ files: [{ \u76EE\u6807: finalRel, \u5185\u5BB9: draftText, sha256: draftHashOf(draftText) }],
32097
+ summary,
32098
+ lines: [
32099
+ `\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\uFF1A\u96C6${episodeNo(\u96C6)} ${ep.\u6807\u9898}`,
32100
+ `\u6765\u6E90\u8349\u7A3F\uFF1A${draftRel}`,
32101
+ `\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`
32103
+ ],
32104
+ provenance: provenance2
32105
+ });
32106
+ if (!res.ok) return { ok: false, reason: res.reason };
32107
+ return {
32108
+ ok: true,
32109
+ path: finalRel,
32110
+ draftPath: draftRel,
32111
+ \u96C6,
32112
+ \u6807\u9898: ep.\u6807\u9898,
32113
+ alreadyCommitted: res.alreadyCommitted === true,
32114
+ \u5BA1\u8BFB\u72B6\u6001: reviewStatus,
32115
+ 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
+ };
32117
+ } catch (error) {
32118
+ return failureFrom(error, "\u77ED\u5267\u5355\u96C6\u5B9A\u7A3F\u5931\u8D25\uFF1A");
32119
+ }
32120
+ }, provenance2);
32121
+ }
32122
+ function createShortdramaTools(deps) {
32123
+ return SHORTDRAMA_TOOL_DEFINITIONS.map((tool) => {
32124
+ if (tool.name === "novel_shortdrama_settle_episode") {
32125
+ return {
32126
+ ...tool,
32127
+ execute: (args, exec) => executeSettleEpisode(deps, args, exec)
32128
+ };
32129
+ }
32130
+ if (tool.name !== "novel_shortdrama_render_episode") return tool;
32131
+ const parameters = tool.parameters;
32132
+ return {
32133
+ ...tool,
32134
+ description: "\u6E32\u67D3\u5E76\u4FDD\u5B58\u77ED\u5267\u5355\u96C6\u8349\u7A3F\uFF1A\u5FC5\u4F20 bookId\uFF0C\u6838\u5BF9\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\uFF0C\u7ECF\u539F\u751F\u5199\u5165\u4FDD\u5B58\u5230\u8349\u7A3F\u533A/\u5267\u672C/\u77ED\u5267/\u96C6001.md \u8D77\uFF0C\u8BFB\u56DE\u6838\u9A8C\u540E\u624D\u8FD4\u56DE saved=true \u548C\u5B9E\u9645 path\u3002finalPath \u662F\u672A\u6765\u5B9A\u7A3F\u8DEF\u5F84\uFF1B\u8349\u7A3F\u4ECD\u987B\u8282\u62CD\u68C0\u67E5\u3001\u5BA1\u8BFB\u548C\u4F5C\u8005\u786E\u8BA4\uFF0C\u4E0D\u4EE3\u8868\u5B9A\u7A3F\u3002\u53F0\u8BCD\u8D85\u957F\u53EA\u62A5\u8B66\u544A\u3001\u4E0D\u4E22\u7A3F\u3002",
32135
+ parameters: {
32136
+ ...tool.parameters,
32137
+ properties: { ...parameters.properties, bookId: { type: "string", description: "\u5F53\u524D\u77ED\u5267\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" } },
32138
+ required: ["bookId", ...parameters.required]
32139
+ },
32140
+ execute: async (args, exec) => {
32141
+ try {
32142
+ const resolved = resolveShortdramaBook(deps, args["bookId"], exec, "\u4FDD\u5B58\u5230\u5176\u4ED6\u9879\u76EE");
32143
+ if (!resolved.ok) return resolved;
32144
+ const { bookRoot: root } = resolved;
32145
+ const rendered = renderEpisodeScript(args);
32146
+ const draftPath = `\u8349\u7A3F\u533A/${rendered.path}`;
32147
+ const access = gateFileAccess(root, draftPath);
32148
+ 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
+ exec?.signal?.throwIfAborted();
32150
+ await deps.writeDraft(root, { relPath: draftPath, content: rendered.\u5185\u5BB9 }, exec);
32151
+ if (fs55.readFileSync(path67.join(root, draftPath), "utf8") !== rendered.\u5185\u5BB9) {
32152
+ 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
+ }
32154
+ 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" };
32155
+ } catch (error) {
32156
+ if (exec?.signal?.aborted) throw error;
32157
+ return { ...failureFrom(error, "\u77ED\u5267\u8349\u7A3F\u4FDD\u5B58\u5931\u8D25\uFF1A"), saved: false };
31849
32158
  }
31850
- throw error;
31851
32159
  }
31852
32160
  };
31853
- for (const relative12 of [...new Set(relatives)].sort()) visit(relative12);
31854
- return { ok: true, fingerprint: createHash19("sha256").update(JSON.stringify([canonicalizePath(root), request, files])).digest("hex") };
31855
- } catch (error) {
31856
- return { ok: false, reason: `\u65E0\u6CD5\u6838\u5BF9\u4F5C\u8005\u88C1\u51B3\u5185\u5BB9\uFF1A${error instanceof Error ? error.message : String(error)}` };
31857
- }
32161
+ });
31858
32162
  }
31859
32163
 
31860
32164
  // src/story-status.ts
@@ -31960,8 +32264,8 @@ var MAINTENANCE_OUTPUT = {
31960
32264
  };
31961
32265
 
31962
32266
  // src/book-upgrade-tools.ts
31963
- import fs55 from "node:fs";
31964
- import path67 from "node:path";
32267
+ import fs56 from "node:fs";
32268
+ import path68 from "node:path";
31965
32269
  import { validateJsonSchemaValue as validateJsonSchemaValue2 } from "@deepseek-ai/dsh-tools";
31966
32270
 
31967
32271
  // src/book-upgrade-output.ts
@@ -32041,8 +32345,8 @@ var BOOK_UPGRADE_WRITE_OUTPUT = {
32041
32345
  var marker2 = { maintenance: "book-upgrade" };
32042
32346
  var cancelled = () => ({ ...marker2, ...toolFailure("author-cancelled", "\u4E66\u4ED3\u5347\u7EA7\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF0C\u672C\u6B21\u4E0D\u7EE7\u7EED\u5199\u5165\u3002") });
32043
32347
  var identity2 = (root) => {
32044
- const real = fs55.realpathSync.native(root);
32045
- return process.platform === "win32" ? path67.resolve(real).toLowerCase() : path67.resolve(real);
32348
+ const real = fs56.realpathSync.native(root);
32349
+ return process.platform === "win32" ? path68.resolve(real).toLowerCase() : path68.resolve(real);
32046
32350
  };
32047
32351
  function provenance(exec) {
32048
32352
  if (exec === void 0) return void 0;
@@ -32196,7 +32500,7 @@ function createBookUpgradeTools(deps) {
32196
32500
  }
32197
32501
 
32198
32502
  // src/novel-tools.ts
32199
- import * as fs59 from "node:fs";
32503
+ import * as fs60 from "node:fs";
32200
32504
  import * as nodePath3 from "node:path";
32201
32505
 
32202
32506
  // src/design-commit-result.ts
@@ -32662,14 +32966,14 @@ function onboardingMissing(answers) {
32662
32966
  }
32663
32967
 
32664
32968
  // src/study/onboarding-store.ts
32665
- import * as fs56 from "node:fs";
32666
- import * as path68 from "node:path";
32969
+ import * as fs57 from "node:fs";
32970
+ import * as path69 from "node:path";
32667
32971
  function onboardingDraftPath(workspaceRoot) {
32668
- return path68.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
32972
+ return path69.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
32669
32973
  }
32670
32974
  function readOnboardingDraft(workspaceRoot) {
32671
32975
  try {
32672
- const raw = fs56.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
32976
+ const raw = fs57.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
32673
32977
  return validateOnboardingAnswers(JSON.parse(raw));
32674
32978
  } catch {
32675
32979
  return {};
@@ -32677,27 +32981,27 @@ function readOnboardingDraft(workspaceRoot) {
32677
32981
  }
32678
32982
  function saveOnboardingDraft(workspaceRoot, answers) {
32679
32983
  const target = onboardingDraftPath(workspaceRoot);
32680
- fs56.mkdirSync(path68.dirname(target), { recursive: true });
32681
- fs56.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
32984
+ fs57.mkdirSync(path69.dirname(target), { recursive: true });
32985
+ fs57.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
32682
32986
  }
32683
32987
  function consumeOnboardingDraft(workspaceRoot) {
32684
32988
  try {
32685
- fs56.unlinkSync(onboardingDraftPath(workspaceRoot));
32989
+ fs57.unlinkSync(onboardingDraftPath(workspaceRoot));
32686
32990
  } catch {
32687
32991
  }
32688
32992
  }
32689
32993
 
32690
32994
  // ../drafting/src/context.ts
32691
- import * as fs57 from "node:fs";
32692
- import * as path69 from "node:path";
32693
-
32694
- // ../drafting/src/write.ts
32695
32995
  import * as fs58 from "node:fs";
32696
32996
  import * as path70 from "node:path";
32997
+
32998
+ // ../drafting/src/write.ts
32999
+ import * as fs59 from "node:fs";
33000
+ import * as path71 from "node:path";
32697
33001
  var DRAFT_KEYS = ["\u8EAB\u4EFD", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u6765\u6E90\u5FEB\u7167", "\u89D2\u8272", "\u9009\u5B9A"];
32698
33002
  function readText12(root, rel) {
32699
33003
  try {
32700
- return fs58.readFileSync(path70.join(root, rel), "utf-8");
33004
+ return fs59.readFileSync(path71.join(root, rel), "utf-8");
32701
33005
  } catch {
32702
33006
  return null;
32703
33007
  }
@@ -32706,9 +33010,9 @@ function draftDir(key) {
32706
33010
  return paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D);
32707
33011
  }
32708
33012
  function listDraftFiles(bookRoot, key) {
32709
- const abs = path70.join(bookRoot, draftDir(key));
32710
- if (!fs58.existsSync(abs) || !fs58.statSync(abs).isDirectory()) return [];
32711
- return fs58.readdirSync(abs).filter((f) => f.endsWith(".md")).sort((a, b) => a.localeCompare(b, "zh"));
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"));
32712
33016
  }
32713
33017
  function parseDraftNo(file) {
32714
33018
  const m = /^稿(\d+)\.md$/.exec(file);
@@ -32717,7 +33021,7 @@ function parseDraftNo(file) {
32717
33021
  function latestVersion(bookRoot, key) {
32718
33022
  let max = null;
32719
33023
  for (const file of listDraftFiles(bookRoot, key)) {
32720
- const text5 = readText12(bookRoot, path70.posix.join(draftDir(key), file));
33024
+ const text5 = readText12(bookRoot, path71.posix.join(draftDir(key), file));
32721
33025
  if (text5 === null) continue;
32722
33026
  const doc = parseDocument(text5);
32723
33027
  if (!doc.ok) continue;
@@ -32744,7 +33048,7 @@ function selectDraftLocked(bookRoot, input) {
32744
33048
  const files = listDraftFiles(bookRoot, input);
32745
33049
  if (!files.includes(target)) return { ok: false, reason: `\u8349\u7A3F\u4E0D\u5B58\u5728:${target}` };
32746
33050
  for (const file of files) {
32747
- const rel = path70.posix.join(dir, file);
33051
+ const rel = path71.posix.join(dir, file);
32748
33052
  const text5 = readText12(bookRoot, rel);
32749
33053
  if (text5 === null) continue;
32750
33054
  const doc = parseDocument(text5);
@@ -32768,7 +33072,7 @@ function writeDraftLocked(bookRoot, input) {
32768
33072
  const parent = latestVersion(bookRoot, key);
32769
33073
  const ver = parent === null ? initialVersion("\u5199\u7A3F") : bumpVersion(parent, "\u5199\u7A3F");
32770
33074
  const file = nextFileName(bookRoot, key);
32771
- const relPath = path70.posix.join(draftDir(key), file);
33075
+ const relPath = path71.posix.join(draftDir(key), file);
32772
33076
  const fields = applyVersionFields(
32773
33077
  {
32774
33078
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -32800,7 +33104,7 @@ function importAuthorDraftLocked(bookRoot, input) {
32800
33104
  const explicitParent = input.\u7236\u7248\u672C ?? latestVersion(bookRoot, key);
32801
33105
  const ver = explicitParent === null ? initialVersion("\u4F5C\u8005\u7A3F\u5BFC\u5165") : bumpVersion(explicitParent, "\u4F5C\u8005\u7A3F\u5BFC\u5165");
32802
33106
  const file = nextFileName(bookRoot, key);
32803
- const relPath = path70.posix.join(draftDir(key), file);
33107
+ const relPath = path71.posix.join(draftDir(key), file);
32804
33108
  const fields = applyVersionFields(
32805
33109
  {
32806
33110
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -32865,7 +33169,6 @@ function createNovelTools(deps) {
32865
33169
  if (\u7AE0\u540D === "") return { ok: false, reason: "\u7AE0\u540D\u4E0D\u80FD\u4E3A\u7A7A\uFF08\u987B\u4E0E\u8FD1\u671F\u7A97\u53E3\u6761\u76EE\u9010\u5B57\u4E00\u81F4\uFF09" };
32866
33170
  return { ok: true, key: { \u5377, \u7AE0, \u7AE0\u540D } };
32867
33171
  };
32868
- const notApproved = (reason) => /取消|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}`);
32869
33172
  const memoryProperties = {
32870
33173
  \u540D\u79F0: { type: "string", description: "\u4E00\u4E8B\u4E00\u6761\uFF1B\u540C\u4E00\u4E8B\u9879\u6CBF\u7528\u5DF2\u6709\u540D\u79F0" },
32871
33174
  \u63CF\u8FF0: { type: "string", description: "\u4E00\u53E5\u8BDD\u8BF4\u660E\u4EE5\u540E\u4F55\u65F6\u9700\u8981\u8FD9\u6761\u8BB0\u5FC6" },
@@ -33137,7 +33440,7 @@ function createNovelTools(deps) {
33137
33440
  paths.\u5377\u7EB2(\u5377),
33138
33441
  paths.\u8BA1\u5212\u65F6\u95F4\u7EBF(\u5377),
33139
33442
  paths.\u8FD1\u671F\u7A97\u53E3(\u5377)
33140
- ].filter((p) => fs59.existsSync(nodePath3.join(bookRoot, p)));
33443
+ ].filter((p) => fs60.existsSync(nodePath3.join(bookRoot, p)));
33141
33444
  const commit = commitConfirmed({ bookRoot, paths: seedPaths, prefix: "design", summary: "\u6700\u5C0F\u8BBE\u8BA1\u9AA8\u67B6", provenance: provenanceOf(sessionContext, seedPaths) });
33142
33445
  if (!commit.ok) {
33143
33446
  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}` };
@@ -33733,7 +34036,7 @@ function createNovelTools(deps) {
33733
34036
  const rel = paths.\u8FD1\u671F\u7A97\u53E3(\u5377);
33734
34037
  let text5 = "";
33735
34038
  try {
33736
- text5 = fs59.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
34039
+ text5 = fs60.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
33737
34040
  } catch {
33738
34041
  text5 = "";
33739
34042
  }
@@ -34429,7 +34732,7 @@ function createNovelTools(deps) {
34429
34732
  const res = archiveRetconRequest({ bookRoot, chapter: \u5B9A\u7A3F\u76F8\u5BF9, request, provenance: provenanceOf(sessionContext) }, (plannedPackageDir) => {
34430
34733
  let \u66F4\u6B63\u540E\u5168\u6587;
34431
34734
  try {
34432
- const src = fs59.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
34735
+ const src = fs60.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
34433
34736
  const doc = parseDocument(src);
34434
34737
  if (!doc.ok) return { ok: false, reason: `\u5B9A\u7A3F\u7AE0\u89E3\u6790\u5931\u8D25\uFF1A${doc.detail}` };
34435
34738
  const parent = extractVersionFields(doc.data.fields).\u7248\u672C;
@@ -34457,19 +34760,19 @@ function createNovelTools(deps) {
34457
34760
  const value = optionalText(f);
34458
34761
  return value === null ? [] : [[\u5019\u9009\u6587\u4EF6[f], value]];
34459
34762
  }));
34460
- if (fs59.existsSync(\u5305\u7EDD\u5BF9)) {
34461
- for (const name3 of fs59.readdirSync(\u5305\u7EDD\u5BF9)) {
34763
+ if (fs60.existsSync(\u5305\u7EDD\u5BF9)) {
34764
+ for (const name3 of fs60.readdirSync(\u5305\u7EDD\u5BF9)) {
34462
34765
  const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
34463
- const stat = fs59.lstatSync(file);
34464
- if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs59.readFileSync(file, "utf8") !== contents.get(name3)) {
34766
+ const stat = fs60.lstatSync(file);
34767
+ if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs60.readFileSync(file, "utf8") !== contents.get(name3)) {
34465
34768
  return { ok: false, reason: "\u8865\u507F\u5305\u5019\u9009\u51B2\u7A81\uFF0C\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6838\u5BF9\u540E\u5904\u7406" };
34466
34769
  }
34467
34770
  }
34468
34771
  }
34469
- fs59.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
34772
+ fs60.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
34470
34773
  for (const [name3, value] of contents) {
34471
34774
  const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
34472
- if (!fs59.existsSync(file)) fs59.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
34775
+ if (!fs60.existsSync(file)) fs60.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
34473
34776
  }
34474
34777
  packageDir = \u5305\u76F8\u5BF9;
34475
34778
  }
@@ -34490,7 +34793,7 @@ function createNovelTools(deps) {
34490
34793
  retconFiles.push({ \u76EE\u6807: \u6458\u8981\u76F8\u5BF9, \u5185\u5BB9: request.\u66F4\u6B63\u540E\u7AE0\u6458\u8981 });
34491
34794
  } else {
34492
34795
  try {
34493
- const \u6458\u8981\u73B0\u6587 = fs59.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
34796
+ const \u6458\u8981\u73B0\u6587 = fs60.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
34494
34797
  retconFiles.push({
34495
34798
  \u76EE\u6807: \u6458\u8981\u76F8\u5BF9,
34496
34799
  \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")})
@@ -34772,7 +35075,7 @@ ${\u6458\u8981\u73B0\u6587}`
34772
35075
  bookRootOfBookId: deps.bookRootOfBookId,
34773
35076
  readContractFields: (bookRoot) => readExistingContract(bookRoot).fields
34774
35077
  }),
34775
- ...SHORTDRAMA_TOOL_DEFINITIONS
35078
+ ...createShortdramaTools({ bookRootOfBookId: deps.bookRootOfBookId, writeDraft: writeNative, askFn: deps.askFn, provenanceOf })
34776
35079
  );
34777
35080
  const locked = /* @__PURE__ */ new Set([
34778
35081
  "novel_new_outline_draft",
@@ -34792,9 +35095,10 @@ ${\u6458\u8981\u73B0\u6587}`
34792
35095
  "novel_record_review_findings",
34793
35096
  "novel_record_proposal",
34794
35097
  "novel_resolve_proposal",
34795
- "novel_note_pending"
35098
+ "novel_note_pending",
35099
+ "novel_shortdrama_render_episode"
34796
35100
  ]);
34797
- const nativeTools = NATIVE_DESIGN_TOOLS;
35101
+ const nativeTools = /* @__PURE__ */ new Set([...NATIVE_DESIGN_TOOLS, "novel_shortdrama_render_episode"]);
34798
35102
  const registered = deps.testTools === true ? tools : tools.filter((tool) => !NOVEL_TEST_TOOL_NAMES.includes(tool.name));
34799
35103
  const guarded = registered.map((tool) => {
34800
35104
  if (!locked.has(tool.name)) return tool;
@@ -34806,7 +35110,10 @@ ${\u6458\u8981\u73B0\u6587}`
34806
35110
  if (root === void 0) return tool.execute(args, sessionContext);
34807
35111
  try {
34808
35112
  if (nativeTools.has(tool.name)) {
34809
- return withBookWriteAsync(root, async () => tool.execute(args, sessionContext), provenanceOf(sessionContext)).catch((error) => failureFrom(error));
35113
+ return withBookWriteAsync(root, async () => tool.execute(args, sessionContext), provenanceOf(sessionContext)).catch((error) => {
35114
+ if (sessionContext?.signal?.aborted) throw error;
35115
+ return failureFrom(error);
35116
+ });
34810
35117
  }
34811
35118
  return withBookWrite(root, () => tool.execute(args, sessionContext), provenanceOf(sessionContext));
34812
35119
  } catch (error) {
@@ -34947,8 +35254,8 @@ function finishDesignCommit(bookRoot, writtenPaths, args, defaultSummary, chapte
34947
35254
  import { boundContextSummary, createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
34948
35255
 
34949
35256
  // src/study/service.ts
34950
- import * as fs62 from "node:fs";
34951
- import * as path73 from "node:path";
35257
+ import * as fs63 from "node:fs";
35258
+ import * as path74 from "node:path";
34952
35259
 
34953
35260
  // ../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
34954
35261
  var Diff = class {
@@ -35050,16 +35357,16 @@ var Diff = class {
35050
35357
  }
35051
35358
  }
35052
35359
  }
35053
- addToPath(path80, added, removed, oldPosInc, options2) {
35054
- const last = path80.lastComponent;
35360
+ addToPath(path81, added, removed, oldPosInc, options2) {
35361
+ const last = path81.lastComponent;
35055
35362
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
35056
35363
  return {
35057
- oldPos: path80.oldPos + oldPosInc,
35364
+ oldPos: path81.oldPos + oldPosInc,
35058
35365
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
35059
35366
  };
35060
35367
  } else {
35061
35368
  return {
35062
- oldPos: path80.oldPos + oldPosInc,
35369
+ oldPos: path81.oldPos + oldPosInc,
35063
35370
  lastComponent: { count: 1, added, removed, previousComponent: last }
35064
35371
  };
35065
35372
  }
@@ -35250,7 +35557,7 @@ var text4 = (value) => typeof value === "string" ? value : "";
35250
35557
  var terms = (value) => Array.isArray(value) ? value.flatMap(terms) : typeof value === "string" ? value.split(/[、,,;]/).map((item) => item.trim()).filter(Boolean) : [];
35251
35558
  var wiki = (body) => [...body.matchAll(/\[\[([^\]\n]+)\]\]/g)].map((match) => match[1].split("|")[0].trim());
35252
35559
  var identity3 = (name3) => name3.trim().replace(/[\s「」『』【】()()::,,。!?!?]/g, "").toLowerCase();
35253
- var kindOf = (path80, 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() : path80.includes("/\u4EBA\u7269\u6863\u6848/") ? "\u4EBA\u7269" : path80.includes("/\u4EBA\u7269\u5173\u7CFB/") ? "\u5173\u7CFB" : path80.includes("/\u7EC4\u7EC7\u4E0E\u9635\u8425/") ? "\u7EC4\u7EC7" : path80.includes("/\u5730\u70B9\u4E0E\u7A7A\u95F4/") ? "\u5730\u70B9" : "\u8BBE\u5B9A";
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";
35254
35561
  function readStoryGraph(source2) {
35255
35562
  const records = [], edges = [], events = [];
35256
35563
  const warnings = [];
@@ -35282,7 +35589,7 @@ function readStoryGraph(source2) {
35282
35589
  aliases.set(name3, values);
35283
35590
  };
35284
35591
  const strings = (fields) => Object.fromEntries(Object.entries(fields).filter((pair) => typeof pair[1] === "string"));
35285
- const fromFields = (id, label2, kind2, path80, line, fields, body) => ({
35592
+ const fromFields = (id, label2, kind2, path81, line, fields, body) => ({
35286
35593
  id,
35287
35594
  label: label2,
35288
35595
  kind: kind2,
@@ -35291,23 +35598,23 @@ function readStoryGraph(source2) {
35291
35598
  chapter: chapter(fields["\u8D77\u59CB\u7AE0"]) ?? chapter(fields["\u751F\u6548\u7AE0"]) ?? chapter(fields["\u7AE0\u53F7"]) ?? entryChapterNo({ \u5B57\u6BB5: strings(fields) }) ?? void 0,
35292
35599
  endChapter: chapter(fields["\u5931\u6548\u7AE0"]),
35293
35600
  revealChapter: chapter(fields["\u62AB\u9732\u7AE0"]) ?? chapter(fields["\u63ED\u793A\u7AE0"]),
35294
- source: { space: "book:" + source2.bookId, path: path80 },
35601
+ source: { space: "book:" + source2.bookId, path: path81 },
35295
35602
  line,
35296
35603
  preview: body.trim().slice(0, 600),
35297
35604
  // Expose authored scalar/list field names as grouping choices without
35298
35605
  // guessing whether 宗门/血脉/师承 means faction, family or another identity.
35299
35606
  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 })))
35300
35607
  });
35301
- const scan = (path80, depth = 0) => {
35608
+ const scan = (path81, depth = 0) => {
35302
35609
  if (depth > 12) {
35303
- warnings.push({ path: path80, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
35610
+ warnings.push({ path: path81, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
35304
35611
  return;
35305
35612
  }
35306
35613
  let entries;
35307
35614
  try {
35308
- entries = source2.list(path80);
35615
+ entries = source2.list(path81);
35309
35616
  } catch (error) {
35310
- if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
35617
+ if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
35311
35618
  return;
35312
35619
  }
35313
35620
  for (const entry of entries) {
@@ -35398,26 +35705,26 @@ function readStoryGraph(source2) {
35398
35705
  };
35399
35706
  scan("\u4E16\u754C\u4E66");
35400
35707
  for (const category of LEDGER_NAMES) {
35401
- const path80 = "\u8D26\u672C/" + category + ".md";
35708
+ const path81 = "\u8D26\u672C/" + category + ".md";
35402
35709
  let raw;
35403
35710
  try {
35404
- raw = source2.read(path80);
35711
+ raw = source2.read(path81);
35405
35712
  } catch (error) {
35406
- if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
35713
+ if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
35407
35714
  continue;
35408
35715
  }
35409
35716
  const ranges2 = createEvidenceRanges(raw);
35410
- sourceHashes[path80] = ranges2.hash;
35411
- const parsed = parseLedgerHistory(raw, category, path80);
35717
+ sourceHashes[path81] = ranges2.hash;
35718
+ const parsed = parseLedgerHistory(raw, category, path81);
35412
35719
  if (!parsed.ok) {
35413
- warnings.push({ path: path80, message: parsed.reason });
35720
+ warnings.push({ path: path81, message: parsed.reason });
35414
35721
  continue;
35415
35722
  }
35416
35723
  for (const [index, entry] of parsed.entries.entries()) {
35417
- const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path80 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
35724
+ const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path81 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
35418
35725
  const content = category === "\u65F6\u95F4\u7EBF" ? renderTimelineContent(entry) : entry.\u6B63\u6587;
35419
35726
  const evidenceId = id + ":" + entry.\u884C\u53F7;
35420
- const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path80, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
35727
+ const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path81, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
35421
35728
  const recordChapter2 = entryChapterNo(entry) ?? void 0;
35422
35729
  const storyTime = category === "\u65F6\u95F4\u7EBF" ? timelineStoryTime(entry) : void 0;
35423
35730
  const record4 = { ...base, recordChapter: recordChapter2, storyTime, historyBasis: recordChapter2 ? "recorded" : "unknown", evidenceId };
@@ -35438,11 +35745,11 @@ function readStoryGraph(source2) {
35438
35745
  links.push({ record: record4, targets: wiki(content), pair: false });
35439
35746
  }
35440
35747
  }
35441
- const resolve22 = (target, path80) => {
35748
+ const resolve22 = (target, path81) => {
35442
35749
  const name3 = target.replace(/^\[\[|\]\]$/g, "").replace(/@\d+$/, "").replace(/\\/g, "/");
35443
35750
  const found = aliases.get(name3);
35444
35751
  if (found?.size === 1) return [...found][0];
35445
- warnings.push({ path: path80, 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 });
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 });
35446
35753
  return void 0;
35447
35754
  };
35448
35755
  for (const item of links) {
@@ -35466,32 +35773,32 @@ function readStoryGraph(source2) {
35466
35773
  const currentBound = (items) => items.map((item) => item.currentOnlyAt === void 0 ? item : { ...item, currentOnlyAt: maxChapter });
35467
35774
  const withChapters = evidence.map((item) => {
35468
35775
  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));
35469
- return { ...item, relatedChapters: [...new Set(references)].map((path80) => ({ space: item.source.space, path: path80 })) };
35776
+ return { ...item, relatedChapters: [...new Set(references)].map((path81) => ({ space: item.source.space, path: path81 })) };
35470
35777
  });
35471
35778
  return { bookId: source2.bookId, bookName: source2.bookName, maxChapter, records: currentBound(records), edges: currentBound(edges), events, warnings, evidence: withChapters, entities, sourceHashes, fingerprint: fingerprint2, format: format2 };
35472
35779
  }
35473
35780
 
35474
35781
  // src/study/graph-source.ts
35475
- import * as fs60 from "node:fs";
35476
- import * as path71 from "node:path";
35782
+ import * as fs61 from "node:fs";
35783
+ import * as path72 from "node:path";
35477
35784
  import { createHash as createHash20 } from "node:crypto";
35478
35785
  function readGraphFile(base, relative12) {
35479
35786
  validateAuthorRelativePath(relative12);
35480
- const file = path71.join(base, relative12);
35787
+ const file = path72.join(base, relative12);
35481
35788
  const checkPhysical = () => {
35482
- if (stripDevicePrefix(fs60.realpathSync.native(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
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");
35483
35790
  };
35484
35791
  checkPhysical();
35485
- const initial = fs60.lstatSync(file);
35792
+ const initial = fs61.lstatSync(file);
35486
35793
  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");
35487
35794
  if (initial.size > 4 * 1024 * 1024) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u8D85\u8FC74MiB\uFF0C\u672A\u622A\u65AD\u8BFB\u53D6");
35488
- const descriptor = fs60.openSync(file, fs60.constants.O_RDONLY | (fs60.constants.O_NOFOLLOW ?? 0));
35795
+ const descriptor = fs61.openSync(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
35489
35796
  try {
35490
- const opened = fs60.fstatSync(descriptor);
35797
+ const opened = fs61.fstatSync(descriptor);
35491
35798
  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");
35492
- const bytes = fs60.readFileSync(descriptor);
35799
+ const bytes = fs61.readFileSync(descriptor);
35493
35800
  checkPhysical();
35494
- const current = fs60.lstatSync(file), finished = fs60.fstatSync(descriptor);
35801
+ const current = fs61.lstatSync(file), finished = fs61.fstatSync(descriptor);
35495
35802
  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");
35496
35803
  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");
35497
35804
  try {
@@ -35500,26 +35807,26 @@ function readGraphFile(base, relative12) {
35500
35807
  throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u4F7F\u7528UTF-8");
35501
35808
  }
35502
35809
  } finally {
35503
- fs60.closeSync(descriptor);
35810
+ fs61.closeSync(descriptor);
35504
35811
  }
35505
35812
  }
35506
35813
  async function readGraphFileAsync(base, relative12, signal) {
35507
35814
  signal?.throwIfAborted();
35508
35815
  validateAuthorRelativePath(relative12);
35509
- const file = path71.join(base, relative12);
35816
+ const file = path72.join(base, relative12);
35510
35817
  const checkPhysical = async () => {
35511
- if (stripDevicePrefix(await fs60.promises.realpath(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
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");
35512
35819
  };
35513
35820
  await checkPhysical();
35514
- const initial = await fs60.promises.lstat(file);
35821
+ const initial = await fs61.promises.lstat(file);
35515
35822
  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");
35516
- const handle = await fs60.promises.open(file, fs60.constants.O_RDONLY | (fs60.constants.O_NOFOLLOW ?? 0));
35823
+ const handle = await fs61.promises.open(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
35517
35824
  try {
35518
35825
  const opened = await handle.stat();
35519
35826
  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");
35520
35827
  const bytes = await handle.readFile({ signal });
35521
35828
  await checkPhysical();
35522
- const current = await fs60.promises.lstat(file), finished = await handle.stat();
35829
+ const current = await fs61.promises.lstat(file), finished = await handle.stat();
35523
35830
  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");
35524
35831
  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");
35525
35832
  try {
@@ -35539,12 +35846,12 @@ async function scanGraphFiles(root, space, signal) {
35539
35846
  if (depth > 12) return;
35540
35847
  try {
35541
35848
  const directory = authorDocumentPath(root, relative12, true);
35542
- const entries = await fs60.promises.readdir(directory, { withFileTypes: true });
35849
+ const entries = await fs61.promises.readdir(directory, { withFileTypes: true });
35543
35850
  const rows = entries.filter((item) => !item.name.startsWith(".") && item.name !== "node_modules").map((item) => ({
35544
35851
  name: item.name,
35545
35852
  directory: item.isDirectory(),
35546
35853
  draft: false,
35547
- ref: { space, path: path71.posix.join(relative12, item.name) },
35854
+ ref: { space, path: path72.posix.join(relative12, item.name) },
35548
35855
  ...item.isSymbolicLink() || !item.isFile() && !item.isDirectory() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
35549
35856
  }));
35550
35857
  directories.set(relative12, rows);
@@ -35769,8 +36076,8 @@ function overlayExtractions(graph, extractions) {
35769
36076
  }
35770
36077
 
35771
36078
  // src/indexing/graph-storage.ts
35772
- import * as fs61 from "node:fs";
35773
- import * as path72 from "node:path";
36079
+ import * as fs62 from "node:fs";
36080
+ import * as path73 from "node:path";
35774
36081
  import { createRequire as createRequire2 } from "node:module";
35775
36082
  import { createHash as createHash21, randomUUID as randomUUID8 } from "node:crypto";
35776
36083
  var APPLICATION_ID2 = 1465272113;
@@ -35792,24 +36099,24 @@ function initialGraphState(bookId2) {
35792
36099
  }
35793
36100
  function graphFile(root, name3) {
35794
36101
  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");
35795
- const runtime = path72.join(root, ".webnovel");
35796
- for (const [target, directory] of [[runtime, true], [path72.join(runtime, name3), false]]) {
36102
+ const runtime = path73.join(root, ".webnovel");
36103
+ for (const [target, directory] of [[runtime, true], [path73.join(runtime, name3), false]]) {
35797
36104
  try {
35798
- const stat = fs61.lstatSync(target);
36105
+ const stat = fs62.lstatSync(target);
35799
36106
  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");
35800
36107
  } catch (error) {
35801
36108
  if (error.code !== "ENOENT") throw error;
35802
36109
  }
35803
36110
  }
35804
- return path72.join(runtime, name3);
36111
+ return path73.join(runtime, name3);
35805
36112
  }
35806
36113
  function readGraphState(root, bookId2) {
35807
36114
  const file = graphFile(root, STATE_NAME);
35808
- if (!fs61.existsSync(file)) return initialGraphState(bookId2);
35809
- if (fs61.statSync(file).size > 32768) throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u8FC7\u5927\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
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");
35810
36117
  let value;
35811
36118
  try {
35812
- value = JSON.parse(fs61.readFileSync(file, "utf8"));
36119
+ value = JSON.parse(fs62.readFileSync(file, "utf8"));
35813
36120
  } catch {
35814
36121
  throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
35815
36122
  }
@@ -35819,12 +36126,12 @@ function readGraphState(root, bookId2) {
35819
36126
  function writeGraphState(root, state) {
35820
36127
  const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID8()}.tmp`;
35821
36128
  try {
35822
- fs61.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
36129
+ fs62.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
35823
36130
  graphFile(root, STATE_NAME);
35824
- fs61.renameSync(temporary, file);
36131
+ fs62.renameSync(temporary, file);
35825
36132
  } finally {
35826
36133
  try {
35827
- fs61.unlinkSync(temporary);
36134
+ fs62.unlinkSync(temporary);
35828
36135
  } catch {
35829
36136
  }
35830
36137
  }
@@ -35839,10 +36146,10 @@ function changeGraphState(root, bookId2, update) {
35839
36146
  function acquireGraphLease(root) {
35840
36147
  return withBookLockAsync(root, async () => {
35841
36148
  const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID8();
35842
- if (fs61.existsSync(file)) {
36149
+ if (fs62.existsSync(file)) {
35843
36150
  let pid;
35844
36151
  try {
35845
- pid = JSON.parse(fs61.readFileSync(file, "utf8")).pid;
36152
+ pid = JSON.parse(fs62.readFileSync(file, "utf8")).pid;
35846
36153
  } catch {
35847
36154
  throw new Error("\u56FE\u8C31\u4EFB\u52A1\u9501\u65E0\u6CD5\u89E3\u6790\uFF0C\u672A\u6E05\u7406\u539F\u6587\u4EF6");
35848
36155
  }
@@ -35854,12 +36161,12 @@ function acquireGraphLease(root) {
35854
36161
  dead2 = error.code === "ESRCH";
35855
36162
  }
35856
36163
  if (!dead2) throw new Error("\u53E6\u4E00\u56FE\u8C31\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C");
35857
- fs61.unlinkSync(graphFile(root, "story-graph.worker.lock"));
36164
+ fs62.unlinkSync(graphFile(root, "story-graph.worker.lock"));
35858
36165
  }
35859
- fs61.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
36166
+ fs62.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
35860
36167
  return () => {
35861
36168
  try {
35862
- if (JSON.parse(fs61.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs61.unlinkSync(file);
36169
+ if (JSON.parse(fs62.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs62.unlinkSync(file);
35863
36170
  } catch {
35864
36171
  }
35865
36172
  };
@@ -35867,20 +36174,20 @@ function acquireGraphLease(root) {
35867
36174
  }
35868
36175
  function graphCacheSignature(root) {
35869
36176
  const file = graphFile(root, CACHE_NAME);
35870
- return fs61.existsSync(file) ? createHash21("sha256").update(fs61.readFileSync(file)).digest("hex") : "missing";
36177
+ return fs62.existsSync(file) ? createHash21("sha256").update(fs62.readFileSync(file)).digest("hex") : "missing";
35871
36178
  }
35872
36179
  function cacheHeader(file) {
35873
- const header2 = Buffer.alloc(100), handle = fs61.openSync(file, "r");
36180
+ const header2 = Buffer.alloc(100), handle = fs62.openSync(file, "r");
35874
36181
  try {
35875
- fs61.readSync(handle, header2, 0, 100, 0);
36182
+ fs62.readSync(handle, header2, 0, 100, 0);
35876
36183
  } finally {
35877
- fs61.closeSync(handle);
36184
+ fs62.closeSync(handle);
35878
36185
  }
35879
36186
  return header2;
35880
36187
  }
35881
36188
  function replaceGraphCache(root, bookId2) {
35882
36189
  const file = graphFile(root, CACHE_NAME);
35883
- if (!fs61.existsSync(file)) return;
36190
+ if (!fs62.existsSync(file)) return;
35884
36191
  const header2 = cacheHeader(file);
35885
36192
  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");
35886
36193
  let db;
@@ -35900,12 +36207,12 @@ function replaceGraphCache(root, bookId2) {
35900
36207
  try {
35901
36208
  for (const ending of ["", "-journal", "-wal", "-shm"]) {
35902
36209
  const source2 = graphFile(root, CACHE_NAME + ending), target = source2 + suffix;
35903
- if (!fs61.existsSync(source2)) continue;
35904
- fs61.renameSync(source2, target);
36210
+ if (!fs62.existsSync(source2)) continue;
36211
+ fs62.renameSync(source2, target);
35905
36212
  moved.push([source2, target]);
35906
36213
  }
35907
36214
  } catch (error) {
35908
- for (const [source2, target] of moved.reverse()) if (!fs61.existsSync(source2)) fs61.renameSync(target, source2);
36215
+ for (const [source2, target] of moved.reverse()) if (!fs62.existsSync(source2)) fs62.renameSync(target, source2);
35909
36216
  throw error;
35910
36217
  }
35911
36218
  }
@@ -35926,7 +36233,7 @@ function readGraphCache(root, bookId2) {
35926
36233
  let db;
35927
36234
  try {
35928
36235
  const file = graphFile(root, CACHE_NAME);
35929
- if (!fs61.existsSync(file)) return { status: "missing", extractions: [] };
36236
+ if (!fs62.existsSync(file)) return { status: "missing", extractions: [] };
35930
36237
  const header2 = cacheHeader(file);
35931
36238
  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");
35932
36239
  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");
@@ -35948,7 +36255,7 @@ function readGraphCache(root, bookId2) {
35948
36255
  }
35949
36256
  }
35950
36257
  function saveGraphCache(root, graph, extraction) {
35951
- const filename = graphFile(root, CACHE_NAME), exists3 = fs61.existsSync(filename);
36258
+ const filename = graphFile(root, CACHE_NAME), exists3 = fs62.existsSync(filename);
35952
36259
  if (exists3) {
35953
36260
  const header2 = cacheHeader(filename);
35954
36261
  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");
@@ -35997,9 +36304,9 @@ function routeForDocument(ref2) {
35997
36304
  return "\u6821\u51C6\u4F5C\u54C1\u73B0\u72B6\uFF0C\u518D\u6309\u4FEE\u6539\u5185\u5BB9\u9009\u62E9\u5BF9\u5E94\u8282\u70B9";
35998
36305
  }
35999
36306
  function textOf(target) {
36000
- if (!fs62.existsSync(target) || !fs62.statSync(target).isFile()) throw new AuthorDocumentError("not-found", "\u6587\u4EF6\u4E0D\u5B58\u5728");
36001
- if (fs62.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");
36002
- const bytes = fs62.readFileSync(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);
36003
36310
  if (bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u8BE5\u6587\u4EF6\u4E0D\u662F\u6587\u672C\u6587\u4EF6");
36004
36311
  try {
36005
36312
  return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -36019,7 +36326,7 @@ var ORPHAN_SIGNALS = ["\u4E66\u7C4D\u4FE1\u606F.json", "\u6545\u4E8B\u5927\u7EB2
36019
36326
  function orphanSignals(dir) {
36020
36327
  let entries;
36021
36328
  try {
36022
- entries = fs62.readdirSync(dir);
36329
+ entries = fs63.readdirSync(dir);
36023
36330
  } catch {
36024
36331
  return void 0;
36025
36332
  }
@@ -36031,18 +36338,18 @@ function scanOrphanDrafts(workspace, bookNames) {
36031
36338
  const scanLevel = (parent, prefix, skip) => {
36032
36339
  let entries;
36033
36340
  try {
36034
- entries = fs62.readdirSync(parent, { withFileTypes: true });
36341
+ entries = fs63.readdirSync(parent, { withFileTypes: true });
36035
36342
  } catch {
36036
36343
  return;
36037
36344
  }
36038
36345
  for (const entry of entries) {
36039
36346
  if (!entry.isDirectory() || skip.has(entry.name)) continue;
36040
- const signals = orphanSignals(path73.join(parent, entry.name));
36347
+ const signals = orphanSignals(path74.join(parent, entry.name));
36041
36348
  if (signals !== void 0) orphans.push({ name: entry.name, path: prefix + entry.name, detail: `\u542B ${signals.join("\u3001")}` });
36042
36349
  }
36043
36350
  };
36044
36351
  scanLevel(workspace, "", /* @__PURE__ */ new Set([...bookNames, "\u4E66\u623F"]));
36045
- scanLevel(path73.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
36352
+ scanLevel(path74.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
36046
36353
  return orphans;
36047
36354
  }
36048
36355
  var StudyService = class {
@@ -36050,19 +36357,19 @@ var StudyService = class {
36050
36357
  constructor(workspace) {
36051
36358
  if (!isFullyQualifiedPath(workspace)) throw new AuthorDocumentError("invalid-path", "\u5DE5\u4F5C\u8303\u56F4\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
36052
36359
  this.workspace = canonicalizePath(workspace);
36053
- if (!fs62.existsSync(this.workspace) || !fs62.statSync(this.workspace).isDirectory()) throw new AuthorDocumentError("not-found", "\u5DE5\u4F5C\u8303\u56F4\u76EE\u5F55\u4E0D\u5B58\u5728");
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");
36054
36361
  }
36055
36362
  source(space) {
36056
36363
  if (space === "shared") {
36057
36364
  const root2 = authorDocumentPath(this.workspace, "\u4E66\u623F");
36058
- if (!fs62.existsSync(root2)) throw new AuthorDocumentError("not-found", "\u5F53\u524D\u5DE5\u4F5C\u8303\u56F4\u5C1A\u65E0\u5171\u4EAB\u8D44\u6599");
36059
- if (fs62.existsSync(path73.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");
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");
36060
36367
  return { root: root2, owner: "\u5171\u4EAB\u8D44\u6599" };
36061
36368
  }
36062
36369
  const books = scanWorkspaceBooks(this.workspace).filter((book2) => book2.bookId && "book:" + book2.bookId === space);
36063
36370
  if (books.length !== 1) throw new AuthorDocumentError("not-found", "\u4E66\u76EE\u4E0D\u5B58\u5728\u6216\u4E66id\u4E0D\u552F\u4E00");
36064
36371
  const book = books[0];
36065
- const root = authorDocumentPath(this.workspace, path73.relative(this.workspace, book.root));
36372
+ const root = authorDocumentPath(this.workspace, path74.relative(this.workspace, book.root));
36066
36373
  return { root, owner: book.name, bookId: book.bookId };
36067
36374
  }
36068
36375
  shelf() {
@@ -36077,7 +36384,7 @@ var StudyService = class {
36077
36384
  let shared = false;
36078
36385
  let sharedError;
36079
36386
  try {
36080
- shared = fs62.statSync(this.source("shared").root).isDirectory();
36387
+ shared = fs63.statSync(this.source("shared").root).isDirectory();
36081
36388
  } catch (error) {
36082
36389
  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";
36083
36390
  }
@@ -36118,12 +36425,12 @@ var StudyService = class {
36118
36425
  // once for tree badges and a second time for the evidence itself.
36119
36426
  list: (relative12) => {
36120
36427
  const directory = authorDocumentPath(source2.root, relative12, true);
36121
- if (!fs62.existsSync(directory)) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36122
- return fs62.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => ({
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) => ({
36123
36430
  name: entry.name,
36124
36431
  directory: entry.isDirectory(),
36125
36432
  draft: false,
36126
- ref: { space, path: path73.posix.join(relative12, entry.name) },
36433
+ ref: { space, path: path74.posix.join(relative12, entry.name) },
36127
36434
  ...entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
36128
36435
  }));
36129
36436
  },
@@ -36193,13 +36500,13 @@ var StudyService = class {
36193
36500
  }
36194
36501
  treeAt(source2, ref2) {
36195
36502
  const directory = authorDocumentPath(source2.root, ref2.path, true);
36196
- if (!fs62.existsSync(directory) || !fs62.statSync(directory).isDirectory()) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36197
- return fs62.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => {
36198
- const relative12 = path73.posix.join(ref2.path, entry.name);
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);
36199
36506
  const item = { ref: { space: ref2.space, path: relative12 }, name: entry.name, directory: entry.isDirectory(), draft: ref2.space !== "shared" && relative12.startsWith("\u8349\u7A3F\u533A") };
36200
36507
  try {
36201
36508
  const target = authorDocumentPath(source2.root, relative12);
36202
- const info = fs62.statSync(target);
36509
+ const info = fs63.statSync(target);
36203
36510
  if (!info.isDirectory() && !info.isFile()) return { ...item, error: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B" };
36204
36511
  const badge = info.isFile() && entry.name.endsWith(".md") && info.size <= MAX_DOCUMENT_BYTES2 ? fieldLabel(textOf(target)).badge : void 0;
36205
36512
  return { ...item, absolutePath: target, directory: info.isDirectory(), ...badge ? { badge } : {} };
@@ -36217,7 +36524,7 @@ var StudyService = class {
36217
36524
  read(ref2) {
36218
36525
  const source2 = this.source(ref2.space);
36219
36526
  const absolutePath = authorDocumentPath(source2.root, ref2.path);
36220
- ref2 = { ...ref2, path: path73.relative(canonicalizePath(source2.root), absolutePath).split(path73.sep).join("/") };
36527
+ ref2 = { ...ref2, path: path74.relative(canonicalizePath(source2.root), absolutePath).split(path74.sep).join("/") };
36221
36528
  const text5 = textOf(absolutePath);
36222
36529
  const parsed = parseDocument(text5);
36223
36530
  const metadata2 = fieldLabel(text5);
@@ -36225,7 +36532,7 @@ var StudyService = class {
36225
36532
  return {
36226
36533
  ref: ref2,
36227
36534
  owner: source2.owner,
36228
- name: path73.basename(ref2.path),
36535
+ name: path74.basename(ref2.path),
36229
36536
  absolutePath,
36230
36537
  body: parsed.ok ? parsed.data.body : text5,
36231
36538
  hash: documentHash(text5),
@@ -36244,14 +36551,14 @@ var StudyService = class {
36244
36551
  return null;
36245
36552
  }
36246
36553
  }
36247
- absolutePath = path73.resolve(this.workspace, absolutePath);
36554
+ absolutePath = path74.resolve(this.workspace, absolutePath);
36248
36555
  }
36249
36556
  const spaces = this.shelf().books.filter((book) => !book.error).map((book) => book.id);
36250
36557
  spaces.push("shared");
36251
36558
  for (const space of spaces) {
36252
36559
  try {
36253
36560
  const source2 = this.source(space);
36254
- const relative12 = path73.relative(source2.root, absolutePath).split(path73.sep).join("/");
36561
+ const relative12 = path74.relative(source2.root, absolutePath).split(path74.sep).join("/");
36255
36562
  return this.read({ space, path: relative12 });
36256
36563
  } catch {
36257
36564
  }
@@ -36264,7 +36571,7 @@ var StudyService = class {
36264
36571
  const scanned = scanWorkspaceBooks(this.workspace);
36265
36572
  const spaces = scanned.filter((book) => book.bookId && scanned.filter((other) => other.bookId === book.bookId).length === 1).map((book) => "book:" + book.bookId);
36266
36573
  try {
36267
- if (fs62.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
36574
+ if (fs63.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
36268
36575
  } catch {
36269
36576
  }
36270
36577
  const term = query.trim().toLocaleLowerCase();
@@ -36331,7 +36638,7 @@ var StudyService = class {
36331
36638
  const status = deriveChapterFacts(facts);
36332
36639
  const pending = findPendingReviewDraft(source2.root, key);
36333
36640
  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)];
36334
- const relative12 = candidates.find((candidate) => fs62.existsSync(path73.join(source2.root, candidate)));
36641
+ const relative12 = candidates.find((candidate) => fs63.existsSync(path74.join(source2.root, candidate)));
36335
36642
  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 } } : {} };
36336
36643
  })
36337
36644
  };
@@ -37280,7 +37587,7 @@ function brandString(value) {
37280
37587
 
37281
37588
  // src/native-write.ts
37282
37589
  import { randomUUID as randomUUID9 } from "node:crypto";
37283
- import * as path74 from "node:path";
37590
+ import * as path75 from "node:path";
37284
37591
  import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
37285
37592
  function nativeToolRuntime(ctx) {
37286
37593
  const pipeline = new ToolExecutionPipeline(ctx);
@@ -37311,7 +37618,7 @@ function createNativeWriteBridge(runtime) {
37311
37618
  exec.signal.throwIfAborted();
37312
37619
  const target = resolveInsideBook(root, op.relPath);
37313
37620
  if (!target.ok) throw new Error("\u539F\u751F\u5199\u5165\u76EE\u6807\u4E0D\u5728\u4E66\u4ED3\u5185");
37314
- const file = path74.resolve(root, target.relPath);
37621
+ const file = path75.resolve(root, target.relPath);
37315
37622
  const callId = brandString(`webnovel-write-${randomUUID9()}`);
37316
37623
  pending.set(callId, { parent: exec.token, agent: exec.agent, file, content: op.content });
37317
37624
  try {
@@ -37335,10 +37642,10 @@ function createNativeWriteBridge(runtime) {
37335
37642
  }
37336
37643
 
37337
37644
  // src/indexing/manager.ts
37338
- import * as fs63 from "node:fs";
37645
+ import * as fs64 from "node:fs";
37339
37646
 
37340
37647
  // src/indexing/git.ts
37341
- import * as path75 from "node:path";
37648
+ import * as path76 from "node:path";
37342
37649
  import { execFile } from "node:child_process";
37343
37650
  async function git(root, args) {
37344
37651
  return new Promise((resolve22) => execFile("git", ["--literal-pathspecs", "-C", root, ...args], {
@@ -37364,8 +37671,8 @@ async function bookGitWatchPaths(root) {
37364
37671
  git(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"])
37365
37672
  ]);
37366
37673
  return [...new Set(directories.filter((value) => !!value?.trim()).flatMap((value) => {
37367
- const directory = path75.resolve(root, value.trim());
37368
- return [directory, path75.join(directory, "refs")];
37674
+ const directory = path76.resolve(root, value.trim());
37675
+ return [directory, path76.join(directory, "refs")];
37369
37676
  }))];
37370
37677
  }
37371
37678
 
@@ -37772,7 +38079,7 @@ var BookIndexManager = class {
37772
38079
  for (const directory of await bookGitWatchPaths(record4.book.root)) {
37773
38080
  if (this.closing) return;
37774
38081
  try {
37775
- const watcher = fs63.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
38082
+ const watcher = fs64.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
37776
38083
  const name3 = filename?.toString().replaceAll("\\", "/");
37777
38084
  if (directory.endsWith("refs") || !name3 || /^(HEAD|packed-refs|refs)(\/|$)/.test(name3)) {
37778
38085
  this.scheduleProbe(record4);
@@ -38146,7 +38453,7 @@ function indexFailureMessage(book, notice) {
38146
38453
  }
38147
38454
 
38148
38455
  // src/reference/host.ts
38149
- import * as path76 from "node:path";
38456
+ import * as path77 from "node:path";
38150
38457
  import { BlockAssembler, createUserMessage as createUserMessage4 } from "@deepseek-ai/dsh-llm";
38151
38458
  var ReferenceHost = class {
38152
38459
  constructor(access) {
@@ -38164,26 +38471,26 @@ var ReferenceHost = class {
38164
38471
  async readFile(agent, workspace, filename, signal) {
38165
38472
  const active = AbortSignal.any([this.shutdown.signal, ...signal ? [signal] : []]);
38166
38473
  active.throwIfAborted();
38167
- const fs67 = this.access.fs(agent);
38168
- if (!fs67) throw new ReferenceError2("fs-unavailable", "DSH \u6587\u4EF6\u670D\u52A1\u4E0D\u53EF\u7528");
38169
- if (!path76.isAbsolute(filename)) throw new ReferenceError2("source-path", "\u8BF7\u9009\u62E9\u539F\u6587\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");
38170
- const mapped = fs67.processPathFromHostPath(filename), workspacePath = fs67.processPathFromHostPath(workspace);
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);
38171
38478
  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");
38172
- const info = await fs67.lstat(mapped, void 0, active);
38479
+ const info = await fs68.lstat(mapped, void 0, active);
38173
38480
  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");
38174
- let ancestor = path76.dirname(mapped);
38175
- while (path76.dirname(ancestor) !== ancestor) {
38176
- if ((await fs67.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");
38177
- ancestor = path76.dirname(ancestor);
38178
- }
38179
- const target = await fs67.resolve(mapped, { signal: active });
38180
- const library = await fs67.resolve(path76.join(workspacePath, "\u4E66\u623F/\u53C2\u8003\u4E66"), { signal: active });
38181
- if (fs67.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");
38182
- const before = await fs67.stat(target, active);
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);
38183
38490
  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");
38184
- const bytes = await fs67.readBytes(target, active, REFERENCE_LIMITS.sourceBytes);
38185
- const afterTarget = await fs67.resolve(mapped, { signal: active }), after = await fs67.stat(afterTarget, active);
38186
- const afterPath = await fs67.lstat(mapped, void 0, active);
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);
38187
38494
  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");
38188
38495
  active.throwIfAborted();
38189
38496
  return bytes;
@@ -38329,8 +38636,8 @@ function createIndexAutoPreference(settings, fallback) {
38329
38636
  }
38330
38637
 
38331
38638
  // src/scripts/deterministic-checks.ts
38332
- import * as fs64 from "node:fs";
38333
- import * as path77 from "node:path";
38639
+ import * as fs65 from "node:fs";
38640
+ import * as path78 from "node:path";
38334
38641
  function parseArgs(argv) {
38335
38642
  const values = /* @__PURE__ */ new Map();
38336
38643
  for (let i = 0; i < argv.length; i += 1) {
@@ -38360,8 +38667,8 @@ function runChecksCli(argv) {
38360
38667
  console.error(`\u524D\u7F6E\u53C2\u6570\u9519\u8BEF\uFF1A${err instanceof Error ? err.message : String(err)}`);
38361
38668
  return 1;
38362
38669
  }
38363
- if (!fs64.existsSync(args.book) || !fs64.statSync(args.book).isDirectory()) {
38364
- console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path77.resolve(args.book)}`);
38670
+ if (!fs65.existsSync(args.book) || !fs65.statSync(args.book).isDirectory()) {
38671
+ console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path78.resolve(args.book)}`);
38365
38672
  return 1;
38366
38673
  }
38367
38674
  try {
@@ -38395,8 +38702,8 @@ function runChecksCli(argv) {
38395
38702
  }
38396
38703
 
38397
38704
  // src/scripts/draft-length-cli.ts
38398
- import * as fs65 from "node:fs";
38399
- import * as path78 from "node:path";
38705
+ import * as fs66 from "node:fs";
38706
+ import * as path79 from "node:path";
38400
38707
  function unverified(reason, exitCode) {
38401
38708
  console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", \u7EDF\u8BA1\u72B6\u6001: "\u672A\u6838\u9A8C", \u539F\u56E0: reason }, null, 2));
38402
38709
  return exitCode;
@@ -38417,14 +38724,14 @@ function draftLengthCli(argv) {
38417
38724
  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);
38418
38725
  }
38419
38726
  try {
38420
- if (!fs65.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
38727
+ if (!fs66.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
38421
38728
  const resolved = resolveInsideBook(book, requested);
38422
38729
  if (!resolved.ok) return unverified(resolved.reason, 1);
38423
38730
  const target = draftLengthTarget(resolved.relPath);
38424
38731
  if (target?.\u6587\u672C\u9636\u6BB5 !== "\u8349\u7A3F\u6587\u4EF6") return unverified("\u5B9E\u9645\u76EE\u6807\u4E0D\u662F\u89C4\u8303\u5B8C\u6574\u7A3F", 1);
38425
- const file = path78.join(book, resolved.relPath);
38426
- if (!fs65.statSync(file).isFile()) return unverified("\u7A3F\u4EF6\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6", 1);
38427
- const text5 = fs65.readFileSync(file, "utf8");
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");
38428
38735
  const result = draftLengthFeedback(target, text5, readChapterLength(book));
38429
38736
  console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", ...result }, null, 2));
38430
38737
  return result.\u7EDF\u8BA1\u72B6\u6001 === "\u5DF2\u7EDF\u8BA1" ? 0 : 1;
@@ -38643,8 +38950,8 @@ function exportCli(argv) {
38643
38950
  }
38644
38951
 
38645
38952
  // src/scripts/screenplay-export-cli.ts
38646
- import * as fs66 from "node:fs";
38647
- import * as path79 from "node:path";
38953
+ import * as fs67 from "node:fs";
38954
+ import * as path80 from "node:path";
38648
38955
  function argValue5(argv, name3) {
38649
38956
  const i = argv.indexOf(`--${name3}`);
38650
38957
  return i === -1 ? void 0 : argv[i + 1];
@@ -38705,12 +39012,12 @@ function screenplayExportCli(argv) {
38705
39012
  const \u5206\u955C\u5934raw = argValue5(argv, "\u5206\u955C\u5934")?.trim();
38706
39013
  let \u5206\u955C\u5934\u8868;
38707
39014
  if (\u5206\u955C\u5934raw !== void 0) {
38708
- const shotPath = path79.isAbsolute(\u5206\u955C\u5934raw) ? \u5206\u955C\u5934raw : path79.join(book, \u5206\u955C\u5934raw);
38709
- if (!fs66.existsSync(shotPath) || !fs66.statSync(shotPath).isFile()) {
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()) {
38710
39017
  console.error(`\u5206\u955C\u5934\u8868\u4E0D\u5B58\u5728\uFF1A${shotPath}`);
38711
39018
  return 1;
38712
39019
  }
38713
- const parsed = parseShotListTable(fs66.readFileSync(shotPath, "utf-8"));
39020
+ const parsed = parseShotListTable(fs67.readFileSync(shotPath, "utf-8"));
38714
39021
  if (!parsed.ok || parsed.shotList === void 0) {
38715
39022
  console.error(`\u5206\u955C\u5934\u8868\u89E3\u6790\u5931\u8D25\uFF1A${parsed.problems.join("\uFF1B")}`);
38716
39023
  return 1;
@@ -38720,13 +39027,13 @@ function screenplayExportCli(argv) {
38720
39027
  const \u603B\u7EB2raw = argValue5(argv, "\u603B\u7EB2")?.trim();
38721
39028
  let \u603B\u7EB2;
38722
39029
  if (\u603B\u7EB2raw !== void 0) {
38723
- const biblePath = path79.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path79.join(book, \u603B\u7EB2raw);
38724
- if (!fs66.existsSync(biblePath) || !fs66.statSync(biblePath).isFile()) {
39030
+ const biblePath = path80.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path80.join(book, \u603B\u7EB2raw);
39031
+ if (!fs67.existsSync(biblePath) || !fs67.statSync(biblePath).isFile()) {
38725
39032
  console.error(`\u603B\u7EB2\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${biblePath}`);
38726
39033
  return 1;
38727
39034
  }
38728
39035
  try {
38729
- const parsedBible = JSON.parse(fs66.readFileSync(biblePath, "utf-8"));
39036
+ const parsedBible = JSON.parse(fs67.readFileSync(biblePath, "utf-8"));
38730
39037
  if (typeof parsedBible !== "object" || parsedBible === null || Array.isArray(parsedBible)) {
38731
39038
  console.error("\u603B\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A\u603B\u7EB2 JSON \u987B\u4E3A\u5BF9\u8C61\uFF08StoryBibleInput \u4E03\u8282\uFF09");
38732
39039
  return 1;