@yangda611/dsh-scriptor 8.4.3 → 8.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/cli.js +7 -0
- package/lib/client.js +103 -79
- package/lib/index.js +416 -267
- package/package.json +1 -1
- package/skills/novel-inspiration/SKILL.md +5 -3
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, path80) {
|
|
117
|
+
const ctrl = callVisitor(key, node, visitor, path80);
|
|
118
118
|
if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
|
|
119
|
-
replaceNode(key,
|
|
120
|
-
return visit_(key, ctrl, visitor,
|
|
119
|
+
replaceNode(key, path80, ctrl);
|
|
120
|
+
return visit_(key, ctrl, visitor, path80);
|
|
121
121
|
}
|
|
122
122
|
if (typeof ctrl !== "symbol") {
|
|
123
123
|
if (identity4.isCollection(node)) {
|
|
124
|
-
|
|
124
|
+
path80 = Object.freeze(path80.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, path80);
|
|
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
|
+
path80 = Object.freeze(path80.concat(node));
|
|
138
|
+
const ck = visit_("key", node.key, visitor, path80);
|
|
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, path80);
|
|
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, path80) {
|
|
165
|
+
const ctrl = await callVisitor(key, node, visitor, path80);
|
|
166
166
|
if (identity4.isNode(ctrl) || identity4.isPair(ctrl)) {
|
|
167
|
-
replaceNode(key,
|
|
168
|
-
return visitAsync_(key, ctrl, visitor,
|
|
167
|
+
replaceNode(key, path80, ctrl);
|
|
168
|
+
return visitAsync_(key, ctrl, visitor, path80);
|
|
169
169
|
}
|
|
170
170
|
if (typeof ctrl !== "symbol") {
|
|
171
171
|
if (identity4.isCollection(node)) {
|
|
172
|
-
|
|
172
|
+
path80 = Object.freeze(path80.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, path80);
|
|
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
|
+
path80 = Object.freeze(path80.concat(node));
|
|
186
|
+
const ck = await visitAsync_("key", node.key, visitor, path80);
|
|
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, path80);
|
|
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, path80) {
|
|
219
219
|
if (typeof visitor === "function")
|
|
220
|
-
return visitor(key, node,
|
|
220
|
+
return visitor(key, node, path80);
|
|
221
221
|
if (identity4.isMap(node))
|
|
222
|
-
return visitor.Map?.(key, node,
|
|
222
|
+
return visitor.Map?.(key, node, path80);
|
|
223
223
|
if (identity4.isSeq(node))
|
|
224
|
-
return visitor.Seq?.(key, node,
|
|
224
|
+
return visitor.Seq?.(key, node, path80);
|
|
225
225
|
if (identity4.isPair(node))
|
|
226
|
-
return visitor.Pair?.(key, node,
|
|
226
|
+
return visitor.Pair?.(key, node, path80);
|
|
227
227
|
if (identity4.isScalar(node))
|
|
228
|
-
return visitor.Scalar?.(key, node,
|
|
228
|
+
return visitor.Scalar?.(key, node, path80);
|
|
229
229
|
if (identity4.isAlias(node))
|
|
230
|
-
return visitor.Alias?.(key, node,
|
|
230
|
+
return visitor.Alias?.(key, node, path80);
|
|
231
231
|
return void 0;
|
|
232
232
|
}
|
|
233
|
-
function replaceNode(key,
|
|
234
|
-
const parent =
|
|
233
|
+
function replaceNode(key, path80, node) {
|
|
234
|
+
const parent = path80[path80.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, path80, value) {
|
|
845
845
|
let v = value;
|
|
846
|
-
for (let i =
|
|
847
|
-
const k =
|
|
846
|
+
for (let i = path80.length - 1; i >= 0; --i) {
|
|
847
|
+
const k = path80[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 = (path80) => path80 == null || typeof path80 === "object" && !!path80[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(path80, value) {
|
|
897
|
+
if (isEmptyPath(path80))
|
|
898
898
|
this.add(value);
|
|
899
899
|
else {
|
|
900
|
-
const [key, ...rest] =
|
|
900
|
+
const [key, ...rest] = path80;
|
|
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(path80) {
|
|
915
|
+
const [key, ...rest] = path80;
|
|
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(path80, keepScalar) {
|
|
930
|
+
const [key, ...rest] = path80;
|
|
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(path80) {
|
|
949
|
+
const [key, ...rest] = path80;
|
|
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(path80, value) {
|
|
960
|
+
const [key, ...rest] = path80;
|
|
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(path80, value) {
|
|
3476
3476
|
if (assertCollection(this.contents))
|
|
3477
|
-
this.contents.addIn(
|
|
3477
|
+
this.contents.addIn(path80, 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(path80) {
|
|
3553
|
+
if (Collection.isEmptyPath(path80)) {
|
|
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(path80) : 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(path80, keepScalar) {
|
|
3575
|
+
if (Collection.isEmptyPath(path80))
|
|
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(path80, 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(path80) {
|
|
3589
|
+
if (Collection.isEmptyPath(path80))
|
|
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(path80) : 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(path80, value) {
|
|
3609
|
+
if (Collection.isEmptyPath(path80)) {
|
|
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(path80), value);
|
|
3613
3613
|
} else if (assertCollection(this.contents)) {
|
|
3614
|
-
this.contents.setIn(
|
|
3614
|
+
this.contents.setIn(path80, 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, path80) => {
|
|
5575
5575
|
let item = cst;
|
|
5576
|
-
for (const [field, index] of
|
|
5576
|
+
for (const [field, index] of path80) {
|
|
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, path80) => {
|
|
5586
|
+
const parent = visit.itemAtPath(cst, path80.slice(0, -1));
|
|
5587
|
+
const field = path80[path80.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(path80, item, visitor) {
|
|
5594
|
+
let ctrl = visitor(item, path80);
|
|
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(path80.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, path80);
|
|
5613
5613
|
}
|
|
5614
5614
|
}
|
|
5615
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5615
|
+
return typeof ctrl === "function" ? ctrl(item, path80) : 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 fs67 = this.flowScalar(this.type);
|
|
6918
6918
|
if (atNextItem || it.value) {
|
|
6919
|
-
map.items.push({ start, key:
|
|
6919
|
+
map.items.push({ start, key: fs67, sep: [] });
|
|
6920
6920
|
this.onKeyLine = true;
|
|
6921
6921
|
} else if (it.sep) {
|
|
6922
|
-
this.stack.push(
|
|
6922
|
+
this.stack.push(fs67);
|
|
6923
6923
|
} else {
|
|
6924
|
-
Object.assign(it, { key:
|
|
6924
|
+
Object.assign(it, { key: fs67, 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 fs67 = this.flowScalar(this.type);
|
|
7053
7053
|
if (!it || it.value)
|
|
7054
|
-
fc.items.push({ start: [], key:
|
|
7054
|
+
fc.items.push({ start: [], key: fs67, sep: [] });
|
|
7055
7055
|
else if (it.sep)
|
|
7056
|
-
this.stack.push(
|
|
7056
|
+
this.stack.push(fs67);
|
|
7057
7057
|
else
|
|
7058
|
-
Object.assign(it, { key:
|
|
7058
|
+
Object.assign(it, { key: fs67, 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 fs67 = __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
|
+
fs67.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
|
+
fs67.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
|
+
fs67.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 fs67 = __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(path80, options2) {
|
|
7879
7879
|
return new Promise((resolve22, reject) => {
|
|
7880
|
-
open(
|
|
7880
|
+
open(path80, { ...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(path80, 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
|
+
fs67.open(path80, "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) fs67.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
|
+
fs67.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);
|
|
@@ -11101,17 +11101,17 @@ Schema.prototype.volatile = function volatile() {
|
|
|
11101
11101
|
};
|
|
11102
11102
|
var resolvers = {};
|
|
11103
11103
|
var checkedVolatile = /* @__PURE__ */ Symbol("checked-volatile-schema");
|
|
11104
|
-
function validateVolatileSchema(schema,
|
|
11104
|
+
function validateVolatileSchema(schema, path80 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
|
|
11105
11105
|
const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
|
|
11106
11106
|
if (states.has(blocked)) return;
|
|
11107
11107
|
states.add(blocked);
|
|
11108
11108
|
seen.set(schema, states);
|
|
11109
|
-
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path:
|
|
11109
|
+
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path: path80 });
|
|
11110
11110
|
const nested = blocked || !!schema.meta?.volatile;
|
|
11111
|
-
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...
|
|
11112
|
-
if (schema.sKey) validateVolatileSchema(schema.sKey, [...
|
|
11113
|
-
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...
|
|
11114
|
-
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...
|
|
11111
|
+
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path80, key], nested, seen);
|
|
11112
|
+
if (schema.sKey) validateVolatileSchema(schema.sKey, [...path80, "<key>"], true, seen);
|
|
11113
|
+
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path80, "*"], true, seen);
|
|
11114
|
+
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path80, String(index)], true, seen);
|
|
11115
11115
|
}
|
|
11116
11116
|
Schema.extend = function extend(type, resolve22) {
|
|
11117
11117
|
resolvers[type] = resolve22;
|
|
@@ -12958,6 +12958,13 @@ var DOCUMENT_FIELDS = {
|
|
|
12958
12958
|
type: "single-line-text",
|
|
12959
12959
|
owner: "system"
|
|
12960
12960
|
},
|
|
12961
|
+
/** 建书硬性流程(8.4.4):创建时选定的目标总字数(汉字数),决定篇幅规划;建书前必须问作者拿到答案,不静默用默认值。 */
|
|
12962
|
+
targetTotalWords: {
|
|
12963
|
+
name: "\u76EE\u6807\u603B\u5B57\u6570",
|
|
12964
|
+
description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF09\uFF1B\u521B\u5EFA\u65F6\u9009\u5B9A\uFF0C\u51B3\u5B9A\u7BC7\u5E45\u89C4\u5212",
|
|
12965
|
+
type: "positive-integer",
|
|
12966
|
+
owner: "system"
|
|
12967
|
+
},
|
|
12961
12968
|
timelineEvent: {
|
|
12962
12969
|
name: "\u4E8B\u4EF6",
|
|
12963
12970
|
description: "\u5B9E\u9645\u53D1\u751F\u7684\u4E8B\u4EF6\u63CF\u8FF0\uFF0C\u4E0D\u662F\u4E8B\u4EF6\u6761\u76EE\u7684\u540D\u79F0\u6216\u8BB0\u5F55\u7AE0\u53F7",
|
|
@@ -17144,6 +17151,12 @@ function marketOf(concept) {
|
|
|
17144
17151
|
function outputFormOf(concept) {
|
|
17145
17152
|
return concept !== null && concept !== void 0 && isOutputFormValue(concept.\u8F93\u51FA\u5F62\u6001) ? concept.\u8F93\u51FA\u5F62\u6001 : DEFAULT_OUTPUT_FORM;
|
|
17146
17153
|
}
|
|
17154
|
+
function targetTotalWordsOf(concept) {
|
|
17155
|
+
return concept !== null && concept !== void 0 && typeof concept.\u76EE\u6807\u603B\u5B57\u6570 === "number" && Number.isSafeInteger(concept.\u76EE\u6807\u603B\u5B57\u6570) && concept.\u76EE\u6807\u603B\u5B57\u6570 > 0 ? concept.\u76EE\u6807\u603B\u5B57\u6570 : void 0;
|
|
17156
|
+
}
|
|
17157
|
+
function isTargetTotalWordsValue(value) {
|
|
17158
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
17159
|
+
}
|
|
17147
17160
|
var \u5FC5\u586B\u96C6 = new Set(\u6784\u60F3\u5FC5\u586B\u8981\u7D20);
|
|
17148
17161
|
function isConceptBlank(value) {
|
|
17149
17162
|
if (value === void 0 || value === null) return true;
|
|
@@ -17187,6 +17200,7 @@ function parseConcept(text5) {
|
|
|
17187
17200
|
const \u72B6\u6001 = r2.data.fields["\u72B6\u6001"] === "\u5DF2\u786E\u8BA4" ? "\u5DF2\u786E\u8BA4" : "\u5019\u9009";
|
|
17188
17201
|
const \u5E02\u573A = r2.data.fields[DOCUMENT_FIELDS.market.name];
|
|
17189
17202
|
const \u8F93\u51FA\u5F62\u6001 = r2.data.fields[DOCUMENT_FIELDS.outputForm.name];
|
|
17203
|
+
const \u76EE\u6807\u603B\u5B57\u6570 = r2.data.fields[DOCUMENT_FIELDS.targetTotalWords.name];
|
|
17190
17204
|
return {
|
|
17191
17205
|
\u72B6\u6001,
|
|
17192
17206
|
\u6838\u5FC3\u521B\u610F: bodies["\u6838\u5FC3\u521B\u610F"] ?? "",
|
|
@@ -17198,7 +17212,8 @@ function parseConcept(text5) {
|
|
|
17198
17212
|
\u660E\u786E\u4E0D\u8981\u4EC0\u4E48: bodies["\u660E\u786E\u4E0D\u8981\u4EC0\u4E48"] ?? "",
|
|
17199
17213
|
\u8981\u7D20\u72B6\u6001: states,
|
|
17200
17214
|
...isMarketValue(\u5E02\u573A) ? { \u5E02\u573A } : {},
|
|
17201
|
-
...isOutputFormValue(\u8F93\u51FA\u5F62\u6001) ? { \u8F93\u51FA\u5F62\u6001 } : {}
|
|
17215
|
+
...isOutputFormValue(\u8F93\u51FA\u5F62\u6001) ? { \u8F93\u51FA\u5F62\u6001 } : {},
|
|
17216
|
+
...isTargetTotalWordsValue(\u76EE\u6807\u603B\u5B57\u6570) ? { \u76EE\u6807\u603B\u5B57\u6570 } : {}
|
|
17202
17217
|
};
|
|
17203
17218
|
}
|
|
17204
17219
|
function serializeConcept(concept) {
|
|
@@ -17211,10 +17226,12 @@ function serializeConcept(concept) {
|
|
|
17211
17226
|
lines.push(body.trim(), "");
|
|
17212
17227
|
}
|
|
17213
17228
|
}
|
|
17229
|
+
const totalWords = targetTotalWordsOf(concept);
|
|
17214
17230
|
return serializeDocument({
|
|
17215
17231
|
\u72B6\u6001: concept.\u72B6\u6001,
|
|
17216
17232
|
[DOCUMENT_FIELDS.market.name]: marketOf(concept),
|
|
17217
|
-
[DOCUMENT_FIELDS.outputForm.name]: outputFormOf(concept)
|
|
17233
|
+
[DOCUMENT_FIELDS.outputForm.name]: outputFormOf(concept),
|
|
17234
|
+
...totalWords === void 0 ? {} : { [DOCUMENT_FIELDS.targetTotalWords.name]: totalWords }
|
|
17218
17235
|
}, lines.join("\n").trimEnd() + "\n");
|
|
17219
17236
|
}
|
|
17220
17237
|
function extractElementBodies(body) {
|
|
@@ -17997,7 +18014,8 @@ function labeledHeadings(names, state) {
|
|
|
17997
18014
|
function resolveContractFields(opts = {}) {
|
|
17998
18015
|
if (opts.\u5E02\u573A !== void 0 && !isMarketValue(opts.\u5E02\u573A)) throw new Error(`\u5E02\u573A\u53D6\u503C\u975E\u6CD5\uFF1A${String(opts.\u5E02\u573A)}\uFF0C\u53EA\u63A5\u53D7 \u6D77\u5916 / \u4E2D\u6587`);
|
|
17999
18016
|
if (opts.\u8F93\u51FA\u5F62\u6001 !== void 0 && !isOutputFormValue(opts.\u8F93\u51FA\u5F62\u6001)) throw new Error(`\u8F93\u51FA\u5F62\u6001\u53D6\u503C\u975E\u6CD5\uFF1A${String(opts.\u8F93\u51FA\u5F62\u6001)}\uFF0C\u53EA\u63A5\u53D7 \u77ED\u5267 / \u7535\u5F71\u5267\u672C / \u5C0F\u8BF4`);
|
|
18000
|
-
|
|
18017
|
+
if (opts.\u76EE\u6807\u603B\u5B57\u6570 !== void 0 && (!Number.isSafeInteger(opts.\u76EE\u6807\u603B\u5B57\u6570) || opts.\u76EE\u6807\u603B\u5B57\u6570 <= 0)) throw new Error(`\u76EE\u6807\u603B\u5B57\u6570\u53D6\u503C\u975E\u6CD5\uFF1A${String(opts.\u76EE\u6807\u603B\u5B57\u6570)}\uFF0C\u53EA\u63A5\u53D7\u6B63\u6574\u6570\u6C49\u5B57\u6570`);
|
|
18018
|
+
return { \u5E02\u573A: opts.\u5E02\u573A ?? DEFAULT_MARKET, \u8F93\u51FA\u5F62\u6001: opts.\u8F93\u51FA\u5F62\u6001 ?? DEFAULT_OUTPUT_FORM, ...opts.\u76EE\u6807\u603B\u5B57\u6570 === void 0 ? {} : { \u76EE\u6807\u603B\u5B57\u6570: opts.\u76EE\u6807\u603B\u5B57\u6570 } };
|
|
18001
18019
|
}
|
|
18002
18020
|
function emptyContractBody(bookId2, fieldOpts = {}) {
|
|
18003
18021
|
const fields = resolveContractFields(fieldOpts);
|
|
@@ -18005,10 +18023,11 @@ function emptyContractBody(bookId2, fieldOpts = {}) {
|
|
|
18005
18023
|
...bookId2 === void 0 ? {} : { \u4E66id: bookId2 },
|
|
18006
18024
|
[BOOK_FORMAT_VERSION_FIELD]: CURRENT_BOOK_FORMAT_VERSION,
|
|
18007
18025
|
[DOCUMENT_FIELDS.market.name]: fields.\u5E02\u573A,
|
|
18008
|
-
[DOCUMENT_FIELDS.outputForm.name]: fields.\u8F93\u51FA\u5F62\u6001
|
|
18026
|
+
[DOCUMENT_FIELDS.outputForm.name]: fields.\u8F93\u51FA\u5F62\u6001,
|
|
18027
|
+
...fields.\u76EE\u6807\u603B\u5B57\u6570 === void 0 ? {} : { [DOCUMENT_FIELDS.targetTotalWords.name]: fields.\u76EE\u6807\u603B\u5B57\u6570 }
|
|
18009
18028
|
}, `# \u4F5C\u54C1\u5951\u7EA6
|
|
18010
18029
|
|
|
18011
|
-
${labeledHeadings(\u5951\u7EA6\u516D\u90E8, "\u7559\u767D")}`, ["\u4E66id", BOOK_FORMAT_VERSION_FIELD, DOCUMENT_FIELDS.market.name, DOCUMENT_FIELDS.outputForm.name]);
|
|
18030
|
+
${labeledHeadings(\u5951\u7EA6\u516D\u90E8, "\u7559\u767D")}`, ["\u4E66id", BOOK_FORMAT_VERSION_FIELD, DOCUMENT_FIELDS.market.name, DOCUMENT_FIELDS.outputForm.name, ...fields.\u76EE\u6807\u603B\u5B57\u6570 === void 0 ? [] : [DOCUMENT_FIELDS.targetTotalWords.name]]);
|
|
18012
18031
|
}
|
|
18013
18032
|
function emptySkeletonBody() {
|
|
18014
18033
|
return `# \u6545\u4E8B\u9AA8\u67B6
|
|
@@ -18043,7 +18062,8 @@ function scaffoldBookFiles(bookRoot, concept, opts = {}) {
|
|
|
18043
18062
|
const parsedConcept = typeof concept === "string" ? parseConcept(concept) : concept;
|
|
18044
18063
|
const fields = resolveContractFields({
|
|
18045
18064
|
\u5E02\u573A: opts.\u5E02\u573A ?? (parsedConcept === null ? void 0 : marketOf(parsedConcept)),
|
|
18046
|
-
\u8F93\u51FA\u5F62\u6001: opts.\u8F93\u51FA\u5F62\u6001 ?? (parsedConcept === null ? void 0 : outputFormOf(parsedConcept))
|
|
18065
|
+
\u8F93\u51FA\u5F62\u6001: opts.\u8F93\u51FA\u5F62\u6001 ?? (parsedConcept === null ? void 0 : outputFormOf(parsedConcept)),
|
|
18066
|
+
\u76EE\u6807\u603B\u5B57\u6570: opts.\u76EE\u6807\u603B\u5B57\u6570 ?? (parsedConcept === null ? void 0 : targetTotalWordsOf(parsedConcept))
|
|
18047
18067
|
});
|
|
18048
18068
|
const ops = [
|
|
18049
18069
|
{ relPath: paths.\u5951\u7EA6(), content: emptyContractBody(opts.bookId, fields) },
|
|
@@ -19411,6 +19431,9 @@ function createBook(input) {
|
|
|
19411
19431
|
if (input.concept.\u8F93\u51FA\u5F62\u6001 !== void 0 && !isOutputFormValue(input.concept.\u8F93\u51FA\u5F62\u6001)) {
|
|
19412
19432
|
return { ok: false, reason: `\u8F93\u51FA\u5F62\u6001\u53D6\u503C\u975E\u6CD5\uFF1A${String(input.concept.\u8F93\u51FA\u5F62\u6001)}\uFF0C\u53EA\u63A5\u53D7 \u77ED\u5267 / \u7535\u5F71\u5267\u672C / \u5C0F\u8BF4` };
|
|
19413
19433
|
}
|
|
19434
|
+
if (input.concept.\u76EE\u6807\u603B\u5B57\u6570 !== void 0 && !isTargetTotalWordsValue(input.concept.\u76EE\u6807\u603B\u5B57\u6570)) {
|
|
19435
|
+
return { ok: false, reason: `\u76EE\u6807\u603B\u5B57\u6570\u53D6\u503C\u975E\u6CD5\uFF1A${String(input.concept.\u76EE\u6807\u603B\u5B57\u6570)}\uFF0C\u53EA\u63A5\u53D7\u6B63\u6574\u6570\u6C49\u5B57\u6570` };
|
|
19436
|
+
}
|
|
19414
19437
|
try {
|
|
19415
19438
|
return withBookLock(workspaceRoot, () => {
|
|
19416
19439
|
const bookId2 = generateBookId(input.\u4E66\u540D);
|
|
@@ -19421,7 +19444,7 @@ function createBook(input) {
|
|
|
19421
19444
|
try {
|
|
19422
19445
|
fs32.mkdirSync(bookRoot);
|
|
19423
19446
|
created = true;
|
|
19424
|
-
scaffoldBookFiles(bookRoot, input.concept, { bookId: bookId2, \u5E02\u573A: marketOf(input.concept), \u8F93\u51FA\u5F62\u6001: outputFormOf(input.concept) });
|
|
19447
|
+
scaffoldBookFiles(bookRoot, input.concept, { bookId: bookId2, \u5E02\u573A: marketOf(input.concept), \u8F93\u51FA\u5F62\u6001: outputFormOf(input.concept), \u76EE\u6807\u603B\u5B57\u6570: targetTotalWordsOf(input.concept) });
|
|
19425
19448
|
const commit = initFirstCommit(bookRoot);
|
|
19426
19449
|
return { ok: true, bookRoot, bookId: bookId2, commit };
|
|
19427
19450
|
} catch (err) {
|
|
@@ -32083,7 +32106,7 @@ function createBookUpgradeTools(deps) {
|
|
|
32083
32106
|
}
|
|
32084
32107
|
|
|
32085
32108
|
// src/novel-tools.ts
|
|
32086
|
-
import * as
|
|
32109
|
+
import * as fs59 from "node:fs";
|
|
32087
32110
|
import * as nodePath3 from "node:path";
|
|
32088
32111
|
|
|
32089
32112
|
// src/design-commit-result.ts
|
|
@@ -32519,17 +32542,72 @@ function acceptEditorSuggestion(hub, agent, args) {
|
|
|
32519
32542
|
return { ok: true, requestId, delivered: true, message: EDITOR_DELIVERED_MESSAGE };
|
|
32520
32543
|
}
|
|
32521
32544
|
|
|
32522
|
-
//
|
|
32545
|
+
// src/study/onboarding.ts
|
|
32546
|
+
var MARKET_VALUES2 = ["\u6D77\u5916", "\u4E2D\u6587"];
|
|
32547
|
+
var OUTPUT_FORM_VALUES2 = ["\u77ED\u5267", "\u7535\u5F71\u5267\u672C", "\u5C0F\u8BF4"];
|
|
32548
|
+
function isMarketValue2(value) {
|
|
32549
|
+
return typeof value === "string" && MARKET_VALUES2.includes(value);
|
|
32550
|
+
}
|
|
32551
|
+
function isOutputFormValue2(value) {
|
|
32552
|
+
return typeof value === "string" && OUTPUT_FORM_VALUES2.includes(value);
|
|
32553
|
+
}
|
|
32554
|
+
var ONBOARDING_DRAFT_RELATIVE = "\u4E66\u623F/\u6784\u60F3/_\u5F85\u5EFA\u4E66.json";
|
|
32555
|
+
function validateOnboardingAnswers(value) {
|
|
32556
|
+
if (value === null || typeof value !== "object") return {};
|
|
32557
|
+
const record4 = value;
|
|
32558
|
+
const out = {};
|
|
32559
|
+
if (isMarketValue2(record4["\u5E02\u573A"])) out.\u5E02\u573A = record4["\u5E02\u573A"];
|
|
32560
|
+
if (isOutputFormValue2(record4["\u8F93\u51FA\u5F62\u6001"])) out.\u8F93\u51FA\u5F62\u6001 = record4["\u8F93\u51FA\u5F62\u6001"];
|
|
32561
|
+
if (typeof record4["\u76EE\u6807\u603B\u5B57\u6570"] === "number" && Number.isSafeInteger(record4["\u76EE\u6807\u603B\u5B57\u6570"]) && record4["\u76EE\u6807\u603B\u5B57\u6570"] > 0) {
|
|
32562
|
+
out.\u76EE\u6807\u603B\u5B57\u6570 = record4["\u76EE\u6807\u603B\u5B57\u6570"];
|
|
32563
|
+
}
|
|
32564
|
+
return out;
|
|
32565
|
+
}
|
|
32566
|
+
function onboardingMissing(answers) {
|
|
32567
|
+
const missing = [];
|
|
32568
|
+
if (answers.\u5E02\u573A === void 0) missing.push("\u5E02\u573A");
|
|
32569
|
+
if (answers.\u8F93\u51FA\u5F62\u6001 === void 0) missing.push("\u8F93\u51FA\u5F62\u6001");
|
|
32570
|
+
if (answers.\u76EE\u6807\u603B\u5B57\u6570 === void 0) missing.push("\u76EE\u6807\u603B\u5B57\u6570");
|
|
32571
|
+
return missing;
|
|
32572
|
+
}
|
|
32573
|
+
|
|
32574
|
+
// src/study/onboarding-store.ts
|
|
32523
32575
|
import * as fs56 from "node:fs";
|
|
32524
32576
|
import * as path68 from "node:path";
|
|
32577
|
+
function onboardingDraftPath(workspaceRoot) {
|
|
32578
|
+
return path68.join(workspaceRoot, ...ONBOARDING_DRAFT_RELATIVE.split("/"));
|
|
32579
|
+
}
|
|
32580
|
+
function readOnboardingDraft(workspaceRoot) {
|
|
32581
|
+
try {
|
|
32582
|
+
const raw = fs56.readFileSync(onboardingDraftPath(workspaceRoot), "utf-8");
|
|
32583
|
+
return validateOnboardingAnswers(JSON.parse(raw));
|
|
32584
|
+
} catch {
|
|
32585
|
+
return {};
|
|
32586
|
+
}
|
|
32587
|
+
}
|
|
32588
|
+
function saveOnboardingDraft(workspaceRoot, answers) {
|
|
32589
|
+
const target = onboardingDraftPath(workspaceRoot);
|
|
32590
|
+
fs56.mkdirSync(path68.dirname(target), { recursive: true });
|
|
32591
|
+
fs56.writeFileSync(target, JSON.stringify({ ...answers, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
|
|
32592
|
+
}
|
|
32593
|
+
function consumeOnboardingDraft(workspaceRoot) {
|
|
32594
|
+
try {
|
|
32595
|
+
fs56.unlinkSync(onboardingDraftPath(workspaceRoot));
|
|
32596
|
+
} catch {
|
|
32597
|
+
}
|
|
32598
|
+
}
|
|
32525
32599
|
|
|
32526
|
-
// ../drafting/src/
|
|
32600
|
+
// ../drafting/src/context.ts
|
|
32527
32601
|
import * as fs57 from "node:fs";
|
|
32528
32602
|
import * as path69 from "node:path";
|
|
32603
|
+
|
|
32604
|
+
// ../drafting/src/write.ts
|
|
32605
|
+
import * as fs58 from "node:fs";
|
|
32606
|
+
import * as path70 from "node:path";
|
|
32529
32607
|
var DRAFT_KEYS = ["\u8EAB\u4EFD", "\u7248\u672C", "\u7236\u7248\u672C", "\u751F\u6210\u6A21\u5757", "\u6765\u6E90\u5FEB\u7167", "\u89D2\u8272", "\u9009\u5B9A"];
|
|
32530
32608
|
function readText12(root, rel) {
|
|
32531
32609
|
try {
|
|
32532
|
-
return
|
|
32610
|
+
return fs58.readFileSync(path70.join(root, rel), "utf-8");
|
|
32533
32611
|
} catch {
|
|
32534
32612
|
return null;
|
|
32535
32613
|
}
|
|
@@ -32538,9 +32616,9 @@ function draftDir(key) {
|
|
|
32538
32616
|
return paths.\u8349\u7A3F\u76EE\u5F55(key.\u5377, key.\u7AE0\u540D);
|
|
32539
32617
|
}
|
|
32540
32618
|
function listDraftFiles(bookRoot, key) {
|
|
32541
|
-
const abs =
|
|
32542
|
-
if (!
|
|
32543
|
-
return
|
|
32619
|
+
const abs = path70.join(bookRoot, draftDir(key));
|
|
32620
|
+
if (!fs58.existsSync(abs) || !fs58.statSync(abs).isDirectory()) return [];
|
|
32621
|
+
return fs58.readdirSync(abs).filter((f) => f.endsWith(".md")).sort((a, b) => a.localeCompare(b, "zh"));
|
|
32544
32622
|
}
|
|
32545
32623
|
function parseDraftNo(file) {
|
|
32546
32624
|
const m = /^稿(\d+)\.md$/.exec(file);
|
|
@@ -32549,7 +32627,7 @@ function parseDraftNo(file) {
|
|
|
32549
32627
|
function latestVersion(bookRoot, key) {
|
|
32550
32628
|
let max = null;
|
|
32551
32629
|
for (const file of listDraftFiles(bookRoot, key)) {
|
|
32552
|
-
const text5 = readText12(bookRoot,
|
|
32630
|
+
const text5 = readText12(bookRoot, path70.posix.join(draftDir(key), file));
|
|
32553
32631
|
if (text5 === null) continue;
|
|
32554
32632
|
const doc = parseDocument(text5);
|
|
32555
32633
|
if (!doc.ok) continue;
|
|
@@ -32576,7 +32654,7 @@ function selectDraftLocked(bookRoot, input) {
|
|
|
32576
32654
|
const files = listDraftFiles(bookRoot, input);
|
|
32577
32655
|
if (!files.includes(target)) return { ok: false, reason: `\u8349\u7A3F\u4E0D\u5B58\u5728:${target}` };
|
|
32578
32656
|
for (const file of files) {
|
|
32579
|
-
const rel =
|
|
32657
|
+
const rel = path70.posix.join(dir, file);
|
|
32580
32658
|
const text5 = readText12(bookRoot, rel);
|
|
32581
32659
|
if (text5 === null) continue;
|
|
32582
32660
|
const doc = parseDocument(text5);
|
|
@@ -32600,7 +32678,7 @@ function writeDraftLocked(bookRoot, input) {
|
|
|
32600
32678
|
const parent = latestVersion(bookRoot, key);
|
|
32601
32679
|
const ver = parent === null ? initialVersion("\u5199\u7A3F") : bumpVersion(parent, "\u5199\u7A3F");
|
|
32602
32680
|
const file = nextFileName(bookRoot, key);
|
|
32603
|
-
const relPath =
|
|
32681
|
+
const relPath = path70.posix.join(draftDir(key), file);
|
|
32604
32682
|
const fields = applyVersionFields(
|
|
32605
32683
|
{
|
|
32606
32684
|
\u8EAB\u4EFD: { \u5377: input.\u5377, \u7AE0: input.\u7AE0, \u7AE0\u540D: input.\u7AE0\u540D },
|
|
@@ -32632,7 +32710,7 @@ function importAuthorDraftLocked(bookRoot, input) {
|
|
|
32632
32710
|
const explicitParent = input.\u7236\u7248\u672C ?? latestVersion(bookRoot, key);
|
|
32633
32711
|
const ver = explicitParent === null ? initialVersion("\u4F5C\u8005\u7A3F\u5BFC\u5165") : bumpVersion(explicitParent, "\u4F5C\u8005\u7A3F\u5BFC\u5165");
|
|
32634
32712
|
const file = nextFileName(bookRoot, key);
|
|
32635
|
-
const relPath =
|
|
32713
|
+
const relPath = path70.posix.join(draftDir(key), file);
|
|
32636
32714
|
if (input.\u89D2\u8272 === "\u5F85\u5BA1\u7A3F") demoteOtherPendingDrafts(bookRoot, key, relPath);
|
|
32637
32715
|
const fields = applyVersionFields(
|
|
32638
32716
|
{
|
|
@@ -32788,13 +32866,14 @@ function createNovelTools(deps) {
|
|
|
32788
32866
|
},
|
|
32789
32867
|
{
|
|
32790
32868
|
name: "novel_create_book",
|
|
32791
|
-
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\
|
|
32869
|
+
description: "\u65B0\u5EFA\u4E00\u90E8\u957F\u7BC7\u5C0F\u8BF4\u5E76\u521D\u59CB\u5316\u89C4\u8303\u4E66\u4ED3\u3002\u524D\u7F6E\u8981\u6C42\uFF1A\u4E03\u4E2A\u6784\u60F3\u5B57\u6BB5\u9F50\u5168\u3001\u6838\u5FC3\u521B\u610F\u4E0E\u9898\u6750\u76EE\u6807\u8BFB\u8005\u660E\u786E\uFF0C\u5176\u4F59\u53EF\u7559\u767D\uFF1B\u4F5C\u8005\u5DF2\u786E\u8BA4\u7ACB\u9879\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u95EE\u4F5C\u8005\u4E09\u4E2A\u95EE\u9898\u518D\u8C03\uFF0C\u7F3A\u4EFB\u4F55\u4E00\u4E2A\u90FD\u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF1A\u8FD9\u4E2A\u9879\u76EE\u9762\u5411\u6D77\u5916\u8FD8\u662F\u4E2D\u6587\u5E02\u573A\uFF08\u5E02\u573A\uFF09\uFF0C\u8981\u51FA\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u8FD8\u662F\u5C0F\u8BF4\uFF08\u8F93\u51FA\u5F62\u6001\uFF09\uFF0C\u8FD9\u672C\u4E66\u76EE\u6807\u5199\u591A\u5C11\u5B57\uFF08\u76EE\u6807\u603B\u5B57\u6570\uFF0C\u6C49\u5B57\u6570\uFF09\u3002\u4E09\u4E2A\u503C\u7F3A\u4E00\u4E0D\u53EF\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u201C\u5C31\u6309\u9ED8\u8BA4\u6765\u201D\u624D\u4F20\u9ED8\u8BA4\uFF08\u4E2D\u6587 / \u5C0F\u8BF4 / 100\u4E07\u5B57\uFF09\uFF0C\u4E0D\u8981\u7528\u9ED8\u8BA4\u503C\u6084\u6084\u5EFA\u4E66\u3002\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF0C\u9009\u597D\u540E\u4E0D\u7528\u5728\u804A\u5929\u91CC\u518D\u95EE\u3002",
|
|
32792
32870
|
parameters: {
|
|
32793
32871
|
type: "object",
|
|
32794
32872
|
properties: {
|
|
32795
32873
|
bookName: { type: "string", description: "\u5C0F\u8BF4\u4E66\u540D\uFF08\u4E0D\u53EF\u542B\u8DEF\u5F84\u5B57\u7B26\u4E0E\u4FDD\u7559\u5B57\uFF09" },
|
|
32796
|
-
\u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\uFF08\u6D77\u5916\u9898\u6750\u5E93\uFF09\u6216\u4E2D\u6587\uFF08\u4E2D\u6587\u9898\u6750\u5E93\uFF09\
|
|
32797
|
-
\u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\
|
|
32874
|
+
\u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\uFF08\u6D77\u5916\u9898\u6750\u5E93\uFF09\u6216\u4E2D\u6587\uFF08\u4E2D\u6587\u9898\u6750\u5E93\uFF09\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20\u4E2D\u6587\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
|
|
32875
|
+
\u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20\u5C0F\u8BF4\u3002\u77ED\u5267\u8D70\u6309\u96C6\u6D41\u6C34\u7EBF\uFF0C\u7535\u5F71\u5267\u672C\u8D70\u5267\u672C\u6D41\u6C34\u7EBF\uFF0C\u5C0F\u8BF4\u8D70\u539F\u957F\u7BC7\u6D41\u6C34\u7EBF\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
|
|
32876
|
+
\u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF09\u3002\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1B\u4F5C\u8005\u660E\u786E\u8BF4\u6309\u9ED8\u8BA4\u624D\u4F20 1000000\uFF08\u957F\u7BC7\uFF09\u3002\u9876\u5C42\u53C2\u6570\u4F18\u5148\u4E8E concept \u91CC\u7684\u540C\u540D\u5B57\u6BB5\u3002" },
|
|
32798
32877
|
concept: {
|
|
32799
32878
|
type: "object",
|
|
32800
32879
|
description: "\u4F5C\u54C1\u6784\u60F3\u4E03\u8981\u7D20\uFF08\u72B6\u6001\u5FC5\u987B\u4E3A\u5DF2\u786E\u8BA4\uFF09",
|
|
@@ -32807,8 +32886,9 @@ function createNovelTools(deps) {
|
|
|
32807
32886
|
\u6838\u5FC3\u770B\u70B9: { type: "string" },
|
|
32808
32887
|
\u5DEE\u5F02\u5316\u65B9\u5411: { type: "string" },
|
|
32809
32888
|
\u660E\u786E\u4E0D\u8981\u4EC0\u4E48: { type: "string" },
|
|
32810
|
-
\u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\u6216\u4E2D\u6587\uFF1B\
|
|
32811
|
-
\u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\uFF1B\
|
|
32889
|
+
\u5E02\u573A: { type: "string", enum: [...MARKET_VALUES], description: "\u76EE\u6807\u5E02\u573A\uFF1A\u6D77\u5916\u6216\u4E2D\u6587\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" },
|
|
32890
|
+
\u8F93\u51FA\u5F62\u6001: { type: "string", enum: [...OUTPUT_FORM_VALUES], description: "\u8F93\u51FA\u5F62\u6001\uFF1A\u77ED\u5267\u3001\u7535\u5F71\u5267\u672C\u6216\u5C0F\u8BF4\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" },
|
|
32891
|
+
\u76EE\u6807\u603B\u5B57\u6570: { type: "integer", minimum: 1, description: "\u76EE\u6807\u603B\u5B57\u6570\uFF08\u6C49\u5B57\u6570\uFF0C\u6B63\u6574\u6570\uFF09\uFF1B\u5EFA\u4E66\u524D\u5FC5\u987B\u786E\u8BA4\uFF0C\u7F3A\u4E86\u4F1A\u88AB\u62D2\u7EDD" }
|
|
32812
32892
|
},
|
|
32813
32893
|
required: ["\u72B6\u6001", "\u6838\u5FC3\u521B\u610F", "\u9898\u6750\u4E0E\u76EE\u6807\u8BFB\u8005", "\u4E3B\u89D2\u6838\u5FC3\u6B32\u671B", "\u4E3B\u8981\u51B2\u7A81", "\u6838\u5FC3\u770B\u70B9", "\u5DEE\u5F02\u5316\u65B9\u5411", "\u660E\u786E\u4E0D\u8981\u4EC0\u4E48"]
|
|
32814
32894
|
}
|
|
@@ -32834,13 +32914,24 @@ function createNovelTools(deps) {
|
|
|
32834
32914
|
if (root === void 0) return toolFailure("host-unavailable", "\u5DE5\u4F5C\u8303\u56F4\u672A\u5C31\u7EEA\uFF1A\u5DE5\u4F5C\u53F0\u8FD8\u6CA1\u6709\u52A0\u8F7D\u5DE5\u4F5C\u533A");
|
|
32835
32915
|
const bookName = String(args["bookName"]).trim();
|
|
32836
32916
|
const concept = args["concept"];
|
|
32837
|
-
const
|
|
32838
|
-
const \
|
|
32839
|
-
|
|
32840
|
-
|
|
32841
|
-
|
|
32842
|
-
|
|
32843
|
-
|
|
32917
|
+
const draft = readOnboardingDraft(root);
|
|
32918
|
+
const \u5E02\u573A = args["\u5E02\u573A"] ?? concept.\u5E02\u573A ?? draft.\u5E02\u573A;
|
|
32919
|
+
const \u8F93\u51FA\u5F62\u6001 = args["\u8F93\u51FA\u5F62\u6001"] ?? concept.\u8F93\u51FA\u5F62\u6001 ?? draft.\u8F93\u51FA\u5F62\u6001;
|
|
32920
|
+
const rawWords = args["\u76EE\u6807\u603B\u5B57\u6570"] ?? concept.\u76EE\u6807\u603B\u5B57\u6570 ?? draft.\u76EE\u6807\u603B\u5B57\u6570;
|
|
32921
|
+
const \u76EE\u6807\u603B\u5B57\u6570 = typeof rawWords === "string" ? Number(rawWords) : rawWords;
|
|
32922
|
+
const missing = onboardingMissing({ \u5E02\u573A, \u8F93\u51FA\u5F62\u6001, \u76EE\u6807\u603B\u5B57\u6570 });
|
|
32923
|
+
if (missing.length > 0) {
|
|
32924
|
+
return toolFailure(
|
|
32925
|
+
"invalid-argument",
|
|
32926
|
+
`\u5EFA\u4E66\u524D\u5FC5\u987B\u5148\u786E\u8BA4${missing.join("\u3001")}\uFF0C\u7F3A\u4E86\u4E0D\u80FD\u5EFA\u4E66\u3002`,
|
|
32927
|
+
`\u5148\u95EE\u4F5C\u8005\uFF08\u540C\u4E00\u6761\u6D88\u606F\u4E00\u6B21\u95EE\u5B8C\uFF0C\u5404\u7ED9\u9009\u9879\uFF1B\u4F5C\u8005\u4E5F\u53EF\u4EE5\u5728\u4E66\u623F\u9762\u677F\u70B9\u201C\u65B0\u5EFA\u4E66\u201D\u76F4\u63A5\u70B9\u9009\uFF0C\u9009\u597D\u540E\u76F4\u63A5\u91CD\u8C03\u672C\u5DE5\u5177\uFF09\uFF1A\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 5. \u81EA\u5DF1\u6709\u60F3\u6CD5\uFF0C\u624B\u52A8\u8F93\u5165\u5177\u4F53\u6570\u5B57\uFF09\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`
|
|
32928
|
+
);
|
|
32929
|
+
}
|
|
32930
|
+
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`);
|
|
32931
|
+
if (\u8F93\u51FA\u5F62\u6001 !== void 0 && !isOutputFormValue(\u8F93\u51FA\u5F62\u6001)) return toolFailure("invalid-argument", `\u8F93\u51FA\u5F62\u6001\u53D6\u503C\u975E\u6CD5\uFF1A${String(\u8F93\u51FA\u5F62\u6001)}\uFF0C\u53EA\u63A5\u53D7 \u77ED\u5267 / \u7535\u5F71\u5267\u672C / \u5C0F\u8BF4`);
|
|
32932
|
+
if (!isTargetTotalWordsValue(\u76EE\u6807\u603B\u5B57\u6570)) return toolFailure("invalid-argument", `\u76EE\u6807\u603B\u5B57\u6570\u53D6\u503C\u975E\u6CD5\uFF1A${String(\u76EE\u6807\u603B\u5B57\u6570)}\uFF0C\u53EA\u63A5\u53D7\u6B63\u6574\u6570\u6C49\u5B57\u6570`);
|
|
32933
|
+
const res = createBook({ workspaceRoot: root, \u4E66\u540D: bookName, concept: { ...concept, \u5E02\u573A, \u8F93\u51FA\u5F62\u6001, \u76EE\u6807\u603B\u5B57\u6570 } });
|
|
32934
|
+
if (res.ok) consumeOnboardingDraft(root);
|
|
32844
32935
|
return res;
|
|
32845
32936
|
}
|
|
32846
32937
|
},
|
|
@@ -32955,7 +33046,7 @@ function createNovelTools(deps) {
|
|
|
32955
33046
|
paths.\u5377\u7EB2(\u5377),
|
|
32956
33047
|
paths.\u8BA1\u5212\u65F6\u95F4\u7EBF(\u5377),
|
|
32957
33048
|
paths.\u8FD1\u671F\u7A97\u53E3(\u5377)
|
|
32958
|
-
].filter((p) =>
|
|
33049
|
+
].filter((p) => fs59.existsSync(nodePath3.join(bookRoot, p)));
|
|
32959
33050
|
const commit = commitConfirmed({ bookRoot, paths: seedPaths, prefix: "design", summary: "\u6700\u5C0F\u8BBE\u8BA1\u9AA8\u67B6", provenance: provenanceOf(sessionContext, seedPaths) });
|
|
32960
33051
|
if (!commit.ok) {
|
|
32961
33052
|
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}` };
|
|
@@ -33551,7 +33642,7 @@ function createNovelTools(deps) {
|
|
|
33551
33642
|
const rel = paths.\u8FD1\u671F\u7A97\u53E3(\u5377);
|
|
33552
33643
|
let text5 = "";
|
|
33553
33644
|
try {
|
|
33554
|
-
text5 =
|
|
33645
|
+
text5 = fs59.readFileSync(nodePath3.join(book.bookRoot, rel), "utf-8");
|
|
33555
33646
|
} catch {
|
|
33556
33647
|
text5 = "";
|
|
33557
33648
|
}
|
|
@@ -34247,7 +34338,7 @@ function createNovelTools(deps) {
|
|
|
34247
34338
|
const res = archiveRetconRequest({ bookRoot, chapter: \u5B9A\u7A3F\u76F8\u5BF9, request, provenance: provenanceOf(sessionContext) }, (plannedPackageDir) => {
|
|
34248
34339
|
let \u66F4\u6B63\u540E\u5168\u6587;
|
|
34249
34340
|
try {
|
|
34250
|
-
const src =
|
|
34341
|
+
const src = fs59.readFileSync(nodePath3.join(bookRoot, \u5B9A\u7A3F\u76F8\u5BF9), "utf-8");
|
|
34251
34342
|
const doc = parseDocument(src);
|
|
34252
34343
|
if (!doc.ok) return { ok: false, reason: `\u5B9A\u7A3F\u7AE0\u89E3\u6790\u5931\u8D25\uFF1A${doc.detail}` };
|
|
34253
34344
|
const parent = extractVersionFields(doc.data.fields).\u7248\u672C;
|
|
@@ -34275,19 +34366,19 @@ function createNovelTools(deps) {
|
|
|
34275
34366
|
const value = optionalText(f);
|
|
34276
34367
|
return value === null ? [] : [[\u5019\u9009\u6587\u4EF6[f], value]];
|
|
34277
34368
|
}));
|
|
34278
|
-
if (
|
|
34279
|
-
for (const name3 of
|
|
34369
|
+
if (fs59.existsSync(\u5305\u7EDD\u5BF9)) {
|
|
34370
|
+
for (const name3 of fs59.readdirSync(\u5305\u7EDD\u5BF9)) {
|
|
34280
34371
|
const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
|
|
34281
|
-
const stat =
|
|
34282
|
-
if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() ||
|
|
34372
|
+
const stat = fs59.lstatSync(file);
|
|
34373
|
+
if (!contents.has(name3) || !stat.isFile() || stat.isSymbolicLink() || fs59.readFileSync(file, "utf8") !== contents.get(name3)) {
|
|
34283
34374
|
return { ok: false, reason: "\u8865\u507F\u5305\u5019\u9009\u51B2\u7A81\uFF0C\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6838\u5BF9\u540E\u5904\u7406" };
|
|
34284
34375
|
}
|
|
34285
34376
|
}
|
|
34286
34377
|
}
|
|
34287
|
-
|
|
34378
|
+
fs59.mkdirSync(\u5305\u7EDD\u5BF9, { recursive: true });
|
|
34288
34379
|
for (const [name3, value] of contents) {
|
|
34289
34380
|
const file = nodePath3.join(\u5305\u7EDD\u5BF9, name3);
|
|
34290
|
-
if (!
|
|
34381
|
+
if (!fs59.existsSync(file)) fs59.writeFileSync(file, value, { encoding: "utf8", flag: "wx" });
|
|
34291
34382
|
}
|
|
34292
34383
|
packageDir = \u5305\u76F8\u5BF9;
|
|
34293
34384
|
}
|
|
@@ -34308,7 +34399,7 @@ function createNovelTools(deps) {
|
|
|
34308
34399
|
retconFiles.push({ \u76EE\u6807: \u6458\u8981\u76F8\u5BF9, \u5185\u5BB9: request.\u66F4\u6B63\u540E\u7AE0\u6458\u8981 });
|
|
34309
34400
|
} else {
|
|
34310
34401
|
try {
|
|
34311
|
-
const \u6458\u8981\u73B0\u6587 =
|
|
34402
|
+
const \u6458\u8981\u73B0\u6587 = fs59.readFileSync(nodePath3.join(bookRoot, \u6458\u8981\u76F8\u5BF9), "utf-8");
|
|
34312
34403
|
retconFiles.push({
|
|
34313
34404
|
\u76EE\u6807: \u6458\u8981\u76F8\u5BF9,
|
|
34314
34405
|
\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")})
|
|
@@ -34765,8 +34856,8 @@ function finishDesignCommit(bookRoot, writtenPaths, args, defaultSummary, chapte
|
|
|
34765
34856
|
import { boundContextSummary, createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
|
|
34766
34857
|
|
|
34767
34858
|
// src/study/service.ts
|
|
34768
|
-
import * as
|
|
34769
|
-
import * as
|
|
34859
|
+
import * as fs62 from "node:fs";
|
|
34860
|
+
import * as path73 from "node:path";
|
|
34770
34861
|
|
|
34771
34862
|
// ../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
|
|
34772
34863
|
var Diff = class {
|
|
@@ -34868,16 +34959,16 @@ var Diff = class {
|
|
|
34868
34959
|
}
|
|
34869
34960
|
}
|
|
34870
34961
|
}
|
|
34871
|
-
addToPath(
|
|
34872
|
-
const last =
|
|
34962
|
+
addToPath(path80, added, removed, oldPosInc, options2) {
|
|
34963
|
+
const last = path80.lastComponent;
|
|
34873
34964
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
34874
34965
|
return {
|
|
34875
|
-
oldPos:
|
|
34966
|
+
oldPos: path80.oldPos + oldPosInc,
|
|
34876
34967
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
34877
34968
|
};
|
|
34878
34969
|
} else {
|
|
34879
34970
|
return {
|
|
34880
|
-
oldPos:
|
|
34971
|
+
oldPos: path80.oldPos + oldPosInc,
|
|
34881
34972
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
34882
34973
|
};
|
|
34883
34974
|
}
|
|
@@ -35068,7 +35159,7 @@ var text4 = (value) => typeof value === "string" ? value : "";
|
|
|
35068
35159
|
var terms = (value) => Array.isArray(value) ? value.flatMap(terms) : typeof value === "string" ? value.split(/[、,,;]/).map((item) => item.trim()).filter(Boolean) : [];
|
|
35069
35160
|
var wiki = (body) => [...body.matchAll(/\[\[([^\]\n]+)\]\]/g)].map((match) => match[1].split("|")[0].trim());
|
|
35070
35161
|
var identity3 = (name3) => name3.trim().replace(/[\s「」『』【】()()::,,。!?!?]/g, "").toLowerCase();
|
|
35071
|
-
var kindOf = (
|
|
35162
|
+
var kindOf = (path80, declared) => typeof declared === "string" && declared.trim() ? { \u4EBA\u7269\u6863\u6848: "\u4EBA\u7269", \u4EBA\u7269\u5173\u7CFB: "\u5173\u7CFB", \u7EC4\u7EC7\u4E0E\u9635\u8425: "\u7EC4\u7EC7", \u5730\u70B9\u4E0E\u7A7A\u95F4: "\u5730\u70B9" }[declared.trim()] ?? declared.trim() : path80.includes("/\u4EBA\u7269\u6863\u6848/") ? "\u4EBA\u7269" : path80.includes("/\u4EBA\u7269\u5173\u7CFB/") ? "\u5173\u7CFB" : path80.includes("/\u7EC4\u7EC7\u4E0E\u9635\u8425/") ? "\u7EC4\u7EC7" : path80.includes("/\u5730\u70B9\u4E0E\u7A7A\u95F4/") ? "\u5730\u70B9" : "\u8BBE\u5B9A";
|
|
35072
35163
|
function readStoryGraph(source2) {
|
|
35073
35164
|
const records = [], edges = [], events = [];
|
|
35074
35165
|
const warnings = [];
|
|
@@ -35100,7 +35191,7 @@ function readStoryGraph(source2) {
|
|
|
35100
35191
|
aliases.set(name3, values);
|
|
35101
35192
|
};
|
|
35102
35193
|
const strings = (fields) => Object.fromEntries(Object.entries(fields).filter((pair) => typeof pair[1] === "string"));
|
|
35103
|
-
const fromFields = (id, label2, kind2,
|
|
35194
|
+
const fromFields = (id, label2, kind2, path80, line, fields, body) => ({
|
|
35104
35195
|
id,
|
|
35105
35196
|
label: label2,
|
|
35106
35197
|
kind: kind2,
|
|
@@ -35109,23 +35200,23 @@ function readStoryGraph(source2) {
|
|
|
35109
35200
|
chapter: chapter(fields["\u8D77\u59CB\u7AE0"]) ?? chapter(fields["\u751F\u6548\u7AE0"]) ?? chapter(fields["\u7AE0\u53F7"]) ?? entryChapterNo({ \u5B57\u6BB5: strings(fields) }) ?? void 0,
|
|
35110
35201
|
endChapter: chapter(fields["\u5931\u6548\u7AE0"]),
|
|
35111
35202
|
revealChapter: chapter(fields["\u62AB\u9732\u7AE0"]) ?? chapter(fields["\u63ED\u793A\u7AE0"]),
|
|
35112
|
-
source: { space: "book:" + source2.bookId, path:
|
|
35203
|
+
source: { space: "book:" + source2.bookId, path: path80 },
|
|
35113
35204
|
line,
|
|
35114
35205
|
preview: body.trim().slice(0, 600),
|
|
35115
35206
|
// Expose authored scalar/list field names as grouping choices without
|
|
35116
35207
|
// guessing whether 宗门/血脉/师承 means faction, family or another identity.
|
|
35117
35208
|
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 })))
|
|
35118
35209
|
});
|
|
35119
|
-
const scan = (
|
|
35210
|
+
const scan = (path80, depth = 0) => {
|
|
35120
35211
|
if (depth > 12) {
|
|
35121
|
-
warnings.push({ path:
|
|
35212
|
+
warnings.push({ path: path80, message: "\u76EE\u5F55\u5C42\u7EA7\u8FC7\u6DF1\uFF0C\u672A\u7EE7\u7EED\u8BFB\u53D6" });
|
|
35122
35213
|
return;
|
|
35123
35214
|
}
|
|
35124
35215
|
let entries;
|
|
35125
35216
|
try {
|
|
35126
|
-
entries = source2.list(
|
|
35217
|
+
entries = source2.list(path80);
|
|
35127
35218
|
} catch (error) {
|
|
35128
|
-
if (error.code !== "not-found") warnings.push({ path:
|
|
35219
|
+
if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u76EE\u5F55\u65E0\u6CD5\u8BFB\u53D6" });
|
|
35129
35220
|
return;
|
|
35130
35221
|
}
|
|
35131
35222
|
for (const entry of entries) {
|
|
@@ -35216,26 +35307,26 @@ function readStoryGraph(source2) {
|
|
|
35216
35307
|
};
|
|
35217
35308
|
scan("\u4E16\u754C\u4E66");
|
|
35218
35309
|
for (const category of LEDGER_NAMES) {
|
|
35219
|
-
const
|
|
35310
|
+
const path80 = "\u8D26\u672C/" + category + ".md";
|
|
35220
35311
|
let raw;
|
|
35221
35312
|
try {
|
|
35222
|
-
raw = source2.read(
|
|
35313
|
+
raw = source2.read(path80);
|
|
35223
35314
|
} catch (error) {
|
|
35224
|
-
if (error.code !== "not-found") warnings.push({ path:
|
|
35315
|
+
if (error.code !== "not-found") warnings.push({ path: path80, message: "\u8BE5\u8D26\u672C\u65E0\u6CD5\u8BFB\u53D6" });
|
|
35225
35316
|
continue;
|
|
35226
35317
|
}
|
|
35227
35318
|
const ranges2 = createEvidenceRanges(raw);
|
|
35228
|
-
sourceHashes[
|
|
35229
|
-
const parsed = parseLedgerHistory(raw, category,
|
|
35319
|
+
sourceHashes[path80] = ranges2.hash;
|
|
35320
|
+
const parsed = parseLedgerHistory(raw, category, path80);
|
|
35230
35321
|
if (!parsed.ok) {
|
|
35231
|
-
warnings.push({ path:
|
|
35322
|
+
warnings.push({ path: path80, message: parsed.reason });
|
|
35232
35323
|
continue;
|
|
35233
35324
|
}
|
|
35234
35325
|
for (const [index, entry] of parsed.entries.entries()) {
|
|
35235
|
-
const id = category === "\u65F6\u95F4\u7EBF" ? "event:" +
|
|
35326
|
+
const id = category === "\u65F6\u95F4\u7EBF" ? "event:" + path80 + ":" + entry.\u884C\u53F7 : "ledger:" + category + ":" + identity3(entry.\u540D\u79F0);
|
|
35236
35327
|
const content = category === "\u65F6\u95F4\u7EBF" ? renderTimelineContent(entry) : entry.\u6B63\u6587;
|
|
35237
35328
|
const evidenceId = id + ":" + entry.\u884C\u53F7;
|
|
35238
|
-
const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category,
|
|
35329
|
+
const base = fromFields(id, entry.\u540D\u79F0, category === "\u65F6\u95F4\u7EBF" ? "\u4E8B\u4EF6" : category, path80, entry.\u884C\u53F7, entry.\u5B57\u6BB5, content);
|
|
35239
35330
|
const recordChapter2 = entryChapterNo(entry) ?? void 0;
|
|
35240
35331
|
const storyTime = category === "\u65F6\u95F4\u7EBF" ? timelineStoryTime(entry) : void 0;
|
|
35241
35332
|
const record4 = { ...base, recordChapter: recordChapter2, storyTime, historyBasis: recordChapter2 ? "recorded" : "unknown", evidenceId };
|
|
@@ -35256,11 +35347,11 @@ function readStoryGraph(source2) {
|
|
|
35256
35347
|
links.push({ record: record4, targets: wiki(content), pair: false });
|
|
35257
35348
|
}
|
|
35258
35349
|
}
|
|
35259
|
-
const resolve22 = (target,
|
|
35350
|
+
const resolve22 = (target, path80) => {
|
|
35260
35351
|
const name3 = target.replace(/^\[\[|\]\]$/g, "").replace(/@\d+$/, "").replace(/\\/g, "/");
|
|
35261
35352
|
const found = aliases.get(name3);
|
|
35262
35353
|
if (found?.size === 1) return [...found][0];
|
|
35263
|
-
warnings.push({ path:
|
|
35354
|
+
warnings.push({ path: path80, message: found?.size ? "\u540C\u540D\u6216\u522B\u540D\u4E0D\u552F\u4E00\uFF0C\u672A\u5408\u5E76\uFF1A" + name3 : "\u5F15\u7528\u672A\u627E\u5230\u5BF9\u5E94\u5B9E\u4F53\uFF1A" + name3 });
|
|
35264
35355
|
return void 0;
|
|
35265
35356
|
};
|
|
35266
35357
|
for (const item of links) {
|
|
@@ -35284,32 +35375,32 @@ function readStoryGraph(source2) {
|
|
|
35284
35375
|
const currentBound = (items) => items.map((item) => item.currentOnlyAt === void 0 ? item : { ...item, currentOnlyAt: maxChapter });
|
|
35285
35376
|
const withChapters = evidence.map((item) => {
|
|
35286
35377
|
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));
|
|
35287
|
-
return { ...item, relatedChapters: [...new Set(references)].map((
|
|
35378
|
+
return { ...item, relatedChapters: [...new Set(references)].map((path80) => ({ space: item.source.space, path: path80 })) };
|
|
35288
35379
|
});
|
|
35289
35380
|
return { bookId: source2.bookId, bookName: source2.bookName, maxChapter, records: currentBound(records), edges: currentBound(edges), events, warnings, evidence: withChapters, entities, sourceHashes, fingerprint: fingerprint2, format: format2 };
|
|
35290
35381
|
}
|
|
35291
35382
|
|
|
35292
35383
|
// src/study/graph-source.ts
|
|
35293
|
-
import * as
|
|
35294
|
-
import * as
|
|
35384
|
+
import * as fs60 from "node:fs";
|
|
35385
|
+
import * as path71 from "node:path";
|
|
35295
35386
|
import { createHash as createHash20 } from "node:crypto";
|
|
35296
35387
|
function readGraphFile(base, relative12) {
|
|
35297
35388
|
validateAuthorRelativePath(relative12);
|
|
35298
|
-
const file =
|
|
35389
|
+
const file = path71.join(base, relative12);
|
|
35299
35390
|
const checkPhysical = () => {
|
|
35300
|
-
if (stripDevicePrefix(
|
|
35391
|
+
if (stripDevicePrefix(fs60.realpathSync.native(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
|
|
35301
35392
|
};
|
|
35302
35393
|
checkPhysical();
|
|
35303
|
-
const initial =
|
|
35394
|
+
const initial = fs60.lstatSync(file);
|
|
35304
35395
|
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");
|
|
35305
35396
|
if (initial.size > 4 * 1024 * 1024) throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u8D85\u8FC74MiB\uFF0C\u672A\u622A\u65AD\u8BFB\u53D6");
|
|
35306
|
-
const descriptor =
|
|
35397
|
+
const descriptor = fs60.openSync(file, fs60.constants.O_RDONLY | (fs60.constants.O_NOFOLLOW ?? 0));
|
|
35307
35398
|
try {
|
|
35308
|
-
const opened =
|
|
35399
|
+
const opened = fs60.fstatSync(descriptor);
|
|
35309
35400
|
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");
|
|
35310
|
-
const bytes =
|
|
35401
|
+
const bytes = fs60.readFileSync(descriptor);
|
|
35311
35402
|
checkPhysical();
|
|
35312
|
-
const current =
|
|
35403
|
+
const current = fs60.lstatSync(file), finished = fs60.fstatSync(descriptor);
|
|
35313
35404
|
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");
|
|
35314
35405
|
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");
|
|
35315
35406
|
try {
|
|
@@ -35318,26 +35409,26 @@ function readGraphFile(base, relative12) {
|
|
|
35318
35409
|
throw new AuthorDocumentError("read-only", "\u56FE\u8C31\u6765\u6E90\u5FC5\u987B\u4F7F\u7528UTF-8");
|
|
35319
35410
|
}
|
|
35320
35411
|
} finally {
|
|
35321
|
-
|
|
35412
|
+
fs60.closeSync(descriptor);
|
|
35322
35413
|
}
|
|
35323
35414
|
}
|
|
35324
35415
|
async function readGraphFileAsync(base, relative12, signal) {
|
|
35325
35416
|
signal?.throwIfAborted();
|
|
35326
35417
|
validateAuthorRelativePath(relative12);
|
|
35327
|
-
const file =
|
|
35418
|
+
const file = path71.join(base, relative12);
|
|
35328
35419
|
const checkPhysical = async () => {
|
|
35329
|
-
if (stripDevicePrefix(await
|
|
35420
|
+
if (stripDevicePrefix(await fs60.promises.realpath(file)) !== file) throw new AuthorDocumentError("invalid-path", "\u56FE\u8C31\u6765\u6E90\u8DEF\u5F84\u5305\u542B\u94FE\u63A5\u6216\u522B\u540D");
|
|
35330
35421
|
};
|
|
35331
35422
|
await checkPhysical();
|
|
35332
|
-
const initial = await
|
|
35423
|
+
const initial = await fs60.promises.lstat(file);
|
|
35333
35424
|
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");
|
|
35334
|
-
const handle = await
|
|
35425
|
+
const handle = await fs60.promises.open(file, fs60.constants.O_RDONLY | (fs60.constants.O_NOFOLLOW ?? 0));
|
|
35335
35426
|
try {
|
|
35336
35427
|
const opened = await handle.stat();
|
|
35337
35428
|
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");
|
|
35338
35429
|
const bytes = await handle.readFile({ signal });
|
|
35339
35430
|
await checkPhysical();
|
|
35340
|
-
const current = await
|
|
35431
|
+
const current = await fs60.promises.lstat(file), finished = await handle.stat();
|
|
35341
35432
|
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");
|
|
35342
35433
|
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");
|
|
35343
35434
|
try {
|
|
@@ -35357,12 +35448,12 @@ async function scanGraphFiles(root, space, signal) {
|
|
|
35357
35448
|
if (depth > 12) return;
|
|
35358
35449
|
try {
|
|
35359
35450
|
const directory = authorDocumentPath(root, relative12, true);
|
|
35360
|
-
const entries = await
|
|
35451
|
+
const entries = await fs60.promises.readdir(directory, { withFileTypes: true });
|
|
35361
35452
|
const rows = entries.filter((item) => !item.name.startsWith(".") && item.name !== "node_modules").map((item) => ({
|
|
35362
35453
|
name: item.name,
|
|
35363
35454
|
directory: item.isDirectory(),
|
|
35364
35455
|
draft: false,
|
|
35365
|
-
ref: { space, path:
|
|
35456
|
+
ref: { space, path: path71.posix.join(relative12, item.name) },
|
|
35366
35457
|
...item.isSymbolicLink() || !item.isFile() && !item.isDirectory() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
|
|
35367
35458
|
}));
|
|
35368
35459
|
directories.set(relative12, rows);
|
|
@@ -35587,8 +35678,8 @@ function overlayExtractions(graph, extractions) {
|
|
|
35587
35678
|
}
|
|
35588
35679
|
|
|
35589
35680
|
// src/indexing/graph-storage.ts
|
|
35590
|
-
import * as
|
|
35591
|
-
import * as
|
|
35681
|
+
import * as fs61 from "node:fs";
|
|
35682
|
+
import * as path72 from "node:path";
|
|
35592
35683
|
import { createRequire as createRequire2 } from "node:module";
|
|
35593
35684
|
import { createHash as createHash21, randomUUID as randomUUID8 } from "node:crypto";
|
|
35594
35685
|
var APPLICATION_ID2 = 1465272113;
|
|
@@ -35610,24 +35701,24 @@ function initialGraphState(bookId2) {
|
|
|
35610
35701
|
}
|
|
35611
35702
|
function graphFile(root, name3) {
|
|
35612
35703
|
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");
|
|
35613
|
-
const runtime =
|
|
35614
|
-
for (const [target, directory] of [[runtime, true], [
|
|
35704
|
+
const runtime = path72.join(root, ".webnovel");
|
|
35705
|
+
for (const [target, directory] of [[runtime, true], [path72.join(runtime, name3), false]]) {
|
|
35615
35706
|
try {
|
|
35616
|
-
const stat =
|
|
35707
|
+
const stat = fs61.lstatSync(target);
|
|
35617
35708
|
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");
|
|
35618
35709
|
} catch (error) {
|
|
35619
35710
|
if (error.code !== "ENOENT") throw error;
|
|
35620
35711
|
}
|
|
35621
35712
|
}
|
|
35622
|
-
return
|
|
35713
|
+
return path72.join(runtime, name3);
|
|
35623
35714
|
}
|
|
35624
35715
|
function readGraphState(root, bookId2) {
|
|
35625
35716
|
const file = graphFile(root, STATE_NAME);
|
|
35626
|
-
if (!
|
|
35627
|
-
if (
|
|
35717
|
+
if (!fs61.existsSync(file)) return initialGraphState(bookId2);
|
|
35718
|
+
if (fs61.statSync(file).size > 32768) throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u8FC7\u5927\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
|
|
35628
35719
|
let value;
|
|
35629
35720
|
try {
|
|
35630
|
-
value = JSON.parse(
|
|
35721
|
+
value = JSON.parse(fs61.readFileSync(file, "utf8"));
|
|
35631
35722
|
} catch {
|
|
35632
35723
|
throw new Error("\u56FE\u8C31\u63A7\u5236\u8BB0\u5F55\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u4FDD\u7559\u73B0\u573A");
|
|
35633
35724
|
}
|
|
@@ -35637,12 +35728,12 @@ function readGraphState(root, bookId2) {
|
|
|
35637
35728
|
function writeGraphState(root, state) {
|
|
35638
35729
|
const file = graphFile(root, STATE_NAME), temporary = `${file}.${randomUUID8()}.tmp`;
|
|
35639
35730
|
try {
|
|
35640
|
-
|
|
35731
|
+
fs61.writeFileSync(temporary, JSON.stringify(state) + "\n", { flag: "wx", mode: 384 });
|
|
35641
35732
|
graphFile(root, STATE_NAME);
|
|
35642
|
-
|
|
35733
|
+
fs61.renameSync(temporary, file);
|
|
35643
35734
|
} finally {
|
|
35644
35735
|
try {
|
|
35645
|
-
|
|
35736
|
+
fs61.unlinkSync(temporary);
|
|
35646
35737
|
} catch {
|
|
35647
35738
|
}
|
|
35648
35739
|
}
|
|
@@ -35657,10 +35748,10 @@ function changeGraphState(root, bookId2, update) {
|
|
|
35657
35748
|
function acquireGraphLease(root) {
|
|
35658
35749
|
return withBookLockAsync(root, async () => {
|
|
35659
35750
|
const file = graphFile(root, "story-graph.worker.lock"), token = randomUUID8();
|
|
35660
|
-
if (
|
|
35751
|
+
if (fs61.existsSync(file)) {
|
|
35661
35752
|
let pid;
|
|
35662
35753
|
try {
|
|
35663
|
-
pid = JSON.parse(
|
|
35754
|
+
pid = JSON.parse(fs61.readFileSync(file, "utf8")).pid;
|
|
35664
35755
|
} catch {
|
|
35665
35756
|
throw new Error("\u56FE\u8C31\u4EFB\u52A1\u9501\u65E0\u6CD5\u89E3\u6790\uFF0C\u672A\u6E05\u7406\u539F\u6587\u4EF6");
|
|
35666
35757
|
}
|
|
@@ -35672,12 +35763,12 @@ function acquireGraphLease(root) {
|
|
|
35672
35763
|
dead2 = error.code === "ESRCH";
|
|
35673
35764
|
}
|
|
35674
35765
|
if (!dead2) throw new Error("\u53E6\u4E00\u56FE\u8C31\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C");
|
|
35675
|
-
|
|
35766
|
+
fs61.unlinkSync(graphFile(root, "story-graph.worker.lock"));
|
|
35676
35767
|
}
|
|
35677
|
-
|
|
35768
|
+
fs61.writeFileSync(file, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 384 });
|
|
35678
35769
|
return () => {
|
|
35679
35770
|
try {
|
|
35680
|
-
if (JSON.parse(
|
|
35771
|
+
if (JSON.parse(fs61.readFileSync(graphFile(root, "story-graph.worker.lock"), "utf8")).token === token) fs61.unlinkSync(file);
|
|
35681
35772
|
} catch {
|
|
35682
35773
|
}
|
|
35683
35774
|
};
|
|
@@ -35685,20 +35776,20 @@ function acquireGraphLease(root) {
|
|
|
35685
35776
|
}
|
|
35686
35777
|
function graphCacheSignature(root) {
|
|
35687
35778
|
const file = graphFile(root, CACHE_NAME);
|
|
35688
|
-
return
|
|
35779
|
+
return fs61.existsSync(file) ? createHash21("sha256").update(fs61.readFileSync(file)).digest("hex") : "missing";
|
|
35689
35780
|
}
|
|
35690
35781
|
function cacheHeader(file) {
|
|
35691
|
-
const header2 = Buffer.alloc(100), handle =
|
|
35782
|
+
const header2 = Buffer.alloc(100), handle = fs61.openSync(file, "r");
|
|
35692
35783
|
try {
|
|
35693
|
-
|
|
35784
|
+
fs61.readSync(handle, header2, 0, 100, 0);
|
|
35694
35785
|
} finally {
|
|
35695
|
-
|
|
35786
|
+
fs61.closeSync(handle);
|
|
35696
35787
|
}
|
|
35697
35788
|
return header2;
|
|
35698
35789
|
}
|
|
35699
35790
|
function replaceGraphCache(root, bookId2) {
|
|
35700
35791
|
const file = graphFile(root, CACHE_NAME);
|
|
35701
|
-
if (!
|
|
35792
|
+
if (!fs61.existsSync(file)) return;
|
|
35702
35793
|
const header2 = cacheHeader(file);
|
|
35703
35794
|
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");
|
|
35704
35795
|
let db;
|
|
@@ -35718,12 +35809,12 @@ function replaceGraphCache(root, bookId2) {
|
|
|
35718
35809
|
try {
|
|
35719
35810
|
for (const ending of ["", "-journal", "-wal", "-shm"]) {
|
|
35720
35811
|
const source2 = graphFile(root, CACHE_NAME + ending), target = source2 + suffix;
|
|
35721
|
-
if (!
|
|
35722
|
-
|
|
35812
|
+
if (!fs61.existsSync(source2)) continue;
|
|
35813
|
+
fs61.renameSync(source2, target);
|
|
35723
35814
|
moved.push([source2, target]);
|
|
35724
35815
|
}
|
|
35725
35816
|
} catch (error) {
|
|
35726
|
-
for (const [source2, target] of moved.reverse()) if (!
|
|
35817
|
+
for (const [source2, target] of moved.reverse()) if (!fs61.existsSync(source2)) fs61.renameSync(target, source2);
|
|
35727
35818
|
throw error;
|
|
35728
35819
|
}
|
|
35729
35820
|
}
|
|
@@ -35744,7 +35835,7 @@ function readGraphCache(root, bookId2) {
|
|
|
35744
35835
|
let db;
|
|
35745
35836
|
try {
|
|
35746
35837
|
const file = graphFile(root, CACHE_NAME);
|
|
35747
|
-
if (!
|
|
35838
|
+
if (!fs61.existsSync(file)) return { status: "missing", extractions: [] };
|
|
35748
35839
|
const header2 = cacheHeader(file);
|
|
35749
35840
|
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");
|
|
35750
35841
|
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");
|
|
@@ -35766,7 +35857,7 @@ function readGraphCache(root, bookId2) {
|
|
|
35766
35857
|
}
|
|
35767
35858
|
}
|
|
35768
35859
|
function saveGraphCache(root, graph, extraction) {
|
|
35769
|
-
const filename = graphFile(root, CACHE_NAME), exists3 =
|
|
35860
|
+
const filename = graphFile(root, CACHE_NAME), exists3 = fs61.existsSync(filename);
|
|
35770
35861
|
if (exists3) {
|
|
35771
35862
|
const header2 = cacheHeader(filename);
|
|
35772
35863
|
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");
|
|
@@ -35815,9 +35906,9 @@ function routeForDocument(ref2) {
|
|
|
35815
35906
|
return "\u6821\u51C6\u4F5C\u54C1\u73B0\u72B6\uFF0C\u518D\u6309\u4FEE\u6539\u5185\u5BB9\u9009\u62E9\u5BF9\u5E94\u8282\u70B9";
|
|
35816
35907
|
}
|
|
35817
35908
|
function textOf(target) {
|
|
35818
|
-
if (!
|
|
35819
|
-
if (
|
|
35820
|
-
const bytes =
|
|
35909
|
+
if (!fs62.existsSync(target) || !fs62.statSync(target).isFile()) throw new AuthorDocumentError("not-found", "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
35910
|
+
if (fs62.statSync(target).size > MAX_DOCUMENT_BYTES2) throw new AuthorDocumentError("read-only", "\u6587\u4EF6\u8D85\u8FC7 4 MiB\uFF0C\u4E0D\u80FD\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\uFF1B\u5185\u5BB9\u672A\u622A\u65AD");
|
|
35911
|
+
const bytes = fs62.readFileSync(target);
|
|
35821
35912
|
if (bytes.includes(0)) throw new AuthorDocumentError("read-only", "\u8BE5\u6587\u4EF6\u4E0D\u662F\u6587\u672C\u6587\u4EF6");
|
|
35822
35913
|
try {
|
|
35823
35914
|
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
@@ -35838,19 +35929,19 @@ var StudyService = class {
|
|
|
35838
35929
|
constructor(workspace) {
|
|
35839
35930
|
if (!isFullyQualifiedPath(workspace)) throw new AuthorDocumentError("invalid-path", "\u5DE5\u4F5C\u8303\u56F4\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
|
|
35840
35931
|
this.workspace = canonicalizePath(workspace);
|
|
35841
|
-
if (!
|
|
35932
|
+
if (!fs62.existsSync(this.workspace) || !fs62.statSync(this.workspace).isDirectory()) throw new AuthorDocumentError("not-found", "\u5DE5\u4F5C\u8303\u56F4\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
35842
35933
|
}
|
|
35843
35934
|
source(space) {
|
|
35844
35935
|
if (space === "shared") {
|
|
35845
35936
|
const root2 = authorDocumentPath(this.workspace, "\u4E66\u623F");
|
|
35846
|
-
if (!
|
|
35847
|
-
if (
|
|
35937
|
+
if (!fs62.existsSync(root2)) throw new AuthorDocumentError("not-found", "\u5F53\u524D\u5DE5\u4F5C\u8303\u56F4\u5C1A\u65E0\u5171\u4EAB\u8D44\u6599");
|
|
35938
|
+
if (fs62.existsSync(path73.join(root2, paths.\u5951\u7EA6()))) throw new AuthorDocumentError("read-only", "\u5171\u4EAB\u76EE\u5F55\u4E0E\u4E66\u4ED3\u91CD\u53E0\uFF0C\u8BF7\u901A\u8FC7\u4E66\u76EE\u5165\u53E3\u8BBF\u95EE\uFF1B\u5171\u4EAB\u5199\u5165\u5DF2\u5173\u95ED");
|
|
35848
35939
|
return { root: root2, owner: "\u5171\u4EAB\u8D44\u6599" };
|
|
35849
35940
|
}
|
|
35850
35941
|
const books = scanWorkspaceBooks(this.workspace).filter((book2) => book2.bookId && "book:" + book2.bookId === space);
|
|
35851
35942
|
if (books.length !== 1) throw new AuthorDocumentError("not-found", "\u4E66\u76EE\u4E0D\u5B58\u5728\u6216\u4E66id\u4E0D\u552F\u4E00");
|
|
35852
35943
|
const book = books[0];
|
|
35853
|
-
const root = authorDocumentPath(this.workspace,
|
|
35944
|
+
const root = authorDocumentPath(this.workspace, path73.relative(this.workspace, book.root));
|
|
35854
35945
|
return { root, owner: book.name, bookId: book.bookId };
|
|
35855
35946
|
}
|
|
35856
35947
|
shelf() {
|
|
@@ -35865,12 +35956,28 @@ var StudyService = class {
|
|
|
35865
35956
|
let shared = false;
|
|
35866
35957
|
let sharedError;
|
|
35867
35958
|
try {
|
|
35868
|
-
shared =
|
|
35959
|
+
shared = fs62.statSync(this.source("shared").root).isDirectory();
|
|
35869
35960
|
} catch (error) {
|
|
35870
35961
|
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";
|
|
35871
35962
|
}
|
|
35872
35963
|
return { workspace: this.workspace, books, shared, ...sharedError ? { sharedError } : {} };
|
|
35873
35964
|
}
|
|
35965
|
+
/** 建书向导(8.4.4):读待建书草稿——书房面板点选的答案,novel_create_book 找不到参数时作后备。 */
|
|
35966
|
+
readOnboarding() {
|
|
35967
|
+
return readOnboardingDraft(this.workspace);
|
|
35968
|
+
}
|
|
35969
|
+
/** 建书向导:保存作者点选的答案。三项必须齐全,缺项直接报可读错误,不存半成品。 */
|
|
35970
|
+
saveOnboarding(answers) {
|
|
35971
|
+
const validated = validateOnboardingAnswers(answers);
|
|
35972
|
+
const missing = onboardingMissing(validated);
|
|
35973
|
+
if (missing.length > 0) throw new AuthorDocumentError("invalid-document", `\u65B0\u5EFA\u4E66\u8FD8\u5DEE${missing.join("\u3001")}\u6CA1\u9009\uFF0C\u9009\u5B8C\u518D\u4FDD\u5B58`);
|
|
35974
|
+
saveOnboardingDraft(this.workspace, validated);
|
|
35975
|
+
return validated;
|
|
35976
|
+
}
|
|
35977
|
+
/** 建书向导:清除待建书草稿。 */
|
|
35978
|
+
clearOnboarding() {
|
|
35979
|
+
consumeOnboardingDraft(this.workspace);
|
|
35980
|
+
}
|
|
35874
35981
|
indexBook(space) {
|
|
35875
35982
|
if (space === "shared") throw new AuthorDocumentError("invalid-path", "\u7D22\u5F15\u53EA\u9002\u7528\u4E8E\u6307\u5B9A\u4E66\u4ED3");
|
|
35876
35983
|
const source2 = this.source(space);
|
|
@@ -35889,12 +35996,12 @@ var StudyService = class {
|
|
|
35889
35996
|
// once for tree badges and a second time for the evidence itself.
|
|
35890
35997
|
list: (relative12) => {
|
|
35891
35998
|
const directory = authorDocumentPath(source2.root, relative12, true);
|
|
35892
|
-
if (!
|
|
35893
|
-
return
|
|
35999
|
+
if (!fs62.existsSync(directory)) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
36000
|
+
return fs62.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => ({
|
|
35894
36001
|
name: entry.name,
|
|
35895
36002
|
directory: entry.isDirectory(),
|
|
35896
36003
|
draft: false,
|
|
35897
|
-
ref: { space, path:
|
|
36004
|
+
ref: { space, path: path73.posix.join(relative12, entry.name) },
|
|
35898
36005
|
...entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile() ? { error: "\u8BE5\u6761\u76EE\u4E0D\u662F\u5B89\u5168\u7684\u666E\u901A\u6587\u4EF6\u6216\u76EE\u5F55" } : {}
|
|
35899
36006
|
}));
|
|
35900
36007
|
},
|
|
@@ -35964,13 +36071,13 @@ var StudyService = class {
|
|
|
35964
36071
|
}
|
|
35965
36072
|
treeAt(source2, ref2) {
|
|
35966
36073
|
const directory = authorDocumentPath(source2.root, ref2.path, true);
|
|
35967
|
-
if (!
|
|
35968
|
-
return
|
|
35969
|
-
const relative12 =
|
|
36074
|
+
if (!fs62.existsSync(directory) || !fs62.statSync(directory).isDirectory()) throw new AuthorDocumentError("not-found", "\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
36075
|
+
return fs62.readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => {
|
|
36076
|
+
const relative12 = path73.posix.join(ref2.path, entry.name);
|
|
35970
36077
|
const item = { ref: { space: ref2.space, path: relative12 }, name: entry.name, directory: entry.isDirectory(), draft: ref2.space !== "shared" && relative12.startsWith("\u8349\u7A3F\u533A") };
|
|
35971
36078
|
try {
|
|
35972
36079
|
const target = authorDocumentPath(source2.root, relative12);
|
|
35973
|
-
const info =
|
|
36080
|
+
const info = fs62.statSync(target);
|
|
35974
36081
|
if (!info.isDirectory() && !info.isFile()) return { ...item, error: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B" };
|
|
35975
36082
|
const badge = info.isFile() && entry.name.endsWith(".md") && info.size <= MAX_DOCUMENT_BYTES2 ? fieldLabel(textOf(target)).badge : void 0;
|
|
35976
36083
|
return { ...item, absolutePath: target, directory: info.isDirectory(), ...badge ? { badge } : {} };
|
|
@@ -35988,7 +36095,7 @@ var StudyService = class {
|
|
|
35988
36095
|
read(ref2) {
|
|
35989
36096
|
const source2 = this.source(ref2.space);
|
|
35990
36097
|
const absolutePath = authorDocumentPath(source2.root, ref2.path);
|
|
35991
|
-
ref2 = { ...ref2, path:
|
|
36098
|
+
ref2 = { ...ref2, path: path73.relative(canonicalizePath(source2.root), absolutePath).split(path73.sep).join("/") };
|
|
35992
36099
|
const text5 = textOf(absolutePath);
|
|
35993
36100
|
const parsed = parseDocument(text5);
|
|
35994
36101
|
const metadata2 = fieldLabel(text5);
|
|
@@ -35996,7 +36103,7 @@ var StudyService = class {
|
|
|
35996
36103
|
return {
|
|
35997
36104
|
ref: ref2,
|
|
35998
36105
|
owner: source2.owner,
|
|
35999
|
-
name:
|
|
36106
|
+
name: path73.basename(ref2.path),
|
|
36000
36107
|
absolutePath,
|
|
36001
36108
|
body: parsed.ok ? parsed.data.body : text5,
|
|
36002
36109
|
hash: documentHash(text5),
|
|
@@ -36015,14 +36122,14 @@ var StudyService = class {
|
|
|
36015
36122
|
return null;
|
|
36016
36123
|
}
|
|
36017
36124
|
}
|
|
36018
|
-
absolutePath =
|
|
36125
|
+
absolutePath = path73.resolve(this.workspace, absolutePath);
|
|
36019
36126
|
}
|
|
36020
36127
|
const spaces = this.shelf().books.filter((book) => !book.error).map((book) => book.id);
|
|
36021
36128
|
spaces.push("shared");
|
|
36022
36129
|
for (const space of spaces) {
|
|
36023
36130
|
try {
|
|
36024
36131
|
const source2 = this.source(space);
|
|
36025
|
-
const relative12 =
|
|
36132
|
+
const relative12 = path73.relative(source2.root, absolutePath).split(path73.sep).join("/");
|
|
36026
36133
|
return this.read({ space, path: relative12 });
|
|
36027
36134
|
} catch {
|
|
36028
36135
|
}
|
|
@@ -36035,7 +36142,7 @@ var StudyService = class {
|
|
|
36035
36142
|
const scanned = scanWorkspaceBooks(this.workspace);
|
|
36036
36143
|
const spaces = scanned.filter((book) => book.bookId && scanned.filter((other) => other.bookId === book.bookId).length === 1).map((book) => "book:" + book.bookId);
|
|
36037
36144
|
try {
|
|
36038
|
-
if (
|
|
36145
|
+
if (fs62.statSync(this.source("shared").root).isDirectory()) spaces.push("shared");
|
|
36039
36146
|
} catch {
|
|
36040
36147
|
}
|
|
36041
36148
|
const term = query.trim().toLocaleLowerCase();
|
|
@@ -36102,7 +36209,7 @@ var StudyService = class {
|
|
|
36102
36209
|
const status = deriveChapterFacts(facts);
|
|
36103
36210
|
const pending = findPendingReviewDraft(source2.root, key);
|
|
36104
36211
|
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)];
|
|
36105
|
-
const relative12 = candidates.find((candidate) =>
|
|
36212
|
+
const relative12 = candidates.find((candidate) => fs62.existsSync(path73.join(source2.root, candidate)));
|
|
36106
36213
|
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 } } : {} };
|
|
36107
36214
|
})
|
|
36108
36215
|
};
|
|
@@ -36630,8 +36737,36 @@ function childEnd(reason) {
|
|
|
36630
36737
|
}
|
|
36631
36738
|
|
|
36632
36739
|
// src/study/web.ts
|
|
36740
|
+
function agentRoots(registry2) {
|
|
36741
|
+
if (!registry2) return [];
|
|
36742
|
+
const value = registry2.roots;
|
|
36743
|
+
if (typeof value === "function") {
|
|
36744
|
+
try {
|
|
36745
|
+
const result = value();
|
|
36746
|
+
if (Array.isArray(result)) return result;
|
|
36747
|
+
} catch {
|
|
36748
|
+
}
|
|
36749
|
+
} else if (Array.isArray(value)) {
|
|
36750
|
+
return value;
|
|
36751
|
+
}
|
|
36752
|
+
return [];
|
|
36753
|
+
}
|
|
36754
|
+
function agentList(registry2) {
|
|
36755
|
+
if (!registry2) return [];
|
|
36756
|
+
const value = registry2.list;
|
|
36757
|
+
if (typeof value === "function") {
|
|
36758
|
+
try {
|
|
36759
|
+
const result = value();
|
|
36760
|
+
if (Array.isArray(result)) return result;
|
|
36761
|
+
} catch {
|
|
36762
|
+
}
|
|
36763
|
+
} else if (Array.isArray(value)) {
|
|
36764
|
+
return value;
|
|
36765
|
+
}
|
|
36766
|
+
return [];
|
|
36767
|
+
}
|
|
36633
36768
|
var STUDY_API_PATH = "/api/webnovel/study/";
|
|
36634
|
-
var METHODS = ["shelf", "tree", "read", "resolve", "search", "chapters", "graph", "graph-view", "graph-preview", "graph-control", "book-inspection", "workflow", "save", "notify", "retry-commit", "index-status", "index-control", "ask", "ask-cancel", "suggestions"];
|
|
36769
|
+
var METHODS = ["shelf", "tree", "read", "resolve", "search", "chapters", "graph", "graph-view", "graph-preview", "graph-control", "book-inspection", "workflow", "save", "notify", "retry-commit", "index-status", "index-control", "ask", "ask-cancel", "suggestions", "onboarding"];
|
|
36635
36770
|
function graphReaderRequest(input) {
|
|
36636
36771
|
const result = {};
|
|
36637
36772
|
for (const key of ["person", "query", "cluster", "relation", "groupField", "evidenceId"]) if (input[key] !== void 0) {
|
|
@@ -36805,7 +36940,9 @@ function createStudyHandler(runtime, indexing, workflow = new WorkflowObserver()
|
|
|
36805
36940
|
request.signal.throwIfAborted();
|
|
36806
36941
|
const sessionId = stringOf(input, "sessionId");
|
|
36807
36942
|
const agent = runtime.agents.get(sessionId);
|
|
36808
|
-
|
|
36943
|
+
const roots = agentRoots(runtime.agents);
|
|
36944
|
+
const isRoot = agent !== void 0 && (roots.length > 0 ? roots.includes(agent) : agent.session?.header?.origin !== "subagent");
|
|
36945
|
+
if (!agent || !isRoot) throw new AuthorDocumentError("read-only", "\u8BF7\u5728\u5F53\u524D\u4E3B\u4F1A\u8BDD\u4E2D\u6253\u5F00\u4E66\u623F");
|
|
36809
36946
|
const cwd = agent.session.header.cwd;
|
|
36810
36947
|
if (!cwd || !isFullyQualifiedPath(cwd)) throw new AuthorDocumentError("invalid-path", "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u6709\u6548\u5DE5\u4F5C\u8303\u56F4");
|
|
36811
36948
|
const service = new StudyService(cwd);
|
|
@@ -36936,6 +37073,16 @@ function createStudyHandler(runtime, indexing, workflow = new WorkflowObserver()
|
|
|
36936
37073
|
case "retry-commit":
|
|
36937
37074
|
value = service.retryCommit(refOf(input), stringOf(input, "hash"), stringOf(input, "operationId"), sessionId);
|
|
36938
37075
|
break;
|
|
37076
|
+
case "onboarding": {
|
|
37077
|
+
const action = typeof input["action"] === "string" ? input["action"] : "read";
|
|
37078
|
+
if (action === "save") value = { saved: service.saveOnboarding(input["answers"]) };
|
|
37079
|
+
else if (action === "clear") {
|
|
37080
|
+
service.clearOnboarding();
|
|
37081
|
+
value = { cleared: true };
|
|
37082
|
+
} else if (action === "read") value = { answers: service.readOnboarding() };
|
|
37083
|
+
else throw new AuthorDocumentError("invalid-document", "\u672A\u77E5\u7684\u5411\u5BFC\u64CD\u4F5C");
|
|
37084
|
+
break;
|
|
37085
|
+
}
|
|
36939
37086
|
default:
|
|
36940
37087
|
return reply(404, { ok: false, code: "not-found", error: "\u672A\u77E5\u4E66\u623F\u64CD\u4F5C" });
|
|
36941
37088
|
}
|
|
@@ -36998,7 +37145,7 @@ function brandString(value) {
|
|
|
36998
37145
|
|
|
36999
37146
|
// src/native-write.ts
|
|
37000
37147
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
37001
|
-
import * as
|
|
37148
|
+
import * as path74 from "node:path";
|
|
37002
37149
|
import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
|
|
37003
37150
|
function nativeToolRuntime(ctx) {
|
|
37004
37151
|
const pipeline = new ToolExecutionPipeline(ctx);
|
|
@@ -37029,7 +37176,7 @@ function createNativeWriteBridge(runtime) {
|
|
|
37029
37176
|
exec.signal.throwIfAborted();
|
|
37030
37177
|
const target = resolveInsideBook(root, op.relPath);
|
|
37031
37178
|
if (!target.ok) throw new Error("\u539F\u751F\u5199\u5165\u76EE\u6807\u4E0D\u5728\u4E66\u4ED3\u5185");
|
|
37032
|
-
const file =
|
|
37179
|
+
const file = path74.resolve(root, target.relPath);
|
|
37033
37180
|
const callId = brandString(`webnovel-write-${randomUUID9()}`);
|
|
37034
37181
|
pending.set(callId, { parent: exec.token, agent: exec.agent, file, content: op.content });
|
|
37035
37182
|
try {
|
|
@@ -37053,10 +37200,10 @@ function createNativeWriteBridge(runtime) {
|
|
|
37053
37200
|
}
|
|
37054
37201
|
|
|
37055
37202
|
// src/indexing/manager.ts
|
|
37056
|
-
import * as
|
|
37203
|
+
import * as fs63 from "node:fs";
|
|
37057
37204
|
|
|
37058
37205
|
// src/indexing/git.ts
|
|
37059
|
-
import * as
|
|
37206
|
+
import * as path75 from "node:path";
|
|
37060
37207
|
import { execFile } from "node:child_process";
|
|
37061
37208
|
async function git(root, args) {
|
|
37062
37209
|
return new Promise((resolve22) => execFile("git", ["--literal-pathspecs", "-C", root, ...args], {
|
|
@@ -37082,8 +37229,8 @@ async function bookGitWatchPaths(root) {
|
|
|
37082
37229
|
git(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"])
|
|
37083
37230
|
]);
|
|
37084
37231
|
return [...new Set(directories.filter((value) => !!value?.trim()).flatMap((value) => {
|
|
37085
|
-
const directory =
|
|
37086
|
-
return [directory,
|
|
37232
|
+
const directory = path75.resolve(root, value.trim());
|
|
37233
|
+
return [directory, path75.join(directory, "refs")];
|
|
37087
37234
|
}))];
|
|
37088
37235
|
}
|
|
37089
37236
|
|
|
@@ -37490,7 +37637,7 @@ var BookIndexManager = class {
|
|
|
37490
37637
|
for (const directory of await bookGitWatchPaths(record4.book.root)) {
|
|
37491
37638
|
if (this.closing) return;
|
|
37492
37639
|
try {
|
|
37493
|
-
const watcher =
|
|
37640
|
+
const watcher = fs63.watch(directory, { recursive: directory.endsWith("refs"), persistent: false }, (_event, filename) => {
|
|
37494
37641
|
const name3 = filename?.toString().replaceAll("\\", "/");
|
|
37495
37642
|
if (directory.endsWith("refs") || !name3 || /^(HEAD|packed-refs|refs)(\/|$)/.test(name3)) {
|
|
37496
37643
|
this.scheduleProbe(record4);
|
|
@@ -37864,7 +38011,7 @@ function indexFailureMessage(book, notice) {
|
|
|
37864
38011
|
}
|
|
37865
38012
|
|
|
37866
38013
|
// src/reference/host.ts
|
|
37867
|
-
import * as
|
|
38014
|
+
import * as path76 from "node:path";
|
|
37868
38015
|
import { BlockAssembler, createUserMessage as createUserMessage4 } from "@deepseek-ai/dsh-llm";
|
|
37869
38016
|
var ReferenceHost = class {
|
|
37870
38017
|
constructor(access) {
|
|
@@ -37882,26 +38029,26 @@ var ReferenceHost = class {
|
|
|
37882
38029
|
async readFile(agent, workspace, filename, signal) {
|
|
37883
38030
|
const active = AbortSignal.any([this.shutdown.signal, ...signal ? [signal] : []]);
|
|
37884
38031
|
active.throwIfAborted();
|
|
37885
|
-
const
|
|
37886
|
-
if (!
|
|
37887
|
-
if (!
|
|
37888
|
-
const mapped =
|
|
38032
|
+
const fs67 = this.access.fs(agent);
|
|
38033
|
+
if (!fs67) throw new ReferenceError2("fs-unavailable", "DSH \u6587\u4EF6\u670D\u52A1\u4E0D\u53EF\u7528");
|
|
38034
|
+
if (!path76.isAbsolute(filename)) throw new ReferenceError2("source-path", "\u8BF7\u9009\u62E9\u539F\u6587\u6587\u4EF6\u7684\u7EDD\u5BF9\u8DEF\u5F84");
|
|
38035
|
+
const mapped = fs67.processPathFromHostPath(filename), workspacePath = fs67.processPathFromHostPath(workspace);
|
|
37889
38036
|
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");
|
|
37890
|
-
const info = await
|
|
38037
|
+
const info = await fs67.lstat(mapped, void 0, active);
|
|
37891
38038
|
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");
|
|
37892
|
-
let ancestor =
|
|
37893
|
-
while (
|
|
37894
|
-
if ((await
|
|
37895
|
-
ancestor =
|
|
37896
|
-
}
|
|
37897
|
-
const target = await
|
|
37898
|
-
const library = await
|
|
37899
|
-
if (
|
|
37900
|
-
const before = await
|
|
38039
|
+
let ancestor = path76.dirname(mapped);
|
|
38040
|
+
while (path76.dirname(ancestor) !== ancestor) {
|
|
38041
|
+
if ((await fs67.lstat(ancestor, void 0, active))?.type !== "directory") throw new ReferenceError2("source-type", "\u539F\u6587\u7684\u7956\u5148\u76EE\u5F55\u5305\u542B\u94FE\u63A5\u6216\u4E0D\u53EF\u8BBF\u95EE\u8DEF\u5F84");
|
|
38042
|
+
ancestor = path76.dirname(ancestor);
|
|
38043
|
+
}
|
|
38044
|
+
const target = await fs67.resolve(mapped, { signal: active });
|
|
38045
|
+
const library = await fs67.resolve(path76.join(workspacePath, "\u4E66\u623F/\u53C2\u8003\u4E66"), { signal: active });
|
|
38046
|
+
if (fs67.contains(library, target)) throw new ReferenceError2("source-path", "\u539F\u6587\u4EF6\u4E0D\u80FD\u4F4D\u4E8E\u5F85\u6E05\u9664\u7684\u53D7\u7BA1\u53C2\u8003\u5E93\u5185");
|
|
38047
|
+
const before = await fs67.stat(target, active);
|
|
37901
38048
|
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");
|
|
37902
|
-
const bytes = await
|
|
37903
|
-
const afterTarget = await
|
|
37904
|
-
const afterPath = await
|
|
38049
|
+
const bytes = await fs67.readBytes(target, active, REFERENCE_LIMITS.sourceBytes);
|
|
38050
|
+
const afterTarget = await fs67.resolve(mapped, { signal: active }), after = await fs67.stat(afterTarget, active);
|
|
38051
|
+
const afterPath = await fs67.lstat(mapped, void 0, active);
|
|
37905
38052
|
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");
|
|
37906
38053
|
active.throwIfAborted();
|
|
37907
38054
|
return bytes;
|
|
@@ -38047,8 +38194,8 @@ function createIndexAutoPreference(settings, fallback) {
|
|
|
38047
38194
|
}
|
|
38048
38195
|
|
|
38049
38196
|
// src/scripts/deterministic-checks.ts
|
|
38050
|
-
import * as
|
|
38051
|
-
import * as
|
|
38197
|
+
import * as fs64 from "node:fs";
|
|
38198
|
+
import * as path77 from "node:path";
|
|
38052
38199
|
function parseArgs(argv) {
|
|
38053
38200
|
const values = /* @__PURE__ */ new Map();
|
|
38054
38201
|
for (let i = 0; i < argv.length; i += 1) {
|
|
@@ -38078,8 +38225,8 @@ function runChecksCli(argv) {
|
|
|
38078
38225
|
console.error(`\u524D\u7F6E\u53C2\u6570\u9519\u8BEF\uFF1A${err instanceof Error ? err.message : String(err)}`);
|
|
38079
38226
|
return 1;
|
|
38080
38227
|
}
|
|
38081
|
-
if (!
|
|
38082
|
-
console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${
|
|
38228
|
+
if (!fs64.existsSync(args.book) || !fs64.statSync(args.book).isDirectory()) {
|
|
38229
|
+
console.error(`\u4E66\u4ED3\u4E0D\u5B58\u5728\uFF1A${path77.resolve(args.book)}`);
|
|
38083
38230
|
return 1;
|
|
38084
38231
|
}
|
|
38085
38232
|
try {
|
|
@@ -38113,8 +38260,8 @@ function runChecksCli(argv) {
|
|
|
38113
38260
|
}
|
|
38114
38261
|
|
|
38115
38262
|
// src/scripts/draft-length-cli.ts
|
|
38116
|
-
import * as
|
|
38117
|
-
import * as
|
|
38263
|
+
import * as fs65 from "node:fs";
|
|
38264
|
+
import * as path78 from "node:path";
|
|
38118
38265
|
function unverified(reason, exitCode) {
|
|
38119
38266
|
console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", \u7EDF\u8BA1\u72B6\u6001: "\u672A\u6838\u9A8C", \u539F\u56E0: reason }, null, 2));
|
|
38120
38267
|
return exitCode;
|
|
@@ -38135,14 +38282,14 @@ function draftLengthCli(argv) {
|
|
|
38135
38282
|
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);
|
|
38136
38283
|
}
|
|
38137
38284
|
try {
|
|
38138
|
-
if (!
|
|
38285
|
+
if (!fs65.statSync(book).isDirectory()) return unverified("\u4E66\u4ED3\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55", 1);
|
|
38139
38286
|
const resolved = resolveInsideBook(book, requested);
|
|
38140
38287
|
if (!resolved.ok) return unverified(resolved.reason, 1);
|
|
38141
38288
|
const target = draftLengthTarget(resolved.relPath);
|
|
38142
38289
|
if (target?.\u6587\u672C\u9636\u6BB5 !== "\u8349\u7A3F\u6587\u4EF6") return unverified("\u5B9E\u9645\u76EE\u6807\u4E0D\u662F\u89C4\u8303\u5B8C\u6574\u7A3F", 1);
|
|
38143
|
-
const file =
|
|
38144
|
-
if (!
|
|
38145
|
-
const text5 =
|
|
38290
|
+
const file = path78.join(book, resolved.relPath);
|
|
38291
|
+
if (!fs65.statSync(file).isFile()) return unverified("\u7A3F\u4EF6\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6", 1);
|
|
38292
|
+
const text5 = fs65.readFileSync(file, "utf8");
|
|
38146
38293
|
const result = draftLengthFeedback(target, text5, readChapterLength(book));
|
|
38147
38294
|
console.log(JSON.stringify({ \u6838\u9A8C\u6765\u6E90: "\u5F53\u524D\u6587\u4EF6", ...result }, null, 2));
|
|
38148
38295
|
return result.\u7EDF\u8BA1\u72B6\u6001 === "\u5DF2\u7EDF\u8BA1" ? 0 : 1;
|
|
@@ -38361,8 +38508,8 @@ function exportCli(argv) {
|
|
|
38361
38508
|
}
|
|
38362
38509
|
|
|
38363
38510
|
// src/scripts/screenplay-export-cli.ts
|
|
38364
|
-
import * as
|
|
38365
|
-
import * as
|
|
38511
|
+
import * as fs66 from "node:fs";
|
|
38512
|
+
import * as path79 from "node:path";
|
|
38366
38513
|
function argValue5(argv, name3) {
|
|
38367
38514
|
const i = argv.indexOf(`--${name3}`);
|
|
38368
38515
|
return i === -1 ? void 0 : argv[i + 1];
|
|
@@ -38423,12 +38570,12 @@ function screenplayExportCli(argv) {
|
|
|
38423
38570
|
const \u5206\u955C\u5934raw = argValue5(argv, "\u5206\u955C\u5934")?.trim();
|
|
38424
38571
|
let \u5206\u955C\u5934\u8868;
|
|
38425
38572
|
if (\u5206\u955C\u5934raw !== void 0) {
|
|
38426
|
-
const shotPath =
|
|
38427
|
-
if (!
|
|
38573
|
+
const shotPath = path79.isAbsolute(\u5206\u955C\u5934raw) ? \u5206\u955C\u5934raw : path79.join(book, \u5206\u955C\u5934raw);
|
|
38574
|
+
if (!fs66.existsSync(shotPath) || !fs66.statSync(shotPath).isFile()) {
|
|
38428
38575
|
console.error(`\u5206\u955C\u5934\u8868\u4E0D\u5B58\u5728\uFF1A${shotPath}`);
|
|
38429
38576
|
return 1;
|
|
38430
38577
|
}
|
|
38431
|
-
const parsed = parseShotListTable(
|
|
38578
|
+
const parsed = parseShotListTable(fs66.readFileSync(shotPath, "utf-8"));
|
|
38432
38579
|
if (!parsed.ok || parsed.shotList === void 0) {
|
|
38433
38580
|
console.error(`\u5206\u955C\u5934\u8868\u89E3\u6790\u5931\u8D25\uFF1A${parsed.problems.join("\uFF1B")}`);
|
|
38434
38581
|
return 1;
|
|
@@ -38438,13 +38585,13 @@ function screenplayExportCli(argv) {
|
|
|
38438
38585
|
const \u603B\u7EB2raw = argValue5(argv, "\u603B\u7EB2")?.trim();
|
|
38439
38586
|
let \u603B\u7EB2;
|
|
38440
38587
|
if (\u603B\u7EB2raw !== void 0) {
|
|
38441
|
-
const biblePath =
|
|
38442
|
-
if (!
|
|
38588
|
+
const biblePath = path79.isAbsolute(\u603B\u7EB2raw) ? \u603B\u7EB2raw : path79.join(book, \u603B\u7EB2raw);
|
|
38589
|
+
if (!fs66.existsSync(biblePath) || !fs66.statSync(biblePath).isFile()) {
|
|
38443
38590
|
console.error(`\u603B\u7EB2\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${biblePath}`);
|
|
38444
38591
|
return 1;
|
|
38445
38592
|
}
|
|
38446
38593
|
try {
|
|
38447
|
-
const parsedBible = JSON.parse(
|
|
38594
|
+
const parsedBible = JSON.parse(fs66.readFileSync(biblePath, "utf-8"));
|
|
38448
38595
|
if (typeof parsedBible !== "object" || parsedBible === null || Array.isArray(parsedBible)) {
|
|
38449
38596
|
console.error("\u603B\u7EB2\u89E3\u6790\u5931\u8D25\uFF1A\u603B\u7EB2 JSON \u987B\u4E3A\u5BF9\u8C61\uFF08StoryBibleInput \u4E03\u8282\uFF09");
|
|
38450
38597
|
return 1;
|
|
@@ -38759,7 +38906,9 @@ function apply(ctx, entry) {
|
|
|
38759
38906
|
},
|
|
38760
38907
|
notify: (book, notice) => {
|
|
38761
38908
|
const registry2 = typeof ctx.get === "function" ? ctx.get("agents") : void 0;
|
|
38762
|
-
const
|
|
38909
|
+
const roots = agentRoots(registry2);
|
|
38910
|
+
const candidates = roots.length > 0 ? roots : agentList(registry2);
|
|
38911
|
+
const agent = candidates.find((candidate) => (candidate.id === notice.sessionId || candidate.session?.header?.id === notice.sessionId) && registry2?.get(candidate.id) === candidate);
|
|
38763
38912
|
if (!agent || !isMainAgent(agent) || !isWritingAgent(agent) || !agent.session?.header || typeof agent.followup !== "function") return false;
|
|
38764
38913
|
if (bookRootOfBookIdFor(book.bookId, agent) !== book.root) return false;
|
|
38765
38914
|
return notifySaved(agent, indexFailureMessage(book, notice)).notification === "delivered";
|