@yangda611/dsh-scriptor 8.4.8 → 8.4.9

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;
@@ -21021,11 +21021,19 @@ function screenplayFinalPath() {
21021
21021
  }
21022
21022
 
21023
21023
  // ../core/src/shortdrama/types.ts
21024
+ var SHORTDRAMA_ORIENTATIONS = ["\u7AD6\u5C4F", "\u6A2A\u5C4F"];
21025
+ var HOOK_TYPES = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
21024
21026
  var HOOK_ROTATION = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
21025
21027
  function hookTypeForEpisode(\u96C6) {
21026
21028
  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
21029
  return HOOK_ROTATION[(\u96C6 - 1) % HOOK_ROTATION.length];
21028
21030
  }
21031
+ function isHookType(value) {
21032
+ return typeof value === "string" && HOOK_TYPES.includes(value);
21033
+ }
21034
+ function isShortDramaOrientation(value) {
21035
+ return typeof value === "string" && SHORTDRAMA_ORIENTATIONS.includes(value);
21036
+ }
21029
21037
 
21030
21038
  // ../core/src/shortdrama/templates.ts
21031
21039
  var SHORTDRAMA_SOURCES = {
@@ -21392,7 +21400,74 @@ function isBeatMark(mark) {
21392
21400
  function fail3(message) {
21393
21401
  throw new Error(`\u5355\u96C6\u5267\u672C\u6E32\u67D3\u5931\u8D25\uFF1A${message}`);
21394
21402
  }
21403
+ function requireRecord(value, field) {
21404
+ if (value === null || typeof value !== "object" || Array.isArray(value)) fail3(`${field}\u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61`);
21405
+ return value;
21406
+ }
21407
+ function requireArray(value, field) {
21408
+ if (!Array.isArray(value)) fail3(`${field}\u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4`);
21409
+ return value;
21410
+ }
21411
+ function requireString(value, field) {
21412
+ if (typeof value !== "string") fail3(`${field}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
21413
+ }
21414
+ function requireNumber(value, field) {
21415
+ if (typeof value !== "number") fail3(`${field}\u5FC5\u987B\u662F\u6570\u5B57`);
21416
+ }
21417
+ function requireStringArray(value, field) {
21418
+ for (const [index, item] of requireArray(value, field).entries()) requireString(item, `${field}[${index}]`);
21419
+ }
21420
+ function validateLines(value, field) {
21421
+ for (const [index, item] of requireArray(value, field).entries()) {
21422
+ const where = `${field}[${index}]`;
21423
+ const line = requireRecord(item, where);
21424
+ requireString(line["\u89D2\u8272"], `${where}.\u89D2\u8272`);
21425
+ requireString(line["\u53F0\u8BCD"], `${where}.\u53F0\u8BCD`);
21426
+ if (line["\u62EC\u53F7\u63D0\u793A"] !== void 0) requireString(line["\u62EC\u53F7\u63D0\u793A"], `${where}.\u62EC\u53F7\u63D0\u793A`);
21427
+ }
21428
+ }
21429
+ function validateStructure(input) {
21430
+ const value = requireRecord(input, "\u53C2\u6570");
21431
+ for (const field of ["\u6807\u9898", "\u6838\u5FC3\u60F3\u6CD5", "\u723D\u70B9", "\u7ED3\u5C3E\u60AC\u5FF5"]) requireString(value[field], field);
21432
+ if (!isShortDramaOrientation(value["\u753B\u5E45"])) fail3("\u753B\u5E45\u5FC5\u987B\u662F\u7AD6\u5C4F\u6216\u6A2A\u5C4F");
21433
+ if (!isHookType(value["\u94A9\u5B50\u7C7B\u578B"])) fail3("\u94A9\u5B50\u7C7B\u578B\u5FC5\u987B\u662F\u8EAB\u4EFD\u3001\u60C5\u611F\u6216\u987F\u609F");
21434
+ for (const field of ["\u5F00\u573A\u51B2\u7A81\u79D2", "\u7ED3\u5C3E\u94A9\u5B50\u79D2"]) requireNumber(value[field], field);
21435
+ for (const [index, second] of requireArray(value["\u53CD\u8F6C\u79D2"], "\u53CD\u8F6C\u79D2").entries()) requireNumber(second, `\u53CD\u8F6C\u79D2[${index}]`);
21436
+ for (const [index, item] of requireArray(value["\u573A\u666F"], "\u573A\u666F").entries()) {
21437
+ const where = `\u573A\u666F[${index}]`;
21438
+ const scene = requireRecord(item, where);
21439
+ for (const field of ["\u5730\u70B9", "\u65F6\u95F4", "\u52A8\u4F5C"]) requireString(scene[field], `${where}.${field}`);
21440
+ if (scene["\u5185\u5916"] !== "\u5185" && scene["\u5185\u5916"] !== "\u5916") fail3(`${where}.\u5185\u5916\u5FC5\u987B\u662F\u5185\u6216\u5916`);
21441
+ validateLines(scene["\u53F0\u8BCD"], `${where}.\u53F0\u8BCD`);
21442
+ if (scene["\u573A\u666F\u73AF\u5883"] !== void 0) requireString(scene["\u573A\u666F\u73AF\u5883"], `${where}.\u573A\u666F\u73AF\u5883`);
21443
+ if (scene["\u4EBA\u7269"] !== void 0) {
21444
+ for (const [personIndex, personItem] of requireArray(scene["\u4EBA\u7269"], `${where}.\u4EBA\u7269`).entries()) {
21445
+ const personWhere = `${where}.\u4EBA\u7269[${personIndex}]`;
21446
+ const person = requireRecord(personItem, personWhere);
21447
+ requireString(person["\u89D2\u8272"], `${personWhere}.\u89D2\u8272`);
21448
+ if (person["\u5F62\u8C61\u6807\u8BC6"] !== void 0) requireString(person["\u5F62\u8C61\u6807\u8BC6"], `${personWhere}.\u5F62\u8C61\u6807\u8BC6`);
21449
+ }
21450
+ }
21451
+ if (scene["\u955C\u5934"] !== void 0) {
21452
+ for (const [shotIndex, shotItem] of requireArray(scene["\u955C\u5934"], `${where}.\u955C\u5934`).entries()) {
21453
+ const shotWhere = `${where}.\u955C\u5934[${shotIndex}]`;
21454
+ const shot = requireRecord(shotItem, shotWhere);
21455
+ requireNumber(shot["\u955C\u5934\u53F7"], `${shotWhere}.\u955C\u5934\u53F7`);
21456
+ for (const field of ["\u5F00\u59CB\u79D2", "\u7ED3\u675F\u79D2"]) {
21457
+ if (shot[field] !== null) requireNumber(shot[field], `${shotWhere}.${field}\uFF08\u672A\u77E5\u65F6\u586B null\uFF09`);
21458
+ }
21459
+ for (const field of ["\u666F\u522B", "\u89D2\u5EA6", "\u8FD0\u955C"]) requireString(shot[field], `${shotWhere}.${field}`);
21460
+ requireStringArray(shot["\u63CF\u5199"], `${shotWhere}.\u63CF\u5199`);
21461
+ validateLines(shot["\u53F0\u8BCD"], `${shotWhere}.\u53F0\u8BCD`);
21462
+ for (const field of ["\u73AF\u5883\u58F0", "\u5B57\u5E55"]) {
21463
+ if (shot[field] !== void 0) requireStringArray(shot[field], `${shotWhere}.${field}`);
21464
+ }
21465
+ }
21466
+ }
21467
+ }
21468
+ }
21395
21469
  function validate(input) {
21470
+ validateStructure(input);
21396
21471
  const warnings = [];
21397
21472
  const template = RHYTHM_TEMPLATES[input.\u753B\u5E45];
21398
21473
  if (!Number.isSafeInteger(input.\u96C6) || input.\u96C6 < 1 || input.\u96C6 > 100) {
@@ -31456,6 +31531,10 @@ function createScreenplayTools(deps = {}) {
31456
31531
  ];
31457
31532
  }
31458
31533
 
31534
+ // src/shortdrama-tools.ts
31535
+ import * as fs54 from "node:fs";
31536
+ import * as path66 from "node:path";
31537
+
31459
31538
  // src/tool-failure.ts
31460
31539
  var NEXT_STEP = {
31461
31540
  "invalid-argument": "\u6309 reason \u4FEE\u6B63\u53C2\u6570\u540E\u91CD\u65B0\u8C03\u7528\u3002",
@@ -31607,7 +31686,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31607
31686
  },
31608
31687
  {
31609
31688
  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",
31689
+ 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
31690
  parameters: {
31612
31691
  type: "object",
31613
31692
  properties: {
@@ -31668,7 +31747,10 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31668
31747
  type: "object",
31669
31748
  properties: {
31670
31749
  ok: { type: "boolean" },
31671
- path: { type: "string", description: "\u5B9A\u7A3F\u8DEF\u5F84\uFF0C\u5982 \u5267\u672C/\u77ED\u5267/\u96C6001.md" },
31750
+ 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" },
31751
+ finalPath: { type: "string", description: "\u672A\u6765\u5B9A\u7A3F\u8DEF\u5F84\uFF1B\u4E0D\u8868\u793A\u5DF2\u7ECF\u5B9A\u7A3F" },
31752
+ saved: { type: "boolean", description: "\u5B9E\u9645\u6587\u4EF6\u8BFB\u56DE\u4E00\u81F4\u65F6\u624D\u4E3A true" },
31753
+ message: { type: "string" },
31672
31754
  \u5185\u5BB9: { type: "string" },
31673
31755
  \u8B66\u544A: { type: "array" },
31674
31756
  reason: { type: "string" }
@@ -31680,7 +31762,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31680
31762
  execute: (args) => run(() => {
31681
31763
  const input = asRecord2(args, "\u53C2\u6570");
31682
31764
  const rendered = renderEpisodeScript(input);
31683
- return { ok: true, ...rendered };
31765
+ return { ok: true, ...rendered, finalPath: rendered.path, saved: false, message: "\u4EC5\u6E32\u67D3\u9884\u89C8\uFF0C\u5C1A\u672A\u4FDD\u5B58\u6587\u4EF6\u3002" };
31684
31766
  })
31685
31767
  },
31686
31768
  {
@@ -31823,10 +31905,47 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
31823
31905
  })
31824
31906
  }
31825
31907
  ];
31908
+ function createShortdramaTools(deps) {
31909
+ return SHORTDRAMA_TOOL_DEFINITIONS.map((tool) => {
31910
+ if (tool.name !== "novel_shortdrama_render_episode") return tool;
31911
+ const parameters = tool.parameters;
31912
+ return {
31913
+ ...tool,
31914
+ 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",
31915
+ parameters: {
31916
+ ...tool.parameters,
31917
+ properties: { ...parameters.properties, bookId: { type: "string", description: "\u5F53\u524D\u77ED\u5267\u7684\u4E66id\uFF08\u5FC5\u586B\uFF09" } },
31918
+ required: ["bookId", ...parameters.required]
31919
+ },
31920
+ execute: async (args, exec) => {
31921
+ const bookId2 = typeof args["bookId"] === "string" ? args["bookId"].trim() : "";
31922
+ if (bookId2 === "") return toolFailure("book-not-found", "bookId \u5FC5\u586B\uFF0C\u8BF7\u5148\u6838\u5BF9\u5F53\u524D\u77ED\u5267\u4E66\u76EE\u3002");
31923
+ try {
31924
+ const root = deps.bookRootOfBookId(bookId2, exec?.agent);
31925
+ if (root === void 0) return toolFailure("book-not-found", `\u4E66id\u4E0D\u5B58\u5728\u6216\u4E0D\u552F\u4E00\uFF1A${bookId2}`);
31926
+ if (readExistingContract(root).fields["\u8F93\u51FA\u5F62\u6001"] !== "\u77ED\u5267") return toolFailure("invalid-argument", "\u4F5C\u54C1\u5951\u7EA6\u7684\u8F93\u51FA\u5F62\u6001\u5FC5\u987B\u662F\u77ED\u5267\uFF0C\u4E0D\u80FD\u4FDD\u5B58\u5230\u5176\u4ED6\u9879\u76EE\u3002");
31927
+ const rendered = renderEpisodeScript(args);
31928
+ const draftPath = `\u8349\u7A3F\u533A/${rendered.path}`;
31929
+ const access = gateFileAccess(root, draftPath);
31930
+ 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}`);
31931
+ exec?.signal?.throwIfAborted();
31932
+ await deps.writeDraft(root, { relPath: draftPath, content: rendered.\u5185\u5BB9 }, exec);
31933
+ if (fs54.readFileSync(path66.join(root, draftPath), "utf8") !== rendered.\u5185\u5BB9) {
31934
+ 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 };
31935
+ }
31936
+ 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" };
31937
+ } catch (error) {
31938
+ if (exec?.signal?.aborted) throw error;
31939
+ return { ...failureFrom(error, "\u77ED\u5267\u8349\u7A3F\u4FDD\u5B58\u5931\u8D25\uFF1A"), saved: false };
31940
+ }
31941
+ }
31942
+ };
31943
+ });
31944
+ }
31826
31945
 
