@c4a/extract 0.6.2 → 0.6.3
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/bin/c4a-extract-code.js +196 -346
- package/index.js +337 -364
- package/package.json +4 -1
package/index.js
CHANGED
|
@@ -320,26 +320,26 @@ var require_directives = __commonJS((exports) => {
|
|
|
320
320
|
return false;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
tagName(
|
|
324
|
-
if (
|
|
323
|
+
tagName(source, onError) {
|
|
324
|
+
if (source === "!")
|
|
325
325
|
return "!";
|
|
326
|
-
if (
|
|
327
|
-
onError(`Not a valid tag: ${
|
|
326
|
+
if (source[0] !== "!") {
|
|
327
|
+
onError(`Not a valid tag: ${source}`);
|
|
328
328
|
return null;
|
|
329
329
|
}
|
|
330
|
-
if (
|
|
331
|
-
const verbatim =
|
|
330
|
+
if (source[1] === "<") {
|
|
331
|
+
const verbatim = source.slice(2, -1);
|
|
332
332
|
if (verbatim === "!" || verbatim === "!!") {
|
|
333
|
-
onError(`Verbatim tags aren't resolved, so ${
|
|
333
|
+
onError(`Verbatim tags aren't resolved, so ${source} is invalid.`);
|
|
334
334
|
return null;
|
|
335
335
|
}
|
|
336
|
-
if (
|
|
336
|
+
if (source[source.length - 1] !== ">")
|
|
337
337
|
onError("Verbatim tags must end with a >");
|
|
338
338
|
return verbatim;
|
|
339
339
|
}
|
|
340
|
-
const [, handle, suffix] =
|
|
340
|
+
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s);
|
|
341
341
|
if (!suffix)
|
|
342
|
-
onError(`The ${
|
|
342
|
+
onError(`The ${source} tag has no suffix`);
|
|
343
343
|
const prefix = this.tags[handle];
|
|
344
344
|
if (prefix) {
|
|
345
345
|
try {
|
|
@@ -350,8 +350,8 @@ var require_directives = __commonJS((exports) => {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
if (handle === "!")
|
|
353
|
-
return
|
|
354
|
-
onError(`Could not resolve tag: ${
|
|
353
|
+
return source;
|
|
354
|
+
onError(`Could not resolve tag: ${source}`);
|
|
355
355
|
return null;
|
|
356
356
|
}
|
|
357
357
|
tagString(tag) {
|
|
@@ -423,21 +423,21 @@ var require_anchors = __commonJS((exports) => {
|
|
|
423
423
|
const sourceObjects = new Map;
|
|
424
424
|
let prevAnchors = null;
|
|
425
425
|
return {
|
|
426
|
-
onAnchor: (
|
|
427
|
-
aliasObjects.push(
|
|
426
|
+
onAnchor: (source) => {
|
|
427
|
+
aliasObjects.push(source);
|
|
428
428
|
prevAnchors ?? (prevAnchors = anchorNames(doc));
|
|
429
429
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
430
430
|
prevAnchors.add(anchor);
|
|
431
431
|
return anchor;
|
|
432
432
|
},
|
|
433
433
|
setAnchors: () => {
|
|
434
|
-
for (const
|
|
435
|
-
const ref = sourceObjects.get(
|
|
434
|
+
for (const source of aliasObjects) {
|
|
435
|
+
const ref = sourceObjects.get(source);
|
|
436
436
|
if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
|
|
437
437
|
ref.node.anchor = ref.anchor;
|
|
438
438
|
} else {
|
|
439
439
|
const error = new Error("Failed to resolve repeated object (this should not happen)");
|
|
440
|
-
error.source =
|
|
440
|
+
error.source = source;
|
|
441
441
|
throw error;
|
|
442
442
|
}
|
|
443
443
|
}
|
|
@@ -571,9 +571,9 @@ var require_Alias = __commonJS((exports) => {
|
|
|
571
571
|
var toJS = require_toJS();
|
|
572
572
|
|
|
573
573
|
class Alias extends Node.NodeBase {
|
|
574
|
-
constructor(
|
|
574
|
+
constructor(source) {
|
|
575
575
|
super(identity.ALIAS);
|
|
576
|
-
this.source =
|
|
576
|
+
this.source = source;
|
|
577
577
|
Object.defineProperty(this, "tag", {
|
|
578
578
|
set() {
|
|
579
579
|
throw new Error("Alias nodes cannot have tags");
|
|
@@ -608,15 +608,15 @@ var require_Alias = __commonJS((exports) => {
|
|
|
608
608
|
if (!ctx)
|
|
609
609
|
return { source: this.source };
|
|
610
610
|
const { anchors: anchors2, doc, maxAliasCount } = ctx;
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
611
|
+
const source = this.resolve(doc, ctx);
|
|
612
|
+
if (!source) {
|
|
613
613
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
614
614
|
throw new ReferenceError(msg);
|
|
615
615
|
}
|
|
616
|
-
let data = anchors2.get(
|
|
616
|
+
let data = anchors2.get(source);
|
|
617
617
|
if (!data) {
|
|
618
|
-
toJS.toJS(
|
|
619
|
-
data = anchors2.get(
|
|
618
|
+
toJS.toJS(source, null, ctx);
|
|
619
|
+
data = anchors2.get(source);
|
|
620
620
|
}
|
|
621
621
|
if (data?.res === undefined) {
|
|
622
622
|
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
@@ -625,7 +625,7 @@ var require_Alias = __commonJS((exports) => {
|
|
|
625
625
|
if (maxAliasCount >= 0) {
|
|
626
626
|
data.count += 1;
|
|
627
627
|
if (data.aliasCount === 0)
|
|
628
|
-
data.aliasCount = getAliasCount(doc,
|
|
628
|
+
data.aliasCount = getAliasCount(doc, source, anchors2);
|
|
629
629
|
if (data.count * data.aliasCount > maxAliasCount) {
|
|
630
630
|
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
631
631
|
throw new ReferenceError(msg);
|
|
@@ -649,8 +649,8 @@ var require_Alias = __commonJS((exports) => {
|
|
|
649
649
|
}
|
|
650
650
|
function getAliasCount(doc, node2, anchors2) {
|
|
651
651
|
if (identity.isAlias(node2)) {
|
|
652
|
-
const
|
|
653
|
-
const anchor = anchors2 &&
|
|
652
|
+
const source = node2.resolve(doc);
|
|
653
|
+
const anchor = anchors2 && source && anchors2.get(source);
|
|
654
654
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
655
655
|
} else if (identity.isCollection(node2)) {
|
|
656
656
|
let count = 0;
|
|
@@ -1640,10 +1640,10 @@ var require_merge = __commonJS((exports) => {
|
|
|
1640
1640
|
mergeValue(ctx, map, value);
|
|
1641
1641
|
}
|
|
1642
1642
|
function mergeValue(ctx, map, value) {
|
|
1643
|
-
const
|
|
1644
|
-
if (!identity.isMap(
|
|
1643
|
+
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
1644
|
+
if (!identity.isMap(source))
|
|
1645
1645
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1646
|
-
const srcMap =
|
|
1646
|
+
const srcMap = source.toJSON(null, ctx, Map);
|
|
1647
1647
|
for (const [key, value2] of srcMap) {
|
|
1648
1648
|
if (map instanceof Map) {
|
|
1649
1649
|
if (!map.has(key))
|
|
@@ -2194,7 +2194,7 @@ var require_null = __commonJS((exports) => {
|
|
|
2194
2194
|
tag: "tag:yaml.org,2002:null",
|
|
2195
2195
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
2196
2196
|
resolve: () => new Scalar.Scalar(null),
|
|
2197
|
-
stringify: ({ source
|
|
2197
|
+
stringify: ({ source }, ctx) => typeof source === "string" && nullTag.test.test(source) ? source : ctx.options.nullStr
|
|
2198
2198
|
};
|
|
2199
2199
|
exports.nullTag = nullTag;
|
|
2200
2200
|
});
|
|
@@ -2208,11 +2208,11 @@ var require_bool = __commonJS((exports) => {
|
|
|
2208
2208
|
tag: "tag:yaml.org,2002:bool",
|
|
2209
2209
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2210
2210
|
resolve: (str) => new Scalar.Scalar(str[0] === "t" || str[0] === "T"),
|
|
2211
|
-
stringify({ source
|
|
2212
|
-
if (
|
|
2213
|
-
const sv =
|
|
2211
|
+
stringify({ source, value }, ctx) {
|
|
2212
|
+
if (source && boolTag.test.test(source)) {
|
|
2213
|
+
const sv = source[0] === "t" || source[0] === "T";
|
|
2214
2214
|
if (value === sv)
|
|
2215
|
-
return
|
|
2215
|
+
return source;
|
|
2216
2216
|
}
|
|
2217
2217
|
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
2218
2218
|
}
|
|
@@ -2623,10 +2623,10 @@ var require_omap = __commonJS((exports) => {
|
|
|
2623
2623
|
// ../../node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/bool.js
|
|
2624
2624
|
var require_bool2 = __commonJS((exports) => {
|
|
2625
2625
|
var Scalar = require_Scalar();
|
|
2626
|
-
function boolStringify({ value, source
|
|
2626
|
+
function boolStringify({ value, source }, ctx) {
|
|
2627
2627
|
const boolObj = value ? trueTag : falseTag;
|
|
2628
|
-
if (
|
|
2629
|
-
return
|
|
2628
|
+
if (source && boolObj.test.test(source))
|
|
2629
|
+
return source;
|
|
2630
2630
|
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
2631
2631
|
}
|
|
2632
2632
|
var trueTag = {
|
|
@@ -3839,7 +3839,7 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3839
3839
|
let hasSpace = false;
|
|
3840
3840
|
let sep = "";
|
|
3841
3841
|
for (const token of end) {
|
|
3842
|
-
const { source
|
|
3842
|
+
const { source, type } = token;
|
|
3843
3843
|
switch (type) {
|
|
3844
3844
|
case "space":
|
|
3845
3845
|
hasSpace = true;
|
|
@@ -3847,7 +3847,7 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3847
3847
|
case "comment": {
|
|
3848
3848
|
if (reqSpace && !hasSpace)
|
|
3849
3849
|
onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
3850
|
-
const cb =
|
|
3850
|
+
const cb = source.substring(1) || " ";
|
|
3851
3851
|
if (!comment)
|
|
3852
3852
|
comment = cb;
|
|
3853
3853
|
else
|
|
@@ -3857,13 +3857,13 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3857
3857
|
}
|
|
3858
3858
|
case "newline":
|
|
3859
3859
|
if (comment)
|
|
3860
|
-
sep +=
|
|
3860
|
+
sep += source;
|
|
3861
3861
|
hasSpace = true;
|
|
3862
3862
|
break;
|
|
3863
3863
|
default:
|
|
3864
3864
|
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`);
|
|
3865
3865
|
}
|
|
3866
|
-
offset +=
|
|
3866
|
+
offset += source.length;
|
|
3867
3867
|
}
|
|
3868
3868
|
}
|
|
3869
3869
|
return { comment, offset };
|
|
@@ -4251,13 +4251,13 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4251
4251
|
onError(props[0], "IMPOSSIBLE", "Block scalar header not found");
|
|
4252
4252
|
return null;
|
|
4253
4253
|
}
|
|
4254
|
-
const { source
|
|
4255
|
-
const mode =
|
|
4254
|
+
const { source } = props[0];
|
|
4255
|
+
const mode = source[0];
|
|
4256
4256
|
let indent = 0;
|
|
4257
4257
|
let chomp = "";
|
|
4258
4258
|
let error = -1;
|
|
4259
|
-
for (let i = 1;i <
|
|
4260
|
-
const ch =
|
|
4259
|
+
for (let i = 1;i < source.length; ++i) {
|
|
4260
|
+
const ch = source[i];
|
|
4261
4261
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
4262
4262
|
chomp = ch;
|
|
4263
4263
|
else {
|
|
@@ -4269,10 +4269,10 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4269
4269
|
}
|
|
4270
4270
|
}
|
|
4271
4271
|
if (error !== -1)
|
|
4272
|
-
onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${
|
|
4272
|
+
onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
|
|
4273
4273
|
let hasSpace = false;
|
|
4274
4274
|
let comment = "";
|
|
4275
|
-
let length =
|
|
4275
|
+
let length = source.length;
|
|
4276
4276
|
for (let i = 1;i < props.length; ++i) {
|
|
4277
4277
|
const token = props[i];
|
|
4278
4278
|
switch (token.type) {
|
|
@@ -4304,8 +4304,8 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4304
4304
|
}
|
|
4305
4305
|
return { mode, indent, chomp, comment, length };
|
|
4306
4306
|
}
|
|
4307
|
-
function splitLines(
|
|
4308
|
-
const split =
|
|
4307
|
+
function splitLines(source) {
|
|
4308
|
+
const split = source.split(/\n( *)/);
|
|
4309
4309
|
const first = split[0];
|
|
4310
4310
|
const m = first.match(/^( *)/);
|
|
4311
4311
|
const line0 = m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first];
|
|
@@ -4322,22 +4322,22 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4322
4322
|
var Scalar = require_Scalar();
|
|
4323
4323
|
var resolveEnd = require_resolve_end();
|
|
4324
4324
|
function resolveFlowScalar(scalar, strict, onError) {
|
|
4325
|
-
const { offset, type, source
|
|
4325
|
+
const { offset, type, source, end } = scalar;
|
|
4326
4326
|
let _type;
|
|
4327
4327
|
let value;
|
|
4328
4328
|
const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
|
|
4329
4329
|
switch (type) {
|
|
4330
4330
|
case "scalar":
|
|
4331
4331
|
_type = Scalar.Scalar.PLAIN;
|
|
4332
|
-
value = plainValue(
|
|
4332
|
+
value = plainValue(source, _onError);
|
|
4333
4333
|
break;
|
|
4334
4334
|
case "single-quoted-scalar":
|
|
4335
4335
|
_type = Scalar.Scalar.QUOTE_SINGLE;
|
|
4336
|
-
value = singleQuotedValue(
|
|
4336
|
+
value = singleQuotedValue(source, _onError);
|
|
4337
4337
|
break;
|
|
4338
4338
|
case "double-quoted-scalar":
|
|
4339
4339
|
_type = Scalar.Scalar.QUOTE_DOUBLE;
|
|
4340
|
-
value = doubleQuotedValue(
|
|
4340
|
+
value = doubleQuotedValue(source, _onError);
|
|
4341
4341
|
break;
|
|
4342
4342
|
default:
|
|
4343
4343
|
onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
@@ -4345,10 +4345,10 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4345
4345
|
value: "",
|
|
4346
4346
|
type: null,
|
|
4347
4347
|
comment: "",
|
|
4348
|
-
range: [offset, offset +
|
|
4348
|
+
range: [offset, offset + source.length, offset + source.length]
|
|
4349
4349
|
};
|
|
4350
4350
|
}
|
|
4351
|
-
const valueEnd = offset +
|
|
4351
|
+
const valueEnd = offset + source.length;
|
|
4352
4352
|
const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError);
|
|
4353
4353
|
return {
|
|
4354
4354
|
value,
|
|
@@ -4357,9 +4357,9 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4357
4357
|
range: [offset, valueEnd, re.offset]
|
|
4358
4358
|
};
|
|
4359
4359
|
}
|
|
4360
|
-
function plainValue(
|
|
4360
|
+
function plainValue(source, onError) {
|
|
4361
4361
|
let badChar = "";
|
|
4362
|
-
switch (
|
|
4362
|
+
switch (source[0]) {
|
|
4363
4363
|
case "\t":
|
|
4364
4364
|
badChar = "a tab character";
|
|
4365
4365
|
break;
|
|
@@ -4371,25 +4371,25 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4371
4371
|
break;
|
|
4372
4372
|
case "|":
|
|
4373
4373
|
case ">": {
|
|
4374
|
-
badChar = `block scalar indicator ${
|
|
4374
|
+
badChar = `block scalar indicator ${source[0]}`;
|
|
4375
4375
|
break;
|
|
4376
4376
|
}
|
|
4377
4377
|
case "@":
|
|
4378
4378
|
case "`": {
|
|
4379
|
-
badChar = `reserved character ${
|
|
4379
|
+
badChar = `reserved character ${source[0]}`;
|
|
4380
4380
|
break;
|
|
4381
4381
|
}
|
|
4382
4382
|
}
|
|
4383
4383
|
if (badChar)
|
|
4384
4384
|
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
|
|
4385
|
-
return foldLines(
|
|
4385
|
+
return foldLines(source);
|
|
4386
4386
|
}
|
|
4387
|
-
function singleQuotedValue(
|
|
4388
|
-
if (
|
|
4389
|
-
onError(
|
|
4390
|
-
return foldLines(
|
|
4387
|
+
function singleQuotedValue(source, onError) {
|
|
4388
|
+
if (source[source.length - 1] !== "'" || source.length === 1)
|
|
4389
|
+
onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
4390
|
+
return foldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
4391
4391
|
}
|
|
4392
|
-
function foldLines(
|
|
4392
|
+
function foldLines(source) {
|
|
4393
4393
|
let first, line;
|
|
4394
4394
|
try {
|
|
4395
4395
|
first = new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
@@ -4400,14 +4400,14 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4400
4400
|
first = /(.*?)[ \t]*\r?\n/sy;
|
|
4401
4401
|
line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
|
|
4402
4402
|
}
|
|
4403
|
-
let match = first.exec(
|
|
4403
|
+
let match = first.exec(source);
|
|
4404
4404
|
if (!match)
|
|
4405
|
-
return
|
|
4405
|
+
return source;
|
|
4406
4406
|
let res = match[1];
|
|
4407
4407
|
let sep = " ";
|
|
4408
4408
|
let pos = first.lastIndex;
|
|
4409
4409
|
line.lastIndex = pos;
|
|
4410
|
-
while (match = line.exec(
|
|
4410
|
+
while (match = line.exec(source)) {
|
|
4411
4411
|
if (match[1] === "") {
|
|
4412
4412
|
if (sep === `
|
|
4413
4413
|
`)
|
|
@@ -4423,68 +4423,68 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4423
4423
|
}
|
|
4424
4424
|
const last = /[ \t]*(.*)/sy;
|
|
4425
4425
|
last.lastIndex = pos;
|
|
4426
|
-
match = last.exec(
|
|
4426
|
+
match = last.exec(source);
|
|
4427
4427
|
return res + sep + (match?.[1] ?? "");
|
|
4428
4428
|
}
|
|
4429
|
-
function doubleQuotedValue(
|
|
4429
|
+
function doubleQuotedValue(source, onError) {
|
|
4430
4430
|
let res = "";
|
|
4431
|
-
for (let i = 1;i <
|
|
4432
|
-
const ch =
|
|
4433
|
-
if (ch === "\r" &&
|
|
4431
|
+
for (let i = 1;i < source.length - 1; ++i) {
|
|
4432
|
+
const ch = source[i];
|
|
4433
|
+
if (ch === "\r" && source[i + 1] === `
|
|
4434
4434
|
`)
|
|
4435
4435
|
continue;
|
|
4436
4436
|
if (ch === `
|
|
4437
4437
|
`) {
|
|
4438
|
-
const { fold, offset } = foldNewline(
|
|
4438
|
+
const { fold, offset } = foldNewline(source, i);
|
|
4439
4439
|
res += fold;
|
|
4440
4440
|
i = offset;
|
|
4441
4441
|
} else if (ch === "\\") {
|
|
4442
|
-
let next =
|
|
4442
|
+
let next = source[++i];
|
|
4443
4443
|
const cc = escapeCodes[next];
|
|
4444
4444
|
if (cc)
|
|
4445
4445
|
res += cc;
|
|
4446
4446
|
else if (next === `
|
|
4447
4447
|
`) {
|
|
4448
|
-
next =
|
|
4448
|
+
next = source[i + 1];
|
|
4449
4449
|
while (next === " " || next === "\t")
|
|
4450
|
-
next =
|
|
4451
|
-
} else if (next === "\r" &&
|
|
4450
|
+
next = source[++i + 1];
|
|
4451
|
+
} else if (next === "\r" && source[i + 1] === `
|
|
4452
4452
|
`) {
|
|
4453
|
-
next =
|
|
4453
|
+
next = source[++i + 1];
|
|
4454
4454
|
while (next === " " || next === "\t")
|
|
4455
|
-
next =
|
|
4455
|
+
next = source[++i + 1];
|
|
4456
4456
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
4457
4457
|
const length = { x: 2, u: 4, U: 8 }[next];
|
|
4458
|
-
res += parseCharCode(
|
|
4458
|
+
res += parseCharCode(source, i + 1, length, onError);
|
|
4459
4459
|
i += length;
|
|
4460
4460
|
} else {
|
|
4461
|
-
const raw =
|
|
4461
|
+
const raw = source.substr(i - 1, 2);
|
|
4462
4462
|
onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4463
4463
|
res += raw;
|
|
4464
4464
|
}
|
|
4465
4465
|
} else if (ch === " " || ch === "\t") {
|
|
4466
4466
|
const wsStart = i;
|
|
4467
|
-
let next =
|
|
4467
|
+
let next = source[i + 1];
|
|
4468
4468
|
while (next === " " || next === "\t")
|
|
4469
|
-
next =
|
|
4469
|
+
next = source[++i + 1];
|
|
4470
4470
|
if (next !== `
|
|
4471
|
-
` && !(next === "\r" &&
|
|
4471
|
+
` && !(next === "\r" && source[i + 2] === `
|
|
4472
4472
|
`))
|
|
4473
|
-
res += i > wsStart ?
|
|
4473
|
+
res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
|
|
4474
4474
|
} else {
|
|
4475
4475
|
res += ch;
|
|
4476
4476
|
}
|
|
4477
4477
|
}
|
|
4478
|
-
if (
|
|
4479
|
-
onError(
|
|
4478
|
+
if (source[source.length - 1] !== '"' || source.length === 1)
|
|
4479
|
+
onError(source.length, "MISSING_CHAR", 'Missing closing "quote');
|
|
4480
4480
|
return res;
|
|
4481
4481
|
}
|
|
4482
|
-
function foldNewline(
|
|
4482
|
+
function foldNewline(source, offset) {
|
|
4483
4483
|
let fold = "";
|
|
4484
|
-
let ch =
|
|
4484
|
+
let ch = source[offset + 1];
|
|
4485
4485
|
while (ch === " " || ch === "\t" || ch === `
|
|
4486
4486
|
` || ch === "\r") {
|
|
4487
|
-
if (ch === "\r" &&
|
|
4487
|
+
if (ch === "\r" && source[offset + 2] !== `
|
|
4488
4488
|
`)
|
|
4489
4489
|
break;
|
|
4490
4490
|
if (ch === `
|
|
@@ -4492,7 +4492,7 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4492
4492
|
fold += `
|
|
4493
4493
|
`;
|
|
4494
4494
|
offset += 1;
|
|
4495
|
-
ch =
|
|
4495
|
+
ch = source[offset + 1];
|
|
4496
4496
|
}
|
|
4497
4497
|
if (!fold)
|
|
4498
4498
|
fold = " ";
|
|
@@ -4519,12 +4519,12 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4519
4519
|
"\\": "\\",
|
|
4520
4520
|
"\t": "\t"
|
|
4521
4521
|
};
|
|
4522
|
-
function parseCharCode(
|
|
4523
|
-
const cc =
|
|
4522
|
+
function parseCharCode(source, offset, length, onError) {
|
|
4523
|
+
const cc = source.substr(offset, length);
|
|
4524
4524
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
4525
4525
|
const code = ok ? parseInt(cc, 16) : NaN;
|
|
4526
4526
|
if (isNaN(code)) {
|
|
4527
|
-
const raw =
|
|
4527
|
+
const raw = source.substr(offset - 2, length + 2);
|
|
4528
4528
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4529
4529
|
return raw;
|
|
4530
4530
|
}
|
|
@@ -4719,13 +4719,13 @@ var require_compose_node = __commonJS((exports) => {
|
|
|
4719
4719
|
}
|
|
4720
4720
|
return node2;
|
|
4721
4721
|
}
|
|
4722
|
-
function composeAlias({ options }, { offset, source
|
|
4723
|
-
const alias = new Alias.Alias(
|
|
4722
|
+
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
4723
|
+
const alias = new Alias.Alias(source.substring(1));
|
|
4724
4724
|
if (alias.source === "")
|
|
4725
4725
|
onError(offset, "BAD_ALIAS", "Alias cannot be an empty string");
|
|
4726
4726
|
if (alias.source.endsWith(":"))
|
|
4727
|
-
onError(offset +
|
|
4728
|
-
const valueEnd = offset +
|
|
4727
|
+
onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
|
|
4728
|
+
const valueEnd = offset + source.length;
|
|
4729
4729
|
const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
|
|
4730
4730
|
alias.range = [offset, valueEnd, re.offset];
|
|
4731
4731
|
if (re.comment)
|
|
@@ -4790,21 +4790,21 @@ var require_composer = __commonJS((exports) => {
|
|
|
4790
4790
|
return [src, src + 1];
|
|
4791
4791
|
if (Array.isArray(src))
|
|
4792
4792
|
return src.length === 2 ? src : [src[0], src[1]];
|
|
4793
|
-
const { offset, source
|
|
4794
|
-
return [offset, offset + (typeof
|
|
4793
|
+
const { offset, source } = src;
|
|
4794
|
+
return [offset, offset + (typeof source === "string" ? source.length : 1)];
|
|
4795
4795
|
}
|
|
4796
4796
|
function parsePrelude(prelude) {
|
|
4797
4797
|
let comment = "";
|
|
4798
4798
|
let atComment = false;
|
|
4799
4799
|
let afterEmptyLine = false;
|
|
4800
4800
|
for (let i = 0;i < prelude.length; ++i) {
|
|
4801
|
-
const
|
|
4802
|
-
switch (
|
|
4801
|
+
const source = prelude[i];
|
|
4802
|
+
switch (source[0]) {
|
|
4803
4803
|
case "#":
|
|
4804
4804
|
comment += (comment === "" ? "" : afterEmptyLine ? `
|
|
4805
4805
|
|
|
4806
4806
|
` : `
|
|
4807
|
-
`) + (
|
|
4807
|
+
`) + (source.substring(1) || " ");
|
|
4808
4808
|
atComment = true;
|
|
4809
4809
|
afterEmptyLine = false;
|
|
4810
4810
|
break;
|
|
@@ -4829,8 +4829,8 @@ var require_composer = __commonJS((exports) => {
|
|
|
4829
4829
|
this.prelude = [];
|
|
4830
4830
|
this.errors = [];
|
|
4831
4831
|
this.warnings = [];
|
|
4832
|
-
this.onError = (
|
|
4833
|
-
const pos = getErrorPos(
|
|
4832
|
+
this.onError = (source, code, message, warning) => {
|
|
4833
|
+
const pos = getErrorPos(source);
|
|
4834
4834
|
if (warning)
|
|
4835
4835
|
this.warnings.push(new errors2.YAMLWarning(pos, code, message));
|
|
4836
4836
|
else
|
|
@@ -4993,7 +4993,7 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
4993
4993
|
}
|
|
4994
4994
|
function createScalarToken(value, context) {
|
|
4995
4995
|
const { implicitKey = false, indent, inFlow = false, offset = -1, type = "PLAIN" } = context;
|
|
4996
|
-
const
|
|
4996
|
+
const source = stringifyString.stringifyString({ type, value }, {
|
|
4997
4997
|
implicitKey,
|
|
4998
4998
|
indent: indent > 0 ? " ".repeat(indent) : "",
|
|
4999
4999
|
inFlow,
|
|
@@ -5003,13 +5003,13 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5003
5003
|
{ type: "newline", offset: -1, indent, source: `
|
|
5004
5004
|
` }
|
|
5005
5005
|
];
|
|
5006
|
-
switch (
|
|
5006
|
+
switch (source[0]) {
|
|
5007
5007
|
case "|":
|
|
5008
5008
|
case ">": {
|
|
5009
|
-
const he =
|
|
5009
|
+
const he = source.indexOf(`
|
|
5010
5010
|
`);
|
|
5011
|
-
const head =
|
|
5012
|
-
const body =
|
|
5011
|
+
const head = source.substring(0, he);
|
|
5012
|
+
const body = source.substring(he + 1) + `
|
|
5013
5013
|
`;
|
|
5014
5014
|
const props = [
|
|
5015
5015
|
{ type: "block-scalar-header", offset, indent, source: head }
|
|
@@ -5020,11 +5020,11 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5020
5020
|
return { type: "block-scalar", offset, indent, props, source: body };
|
|
5021
5021
|
}
|
|
5022
5022
|
case '"':
|
|
5023
|
-
return { type: "double-quoted-scalar", offset, indent, source
|
|
5023
|
+
return { type: "double-quoted-scalar", offset, indent, source, end };
|
|
5024
5024
|
case "'":
|
|
5025
|
-
return { type: "single-quoted-scalar", offset, indent, source
|
|
5025
|
+
return { type: "single-quoted-scalar", offset, indent, source, end };
|
|
5026
5026
|
default:
|
|
5027
|
-
return { type: "scalar", offset, indent, source
|
|
5027
|
+
return { type: "scalar", offset, indent, source, end };
|
|
5028
5028
|
}
|
|
5029
5029
|
}
|
|
5030
5030
|
function setScalarValue(token, value, context = {}) {
|
|
@@ -5050,32 +5050,32 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5050
5050
|
default:
|
|
5051
5051
|
type = "PLAIN";
|
|
5052
5052
|
}
|
|
5053
|
-
const
|
|
5053
|
+
const source = stringifyString.stringifyString({ type, value }, {
|
|
5054
5054
|
implicitKey: implicitKey || indent === null,
|
|
5055
5055
|
indent: indent !== null && indent > 0 ? " ".repeat(indent) : "",
|
|
5056
5056
|
inFlow,
|
|
5057
5057
|
options: { blockQuote: true, lineWidth: -1 }
|
|
5058
5058
|
});
|
|
5059
|
-
switch (
|
|
5059
|
+
switch (source[0]) {
|
|
5060
5060
|
case "|":
|
|
5061
5061
|
case ">":
|
|
5062
|
-
setBlockScalarValue(token,
|
|
5062
|
+
setBlockScalarValue(token, source);
|
|
5063
5063
|
break;
|
|
5064
5064
|
case '"':
|
|
5065
|
-
setFlowScalarValue(token,
|
|
5065
|
+
setFlowScalarValue(token, source, "double-quoted-scalar");
|
|
5066
5066
|
break;
|
|
5067
5067
|
case "'":
|
|
5068
|
-
setFlowScalarValue(token,
|
|
5068
|
+
setFlowScalarValue(token, source, "single-quoted-scalar");
|
|
5069
5069
|
break;
|
|
5070
5070
|
default:
|
|
5071
|
-
setFlowScalarValue(token,
|
|
5071
|
+
setFlowScalarValue(token, source, "scalar");
|
|
5072
5072
|
}
|
|
5073
5073
|
}
|
|
5074
|
-
function setBlockScalarValue(token,
|
|
5075
|
-
const he =
|
|
5074
|
+
function setBlockScalarValue(token, source) {
|
|
5075
|
+
const he = source.indexOf(`
|
|
5076
5076
|
`);
|
|
5077
|
-
const head =
|
|
5078
|
-
const body =
|
|
5077
|
+
const head = source.substring(0, he);
|
|
5078
|
+
const body = source.substring(he + 1) + `
|
|
5079
5079
|
`;
|
|
5080
5080
|
if (token.type === "block-scalar") {
|
|
5081
5081
|
const header = token.props[0];
|
|
@@ -5112,32 +5112,32 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5112
5112
|
}
|
|
5113
5113
|
return false;
|
|
5114
5114
|
}
|
|
5115
|
-
function setFlowScalarValue(token,
|
|
5115
|
+
function setFlowScalarValue(token, source, type) {
|
|
5116
5116
|
switch (token.type) {
|
|
5117
5117
|
case "scalar":
|
|
5118
5118
|
case "double-quoted-scalar":
|
|
5119
5119
|
case "single-quoted-scalar":
|
|
5120
5120
|
token.type = type;
|
|
5121
|
-
token.source =
|
|
5121
|
+
token.source = source;
|
|
5122
5122
|
break;
|
|
5123
5123
|
case "block-scalar": {
|
|
5124
5124
|
const end = token.props.slice(1);
|
|
5125
|
-
let oa =
|
|
5125
|
+
let oa = source.length;
|
|
5126
5126
|
if (token.props[0].type === "block-scalar-header")
|
|
5127
5127
|
oa -= token.props[0].source.length;
|
|
5128
5128
|
for (const tok of end)
|
|
5129
5129
|
tok.offset += oa;
|
|
5130
5130
|
delete token.props;
|
|
5131
|
-
Object.assign(token, { type, source
|
|
5131
|
+
Object.assign(token, { type, source, end });
|
|
5132
5132
|
break;
|
|
5133
5133
|
}
|
|
5134
5134
|
case "block-map":
|
|
5135
5135
|
case "block-seq": {
|
|
5136
|
-
const offset = token.offset +
|
|
5136
|
+
const offset = token.offset + source.length;
|
|
5137
5137
|
const nl = { type: "newline", offset, indent: token.indent, source: `
|
|
5138
5138
|
` };
|
|
5139
5139
|
delete token.items;
|
|
5140
|
-
Object.assign(token, { type, source
|
|
5140
|
+
Object.assign(token, { type, source, end: [nl] });
|
|
5141
5141
|
break;
|
|
5142
5142
|
}
|
|
5143
5143
|
default: {
|
|
@@ -5146,7 +5146,7 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5146
5146
|
for (const key of Object.keys(token))
|
|
5147
5147
|
if (key !== "type" && key !== "offset")
|
|
5148
5148
|
delete token[key];
|
|
5149
|
-
Object.assign(token, { type, indent, source
|
|
5149
|
+
Object.assign(token, { type, indent, source, end });
|
|
5150
5150
|
}
|
|
5151
5151
|
}
|
|
5152
5152
|
}
|
|
@@ -5297,8 +5297,8 @@ var require_cst = __commonJS((exports) => {
|
|
|
5297
5297
|
return JSON.stringify(token);
|
|
5298
5298
|
}
|
|
5299
5299
|
}
|
|
5300
|
-
function tokenType(
|
|
5301
|
-
switch (
|
|
5300
|
+
function tokenType(source) {
|
|
5301
|
+
switch (source) {
|
|
5302
5302
|
case BOM:
|
|
5303
5303
|
return "byte-order-mark";
|
|
5304
5304
|
case DOCUMENT:
|
|
@@ -5334,7 +5334,7 @@ var require_cst = __commonJS((exports) => {
|
|
|
5334
5334
|
case ",":
|
|
5335
5335
|
return "comma";
|
|
5336
5336
|
}
|
|
5337
|
-
switch (
|
|
5337
|
+
switch (source[0]) {
|
|
5338
5338
|
case " ":
|
|
5339
5339
|
case "\t":
|
|
5340
5340
|
return "space";
|
|
@@ -5410,11 +5410,11 @@ var require_lexer = __commonJS((exports) => {
|
|
|
5410
5410
|
this.next = null;
|
|
5411
5411
|
this.pos = 0;
|
|
5412
5412
|
}
|
|
5413
|
-
*lex(
|
|
5414
|
-
if (
|
|
5415
|
-
if (typeof
|
|
5413
|
+
*lex(source, incomplete = false) {
|
|
5414
|
+
if (source) {
|
|
5415
|
+
if (typeof source !== "string")
|
|
5416
5416
|
throw TypeError("source is not a string");
|
|
5417
|
-
this.buffer = this.buffer ? this.buffer +
|
|
5417
|
+
this.buffer = this.buffer ? this.buffer + source : source;
|
|
5418
5418
|
this.lineEndPos = null;
|
|
5419
5419
|
}
|
|
5420
5420
|
this.atEnd = !incomplete;
|
|
@@ -6088,29 +6088,29 @@ var require_parser = __commonJS((exports) => {
|
|
|
6088
6088
|
this.lexer = new lexer.Lexer;
|
|
6089
6089
|
this.onNewLine = onNewLine;
|
|
6090
6090
|
}
|
|
6091
|
-
*parse(
|
|
6091
|
+
*parse(source, incomplete = false) {
|
|
6092
6092
|
if (this.onNewLine && this.offset === 0)
|
|
6093
6093
|
this.onNewLine(0);
|
|
6094
|
-
for (const lexeme of this.lexer.lex(
|
|
6094
|
+
for (const lexeme of this.lexer.lex(source, incomplete))
|
|
6095
6095
|
yield* this.next(lexeme);
|
|
6096
6096
|
if (!incomplete)
|
|
6097
6097
|
yield* this.end();
|
|
6098
6098
|
}
|
|
6099
|
-
*next(
|
|
6100
|
-
this.source =
|
|
6099
|
+
*next(source) {
|
|
6100
|
+
this.source = source;
|
|
6101
6101
|
if (node_process.env.LOG_TOKENS)
|
|
6102
|
-
console.log("|", cst.prettyToken(
|
|
6102
|
+
console.log("|", cst.prettyToken(source));
|
|
6103
6103
|
if (this.atScalar) {
|
|
6104
6104
|
this.atScalar = false;
|
|
6105
6105
|
yield* this.step();
|
|
6106
|
-
this.offset +=
|
|
6106
|
+
this.offset += source.length;
|
|
6107
6107
|
return;
|
|
6108
6108
|
}
|
|
6109
|
-
const type = cst.tokenType(
|
|
6109
|
+
const type = cst.tokenType(source);
|
|
6110
6110
|
if (!type) {
|
|
6111
|
-
const message = `Not a YAML token: ${
|
|
6112
|
-
yield* this.pop({ type: "error", offset: this.offset, message, source
|
|
6113
|
-
this.offset +=
|
|
6111
|
+
const message = `Not a YAML token: ${source}`;
|
|
6112
|
+
yield* this.pop({ type: "error", offset: this.offset, message, source });
|
|
6113
|
+
this.offset += source.length;
|
|
6114
6114
|
} else if (type === "scalar") {
|
|
6115
6115
|
this.atNewLine = false;
|
|
6116
6116
|
this.atScalar = true;
|
|
@@ -6123,17 +6123,17 @@ var require_parser = __commonJS((exports) => {
|
|
|
6123
6123
|
this.atNewLine = true;
|
|
6124
6124
|
this.indent = 0;
|
|
6125
6125
|
if (this.onNewLine)
|
|
6126
|
-
this.onNewLine(this.offset +
|
|
6126
|
+
this.onNewLine(this.offset + source.length);
|
|
6127
6127
|
break;
|
|
6128
6128
|
case "space":
|
|
6129
|
-
if (this.atNewLine &&
|
|
6130
|
-
this.indent +=
|
|
6129
|
+
if (this.atNewLine && source[0] === " ")
|
|
6130
|
+
this.indent += source.length;
|
|
6131
6131
|
break;
|
|
6132
6132
|
case "explicit-key-ind":
|
|
6133
6133
|
case "map-value-ind":
|
|
6134
6134
|
case "seq-item-ind":
|
|
6135
6135
|
if (this.atNewLine)
|
|
6136
|
-
this.indent +=
|
|
6136
|
+
this.indent += source.length;
|
|
6137
6137
|
break;
|
|
6138
6138
|
case "doc-mode":
|
|
6139
6139
|
case "flow-error-end":
|
|
@@ -6141,7 +6141,7 @@ var require_parser = __commonJS((exports) => {
|
|
|
6141
6141
|
default:
|
|
6142
6142
|
this.atNewLine = false;
|
|
6143
6143
|
}
|
|
6144
|
-
this.offset +=
|
|
6144
|
+
this.offset += source.length;
|
|
6145
6145
|
}
|
|
6146
6146
|
}
|
|
6147
6147
|
*end() {
|
|
@@ -6850,26 +6850,26 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6850
6850
|
const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter || null;
|
|
6851
6851
|
return { lineCounter: lineCounter$1, prettyErrors };
|
|
6852
6852
|
}
|
|
6853
|
-
function parseAllDocuments(
|
|
6853
|
+
function parseAllDocuments(source, options = {}) {
|
|
6854
6854
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
6855
6855
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
6856
6856
|
const composer$1 = new composer.Composer(options);
|
|
6857
|
-
const docs = Array.from(composer$1.compose(parser$1.parse(
|
|
6857
|
+
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
6858
6858
|
if (prettyErrors && lineCounter2)
|
|
6859
6859
|
for (const doc of docs) {
|
|
6860
|
-
doc.errors.forEach(errors2.prettifyError(
|
|
6861
|
-
doc.warnings.forEach(errors2.prettifyError(
|
|
6860
|
+
doc.errors.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6861
|
+
doc.warnings.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6862
6862
|
}
|
|
6863
6863
|
if (docs.length > 0)
|
|
6864
6864
|
return docs;
|
|
6865
6865
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
6866
6866
|
}
|
|
6867
|
-
function parseDocument(
|
|
6867
|
+
function parseDocument(source, options = {}) {
|
|
6868
6868
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
6869
6869
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
6870
6870
|
const composer$1 = new composer.Composer(options);
|
|
6871
6871
|
let doc = null;
|
|
6872
|
-
for (const _doc of composer$1.compose(parser$1.parse(
|
|
6872
|
+
for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
|
|
6873
6873
|
if (!doc)
|
|
6874
6874
|
doc = _doc;
|
|
6875
6875
|
else if (doc.options.logLevel !== "silent") {
|
|
@@ -6878,8 +6878,8 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6878
6878
|
}
|
|
6879
6879
|
}
|
|
6880
6880
|
if (prettyErrors && lineCounter2) {
|
|
6881
|
-
doc.errors.forEach(errors2.prettifyError(
|
|
6882
|
-
doc.warnings.forEach(errors2.prettifyError(
|
|
6881
|
+
doc.errors.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6882
|
+
doc.warnings.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6883
6883
|
}
|
|
6884
6884
|
return doc;
|
|
6885
6885
|
}
|
|
@@ -7700,8 +7700,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
7700
7700
|
if (chars.length < 1) {
|
|
7701
7701
|
return;
|
|
7702
7702
|
}
|
|
7703
|
-
const
|
|
7704
|
-
return `${
|
|
7703
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
7704
|
+
return `${source}*`;
|
|
7705
7705
|
};
|
|
7706
7706
|
var repeatedExtglobRecursion = (pattern) => {
|
|
7707
7707
|
let depth = 0;
|
|
@@ -8487,19 +8487,19 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
8487
8487
|
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
8488
8488
|
if (!match)
|
|
8489
8489
|
return;
|
|
8490
|
-
const
|
|
8491
|
-
if (!
|
|
8490
|
+
const source2 = create(match[1]);
|
|
8491
|
+
if (!source2)
|
|
8492
8492
|
return;
|
|
8493
|
-
return
|
|
8493
|
+
return source2 + DOT_LITERAL + match[2];
|
|
8494
8494
|
}
|
|
8495
8495
|
}
|
|
8496
8496
|
};
|
|
8497
8497
|
const output = utils.removePrefix(input, state);
|
|
8498
|
-
let
|
|
8499
|
-
if (
|
|
8500
|
-
|
|
8498
|
+
let source = create(output);
|
|
8499
|
+
if (source && opts.strictSlashes !== true) {
|
|
8500
|
+
source += `${SLASH_LITERAL}?`;
|
|
8501
8501
|
}
|
|
8502
|
-
return
|
|
8502
|
+
return source;
|
|
8503
8503
|
};
|
|
8504
8504
|
module.exports = parse;
|
|
8505
8505
|
});
|
|
@@ -8607,11 +8607,11 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
8607
8607
|
const opts = options || {};
|
|
8608
8608
|
const prepend = opts.contains ? "" : "^";
|
|
8609
8609
|
const append = opts.contains ? "" : "$";
|
|
8610
|
-
let
|
|
8610
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
8611
8611
|
if (state && state.negated === true) {
|
|
8612
|
-
|
|
8612
|
+
source = `^(?!${source}).*$`;
|
|
8613
8613
|
}
|
|
8614
|
-
const regex = picomatch.toRegex(
|
|
8614
|
+
const regex = picomatch.toRegex(source, options);
|
|
8615
8615
|
if (returnState === true) {
|
|
8616
8616
|
regex.state = state;
|
|
8617
8617
|
}
|
|
@@ -8630,10 +8630,10 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
8630
8630
|
}
|
|
8631
8631
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
8632
8632
|
};
|
|
8633
|
-
picomatch.toRegex = (
|
|
8633
|
+
picomatch.toRegex = (source, options) => {
|
|
8634
8634
|
try {
|
|
8635
8635
|
const opts = options || {};
|
|
8636
|
-
return new RegExp(
|
|
8636
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
8637
8637
|
} catch (err) {
|
|
8638
8638
|
if (options && options.debug === true)
|
|
8639
8639
|
throw err;
|
|
@@ -8775,156 +8775,6 @@ var FactRelation;
|
|
|
8775
8775
|
FactRelation2["Supersedes"] = "supersedes";
|
|
8776
8776
|
FactRelation2["References"] = "references";
|
|
8777
8777
|
})(FactRelation ||= {});
|
|
8778
|
-
// ../core/src/types/serverConfig.ts
|
|
8779
|
-
var DEFAULT_SERVER_CONFIG = {
|
|
8780
|
-
server: {
|
|
8781
|
-
port: 5100,
|
|
8782
|
-
host: "::"
|
|
8783
|
-
},
|
|
8784
|
-
git_hosts: [],
|
|
8785
|
-
daemon_scheduler: {
|
|
8786
|
-
enabled: true,
|
|
8787
|
-
host: "localhost",
|
|
8788
|
-
port: 5110,
|
|
8789
|
-
workspace: "./data/daemon-workspace",
|
|
8790
|
-
max_daemons: 20
|
|
8791
|
-
},
|
|
8792
|
-
doc_db: {
|
|
8793
|
-
provider: "sqlite",
|
|
8794
|
-
sqlite: {
|
|
8795
|
-
path: "./data/c4a.db"
|
|
8796
|
-
},
|
|
8797
|
-
mongodb: {
|
|
8798
|
-
uri: "mongodb://localhost:27017/c4a?directConnection=true",
|
|
8799
|
-
database: "c4a"
|
|
8800
|
-
}
|
|
8801
|
-
},
|
|
8802
|
-
graph_db: {
|
|
8803
|
-
provider: "neo4j",
|
|
8804
|
-
neo4j: {
|
|
8805
|
-
uri: "bolt://localhost:7687",
|
|
8806
|
-
username: "neo4j",
|
|
8807
|
-
password: ""
|
|
8808
|
-
},
|
|
8809
|
-
nebulagraph: {
|
|
8810
|
-
uri: "localhost:9669",
|
|
8811
|
-
username: "root",
|
|
8812
|
-
password: "nebula",
|
|
8813
|
-
space: "c4a"
|
|
8814
|
-
},
|
|
8815
|
-
duckdb: {
|
|
8816
|
-
path: "./data/c4a-graph.duckdb"
|
|
8817
|
-
}
|
|
8818
|
-
},
|
|
8819
|
-
vector_db: {
|
|
8820
|
-
provider: "lancedb",
|
|
8821
|
-
collection_prefix: "c4a_",
|
|
8822
|
-
qdrant: {
|
|
8823
|
-
url: "http://localhost:6333",
|
|
8824
|
-
api_key: ""
|
|
8825
|
-
},
|
|
8826
|
-
milvus: {
|
|
8827
|
-
address: "localhost:19530"
|
|
8828
|
-
},
|
|
8829
|
-
lancedb: {
|
|
8830
|
-
path: "./data/lancedb"
|
|
8831
|
-
}
|
|
8832
|
-
},
|
|
8833
|
-
llm: {
|
|
8834
|
-
provider: "openai",
|
|
8835
|
-
openai: {
|
|
8836
|
-
api_key: "",
|
|
8837
|
-
base_url: "",
|
|
8838
|
-
default_model: "gpt-5.3-codex",
|
|
8839
|
-
wire_api: "chat"
|
|
8840
|
-
},
|
|
8841
|
-
anthropic: {
|
|
8842
|
-
api_key: "",
|
|
8843
|
-
base_url: "",
|
|
8844
|
-
default_model: "claude-opus-4-6"
|
|
8845
|
-
},
|
|
8846
|
-
google: {
|
|
8847
|
-
api_key: "",
|
|
8848
|
-
base_url: "",
|
|
8849
|
-
default_model: "gemini-3-pro-preview"
|
|
8850
|
-
}
|
|
8851
|
-
},
|
|
8852
|
-
task: {
|
|
8853
|
-
concurrency: {
|
|
8854
|
-
code_index: 2,
|
|
8855
|
-
doc_index: 2,
|
|
8856
|
-
remote_clone: 2,
|
|
8857
|
-
modeling: 1
|
|
8858
|
-
},
|
|
8859
|
-
default_timeout_ms: 150 * 60 * 1000,
|
|
8860
|
-
memory_ttl_ms: 48 * 60 * 60 * 1000,
|
|
8861
|
-
cleanup_interval_ms: 10 * 60 * 1000,
|
|
8862
|
-
log_max_entries: 500
|
|
8863
|
-
},
|
|
8864
|
-
indexing: {
|
|
8865
|
-
task_timeout_ms: 150 * 60 * 1000,
|
|
8866
|
-
file_timeout_ms: 15 * 60 * 1000
|
|
8867
|
-
},
|
|
8868
|
-
intent_router: {
|
|
8869
|
-
provider: "huggingface",
|
|
8870
|
-
huggingface: {
|
|
8871
|
-
model_id: "context4ai/intent-router-onnx",
|
|
8872
|
-
cache_dir: "./models/intent-router"
|
|
8873
|
-
},
|
|
8874
|
-
xenova: {
|
|
8875
|
-
model_id: "context4ai/intent-router-onnx",
|
|
8876
|
-
cache_dir: "./models/intent-router"
|
|
8877
|
-
}
|
|
8878
|
-
},
|
|
8879
|
-
embedding: {
|
|
8880
|
-
provider: "huggingface",
|
|
8881
|
-
huggingface: {
|
|
8882
|
-
model_id: "Xenova/all-MiniLM-L6-v2",
|
|
8883
|
-
dtype: "q8",
|
|
8884
|
-
cache_dir: "./models/embedding"
|
|
8885
|
-
},
|
|
8886
|
-
xenova: {
|
|
8887
|
-
model_id: "Xenova/bge-m3",
|
|
8888
|
-
dtype: "q8",
|
|
8889
|
-
cache_dir: "./models/embedding"
|
|
8890
|
-
},
|
|
8891
|
-
openai: {
|
|
8892
|
-
api_key: "",
|
|
8893
|
-
base_url: "",
|
|
8894
|
-
model_id: "text-embedding-3-small"
|
|
8895
|
-
},
|
|
8896
|
-
google: {
|
|
8897
|
-
api_key: "",
|
|
8898
|
-
model_id: "text-embedding-004"
|
|
8899
|
-
}
|
|
8900
|
-
},
|
|
8901
|
-
reranker: {
|
|
8902
|
-
enabled: false,
|
|
8903
|
-
provider: "huggingface",
|
|
8904
|
-
huggingface: {
|
|
8905
|
-
model_id: "onnx-community/bge-reranker-v2-m3-ONNX",
|
|
8906
|
-
dtype: "q8",
|
|
8907
|
-
cache_dir: "./models/reranker"
|
|
8908
|
-
},
|
|
8909
|
-
xenova: {
|
|
8910
|
-
model_id: "onnx-community/bge-reranker-v2-m3-ONNX",
|
|
8911
|
-
dtype: "q8",
|
|
8912
|
-
cache_dir: "./models/reranker"
|
|
8913
|
-
},
|
|
8914
|
-
max_rerank: 20
|
|
8915
|
-
}
|
|
8916
|
-
};
|
|
8917
|
-
// ../core/src/types/daemon.ts
|
|
8918
|
-
var CODE_PACKAGE_FILES = new Set([
|
|
8919
|
-
"package.json",
|
|
8920
|
-
"pyproject.toml",
|
|
8921
|
-
"setup.py",
|
|
8922
|
-
"go.mod",
|
|
8923
|
-
"cargo.toml",
|
|
8924
|
-
"pom.xml",
|
|
8925
|
-
"build.gradle",
|
|
8926
|
-
"build.gradle.kts"
|
|
8927
|
-
]);
|
|
8928
8778
|
// ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
8929
8779
|
var exports_external = {};
|
|
8930
8780
|
__export(exports_external, {
|
|
@@ -13651,9 +13501,9 @@ class ExtractionPluginRegistry {
|
|
|
13651
13501
|
register(plugin) {
|
|
13652
13502
|
this.#plugins.push(plugin);
|
|
13653
13503
|
}
|
|
13654
|
-
resolve(
|
|
13655
|
-
const declaredLanguage =
|
|
13656
|
-
const manifestLanguages = new Set(
|
|
13504
|
+
resolve(source) {
|
|
13505
|
+
const declaredLanguage = source.language?.toLowerCase();
|
|
13506
|
+
const manifestLanguages = new Set(source.manifests.flatMap((manifest) => MANIFEST_LANGUAGE_CANDIDATES[manifest.type] ?? []));
|
|
13657
13507
|
const candidates = this.#plugins.filter((plugin) => {
|
|
13658
13508
|
const pluginLanguages = plugin.languages.map((language) => language.toLowerCase());
|
|
13659
13509
|
if (declaredLanguage) {
|
|
@@ -13665,7 +13515,7 @@ class ExtractionPluginRegistry {
|
|
|
13665
13515
|
return pluginLanguages.some((language) => manifestLanguages.has(language));
|
|
13666
13516
|
});
|
|
13667
13517
|
for (const plugin of candidates) {
|
|
13668
|
-
if (plugin.canHandle(
|
|
13518
|
+
if (plugin.canHandle(source)) {
|
|
13669
13519
|
return plugin;
|
|
13670
13520
|
}
|
|
13671
13521
|
}
|
|
@@ -13723,6 +13573,11 @@ import { Buffer as Buffer2 } from "node:buffer";
|
|
|
13723
13573
|
import { createHash as createHash2 } from "node:crypto";
|
|
13724
13574
|
|
|
13725
13575
|
// src/documentCaptureFidelity.ts
|
|
13576
|
+
var DOCUMENT_RESOURCE_SOURCE_MISSING_REASON_CODE = "document.resource.source-missing";
|
|
13577
|
+
var DOCUMENT_RESOURCE_PERMISSION_DENIED_REASON_CODE = "document.resource.permission-denied";
|
|
13578
|
+
function isNonBlockingDocumentResourceFailureReasonCode(code) {
|
|
13579
|
+
return code === DOCUMENT_RESOURCE_SOURCE_MISSING_REASON_CODE || code === DOCUMENT_RESOURCE_PERMISSION_DENIED_REASON_CODE;
|
|
13580
|
+
}
|
|
13726
13581
|
function isRecord(value) {
|
|
13727
13582
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13728
13583
|
}
|
|
@@ -13732,6 +13587,17 @@ function requiredString(value, field) {
|
|
|
13732
13587
|
}
|
|
13733
13588
|
return value.trim();
|
|
13734
13589
|
}
|
|
13590
|
+
function resourceAssetPath(value, field) {
|
|
13591
|
+
const path2 = requiredString(value, field);
|
|
13592
|
+
if (path2.startsWith("/") || path2.includes("\\") || path2.includes("\x00") || /^[a-zA-Z]:/u.test(path2)) {
|
|
13593
|
+
throw new TypeError(`${field} must be a POSIX relative path`);
|
|
13594
|
+
}
|
|
13595
|
+
const segments = path2.split("/");
|
|
13596
|
+
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
13597
|
+
throw new TypeError(`${field} must not contain empty, dot, or parent segments`);
|
|
13598
|
+
}
|
|
13599
|
+
return path2;
|
|
13600
|
+
}
|
|
13735
13601
|
function counts(value, field) {
|
|
13736
13602
|
if (!isRecord(value))
|
|
13737
13603
|
throw new TypeError(`${field} must be an object`);
|
|
@@ -13827,6 +13693,64 @@ function parseDocumentCaptureFidelity(value, field) {
|
|
|
13827
13693
|
issues
|
|
13828
13694
|
};
|
|
13829
13695
|
}
|
|
13696
|
+
function parseDocumentResourceMaterialization(value, field) {
|
|
13697
|
+
if (value === undefined)
|
|
13698
|
+
return;
|
|
13699
|
+
if (!isRecord(value))
|
|
13700
|
+
throw new TypeError(`${field} must be an object`);
|
|
13701
|
+
if (value.status !== "complete" && value.status !== "warning" && value.status !== "error") {
|
|
13702
|
+
throw new TypeError(`${field}.status must be complete, warning, or error`);
|
|
13703
|
+
}
|
|
13704
|
+
const discovered = counts(value.discovered, `${field}.discovered`);
|
|
13705
|
+
const materialized = counts(value.materialized, `${field}.materialized`);
|
|
13706
|
+
const referenceOnly = counts(value.reference_only, `${field}.reference_only`);
|
|
13707
|
+
const failed = counts(value.failed, `${field}.failed`);
|
|
13708
|
+
if (!Array.isArray(value.items))
|
|
13709
|
+
throw new TypeError(`${field}.items must be an array`);
|
|
13710
|
+
const items = value.items.map((item, index) => {
|
|
13711
|
+
if (!isRecord(item))
|
|
13712
|
+
throw new TypeError(`${field}.items[${index}] must be an object`);
|
|
13713
|
+
if (item.status !== "materialized" && item.status !== "reference-only" && item.status !== "failed") {
|
|
13714
|
+
throw new TypeError(`${field}.items[${index}].status is invalid`);
|
|
13715
|
+
}
|
|
13716
|
+
if (typeof item.required !== "boolean" || !Array.isArray(item.asset_paths) || item.asset_paths.some((path2) => typeof path2 !== "string" || path2.trim().length === 0)) {
|
|
13717
|
+
throw new TypeError(`${field}.items[${index}] must include required and asset_paths`);
|
|
13718
|
+
}
|
|
13719
|
+
const reasonCode = item.reason_code === undefined ? undefined : requiredString(item.reason_code, `${field}.items[${index}].reason_code`);
|
|
13720
|
+
const reason = item.reason === undefined ? undefined : requiredString(item.reason, `${field}.items[${index}].reason`);
|
|
13721
|
+
return {
|
|
13722
|
+
kind: requiredString(item.kind, `${field}.items[${index}].kind`),
|
|
13723
|
+
locator: requiredString(item.locator, `${field}.items[${index}].locator`),
|
|
13724
|
+
status: item.status,
|
|
13725
|
+
required: item.required,
|
|
13726
|
+
asset_paths: item.asset_paths.map((path2, pathIndex) => resourceAssetPath(path2, `${field}.items[${index}].asset_paths[${pathIndex}]`)),
|
|
13727
|
+
...reasonCode !== undefined ? { reason_code: reasonCode } : {},
|
|
13728
|
+
...reason !== undefined ? { reason } : {}
|
|
13729
|
+
};
|
|
13730
|
+
});
|
|
13731
|
+
const expectedStatus = items.some((item) => item.status === "failed" && item.required && !isNonBlockingDocumentResourceFailureReasonCode(item.reason_code)) ? "error" : items.some((item) => item.status === "failed") || items.some((item) => item.status === "reference-only" && item.kind === "poll" && item.reason?.includes("absent") === true) ? "warning" : "complete";
|
|
13732
|
+
if (value.status !== expectedStatus)
|
|
13733
|
+
throw new TypeError(`${field}.status must be ${expectedStatus} for its items`);
|
|
13734
|
+
const expected = (status) => {
|
|
13735
|
+
const map = new Map;
|
|
13736
|
+
for (const item of items) {
|
|
13737
|
+
if (status !== undefined && item.status !== status)
|
|
13738
|
+
continue;
|
|
13739
|
+
map.set(item.kind, (map.get(item.kind) ?? 0) + 1);
|
|
13740
|
+
}
|
|
13741
|
+
return Object.fromEntries([...map].sort(([left], [right]) => left.localeCompare(right)));
|
|
13742
|
+
};
|
|
13743
|
+
for (const [name, actual, wanted] of [
|
|
13744
|
+
["discovered", discovered, expected()],
|
|
13745
|
+
["materialized", materialized, expected("materialized")],
|
|
13746
|
+
["reference_only", referenceOnly, expected("reference-only")],
|
|
13747
|
+
["failed", failed, expected("failed")]
|
|
13748
|
+
]) {
|
|
13749
|
+
if (JSON.stringify(actual) !== JSON.stringify(wanted))
|
|
13750
|
+
throw new TypeError(`${field}.${name} does not match items`);
|
|
13751
|
+
}
|
|
13752
|
+
return { status: value.status, discovered, materialized, reference_only: referenceOnly, failed, items };
|
|
13753
|
+
}
|
|
13830
13754
|
|
|
13831
13755
|
// src/documentEvidence.ts
|
|
13832
13756
|
var DOCUMENT_EVIDENCE_NORMALIZER_VERSION = "document-evidence-normalizer.v2";
|
|
@@ -13903,8 +13827,8 @@ function decodeSnapshotLocatorPath(path2) {
|
|
|
13903
13827
|
throw new TypeError(`invalid encoded snapshot locator path: ${path2}: ${message}`);
|
|
13904
13828
|
}
|
|
13905
13829
|
}
|
|
13906
|
-
function parseDocumentSourceLocator(
|
|
13907
|
-
const match = /^(file|lark):(.+)$/u.exec(
|
|
13830
|
+
function parseDocumentSourceLocator(source) {
|
|
13831
|
+
const match = /^(file|lark):(.+)$/u.exec(source);
|
|
13908
13832
|
if (match?.[1] === undefined || match[2] === undefined)
|
|
13909
13833
|
return null;
|
|
13910
13834
|
const segments = match[2].split("/");
|
|
@@ -14127,12 +14051,18 @@ function createDocumentSnapshotFileEntry(input) {
|
|
|
14127
14051
|
function createDocumentSnapshotManifest(input) {
|
|
14128
14052
|
const files = input.files.map(createDocumentSnapshotFileEntry);
|
|
14129
14053
|
const sourceName = normalizeDocumentSourceName(input.sourceName);
|
|
14054
|
+
const logicalFiles = [...input.files];
|
|
14055
|
+
for (const asset of input.assets ?? []) {
|
|
14056
|
+
if (asset.role !== "evidence" || asset.content_hash === undefined)
|
|
14057
|
+
continue;
|
|
14058
|
+
logicalFiles.push({ path: `@asset/${normalizeSnapshotRelativePath(asset.path)}`, bytes: asset.content_hash });
|
|
14059
|
+
}
|
|
14130
14060
|
return parseDocumentSnapshotManifest({
|
|
14131
14061
|
schema_version: DOCUMENT_SNAPSHOT_MANIFEST_SCHEMA_VERSION,
|
|
14132
14062
|
source_type: input.sourceType,
|
|
14133
14063
|
source_name: sourceName,
|
|
14134
14064
|
captured_at: input.capturedAt,
|
|
14135
|
-
snapshot_hash: computeLogicalRawHash(
|
|
14065
|
+
snapshot_hash: computeLogicalRawHash(logicalFiles),
|
|
14136
14066
|
normalizer_version: input.normalizerVersion ?? DOCUMENT_EVIDENCE_NORMALIZER_VERSION,
|
|
14137
14067
|
files,
|
|
14138
14068
|
...input.assets !== undefined ? { assets: input.assets } : {},
|
|
@@ -14176,12 +14106,14 @@ function parseAssetEntry(value, index) {
|
|
|
14176
14106
|
}
|
|
14177
14107
|
const contentHash2 = typeof value.content_hash === "string" && HASH_ID_RE.test(value.content_hash) ? normalizeHashId(value.content_hash) : undefined;
|
|
14178
14108
|
const mediaType = typeof value.media_type === "string" && value.media_type.trim().length > 0 ? value.media_type.trim() : undefined;
|
|
14179
|
-
const
|
|
14109
|
+
const role = value.role === "evidence" || value.role === "presentation" || value.role === "audit" ? value.role : undefined;
|
|
14110
|
+
const source = parseStringRecord(value.source, `snapshot manifest assets[${index}].source`);
|
|
14180
14111
|
return {
|
|
14181
14112
|
path: normalizeSnapshotRelativePath(value.path),
|
|
14182
14113
|
...contentHash2 !== undefined ? { content_hash: contentHash2 } : {},
|
|
14183
14114
|
...mediaType !== undefined ? { media_type: mediaType } : {},
|
|
14184
|
-
...
|
|
14115
|
+
...role !== undefined ? { role } : {},
|
|
14116
|
+
...source !== undefined ? { source } : {}
|
|
14185
14117
|
};
|
|
14186
14118
|
}
|
|
14187
14119
|
function parseStringRecord(value, field) {
|
|
@@ -14273,13 +14205,45 @@ function optionalRouteHints(value, field) {
|
|
|
14273
14205
|
});
|
|
14274
14206
|
return result.length > 0 ? result : undefined;
|
|
14275
14207
|
}
|
|
14208
|
+
function captureReportMetadata(value) {
|
|
14209
|
+
if (value === undefined)
|
|
14210
|
+
return;
|
|
14211
|
+
if (!isRecord2(value))
|
|
14212
|
+
throw new TypeError("snapshot manifest metadata.capture.report must be an object");
|
|
14213
|
+
const path2 = optionalMetadataString(value.path, "snapshot manifest metadata.capture.report.path");
|
|
14214
|
+
if (path2 === undefined)
|
|
14215
|
+
throw new TypeError("snapshot manifest metadata.capture.report.path is required");
|
|
14216
|
+
const fidelityStatus = value.fidelityStatus;
|
|
14217
|
+
const evidenceStatus = value.evidenceStatus;
|
|
14218
|
+
const projectionStatus = value.projectionStatus;
|
|
14219
|
+
const resourceStatus = value.resourceStatus;
|
|
14220
|
+
if (fidelityStatus !== "complete" && fidelityStatus !== "warning" && fidelityStatus !== "error") {
|
|
14221
|
+
throw new TypeError("snapshot manifest metadata.capture.report.fidelityStatus is invalid");
|
|
14222
|
+
}
|
|
14223
|
+
if (evidenceStatus !== "complete" && evidenceStatus !== "error") {
|
|
14224
|
+
throw new TypeError("snapshot manifest metadata.capture.report.evidenceStatus is invalid");
|
|
14225
|
+
}
|
|
14226
|
+
if (projectionStatus !== "complete" && projectionStatus !== "generic" && projectionStatus !== "warning" && projectionStatus !== "error") {
|
|
14227
|
+
throw new TypeError("snapshot manifest metadata.capture.report.projectionStatus is invalid");
|
|
14228
|
+
}
|
|
14229
|
+
if (resourceStatus !== "complete" && resourceStatus !== "warning" && resourceStatus !== "error") {
|
|
14230
|
+
throw new TypeError("snapshot manifest metadata.capture.report.resourceStatus is invalid");
|
|
14231
|
+
}
|
|
14232
|
+
return {
|
|
14233
|
+
path: normalizeSnapshotRelativePath(path2),
|
|
14234
|
+
fidelityStatus,
|
|
14235
|
+
evidenceStatus,
|
|
14236
|
+
projectionStatus,
|
|
14237
|
+
resourceStatus
|
|
14238
|
+
};
|
|
14239
|
+
}
|
|
14276
14240
|
function parseManifestMetadata(value) {
|
|
14277
14241
|
if (value === undefined)
|
|
14278
14242
|
return;
|
|
14279
14243
|
if (!isRecord2(value)) {
|
|
14280
14244
|
throw new TypeError("snapshot manifest metadata must be an object");
|
|
14281
14245
|
}
|
|
14282
|
-
let
|
|
14246
|
+
let source;
|
|
14283
14247
|
if (value.source !== undefined) {
|
|
14284
14248
|
if (!isRecord2(value.source)) {
|
|
14285
14249
|
throw new TypeError("snapshot manifest metadata.source must be an object");
|
|
@@ -14289,15 +14253,15 @@ function parseManifestMetadata(value) {
|
|
|
14289
14253
|
const wikiToken = optionalMetadataString(value.source.wikiToken, "snapshot manifest metadata.source.wikiToken");
|
|
14290
14254
|
const title = optionalMetadataString(value.source.title, "snapshot manifest metadata.source.title");
|
|
14291
14255
|
const revisionId = optionalMetadataString(value.source.revisionId, "snapshot manifest metadata.source.revisionId");
|
|
14292
|
-
|
|
14256
|
+
source = {
|
|
14293
14257
|
...url !== undefined ? { url } : {},
|
|
14294
14258
|
...docToken !== undefined ? { docToken } : {},
|
|
14295
14259
|
...wikiToken !== undefined ? { wikiToken } : {},
|
|
14296
14260
|
...title !== undefined ? { title } : {},
|
|
14297
14261
|
...revisionId !== undefined ? { revisionId } : {}
|
|
14298
14262
|
};
|
|
14299
|
-
if (Object.keys(
|
|
14300
|
-
|
|
14263
|
+
if (Object.keys(source).length === 0)
|
|
14264
|
+
source = undefined;
|
|
14301
14265
|
}
|
|
14302
14266
|
let capture;
|
|
14303
14267
|
if (value.capture !== undefined) {
|
|
@@ -14308,19 +14272,23 @@ function parseManifestMetadata(value) {
|
|
|
14308
14272
|
const documentExtensions = optionalMetadataStringArray(value.capture.documentExtensions, "snapshot manifest metadata.capture.documentExtensions");
|
|
14309
14273
|
const routeFiles = optionalRouteFiles(value.capture.routeFiles, "snapshot manifest metadata.capture.routeFiles");
|
|
14310
14274
|
const routeHints = optionalRouteHints(value.capture.routeHints, "snapshot manifest metadata.capture.routeHints");
|
|
14275
|
+
const report = captureReportMetadata(value.capture.report);
|
|
14311
14276
|
const fidelity = parseDocumentCaptureFidelity(value.capture.fidelity, "snapshot manifest metadata.capture.fidelity");
|
|
14277
|
+
const resourceMaterialization = parseDocumentResourceMaterialization(value.capture.resourceMaterialization, "snapshot manifest metadata.capture.resourceMaterialization");
|
|
14312
14278
|
capture = {
|
|
14313
14279
|
...include !== undefined ? { include } : {},
|
|
14314
14280
|
...documentExtensions !== undefined ? { documentExtensions } : {},
|
|
14315
14281
|
...routeFiles !== undefined ? { routeFiles } : {},
|
|
14316
14282
|
...routeHints !== undefined ? { routeHints } : {},
|
|
14317
|
-
...
|
|
14283
|
+
...report !== undefined ? { report } : {},
|
|
14284
|
+
...fidelity !== undefined ? { fidelity } : {},
|
|
14285
|
+
...resourceMaterialization !== undefined ? { resourceMaterialization } : {}
|
|
14318
14286
|
};
|
|
14319
14287
|
if (Object.keys(capture).length === 0)
|
|
14320
14288
|
capture = undefined;
|
|
14321
14289
|
}
|
|
14322
|
-
return
|
|
14323
|
-
...
|
|
14290
|
+
return source !== undefined || capture !== undefined ? {
|
|
14291
|
+
...source !== undefined ? { source } : {},
|
|
14324
14292
|
...capture !== undefined ? { capture } : {}
|
|
14325
14293
|
} : {};
|
|
14326
14294
|
}
|
|
@@ -14943,8 +14911,8 @@ var normalizeExtractionPaths = (extraction, entryDetection, modulePath, commitHa
|
|
|
14943
14911
|
entryDetection: prefixEntryDetectionPaths(entryDetection, modulePath),
|
|
14944
14912
|
extraction: prefixExtractionPaths(extraction, modulePath, commitHash)
|
|
14945
14913
|
});
|
|
14946
|
-
var extractLeadingJsDoc = (
|
|
14947
|
-
const match =
|
|
14914
|
+
var extractLeadingJsDoc = (source) => {
|
|
14915
|
+
const match = source.match(/^\s*\/\*\*([\s\S]*?)\*\//u);
|
|
14948
14916
|
if (!match?.[1])
|
|
14949
14917
|
return;
|
|
14950
14918
|
const doc = match[1].replace(/^\s*\* ?/gmu, "").replace(/\r\n?/gu, `
|
|
@@ -15095,10 +15063,10 @@ var normalizeDoc = (value) => {
|
|
|
15095
15063
|
`).replace(/[ \t]+$/gmu, "").trim();
|
|
15096
15064
|
return normalized.length > 0 ? normalized : undefined;
|
|
15097
15065
|
};
|
|
15098
|
-
var resolveVersion = (label,
|
|
15066
|
+
var resolveVersion = (label, source) => {
|
|
15099
15067
|
const canonical = typeof label === "string" ? canonicalizeCodeVersionLabel(label) : null;
|
|
15100
15068
|
if (canonical) {
|
|
15101
|
-
return { version_label: canonical, version_source:
|
|
15069
|
+
return { version_label: canonical, version_source: source ?? "package-json" };
|
|
15102
15070
|
}
|
|
15103
15071
|
return { version_label: FALLBACK_VERSION_LABEL, version_source: "fallback-0.0.1" };
|
|
15104
15072
|
};
|
|
@@ -15112,7 +15080,7 @@ var commonCommit = (rows) => {
|
|
|
15112
15080
|
const commits = new Set(rows.digests.map((row) => row.dir_commit).filter((commit) => commit && commit !== "unknown"));
|
|
15113
15081
|
return commits.size === 1 ? Array.from(commits)[0] : null;
|
|
15114
15082
|
};
|
|
15115
|
-
var metaText = (manifest,
|
|
15083
|
+
var metaText = (manifest, source, rows) => {
|
|
15116
15084
|
const digestByModule = new Map(rows.digests.map((row) => [row.module_path, row]));
|
|
15117
15085
|
const meta = {
|
|
15118
15086
|
schema_version: CODE_SNAPSHOT_META_SCHEMA_VERSION,
|
|
@@ -15138,7 +15106,7 @@ var metaText = (manifest, source2, rows) => {
|
|
|
15138
15106
|
code_snapshot_contract_version: manifest.code_snapshot_contract_version,
|
|
15139
15107
|
snapshot_content_hash: manifest.snapshot_content_hash,
|
|
15140
15108
|
toolchain: manifest.toolchain,
|
|
15141
|
-
version_policy:
|
|
15109
|
+
version_policy: source.version_policy,
|
|
15142
15110
|
...manifest.version_label ? { version_label: manifest.version_label } : {},
|
|
15143
15111
|
...manifest.version_source ? { version_source: manifest.version_source } : {},
|
|
15144
15112
|
head_commit: manifest.head_commit,
|
|
@@ -15301,7 +15269,7 @@ var buildCodeSnapshot = (input) => {
|
|
|
15301
15269
|
};
|
|
15302
15270
|
const snapshotContentHash = hashStable(sourceHashInput);
|
|
15303
15271
|
const dirty = rows.digests.some((row) => row.dirty);
|
|
15304
|
-
const
|
|
15272
|
+
const source = {
|
|
15305
15273
|
source_id: input.sourceId,
|
|
15306
15274
|
source_slug: input.sourceSlug,
|
|
15307
15275
|
source_type: "aspect-code",
|
|
@@ -15317,13 +15285,13 @@ var buildCodeSnapshot = (input) => {
|
|
|
15317
15285
|
const commonVersionLabel = commonVersionField(rows.digests, "version_label");
|
|
15318
15286
|
const commonVersionSource = commonVersionField(rows.digests, "version_source");
|
|
15319
15287
|
if (commonVersionLabel && commonVersionLabel !== "mixed") {
|
|
15320
|
-
|
|
15288
|
+
source.version_label = commonVersionLabel;
|
|
15321
15289
|
}
|
|
15322
15290
|
if (commonVersionSource) {
|
|
15323
|
-
|
|
15291
|
+
source.version_source = commonVersionSource;
|
|
15324
15292
|
}
|
|
15325
15293
|
const files = {
|
|
15326
|
-
"source.yaml": manifestText(
|
|
15294
|
+
"source.yaml": manifestText(source),
|
|
15327
15295
|
"digests.jsonl": jsonl(rows.digests),
|
|
15328
15296
|
"source-files.jsonl": jsonl(rows.sourceFiles),
|
|
15329
15297
|
"packages.jsonl": jsonl(rows.packages),
|
|
@@ -15341,9 +15309,9 @@ var buildCodeSnapshot = (input) => {
|
|
|
15341
15309
|
dirty,
|
|
15342
15310
|
script_hash: input.scriptHash,
|
|
15343
15311
|
toolchain: input.toolchain,
|
|
15344
|
-
version_policy:
|
|
15345
|
-
...
|
|
15346
|
-
...
|
|
15312
|
+
version_policy: source.version_policy,
|
|
15313
|
+
...source.version_label ? { version_label: source.version_label } : {},
|
|
15314
|
+
...source.version_source ? { version_source: source.version_source } : {},
|
|
15347
15315
|
snapshot_content_hash: snapshotContentHash,
|
|
15348
15316
|
...input.worktreeContentHash ? { worktree_content_hash: input.worktreeContentHash } : {},
|
|
15349
15317
|
module_count: rows.packages.length,
|
|
@@ -15354,7 +15322,7 @@ var buildCodeSnapshot = (input) => {
|
|
|
15354
15322
|
let converged = false;
|
|
15355
15323
|
for (let i = 0;i < 50; i++) {
|
|
15356
15324
|
files["manifest.json"] = manifestText(manifest);
|
|
15357
|
-
files["_meta.yaml"] = metaText(manifest,
|
|
15325
|
+
files["_meta.yaml"] = metaText(manifest, source, rows);
|
|
15358
15326
|
const totalBytes = Object.values(files).reduce((sum, content) => sum + byteLength(content), 0);
|
|
15359
15327
|
if (totalBytes === manifest.total_bytes) {
|
|
15360
15328
|
converged = true;
|
|
@@ -15366,8 +15334,8 @@ var buildCodeSnapshot = (input) => {
|
|
|
15366
15334
|
throw new Error("code snapshot manifest total_bytes did not converge");
|
|
15367
15335
|
}
|
|
15368
15336
|
files["manifest.json"] = manifestText(manifest);
|
|
15369
|
-
files["_meta.yaml"] = metaText(manifest,
|
|
15370
|
-
return { source
|
|
15337
|
+
files["_meta.yaml"] = metaText(manifest, source, rows);
|
|
15338
|
+
return { source, manifest, rows, files };
|
|
15371
15339
|
};
|
|
15372
15340
|
// src/runner.ts
|
|
15373
15341
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -15546,29 +15514,29 @@ var resetParser = () => {
|
|
|
15546
15514
|
parsedBytesSinceReset = 0;
|
|
15547
15515
|
parserDead = false;
|
|
15548
15516
|
};
|
|
15549
|
-
var tryParse = async (
|
|
15517
|
+
var tryParse = async (source, isTsx) => {
|
|
15550
15518
|
const { parser, tsLanguage, tsxLanguage } = await initParser();
|
|
15551
15519
|
parser.setLanguage(isTsx ? tsxLanguage : tsLanguage);
|
|
15552
|
-
const tree = parser.parse(
|
|
15553
|
-
parsedBytesSinceReset +=
|
|
15520
|
+
const tree = parser.parse(source);
|
|
15521
|
+
parsedBytesSinceReset += source.length;
|
|
15554
15522
|
if (tree.rootNode.hasError()) {
|
|
15555
15523
|
return null;
|
|
15556
15524
|
}
|
|
15557
15525
|
return tree;
|
|
15558
15526
|
};
|
|
15559
|
-
var parseFile = async (
|
|
15527
|
+
var parseFile = async (source, isTsx) => {
|
|
15560
15528
|
if (parserDead)
|
|
15561
15529
|
return null;
|
|
15562
15530
|
if (parsedBytesSinceReset > PARSER_RESET_THRESHOLD) {
|
|
15563
15531
|
resetParser();
|
|
15564
15532
|
}
|
|
15565
15533
|
try {
|
|
15566
|
-
return await tryParse(
|
|
15534
|
+
return await tryParse(source, isTsx);
|
|
15567
15535
|
} catch {
|
|
15568
15536
|
resetParser();
|
|
15569
15537
|
}
|
|
15570
15538
|
try {
|
|
15571
|
-
return await tryParse(
|
|
15539
|
+
return await tryParse(source, isTsx);
|
|
15572
15540
|
} catch (error) {
|
|
15573
15541
|
console.warn("[extract] Parser unrecoverable after retry, skipping remaining files:", error);
|
|
15574
15542
|
parserDead = true;
|
|
@@ -15652,6 +15620,8 @@ export {
|
|
|
15652
15620
|
parseFile,
|
|
15653
15621
|
parseDocumentSourceLocator,
|
|
15654
15622
|
parseDocumentSnapshotManifest,
|
|
15623
|
+
parseDocumentResourceMaterialization,
|
|
15624
|
+
parseDocumentCaptureFidelity,
|
|
15655
15625
|
normalizeSnapshotRelativePath,
|
|
15656
15626
|
normalizeRelativePath,
|
|
15657
15627
|
normalizeMarkdownDocument,
|
|
@@ -15665,6 +15635,7 @@ export {
|
|
|
15665
15635
|
loadRunnerPlugins,
|
|
15666
15636
|
jsonl,
|
|
15667
15637
|
isScanExcludedDir,
|
|
15638
|
+
isNonBlockingDocumentResourceFailureReasonCode,
|
|
15668
15639
|
initParser,
|
|
15669
15640
|
hashStable,
|
|
15670
15641
|
getGitCommitHash,
|
|
@@ -15709,6 +15680,8 @@ export {
|
|
|
15709
15680
|
ExtractionPluginRegistry,
|
|
15710
15681
|
ExtractionInputError,
|
|
15711
15682
|
DOCUMENT_SNAPSHOT_MANIFEST_SCHEMA_VERSION,
|
|
15683
|
+
DOCUMENT_RESOURCE_SOURCE_MISSING_REASON_CODE,
|
|
15684
|
+
DOCUMENT_RESOURCE_PERMISSION_DENIED_REASON_CODE,
|
|
15712
15685
|
DOCUMENT_EVIDENCE_NORMALIZER_VERSION,
|
|
15713
15686
|
DEFAULT_SOURCE_SPAN_HASH_LENGTH,
|
|
15714
15687
|
CODE_SNAPSHOT_META_SCHEMA_VERSION
|