strikethroo 3.18.0 → 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-BlSNa2QY.js → arc-XmjVSUrZ.js} +1 -1
- package/dist-web/assets/{architectureDiagram-3BPJPVTR-CPcCF2a4.js → architectureDiagram-3BPJPVTR-BkIMNPZQ.js} +1 -1
- package/dist-web/assets/{blockDiagram-GPEHLZMM-ECDR0edZ.js → blockDiagram-GPEHLZMM-CIUhAyCy.js} +1 -1
- package/dist-web/assets/{c4Diagram-AAUBKEIU-oM3VnEAQ.js → c4Diagram-AAUBKEIU-DHmyXhPl.js} +1 -1
- package/dist-web/assets/channel-BluR9kJ8.js +1 -0
- package/dist-web/assets/{chunk-2J33WTMH-DHk5SJLz.js → chunk-2J33WTMH-CsadzJpE.js} +1 -1
- package/dist-web/assets/{chunk-4BX2VUAB-CjBwgkMu.js → chunk-4BX2VUAB-rdZMTiJd.js} +1 -1
- package/dist-web/assets/{chunk-55IACEB6-D95zqyiV.js → chunk-55IACEB6-BFgbJmlS.js} +1 -1
- package/dist-web/assets/{chunk-727SXJPM-DCCPRUfv.js → chunk-727SXJPM-CaGOdOo-.js} +1 -1
- package/dist-web/assets/{chunk-AQP2D5EJ-qur7KQyD.js → chunk-AQP2D5EJ-Dj1Z_buE.js} +1 -1
- package/dist-web/assets/{chunk-FMBD7UC4-D46Su7Fv.js → chunk-FMBD7UC4-ByPFO0XR.js} +1 -1
- package/dist-web/assets/{chunk-ND2GUHAM-BioGsqxt.js → chunk-ND2GUHAM-CRT0WqT3.js} +1 -1
- package/dist-web/assets/{chunk-QZHKN3VN-C8LdDiqn.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-ccY03BRh.js → cose-bilkent-S5V4N54A-8sFxzH_F.js} +1 -1
- package/dist-web/assets/{dagre-BM42HDAG-BYLmCViB.js → dagre-BM42HDAG-CXKxHlld.js} +1 -1
- package/dist-web/assets/{diagram-2AECGRRQ-DTvenvXR.js → diagram-2AECGRRQ-DtcDQjmq.js} +1 -1
- package/dist-web/assets/{diagram-5GNKFQAL-CCzsYDmr.js → diagram-5GNKFQAL-C5z5tfjo.js} +1 -1
- package/dist-web/assets/{diagram-KO2AKTUF-QSff7J_V.js → diagram-KO2AKTUF-DzGoK3-W.js} +1 -1
- package/dist-web/assets/{diagram-LMA3HP47-CVqlEmu2.js → diagram-LMA3HP47-CClXYqlA.js} +1 -1
- package/dist-web/assets/{diagram-OG6HWLK6-dBVz-I46.js → diagram-OG6HWLK6-CCOd6tb5.js} +1 -1
- package/dist-web/assets/{erDiagram-TEJ5UH35-B_y4ftNu.js → erDiagram-TEJ5UH35-DyUNZPGi.js} +1 -1
- package/dist-web/assets/{flowDiagram-I6XJVG4X-M410hT_n.js → flowDiagram-I6XJVG4X-DWE9txcF.js} +1 -1
- package/dist-web/assets/{ganttDiagram-6RSMTGT7-qiri2OJa.js → ganttDiagram-6RSMTGT7-B-OtEqRy.js} +1 -1
- package/dist-web/assets/{gitGraphDiagram-PVQCEYII-FqGGBobG.js → gitGraphDiagram-PVQCEYII-F9vafo91.js} +1 -1
- package/dist-web/assets/{index-BaFSLlgl.js → index-CwMlRsHB.js} +1 -1
- package/dist-web/assets/{index-DrUIu0u6.js → index-D_5U356C.js} +4 -4
- package/dist-web/assets/{index-1SV04K_c.js → index-DahCY-9n.js} +1 -1
- package/dist-web/assets/{infoDiagram-5YYISTIA-CczHqRr1.js → infoDiagram-5YYISTIA-BqiJJ4mQ.js} +1 -1
- package/dist-web/assets/{ishikawaDiagram-YF4QCWOH-ty1DRy6n.js → ishikawaDiagram-YF4QCWOH-BJhigZjk.js} +1 -1
- package/dist-web/assets/{journeyDiagram-JHISSGLW-D_JYvt6i.js → journeyDiagram-JHISSGLW-DbnfMDvR.js} +1 -1
- package/dist-web/assets/{kanban-definition-UN3LZRKU-CT67nUTK.js → kanban-definition-UN3LZRKU-CWbRbJ6f.js} +1 -1
- package/dist-web/assets/{linear-B1HaE_t1.js → linear-D3Xq7OUM.js} +1 -1
- package/dist-web/assets/{mermaid.core-Dumx_iKV.js → mermaid.core-CT0YFN3s.js} +4 -4
- package/dist-web/assets/{mindmap-definition-RKZ34NQL-CVulJo63.js → mindmap-definition-RKZ34NQL-D6AZLTGR.js} +1 -1
- package/dist-web/assets/{pieDiagram-4H26LBE5-C1yD5ntZ.js → pieDiagram-4H26LBE5-NGxhfGd1.js} +1 -1
- package/dist-web/assets/{quadrantDiagram-W4KKPZXB-B7PoiM8c.js → quadrantDiagram-W4KKPZXB-jNVzj-DZ.js} +1 -1
- package/dist-web/assets/{requirementDiagram-4Y6WPE33-COvHb3Mv.js → requirementDiagram-4Y6WPE33-cxYkgHCv.js} +1 -1
- package/dist-web/assets/{sankeyDiagram-5OEKKPKP-CAnwm5-J.js → sankeyDiagram-5OEKKPKP-CO7LMTUX.js} +1 -1
- package/dist-web/assets/{sequenceDiagram-3UESZ5HK-C2KFLIUq.js → sequenceDiagram-3UESZ5HK-C8d8VIsZ.js} +1 -1
- package/dist-web/assets/{stateDiagram-AJRCARHV-CqmhS5P6.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-DvPre9M_.js → timeline-definition-PNZ67QCA-Bef04SiL.js} +1 -1
- package/dist-web/assets/{vennDiagram-CIIHVFJN-Top6i7KH.js → vennDiagram-CIIHVFJN-DlZHmyp0.js} +1 -1
- package/dist-web/assets/{wardley-L42UT6IY-_jVLsWqf.js → wardley-L42UT6IY-ChkIPtT_.js} +1 -1
- package/dist-web/assets/{wardleyDiagram-YWT4CUSO-BV4e5mP6.js → wardleyDiagram-YWT4CUSO-D67J0WGX.js} +1 -1
- package/dist-web/assets/{xychartDiagram-2RQKCTM6-Bn1hw4Jk.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/scripts/code-review.cjs +2710 -264
- 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/scripts/dispatch-task-execution.cjs +420 -213
- package/templates/strikethroo/config/config.yaml +95 -6
- package/templates/strikethroo/gitignore +13 -10
- package/dist-web/assets/channel-CmU4mBgT.js +0 -1
- package/dist-web/assets/classDiagram-4FO5ZUOK-D_FMKQsB.js +0 -1
- package/dist-web/assets/classDiagram-v2-Q7XG4LA2-D_FMKQsB.js +0 -1
- package/dist-web/assets/stateDiagram-v2-BHNVJYJU-C3Kw8ZDR.js +0 -1
|
@@ -47,8 +47,8 @@ __export(code_review_exports, {
|
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(code_review_exports);
|
|
49
49
|
var crypto = __toESM(require("crypto"));
|
|
50
|
-
var
|
|
51
|
-
var
|
|
50
|
+
var fs7 = __toESM(require("fs"));
|
|
51
|
+
var path8 = __toESM(require("path"));
|
|
52
52
|
|
|
53
53
|
// src/types.ts
|
|
54
54
|
var SUPPORTED_HARNESSES = [
|
|
@@ -195,106 +195,2455 @@ var scanPlanDir = (planDirPath, dirName, isArchive) => {
|
|
|
195
195
|
} catch (_err) {
|
|
196
196
|
return [];
|
|
197
197
|
}
|
|
198
|
-
});
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
var getAllPlans = (taskManagerRoot) => {
|
|
201
|
+
const sources = [
|
|
202
|
+
{ dir: path2.join(taskManagerRoot, "plans"), isArchive: false },
|
|
203
|
+
{ dir: path2.join(taskManagerRoot, "archive"), isArchive: true }
|
|
204
|
+
];
|
|
205
|
+
return sources.flatMap(({ dir, isArchive }) => {
|
|
206
|
+
if (!fs2.existsSync(dir)) return [];
|
|
207
|
+
let entries;
|
|
208
|
+
try {
|
|
209
|
+
entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
210
|
+
} catch (_err) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
return entries.filter((e) => e.isDirectory()).flatMap((e) => scanPlanDir(path2.join(dir, e.name), e.name, isArchive));
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/skill-scripts/shared/plan-resolve.ts
|
|
218
|
+
var isValidRootDir = (strikethrooPath) => {
|
|
219
|
+
try {
|
|
220
|
+
if (!fs3.existsSync(strikethrooPath)) return false;
|
|
221
|
+
if (!fs3.lstatSync(strikethrooPath).isDirectory()) return false;
|
|
222
|
+
const metadataPath = path3.join(strikethrooPath, ".init-metadata.json");
|
|
223
|
+
if (!fs3.existsSync(metadataPath)) return false;
|
|
224
|
+
const metadata = JSON.parse(fs3.readFileSync(metadataPath, "utf8"));
|
|
225
|
+
return metadata && typeof metadata === "object" && "version" in metadata;
|
|
226
|
+
} catch (_err) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var checkStandardRootShortcut = (filePath) => {
|
|
231
|
+
const planDir = path3.dirname(filePath);
|
|
232
|
+
const parentDir = path3.dirname(planDir);
|
|
233
|
+
const possibleRoot = path3.dirname(parentDir);
|
|
234
|
+
const parentBase = path3.basename(parentDir);
|
|
235
|
+
if (parentBase !== "plans" && parentBase !== "archive") return null;
|
|
236
|
+
if (path3.basename(possibleRoot) !== "strikethroo") return null;
|
|
237
|
+
const dotAiDir = path3.dirname(possibleRoot);
|
|
238
|
+
if (path3.basename(dotAiDir) !== ".ai") return null;
|
|
239
|
+
return isValidRootDir(possibleRoot) ? possibleRoot : null;
|
|
240
|
+
};
|
|
241
|
+
var resolveByPath = (absolutePath) => {
|
|
242
|
+
let content;
|
|
243
|
+
try {
|
|
244
|
+
content = fs3.readFileSync(absolutePath, "utf8");
|
|
245
|
+
} catch (_err) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
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
|
|
199
2451
|
};
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
return entries.filter((e) => e.isDirectory()).flatMap((e) => scanPlanDir(path2.join(dir, e.name), e.name, isArchive));
|
|
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
|
|
214
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
|
|
215
2500
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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: () => {
|
|
228
2521
|
}
|
|
229
2522
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
+
});
|
|
240
2546
|
};
|
|
241
|
-
var
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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.`);
|
|
246
2556
|
return null;
|
|
247
2557
|
}
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (!
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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);
|
|
258
2580
|
};
|
|
259
|
-
var
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
+
}
|
|
268
2590
|
return {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
2591
|
+
kind: "invalid",
|
|
2592
|
+
errors: [
|
|
2593
|
+
`config.yaml could not be read: ${error instanceof Error ? error.message : String(error)}`
|
|
2594
|
+
]
|
|
273
2595
|
};
|
|
274
2596
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
+
};
|
|
284
2607
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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) };
|
|
288
2642
|
};
|
|
289
2643
|
|
|
290
|
-
// src/skill-scripts/shared/harness-availability.ts
|
|
291
|
-
var fs5 = __toESM(require("fs"));
|
|
292
|
-
var path5 = __toESM(require("path"));
|
|
293
|
-
var import_child_process3 = require("child_process");
|
|
294
|
-
|
|
295
2644
|
// src/skill-scripts/shared/external-dispatch.ts
|
|
296
|
-
var
|
|
297
|
-
var
|
|
2645
|
+
var fs5 = __toESM(require("fs"));
|
|
2646
|
+
var path6 = __toESM(require("path"));
|
|
298
2647
|
var import_child_process2 = require("child_process");
|
|
299
2648
|
var command = (executable, argv, request) => ({
|
|
300
2649
|
executable,
|
|
@@ -310,6 +2659,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
310
2659
|
"claude",
|
|
311
2660
|
[
|
|
312
2661
|
"-p",
|
|
2662
|
+
...request.cliArgs,
|
|
313
2663
|
...modelArgv(request.model),
|
|
314
2664
|
...request.reasoningEffort === void 0 ? [] : ["--effort", request.reasoningEffort]
|
|
315
2665
|
],
|
|
@@ -323,6 +2673,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
323
2673
|
"codex",
|
|
324
2674
|
[
|
|
325
2675
|
"exec",
|
|
2676
|
+
...request.cliArgs,
|
|
326
2677
|
...modelArgv(request.model),
|
|
327
2678
|
...request.reasoningEffort === void 0 ? [] : ["--config", `model_reasoning_effort=${request.reasoningEffort}`],
|
|
328
2679
|
"-"
|
|
@@ -333,19 +2684,23 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
333
2684
|
},
|
|
334
2685
|
cursor: {
|
|
335
2686
|
executable: "cursor-agent",
|
|
336
|
-
buildCommand: (request) => command(
|
|
2687
|
+
buildCommand: (request) => command(
|
|
2688
|
+
"cursor-agent",
|
|
2689
|
+
["--print", ...request.cliArgs, ...modelArgv(request.model)],
|
|
2690
|
+
request
|
|
2691
|
+
),
|
|
337
2692
|
authenticationArgv: () => ["status"]
|
|
338
2693
|
},
|
|
339
2694
|
gemini: {
|
|
340
2695
|
executable: "gemini",
|
|
341
2696
|
// The empty positional prompt is the existing contract — content travels on
|
|
342
2697
|
// stdin. It stays even when the model pair is dropped.
|
|
343
|
-
buildCommand: (request) => command("gemini", ["--prompt", "", ...modelArgv(request.model)], request),
|
|
2698
|
+
buildCommand: (request) => command("gemini", ["--prompt", "", ...request.cliArgs, ...modelArgv(request.model)], request),
|
|
344
2699
|
authenticationArgv: () => ["auth", "status"]
|
|
345
2700
|
},
|
|
346
2701
|
copilot: {
|
|
347
2702
|
executable: "copilot",
|
|
348
|
-
buildCommand: (request) => command("copilot", ["-p", "", ...modelArgv(request.model)], request),
|
|
2703
|
+
buildCommand: (request) => command("copilot", ["-p", "", ...request.cliArgs, ...modelArgv(request.model)], request),
|
|
349
2704
|
authenticationArgv: () => ["auth", "status"]
|
|
350
2705
|
},
|
|
351
2706
|
opencode: {
|
|
@@ -354,6 +2709,7 @@ var EXTERNAL_HARNESS_ADAPTERS = {
|
|
|
354
2709
|
"opencode",
|
|
355
2710
|
[
|
|
356
2711
|
"run",
|
|
2712
|
+
...request.cliArgs,
|
|
357
2713
|
...modelArgv(request.model),
|
|
358
2714
|
...request.reasoningEffort === void 0 ? [] : ["--variant", request.reasoningEffort],
|
|
359
2715
|
"-"
|
|
@@ -369,25 +2725,28 @@ if (adapterKeys.join("\0") !== harnessKeys.join("\0")) {
|
|
|
369
2725
|
throw new Error("External harness adapter registry does not cover SUPPORTED_HARNESSES exactly.");
|
|
370
2726
|
}
|
|
371
2727
|
var reviewCommandRequest = (request) => ({
|
|
2728
|
+
cliArgs: request.cliArgs ?? [],
|
|
372
2729
|
workspace: request.workspace,
|
|
373
2730
|
prompt: request.prompt
|
|
374
2731
|
});
|
|
375
|
-
var executableOnPath = (executable) => (process.env.PATH ?? "").split(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
}
|
|
382
2741
|
}
|
|
383
|
-
|
|
2742
|
+
);
|
|
384
2743
|
var CAPTURED_STDOUT_LIMIT = 262144;
|
|
385
2744
|
var STDIO_SLOTS = {
|
|
386
2745
|
ignore: { stdout: "ignore" },
|
|
387
2746
|
inherit: { stdout: "inherit" },
|
|
388
2747
|
capture: { stdout: "pipe" }
|
|
389
2748
|
};
|
|
390
|
-
var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Promise((
|
|
2749
|
+
var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Promise((resolve4, reject) => {
|
|
391
2750
|
let settled = false;
|
|
392
2751
|
const fail = (error) => {
|
|
393
2752
|
if (settled) return;
|
|
@@ -419,7 +2778,7 @@ var runProcess = (executable, argv, cwd, stdin, outputMode = "ignore") => new Pr
|
|
|
419
2778
|
child.once("close", (code) => {
|
|
420
2779
|
if (settled) return;
|
|
421
2780
|
settled = true;
|
|
422
|
-
|
|
2781
|
+
resolve4({
|
|
423
2782
|
exitCode: code ?? 1,
|
|
424
2783
|
...outputMode === "capture" ? { stdout: captured } : {}
|
|
425
2784
|
});
|
|
@@ -470,11 +2829,12 @@ var prepareLaunch = async (harness, input, active, guard) => {
|
|
|
470
2829
|
}
|
|
471
2830
|
const blocked = guard?.();
|
|
472
2831
|
if (blocked) return blocked;
|
|
473
|
-
|
|
2832
|
+
const executable = adapter.executable;
|
|
2833
|
+
if (!active.executableExists(executable)) {
|
|
474
2834
|
return {
|
|
475
2835
|
kind: "fallback",
|
|
476
2836
|
reason: "executable-unavailable",
|
|
477
|
-
detail: `${
|
|
2837
|
+
detail: `${executable} is unavailable.`
|
|
478
2838
|
};
|
|
479
2839
|
}
|
|
480
2840
|
const commandSpec = adapter.buildCommand(input);
|
|
@@ -508,143 +2868,166 @@ var dispatchReview = async (request, overrides = {}) => {
|
|
|
508
2868
|
};
|
|
509
2869
|
|
|
510
2870
|
// src/skill-scripts/shared/harness-availability.ts
|
|
511
|
-
var AVAILABILITY_REGISTRY_VERSION =
|
|
2871
|
+
var AVAILABILITY_REGISTRY_VERSION = 3;
|
|
512
2872
|
var AVAILABLE_TTL_MS = 30 * 60 * 1e3;
|
|
513
2873
|
var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
|
|
514
2874
|
var PROBE_TIMEOUT_MS = 2e4;
|
|
515
|
-
var AVAILABILITY_CACHE_RELATIVE_PATH =
|
|
516
|
-
var
|
|
517
|
-
var
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
},
|
|
524
|
-
codex: {
|
|
525
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
526
|
-
executable: "codex",
|
|
527
|
-
buildCommand: (cwd) => probeCommand("codex", ["exec", "-"], cwd)
|
|
528
|
-
},
|
|
529
|
-
cursor: {
|
|
530
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
531
|
-
executable: "cursor-agent",
|
|
532
|
-
buildCommand: (cwd) => probeCommand("cursor-agent", ["--print"], cwd)
|
|
533
|
-
},
|
|
534
|
-
gemini: {
|
|
535
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
536
|
-
executable: "gemini",
|
|
537
|
-
buildCommand: (cwd) => probeCommand("gemini", ["--prompt", PROBE_PROMPT], cwd, "")
|
|
538
|
-
},
|
|
539
|
-
copilot: {
|
|
540
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
541
|
-
executable: "copilot",
|
|
542
|
-
buildCommand: (cwd) => probeCommand("copilot", ["-p", PROBE_PROMPT], cwd, "")
|
|
543
|
-
},
|
|
544
|
-
opencode: {
|
|
545
|
-
version: AVAILABILITY_REGISTRY_VERSION,
|
|
546
|
-
executable: "opencode",
|
|
547
|
-
buildCommand: (cwd) => probeCommand("opencode", ["run", "-"], cwd)
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
var registryKeys = Object.keys(HARNESS_AVAILABILITY_REGISTRY).sort();
|
|
551
|
-
var harnessKeys2 = [...SUPPORTED_HARNESSES].sort();
|
|
552
|
-
if (registryKeys.join("\0") !== harnessKeys2.join("\0")) {
|
|
553
|
-
throw new Error("Harness availability registry does not cover SUPPORTED_HARNESSES exactly.");
|
|
554
|
-
}
|
|
555
|
-
for (const harness of SUPPORTED_HARNESSES) {
|
|
556
|
-
const availability = HARNESS_AVAILABILITY_REGISTRY[harness];
|
|
557
|
-
if (availability.executable !== EXTERNAL_HARNESS_ADAPTERS[harness].executable) {
|
|
558
|
-
throw new Error(`Harness availability executable disagrees with the ${harness} adapter.`);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
var safeReason = (value, fallback) => {
|
|
562
|
-
if (typeof value !== "string") return fallback;
|
|
563
|
-
const firstLine = value.replace(/[\r\n]+/g, " ").trim().slice(0, 200);
|
|
564
|
-
return firstLine || fallback;
|
|
565
|
-
};
|
|
566
|
-
var isOutcome = (value) => {
|
|
567
|
-
if (!value || typeof value !== "object") return false;
|
|
568
|
-
const entry = value;
|
|
569
|
-
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";
|
|
570
|
-
};
|
|
571
|
-
var readCache = (cachePath) => {
|
|
572
|
-
try {
|
|
573
|
-
const parsed = JSON.parse(fs5.readFileSync(cachePath, "utf8"));
|
|
574
|
-
if (!parsed || typeof parsed !== "object") throw new Error("invalid cache");
|
|
575
|
-
const record = parsed;
|
|
576
|
-
if (record.version !== 1 || !record.harnesses || typeof record.harnesses !== "object") {
|
|
577
|
-
throw new Error("invalid cache");
|
|
578
|
-
}
|
|
579
|
-
const harnesses = {};
|
|
580
|
-
for (const harness of SUPPORTED_HARNESSES) {
|
|
581
|
-
const candidate = record.harnesses[harness];
|
|
582
|
-
if (isOutcome(candidate)) harnesses[harness] = candidate;
|
|
583
|
-
}
|
|
584
|
-
return { version: 1, harnesses };
|
|
585
|
-
} catch {
|
|
586
|
-
return { version: 1, harnesses: {} };
|
|
587
|
-
}
|
|
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
|
+
};
|
|
588
2883
|
};
|
|
589
|
-
var
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
fs5.unlinkSync(temporary);
|
|
609
|
-
} 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
|
+
}
|
|
610
2903
|
}
|
|
611
2904
|
}
|
|
2905
|
+
return void 0;
|
|
612
2906
|
};
|
|
613
|
-
var runProbe = (command2, timeoutMs) => new Promise((
|
|
2907
|
+
var runProbe = (command2, timeoutMs) => new Promise((resolve4) => {
|
|
614
2908
|
let settled = false;
|
|
615
|
-
let
|
|
2909
|
+
let timedOut = false;
|
|
616
2910
|
const finish = (result) => {
|
|
617
2911
|
if (settled) return;
|
|
618
2912
|
settled = true;
|
|
619
|
-
|
|
2913
|
+
resolve4(result);
|
|
620
2914
|
};
|
|
621
2915
|
const child = (0, import_child_process3.spawn)(command2.executable, command2.argv, {
|
|
622
2916
|
cwd: command2.cwd,
|
|
623
2917
|
shell: false,
|
|
624
|
-
stdio: ["pipe", "ignore", "
|
|
2918
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
625
2919
|
});
|
|
626
2920
|
const timer = setTimeout(() => {
|
|
2921
|
+
timedOut = true;
|
|
627
2922
|
child.kill("SIGKILL");
|
|
628
|
-
finish({ exitCode: 1, timedOut: true, detail: "Probe timed out." });
|
|
629
2923
|
}, timeoutMs);
|
|
630
|
-
child.
|
|
631
|
-
if (diagnostics.length < 400) diagnostics += String(chunk).slice(0, 400 - diagnostics.length);
|
|
632
|
-
});
|
|
633
|
-
child.once("error", (error) => {
|
|
2924
|
+
child.once("error", () => {
|
|
634
2925
|
clearTimeout(timer);
|
|
635
|
-
finish({ exitCode: 1,
|
|
2926
|
+
finish({ exitCode: 1, timedOut });
|
|
636
2927
|
});
|
|
637
2928
|
child.once("close", (code) => {
|
|
638
2929
|
clearTimeout(timer);
|
|
639
|
-
finish({ exitCode: code ?? 1,
|
|
2930
|
+
finish({ exitCode: code ?? 1, timedOut });
|
|
640
2931
|
});
|
|
641
2932
|
child.stdin?.on("error", () => void 0);
|
|
642
2933
|
child.stdin?.end(command2.stdin);
|
|
643
2934
|
});
|
|
644
2935
|
var defaultDependencies = {
|
|
645
2936
|
now: Date.now,
|
|
2937
|
+
resolveExecutable,
|
|
646
2938
|
runProbe
|
|
647
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
|
+
};
|
|
648
3031
|
var checkHarnessAvailability = async (request, overrides = {}) => {
|
|
649
3032
|
const active = { ...defaultDependencies, ...overrides };
|
|
650
3033
|
const now = active.now();
|
|
@@ -659,38 +3042,76 @@ var checkHarnessAvailability = async (request, overrides = {}) => {
|
|
|
659
3042
|
};
|
|
660
3043
|
}
|
|
661
3044
|
const harness = request.harness;
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
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.");
|
|
665
3047
|
const definition = HARNESS_AVAILABILITY_REGISTRY[harness];
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const reason = available ? "Harness probe succeeded." : safeReason(
|
|
674
|
-
probe.detail,
|
|
675
|
-
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
|
|
676
3055
|
);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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;
|
|
684
3067
|
};
|
|
3068
|
+
const probeWorkspace = initializeProbeWorkspace();
|
|
3069
|
+
if (!probeWorkspace) {
|
|
3070
|
+
return complete(outcome(harness, false, now, "Harness readiness check failed."));
|
|
3071
|
+
}
|
|
685
3072
|
try {
|
|
686
|
-
|
|
687
|
-
|
|
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 });
|
|
688
3094
|
}
|
|
689
|
-
return outcome;
|
|
690
3095
|
};
|
|
691
3096
|
|
|
692
3097
|
// src/skill-scripts/shared/harness-discovery.ts
|
|
693
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
|
+
}
|
|
694
3115
|
const outcomes = await Promise.all(
|
|
695
3116
|
SUPPORTED_HARNESSES.map(async (harness) => {
|
|
696
3117
|
try {
|
|
@@ -699,7 +3120,8 @@ var discoverHarnesses = async (request, overrides = {}) => {
|
|
|
699
3120
|
strikethrooRoot: request.strikethrooRoot,
|
|
700
3121
|
workspace: request.workspace,
|
|
701
3122
|
harness,
|
|
702
|
-
currentHarness: request.currentHarness
|
|
3123
|
+
currentHarness: request.currentHarness,
|
|
3124
|
+
invocation: configuration.config[harness]
|
|
703
3125
|
},
|
|
704
3126
|
overrides
|
|
705
3127
|
);
|
|
@@ -718,10 +3140,13 @@ var discoverHarnesses = async (request, overrides = {}) => {
|
|
|
718
3140
|
);
|
|
719
3141
|
const reviewerCandidates = SUPPORTED_HARNESSES.filter((harness) => {
|
|
720
3142
|
if (harness === request.currentHarness) return false;
|
|
721
|
-
const
|
|
722
|
-
return
|
|
3143
|
+
const outcome2 = outcomes.find((candidate) => candidate.harness === harness);
|
|
3144
|
+
return outcome2?.available === true;
|
|
723
3145
|
});
|
|
724
|
-
|
|
3146
|
+
const reviewerInvocations = Object.fromEntries(
|
|
3147
|
+
reviewerCandidates.map((harness) => [harness, { cliArgs: configuration.config[harness].cliArgs }])
|
|
3148
|
+
);
|
|
3149
|
+
return { outcomes, reviewerCandidates, reviewerInvocations };
|
|
725
3150
|
};
|
|
726
3151
|
|
|
727
3152
|
// src/skill-scripts/shared/review-findings.ts
|
|
@@ -731,13 +3156,13 @@ var CONFIDENCES = ["high", "medium", "low"];
|
|
|
731
3156
|
var XMLLINT_TIMEOUT_MS = 3e4;
|
|
732
3157
|
var isSeverity = (value) => SEVERITIES.includes(value);
|
|
733
3158
|
var isConfidence = (value) => CONFIDENCES.includes(value);
|
|
734
|
-
var validateAgainstSchema = (xsdFile, xmlFile, timeoutMs = XMLLINT_TIMEOUT_MS) => new Promise((
|
|
3159
|
+
var validateAgainstSchema = (xsdFile, xmlFile, timeoutMs = XMLLINT_TIMEOUT_MS) => new Promise((resolve4) => {
|
|
735
3160
|
let settled = false;
|
|
736
3161
|
let diagnostics = "";
|
|
737
3162
|
const finish = (result) => {
|
|
738
3163
|
if (settled) return;
|
|
739
3164
|
settled = true;
|
|
740
|
-
|
|
3165
|
+
resolve4(result);
|
|
741
3166
|
};
|
|
742
3167
|
const child = (0, import_child_process4.spawn)("xmllint", ["--nonet", "--schema", xsdFile, xmlFile, "--noout"], {
|
|
743
3168
|
shell: false,
|
|
@@ -931,8 +3356,8 @@ var countFindings = (findings) => {
|
|
|
931
3356
|
};
|
|
932
3357
|
|
|
933
3358
|
// src/skill-scripts/code-review.ts
|
|
934
|
-
var HOOK_RELATIVE_PATH =
|
|
935
|
-
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");
|
|
936
3361
|
var REVIEW_DIR_NAME = "review";
|
|
937
3362
|
var BASE_COMMIT_FILE_NAME = "base-commit.json";
|
|
938
3363
|
var REVIEW_FILE_NAME = "review.xml";
|
|
@@ -942,7 +3367,7 @@ var SHA_RE = /^[0-9a-f]{40}$/i;
|
|
|
942
3367
|
var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
943
3368
|
var readFileOrNull = (filePath) => {
|
|
944
3369
|
try {
|
|
945
|
-
return
|
|
3370
|
+
return fs7.readFileSync(filePath, "utf8");
|
|
946
3371
|
} catch {
|
|
947
3372
|
return null;
|
|
948
3373
|
}
|
|
@@ -950,18 +3375,18 @@ var readFileOrNull = (filePath) => {
|
|
|
950
3375
|
var writeTranscript = (reviewDir, transcript) => {
|
|
951
3376
|
if (transcript === void 0 || transcript === "") return;
|
|
952
3377
|
try {
|
|
953
|
-
|
|
954
|
-
|
|
3378
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3379
|
+
fs7.writeFileSync(path8.join(reviewDir, TRANSCRIPT_FILE_NAME), transcript, "utf8");
|
|
955
3380
|
} catch {
|
|
956
3381
|
}
|
|
957
3382
|
};
|
|
958
3383
|
var createFindingsGate = () => async (context) => {
|
|
959
|
-
const reviewDir =
|
|
960
|
-
const findingsFile =
|
|
3384
|
+
const reviewDir = path8.dirname(context.reviewFile);
|
|
3385
|
+
const findingsFile = path8.join(reviewDir, FINDINGS_FILE_NAME);
|
|
961
3386
|
const record = (payload) => {
|
|
962
3387
|
try {
|
|
963
|
-
|
|
964
|
-
|
|
3388
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3389
|
+
fs7.writeFileSync(findingsFile, `${JSON.stringify(payload, null, 2)}
|
|
965
3390
|
`, "utf8");
|
|
966
3391
|
} catch (error) {
|
|
967
3392
|
throw new Error(
|
|
@@ -977,8 +3402,8 @@ var createFindingsGate = () => async (context) => {
|
|
|
977
3402
|
return { kind: "findings-absent", detail };
|
|
978
3403
|
}
|
|
979
3404
|
try {
|
|
980
|
-
|
|
981
|
-
|
|
3405
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
3406
|
+
fs7.writeFileSync(
|
|
982
3407
|
context.reviewFile,
|
|
983
3408
|
delivered.endsWith("\n") ? delivered : `${delivered}
|
|
984
3409
|
`,
|
|
@@ -1081,7 +3506,7 @@ var defaultDependencies2 = {
|
|
|
1081
3506
|
validatorAvailable: () => executableOnPath("xmllint")
|
|
1082
3507
|
};
|
|
1083
3508
|
var readReviewerSkill = () => {
|
|
1084
|
-
const skillFile =
|
|
3509
|
+
const skillFile = path8.resolve(__dirname, "..", "SKILL.md");
|
|
1085
3510
|
const content = readFileOrNull(skillFile);
|
|
1086
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;
|
|
1087
3512
|
};
|
|
@@ -1177,7 +3602,7 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1177
3602
|
}
|
|
1178
3603
|
};
|
|
1179
3604
|
}
|
|
1180
|
-
const hookFile =
|
|
3605
|
+
const hookFile = path8.join(strikethrooRoot, HOOK_RELATIVE_PATH);
|
|
1181
3606
|
const hookContent = readFileOrNull(hookFile);
|
|
1182
3607
|
if (hookContent === null) {
|
|
1183
3608
|
return {
|
|
@@ -1197,8 +3622,8 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1197
3622
|
)
|
|
1198
3623
|
};
|
|
1199
3624
|
}
|
|
1200
|
-
const xsdFile =
|
|
1201
|
-
if (!
|
|
3625
|
+
const xsdFile = path8.join(strikethrooRoot, XSD_RELATIVE_PATH);
|
|
3626
|
+
if (!fs7.existsSync(xsdFile)) {
|
|
1202
3627
|
return {
|
|
1203
3628
|
kind: "ended",
|
|
1204
3629
|
result: skip(
|
|
@@ -1220,7 +3645,7 @@ var resolveReviewContext = (startPath, validatorAvailable = () => executableOnPa
|
|
|
1220
3645
|
kind: "resolved",
|
|
1221
3646
|
context: {
|
|
1222
3647
|
strikethrooRoot,
|
|
1223
|
-
workspace:
|
|
3648
|
+
workspace: path8.dirname(path8.dirname(strikethrooRoot)),
|
|
1224
3649
|
hookFile,
|
|
1225
3650
|
hookContent,
|
|
1226
3651
|
xsdFile
|
|
@@ -1241,7 +3666,7 @@ var runReview = async (request, overrides = {}) => {
|
|
|
1241
3666
|
};
|
|
1242
3667
|
}
|
|
1243
3668
|
const { planDir, planFile, planId } = resolved;
|
|
1244
|
-
const baseCommitFile =
|
|
3669
|
+
const baseCommitFile = path8.join(planDir, REVIEW_DIR_NAME, BASE_COMMIT_FILE_NAME);
|
|
1245
3670
|
const baseCommit = _readBaseCommit(baseCommitFile);
|
|
1246
3671
|
if (baseCommit === null) {
|
|
1247
3672
|
return skip(
|
|
@@ -1254,6 +3679,14 @@ var runReview = async (request, overrides = {}) => {
|
|
|
1254
3679
|
workspace,
|
|
1255
3680
|
currentHarness: request.currentHarness
|
|
1256
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
|
+
}
|
|
1257
3690
|
const harness = discovery.reviewerCandidates[0];
|
|
1258
3691
|
if (harness === void 0) {
|
|
1259
3692
|
return skip(
|
|
@@ -1274,20 +3707,20 @@ var runReview = async (request, overrides = {}) => {
|
|
|
1274
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.`
|
|
1275
3708
|
);
|
|
1276
3709
|
}
|
|
1277
|
-
const reviewDir =
|
|
1278
|
-
const reviewFile =
|
|
3710
|
+
const reviewDir = path8.join(planDir, REVIEW_DIR_NAME);
|
|
3711
|
+
const reviewFile = path8.join(reviewDir, REVIEW_FILE_NAME);
|
|
1279
3712
|
try {
|
|
1280
|
-
|
|
3713
|
+
fs7.mkdirSync(reviewDir, { recursive: true });
|
|
1281
3714
|
} catch (error) {
|
|
1282
3715
|
return {
|
|
1283
3716
|
kind: "infrastructure-failure",
|
|
1284
3717
|
detail: `Could not create the review directory ${reviewDir}: ${errorMessage2(error)}`
|
|
1285
3718
|
};
|
|
1286
3719
|
}
|
|
1287
|
-
const staleArtifacts = [reviewFile,
|
|
3720
|
+
const staleArtifacts = [reviewFile, path8.join(reviewDir, TRANSCRIPT_FILE_NAME)];
|
|
1288
3721
|
for (const stale of staleArtifacts) {
|
|
1289
3722
|
try {
|
|
1290
|
-
|
|
3723
|
+
fs7.rmSync(stale, { force: true });
|
|
1291
3724
|
} catch (error) {
|
|
1292
3725
|
return {
|
|
1293
3726
|
kind: "infrastructure-failure",
|
|
@@ -1309,7 +3742,15 @@ var runReview = async (request, overrides = {}) => {
|
|
|
1309
3742
|
skillInstructions: readReviewerSkill(),
|
|
1310
3743
|
deliveryToken
|
|
1311
3744
|
});
|
|
1312
|
-
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
|
+
});
|
|
1313
3754
|
if (dispatched.kind === "infrastructure-failure") {
|
|
1314
3755
|
return { kind: "infrastructure-failure", detail: dispatched.detail };
|
|
1315
3756
|
}
|
|
@@ -1347,16 +3788,16 @@ var runReview = async (request, overrides = {}) => {
|
|
|
1347
3788
|
harness,
|
|
1348
3789
|
baseCommit,
|
|
1349
3790
|
reviewFile,
|
|
1350
|
-
reviewFilePresent:
|
|
3791
|
+
reviewFilePresent: fs7.existsSync(reviewFile),
|
|
1351
3792
|
verdict: _verdictFor(findingsGate),
|
|
1352
3793
|
findingsGate
|
|
1353
3794
|
};
|
|
1354
3795
|
};
|
|
1355
|
-
var _verdictFor = (
|
|
1356
|
-
if (
|
|
1357
|
-
return { kind: "review-failed", detail:
|
|
3796
|
+
var _verdictFor = (outcome2) => {
|
|
3797
|
+
if (outcome2.kind !== "evaluated") {
|
|
3798
|
+
return { kind: "review-failed", detail: outcome2.detail };
|
|
1358
3799
|
}
|
|
1359
|
-
const { counts, findingsFile } =
|
|
3800
|
+
const { counts, findingsFile } = outcome2;
|
|
1360
3801
|
if (counts.total === 0) {
|
|
1361
3802
|
return {
|
|
1362
3803
|
kind: "review-recorded",
|
|
@@ -1422,3 +3863,8 @@ if (require.main === module) {
|
|
|
1422
3863
|
main,
|
|
1423
3864
|
runReview
|
|
1424
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
|
+
*/
|