strikethroo 3.17.2 → 3.19.0
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/dist-web/assets/{arc-C3L1jkFY.js → arc-XmjVSUrZ.js} +1 -1
- package/dist-web/assets/{architectureDiagram-3BPJPVTR-Dc5wdWPF.js → architectureDiagram-3BPJPVTR-BkIMNPZQ.js} +1 -1
- package/dist-web/assets/{blockDiagram-GPEHLZMM-BCqaESV7.js → blockDiagram-GPEHLZMM-CIUhAyCy.js} +1 -1
- package/dist-web/assets/{c4Diagram-AAUBKEIU-DNecSAwM.js → c4Diagram-AAUBKEIU-DHmyXhPl.js} +1 -1
- package/dist-web/assets/channel-BluR9kJ8.js +1 -0
- package/dist-web/assets/{chunk-2J33WTMH-3QS28848.js → chunk-2J33WTMH-CsadzJpE.js} +1 -1
- package/dist-web/assets/{chunk-4BX2VUAB-B6R-x-SN.js → chunk-4BX2VUAB-rdZMTiJd.js} +1 -1
- package/dist-web/assets/{chunk-55IACEB6-BYY5vsbu.js → chunk-55IACEB6-BFgbJmlS.js} +1 -1
- package/dist-web/assets/{chunk-727SXJPM-BZxIJIkN.js → chunk-727SXJPM-CaGOdOo-.js} +1 -1
- package/dist-web/assets/{chunk-AQP2D5EJ-Dwpt8x10.js → chunk-AQP2D5EJ-Dj1Z_buE.js} +1 -1
- package/dist-web/assets/{chunk-FMBD7UC4-BkIlqLqc.js → chunk-FMBD7UC4-ByPFO0XR.js} +1 -1
- package/dist-web/assets/{chunk-ND2GUHAM-BZAfIvWk.js → chunk-ND2GUHAM-CRT0WqT3.js} +1 -1
- package/dist-web/assets/{chunk-QZHKN3VN-wAp9ruCQ.js → chunk-QZHKN3VN-DeBs7Z-A.js} +1 -1
- package/dist-web/assets/classDiagram-4FO5ZUOK-dvsWFqDg.js +1 -0
- package/dist-web/assets/classDiagram-v2-Q7XG4LA2-dvsWFqDg.js +1 -0
- package/dist-web/assets/{cose-bilkent-S5V4N54A-BWhls-Li.js → cose-bilkent-S5V4N54A-8sFxzH_F.js} +1 -1
- package/dist-web/assets/{dagre-BM42HDAG-D_rm5H8p.js → dagre-BM42HDAG-CXKxHlld.js} +1 -1
- package/dist-web/assets/{diagram-2AECGRRQ-CgrRz62Y.js → diagram-2AECGRRQ-DtcDQjmq.js} +1 -1
- package/dist-web/assets/{diagram-5GNKFQAL-BRdPFx5y.js → diagram-5GNKFQAL-C5z5tfjo.js} +1 -1
- package/dist-web/assets/{diagram-KO2AKTUF-CRkShN2W.js → diagram-KO2AKTUF-DzGoK3-W.js} +1 -1
- package/dist-web/assets/{diagram-LMA3HP47-Bxah1b5X.js → diagram-LMA3HP47-CClXYqlA.js} +1 -1
- package/dist-web/assets/{diagram-OG6HWLK6-D9gsqeVI.js → diagram-OG6HWLK6-CCOd6tb5.js} +1 -1
- package/dist-web/assets/{erDiagram-TEJ5UH35-BxuqpCGH.js → erDiagram-TEJ5UH35-DyUNZPGi.js} +1 -1
- package/dist-web/assets/{flowDiagram-I6XJVG4X-CVc346ab.js → flowDiagram-I6XJVG4X-DWE9txcF.js} +1 -1
- package/dist-web/assets/{ganttDiagram-6RSMTGT7-CoV2q8mu.js → ganttDiagram-6RSMTGT7-B-OtEqRy.js} +1 -1
- package/dist-web/assets/{gitGraphDiagram-PVQCEYII-DpBtbvUQ.js → gitGraphDiagram-PVQCEYII-F9vafo91.js} +1 -1
- package/dist-web/assets/{index-DXAUzXLU.js → index-CwMlRsHB.js} +1 -1
- package/dist-web/assets/{index-B5AkN942.js → index-D_5U356C.js} +4 -4
- package/dist-web/assets/{index-qiGGVGhU.js → index-DahCY-9n.js} +1 -1
- package/dist-web/assets/{infoDiagram-5YYISTIA-Cs1LaltR.js → infoDiagram-5YYISTIA-BqiJJ4mQ.js} +1 -1
- package/dist-web/assets/{ishikawaDiagram-YF4QCWOH-2dwQITAJ.js → ishikawaDiagram-YF4QCWOH-BJhigZjk.js} +1 -1
- package/dist-web/assets/{journeyDiagram-JHISSGLW-C5NXwRcO.js → journeyDiagram-JHISSGLW-DbnfMDvR.js} +1 -1
- package/dist-web/assets/{kanban-definition-UN3LZRKU-D8L4UiFp.js → kanban-definition-UN3LZRKU-CWbRbJ6f.js} +1 -1
- package/dist-web/assets/{linear-BmwJXk2t.js → linear-D3Xq7OUM.js} +1 -1
- package/dist-web/assets/{mermaid.core-CxfmFJso.js → mermaid.core-CT0YFN3s.js} +4 -4
- package/dist-web/assets/{mindmap-definition-RKZ34NQL-CCk10yMr.js → mindmap-definition-RKZ34NQL-D6AZLTGR.js} +1 -1
- package/dist-web/assets/{pieDiagram-4H26LBE5-CNaROrHh.js → pieDiagram-4H26LBE5-NGxhfGd1.js} +1 -1
- package/dist-web/assets/{quadrantDiagram-W4KKPZXB-C9eBwT_4.js → quadrantDiagram-W4KKPZXB-jNVzj-DZ.js} +1 -1
- package/dist-web/assets/{requirementDiagram-4Y6WPE33-CuWFUe-Z.js → requirementDiagram-4Y6WPE33-cxYkgHCv.js} +1 -1
- package/dist-web/assets/{sankeyDiagram-5OEKKPKP-xGYYGBDj.js → sankeyDiagram-5OEKKPKP-CO7LMTUX.js} +1 -1
- package/dist-web/assets/{sequenceDiagram-3UESZ5HK-Corn4mP3.js → sequenceDiagram-3UESZ5HK-C8d8VIsZ.js} +1 -1
- package/dist-web/assets/{stateDiagram-AJRCARHV-DP1EwgDv.js → stateDiagram-AJRCARHV-DVxepHih.js} +1 -1
- package/dist-web/assets/stateDiagram-v2-BHNVJYJU-OpTLx_eY.js +1 -0
- package/dist-web/assets/{timeline-definition-PNZ67QCA-DgVY9v5q.js → timeline-definition-PNZ67QCA-Bef04SiL.js} +1 -1
- package/dist-web/assets/{vennDiagram-CIIHVFJN-B47n0Ab2.js → vennDiagram-CIIHVFJN-DlZHmyp0.js} +1 -1
- package/dist-web/assets/{wardley-L42UT6IY-ubK4o7Fl.js → wardley-L42UT6IY-ChkIPtT_.js} +1 -1
- package/dist-web/assets/{wardleyDiagram-YWT4CUSO-ChirN_61.js → wardleyDiagram-YWT4CUSO-D67J0WGX.js} +1 -1
- package/dist-web/assets/{xychartDiagram-2RQKCTM6-Cf8q2_P7.js → xychartDiagram-2RQKCTM6-BoNIIDDe.js} +1 -1
- package/dist-web/index.html +1 -1
- package/package.json +1 -1
- package/templates/harness/skills/st-code-review/SKILL.md +47 -281
- package/templates/harness/skills/st-code-review/scripts/code-review.cjs +2725 -509
- package/templates/harness/skills/st-execute-blueprint/SKILL.md +15 -18
- package/templates/harness/skills/st-execute-blueprint/scripts/dispatch-task-execution.cjs +420 -213
- package/templates/harness/skills/st-execute-task/scripts/dispatch-task-execution.cjs +420 -213
- package/templates/harness/skills/st-full-workflow/SKILL.md +15 -18
- package/templates/harness/skills/st-full-workflow/scripts/dispatch-task-execution.cjs +420 -213
- package/templates/strikethroo/config/config.yaml +95 -6
- package/templates/strikethroo/config/hooks/CODE_REVIEW.md +19 -29
- package/templates/strikethroo/gitignore +13 -10
- package/dist-web/assets/channel-DmY2Krrw.js +0 -1
- package/dist-web/assets/classDiagram-4FO5ZUOK-C91aiCZF.js +0 -1
- package/dist-web/assets/classDiagram-v2-Q7XG4LA2-C91aiCZF.js +0 -1
- package/dist-web/assets/stateDiagram-v2-BHNVJYJU-DQIao4rH.js +0 -1
|
@@ -34,25 +34,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
// src/skill-scripts/code-review.ts
|
|
35
35
|
var code_review_exports = {};
|
|
36
36
|
__export(code_review_exports, {
|
|
37
|
-
MAX_REVIEW_ROUNDS: () => MAX_REVIEW_ROUNDS,
|
|
38
|
-
_decideRound: () => _decideRound,
|
|
39
37
|
_exitCodeFor: () => _exitCodeFor,
|
|
40
38
|
_extractReviewDocument: () => _extractReviewDocument,
|
|
41
39
|
_makeDeliveryToken: () => _makeDeliveryToken,
|
|
42
40
|
_readBaseCommit: () => _readBaseCommit,
|
|
43
41
|
_readCumulativeDiff: () => _readCumulativeDiff,
|
|
44
|
-
|
|
42
|
+
_verdictFor: () => _verdictFor,
|
|
45
43
|
buildReviewerPrompt: () => buildReviewerPrompt,
|
|
46
44
|
createFindingsGate: () => createFindingsGate,
|
|
47
45
|
main: () => main,
|
|
48
|
-
|
|
49
|
-
runBoundedReviewRound: () => runBoundedReviewRound,
|
|
50
|
-
runReviewRound: () => runReviewRound
|
|
46
|
+
runReview: () => runReview
|
|
51
47
|
});
|
|
52
48
|
module.exports = __toCommonJS(code_review_exports);
|
|
53
49
|
var crypto = __toESM(require("crypto"));
|
|
54
|
-
var
|
|
55
|
-
var
|
|
50
|
+
var fs7 = __toESM(require("fs"));
|
|
51
|
+
var path8 = __toESM(require("path"));
|
|
56
52
|
|
|
57
53
|
// src/types.ts
|
|
58
54
|
var SUPPORTED_HARNESSES = [
|
|
@@ -249,56 +245,2405 @@ var resolveByPath = (absolutePath) => {
|
|
|
249
245
|
} catch (_err) {
|
|
250
246
|
return null;
|
|
251
247
|
}
|
|
252
|
-
const planId = extractPlanId(content, absolutePath);
|
|
253
|
-
if (planId === null) return null;
|
|
254
|
-
const tmRoot = checkStandardRootShortcut(absolutePath) || findStrikethrooRoot(path3.dirname(absolutePath));
|
|
255
|
-
if (!tmRoot) return null;
|
|
256
|
-
return {
|
|
257
|
-
planFile: absolutePath,
|
|
258
|
-
planDir: path3.dirname(absolutePath),
|
|
259
|
-
strikethrooRoot: tmRoot,
|
|
260
|
-
planId
|
|
261
|
-
};
|
|
248
|
+
const planId = extractPlanId(content, absolutePath);
|
|
249
|
+
if (planId === null) return null;
|
|
250
|
+
const tmRoot = checkStandardRootShortcut(absolutePath) || findStrikethrooRoot(path3.dirname(absolutePath));
|
|
251
|
+
if (!tmRoot) return null;
|
|
252
|
+
return {
|
|
253
|
+
planFile: absolutePath,
|
|
254
|
+
planDir: path3.dirname(absolutePath),
|
|
255
|
+
strikethrooRoot: tmRoot,
|
|
256
|
+
planId
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
var resolveByIdInAncestry = (planId, startPath, searched = /* @__PURE__ */ new Set()) => {
|
|
260
|
+
const tmRoot = findStrikethrooRoot(startPath);
|
|
261
|
+
if (!tmRoot) return null;
|
|
262
|
+
const normalized = path3.normalize(tmRoot);
|
|
263
|
+
if (searched.has(normalized)) return null;
|
|
264
|
+
searched.add(normalized);
|
|
265
|
+
const plans = getAllPlans(tmRoot);
|
|
266
|
+
const match = plans.find((p) => p.id === planId);
|
|
267
|
+
if (match) {
|
|
268
|
+
return {
|
|
269
|
+
planFile: match.file,
|
|
270
|
+
planDir: match.dir,
|
|
271
|
+
strikethrooRoot: tmRoot,
|
|
272
|
+
planId
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
const parentOfRoot = path3.dirname(path3.dirname(tmRoot));
|
|
276
|
+
if (parentOfRoot === tmRoot) return null;
|
|
277
|
+
return resolveByIdInAncestry(planId, parentOfRoot, searched);
|
|
278
|
+
};
|
|
279
|
+
var resolvePlan = (input, startPath = process.cwd()) => {
|
|
280
|
+
if (input === null || input === void 0 || input === "") return null;
|
|
281
|
+
const inputStr = String(input);
|
|
282
|
+
if (inputStr.startsWith("/")) {
|
|
283
|
+
return resolveByPath(inputStr);
|
|
284
|
+
}
|
|
285
|
+
const planId = parseInt(inputStr, 10);
|
|
286
|
+
if (Number.isNaN(planId)) return null;
|
|
287
|
+
return resolveByIdInAncestry(planId, startPath);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// src/skill-scripts/shared/harness-availability.ts
|
|
291
|
+
var import_crypto2 = require("crypto");
|
|
292
|
+
var import_child_process3 = require("child_process");
|
|
293
|
+
var fs6 = __toESM(require("fs"));
|
|
294
|
+
var os = __toESM(require("os"));
|
|
295
|
+
var path7 = __toESM(require("path"));
|
|
296
|
+
|
|
297
|
+
// src/skill-scripts/shared/harness-configuration.ts
|
|
298
|
+
var import_crypto = require("crypto");
|
|
299
|
+
var fs4 = __toESM(require("fs"));
|
|
300
|
+
var path5 = __toESM(require("path"));
|
|
301
|
+
|
|
302
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
303
|
+
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
304
|
+
var MERGE_KEY = /* @__PURE__ */ Symbol("MERGE_KEY");
|
|
305
|
+
function defineScalarTag(tagName, options) {
|
|
306
|
+
return {
|
|
307
|
+
tagName,
|
|
308
|
+
nodeKind: "scalar",
|
|
309
|
+
implicit: options.implicit ?? false,
|
|
310
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
311
|
+
implicitFirstChars: options.implicitFirstChars ?? null,
|
|
312
|
+
resolve: options.resolve,
|
|
313
|
+
identify: options.identify ?? null,
|
|
314
|
+
represent: options.represent ?? ((data) => String(data)),
|
|
315
|
+
representTagName: options.representTagName ?? null
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function defineSequenceTag(tagName, options) {
|
|
319
|
+
const carrierIsResult = options.finalize === void 0;
|
|
320
|
+
return {
|
|
321
|
+
tagName,
|
|
322
|
+
nodeKind: "sequence",
|
|
323
|
+
implicit: false,
|
|
324
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
325
|
+
create: options.create,
|
|
326
|
+
addItem: options.addItem,
|
|
327
|
+
finalize: options.finalize ?? ((carrier) => carrier),
|
|
328
|
+
carrierIsResult,
|
|
329
|
+
identify: options.identify ?? null,
|
|
330
|
+
represent: options.represent ?? ((data) => data),
|
|
331
|
+
representTagName: options.representTagName ?? null
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function defineMappingTag(tagName, options) {
|
|
335
|
+
const carrierIsResult = options.finalize === void 0;
|
|
336
|
+
return {
|
|
337
|
+
tagName,
|
|
338
|
+
nodeKind: "mapping",
|
|
339
|
+
implicit: false,
|
|
340
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
341
|
+
create: options.create,
|
|
342
|
+
addPair: options.addPair,
|
|
343
|
+
has: options.has,
|
|
344
|
+
keys: options.keys,
|
|
345
|
+
get: options.get,
|
|
346
|
+
finalize: options.finalize ?? ((carrier) => carrier),
|
|
347
|
+
carrierIsResult,
|
|
348
|
+
identify: options.identify ?? null,
|
|
349
|
+
represent: options.represent ?? ((data) => data),
|
|
350
|
+
representTagName: options.representTagName ?? null
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
var strTag = defineScalarTag("tag:yaml.org,2002:str", {
|
|
354
|
+
resolve: (source) => source,
|
|
355
|
+
identify: (data) => typeof data === "string"
|
|
356
|
+
});
|
|
357
|
+
var NULL_VALUES$1 = [
|
|
358
|
+
"",
|
|
359
|
+
"~",
|
|
360
|
+
"null",
|
|
361
|
+
"Null",
|
|
362
|
+
"NULL"
|
|
363
|
+
];
|
|
364
|
+
var nullCoreTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
365
|
+
implicit: true,
|
|
366
|
+
implicitFirstChars: [
|
|
367
|
+
"",
|
|
368
|
+
"~",
|
|
369
|
+
"n",
|
|
370
|
+
"N"
|
|
371
|
+
],
|
|
372
|
+
resolve: (source) => {
|
|
373
|
+
if (NULL_VALUES$1.indexOf(source) !== -1) return null;
|
|
374
|
+
return NOT_RESOLVED;
|
|
375
|
+
},
|
|
376
|
+
identify: (object) => object === null,
|
|
377
|
+
represent: () => "null"
|
|
378
|
+
});
|
|
379
|
+
var nullJsonTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
380
|
+
implicit: true,
|
|
381
|
+
implicitFirstChars: ["n"],
|
|
382
|
+
resolve: (source, isExplicit) => {
|
|
383
|
+
if (source === "null" || isExplicit && source === "") return null;
|
|
384
|
+
return NOT_RESOLVED;
|
|
385
|
+
},
|
|
386
|
+
identify: (object) => object === null,
|
|
387
|
+
represent: () => "null"
|
|
388
|
+
});
|
|
389
|
+
var NULL_VALUES = [
|
|
390
|
+
"",
|
|
391
|
+
"~",
|
|
392
|
+
"null",
|
|
393
|
+
"Null",
|
|
394
|
+
"NULL"
|
|
395
|
+
];
|
|
396
|
+
var nullYaml11Tag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
397
|
+
implicit: true,
|
|
398
|
+
implicitFirstChars: [
|
|
399
|
+
"",
|
|
400
|
+
"~",
|
|
401
|
+
"n",
|
|
402
|
+
"N"
|
|
403
|
+
],
|
|
404
|
+
resolve: (source) => {
|
|
405
|
+
if (NULL_VALUES.indexOf(source) !== -1) return null;
|
|
406
|
+
return NOT_RESOLVED;
|
|
407
|
+
},
|
|
408
|
+
identify: (object) => object === null,
|
|
409
|
+
represent: () => "null"
|
|
410
|
+
});
|
|
411
|
+
var TRUE_VALUES$2 = [
|
|
412
|
+
"true",
|
|
413
|
+
"True",
|
|
414
|
+
"TRUE"
|
|
415
|
+
];
|
|
416
|
+
var FALSE_VALUES$2 = [
|
|
417
|
+
"false",
|
|
418
|
+
"False",
|
|
419
|
+
"FALSE"
|
|
420
|
+
];
|
|
421
|
+
var boolCoreTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
422
|
+
implicit: true,
|
|
423
|
+
implicitFirstChars: [
|
|
424
|
+
"t",
|
|
425
|
+
"T",
|
|
426
|
+
"f",
|
|
427
|
+
"F"
|
|
428
|
+
],
|
|
429
|
+
resolve: (source) => {
|
|
430
|
+
if (TRUE_VALUES$2.indexOf(source) !== -1) return true;
|
|
431
|
+
if (FALSE_VALUES$2.indexOf(source) !== -1) return false;
|
|
432
|
+
return NOT_RESOLVED;
|
|
433
|
+
},
|
|
434
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
435
|
+
represent: (object) => object ? "true" : "false"
|
|
436
|
+
});
|
|
437
|
+
var TRUE_VALUES$1 = ["true"];
|
|
438
|
+
var FALSE_VALUES$1 = ["false"];
|
|
439
|
+
var boolJsonTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
440
|
+
implicit: true,
|
|
441
|
+
implicitFirstChars: ["t", "f"],
|
|
442
|
+
resolve: (source) => {
|
|
443
|
+
if (TRUE_VALUES$1.indexOf(source) !== -1) return true;
|
|
444
|
+
if (FALSE_VALUES$1.indexOf(source) !== -1) return false;
|
|
445
|
+
return NOT_RESOLVED;
|
|
446
|
+
},
|
|
447
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
448
|
+
represent: (object) => object ? "true" : "false"
|
|
449
|
+
});
|
|
450
|
+
var TRUE_VALUES = [
|
|
451
|
+
"true",
|
|
452
|
+
"True",
|
|
453
|
+
"TRUE",
|
|
454
|
+
"y",
|
|
455
|
+
"Y",
|
|
456
|
+
"yes",
|
|
457
|
+
"Yes",
|
|
458
|
+
"YES",
|
|
459
|
+
"on",
|
|
460
|
+
"On",
|
|
461
|
+
"ON"
|
|
462
|
+
];
|
|
463
|
+
var FALSE_VALUES = [
|
|
464
|
+
"false",
|
|
465
|
+
"False",
|
|
466
|
+
"FALSE",
|
|
467
|
+
"n",
|
|
468
|
+
"N",
|
|
469
|
+
"no",
|
|
470
|
+
"No",
|
|
471
|
+
"NO",
|
|
472
|
+
"off",
|
|
473
|
+
"Off",
|
|
474
|
+
"OFF"
|
|
475
|
+
];
|
|
476
|
+
var boolYaml11Tag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
477
|
+
implicit: true,
|
|
478
|
+
implicitFirstChars: [
|
|
479
|
+
"y",
|
|
480
|
+
"Y",
|
|
481
|
+
"n",
|
|
482
|
+
"N",
|
|
483
|
+
"t",
|
|
484
|
+
"T",
|
|
485
|
+
"f",
|
|
486
|
+
"F",
|
|
487
|
+
"o",
|
|
488
|
+
"O"
|
|
489
|
+
],
|
|
490
|
+
resolve: (source) => {
|
|
491
|
+
if (TRUE_VALUES.indexOf(source) !== -1) return true;
|
|
492
|
+
if (FALSE_VALUES.indexOf(source) !== -1) return false;
|
|
493
|
+
return NOT_RESOLVED;
|
|
494
|
+
},
|
|
495
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
496
|
+
represent: (object) => object ? "true" : "false"
|
|
497
|
+
});
|
|
498
|
+
var YAML_INTEGER_IMPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
499
|
+
var YAML_INTEGER_EXPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
500
|
+
function parseYamlInteger$2(source) {
|
|
501
|
+
let value = source;
|
|
502
|
+
let sign = 1;
|
|
503
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
504
|
+
if (value[0] === "-") sign = -1;
|
|
505
|
+
value = value.slice(1);
|
|
506
|
+
}
|
|
507
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
508
|
+
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
509
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
510
|
+
return sign * parseInt(value, 10);
|
|
511
|
+
}
|
|
512
|
+
function resolveYamlInteger$2(source, isExplicit) {
|
|
513
|
+
if (isExplicit) {
|
|
514
|
+
if (!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
515
|
+
} else if (!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
516
|
+
const result = parseYamlInteger$2(source);
|
|
517
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
518
|
+
}
|
|
519
|
+
var intCoreTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
520
|
+
implicit: true,
|
|
521
|
+
implicitFirstChars: [
|
|
522
|
+
"-",
|
|
523
|
+
"+",
|
|
524
|
+
..."0123456789"
|
|
525
|
+
],
|
|
526
|
+
resolve: resolveYamlInteger$2,
|
|
527
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
528
|
+
represent: (object) => object.toString(10)
|
|
529
|
+
});
|
|
530
|
+
var YAML_INTEGER_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)$");
|
|
531
|
+
var YAML_INTEGER_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
532
|
+
function parseYamlInteger$1(source) {
|
|
533
|
+
let value = source;
|
|
534
|
+
let sign = 1;
|
|
535
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
536
|
+
if (value[0] === "-") sign = -1;
|
|
537
|
+
value = value.slice(1);
|
|
538
|
+
}
|
|
539
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
540
|
+
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
541
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
542
|
+
return sign * parseInt(value, 10);
|
|
543
|
+
}
|
|
544
|
+
function resolveYamlInteger$1(source, isExplicit) {
|
|
545
|
+
if (isExplicit) {
|
|
546
|
+
if (!YAML_INTEGER_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
547
|
+
} else if (!YAML_INTEGER_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
548
|
+
const result = parseYamlInteger$1(source);
|
|
549
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
550
|
+
}
|
|
551
|
+
var intJsonTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
552
|
+
implicit: true,
|
|
553
|
+
implicitFirstChars: ["-", ..."0123456789"],
|
|
554
|
+
resolve: resolveYamlInteger$1,
|
|
555
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
556
|
+
represent: (object) => object.toString(10)
|
|
557
|
+
});
|
|
558
|
+
var YAML_INTEGER_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");
|
|
559
|
+
function parseYamlInteger(source) {
|
|
560
|
+
let value = source.replace(/_/g, "");
|
|
561
|
+
let sign = 1;
|
|
562
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
563
|
+
if (value[0] === "-") sign = -1;
|
|
564
|
+
value = value.slice(1);
|
|
565
|
+
}
|
|
566
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
567
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
568
|
+
if (value.includes(":")) {
|
|
569
|
+
let result = 0;
|
|
570
|
+
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
571
|
+
return sign * result;
|
|
572
|
+
}
|
|
573
|
+
if (value !== "0" && value[0] === "0") return sign * parseInt(value, 8);
|
|
574
|
+
return sign * parseInt(value, 10);
|
|
575
|
+
}
|
|
576
|
+
function resolveYamlInteger(source) {
|
|
577
|
+
if (!YAML_INTEGER_PATTERN.test(source)) return NOT_RESOLVED;
|
|
578
|
+
const result = parseYamlInteger(source);
|
|
579
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
580
|
+
}
|
|
581
|
+
var intYaml11Tag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
582
|
+
implicit: true,
|
|
583
|
+
implicitFirstChars: [
|
|
584
|
+
"-",
|
|
585
|
+
"+",
|
|
586
|
+
..."0123456789"
|
|
587
|
+
],
|
|
588
|
+
resolve: resolveYamlInteger,
|
|
589
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
590
|
+
represent: (object) => object.toString(10)
|
|
591
|
+
});
|
|
592
|
+
var YAML_FLOAT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
593
|
+
var YAML_FLOAT_SPECIAL_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
594
|
+
function resolveYamlFloat$2(source) {
|
|
595
|
+
if (!YAML_FLOAT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
596
|
+
let value = source.toLowerCase();
|
|
597
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
598
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
599
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
600
|
+
if (value === ".nan") return NaN;
|
|
601
|
+
const result = sign * parseFloat(value);
|
|
602
|
+
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN$1.test(source)) return result;
|
|
603
|
+
return NOT_RESOLVED;
|
|
604
|
+
}
|
|
605
|
+
function representYamlFloat$2(object) {
|
|
606
|
+
if (isNaN(object)) return ".nan";
|
|
607
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
608
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
609
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
610
|
+
const result = object.toString(10);
|
|
611
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
612
|
+
}
|
|
613
|
+
var floatCoreTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
614
|
+
implicit: true,
|
|
615
|
+
implicitFirstChars: [
|
|
616
|
+
"-",
|
|
617
|
+
"+",
|
|
618
|
+
".",
|
|
619
|
+
..."0123456789"
|
|
620
|
+
],
|
|
621
|
+
resolve: resolveYamlFloat$2,
|
|
622
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
623
|
+
represent: representYamlFloat$2
|
|
624
|
+
});
|
|
625
|
+
var YAML_FLOAT_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
|
|
626
|
+
var YAML_FLOAT_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
627
|
+
function resolveYamlFloat$1(source, isExplicit) {
|
|
628
|
+
if (isExplicit) {
|
|
629
|
+
if (!YAML_FLOAT_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
630
|
+
let value = source.toLowerCase();
|
|
631
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
632
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
633
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
634
|
+
if (value === ".nan") return NaN;
|
|
635
|
+
const result2 = sign * parseFloat(value);
|
|
636
|
+
return Number.isFinite(result2) ? result2 : NOT_RESOLVED;
|
|
637
|
+
}
|
|
638
|
+
if (!YAML_FLOAT_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
639
|
+
const result = Number(source);
|
|
640
|
+
if (Number.isFinite(result)) return result;
|
|
641
|
+
return NOT_RESOLVED;
|
|
642
|
+
}
|
|
643
|
+
function representYamlFloat$1(object) {
|
|
644
|
+
if (isNaN(object)) return ".nan";
|
|
645
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
646
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
647
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
648
|
+
const result = object.toString(10);
|
|
649
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
650
|
+
}
|
|
651
|
+
var floatJsonTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
652
|
+
implicit: true,
|
|
653
|
+
implicitFirstChars: ["-", ..."0123456789"],
|
|
654
|
+
resolve: resolveYamlFloat$1,
|
|
655
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
656
|
+
represent: representYamlFloat$1
|
|
657
|
+
});
|
|
658
|
+
var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
659
|
+
var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
660
|
+
function resolveYamlFloat(source) {
|
|
661
|
+
if (!YAML_FLOAT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
662
|
+
let value = source.toLowerCase().replace(/_/g, "");
|
|
663
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
664
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
665
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
666
|
+
if (value === ".nan") return NaN;
|
|
667
|
+
let result = 0;
|
|
668
|
+
if (value.includes(":")) {
|
|
669
|
+
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
670
|
+
result *= sign;
|
|
671
|
+
} else result = sign * parseFloat(value);
|
|
672
|
+
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN.test(source)) return result;
|
|
673
|
+
return NOT_RESOLVED;
|
|
674
|
+
}
|
|
675
|
+
function representYamlFloat(object) {
|
|
676
|
+
if (isNaN(object)) return ".nan";
|
|
677
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
678
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
679
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
680
|
+
const result = object.toString(10);
|
|
681
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
682
|
+
}
|
|
683
|
+
var floatYaml11Tag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
684
|
+
implicit: true,
|
|
685
|
+
implicitFirstChars: [
|
|
686
|
+
"-",
|
|
687
|
+
"+",
|
|
688
|
+
".",
|
|
689
|
+
..."0123456789"
|
|
690
|
+
],
|
|
691
|
+
resolve: resolveYamlFloat,
|
|
692
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
693
|
+
represent: representYamlFloat
|
|
694
|
+
});
|
|
695
|
+
var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
|
|
696
|
+
implicit: true,
|
|
697
|
+
implicitFirstChars: ["<"],
|
|
698
|
+
resolve: (source, isExplicit) => {
|
|
699
|
+
if (source === "<<" || isExplicit && source === "") return MERGE_KEY;
|
|
700
|
+
return NOT_RESOLVED;
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
704
|
+
function resolveYamlBinary(source) {
|
|
705
|
+
const input = source.replace(/\s/g, "");
|
|
706
|
+
if (input.length % 4 !== 0 || !BASE64_PATTERN.test(input)) return NOT_RESOLVED;
|
|
707
|
+
const binary = atob(input);
|
|
708
|
+
const result = new Uint8Array(binary.length);
|
|
709
|
+
for (let index = 0; index < binary.length; index++) result[index] = binary.charCodeAt(index);
|
|
710
|
+
return result;
|
|
711
|
+
}
|
|
712
|
+
function representYamlBinary(object) {
|
|
713
|
+
let binary = "";
|
|
714
|
+
for (let index = 0; index < object.length; index++) binary += String.fromCharCode(object[index]);
|
|
715
|
+
return btoa(binary);
|
|
716
|
+
}
|
|
717
|
+
var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
|
|
718
|
+
resolve: resolveYamlBinary,
|
|
719
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Uint8Array]",
|
|
720
|
+
represent: representYamlBinary
|
|
721
|
+
});
|
|
722
|
+
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
723
|
+
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
724
|
+
function resolveYamlTimestamp(source) {
|
|
725
|
+
let match = YAML_DATE_REGEXP.exec(source);
|
|
726
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
|
|
727
|
+
if (match === null) return NOT_RESOLVED;
|
|
728
|
+
const year = +match[1];
|
|
729
|
+
const month = +match[2] - 1;
|
|
730
|
+
const day = +match[3];
|
|
731
|
+
if (!match[4]) {
|
|
732
|
+
const date2 = new Date(Date.UTC(year, month, day));
|
|
733
|
+
if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
|
|
734
|
+
return date2;
|
|
735
|
+
}
|
|
736
|
+
const hour = +match[4];
|
|
737
|
+
const minute = +match[5];
|
|
738
|
+
const second = +match[6];
|
|
739
|
+
let fraction = 0;
|
|
740
|
+
if (hour > 23 || minute > 59 || second > 59) return NOT_RESOLVED;
|
|
741
|
+
if (match[7]) {
|
|
742
|
+
let value = match[7].slice(0, 3);
|
|
743
|
+
while (value.length < 3) value += "0";
|
|
744
|
+
fraction = +value;
|
|
745
|
+
}
|
|
746
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
747
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
|
|
748
|
+
if (match[9]) {
|
|
749
|
+
const offsetHour = +match[10];
|
|
750
|
+
const offsetMinute = +(match[11] || 0);
|
|
751
|
+
if (offsetHour > 23 || offsetMinute > 59) return NOT_RESOLVED;
|
|
752
|
+
const offset = (offsetHour * 60 + offsetMinute) * 6e4;
|
|
753
|
+
date.setTime(date.getTime() - (match[9] === "-" ? -offset : offset));
|
|
754
|
+
}
|
|
755
|
+
return date;
|
|
756
|
+
}
|
|
757
|
+
var timestampTag = defineScalarTag("tag:yaml.org,2002:timestamp", {
|
|
758
|
+
implicit: true,
|
|
759
|
+
implicitFirstChars: [..."0123456789"],
|
|
760
|
+
resolve: resolveYamlTimestamp,
|
|
761
|
+
identify: (object) => object instanceof Date,
|
|
762
|
+
represent: (object) => object.toISOString()
|
|
763
|
+
});
|
|
764
|
+
var seqTag = defineSequenceTag("tag:yaml.org,2002:seq", {
|
|
765
|
+
create: () => [],
|
|
766
|
+
addItem: (container, item) => {
|
|
767
|
+
container.push(item);
|
|
768
|
+
},
|
|
769
|
+
identify: Array.isArray
|
|
770
|
+
});
|
|
771
|
+
function isPlainObject(data) {
|
|
772
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
|
|
773
|
+
const prototype = Object.getPrototypeOf(data);
|
|
774
|
+
return prototype === null || prototype === Object.prototype;
|
|
775
|
+
}
|
|
776
|
+
function pick(object, keys) {
|
|
777
|
+
const result = {};
|
|
778
|
+
for (const key of keys) if (object[key] !== void 0) result[key] = object[key];
|
|
779
|
+
return result;
|
|
780
|
+
}
|
|
781
|
+
var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
|
|
782
|
+
create: () => ({
|
|
783
|
+
list: [],
|
|
784
|
+
seen: /* @__PURE__ */ new Set()
|
|
785
|
+
}),
|
|
786
|
+
addItem: (carrier, item) => {
|
|
787
|
+
let key;
|
|
788
|
+
if (item instanceof Map) {
|
|
789
|
+
if (item.size !== 1) return "cannot resolve an ordered map item";
|
|
790
|
+
key = item.keys().next().value;
|
|
791
|
+
} else if (isPlainObject(item)) {
|
|
792
|
+
const itemKeys = Object.keys(item);
|
|
793
|
+
if (itemKeys.length !== 1) return "cannot resolve an ordered map item";
|
|
794
|
+
key = itemKeys[0];
|
|
795
|
+
} else return "cannot resolve an ordered map item";
|
|
796
|
+
if (carrier.seen.has(key)) return "duplicate key in ordered map";
|
|
797
|
+
carrier.seen.add(key);
|
|
798
|
+
carrier.list.push(item);
|
|
799
|
+
return "";
|
|
800
|
+
},
|
|
801
|
+
finalize: (carrier) => carrier.list
|
|
802
|
+
});
|
|
803
|
+
var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
804
|
+
create: () => [],
|
|
805
|
+
addItem: (container, item) => {
|
|
806
|
+
if (item instanceof Map) {
|
|
807
|
+
if (item.size !== 1) return "cannot resolve a pairs item";
|
|
808
|
+
container.push(item.entries().next().value);
|
|
809
|
+
return "";
|
|
810
|
+
}
|
|
811
|
+
if (Object.prototype.toString.call(item) !== "[object Object]") return "cannot resolve a pairs item";
|
|
812
|
+
const object = item;
|
|
813
|
+
const keys = Object.keys(object);
|
|
814
|
+
if (keys.length !== 1) return "cannot resolve a pairs item";
|
|
815
|
+
container.push([keys[0], object[keys[0]]]);
|
|
816
|
+
return "";
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
820
|
+
create: () => ({}),
|
|
821
|
+
identify: isPlainObject,
|
|
822
|
+
represent: (o) => {
|
|
823
|
+
const map = /* @__PURE__ */ new Map();
|
|
824
|
+
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
825
|
+
return map;
|
|
826
|
+
},
|
|
827
|
+
addPair: (container, key, value) => {
|
|
828
|
+
if (key !== null && typeof key === "object") return "object-based map does not support complex keys";
|
|
829
|
+
const normalizedKey = String(key);
|
|
830
|
+
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
831
|
+
value,
|
|
832
|
+
enumerable: true,
|
|
833
|
+
configurable: true,
|
|
834
|
+
writable: true
|
|
835
|
+
});
|
|
836
|
+
else container[normalizedKey] = value;
|
|
837
|
+
return "";
|
|
838
|
+
},
|
|
839
|
+
has: (container, key) => {
|
|
840
|
+
if (key !== null && typeof key === "object") return false;
|
|
841
|
+
return Object.prototype.hasOwnProperty.call(container, String(key));
|
|
842
|
+
},
|
|
843
|
+
keys: (container) => Object.keys(container),
|
|
844
|
+
get: (container, key) => container[String(key)]
|
|
845
|
+
});
|
|
846
|
+
var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
847
|
+
create: () => /* @__PURE__ */ new Set(),
|
|
848
|
+
identify: (data) => data instanceof Set,
|
|
849
|
+
represent: (data) => {
|
|
850
|
+
const map = /* @__PURE__ */ new Map();
|
|
851
|
+
for (const key of data) map.set(key, null);
|
|
852
|
+
return map;
|
|
853
|
+
},
|
|
854
|
+
addPair: (container, key, value) => {
|
|
855
|
+
if (value !== null) return "cannot resolve a set item";
|
|
856
|
+
container.add(key);
|
|
857
|
+
return "";
|
|
858
|
+
},
|
|
859
|
+
has: (container, key) => container.has(key),
|
|
860
|
+
keys: (container) => container.keys(),
|
|
861
|
+
get: () => null
|
|
862
|
+
});
|
|
863
|
+
function createTagDefinitionMap() {
|
|
864
|
+
return {
|
|
865
|
+
scalar: {},
|
|
866
|
+
sequence: {},
|
|
867
|
+
mapping: {}
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
function createTagDefinitionListMap() {
|
|
871
|
+
return {
|
|
872
|
+
scalar: [],
|
|
873
|
+
sequence: [],
|
|
874
|
+
mapping: []
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function compileTags(tags) {
|
|
878
|
+
const result = [];
|
|
879
|
+
for (const tag of tags) {
|
|
880
|
+
let index = result.length;
|
|
881
|
+
for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
|
|
882
|
+
const previous = result[previousIndex];
|
|
883
|
+
if (previous.nodeKind === tag.nodeKind && previous.tagName === tag.tagName && previous.matchByTagPrefix === tag.matchByTagPrefix) {
|
|
884
|
+
index = previousIndex;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
result[index] = tag;
|
|
889
|
+
}
|
|
890
|
+
return result;
|
|
891
|
+
}
|
|
892
|
+
var Schema = class Schema2 {
|
|
893
|
+
tags;
|
|
894
|
+
implicitScalarTags;
|
|
895
|
+
implicitScalarByFirstChar;
|
|
896
|
+
implicitScalarAnyFirstChar;
|
|
897
|
+
defaultScalarTag;
|
|
898
|
+
defaultSequenceTag;
|
|
899
|
+
defaultMappingTag;
|
|
900
|
+
exact;
|
|
901
|
+
prefix;
|
|
902
|
+
constructor(tags) {
|
|
903
|
+
const compiledTags = compileTags(tags);
|
|
904
|
+
const implicitScalarTags = [];
|
|
905
|
+
const exact = createTagDefinitionMap();
|
|
906
|
+
const prefix = createTagDefinitionListMap();
|
|
907
|
+
for (const tag of compiledTags) {
|
|
908
|
+
if (tag.nodeKind === "scalar" && tag.implicit) {
|
|
909
|
+
if (tag.matchByTagPrefix) throw new Error("Implicit scalar tags cannot match by tag prefix");
|
|
910
|
+
implicitScalarTags.push(tag);
|
|
911
|
+
}
|
|
912
|
+
switch (tag.nodeKind) {
|
|
913
|
+
case "scalar":
|
|
914
|
+
if (tag.matchByTagPrefix) prefix.scalar.push(tag);
|
|
915
|
+
else exact.scalar[tag.tagName] = tag;
|
|
916
|
+
break;
|
|
917
|
+
case "sequence":
|
|
918
|
+
if (tag.matchByTagPrefix) prefix.sequence.push(tag);
|
|
919
|
+
else exact.sequence[tag.tagName] = tag;
|
|
920
|
+
break;
|
|
921
|
+
case "mapping":
|
|
922
|
+
if (tag.matchByTagPrefix) prefix.mapping.push(tag);
|
|
923
|
+
else exact.mapping[tag.tagName] = tag;
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const implicitScalarAnyFirstChar = implicitScalarTags.filter((tag) => tag.implicitFirstChars === null);
|
|
928
|
+
const keys = /* @__PURE__ */ new Set();
|
|
929
|
+
for (const tag of implicitScalarTags) if (tag.implicitFirstChars !== null) for (const key of tag.implicitFirstChars) keys.add(key);
|
|
930
|
+
const implicitScalarByFirstChar = /* @__PURE__ */ new Map();
|
|
931
|
+
for (const key of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag) => tag.implicitFirstChars === null || tag.implicitFirstChars.indexOf(key) !== -1));
|
|
932
|
+
const defaultScalarTag = exact.scalar["tag:yaml.org,2002:str"];
|
|
933
|
+
if (!defaultScalarTag) throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");
|
|
934
|
+
this.tags = compiledTags;
|
|
935
|
+
this.implicitScalarTags = implicitScalarTags;
|
|
936
|
+
this.implicitScalarByFirstChar = implicitScalarByFirstChar;
|
|
937
|
+
this.implicitScalarAnyFirstChar = implicitScalarAnyFirstChar;
|
|
938
|
+
this.defaultScalarTag = defaultScalarTag;
|
|
939
|
+
this.defaultSequenceTag = exact.sequence["tag:yaml.org,2002:seq"];
|
|
940
|
+
this.defaultMappingTag = exact.mapping["tag:yaml.org,2002:map"];
|
|
941
|
+
this.exact = exact;
|
|
942
|
+
this.prefix = prefix;
|
|
943
|
+
}
|
|
944
|
+
withTags(...tags) {
|
|
945
|
+
let flatTags = [];
|
|
946
|
+
for (const tag of tags) flatTags = flatTags.concat(tag);
|
|
947
|
+
return new Schema2([...this.tags, ...flatTags]);
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
var FAILSAFE_SCHEMA = new Schema([
|
|
951
|
+
strTag,
|
|
952
|
+
seqTag,
|
|
953
|
+
mapTag
|
|
954
|
+
]);
|
|
955
|
+
var JSON_SCHEMA = new Schema([
|
|
956
|
+
...FAILSAFE_SCHEMA.tags,
|
|
957
|
+
nullJsonTag,
|
|
958
|
+
boolJsonTag,
|
|
959
|
+
intJsonTag,
|
|
960
|
+
floatJsonTag
|
|
961
|
+
]);
|
|
962
|
+
var CORE_SCHEMA = new Schema([
|
|
963
|
+
...FAILSAFE_SCHEMA.tags,
|
|
964
|
+
nullCoreTag,
|
|
965
|
+
boolCoreTag,
|
|
966
|
+
intCoreTag,
|
|
967
|
+
floatCoreTag
|
|
968
|
+
]);
|
|
969
|
+
var YAML11_SCHEMA = new Schema([
|
|
970
|
+
...FAILSAFE_SCHEMA.tags,
|
|
971
|
+
nullYaml11Tag,
|
|
972
|
+
boolYaml11Tag,
|
|
973
|
+
intYaml11Tag,
|
|
974
|
+
floatYaml11Tag,
|
|
975
|
+
timestampTag,
|
|
976
|
+
mergeTag,
|
|
977
|
+
binaryTag,
|
|
978
|
+
omapTag,
|
|
979
|
+
pairsTag,
|
|
980
|
+
setTag
|
|
981
|
+
]);
|
|
982
|
+
var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
983
|
+
create: () => /* @__PURE__ */ new Map(),
|
|
984
|
+
addPair: (container, key, value) => {
|
|
985
|
+
container.set(key, value);
|
|
986
|
+
return "";
|
|
987
|
+
},
|
|
988
|
+
has: (container, key) => container.has(key),
|
|
989
|
+
keys: (container) => container.keys(),
|
|
990
|
+
get: (container, key) => container.get(key),
|
|
991
|
+
identify: (data) => data instanceof Map || isPlainObject(data),
|
|
992
|
+
represent: (data) => {
|
|
993
|
+
if (data instanceof Map) return data;
|
|
994
|
+
const map = /* @__PURE__ */ new Map();
|
|
995
|
+
const obj = data;
|
|
996
|
+
for (const key of Object.keys(obj)) map.set(key, obj[key]);
|
|
997
|
+
return map;
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
function normalizeKey(key) {
|
|
1001
|
+
if (Array.isArray(key)) {
|
|
1002
|
+
const array = Array.prototype.slice.call(key);
|
|
1003
|
+
for (let index = 0; index < array.length; index++) {
|
|
1004
|
+
if (Array.isArray(array[index])) return null;
|
|
1005
|
+
if (typeof array[index] === "object" && Object.prototype.toString.call(array[index]) === "[object Object]") array[index] = "[object Object]";
|
|
1006
|
+
}
|
|
1007
|
+
return String(array);
|
|
1008
|
+
}
|
|
1009
|
+
if (typeof key === "object" && Object.prototype.toString.call(key) === "[object Object]") return "[object Object]";
|
|
1010
|
+
return String(key);
|
|
1011
|
+
}
|
|
1012
|
+
var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
1013
|
+
create: () => ({}),
|
|
1014
|
+
identify: isPlainObject,
|
|
1015
|
+
represent: (o) => {
|
|
1016
|
+
const map = /* @__PURE__ */ new Map();
|
|
1017
|
+
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
1018
|
+
return map;
|
|
1019
|
+
},
|
|
1020
|
+
addPair: (container, key, value) => {
|
|
1021
|
+
const normalizedKey = normalizeKey(key);
|
|
1022
|
+
if (normalizedKey === null) return "nested arrays are not supported inside keys";
|
|
1023
|
+
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
1024
|
+
value,
|
|
1025
|
+
enumerable: true,
|
|
1026
|
+
configurable: true,
|
|
1027
|
+
writable: true
|
|
1028
|
+
});
|
|
1029
|
+
else container[normalizedKey] = value;
|
|
1030
|
+
return "";
|
|
1031
|
+
},
|
|
1032
|
+
has: (container, key) => {
|
|
1033
|
+
const normalizedKey = normalizeKey(key);
|
|
1034
|
+
return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
|
|
1035
|
+
},
|
|
1036
|
+
keys: (container) => Object.keys(container),
|
|
1037
|
+
get: (container, key) => container[String(key)]
|
|
1038
|
+
});
|
|
1039
|
+
var DEFAULT_SNIPPET_OPTIONS = {
|
|
1040
|
+
maxLength: 79,
|
|
1041
|
+
indent: 1,
|
|
1042
|
+
linesBefore: 3,
|
|
1043
|
+
linesAfter: 2
|
|
1044
|
+
};
|
|
1045
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
1046
|
+
let head = "";
|
|
1047
|
+
let tail = "";
|
|
1048
|
+
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
1049
|
+
if (position - lineStart > maxHalfLength) {
|
|
1050
|
+
head = " ... ";
|
|
1051
|
+
lineStart = position - maxHalfLength + head.length;
|
|
1052
|
+
}
|
|
1053
|
+
if (lineEnd - position > maxHalfLength) {
|
|
1054
|
+
tail = " ...";
|
|
1055
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
1059
|
+
pos: position - lineStart + head.length
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
function padStart(string, max) {
|
|
1063
|
+
return " ".repeat(Math.max(max - string.length, 0)) + string;
|
|
1064
|
+
}
|
|
1065
|
+
function makeSnippet(mark, options) {
|
|
1066
|
+
if (!mark.buffer) return null;
|
|
1067
|
+
const opts = {
|
|
1068
|
+
...DEFAULT_SNIPPET_OPTIONS,
|
|
1069
|
+
...options
|
|
1070
|
+
};
|
|
1071
|
+
const re = /\r?\n|\r|\0/g;
|
|
1072
|
+
const lineStarts = [0];
|
|
1073
|
+
const lineEnds = [];
|
|
1074
|
+
let match;
|
|
1075
|
+
let foundLineNo = -1;
|
|
1076
|
+
while (match = re.exec(mark.buffer)) {
|
|
1077
|
+
lineEnds.push(match.index);
|
|
1078
|
+
lineStarts.push(match.index + match[0].length);
|
|
1079
|
+
if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
|
|
1080
|
+
}
|
|
1081
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
1082
|
+
let result = "";
|
|
1083
|
+
const lineNoLength = Math.min(mark.line + opts.linesAfter, lineEnds.length).toString().length;
|
|
1084
|
+
const maxLineLength = opts.maxLength - (opts.indent + lineNoLength + 3);
|
|
1085
|
+
for (let i = 1; i <= opts.linesBefore; i++) {
|
|
1086
|
+
if (foundLineNo - i < 0) break;
|
|
1087
|
+
const line2 = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
1088
|
+
result = `${" ".repeat(opts.indent)}${padStart((mark.line - i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
1089
|
+
${result}`;
|
|
1090
|
+
}
|
|
1091
|
+
const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
1092
|
+
result += `${" ".repeat(opts.indent)}${padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}
|
|
1093
|
+
`;
|
|
1094
|
+
result += `${"-".repeat(opts.indent + lineNoLength + 3 + line.pos)}^
|
|
1095
|
+
`;
|
|
1096
|
+
for (let i = 1; i <= opts.linesAfter; i++) {
|
|
1097
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
1098
|
+
const line2 = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
1099
|
+
result += `${" ".repeat(opts.indent)}${padStart((mark.line + i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
1100
|
+
`;
|
|
1101
|
+
}
|
|
1102
|
+
return result.replace(/\n$/, "");
|
|
1103
|
+
}
|
|
1104
|
+
function formatError(exception, compact) {
|
|
1105
|
+
let where = "";
|
|
1106
|
+
if (!exception.mark) return exception.reason;
|
|
1107
|
+
if (exception.mark.name) where += `in "${exception.mark.name}" `;
|
|
1108
|
+
where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
|
|
1109
|
+
if (!compact && exception.mark.snippet) where += `
|
|
1110
|
+
|
|
1111
|
+
${exception.mark.snippet}`;
|
|
1112
|
+
return `${exception.reason} ${where}`;
|
|
1113
|
+
}
|
|
1114
|
+
var YAMLException = class extends Error {
|
|
1115
|
+
reason;
|
|
1116
|
+
mark;
|
|
1117
|
+
constructor(reason, mark) {
|
|
1118
|
+
super();
|
|
1119
|
+
this.name = "YAMLException";
|
|
1120
|
+
this.reason = reason;
|
|
1121
|
+
this.mark = mark;
|
|
1122
|
+
this.message = formatError(this, false);
|
|
1123
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
1124
|
+
}
|
|
1125
|
+
toString(compact) {
|
|
1126
|
+
return `${this.name}: ${formatError(this, compact)}`;
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
function throwErrorAt(source, position, message, filename = "") {
|
|
1130
|
+
let line = 0;
|
|
1131
|
+
let lineStart = 0;
|
|
1132
|
+
for (let index = 0; index < position; index++) {
|
|
1133
|
+
const ch = source.charCodeAt(index);
|
|
1134
|
+
if (ch === 10) {
|
|
1135
|
+
line++;
|
|
1136
|
+
lineStart = index + 1;
|
|
1137
|
+
} else if (ch === 13) {
|
|
1138
|
+
line++;
|
|
1139
|
+
if (source.charCodeAt(index + 1) === 10) index++;
|
|
1140
|
+
lineStart = index + 1;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const mark = {
|
|
1144
|
+
name: filename,
|
|
1145
|
+
buffer: source,
|
|
1146
|
+
position,
|
|
1147
|
+
line,
|
|
1148
|
+
column: position - lineStart
|
|
1149
|
+
};
|
|
1150
|
+
mark.snippet = makeSnippet(mark);
|
|
1151
|
+
throw new YAMLException(message, mark);
|
|
1152
|
+
}
|
|
1153
|
+
var NO_RANGE$3 = -1;
|
|
1154
|
+
function simpleEscapeSequence(c) {
|
|
1155
|
+
switch (c) {
|
|
1156
|
+
case 48:
|
|
1157
|
+
return "\0";
|
|
1158
|
+
case 97:
|
|
1159
|
+
return "\x07";
|
|
1160
|
+
case 98:
|
|
1161
|
+
return "\b";
|
|
1162
|
+
case 116:
|
|
1163
|
+
return " ";
|
|
1164
|
+
case 9:
|
|
1165
|
+
return " ";
|
|
1166
|
+
case 110:
|
|
1167
|
+
return "\n";
|
|
1168
|
+
case 118:
|
|
1169
|
+
return "\v";
|
|
1170
|
+
case 102:
|
|
1171
|
+
return "\f";
|
|
1172
|
+
case 114:
|
|
1173
|
+
return "\r";
|
|
1174
|
+
case 101:
|
|
1175
|
+
return "\x1B";
|
|
1176
|
+
case 32:
|
|
1177
|
+
return " ";
|
|
1178
|
+
case 34:
|
|
1179
|
+
return '"';
|
|
1180
|
+
case 47:
|
|
1181
|
+
return "/";
|
|
1182
|
+
case 92:
|
|
1183
|
+
return "\\";
|
|
1184
|
+
case 78:
|
|
1185
|
+
return "\x85";
|
|
1186
|
+
case 95:
|
|
1187
|
+
return "\xA0";
|
|
1188
|
+
case 76:
|
|
1189
|
+
return "\u2028";
|
|
1190
|
+
case 80:
|
|
1191
|
+
return "\u2029";
|
|
1192
|
+
default:
|
|
1193
|
+
return "";
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
var simpleEscapeCheck = new Array(256);
|
|
1197
|
+
var simpleEscapeMap = new Array(256);
|
|
1198
|
+
for (let i = 0; i < 256; i++) {
|
|
1199
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1200
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1201
|
+
}
|
|
1202
|
+
function charFromCodepoint(c) {
|
|
1203
|
+
if (c <= 65535) return String.fromCharCode(c);
|
|
1204
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1205
|
+
}
|
|
1206
|
+
function fromHexCode$1(c) {
|
|
1207
|
+
if (c >= 48 && c <= 57) return c - 48;
|
|
1208
|
+
return (c | 32) - 97 + 10;
|
|
1209
|
+
}
|
|
1210
|
+
function escapedHexLen$1(c) {
|
|
1211
|
+
if (c === 120) return 2;
|
|
1212
|
+
if (c === 117) return 4;
|
|
1213
|
+
return 8;
|
|
1214
|
+
}
|
|
1215
|
+
function skipFoldedBreaks(input, position, end) {
|
|
1216
|
+
let breaks = 0;
|
|
1217
|
+
while (position < end) {
|
|
1218
|
+
const ch = input.charCodeAt(position);
|
|
1219
|
+
if (ch === 10) {
|
|
1220
|
+
breaks++;
|
|
1221
|
+
position++;
|
|
1222
|
+
} else if (ch === 13) {
|
|
1223
|
+
breaks++;
|
|
1224
|
+
position++;
|
|
1225
|
+
if (input.charCodeAt(position) === 10) position++;
|
|
1226
|
+
} else if (ch === 32 || ch === 9) position++;
|
|
1227
|
+
else break;
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
position,
|
|
1231
|
+
breaks
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function foldedBreaks(count) {
|
|
1235
|
+
if (count === 1) return " ";
|
|
1236
|
+
return "\n".repeat(count - 1);
|
|
1237
|
+
}
|
|
1238
|
+
function getPlainValue(input, start, end) {
|
|
1239
|
+
let result = "";
|
|
1240
|
+
let position = start;
|
|
1241
|
+
let captureStart = start;
|
|
1242
|
+
let captureEnd = start;
|
|
1243
|
+
while (position < end) {
|
|
1244
|
+
const ch = input.charCodeAt(position);
|
|
1245
|
+
if (ch === 10 || ch === 13) {
|
|
1246
|
+
result += input.slice(captureStart, captureEnd);
|
|
1247
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1248
|
+
result += foldedBreaks(fold.breaks);
|
|
1249
|
+
position = captureStart = captureEnd = fold.position;
|
|
1250
|
+
} else {
|
|
1251
|
+
position++;
|
|
1252
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
return result + input.slice(captureStart, captureEnd);
|
|
1256
|
+
}
|
|
1257
|
+
function getSingleQuotedValue(input, start, end) {
|
|
1258
|
+
let result = "";
|
|
1259
|
+
let position = start;
|
|
1260
|
+
let captureStart = start;
|
|
1261
|
+
let captureEnd = start;
|
|
1262
|
+
while (position < end) {
|
|
1263
|
+
const ch = input.charCodeAt(position);
|
|
1264
|
+
if (ch === 39) {
|
|
1265
|
+
result += input.slice(captureStart, position) + "'";
|
|
1266
|
+
position += 2;
|
|
1267
|
+
captureStart = captureEnd = position;
|
|
1268
|
+
} else if (ch === 10 || ch === 13) {
|
|
1269
|
+
result += input.slice(captureStart, captureEnd);
|
|
1270
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1271
|
+
result += foldedBreaks(fold.breaks);
|
|
1272
|
+
position = captureStart = captureEnd = fold.position;
|
|
1273
|
+
} else {
|
|
1274
|
+
position++;
|
|
1275
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return result + input.slice(captureStart, end);
|
|
1279
|
+
}
|
|
1280
|
+
function getDoubleQuotedValue(input, start, end) {
|
|
1281
|
+
let result = "";
|
|
1282
|
+
let position = start;
|
|
1283
|
+
let captureStart = start;
|
|
1284
|
+
let captureEnd = start;
|
|
1285
|
+
while (position < end) {
|
|
1286
|
+
const ch = input.charCodeAt(position);
|
|
1287
|
+
if (ch === 92) {
|
|
1288
|
+
result += input.slice(captureStart, position);
|
|
1289
|
+
position++;
|
|
1290
|
+
const escaped = input.charCodeAt(position);
|
|
1291
|
+
if (escaped === 10 || escaped === 13) position = skipFoldedBreaks(input, position, end).position;
|
|
1292
|
+
else if (escaped < 256 && simpleEscapeCheck[escaped]) {
|
|
1293
|
+
result += simpleEscapeMap[escaped];
|
|
1294
|
+
position++;
|
|
1295
|
+
} else {
|
|
1296
|
+
let hexLength = escapedHexLen$1(escaped);
|
|
1297
|
+
let hexResult = 0;
|
|
1298
|
+
for (; hexLength > 0; hexLength--) {
|
|
1299
|
+
position++;
|
|
1300
|
+
const digit = fromHexCode$1(input.charCodeAt(position));
|
|
1301
|
+
hexResult = (hexResult << 4) + digit;
|
|
1302
|
+
}
|
|
1303
|
+
result += charFromCodepoint(hexResult);
|
|
1304
|
+
position++;
|
|
1305
|
+
}
|
|
1306
|
+
captureStart = captureEnd = position;
|
|
1307
|
+
} else if (ch === 10 || ch === 13) {
|
|
1308
|
+
result += input.slice(captureStart, captureEnd);
|
|
1309
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1310
|
+
result += foldedBreaks(fold.breaks);
|
|
1311
|
+
position = captureStart = captureEnd = fold.position;
|
|
1312
|
+
} else {
|
|
1313
|
+
position++;
|
|
1314
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
return result + input.slice(captureStart, end);
|
|
1318
|
+
}
|
|
1319
|
+
function getBlockValue(input, start, end, indent, chomping, folded) {
|
|
1320
|
+
const textIndent = indent < 0 ? 0 : indent;
|
|
1321
|
+
const region = input.slice(start, end).replace(/\r\n?/g, "\n");
|
|
1322
|
+
const lines = region === "" ? [] : (region.endsWith("\n") ? region.slice(0, -1) : region).split("\n");
|
|
1323
|
+
let result = "";
|
|
1324
|
+
let didReadContent = false;
|
|
1325
|
+
let emptyLines = 0;
|
|
1326
|
+
let atMoreIndented = false;
|
|
1327
|
+
for (const line of lines) {
|
|
1328
|
+
let column = 0;
|
|
1329
|
+
while (column < textIndent && line.charCodeAt(column) === 32) column++;
|
|
1330
|
+
if (indent < 0 || column >= line.length) {
|
|
1331
|
+
emptyLines++;
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
const content = line.slice(textIndent);
|
|
1335
|
+
const first = content.charCodeAt(0);
|
|
1336
|
+
if (folded) if (first === 32 || first === 9) {
|
|
1337
|
+
atMoreIndented = true;
|
|
1338
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1339
|
+
} else if (atMoreIndented) {
|
|
1340
|
+
atMoreIndented = false;
|
|
1341
|
+
result += "\n".repeat(emptyLines + 1);
|
|
1342
|
+
} else if (emptyLines === 0) {
|
|
1343
|
+
if (didReadContent) result += " ";
|
|
1344
|
+
} else result += "\n".repeat(emptyLines);
|
|
1345
|
+
else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1346
|
+
result += content;
|
|
1347
|
+
didReadContent = true;
|
|
1348
|
+
emptyLines = 0;
|
|
1349
|
+
}
|
|
1350
|
+
if (chomping === 3) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1351
|
+
else if (chomping !== 2) {
|
|
1352
|
+
if (didReadContent) result += "\n";
|
|
1353
|
+
}
|
|
1354
|
+
return result;
|
|
1355
|
+
}
|
|
1356
|
+
function getScalarValue(input, scalar) {
|
|
1357
|
+
if (scalar.valueStart === NO_RANGE$3) return "";
|
|
1358
|
+
const { valueStart, valueEnd } = scalar;
|
|
1359
|
+
if (scalar.fast) return input.slice(valueStart, valueEnd);
|
|
1360
|
+
switch (scalar.style) {
|
|
1361
|
+
case 2:
|
|
1362
|
+
return getSingleQuotedValue(input, valueStart, valueEnd);
|
|
1363
|
+
case 3:
|
|
1364
|
+
return getDoubleQuotedValue(input, valueStart, valueEnd);
|
|
1365
|
+
case 4:
|
|
1366
|
+
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
|
|
1367
|
+
case 5:
|
|
1368
|
+
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
|
|
1369
|
+
default:
|
|
1370
|
+
return getPlainValue(input, valueStart, valueEnd);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
var DEFAULT_TAG_HANDLERS = {
|
|
1374
|
+
"!": "!",
|
|
1375
|
+
"!!": "tag:yaml.org,2002:"
|
|
1376
|
+
};
|
|
1377
|
+
function tagNameFull(rawTag, tagHandlers) {
|
|
1378
|
+
if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
|
|
1379
|
+
const handleEnd = rawTag.indexOf("!", 1);
|
|
1380
|
+
const handle = handleEnd === -1 ? "!" : rawTag.slice(0, handleEnd + 1);
|
|
1381
|
+
const prefix = tagHandlers?.[handle] ?? DEFAULT_TAG_HANDLERS[handle] ?? handle;
|
|
1382
|
+
return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
|
|
1383
|
+
}
|
|
1384
|
+
var NO_RANGE$2 = -1;
|
|
1385
|
+
var DEFAULT_CONSTRUCTOR_OPTIONS = {
|
|
1386
|
+
filename: "",
|
|
1387
|
+
schema: CORE_SCHEMA,
|
|
1388
|
+
json: false,
|
|
1389
|
+
maxTotalMergeKeys: 1e4,
|
|
1390
|
+
maxAliases: -1
|
|
1391
|
+
};
|
|
1392
|
+
function eventPosition$1(event) {
|
|
1393
|
+
if ("tagStart" in event && event.tagStart !== NO_RANGE$2) return event.tagStart;
|
|
1394
|
+
if ("anchorStart" in event && event.anchorStart !== NO_RANGE$2) return event.anchorStart;
|
|
1395
|
+
if ("valueStart" in event && event.valueStart !== NO_RANGE$2) return event.valueStart;
|
|
1396
|
+
if ("start" in event) return event.start;
|
|
1397
|
+
return 0;
|
|
1398
|
+
}
|
|
1399
|
+
function throwError$1(state, message) {
|
|
1400
|
+
throwErrorAt(state.source, state.position, message, state.filename);
|
|
1401
|
+
}
|
|
1402
|
+
function finalizeCollection(state, position, tag, carrier) {
|
|
1403
|
+
try {
|
|
1404
|
+
return tag.finalize(carrier);
|
|
1405
|
+
} catch (error) {
|
|
1406
|
+
if (error instanceof YAMLException) throw error;
|
|
1407
|
+
throwErrorAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
function lookupTag(exact, prefix, tagName) {
|
|
1411
|
+
const exactTag = exact[tagName];
|
|
1412
|
+
if (exactTag) return exactTag;
|
|
1413
|
+
for (const tag of prefix) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1414
|
+
}
|
|
1415
|
+
function findExplicitTag(state, exact, prefix, tagName, nodeKind) {
|
|
1416
|
+
const tag = lookupTag(exact, prefix, tagName);
|
|
1417
|
+
if (tag) return tag;
|
|
1418
|
+
throwError$1(state, `unknown ${nodeKind} tag !<${tagName}>`);
|
|
1419
|
+
}
|
|
1420
|
+
function constructScalar(state, event) {
|
|
1421
|
+
const source = getScalarValue(state.source, event);
|
|
1422
|
+
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1423
|
+
const strTag2 = state.schema.defaultScalarTag;
|
|
1424
|
+
if (rawTag !== "") {
|
|
1425
|
+
if (rawTag === "!") return {
|
|
1426
|
+
value: source,
|
|
1427
|
+
tag: strTag2
|
|
1428
|
+
};
|
|
1429
|
+
const tagName = tagNameFull(rawTag, state.tagHandlers);
|
|
1430
|
+
const scalarTag = lookupTag(state.schema.exact.scalar, state.schema.prefix.scalar, tagName);
|
|
1431
|
+
if (scalarTag) {
|
|
1432
|
+
const result = scalarTag.resolve(source, true, tagName);
|
|
1433
|
+
if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1434
|
+
return {
|
|
1435
|
+
value: result,
|
|
1436
|
+
tag: scalarTag
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
const collectionTagDef = lookupTag(state.schema.exact.mapping, state.schema.prefix.mapping, tagName) ?? lookupTag(state.schema.exact.sequence, state.schema.prefix.sequence, tagName);
|
|
1440
|
+
if (collectionTagDef) {
|
|
1441
|
+
if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1442
|
+
const carrier = collectionTagDef.create(tagName);
|
|
1443
|
+
return {
|
|
1444
|
+
value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier),
|
|
1445
|
+
tag: collectionTagDef
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
throwError$1(state, `unknown scalar tag !<${tagName}>`);
|
|
1449
|
+
}
|
|
1450
|
+
if (event.style === 1) {
|
|
1451
|
+
const candidates = state.schema.implicitScalarByFirstChar.get(source.charAt(0)) ?? state.schema.implicitScalarAnyFirstChar;
|
|
1452
|
+
for (const tag of candidates) {
|
|
1453
|
+
const result = tag.resolve(source, false, tag.tagName);
|
|
1454
|
+
if (result !== NOT_RESOLVED) return {
|
|
1455
|
+
value: result,
|
|
1456
|
+
tag
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
return {
|
|
1461
|
+
value: strTag2.resolve(source, false, strTag2.tagName),
|
|
1462
|
+
tag: strTag2
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function collectionTag(state, event, exact, prefix, defaultTagName, nodeKind) {
|
|
1466
|
+
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1467
|
+
const tagName = rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
|
|
1468
|
+
return {
|
|
1469
|
+
tagName,
|
|
1470
|
+
tag: findExplicitTag(state, exact, prefix, tagName, nodeKind)
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function isMappingTag(tag) {
|
|
1474
|
+
return tag.nodeKind === "mapping";
|
|
1475
|
+
}
|
|
1476
|
+
function mergeKeys(state, frame, source, sourceTag) {
|
|
1477
|
+
for (const sourceKey of sourceTag.keys(source)) {
|
|
1478
|
+
if (state.maxTotalMergeKeys !== -1 && ++state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1479
|
+
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1480
|
+
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1481
|
+
if (err) throwError$1(state, err);
|
|
1482
|
+
(frame.overridable ??= /* @__PURE__ */ new Set()).add(sourceKey);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
function mergeSource(state, frame, source, sourceTag) {
|
|
1486
|
+
state.position = frame.keyPosition;
|
|
1487
|
+
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1488
|
+
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) for (const element of source) mergeKeys(state, frame, element, frame.tag);
|
|
1489
|
+
else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1490
|
+
}
|
|
1491
|
+
function addMappingValue(state, frame, key, value, tag) {
|
|
1492
|
+
state.position = frame.keyPosition;
|
|
1493
|
+
if (key === MERGE_KEY) {
|
|
1494
|
+
mergeSource(state, frame, value, tag);
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
if (!state.json && frame.tag.has(frame.value, key) && !frame.overridable?.has(key)) throwError$1(state, "duplicated mapping key");
|
|
1498
|
+
const err = frame.tag.addPair(frame.value, key, value);
|
|
1499
|
+
if (err) throwError$1(state, err);
|
|
1500
|
+
frame.overridable?.delete(key);
|
|
1501
|
+
}
|
|
1502
|
+
function addValue(state, value, tag) {
|
|
1503
|
+
const frame = state.frames[state.frames.length - 1];
|
|
1504
|
+
if (frame.kind === "document") {
|
|
1505
|
+
frame.value = value;
|
|
1506
|
+
frame.hasValue = true;
|
|
1507
|
+
} else if (frame.kind === "sequence") {
|
|
1508
|
+
if (frame.merge) {
|
|
1509
|
+
if (!isMappingTag(tag)) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1510
|
+
}
|
|
1511
|
+
const err = frame.tag.addItem(frame.value, value, frame.index++);
|
|
1512
|
+
if (err) throwError$1(state, err);
|
|
1513
|
+
} else if (frame.hasKey) {
|
|
1514
|
+
const key = frame.key;
|
|
1515
|
+
frame.key = void 0;
|
|
1516
|
+
frame.hasKey = false;
|
|
1517
|
+
addMappingValue(state, frame, key, value, tag);
|
|
1518
|
+
} else {
|
|
1519
|
+
frame.key = value;
|
|
1520
|
+
frame.keyPosition = state.position;
|
|
1521
|
+
frame.hasKey = true;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
function storeAnchor(state, event, value, tag, isValueFinal) {
|
|
1525
|
+
if (event.anchorStart !== NO_RANGE$2) {
|
|
1526
|
+
const anchor = {
|
|
1527
|
+
value,
|
|
1528
|
+
tag,
|
|
1529
|
+
isValueFinal
|
|
1530
|
+
};
|
|
1531
|
+
state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
|
|
1532
|
+
return anchor;
|
|
1533
|
+
}
|
|
1534
|
+
return null;
|
|
1535
|
+
}
|
|
1536
|
+
function constructFromEvents(events, options) {
|
|
1537
|
+
const state = {
|
|
1538
|
+
...DEFAULT_CONSTRUCTOR_OPTIONS,
|
|
1539
|
+
...options,
|
|
1540
|
+
events,
|
|
1541
|
+
documents: [],
|
|
1542
|
+
eventIndex: 0,
|
|
1543
|
+
position: 0,
|
|
1544
|
+
frames: [],
|
|
1545
|
+
anchors: /* @__PURE__ */ new Map(),
|
|
1546
|
+
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
1547
|
+
totalMergeKeys: 0,
|
|
1548
|
+
aliasCount: 0
|
|
1549
|
+
};
|
|
1550
|
+
while (state.eventIndex < state.events.length) {
|
|
1551
|
+
const event = state.events[state.eventIndex++];
|
|
1552
|
+
state.position = eventPosition$1(event);
|
|
1553
|
+
switch (event.type) {
|
|
1554
|
+
case 1:
|
|
1555
|
+
state.anchors = /* @__PURE__ */ new Map();
|
|
1556
|
+
state.aliasCount = 0;
|
|
1557
|
+
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
1558
|
+
for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
|
|
1559
|
+
state.frames.push({
|
|
1560
|
+
kind: "document",
|
|
1561
|
+
position: state.position,
|
|
1562
|
+
value: void 0,
|
|
1563
|
+
hasValue: false
|
|
1564
|
+
});
|
|
1565
|
+
break;
|
|
1566
|
+
case 4: {
|
|
1567
|
+
const { value, tag } = constructScalar(state, event);
|
|
1568
|
+
storeAnchor(state, event, value, tag, true);
|
|
1569
|
+
addValue(state, value, tag);
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
case 2: {
|
|
1573
|
+
const definition = collectionTag(state, event, state.schema.exact.sequence, state.schema.prefix.sequence, "tag:yaml.org,2002:seq", "sequence");
|
|
1574
|
+
const value = definition.tag.create(definition.tagName);
|
|
1575
|
+
const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
|
|
1576
|
+
const parent = state.frames[state.frames.length - 1];
|
|
1577
|
+
const merge = parent !== void 0 && parent.kind === "mapping" && parent.hasKey && parent.key === MERGE_KEY;
|
|
1578
|
+
state.frames.push({
|
|
1579
|
+
kind: "sequence",
|
|
1580
|
+
position: state.position,
|
|
1581
|
+
value,
|
|
1582
|
+
tag: definition.tag,
|
|
1583
|
+
anchor,
|
|
1584
|
+
index: 0,
|
|
1585
|
+
merge
|
|
1586
|
+
});
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
case 3: {
|
|
1590
|
+
const definition = collectionTag(state, event, state.schema.exact.mapping, state.schema.prefix.mapping, "tag:yaml.org,2002:map", "mapping");
|
|
1591
|
+
const value = definition.tag.create(definition.tagName);
|
|
1592
|
+
const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
|
|
1593
|
+
state.frames.push({
|
|
1594
|
+
kind: "mapping",
|
|
1595
|
+
position: state.position,
|
|
1596
|
+
value,
|
|
1597
|
+
tag: definition.tag,
|
|
1598
|
+
anchor,
|
|
1599
|
+
key: void 0,
|
|
1600
|
+
keyPosition: state.position,
|
|
1601
|
+
hasKey: false,
|
|
1602
|
+
overridable: null
|
|
1603
|
+
});
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
1606
|
+
case 5: {
|
|
1607
|
+
if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
|
|
1608
|
+
const name = state.source.slice(event.anchorStart, event.anchorEnd);
|
|
1609
|
+
const anchor = state.anchors.get(name);
|
|
1610
|
+
if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
|
|
1611
|
+
if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
|
|
1612
|
+
addValue(state, anchor.value, anchor.tag);
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1615
|
+
case 6: {
|
|
1616
|
+
const frame = state.frames.pop();
|
|
1617
|
+
if (frame.kind === "document") state.documents.push(frame.value);
|
|
1618
|
+
else {
|
|
1619
|
+
const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
|
|
1620
|
+
if (frame.anchor) {
|
|
1621
|
+
frame.anchor.value = value;
|
|
1622
|
+
frame.anchor.isValueFinal = true;
|
|
1623
|
+
}
|
|
1624
|
+
addValue(state, value, frame.tag);
|
|
1625
|
+
}
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return state.documents;
|
|
1631
|
+
}
|
|
1632
|
+
var NO_RANGE$1 = -1;
|
|
1633
|
+
var HAS_OWN = Object.prototype.hasOwnProperty;
|
|
1634
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1635
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1636
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1637
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1638
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1639
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
|
|
1640
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
|
|
1641
|
+
var NS_URI_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
|
|
1642
|
+
var NS_TAG_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
|
|
1643
|
+
var PATTERN_TAG_URI = new RegExp(`^(?:${NS_URI_CHAR})*$`);
|
|
1644
|
+
var PATTERN_TAG_SUFFIX = new RegExp(`^(?:${NS_TAG_CHAR})+$`);
|
|
1645
|
+
var PATTERN_TAG_PREFIX = new RegExp(`^(?:!(?:${NS_URI_CHAR})*|${NS_TAG_CHAR}(?:${NS_URI_CHAR})*)$`);
|
|
1646
|
+
var DEFAULT_PARSER_OPTIONS = {
|
|
1647
|
+
filename: "",
|
|
1648
|
+
maxDepth: 100
|
|
1649
|
+
};
|
|
1650
|
+
function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
1651
|
+
state.events.push({
|
|
1652
|
+
type: 1,
|
|
1653
|
+
explicitStart,
|
|
1654
|
+
explicitEnd,
|
|
1655
|
+
directives: state.directives
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1659
|
+
state.events.push({
|
|
1660
|
+
type: 2,
|
|
1661
|
+
start,
|
|
1662
|
+
anchorStart,
|
|
1663
|
+
anchorEnd,
|
|
1664
|
+
tagStart,
|
|
1665
|
+
tagEnd,
|
|
1666
|
+
style
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1670
|
+
state.events.push({
|
|
1671
|
+
type: 3,
|
|
1672
|
+
start,
|
|
1673
|
+
anchorStart,
|
|
1674
|
+
anchorEnd,
|
|
1675
|
+
tagStart,
|
|
1676
|
+
tagEnd,
|
|
1677
|
+
style
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = 1, indent = -1, fast = false) {
|
|
1681
|
+
state.events.push({
|
|
1682
|
+
type: 4,
|
|
1683
|
+
valueStart,
|
|
1684
|
+
valueEnd,
|
|
1685
|
+
anchorStart,
|
|
1686
|
+
anchorEnd,
|
|
1687
|
+
tagStart,
|
|
1688
|
+
tagEnd,
|
|
1689
|
+
style,
|
|
1690
|
+
chomping,
|
|
1691
|
+
indent,
|
|
1692
|
+
fast
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
function addAliasEvent(state, anchorStart, anchorEnd) {
|
|
1696
|
+
state.events.push({
|
|
1697
|
+
type: 5,
|
|
1698
|
+
anchorStart,
|
|
1699
|
+
anchorEnd
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
function addPopEvent(state) {
|
|
1703
|
+
state.events.push({ type: 6 });
|
|
1704
|
+
}
|
|
1705
|
+
function addEmptyScalarEvent(state) {
|
|
1706
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 1);
|
|
1707
|
+
}
|
|
1708
|
+
function emptyProperties() {
|
|
1709
|
+
return {
|
|
1710
|
+
anchorStart: NO_RANGE$1,
|
|
1711
|
+
anchorEnd: NO_RANGE$1,
|
|
1712
|
+
tagStart: NO_RANGE$1,
|
|
1713
|
+
tagEnd: NO_RANGE$1
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function snapshotState(state) {
|
|
1717
|
+
return {
|
|
1718
|
+
position: state.position,
|
|
1719
|
+
line: state.line,
|
|
1720
|
+
lineStart: state.lineStart,
|
|
1721
|
+
lineIndent: state.lineIndent,
|
|
1722
|
+
firstTabInLine: state.firstTabInLine,
|
|
1723
|
+
eventsLength: state.events.length
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
function restoreState(state, snapshot) {
|
|
1727
|
+
state.position = snapshot.position;
|
|
1728
|
+
state.line = snapshot.line;
|
|
1729
|
+
state.lineStart = snapshot.lineStart;
|
|
1730
|
+
state.lineIndent = snapshot.lineIndent;
|
|
1731
|
+
state.firstTabInLine = snapshot.firstTabInLine;
|
|
1732
|
+
state.events.length = snapshot.eventsLength;
|
|
1733
|
+
}
|
|
1734
|
+
function throwError(state, message) {
|
|
1735
|
+
throwErrorAt(state.input.slice(0, state.length), state.position, message, state.filename);
|
|
1736
|
+
}
|
|
1737
|
+
function isEol(c) {
|
|
1738
|
+
return c === 10 || c === 13;
|
|
1739
|
+
}
|
|
1740
|
+
function isWhiteSpace(c) {
|
|
1741
|
+
return c === 9 || c === 32;
|
|
1742
|
+
}
|
|
1743
|
+
function isWsOrEol(c) {
|
|
1744
|
+
return isWhiteSpace(c) || isEol(c);
|
|
1745
|
+
}
|
|
1746
|
+
function isWsOrEolOrEnd(c) {
|
|
1747
|
+
return c === 0 || isWsOrEol(c);
|
|
1748
|
+
}
|
|
1749
|
+
function isFlowIndicator(c) {
|
|
1750
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1751
|
+
}
|
|
1752
|
+
function fromDecimalCode(c) {
|
|
1753
|
+
return c >= 48 && c <= 57 ? c - 48 : -1;
|
|
1754
|
+
}
|
|
1755
|
+
function fromHexCode(c) {
|
|
1756
|
+
if (c >= 48 && c <= 57) return c - 48;
|
|
1757
|
+
const lc = c | 32;
|
|
1758
|
+
if (lc >= 97 && lc <= 102) return lc - 97 + 10;
|
|
1759
|
+
return -1;
|
|
1760
|
+
}
|
|
1761
|
+
function escapedHexLen(c) {
|
|
1762
|
+
if (c === 120) return 2;
|
|
1763
|
+
if (c === 117) return 4;
|
|
1764
|
+
if (c === 85) return 8;
|
|
1765
|
+
return 0;
|
|
1766
|
+
}
|
|
1767
|
+
function isSimpleEscape(c) {
|
|
1768
|
+
return c === 48 || c === 97 || c === 98 || c === 116 || c === 9 || c === 110 || c === 118 || c === 102 || c === 114 || c === 101 || c === 32 || c === 34 || c === 47 || c === 92 || c === 78 || c === 95 || c === 76 || c === 80;
|
|
1769
|
+
}
|
|
1770
|
+
function consumeLineBreak(state) {
|
|
1771
|
+
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1772
|
+
else {
|
|
1773
|
+
state.position++;
|
|
1774
|
+
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1775
|
+
}
|
|
1776
|
+
state.line++;
|
|
1777
|
+
state.lineStart = state.position;
|
|
1778
|
+
state.lineIndent = 0;
|
|
1779
|
+
state.firstTabInLine = -1;
|
|
1780
|
+
}
|
|
1781
|
+
function skipSeparationSpace(state, allowComments) {
|
|
1782
|
+
let lineBreaks = 0;
|
|
1783
|
+
let ch = state.input.charCodeAt(state.position);
|
|
1784
|
+
let hasSeparation = state.position === state.lineStart || isWsOrEol(state.input.charCodeAt(state.position - 1));
|
|
1785
|
+
while (ch !== 0) {
|
|
1786
|
+
while (isWhiteSpace(ch)) {
|
|
1787
|
+
hasSeparation = true;
|
|
1788
|
+
if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
|
|
1789
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1790
|
+
}
|
|
1791
|
+
if (allowComments && hasSeparation && ch === 35) do
|
|
1792
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1793
|
+
while (!isEol(ch) && ch !== 0);
|
|
1794
|
+
if (!isEol(ch)) break;
|
|
1795
|
+
consumeLineBreak(state);
|
|
1796
|
+
lineBreaks++;
|
|
1797
|
+
hasSeparation = true;
|
|
1798
|
+
ch = state.input.charCodeAt(state.position);
|
|
1799
|
+
while (ch === 32) {
|
|
1800
|
+
state.lineIndent++;
|
|
1801
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return lineBreaks;
|
|
1805
|
+
}
|
|
1806
|
+
function testDocumentSeparator(state, position = state.position) {
|
|
1807
|
+
const ch = state.input.charCodeAt(position);
|
|
1808
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(position + 1) && ch === state.input.charCodeAt(position + 2)) {
|
|
1809
|
+
const following = state.input.charCodeAt(position + 3);
|
|
1810
|
+
return following === 0 || isWsOrEol(following);
|
|
1811
|
+
}
|
|
1812
|
+
return false;
|
|
1813
|
+
}
|
|
1814
|
+
function skipUntilLineEnd(state) {
|
|
1815
|
+
let ch = state.input.charCodeAt(state.position);
|
|
1816
|
+
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1817
|
+
}
|
|
1818
|
+
function checkPrintable(state, start, end) {
|
|
1819
|
+
if (PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state, "the stream contains non-printable characters");
|
|
1820
|
+
}
|
|
1821
|
+
function readTagProperty(state, props, inFlow) {
|
|
1822
|
+
if (state.input.charCodeAt(state.position) !== 33) return false;
|
|
1823
|
+
if (props.tagStart !== NO_RANGE$1) throwError(state, "duplication of a tag property");
|
|
1824
|
+
const start = state.position;
|
|
1825
|
+
let isVerbatim = false;
|
|
1826
|
+
let isNamed = false;
|
|
1827
|
+
let tagHandle = "!";
|
|
1828
|
+
let ch = state.input.charCodeAt(++state.position);
|
|
1829
|
+
if (ch === 60) {
|
|
1830
|
+
isVerbatim = true;
|
|
1831
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1832
|
+
} else if (ch === 33) {
|
|
1833
|
+
isNamed = true;
|
|
1834
|
+
tagHandle = "!!";
|
|
1835
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1836
|
+
}
|
|
1837
|
+
let suffixStart = state.position;
|
|
1838
|
+
let tagName;
|
|
1839
|
+
if (isVerbatim) {
|
|
1840
|
+
while (ch !== 0 && ch !== 62) ch = state.input.charCodeAt(++state.position);
|
|
1841
|
+
if (ch !== 62) throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1842
|
+
tagName = state.input.slice(suffixStart, state.position);
|
|
1843
|
+
state.position++;
|
|
1844
|
+
} else {
|
|
1845
|
+
while (ch !== 0 && !isWsOrEol(ch) && !(inFlow && isFlowIndicator(ch))) {
|
|
1846
|
+
if (ch === 33) if (!isNamed) {
|
|
1847
|
+
tagHandle = state.input.slice(suffixStart - 1, state.position + 1);
|
|
1848
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
|
|
1849
|
+
isNamed = true;
|
|
1850
|
+
suffixStart = state.position + 1;
|
|
1851
|
+
} else throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1852
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1853
|
+
}
|
|
1854
|
+
tagName = state.input.slice(suffixStart, state.position);
|
|
1855
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1856
|
+
}
|
|
1857
|
+
if (tagName && !(isVerbatim ? PATTERN_TAG_URI.test(tagName) : PATTERN_TAG_SUFFIX.test(tagName))) throwError(state, `tag name cannot contain such characters: ${tagName}`);
|
|
1858
|
+
if (!isVerbatim && tagHandle !== "!" && tagHandle !== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state, `undeclared tag handle "${tagHandle}"`);
|
|
1859
|
+
props.tagStart = start;
|
|
1860
|
+
props.tagEnd = state.position;
|
|
1861
|
+
return true;
|
|
1862
|
+
}
|
|
1863
|
+
function readAnchorProperty(state, props) {
|
|
1864
|
+
if (state.input.charCodeAt(state.position) !== 38) return false;
|
|
1865
|
+
if (props.anchorStart !== NO_RANGE$1) throwError(state, "duplication of an anchor property");
|
|
1866
|
+
state.position++;
|
|
1867
|
+
const start = state.position;
|
|
1868
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1869
|
+
if (state.position === start) throwError(state, "name of an anchor node must contain at least one character");
|
|
1870
|
+
props.anchorStart = start;
|
|
1871
|
+
props.anchorEnd = state.position;
|
|
1872
|
+
return true;
|
|
1873
|
+
}
|
|
1874
|
+
function readAlias(state, props) {
|
|
1875
|
+
if (state.input.charCodeAt(state.position) !== 42) return false;
|
|
1876
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) throwError(state, "alias node should not have any properties");
|
|
1877
|
+
state.position++;
|
|
1878
|
+
const start = state.position;
|
|
1879
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1880
|
+
if (state.position === start) throwError(state, "name of an alias node must contain at least one character");
|
|
1881
|
+
addAliasEvent(state, start, state.position);
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
function readFlowScalarBreak(state, nodeIndent) {
|
|
1885
|
+
skipSeparationSpace(state, false);
|
|
1886
|
+
if (state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
1887
|
+
}
|
|
1888
|
+
function readSingleQuotedScalar(state, nodeIndent, props) {
|
|
1889
|
+
if (state.input.charCodeAt(state.position) !== 39) return false;
|
|
1890
|
+
state.position++;
|
|
1891
|
+
const start = state.position;
|
|
1892
|
+
let simple = true;
|
|
1893
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1894
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1895
|
+
if (ch === 39) {
|
|
1896
|
+
if (state.input.charCodeAt(state.position + 1) === 39) {
|
|
1897
|
+
simple = false;
|
|
1898
|
+
state.position += 2;
|
|
1899
|
+
continue;
|
|
1900
|
+
}
|
|
1901
|
+
const end = state.position;
|
|
1902
|
+
state.position++;
|
|
1903
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2, 1, -1, simple);
|
|
1904
|
+
return true;
|
|
1905
|
+
}
|
|
1906
|
+
if (isEol(ch)) {
|
|
1907
|
+
simple = false;
|
|
1908
|
+
readFlowScalarBreak(state, nodeIndent);
|
|
1909
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1910
|
+
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1911
|
+
else state.position++;
|
|
1912
|
+
}
|
|
1913
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1914
|
+
}
|
|
1915
|
+
function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
1916
|
+
if (state.input.charCodeAt(state.position) !== 34) return false;
|
|
1917
|
+
state.position++;
|
|
1918
|
+
const start = state.position;
|
|
1919
|
+
let simple = true;
|
|
1920
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1921
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1922
|
+
if (ch === 34) {
|
|
1923
|
+
const end = state.position;
|
|
1924
|
+
state.position++;
|
|
1925
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 3, 1, -1, simple);
|
|
1926
|
+
return true;
|
|
1927
|
+
}
|
|
1928
|
+
if (ch === 92) {
|
|
1929
|
+
simple = false;
|
|
1930
|
+
const escaped = state.input.charCodeAt(++state.position);
|
|
1931
|
+
if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
|
|
1932
|
+
else if (isSimpleEscape(escaped)) state.position++;
|
|
1933
|
+
else {
|
|
1934
|
+
let hexLength = escapedHexLen(escaped);
|
|
1935
|
+
if (hexLength === 0) throwError(state, "unknown escape sequence");
|
|
1936
|
+
while (hexLength-- > 0) {
|
|
1937
|
+
state.position++;
|
|
1938
|
+
if (fromHexCode(state.input.charCodeAt(state.position)) < 0) throwError(state, "expected hexadecimal character");
|
|
1939
|
+
}
|
|
1940
|
+
state.position++;
|
|
1941
|
+
}
|
|
1942
|
+
} else if (isEol(ch)) {
|
|
1943
|
+
simple = false;
|
|
1944
|
+
readFlowScalarBreak(state, nodeIndent);
|
|
1945
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1946
|
+
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1947
|
+
else state.position++;
|
|
1948
|
+
}
|
|
1949
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1950
|
+
}
|
|
1951
|
+
function readBlockScalar(state, parentIndent, props) {
|
|
1952
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1953
|
+
let chomping = 1;
|
|
1954
|
+
let indent = -1;
|
|
1955
|
+
let detectedIndent = false;
|
|
1956
|
+
if (ch !== 124 && ch !== 62) return false;
|
|
1957
|
+
const style = ch === 124 ? 4 : 5;
|
|
1958
|
+
state.position++;
|
|
1959
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1960
|
+
const current = state.input.charCodeAt(state.position);
|
|
1961
|
+
const digit = fromDecimalCode(current);
|
|
1962
|
+
if (current === 43 || current === 45) {
|
|
1963
|
+
if (chomping !== 1) throwError(state, "repeat of a chomping mode identifier");
|
|
1964
|
+
chomping = current === 43 ? 3 : 2;
|
|
1965
|
+
state.position++;
|
|
1966
|
+
} else if (digit >= 0) {
|
|
1967
|
+
if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1968
|
+
if (detectedIndent) throwError(state, "repeat of an indentation width identifier");
|
|
1969
|
+
indent = parentIndent + digit - 1;
|
|
1970
|
+
detectedIndent = true;
|
|
1971
|
+
state.position++;
|
|
1972
|
+
} else break;
|
|
1973
|
+
}
|
|
1974
|
+
let hadWhitespace = false;
|
|
1975
|
+
while (isWhiteSpace(state.input.charCodeAt(state.position))) {
|
|
1976
|
+
hadWhitespace = true;
|
|
1977
|
+
state.position++;
|
|
1978
|
+
}
|
|
1979
|
+
if (hadWhitespace && state.input.charCodeAt(state.position) === 35) skipUntilLineEnd(state);
|
|
1980
|
+
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
1981
|
+
else if (state.input.charCodeAt(state.position) !== 0) throwError(state, "a line break is expected");
|
|
1982
|
+
let contentIndent = detectedIndent ? indent : -1;
|
|
1983
|
+
let maxLeadingIndent = 0;
|
|
1984
|
+
const valueStart = state.position;
|
|
1985
|
+
let valueEnd = state.position;
|
|
1986
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1987
|
+
const linePosition = state.position;
|
|
1988
|
+
let column = 0;
|
|
1989
|
+
while (state.input.charCodeAt(linePosition + column) === 32) column++;
|
|
1990
|
+
const first = state.input.charCodeAt(linePosition + column);
|
|
1991
|
+
if (first === 0) {
|
|
1992
|
+
if (contentIndent >= 0) {
|
|
1993
|
+
if (column > contentIndent) valueEnd = linePosition + column;
|
|
1994
|
+
} else if (column > 0) valueEnd = linePosition + column;
|
|
1995
|
+
break;
|
|
1996
|
+
}
|
|
1997
|
+
if (linePosition === state.lineStart && testDocumentSeparator(state, linePosition)) break;
|
|
1998
|
+
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
1999
|
+
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
2000
|
+
if (first === 9 && column < parentIndent) {
|
|
2001
|
+
state.position = linePosition + column;
|
|
2002
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2003
|
+
}
|
|
2004
|
+
if (column < maxLeadingIndent) {
|
|
2005
|
+
state.position = linePosition + column;
|
|
2006
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
if (contentIndent === -1 && first !== 0 && !isEol(first) && column < parentIndent) {
|
|
2010
|
+
state.lineIndent = column;
|
|
2011
|
+
state.position = linePosition + column;
|
|
2012
|
+
break;
|
|
2013
|
+
}
|
|
2014
|
+
if (!detectedIndent && first !== 0 && !isEol(first) && contentIndent === -1) contentIndent = column;
|
|
2015
|
+
const requiredIndent = contentIndent === -1 ? parentIndent + 1 : contentIndent;
|
|
2016
|
+
if (first !== 0 && !isEol(first) && column < requiredIndent) {
|
|
2017
|
+
state.lineIndent = column;
|
|
2018
|
+
state.position = linePosition + column;
|
|
2019
|
+
break;
|
|
2020
|
+
}
|
|
2021
|
+
skipUntilLineEnd(state);
|
|
2022
|
+
valueEnd = state.position;
|
|
2023
|
+
if (isEol(state.input.charCodeAt(state.position))) {
|
|
2024
|
+
consumeLineBreak(state);
|
|
2025
|
+
valueEnd = state.position;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
checkPrintable(state, valueStart, valueEnd);
|
|
2029
|
+
addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
|
|
2030
|
+
return true;
|
|
2031
|
+
}
|
|
2032
|
+
function canStartPlainScalar(state, nodeContext) {
|
|
2033
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2034
|
+
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
2035
|
+
if (ch === 0 || isWsOrEol(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96 || inFlow && isFlowIndicator(ch)) return false;
|
|
2036
|
+
if (ch === 63 || ch === 45) {
|
|
2037
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
2038
|
+
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) return false;
|
|
2039
|
+
}
|
|
2040
|
+
return true;
|
|
2041
|
+
}
|
|
2042
|
+
function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
2043
|
+
if (!canStartPlainScalar(state, nodeContext)) return false;
|
|
2044
|
+
const start = state.position;
|
|
2045
|
+
let end = state.position;
|
|
2046
|
+
let ch = state.input.charCodeAt(state.position);
|
|
2047
|
+
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
2048
|
+
let multiline = false;
|
|
2049
|
+
while (ch !== 0) {
|
|
2050
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) break;
|
|
2051
|
+
if (ch === 58) {
|
|
2052
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
2053
|
+
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
2054
|
+
} else if (ch === 35) {
|
|
2055
|
+
if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
|
|
2056
|
+
} else if (inFlow && isFlowIndicator(ch)) break;
|
|
2057
|
+
else if (isEol(ch)) {
|
|
2058
|
+
const savedPosition = state.position;
|
|
2059
|
+
const savedLine = state.line;
|
|
2060
|
+
const savedLineStart = state.lineStart;
|
|
2061
|
+
const savedLineIndent = state.lineIndent;
|
|
2062
|
+
skipSeparationSpace(state, false);
|
|
2063
|
+
if (state.lineIndent >= nodeIndent) {
|
|
2064
|
+
multiline = true;
|
|
2065
|
+
ch = state.input.charCodeAt(state.position);
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
state.position = savedPosition;
|
|
2069
|
+
state.line = savedLine;
|
|
2070
|
+
state.lineStart = savedLineStart;
|
|
2071
|
+
state.lineIndent = savedLineIndent;
|
|
2072
|
+
break;
|
|
2073
|
+
}
|
|
2074
|
+
if (!isWhiteSpace(ch)) end = state.position + 1;
|
|
2075
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2076
|
+
}
|
|
2077
|
+
if (end === start) return false;
|
|
2078
|
+
checkPrintable(state, start, end);
|
|
2079
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1, 1, -1, !multiline);
|
|
2080
|
+
return true;
|
|
2081
|
+
}
|
|
2082
|
+
function skipFlowSeparationSpace(state, nodeIndent) {
|
|
2083
|
+
const startLine = state.line;
|
|
2084
|
+
skipSeparationSpace(state, true);
|
|
2085
|
+
if (state.line > startLine && state.lineIndent < nodeIndent || state.firstTabInLine !== -1 && state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
2086
|
+
}
|
|
2087
|
+
function readFlowCollection(state, nodeIndent, props) {
|
|
2088
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2089
|
+
const isMapping = ch === 123;
|
|
2090
|
+
const start = state.position;
|
|
2091
|
+
let readNext = true;
|
|
2092
|
+
if (ch !== 91 && ch !== 123) return false;
|
|
2093
|
+
const terminator = isMapping ? 125 : 93;
|
|
2094
|
+
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
|
|
2095
|
+
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
|
|
2096
|
+
state.position++;
|
|
2097
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2098
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2099
|
+
let ch2 = state.input.charCodeAt(state.position);
|
|
2100
|
+
if (ch2 === terminator) {
|
|
2101
|
+
state.position++;
|
|
2102
|
+
addPopEvent(state);
|
|
2103
|
+
return true;
|
|
2104
|
+
} else if (!readNext) throwError(state, "missed comma between flow collection entries");
|
|
2105
|
+
else if (ch2 === 44) throwError(state, "expected the node content, but found ','");
|
|
2106
|
+
let isPair = false;
|
|
2107
|
+
let isExplicitPair = false;
|
|
2108
|
+
if (ch2 === 63 && isWsOrEol(state.input.charCodeAt(state.position + 1))) {
|
|
2109
|
+
isPair = isExplicitPair = true;
|
|
2110
|
+
state.position += 1;
|
|
2111
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2112
|
+
}
|
|
2113
|
+
const entryLine = state.line;
|
|
2114
|
+
const entryStart = snapshotState(state);
|
|
2115
|
+
const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2116
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2117
|
+
ch2 = state.input.charCodeAt(state.position);
|
|
2118
|
+
if ((isMapping || isExplicitPair || state.line === entryLine) && ch2 === 58) {
|
|
2119
|
+
isPair = true;
|
|
2120
|
+
state.position++;
|
|
2121
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2122
|
+
if (!isMapping) {
|
|
2123
|
+
restoreState(state, entryStart);
|
|
2124
|
+
addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
|
|
2125
|
+
if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
|
|
2126
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2127
|
+
state.position++;
|
|
2128
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2129
|
+
} else if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2130
|
+
if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
|
|
2131
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2132
|
+
if (!isMapping) addPopEvent(state);
|
|
2133
|
+
} else if (isMapping && isPair) {
|
|
2134
|
+
if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2135
|
+
addEmptyScalarEvent(state);
|
|
2136
|
+
} else if (isMapping) addEmptyScalarEvent(state);
|
|
2137
|
+
else if (isPair) {
|
|
2138
|
+
restoreState(state, entryStart);
|
|
2139
|
+
addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
|
|
2140
|
+
parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2141
|
+
addEmptyScalarEvent(state);
|
|
2142
|
+
addPopEvent(state);
|
|
2143
|
+
}
|
|
2144
|
+
ch2 = state.input.charCodeAt(state.position);
|
|
2145
|
+
if (ch2 === 44) {
|
|
2146
|
+
readNext = true;
|
|
2147
|
+
state.position++;
|
|
2148
|
+
} else readNext = false;
|
|
2149
|
+
}
|
|
2150
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
2151
|
+
}
|
|
2152
|
+
function readBlockSequence(state, nodeIndent, props) {
|
|
2153
|
+
if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
|
|
2154
|
+
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2155
|
+
while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
|
|
2156
|
+
if (state.firstTabInLine !== -1) {
|
|
2157
|
+
state.position = state.firstTabInLine;
|
|
2158
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2159
|
+
}
|
|
2160
|
+
const entryLine = state.line;
|
|
2161
|
+
state.position++;
|
|
2162
|
+
const hadBreak = skipSeparationSpace(state, true) > 0;
|
|
2163
|
+
if (state.firstTabInLine !== -1 && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
|
|
2164
|
+
if (hadBreak && state.lineIndent <= nodeIndent) addEmptyScalarEvent(state);
|
|
2165
|
+
else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2166
|
+
skipSeparationSpace(state, true);
|
|
2167
|
+
if (state.lineIndent < nodeIndent || state.position >= state.length) break;
|
|
2168
|
+
if (state.lineIndent > nodeIndent) throwError(state, "bad indentation of a sequence entry");
|
|
2169
|
+
if (state.line === entryLine && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
|
|
2170
|
+
}
|
|
2171
|
+
addPopEvent(state);
|
|
2172
|
+
return true;
|
|
2173
|
+
}
|
|
2174
|
+
function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
2175
|
+
let atExplicitKey = false;
|
|
2176
|
+
let detected = false;
|
|
2177
|
+
let mappingOpened = false;
|
|
2178
|
+
let pendingExplicitKey = false;
|
|
2179
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2180
|
+
let ch = state.input.charCodeAt(state.position);
|
|
2181
|
+
while (ch !== 0) {
|
|
2182
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
2183
|
+
state.position = state.firstTabInLine;
|
|
2184
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2185
|
+
}
|
|
2186
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
2187
|
+
const entryLine = state.line;
|
|
2188
|
+
if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
|
|
2189
|
+
if (!mappingOpened) {
|
|
2190
|
+
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2191
|
+
mappingOpened = true;
|
|
2192
|
+
}
|
|
2193
|
+
if (ch === 63) {
|
|
2194
|
+
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2195
|
+
detected = true;
|
|
2196
|
+
atExplicitKey = true;
|
|
2197
|
+
} else if (atExplicitKey) atExplicitKey = false;
|
|
2198
|
+
else {
|
|
2199
|
+
addEmptyScalarEvent(state);
|
|
2200
|
+
detected = true;
|
|
2201
|
+
atExplicitKey = false;
|
|
2202
|
+
}
|
|
2203
|
+
state.position += 1;
|
|
2204
|
+
pendingExplicitKey = true;
|
|
2205
|
+
} else {
|
|
2206
|
+
if (atExplicitKey) {
|
|
2207
|
+
addEmptyScalarEvent(state);
|
|
2208
|
+
atExplicitKey = false;
|
|
2209
|
+
}
|
|
2210
|
+
const beforeKey = snapshotState(state);
|
|
2211
|
+
if (!parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
|
|
2212
|
+
if (state.line === entryLine) {
|
|
2213
|
+
ch = state.input.charCodeAt(state.position);
|
|
2214
|
+
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2215
|
+
if (ch === 58) {
|
|
2216
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2217
|
+
if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2218
|
+
if (!mappingOpened) {
|
|
2219
|
+
restoreState(state, beforeKey);
|
|
2220
|
+
addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2221
|
+
mappingOpened = true;
|
|
2222
|
+
parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
|
|
2223
|
+
ch = state.input.charCodeAt(state.position);
|
|
2224
|
+
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2225
|
+
state.position++;
|
|
2226
|
+
}
|
|
2227
|
+
detected = true;
|
|
2228
|
+
atExplicitKey = false;
|
|
2229
|
+
pendingExplicitKey = false;
|
|
2230
|
+
} else if (detected) throwError(state, "expected ':' after a mapping key");
|
|
2231
|
+
else {
|
|
2232
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2233
|
+
restoreState(state, beforeKey);
|
|
2234
|
+
return false;
|
|
2235
|
+
}
|
|
2236
|
+
return true;
|
|
2237
|
+
}
|
|
2238
|
+
} else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2239
|
+
else {
|
|
2240
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2241
|
+
restoreState(state, beforeKey);
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
return true;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, pendingExplicitKey)) pendingExplicitKey = false;
|
|
2248
|
+
if (!atExplicitKey) {
|
|
2249
|
+
if (pendingExplicitKey) {
|
|
2250
|
+
addEmptyScalarEvent(state);
|
|
2251
|
+
pendingExplicitKey = false;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
skipSeparationSpace(state, true);
|
|
2255
|
+
ch = state.input.charCodeAt(state.position);
|
|
2256
|
+
if ((state.line === entryLine || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
|
|
2257
|
+
else if (state.lineIndent < nodeIndent) break;
|
|
2258
|
+
}
|
|
2259
|
+
if (!detected) return false;
|
|
2260
|
+
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2261
|
+
if (mappingOpened) addPopEvent(state);
|
|
2262
|
+
return true;
|
|
2263
|
+
}
|
|
2264
|
+
function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping = true) {
|
|
2265
|
+
if (state.depth >= state.maxDepth) throwError(state, `nesting exceeded maxDepth (${state.maxDepth})`);
|
|
2266
|
+
state.depth++;
|
|
2267
|
+
let indentStatus = 1;
|
|
2268
|
+
let atNewLine = false;
|
|
2269
|
+
let hasContent = false;
|
|
2270
|
+
let propertyStart = null;
|
|
2271
|
+
const props = emptyProperties();
|
|
2272
|
+
let allowBlockScalars = nodeContext === CONTEXT_BLOCK_OUT || nodeContext === CONTEXT_BLOCK_IN;
|
|
2273
|
+
let allowBlockCollections = allowBlockScalars;
|
|
2274
|
+
const allowBlockStyles = allowBlockScalars;
|
|
2275
|
+
if (allowToSeek && skipSeparationSpace(state, true)) {
|
|
2276
|
+
atNewLine = true;
|
|
2277
|
+
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2278
|
+
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2279
|
+
else indentStatus = -1;
|
|
2280
|
+
}
|
|
2281
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2282
|
+
state.depth--;
|
|
2283
|
+
return false;
|
|
2284
|
+
}
|
|
2285
|
+
if (indentStatus === 1) while (true) {
|
|
2286
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2287
|
+
const propertyState = snapshotState(state);
|
|
2288
|
+
if (atNewLine && indentStatus !== 1 && (ch === 33 || ch === 38)) break;
|
|
2289
|
+
if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
|
|
2290
|
+
const fallbackState = snapshotState(state);
|
|
2291
|
+
const flowIndent = parentIndent + 1;
|
|
2292
|
+
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === 3) {
|
|
2293
|
+
state.depth--;
|
|
2294
|
+
return true;
|
|
2295
|
+
}
|
|
2296
|
+
restoreState(state, fallbackState);
|
|
2297
|
+
}
|
|
2298
|
+
if (atNewLine && (ch === 33 && props.tagStart !== NO_RANGE$1 || ch === 38 && props.anchorStart !== NO_RANGE$1)) break;
|
|
2299
|
+
if (!readTagProperty(state, props, nodeContext === CONTEXT_FLOW_IN) && !readAnchorProperty(state, props)) break;
|
|
2300
|
+
if (propertyStart === null) propertyStart = propertyState;
|
|
2301
|
+
if (skipSeparationSpace(state, true)) {
|
|
2302
|
+
atNewLine = true;
|
|
2303
|
+
allowBlockCollections = allowBlockStyles;
|
|
2304
|
+
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2305
|
+
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2306
|
+
else indentStatus = -1;
|
|
2307
|
+
} else allowBlockCollections = false;
|
|
2308
|
+
}
|
|
2309
|
+
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
|
|
2310
|
+
if (indentStatus === 1 || nodeContext === CONTEXT_BLOCK_OUT) {
|
|
2311
|
+
const flowIndent = nodeContext === CONTEXT_FLOW_IN || nodeContext === CONTEXT_FLOW_OUT ? parentIndent : parentIndent + 1;
|
|
2312
|
+
const blockIndent = state.position - state.lineStart;
|
|
2313
|
+
if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent, props) || readBlockMapping(state, blockIndent, flowIndent, props)) || readFlowCollection(state, flowIndent, props)) hasContent = true;
|
|
2314
|
+
else {
|
|
2315
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2316
|
+
if (propertyStart !== null && allowPropertyMapping && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62) {
|
|
2317
|
+
const fallbackState = snapshotState(state);
|
|
2318
|
+
const propertyIndent = propertyStart.position - propertyStart.lineStart;
|
|
2319
|
+
restoreState(state, propertyStart);
|
|
2320
|
+
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === 3) hasContent = true;
|
|
2321
|
+
else restoreState(state, fallbackState);
|
|
2322
|
+
}
|
|
2323
|
+
if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
|
|
2324
|
+
}
|
|
2325
|
+
else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent, props);
|
|
2326
|
+
}
|
|
2327
|
+
allowBlockScalars = allowBlockScalars && !hasContent;
|
|
2328
|
+
if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
|
|
2329
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2330
|
+
hasContent = true;
|
|
2331
|
+
}
|
|
2332
|
+
state.depth--;
|
|
2333
|
+
return hasContent || props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1;
|
|
2334
|
+
}
|
|
2335
|
+
function readDirective(state) {
|
|
2336
|
+
if (state.lineIndent > 0 || state.input.charCodeAt(state.position) !== 37) return false;
|
|
2337
|
+
state.position++;
|
|
2338
|
+
const nameStart = state.position;
|
|
2339
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2340
|
+
const name = state.input.slice(nameStart, state.position);
|
|
2341
|
+
const args = [];
|
|
2342
|
+
if (name.length === 0) throwError(state, "directive name must not be less than one character in length");
|
|
2343
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isEol(state.input.charCodeAt(state.position))) {
|
|
2344
|
+
while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position++;
|
|
2345
|
+
if (state.input.charCodeAt(state.position) === 35 || isEol(state.input.charCodeAt(state.position)) || state.input.charCodeAt(state.position) === 0) break;
|
|
2346
|
+
const start = state.position;
|
|
2347
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2348
|
+
args.push(state.input.slice(start, state.position));
|
|
2349
|
+
}
|
|
2350
|
+
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
2351
|
+
if (name === "YAML") {
|
|
2352
|
+
if (state.directives.some((directive) => directive.kind === "yaml")) throwError(state, "duplication of %YAML directive");
|
|
2353
|
+
if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
|
|
2354
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
2355
|
+
if (match === null) throwError(state, "ill-formed argument of the YAML directive");
|
|
2356
|
+
if (parseInt(match[1], 10) !== 1) throwError(state, "unacceptable YAML version of the document");
|
|
2357
|
+
state.directives.push({
|
|
2358
|
+
kind: "yaml",
|
|
2359
|
+
version: args[0]
|
|
2360
|
+
});
|
|
2361
|
+
} else if (name === "TAG") {
|
|
2362
|
+
if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
|
|
2363
|
+
const [handle, prefix] = args;
|
|
2364
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
2365
|
+
if (HAS_OWN.call(state.tagHandlers, handle)) throwError(state, `there is a previously declared suffix for "${handle}" tag handle`);
|
|
2366
|
+
if (!PATTERN_TAG_PREFIX.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
2367
|
+
state.tagHandlers[handle] = prefix;
|
|
2368
|
+
state.directives.push({
|
|
2369
|
+
kind: "tag",
|
|
2370
|
+
handle,
|
|
2371
|
+
prefix
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
return true;
|
|
2375
|
+
}
|
|
2376
|
+
function readDocument(state) {
|
|
2377
|
+
state.directives = [];
|
|
2378
|
+
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
2379
|
+
let hasDirectives = false;
|
|
2380
|
+
skipSeparationSpace(state, true);
|
|
2381
|
+
while (readDirective(state)) {
|
|
2382
|
+
hasDirectives = true;
|
|
2383
|
+
skipSeparationSpace(state, true);
|
|
2384
|
+
}
|
|
2385
|
+
let explicitStart = false;
|
|
2386
|
+
let explicitEnd = false;
|
|
2387
|
+
let allowCompact = true;
|
|
2388
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 3))) {
|
|
2389
|
+
explicitStart = true;
|
|
2390
|
+
const markerLine = state.line;
|
|
2391
|
+
state.position += 3;
|
|
2392
|
+
skipSeparationSpace(state, true);
|
|
2393
|
+
allowCompact = state.line > markerLine;
|
|
2394
|
+
} else if (hasDirectives) throwError(state, "directives end mark is expected");
|
|
2395
|
+
const documentEventIndex = state.events.length;
|
|
2396
|
+
if (!explicitStart && state.position === state.lineStart && state.input.charCodeAt(state.position) === 46 && testDocumentSeparator(state)) {
|
|
2397
|
+
state.position += 3;
|
|
2398
|
+
skipSeparationSpace(state, true);
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
addDocumentEvent(state, explicitStart, false);
|
|
2402
|
+
if (!parseNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
|
|
2403
|
+
skipSeparationSpace(state, true);
|
|
2404
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2405
|
+
explicitEnd = state.input.charCodeAt(state.position) === 46;
|
|
2406
|
+
if (explicitEnd) {
|
|
2407
|
+
const markerLine = state.line;
|
|
2408
|
+
state.position += 3;
|
|
2409
|
+
skipSeparationSpace(state, true);
|
|
2410
|
+
if (state.line === markerLine && state.position < state.length) throwError(state, "end of the stream or a document separator is expected");
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
const documentEvent = state.events[documentEventIndex];
|
|
2414
|
+
if (documentEvent?.type === 1) documentEvent.explicitEnd = explicitEnd;
|
|
2415
|
+
addPopEvent(state);
|
|
2416
|
+
if (!explicitEnd && state.position < state.length && !(state.position === state.lineStart && testDocumentSeparator(state))) throwError(state, "end of the stream or a document separator is expected");
|
|
2417
|
+
}
|
|
2418
|
+
function parseEvents(input, options) {
|
|
2419
|
+
const length = input.length;
|
|
2420
|
+
const state = {
|
|
2421
|
+
...DEFAULT_PARSER_OPTIONS,
|
|
2422
|
+
...options,
|
|
2423
|
+
input: `${input}\0`,
|
|
2424
|
+
length,
|
|
2425
|
+
position: 0,
|
|
2426
|
+
line: 0,
|
|
2427
|
+
lineStart: 0,
|
|
2428
|
+
lineIndent: 0,
|
|
2429
|
+
firstTabInLine: -1,
|
|
2430
|
+
depth: 0,
|
|
2431
|
+
directives: [],
|
|
2432
|
+
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
2433
|
+
events: []
|
|
2434
|
+
};
|
|
2435
|
+
const nullpos = input.indexOf("\0");
|
|
2436
|
+
if (nullpos !== -1) throwErrorAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2437
|
+
if (state.input.charCodeAt(state.position) === 65279) state.position++;
|
|
2438
|
+
while (state.position < state.length) {
|
|
2439
|
+
skipSeparationSpace(state, true);
|
|
2440
|
+
if (state.position >= state.length) break;
|
|
2441
|
+
const documentStart = state.position;
|
|
2442
|
+
readDocument(state);
|
|
2443
|
+
if (state.position === documentStart)
|
|
2444
|
+
throwError(state, "can not read a document");
|
|
2445
|
+
}
|
|
2446
|
+
return state.events;
|
|
2447
|
+
}
|
|
2448
|
+
var DEFAULT_LOAD_OPTIONS = {
|
|
2449
|
+
...DEFAULT_PARSER_OPTIONS,
|
|
2450
|
+
...DEFAULT_CONSTRUCTOR_OPTIONS
|
|
2451
|
+
};
|
|
2452
|
+
function loadDocuments(input, options = {}) {
|
|
2453
|
+
const opts = {
|
|
2454
|
+
...DEFAULT_LOAD_OPTIONS,
|
|
2455
|
+
...options
|
|
2456
|
+
};
|
|
2457
|
+
const source = String(input);
|
|
2458
|
+
const PARSER_OPT_KEYS = Object.keys(DEFAULT_PARSER_OPTIONS);
|
|
2459
|
+
const CONSTRUCTOR_OPT_KEYS = Object.keys(DEFAULT_CONSTRUCTOR_OPTIONS);
|
|
2460
|
+
return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
|
|
2461
|
+
...pick(opts, CONSTRUCTOR_OPT_KEYS),
|
|
2462
|
+
source
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
function load(input, options) {
|
|
2466
|
+
const documents = loadDocuments(input, options);
|
|
2467
|
+
if (documents.length === 0) throw new YAMLException("expected a document, but the input is empty");
|
|
2468
|
+
if (documents.length === 1) return documents[0];
|
|
2469
|
+
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2470
|
+
}
|
|
2471
|
+
var ESCAPE_SEQUENCES = {};
|
|
2472
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2473
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2474
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2475
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2476
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2477
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2478
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2479
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2480
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2481
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2482
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2483
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2484
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2485
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2486
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2487
|
+
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2488
|
+
indent: 2,
|
|
2489
|
+
seqNoIndent: false,
|
|
2490
|
+
seqInlineFirst: true,
|
|
2491
|
+
sortKeys: false,
|
|
2492
|
+
lineWidth: 80,
|
|
2493
|
+
flowBracketPadding: false,
|
|
2494
|
+
flowSkipCommaSpace: false,
|
|
2495
|
+
flowSkipColonSpace: false,
|
|
2496
|
+
quoteFlowKeys: false,
|
|
2497
|
+
quoteStyle: "single",
|
|
2498
|
+
forceQuotes: false,
|
|
2499
|
+
tagBeforeAnchor: false
|
|
2500
|
+
};
|
|
2501
|
+
var DEFAULT_DUMP_SCHEMA = YAML11_SCHEMA.withTags({
|
|
2502
|
+
...intYaml11Tag,
|
|
2503
|
+
resolve: (source, isExplicit, tagName) => {
|
|
2504
|
+
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2505
|
+
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2506
|
+
}
|
|
2507
|
+
}, {
|
|
2508
|
+
...floatYaml11Tag,
|
|
2509
|
+
resolve: (source, isExplicit, tagName) => {
|
|
2510
|
+
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2511
|
+
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
var DEFAULT_DUMP_OPTIONS = {
|
|
2515
|
+
...DEFAULT_PRESENTER_OPTIONS,
|
|
2516
|
+
schema: DEFAULT_DUMP_SCHEMA,
|
|
2517
|
+
skipInvalid: false,
|
|
2518
|
+
noRefs: false,
|
|
2519
|
+
flowLevel: -1,
|
|
2520
|
+
transform: () => {
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
|
|
2524
|
+
// src/skill-scripts/shared/execution-routing.ts
|
|
2525
|
+
var path4 = __toESM(require("path"));
|
|
2526
|
+
var WORKSPACE_CONFIG_RELPATH = path4.join("config", "config.yaml");
|
|
2527
|
+
|
|
2528
|
+
// src/skill-scripts/shared/harness-configuration.ts
|
|
2529
|
+
var HARNESS_CONFIGURATION_SECTION = "harnesses";
|
|
2530
|
+
var HARNESS_CONFIGURATION_NORMALIZATION_VERSION = 1;
|
|
2531
|
+
var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2532
|
+
var hashHarnessCliArgs = (harness, cliArgs, normalizationVersion = HARNESS_CONFIGURATION_NORMALIZATION_VERSION) => (0, import_crypto.createHash)("sha256").update(
|
|
2533
|
+
JSON.stringify({
|
|
2534
|
+
schema: normalizationVersion,
|
|
2535
|
+
harness,
|
|
2536
|
+
cliArgs
|
|
2537
|
+
}),
|
|
2538
|
+
"utf8"
|
|
2539
|
+
).digest("hex");
|
|
2540
|
+
var normalizeInvocation = (harness, cliArgs) => {
|
|
2541
|
+
const immutableArgs = Object.freeze([...cliArgs]);
|
|
2542
|
+
return Object.freeze({
|
|
2543
|
+
cliArgs: immutableArgs,
|
|
2544
|
+
cliArgsHash: hashHarnessCliArgs(harness, immutableArgs)
|
|
2545
|
+
});
|
|
2546
|
+
};
|
|
2547
|
+
var emptyConfiguration = () => Object.freeze(
|
|
2548
|
+
Object.fromEntries(
|
|
2549
|
+
SUPPORTED_HARNESSES.map((harness) => [harness, normalizeInvocation(harness, [])])
|
|
2550
|
+
)
|
|
2551
|
+
);
|
|
2552
|
+
var validateHarnessEntry = (harness, raw, errors) => {
|
|
2553
|
+
const entryPath = `config.yaml ${HARNESS_CONFIGURATION_SECTION}.${harness}`;
|
|
2554
|
+
if (!isPlainObject2(raw)) {
|
|
2555
|
+
errors.push(`${entryPath} must be a mapping.`);
|
|
2556
|
+
return null;
|
|
2557
|
+
}
|
|
2558
|
+
for (const key of Object.keys(raw)) {
|
|
2559
|
+
if (key !== "cli_args") errors.push(`${entryPath}.${key} is not supported.`);
|
|
2560
|
+
}
|
|
2561
|
+
if (!("cli_args" in raw)) return normalizeInvocation(harness, []);
|
|
2562
|
+
if (!Array.isArray(raw.cli_args)) {
|
|
2563
|
+
errors.push(`${entryPath}.cli_args must be an array of exact strings.`);
|
|
2564
|
+
return null;
|
|
2565
|
+
}
|
|
2566
|
+
const cliArgs = [];
|
|
2567
|
+
raw.cli_args.forEach((value, index) => {
|
|
2568
|
+
const valuePath = `${entryPath}.cli_args[${index}]`;
|
|
2569
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
2570
|
+
errors.push(`${valuePath} must be a non-empty string.`);
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
if (value.includes("\0")) {
|
|
2574
|
+
errors.push(`${valuePath} must not contain a NUL character.`);
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
cliArgs.push(value);
|
|
2578
|
+
});
|
|
2579
|
+
return normalizeInvocation(harness, cliArgs);
|
|
262
2580
|
};
|
|
263
|
-
var
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
2581
|
+
var loadHarnessConfiguration = (strikethrooRoot) => {
|
|
2582
|
+
const configPath = path5.join(strikethrooRoot, WORKSPACE_CONFIG_RELPATH);
|
|
2583
|
+
let contents;
|
|
2584
|
+
try {
|
|
2585
|
+
contents = fs4.readFileSync(configPath, "utf8");
|
|
2586
|
+
} catch (error) {
|
|
2587
|
+
if (error.code === "ENOENT") {
|
|
2588
|
+
return { kind: "config", config: emptyConfiguration() };
|
|
2589
|
+
}
|
|
272
2590
|
return {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
2591
|
+
kind: "invalid",
|
|
2592
|
+
errors: [
|
|
2593
|
+
`config.yaml could not be read: ${error instanceof Error ? error.message : String(error)}`
|
|
2594
|
+
]
|
|
277
2595
|
};
|
|
278
2596
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
2597
|
+
let document;
|
|
2598
|
+
try {
|
|
2599
|
+
document = load(contents);
|
|
2600
|
+
} catch (error) {
|
|
2601
|
+
return {
|
|
2602
|
+
kind: "invalid",
|
|
2603
|
+
errors: [
|
|
2604
|
+
`config.yaml is not valid YAML: ${error instanceof Error ? error.message : String(error)}`
|
|
2605
|
+
]
|
|
2606
|
+
};
|
|
288
2607
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
2608
|
+
if (document === null || document === void 0) {
|
|
2609
|
+
return { kind: "config", config: emptyConfiguration() };
|
|
2610
|
+
}
|
|
2611
|
+
if (!isPlainObject2(document)) {
|
|
2612
|
+
return { kind: "invalid", errors: ["config.yaml must be a YAML mapping."] };
|
|
2613
|
+
}
|
|
2614
|
+
const section = document[HARNESS_CONFIGURATION_SECTION];
|
|
2615
|
+
if (section === null || section === void 0) {
|
|
2616
|
+
return { kind: "config", config: emptyConfiguration() };
|
|
2617
|
+
}
|
|
2618
|
+
if (!isPlainObject2(section)) {
|
|
2619
|
+
return {
|
|
2620
|
+
kind: "invalid",
|
|
2621
|
+
errors: [`config.yaml ${HARNESS_CONFIGURATION_SECTION} must be a YAML mapping.`]
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
const errors = [];
|
|
2625
|
+
const supportedHarnesses = new Set(SUPPORTED_HARNESSES);
|
|
2626
|
+
for (const harness of Object.keys(section)) {
|
|
2627
|
+
if (!supportedHarnesses.has(harness)) {
|
|
2628
|
+
errors.push(`config.yaml ${HARNESS_CONFIGURATION_SECTION}.${harness} is not supported.`);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
const entries = {};
|
|
2632
|
+
for (const harness of SUPPORTED_HARNESSES) {
|
|
2633
|
+
if (!(harness in section)) {
|
|
2634
|
+
entries[harness] = normalizeInvocation(harness, []);
|
|
2635
|
+
continue;
|
|
2636
|
+
}
|
|
2637
|
+
const entry = validateHarnessEntry(harness, section[harness], errors);
|
|
2638
|
+
if (entry) entries[harness] = entry;
|
|
2639
|
+
}
|
|
2640
|
+
if (errors.length > 0) return { kind: "invalid", errors };
|
|
2641
|
+
return { kind: "config", config: Object.freeze(entries) };
|
|
292
2642
|
};
|
|
293
2643
|
|
|
294
|
-
// src/skill-scripts/shared/harness-availability.ts
|
|
295
|
-
var fs5 = __toESM(require("fs"));
|
|
296
|
-
var path5 = __toESM(require("path"));
|
|
297
|
-
var import_child_process3 = require("child_process");
|
|
298
|
-
|
|
299
2644
|
// src/skill-scripts/shared/external-dispatch.ts
|
|
300
|
-
var
|
|
301
|
-
var
|
|
2645
|
+
var fs5 = __toESM(require("fs"));
|
|
2646
|
+
var path6 = __toESM(require("path"));
|
|
302
2647
|
var import_child_process2 = require("child_process");
|
|
303
2648
|
var command = (executable, argv, request) => ({
|
|
304
2649
|
executable,
|
|
@@ -314,6 +2659,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
314
2659
|
"claude",
|
|
315
2660
|
[
|
|
316
2661
|
"-p",
|
|
2662
|
+
...request.cliArgs,
|
|
317
2663
|
...modelArgv(request.model),
|
|
318
2664
|
...request.reasoningEffort === void 0 ? [] : ["--effort", request.reasoningEffort]
|
|
319
2665
|
],
|
|
@@ -327,6 +2673,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
327
2673
|
"codex",
|
|
328
2674
|
[
|
|
329
2675
|
"exec",
|
|
2676
|
+
...request.cliArgs,
|
|
330
2677
|
...modelArgv(request.model),
|
|
331
2678
|
...request.reasoningEffort === void 0 ? [] : ["--config", `model_reasoning_effort=${request.reasoningEffort}`],
|
|
332
2679
|
"-"
|
|
@@ -337,19 +2684,23 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
337
2684
|
},
|
|
338
2685
|
cursor: {
|
|
339
2686
|
executable: "cursor-agent",
|
|
340
|
-
buildCommand: (request) => command(
|
|
2687
|
+
buildCommand: (request) => command(
|
|
2688
|
+
"cursor-agent",
|
|
2689
|
+
["--print", ...request.cliArgs, ...modelArgv(request.model)],
|
|
2690
|
+
request
|
|
2691
|
+
),
|
|
341
2692
|
authenticationArgv: () => ["status"]
|
|
342
2693
|
},
|
|
343
2694
|
gemini: {
|
|
344
2695
|
executable: "gemini",
|
|
345
2696
|
// The empty positional prompt is the existing contract — content travels on
|
|
346
2697
|
// stdin. It stays even when the model pair is dropped.
|
|
347
|
-
buildCommand: (request) => command("gemini", ["--prompt", "", ...modelArgv(request.model)], request),
|
|
2698
|
+
buildCommand: (request) => command("gemini", ["--prompt", "", ...request.cliArgs, ...modelArgv(request.model)], request),
|
|
348
2699
|
authenticationArgv: () => ["auth", "status"]
|
|
349
2700
|
},
|
|
350
2701
|
copilot: {
|
|
351
2702
|
executable: "copilot",
|
|
352
|
-
buildCommand: (request) => command("copilot", ["-p", "", ...modelArgv(request.model)], request),
|
|
2703
|
+
buildCommand: (request) => command("copilot", ["-p", "", ...request.cliArgs, ...modelArgv(request.model)], request),
|
|
353
2704
|
authenticationArgv: () => ["auth", "status"]
|
|
354
2705
|
},
|
|
355
2706
|
opencode: {
|
|
@@ -358,6 +2709,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
358
2709
|
"opencode",
|
|
359
2710
|
[
|
|
360
2711
|
"run",
|
|
2712
|
+
...request.cliArgs,
|
|
361
2713
|
...modelArgv(request.model),
|
|
362
2714
|
...request.reasoningEffort === void 0 ? [] : ["--variant", request.reasoningEffort],
|
|
363
2715
|
"-"
|
|
@@ -373,25 +2725,28 @@ if (adapterKeys.join("\0") !== harnessKeys.join("\0")) {
|
|
|
373
2725
|
throw new Error("External harness adapter registry does not cover SUPPORTED_HARNESSES exactly.");
|
|
374
2726
|
}
|
|
375
2727
|
var reviewCommandRequest = (request) => ({
|
|
2728
|
+
cliArgs: request.cliArgs ?? [],
|
|
376
2729
|
workspace: request.workspace,
|
|
377
2730
|
prompt: request.prompt
|
|
378
2731
|
});
|
|
379
|
-
var executableOnPath = (executable) => (process.env.PATH ?? "").split(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
2732
|
+
var executableOnPath = (executable) => (/[\\/]/.test(executable) ? [""] : (process.env.PATH ?? "").split(path6.delimiter)).some(
|
|
2733
|
+
(directory) => {
|
|
2734
|
+
if (!directory && !/[\\/]/.test(executable)) return false;
|
|
2735
|
+
const candidate = directory === "" ? executable : path6.join(directory, executable);
|
|
2736
|
+
try {
|
|
2737
|
+
return fs5.statSync(candidate).isFile();
|
|
2738
|
+
} catch {
|
|
2739
|
+
return false;
|
|
2740
|
+
}
|
|
386
2741
|
}
|
|
387
|
-
|
|
2742
|
+
);
|
|
388
2743
|
var CAPTURED_STDOUT_LIMIT = 262144;
|
|
389
2744
|
var STDIO_SLOTS = {
|
|
390
2745
|
ignore: { stdout: "ignore" },
|
|
391
2746
|
inherit: { stdout: "inherit" },
|
|
392
2747
|
capture: { stdout: "pipe" }
|
|
393
2748
|
};
|
|
394
|
-
var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Promise((
|
|
2749
|
+
var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Promise((resolve4, reject) => {
|
|
395
2750
|
let settled = false;
|
|
396
2751
|
const fail = (error) => {
|
|
397
2752
|
if (settled) return;
|
|
@@ -423,7 +2778,7 @@ var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Pr
|
|
|
423
2778
|
child.once("close", (code) => {
|
|
424
2779
|
if (settled) return;
|
|
425
2780
|
settled = true;
|
|
426
|
-
|
|
2781
|
+
resolve4({
|
|
427
2782
|
exitCode: code ?? 1,
|
|
428
2783
|
...outputMode === "capture" ? { stdout: captured } : {}
|
|
429
2784
|
});
|
|
@@ -474,11 +2829,12 @@ var prepareLaunch = async (harness, input, active, guard) => {
|
|
|
474
2829
|
}
|
|
475
2830
|
const blocked = guard?.();
|
|
476
2831
|
if (blocked) return blocked;
|
|
477
|
-
|
|
2832
|
+
const executable = adapter.executable;
|
|
2833
|
+
if (!active.executableExists(executable)) {
|
|
478
2834
|
return {
|
|
479
2835
|
kind: "fallback",
|
|
480
2836
|
reason: "executable-unavailable",
|
|
481
|
-
detail: `${
|
|
2837
|
+
detail: `${executable} is unavailable.`
|
|
482
2838
|
};
|
|
483
2839
|
}
|
|
484
2840
|
const commandSpec = adapter.buildCommand(input);
|
|
@@ -512,143 +2868,166 @@ var dispatchReview = async (request, overrides = {}) => {
|
|
|
512
2868
|
};
|
|
513
2869
|
|
|
514
2870
|
// src/skill-scripts/shared/harness-availability.ts
|
|
515
|
-
var AVAILABILITY_REGISTRY_VERSION =
|
|
2871
|
+
var AVAILABILITY_REGISTRY_VERSION = 3;
|
|
516
2872
|
var AVAILABLE_TTL_MS = 30 * 60 * 1e3;
|
|
517
2873
|
var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
|
|
518
2874
|
var PROBE_TIMEOUT_MS = 2e4;
|
|
519
|
-
var AVAILABILITY_CACHE_RELATIVE_PATH =
|
|
520
|
-
var
|
|
521
|
-
var
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
codex: {
|
|
529
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
530
|
-
executable: "codex",
|
|
531
|
-
buildCommand: (cwd) => probeCommand("codex", ["exec", "-"], cwd)
|
|
532
|
-
},
|
|
533
|
-
cursor: {
|
|
534
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
535
|
-
executable: "cursor-agent",
|
|
536
|
-
buildCommand: (cwd) => probeCommand("cursor-agent", ["--print"], cwd)
|
|
537
|
-
},
|
|
538
|
-
gemini: {
|
|
539
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
540
|
-
executable: "gemini",
|
|
541
|
-
buildCommand: (cwd) => probeCommand("gemini", ["--prompt", PROBE_PROMPT], cwd, "")
|
|
542
|
-
},
|
|
543
|
-
copilot: {
|
|
544
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
545
|
-
executable: "copilot",
|
|
546
|
-
buildCommand: (cwd) => probeCommand("copilot", ["-p", PROBE_PROMPT], cwd, "")
|
|
547
|
-
},
|
|
548
|
-
opencode: {
|
|
549
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
550
|
-
executable: "opencode",
|
|
551
|
-
buildCommand: (cwd) => probeCommand("opencode", ["run", "-"], cwd)
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
var registryKeys = Object.keys(HARNESS_AVAILABILITY_REGISTRY).sort();
|
|
555
|
-
var harnessKeys2 = [...SUPPORTED_HARNESSES].sort();
|
|
556
|
-
if (registryKeys.join("\0") !== harnessKeys2.join("\0")) {
|
|
557
|
-
throw new Error("Harness availability registry does not cover SUPPORTED_HARNESSES exactly.");
|
|
558
|
-
}
|
|
559
|
-
for (const harness of SUPPORTED_HARNESSES) {
|
|
560
|
-
const availability = HARNESS_AVAILABILITY_REGISTRY[harness];
|
|
561
|
-
if (availability.executable !== EXTERNAL_HARNESS_ADAPTERS[harness].executable) {
|
|
562
|
-
throw new Error(`Harness availability executable disagrees with the ${harness} adapter.`);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
var safeReason = (value, fallback) => {
|
|
566
|
-
if (typeof value !== "string") return fallback;
|
|
567
|
-
const firstLine = value.replace(/[\r\n]+/g, " ").trim().slice(0, 200);
|
|
568
|
-
return firstLine || fallback;
|
|
569
|
-
};
|
|
570
|
-
var isOutcome = (value) => {
|
|
571
|
-
if (!value || typeof value !== "object") return false;
|
|
572
|
-
const entry = value;
|
|
573
|
-
return typeof entry.available === "boolean" && typeof entry.observedAt === "number" && Number.isFinite(entry.observedAt) && typeof entry.expiresAt === "number" && Number.isFinite(entry.expiresAt) && typeof entry.reason === "string";
|
|
574
|
-
};
|
|
575
|
-
var readCache = (cachePath) => {
|
|
576
|
-
try {
|
|
577
|
-
const parsed = JSON.parse(fs5.readFileSync(cachePath, "utf8"));
|
|
578
|
-
if (!parsed || typeof parsed !== "object") throw new Error("invalid cache");
|
|
579
|
-
const record = parsed;
|
|
580
|
-
if (record.version !== 1 || !record.harnesses || typeof record.harnesses !== "object") {
|
|
581
|
-
throw new Error("invalid cache");
|
|
582
|
-
}
|
|
583
|
-
const harnesses = {};
|
|
584
|
-
for (const harness of SUPPORTED_HARNESSES) {
|
|
585
|
-
const candidate = record.harnesses[harness];
|
|
586
|
-
if (isOutcome(candidate)) harnesses[harness] = candidate;
|
|
587
|
-
}
|
|
588
|
-
return { version: 1, harnesses };
|
|
589
|
-
} catch {
|
|
590
|
-
return { version: 1, harnesses: {} };
|
|
591
|
-
}
|
|
2875
|
+
var AVAILABILITY_CACHE_RELATIVE_PATH = path7.join("runtime", "harness-availability.json");
|
|
2876
|
+
var CACHE_VERSION = 2;
|
|
2877
|
+
var availabilityDefinition = (harness) => {
|
|
2878
|
+
const adapter = EXTERNAL_HARNESS_ADAPTERS[harness];
|
|
2879
|
+
return {
|
|
2880
|
+
executable: adapter.executable,
|
|
2881
|
+
buildCommand: (cwd, cliArgs, prompt) => adapter.buildCommand({ cliArgs, workspace: cwd, prompt })
|
|
2882
|
+
};
|
|
592
2883
|
};
|
|
593
|
-
var
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
fs5.unlinkSync(temporary);
|
|
613
|
-
} catch {
|
|
2884
|
+
var HARNESS_AVAILABILITY_REGISTRY = Object.freeze(
|
|
2885
|
+
Object.fromEntries(
|
|
2886
|
+
SUPPORTED_HARNESSES.map((harness) => [harness, availabilityDefinition(harness)])
|
|
2887
|
+
)
|
|
2888
|
+
);
|
|
2889
|
+
var resolveExecutable = (executable) => {
|
|
2890
|
+
const extensions = process.platform === "win32" ? ["", ...(process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";")] : [""];
|
|
2891
|
+
const directories = /[\\/]/.test(executable) ? [""] : (process.env.PATH ?? "").split(path7.delimiter).filter(Boolean);
|
|
2892
|
+
for (const directory of directories) {
|
|
2893
|
+
for (const extension of extensions) {
|
|
2894
|
+
const candidate = path7.resolve(directory, `${executable}${extension}`);
|
|
2895
|
+
try {
|
|
2896
|
+
fs6.accessSync(
|
|
2897
|
+
candidate,
|
|
2898
|
+
process.platform === "win32" ? fs6.constants.F_OK : fs6.constants.X_OK
|
|
2899
|
+
);
|
|
2900
|
+
if (fs6.statSync(candidate).isFile()) return fs6.realpathSync(candidate);
|
|
2901
|
+
} catch {
|
|
2902
|
+
}
|
|
614
2903
|
}
|
|
615
2904
|
}
|
|
2905
|
+
return void 0;
|
|
616
2906
|
};
|
|
617
|
-
var runProbe = (command2, timeoutMs) => new Promise((
|
|
2907
|
+
var runProbe = (command2, timeoutMs) => new Promise((resolve4) => {
|
|
618
2908
|
let settled = false;
|
|
619
|
-
let
|
|
2909
|
+
let timedOut = false;
|
|
620
2910
|
const finish = (result) => {
|
|
621
2911
|
if (settled) return;
|
|
622
2912
|
settled = true;
|
|
623
|
-
|
|
2913
|
+
resolve4(result);
|
|
624
2914
|
};
|
|
625
2915
|
const child = (0, import_child_process3.spawn)(command2.executable, command2.argv, {
|
|
626
2916
|
cwd: command2.cwd,
|
|
627
2917
|
shell: false,
|
|
628
|
-
stdio: ["pipe", "ignore", "
|
|
2918
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
629
2919
|
});
|
|
630
2920
|
const timer = setTimeout(() => {
|
|
2921
|
+
timedOut = true;
|
|
631
2922
|
child.kill("SIGKILL");
|
|
632
|
-
finish({ exitCode: 1, timedOut: true, detail: "Probe timed out." });
|
|
633
2923
|
}, timeoutMs);
|
|
634
|
-
child.
|
|
635
|
-
if (diagnostics.length < 400) diagnostics += String(chunk).slice(0, 400 - diagnostics.length);
|
|
636
|
-
});
|
|
637
|
-
child.once("error", (error) => {
|
|
2924
|
+
child.once("error", () => {
|
|
638
2925
|
clearTimeout(timer);
|
|
639
|
-
finish({ exitCode: 1,
|
|
2926
|
+
finish({ exitCode: 1, timedOut });
|
|
640
2927
|
});
|
|
641
2928
|
child.once("close", (code) => {
|
|
642
2929
|
clearTimeout(timer);
|
|
643
|
-
finish({ exitCode: code ?? 1,
|
|
2930
|
+
finish({ exitCode: code ?? 1, timedOut });
|
|
644
2931
|
});
|
|
645
2932
|
child.stdin?.on("error", () => void 0);
|
|
646
2933
|
child.stdin?.end(command2.stdin);
|
|
647
2934
|
});
|
|
648
2935
|
var defaultDependencies = {
|
|
649
2936
|
now: Date.now,
|
|
2937
|
+
resolveExecutable,
|
|
650
2938
|
runProbe
|
|
651
2939
|
};
|
|
2940
|
+
var isHarness = (value) => typeof value === "string" && SUPPORTED_HARNESSES.includes(value);
|
|
2941
|
+
var isCacheEntry = (value) => {
|
|
2942
|
+
if (!value || typeof value !== "object") return false;
|
|
2943
|
+
const entry = value;
|
|
2944
|
+
return typeof entry.key === "string" && isHarness(entry.harness) && typeof entry.available === "boolean" && typeof entry.observedAt === "number" && Number.isFinite(entry.observedAt) && typeof entry.expiresAt === "number" && Number.isFinite(entry.expiresAt) && typeof entry.reason === "string";
|
|
2945
|
+
};
|
|
2946
|
+
var emptyCache = () => ({ version: CACHE_VERSION, entries: [] });
|
|
2947
|
+
var readCache = (cachePath) => {
|
|
2948
|
+
try {
|
|
2949
|
+
const parsed = JSON.parse(fs6.readFileSync(cachePath, "utf8"));
|
|
2950
|
+
if (!parsed || typeof parsed !== "object") return emptyCache();
|
|
2951
|
+
const record = parsed;
|
|
2952
|
+
if (record.version !== CACHE_VERSION || !Array.isArray(record.entries)) return emptyCache();
|
|
2953
|
+
return { version: CACHE_VERSION, entries: record.entries.filter(isCacheEntry) };
|
|
2954
|
+
} catch {
|
|
2955
|
+
return emptyCache();
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
var writeCache = (cachePath, entry) => {
|
|
2959
|
+
fs6.mkdirSync(path7.dirname(cachePath), { recursive: true });
|
|
2960
|
+
const cache = readCache(cachePath);
|
|
2961
|
+
const existingIndex = cache.entries.findIndex((candidate) => candidate.key === entry.key);
|
|
2962
|
+
if (existingIndex === -1) cache.entries.push(entry);
|
|
2963
|
+
else if (cache.entries[existingIndex].observedAt <= entry.observedAt) {
|
|
2964
|
+
cache.entries[existingIndex] = entry;
|
|
2965
|
+
}
|
|
2966
|
+
const temporary = `${cachePath}.${process.pid}.${(0, import_crypto2.randomUUID)()}.tmp`;
|
|
2967
|
+
try {
|
|
2968
|
+
fs6.writeFileSync(temporary, `${JSON.stringify(cache, null, 2)}
|
|
2969
|
+
`, { mode: 384 });
|
|
2970
|
+
fs6.renameSync(temporary, cachePath);
|
|
2971
|
+
} finally {
|
|
2972
|
+
try {
|
|
2973
|
+
fs6.unlinkSync(temporary);
|
|
2974
|
+
} catch {
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2978
|
+
var cacheKey = (harness, executableIdentity, invocation) => (0, import_crypto2.createHash)("sha256").update(
|
|
2979
|
+
JSON.stringify({
|
|
2980
|
+
harness,
|
|
2981
|
+
executableIdentity,
|
|
2982
|
+
cliArgsHash: invocation.cliArgsHash,
|
|
2983
|
+
normalizationVersion: HARNESS_CONFIGURATION_NORMALIZATION_VERSION,
|
|
2984
|
+
probeRegistryVersion: AVAILABILITY_REGISTRY_VERSION
|
|
2985
|
+
})
|
|
2986
|
+
).digest("hex");
|
|
2987
|
+
var readinessEvidence = () => {
|
|
2988
|
+
const nonce = (0, import_crypto2.randomUUID)();
|
|
2989
|
+
return {
|
|
2990
|
+
file: "strikethroo-readiness.txt",
|
|
2991
|
+
content: `strikethroo-readiness:${nonce}
|
|
2992
|
+
`
|
|
2993
|
+
};
|
|
2994
|
+
};
|
|
2995
|
+
var readinessPrompt = (evidence) => `Run a shell command that creates ${evidence.file} in the current workspace with the exact UTF-8 content ${JSON.stringify(evidence.content)}. Do not use a file editing tool.
|
|
2996
|
+
STRIKETHROO_READINESS=${JSON.stringify(evidence)}
|
|
2997
|
+
`;
|
|
2998
|
+
var initializeProbeWorkspace = () => {
|
|
2999
|
+
const workspace = fs6.mkdtempSync(path7.join(os.tmpdir(), "strikethroo-harness-probe-"));
|
|
3000
|
+
const initialized = (0, import_child_process3.spawnSync)("git", ["init", "--quiet"], {
|
|
3001
|
+
cwd: workspace,
|
|
3002
|
+
shell: false,
|
|
3003
|
+
stdio: "ignore",
|
|
3004
|
+
timeout: 5e3
|
|
3005
|
+
});
|
|
3006
|
+
if (initialized.status === 0 && !initialized.error) return workspace;
|
|
3007
|
+
fs6.rmSync(workspace, { recursive: true, force: true });
|
|
3008
|
+
return void 0;
|
|
3009
|
+
};
|
|
3010
|
+
var hasReadinessEvidence = (workspace, evidence) => {
|
|
3011
|
+
const target = path7.join(workspace, evidence.file);
|
|
3012
|
+
try {
|
|
3013
|
+
return fs6.lstatSync(target).isFile() && fs6.readFileSync(target, "utf8") === evidence.content;
|
|
3014
|
+
} catch {
|
|
3015
|
+
return false;
|
|
3016
|
+
}
|
|
3017
|
+
};
|
|
3018
|
+
var outcome = (harness, available, now, reason) => ({
|
|
3019
|
+
harness,
|
|
3020
|
+
available,
|
|
3021
|
+
observedAt: now,
|
|
3022
|
+
expiresAt: now + (available ? AVAILABLE_TTL_MS : UNAVAILABLE_TTL_MS),
|
|
3023
|
+
reason,
|
|
3024
|
+
source: "probe"
|
|
3025
|
+
});
|
|
3026
|
+
var invocationFor = (request, harness) => {
|
|
3027
|
+
if (request.invocation) return request.invocation;
|
|
3028
|
+
const loaded = loadHarnessConfiguration(request.strikethrooRoot);
|
|
3029
|
+
return loaded.kind === "config" ? loaded.config[harness] : void 0;
|
|
3030
|
+
};
|
|
652
3031
|
var checkHarnessAvailability = async (request, overrides = {}) => {
|
|
653
3032
|
const active = { ...defaultDependencies, ...overrides };
|
|
654
3033
|
const now = active.now();
|
|
@@ -663,38 +3042,76 @@ var checkHarnessAvailability = async (request, overrides = {}) => {
|
|
|
663
3042
|
};
|
|
664
3043
|
}
|
|
665
3044
|
const harness = request.harness;
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
if (cached && cached.expiresAt > now) return { harness, ...cached, source: "cache" };
|
|
3045
|
+
const invocation = invocationFor(request, harness);
|
|
3046
|
+
if (!invocation) return outcome(harness, false, now, "Harness configuration is invalid.");
|
|
669
3047
|
const definition = HARNESS_AVAILABILITY_REGISTRY[harness];
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const reason = available ? "Harness probe succeeded." : safeReason(
|
|
678
|
-
probe.detail,
|
|
679
|
-
probe.timedOut ? "Harness probe timed out." : "Harness probe failed."
|
|
3048
|
+
const executableIdentity = active.resolveExecutable(definition.executable);
|
|
3049
|
+
if (!executableIdentity)
|
|
3050
|
+
return outcome(harness, false, now, "Harness executable is unavailable.");
|
|
3051
|
+
const key = cacheKey(harness, executableIdentity, invocation);
|
|
3052
|
+
const cachePath = path7.join(request.strikethrooRoot, AVAILABILITY_CACHE_RELATIVE_PATH);
|
|
3053
|
+
const cached = readCache(cachePath).entries.find(
|
|
3054
|
+
(entry) => entry.key === key && entry.expiresAt > now
|
|
680
3055
|
);
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
3056
|
+
if (cached) {
|
|
3057
|
+
const { key: _key, ...cachedOutcome } = cached;
|
|
3058
|
+
return { ...cachedOutcome, source: "cache" };
|
|
3059
|
+
}
|
|
3060
|
+
const complete = (result) => {
|
|
3061
|
+
const { source: _source, ...cacheEntry } = result;
|
|
3062
|
+
try {
|
|
3063
|
+
writeCache(cachePath, { key, ...cacheEntry });
|
|
3064
|
+
} catch {
|
|
3065
|
+
}
|
|
3066
|
+
return result;
|
|
688
3067
|
};
|
|
3068
|
+
const probeWorkspace = initializeProbeWorkspace();
|
|
3069
|
+
if (!probeWorkspace) {
|
|
3070
|
+
return complete(outcome(harness, false, now, "Harness readiness check failed."));
|
|
3071
|
+
}
|
|
689
3072
|
try {
|
|
690
|
-
|
|
691
|
-
|
|
3073
|
+
const evidence = readinessEvidence();
|
|
3074
|
+
const command2 = definition.buildCommand(
|
|
3075
|
+
probeWorkspace,
|
|
3076
|
+
invocation.cliArgs,
|
|
3077
|
+
readinessPrompt(evidence)
|
|
3078
|
+
);
|
|
3079
|
+
const probe = await active.runProbe(
|
|
3080
|
+
{ ...command2, executable: executableIdentity },
|
|
3081
|
+
PROBE_TIMEOUT_MS
|
|
3082
|
+
);
|
|
3083
|
+
const available = probe.exitCode === 0 && !probe.timedOut && hasReadinessEvidence(probeWorkspace, evidence);
|
|
3084
|
+
return complete(
|
|
3085
|
+
outcome(
|
|
3086
|
+
harness,
|
|
3087
|
+
available,
|
|
3088
|
+
now,
|
|
3089
|
+
available ? "Harness readiness verified." : "Harness readiness check failed."
|
|
3090
|
+
)
|
|
3091
|
+
);
|
|
3092
|
+
} finally {
|
|
3093
|
+
fs6.rmSync(probeWorkspace, { recursive: true, force: true });
|
|
692
3094
|
}
|
|
693
|
-
return outcome;
|
|
694
3095
|
};
|
|
695
3096
|
|
|
696
3097
|
// src/skill-scripts/shared/harness-discovery.ts
|
|
697
3098
|
var discoverHarnesses = async (request, overrides = {}) => {
|
|
3099
|
+
const configuration = loadHarnessConfiguration(request.strikethrooRoot);
|
|
3100
|
+
if (configuration.kind === "invalid") {
|
|
3101
|
+
const now = (overrides.now ?? Date.now)();
|
|
3102
|
+
return {
|
|
3103
|
+
outcomes: SUPPORTED_HARNESSES.map((harness) => ({
|
|
3104
|
+
harness,
|
|
3105
|
+
available: harness === request.currentHarness,
|
|
3106
|
+
observedAt: now,
|
|
3107
|
+
expiresAt: now,
|
|
3108
|
+
reason: harness === request.currentHarness ? "Native/current harness targets do not require a probe." : "Harness configuration is invalid.",
|
|
3109
|
+
source: harness === request.currentHarness ? "bypass" : "probe"
|
|
3110
|
+
})),
|
|
3111
|
+
reviewerCandidates: [],
|
|
3112
|
+
configurationErrors: configuration.errors
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
698
3115
|
const outcomes = await Promise.all(
|
|
699
3116
|
SUPPORTED_HARNESSES.map(async (harness) => {
|
|
700
3117
|
try {
|
|
@@ -703,7 +3120,8 @@ var discoverHarnesses = async (request, overrides = {}) => {
|
|
|
703
3120
|
strikethrooRoot: request.strikethrooRoot,
|
|
704
3121
|
workspace: request.workspace,
|
|
705
3122
|
harness,
|
|
706
|
-
currentHarness: request.currentHarness
|
|
3123
|
+
currentHarness: request.currentHarness,
|
|
3124
|
+
invocation: configuration.config[harness]
|
|
707
3125
|
},
|
|
708
3126
|
overrides
|
|
709
3127
|
);
|
|
@@ -722,76 +3140,29 @@ var discoverHarnesses = async (request, overrides = {}) => {
|
|
|
722
3140
|
);
|
|
723
3141
|
const reviewerCandidates = SUPPORTED_HARNESSES.filter((harness) => {
|
|
724
3142
|
if (harness === request.currentHarness) return false;
|
|
725
|
-
const
|
|
726
|
-
return
|
|
3143
|
+
const outcome2 = outcomes.find((candidate) => candidate.harness === harness);
|
|
3144
|
+
return outcome2?.available === true;
|
|
727
3145
|
});
|
|
728
|
-
|
|
3146
|
+
const reviewerInvocations = Object.fromEntries(
|
|
3147
|
+
reviewerCandidates.map((harness) => [harness, { cliArgs: configuration.config[harness].cliArgs }])
|
|
3148
|
+
);
|
|
3149
|
+
return { outcomes, reviewerCandidates, reviewerInvocations };
|
|
729
3150
|
};
|
|
730
3151
|
|
|
731
3152
|
// src/skill-scripts/shared/review-findings.ts
|
|
732
3153
|
var import_child_process4 = require("child_process");
|
|
733
|
-
var
|
|
734
|
-
var
|
|
735
|
-
var MAX_REVIEW_ROUNDS = 3;
|
|
736
|
-
var DEFAULT_SEVERITY_FLOOR = "major";
|
|
737
|
-
var DEFAULT_CONFIDENCE_FLOOR = "high";
|
|
3154
|
+
var SEVERITIES = ["critical", "major", "minor", "info"];
|
|
3155
|
+
var CONFIDENCES = ["high", "medium", "low"];
|
|
738
3156
|
var XMLLINT_TIMEOUT_MS = 3e4;
|
|
739
|
-
var isSeverity = (value) => value
|
|
740
|
-
var isConfidence = (value) => value
|
|
741
|
-
var
|
|
742
|
-
var CONFIDENCE_FLOOR_RE = /^[ \t]*#{0,6}[ \t]*confidence floor[ \t]*:[ \t]*`?([a-z]+)`?/im;
|
|
743
|
-
var ROUND_BUDGET_RE = /^[ \t]*#{0,6}[ \t]*round budget[ \t]*:[ \t]*`?(-?\d{1,9})`?/im;
|
|
744
|
-
var parseReviewMandate = (hookContent) => {
|
|
745
|
-
const notes = [];
|
|
746
|
-
const severityMatch = SEVERITY_FLOOR_RE.exec(hookContent);
|
|
747
|
-
const statedSeverity = (severityMatch?.[1] ?? "").toLowerCase();
|
|
748
|
-
let severityFloor = DEFAULT_SEVERITY_FLOOR;
|
|
749
|
-
if (isSeverity(statedSeverity)) {
|
|
750
|
-
severityFloor = statedSeverity;
|
|
751
|
-
} else {
|
|
752
|
-
notes.push(
|
|
753
|
-
`The hook states no recognised severity floor, so the compiled default \`${DEFAULT_SEVERITY_FLOOR}\` applies.`
|
|
754
|
-
);
|
|
755
|
-
}
|
|
756
|
-
const confidenceMatch = CONFIDENCE_FLOOR_RE.exec(hookContent);
|
|
757
|
-
const statedConfidence = (confidenceMatch?.[1] ?? "").toLowerCase();
|
|
758
|
-
let confidenceFloor = DEFAULT_CONFIDENCE_FLOOR;
|
|
759
|
-
if (isConfidence(statedConfidence)) {
|
|
760
|
-
confidenceFloor = statedConfidence;
|
|
761
|
-
} else {
|
|
762
|
-
notes.push(
|
|
763
|
-
`The hook states no recognised confidence floor, so the compiled default \`${DEFAULT_CONFIDENCE_FLOOR}\` applies.`
|
|
764
|
-
);
|
|
765
|
-
}
|
|
766
|
-
const budgetMatch = ROUND_BUDGET_RE.exec(hookContent);
|
|
767
|
-
let roundBudget = MAX_REVIEW_ROUNDS;
|
|
768
|
-
if (budgetMatch === null) {
|
|
769
|
-
notes.push(
|
|
770
|
-
`The hook states no round budget, so the compiled ceiling of ${MAX_REVIEW_ROUNDS} rounds applies.`
|
|
771
|
-
);
|
|
772
|
-
} else {
|
|
773
|
-
const stated = Number(budgetMatch[1]);
|
|
774
|
-
if (!Number.isInteger(stated) || stated < 1) {
|
|
775
|
-
notes.push(
|
|
776
|
-
`The hook states a round budget of "${budgetMatch[1]}", which is not a positive whole number of rounds, so the compiled ceiling of ${MAX_REVIEW_ROUNDS} applies.`
|
|
777
|
-
);
|
|
778
|
-
} else if (stated > MAX_REVIEW_ROUNDS) {
|
|
779
|
-
notes.push(
|
|
780
|
-
`The hook states a round budget of ${stated}, above the compiled ceiling of ${MAX_REVIEW_ROUNDS}. The ceiling is enforced in code and cannot be raised by editing the hook, so ${MAX_REVIEW_ROUNDS} rounds apply.`
|
|
781
|
-
);
|
|
782
|
-
} else {
|
|
783
|
-
roundBudget = stated;
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
return { severityFloor, confidenceFloor, roundBudget, notes };
|
|
787
|
-
};
|
|
788
|
-
var validateAgainstSchema = (xsdFile, xmlFile, timeoutMs = XMLLINT_TIMEOUT_MS) => new Promise((resolve3) => {
|
|
3157
|
+
var isSeverity = (value) => SEVERITIES.includes(value);
|
|
3158
|
+
var isConfidence = (value) => CONFIDENCES.includes(value);
|
|
3159
|
+
var validateAgainstSchema = (xsdFile, xmlFile, timeoutMs = XMLLINT_TIMEOUT_MS) => new Promise((resolve4) => {
|
|
789
3160
|
let settled = false;
|
|
790
3161
|
let diagnostics = "";
|
|
791
3162
|
const finish = (result) => {
|
|
792
3163
|
if (settled) return;
|
|
793
3164
|
settled = true;
|
|
794
|
-
|
|
3165
|
+
resolve4(result);
|
|
795
3166
|
};
|
|
796
3167
|
const child = (0, import_child_process4.spawn)("xmllint", ["--nonet", "--schema", xsdFile, xmlFile, "--noout"], {
|
|
797
3168
|
shell: false,
|
|
@@ -943,12 +3314,11 @@ var parseReviewFindings = (xml) => {
|
|
|
943
3314
|
comment = {
|
|
944
3315
|
file: file ?? "",
|
|
945
3316
|
location: lineRange(attributes),
|
|
946
|
-
// Absent, empty, and unrecognised all become null
|
|
947
|
-
//
|
|
3317
|
+
// Absent, empty, and unrecognised all become null. The label is
|
|
3318
|
+
// advisory, so an unreadable one is dropped rather than guessed at.
|
|
948
3319
|
severity: isSeverity(severity) ? severity : null,
|
|
949
3320
|
confidence: isConfidence(confidence) ? confidence : null,
|
|
950
3321
|
category: null,
|
|
951
|
-
hasSuggestion: false,
|
|
952
3322
|
summary: ""
|
|
953
3323
|
};
|
|
954
3324
|
capture = null;
|
|
@@ -965,60 +3335,29 @@ var parseReviewFindings = (xml) => {
|
|
|
965
3335
|
} else if (name === "category") {
|
|
966
3336
|
capture = "category";
|
|
967
3337
|
buffer = "";
|
|
968
|
-
} else if (name === "suggestion") {
|
|
969
|
-
comment.hasSuggestion = true;
|
|
970
3338
|
}
|
|
971
3339
|
}
|
|
972
3340
|
return findings;
|
|
973
3341
|
};
|
|
974
|
-
var
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
3342
|
+
var countFindings = (findings) => {
|
|
3343
|
+
const counts = {
|
|
3344
|
+
total: findings.length,
|
|
3345
|
+
critical: 0,
|
|
3346
|
+
major: 0,
|
|
3347
|
+
minor: 0,
|
|
3348
|
+
info: 0,
|
|
3349
|
+
unlabelled: 0
|
|
3350
|
+
};
|
|
979
3351
|
for (const finding of findings) {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
reasons.push("severity-absent");
|
|
983
|
-
} else if (SEVERITY_RANK[finding.severity] < SEVERITY_RANK[severityFloor]) {
|
|
984
|
-
reasons.push("severity-below-floor");
|
|
985
|
-
}
|
|
986
|
-
if (finding.confidence === null) {
|
|
987
|
-
reasons.push("confidence-absent");
|
|
988
|
-
} else if (CONFIDENCE_RANK[finding.confidence] < CONFIDENCE_RANK[confidenceFloor]) {
|
|
989
|
-
reasons.push("confidence-below-floor");
|
|
990
|
-
}
|
|
991
|
-
const clearsFloors = reasons.length === 0;
|
|
992
|
-
if (clearsFloors) aboveFloor += 1;
|
|
993
|
-
if (!finding.hasSuggestion) {
|
|
994
|
-
reasons.push("no-suggestion");
|
|
995
|
-
if (clearsFloors) aboveFloorWithoutSuggestion += 1;
|
|
996
|
-
}
|
|
997
|
-
if (reasons.length === 0) {
|
|
998
|
-
actionable.push(finding);
|
|
999
|
-
} else {
|
|
1000
|
-
recorded.push({ ...finding, reasons });
|
|
1001
|
-
}
|
|
3352
|
+
if (finding.severity === null) counts.unlabelled += 1;
|
|
3353
|
+
else counts[finding.severity] += 1;
|
|
1002
3354
|
}
|
|
1003
|
-
return
|
|
1004
|
-
severityFloor,
|
|
1005
|
-
confidenceFloor,
|
|
1006
|
-
actionable,
|
|
1007
|
-
recorded,
|
|
1008
|
-
counts: {
|
|
1009
|
-
total: findings.length,
|
|
1010
|
-
aboveFloor,
|
|
1011
|
-
belowFloor: findings.length - aboveFloor,
|
|
1012
|
-
actionable: actionable.length,
|
|
1013
|
-
recorded: recorded.length,
|
|
1014
|
-
aboveFloorWithoutSuggestion
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
3355
|
+
return counts;
|
|
1017
3356
|
};
|
|
1018
3357
|
|
|
1019
3358
|
// src/skill-scripts/code-review.ts
|
|
1020
|
-
var HOOK_RELATIVE_PATH =
|
|
1021
|
-
var XSD_RELATIVE_PATH =
|
|
3359
|
+
var HOOK_RELATIVE_PATH = path8.join("config", "hooks", "CODE_REVIEW.md");
|
|
3360
|
+
var XSD_RELATIVE_PATH = path8.join("config", "schemas", "self-review-v2.xsd");
|
|
1022
3361
|
var REVIEW_DIR_NAME = "review";
|
|
1023
3362
|
var BASE_COMMIT_FILE_NAME = "base-commit.json";
|
|
1024
3363
|
var REVIEW_FILE_NAME = "review.xml";
|
|
@@ -1028,49 +3367,43 @@ var SHA_RE = /^[0-9a-f]{40}$/i;
|
|
|
1028
3367
|
var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
1029
3368
|
var readFileOrNull = (filePath) => {
|
|
1030
3369
|
try {
|
|
1031
|
-
return
|
|
3370
|
+
return fs7.readFileSync(filePath, "utf8");
|
|
1032
3371
|
} catch {
|
|
1033
3372
|
return null;
|
|
1034
3373
|
}
|
|
1035
3374
|
};
|
|
1036
|
-
var writeTranscript = (
|
|
3375
|
+
var writeTranscript = (reviewDir, transcript) => {
|
|
1037
3376
|
if (transcript === void 0 || transcript === "") return;
|
|
1038
3377
|
try {
|
|
1039
|
-
|
|
1040
|
-
|
|
3378
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3379
|
+
fs7.writeFileSync(path8.join(reviewDir, TRANSCRIPT_FILE_NAME), transcript, "utf8");
|
|
1041
3380
|
} catch {
|
|
1042
3381
|
}
|
|
1043
3382
|
};
|
|
1044
|
-
var createFindingsGate = (
|
|
1045
|
-
const
|
|
1046
|
-
const findingsFile =
|
|
3383
|
+
var createFindingsGate = () => async (context) => {
|
|
3384
|
+
const reviewDir = path8.dirname(context.reviewFile);
|
|
3385
|
+
const findingsFile = path8.join(reviewDir, FINDINGS_FILE_NAME);
|
|
1047
3386
|
const record = (payload) => {
|
|
1048
3387
|
try {
|
|
1049
|
-
|
|
1050
|
-
|
|
3388
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3389
|
+
fs7.writeFileSync(findingsFile, `${JSON.stringify(payload, null, 2)}
|
|
1051
3390
|
`, "utf8");
|
|
1052
3391
|
} catch (error) {
|
|
1053
3392
|
throw new Error(
|
|
1054
|
-
`The review
|
|
3393
|
+
`The review findings could not be written to ${findingsFile}: ${errorMessage2(error)}`
|
|
1055
3394
|
);
|
|
1056
3395
|
}
|
|
1057
3396
|
};
|
|
1058
|
-
const base = {
|
|
1059
|
-
round: context.round,
|
|
1060
|
-
reviewFile: context.reviewFile,
|
|
1061
|
-
xsdFile: context.xsdFile,
|
|
1062
|
-
severityFloor: mandate.severityFloor,
|
|
1063
|
-
confidenceFloor: mandate.confidenceFloor
|
|
1064
|
-
};
|
|
3397
|
+
const base = { reviewFile: context.reviewFile, xsdFile: context.xsdFile };
|
|
1065
3398
|
const delivered = _extractReviewDocument(context.reviewerStdout, context.deliveryToken);
|
|
1066
3399
|
if (delivered === null) {
|
|
1067
3400
|
const detail = "The reviewer printed no complete findings document between this dispatch's delimiters. A round with no findings document cannot be read as a round with no findings.";
|
|
1068
|
-
record({ ...base, status: "findings-absent", detail,
|
|
3401
|
+
record({ ...base, status: "findings-absent", detail, findings: [] });
|
|
1069
3402
|
return { kind: "findings-absent", detail };
|
|
1070
3403
|
}
|
|
1071
3404
|
try {
|
|
1072
|
-
|
|
1073
|
-
|
|
3405
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3406
|
+
fs7.writeFileSync(
|
|
1074
3407
|
context.reviewFile,
|
|
1075
3408
|
delivered.endsWith("\n") ? delivered : `${delivered}
|
|
1076
3409
|
`,
|
|
@@ -1087,46 +3420,25 @@ var createFindingsGate = (mandate) => async (context) => {
|
|
|
1087
3420
|
...base,
|
|
1088
3421
|
status: "validator-unavailable",
|
|
1089
3422
|
detail: validation.detail,
|
|
1090
|
-
|
|
1091
|
-
recorded: []
|
|
3423
|
+
findings: []
|
|
1092
3424
|
});
|
|
1093
3425
|
return { kind: "validator-unavailable", detail: validation.detail };
|
|
1094
3426
|
}
|
|
1095
3427
|
if (validation.kind === "invalid") {
|
|
1096
|
-
const detail = `${context.reviewFile} does not validate against ${context.xsdFile}, so its findings
|
|
1097
|
-
record({ ...base, status: "schema-invalid", detail,
|
|
3428
|
+
const detail = `${context.reviewFile} does not validate against ${context.xsdFile}, so its findings could not be certified and none of them was recorded. xmllint reported: ${validation.detail}`;
|
|
3429
|
+
record({ ...base, status: "schema-invalid", detail, findings: [] });
|
|
1098
3430
|
return { kind: "schema-invalid", detail };
|
|
1099
3431
|
}
|
|
1100
3432
|
const xml = readFileOrNull(context.reviewFile);
|
|
1101
3433
|
if (xml === null) {
|
|
1102
3434
|
const detail = `${context.reviewFile} validated but could not then be read.`;
|
|
1103
|
-
record({ ...base, status: "findings-absent", detail,
|
|
3435
|
+
record({ ...base, status: "findings-absent", detail, findings: [] });
|
|
1104
3436
|
return { kind: "findings-absent", detail };
|
|
1105
3437
|
}
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
);
|
|
1111
|
-
record({
|
|
1112
|
-
...base,
|
|
1113
|
-
status: "evaluated",
|
|
1114
|
-
counts: partition.counts,
|
|
1115
|
-
actionable: partition.actionable,
|
|
1116
|
-
recorded: partition.recorded
|
|
1117
|
-
});
|
|
1118
|
-
return {
|
|
1119
|
-
kind: "evaluated",
|
|
1120
|
-
aboveFloor: partition.counts.aboveFloor,
|
|
1121
|
-
belowFloor: partition.counts.belowFloor,
|
|
1122
|
-
actionable: partition.counts.actionable,
|
|
1123
|
-
recorded: partition.counts.recorded,
|
|
1124
|
-
total: partition.counts.total,
|
|
1125
|
-
aboveFloorWithoutSuggestion: partition.counts.aboveFloorWithoutSuggestion,
|
|
1126
|
-
severityFloor: mandate.severityFloor,
|
|
1127
|
-
confidenceFloor: mandate.confidenceFloor,
|
|
1128
|
-
findingsFile
|
|
1129
|
-
};
|
|
3438
|
+
const findings = parseReviewFindings(xml);
|
|
3439
|
+
const counts = countFindings(findings);
|
|
3440
|
+
record({ ...base, status: "evaluated", counts, findings });
|
|
3441
|
+
return { kind: "evaluated", counts, findingsFile };
|
|
1130
3442
|
};
|
|
1131
3443
|
var _readBaseCommit = (filePath) => {
|
|
1132
3444
|
const raw = readFileOrNull(filePath);
|
|
@@ -1194,23 +3506,10 @@ var defaultDependencies2 = {
|
|
|
1194
3506
|
validatorAvailable: () => executableOnPath("xmllint")
|
|
1195
3507
|
};
|
|
1196
3508
|
var readReviewerSkill = () => {
|
|
1197
|
-
const skillFile =
|
|
3509
|
+
const skillFile = path8.resolve(__dirname, "..", "SKILL.md");
|
|
1198
3510
|
const content = readFileOrNull(skillFile);
|
|
1199
3511
|
return content === null ? "Load the `st-code-review` skill and follow its Operating Procedure. If that skill is not installed on this harness, follow the mandate below exactly." : content;
|
|
1200
3512
|
};
|
|
1201
|
-
var renderAdjudicated = (findings) => {
|
|
1202
|
-
if (findings.length === 0) {
|
|
1203
|
-
return "None. This is the first round, or no earlier finding has been ruled on.";
|
|
1204
|
-
}
|
|
1205
|
-
return findings.map((finding) => {
|
|
1206
|
-
const attributes = [
|
|
1207
|
-
finding.severity === void 0 ? null : `severity=${finding.severity}`,
|
|
1208
|
-
finding.confidence === void 0 ? null : `confidence=${finding.confidence}`
|
|
1209
|
-
].filter((part) => part !== null).join(" ");
|
|
1210
|
-
const where = finding.location === void 0 ? finding.file : `${finding.file}:${finding.location}`;
|
|
1211
|
-
return `- [${finding.disposition}] ${where}${attributes ? ` (${attributes})` : ""} \u2014 ${finding.summary}`;
|
|
1212
|
-
}).join("\n");
|
|
1213
|
-
};
|
|
1214
3513
|
var _makeDeliveryToken = () => crypto.randomBytes(6).toString("hex");
|
|
1215
3514
|
var beginMarker = (token) => `<<<BEGIN REVIEW XML ${token}>>>`;
|
|
1216
3515
|
var endMarker = (token) => `<<<END REVIEW XML ${token}>>>`;
|
|
@@ -1232,7 +3531,7 @@ var _extractReviewDocument = (stdout, token) => {
|
|
|
1232
3531
|
return null;
|
|
1233
3532
|
};
|
|
1234
3533
|
var buildReviewerPrompt = (input) => [
|
|
1235
|
-
`Strikethroo code review gate \u2014 Plan ${input.planId}
|
|
3534
|
+
`Strikethroo code review gate \u2014 Plan ${input.planId}.`,
|
|
1236
3535
|
"",
|
|
1237
3536
|
"You are the independent reviewer, running on a different harness than the one",
|
|
1238
3537
|
"that wrote this code. You detect; you never fix. Do not edit, create, or delete",
|
|
@@ -1245,7 +3544,6 @@ var buildReviewerPrompt = (input) => [
|
|
|
1245
3544
|
`Review mandate hook: ${input.hookFile}`,
|
|
1246
3545
|
`Findings schema to validate against: ${input.xsdFile}`,
|
|
1247
3546
|
`Base commit anchoring this plan's scope: ${input.baseCommit}`,
|
|
1248
|
-
`Round: ${input.round}`,
|
|
1249
3547
|
"",
|
|
1250
3548
|
"## How to deliver your findings",
|
|
1251
3549
|
"",
|
|
@@ -1264,9 +3562,9 @@ var buildReviewerPrompt = (input) => [
|
|
|
1264
3562
|
"Copy those two lines from this dispatch; never invent a token. Print nothing after",
|
|
1265
3563
|
"the closing line. Do not write the document to a file \u2014 this channel is the only",
|
|
1266
3564
|
"one that is read. The document is validated against the schema named above, so an",
|
|
1267
|
-
"incomplete or invented document fails the
|
|
3565
|
+
"incomplete or invented document fails the review. Being unable to read the",
|
|
1268
3566
|
"repository is not a reason to emit this block: a review you could not perform is a",
|
|
1269
|
-
"failed
|
|
3567
|
+
"failed review, and emitting well-formed XML instead of reporting that failure is a",
|
|
1270
3568
|
"worse outcome than the failure.",
|
|
1271
3569
|
"",
|
|
1272
3570
|
"## Review mandate (authoritative \u2014 it overrides the reviewer instructions below)",
|
|
@@ -1277,10 +3575,6 @@ var buildReviewerPrompt = (input) => [
|
|
|
1277
3575
|
"",
|
|
1278
3576
|
input.skillInstructions.trim(),
|
|
1279
3577
|
"",
|
|
1280
|
-
"## Prior adjudicated findings \u2014 do not re-litigate these",
|
|
1281
|
-
"",
|
|
1282
|
-
renderAdjudicated(input.adjudicatedFindings),
|
|
1283
|
-
"",
|
|
1284
3578
|
"## Cumulative diff",
|
|
1285
3579
|
"",
|
|
1286
3580
|
`Produced with \`git diff ${input.baseCommit} --\` in ${input.workspace}: the recorded`,
|
|
@@ -1292,48 +3586,6 @@ ${input.diff}
|
|
|
1292
3586
|
<<<END CUMULATIVE DIFF>>>`,
|
|
1293
3587
|
""
|
|
1294
3588
|
].join("\n");
|
|
1295
|
-
var asAdjudicated = (value, disposition) => {
|
|
1296
|
-
if (!Array.isArray(value)) return [];
|
|
1297
|
-
const adjudicated = [];
|
|
1298
|
-
for (const entry of value) {
|
|
1299
|
-
if (entry === null || typeof entry !== "object") continue;
|
|
1300
|
-
const finding = entry;
|
|
1301
|
-
if (typeof finding["file"] !== "string") continue;
|
|
1302
|
-
adjudicated.push({
|
|
1303
|
-
file: finding["file"],
|
|
1304
|
-
...typeof finding["location"] === "string" ? { location: finding["location"] } : {},
|
|
1305
|
-
...typeof finding["severity"] === "string" ? { severity: finding["severity"] } : {},
|
|
1306
|
-
...typeof finding["confidence"] === "string" ? { confidence: finding["confidence"] } : {},
|
|
1307
|
-
summary: typeof finding["summary"] === "string" ? finding["summary"] : "",
|
|
1308
|
-
disposition
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
|
-
return adjudicated;
|
|
1312
|
-
};
|
|
1313
|
-
var _readPriorAdjudicated = (planDir, round) => {
|
|
1314
|
-
const carried = /* @__PURE__ */ new Map();
|
|
1315
|
-
for (let prior = 1; prior < round; prior += 1) {
|
|
1316
|
-
const raw = readFileOrNull(
|
|
1317
|
-
path6.join(planDir, REVIEW_DIR_NAME, `round-${prior}`, FINDINGS_FILE_NAME)
|
|
1318
|
-
);
|
|
1319
|
-
if (raw === null) continue;
|
|
1320
|
-
try {
|
|
1321
|
-
const parsed = JSON.parse(raw);
|
|
1322
|
-
if (parsed === null || typeof parsed !== "object") continue;
|
|
1323
|
-
const partition = parsed;
|
|
1324
|
-
const roundFindings = [
|
|
1325
|
-
...asAdjudicated(partition["actionable"], "applied"),
|
|
1326
|
-
...asAdjudicated(partition["recorded"], "recorded-below-floor")
|
|
1327
|
-
];
|
|
1328
|
-
for (const finding of roundFindings) {
|
|
1329
|
-
carried.set(`${finding.file}|${finding.location ?? ""}|${finding.summary}`, finding);
|
|
1330
|
-
}
|
|
1331
|
-
} catch {
|
|
1332
|
-
continue;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
return [...carried.values()];
|
|
1336
|
-
};
|
|
1337
3589
|
var skip = (reason, detail) => ({
|
|
1338
3590
|
kind: "skipped",
|
|
1339
3591
|
reason,
|
|
@@ -1350,7 +3602,7 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1350
3602
|
}
|
|
1351
3603
|
};
|
|
1352
3604
|
}
|
|
1353
|
-
const hookFile =
|
|
3605
|
+
const hookFile = path8.join(strikethrooRoot, HOOK_RELATIVE_PATH);
|
|
1354
3606
|
const hookContent = readFileOrNull(hookFile);
|
|
1355
3607
|
if (hookContent === null) {
|
|
1356
3608
|
return {
|
|
@@ -1370,8 +3622,8 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1370
3622
|
)
|
|
1371
3623
|
};
|
|
1372
3624
|
}
|
|
1373
|
-
const xsdFile =
|
|
1374
|
-
if (!
|
|
3625
|
+
const xsdFile = path8.join(strikethrooRoot, XSD_RELATIVE_PATH);
|
|
3626
|
+
if (!fs7.existsSync(xsdFile)) {
|
|
1375
3627
|
return {
|
|
1376
3628
|
kind: "ended",
|
|
1377
3629
|
result: skip(
|
|
@@ -1393,20 +3645,19 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1393
3645
|
kind: "resolved",
|
|
1394
3646
|
context: {
|
|
1395
3647
|
strikethrooRoot,
|
|
1396
|
-
workspace:
|
|
3648
|
+
workspace: path8.dirname(path8.dirname(strikethrooRoot)),
|
|
1397
3649
|
hookFile,
|
|
1398
3650
|
hookContent,
|
|
1399
|
-
xsdFile
|
|
1400
|
-
mandate: parseReviewMandate(hookContent)
|
|
3651
|
+
xsdFile
|
|
1401
3652
|
}
|
|
1402
3653
|
};
|
|
1403
3654
|
};
|
|
1404
|
-
var
|
|
3655
|
+
var runReview = async (request, overrides = {}) => {
|
|
1405
3656
|
const dependencies2 = { ...defaultDependencies2, ...overrides };
|
|
1406
3657
|
const startPath = request.startPath ?? process.cwd();
|
|
1407
3658
|
const resolution = resolveReviewContext(startPath, dependencies2.validatorAvailable);
|
|
1408
3659
|
if (resolution.kind === "ended") return resolution.result;
|
|
1409
|
-
const { strikethrooRoot, workspace, hookFile, hookContent, xsdFile
|
|
3660
|
+
const { strikethrooRoot, workspace, hookFile, hookContent, xsdFile } = resolution.context;
|
|
1410
3661
|
const resolved = resolvePlan(request.plan, startPath);
|
|
1411
3662
|
if (!resolved) {
|
|
1412
3663
|
return {
|
|
@@ -1415,7 +3666,7 @@ var runReviewRound = async (request, overrides = {}) => {
|
|
|
1415
3666
|
};
|
|
1416
3667
|
}
|
|
1417
3668
|
const { planDir, planFile, planId } = resolved;
|
|
1418
|
-
const baseCommitFile =
|
|
3669
|
+
const baseCommitFile = path8.join(planDir, REVIEW_DIR_NAME, BASE_COMMIT_FILE_NAME);
|
|
1419
3670
|
const baseCommit = _readBaseCommit(baseCommitFile);
|
|
1420
3671
|
if (baseCommit === null) {
|
|
1421
3672
|
return skip(
|
|
@@ -1428,6 +3679,14 @@ var runReviewRound = async (request, overrides = {}) => {
|
|
|
1428
3679
|
workspace,
|
|
1429
3680
|
currentHarness: request.currentHarness
|
|
1430
3681
|
});
|
|
3682
|
+
if (discovery.configurationErrors !== void 0) {
|
|
3683
|
+
return {
|
|
3684
|
+
kind: "infrastructure-failure",
|
|
3685
|
+
detail: `Harness invocation configuration is invalid: ${discovery.configurationErrors.join(
|
|
3686
|
+
" "
|
|
3687
|
+
)}`
|
|
3688
|
+
};
|
|
3689
|
+
}
|
|
1431
3690
|
const harness = discovery.reviewerCandidates[0];
|
|
1432
3691
|
if (harness === void 0) {
|
|
1433
3692
|
return skip(
|
|
@@ -1448,24 +3707,24 @@ var runReviewRound = async (request, overrides = {}) => {
|
|
|
1448
3707
|
`The diff from ${baseCommit} to the working tree in ${workspace} is empty, so there was nothing to review. No reviewer was dispatched, and no round was certified.`
|
|
1449
3708
|
);
|
|
1450
3709
|
}
|
|
1451
|
-
const
|
|
1452
|
-
const reviewFile =
|
|
3710
|
+
const reviewDir = path8.join(planDir, REVIEW_DIR_NAME);
|
|
3711
|
+
const reviewFile = path8.join(reviewDir, REVIEW_FILE_NAME);
|
|
1453
3712
|
try {
|
|
1454
|
-
|
|
3713
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
1455
3714
|
} catch (error) {
|
|
1456
3715
|
return {
|
|
1457
3716
|
kind: "infrastructure-failure",
|
|
1458
|
-
detail: `Could not create the review
|
|
3717
|
+
detail: `Could not create the review directory ${reviewDir}: ${errorMessage2(error)}`
|
|
1459
3718
|
};
|
|
1460
3719
|
}
|
|
1461
|
-
const staleArtifacts = [reviewFile,
|
|
3720
|
+
const staleArtifacts = [reviewFile, path8.join(reviewDir, TRANSCRIPT_FILE_NAME)];
|
|
1462
3721
|
for (const stale of staleArtifacts) {
|
|
1463
3722
|
try {
|
|
1464
|
-
|
|
3723
|
+
fs7.rmSync(stale, { force: true });
|
|
1465
3724
|
} catch (error) {
|
|
1466
3725
|
return {
|
|
1467
3726
|
kind: "infrastructure-failure",
|
|
1468
|
-
detail: `Could not remove the stale
|
|
3727
|
+
detail: `Could not remove the stale review artifact ${stale}: ${errorMessage2(error)}`
|
|
1469
3728
|
};
|
|
1470
3729
|
}
|
|
1471
3730
|
}
|
|
@@ -1479,13 +3738,19 @@ var runReviewRound = async (request, overrides = {}) => {
|
|
|
1479
3738
|
hookContent,
|
|
1480
3739
|
xsdFile,
|
|
1481
3740
|
baseCommit,
|
|
1482
|
-
round: request.round,
|
|
1483
3741
|
diff,
|
|
1484
|
-
adjudicatedFindings: request.adjudicatedFindings ?? _readPriorAdjudicated(planDir, request.round),
|
|
1485
3742
|
skillInstructions: readReviewerSkill(),
|
|
1486
3743
|
deliveryToken
|
|
1487
3744
|
});
|
|
1488
|
-
const
|
|
3745
|
+
const invocation = discovery.reviewerInvocations?.[harness];
|
|
3746
|
+
const dispatched = await dependencies2.dispatch({
|
|
3747
|
+
harness,
|
|
3748
|
+
workspace,
|
|
3749
|
+
prompt,
|
|
3750
|
+
...invocation === void 0 ? {} : {
|
|
3751
|
+
cliArgs: invocation.cliArgs
|
|
3752
|
+
}
|
|
3753
|
+
});
|
|
1489
3754
|
if (dispatched.kind === "infrastructure-failure") {
|
|
1490
3755
|
return { kind: "infrastructure-failure", detail: dispatched.detail };
|
|
1491
3756
|
}
|
|
@@ -1493,95 +3758,56 @@ var runReviewRound = async (request, overrides = {}) => {
|
|
|
1493
3758
|
return {
|
|
1494
3759
|
kind: "fallback",
|
|
1495
3760
|
harness,
|
|
1496
|
-
round: request.round,
|
|
1497
3761
|
reason: dispatched.reason,
|
|
1498
3762
|
detail: dispatched.detail
|
|
1499
3763
|
};
|
|
1500
3764
|
}
|
|
1501
3765
|
if (dispatched.kind === "launched-failure") {
|
|
1502
|
-
writeTranscript(
|
|
3766
|
+
writeTranscript(reviewDir, dispatched.stdout);
|
|
1503
3767
|
return {
|
|
1504
3768
|
kind: "launched-failure",
|
|
1505
3769
|
harness,
|
|
1506
|
-
round: request.round,
|
|
1507
3770
|
reviewFile,
|
|
1508
3771
|
exitCode: dispatched.exitCode,
|
|
1509
3772
|
detail: `The ${harness} reviewer exited ${dispatched.exitCode}.`
|
|
1510
3773
|
};
|
|
1511
3774
|
}
|
|
1512
|
-
const evaluate = dependencies2.evaluateFindings ?? createFindingsGate(
|
|
3775
|
+
const evaluate = dependencies2.evaluateFindings ?? createFindingsGate();
|
|
1513
3776
|
const findingsGate = await evaluate({
|
|
1514
3777
|
reviewFile,
|
|
1515
3778
|
xsdFile,
|
|
1516
3779
|
planDir,
|
|
1517
|
-
round: request.round,
|
|
1518
3780
|
reviewerStdout: dispatched.stdout ?? "",
|
|
1519
3781
|
deliveryToken
|
|
1520
3782
|
});
|
|
1521
3783
|
if (findingsGate.kind !== "evaluated") {
|
|
1522
|
-
writeTranscript(
|
|
3784
|
+
writeTranscript(reviewDir, dispatched.stdout);
|
|
1523
3785
|
}
|
|
1524
3786
|
return {
|
|
1525
3787
|
kind: "reviewed",
|
|
1526
3788
|
harness,
|
|
1527
|
-
round: request.round,
|
|
1528
3789
|
baseCommit,
|
|
1529
3790
|
reviewFile,
|
|
1530
|
-
reviewFilePresent:
|
|
3791
|
+
reviewFilePresent: fs7.existsSync(reviewFile),
|
|
3792
|
+
verdict: _verdictFor(findingsGate),
|
|
1531
3793
|
findingsGate
|
|
1532
3794
|
};
|
|
1533
3795
|
};
|
|
1534
|
-
var
|
|
1535
|
-
if (
|
|
1536
|
-
return { kind: "
|
|
1537
|
-
}
|
|
1538
|
-
const recorded = `${outcome.recorded} finding(s) were recorded without being applied, of which ${outcome.aboveFloorWithoutSuggestion} cleared both floors but carried no local fix. See ${outcome.findingsFile}.`;
|
|
1539
|
-
if (outcome.actionable === 0) {
|
|
1540
|
-
return {
|
|
1541
|
-
kind: "gate-passed",
|
|
1542
|
-
detail: `No finding cleared the \`${outcome.severityFloor}\` severity floor and the \`${outcome.confidenceFloor}\` confidence floor with a local fix attached, so the review gate passed on round ${round}. ${recorded}`
|
|
1543
|
-
};
|
|
1544
|
-
}
|
|
1545
|
-
if (round >= roundBudget) {
|
|
1546
|
-
return {
|
|
1547
|
-
kind: "budget-exhausted",
|
|
1548
|
-
actionable: outcome.actionable,
|
|
1549
|
-
detail: `Round ${round} of an enforced ${roundBudget}-round budget still reports ${outcome.actionable} actionable finding(s), so the review gate halts with the budget exhausted. The plan stays in \`plans/\` and every round's findings are recorded under its \`review/\` directory. ${recorded}`
|
|
1550
|
-
};
|
|
3796
|
+
var _verdictFor = (outcome2) => {
|
|
3797
|
+
if (outcome2.kind !== "evaluated") {
|
|
3798
|
+
return { kind: "review-failed", detail: outcome2.detail };
|
|
1551
3799
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
nextRound: round + 1,
|
|
1555
|
-
actionable: outcome.actionable,
|
|
1556
|
-
detail: `${outcome.actionable} finding(s) clear both floors and carry a local fix. Dispatch them on the implementer route, re-run POST_EXECUTION in full, then run round ${round + 1} of ${roundBudget}. ${recorded}`
|
|
1557
|
-
};
|
|
1558
|
-
};
|
|
1559
|
-
var runBoundedReviewRound = async (request, overrides = {}) => {
|
|
1560
|
-
const startPath = request.startPath ?? process.cwd();
|
|
1561
|
-
const resolution = resolveReviewContext(
|
|
1562
|
-
startPath,
|
|
1563
|
-
{ ...defaultDependencies2, ...overrides }.validatorAvailable
|
|
1564
|
-
);
|
|
1565
|
-
if (resolution.kind === "ended") return resolution.result;
|
|
1566
|
-
const { mandate } = resolution.context;
|
|
1567
|
-
if (request.round > mandate.roundBudget) {
|
|
3800
|
+
const { counts, findingsFile } = outcome2;
|
|
3801
|
+
if (counts.total === 0) {
|
|
1568
3802
|
return {
|
|
1569
|
-
kind: "
|
|
1570
|
-
|
|
1571
|
-
roundBudget: mandate.roundBudget,
|
|
1572
|
-
roundCeiling: MAX_REVIEW_ROUNDS,
|
|
1573
|
-
mandateNotes: mandate.notes,
|
|
1574
|
-
detail: `Round ${request.round} was requested, but the review gate enforces a ${mandate.roundBudget}-round budget (compiled ceiling ${MAX_REVIEW_ROUNDS}). No reviewer was dispatched. The plan stays in \`plans/\` and the rounds already run are recorded under its \`review/\` directory.`
|
|
3803
|
+
kind: "review-recorded",
|
|
3804
|
+
detail: `The reviewer raised no findings. See ${findingsFile}.`
|
|
1575
3805
|
};
|
|
1576
3806
|
}
|
|
1577
|
-
const
|
|
1578
|
-
if (result.kind !== "reviewed") return result;
|
|
3807
|
+
const byLabel = SEVERITIES.filter((label) => counts[label] > 0).map((label) => `${counts[label]} ${label}`).concat(counts.unlabelled > 0 ? [`${counts.unlabelled} unlabelled`] : []).join(", ");
|
|
1579
3808
|
return {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
roundBudget: mandate.roundBudget,
|
|
1583
|
-
roundCeiling: MAX_REVIEW_ROUNDS,
|
|
1584
|
-
mandateNotes: mandate.notes
|
|
3809
|
+
kind: "review-recorded",
|
|
3810
|
+
detail: `The reviewer raised ${counts.total} finding(s) (${byLabel}). They are recorded, not applied: read them and decide which to act on. See ${findingsFile}.`
|
|
1585
3811
|
};
|
|
1586
3812
|
};
|
|
1587
3813
|
var emit = (result, exitCode) => {
|
|
@@ -1592,34 +3818,23 @@ var emit = (result, exitCode) => {
|
|
|
1592
3818
|
var _exitCodeFor = (result) => {
|
|
1593
3819
|
if (result.kind === "infrastructure-failure") return 2;
|
|
1594
3820
|
if (result.kind === "launched-failure") return 1;
|
|
1595
|
-
if (result.kind === "
|
|
1596
|
-
if (result.kind === "reviewed" && result.decision !== void 0) {
|
|
1597
|
-
return result.decision.kind === "budget-exhausted" || result.decision.kind === "round-failed" ? 1 : 0;
|
|
1598
|
-
}
|
|
3821
|
+
if (result.kind === "reviewed") return result.verdict.kind === "review-failed" ? 1 : 0;
|
|
1599
3822
|
return 0;
|
|
1600
3823
|
};
|
|
1601
3824
|
var main = async (startPath = process.cwd()) => {
|
|
1602
|
-
const [planArg, harnessArg
|
|
3825
|
+
const [planArg, harnessArg] = process.argv.slice(2);
|
|
1603
3826
|
if (!planArg || !harnessArg || !SUPPORTED_HARNESSES.includes(harnessArg)) {
|
|
1604
3827
|
emit(
|
|
1605
3828
|
{
|
|
1606
3829
|
kind: "infrastructure-failure",
|
|
1607
|
-
detail: `Usage: code-review.cjs <plan-id-or-path> <current-harness
|
|
3830
|
+
detail: `Usage: code-review.cjs <plan-id-or-path> <current-harness>. <current-harness> is one of: ${SUPPORTED_HARNESSES.join(", ")}.`
|
|
1608
3831
|
},
|
|
1609
3832
|
2
|
|
1610
3833
|
);
|
|
1611
3834
|
}
|
|
1612
|
-
const
|
|
1613
|
-
if (!Number.isInteger(round) || round < 1) {
|
|
1614
|
-
emit(
|
|
1615
|
-
{ kind: "infrastructure-failure", detail: `Round "${roundArg}" is not a positive integer.` },
|
|
1616
|
-
2
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
const result = await runBoundedReviewRound({
|
|
3835
|
+
const result = await runReview({
|
|
1620
3836
|
plan: planArg,
|
|
1621
3837
|
currentHarness: harnessArg,
|
|
1622
|
-
round,
|
|
1623
3838
|
startPath
|
|
1624
3839
|
});
|
|
1625
3840
|
emit(result, _exitCodeFor(result));
|
|
@@ -1637,18 +3852,19 @@ if (require.main === module) {
|
|
|
1637
3852
|
}
|
|
1638
3853
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1639
3854
|
0 && (module.exports = {
|
|
1640
|
-
MAX_REVIEW_ROUNDS,
|
|
1641
|
-
_decideRound,
|
|
1642
3855
|
_exitCodeFor,
|
|
1643
3856
|
_extractReviewDocument,
|
|
1644
3857
|
_makeDeliveryToken,
|
|
1645
3858
|
_readBaseCommit,
|
|
1646
3859
|
_readCumulativeDiff,
|
|
1647
|
-
|
|
3860
|
+
_verdictFor,
|
|
1648
3861
|
buildReviewerPrompt,
|
|
1649
3862
|
createFindingsGate,
|
|
1650
3863
|
main,
|
|
1651
|
-
|
|
1652
|
-
runBoundedReviewRound,
|
|
1653
|
-
runReviewRound
|
|
3864
|
+
runReview
|
|
1654
3865
|
});
|
|
3866
|
+
/*! Bundled license information:
|
|
3867
|
+
|
|
3868
|
+
js-yaml/dist/js-yaml.mjs:
|
|
3869
|
+
(*! js-yaml 5.2.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
3870
|
+
*/
|