@yangda611/dsh-scriptor 8.4.7 → 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/README.md +11 -9
- package/lib/cli.js +111 -17
- package/lib/graph.js +1 -1
- package/lib/index.js +485 -305
- package/lib/reranking.js +2 -2
- package/lib/retrieval.js +5 -2
- package/lib/scenes.js +1 -1
- package/package.json +1 -1
- package/skills/novel-design/SKILL.md +2 -2
- package/skills/novel-director/SKILL.md +2 -2
- package/skills/novel-drafting/SKILL.md +11 -0
- package/skills/novel-export/SKILL.md +7 -7
- package/skills/novel-inspiration/SKILL.md +2 -2
- package/skills/novel-shortdrama/SKILL.md +2 -1
- package/skills/novel-shortdrama//345/267/245/345/272/217//345/215/225/351/233/206/345/211/247/346/234/254.md +2 -2
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,
|
|
117
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
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,
|
|
120
|
-
return visit_(key, ctrl, visitor,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
138
|
-
const ck = visit_("key", node.key, visitor,
|
|
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,
|
|
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,
|
|
165
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
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,
|
|
168
|
-
return visitAsync_(key, ctrl, visitor,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
186
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
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,
|
|
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,
|
|
218
|
+
function callVisitor(key, node, visitor, path81) {
|
|
219
219
|
if (typeof visitor === "function")
|
|
220
|
-
return visitor(key, node,
|
|
220
|
+
return visitor(key, node, path81);
|
|
221
221
|
if (identity4.isMap(node))
|
|
222
|
-
return visitor.Map?.(key, node,
|
|
222
|
+
return visitor.Map?.(key, node, path81);
|
|
223
223
|
if (identity4.isSeq(node))
|
|
224
|
-
return visitor.Seq?.(key, node,
|
|
224
|
+
return visitor.Seq?.(key, node, path81);
|
|
225
225
|
if (identity4.isPair(node))
|
|
226
|
-
return visitor.Pair?.(key, node,
|
|
226
|
+
return visitor.Pair?.(key, node, path81);
|
|
227
227
|
if (identity4.isScalar(node))
|
|
228
|
-
return visitor.Scalar?.(key, node,
|
|
228
|
+
return visitor.Scalar?.(key, node, path81);
|
|
229
229
|
if (identity4.isAlias(node))
|
|
230
|
-
return visitor.Alias?.(key, node,
|
|
230
|
+
return visitor.Alias?.(key, node, path81);
|
|
231
231
|
return void 0;
|
|
232
232
|
}
|
|
233
|
-
function replaceNode(key,
|
|
234
|
-
const parent =
|
|
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,
|
|
844
|
+
function collectionFromPath(schema, path81, value) {
|
|
845
845
|
let v = value;
|
|
846
|
-
for (let i =
|
|
847
|
-
const k =
|
|
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 = (
|
|
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(
|
|
897
|
-
if (isEmptyPath(
|
|
896
|
+
addIn(path81, value) {
|
|
897
|
+
if (isEmptyPath(path81))
|
|
898
898
|
this.add(value);
|
|
899
899
|
else {
|
|
900
|
-
const [key, ...rest] =
|
|
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(
|
|
915
|
-
const [key, ...rest] =
|
|
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(
|
|
930
|
-
const [key, ...rest] =
|
|
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(
|
|
949
|
-
const [key, ...rest] =
|
|
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(
|
|
960
|
-
const [key, ...rest] =
|
|
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(
|
|
3475
|
+
addIn(path81, value) {
|
|
3476
3476
|
if (assertCollection(this.contents))
|
|
3477
|
-
this.contents.addIn(
|
|
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(
|
|
3553
|
-
if (Collection.isEmptyPath(
|
|
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(
|
|
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(
|
|
3575
|
-
if (Collection.isEmptyPath(
|
|
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(
|
|
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(
|
|
3589
|
-
if (Collection.isEmptyPath(
|
|
3588
|
+
hasIn(path81) {
|
|
3589
|
+
if (Collection.isEmptyPath(path81))
|
|
3590
3590
|
return this.contents !== void 0;
|
|
3591
|
-
return identity4.isCollection(this.contents) ? this.contents.hasIn(
|
|
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(
|
|
3609
|
-
if (Collection.isEmptyPath(
|
|
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(
|
|
3612
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path81), value);
|
|
3613
3613
|
} else if (assertCollection(this.contents)) {
|
|
3614
|
-
this.contents.setIn(
|
|
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,
|
|
5574
|
+
visit.itemAtPath = (cst, path81) => {
|
|
5575
5575
|
let item = cst;
|
|
5576
|
-
for (const [field, index] of
|
|
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,
|
|
5586
|
-
const parent = visit.itemAtPath(cst,
|
|
5587
|
-
const field =
|
|
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(
|
|
5594
|
-
let ctrl = visitor(item,
|
|
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(
|
|
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,
|
|
5612
|
+
ctrl = ctrl(item, path81);
|
|
5613
5613
|
}
|
|
5614
5614
|
}
|
|
5615
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
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
|
|
6917
|
+
const fs68 = this.flowScalar(this.type);
|
|
6918
6918
|
if (atNextItem || it.value) {
|
|
6919
|
-
map.items.push({ start, key:
|
|
6919
|
+
map.items.push({ start, key: fs68, sep: [] });
|
|
6920
6920
|
this.onKeyLine = true;
|
|
6921
6921
|
} else if (it.sep) {
|
|
6922
|
-
this.stack.push(
|
|
6922
|
+
this.stack.push(fs68);
|
|
6923
6923
|
} else {
|
|
6924
|
-
Object.assign(it, { key:
|
|
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
|
|
7052
|
+
const fs68 = this.flowScalar(this.type);
|
|
7053
7053
|
if (!it || it.value)
|
|
7054
|
-
fc.items.push({ start: [], key:
|
|
7054
|
+
fc.items.push({ start: [], key: fs68, sep: [] });
|
|
7055
7055
|
else if (it.sep)
|
|
7056
|
-
this.stack.push(
|
|
7056
|
+
this.stack.push(fs68);
|
|
7057
7057
|
else
|
|
7058
|
-
Object.assign(it, { key:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
7878
|
+
function openPromise(path81, options2) {
|
|
7879
7879
|
return new Promise((resolve22, reject) => {
|
|
7880
|
-
open(
|
|
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(
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
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,
|
|
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:
|
|
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, [...
|
|
11116
|
-
if (schema.sKey) validateVolatileSchema(schema.sKey, [...
|
|
11117
|
-
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...
|
|
11118
|
-
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...
|
|
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;
|
|
@@ -12233,6 +12233,11 @@ function inside(root, rel) {
|
|
|
12233
12233
|
if (!isInsideCanonicalRoot(root, abs)) throw new Error(`\u4E8B\u52A1\u8DEF\u5F84\u9003\u9038\u4E66\u4ED3\uFF1A${rel}`);
|
|
12234
12234
|
return abs;
|
|
12235
12235
|
}
|
|
12236
|
+
function hasReservedTopLevel(relPath) {
|
|
12237
|
+
let first = relPath.split("/")[0]?.toLowerCase() ?? "";
|
|
12238
|
+
if (process.platform === "win32") first = first.replace(/[. ]+$/, "");
|
|
12239
|
+
return first === RUNTIME_DIR || first === ".git";
|
|
12240
|
+
}
|
|
12236
12241
|
function writeDurable(file, content, flag = "wx") {
|
|
12237
12242
|
const fd = fs6.openSync(file, flag, 438);
|
|
12238
12243
|
try {
|
|
@@ -12567,11 +12572,16 @@ function runLocked(root, ops, options2) {
|
|
|
12567
12572
|
const id = `${Date.now().toString(36)}-${process.pid}-${randomBytes(5).toString("hex")}`;
|
|
12568
12573
|
const normalized = ops.map((op) => ({ relPath: safeRel(op.relPath), content: op.content }));
|
|
12569
12574
|
for (const op of normalized) {
|
|
12570
|
-
|
|
12571
|
-
if (first === RUNTIME_DIR || first === ".git") throw new Error(`\u4E8B\u52A1\u76EE\u6807\u4E3A\u4FDD\u7559\u8DEF\u5F84\uFF1A${op.relPath}`);
|
|
12575
|
+
if (hasReservedTopLevel(op.relPath)) throw new Error(`\u4E8B\u52A1\u76EE\u6807\u4E3A\u4FDD\u7559\u8DEF\u5F84\uFF1A${op.relPath}`);
|
|
12572
12576
|
inside(root, op.relPath);
|
|
12573
12577
|
}
|
|
12574
|
-
|
|
12578
|
+
const targets = normalized.map((op) => {
|
|
12579
|
+
const target = canonicalizePath(inside(root, op.relPath));
|
|
12580
|
+
const relative12 = path6.relative(root, target).split(path6.sep).map((part) => process.platform === "win32" ? part.replace(/[. ]+$/, "").toLowerCase() : part).join("/");
|
|
12581
|
+
if (hasReservedTopLevel(relative12)) throw new Error(`\u4E8B\u52A1\u76EE\u6807\u4E3A\u4FDD\u7559\u8DEF\u5F84\uFF1A${op.relPath}`);
|
|
12582
|
+
return relative12;
|
|
12583
|
+
});
|
|
12584
|
+
if (new Set(targets).size !== normalized.length) {
|
|
12575
12585
|
throw new Error("\u4E8B\u52A1\u76EE\u6807\u8DEF\u5F84\u91CD\u590D");
|
|
12576
12586
|
}
|
|
12577
12587
|
const txRoot = path6.join(root, TRANSACTION_DIR, id);
|
|
@@ -21011,11 +21021,19 @@ function screenplayFinalPath() {
|
|
|
21011
21021
|
}
|
|
21012
21022
|
|
|
21013
21023
|
// ../core/src/shortdrama/types.ts
|
|
21024
|
+
var SHORTDRAMA_ORIENTATIONS = ["\u7AD6\u5C4F", "\u6A2A\u5C4F"];
|
|
21025
|
+
var HOOK_TYPES = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
|
|
21014
21026
|
var HOOK_ROTATION = ["\u8EAB\u4EFD", "\u60C5\u611F", "\u987F\u609F"];
|
|
21015
21027
|
function hookTypeForEpisode(\u96C6) {
|
|
21016
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`);
|
|
21017
21029
|
return HOOK_ROTATION[(\u96C6 - 1) % HOOK_ROTATION.length];
|
|
21018
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
|
+
}
|
|
21019
21037
|
|
|
21020
21038
|
// ../core/src/shortdrama/templates.ts
|
|
21021
21039
|
var SHORTDRAMA_SOURCES = {
|
|
@@ -21382,7 +21400,74 @@ function isBeatMark(mark) {
|
|
|
21382
21400
|
function fail3(message) {
|
|
21383
21401
|
throw new Error(`\u5355\u96C6\u5267\u672C\u6E32\u67D3\u5931\u8D25\uFF1A${message}`);
|
|
21384
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
|
+
}
|
|
21385
21469
|
function validate(input) {
|
|
21470
|
+
validateStructure(input);
|
|
21386
21471
|
const warnings = [];
|
|
21387
21472
|
const template = RHYTHM_TEMPLATES[input.\u753B\u5E45];
|
|
21388
21473
|
if (!Number.isSafeInteger(input.\u96C6) || input.\u96C6 < 1 || input.\u96C6 > 100) {
|
|
@@ -24008,10 +24093,10 @@ function computeScreenplayExport(bookRoot, options2) {
|
|
|
24008
24093
|
if (options2.\u5F62\u6001 !== "\u7535\u5F71\u5267\u672C" && options2.\u5F62\u6001 !== "\u77ED\u5267") return fail4(["\u5BFC\u51FA\u5F62\u6001\u5FC5\u987B\u662F \u7535\u5F71\u5267\u672C \u6216 \u77ED\u5267"]);
|
|
24009
24094
|
const \u683C\u5F0F = options2.\u683C\u5F0F ?? "storyboard";
|
|
24010
24095
|
if (\u683C\u5F0F !== "storyboard" && \u683C\u5F0F !== "master-scene" && \u683C\u5F0F !== "fountain" && \u683C\u5F0F !== "both") {
|
|
24011
|
-
return fail4(["\u5BFC\u51FA\u683C\u5F0F\u5FC5\u987B\u662F storyboard\u3001master-scene\u3001fountain \u6216 both\
|
|
24096
|
+
return fail4(["\u5BFC\u51FA\u683C\u5F0F\u5FC5\u987B\u662F storyboard\u3001master-scene\u3001fountain \u6216 both\u3002\u65E7\u503C markdown \u5DF2\u5E9F\u5F03\u3002\u7535\u5F71\u9ED8\u8BA4 storyboard\uFF0C\u6B21\u8981\u5BFC\u51FA\u7528 master-scene\u3002"]);
|
|
24012
24097
|
}
|
|
24013
24098
|
if (options2.\u5F62\u6001 === "\u77ED\u5267" && \u683C\u5F0F === "master-scene") {
|
|
24014
|
-
return fail4(["\u77ED\u5267\u6CA1\u6709 master-scene \u5F62\u6001\
|
|
24099
|
+
return fail4(["\u77ED\u5267\u6CA1\u6709 master-scene \u5F62\u6001\uFF0C\u77ED\u5267\u5267\u672C\u672C\u8EAB\u5C31\u662F\u5206\u955C\u5267\u672C\u3002\u8BF7\u7528 storyboard\uFF08\u9ED8\u8BA4\uFF09\u3001fountain \u6216 both\u3002"]);
|
|
24015
24100
|
}
|
|
24016
24101
|
if (options2.\u5F62\u6001 === "\u77ED\u5267" && (options2.\u96C6 === void 0 || !Number.isSafeInteger(options2.\u96C6) || options2.\u96C6 < 1 || options2.\u96C6 > 100)) {
|
|
24017
24102
|
return fail4(["\u77ED\u5267\u5BFC\u51FA\u5FC5\u987B\u4F20 --\u96C6 1\u2013100 \u7684\u96C6\u53F7"]);
|
|
@@ -24034,9 +24119,9 @@ function computeScreenplayExport(bookRoot, options2) {
|
|
|
24034
24119
|
const \u5B9A\u7A3F\u76F8\u5BF9\u8DEF\u5F84 = options2.\u5F62\u6001 === "\u7535\u5F71\u5267\u672C" ? paths.\u7535\u5F71\u5267\u672C() : paths.\u77ED\u5267\u96C6(options2.\u96C6);
|
|
24035
24120
|
let source2;
|
|
24036
24121
|
try {
|
|
24037
|
-
source2 =
|
|
24038
|
-
} catch {
|
|
24039
|
-
return fail4([`\u5267\u672C\u5B9A\u7A3F\
|
|
24122
|
+
source2 = readMaterialFile(root, \u5B9A\u7A3F\u76F8\u5BF9\u8DEF\u5F84).text;
|
|
24123
|
+
} catch (error) {
|
|
24124
|
+
return fail4([`\u5267\u672C\u5B9A\u7A3F\u8BFB\u53D6\u5931\u8D25\uFF1A${\u5B9A\u7A3F\u76F8\u5BF9\u8DEF\u5F84}\uFF08${error instanceof Error ? error.message : String(error)}\uFF09\u3002\u8BF7\u5148\u628A\u5267\u672C\u5B9A\u7A3F\u5230 \u5267\u672C/ \u76EE\u5F55\u3002\u76EE\u5F55\u7EA6\u5B9A\u89C1 docs/book-format.md\u300C\u5267\u672C\u5B9A\u7A3F\u76EE\u5F55\u300D\u3002`]);
|
|
24040
24125
|
}
|
|
24041
24126
|
const stem = safeFileStem(\u4E66\u540D);
|
|
24042
24127
|
if (options2.\u603B\u7EB2 !== void 0) \u603B\u7EB2\u6587\u4EF6 = `${stem}-\u603B\u7EB2.md`;
|
|
@@ -24102,6 +24187,7 @@ function computeScreenplayExport(bookRoot, options2) {
|
|
|
24102
24187
|
const parsed = parseEpisodeScript(source2);
|
|
24103
24188
|
if (!parsed.ok || parsed.episode === void 0) return fail4(parsed.problems);
|
|
24104
24189
|
const episode = parsed.episode;
|
|
24190
|
+
if (episode.\u96C6 !== options2.\u96C6) return fail4(["\u96C6\u53F7\u4E0D\u4E00\u81F4\uFF1A\u5B9A\u7A3F\u6587\u4EF6\u540D\u548C\u5267\u672C\u6B63\u6587\u5FC5\u987B\u5C5E\u4E8E\u540C\u4E00\u96C6"]);
|
|
24105
24191
|
let rendered;
|
|
24106
24192
|
try {
|
|
24107
24193
|
rendered = renderEpisodeScript(episode);
|
|
@@ -24594,12 +24680,14 @@ function ingestAuthorRevisionLocked(bookRoot, key, body) {
|
|
|
24594
24680
|
const baseVer = parent === null ? initialVersion("\u4F5C\u8005\u624B\u6539") : bumpVersion(parent, "\u4F5C\u8005\u624B\u6539");
|
|
24595
24681
|
const ver = { ...baseVer, \u751F\u6210\u6A21\u5757: "\u4F5C\u8005\u624B\u6539" };
|
|
24596
24682
|
const relPath = path46.posix.join(paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D), nextDraftFileName(bookRoot, key));
|
|
24597
|
-
demoteOtherPendingDrafts(bookRoot, key, relPath);
|
|
24598
24683
|
const fields = applyVersionFields(
|
|
24599
24684
|
{ ...doc.data.fields, \u89D2\u8272: "\u5F85\u5BA1\u7A3F", \u9009\u5B9A: true },
|
|
24600
24685
|
ver
|
|
24601
24686
|
);
|
|
24602
|
-
|
|
24687
|
+
writeBatchAtomic(bookRoot, [
|
|
24688
|
+
...prepareDraftDemotions(bookRoot, key, relPath),
|
|
24689
|
+
{ relPath, content: serializeDocument(fields, body, \u8349\u7A3F\u5B57\u6BB5\u5E8F) }
|
|
24690
|
+
]);
|
|
24603
24691
|
const record4 = loadReviewRecord(bookRoot, key);
|
|
24604
24692
|
const followup = followupReport(bookRoot, key, body, record4);
|
|
24605
24693
|
const diff = lineDiff(parentBody, body);
|
|
@@ -24803,12 +24891,8 @@ function readText10(root, rel) {
|
|
|
24803
24891
|
return null;
|
|
24804
24892
|
}
|
|
24805
24893
|
}
|
|
24806
|
-
function bodyOnly2(text5) {
|
|
24807
|
-
const r2 = parseDocument(text5);
|
|
24808
|
-
return (r2.ok ? r2.data.body : text5).trim();
|
|
24809
|
-
}
|
|
24810
24894
|
function stripSummaryHeading2(text5) {
|
|
24811
|
-
return
|
|
24895
|
+
return text5.trim().replace(/^#\s*章摘要\s*\n+/, "").trim();
|
|
24812
24896
|
}
|
|
24813
24897
|
function extractSection2(body, title) {
|
|
24814
24898
|
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
@@ -24848,7 +24932,9 @@ function computeVolumeSummaryCandidate(bookRoot, \u5377) {
|
|
|
24848
24932
|
\u7F3A\u7AE0\u6458\u8981.push(c.\u7AE0);
|
|
24849
24933
|
continue;
|
|
24850
24934
|
}
|
|
24851
|
-
const
|
|
24935
|
+
const parsed = parseDocument(text5);
|
|
24936
|
+
if (!parsed.ok) return { ok: false, reason: `\u7AE0\u6458\u8981\u89E3\u6790\u5931\u8D25\uFF1A${rel}\uFF1B${parsed.detail}\uFF0C\u4E0D\u4EA7\u5019\u9009\u4E0D\u843D\u76D8`, \u7F3A\u7AE0\u6458\u8981: [] };
|
|
24937
|
+
const content = stripSummaryHeading2(parsed.data.body);
|
|
24852
24938
|
if (content === "" || content === "\uFF08\u65E0\u6458\u8981\u6C89\u6DC0\uFF09") {
|
|
24853
24939
|
\u7F3A\u7AE0\u6458\u8981.push(c.\u7AE0);
|
|
24854
24940
|
continue;
|
|
@@ -24883,7 +24969,9 @@ ${content}`);
|
|
|
24883
24969
|
}
|
|
24884
24970
|
const \u7EBF\u7D22\u6BB5 = \u7EBF\u7D22\u6BB5Parts.join("\n");
|
|
24885
24971
|
const \u5377\u7EB2\u6587 = readText10(bookRoot, paths.\u5377\u7EB2(\u5377));
|
|
24886
|
-
const \u5377\
|
|
24972
|
+
const \u5377\u7EB2 = \u5377\u7EB2\u6587 === null ? null : parseDocument(\u5377\u7EB2\u6587);
|
|
24973
|
+
if (\u5377\u7EB2 !== null && !\u5377\u7EB2.ok) return { ok: false, reason: `\u5377\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A${paths.\u5377\u7EB2(\u5377)}\uFF1B${\u5377\u7EB2.detail}\uFF0C\u4E0D\u4EA7\u5019\u9009\u4E0D\u843D\u76D8`, \u7F3A\u7AE0\u6458\u8981: [] };
|
|
24974
|
+
const \u5377\u672B\u5151\u73B0 = \u5377\u7EB2 === null ? null : extractSection2(\u5377\u7EB2.data.body, "\u5377\u672B\u5151\u73B0");
|
|
24887
24975
|
const \u5019\u9009 = [
|
|
24888
24976
|
"# \u5377\u6458\u8981",
|
|
24889
24977
|
"",
|
|
@@ -29183,6 +29271,23 @@ var savePolicy = `\u3010\u8349\u7A3F\u4FDD\u5B58\u3011
|
|
|
29183
29271
|
\u5B8C\u6574\u7A3F\u6B63\u6587\u6709\u4FEE\u6539\u65F6\u53E6\u5B58\u7A3F<N+1>.md\uFF0C\u7236\u7248\u672C\u6307\u5411\u6E90\u7A3F\uFF0C\u65E7\u5B8C\u6574\u7A3F\u6B63\u6587\u4E0D\u8986\u76D6\u3002
|
|
29184
29272
|
\u4EC5\u4E3A\u6B63\u786E\u4EA4\u4ED8\u800C\u8C03\u6574\u89D2\u8272\u3001\u9009\u5B9A\u6807\u8BB0\u65F6\uFF0C\u4FDD\u7559\u6B63\u6587\u53CA\u5176\u4F59\u5143\u6570\u636E\uFF0C\u4E0D\u4F2A\u9020\u65B0\u7248\u672C\u3002
|
|
29185
29273
|
\u62A5\u544A\u51C6\u786E\u4EA4\u4ED8\u8DEF\u5F84\u3001\u65B0\u5199\u6216\u590D\u7528\u3001\u7EDF\u8BA1\u6765\u6E90\u53CA\u672A\u51B3\u9879\u3002\u7BC7\u5E45\u8FBE\u6807\u4E0D\u4EE3\u8868\u5BA1\u8BFB\u901A\u8FC7\u3002`;
|
|
29274
|
+
var longWriteRecovery = `\u3010\u957F\u6587\u672C\u5199\u5165\u6062\u590D\u3011
|
|
29275
|
+
\u65B0\u6587\u4EF6\u8D85\u8FC7 400 \u5B57\u7B26\u65F6\uFF0C\u9996\u6B21\u4FDD\u5B58\u5C31\u5206\u6BB5\u3002
|
|
29276
|
+
\u5148 read \u76EE\u6807\uFF0C\u786E\u8BA4\u4E0D\u5B58\u5728\uFF1B\u5176\u4ED6\u8BFB\u53D6\u9519\u8BEF\u5373\u505C\u3002
|
|
29277
|
+
\u5148 write \u6B63\u786E\u5934\u90E8\u548C\u672C\u4EFB\u52A1\u521B\u5EFA\u7684\u552F\u4E00\u968F\u673A ASCII \u5C3E\u6807\u8BB0\u3002
|
|
29278
|
+
\u9996\u6B21 write \u7684\u5185\u5BB9\u4E5F\u9650 400 \u5B57\u7B26\u3002
|
|
29279
|
+
\u6BCF\u6B21 edit \u53EA\u66FF\u6362\u5C3E\u6807\u8BB0\uFF0Cnew_string \u542B\u6807\u8BB0\u9650 400 \u5B57\u7B26\u3002
|
|
29280
|
+
\u6BCF\u6BB5\u6210\u529F\u540E\u624D\u63D0\u4EA4\u4E0B\u4E00\u6BB5\uFF0C\u4E0D\u5E76\u884C\u6539\u540C\u4E00\u6587\u4EF6\u3002
|
|
29281
|
+
\u672B\u6BB5\u4E5F\u9650 400 \u5B57\u7B26\uFF0C\u66FF\u6362\u65F6\u79FB\u9664\u6807\u8BB0\u3002
|
|
29282
|
+
read \u6587\u4EF6\u672B\u5C3E\uFF0C\u786E\u8BA4\u6807\u8BB0\u5DF2\u79FB\u9664\u3001\u4EA4\u4ED8\u5B8C\u6574\u3002
|
|
29283
|
+
\u9519\u8BEF\u4FE1\u606F\uFF1AUnterminated string in JSON\u3002
|
|
29284
|
+
\u9519\u8BEF\u4FE1\u606F\uFF1AMalformed response\u3002
|
|
29285
|
+
\u51FA\u73B0\u4EFB\u4E00\u9519\u8BEF\uFF0C\u5148 read \u76EE\u6807\u3002
|
|
29286
|
+
\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u76F8\u540C\u7684\u957F\u53C2\u6570\u3002
|
|
29287
|
+
edit \u5931\u8D25\u540E\u5148 read\uFF0C\u53EA\u5728\u5DF2\u5199\u672B\u5C3E\u4E0E\u672C\u4EFB\u52A1\u6807\u8BB0\u660E\u786E\u65F6\u7EED\u5199\u3002
|
|
29288
|
+
\u76EE\u6807\u5DF2\u6709\u5185\u5BB9\u4E14\u65E0\u672C\u4EFB\u52A1\u6807\u8BB0\u65F6\uFF0C\u505C\u6B62\u5E76\u62A5\u544A\u4E3B\u63A7\u3002
|
|
29289
|
+
\u65E0\u6CD5\u786E\u8BA4\u7EED\u5199\u8FB9\u754C\u65F6\uFF0C\u505C\u6B62\uFF1B\u4E0D\u5F97\u8986\u76D6\u6216\u731C\u8865\u3002
|
|
29290
|
+
\u6B64\u65B9\u6CD5\u4EC5\u6784\u5EFA\u65B0\u6587\u672C\uFF0C\u4E0D\u6539\u5DF2\u6709\u6B63\u6587\u3002`;
|
|
29186
29291
|
var rolePolicies = {
|
|
29187
29292
|
drafting: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6B63\u6587\u8D77\u8349\u3011
|
|
29188
29293
|
\u7B2C\u4E00\u4EFD\u5B8C\u6574\u7A3F\u4EE5\u5DF2\u786E\u8BA4\u7684\u5951\u7EA6\u7BC7\u5E45\u533A\u95F4\u4E3A\u76EE\u6807\u3002\u672A\u914D\u7F6E\u3001\u672A\u786E\u8BA4\u6216\u914D\u7F6E\u9519\u8BEF\u65F6\u5982\u5B9E\u8BF4\u660E\uFF0C\u4E0D\u7F16\u9020\u8303\u56F4\u3002
|
|
@@ -29204,16 +29309,25 @@ var rolePolicies = {
|
|
|
29204
29309
|
settle: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u6C89\u6DC0\u5BF9\u8D26\u3011
|
|
29205
29310
|
\u6C89\u6DC0\u5BF9\u8D26\u53EA\u8BFB\u4E0D\u5199\uFF0C\u6309\u4EFB\u52A1\u5E95\u672C\u8FD4\u56DE\u5019\u9009\uFF1B\u8BA1\u5212\u3001\u63A8\u6D4B\u548C\u4EBA\u7269\u8BC1\u8A00\u4E0D\u5192\u5145\u5DF2\u53D1\u751F\u4E8B\u5B9E\uFF0C\u4E0D\u76F4\u63A5\u4FEE\u6539\u8D26\u672C\u3002`,
|
|
29206
29311
|
screenplay: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u7535\u5F71\u5267\u672C\u6539\u7F16\u3011
|
|
29207
|
-
\u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u7535\u5F71\u5267\u672C\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002
|
|
29208
|
-
\
|
|
29312
|
+
\u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u7535\u5F71\u5267\u672C\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002
|
|
29313
|
+
\u5267\u672C\u6309\u6545\u4E8B\u7A3F\u3001\u5206\u573A\u5927\u7EB2\u3001\u5267\u672C\u8349\u7A3F\u3001\u5BA1\u8BFB\u56DB\u6B65\u63A8\u8FDB\u3002
|
|
29314
|
+
\u4E2D\u95F4\u7A3F\u653E\u8349\u7A3F\u533A/\u5267\u672C/\uFF0C\u6587\u4EF6\u540D\u4F9D\u6B21\u4E3A\u6545\u4E8B\u7A3F.md\u3001\u5206\u573A\u5927\u7EB2.md\u3001\u5267\u672C\u8349\u7A3F.md\u3002
|
|
29315
|
+
\u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u7535\u5F71/\u5267\u672C.md\u3002
|
|
29316
|
+
\u573A\u666F\u6807\u9898\u5199\u4E3A\u201C\u573A\u53F7 INT./EXT. \u5730\u70B9 - \u65F6\u95F4\u201D\u3002
|
|
29317
|
+
\u52A8\u4F5C\u884C\u7528\u73B0\u5728\u65F6\uFF0C\u53EA\u5199\u53EF\u89C1\u6216\u53EF\u542C\u5185\u5BB9\u3002
|
|
29318
|
+
\u89D2\u8272\u540D\u5168\u5927\u5199\uFF0C\u540E\u63A5\u53F0\u8BCD\u548C\u62EC\u53F7\u63D0\u793A\uFF1B\u505C\u987F\u53EA\u7528 (pause)\uFF0C\u4E0D\u7528 (beat)\u3002
|
|
29319
|
+
\u97F3\u6548\u5199\u8FDB\u52A8\u4F5C\u884C\uFF0C\u4E0D\u7528 SFX:/MUSIC: \u72EC\u5360\u884C\uFF1B\u97F3\u4E50\u4E0E\u955C\u5934\u63D0\u793A\u4E0D\u8FDB\u7F16\u5267\u5C42\u3002
|
|
29209
29320
|
\u5BA1\u8BFB\u4E09\u6A21\u5757\u8DD1\u5B8C\u518D\u5B9A\u7A3F\uFF0C\u4EFB\u4E00\u9AD8\u7EA7\u522B\u53D1\u73B0\u9879\u5373\u963B\u65AD\uFF0C\u4E0D\u628A\u5F85\u5199\u5360\u4F4D\u5F53\u6210\u7A3F\u3002`,
|
|
29210
29321
|
shortdrama: `\u3010\u5F53\u524D\u89D2\u8272\uFF1A\u77ED\u5267\u7BA1\u7EBF\u3011
|
|
29211
29322
|
\u53EA\u5728\u5951\u7EA6\u8F93\u51FA\u5F62\u6001=\u77ED\u5267\u65F6\u8D70\u672C\u7BA1\u7EBF\u3002\u6309\u5206\u96C6\u94A9\u5B50/\u723D\u70B9\u5927\u7EB2\u2192\u5355\u96C6\u5267\u672C\u2192\u5BA1\u8BFB\u8D70\uFF0C\u6BCF\u96C6\u4E00\u4E2A\u6838\u5FC3\u60F3\u6CD5\uFF1B\u5B9A\u7A3F\u53EA\u8BA4\u5267\u672C/\u77ED\u5267/\u96C6001.md \u8D77\u3002
|
|
29212
|
-
\u7AD6\u5C4F\u4E0E\u6A2A\u5C4F\
|
|
29323
|
+
\u7AD6\u5C4F\u4E0E\u6A2A\u5C4F\u8282\u594F\u5206\u5F00\uFF0C\u4E0D\u6DF7\u7528\u3002\u7AD6\u5C4F\u6BCF\u96C6 60\u2013120 \u79D2\uFF0C5 \u79D2\u5185\u8D77\u51B2\u7A81\u3002
|
|
29324
|
+
\u6BCF 20\u201330 \u79D2\u5B89\u6392\u53CD\u8F6C\uFF0C\u7ED3\u5C3E 5\u201310 \u79D2\u7559\u60AC\u5FF5\u3002
|
|
29325
|
+
\u6A2A\u5C4F\u6BCF\u96C6 10\u201320 \u5206\u949F\uFF0C\u5177\u5907\u8D77\u627F\u8F6C\u5408\u3002
|
|
29213
29326
|
\u6BCF\u96C6\u8DD1\u8282\u62CD\u68C0\u67E5\u5668\uFF0C\u4E0D\u901A\u8FC7\u7684\u96C6\u4E0D\u8FDB\u5B9A\u7A3F\u3002\u53F0\u8BCD\u8981\u77ED\uFF08\u4E00\u884C\u7EA6 <12 \u5B57\uFF09\uFF0C\u53F0\u8BCD\u5373\u884C\u52A8\u3002`
|
|
29214
29327
|
};
|
|
29215
29328
|
function workerPolicyFor(role2) {
|
|
29216
|
-
|
|
29329
|
+
const canWrite = role2 === "drafting" || role2 === "polish" || role2 === "screenplay" || role2 === "shortdrama";
|
|
29330
|
+
return [commonPolicy, canWrite ? longWriteRecovery : "", role2 === "drafting" || role2 === "polish" ? savePolicy : "", rolePolicies[role2]].filter(Boolean).join("\n\n");
|
|
29217
29331
|
}
|
|
29218
29332
|
function attachWorkerPolicyToAgent(agent, role2) {
|
|
29219
29333
|
const context = agent.ctx;
|
|
@@ -29564,7 +29678,7 @@ function attachStatusToAgent(agentCtx, deps) {
|
|
|
29564
29678
|
}
|
|
29565
29679
|
}
|
|
29566
29680
|
|
|
29567
|
-
// ../../node_modules/.pnpm/@deepseek-ai+dsh-system-
|
|
29681
|
+
// ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
|
|
29568
29682
|
import { Service } from "@deepseek-ai/cordis";
|
|
29569
29683
|
|
|
29570
29684
|
// ../../node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.2-rc.1_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-scope/lib/index.js
|
|
@@ -29784,7 +29898,7 @@ function scopeTarget(base, key) {
|
|
|
29784
29898
|
return carrier;
|
|
29785
29899
|
}
|
|
29786
29900
|
|
|
29787
|
-
// ../../node_modules/.pnpm/@deepseek-ai+dsh-system-
|
|
29901
|
+
// ../../node_modules/.pnpm/@deepseek-ai+dsh-system-pro_fa06e1bbf047b6f0c55c453e3a409cd3/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js
|
|
29788
29902
|
var SECTION_ORDERS = {
|
|
29789
29903
|
HARNESS_IDENTITY: -1e3,
|
|
29790
29904
|
DEPLOYMENT_PERSONA_PREFIX: 0,
|
|
@@ -30912,6 +31026,9 @@ function ingestFindingsLocked(bookRoot, key, \u6A21\u5757\u540D, rawFindings, ex
|
|
|
30912
31026
|
if (check === void 0) {
|
|
30913
31027
|
return { ok: false, reason: `\u672A\u6CE8\u518C\u7684\u5BA1\u8BFB\u6A21\u5757:${\u6A21\u5757\u540D}`, record: null };
|
|
30914
31028
|
}
|
|
31029
|
+
if (check.\u9002\u7528\u8303\u56F4 !== "\u7AE0") {
|
|
31030
|
+
return { ok: false, reason: `\u5BA1\u8BFB\u6A21\u5757 ${\u6A21\u5757\u540D} \u9002\u7528\u8303\u56F4\u662F ${check.\u9002\u7528\u8303\u56F4}\uFF0C\u4E0D\u80FD\u56DE\u5199\u8FDB\u7AE0\u7684\u5BA1\u6838\u8BB0\u5F55`, record: null };
|
|
31031
|
+
}
|
|
30915
31032
|
const authorOpinion = check.\u6267\u884C\u5F62\u6001 === "\u4F5C\u8005";
|
|
30916
31033
|
if (!authorOpinion && (typeof expectedFingerprint !== "string" || expectedFingerprint.trim() === "")) {
|
|
30917
31034
|
return { ok: false, reason: "\u81EA\u52A8\u5BA1\u8BFB\u7ED3\u679C\u5FC5\u987B\u643A\u5E26\u5BA1\u8BFB\u6307\u7EB9\uFF1A\u6BCF\u4E2A\u6A21\u5757\u56DE\u5199\u5747\u9700\u63D0\u4F9B\u5B9E\u9645\u5BA1\u8BFB\u8F93\u5165\u7684\u6307\u7EB9\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5BA1\u6838", record: null };
|
|
@@ -31042,6 +31159,9 @@ function computeScreenplayReview(bookRoot, input) {
|
|
|
31042
31159
|
}
|
|
31043
31160
|
function computeEpisodeReview(bookRoot, key, input) {
|
|
31044
31161
|
registerFilmDramaChecks();
|
|
31162
|
+
if (key.\u96C6 !== input.\u5267\u672C.\u96C6 || key.\u96C6 !== input.\u5927\u7EB2.\u96C6) {
|
|
31163
|
+
return { ok: false, reason: "\u96C6\u53F7\u4E0D\u4E00\u81F4\uFF1A\u5BA1\u6838\u8BB0\u5F55\u3001\u5355\u96C6\u5267\u672C\u548C\u5206\u96C6\u5927\u7EB2\u5FC5\u987B\u5C5E\u4E8E\u540C\u4E00\u96C6", record: null };
|
|
31164
|
+
}
|
|
31045
31165
|
const \u5267\u672C\u6587\u672C = renderEpisodeScript(input.\u5267\u672C).\u5185\u5BB9;
|
|
31046
31166
|
const computed = computeEpisodeFindings({ \u96C6: key.\u96C6, \u5267\u672C: input.\u5267\u672C, \u5267\u672C\u6587\u672C, \u5927\u7EB2: input.\u5927\u7EB2, \u6750\u6599\u7248\u672C: input.\u6750\u6599\u7248\u672C });
|
|
31047
31167
|
const existing = loadEpisodeReviewRecord(bookRoot, key.\u96C6) ?? emptyReviewRecord();
|
|
@@ -31062,6 +31182,9 @@ function runEpisodeReviewRecordLocked(bookRoot, key, input) {
|
|
|
31062
31182
|
}
|
|
31063
31183
|
var runEpisodeReviewRecord = bookWriter(runEpisodeReviewRecordLocked);
|
|
31064
31184
|
function ingestFilmDramaFindings(args) {
|
|
31185
|
+
return withBookWrite(args.bookRoot, () => ingestFilmDramaFindingsLocked(args));
|
|
31186
|
+
}
|
|
31187
|
+
function ingestFilmDramaFindingsLocked(args) {
|
|
31065
31188
|
registerFilmDramaChecks();
|
|
31066
31189
|
const { bookRoot, scope: scope2, \u6A21\u5757\u540D } = args;
|
|
31067
31190
|
const check = getCheck(\u6A21\u5757\u540D);
|
|
@@ -31103,6 +31226,14 @@ function ingestFilmDramaFindings(args) {
|
|
|
31103
31226
|
if (!authorOpinion && expectedFingerprint !== recomputed) {
|
|
31104
31227
|
return { ok: false, reason: "\u5BA1\u8BFB\u7ED3\u679C\u5DF2\u8FC7\u671F\uFF1A\u56DE\u5199\u6307\u7EB9\u4E0E\u5F53\u524D\u5BA1\u6838\u8F93\u5165\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5BA1\u6838", record: null };
|
|
31105
31228
|
}
|
|
31229
|
+
if (scope2 === "\u96C6") {
|
|
31230
|
+
const script = parseEpisodeScript(args.\u5267\u672C\u6587\u672C);
|
|
31231
|
+
const outlineEpisode = /^集(\d+)\s/.exec(args.\u5927\u7EB2\u6587\u672C)?.[1];
|
|
31232
|
+
if (!script.ok || script.episode === void 0) return { ok: false, reason: "\u5355\u96C6\u5267\u672C\u6587\u672C\u89E3\u6790\u5931\u8D25\uFF0C\u4E0D\u80FD\u56DE\u5199\u5BA1\u8BFB\u7ED3\u679C", record: null };
|
|
31233
|
+
if (script.episode.\u96C6 !== args.\u96C6 || outlineEpisode === void 0 || Number(outlineEpisode) !== args.\u96C6) {
|
|
31234
|
+
return { ok: false, reason: "\u96C6\u53F7\u4E0D\u4E00\u81F4\uFF1A\u5BA1\u6838\u8BB0\u5F55\u3001\u5355\u96C6\u5267\u672C\u548C\u5206\u96C6\u5927\u7EB2\u5FC5\u987B\u5C5E\u4E8E\u540C\u4E00\u96C6", record: null };
|
|
31235
|
+
}
|
|
31236
|
+
}
|
|
31106
31237
|
const record0 = existing ?? emptyReviewRecord();
|
|
31107
31238
|
const hasPriorReviewState = record0.\u5B8C\u6210 || record0.\u95EE\u9898.length > 0 || Object.keys(record0.\u6A21\u5757).length > 0;
|
|
31108
31239
|
const stale = record0.\u5BA1\u8BFB\u6307\u7EB9 !== void 0 && record0.\u5BA1\u8BFB\u6307\u7EB9 !== recomputed || record0.\u5BA1\u8BFB\u6307\u7EB9 === void 0 && hasPriorReviewState;
|
|
@@ -31400,6 +31531,10 @@ function createScreenplayTools(deps = {}) {
|
|
|
31400
31531
|
];
|
|
31401
31532
|
}
|
|
31402
31533
|
|
|
31534
|
+
// src/shortdrama-tools.ts
|
|
31535
|
+
import * as fs54 from "node:fs";
|
|
31536
|
+
import * as path66 from "node:path";
|
|
31537
|
+
|
|
31403
31538
|
// src/tool-failure.ts
|
|
31404
31539
|
var NEXT_STEP = {
|
|
31405
31540
|
"invalid-argument": "\u6309 reason \u4FEE\u6B63\u53C2\u6570\u540E\u91CD\u65B0\u8C03\u7528\u3002",
|
|
@@ -31551,7 +31686,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
|
|
|
31551
31686
|
},
|
|
31552
31687
|
{
|
|
31553
31688
|
name: "novel_shortdrama_render_episode",
|
|
31554
|
-
description: "\u77ED\u5267\u5355\u96C6\u5267\u672C\u6E32\u67D3\
|
|
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",
|
|
31555
31690
|
parameters: {
|
|
31556
31691
|
type: "object",
|
|
31557
31692
|
properties: {
|
|
@@ -31612,7 +31747,10 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
|
|
|
31612
31747
|
type: "object",
|
|
31613
31748
|
properties: {
|
|
31614
31749
|
ok: { type: "boolean" },
|
|
31615
|
-
path: { type: "string", description: "\
|
|
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" },
|
|
31616
31754
|
\u5185\u5BB9: { type: "string" },
|
|
31617
31755
|
\u8B66\u544A: { type: "array" },
|
|
31618
31756
|
reason: { type: "string" }
|
|
@@ -31624,7 +31762,7 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
|
|
|
31624
31762
|
execute: (args) => run(() => {
|
|
31625
31763
|
const input = asRecord2(args, "\u53C2\u6570");
|
|
31626
31764
|
const rendered = renderEpisodeScript(input);
|
|
31627
|
-
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" };
|
|
31628
31766
|
})
|
|
31629
31767
|
},
|
|
31630
31768
|
{
|
|
@@ -31767,10 +31905,47 @@ var SHORTDRAMA_TOOL_DEFINITIONS = [
|
|
|
31767
31905
|
})
|
|
31768
31906
|
}
|
|
31769
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
|
+
}
|
|
31770
31945
|
|
|
31771
31946
|
// src/approval-snapshot.ts
|
|
31772
|
-
import * as
|
|
31773
|
-
import * as
|
|
31947
|
+
import * as fs55 from "node:fs";
|
|
31948
|
+
import * as path67 from "node:path";
|
|
31774
31949
|
import { createHash as createHash19 } from "node:crypto";
|
|
31775
31950
|
function captureApprovalFiles(root, relatives, request) {
|
|
31776
31951
|
try {
|
|
@@ -31778,13 +31953,13 @@ function captureApprovalFiles(root, relatives, request) {
|
|
|
31778
31953
|
const visit = (relative12) => {
|
|
31779
31954
|
const target = authorDocumentPath(root, relative12);
|
|
31780
31955
|
try {
|
|
31781
|
-
const stat =
|
|
31956
|
+
const stat = fs55.statSync(target);
|
|
31782
31957
|
if (stat.isDirectory()) {
|
|
31783
|
-
const names =
|
|
31958
|
+
const names = fs55.readdirSync(target).sort();
|
|
31784
31959
|
files.push([relative12 + "/", JSON.stringify(names)]);
|
|
31785
|
-
for (const name3 of names) visit(
|
|
31960
|
+
for (const name3 of names) visit(path67.posix.join(relative12, name3));
|
|
31786
31961
|
} else if (stat.isFile()) {
|
|
31787
|
-
files.push([relative12, createHash19("sha256").update(
|
|
31962
|
+
files.push([relative12, createHash19("sha256").update(fs55.readFileSync(target)).digest("hex")]);
|
|
31788
31963
|
} else throw new Error(`\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55\uFF1A${relative12}`);
|
|
31789
31964
|
} catch (error) {
|
|
31790
31965
|
if (error.code === "ENOENT") {
|
|
@@ -31904,8 +32079,8 @@ var MAINTENANCE_OUTPUT = {
|
|
|
31904
32079
|
};
|
|
31905
32080
|
|
|
31906
32081
|
// src/book-upgrade-tools.ts
|
|
31907
|
-
import
|
|
31908
|
-
import
|
|
32082
|
+
import fs56 from "node:fs";
|
|
32083
|
+
import path68 from "node:path";
|
|
31909
32084
|
import { validateJsonSchemaValue as validateJsonSchemaValue2 } from "@deepseek-ai/dsh-tools";
|
|
31910
32085
|
|
|
31911
32086
|
// src/book-upgrade-output.ts
|
|
@@ -31985,8 +32160,8 @@ var BOOK_UPGRADE_WRITE_OUTPUT = {
|
|
|
31985
32160
|
var marker2 = { maintenance: "book-upgrade" };
|
|
31986
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") });
|
|
31987
32162
|
var identity2 = (root) => {
|
|
31988
|
-
const real =
|
|
31989
|
-
return process.platform === "win32" ?
|
|
32163
|
+
const real = fs56.realpathSync.native(root);
|
|
32164
|
+
return process.platform === "win32" ? path68.resolve(real).toLowerCase() : path68.resolve(real);
|
|
31990
32165
|
};
|
|
31991
32166
|
function provenance(exec) {
|
|
31992
32167
|
if (exec === void 0) return void 0;
|
|
@@ -32140,7 +32315,7 @@ function createBookUpgradeTools(deps) {
|
|
|
32140
32315
|
}
|
|
32141
32316
|
|
|
32142
32317
|
// src/novel-tools.ts
|
|
32143
|
-
import * as
|
|
32318
|
+
import * as fs60 from "node:fs";
|
|
32144
32319
|
import * as nodePath3 from "node:path";
|
|
32145
32320
|
|
|
32146
32321
|
// src/design-commit-result.ts
|
|
@@ -32606,14 +32781,14 @@ function onboardingMissing(answers) {
|
|
|
32606
32781
|
}
|
|
32607
32782
|
|
|
32608
32783
|
// src/study/onboarding-store.ts
|
|
32609
|
-
import * as
|
|
32610
|
-
import * as
|
|
32784
|
+
import * as fs57 from "node:fs";
|
|
32785
|
+
import * as path69 from "node:path";
|
|
32611
32786
|
function onboardingDraftPath(workspaceRoot) {
|
|
32612
|
-
return
|
|
32787
|
+
return path69.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
|
|
32613
32788
|
}
|
|
32614
32789
|
function readOnboardingDraft(workspaceRoot) {
|
|
32615
32790
|
try {
|
|
32616
|
-
const raw =
|
|
32791
|
+
const raw = fs57.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
|
|
32617
32792
|
return validateOnboardingAnswers(JSON.parse(raw));
|
|
32618
32793
|
} catch {
|
|
32619
32794
|
return {};
|
|
@@ -32621,27 +32796,27 @@ function readOnboardingDraft(workspaceRoot) {
|
|
|
32621
32796
|
}
|
|
32622
32797
|
function saveOnboardingDraft(workspaceRoot, answers) {
|
|
32623
32798
|
const target = onboardingDraftPath(workspaceRoot);
|
|
32624
|
-
|
|
32625
|
-
|
|
32799
|
+
fs57.mkdirSync(path69.dirname(target), { recursive: true });
|
|
32800
|
+
fs57.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
|
|
32626
32801
|
}
|
|
32627
32802
|
function consumeOnboardingDraft(workspaceRoot) {
|
|
32628
32803
|
try {
|
|
32629
|
-
|
|
32804
|
+
fs57.unlinkSync(onboardingDraftPath(workspaceRoot));
|
|
32630
32805
|
} catch {
|
|
32631
32806
|
}
|
|
32632
32807
|
}
|
|
32633
32808
|
|
|
32634
32809
|
// ../drafting/src/context.ts
|
|
32635
|
-
import * as fs57 from "node:fs";
|
|
32636
|
-
import * as path69 from "node:path";
|
|
32637
|
-
|
|
32638
|
-
// ../drafting/src/write.ts
|
|
32639
32810
|
import * as fs58 from "node:fs";
|
|
32640
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";
|
|
32641
32816
|
var DRAFT_KEYS = ["\u8EAB\u4EFD", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u6765\u6E90\u5FEB\u7167", "\u89D2\u8272", "\u9009\u5B9A"];
|
|
32642
32817
|
function readText12(root, rel) {
|
|
32643
32818
|
try {
|
|
32644
|
-
return
|
|
32819
|
+
return fs59.readFileSync(path71.join(root, rel), "utf-8");
|
|
32645
32820
|
} catch {
|
|
32646
32821
|
return null;
|
|
32647
32822
|
}
|
|
@@ -32650,9 +32825,9 @@ function draftDir(key) {
|
|
|
32650
32825
|
return paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D);
|
|
32651
32826
|
}
|
|
32652
32827
|
function listDraftFiles(bookRoot, key) {
|
|
32653
|
-
const abs =
|
|
32654
|
-
if (!
|
|
32655
|
-
return
|
|
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"));
|
|
32656
32831
|
}
|
|
32657
32832
|
function parseDraftNo(file) {
|
|
32658
32833
|
const m = /^稿(\d+)\.md$/.exec(file);
|
|
@@ -32661,7 +32836,7 @@ function parseDraftNo(file) {
|
|
|
32661
32836
|
function latestVersion(bookRoot, key) {
|
|
32662
32837
|
let max = null;
|
|
32663
32838
|
for (const file of listDraftFiles(bookRoot, key)) {
|
|
32664
|
-
const text5 = readText12(bookRoot,
|
|
32839
|
+
const text5 = readText12(bookRoot, path71.posix.join(draftDir(key), file));
|
|
32665
32840
|
if (text5 === null) continue;
|
|
32666
32841
|
const doc = parseDocument(text5);
|
|
32667
32842
|
if (!doc.ok) continue;
|
|
@@ -32688,7 +32863,7 @@ function selectDraftLocked(bookRoot, input) {
|
|
|
32688
32863
|
const files = listDraftFiles(bookRoot, input);
|
|
32689
32864
|
if (!files.includes(target)) return { ok: false, reason: `\u8349\u7A3F\u4E0D\u5B58\u5728:${target}` };
|
|
32690
32865
|
for (const file of files) {
|
|
32691
|
-
const rel =
|
|
32866
|
+
const rel = path71.posix.join(dir, file);
|
|
32692
32867
|
const text5 = readText12(bookRoot, rel);
|
|
32693
32868
|
if (text5 === null) continue;
|
|
32694
32869
|
const doc = parseDocument(text5);
|
|
@@ -32712,7 +32887,7 @@ function writeDraftLocked(bookRoot, input) {
|
|
|
32712
32887
|
const parent = latestVersion(bookRoot, key);
|
|
32713
32888
|
const ver = parent === null ? initialVersion("\u5199\u7A3F") : bumpVersion(parent, "\u5199\u7A3F");
|
|
32714
32889
|
const file = nextFileName(bookRoot, key);
|
|
32715
|
-
const relPath =
|
|
32890
|
+
const relPath = path71.posix.join(draftDir(key), file);
|
|
32716
32891
|
const fields = applyVersionFields(
|
|
32717
32892
|
{
|
|
32718
32893
|
\u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
|
|
@@ -32744,8 +32919,7 @@ function importAuthorDraftLocked(bookRoot, input) {
|
|
|
32744
32919
|
const explicitParent = input.\u7236\u7248\u672C ?? latestVersion(bookRoot, key);
|
|
32745
32920
|
const ver = explicitParent === null ? initialVersion("\u4F5C\u8005\u7A3F\u5BFC\u5165") : bumpVersion(explicitParent, "\u4F5C\u8005\u7A3F\u5BFC\u5165");
|
|
32746
32921
|
const file = nextFileName(bookRoot, key);
|
|
32747
|
-
const relPath =
|
|
32748
|
-
if (input.\u89D2\u8272 === "\u5F85\u5BA1\u7A3F") demoteOtherPendingDrafts(bookRoot, key, relPath);
|
|
32922
|
+
const relPath = path71.posix.join(draftDir(key), file);
|
|
32749
32923
|
const fields = applyVersionFields(
|
|
32750
32924
|
{
|
|
32751
32925
|
\u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
|
|
@@ -32754,7 +32928,9 @@ function importAuthorDraftLocked(bookRoot, input) {
|
|
|
32754
32928
|
},
|
|
32755
32929
|
{ ...ver, \u751F\u6210\u6A21\u5757: input.\u751F\u6210\u6A21\u5757 }
|
|
32756
32930
|
);
|
|
32757
|
-
|
|
32931
|
+
const ops = input.\u89D2\u8272 === "\u5F85\u5BA1\u7A3F" ? [...prepareDraftDemotions(bookRoot, key, relPath)] : [];
|
|
32932
|
+
ops.push({ relPath, content: serializeDocument(fields, composeBody(prose, facts), DRAFT_KEYS) });
|
|
32933
|
+
writeBatchAtomic(bookRoot, ops);
|
|
32758
32934
|
return { ok: true, relPath, \u64AD\u62A5 };
|
|
32759
32935
|
}
|
|
32760
32936
|
var importAuthorDraft = bookWriter(importAuthorDraftLocked);
|
|
@@ -32900,7 +33076,7 @@ function createNovelTools(deps) {
|
|
|
32900
33076
|
},
|
|
32901
33077
|
{
|
|
32902
33078
|
name: "novel_create_book",
|
|
32903
|
-
description: "\u65B0\u5EFA\u4E00\u90E8\u957F\u7BC7\u5C0F\u8BF4\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\u3001\u6838\u5FC3\u521B\u610F\u4E0E\u9898\u6750\u76EE\u6807\u8BFB\u8005\u660E\u786E\uFF0C\u5176\u4F59\u53EF\u7559\u767D\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u95EE\u4F5C\u8005\u4E09\u4E2A\u95EE\u9898\u518D\u8C03\uFF0C\u7F3A\u4EFB\u4F55\u4E00\u4E2A\u90FD\u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\
|
|
33079
|
+
description: "\u65B0\u5EFA\u4E00\u90E8\u957F\u7BC7\u5C0F\u8BF4\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\u3001\u6838\u5FC3\u521B\u610F\u4E0E\u9898\u6750\u76EE\u6807\u8BFB\u8005\u660E\u786E\uFF0C\u5176\u4F59\u53EF\u7559\u767D\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u95EE\u4F5C\u8005\u4E09\u4E2A\u95EE\u9898\u518D\u8C03\uFF0C\u7F3A\u4EFB\u4F55\u4E00\u4E2A\u90FD\u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\u3002\u5E02\u573A\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF1F\u8F93\u51FA\u5F62\u6001\uFF1A\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF1F\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF09\uFF1A\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF1F\u4E09\u4E2A\u503C\u7F3A\u4E00\u4E0D\u53EF\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u201C\u5C31\u6309\u9ED8\u8BA4\u6765\u201D\u624D\u4F20\u9ED8\u8BA4\uFF08\u4E2D\u6587 / \u5C0F\u8BF4 / 100\u4E07\u5B57\uFF09\uFF0C\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u6084\u6084\u5EFA\u4E66\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF0C\u9009\u597D\u540E\u4E0D\u7528\u5728\u804A\u5929\u91CC\u518D\u95EE\u3002\u5EFA\u4E66\u53EA\u80FD\u8C03\u672C\u5DE5\u5177\uFF0C\u7981\u6B62\u7528\u6587\u4EF6\u5DE5\u5177\u624B\u5199\u4E66\u7C4D\u4FE1\u606F\u3001\u5927\u7EB2\u6216\u7AE0\u8282\u6587\u4EF6\u6765\u5192\u5145\u5EFA\u4E66\u3002\u5982\u679C\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u672C\u5DE5\u5177\uFF0C\u660E\u786E\u544A\u8BC9\u4F5C\u8005\u6CA1\u6709\u5EFA\u4E66\u5DE5\u5177\uFF0C\u4E0D\u8981\u624B\u5199\u4E66\u7A3F\u6587\u4EF6\u3002",
|
|
32904
33080
|
parameters: {
|
|
32905
33081
|
type: "object",
|
|
32906
33082
|
properties: {
|
|
@@ -32958,7 +33134,7 @@ function createNovelTools(deps) {
|
|
|
32958
33134
|
return toolFailure(
|
|
32959
33135
|
"invalid-argument",
|
|
32960
33136
|
`\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u786E\u8BA4${missing.join("\u3001")}\uFF0C\u7F3A\u4E86\u4E0D\u80FD\u5EFA\u4E66\u3002`,
|
|
32961
|
-
`\u5148\u95EE\u4F5C\u8005\
|
|
33137
|
+
`\u5148\u95EE\u4F5C\u8005\uFF0C\u540C\u4E00\u6761\u6D88\u606F\u4E00\u6B21\u95EE\u5B8C\uFF0C\u5404\u7ED9\u9009\u9879\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF1B\u9009\u597D\u540E\u76F4\u63A5\u91CD\u8C03\u672C\u5DE5\u5177\u3002\u5E02\u573A\u2014\u2014\u201C\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF1F\u201D\uFF081. \u4E2D\u6587\u2605\u63A8\u8350 2. \u6D77\u5916 3. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\uFF09\uFF1B\u8F93\u51FA\u5F62\u6001\u2014\u2014\u201C\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF1F\u201D\uFF081. \u5C0F\u8BF4\u2605\u63A8\u8350 2. \u77ED\u5267 3. \u7535\u5F71\u5267\u672C 4. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\uFF09\uFF1B\u76EE\u6807\u603B\u5B57\u6570\u2014\u2014\u201C\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF1F\u201D\uFF081. \u77ED\u7BC7\xB75\u4E07\u5B57 2. \u4E2D\u7BC7\xB730\u4E07\u5B57 3. \u957F\u7BC7\xB7100\u4E07\u5B57\u2605\u63A8\u8350 4. \u8D85\u957F\u7BC7\xB7200\u4E07\u5B57\uFF09\uFF1B\u53E6\u53EF\u9009\uFF1A5. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\u5177\u4F53\u6570\u5B57\u3002\u62FF\u5230\u7B54\u6848\u518D\u8C03 novel_create_book\uFF0C\u628A\u503C\u4F20\u8FDB\u6765\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u201C\u5C31\u6309\u9ED8\u8BA4\u6765\u201D\u624D\u4F20\u9ED8\u8BA4\uFF08\u4E2D\u6587 / \u5C0F\u8BF4 / 100\u4E07\u5B57\uFF09\u3002\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u76F4\u63A5\u5EFA\u4E66\u3002`
|
|
32962
33138
|
);
|
|
32963
33139
|
}
|
|
32964
33140
|
if (\u5E02\u573A !== void 0 && !isMarketValue(\u5E02\u573A)) return toolFailure("invalid-argument", `\u5E02\u573A\u53D6\u503C\u975E\u6CD5\uFF1A${String(\u5E02\u573A)}\uFF0C\u53EA\u63A5\u53D7 \u6D77\u5916 / \u4E2D\u6587`);
|
|
@@ -33080,7 +33256,7 @@ function createNovelTools(deps) {
|
|
|
33080
33256
|
paths.\u5377\u7EB2(\u5377),
|
|
33081
33257
|
paths.\u8BA1\u5212\u65F6\u95F4\u7EBF(\u5377),
|
|
33082
33258
|
paths.\u8FD1\u671F\u7A97\u53E3(\u5377)
|
|
33083
|
-
].filter((p) =>
|
|
33259
|
+
].filter((p) => fs60.existsSync(nodePath3.join(bookRoot, p)));
|
|
33084
33260
|
const commit = commitConfirmed({ bookRoot, paths: seedPaths, prefix: "design", summary: "\u6700\u5C0F\u8BBE\u8BA1\u9AA8\u67B6", provenance: provenanceOf(sessionContext, seedPaths) });
|
|
33085
33261
|
if (!commit.ok) {
|
|
33086
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}` };
|
|
@@ -33676,7 +33852,7 @@ function createNovelTools(deps) {
|
|
|
33676
33852
|
const rel = paths.\u8FD1\u671F\u7A97\u53E3(\u5377);
|
|
33677
33853
|
let text5 = "";
|
|
33678
33854
|
try {
|
|
33679
|
-
text5 =
|
|
33855
|
+
text5 = fs60.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
|
|
33680
33856
|
} catch {
|
|
33681
33857
|
text5 = "";
|
|
33682
33858
|
}
|
|
@@ -34372,7 +34548,7 @@ function createNovelTools(deps) {
|
|
|
34372
34548
|
const res = archiveRetconRequest({ bookRoot, chapter: \u5B9A\u7A3F\u76F8\u5BF9, request, provenance: provenanceOf(sessionContext) }, (plannedPackageDir) => {
|
|
34373
34549
|
let \u66F4\u6B63\u540E\u5168\u6587;
|
|
34374
34550
|
try {
|
|
34375
|
-
const src =
|
|
34551
|
+
const src = fs60.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
|
|
34376
34552
|
const doc = parseDocument(src);
|
|
34377
34553
|
if (!doc.ok) return { ok: false, reason: `\u5B9A\u7A3F\u7AE0\u89E3\u6790\u5931\u8D25\uFF1A${doc.detail}` };
|
|
34378
34554
|
const parent = extractVersionFields(doc.data.fields).\u7248\u672C;
|
|
@@ -34400,19 +34576,19 @@ function createNovelTools(deps) {
|
|
|
34400
34576
|
const value = optionalText(f);
|
|
34401
34577
|
return value === null ? [] : [[\u5019\u9009\u6587\u4EF6[f], value]];
|
|
34402
34578
|
}));
|
|
34403
|
-
if (
|
|
34404
|
-
for (const name3 of
|
|
34579
|
+
if (fs60.existsSync(\u5305\u7EDD\u5BF9)) {
|
|
34580
|
+
for (const name3 of fs60.readdirSync(\u5305\u7EDD\u5BF9)) {
|
|
34405
34581
|
const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
|
|
34406
|
-
const stat =
|
|
34407
|
-
if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() ||
|
|
34582
|
+
const stat = fs60.lstatSync(file);
|
|
34583
|
+
if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs60.readFileSync(file, "utf8") !== contents.get(name3)) {
|
|
34408
34584
|
return { ok: false, reason: "\u8865\u507F\u5305\u5019\u9009\u51B2\u7A81\uFF0C\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6838\u5BF9\u540E\u5904\u7406" };
|
|
34409
34585
|
}
|
|
34410
34586
|
}
|
|
34411
34587
|
}
|
|
34412
|
-
|
|
34588
|
+
fs60.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
|
|
34413
34589
|
for (const [name3, value] of contents) {
|
|
34414
34590
|
const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
|
|
34415
|
-
if (!
|
|
34591
|
+
if (!fs60.existsSync(file)) fs60.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
|
|
34416
34592
|
}
|
|
34417
34593
|
packageDir = \u5305\u76F8\u5BF9;
|
|
34418
34594
|
}
|
|
@@ -34433,7 +34609,7 @@ function createNovelTools(deps) {
|
|
|
34433
34609
|
retconFiles.push({ \u76EE\u6807: \u6458\u8981\u76F8\u5BF9, \u5185\u5BB9: request.\u66F4\u6B63\u540E\u7AE0\u6458\u8981 });
|
|
34434
34610
|
} else {
|
|
34435
34611
|
try {
|
|
34436
|
-
const \u6458\u8981\u73B0\u6587 =
|
|
34612
|
+
const \u6458\u8981\u73B0\u6587 = fs60.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
|
|
34437
34613
|
retconFiles.push({
|
|
34438
34614
|
\u76EE\u6807: \u6458\u8981\u76F8\u5BF9,
|
|
34439
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")})
|
|
@@ -34715,7 +34891,7 @@ ${\u6458\u8981\u73B0\u6587}`
|
|
|
34715
34891
|
bookRootOfBookId: deps.bookRootOfBookId,
|
|
34716
34892
|
readContractFields: (bookRoot) => readExistingContract(bookRoot).fields
|
|
34717
34893
|
}),
|
|
34718
|
-
...
|
|
34894
|
+
...createShortdramaTools({ bookRootOfBookId: deps.bookRootOfBookId, writeDraft: writeNative })
|
|
34719
34895
|
);
|
|
34720
34896
|
const locked = /* @__PURE__ */ new Set([
|
|
34721
34897
|
"novel_new_outline_draft",
|
|
@@ -34735,9 +34911,10 @@ ${\u6458\u8981\u73B0\u6587}`
|
|
|
34735
34911
|
"novel_record_review_findings",
|
|
34736
34912
|
"novel_record_proposal",
|
|
34737
34913
|
"novel_resolve_proposal",
|
|
34738
|
-
"novel_note_pending"
|
|
34914
|
+
"novel_note_pending",
|
|
34915
|
+
"novel_shortdrama_render_episode"
|
|
34739
34916
|
]);
|
|
34740
|
-
const nativeTools = NATIVE_DESIGN_TOOLS;
|
|
34917
|
+
const nativeTools = /* @__PURE__ */ new Set([...NATIVE_DESIGN_TOOLS, "novel_shortdrama_render_episode"]);
|
|
34741
34918
|
const registered = deps.testTools === true ? tools : tools.filter((tool) => !NOVEL_TEST_TOOL_NAMES.includes(tool.name));
|
|
34742
34919
|
const guarded = registered.map((tool) => {
|
|
34743
34920
|
if (!locked.has(tool.name)) return tool;
|
|
@@ -34749,7 +34926,10 @@ ${\u6458\u8981\u73B0\u6587}`
|
|
|
34749
34926
|
if (root === void 0) return tool.execute(args, sessionContext);
|
|
34750
34927
|
try {
|
|
34751
34928
|
if (nativeTools.has(tool.name)) {
|
|
34752
|
-
return withBookWriteAsync(root, async () => tool.execute(args, sessionContext), provenanceOf(sessionContext)).catch((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
|
+
});
|
|
34753
34933
|
}
|
|
34754
34934
|
return withBookWrite(root, () => tool.execute(args, sessionContext), provenanceOf(sessionContext));
|
|
34755
34935
|
} catch (error) {
|
|
@@ -34890,8 +35070,8 @@ function finishDesignCommit(bookRoot, writtenPaths, args, defaultSummary, chapte
|
|
|
34890
35070
|
import { boundContextSummary, createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
|
|
34891
35071
|
|
|
34892
35072
|
// src/study/service.ts
|
|
34893
|
-
import * as
|
|
34894
|
-
import * as
|
|
35073
|
+
import * as fs63 from "node:fs";
|
|
35074
|
+
import * as path74 from "node:path";
|
|
34895
35075
|
|
|
34896
35076
|
// ../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
|
|
34897
35077
|
var Diff = class {
|
|
@@ -34993,16 +35173,16 @@ var Diff = class {
|
|
|
34993
35173
|
}
|
|
34994
35174
|
}
|
|
34995
35175
|
}
|
|
34996
|
-
addToPath(
|
|
34997
|
-
const last =
|
|
35176
|
+
addToPath(path81, added, removed, oldPosInc, options2) {
|
|
35177
|
+
const last = path81.lastComponent;
|
|
34998
35178
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
34999
35179
|
return {
|
|
35000
|
-
oldPos:
|
|
35180
|
+
oldPos: path81.oldPos + oldPosInc,
|
|
35001
35181
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
35002
35182
|
};
|
|
35003
35183
|
} else {
|
|
35004
35184
|
return {
|
|
35005
|
-
oldPos:
|
|
35185
|
+
oldPos: path81.oldPos + oldPosInc,
|
|
35006
35186
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
35007
35187
|
};
|
|
35008
35188
|
}
|
|
@@ -35193,7 +35373,7 @@ var text4 = (value) => typeof value === "string" ? value : "";
|
|
|
35193
35373
|
var terms = (value) => Array.isArray(value) ? value.flatMap(terms) : typeof value === "string" ? value.split(/[、,,;]/).map((item) => item.trim()).filter(Boolean) : [];
|
|
35194
35374
|
var wiki = (body) => [...body.matchAll(/\[\[([^\]\n]+)\]\]/g)].map((match) => match[1].split("|")[0].trim());
|
|
35195
35375
|
var identity3 = (name3) => name3.trim().replace(/[\s「」『』【】()()::,,。!?!?]/g, "").toLowerCase();
|
|
35196
|
-
var kindOf = (
|
|
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";
|
|
35197
35377
|
function readStoryGraph(source2) {
|
|
35198
35378
|
const records = [], edges = [], events = [];
|
|
35199
35379
|
const warnings = [];
|
|
@@ -35225,7 +35405,7 @@ function readStoryGraph(source2) {
|
|
|
35225
35405
|
aliases.set(name3, values);
|
|
35226
35406
|
};
|
|
35227
35407
|
const strings = (fields) => Object.fromEntries(Object.entries(fields).filter((pair) => typeof pair[1] === "string"));
|
|
35228
|
-
const fromFields = (id, label2, kind2,
|
|
35408
|
+
const fromFields = (id, label2, kind2, path81, line, fields, body) => ({
|
|
35229
35409
|
id,
|
|
35230
35410
|
label: label2,
|
|
35231
35411
|
kind: kind2,
|
|
@@ -35234,23 +35414,23 @@ function readStoryGraph(source2) {
|
|
|
35234
35414
|
chapter: chapter(fields["\u8D77\u59CB\u7AE0"]) ?? chapter(fields["\u751F\u6548\u7AE0"]) ?? chapter(fields["\u7AE0\u53F7"]) ?? entryChapterNo({ \u5B57\u6BB5: strings(fields) }) ?? void 0,
|
|
35235
35415
|
endChapter: chapter(fields["\u5931\u6548\u7AE0"]),
|
|
35236
35416
|
revealChapter: chapter(fields["\u62AB\u9732\u7AE0"]) ?? chapter(fields["\u63ED\u793A\u7AE0"]),
|
|
35237
|
-
source: { space: "book:" + source2.bookId, path:
|
|
35417
|
+
source: { space: "book:" + source2.bookId, path: path81 },
|
|
35238
35418
|
line,
|
|
35239
35419
|
preview: body.trim().slice(0, 600),
|
|
35240
35420
|
// Expose authored scalar/list field names as grouping choices without
|
|
35241
35421
|
// guessing whether 宗门/血脉/师承 means faction, family or another identity.
|
|
35242
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 })))
|
|
35243
35423
|
});
|
|
35244
|
-
const scan = (
|
|
35424
|
+
const scan = (path81, depth = 0) => {
|
|
35245
35425
|
if (depth > 12) {
|
|
35246
|
-
warnings.push({ path:
|
|
35426
|
+
warnings.push({ path: path81, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
|
|
35247
35427
|
return;
|
|
35248
35428
|
}
|
|
35249
35429
|
let entries;
|
|
35250
35430
|
try {
|
|
35251
|
-
entries = source2.list(
|
|
35431
|
+
entries = source2.list(path81);
|
|
35252
35432
|
} catch (error) {
|
|
35253
|
-
if (error.code !== "not-found") warnings.push({ path:
|
|
35433
|
+
if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
|
|
35254
35434
|
return;
|
|
35255
35435
|
}
|
|
35256
35436
|
for (const entry of entries) {
|
|
@@ -35341,26 +35521,26 @@ function readStoryGraph(source2) {
|
|
|
35341
35521
|
};
|
|
35342
35522
|
scan("\u4E16\u754C\u4E66");
|
|
35343
35523
|
for (const category of LEDGER_NAMES) {
|
|
35344
|
-
const
|
|
35524
|
+
const path81 = "\u8D26\u672C/" + category + ".md";
|
|
35345
35525
|
let raw;
|
|
35346
35526
|
try {
|
|
35347
|
-
raw = source2.read(
|
|
35527
|
+
raw = source2.read(path81);
|
|
35348
35528
|
} catch (error) {
|
|
35349
|
-
if (error.code !== "not-found") warnings.push({ path:
|
|
35529
|
+
if (error.code !== "not-found") warnings.push({ path: path81, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
|
|
35350
35530
|
continue;
|
|
35351
35531
|
}
|
|
35352
35532
|
const ranges2 = createEvidenceRanges(raw);
|
|
35353
|
-
sourceHashes[
|
|
35354
|
-
const parsed = parseLedgerHistory(raw, category,
|
|
35533
|
+
sourceHashes[path81] = ranges2.hash;
|
|
35534
|
+
const parsed = parseLedgerHistory(raw, category, path81);
|
|
35355
35535
|
if (!parsed.ok) {
|
|
35356
|
-
warnings.push({ path:
|
|
35536
|
+
warnings.push({ path: path81, message: parsed.reason });
|
|
35357
35537
|
continue;
|
|
35358
35538
|
}
|
|
35359
35539
|
for (const [index, entry] of parsed.entries.entries()) {
|
|
35360
|
-
const id = category === "\u65F6\u95F4\u7EBF" ? "event:" +
|
|
35540
|
+
const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path81 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
|
|
35361
35541
|
const content = category === "\u65F6\u95F4\u7EBF" ? renderTimelineContent(entry) : entry.\u6B63\u6587;
|
|
35362
35542
|
const evidenceId = id + ":" + entry.\u884C\u53F7;
|
|
35363
|
-
const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category,
|
|
35543
|
+
const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path81, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
|
|
35364
35544
|
const recordChapter2 = entryChapterNo(entry) ?? void 0;
|
|
35365
35545
|
const storyTime = category === "\u65F6\u95F4\u7EBF" ? timelineStoryTime(entry) : void 0;
|
|
35366
35546
|
const record4 = { ...base, recordChapter: recordChapter2, storyTime, historyBasis: recordChapter2 ? "recorded" : "unknown", evidenceId };
|
|
@@ -35381,11 +35561,11 @@ function readStoryGraph(source2) {
|
|
|
35381
35561
|
links.push({ record: record4, targets: wiki(content), pair: false });
|
|
35382
35562
|
}
|
|
35383
35563
|
}
|
|
35384
|
-
const resolve22 = (target,
|
|
35564
|
+
const resolve22 = (target, path81) => {
|
|
35385
35565
|
const name3 = target.replace(/^\[\[|\]\]$/g, "").replace(/@\d+$/, "").replace(/\\/g, "/");
|
|
35386
35566
|
const found = aliases.get(name3);
|
|
35387
35567
|
if (found?.size === 1) return [...found][0];
|
|
35388
|
-
warnings.push({ path:
|
|
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 });
|
|
35389
35569
|
return void 0;
|
|
35390
35570
|
};
|
|
35391
35571
|
for (const item of links) {
|
|
@@ -35409,32 +35589,32 @@ function readStoryGraph(source2) {
|
|
|
35409
35589
|
const currentBound = (items) => items.map((item) => item.currentOnlyAt === void 0 ? item : { ...item, currentOnlyAt: maxChapter });
|
|
35410
35590
|
const withChapters = evidence.map((item) => {
|
|
35411
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));
|
|
35412
|
-
return { ...item, relatedChapters: [...new Set(references)].map((
|
|
35592
|
+
return { ...item, relatedChapters: [...new Set(references)].map((path81) => ({ space: item.source.space, path: path81 })) };
|
|
35413
35593
|
});
|
|
35414
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 };
|
|
35415
35595
|
}
|
|
35416
35596
|
|
|
35417
35597
|
// src/study/graph-source.ts
|
|
35418
|
-
import * as
|
|
35419
|
-
import * as
|
|
35598
|
+
import * as fs61 from "node:fs";
|
|
35599
|
+
import * as path72 from "node:path";
|
|
35420
35600
|
import { createHash as createHash20 } from "node:crypto";
|
|
35421
35601
|
function readGraphFile(base, relative12) {
|
|
35422
35602
|
validateAuthorRelativePath(relative12);
|
|
35423
|
-
const file =
|
|
35603
|
+
const file = path72.join(base, relative12);
|
|
35424
35604
|
const checkPhysical = () => {
|
|
35425
|
-
if (stripDevicePrefix(
|
|
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");
|
|
35426
35606
|
};
|
|
35427
35607
|
checkPhysical();
|
|
35428
|
-
const initial =
|
|
35608
|
+
const initial = fs61.lstatSync(file);
|
|
35429
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");
|
|
35430
35610
|
if (initial.size > 4 * 1024 * 1024) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u8D85\u8FC74MiB\uFF0C\u672A\u622A\u65AD\u8BFB\u53D6");
|
|
35431
|
-
const descriptor =
|
|
35611
|
+
const descriptor = fs61.openSync(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
|
|
35432
35612
|
try {
|
|
35433
|
-
const opened =
|
|
35613
|
+
const opened = fs61.fstatSync(descriptor);
|
|
35434
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");
|
|
35435
|
-
const bytes =
|
|
35615
|
+
const bytes = fs61.readFileSync(descriptor);
|
|
35436
35616
|
checkPhysical();
|
|
35437
|
-
const current =
|
|
35617
|
+
const current = fs61.lstatSync(file), finished = fs61.fstatSync(descriptor);
|
|
35438
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");
|
|
35439
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");
|
|
35440
35620
|
try {
|
|
@@ -35443,26 +35623,26 @@ function readGraphFile(base, relative12) {
|
|
|
35443
35623
|
throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u4F7F\u7528UTF-8");
|
|
35444
35624
|
}
|
|
35445
35625
|
} finally {
|
|
35446
|
-
|
|
35626
|
+
fs61.closeSync(descriptor);
|
|
35447
35627
|
}
|
|
35448
35628
|
}
|
|
35449
35629
|
async function readGraphFileAsync(base, relative12, signal) {
|
|
35450
35630
|
signal?.throwIfAborted();
|
|
35451
35631
|
validateAuthorRelativePath(relative12);
|
|
35452
|
-
const file =
|
|
35632
|
+
const file = path72.join(base, relative12);
|
|
35453
35633
|
const checkPhysical = async () => {
|
|
35454
|
-
if (stripDevicePrefix(await
|
|
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");
|
|
35455
35635
|
};
|
|
35456
35636
|
await checkPhysical();
|
|
35457
|
-
const initial = await
|
|
35637
|
+
const initial = await fs61.promises.lstat(file);
|
|
35458
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");
|
|
35459
|
-
const handle = await
|
|
35639
|
+
const handle = await fs61.promises.open(file, fs61.constants.O_RDONLY | (fs61.constants.O_NOFOLLOW ?? 0));
|
|
35460
35640
|
try {
|
|
35461
35641
|
const opened = await handle.stat();
|
|
35462
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");
|
|
35463
35643
|
const bytes = await handle.readFile({ signal });
|
|
35464
35644
|
await checkPhysical();
|
|
35465
|
-
const current = await
|
|
35645
|
+
const current = await fs61.promises.lstat(file), finished = await handle.stat();
|
|
35466
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");
|
|
35467
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");
|
|
35468
35648
|
try {
|
|
@@ -35482,12 +35662,12 @@ async function scanGraphFiles(root, space, signal) {
|
|
|
35482
35662
|
if (depth > 12) return;
|
|
35483
35663
|
try {
|
|
35484
35664
|
const directory = authorDocumentPath(root, relative12, true);
|
|
35485
|
-
const entries = await
|
|
35665
|
+
const entries = await fs61.promises.readdir(directory, { withFileTypes: true });
|
|
35486
35666
|
const rows = entries.filter((item) => !item.name.startsWith(".") && item.name !== "node_modules").map((item) => ({
|
|
35487
35667
|
name: item.name,
|
|
35488
35668
|
directory: item.isDirectory(),
|
|
35489
35669
|
draft: false,
|
|
35490
|
-
ref: { space, path:
|
|
35670
|
+
ref: { space, path: path72.posix.join(relative12, item.name) },
|
|
35491
35671
|
...item.isSymbolicLink() || !item.isFile() && !item.isDirectory() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
|
|
35492
35672
|
}));
|
|
35493
35673
|
directories.set(relative12, rows);
|
|
@@ -35712,8 +35892,8 @@ function overlayExtractions(graph, extractions) {
|
|
|
35712
35892
|
}
|
|
35713
35893
|
|
|
35714
35894
|
// src/indexing/graph-storage.ts
|
|
35715
|
-
import * as
|
|
35716
|
-
import * as
|
|
35895
|
+
import * as fs62 from "node:fs";
|
|
35896
|
+
import * as path73 from "node:path";
|
|
35717
35897
|
import { createRequire as createRequire2 } from "node:module";
|
|
35718
35898
|
import { createHash as createHash21, randomUUID as randomUUID8 } from "node:crypto";
|
|
35719
35899
|
var APPLICATION_ID2 = 1465272113;
|
|
@@ -35735,24 +35915,24 @@ function initialGraphState(bookId2) {
|
|
|
35735
35915
|
}
|
|
35736
35916
|
function graphFile(root, name3) {
|
|
35737
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");
|
|
35738
|
-
const runtime =
|
|
35739
|
-
for (const [target, directory] of [[runtime, true], [
|
|
35918
|
+
const runtime = path73.join(root, ".webnovel");
|
|
35919
|
+
for (const [target, directory] of [[runtime, true], [path73.join(runtime, name3), false]]) {
|
|
35740
35920
|
try {
|
|
35741
|
-
const stat =
|
|
35921
|
+
const stat = fs62.lstatSync(target);
|
|
35742
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");
|
|
35743
35923
|
} catch (error) {
|
|
35744
35924
|
if (error.code !== "ENOENT") throw error;
|
|
35745
35925
|
}
|
|
35746
35926
|
}
|
|
35747
|
-
return
|
|
35927
|
+
return path73.join(runtime, name3);
|
|
35748
35928
|
}
|
|
35749
35929
|
function readGraphState(root, bookId2) {
|
|
35750
35930
|
const file = graphFile(root, STATE_NAME);
|
|
35751
|
-
if (!
|
|
35752
|
-
if (
|
|
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");
|
|
35753
35933
|
let value;
|
|
35754
35934
|
try {
|
|
35755
|
-
value = JSON.parse(
|
|
35935
|
+
value = JSON.parse(fs62.readFileSync(file, "utf8"));
|
|
35756
35936
|
} catch {
|
|
35757
35937
|
throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
|
|
35758
35938
|
}
|
|
@@ -35762,12 +35942,12 @@ function readGraphState(root, bookId2) {
|
|
|
35762
35942
|
function writeGraphState(root, state) {
|
|
35763
35943
|
const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID8()}.tmp`;
|
|
35764
35944
|
try {
|
|
35765
|
-
|
|
35945
|
+
fs62.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
|
|
35766
35946
|
graphFile(root, STATE_NAME);
|
|
35767
|
-
|
|
35947
|
+
fs62.renameSync(temporary, file);
|
|
35768
35948
|
} finally {
|
|
35769
35949
|
try {
|
|
35770
|
-
|
|
35950
|
+
fs62.unlinkSync(temporary);
|
|
35771
35951
|
} catch {
|
|
35772
35952
|
}
|
|
35773
35953
|
}
|
|
@@ -35782,10 +35962,10 @@ function changeGraphState(root, bookId2, update) {
|
|
|
35782
35962
|
function acquireGraphLease(root) {
|
|
35783
35963
|
return withBookLockAsync(root, async () => {
|
|
35784
35964
|
const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID8();
|
|
35785
|
-
if (
|
|
35965
|
+
if (fs62.existsSync(file)) {
|
|
35786
35966
|
let pid;
|
|
35787
35967
|
try {
|
|
35788
|
-
pid = JSON.parse(
|
|
35968
|
+
pid = JSON.parse(fs62.readFileSync(file, "utf8")).pid;
|
|
35789
35969
|
} catch {
|
|
35790
35970
|
throw new Error("\u56FE\u8C31\u4EFB\u52A1\u9501\u65E0\u6CD5\u89E3\u6790\uFF0C\u672A\u6E05\u7406\u539F\u6587\u4EF6");
|
|
35791
35971
|
}
|
|
@@ -35797,12 +35977,12 @@ function acquireGraphLease(root) {
|
|
|
35797
35977
|
dead2 = error.code === "ESRCH";
|
|
35798
35978
|
}
|
|
35799
35979
|
if (!dead2) throw new Error("\u53E6\u4E00\u56FE\u8C31\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C");
|
|
35800
|
-
|
|
35980
|
+
fs62.unlinkSync(graphFile(root, "story-graph.worker.lock"));
|
|
35801
35981
|
}
|
|
35802
|
-
|
|
35982
|
+
fs62.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
|
|
35803
35983
|
return () => {
|
|
35804
35984
|
try {
|
|
35805
|
-
if (JSON.parse(
|
|
35985
|
+
if (JSON.parse(fs62.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs62.unlinkSync(file);
|
|
35806
35986
|
} catch {
|
|
35807
35987
|
}
|
|
35808
35988
|
};
|
|
@@ -35810,20 +35990,20 @@ function acquireGraphLease(root) {
|
|
|
35810
35990
|
}
|
|
35811
35991
|
function graphCacheSignature(root) {
|
|
35812
35992
|
const file = graphFile(root, CACHE_NAME);
|
|
35813
|
-
return
|
|
35993
|
+
return fs62.existsSync(file) ? createHash21("sha256").update(fs62.readFileSync(file)).digest("hex") : "missing";
|
|
35814
35994
|
}
|
|
35815
35995
|
function cacheHeader(file) {
|
|
35816
|
-
const header2 = Buffer.alloc(100), handle =
|
|
35996
|
+
const header2 = Buffer.alloc(100), handle = fs62.openSync(file, "r");
|
|
35817
35997
|
try {
|
|
35818
|
-
|
|
35998
|
+
fs62.readSync(handle, header2, 0, 100, 0);
|
|
35819
35999
|
} finally {
|
|
35820
|
-
|
|
36000
|
+
fs62.closeSync(handle);
|
|
35821
36001
|
}
|
|
35822
36002
|
return header2;
|
|
35823
36003
|
}
|
|
35824
36004
|
function replaceGraphCache(root, bookId2) {
|
|
35825
36005
|
const file = graphFile(root, CACHE_NAME);
|
|
35826
|
-
if (!
|
|
36006
|
+
if (!fs62.existsSync(file)) return;
|
|
35827
36007
|
const header2 = cacheHeader(file);
|
|
35828
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");
|
|
35829
36009
|
let db;
|
|
@@ -35843,12 +36023,12 @@ function replaceGraphCache(root, bookId2) {
|
|
|
35843
36023
|
try {
|
|
35844
36024
|
for (const ending of ["", "-journal", "-wal", "-shm"]) {
|
|
35845
36025
|
const source2 = graphFile(root, CACHE_NAME + ending), target = source2 + suffix;
|
|
35846
|
-
if (!
|
|
35847
|
-
|
|
36026
|
+
if (!fs62.existsSync(source2)) continue;
|
|
36027
|
+
fs62.renameSync(source2, target);
|
|
35848
36028
|
moved.push([source2, target]);
|
|
35849
36029
|
}
|
|
35850
36030
|
} catch (error) {
|
|
35851
|
-
for (const [source2, target] of moved.reverse()) if (!
|
|
36031
|
+
for (const [source2, target] of moved.reverse()) if (!fs62.existsSync(source2)) fs62.renameSync(target, source2);
|
|
35852
36032
|
throw error;
|
|
35853
36033
|
}
|
|
35854
36034
|
}
|
|
@@ -35869,7 +36049,7 @@ function readGraphCache(root, bookId2) {
|
|
|
35869
36049
|
let db;
|
|
35870
36050
|
try {
|
|
35871
36051
|
const file = graphFile(root, CACHE_NAME);
|
|
35872
|
-
if (!
|
|
36052
|
+
if (!fs62.existsSync(file)) return { status: "missing", extractions: [] };
|
|
35873
36053
|
const header2 = cacheHeader(file);
|
|
35874
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");
|
|
35875
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");
|
|
@@ -35891,7 +36071,7 @@ function readGraphCache(root, bookId2) {
|
|
|
35891
36071
|
}
|
|
35892
36072
|
}
|
|
35893
36073
|
function saveGraphCache(root, graph, extraction) {
|
|
35894
|
-
const filename = graphFile(root, CACHE_NAME), exists3 =
|
|
36074
|
+
const filename = graphFile(root, CACHE_NAME), exists3 = fs62.existsSync(filename);
|
|
35895
36075
|
if (exists3) {
|
|
35896
36076
|
const header2 = cacheHeader(filename);
|
|
35897
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");
|
|
@@ -35940,9 +36120,9 @@ function routeForDocument(ref2) {
|
|
|
35940
36120
|
return "\u6821\u51C6\u4F5C\u54C1\u73B0\u72B6\uFF0C\u518D\u6309\u4FEE\u6539\u5185\u5BB9\u9009\u62E9\u5BF9\u5E94\u8282\u70B9";
|
|
35941
36121
|
}
|
|
35942
36122
|
function textOf(target) {
|
|
35943
|
-
if (!
|
|
35944
|
-
if (
|
|
35945
|
-
const bytes =
|
|
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);
|
|
35946
36126
|
if (bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u8BE5\u6587\u4EF6\u4E0D\u662F\u6587\u672C\u6587\u4EF6");
|
|
35947
36127
|
try {
|
|
35948
36128
|
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
@@ -35962,7 +36142,7 @@ var ORPHAN_SIGNALS = ["\u4E66\u7C4D\u4FE1\u606F.json", "\u6545\u4E8B\u5927\u7EB2
|
|
|
35962
36142
|
function orphanSignals(dir) {
|
|
35963
36143
|
let entries;
|
|
35964
36144
|
try {
|
|
35965
|
-
entries =
|
|
36145
|
+
entries = fs63.readdirSync(dir);
|
|
35966
36146
|
} catch {
|
|
35967
36147
|
return void 0;
|
|
35968
36148
|
}
|
|
@@ -35974,18 +36154,18 @@ function scanOrphanDrafts(workspace, bookNames) {
|
|
|
35974
36154
|
const scanLevel = (parent, prefix, skip) => {
|
|
35975
36155
|
let entries;
|
|
35976
36156
|
try {
|
|
35977
|
-
entries =
|
|
36157
|
+
entries = fs63.readdirSync(parent, { withFileTypes: true });
|
|
35978
36158
|
} catch {
|
|
35979
36159
|
return;
|
|
35980
36160
|
}
|
|
35981
36161
|
for (const entry of entries) {
|
|
35982
36162
|
if (!entry.isDirectory() || skip.has(entry.name)) continue;
|
|
35983
|
-
const signals = orphanSignals(
|
|
36163
|
+
const signals = orphanSignals(path74.join(parent, entry.name));
|
|
35984
36164
|
if (signals !== void 0) orphans.push({ name: entry.name, path: prefix + entry.name, detail: `\u542B ${signals.join("\u3001")}` });
|
|
35985
36165
|
}
|
|
35986
36166
|
};
|
|
35987
36167
|
scanLevel(workspace, "", /* @__PURE__ */ new Set([...bookNames, "\u4E66\u623F"]));
|
|
35988
|
-
scanLevel(
|
|
36168
|
+
scanLevel(path74.join(workspace, "\u4E66\u623F"), "\u4E66\u623F/", /* @__PURE__ */ new Set());
|
|
35989
36169
|
return orphans;
|
|
35990
36170
|
}
|
|
35991
36171
|
var StudyService = class {
|
|
@@ -35993,19 +36173,19 @@ var StudyService = class {
|
|
|
35993
36173
|
constructor(workspace) {
|
|
35994
36174
|
if (!isFullyQualifiedPath(workspace)) throw new AuthorDocumentError("invalid-path", "\u5DE5\u4F5C\u8303\u56F4\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
|
|
35995
36175
|
this.workspace = canonicalizePath(workspace);
|
|
35996
|
-
if (!
|
|
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");
|
|
35997
36177
|
}
|
|
35998
36178
|
source(space) {
|
|
35999
36179
|
if (space === "shared") {
|
|
36000
36180
|
const root2 = authorDocumentPath(this.workspace, "\u4E66\u623F");
|
|
36001
|
-
if (!
|
|
36002
|
-
if (
|
|
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");
|
|
36003
36183
|
return { root: root2, owner: "\u5171\u4EAB\u8D44\u6599" };
|
|
36004
36184
|
}
|
|
36005
36185
|
const books = scanWorkspaceBooks(this.workspace).filter((book2) => book2.bookId && "book:" + book2.bookId === space);
|
|
36006
36186
|
if (books.length !== 1) throw new AuthorDocumentError("not-found", "\u4E66\u76EE\u4E0D\u5B58\u5728\u6216\u4E66id\u4E0D\u552F\u4E00");
|
|
36007
36187
|
const book = books[0];
|
|
36008
|
-
const root = authorDocumentPath(this.workspace,
|
|
36188
|
+
const root = authorDocumentPath(this.workspace, path74.relative(this.workspace, book.root));
|
|
36009
36189
|
return { root, owner: book.name, bookId: book.bookId };
|
|
36010
36190
|
}
|
|
36011
36191
|
shelf() {
|
|
@@ -36020,7 +36200,7 @@ var StudyService = class {
|
|
|
36020
36200
|
let shared = false;
|
|
36021
36201
|
let sharedError;
|
|
36022
36202
|
try {
|
|
36023
|
-
shared =
|
|
36203
|
+
shared = fs63.statSync(this.source("shared").root).isDirectory();
|
|
36024
36204
|
} catch (error) {
|
|
36025
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";
|
|
36026
36206
|
}
|
|
@@ -36061,12 +36241,12 @@ var StudyService = class {
|
|
|
36061
36241
|
// once for tree badges and a second time for the evidence itself.
|
|
36062
36242
|
list: (relative12) => {
|
|
36063
36243
|
const directory = authorDocumentPath(source2.root, relative12, true);
|
|
36064
|
-
if (!
|
|
36065
|
-
return
|
|
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) => ({
|
|
36066
36246
|
name: entry.name,
|
|
36067
36247
|
directory: entry.isDirectory(),
|
|
36068
36248
|
draft: false,
|
|
36069
|
-
ref: { space, path:
|
|
36249
|
+
ref: { space, path: path74.posix.join(relative12, entry.name) },
|
|
36070
36250
|
...entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
|
|
36071
36251
|
}));
|
|
36072
36252
|
},
|
|
@@ -36136,13 +36316,13 @@ var StudyService = class {
|
|
|
36136
36316
|
}
|
|
36137
36317
|
treeAt(source2, ref2) {
|
|
36138
36318
|
const directory = authorDocumentPath(source2.root, ref2.path, true);
|
|
36139
|
-
if (!
|
|
36140
|
-
return
|
|
36141
|
-
const relative12 =
|
|
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);
|
|
36142
36322
|
const item = { ref: { space: ref2.space, path: relative12 }, name: entry.name, directory: entry.isDirectory(), draft: ref2.space !== "shared" && relative12.startsWith("\u8349\u7A3F\u533A") };
|
|
36143
36323
|
try {
|
|
36144
36324
|
const target = authorDocumentPath(source2.root, relative12);
|
|
36145
|
-
const info =
|
|
36325
|
+
const info = fs63.statSync(target);
|
|
36146
36326
|
if (!info.isDirectory() && !info.isFile()) return { ...item, error: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B" };
|
|
36147
36327
|
const badge = info.isFile() && entry.name.endsWith(".md") && info.size <= MAX_DOCUMENT_BYTES2 ? fieldLabel(textOf(target)).badge : void 0;
|
|
36148
36328
|
return { ...item, absolutePath: target, directory: info.isDirectory(), ...badge ? { badge } : {} };
|
|
@@ -36160,7 +36340,7 @@ var StudyService = class {
|
|
|
36160
36340
|
read(ref2) {
|
|
36161
36341
|
const source2 = this.source(ref2.space);
|
|
36162
36342
|
const absolutePath = authorDocumentPath(source2.root, ref2.path);
|
|
36163
|
-
ref2 = { ...ref2, path:
|
|
36343
|
+
ref2 = { ...ref2, path: path74.relative(canonicalizePath(source2.root), absolutePath).split(path74.sep).join("/") };
|
|
36164
36344
|
const text5 = textOf(absolutePath);
|
|
36165
36345
|
const parsed = parseDocument(text5);
|
|
36166
36346
|
const metadata2 = fieldLabel(text5);
|
|
@@ -36168,7 +36348,7 @@ var StudyService = class {
|
|
|
36168
36348
|
return {
|
|
36169
36349
|
ref: ref2,
|
|
36170
36350
|
owner: source2.owner,
|
|
36171
|
-
name:
|
|
36351
|
+
name: path74.basename(ref2.path),
|
|
36172
36352
|
absolutePath,
|
|
36173
36353
|
body: parsed.ok ? parsed.data.body : text5,
|
|
36174
36354
|
hash: documentHash(text5),
|
|
@@ -36187,14 +36367,14 @@ var StudyService = class {
|
|
|
36187
36367
|
return null;
|
|
36188
36368
|
}
|
|
36189
36369
|
}
|
|
36190
|
-
absolutePath =
|
|
36370
|
+
absolutePath = path74.resolve(this.workspace, absolutePath);
|
|
36191
36371
|
}
|
|
36192
36372
|
const spaces = this.shelf().books.filter((book) => !book.error).map((book) => book.id);
|
|
36193
36373
|
spaces.push("shared");
|
|
36194
36374
|
for (const space of spaces) {
|
|
36195
36375
|
try {
|
|
36196
36376
|
const source2 = this.source(space);
|
|
36197
|
-
const relative12 =
|
|
36377
|
+
const relative12 = path74.relative(source2.root, absolutePath).split(path74.sep).join("/");
|
|
36198
36378
|
return this.read({ space, path: relative12 });
|
|
36199
36379
|
} catch {
|
|
36200
36380
|
}
|
|
@@ -36207,7 +36387,7 @@ var StudyService = class {
|
|
|
36207
36387
|
const scanned = scanWorkspaceBooks(this.workspace);
|
|
36208
36388
|
const spaces = scanned.filter((book) => book.bookId && scanned.filter((other) => other.bookId === book.bookId).length === 1).map((book) => "book:" + book.bookId);
|
|
36209
36389
|
try {
|
|
36210
|
-
if (
|
|
36390
|
+
if (fs63.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
|
|
36211
36391
|
} catch {
|
|
36212
36392
|
}
|
|
36213
36393
|
const term = query.trim().toLocaleLowerCase();
|
|
@@ -36274,7 +36454,7 @@ var StudyService = class {
|
|
|
36274
36454
|
const status = deriveChapterFacts(facts);
|
|
36275
36455
|
const pending = findPendingReviewDraft(source2.root, key);
|
|
36276
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)];
|
|
36277
|
-
const relative12 = candidates.find((candidate) =>
|
|
36457
|
+
const relative12 = candidates.find((candidate) => fs63.existsSync(path74.join(source2.root, candidate)));
|
|
36278
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 } } : {} };
|
|
36279
36459
|
})
|
|
36280
36460
|
};
|
|
@@ -36807,7 +36987,7 @@ function agentRoots(registry2) {
|
|
|
36807
36987
|
const value = registry2.roots;
|
|
36808
36988
|
if (typeof value === "function") {
|
|
36809
36989
|
try {
|
|
36810
|
-
const result = value();
|
|
36990
|
+
const result = value.call(registry2);
|
|
36811
36991
|
if (Array.isArray(result)) return result;
|
|
36812
36992
|
} catch {
|
|
36813
36993
|
}
|
|
@@ -36821,7 +37001,7 @@ function agentList(registry2) {
|
|
|
36821
37001
|
const value = registry2.list;
|
|
36822
37002
|
if (typeof value === "function") {
|
|
36823
37003
|
try {
|
|
36824
|
-
const result = value();
|
|
37004
|
+
const result = value.call(registry2);
|
|
36825
37005
|
if (Array.isArray(result)) return result;
|
|
36826
37006
|
} catch {
|
|
36827
37007
|
}
|
|
@@ -37152,7 +37332,7 @@ function createStudyHandler(runtime, indexing, workflow = new WorkflowObserver()
|
|
|
37152
37332
|
const relPath = stringOf(input, "path");
|
|
37153
37333
|
const orphan = (service.shelf().orphans ?? []).find((item) => item.path === relPath);
|
|
37154
37334
|
if (!orphan) throw new AuthorDocumentError("not-found", "\u6CA1\u6709\u627E\u5230\u8FD9\u4E2A\u672A\u6309\u89C4\u8303\u5EFA\u7ACB\u7684\u4E66\u7A3F\u76EE\u5F55\uFF0C\u8BF7\u5237\u65B0\u4E66\u623F\u540E\u91CD\u8BD5");
|
|
37155
|
-
const message = `\u4E66\u623F\u53D1\u73B0\u672A\u6309\u89C4\u8303\u5EFA\u7ACB\u7684\u4E66\u7A3F\u76EE\u5F55\u300A${orphan.name}\u300B\uFF08${orphan.path}\uFF0C${orphan.detail}\uFF09\
|
|
37335
|
+
const message = `\u4E66\u623F\u53D1\u73B0\u672A\u6309\u89C4\u8303\u5EFA\u7ACB\u7684\u4E66\u7A3F\u76EE\u5F55\u300A${orphan.name}\u300B\uFF08${orphan.path}\uFF0C${orphan.detail}\uFF09\u3002\u76EE\u5F55\u7F3A\u4F5C\u54C1\u5951\u7EA6\uFF08\u4F5C\u54C1\u5951\u7EA6/\u5951\u7EA6.md\uFF09\uFF0C\u6240\u4EE5\u6CA1\u51FA\u73B0\u5728\u300C\u6211\u7684\u4F5C\u54C1\u300D\u91CC\u3002\u8BF7\u7528 novel_create_book \u91CD\u65B0\u5EFA\u4E66\u3002\u4E66\u540D\u3001\u5E02\u573A\u3001\u8F93\u51FA\u5F62\u6001\u3001\u76EE\u6807\u603B\u5B57\u6570\u5148\u95EE\u4F5C\u8005\uFF1B\u4E66\u623F\u5411\u5BFC\u5DF2\u4FDD\u5B58\u7684\u9009\u62E9\u76F4\u63A5\u7528\u3002\u518D\u628A\u5DF2\u6709\u5185\u5BB9\uFF08\u5927\u7EB2\u3001\u7AE0\u8282\uFF09\u6309\u89C4\u8303\u8FC1\u8FDB\u65B0\u4E66\u4ED3\uFF1B\u8FC1\u5B8C\u544A\u8BC9\u4F5C\u8005\u4E66\u5DF2\u51FA\u73B0\u5728\u300C\u6211\u7684\u4F5C\u54C1\u300D\u91CC\u3002\u5982\u679C\u5DF2\u6709\u5185\u5BB9\u4E0D\u503C\u5F97\u8FC1\uFF0C\u4E5F\u8BF7\u660E\u786E\u544A\u8BC9\u4F5C\u8005\uFF0C\u4E0D\u8981\u624B\u5199\u6587\u4EF6\u5192\u5145\u5EFA\u4E66\u3002`;
|
|
37156
37336
|
try {
|
|
37157
37337
|
agent.followup(createUserMessage3({ content: [{ type: "text", text: message }], source: { kind: ORPHAN_REPAIR_SOURCE } }));
|
|
37158
37338
|
} catch {
|
|
@@ -37223,7 +37403,7 @@ function brandString(value) {
|
|
|
37223
37403
|
|
|
37224
37404
|
// src/native-write.ts
|
|
37225
37405
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
37226
|
-
import * as
|
|
37406
|
+
import * as path75 from "node:path";
|
|
37227
37407
|
import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
|
|
37228
37408
|
function nativeToolRuntime(ctx) {
|
|
37229
37409
|
const pipeline = new ToolExecutionPipeline(ctx);
|
|
@@ -37254,7 +37434,7 @@ function createNativeWriteBridge(runtime) {
|
|
|
37254
37434
|
exec.signal.throwIfAborted();
|
|
37255
37435
|
const target = resolveInsideBook(root, op.relPath);
|
|
37256
37436
|
if (!target.ok) throw new Error("\u539F\u751F\u5199\u5165\u76EE\u6807\u4E0D\u5728\u4E66\u4ED3\u5185");
|
|
37257
|
-
const file =
|
|
37437
|
+
const file = path75.resolve(root, target.relPath);
|
|
37258
37438
|
const callId = brandString(`webnovel-write-${randomUUID9()}`);
|
|
37259
37439
|
pending.set(callId, { parent: exec.token, agent: exec.agent, file, content: op.content });
|
|
37260
37440
|
try {
|
|
@@ -37278,10 +37458,10 @@ function createNativeWriteBridge(runtime) {
|
|
|
37278
37458
|
}
|
|
37279
37459
|
|
|
37280
37460
|
// src/indexing/manager.ts
|
|
37281
|
-
import * as
|
|
37461
|
+
import * as fs64 from "node:fs";
|
|
37282
37462
|
|
|
37283
37463
|
// src/indexing/git.ts
|
|
37284
|
-
import * as
|
|
37464
|
+
import * as path76 from "node:path";
|
|
37285
37465
|
import { execFile } from "node:child_process";
|
|
37286
37466
|
async function git(root, args) {
|
|
37287
37467
|
return new Promise((resolve22) => execFile("git", ["--literal-pathspecs", "-C", root, ...args], {
|
|
@@ -37307,8 +37487,8 @@ async function bookGitWatchPaths(root) {
|
|
|
37307
37487
|
git(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"])
|
|
37308
37488
|
]);
|
|
37309
37489
|
return [...new Set(directories.filter((value) => !!value?.trim()).flatMap((value) => {
|
|
37310
|
-
const directory =
|
|
37311
|
-
return [directory,
|
|
37490
|
+
const directory = path76.resolve(root, value.trim());
|
|
37491
|
+
return [directory, path76.join(directory, "refs")];
|
|
37312
37492
|
}))];
|
|
37313
37493
|
}
|
|
37314
37494
|
|
|
@@ -37715,7 +37895,7 @@ var BookIndexManager = class {
|
|
|
37715
37895
|
for (const directory of await bookGitWatchPaths(record4.book.root)) {
|
|
37716
37896
|
if (this.closing) return;
|
|
37717
37897
|
try {
|
|
37718
|
-
const watcher =
|
|
37898
|
+
const watcher = fs64.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
|
|
37719
37899
|
const name3 = filename?.toString().replaceAll("\\", "/");
|
|
37720
37900
|
if (directory.endsWith("refs") || !name3 || /^(HEAD|packed-refs|refs)(\/|$)/.test(name3)) {
|
|
37721
37901
|
this.scheduleProbe(record4);
|
|
@@ -38089,7 +38269,7 @@ function indexFailureMessage(book, notice) {
|
|
|
38089
38269
|
}
|
|
38090
38270
|
|
|
38091
38271
|
// src/reference/host.ts
|
|
38092
|
-
import * as
|
|
38272
|
+
import * as path77 from "node:path";
|
|
38093
38273
|
import { BlockAssembler, createUserMessage as createUserMessage4 } from "@deepseek-ai/dsh-llm";
|
|
38094
38274
|
var ReferenceHost = class {
|
|
38095
38275
|
constructor(access) {
|
|
@@ -38107,26 +38287,26 @@ var ReferenceHost = class {
|
|
|
38107
38287
|
async readFile(agent, workspace, filename, signal) {
|
|
38108
38288
|
const active = AbortSignal.any([this.shutdown.signal, ...signal ? [signal] : []]);
|
|
38109
38289
|
active.throwIfAborted();
|
|
38110
|
-
const
|
|
38111
|
-
if (!
|
|
38112
|
-
if (!
|
|
38113
|
-
const mapped =
|
|
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);
|
|
38114
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");
|
|
38115
|
-
const info = await
|
|
38295
|
+
const info = await fs68.lstat(mapped, void 0, active);
|
|
38116
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");
|
|
38117
|
-
let ancestor =
|
|
38118
|
-
while (
|
|
38119
|
-
if ((await
|
|
38120
|
-
ancestor =
|
|
38121
|
-
}
|
|
38122
|
-
const target = await
|
|
38123
|
-
const library = await
|
|
38124
|
-
if (
|
|
38125
|
-
const before = await
|
|
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);
|
|
38126
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");
|
|
38127
|
-
const bytes = await
|
|
38128
|
-
const afterTarget = await
|
|
38129
|
-
const afterPath = await
|
|
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);
|
|
38130
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");
|
|
38131
38311
|
active.throwIfAborted();
|
|
38132
38312
|
return bytes;
|
|
@@ -38272,8 +38452,8 @@ function createIndexAutoPreference(settings, fallback) {
|
|
|
38272
38452
|
}
|
|
38273
38453
|
|
|
38274
38454
|
// src/scripts/deterministic-checks.ts
|
|
38275
|
-
import * as
|
|
38276
|
-
import * as
|
|
38455
|
+
import * as fs65 from "node:fs";
|
|
38456
|
+
import * as path78 from "node:path";
|
|
38277
38457
|
function parseArgs(argv) {
|
|
38278
38458
|
const values = /* @__PURE__ */ new Map();
|
|
38279
38459
|
for (let i = 0; i < argv.length; i += 1) {
|
|
@@ -38303,8 +38483,8 @@ function runChecksCli(argv) {
|
|
|
38303
38483
|
console.error(`\u524D\u7F6E\u53C2\u6570\u9519\u8BEF\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
38304
38484
|
return 1;
|
|
38305
38485
|
}
|
|
38306
|
-
if (!
|
|
38307
|
-
console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${
|
|
38486
|
+
if (!fs65.existsSync(args.book) || !fs65.statSync(args.book).isDirectory()) {
|
|
38487
|
+
console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path78.resolve(args.book)}`);
|
|
38308
38488
|
return 1;
|
|
38309
38489
|
}
|
|
38310
38490
|
try {
|
|
@@ -38338,8 +38518,8 @@ function runChecksCli(argv) {
|
|
|
38338
38518
|
}
|
|
38339
38519
|
|
|
38340
38520
|
// src/scripts/draft-length-cli.ts
|
|
38341
|
-
import * as
|
|
38342
|
-
import * as
|
|
38521
|
+
import * as fs66 from "node:fs";
|
|
38522
|
+
import * as path79 from "node:path";
|
|
38343
38523
|
function unverified(reason, exitCode) {
|
|
38344
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));
|
|
38345
38525
|
return exitCode;
|
|
@@ -38360,14 +38540,14 @@ function draftLengthCli(argv) {
|
|
|
38360
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);
|
|
38361
38541
|
}
|
|
38362
38542
|
try {
|
|
38363
|
-
if (!
|
|
38543
|
+
if (!fs66.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
|
|
38364
38544
|
const resolved = resolveInsideBook(book, requested);
|
|
38365
38545
|
if (!resolved.ok) return unverified(resolved.reason, 1);
|
|
38366
38546
|
const target = draftLengthTarget(resolved.relPath);
|
|
38367
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);
|
|
38368
|
-
const file =
|
|
38369
|
-
if (!
|
|
38370
|
-
const text5 =
|
|
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");
|
|
38371
38551
|
const result = draftLengthFeedback(target, text5, readChapterLength(book));
|
|
38372
38552
|
console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", ...result }, null, 2));
|
|
38373
38553
|
return result.\u7EDF\u8BA1\u72B6\u6001 === "\u5DF2\u7EDF\u8BA1" ? 0 : 1;
|
|
@@ -38586,8 +38766,8 @@ function exportCli(argv) {
|
|
|
38586
38766
|
}
|
|
38587
38767
|
|
|
38588
38768
|
// src/scripts/screenplay-export-cli.ts
|
|
38589
|
-
import * as
|
|
38590
|
-
import * as
|
|
38769
|
+
import * as fs67 from "node:fs";
|
|
38770
|
+
import * as path80 from "node:path";
|
|
38591
38771
|
function argValue5(argv, name3) {
|
|
38592
38772
|
const i = argv.indexOf(`--${name3}`);
|
|
38593
38773
|
return i === -1 ? void 0 : argv[i + 1];
|
|
@@ -38648,12 +38828,12 @@ function screenplayExportCli(argv) {
|
|
|
38648
38828
|
const \u5206\u955C\u5934raw = argValue5(argv, "\u5206\u955C\u5934")?.trim();
|
|
38649
38829
|
let \u5206\u955C\u5934\u8868;
|
|
38650
38830
|
if (\u5206\u955C\u5934raw !== void 0) {
|
|
38651
|
-
const shotPath =
|
|
38652
|
-
if (!
|
|
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()) {
|
|
38653
38833
|
console.error(`\u5206\u955C\u5934\u8868\u4E0D\u5B58\u5728\uFF1A${shotPath}`);
|
|
38654
38834
|
return 1;
|
|
38655
38835
|
}
|
|
38656
|
-
const parsed = parseShotListTable(
|
|
38836
|
+
const parsed = parseShotListTable(fs67.readFileSync(shotPath, "utf-8"));
|
|
38657
38837
|
if (!parsed.ok || parsed.shotList === void 0) {
|
|
38658
38838
|
console.error(`\u5206\u955C\u5934\u8868\u89E3\u6790\u5931\u8D25\uFF1A${parsed.problems.join("\uFF1B")}`);
|
|
38659
38839
|
return 1;
|
|
@@ -38663,13 +38843,13 @@ function screenplayExportCli(argv) {
|
|
|
38663
38843
|
const \u603B\u7EB2raw = argValue5(argv, "\u603B\u7EB2")?.trim();
|
|
38664
38844
|
let \u603B\u7EB2;
|
|
38665
38845
|
if (\u603B\u7EB2raw !== void 0) {
|
|
38666
|
-
const biblePath =
|
|
38667
|
-
if (!
|
|
38846
|
+
const biblePath = path80.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path80.join(book, \u603B\u7EB2raw);
|
|
38847
|
+
if (!fs67.existsSync(biblePath) || !fs67.statSync(biblePath).isFile()) {
|
|
38668
38848
|
console.error(`\u603B\u7EB2\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${biblePath}`);
|
|
38669
38849
|
return 1;
|
|
38670
38850
|
}
|
|
38671
38851
|
try {
|
|
38672
|
-
const parsedBible = JSON.parse(
|
|
38852
|
+
const parsedBible = JSON.parse(fs67.readFileSync(biblePath, "utf-8"));
|
|
38673
38853
|
if (typeof parsedBible !== "object" || parsedBible === null || Array.isArray(parsedBible)) {
|
|
38674
38854
|
console.error("\u603B\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A\u603B\u7EB2 JSON \u987B\u4E3A\u5BF9\u8C61\uFF08StoryBibleInput \u4E03\u8282\uFF09");
|
|
38675
38855
|
return 1;
|