31827
31946
  // src/approval-snapshot.ts
31828
- import * as fs54 from "node:fs";
31829
- import * as path66 from "node:path";
31947
+ import * as fs55 from "node:fs";
31948
+ import * as path67 from "node:path";
31830
31949
  import { createHash as createHash19 } from "node:crypto";
31831
31950
  function captureApprovalFiles(root, relatives, request) {
31832
31951
  try {
@@ -31834,13 +31953,13 @@ function captureApprovalFiles(root, relatives, request) {
31834
31953
  const visit = (relative12) => {
31835
31954
  const target = authorDocumentPath(root, relative12);
31836
31955
  try {
31837
- const stat = fs54.statSync(target);
31956
+ const stat = fs55.statSync(target);
31838
31957
  if (stat.isDirectory()) {
31839
- const names = fs54.readdirSync(target).sort();
31958
+ const names = fs55.readdirSync(target).sort();
31840
31959
  files.push([relative12 + "/", JSON.stringify(names)]);
31841
- for (const name3 of names) visit(path66.posix.join(relative12, name3));
31960
+ for (const name3 of names) visit(path67.posix.join(relative12, name3));
31842
31961
  } else if (stat.isFile()) {
31843
- files.push([relative12, createHash19("sha256").update(fs54.readFileSync(target)).digest("hex")]);
31962
+ files.push([relative12, createHash19("sha256").update(fs55.readFileSync(target)).digest("hex")]);
31844
31963
  } else throw new Error(`\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1A${relative12}`);
31845
31964
  } catch (error) {
31846
31965
  if (error.code === "ENOENT") {
@@ -31960,8 +32079,8 @@ var MAINTENANCE_OUTPUT = {
31960
32079
  };
31961
32080
 
31962
32081
  // src/book-upgrade-tools.ts
31963
- import fs55 from "node:fs";
31964
- import path67 from "node:path";
32082
+ import fs56 from "node:fs";
32083
+ import path68 from "node:path";
31965
32084
  import { validateJsonSchemaValue as validateJsonSchemaValue2 } from "@deepseek-ai/dsh-tools";
31966
32085
 
31967
32086
  // src/book-upgrade-output.ts
@@ -32041,8 +32160,8 @@ var BOOK_UPGRADE_WRITE_OUTPUT = {
32041
32160
  var marker2 = { maintenance: "book-upgrade" };
32042
32161
  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
32162
  var identity2 = (root) => {
32044
- const real = fs55.realpathSync.native(root);
32045
- return process.platform === "win32" ? path67.resolve(real).toLowerCase() : path67.resolve(real);
32163
+ const real = fs56.realpathSync.native(root);
32164
+ return process.platform === "win32" ? path68.resolve(real).toLowerCase() : path68.resolve(real);
32046
32165
  };
32047
32166
  function provenance(exec) {
32048
32167
  if (exec === void 0) return void 0;
@@ -32196,7 +32315,7 @@ function createBookUpgradeTools(deps) {
32196
32315
  }
32197
32316
 
32198
32317
  // src/novel-tools.ts
32199
- import * as fs59 from "node:fs";
32318
+ import * as fs60 from "node:fs";
32200
32319
  import * as nodePath3 from "node:path";
32201
32320
 
32202
32321
  // src/design-commit-result.ts
@@ -32662,14 +32781,14 @@ function onboardingMissing(answers) {
32662
32781
  }
32663
32782
 
32664
32783
  // src/study/onboarding-store.ts
32665
- import * as fs56 from "node:fs";
32666
- import * as path68 from "node:path";
32784
+ import * as fs57 from "node:fs";
32785
+ import * as path69 from "node:path";
32667
32786
  function onboardingDraftPath(workspaceRoot) {
32668
- return path68.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
32787
+ return path69.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
32669
32788
  }
32670
32789
  function readOnboardingDraft(workspaceRoot) {
32671
32790
  try {
32672
- const raw = fs56.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
32791
+ const raw = fs57.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
32673
32792
  return validateOnboardingAnswers(JSON.parse(raw));
32674
32793
  } catch {
32675
32794
  return {};
@@ -32677,27 +32796,27 @@ function readOnboardingDraft(workspaceRoot) {
32677
32796
  }
32678
32797
  function saveOnboardingDraft(workspaceRoot, answers) {
32679
32798
  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");
32799
+ fs57.mkdirSync(path69.dirname(target), { recursive: true });
32800
+ fs57.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
32682
32801
  }
32683
32802
  function consumeOnboardingDraft(workspaceRoot) {
32684
32803
  try {
32685
- fs56.unlinkSync(onboardingDraftPath(workspaceRoot));
32804
+ fs57.unlinkSync(onboardingDraftPath(workspaceRoot));
32686
32805
  } catch {
32687
32806
  }
32688
32807
  }
32689
32808
 
32690
32809
  // ../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
32810
  import * as fs58 from "node:fs";
32696
32811
  import * as path70 from "node:path";
32812
+
32813
+ // ../drafting/src/write.ts
32814
+ import * as fs59 from "node:fs";
32815
+ import * as path71 from "node:path";
32697
32816
  var DRAFT_KEYS = ["\u8EAB\u4EFD", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u6765\u6E90\u5FEB\u7167", "\u89D2\u8272", "\u9009\u5B9A"];
32698
32817
  function readText12(root, rel) {
32699
32818
  try {
32700
- return fs58.readFileSync(path70.join(root, rel), "utf-8");
32819
+ return fs59.readFileSync(path71.join(root, rel), "utf-8");
32701
32820
  } catch {
32702
32821
  return null;
32703
32822
  }
@@ -32706,9 +32825,9 @@ function draftDir(key) {
32706
32825
  return paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D);
32707
32826
  }
32708
32827
  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"));
32828
+ const abs = path71.join(bookRoot, draftDir(key));
32829
+ if (!fs59.existsSync(abs) || !fs59.statSync(abs).isDirectory()) return [];
32830
+ return fs59.readdirSync(abs).filter((f) => f.endsWith(".md")).sort((a, b) => a.localeCompare(b, "zh"));
32712
32831
  }
32713
32832
  function parseDraftNo(file) {
32714
32833
  const m = /^稿(\d+)\.md$/.exec(file);
@@ -32717,7 +32836,7 @@ function parseDraftNo(file) {
32717
32836
  function latestVersion(bookRoot, key) {
32718
32837
  let max = null;
32719
32838
  for (const file of listDraftFiles(bookRoot, key)) {
32720
- const text5 = readText12(bookRoot, path70.posix.join(draftDir(key), file));
32839
+ const text5 = readText12(bookRoot, path71.posix.join(draftDir(key), file));
32721
32840
  if (text5 === null) continue;
32722
32841
  const doc = parseDocument(text5);
32723
32842
  if (!doc.ok) continue;
@@ -32744,7 +32863,7 @@ function selectDraftLocked(bookRoot, input) {
32744
32863
  const files = listDraftFiles(bookRoot, input);
32745
32864
  if (!files.includes(target)) return { ok: false, reason: `\u8349\u7A3F\u4E0D\u5B58\u5728:${target}` };
32746
32865
  for (const file of files) {
32747
- const rel = path70.posix.join(dir, file);
32866
+ const rel = path71.posix.join(dir, file);
32748
32867
  const text5 = readText12(bookRoot, rel);
32749
32868
  if (text5 === null) continue;
32750
32869
  const doc = parseDocument(text5);
@@ -32768,7 +32887,7 @@ function writeDraftLocked(bookRoot, input) {
32768
32887
  const parent = latestVersion(bookRoot, key);
32769
32888
  const ver = parent === null ? initialVersion("\u5199\u7A3F") : bumpVersion(parent, "\u5199\u7A3F");
32770
32889
  const file = nextFileName(bookRoot, key);
32771
- const relPath = path70.posix.join(draftDir(key), file);
32890
+ const relPath = path71.posix.join(draftDir(key), file);
32772
32891
  const fields = applyVersionFields(
32773
32892
  {
32774
32893
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -32800,7 +32919,7 @@ function importAuthorDraftLocked(bookRoot, input) {
32800
32919
  const explicitParent = input.\u7236\u7248\u672C ?? latestVersion(bookRoot, key);
32801
32920
  const ver = explicitParent === null ? initialVersion("\u4F5C\u8005\u7A3F\u5BFC\u5165") : bumpVersion(explicitParent, "\u4F5C\u8005\u7A3F\u5BFC\u5165");
32802
32921
  const file = nextFileName(bookRoot, key);
32803
- const relPath = path70.posix.join(draftDir(key), file);
32922
+ const relPath = path71.posix.join(draftDir(key), file);
32804
32923
  const fields = applyVersionFields(
32805
32924
  {
32806
32925
  \u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
@@ -33137,7 +33256,7 @@ function createNovelTools(deps) {
33137
33256
  paths.\u5377\u7EB2(\u5377),
33138
33257
  paths.\u8BA1\u5212\u65F6\u95F4\u7EBF(\u5377),
33139
33258
  paths.\u8FD1\u671F\u7A97\u53E3(\u5377)
33140
- ].filter((p) => fs59.existsSync(nodePath3.join(bookRoot, p)));
33259
+ ].filter((p) => fs60.existsSync(nodePath3.join(bookRoot, p)));
33141
33260
  const commit = commitConfirmed({ bookRoot, paths: seedPaths, prefix: "design", summary: "\u6700\u5C0F\u8BBE\u8BA1\u9AA8\u67B6", provenance: provenanceOf(sessionContext, seedPaths) });
33142
33261
  if (!commit.ok) {
33143
33262
  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 +33852,7 @@ function createNovelTools(deps) {
33733
33852
  const rel = paths.\u8FD1\u671F\u7A97\u53E3(\u5377);
33734
33853
  let text5 = "";
33735
33854
  try {
33736
- text5 = fs59.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
33855
+ text5 = fs60.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
33737
33856
  } catch {
33738
33857
  text5 = "";
33739
33858
  }
@@ -34429,7 +34548,7 @@ function createNovelTools(deps) {
34429
34548
  const res = archiveRetconRequest({ bookRoot, chapter: \u5B9A\u7A3F\u76F8\u5BF9, request, provenance: provenanceOf(sessionContext) }, (plannedPackageDir) => {
34430
34549
  let \u66F4\u6B63\u540E\u5168\u6587;
34431
34550
  try {
34432
- const src = fs59.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
34551
+ const src = fs60.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
34433
34552
  const doc = parseDocument(src);
34434
34553
  if (!doc.ok) return { ok: false, reason: `\u5B9A\u7A3F\u7AE0\u89E3\u6790\u5931\u8D25\uFF1A${doc.detail}` };
34435
34554
  const parent = extractVersionFields(doc.data.fields).\u7248\u672C;
@@ -34457,19 +34576,19 @@ function createNovelTools(deps) {
34457
34576
  const value = optionalText(f);
34458
34577
  return value === null ? [] : [[\u5019\u9009\u6587\u4EF6[f], value]];
34459
34578
  }));
34460
- if (fs59.existsSync(\u5305\u7EDD\u5BF9)) {
34461
- for (const name3 of fs59.readdirSync(\u5305\u7EDD\u5BF9)) {
34579
+ if (fs60.existsSync(\u5305\u7EDD\u5BF9)) {
34580
+ for (const name3 of fs60.readdirSync(\u5305\u7EDD\u5BF9)) {
34462
34581
  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)) {
34582
+ const stat = fs60.lstatSync(file);
34583
+ if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs60.readFileSync(file, "utf8") !== contents.get(name3)) {
34465
34584
  return { ok: false, reason: "\u8865\u507F\u5305\u5019\u9009\u51B2\u7A81\uFF0C\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6838\u5BF9\u540E\u5904\u7406" };
34466
34585
  }
34467
34586
  }
34468
34587
  }
34469
- fs59.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
34588
+ fs60.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
34470
34589
  for (const [name3, value] of contents) {
34471
34590
  const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
34472
- if (!fs59.existsSync(file)) fs59.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
34591
+ if (!fs60.existsSync(file)) fs60.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
34473
34592
  }
34474
34593
  packageDir = \u5305\u76F8\u5BF9;
34475
34594
  }
@@ -34490,7 +34609,7 @@ function createNovelTools(deps) {
34490
34609
  retconFiles.push({ \u76EE\u6807: \u6458\u8981\u76F8\u5BF9, \u5185\u5BB9: request.\u66F4\u6B63\u540E\u7AE0\u6458\u8981 });
34491
34610
  } else {
34492
34611
  try {
34493
- const \u6458\u8981\u73B0\u6587 = fs59.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
34612
+ const \u6458\u8981\u73B0\u6587 = fs60.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
34494
34613
  retconFiles.push({
34495
34614
  \u76EE\u6807: \u6458\u8981\u76F8\u5BF9,
34496
34615
  \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 +34891,7 @@ ${\u6458\u8981\u73B0\u6587}`
34772
34891
  bookRootOfBookId: deps.bookRootOfBookId,
34773
34892
  readContractFields: (bookRoot) => readExistingContract(bookRoot).fields
34774
34893
  }),
34775
- ...SHORTDRAMA_TOOL_DEFINITIONS
34894
+ ...createShortdramaTools({ bookRootOfBookId: deps.bookRootOfBookId, writeDraft: writeNative })
34776
34895
  );
34777
34896
  const locked = /* @__PURE__ */ new Set([
34778
34897
  "novel_new_outline_draft",
@@ -34792,9 +34911,10 @@ ${\u6458\u8981\u73B0\u6587}`
34792
34911
  "novel_record_review_findings",
34793
34912
  "novel_record_proposal",
34794
34913
  "novel_resolve_proposal",
34795
- "novel_note_pending"
34914
+ "novel_note_pending",
34915
+ "novel_shortdrama_render_episode"
34796
34916
  ]);
34797
- const nativeTools = NATIVE_DESIGN_TOOLS;
34917
+ const nativeTools = /* @__PURE__ */ new Set([...NATIVE_DESIGN_TOOLS, "novel_shortdrama_render_episode"]);
34798
34918
  const registered = deps.testTools === true ? tools : tools.filter((tool) => !NOVEL_TEST_TOOL_NAMES.includes(tool.name));
34799
34919
  const guarded = registered.map((tool) => {
34800
34920
  if (!locked.has(tool.name)) return tool;
@@ -34806,7 +34926,10 @@ ${\u6458\u8981\u73B0\u6587}`
34806
34926
  if (root === void 0) return tool.execute(args, sessionContext);
34807
34927
  try {
34808
34928
  if (nativeTools.has(tool.name)) {
34809
- return withBookWriteAsync(root, async () => tool.execute(args, sessionContext), provenanceOf(sessionContext)).catch((error) => failureFrom(error));
34929
+ return withBookWriteAsync(root, async () => tool.execute(args, sessionContext), provenanceOf(sessionContext)).catch((error) => {
34930
+ if (sessionContext?.signal?.aborted) throw error;
34931
+ return failureFrom(error);
34932
+ });
34810
34933
  }
34811
34934
  return withBookWrite(root, () => tool.execute(args, sessionContext), provenanceOf(sessionContext));
34812
34935
  } catch (error) {
@@ -34947,8 +35070,8 @@ function finishDesignCommit(bookRoot, writtenPaths, args, defaultSummary, chapte
34947
35070
  import { boundContextSummary, createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
34948
35071
 
34949
35072
  // src/study/service.ts
34950
- import * as fs62 from "node:fs";
34951
- import * as path73 from "node:path";
35073
+ import * as fs63 from "node:fs";
35074
+ import * as path74 from "node:path";
34952
35075
 
34953
35076
  // ../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
34954
35077
  var Diff = class {
@@ -35050,16 +35173,16 @@ var Diff = class {
35050
35173
  }
35051
35174
  }
35052
35175
  }
35053
- addToPath(path80, added, removed, oldPosInc, options2) {
35054
- const last = path80.lastComponent;
35176
+ addToPath(path81, added, removed, oldPosInc, options2) {
35177
+ const last = path81.lastComponent;
35055
35178
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
35056
35179
  return {
35057
- oldPos: path80.oldPos + oldPosInc,
35180
+ oldPos: path81.oldPos + oldPosInc,
35058
35181
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
35059
35182
  };
35060
35183
  } else {
35061
35184
  return {
35062
- oldPos: path80.oldPos + oldPosInc,
35185
+ oldPos: path81.oldPos + oldPosInc,
35063
35186
  lastComponent: { count: 1, added, removed, previousComponent: last }
35064
35187
  };
35065
35188
  }
@@ -35250,7 +35373,7 @@ var text4 = (value) => typeof value === "string" ? value : "";
35250
35373
  var terms = (value) => Array.isArray(value) ? value.flatMap(terms) : typeof value === "string" ? value.split(/[、,,;]/).map((item) => item.trim()).filter(Boolean) : [];
35251
35374
  var wiki = (body) => [...body.matchAll(/\[\[([^\]\n]+)\]\]/g)].map((match) => match[1].split("|")[0].trim());
35252
35375
  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";
35376
+ 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
35377
  function readStoryGraph(source2) {
35255
35378
  const records = [], edges = [], events = [];
35256
35379
  const warnings = [];
@@ -35282,7 +35405,7 @@ function readStoryGraph(source2) {
35282
35405
  aliases.set(name3, values);
35283
35406
  };
35284
35407
  const strings = (fields) => Object.fromEntries(Object.entries(fields).filter((pair) => typeof pair[1] === "string"));
35285
- const fromFields = (id, label2, kind2, path80, line, fields, body) => ({
35408
+ const fromFields = (id, label2, kind2, path81, line, fields, body) => ({
35286
35409
  id,
35287
35410
  label: label2,
35288
35411
  kind: kind2,
@@ -35291,23 +35414,23 @@ function readStoryGraph(source2) {
35291
35414
  chapter: chapter(fields["\u8D77\u59CB\u7AE0"]) ?? chapter(fields["\u751F\u6548\u7AE0"]) ?? chapter(fields["\u7AE0\u53F7"]) ?? entryChapterNo({ \u5B57\u6BB5: strings(fields) }) ?? void 0,
35292
35415
  endChapter: chapter(fields["\u5931\u6548\u7AE0"]),
35293
35416
  revealChapter: chapter(fields["\u62AB\u9732\u7AE0"]) ?? chapter(fields["\u63ED\u793A\u7AE0"]),
35294
- source: { space: "book:" + source2.bookId, path: path80 },
35417
+ source: { space: "book:" + source2.bookId, path: path81 },
35295
35418
  line,
35296
35419
  preview: body.trim().slice(0, 600),
35297
35420
  // Expose authored scalar/list field names as grouping choices without
35298
35421
  // guessing whether 宗门/血脉/师承 means faction, family or another identity.
35299
35422
  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
35423
  });
35301
- const scan = (path80, depth = 0) => {
35424
+ const scan = (path81, depth = 0) => {
35302
35425
  if (depth > 12) {
35303
- warnings.push({ path: path80, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
35426
+ warnings.push({ path: path81, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
35304
35427
  return;
35305
35428
  }
35306
35429
  let entries;
35307
35430
  try {
35308
- entries = source2.list(path80);
35431
+ entries = source2.list(path81);
35309
35432
  } catch (error) {
35310
- if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
35433
+ if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
35311
35434
  return;
35312
35435
  }
35313
35436
  for (const entry of entries) {
@@ -35398,26 +35521,26 @@ function readStoryGraph(source2) {
35398
35521
  };
35399
35522
  scan("\u4E16\u754C\u4E66");
35400
35523
  for (const category of LEDGER_NAMES) {
35401
- const path80 = "\u8D26\u672C/" + category + ".md";
35524
+ const path81 = "\u8D26\u672C/" + category + ".md";
35402
35525
  let raw;
35403
35526
  try {
35404
- raw = source2.read(path80);
35527
+ raw = source2.read(path81);
35405
35528
  } catch (error) {
35406
- if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
35529
+ if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
35407
35530
  continue;
35408
35531
  }
35409
35532
  const ranges2 = createEvidenceRanges(raw);
35410
- sourceHashes[path80] = ranges2.hash;
35411
- const parsed = parseLedgerHistory(raw, category, path80);
35533
+ sourceHashes[path81] = ranges2.hash;
35534
+ const parsed = parseLedgerHistory(raw, category, path81);
35412
35535
  if (!parsed.ok) {
35413
- warnings.push({ path: path80, message: parsed.reason });
35536
+ warnings.push({ path: path81, message: parsed.reason });
35414
35537
  continue;
35415
35538
  }
35416
35539
  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);
35540
+ const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path81 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
35418
35541
  const content = category === "\u65F6\u95F4\u7EBF" ? renderTimelineContent(entry) : entry.\u6B63\u6587;
35419
35542
  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);
35543
+ const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path81, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
35421
35544
  const recordChapter2 = entryChapterNo(entry) ?? void 0;
35422
35545
  const storyTime = category === "\u65F6\u95F4\u7EBF" ? timelineStoryTime(entry) : void 0;
35423
35546
  const record4 = { ...base, recordChapter: recordChapter2, storyTime, historyBasis: recordChapter2 ? "recorded" : "unknown", evidenceId };
@@ -35438,11 +35561,11 @@ function readStoryGraph(source2) {
35438
35561
  links.push({ record: record4, targets: wiki(content), pair: false });
35439
35562
  }
35440
35563
  }
35441
- const resolve22 = (target, path80) => {
35564
+ const resolve22 = (target, path81) => {
35442
35565
  const name3 = target.replace(/^\[\[|\]\]$/g, "").replace(/@\d+$/, "").replace(/\\/g, "/");
35443
35566
  const found = aliases.get(name3);
35444
35567
  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 });
35568
+ 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
35569
  return void 0;
35447
35570
  };
35448
35571
  for (const item of links) {
@@ -35466,32 +35589,32 @@ function readStoryGraph(source2) {
35466
35589
  const currentBound = (items) => items.map((item) => item.currentOnlyAt === void 0 ? item : { ...item, currentOnlyAt: maxChapter });
35467
35590
  const withChapters = evidence.map((item) => {
35468
35591
  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 })) };
35592
+ return { ...item, relatedChapters: [...new Set(references)].map((path81) => ({ space: item.source.space, path: path81 })) };
35470
35593
  });
35471
35594
  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
35595
  }
35473
35596
 
35474
35597
  // src/study/graph-source.ts
35475
- import * as fs60 from "node:fs";
35476
- import * as path71 from "node:path";
35598
+ import * as fs61 from "node:fs";
35599
+ import * as path72 from "node:path";
35477
35600
  import { createHash as createHash20 } from "node:crypto";
35478
35601
  function readGraphFile(base, relative12) {
35479
35602
  validateAuthorRelativePath(relative12);
35480
- const file = path71.join(base, relative12);
35603
+ const file = path72.join(base, relative12);
35481
35604
  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");
35605
+ 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
35606
  };
35484
35607
  checkPhysical();
35485
- const initial = fs60.lstatSync(file);
35608
+ const initial = fs61.lstatSync(file);
35486
35609
  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
35610
  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));
35611
+ const descriptor = fs61.openSync(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
35489
35612
  try {
35490
- const opened = fs60.fstatSync(descriptor);
35613
+ const opened = fs61.fstatSync(descriptor);
35491
35614
  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);
35615
+ const bytes = fs61.readFileSync(descriptor);
35493
35616
  checkPhysical();
35494
- const current = fs60.lstatSync(file), finished = fs60.fstatSync(descriptor);
35617
+ const current = fs61.lstatSync(file), finished = fs61.fstatSync(descriptor);
35495
35618
  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
35619
  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
35620
  try {
@@ -35500,26 +35623,26 @@ function readGraphFile(base, relative12) {
35500
35623
  throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u4F7F\u7528UTF-8");
35501
35624
  }
35502
35625
  } finally {
35503
- fs60.closeSync(descriptor);
35626
+ fs61.closeSync(descriptor);
35504
35627
  }
35505
35628
  }
35506
35629
  async function readGraphFileAsync(base, relative12, signal) {
35507
35630
  signal?.throwIfAborted();
35508
35631
  validateAuthorRelativePath(relative12);
35509
- const file = path71.join(base, relative12);
35632
+ const file = path72.join(base, relative12);
35510
35633
  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");
35634
+ 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
35635
  };
35513
35636
  await checkPhysical();
35514
- const initial = await fs60.promises.lstat(file);
35637
+ const initial = await fs61.promises.lstat(file);
35515
35638
  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));
35639
+ const handle = await fs61.promises.open(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
35517
35640
  try {
35518
35641
  const opened = await handle.stat();
35519
35642
  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
35643
  const bytes = await handle.readFile({ signal });
35521
35644
  await checkPhysical();
35522
- const current = await fs60.promises.lstat(file), finished = await handle.stat();
35645
+ const current = await fs61.promises.lstat(file), finished = await handle.stat();
35523
35646
  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
35647
  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
35648
  try {
@@ -35539,12 +35662,12 @@ async function scanGraphFiles(root, space, signal) {
35539
35662
  if (depth > 12) return;
35540
35663
  try {
35541
35664
  const directory = authorDocumentPath(root, relative12, true);
35542
- const entries = await fs60.promises.readdir(directory, { withFileTypes: true });
35665
+ const entries = await fs61.promises.readdir(directory, { withFileTypes: true });
35543
35666
  const rows = entries.filter((item) => !item.name.startsWith(".") && item.name !== "node_modules").map((item) => ({
35544
35667
  name: item.name,
35545
35668
  directory: item.isDirectory(),
35546
35669
  draft: false,
35547
- ref: { space, path: path71.posix.join(relative12, item.name) },
35670
+ ref: { space, path: path72.posix.join(relative12, item.name) },
35548
35671
  ...item.isSymbolicLink() || !item.isFile() && !item.isDirectory() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
35549
35672
  }));
35550
35673
  directories.set(relative12, rows);
@@ -35769,8 +35892,8 @@ function overlayExtractions(graph, extractions) {
35769
35892
  }
35770
35893
 
35771
35894
  // src/indexing/graph-storage.ts
35772
- import * as fs61 from "node:fs";
35773
- import * as path72 from "node:path";
35895
+ import * as fs62 from "node:fs";
35896
+ import * as path73 from "node:path";
35774
35897
  import { createRequire as createRequire2 } from "node:module";
35775
35898
  import { createHash as createHash21, randomUUID as randomUUID8 } from "node:crypto";
35776
35899
  var APPLICATION_ID2 = 1465272113;
@@ -35792,24 +35915,24 @@ function initialGraphState(bookId2) {
35792
35915
  }
35793
35916
  function graphFile(root, name3) {
35794
35917
  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]]) {
35918
+ const runtime = path73.join(root, ".webnovel");
35919
+ for (const [target, directory] of [[runtime, true], [path73.join(runtime, name3), false]]) {
35797
35920
  try {
35798
- const stat = fs61.lstatSync(target);
35921
+ const stat = fs62.lstatSync(target);
35799
35922
  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
35923
  } catch (error) {
35801
35924
  if (error.code !== "ENOENT") throw error;
35802
35925
  }
35803
35926
  }
35804
- return path72.join(runtime, name3);
35927
+ return path73.join(runtime, name3);
35805
35928
  }
35806
35929
  function readGraphState(root, bookId2) {
35807
35930
  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");
35931
+ if (!fs62.existsSync(file)) return initialGraphState(bookId2);
35932
+ if (fs62.statSync(file).size > 32768) throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u8FC7\u5927\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
35810
35933
  let value;
35811
35934
  try {
35812
- value = JSON.parse(fs61.readFileSync(file, "utf8"));
35935
+ value = JSON.parse(fs62.readFileSync(file, "utf8"));
35813
35936
  } catch {
35814
35937
  throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
35815
35938
  }
@@ -35819,12 +35942,12 @@ function readGraphState(root, bookId2) {
35819
35942
  function writeGraphState(root, state) {
35820
35943
  const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID8()}.tmp`;
35821
35944
  try {
35822
- fs61.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
35945
+ fs62.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
35823
35946
  graphFile(root, STATE_NAME);
35824
- fs61.renameSync(temporary, file);
35947
+ fs62.renameSync(temporary, file);
35825
35948
  } finally {
35826
35949
  try {
35827
- fs61.unlinkSync(temporary);
35950
+ fs62.unlinkSync(temporary);
35828
35951
  } catch {
35829
35952
  }
35830
35953
  }
@@ -35839,10 +35962,10 @@ function changeGraphState(root, bookId2, update) {
35839
35962
  function acquireGraphLease(root) {
35840
35963
  return withBookLockAsync(root, async () => {
35841
35964
  const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID8();
35842
- if (fs61.existsSync(file)) {
35965
+ if (fs62.existsSync(file)) {
35843
35966
  let pid;
35844
35967
  try {
35845
- pid = JSON.parse(fs61.readFileSync(file, "utf8")).pid;
35968
+ pid = JSON.parse(fs62.readFileSync(file, "utf8")).pid;
35846
35969
  } catch {
35847
35970
  throw new Error("\u56FE\u8C31\u4EFB\u52A1\u9501\u65E0\u6CD5\u89E3\u6790\uFF0C\u672A\u6E05\u7406\u539F\u6587\u4EF6");
35848
35971
  }
@@ -35854,12 +35977,12 @@ function acquireGraphLease(root) {
35854
35977
  dead2 = error.code === "ESRCH";
35855
35978
  }
35856
35979
  if (!dead2) throw new Error("\u53E6\u4E00\u56FE\u8C31\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C");
35857
- fs61.unlinkSync(graphFile(root, "story-graph.worker.lock"));
35980
+ fs62.unlinkSync(graphFile(root, "story-graph.worker.lock"));
35858
35981
  }
35859
- fs61.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
35982
+ fs62.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
35860
35983
  return () => {
35861
35984
  try {
35862
- if (JSON.parse(fs61.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs61.unlinkSync(file);
35985
+ if (JSON.parse(fs62.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs62.unlinkSync(file);
35863
35986
  } catch {
35864
35987
  }
35865
35988
  };
@@ -35867,20 +35990,20 @@ function acquireGraphLease(root) {
35867
35990
  }
35868
35991
  function graphCacheSignature(root) {
35869
35992
  const file = graphFile(root, CACHE_NAME);
35870
- return fs61.existsSync(file) ? createHash21("sha256").update(fs61.readFileSync(file)).digest("hex") : "missing";
35993
+ return fs62.existsSync(file) ? createHash21("sha256").update(fs62.readFileSync(file)).digest("hex") : "missing";
35871
35994
  }
35872
35995
  function cacheHeader(file) {
35873
- const header2 = Buffer.alloc(100), handle = fs61.openSync(file, "r");
35996
+ const header2 = Buffer.alloc(100), handle = fs62.openSync(file, "r");
35874
35997
  try {
35875
- fs61.readSync(handle, header2, 0, 100, 0);
35998
+ fs62.readSync(handle, header2, 0, 100, 0);
35876
35999
  } finally {
35877
- fs61.closeSync(handle);
36000
+ fs62.closeSync(handle);
35878
36001
  }
35879
36002
  return header2;
35880
36003
  }
35881
36004
  function replaceGraphCache(root, bookId2) {
35882
36005
  const file = graphFile(root, CACHE_NAME);
35883
- if (!fs61.existsSync(file)) return;
36006
+ if (!fs62.existsSync(file)) return;
35884
36007
  const header2 = cacheHeader(file);
35885
36008
  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
36009
  let db;
@@ -35900,12 +36023,12 @@ function replaceGraphCache(root, bookId2) {
35900
36023
  try {
35901
36024
  for (const ending of ["", "-journal", "-wal", "-shm"]) {
35902
36025
  const source2 = graphFile(root, CACHE_NAME + ending), target = source2 + suffix;
35903
- if (!fs61.existsSync(source2)) continue;
35904
- fs61.renameSync(source2, target);
36026
+ if (!fs62.existsSync(source2)) continue;
36027
+ fs62.renameSync(source2, target);
35905
36028
  moved.push([source2, target]);
35906
36029
  }
35907
36030
  } catch (error) {
35908
- for (const [source2, target] of moved.reverse()) if (!fs61.existsSync(source2)) fs61.renameSync(target, source2);
36031
+ for (const [source2, target] of moved.reverse()) if (!fs62.existsSync(source2)) fs62.renameSync(target, source2);
35909
36032
  throw error;
35910
36033
  }
35911
36034
  }
@@ -35926,7 +36049,7 @@ function readGraphCache(root, bookId2) {
35926
36049
  let db;
35927
36050
  try {
35928
36051
  const file = graphFile(root, CACHE_NAME);
35929
- if (!fs61.existsSync(file)) return { status: "missing", extractions: [] };
36052
+ if (!fs62.existsSync(file)) return { status: "missing", extractions: [] };
35930
36053
  const header2 = cacheHeader(file);
35931
36054
  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
36055
  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 +36071,7 @@ function readGraphCache(root, bookId2) {
35948
36071
  }
35949
36072
  }
35950
36073
  function saveGraphCache(root, graph, extraction) {
35951
- const filename = graphFile(root, CACHE_NAME), exists3 = fs61.existsSync(filename);
36074
+ const filename = graphFile(root, CACHE_NAME), exists3 = fs62.existsSync(filename);
35952
36075
  if (exists3) {
35953
36076
  const header2 = cacheHeader(filename);
35954
36077
  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 +36120,9 @@ function routeForDocument(ref2) {
35997
36120
  return "\u6821\u51C6\u4F5C\u54C1\u73B0\u72B6\uFF0C\u518D\u6309\u4FEE\u6539\u5185\u5BB9\u9009\u62E9\u5BF9\u5E94\u8282\u70B9";
35998
36121
  }
35999
36122
  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);
36123
+ if (!fs63.existsSync(target) || !fs63.statSync(target).isFile()) throw new AuthorDocumentError("not-found", "\u6587\u4EF6\u4E0D\u5B58\u5728");
36124
+ 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");
36125
+ const bytes = fs63.readFileSync(target);
36003
36126
  if (bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u8BE5\u6587\u4EF6\u4E0D\u662F\u6587\u672C\u6587\u4EF6");
36004
36127
  try {
36005
36128
  return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -36019,7 +36142,7 @@ var ORPHAN_SIGNALS = ["\u4E66\u7C4D\u4FE1\u606F.json", "\u6545\u4E8B\u5927\u7EB2
36019
36142
  function orphanSignals(dir) {
36020
36143
  let entries;
36021
36144
  try {
36022
- entries = fs62.readdirSync(dir);
36145
+ entries = fs63.readdirSync(dir);
36023
36146
  } catch {
36024
36147
  return void 0;
36025
36148
  }
@@ -36031,18 +36154,18 @@ function scanOrphanDrafts(workspace, bookNames) {
36031
36154
  const scanLevel = (parent, prefix, skip) => {
36032
36155
  let entries;
36033
36156
  try {
36034
- entries = fs62.readdirSync(parent, { withFileTypes: true });
36157
+ entries = fs63.readdirSync(parent, { withFileTypes: true });
36035
36158
  } catch {
36036
36159
  return;
36037
36160
  }
36038
36161
  for (const entry of entries) {
36039
36162
  if (!entry.isDirectory() || skip.has(entry.name)) continue;
36040
- const signals = orphanSignals(path73.join(parent, entry.name));
36163
+ const signals = orphanSignals(path74.join(parent, entry.name));
36041
36164
  if (signals !== void 0) orphans.push({ name: entry.name, path: prefix + entry.name, detail: `\u542B ${signals.join("\u3001")}` });
36042
36165
  }
36043
36166
  };
36044
36167
  scanLevel(workspace, "", /* @__PURE__ */ new Set([...bookNames, "\u4E66\u623F"]));
36045
- scanLevel(path73.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
36168
+ scanLevel(path74.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
36046
36169
  return orphans;
36047
36170
  }
36048
36171
  var StudyService = class {
@@ -36050,19 +36173,19 @@ var StudyService = class {
36050
36173
  constructor(workspace) {
36051
36174
  if (!isFullyQualifiedPath(workspace)) throw new AuthorDocumentError("invalid-path", "\u5DE5\u4F5C\u8303\u56F4\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
36052
36175
  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");
36176
+ 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
36177
  }
36055
36178
  source(space) {
36056
36179
  if (space === "shared") {
36057
36180
  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");
36181
+ if (!fs63.existsSync(root2)) throw new AuthorDocumentError("not-found", "\u5F53\u524D\u5DE5\u4F5C\u8303\u56F4\u5C1A\u65E0\u5171\u4EAB\u8D44\u6599");
36182
+ 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
36183
  return { root: root2, owner: "\u5171\u4EAB\u8D44\u6599" };
36061
36184
  }
36062
36185
  const books = scanWorkspaceBooks(this.workspace).filter((book2) => book2.bookId && "book:" + book2.bookId === space);
36063
36186
  if (books.length !== 1) throw new AuthorDocumentError("not-found", "\u4E66\u76EE\u4E0D\u5B58\u5728\u6216\u4E66id\u4E0D\u552F\u4E00");
36064
36187
  const book = books[0];
36065
- const root = authorDocumentPath(this.workspace, path73.relative(this.workspace, book.root));
36188
+ const root = authorDocumentPath(this.workspace, path74.relative(this.workspace, book.root));
36066
36189
  return { root, owner: book.name, bookId: book.bookId };
36067
36190
  }
36068
36191
  shelf() {
@@ -36077,7 +36200,7 @@ var StudyService = class {
36077
36200
  let shared = false;
36078
36201
  let sharedError;
36079
36202
  try {
36080
- shared = fs62.statSync(this.source("shared").root).isDirectory();
36203
+ shared = fs63.statSync(this.source("shared").root).isDirectory();
36081
36204
  } catch (error) {
36082
36205
  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
36206
  }
@@ -36118,12 +36241,12 @@ var StudyService = class {
36118
36241
  // once for tree badges and a second time for the evidence itself.
36119
36242
  list: (relative12) => {
36120
36243
  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) => ({
36244
+ if (!fs63.existsSync(directory)) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36245
+ return fs63.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => ({
36123
36246
  name: entry.name,
36124
36247
  directory: entry.isDirectory(),
36125
36248
  draft: false,
36126
- ref: { space, path: path73.posix.join(relative12, entry.name) },
36249
+ ref: { space, path: path74.posix.join(relative12, entry.name) },
36127
36250
  ...entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
36128
36251
  }));
36129
36252
  },
@@ -36193,13 +36316,13 @@ var StudyService = class {
36193
36316
  }
36194
36317
  treeAt(source2, ref2) {
36195
36318
  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);
36319
+ if (!fs63.existsSync(directory) || !fs63.statSync(directory).isDirectory()) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
36320
+ return fs63.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => {
36321
+ const relative12 = path74.posix.join(ref2.path, entry.name);
36199
36322
  const item = { ref: { space: ref2.space, path: relative12 }, name: entry.name, directory: entry.isDirectory(), draft: ref2.space !== "shared" && relative12.startsWith("\u8349\u7A3F\u533A") };
36200
36323
  try {
36201
36324
  const target = authorDocumentPath(source2.root, relative12);
36202
- const info = fs62.statSync(target);
36325
+ const info = fs63.statSync(target);
36203
36326
  if (!info.isDirectory() && !info.isFile()) return { ...item, error: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B" };
36204
36327
  const badge = info.isFile() && entry.name.endsWith(".md") && info.size <= MAX_DOCUMENT_BYTES2 ? fieldLabel(textOf(target)).badge : void 0;
36205
36328
  return { ...item, absolutePath: target, directory: info.isDirectory(), ...badge ? { badge } : {} };
@@ -36217,7 +36340,7 @@ var StudyService = class {
36217
36340
  read(ref2) {
36218
36341
  const source2 = this.source(ref2.space);
36219
36342
  const absolutePath = authorDocumentPath(source2.root, ref2.path);
36220
- ref2 = { ...ref2, path: path73.relative(canonicalizePath(source2.root), absolutePath).split(path73.sep).join("/") };
36343
+ ref2 = { ...ref2, path: path74.relative(canonicalizePath(source2.root), absolutePath).split(path74.sep).join("/") };
36221
36344
  const text5 = textOf(absolutePath);
36222
36345
  const parsed = parseDocument(text5);
36223
36346
  const metadata2 = fieldLabel(text5);
@@ -36225,7 +36348,7 @@ var StudyService = class {
36225
36348
  return {
36226
36349
  ref: ref2,
36227
36350
  owner: source2.owner,
36228
- name: path73.basename(ref2.path),
36351
+ name: path74.basename(ref2.path),
36229
36352
  absolutePath,
36230
36353
  body: parsed.ok ? parsed.data.body : text5,
36231
36354
  hash: documentHash(text5),
@@ -36244,14 +36367,14 @@ var StudyService = class {
36244
36367
  return null;
36245
36368
  }
36246
36369
  }
36247
- absolutePath = path73.resolve(this.workspace, absolutePath);
36370
+ absolutePath = path74.resolve(this.workspace, absolutePath);
36248
36371
  }
36249
36372
  const spaces = this.shelf().books.filter((book) => !book.error).map((book) => book.id);
36250
36373
  spaces.push("shared");
36251
36374
  for (const space of spaces) {
36252
36375
  try {
36253
36376
  const source2 = this.source(space);
36254
- const relative12 = path73.relative(source2.root, absolutePath).split(path73.sep).join("/");
36377
+ const relative12 = path74.relative(source2.root, absolutePath).split(path74.sep).join("/");
36255
36378
  return this.read({ space, path: relative12 });
36256
36379
  } catch {
36257
36380
  }
@@ -36264,7 +36387,7 @@ var StudyService = class {
36264
36387
  const scanned = scanWorkspaceBooks(this.workspace);
36265
36388
  const spaces = scanned.filter((book) => book.bookId && scanned.filter((other) => other.bookId === book.bookId).length === 1).map((book) => "book:" + book.bookId);
36266
36389
  try {
36267
- if (fs62.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
36390
+ if (fs63.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
36268
36391
  } catch {
36269
36392
  }
36270
36393
  const term = query.trim().toLocaleLowerCase();
@@ -36331,7 +36454,7 @@ var StudyService = class {
36331
36454
  const status = deriveChapterFacts(facts);
36332
36455
  const pending = findPendingReviewDraft(source2.root, key);
36333
36456
  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)));
36457
+ const relative12 = candidates.find((candidate) => fs63.existsSync(path74.join(source2.root, candidate)));
36335
36458
  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
36459
  })
36337
36460
  };
@@ -37280,7 +37403,7 @@ function brandString(value) {
37280
37403
 
37281
37404
  // src/native-write.ts
37282
37405
  import { randomUUID as randomUUID9 } from "node:crypto";
37283
- import * as path74 from "node:path";
37406
+ import * as path75 from "node:path";
37284
37407
  import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
37285
37408
  function nativeToolRuntime(ctx) {
37286
37409
  const pipeline = new ToolExecutionPipeline(ctx);
@@ -37311,7 +37434,7 @@ function createNativeWriteBridge(runtime) {
37311
37434
  exec.signal.throwIfAborted();
37312
37435
  const target = resolveInsideBook(root, op.relPath);
37313
37436
  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);
37437
+ const file = path75.resolve(root, target.relPath);
37315
37438
  const callId = brandString(`webnovel-write-${randomUUID9()}`);
37316
37439
  pending.set(callId, { parent: exec.token, agent: exec.agent, file, content: op.content });
37317
37440
  try {
@@ -37335,10 +37458,10 @@ function createNativeWriteBridge(runtime) {
37335
37458
  }
37336
37459
 
37337
37460
  // src/indexing/manager.ts
37338
- import * as fs63 from "node:fs";
37461
+ import * as fs64 from "node:fs";
37339
37462
 
37340
37463
  // src/indexing/git.ts
37341
- import * as path75 from "node:path";
37464
+ import * as path76 from "node:path";
37342
37465
  import { execFile } from "node:child_process";
37343
37466
  async function git(root, args) {
37344
37467
  return new Promise((resolve22) => execFile("git", ["--literal-pathspecs", "-C", root, ...args], {
@@ -37364,8 +37487,8 @@ async function bookGitWatchPaths(root) {
37364
37487
  git(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"])
37365
37488
  ]);
37366
37489
  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")];
37490
+ const directory = path76.resolve(root, value.trim());
37491
+ return [directory, path76.join(directory, "refs")];
37369
37492
  }))];
37370
37493
  }
37371
37494
 
@@ -37772,7 +37895,7 @@ var BookIndexManager = class {
37772
37895
  for (const directory of await bookGitWatchPaths(record4.book.root)) {
37773
37896
  if (this.closing) return;
37774
37897
  try {
37775
- const watcher = fs63.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
37898
+ const watcher = fs64.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
37776
37899
  const name3 = filename?.toString().replaceAll("\\", "/");
37777
37900
  if (directory.endsWith("refs") || !name3 || /^(HEAD|packed-refs|refs)(\/|$)/.test(name3)) {
37778
37901
  this.scheduleProbe(record4);
@@ -38146,7 +38269,7 @@ function indexFailureMessage(book, notice) {
38146
38269
  }
38147
38270
 
38148
38271
  // src/reference/host.ts
38149
- import * as path76 from "node:path";
38272
+ import * as path77 from "node:path";
38150
38273
  import { BlockAssembler, createUserMessage as createUserMessage4 } from "@deepseek-ai/dsh-llm";
38151
38274
  var ReferenceHost = class {
38152
38275
  constructor(access) {
@@ -38164,26 +38287,26 @@ var ReferenceHost = class {
38164
38287
  async readFile(agent, workspace, filename, signal) {
38165
38288
  const active = AbortSignal.any([this.shutdown.signal, ...signal ? [signal] : []]);
38166
38289
  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);
38290
+ const fs68 = this.access.fs(agent);
38291
+ if (!fs68) throw new ReferenceError2("fs-unavailable", "DSH \u6587\u4EF6\u670D\u52A1\u4E0D\u53EF\u7528");
38292
+ if (!path77.isAbsolute(filename)) throw new ReferenceError2("source-path", "\u8BF7\u9009\u62E9\u539F\u6587\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");
38293
+ const mapped = fs68.processPathFromHostPath(filename), workspacePath = fs68.processPathFromHostPath(workspace);
38171
38294
  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);
38295
+ const info = await fs68.lstat(mapped, void 0, active);
38173
38296
  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);
38297
+ let ancestor = path77.dirname(mapped);
38298
+ while (path77.dirname(ancestor) !== ancestor) {
38299
+ 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");
38300
+ ancestor = path77.dirname(ancestor);
38301
+ }
38302
+ const target = await fs68.resolve(mapped, { signal: active });
38303
+ const library = await fs68.resolve(path77.join(workspacePath, "\u4E66\u623F/\u53C2\u8003\u4E66"), { signal: active });
38304
+ 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");
38305
+ const before = await fs68.stat(target, active);
38183
38306
  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);
38307
+ const bytes = await fs68.readBytes(target, active, REFERENCE_LIMITS.sourceBytes);
38308
+ const afterTarget = await fs68.resolve(mapped, { signal: active }), after = await fs68.stat(afterTarget, active);
38309
+ const afterPath = await fs68.lstat(mapped, void 0, active);
38187
38310
  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
38311
  active.throwIfAborted();
38189
38312
  return bytes;
@@ -38329,8 +38452,8 @@ function createIndexAutoPreference(settings, fallback) {
38329
38452
  }
38330
38453
 
38331
38454
  // src/scripts/deterministic-checks.ts
38332
- import * as fs64 from "node:fs";
38333
- import * as path77 from "node:path";
38455
+ import * as fs65 from "node:fs";
38456
+ import * as path78 from "node:path";
38334
38457
  function parseArgs(argv) {
38335
38458
  const values = /* @__PURE__ */ new Map();
38336
38459
  for (let i = 0; i < argv.length; i += 1) {
@@ -38360,8 +38483,8 @@ function runChecksCli(argv) {
38360
38483
  console.error(`\u524D\u7F6E\u53C2\u6570\u9519\u8BEF\uFF1A${err instanceof Error ? err.message : String(err)}`);
38361
38484
  return 1;
38362
38485
  }
38363
- if (!fs64.existsSync(args.book) || !fs64.statSync(args.book).isDirectory()) {
38364
- console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path77.resolve(args.book)}`);
38486
+ if (!fs65.existsSync(args.book) || !fs65.statSync(args.book).isDirectory()) {
38487
+ console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path78.resolve(args.book)}`);
38365
38488
  return 1;
38366
38489
  }
38367
38490
  try {
@@ -38395,8 +38518,8 @@ function runChecksCli(argv) {
38395
38518
  }
38396
38519
 
38397
38520
  // src/scripts/draft-length-cli.ts
38398
- import * as fs65 from "node:fs";
38399
- import * as path78 from "node:path";
38521
+ import * as fs66 from "node:fs";
38522
+ import * as path79 from "node:path";
38400
38523
  function unverified(reason, exitCode) {
38401
38524
  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
38525
  return exitCode;
@@ -38417,14 +38540,14 @@ function draftLengthCli(argv) {
38417
38540
  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
38541
  }
38419
38542
  try {
38420
- if (!fs65.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
38543
+ if (!fs66.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
38421
38544
  const resolved = resolveInsideBook(book, requested);
38422
38545
  if (!resolved.ok) return unverified(resolved.reason, 1);
38423
38546
  const target = draftLengthTarget(resolved.relPath);
38424
38547
  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");
38548
+ const file = path79.join(book, resolved.relPath);
38549
+ if (!fs66.statSync(file).isFile()) return unverified("\u7A3F\u4EF6\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6", 1);
38550
+ const text5 = fs66.readFileSync(file, "utf8");
38428
38551
  const result = draftLengthFeedback(target, text5, readChapterLength(book));
38429
38552
  console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", ...result }, null, 2));
38430
38553
  return result.\u7EDF\u8BA1\u72B6\u6001 === "\u5DF2\u7EDF\u8BA1" ? 0 : 1;
@@ -38643,8 +38766,8 @@ function exportCli(argv) {
38643
38766
  }
38644
38767
 
38645
38768
  // src/scripts/screenplay-export-cli.ts
38646
- import * as fs66 from "node:fs";
38647
- import * as path79 from "node:path";
38769
+ import * as fs67 from "node:fs";
38770
+ import * as path80 from "node:path";
38648
38771
  function argValue5(argv, name3) {
38649
38772
  const i = argv.indexOf(`--${name3}`);
38650
38773
  return i === -1 ? void 0 : argv[i + 1];
@@ -38705,12 +38828,12 @@ function screenplayExportCli(argv) {
38705
38828
  const \u5206\u955C\u5934raw = argValue5(argv, "\u5206\u955C\u5934")?.trim();
38706
38829
  let \u5206\u955C\u5934\u8868;
38707
38830
  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()) {
38831
+ const shotPath = path80.isAbsolute(\u5206\u955C\u5934raw) ? \u5206\u955C\u5934raw : path80.join(book, \u5206\u955C\u5934raw);
38832
+ if (!fs67.existsSync(shotPath) || !fs67.statSync(shotPath).isFile()) {
38710
38833
  console.error(`\u5206\u955C\u5934\u8868\u4E0D\u5B58\u5728\uFF1A${shotPath}`);
38711
38834
  return 1;
38712
38835
  }
38713
- const parsed = parseShotListTable(fs66.readFileSync(shotPath, "utf-8"));
38836
+ const parsed = parseShotListTable(fs67.readFileSync(shotPath, "utf-8"));
38714
38837
  if (!parsed.ok || parsed.shotList === void 0) {
38715
38838
  console.error(`\u5206\u955C\u5934\u8868\u89E3\u6790\u5931\u8D25\uFF1A${parsed.problems.join("\uFF1B")}`);
38716
38839
  return 1;
@@ -38720,13 +38843,13 @@ function screenplayExportCli(argv) {
38720
38843
  const \u603B\u7EB2raw = argValue5(argv, "\u603B\u7EB2")?.trim();
38721
38844
  let \u603B\u7EB2;
38722
38845
  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()) {
38846
+ const biblePath = path80.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path80.join(book, \u603B\u7EB2raw);
38847
+ if (!fs67.existsSync(biblePath) || !fs67.statSync(biblePath).isFile()) {
38725
38848
  console.error(`\u603B\u7EB2\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${biblePath}`);
38726
38849
  return 1;
38727
38850
  }
38728
38851
  try {
38729
- const parsedBible = JSON.parse(fs66.readFileSync(biblePath, "utf-8"));
38852
+ const parsedBible = JSON.parse(fs67.readFileSync(biblePath, "utf-8"));
38730
38853
  if (typeof parsedBible !== "object" || parsedBible === null || Array.isArray(parsedBible)) {
38731
38854
  console.error("\u603B\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A\u603B\u7EB2 JSON \u987B\u4E3A\u5BF9\u8C61\uFF08StoryBibleInput \u4E03\u8282\uFF09");
38732
38855
  return 1;