strikethroo 3.22.0 → 3.22.1
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/__tests__/built-skills.d.ts +15 -0
- package/dist/__tests__/built-skills.d.ts.map +1 -0
- package/dist/__tests__/built-skills.js +53 -0
- package/dist/__tests__/built-skills.js.map +1 -0
- package/dist-web/assets/{arc-CguPlWfb.js → arc-Hwddr2kO.js} +1 -1
- package/dist-web/assets/{architectureDiagram-3BPJPVTR-D65RMVqJ.js → architectureDiagram-3BPJPVTR-i11AtK7_.js} +1 -1
- package/dist-web/assets/{blockDiagram-GPEHLZMM-CNIwP_yH.js → blockDiagram-GPEHLZMM-BBT6cVNX.js} +1 -1
- package/dist-web/assets/{c4Diagram-AAUBKEIU-CuZ4SoKV.js → c4Diagram-AAUBKEIU-C3vqlA6y.js} +1 -1
- package/dist-web/assets/channel-Cur0s-J7.js +1 -0
- package/dist-web/assets/{chunk-2J33WTMH-DM4ZcjVq.js → chunk-2J33WTMH-B2qLeglu.js} +1 -1
- package/dist-web/assets/{chunk-4BX2VUAB-DI3-zGiF.js → chunk-4BX2VUAB-BOoURq0p.js} +1 -1
- package/dist-web/assets/{chunk-55IACEB6-DBdh-eer.js → chunk-55IACEB6-DucbZmPO.js} +1 -1
- package/dist-web/assets/{chunk-727SXJPM-B0HDPh0I.js → chunk-727SXJPM-D1jwNHG5.js} +1 -1
- package/dist-web/assets/{chunk-AQP2D5EJ-C0MnLmRm.js → chunk-AQP2D5EJ-DEqgF-yl.js} +1 -1
- package/dist-web/assets/{chunk-FMBD7UC4-CmggDcp1.js → chunk-FMBD7UC4-DyqowetS.js} +1 -1
- package/dist-web/assets/{chunk-ND2GUHAM-BSIdB1y0.js → chunk-ND2GUHAM-B5m1NGQ0.js} +1 -1
- package/dist-web/assets/{chunk-QZHKN3VN-BTHsXhgb.js → chunk-QZHKN3VN-DuDvOVer.js} +1 -1
- package/dist-web/assets/classDiagram-4FO5ZUOK-CjiILMRI.js +1 -0
- package/dist-web/assets/classDiagram-v2-Q7XG4LA2-CjiILMRI.js +1 -0
- package/dist-web/assets/{cose-bilkent-S5V4N54A-IXUMXU5h.js → cose-bilkent-S5V4N54A-C9HUgr5R.js} +1 -1
- package/dist-web/assets/{dagre-BM42HDAG-CtwBET_X.js → dagre-BM42HDAG-DT3KjQHY.js} +1 -1
- package/dist-web/assets/{diagram-2AECGRRQ-DRe1AFa_.js → diagram-2AECGRRQ-DrCpXRj9.js} +1 -1
- package/dist-web/assets/{diagram-5GNKFQAL-D9IRdgWX.js → diagram-5GNKFQAL-QcCYThB2.js} +1 -1
- package/dist-web/assets/{diagram-KO2AKTUF-CQi7gmRS.js → diagram-KO2AKTUF-BsaZwGbo.js} +1 -1
- package/dist-web/assets/{diagram-LMA3HP47-B0fp5jh8.js → diagram-LMA3HP47-B6ZqNLaZ.js} +1 -1
- package/dist-web/assets/{diagram-OG6HWLK6-B2ujFhv2.js → diagram-OG6HWLK6-ZfJLCrYD.js} +1 -1
- package/dist-web/assets/{erDiagram-TEJ5UH35-DcxHh3A8.js → erDiagram-TEJ5UH35-BlnJ9PIz.js} +1 -1
- package/dist-web/assets/{flowDiagram-I6XJVG4X-Btsglt1O.js → flowDiagram-I6XJVG4X-CIfl3CnE.js} +1 -1
- package/dist-web/assets/{ganttDiagram-6RSMTGT7-BRaGl6R4.js → ganttDiagram-6RSMTGT7-CPrwdiin.js} +1 -1
- package/dist-web/assets/{gitGraphDiagram-PVQCEYII-Cl1DR87j.js → gitGraphDiagram-PVQCEYII-DcY9oRGk.js} +1 -1
- package/dist-web/assets/{index-DXt7jz3h.js → index-COfame-T.js} +4 -4
- package/dist-web/assets/{index-CxXoZ0_J.js → index-DGtMmSy6.js} +1 -1
- package/dist-web/assets/{index-DZ4QtqqW.js → index-j2lPssdc.js} +1 -1
- package/dist-web/assets/{infoDiagram-5YYISTIA-GMZDkbDI.js → infoDiagram-5YYISTIA-DVU5i5FV.js} +1 -1
- package/dist-web/assets/{ishikawaDiagram-YF4QCWOH-DC8HBMwN.js → ishikawaDiagram-YF4QCWOH-B8Ga6Rav.js} +1 -1
- package/dist-web/assets/{journeyDiagram-JHISSGLW-4KT1uAXJ.js → journeyDiagram-JHISSGLW-DOzvgBoA.js} +1 -1
- package/dist-web/assets/{kanban-definition-UN3LZRKU-bBpM_7W0.js → kanban-definition-UN3LZRKU-BGc6pe_I.js} +1 -1
- package/dist-web/assets/{linear-BzW5Mi4V.js → linear-BpZOijWC.js} +1 -1
- package/dist-web/assets/{mermaid.core-BZXehlCp.js → mermaid.core-C_2qQ8rS.js} +4 -4
- package/dist-web/assets/{mindmap-definition-RKZ34NQL-B8RhYsaN.js → mindmap-definition-RKZ34NQL-DkMM_7Yr.js} +1 -1
- package/dist-web/assets/{pieDiagram-4H26LBE5-DV749i9Y.js → pieDiagram-4H26LBE5-1TkSQl-I.js} +1 -1
- package/dist-web/assets/{quadrantDiagram-W4KKPZXB-Cduffe8j.js → quadrantDiagram-W4KKPZXB-cmPoFli_.js} +1 -1
- package/dist-web/assets/{requirementDiagram-4Y6WPE33-C7KngwZn.js → requirementDiagram-4Y6WPE33-BRm2ySws.js} +1 -1
- package/dist-web/assets/{sankeyDiagram-5OEKKPKP-CJjwUGG3.js → sankeyDiagram-5OEKKPKP-Bm7c5KA3.js} +1 -1
- package/dist-web/assets/{sequenceDiagram-3UESZ5HK-BARiZOtJ.js → sequenceDiagram-3UESZ5HK-TsJi1UnU.js} +1 -1
- package/dist-web/assets/{stateDiagram-AJRCARHV-DA1dHBGx.js → stateDiagram-AJRCARHV-C96-LO_W.js} +1 -1
- package/dist-web/assets/stateDiagram-v2-BHNVJYJU-DyP066tY.js +1 -0
- package/dist-web/assets/{timeline-definition-PNZ67QCA-ClE6cvJF.js → timeline-definition-PNZ67QCA-CXS_QOle.js} +1 -1
- package/dist-web/assets/{vennDiagram-CIIHVFJN-BLR57Itf.js → vennDiagram-CIIHVFJN-C2GyjnKb.js} +1 -1
- package/dist-web/assets/{wardley-L42UT6IY-EA8x1UUF.js → wardley-L42UT6IY-B4Z1vQiy.js} +1 -1
- package/dist-web/assets/{wardleyDiagram-YWT4CUSO-DHktlei-.js → wardleyDiagram-YWT4CUSO-C4rdUwqJ.js} +1 -1
- package/dist-web/assets/{xychartDiagram-2RQKCTM6-DOxQD_Ha.js → xychartDiagram-2RQKCTM6-ldEuZMCT.js} +1 -1
- package/dist-web/index.html +1 -1
- package/package.json +2 -1
- package/dist-web/assets/channel-BL14r_5w.js +0 -1
- package/dist-web/assets/classDiagram-4FO5ZUOK-DBkbEi_3.js +0 -1
- package/dist-web/assets/classDiagram-v2-Q7XG4LA2-DBkbEi_3.js +0 -1
- package/dist-web/assets/stateDiagram-v2-BHNVJYJU-D4ioaqC3.js +0 -1
- package/templates/harness/skills/st-code-review/SKILL.md +0 -52
- package/templates/harness/skills/st-code-review/references/review-example.xml.md +0 -18
- package/templates/harness/skills/st-code-review/scripts/code-review.cjs +0 -3887
- package/templates/harness/skills/st-code-review/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-code-review/scripts/validate-plan-blueprint.cjs +0 -429
- package/templates/harness/skills/st-create-plan/SKILL.md +0 -111
- package/templates/harness/skills/st-create-plan/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-create-plan/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-create-plan/scripts/get-next-plan-id.cjs +0 -197
- package/templates/harness/skills/st-execute-blueprint/SKILL.md +0 -195
- package/templates/harness/skills/st-execute-blueprint/scripts/capture-base-commit.cjs +0 -330
- package/templates/harness/skills/st-execute-blueprint/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-execute-blueprint/scripts/check-phase-readiness.cjs +0 -471
- package/templates/harness/skills/st-execute-blueprint/scripts/create-feature-branch.cjs +0 -374
- package/templates/harness/skills/st-execute-blueprint/scripts/dispatch-task-execution.cjs +0 -6816
- package/templates/harness/skills/st-execute-blueprint/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-execute-blueprint/scripts/validate-plan-blueprint.cjs +0 -429
- package/templates/harness/skills/st-execute-task/SKILL.md +0 -154
- package/templates/harness/skills/st-execute-task/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-execute-task/scripts/check-task-dependencies.cjs +0 -462
- package/templates/harness/skills/st-execute-task/scripts/dispatch-task-execution.cjs +0 -6816
- package/templates/harness/skills/st-execute-task/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-execute-task/scripts/validate-plan-blueprint.cjs +0 -429
- package/templates/harness/skills/st-full-workflow/SKILL.md +0 -470
- package/templates/harness/skills/st-full-workflow/references/complexity-rubric.md +0 -8
- package/templates/harness/skills/st-full-workflow/scripts/capture-base-commit.cjs +0 -330
- package/templates/harness/skills/st-full-workflow/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-full-workflow/scripts/check-phase-readiness.cjs +0 -471
- package/templates/harness/skills/st-full-workflow/scripts/create-feature-branch.cjs +0 -374
- package/templates/harness/skills/st-full-workflow/scripts/dispatch-task-execution.cjs +0 -6816
- package/templates/harness/skills/st-full-workflow/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-full-workflow/scripts/get-next-plan-id.cjs +0 -197
- package/templates/harness/skills/st-full-workflow/scripts/get-next-task-id.cjs +0 -295
- package/templates/harness/skills/st-full-workflow/scripts/route-task-execution.cjs +0 -2874
- package/templates/harness/skills/st-full-workflow/scripts/validate-plan-blueprint.cjs +0 -429
- package/templates/harness/skills/st-generate-tasks/SKILL.md +0 -218
- package/templates/harness/skills/st-generate-tasks/references/complexity-rubric.md +0 -8
- package/templates/harness/skills/st-generate-tasks/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-generate-tasks/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-generate-tasks/scripts/get-next-task-id.cjs +0 -295
- package/templates/harness/skills/st-generate-tasks/scripts/route-task-execution.cjs +0 -2874
- package/templates/harness/skills/st-generate-tasks/scripts/validate-plan-blueprint.cjs +0 -429
- package/templates/harness/skills/st-refine-plan/SKILL.md +0 -132
- package/templates/harness/skills/st-refine-plan/scripts/check-for-updates.cjs +0 -2502
- package/templates/harness/skills/st-refine-plan/scripts/find-strikethroo-root.cjs +0 -116
- package/templates/harness/skills/st-refine-plan/scripts/validate-plan-blueprint.cjs +0 -429
|
@@ -1,2874 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/skill-scripts/route-task-execution.ts
|
|
27
|
-
var fs5 = __toESM(require("fs"));
|
|
28
|
-
var path5 = __toESM(require("path"));
|
|
29
|
-
|
|
30
|
-
// src/types.ts
|
|
31
|
-
var SUPPORTED_HARNESSES = [
|
|
32
|
-
"claude",
|
|
33
|
-
"codex",
|
|
34
|
-
"cursor",
|
|
35
|
-
"gemini",
|
|
36
|
-
"copilot",
|
|
37
|
-
"opencode"
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
// src/skill-scripts/shared/plan-resolve.ts
|
|
41
|
-
var fs3 = __toESM(require("fs"));
|
|
42
|
-
var path3 = __toESM(require("path"));
|
|
43
|
-
|
|
44
|
-
// src/skill-scripts/shared/root.ts
|
|
45
|
-
var fs = __toESM(require("fs"));
|
|
46
|
-
var path = __toESM(require("path"));
|
|
47
|
-
var EXPECTED_SCHEMA = true ? 4 : 4;
|
|
48
|
-
var isValidStrikethrooRoot = (strikethrooPath) => {
|
|
49
|
-
try {
|
|
50
|
-
if (!fs.existsSync(strikethrooPath)) return false;
|
|
51
|
-
if (!fs.lstatSync(strikethrooPath).isDirectory()) return false;
|
|
52
|
-
const metadataPath = path.join(strikethrooPath, ".init-metadata.json");
|
|
53
|
-
if (!fs.existsSync(metadataPath)) return false;
|
|
54
|
-
const metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
|
|
55
|
-
return metadata && typeof metadata === "object" && "version" in metadata;
|
|
56
|
-
} catch (_err) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var getStrikethrooAt = (directory) => {
|
|
61
|
-
const strikethrooPath = path.join(directory, ".ai", "strikethroo");
|
|
62
|
-
return isValidStrikethrooRoot(strikethrooPath) ? strikethrooPath : null;
|
|
63
|
-
};
|
|
64
|
-
var getParentPaths = (currentPath, acc = []) => {
|
|
65
|
-
const absolutePath = path.resolve(currentPath);
|
|
66
|
-
const nextAcc = [...acc, absolutePath];
|
|
67
|
-
const parentPath = path.dirname(absolutePath);
|
|
68
|
-
if (parentPath === absolutePath) return nextAcc;
|
|
69
|
-
return getParentPaths(parentPath, nextAcc);
|
|
70
|
-
};
|
|
71
|
-
var checkWorkspaceSchema = (metadataPath) => {
|
|
72
|
-
let metadata;
|
|
73
|
-
try {
|
|
74
|
-
metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
|
|
75
|
-
} catch {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const actual = typeof metadata.workspaceSchemaVersion === "number" ? metadata.workspaceSchemaVersion : 1;
|
|
79
|
-
if (actual === EXPECTED_SCHEMA) return;
|
|
80
|
-
if (actual < EXPECTED_SCHEMA) {
|
|
81
|
-
process.stderr.write(
|
|
82
|
-
`Workspace schema v${actual} is older than this skill requires (v${EXPECTED_SCHEMA}). Re-run \`npx strikethroo init\` with the latest CLI to update.
|
|
83
|
-
`
|
|
84
|
-
);
|
|
85
|
-
} else {
|
|
86
|
-
process.stderr.write(
|
|
87
|
-
`This skill (built for workspace schema v${EXPECTED_SCHEMA}) is older than the workspace (v${actual}). Re-run \`npx skills add e0ipso/strikethroo\` to update skills.
|
|
88
|
-
`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
process.exit(1);
|
|
92
|
-
};
|
|
93
|
-
var findStrikethrooRoot = (startPath = process.cwd()) => {
|
|
94
|
-
const paths = getParentPaths(startPath);
|
|
95
|
-
const found = paths.find((p) => getStrikethrooAt(p));
|
|
96
|
-
if (!found) return null;
|
|
97
|
-
const root = getStrikethrooAt(found);
|
|
98
|
-
if (root) checkWorkspaceSchema(path.join(root, ".init-metadata.json"));
|
|
99
|
-
return root;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/skill-scripts/shared/plan-scan.ts
|
|
103
|
-
var fs2 = __toESM(require("fs"));
|
|
104
|
-
var path2 = __toESM(require("path"));
|
|
105
|
-
|
|
106
|
-
// src/skill-scripts/shared/frontmatter.ts
|
|
107
|
-
var ID_PATTERNS = [
|
|
108
|
-
/^\s*["']?id["']?\s*:\s*["']?([+-]?\d+)["']?\s*(?:#.*)?$/im,
|
|
109
|
-
/^\s*id\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
|
|
110
|
-
/^\s*["']?id["']?\s*:\s*"([+-]?\d+)"\s*(?:#.*)?$/im,
|
|
111
|
-
/^\s*["']?id["']?\s*:\s*'([+-]?\d+)'\s*(?:#.*)?$/im,
|
|
112
|
-
/^\s*["']id["']\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
|
|
113
|
-
/^\s*id\s*:\s*[|>]\s*([+-]?\d+)\s*$/im
|
|
114
|
-
];
|
|
115
|
-
var validateId = (rawId) => {
|
|
116
|
-
const id = parseInt(rawId, 10);
|
|
117
|
-
if (Number.isNaN(id) || id < 0 || id > Number.MAX_SAFE_INTEGER) return null;
|
|
118
|
-
return id;
|
|
119
|
-
};
|
|
120
|
-
var extractIdFromMarkdown = (content) => {
|
|
121
|
-
const frontmatterMatch = content.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
|
|
122
|
-
if (!frontmatterMatch || !frontmatterMatch[1]) return null;
|
|
123
|
-
const block = frontmatterMatch[1];
|
|
124
|
-
for (const pattern of ID_PATTERNS) {
|
|
125
|
-
const match = block.match(pattern);
|
|
126
|
-
if (match && match[1]) {
|
|
127
|
-
const id = validateId(match[1]);
|
|
128
|
-
if (id !== null) return id;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
};
|
|
133
|
-
var extractPlanId = (content, _filePath) => {
|
|
134
|
-
return extractIdFromMarkdown(content);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/skill-scripts/shared/plan-scan.ts
|
|
138
|
-
var PLAN_EXTENSIONS = [".md"];
|
|
139
|
-
var scanPlanDir = (planDirPath, dirName, isArchive) => {
|
|
140
|
-
let entries;
|
|
141
|
-
try {
|
|
142
|
-
entries = fs2.readdirSync(planDirPath, { withFileTypes: true });
|
|
143
|
-
} catch (_err) {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
return entries.filter((e) => e.isFile() && PLAN_EXTENSIONS.some((ext) => e.name.endsWith(ext))).flatMap((e) => {
|
|
147
|
-
const filePath = path2.join(planDirPath, e.name);
|
|
148
|
-
try {
|
|
149
|
-
const content = fs2.readFileSync(filePath, "utf8");
|
|
150
|
-
const id = extractPlanId(content, filePath);
|
|
151
|
-
if (id === null) return [];
|
|
152
|
-
return [{ id, file: filePath, dir: planDirPath, isArchive, name: dirName }];
|
|
153
|
-
} catch (_err) {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
var getAllPlans = (taskManagerRoot) => {
|
|
159
|
-
const sources = [
|
|
160
|
-
{ dir: path2.join(taskManagerRoot, "plans"), isArchive: false },
|
|
161
|
-
{ dir: path2.join(taskManagerRoot, "archive"), isArchive: true }
|
|
162
|
-
];
|
|
163
|
-
return sources.flatMap(({ dir, isArchive }) => {
|
|
164
|
-
if (!fs2.existsSync(dir)) return [];
|
|
165
|
-
let entries;
|
|
166
|
-
try {
|
|
167
|
-
entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
168
|
-
} catch (_err) {
|
|
169
|
-
return [];
|
|
170
|
-
}
|
|
171
|
-
return entries.filter((e) => e.isDirectory()).flatMap((e) => scanPlanDir(path2.join(dir, e.name), e.name, isArchive));
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// src/skill-scripts/shared/plan-resolve.ts
|
|
176
|
-
var isValidRootDir = (strikethrooPath) => {
|
|
177
|
-
try {
|
|
178
|
-
if (!fs3.existsSync(strikethrooPath)) return false;
|
|
179
|
-
if (!fs3.lstatSync(strikethrooPath).isDirectory()) return false;
|
|
180
|
-
const metadataPath = path3.join(strikethrooPath, ".init-metadata.json");
|
|
181
|
-
if (!fs3.existsSync(metadataPath)) return false;
|
|
182
|
-
const metadata = JSON.parse(fs3.readFileSync(metadataPath, "utf8"));
|
|
183
|
-
return metadata && typeof metadata === "object" && "version" in metadata;
|
|
184
|
-
} catch (_err) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
var checkStandardRootShortcut = (filePath) => {
|
|
189
|
-
const planDir = path3.dirname(filePath);
|
|
190
|
-
const parentDir = path3.dirname(planDir);
|
|
191
|
-
const possibleRoot = path3.dirname(parentDir);
|
|
192
|
-
const parentBase = path3.basename(parentDir);
|
|
193
|
-
if (parentBase !== "plans" && parentBase !== "archive") return null;
|
|
194
|
-
if (path3.basename(possibleRoot) !== "strikethroo") return null;
|
|
195
|
-
const dotAiDir = path3.dirname(possibleRoot);
|
|
196
|
-
if (path3.basename(dotAiDir) !== ".ai") return null;
|
|
197
|
-
return isValidRootDir(possibleRoot) ? possibleRoot : null;
|
|
198
|
-
};
|
|
199
|
-
var resolveByPath = (absolutePath) => {
|
|
200
|
-
let content;
|
|
201
|
-
try {
|
|
202
|
-
content = fs3.readFileSync(absolutePath, "utf8");
|
|
203
|
-
} catch (_err) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
const planId = extractPlanId(content, absolutePath);
|
|
207
|
-
if (planId === null) return null;
|
|
208
|
-
const tmRoot = checkStandardRootShortcut(absolutePath) || findStrikethrooRoot(path3.dirname(absolutePath));
|
|
209
|
-
if (!tmRoot) return null;
|
|
210
|
-
return {
|
|
211
|
-
planFile: absolutePath,
|
|
212
|
-
planDir: path3.dirname(absolutePath),
|
|
213
|
-
strikethrooRoot: tmRoot,
|
|
214
|
-
planId
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
var resolveByIdInAncestry = (planId, startPath, searched = /* @__PURE__ */ new Set()) => {
|
|
218
|
-
const tmRoot = findStrikethrooRoot(startPath);
|
|
219
|
-
if (!tmRoot) return null;
|
|
220
|
-
const normalized = path3.normalize(tmRoot);
|
|
221
|
-
if (searched.has(normalized)) return null;
|
|
222
|
-
searched.add(normalized);
|
|
223
|
-
const plans = getAllPlans(tmRoot);
|
|
224
|
-
const match = plans.find((p) => p.id === planId);
|
|
225
|
-
if (match) {
|
|
226
|
-
return {
|
|
227
|
-
planFile: match.file,
|
|
228
|
-
planDir: match.dir,
|
|
229
|
-
strikethrooRoot: tmRoot,
|
|
230
|
-
planId
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const parentOfRoot = path3.dirname(path3.dirname(tmRoot));
|
|
234
|
-
if (parentOfRoot === tmRoot) return null;
|
|
235
|
-
return resolveByIdInAncestry(planId, parentOfRoot, searched);
|
|
236
|
-
};
|
|
237
|
-
var resolvePlan = (input, startPath = process.cwd()) => {
|
|
238
|
-
if (input === null || input === void 0 || input === "") return null;
|
|
239
|
-
const inputStr = String(input);
|
|
240
|
-
if (inputStr.startsWith("/")) {
|
|
241
|
-
return resolveByPath(inputStr);
|
|
242
|
-
}
|
|
243
|
-
const planId = parseInt(inputStr, 10);
|
|
244
|
-
if (Number.isNaN(planId)) return null;
|
|
245
|
-
return resolveByIdInAncestry(planId, startPath);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// src/skill-scripts/shared/execution-routing.ts
|
|
249
|
-
var fs4 = __toESM(require("fs"));
|
|
250
|
-
var path4 = __toESM(require("path"));
|
|
251
|
-
|
|
252
|
-
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
253
|
-
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
254
|
-
var MERGE_KEY = /* @__PURE__ */ Symbol("MERGE_KEY");
|
|
255
|
-
function defineScalarTag(tagName, options) {
|
|
256
|
-
return {
|
|
257
|
-
tagName,
|
|
258
|
-
nodeKind: "scalar",
|
|
259
|
-
implicit: options.implicit ?? false,
|
|
260
|
-
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
261
|
-
implicitFirstChars: options.implicitFirstChars ?? null,
|
|
262
|
-
resolve: options.resolve,
|
|
263
|
-
identify: options.identify ?? null,
|
|
264
|
-
represent: options.represent ?? ((data) => String(data)),
|
|
265
|
-
representTagName: options.representTagName ?? null
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function defineSequenceTag(tagName, options) {
|
|
269
|
-
const carrierIsResult = options.finalize === void 0;
|
|
270
|
-
return {
|
|
271
|
-
tagName,
|
|
272
|
-
nodeKind: "sequence",
|
|
273
|
-
implicit: false,
|
|
274
|
-
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
275
|
-
create: options.create,
|
|
276
|
-
addItem: options.addItem,
|
|
277
|
-
finalize: options.finalize ?? ((carrier) => carrier),
|
|
278
|
-
carrierIsResult,
|
|
279
|
-
identify: options.identify ?? null,
|
|
280
|
-
represent: options.represent ?? ((data) => data),
|
|
281
|
-
representTagName: options.representTagName ?? null
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function defineMappingTag(tagName, options) {
|
|
285
|
-
const carrierIsResult = options.finalize === void 0;
|
|
286
|
-
return {
|
|
287
|
-
tagName,
|
|
288
|
-
nodeKind: "mapping",
|
|
289
|
-
implicit: false,
|
|
290
|
-
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
291
|
-
create: options.create,
|
|
292
|
-
addPair: options.addPair,
|
|
293
|
-
has: options.has,
|
|
294
|
-
keys: options.keys,
|
|
295
|
-
get: options.get,
|
|
296
|
-
finalize: options.finalize ?? ((carrier) => carrier),
|
|
297
|
-
carrierIsResult,
|
|
298
|
-
identify: options.identify ?? null,
|
|
299
|
-
represent: options.represent ?? ((data) => data),
|
|
300
|
-
representTagName: options.representTagName ?? null
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
var strTag = defineScalarTag("tag:yaml.org,2002:str", {
|
|
304
|
-
resolve: (source) => source,
|
|
305
|
-
identify: (data) => typeof data === "string"
|
|
306
|
-
});
|
|
307
|
-
var NULL_VALUES$1 = [
|
|
308
|
-
"",
|
|
309
|
-
"~",
|
|
310
|
-
"null",
|
|
311
|
-
"Null",
|
|
312
|
-
"NULL"
|
|
313
|
-
];
|
|
314
|
-
var nullCoreTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
315
|
-
implicit: true,
|
|
316
|
-
implicitFirstChars: [
|
|
317
|
-
"",
|
|
318
|
-
"~",
|
|
319
|
-
"n",
|
|
320
|
-
"N"
|
|
321
|
-
],
|
|
322
|
-
resolve: (source) => {
|
|
323
|
-
if (NULL_VALUES$1.indexOf(source) !== -1) return null;
|
|
324
|
-
return NOT_RESOLVED;
|
|
325
|
-
},
|
|
326
|
-
identify: (object) => object === null,
|
|
327
|
-
represent: () => "null"
|
|
328
|
-
});
|
|
329
|
-
var nullJsonTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
330
|
-
implicit: true,
|
|
331
|
-
implicitFirstChars: ["n"],
|
|
332
|
-
resolve: (source, isExplicit) => {
|
|
333
|
-
if (source === "null" || isExplicit && source === "") return null;
|
|
334
|
-
return NOT_RESOLVED;
|
|
335
|
-
},
|
|
336
|
-
identify: (object) => object === null,
|
|
337
|
-
represent: () => "null"
|
|
338
|
-
});
|
|
339
|
-
var NULL_VALUES = [
|
|
340
|
-
"",
|
|
341
|
-
"~",
|
|
342
|
-
"null",
|
|
343
|
-
"Null",
|
|
344
|
-
"NULL"
|
|
345
|
-
];
|
|
346
|
-
var nullYaml11Tag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
347
|
-
implicit: true,
|
|
348
|
-
implicitFirstChars: [
|
|
349
|
-
"",
|
|
350
|
-
"~",
|
|
351
|
-
"n",
|
|
352
|
-
"N"
|
|
353
|
-
],
|
|
354
|
-
resolve: (source) => {
|
|
355
|
-
if (NULL_VALUES.indexOf(source) !== -1) return null;
|
|
356
|
-
return NOT_RESOLVED;
|
|
357
|
-
},
|
|
358
|
-
identify: (object) => object === null,
|
|
359
|
-
represent: () => "null"
|
|
360
|
-
});
|
|
361
|
-
var TRUE_VALUES$2 = [
|
|
362
|
-
"true",
|
|
363
|
-
"True",
|
|
364
|
-
"TRUE"
|
|
365
|
-
];
|
|
366
|
-
var FALSE_VALUES$2 = [
|
|
367
|
-
"false",
|
|
368
|
-
"False",
|
|
369
|
-
"FALSE"
|
|
370
|
-
];
|
|
371
|
-
var boolCoreTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
372
|
-
implicit: true,
|
|
373
|
-
implicitFirstChars: [
|
|
374
|
-
"t",
|
|
375
|
-
"T",
|
|
376
|
-
"f",
|
|
377
|
-
"F"
|
|
378
|
-
],
|
|
379
|
-
resolve: (source) => {
|
|
380
|
-
if (TRUE_VALUES$2.indexOf(source) !== -1) return true;
|
|
381
|
-
if (FALSE_VALUES$2.indexOf(source) !== -1) return false;
|
|
382
|
-
return NOT_RESOLVED;
|
|
383
|
-
},
|
|
384
|
-
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
385
|
-
represent: (object) => object ? "true" : "false"
|
|
386
|
-
});
|
|
387
|
-
var TRUE_VALUES$1 = ["true"];
|
|
388
|
-
var FALSE_VALUES$1 = ["false"];
|
|
389
|
-
var boolJsonTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
390
|
-
implicit: true,
|
|
391
|
-
implicitFirstChars: ["t", "f"],
|
|
392
|
-
resolve: (source) => {
|
|
393
|
-
if (TRUE_VALUES$1.indexOf(source) !== -1) return true;
|
|
394
|
-
if (FALSE_VALUES$1.indexOf(source) !== -1) return false;
|
|
395
|
-
return NOT_RESOLVED;
|
|
396
|
-
},
|
|
397
|
-
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
398
|
-
represent: (object) => object ? "true" : "false"
|
|
399
|
-
});
|
|
400
|
-
var TRUE_VALUES = [
|
|
401
|
-
"true",
|
|
402
|
-
"True",
|
|
403
|
-
"TRUE",
|
|
404
|
-
"y",
|
|
405
|
-
"Y",
|
|
406
|
-
"yes",
|
|
407
|
-
"Yes",
|
|
408
|
-
"YES",
|
|
409
|
-
"on",
|
|
410
|
-
"On",
|
|
411
|
-
"ON"
|
|
412
|
-
];
|
|
413
|
-
var FALSE_VALUES = [
|
|
414
|
-
"false",
|
|
415
|
-
"False",
|
|
416
|
-
"FALSE",
|
|
417
|
-
"n",
|
|
418
|
-
"N",
|
|
419
|
-
"no",
|
|
420
|
-
"No",
|
|
421
|
-
"NO",
|
|
422
|
-
"off",
|
|
423
|
-
"Off",
|
|
424
|
-
"OFF"
|
|
425
|
-
];
|
|
426
|
-
var boolYaml11Tag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
427
|
-
implicit: true,
|
|
428
|
-
implicitFirstChars: [
|
|
429
|
-
"y",
|
|
430
|
-
"Y",
|
|
431
|
-
"n",
|
|
432
|
-
"N",
|
|
433
|
-
"t",
|
|
434
|
-
"T",
|
|
435
|
-
"f",
|
|
436
|
-
"F",
|
|
437
|
-
"o",
|
|
438
|
-
"O"
|
|
439
|
-
],
|
|
440
|
-
resolve: (source) => {
|
|
441
|
-
if (TRUE_VALUES.indexOf(source) !== -1) return true;
|
|
442
|
-
if (FALSE_VALUES.indexOf(source) !== -1) return false;
|
|
443
|
-
return NOT_RESOLVED;
|
|
444
|
-
},
|
|
445
|
-
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
446
|
-
represent: (object) => object ? "true" : "false"
|
|
447
|
-
});
|
|
448
|
-
var YAML_INTEGER_IMPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
449
|
-
var YAML_INTEGER_EXPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
450
|
-
function parseYamlInteger$2(source) {
|
|
451
|
-
let value = source;
|
|
452
|
-
let sign = 1;
|
|
453
|
-
if (value[0] === "-" || value[0] === "+") {
|
|
454
|
-
if (value[0] === "-") sign = -1;
|
|
455
|
-
value = value.slice(1);
|
|
456
|
-
}
|
|
457
|
-
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
458
|
-
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
459
|
-
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
460
|
-
return sign * parseInt(value, 10);
|
|
461
|
-
}
|
|
462
|
-
function resolveYamlInteger$2(source, isExplicit) {
|
|
463
|
-
if (isExplicit) {
|
|
464
|
-
if (!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
465
|
-
} else if (!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
466
|
-
const result = parseYamlInteger$2(source);
|
|
467
|
-
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
468
|
-
}
|
|
469
|
-
var intCoreTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
470
|
-
implicit: true,
|
|
471
|
-
implicitFirstChars: [
|
|
472
|
-
"-",
|
|
473
|
-
"+",
|
|
474
|
-
..."0123456789"
|
|
475
|
-
],
|
|
476
|
-
resolve: resolveYamlInteger$2,
|
|
477
|
-
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
478
|
-
represent: (object) => object.toString(10)
|
|
479
|
-
});
|
|
480
|
-
var YAML_INTEGER_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)$");
|
|
481
|
-
var YAML_INTEGER_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
482
|
-
function parseYamlInteger$1(source) {
|
|
483
|
-
let value = source;
|
|
484
|
-
let sign = 1;
|
|
485
|
-
if (value[0] === "-" || value[0] === "+") {
|
|
486
|
-
if (value[0] === "-") sign = -1;
|
|
487
|
-
value = value.slice(1);
|
|
488
|
-
}
|
|
489
|
-
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
490
|
-
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
491
|
-
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
492
|
-
return sign * parseInt(value, 10);
|
|
493
|
-
}
|
|
494
|
-
function resolveYamlInteger$1(source, isExplicit) {
|
|
495
|
-
if (isExplicit) {
|
|
496
|
-
if (!YAML_INTEGER_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
497
|
-
} else if (!YAML_INTEGER_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
498
|
-
const result = parseYamlInteger$1(source);
|
|
499
|
-
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
500
|
-
}
|
|
501
|
-
var intJsonTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
502
|
-
implicit: true,
|
|
503
|
-
implicitFirstChars: ["-", ..."0123456789"],
|
|
504
|
-
resolve: resolveYamlInteger$1,
|
|
505
|
-
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
506
|
-
represent: (object) => object.toString(10)
|
|
507
|
-
});
|
|
508
|
-
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_]*))$");
|
|
509
|
-
function parseYamlInteger(source) {
|
|
510
|
-
let value = source.replace(/_/g, "");
|
|
511
|
-
let sign = 1;
|
|
512
|
-
if (value[0] === "-" || value[0] === "+") {
|
|
513
|
-
if (value[0] === "-") sign = -1;
|
|
514
|
-
value = value.slice(1);
|
|
515
|
-
}
|
|
516
|
-
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
517
|
-
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
518
|
-
if (value.includes(":")) {
|
|
519
|
-
let result = 0;
|
|
520
|
-
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
521
|
-
return sign * result;
|
|
522
|
-
}
|
|
523
|
-
if (value !== "0" && value[0] === "0") return sign * parseInt(value, 8);
|
|
524
|
-
return sign * parseInt(value, 10);
|
|
525
|
-
}
|
|
526
|
-
function resolveYamlInteger(source) {
|
|
527
|
-
if (!YAML_INTEGER_PATTERN.test(source)) return NOT_RESOLVED;
|
|
528
|
-
const result = parseYamlInteger(source);
|
|
529
|
-
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
530
|
-
}
|
|
531
|
-
var intYaml11Tag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
532
|
-
implicit: true,
|
|
533
|
-
implicitFirstChars: [
|
|
534
|
-
"-",
|
|
535
|
-
"+",
|
|
536
|
-
..."0123456789"
|
|
537
|
-
],
|
|
538
|
-
resolve: resolveYamlInteger,
|
|
539
|
-
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
540
|
-
represent: (object) => object.toString(10)
|
|
541
|
-
});
|
|
542
|
-
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))$");
|
|
543
|
-
var YAML_FLOAT_SPECIAL_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
544
|
-
function resolveYamlFloat$2(source) {
|
|
545
|
-
if (!YAML_FLOAT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
546
|
-
let value = source.toLowerCase();
|
|
547
|
-
const sign = value[0] === "-" ? -1 : 1;
|
|
548
|
-
if ("+-".includes(value[0])) value = value.slice(1);
|
|
549
|
-
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
550
|
-
if (value === ".nan") return NaN;
|
|
551
|
-
const result = sign * parseFloat(value);
|
|
552
|
-
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN$1.test(source)) return result;
|
|
553
|
-
return NOT_RESOLVED;
|
|
554
|
-
}
|
|
555
|
-
function representYamlFloat$2(object) {
|
|
556
|
-
if (isNaN(object)) return ".nan";
|
|
557
|
-
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
558
|
-
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
559
|
-
if (Object.is(object, -0)) return "-0.0";
|
|
560
|
-
const result = object.toString(10);
|
|
561
|
-
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
562
|
-
}
|
|
563
|
-
var floatCoreTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
564
|
-
implicit: true,
|
|
565
|
-
implicitFirstChars: [
|
|
566
|
-
"-",
|
|
567
|
-
"+",
|
|
568
|
-
".",
|
|
569
|
-
..."0123456789"
|
|
570
|
-
],
|
|
571
|
-
resolve: resolveYamlFloat$2,
|
|
572
|
-
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
573
|
-
represent: representYamlFloat$2
|
|
574
|
-
});
|
|
575
|
-
var YAML_FLOAT_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
|
|
576
|
-
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))$");
|
|
577
|
-
function resolveYamlFloat$1(source, isExplicit) {
|
|
578
|
-
if (isExplicit) {
|
|
579
|
-
if (!YAML_FLOAT_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
580
|
-
let value = source.toLowerCase();
|
|
581
|
-
const sign = value[0] === "-" ? -1 : 1;
|
|
582
|
-
if ("+-".includes(value[0])) value = value.slice(1);
|
|
583
|
-
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
584
|
-
if (value === ".nan") return NaN;
|
|
585
|
-
const result2 = sign * parseFloat(value);
|
|
586
|
-
return Number.isFinite(result2) ? result2 : NOT_RESOLVED;
|
|
587
|
-
}
|
|
588
|
-
if (!YAML_FLOAT_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
589
|
-
const result = Number(source);
|
|
590
|
-
if (Number.isFinite(result)) return result;
|
|
591
|
-
return NOT_RESOLVED;
|
|
592
|
-
}
|
|
593
|
-
function representYamlFloat$1(object) {
|
|
594
|
-
if (isNaN(object)) return ".nan";
|
|
595
|
-
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
596
|
-
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
597
|
-
if (Object.is(object, -0)) return "-0.0";
|
|
598
|
-
const result = object.toString(10);
|
|
599
|
-
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
600
|
-
}
|
|
601
|
-
var floatJsonTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
602
|
-
implicit: true,
|
|
603
|
-
implicitFirstChars: ["-", ..."0123456789"],
|
|
604
|
-
resolve: resolveYamlFloat$1,
|
|
605
|
-
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
606
|
-
represent: representYamlFloat$1
|
|
607
|
-
});
|
|
608
|
-
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))$");
|
|
609
|
-
var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
610
|
-
function resolveYamlFloat(source) {
|
|
611
|
-
if (!YAML_FLOAT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
612
|
-
let value = source.toLowerCase().replace(/_/g, "");
|
|
613
|
-
const sign = value[0] === "-" ? -1 : 1;
|
|
614
|
-
if ("+-".includes(value[0])) value = value.slice(1);
|
|
615
|
-
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
616
|
-
if (value === ".nan") return NaN;
|
|
617
|
-
let result = 0;
|
|
618
|
-
if (value.includes(":")) {
|
|
619
|
-
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
620
|
-
result *= sign;
|
|
621
|
-
} else result = sign * parseFloat(value);
|
|
622
|
-
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN.test(source)) return result;
|
|
623
|
-
return NOT_RESOLVED;
|
|
624
|
-
}
|
|
625
|
-
function representYamlFloat(object) {
|
|
626
|
-
if (isNaN(object)) return ".nan";
|
|
627
|
-
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
628
|
-
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
629
|
-
if (Object.is(object, -0)) return "-0.0";
|
|
630
|
-
const result = object.toString(10);
|
|
631
|
-
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
632
|
-
}
|
|
633
|
-
var floatYaml11Tag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
634
|
-
implicit: true,
|
|
635
|
-
implicitFirstChars: [
|
|
636
|
-
"-",
|
|
637
|
-
"+",
|
|
638
|
-
".",
|
|
639
|
-
..."0123456789"
|
|
640
|
-
],
|
|
641
|
-
resolve: resolveYamlFloat,
|
|
642
|
-
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
643
|
-
represent: representYamlFloat
|
|
644
|
-
});
|
|
645
|
-
var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
|
|
646
|
-
implicit: true,
|
|
647
|
-
implicitFirstChars: ["<"],
|
|
648
|
-
resolve: (source, isExplicit) => {
|
|
649
|
-
if (source === "<<" || isExplicit && source === "") return MERGE_KEY;
|
|
650
|
-
return NOT_RESOLVED;
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
654
|
-
function resolveYamlBinary(source) {
|
|
655
|
-
const input = source.replace(/\s/g, "");
|
|
656
|
-
if (input.length % 4 !== 0 || !BASE64_PATTERN.test(input)) return NOT_RESOLVED;
|
|
657
|
-
const binary = atob(input);
|
|
658
|
-
const result = new Uint8Array(binary.length);
|
|
659
|
-
for (let index = 0; index < binary.length; index++) result[index] = binary.charCodeAt(index);
|
|
660
|
-
return result;
|
|
661
|
-
}
|
|
662
|
-
function representYamlBinary(object) {
|
|
663
|
-
let binary = "";
|
|
664
|
-
for (let index = 0; index < object.length; index++) binary += String.fromCharCode(object[index]);
|
|
665
|
-
return btoa(binary);
|
|
666
|
-
}
|
|
667
|
-
var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
|
|
668
|
-
resolve: resolveYamlBinary,
|
|
669
|
-
identify: (object) => Object.prototype.toString.call(object) === "[object Uint8Array]",
|
|
670
|
-
represent: representYamlBinary
|
|
671
|
-
});
|
|
672
|
-
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
673
|
-
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]))?))?$");
|
|
674
|
-
function resolveYamlTimestamp(source) {
|
|
675
|
-
let match = YAML_DATE_REGEXP.exec(source);
|
|
676
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
|
|
677
|
-
if (match === null) return NOT_RESOLVED;
|
|
678
|
-
const year = +match[1];
|
|
679
|
-
const month = +match[2] - 1;
|
|
680
|
-
const day = +match[3];
|
|
681
|
-
if (!match[4]) {
|
|
682
|
-
const date2 = new Date(Date.UTC(year, month, day));
|
|
683
|
-
if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
|
|
684
|
-
return date2;
|
|
685
|
-
}
|
|
686
|
-
const hour = +match[4];
|
|
687
|
-
const minute = +match[5];
|
|
688
|
-
const second = +match[6];
|
|
689
|
-
let fraction = 0;
|
|
690
|
-
if (hour > 23 || minute > 59 || second > 59) return NOT_RESOLVED;
|
|
691
|
-
if (match[7]) {
|
|
692
|
-
let value = match[7].slice(0, 3);
|
|
693
|
-
while (value.length < 3) value += "0";
|
|
694
|
-
fraction = +value;
|
|
695
|
-
}
|
|
696
|
-
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
697
|
-
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
|
|
698
|
-
if (match[9]) {
|
|
699
|
-
const offsetHour = +match[10];
|
|
700
|
-
const offsetMinute = +(match[11] || 0);
|
|
701
|
-
if (offsetHour > 23 || offsetMinute > 59) return NOT_RESOLVED;
|
|
702
|
-
const offset = (offsetHour * 60 + offsetMinute) * 6e4;
|
|
703
|
-
date.setTime(date.getTime() - (match[9] === "-" ? -offset : offset));
|
|
704
|
-
}
|
|
705
|
-
return date;
|
|
706
|
-
}
|
|
707
|
-
var timestampTag = defineScalarTag("tag:yaml.org,2002:timestamp", {
|
|
708
|
-
implicit: true,
|
|
709
|
-
implicitFirstChars: [..."0123456789"],
|
|
710
|
-
resolve: resolveYamlTimestamp,
|
|
711
|
-
identify: (object) => object instanceof Date,
|
|
712
|
-
represent: (object) => object.toISOString()
|
|
713
|
-
});
|
|
714
|
-
var seqTag = defineSequenceTag("tag:yaml.org,2002:seq", {
|
|
715
|
-
create: () => [],
|
|
716
|
-
addItem: (container, item) => {
|
|
717
|
-
container.push(item);
|
|
718
|
-
},
|
|
719
|
-
identify: Array.isArray
|
|
720
|
-
});
|
|
721
|
-
function isPlainObject(data) {
|
|
722
|
-
if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
|
|
723
|
-
const prototype = Object.getPrototypeOf(data);
|
|
724
|
-
return prototype === null || prototype === Object.prototype;
|
|
725
|
-
}
|
|
726
|
-
function pick(object, keys) {
|
|
727
|
-
const result = {};
|
|
728
|
-
for (const key of keys) if (object[key] !== void 0) result[key] = object[key];
|
|
729
|
-
return result;
|
|
730
|
-
}
|
|
731
|
-
var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
|
|
732
|
-
create: () => ({
|
|
733
|
-
list: [],
|
|
734
|
-
seen: /* @__PURE__ */ new Set()
|
|
735
|
-
}),
|
|
736
|
-
addItem: (carrier, item) => {
|
|
737
|
-
let key;
|
|
738
|
-
if (item instanceof Map) {
|
|
739
|
-
if (item.size !== 1) return "cannot resolve an ordered map item";
|
|
740
|
-
key = item.keys().next().value;
|
|
741
|
-
} else if (isPlainObject(item)) {
|
|
742
|
-
const itemKeys = Object.keys(item);
|
|
743
|
-
if (itemKeys.length !== 1) return "cannot resolve an ordered map item";
|
|
744
|
-
key = itemKeys[0];
|
|
745
|
-
} else return "cannot resolve an ordered map item";
|
|
746
|
-
if (carrier.seen.has(key)) return "duplicate key in ordered map";
|
|
747
|
-
carrier.seen.add(key);
|
|
748
|
-
carrier.list.push(item);
|
|
749
|
-
return "";
|
|
750
|
-
},
|
|
751
|
-
finalize: (carrier) => carrier.list
|
|
752
|
-
});
|
|
753
|
-
var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
754
|
-
create: () => [],
|
|
755
|
-
addItem: (container, item) => {
|
|
756
|
-
if (item instanceof Map) {
|
|
757
|
-
if (item.size !== 1) return "cannot resolve a pairs item";
|
|
758
|
-
container.push(item.entries().next().value);
|
|
759
|
-
return "";
|
|
760
|
-
}
|
|
761
|
-
if (Object.prototype.toString.call(item) !== "[object Object]") return "cannot resolve a pairs item";
|
|
762
|
-
const object = item;
|
|
763
|
-
const keys = Object.keys(object);
|
|
764
|
-
if (keys.length !== 1) return "cannot resolve a pairs item";
|
|
765
|
-
container.push([keys[0], object[keys[0]]]);
|
|
766
|
-
return "";
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
770
|
-
create: () => ({}),
|
|
771
|
-
identify: isPlainObject,
|
|
772
|
-
represent: (o) => {
|
|
773
|
-
const map = /* @__PURE__ */ new Map();
|
|
774
|
-
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
775
|
-
return map;
|
|
776
|
-
},
|
|
777
|
-
addPair: (container, key, value) => {
|
|
778
|
-
if (key !== null && typeof key === "object") return "object-based map does not support complex keys";
|
|
779
|
-
const normalizedKey = String(key);
|
|
780
|
-
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
781
|
-
value,
|
|
782
|
-
enumerable: true,
|
|
783
|
-
configurable: true,
|
|
784
|
-
writable: true
|
|
785
|
-
});
|
|
786
|
-
else container[normalizedKey] = value;
|
|
787
|
-
return "";
|
|
788
|
-
},
|
|
789
|
-
has: (container, key) => {
|
|
790
|
-
if (key !== null && typeof key === "object") return false;
|
|
791
|
-
return Object.prototype.hasOwnProperty.call(container, String(key));
|
|
792
|
-
},
|
|
793
|
-
keys: (container) => Object.keys(container),
|
|
794
|
-
get: (container, key) => container[String(key)]
|
|
795
|
-
});
|
|
796
|
-
var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
797
|
-
create: () => /* @__PURE__ */ new Set(),
|
|
798
|
-
identify: (data) => data instanceof Set,
|
|
799
|
-
represent: (data) => {
|
|
800
|
-
const map = /* @__PURE__ */ new Map();
|
|
801
|
-
for (const key of data) map.set(key, null);
|
|
802
|
-
return map;
|
|
803
|
-
},
|
|
804
|
-
addPair: (container, key, value) => {
|
|
805
|
-
if (value !== null) return "cannot resolve a set item";
|
|
806
|
-
container.add(key);
|
|
807
|
-
return "";
|
|
808
|
-
},
|
|
809
|
-
has: (container, key) => container.has(key),
|
|
810
|
-
keys: (container) => container.keys(),
|
|
811
|
-
get: () => null
|
|
812
|
-
});
|
|
813
|
-
function createTagDefinitionMap() {
|
|
814
|
-
return {
|
|
815
|
-
scalar: {},
|
|
816
|
-
sequence: {},
|
|
817
|
-
mapping: {}
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
function createTagDefinitionListMap() {
|
|
821
|
-
return {
|
|
822
|
-
scalar: [],
|
|
823
|
-
sequence: [],
|
|
824
|
-
mapping: []
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
function compileTags(tags) {
|
|
828
|
-
const result = [];
|
|
829
|
-
for (const tag of tags) {
|
|
830
|
-
let index = result.length;
|
|
831
|
-
for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
|
|
832
|
-
const previous = result[previousIndex];
|
|
833
|
-
if (previous.nodeKind === tag.nodeKind && previous.tagName === tag.tagName && previous.matchByTagPrefix === tag.matchByTagPrefix) {
|
|
834
|
-
index = previousIndex;
|
|
835
|
-
break;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
result[index] = tag;
|
|
839
|
-
}
|
|
840
|
-
return result;
|
|
841
|
-
}
|
|
842
|
-
var Schema = class Schema2 {
|
|
843
|
-
tags;
|
|
844
|
-
implicitScalarTags;
|
|
845
|
-
implicitScalarByFirstChar;
|
|
846
|
-
implicitScalarAnyFirstChar;
|
|
847
|
-
defaultScalarTag;
|
|
848
|
-
defaultSequenceTag;
|
|
849
|
-
defaultMappingTag;
|
|
850
|
-
exact;
|
|
851
|
-
prefix;
|
|
852
|
-
constructor(tags) {
|
|
853
|
-
const compiledTags = compileTags(tags);
|
|
854
|
-
const implicitScalarTags = [];
|
|
855
|
-
const exact = createTagDefinitionMap();
|
|
856
|
-
const prefix = createTagDefinitionListMap();
|
|
857
|
-
for (const tag of compiledTags) {
|
|
858
|
-
if (tag.nodeKind === "scalar" && tag.implicit) {
|
|
859
|
-
if (tag.matchByTagPrefix) throw new Error("Implicit scalar tags cannot match by tag prefix");
|
|
860
|
-
implicitScalarTags.push(tag);
|
|
861
|
-
}
|
|
862
|
-
switch (tag.nodeKind) {
|
|
863
|
-
case "scalar":
|
|
864
|
-
if (tag.matchByTagPrefix) prefix.scalar.push(tag);
|
|
865
|
-
else exact.scalar[tag.tagName] = tag;
|
|
866
|
-
break;
|
|
867
|
-
case "sequence":
|
|
868
|
-
if (tag.matchByTagPrefix) prefix.sequence.push(tag);
|
|
869
|
-
else exact.sequence[tag.tagName] = tag;
|
|
870
|
-
break;
|
|
871
|
-
case "mapping":
|
|
872
|
-
if (tag.matchByTagPrefix) prefix.mapping.push(tag);
|
|
873
|
-
else exact.mapping[tag.tagName] = tag;
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
const implicitScalarAnyFirstChar = implicitScalarTags.filter((tag) => tag.implicitFirstChars === null);
|
|
878
|
-
const keys = /* @__PURE__ */ new Set();
|
|
879
|
-
for (const tag of implicitScalarTags) if (tag.implicitFirstChars !== null) for (const key of tag.implicitFirstChars) keys.add(key);
|
|
880
|
-
const implicitScalarByFirstChar = /* @__PURE__ */ new Map();
|
|
881
|
-
for (const key of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag) => tag.implicitFirstChars === null || tag.implicitFirstChars.indexOf(key) !== -1));
|
|
882
|
-
const defaultScalarTag = exact.scalar["tag:yaml.org,2002:str"];
|
|
883
|
-
if (!defaultScalarTag) throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");
|
|
884
|
-
this.tags = compiledTags;
|
|
885
|
-
this.implicitScalarTags = implicitScalarTags;
|
|
886
|
-
this.implicitScalarByFirstChar = implicitScalarByFirstChar;
|
|
887
|
-
this.implicitScalarAnyFirstChar = implicitScalarAnyFirstChar;
|
|
888
|
-
this.defaultScalarTag = defaultScalarTag;
|
|
889
|
-
this.defaultSequenceTag = exact.sequence["tag:yaml.org,2002:seq"];
|
|
890
|
-
this.defaultMappingTag = exact.mapping["tag:yaml.org,2002:map"];
|
|
891
|
-
this.exact = exact;
|
|
892
|
-
this.prefix = prefix;
|
|
893
|
-
}
|
|
894
|
-
withTags(...tags) {
|
|
895
|
-
let flatTags = [];
|
|
896
|
-
for (const tag of tags) flatTags = flatTags.concat(tag);
|
|
897
|
-
return new Schema2([...this.tags, ...flatTags]);
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
var FAILSAFE_SCHEMA = new Schema([
|
|
901
|
-
strTag,
|
|
902
|
-
seqTag,
|
|
903
|
-
mapTag
|
|
904
|
-
]);
|
|
905
|
-
var JSON_SCHEMA = new Schema([
|
|
906
|
-
...FAILSAFE_SCHEMA.tags,
|
|
907
|
-
nullJsonTag,
|
|
908
|
-
boolJsonTag,
|
|
909
|
-
intJsonTag,
|
|
910
|
-
floatJsonTag
|
|
911
|
-
]);
|
|
912
|
-
var CORE_SCHEMA = new Schema([
|
|
913
|
-
...FAILSAFE_SCHEMA.tags,
|
|
914
|
-
nullCoreTag,
|
|
915
|
-
boolCoreTag,
|
|
916
|
-
intCoreTag,
|
|
917
|
-
floatCoreTag
|
|
918
|
-
]);
|
|
919
|
-
var YAML11_SCHEMA = new Schema([
|
|
920
|
-
...FAILSAFE_SCHEMA.tags,
|
|
921
|
-
nullYaml11Tag,
|
|
922
|
-
boolYaml11Tag,
|
|
923
|
-
intYaml11Tag,
|
|
924
|
-
floatYaml11Tag,
|
|
925
|
-
timestampTag,
|
|
926
|
-
mergeTag,
|
|
927
|
-
binaryTag,
|
|
928
|
-
omapTag,
|
|
929
|
-
pairsTag,
|
|
930
|
-
setTag
|
|
931
|
-
]);
|
|
932
|
-
var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
933
|
-
create: () => /* @__PURE__ */ new Map(),
|
|
934
|
-
addPair: (container, key, value) => {
|
|
935
|
-
container.set(key, value);
|
|
936
|
-
return "";
|
|
937
|
-
},
|
|
938
|
-
has: (container, key) => container.has(key),
|
|
939
|
-
keys: (container) => container.keys(),
|
|
940
|
-
get: (container, key) => container.get(key),
|
|
941
|
-
identify: (data) => data instanceof Map || isPlainObject(data),
|
|
942
|
-
represent: (data) => {
|
|
943
|
-
if (data instanceof Map) return data;
|
|
944
|
-
const map = /* @__PURE__ */ new Map();
|
|
945
|
-
const obj = data;
|
|
946
|
-
for (const key of Object.keys(obj)) map.set(key, obj[key]);
|
|
947
|
-
return map;
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
function normalizeKey(key) {
|
|
951
|
-
if (Array.isArray(key)) {
|
|
952
|
-
const array = Array.prototype.slice.call(key);
|
|
953
|
-
for (let index = 0; index < array.length; index++) {
|
|
954
|
-
if (Array.isArray(array[index])) return null;
|
|
955
|
-
if (typeof array[index] === "object" && Object.prototype.toString.call(array[index]) === "[object Object]") array[index] = "[object Object]";
|
|
956
|
-
}
|
|
957
|
-
return String(array);
|
|
958
|
-
}
|
|
959
|
-
if (typeof key === "object" && Object.prototype.toString.call(key) === "[object Object]") return "[object Object]";
|
|
960
|
-
return String(key);
|
|
961
|
-
}
|
|
962
|
-
var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
963
|
-
create: () => ({}),
|
|
964
|
-
identify: isPlainObject,
|
|
965
|
-
represent: (o) => {
|
|
966
|
-
const map = /* @__PURE__ */ new Map();
|
|
967
|
-
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
968
|
-
return map;
|
|
969
|
-
},
|
|
970
|
-
addPair: (container, key, value) => {
|
|
971
|
-
const normalizedKey = normalizeKey(key);
|
|
972
|
-
if (normalizedKey === null) return "nested arrays are not supported inside keys";
|
|
973
|
-
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
974
|
-
value,
|
|
975
|
-
enumerable: true,
|
|
976
|
-
configurable: true,
|
|
977
|
-
writable: true
|
|
978
|
-
});
|
|
979
|
-
else container[normalizedKey] = value;
|
|
980
|
-
return "";
|
|
981
|
-
},
|
|
982
|
-
has: (container, key) => {
|
|
983
|
-
const normalizedKey = normalizeKey(key);
|
|
984
|
-
return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
|
|
985
|
-
},
|
|
986
|
-
keys: (container) => Object.keys(container),
|
|
987
|
-
get: (container, key) => container[String(key)]
|
|
988
|
-
});
|
|
989
|
-
var DEFAULT_SNIPPET_OPTIONS = {
|
|
990
|
-
maxLength: 79,
|
|
991
|
-
indent: 1,
|
|
992
|
-
linesBefore: 3,
|
|
993
|
-
linesAfter: 2
|
|
994
|
-
};
|
|
995
|
-
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
996
|
-
let head = "";
|
|
997
|
-
let tail = "";
|
|
998
|
-
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
999
|
-
if (position - lineStart > maxHalfLength) {
|
|
1000
|
-
head = " ... ";
|
|
1001
|
-
lineStart = position - maxHalfLength + head.length;
|
|
1002
|
-
}
|
|
1003
|
-
if (lineEnd - position > maxHalfLength) {
|
|
1004
|
-
tail = " ...";
|
|
1005
|
-
lineEnd = position + maxHalfLength - tail.length;
|
|
1006
|
-
}
|
|
1007
|
-
return {
|
|
1008
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
1009
|
-
pos: position - lineStart + head.length
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function padStart(string, max) {
|
|
1013
|
-
return " ".repeat(Math.max(max - string.length, 0)) + string;
|
|
1014
|
-
}
|
|
1015
|
-
function makeSnippet(mark, options) {
|
|
1016
|
-
if (!mark.buffer) return null;
|
|
1017
|
-
const opts = {
|
|
1018
|
-
...DEFAULT_SNIPPET_OPTIONS,
|
|
1019
|
-
...options
|
|
1020
|
-
};
|
|
1021
|
-
const re = /\r?\n|\r|\0/g;
|
|
1022
|
-
const lineStarts = [0];
|
|
1023
|
-
const lineEnds = [];
|
|
1024
|
-
let match;
|
|
1025
|
-
let foundLineNo = -1;
|
|
1026
|
-
while (match = re.exec(mark.buffer)) {
|
|
1027
|
-
lineEnds.push(match.index);
|
|
1028
|
-
lineStarts.push(match.index + match[0].length);
|
|
1029
|
-
if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
|
|
1030
|
-
}
|
|
1031
|
-
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
1032
|
-
let result = "";
|
|
1033
|
-
const lineNoLength = Math.min(mark.line + opts.linesAfter, lineEnds.length).toString().length;
|
|
1034
|
-
const maxLineLength = opts.maxLength - (opts.indent + lineNoLength + 3);
|
|
1035
|
-
for (let i = 1; i <= opts.linesBefore; i++) {
|
|
1036
|
-
if (foundLineNo - i < 0) break;
|
|
1037
|
-
const line2 = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
1038
|
-
result = `${" ".repeat(opts.indent)}${padStart((mark.line - i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
1039
|
-
${result}`;
|
|
1040
|
-
}
|
|
1041
|
-
const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
1042
|
-
result += `${" ".repeat(opts.indent)}${padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}
|
|
1043
|
-
`;
|
|
1044
|
-
result += `${"-".repeat(opts.indent + lineNoLength + 3 + line.pos)}^
|
|
1045
|
-
`;
|
|
1046
|
-
for (let i = 1; i <= opts.linesAfter; i++) {
|
|
1047
|
-
if (foundLineNo + i >= lineEnds.length) break;
|
|
1048
|
-
const line2 = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
1049
|
-
result += `${" ".repeat(opts.indent)}${padStart((mark.line + i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
1050
|
-
`;
|
|
1051
|
-
}
|
|
1052
|
-
return result.replace(/\n$/, "");
|
|
1053
|
-
}
|
|
1054
|
-
function formatError(exception, compact) {
|
|
1055
|
-
let where = "";
|
|
1056
|
-
if (!exception.mark) return exception.reason;
|
|
1057
|
-
if (exception.mark.name) where += `in "${exception.mark.name}" `;
|
|
1058
|
-
where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
|
|
1059
|
-
if (!compact && exception.mark.snippet) where += `
|
|
1060
|
-
|
|
1061
|
-
${exception.mark.snippet}`;
|
|
1062
|
-
return `${exception.reason} ${where}`;
|
|
1063
|
-
}
|
|
1064
|
-
var YAMLException = class extends Error {
|
|
1065
|
-
reason;
|
|
1066
|
-
mark;
|
|
1067
|
-
constructor(reason, mark) {
|
|
1068
|
-
super();
|
|
1069
|
-
this.name = "YAMLException";
|
|
1070
|
-
this.reason = reason;
|
|
1071
|
-
this.mark = mark;
|
|
1072
|
-
this.message = formatError(this, false);
|
|
1073
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
1074
|
-
}
|
|
1075
|
-
toString(compact) {
|
|
1076
|
-
return `${this.name}: ${formatError(this, compact)}`;
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
|
-
function throwErrorAt(source, position, message, filename = "") {
|
|
1080
|
-
let line = 0;
|
|
1081
|
-
let lineStart = 0;
|
|
1082
|
-
for (let index = 0; index < position; index++) {
|
|
1083
|
-
const ch = source.charCodeAt(index);
|
|
1084
|
-
if (ch === 10) {
|
|
1085
|
-
line++;
|
|
1086
|
-
lineStart = index + 1;
|
|
1087
|
-
} else if (ch === 13) {
|
|
1088
|
-
line++;
|
|
1089
|
-
if (source.charCodeAt(index + 1) === 10) index++;
|
|
1090
|
-
lineStart = index + 1;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
const mark = {
|
|
1094
|
-
name: filename,
|
|
1095
|
-
buffer: source,
|
|
1096
|
-
position,
|
|
1097
|
-
line,
|
|
1098
|
-
column: position - lineStart
|
|
1099
|
-
};
|
|
1100
|
-
mark.snippet = makeSnippet(mark);
|
|
1101
|
-
throw new YAMLException(message, mark);
|
|
1102
|
-
}
|
|
1103
|
-
var NO_RANGE$3 = -1;
|
|
1104
|
-
function simpleEscapeSequence(c) {
|
|
1105
|
-
switch (c) {
|
|
1106
|
-
case 48:
|
|
1107
|
-
return "\0";
|
|
1108
|
-
case 97:
|
|
1109
|
-
return "\x07";
|
|
1110
|
-
case 98:
|
|
1111
|
-
return "\b";
|
|
1112
|
-
case 116:
|
|
1113
|
-
return " ";
|
|
1114
|
-
case 9:
|
|
1115
|
-
return " ";
|
|
1116
|
-
case 110:
|
|
1117
|
-
return "\n";
|
|
1118
|
-
case 118:
|
|
1119
|
-
return "\v";
|
|
1120
|
-
case 102:
|
|
1121
|
-
return "\f";
|
|
1122
|
-
case 114:
|
|
1123
|
-
return "\r";
|
|
1124
|
-
case 101:
|
|
1125
|
-
return "\x1B";
|
|
1126
|
-
case 32:
|
|
1127
|
-
return " ";
|
|
1128
|
-
case 34:
|
|
1129
|
-
return '"';
|
|
1130
|
-
case 47:
|
|
1131
|
-
return "/";
|
|
1132
|
-
case 92:
|
|
1133
|
-
return "\\";
|
|
1134
|
-
case 78:
|
|
1135
|
-
return "\x85";
|
|
1136
|
-
case 95:
|
|
1137
|
-
return "\xA0";
|
|
1138
|
-
case 76:
|
|
1139
|
-
return "\u2028";
|
|
1140
|
-
case 80:
|
|
1141
|
-
return "\u2029";
|
|
1142
|
-
default:
|
|
1143
|
-
return "";
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
var simpleEscapeCheck = new Array(256);
|
|
1147
|
-
var simpleEscapeMap = new Array(256);
|
|
1148
|
-
for (let i = 0; i < 256; i++) {
|
|
1149
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1150
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1151
|
-
}
|
|
1152
|
-
function charFromCodepoint(c) {
|
|
1153
|
-
if (c <= 65535) return String.fromCharCode(c);
|
|
1154
|
-
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1155
|
-
}
|
|
1156
|
-
function fromHexCode$1(c) {
|
|
1157
|
-
if (c >= 48 && c <= 57) return c - 48;
|
|
1158
|
-
return (c | 32) - 97 + 10;
|
|
1159
|
-
}
|
|
1160
|
-
function escapedHexLen$1(c) {
|
|
1161
|
-
if (c === 120) return 2;
|
|
1162
|
-
if (c === 117) return 4;
|
|
1163
|
-
return 8;
|
|
1164
|
-
}
|
|
1165
|
-
function skipFoldedBreaks(input, position, end) {
|
|
1166
|
-
let breaks = 0;
|
|
1167
|
-
while (position < end) {
|
|
1168
|
-
const ch = input.charCodeAt(position);
|
|
1169
|
-
if (ch === 10) {
|
|
1170
|
-
breaks++;
|
|
1171
|
-
position++;
|
|
1172
|
-
} else if (ch === 13) {
|
|
1173
|
-
breaks++;
|
|
1174
|
-
position++;
|
|
1175
|
-
if (input.charCodeAt(position) === 10) position++;
|
|
1176
|
-
} else if (ch === 32 || ch === 9) position++;
|
|
1177
|
-
else break;
|
|
1178
|
-
}
|
|
1179
|
-
return {
|
|
1180
|
-
position,
|
|
1181
|
-
breaks
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
function foldedBreaks(count) {
|
|
1185
|
-
if (count === 1) return " ";
|
|
1186
|
-
return "\n".repeat(count - 1);
|
|
1187
|
-
}
|
|
1188
|
-
function getPlainValue(input, start, end) {
|
|
1189
|
-
let result = "";
|
|
1190
|
-
let position = start;
|
|
1191
|
-
let captureStart = start;
|
|
1192
|
-
let captureEnd = start;
|
|
1193
|
-
while (position < end) {
|
|
1194
|
-
const ch = input.charCodeAt(position);
|
|
1195
|
-
if (ch === 10 || ch === 13) {
|
|
1196
|
-
result += input.slice(captureStart, captureEnd);
|
|
1197
|
-
const fold = skipFoldedBreaks(input, position, end);
|
|
1198
|
-
result += foldedBreaks(fold.breaks);
|
|
1199
|
-
position = captureStart = captureEnd = fold.position;
|
|
1200
|
-
} else {
|
|
1201
|
-
position++;
|
|
1202
|
-
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
return result + input.slice(captureStart, captureEnd);
|
|
1206
|
-
}
|
|
1207
|
-
function getSingleQuotedValue(input, start, end) {
|
|
1208
|
-
let result = "";
|
|
1209
|
-
let position = start;
|
|
1210
|
-
let captureStart = start;
|
|
1211
|
-
let captureEnd = start;
|
|
1212
|
-
while (position < end) {
|
|
1213
|
-
const ch = input.charCodeAt(position);
|
|
1214
|
-
if (ch === 39) {
|
|
1215
|
-
result += input.slice(captureStart, position) + "'";
|
|
1216
|
-
position += 2;
|
|
1217
|
-
captureStart = captureEnd = position;
|
|
1218
|
-
} else if (ch === 10 || ch === 13) {
|
|
1219
|
-
result += input.slice(captureStart, captureEnd);
|
|
1220
|
-
const fold = skipFoldedBreaks(input, position, end);
|
|
1221
|
-
result += foldedBreaks(fold.breaks);
|
|
1222
|
-
position = captureStart = captureEnd = fold.position;
|
|
1223
|
-
} else {
|
|
1224
|
-
position++;
|
|
1225
|
-
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
return result + input.slice(captureStart, end);
|
|
1229
|
-
}
|
|
1230
|
-
function getDoubleQuotedValue(input, start, end) {
|
|
1231
|
-
let result = "";
|
|
1232
|
-
let position = start;
|
|
1233
|
-
let captureStart = start;
|
|
1234
|
-
let captureEnd = start;
|
|
1235
|
-
while (position < end) {
|
|
1236
|
-
const ch = input.charCodeAt(position);
|
|
1237
|
-
if (ch === 92) {
|
|
1238
|
-
result += input.slice(captureStart, position);
|
|
1239
|
-
position++;
|
|
1240
|
-
const escaped = input.charCodeAt(position);
|
|
1241
|
-
if (escaped === 10 || escaped === 13) position = skipFoldedBreaks(input, position, end).position;
|
|
1242
|
-
else if (escaped < 256 && simpleEscapeCheck[escaped]) {
|
|
1243
|
-
result += simpleEscapeMap[escaped];
|
|
1244
|
-
position++;
|
|
1245
|
-
} else {
|
|
1246
|
-
let hexLength = escapedHexLen$1(escaped);
|
|
1247
|
-
let hexResult = 0;
|
|
1248
|
-
for (; hexLength > 0; hexLength--) {
|
|
1249
|
-
position++;
|
|
1250
|
-
const digit = fromHexCode$1(input.charCodeAt(position));
|
|
1251
|
-
hexResult = (hexResult << 4) + digit;
|
|
1252
|
-
}
|
|
1253
|
-
result += charFromCodepoint(hexResult);
|
|
1254
|
-
position++;
|
|
1255
|
-
}
|
|
1256
|
-
captureStart = captureEnd = position;
|
|
1257
|
-
} else if (ch === 10 || ch === 13) {
|
|
1258
|
-
result += input.slice(captureStart, captureEnd);
|
|
1259
|
-
const fold = skipFoldedBreaks(input, position, end);
|
|
1260
|
-
result += foldedBreaks(fold.breaks);
|
|
1261
|
-
position = captureStart = captureEnd = fold.position;
|
|
1262
|
-
} else {
|
|
1263
|
-
position++;
|
|
1264
|
-
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
return result + input.slice(captureStart, end);
|
|
1268
|
-
}
|
|
1269
|
-
function getBlockValue(input, start, end, indent, chomping, folded) {
|
|
1270
|
-
const textIndent = indent < 0 ? 0 : indent;
|
|
1271
|
-
const region = input.slice(start, end).replace(/\r\n?/g, "\n");
|
|
1272
|
-
const lines = region === "" ? [] : (region.endsWith("\n") ? region.slice(0, -1) : region).split("\n");
|
|
1273
|
-
let result = "";
|
|
1274
|
-
let didReadContent = false;
|
|
1275
|
-
let emptyLines = 0;
|
|
1276
|
-
let atMoreIndented = false;
|
|
1277
|
-
for (const line of lines) {
|
|
1278
|
-
let column = 0;
|
|
1279
|
-
while (column < textIndent && line.charCodeAt(column) === 32) column++;
|
|
1280
|
-
if (indent < 0 || column >= line.length) {
|
|
1281
|
-
emptyLines++;
|
|
1282
|
-
continue;
|
|
1283
|
-
}
|
|
1284
|
-
const content = line.slice(textIndent);
|
|
1285
|
-
const first = content.charCodeAt(0);
|
|
1286
|
-
if (folded) if (first === 32 || first === 9) {
|
|
1287
|
-
atMoreIndented = true;
|
|
1288
|
-
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1289
|
-
} else if (atMoreIndented) {
|
|
1290
|
-
atMoreIndented = false;
|
|
1291
|
-
result += "\n".repeat(emptyLines + 1);
|
|
1292
|
-
} else if (emptyLines === 0) {
|
|
1293
|
-
if (didReadContent) result += " ";
|
|
1294
|
-
} else result += "\n".repeat(emptyLines);
|
|
1295
|
-
else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1296
|
-
result += content;
|
|
1297
|
-
didReadContent = true;
|
|
1298
|
-
emptyLines = 0;
|
|
1299
|
-
}
|
|
1300
|
-
if (chomping === 3) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1301
|
-
else if (chomping !== 2) {
|
|
1302
|
-
if (didReadContent) result += "\n";
|
|
1303
|
-
}
|
|
1304
|
-
return result;
|
|
1305
|
-
}
|
|
1306
|
-
function getScalarValue(input, scalar) {
|
|
1307
|
-
if (scalar.valueStart === NO_RANGE$3) return "";
|
|
1308
|
-
const { valueStart, valueEnd } = scalar;
|
|
1309
|
-
if (scalar.fast) return input.slice(valueStart, valueEnd);
|
|
1310
|
-
switch (scalar.style) {
|
|
1311
|
-
case 2:
|
|
1312
|
-
return getSingleQuotedValue(input, valueStart, valueEnd);
|
|
1313
|
-
case 3:
|
|
1314
|
-
return getDoubleQuotedValue(input, valueStart, valueEnd);
|
|
1315
|
-
case 4:
|
|
1316
|
-
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
|
|
1317
|
-
case 5:
|
|
1318
|
-
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
|
|
1319
|
-
default:
|
|
1320
|
-
return getPlainValue(input, valueStart, valueEnd);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
var DEFAULT_TAG_HANDLERS = {
|
|
1324
|
-
"!": "!",
|
|
1325
|
-
"!!": "tag:yaml.org,2002:"
|
|
1326
|
-
};
|
|
1327
|
-
function tagNameFull(rawTag, tagHandlers) {
|
|
1328
|
-
if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
|
|
1329
|
-
const handleEnd = rawTag.indexOf("!", 1);
|
|
1330
|
-
const handle = handleEnd === -1 ? "!" : rawTag.slice(0, handleEnd + 1);
|
|
1331
|
-
const prefix = tagHandlers?.[handle] ?? DEFAULT_TAG_HANDLERS[handle] ?? handle;
|
|
1332
|
-
return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
|
|
1333
|
-
}
|
|
1334
|
-
var NO_RANGE$2 = -1;
|
|
1335
|
-
var DEFAULT_CONSTRUCTOR_OPTIONS = {
|
|
1336
|
-
filename: "",
|
|
1337
|
-
schema: CORE_SCHEMA,
|
|
1338
|
-
json: false,
|
|
1339
|
-
maxTotalMergeKeys: 1e4,
|
|
1340
|
-
maxAliases: -1
|
|
1341
|
-
};
|
|
1342
|
-
function eventPosition$1(event) {
|
|
1343
|
-
if ("tagStart" in event && event.tagStart !== NO_RANGE$2) return event.tagStart;
|
|
1344
|
-
if ("anchorStart" in event && event.anchorStart !== NO_RANGE$2) return event.anchorStart;
|
|
1345
|
-
if ("valueStart" in event && event.valueStart !== NO_RANGE$2) return event.valueStart;
|
|
1346
|
-
if ("start" in event) return event.start;
|
|
1347
|
-
return 0;
|
|
1348
|
-
}
|
|
1349
|
-
function throwError$1(state, message) {
|
|
1350
|
-
throwErrorAt(state.source, state.position, message, state.filename);
|
|
1351
|
-
}
|
|
1352
|
-
function finalizeCollection(state, position, tag, carrier) {
|
|
1353
|
-
try {
|
|
1354
|
-
return tag.finalize(carrier);
|
|
1355
|
-
} catch (error) {
|
|
1356
|
-
if (error instanceof YAMLException) throw error;
|
|
1357
|
-
throwErrorAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
function lookupTag(exact, prefix, tagName) {
|
|
1361
|
-
const exactTag = exact[tagName];
|
|
1362
|
-
if (exactTag) return exactTag;
|
|
1363
|
-
for (const tag of prefix) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1364
|
-
}
|
|
1365
|
-
function findExplicitTag(state, exact, prefix, tagName, nodeKind) {
|
|
1366
|
-
const tag = lookupTag(exact, prefix, tagName);
|
|
1367
|
-
if (tag) return tag;
|
|
1368
|
-
throwError$1(state, `unknown ${nodeKind} tag !<${tagName}>`);
|
|
1369
|
-
}
|
|
1370
|
-
function constructScalar(state, event) {
|
|
1371
|
-
const source = getScalarValue(state.source, event);
|
|
1372
|
-
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1373
|
-
const strTag2 = state.schema.defaultScalarTag;
|
|
1374
|
-
if (rawTag !== "") {
|
|
1375
|
-
if (rawTag === "!") return {
|
|
1376
|
-
value: source,
|
|
1377
|
-
tag: strTag2
|
|
1378
|
-
};
|
|
1379
|
-
const tagName = tagNameFull(rawTag, state.tagHandlers);
|
|
1380
|
-
const scalarTag = lookupTag(state.schema.exact.scalar, state.schema.prefix.scalar, tagName);
|
|
1381
|
-
if (scalarTag) {
|
|
1382
|
-
const result = scalarTag.resolve(source, true, tagName);
|
|
1383
|
-
if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1384
|
-
return {
|
|
1385
|
-
value: result,
|
|
1386
|
-
tag: scalarTag
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
const collectionTagDef = lookupTag(state.schema.exact.mapping, state.schema.prefix.mapping, tagName) ?? lookupTag(state.schema.exact.sequence, state.schema.prefix.sequence, tagName);
|
|
1390
|
-
if (collectionTagDef) {
|
|
1391
|
-
if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1392
|
-
const carrier = collectionTagDef.create(tagName);
|
|
1393
|
-
return {
|
|
1394
|
-
value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier),
|
|
1395
|
-
tag: collectionTagDef
|
|
1396
|
-
};
|
|
1397
|
-
}
|
|
1398
|
-
throwError$1(state, `unknown scalar tag !<${tagName}>`);
|
|
1399
|
-
}
|
|
1400
|
-
if (event.style === 1) {
|
|
1401
|
-
const candidates = state.schema.implicitScalarByFirstChar.get(source.charAt(0)) ?? state.schema.implicitScalarAnyFirstChar;
|
|
1402
|
-
for (const tag of candidates) {
|
|
1403
|
-
const result = tag.resolve(source, false, tag.tagName);
|
|
1404
|
-
if (result !== NOT_RESOLVED) return {
|
|
1405
|
-
value: result,
|
|
1406
|
-
tag
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
return {
|
|
1411
|
-
value: strTag2.resolve(source, false, strTag2.tagName),
|
|
1412
|
-
tag: strTag2
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
function collectionTag(state, event, exact, prefix, defaultTagName, nodeKind) {
|
|
1416
|
-
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1417
|
-
const tagName = rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
|
|
1418
|
-
return {
|
|
1419
|
-
tagName,
|
|
1420
|
-
tag: findExplicitTag(state, exact, prefix, tagName, nodeKind)
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
function isMappingTag(tag) {
|
|
1424
|
-
return tag.nodeKind === "mapping";
|
|
1425
|
-
}
|
|
1426
|
-
function mergeKeys(state, frame, source, sourceTag) {
|
|
1427
|
-
for (const sourceKey of sourceTag.keys(source)) {
|
|
1428
|
-
if (state.maxTotalMergeKeys !== -1 && ++state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1429
|
-
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1430
|
-
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1431
|
-
if (err) throwError$1(state, err);
|
|
1432
|
-
(frame.overridable ??= /* @__PURE__ */ new Set()).add(sourceKey);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
function mergeSource(state, frame, source, sourceTag) {
|
|
1436
|
-
state.position = frame.keyPosition;
|
|
1437
|
-
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1438
|
-
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) for (const element of source) mergeKeys(state, frame, element, frame.tag);
|
|
1439
|
-
else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1440
|
-
}
|
|
1441
|
-
function addMappingValue(state, frame, key, value, tag) {
|
|
1442
|
-
state.position = frame.keyPosition;
|
|
1443
|
-
if (key === MERGE_KEY) {
|
|
1444
|
-
mergeSource(state, frame, value, tag);
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
if (!state.json && frame.tag.has(frame.value, key) && !frame.overridable?.has(key)) throwError$1(state, "duplicated mapping key");
|
|
1448
|
-
const err = frame.tag.addPair(frame.value, key, value);
|
|
1449
|
-
if (err) throwError$1(state, err);
|
|
1450
|
-
frame.overridable?.delete(key);
|
|
1451
|
-
}
|
|
1452
|
-
function addValue(state, value, tag) {
|
|
1453
|
-
const frame = state.frames[state.frames.length - 1];
|
|
1454
|
-
if (frame.kind === "document") {
|
|
1455
|
-
frame.value = value;
|
|
1456
|
-
frame.hasValue = true;
|
|
1457
|
-
} else if (frame.kind === "sequence") {
|
|
1458
|
-
if (frame.merge) {
|
|
1459
|
-
if (!isMappingTag(tag)) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1460
|
-
}
|
|
1461
|
-
const err = frame.tag.addItem(frame.value, value, frame.index++);
|
|
1462
|
-
if (err) throwError$1(state, err);
|
|
1463
|
-
} else if (frame.hasKey) {
|
|
1464
|
-
const key = frame.key;
|
|
1465
|
-
frame.key = void 0;
|
|
1466
|
-
frame.hasKey = false;
|
|
1467
|
-
addMappingValue(state, frame, key, value, tag);
|
|
1468
|
-
} else {
|
|
1469
|
-
frame.key = value;
|
|
1470
|
-
frame.keyPosition = state.position;
|
|
1471
|
-
frame.hasKey = true;
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
function storeAnchor(state, event, value, tag, isValueFinal) {
|
|
1475
|
-
if (event.anchorStart !== NO_RANGE$2) {
|
|
1476
|
-
const anchor = {
|
|
1477
|
-
value,
|
|
1478
|
-
tag,
|
|
1479
|
-
isValueFinal
|
|
1480
|
-
};
|
|
1481
|
-
state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
|
|
1482
|
-
return anchor;
|
|
1483
|
-
}
|
|
1484
|
-
return null;
|
|
1485
|
-
}
|
|
1486
|
-
function constructFromEvents(events, options) {
|
|
1487
|
-
const state = {
|
|
1488
|
-
...DEFAULT_CONSTRUCTOR_OPTIONS,
|
|
1489
|
-
...options,
|
|
1490
|
-
events,
|
|
1491
|
-
documents: [],
|
|
1492
|
-
eventIndex: 0,
|
|
1493
|
-
position: 0,
|
|
1494
|
-
frames: [],
|
|
1495
|
-
anchors: /* @__PURE__ */ new Map(),
|
|
1496
|
-
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
1497
|
-
totalMergeKeys: 0,
|
|
1498
|
-
aliasCount: 0
|
|
1499
|
-
};
|
|
1500
|
-
while (state.eventIndex < state.events.length) {
|
|
1501
|
-
const event = state.events[state.eventIndex++];
|
|
1502
|
-
state.position = eventPosition$1(event);
|
|
1503
|
-
switch (event.type) {
|
|
1504
|
-
case 1:
|
|
1505
|
-
state.anchors = /* @__PURE__ */ new Map();
|
|
1506
|
-
state.aliasCount = 0;
|
|
1507
|
-
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
1508
|
-
for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
|
|
1509
|
-
state.frames.push({
|
|
1510
|
-
kind: "document",
|
|
1511
|
-
position: state.position,
|
|
1512
|
-
value: void 0,
|
|
1513
|
-
hasValue: false
|
|
1514
|
-
});
|
|
1515
|
-
break;
|
|
1516
|
-
case 4: {
|
|
1517
|
-
const { value, tag } = constructScalar(state, event);
|
|
1518
|
-
storeAnchor(state, event, value, tag, true);
|
|
1519
|
-
addValue(state, value, tag);
|
|
1520
|
-
break;
|
|
1521
|
-
}
|
|
1522
|
-
case 2: {
|
|
1523
|
-
const definition = collectionTag(state, event, state.schema.exact.sequence, state.schema.prefix.sequence, "tag:yaml.org,2002:seq", "sequence");
|
|
1524
|
-
const value = definition.tag.create(definition.tagName);
|
|
1525
|
-
const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
|
|
1526
|
-
const parent = state.frames[state.frames.length - 1];
|
|
1527
|
-
const merge = parent !== void 0 && parent.kind === "mapping" && parent.hasKey && parent.key === MERGE_KEY;
|
|
1528
|
-
state.frames.push({
|
|
1529
|
-
kind: "sequence",
|
|
1530
|
-
position: state.position,
|
|
1531
|
-
value,
|
|
1532
|
-
tag: definition.tag,
|
|
1533
|
-
anchor,
|
|
1534
|
-
index: 0,
|
|
1535
|
-
merge
|
|
1536
|
-
});
|
|
1537
|
-
break;
|
|
1538
|
-
}
|
|
1539
|
-
case 3: {
|
|
1540
|
-
const definition = collectionTag(state, event, state.schema.exact.mapping, state.schema.prefix.mapping, "tag:yaml.org,2002:map", "mapping");
|
|
1541
|
-
const value = definition.tag.create(definition.tagName);
|
|
1542
|
-
const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
|
|
1543
|
-
state.frames.push({
|
|
1544
|
-
kind: "mapping",
|
|
1545
|
-
position: state.position,
|
|
1546
|
-
value,
|
|
1547
|
-
tag: definition.tag,
|
|
1548
|
-
anchor,
|
|
1549
|
-
key: void 0,
|
|
1550
|
-
keyPosition: state.position,
|
|
1551
|
-
hasKey: false,
|
|
1552
|
-
overridable: null
|
|
1553
|
-
});
|
|
1554
|
-
break;
|
|
1555
|
-
}
|
|
1556
|
-
case 5: {
|
|
1557
|
-
if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
|
|
1558
|
-
const name = state.source.slice(event.anchorStart, event.anchorEnd);
|
|
1559
|
-
const anchor = state.anchors.get(name);
|
|
1560
|
-
if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
|
|
1561
|
-
if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
|
|
1562
|
-
addValue(state, anchor.value, anchor.tag);
|
|
1563
|
-
break;
|
|
1564
|
-
}
|
|
1565
|
-
case 6: {
|
|
1566
|
-
const frame = state.frames.pop();
|
|
1567
|
-
if (frame.kind === "document") state.documents.push(frame.value);
|
|
1568
|
-
else {
|
|
1569
|
-
const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
|
|
1570
|
-
if (frame.anchor) {
|
|
1571
|
-
frame.anchor.value = value;
|
|
1572
|
-
frame.anchor.isValueFinal = true;
|
|
1573
|
-
}
|
|
1574
|
-
addValue(state, value, frame.tag);
|
|
1575
|
-
}
|
|
1576
|
-
break;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
return state.documents;
|
|
1581
|
-
}
|
|
1582
|
-
var NO_RANGE$1 = -1;
|
|
1583
|
-
var HAS_OWN = Object.prototype.hasOwnProperty;
|
|
1584
|
-
var CONTEXT_FLOW_IN = 1;
|
|
1585
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
1586
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
1587
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
1588
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1589
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
|
|
1590
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
|
|
1591
|
-
var NS_URI_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
|
|
1592
|
-
var NS_TAG_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
|
|
1593
|
-
var PATTERN_TAG_URI = new RegExp(`^(?:${NS_URI_CHAR})*$`);
|
|
1594
|
-
var PATTERN_TAG_SUFFIX = new RegExp(`^(?:${NS_TAG_CHAR})+$`);
|
|
1595
|
-
var PATTERN_TAG_PREFIX = new RegExp(`^(?:!(?:${NS_URI_CHAR})*|${NS_TAG_CHAR}(?:${NS_URI_CHAR})*)$`);
|
|
1596
|
-
var DEFAULT_PARSER_OPTIONS = {
|
|
1597
|
-
filename: "",
|
|
1598
|
-
maxDepth: 100
|
|
1599
|
-
};
|
|
1600
|
-
function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
1601
|
-
state.events.push({
|
|
1602
|
-
type: 1,
|
|
1603
|
-
explicitStart,
|
|
1604
|
-
explicitEnd,
|
|
1605
|
-
directives: state.directives
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1609
|
-
state.events.push({
|
|
1610
|
-
type: 2,
|
|
1611
|
-
start,
|
|
1612
|
-
anchorStart,
|
|
1613
|
-
anchorEnd,
|
|
1614
|
-
tagStart,
|
|
1615
|
-
tagEnd,
|
|
1616
|
-
style
|
|
1617
|
-
});
|
|
1618
|
-
}
|
|
1619
|
-
function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1620
|
-
state.events.push({
|
|
1621
|
-
type: 3,
|
|
1622
|
-
start,
|
|
1623
|
-
anchorStart,
|
|
1624
|
-
anchorEnd,
|
|
1625
|
-
tagStart,
|
|
1626
|
-
tagEnd,
|
|
1627
|
-
style
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = 1, indent = -1, fast = false) {
|
|
1631
|
-
state.events.push({
|
|
1632
|
-
type: 4,
|
|
1633
|
-
valueStart,
|
|
1634
|
-
valueEnd,
|
|
1635
|
-
anchorStart,
|
|
1636
|
-
anchorEnd,
|
|
1637
|
-
tagStart,
|
|
1638
|
-
tagEnd,
|
|
1639
|
-
style,
|
|
1640
|
-
chomping,
|
|
1641
|
-
indent,
|
|
1642
|
-
fast
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
function addAliasEvent(state, anchorStart, anchorEnd) {
|
|
1646
|
-
state.events.push({
|
|
1647
|
-
type: 5,
|
|
1648
|
-
anchorStart,
|
|
1649
|
-
anchorEnd
|
|
1650
|
-
});
|
|
1651
|
-
}
|
|
1652
|
-
function addPopEvent(state) {
|
|
1653
|
-
state.events.push({ type: 6 });
|
|
1654
|
-
}
|
|
1655
|
-
function addEmptyScalarEvent(state) {
|
|
1656
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 1);
|
|
1657
|
-
}
|
|
1658
|
-
function emptyProperties() {
|
|
1659
|
-
return {
|
|
1660
|
-
anchorStart: NO_RANGE$1,
|
|
1661
|
-
anchorEnd: NO_RANGE$1,
|
|
1662
|
-
tagStart: NO_RANGE$1,
|
|
1663
|
-
tagEnd: NO_RANGE$1
|
|
1664
|
-
};
|
|
1665
|
-
}
|
|
1666
|
-
function snapshotState(state) {
|
|
1667
|
-
return {
|
|
1668
|
-
position: state.position,
|
|
1669
|
-
line: state.line,
|
|
1670
|
-
lineStart: state.lineStart,
|
|
1671
|
-
lineIndent: state.lineIndent,
|
|
1672
|
-
firstTabInLine: state.firstTabInLine,
|
|
1673
|
-
eventsLength: state.events.length
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
function restoreState(state, snapshot) {
|
|
1677
|
-
state.position = snapshot.position;
|
|
1678
|
-
state.line = snapshot.line;
|
|
1679
|
-
state.lineStart = snapshot.lineStart;
|
|
1680
|
-
state.lineIndent = snapshot.lineIndent;
|
|
1681
|
-
state.firstTabInLine = snapshot.firstTabInLine;
|
|
1682
|
-
state.events.length = snapshot.eventsLength;
|
|
1683
|
-
}
|
|
1684
|
-
function throwError(state, message) {
|
|
1685
|
-
throwErrorAt(state.input.slice(0, state.length), state.position, message, state.filename);
|
|
1686
|
-
}
|
|
1687
|
-
function isEol(c) {
|
|
1688
|
-
return c === 10 || c === 13;
|
|
1689
|
-
}
|
|
1690
|
-
function isWhiteSpace(c) {
|
|
1691
|
-
return c === 9 || c === 32;
|
|
1692
|
-
}
|
|
1693
|
-
function isWsOrEol(c) {
|
|
1694
|
-
return isWhiteSpace(c) || isEol(c);
|
|
1695
|
-
}
|
|
1696
|
-
function isWsOrEolOrEnd(c) {
|
|
1697
|
-
return c === 0 || isWsOrEol(c);
|
|
1698
|
-
}
|
|
1699
|
-
function isFlowIndicator(c) {
|
|
1700
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1701
|
-
}
|
|
1702
|
-
function fromDecimalCode(c) {
|
|
1703
|
-
return c >= 48 && c <= 57 ? c - 48 : -1;
|
|
1704
|
-
}
|
|
1705
|
-
function fromHexCode(c) {
|
|
1706
|
-
if (c >= 48 && c <= 57) return c - 48;
|
|
1707
|
-
const lc = c | 32;
|
|
1708
|
-
if (lc >= 97 && lc <= 102) return lc - 97 + 10;
|
|
1709
|
-
return -1;
|
|
1710
|
-
}
|
|
1711
|
-
function escapedHexLen(c) {
|
|
1712
|
-
if (c === 120) return 2;
|
|
1713
|
-
if (c === 117) return 4;
|
|
1714
|
-
if (c === 85) return 8;
|
|
1715
|
-
return 0;
|
|
1716
|
-
}
|
|
1717
|
-
function isSimpleEscape(c) {
|
|
1718
|
-
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;
|
|
1719
|
-
}
|
|
1720
|
-
function consumeLineBreak(state) {
|
|
1721
|
-
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1722
|
-
else {
|
|
1723
|
-
state.position++;
|
|
1724
|
-
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1725
|
-
}
|
|
1726
|
-
state.line++;
|
|
1727
|
-
state.lineStart = state.position;
|
|
1728
|
-
state.lineIndent = 0;
|
|
1729
|
-
state.firstTabInLine = -1;
|
|
1730
|
-
}
|
|
1731
|
-
function skipSeparationSpace(state, allowComments) {
|
|
1732
|
-
let lineBreaks = 0;
|
|
1733
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1734
|
-
let hasSeparation = state.position === state.lineStart || isWsOrEol(state.input.charCodeAt(state.position - 1));
|
|
1735
|
-
while (ch !== 0) {
|
|
1736
|
-
while (isWhiteSpace(ch)) {
|
|
1737
|
-
hasSeparation = true;
|
|
1738
|
-
if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
|
|
1739
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1740
|
-
}
|
|
1741
|
-
if (allowComments && hasSeparation && ch === 35) do
|
|
1742
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1743
|
-
while (!isEol(ch) && ch !== 0);
|
|
1744
|
-
if (!isEol(ch)) break;
|
|
1745
|
-
consumeLineBreak(state);
|
|
1746
|
-
lineBreaks++;
|
|
1747
|
-
hasSeparation = true;
|
|
1748
|
-
ch = state.input.charCodeAt(state.position);
|
|
1749
|
-
while (ch === 32) {
|
|
1750
|
-
state.lineIndent++;
|
|
1751
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
return lineBreaks;
|
|
1755
|
-
}
|
|
1756
|
-
function testDocumentSeparator(state, position = state.position) {
|
|
1757
|
-
const ch = state.input.charCodeAt(position);
|
|
1758
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(position + 1) && ch === state.input.charCodeAt(position + 2)) {
|
|
1759
|
-
const following = state.input.charCodeAt(position + 3);
|
|
1760
|
-
return following === 0 || isWsOrEol(following);
|
|
1761
|
-
}
|
|
1762
|
-
return false;
|
|
1763
|
-
}
|
|
1764
|
-
function skipUntilLineEnd(state) {
|
|
1765
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1766
|
-
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1767
|
-
}
|
|
1768
|
-
function checkPrintable(state, start, end) {
|
|
1769
|
-
if (PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state, "the stream contains non-printable characters");
|
|
1770
|
-
}
|
|
1771
|
-
function readTagProperty(state, props, inFlow) {
|
|
1772
|
-
if (state.input.charCodeAt(state.position) !== 33) return false;
|
|
1773
|
-
if (props.tagStart !== NO_RANGE$1) throwError(state, "duplication of a tag property");
|
|
1774
|
-
const start = state.position;
|
|
1775
|
-
let isVerbatim = false;
|
|
1776
|
-
let isNamed = false;
|
|
1777
|
-
let tagHandle = "!";
|
|
1778
|
-
let ch = state.input.charCodeAt(++state.position);
|
|
1779
|
-
if (ch === 60) {
|
|
1780
|
-
isVerbatim = true;
|
|
1781
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1782
|
-
} else if (ch === 33) {
|
|
1783
|
-
isNamed = true;
|
|
1784
|
-
tagHandle = "!!";
|
|
1785
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1786
|
-
}
|
|
1787
|
-
let suffixStart = state.position;
|
|
1788
|
-
let tagName;
|
|
1789
|
-
if (isVerbatim) {
|
|
1790
|
-
while (ch !== 0 && ch !== 62) ch = state.input.charCodeAt(++state.position);
|
|
1791
|
-
if (ch !== 62) throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1792
|
-
tagName = state.input.slice(suffixStart, state.position);
|
|
1793
|
-
state.position++;
|
|
1794
|
-
} else {
|
|
1795
|
-
while (ch !== 0 && !isWsOrEol(ch) && !(inFlow && isFlowIndicator(ch))) {
|
|
1796
|
-
if (ch === 33) if (!isNamed) {
|
|
1797
|
-
tagHandle = state.input.slice(suffixStart - 1, state.position + 1);
|
|
1798
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
|
|
1799
|
-
isNamed = true;
|
|
1800
|
-
suffixStart = state.position + 1;
|
|
1801
|
-
} else throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1802
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1803
|
-
}
|
|
1804
|
-
tagName = state.input.slice(suffixStart, state.position);
|
|
1805
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1806
|
-
}
|
|
1807
|
-
if (tagName && !(isVerbatim ? PATTERN_TAG_URI.test(tagName) : PATTERN_TAG_SUFFIX.test(tagName))) throwError(state, `tag name cannot contain such characters: ${tagName}`);
|
|
1808
|
-
if (!isVerbatim && tagHandle !== "!" && tagHandle !== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state, `undeclared tag handle "${tagHandle}"`);
|
|
1809
|
-
props.tagStart = start;
|
|
1810
|
-
props.tagEnd = state.position;
|
|
1811
|
-
return true;
|
|
1812
|
-
}
|
|
1813
|
-
function readAnchorProperty(state, props) {
|
|
1814
|
-
if (state.input.charCodeAt(state.position) !== 38) return false;
|
|
1815
|
-
if (props.anchorStart !== NO_RANGE$1) throwError(state, "duplication of an anchor property");
|
|
1816
|
-
state.position++;
|
|
1817
|
-
const start = state.position;
|
|
1818
|
-
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1819
|
-
if (state.position === start) throwError(state, "name of an anchor node must contain at least one character");
|
|
1820
|
-
props.anchorStart = start;
|
|
1821
|
-
props.anchorEnd = state.position;
|
|
1822
|
-
return true;
|
|
1823
|
-
}
|
|
1824
|
-
function readAlias(state, props) {
|
|
1825
|
-
if (state.input.charCodeAt(state.position) !== 42) return false;
|
|
1826
|
-
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) throwError(state, "alias node should not have any properties");
|
|
1827
|
-
state.position++;
|
|
1828
|
-
const start = state.position;
|
|
1829
|
-
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1830
|
-
if (state.position === start) throwError(state, "name of an alias node must contain at least one character");
|
|
1831
|
-
addAliasEvent(state, start, state.position);
|
|
1832
|
-
return true;
|
|
1833
|
-
}
|
|
1834
|
-
function readFlowScalarBreak(state, nodeIndent) {
|
|
1835
|
-
skipSeparationSpace(state, false);
|
|
1836
|
-
if (state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
1837
|
-
}
|
|
1838
|
-
function readSingleQuotedScalar(state, nodeIndent, props) {
|
|
1839
|
-
if (state.input.charCodeAt(state.position) !== 39) return false;
|
|
1840
|
-
state.position++;
|
|
1841
|
-
const start = state.position;
|
|
1842
|
-
let simple = true;
|
|
1843
|
-
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1844
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1845
|
-
if (ch === 39) {
|
|
1846
|
-
if (state.input.charCodeAt(state.position + 1) === 39) {
|
|
1847
|
-
simple = false;
|
|
1848
|
-
state.position += 2;
|
|
1849
|
-
continue;
|
|
1850
|
-
}
|
|
1851
|
-
const end = state.position;
|
|
1852
|
-
state.position++;
|
|
1853
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2, 1, -1, simple);
|
|
1854
|
-
return true;
|
|
1855
|
-
}
|
|
1856
|
-
if (isEol(ch)) {
|
|
1857
|
-
simple = false;
|
|
1858
|
-
readFlowScalarBreak(state, nodeIndent);
|
|
1859
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1860
|
-
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1861
|
-
else state.position++;
|
|
1862
|
-
}
|
|
1863
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1864
|
-
}
|
|
1865
|
-
function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
1866
|
-
if (state.input.charCodeAt(state.position) !== 34) return false;
|
|
1867
|
-
state.position++;
|
|
1868
|
-
const start = state.position;
|
|
1869
|
-
let simple = true;
|
|
1870
|
-
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1871
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1872
|
-
if (ch === 34) {
|
|
1873
|
-
const end = state.position;
|
|
1874
|
-
state.position++;
|
|
1875
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 3, 1, -1, simple);
|
|
1876
|
-
return true;
|
|
1877
|
-
}
|
|
1878
|
-
if (ch === 92) {
|
|
1879
|
-
simple = false;
|
|
1880
|
-
const escaped = state.input.charCodeAt(++state.position);
|
|
1881
|
-
if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
|
|
1882
|
-
else if (isSimpleEscape(escaped)) state.position++;
|
|
1883
|
-
else {
|
|
1884
|
-
let hexLength = escapedHexLen(escaped);
|
|
1885
|
-
if (hexLength === 0) throwError(state, "unknown escape sequence");
|
|
1886
|
-
while (hexLength-- > 0) {
|
|
1887
|
-
state.position++;
|
|
1888
|
-
if (fromHexCode(state.input.charCodeAt(state.position)) < 0) throwError(state, "expected hexadecimal character");
|
|
1889
|
-
}
|
|
1890
|
-
state.position++;
|
|
1891
|
-
}
|
|
1892
|
-
} else if (isEol(ch)) {
|
|
1893
|
-
simple = false;
|
|
1894
|
-
readFlowScalarBreak(state, nodeIndent);
|
|
1895
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1896
|
-
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1897
|
-
else state.position++;
|
|
1898
|
-
}
|
|
1899
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1900
|
-
}
|
|
1901
|
-
function readBlockScalar(state, parentIndent, props) {
|
|
1902
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1903
|
-
let chomping = 1;
|
|
1904
|
-
let indent = -1;
|
|
1905
|
-
let detectedIndent = false;
|
|
1906
|
-
if (ch !== 124 && ch !== 62) return false;
|
|
1907
|
-
const style = ch === 124 ? 4 : 5;
|
|
1908
|
-
state.position++;
|
|
1909
|
-
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1910
|
-
const current = state.input.charCodeAt(state.position);
|
|
1911
|
-
const digit = fromDecimalCode(current);
|
|
1912
|
-
if (current === 43 || current === 45) {
|
|
1913
|
-
if (chomping !== 1) throwError(state, "repeat of a chomping mode identifier");
|
|
1914
|
-
chomping = current === 43 ? 3 : 2;
|
|
1915
|
-
state.position++;
|
|
1916
|
-
} else if (digit >= 0) {
|
|
1917
|
-
if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1918
|
-
if (detectedIndent) throwError(state, "repeat of an indentation width identifier");
|
|
1919
|
-
indent = parentIndent + digit - 1;
|
|
1920
|
-
detectedIndent = true;
|
|
1921
|
-
state.position++;
|
|
1922
|
-
} else break;
|
|
1923
|
-
}
|
|
1924
|
-
let hadWhitespace = false;
|
|
1925
|
-
while (isWhiteSpace(state.input.charCodeAt(state.position))) {
|
|
1926
|
-
hadWhitespace = true;
|
|
1927
|
-
state.position++;
|
|
1928
|
-
}
|
|
1929
|
-
if (hadWhitespace && state.input.charCodeAt(state.position) === 35) skipUntilLineEnd(state);
|
|
1930
|
-
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
1931
|
-
else if (state.input.charCodeAt(state.position) !== 0) throwError(state, "a line break is expected");
|
|
1932
|
-
let contentIndent = detectedIndent ? indent : -1;
|
|
1933
|
-
let maxLeadingIndent = 0;
|
|
1934
|
-
const valueStart = state.position;
|
|
1935
|
-
let valueEnd = state.position;
|
|
1936
|
-
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1937
|
-
const linePosition = state.position;
|
|
1938
|
-
let column = 0;
|
|
1939
|
-
while (state.input.charCodeAt(linePosition + column) === 32) column++;
|
|
1940
|
-
const first = state.input.charCodeAt(linePosition + column);
|
|
1941
|
-
if (first === 0) {
|
|
1942
|
-
if (contentIndent >= 0) {
|
|
1943
|
-
if (column > contentIndent) valueEnd = linePosition + column;
|
|
1944
|
-
} else if (column > 0) valueEnd = linePosition + column;
|
|
1945
|
-
break;
|
|
1946
|
-
}
|
|
1947
|
-
if (linePosition === state.lineStart && testDocumentSeparator(state, linePosition)) break;
|
|
1948
|
-
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
1949
|
-
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
1950
|
-
if (first === 9 && column < parentIndent) {
|
|
1951
|
-
state.position = linePosition + column;
|
|
1952
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1953
|
-
}
|
|
1954
|
-
if (column < maxLeadingIndent) {
|
|
1955
|
-
state.position = linePosition + column;
|
|
1956
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
if (contentIndent === -1 && first !== 0 && !isEol(first) && column < parentIndent) {
|
|
1960
|
-
state.lineIndent = column;
|
|
1961
|
-
state.position = linePosition + column;
|
|
1962
|
-
break;
|
|
1963
|
-
}
|
|
1964
|
-
if (!detectedIndent && first !== 0 && !isEol(first) && contentIndent === -1) contentIndent = column;
|
|
1965
|
-
const requiredIndent = contentIndent === -1 ? parentIndent + 1 : contentIndent;
|
|
1966
|
-
if (first !== 0 && !isEol(first) && column < requiredIndent) {
|
|
1967
|
-
state.lineIndent = column;
|
|
1968
|
-
state.position = linePosition + column;
|
|
1969
|
-
break;
|
|
1970
|
-
}
|
|
1971
|
-
skipUntilLineEnd(state);
|
|
1972
|
-
valueEnd = state.position;
|
|
1973
|
-
if (isEol(state.input.charCodeAt(state.position))) {
|
|
1974
|
-
consumeLineBreak(state);
|
|
1975
|
-
valueEnd = state.position;
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
checkPrintable(state, valueStart, valueEnd);
|
|
1979
|
-
addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
|
|
1980
|
-
return true;
|
|
1981
|
-
}
|
|
1982
|
-
function canStartPlainScalar(state, nodeContext) {
|
|
1983
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1984
|
-
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
1985
|
-
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;
|
|
1986
|
-
if (ch === 63 || ch === 45) {
|
|
1987
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
1988
|
-
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) return false;
|
|
1989
|
-
}
|
|
1990
|
-
return true;
|
|
1991
|
-
}
|
|
1992
|
-
function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
1993
|
-
if (!canStartPlainScalar(state, nodeContext)) return false;
|
|
1994
|
-
const start = state.position;
|
|
1995
|
-
let end = state.position;
|
|
1996
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1997
|
-
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
1998
|
-
let multiline = false;
|
|
1999
|
-
while (ch !== 0) {
|
|
2000
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) break;
|
|
2001
|
-
if (ch === 58) {
|
|
2002
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
2003
|
-
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
2004
|
-
} else if (ch === 35) {
|
|
2005
|
-
if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
|
|
2006
|
-
} else if (inFlow && isFlowIndicator(ch)) break;
|
|
2007
|
-
else if (isEol(ch)) {
|
|
2008
|
-
const savedPosition = state.position;
|
|
2009
|
-
const savedLine = state.line;
|
|
2010
|
-
const savedLineStart = state.lineStart;
|
|
2011
|
-
const savedLineIndent = state.lineIndent;
|
|
2012
|
-
skipSeparationSpace(state, false);
|
|
2013
|
-
if (state.lineIndent >= nodeIndent) {
|
|
2014
|
-
multiline = true;
|
|
2015
|
-
ch = state.input.charCodeAt(state.position);
|
|
2016
|
-
continue;
|
|
2017
|
-
}
|
|
2018
|
-
state.position = savedPosition;
|
|
2019
|
-
state.line = savedLine;
|
|
2020
|
-
state.lineStart = savedLineStart;
|
|
2021
|
-
state.lineIndent = savedLineIndent;
|
|
2022
|
-
break;
|
|
2023
|
-
}
|
|
2024
|
-
if (!isWhiteSpace(ch)) end = state.position + 1;
|
|
2025
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2026
|
-
}
|
|
2027
|
-
if (end === start) return false;
|
|
2028
|
-
checkPrintable(state, start, end);
|
|
2029
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1, 1, -1, !multiline);
|
|
2030
|
-
return true;
|
|
2031
|
-
}
|
|
2032
|
-
function skipFlowSeparationSpace(state, nodeIndent) {
|
|
2033
|
-
const startLine = state.line;
|
|
2034
|
-
skipSeparationSpace(state, true);
|
|
2035
|
-
if (state.line > startLine && state.lineIndent < nodeIndent || state.firstTabInLine !== -1 && state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
2036
|
-
}
|
|
2037
|
-
function readFlowCollection(state, nodeIndent, props) {
|
|
2038
|
-
const ch = state.input.charCodeAt(state.position);
|
|
2039
|
-
const isMapping = ch === 123;
|
|
2040
|
-
const start = state.position;
|
|
2041
|
-
let readNext = true;
|
|
2042
|
-
if (ch !== 91 && ch !== 123) return false;
|
|
2043
|
-
const terminator = isMapping ? 125 : 93;
|
|
2044
|
-
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
|
|
2045
|
-
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
|
|
2046
|
-
state.position++;
|
|
2047
|
-
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2048
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2049
|
-
let ch2 = state.input.charCodeAt(state.position);
|
|
2050
|
-
if (ch2 === terminator) {
|
|
2051
|
-
state.position++;
|
|
2052
|
-
addPopEvent(state);
|
|
2053
|
-
return true;
|
|
2054
|
-
} else if (!readNext) throwError(state, "missed comma between flow collection entries");
|
|
2055
|
-
else if (ch2 === 44) throwError(state, "expected the node content, but found ','");
|
|
2056
|
-
let isPair = false;
|
|
2057
|
-
let isExplicitPair = false;
|
|
2058
|
-
if (ch2 === 63 && isWsOrEol(state.input.charCodeAt(state.position + 1))) {
|
|
2059
|
-
isPair = isExplicitPair = true;
|
|
2060
|
-
state.position += 1;
|
|
2061
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2062
|
-
}
|
|
2063
|
-
const entryLine = state.line;
|
|
2064
|
-
const entryStart = snapshotState(state);
|
|
2065
|
-
const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2066
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2067
|
-
ch2 = state.input.charCodeAt(state.position);
|
|
2068
|
-
if ((isMapping || isExplicitPair || state.line === entryLine) && ch2 === 58) {
|
|
2069
|
-
isPair = true;
|
|
2070
|
-
state.position++;
|
|
2071
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2072
|
-
if (!isMapping) {
|
|
2073
|
-
restoreState(state, entryStart);
|
|
2074
|
-
addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
|
|
2075
|
-
if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
|
|
2076
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2077
|
-
state.position++;
|
|
2078
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2079
|
-
} else if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2080
|
-
if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
|
|
2081
|
-
skipFlowSeparationSpace(state, nodeIndent);
|
|
2082
|
-
if (!isMapping) addPopEvent(state);
|
|
2083
|
-
} else if (isMapping && isPair) {
|
|
2084
|
-
if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2085
|
-
addEmptyScalarEvent(state);
|
|
2086
|
-
} else if (isMapping) addEmptyScalarEvent(state);
|
|
2087
|
-
else if (isPair) {
|
|
2088
|
-
restoreState(state, entryStart);
|
|
2089
|
-
addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
|
|
2090
|
-
parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
2091
|
-
addEmptyScalarEvent(state);
|
|
2092
|
-
addPopEvent(state);
|
|
2093
|
-
}
|
|
2094
|
-
ch2 = state.input.charCodeAt(state.position);
|
|
2095
|
-
if (ch2 === 44) {
|
|
2096
|
-
readNext = true;
|
|
2097
|
-
state.position++;
|
|
2098
|
-
} else readNext = false;
|
|
2099
|
-
}
|
|
2100
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
2101
|
-
}
|
|
2102
|
-
function readBlockSequence(state, nodeIndent, props) {
|
|
2103
|
-
if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
|
|
2104
|
-
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2105
|
-
while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
|
|
2106
|
-
if (state.firstTabInLine !== -1) {
|
|
2107
|
-
state.position = state.firstTabInLine;
|
|
2108
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
2109
|
-
}
|
|
2110
|
-
const entryLine = state.line;
|
|
2111
|
-
state.position++;
|
|
2112
|
-
const hadBreak = skipSeparationSpace(state, true) > 0;
|
|
2113
|
-
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");
|
|
2114
|
-
if (hadBreak && state.lineIndent <= nodeIndent) addEmptyScalarEvent(state);
|
|
2115
|
-
else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2116
|
-
skipSeparationSpace(state, true);
|
|
2117
|
-
if (state.lineIndent < nodeIndent || state.position >= state.length) break;
|
|
2118
|
-
if (state.lineIndent > nodeIndent) throwError(state, "bad indentation of a sequence entry");
|
|
2119
|
-
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");
|
|
2120
|
-
}
|
|
2121
|
-
addPopEvent(state);
|
|
2122
|
-
return true;
|
|
2123
|
-
}
|
|
2124
|
-
function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
2125
|
-
let atExplicitKey = false;
|
|
2126
|
-
let detected = false;
|
|
2127
|
-
let mappingOpened = false;
|
|
2128
|
-
let pendingExplicitKey = false;
|
|
2129
|
-
if (state.firstTabInLine !== -1) return false;
|
|
2130
|
-
let ch = state.input.charCodeAt(state.position);
|
|
2131
|
-
while (ch !== 0) {
|
|
2132
|
-
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
2133
|
-
state.position = state.firstTabInLine;
|
|
2134
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
2135
|
-
}
|
|
2136
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
2137
|
-
const entryLine = state.line;
|
|
2138
|
-
if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
|
|
2139
|
-
if (!mappingOpened) {
|
|
2140
|
-
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2141
|
-
mappingOpened = true;
|
|
2142
|
-
}
|
|
2143
|
-
if (ch === 63) {
|
|
2144
|
-
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2145
|
-
detected = true;
|
|
2146
|
-
atExplicitKey = true;
|
|
2147
|
-
} else if (atExplicitKey) atExplicitKey = false;
|
|
2148
|
-
else {
|
|
2149
|
-
addEmptyScalarEvent(state);
|
|
2150
|
-
detected = true;
|
|
2151
|
-
atExplicitKey = false;
|
|
2152
|
-
}
|
|
2153
|
-
state.position += 1;
|
|
2154
|
-
pendingExplicitKey = true;
|
|
2155
|
-
} else {
|
|
2156
|
-
if (atExplicitKey) {
|
|
2157
|
-
addEmptyScalarEvent(state);
|
|
2158
|
-
atExplicitKey = false;
|
|
2159
|
-
}
|
|
2160
|
-
const beforeKey = snapshotState(state);
|
|
2161
|
-
if (!parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
|
|
2162
|
-
if (state.line === entryLine) {
|
|
2163
|
-
ch = state.input.charCodeAt(state.position);
|
|
2164
|
-
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2165
|
-
if (ch === 58) {
|
|
2166
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2167
|
-
if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2168
|
-
if (!mappingOpened) {
|
|
2169
|
-
restoreState(state, beforeKey);
|
|
2170
|
-
addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2171
|
-
mappingOpened = true;
|
|
2172
|
-
parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
|
|
2173
|
-
ch = state.input.charCodeAt(state.position);
|
|
2174
|
-
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2175
|
-
state.position++;
|
|
2176
|
-
}
|
|
2177
|
-
detected = true;
|
|
2178
|
-
atExplicitKey = false;
|
|
2179
|
-
pendingExplicitKey = false;
|
|
2180
|
-
} else if (detected) throwError(state, "expected ':' after a mapping key");
|
|
2181
|
-
else {
|
|
2182
|
-
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2183
|
-
restoreState(state, beforeKey);
|
|
2184
|
-
return false;
|
|
2185
|
-
}
|
|
2186
|
-
return true;
|
|
2187
|
-
}
|
|
2188
|
-
} else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2189
|
-
else {
|
|
2190
|
-
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2191
|
-
restoreState(state, beforeKey);
|
|
2192
|
-
return false;
|
|
2193
|
-
}
|
|
2194
|
-
return true;
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, pendingExplicitKey)) pendingExplicitKey = false;
|
|
2198
|
-
if (!atExplicitKey) {
|
|
2199
|
-
if (pendingExplicitKey) {
|
|
2200
|
-
addEmptyScalarEvent(state);
|
|
2201
|
-
pendingExplicitKey = false;
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
skipSeparationSpace(state, true);
|
|
2205
|
-
ch = state.input.charCodeAt(state.position);
|
|
2206
|
-
if ((state.line === entryLine || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
|
|
2207
|
-
else if (state.lineIndent < nodeIndent) break;
|
|
2208
|
-
}
|
|
2209
|
-
if (!detected) return false;
|
|
2210
|
-
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2211
|
-
if (mappingOpened) addPopEvent(state);
|
|
2212
|
-
return true;
|
|
2213
|
-
}
|
|
2214
|
-
function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping = true) {
|
|
2215
|
-
if (state.depth >= state.maxDepth) throwError(state, `nesting exceeded maxDepth (${state.maxDepth})`);
|
|
2216
|
-
state.depth++;
|
|
2217
|
-
let indentStatus = 1;
|
|
2218
|
-
let atNewLine = false;
|
|
2219
|
-
let hasContent = false;
|
|
2220
|
-
let propertyStart = null;
|
|
2221
|
-
const props = emptyProperties();
|
|
2222
|
-
let allowBlockScalars = nodeContext === CONTEXT_BLOCK_OUT || nodeContext === CONTEXT_BLOCK_IN;
|
|
2223
|
-
let allowBlockCollections = allowBlockScalars;
|
|
2224
|
-
const allowBlockStyles = allowBlockScalars;
|
|
2225
|
-
if (allowToSeek && skipSeparationSpace(state, true)) {
|
|
2226
|
-
atNewLine = true;
|
|
2227
|
-
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2228
|
-
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2229
|
-
else indentStatus = -1;
|
|
2230
|
-
}
|
|
2231
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2232
|
-
state.depth--;
|
|
2233
|
-
return false;
|
|
2234
|
-
}
|
|
2235
|
-
if (indentStatus === 1) while (true) {
|
|
2236
|
-
const ch = state.input.charCodeAt(state.position);
|
|
2237
|
-
const propertyState = snapshotState(state);
|
|
2238
|
-
if (atNewLine && indentStatus !== 1 && (ch === 33 || ch === 38)) break;
|
|
2239
|
-
if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
|
|
2240
|
-
const fallbackState = snapshotState(state);
|
|
2241
|
-
const flowIndent = parentIndent + 1;
|
|
2242
|
-
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === 3) {
|
|
2243
|
-
state.depth--;
|
|
2244
|
-
return true;
|
|
2245
|
-
}
|
|
2246
|
-
restoreState(state, fallbackState);
|
|
2247
|
-
}
|
|
2248
|
-
if (atNewLine && (ch === 33 && props.tagStart !== NO_RANGE$1 || ch === 38 && props.anchorStart !== NO_RANGE$1)) break;
|
|
2249
|
-
if (!readTagProperty(state, props, nodeContext === CONTEXT_FLOW_IN) && !readAnchorProperty(state, props)) break;
|
|
2250
|
-
if (propertyStart === null) propertyStart = propertyState;
|
|
2251
|
-
if (skipSeparationSpace(state, true)) {
|
|
2252
|
-
atNewLine = true;
|
|
2253
|
-
allowBlockCollections = allowBlockStyles;
|
|
2254
|
-
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2255
|
-
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2256
|
-
else indentStatus = -1;
|
|
2257
|
-
} else allowBlockCollections = false;
|
|
2258
|
-
}
|
|
2259
|
-
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
|
|
2260
|
-
if (indentStatus === 1 || nodeContext === CONTEXT_BLOCK_OUT) {
|
|
2261
|
-
const flowIndent = nodeContext === CONTEXT_FLOW_IN || nodeContext === CONTEXT_FLOW_OUT ? parentIndent : parentIndent + 1;
|
|
2262
|
-
const blockIndent = state.position - state.lineStart;
|
|
2263
|
-
if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent, props) || readBlockMapping(state, blockIndent, flowIndent, props)) || readFlowCollection(state, flowIndent, props)) hasContent = true;
|
|
2264
|
-
else {
|
|
2265
|
-
const ch = state.input.charCodeAt(state.position);
|
|
2266
|
-
if (propertyStart !== null && allowPropertyMapping && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62) {
|
|
2267
|
-
const fallbackState = snapshotState(state);
|
|
2268
|
-
const propertyIndent = propertyStart.position - propertyStart.lineStart;
|
|
2269
|
-
restoreState(state, propertyStart);
|
|
2270
|
-
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === 3) hasContent = true;
|
|
2271
|
-
else restoreState(state, fallbackState);
|
|
2272
|
-
}
|
|
2273
|
-
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;
|
|
2274
|
-
}
|
|
2275
|
-
else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent, props);
|
|
2276
|
-
}
|
|
2277
|
-
allowBlockScalars = allowBlockScalars && !hasContent;
|
|
2278
|
-
if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
|
|
2279
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
|
|
2280
|
-
hasContent = true;
|
|
2281
|
-
}
|
|
2282
|
-
state.depth--;
|
|
2283
|
-
return hasContent || props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1;
|
|
2284
|
-
}
|
|
2285
|
-
function readDirective(state) {
|
|
2286
|
-
if (state.lineIndent > 0 || state.input.charCodeAt(state.position) !== 37) return false;
|
|
2287
|
-
state.position++;
|
|
2288
|
-
const nameStart = state.position;
|
|
2289
|
-
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2290
|
-
const name = state.input.slice(nameStart, state.position);
|
|
2291
|
-
const args = [];
|
|
2292
|
-
if (name.length === 0) throwError(state, "directive name must not be less than one character in length");
|
|
2293
|
-
while (state.input.charCodeAt(state.position) !== 0 && !isEol(state.input.charCodeAt(state.position))) {
|
|
2294
|
-
while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position++;
|
|
2295
|
-
if (state.input.charCodeAt(state.position) === 35 || isEol(state.input.charCodeAt(state.position)) || state.input.charCodeAt(state.position) === 0) break;
|
|
2296
|
-
const start = state.position;
|
|
2297
|
-
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2298
|
-
args.push(state.input.slice(start, state.position));
|
|
2299
|
-
}
|
|
2300
|
-
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
2301
|
-
if (name === "YAML") {
|
|
2302
|
-
if (state.directives.some((directive) => directive.kind === "yaml")) throwError(state, "duplication of %YAML directive");
|
|
2303
|
-
if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
|
|
2304
|
-
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
2305
|
-
if (match === null) throwError(state, "ill-formed argument of the YAML directive");
|
|
2306
|
-
if (parseInt(match[1], 10) !== 1) throwError(state, "unacceptable YAML version of the document");
|
|
2307
|
-
state.directives.push({
|
|
2308
|
-
kind: "yaml",
|
|
2309
|
-
version: args[0]
|
|
2310
|
-
});
|
|
2311
|
-
} else if (name === "TAG") {
|
|
2312
|
-
if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
|
|
2313
|
-
const [handle, prefix] = args;
|
|
2314
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
2315
|
-
if (HAS_OWN.call(state.tagHandlers, handle)) throwError(state, `there is a previously declared suffix for "${handle}" tag handle`);
|
|
2316
|
-
if (!PATTERN_TAG_PREFIX.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
2317
|
-
state.tagHandlers[handle] = prefix;
|
|
2318
|
-
state.directives.push({
|
|
2319
|
-
kind: "tag",
|
|
2320
|
-
handle,
|
|
2321
|
-
prefix
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2324
|
-
return true;
|
|
2325
|
-
}
|
|
2326
|
-
function readDocument(state) {
|
|
2327
|
-
state.directives = [];
|
|
2328
|
-
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
2329
|
-
let hasDirectives = false;
|
|
2330
|
-
skipSeparationSpace(state, true);
|
|
2331
|
-
while (readDirective(state)) {
|
|
2332
|
-
hasDirectives = true;
|
|
2333
|
-
skipSeparationSpace(state, true);
|
|
2334
|
-
}
|
|
2335
|
-
let explicitStart = false;
|
|
2336
|
-
let explicitEnd = false;
|
|
2337
|
-
let allowCompact = true;
|
|
2338
|
-
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))) {
|
|
2339
|
-
explicitStart = true;
|
|
2340
|
-
const markerLine = state.line;
|
|
2341
|
-
state.position += 3;
|
|
2342
|
-
skipSeparationSpace(state, true);
|
|
2343
|
-
allowCompact = state.line > markerLine;
|
|
2344
|
-
} else if (hasDirectives) throwError(state, "directives end mark is expected");
|
|
2345
|
-
const documentEventIndex = state.events.length;
|
|
2346
|
-
if (!explicitStart && state.position === state.lineStart && state.input.charCodeAt(state.position) === 46 && testDocumentSeparator(state)) {
|
|
2347
|
-
state.position += 3;
|
|
2348
|
-
skipSeparationSpace(state, true);
|
|
2349
|
-
return;
|
|
2350
|
-
}
|
|
2351
|
-
addDocumentEvent(state, explicitStart, false);
|
|
2352
|
-
if (!parseNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
|
|
2353
|
-
skipSeparationSpace(state, true);
|
|
2354
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2355
|
-
explicitEnd = state.input.charCodeAt(state.position) === 46;
|
|
2356
|
-
if (explicitEnd) {
|
|
2357
|
-
const markerLine = state.line;
|
|
2358
|
-
state.position += 3;
|
|
2359
|
-
skipSeparationSpace(state, true);
|
|
2360
|
-
if (state.line === markerLine && state.position < state.length) throwError(state, "end of the stream or a document separator is expected");
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
const documentEvent = state.events[documentEventIndex];
|
|
2364
|
-
if (documentEvent?.type === 1) documentEvent.explicitEnd = explicitEnd;
|
|
2365
|
-
addPopEvent(state);
|
|
2366
|
-
if (!explicitEnd && state.position < state.length && !(state.position === state.lineStart && testDocumentSeparator(state))) throwError(state, "end of the stream or a document separator is expected");
|
|
2367
|
-
}
|
|
2368
|
-
function parseEvents(input, options) {
|
|
2369
|
-
const length = input.length;
|
|
2370
|
-
const state = {
|
|
2371
|
-
...DEFAULT_PARSER_OPTIONS,
|
|
2372
|
-
...options,
|
|
2373
|
-
input: `${input}\0`,
|
|
2374
|
-
length,
|
|
2375
|
-
position: 0,
|
|
2376
|
-
line: 0,
|
|
2377
|
-
lineStart: 0,
|
|
2378
|
-
lineIndent: 0,
|
|
2379
|
-
firstTabInLine: -1,
|
|
2380
|
-
depth: 0,
|
|
2381
|
-
directives: [],
|
|
2382
|
-
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
2383
|
-
events: []
|
|
2384
|
-
};
|
|
2385
|
-
const nullpos = input.indexOf("\0");
|
|
2386
|
-
if (nullpos !== -1) throwErrorAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2387
|
-
if (state.input.charCodeAt(state.position) === 65279) state.position++;
|
|
2388
|
-
while (state.position < state.length) {
|
|
2389
|
-
skipSeparationSpace(state, true);
|
|
2390
|
-
if (state.position >= state.length) break;
|
|
2391
|
-
const documentStart = state.position;
|
|
2392
|
-
readDocument(state);
|
|
2393
|
-
if (state.position === documentStart)
|
|
2394
|
-
throwError(state, "can not read a document");
|
|
2395
|
-
}
|
|
2396
|
-
return state.events;
|
|
2397
|
-
}
|
|
2398
|
-
var DEFAULT_LOAD_OPTIONS = {
|
|
2399
|
-
...DEFAULT_PARSER_OPTIONS,
|
|
2400
|
-
...DEFAULT_CONSTRUCTOR_OPTIONS
|
|
2401
|
-
};
|
|
2402
|
-
function loadDocuments(input, options = {}) {
|
|
2403
|
-
const opts = {
|
|
2404
|
-
...DEFAULT_LOAD_OPTIONS,
|
|
2405
|
-
...options
|
|
2406
|
-
};
|
|
2407
|
-
const source = String(input);
|
|
2408
|
-
const PARSER_OPT_KEYS = Object.keys(DEFAULT_PARSER_OPTIONS);
|
|
2409
|
-
const CONSTRUCTOR_OPT_KEYS = Object.keys(DEFAULT_CONSTRUCTOR_OPTIONS);
|
|
2410
|
-
return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
|
|
2411
|
-
...pick(opts, CONSTRUCTOR_OPT_KEYS),
|
|
2412
|
-
source
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
function load(input, options) {
|
|
2416
|
-
const documents = loadDocuments(input, options);
|
|
2417
|
-
if (documents.length === 0) throw new YAMLException("expected a document, but the input is empty");
|
|
2418
|
-
if (documents.length === 1) return documents[0];
|
|
2419
|
-
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2420
|
-
}
|
|
2421
|
-
var ESCAPE_SEQUENCES = {};
|
|
2422
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2423
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2424
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2425
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2426
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2427
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2428
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2429
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2430
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2431
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2432
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2433
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2434
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2435
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2436
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2437
|
-
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2438
|
-
indent: 2,
|
|
2439
|
-
seqNoIndent: false,
|
|
2440
|
-
seqInlineFirst: true,
|
|
2441
|
-
sortKeys: false,
|
|
2442
|
-
lineWidth: 80,
|
|
2443
|
-
flowBracketPadding: false,
|
|
2444
|
-
flowSkipCommaSpace: false,
|
|
2445
|
-
flowSkipColonSpace: false,
|
|
2446
|
-
quoteFlowKeys: false,
|
|
2447
|
-
quoteStyle: "single",
|
|
2448
|
-
forceQuotes: false,
|
|
2449
|
-
tagBeforeAnchor: false
|
|
2450
|
-
};
|
|
2451
|
-
var DEFAULT_DUMP_SCHEMA = YAML11_SCHEMA.withTags({
|
|
2452
|
-
...intYaml11Tag,
|
|
2453
|
-
resolve: (source, isExplicit, tagName) => {
|
|
2454
|
-
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2455
|
-
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2456
|
-
}
|
|
2457
|
-
}, {
|
|
2458
|
-
...floatYaml11Tag,
|
|
2459
|
-
resolve: (source, isExplicit, tagName) => {
|
|
2460
|
-
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2461
|
-
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2462
|
-
}
|
|
2463
|
-
});
|
|
2464
|
-
var DEFAULT_DUMP_OPTIONS = {
|
|
2465
|
-
...DEFAULT_PRESENTER_OPTIONS,
|
|
2466
|
-
schema: DEFAULT_DUMP_SCHEMA,
|
|
2467
|
-
skipInvalid: false,
|
|
2468
|
-
noRefs: false,
|
|
2469
|
-
flowLevel: -1,
|
|
2470
|
-
transform: () => {
|
|
2471
|
-
}
|
|
2472
|
-
};
|
|
2473
|
-
|
|
2474
|
-
// src/skill-scripts/shared/execution-routing.ts
|
|
2475
|
-
var WORKSPACE_CONFIG_RELPATH = path4.join("config", "config.yaml");
|
|
2476
|
-
var EXECUTION_ROUTING_SECTION = "execution_routing";
|
|
2477
|
-
var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2478
|
-
var isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
2479
|
-
var validateTarget = (profileName, index, raw, supportedHarnesses, errors) => {
|
|
2480
|
-
const label = `profile "${profileName}" models[${index}]`;
|
|
2481
|
-
if (!isPlainObject2(raw)) {
|
|
2482
|
-
errors.push(`${label} must be a mapping with an exact "model" string.`);
|
|
2483
|
-
return null;
|
|
2484
|
-
}
|
|
2485
|
-
for (const key of Object.keys(raw)) {
|
|
2486
|
-
if (key !== "model" && key !== "harness" && key !== "reasoning_effort") {
|
|
2487
|
-
errors.push(`${label} has unknown key "${key}".`);
|
|
2488
|
-
return null;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
if (!isNonEmptyString(raw.model)) {
|
|
2492
|
-
errors.push(`${label} requires a non-empty exact "model" string.`);
|
|
2493
|
-
return null;
|
|
2494
|
-
}
|
|
2495
|
-
const target = { model: raw.model };
|
|
2496
|
-
if ("harness" in raw) {
|
|
2497
|
-
if (!isNonEmptyString(raw.harness)) {
|
|
2498
|
-
errors.push(`${label} "harness" must be a non-empty string when provided.`);
|
|
2499
|
-
return null;
|
|
2500
|
-
}
|
|
2501
|
-
if (!supportedHarnesses.includes(raw.harness)) {
|
|
2502
|
-
errors.push(`${label} harness "${raw.harness}" is not a supported harness.`);
|
|
2503
|
-
return null;
|
|
2504
|
-
}
|
|
2505
|
-
target.harness = raw.harness;
|
|
2506
|
-
}
|
|
2507
|
-
if ("reasoning_effort" in raw) {
|
|
2508
|
-
if (!isNonEmptyString(raw.reasoning_effort)) {
|
|
2509
|
-
errors.push(`${label} "reasoning_effort" must be a non-empty string when provided.`);
|
|
2510
|
-
return null;
|
|
2511
|
-
}
|
|
2512
|
-
target.reasoning_effort = raw.reasoning_effort;
|
|
2513
|
-
}
|
|
2514
|
-
return target;
|
|
2515
|
-
};
|
|
2516
|
-
var validateProfile = (name, raw, supportedHarnesses, errors) => {
|
|
2517
|
-
if (!isPlainObject2(raw)) {
|
|
2518
|
-
errors.push(`profile "${name}" must be a mapping with "description" and "models".`);
|
|
2519
|
-
return null;
|
|
2520
|
-
}
|
|
2521
|
-
if ("resolver" in raw) {
|
|
2522
|
-
errors.push(
|
|
2523
|
-
`profile "${name}" configures a per-profile resolver; only the single top-level "resolver" is supported.`
|
|
2524
|
-
);
|
|
2525
|
-
return null;
|
|
2526
|
-
}
|
|
2527
|
-
for (const key of Object.keys(raw)) {
|
|
2528
|
-
if (key !== "description" && key !== "models") {
|
|
2529
|
-
errors.push(`profile "${name}" has unknown key "${key}".`);
|
|
2530
|
-
return null;
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
if (!isNonEmptyString(raw.description)) {
|
|
2534
|
-
errors.push(`profile "${name}" requires a non-empty LLM-facing "description".`);
|
|
2535
|
-
return null;
|
|
2536
|
-
}
|
|
2537
|
-
if (!Array.isArray(raw.models) || raw.models.length === 0) {
|
|
2538
|
-
errors.push(`profile "${name}" requires a non-empty ordered "models" array.`);
|
|
2539
|
-
return null;
|
|
2540
|
-
}
|
|
2541
|
-
const targets = [];
|
|
2542
|
-
for (let i = 0; i < raw.models.length; i += 1) {
|
|
2543
|
-
const target = validateTarget(name, i, raw.models[i], supportedHarnesses, errors);
|
|
2544
|
-
if (!target) return null;
|
|
2545
|
-
targets.push(target);
|
|
2546
|
-
}
|
|
2547
|
-
return { name, description: raw.description.trim(), targets };
|
|
2548
|
-
};
|
|
2549
|
-
var loadRoutingConfig = (strikethrooRoot, supportedHarnesses) => {
|
|
2550
|
-
const configPath = path4.join(strikethrooRoot, WORKSPACE_CONFIG_RELPATH);
|
|
2551
|
-
let contents;
|
|
2552
|
-
try {
|
|
2553
|
-
contents = fs4.readFileSync(configPath, "utf8");
|
|
2554
|
-
} catch {
|
|
2555
|
-
return { kind: "no-config" };
|
|
2556
|
-
}
|
|
2557
|
-
const hasContent = contents.split(/\r?\n/).some((line) => {
|
|
2558
|
-
const trimmed = line.trim();
|
|
2559
|
-
return trimmed !== "" && !trimmed.startsWith("#");
|
|
2560
|
-
});
|
|
2561
|
-
if (!hasContent) return { kind: "disabled" };
|
|
2562
|
-
let document;
|
|
2563
|
-
try {
|
|
2564
|
-
document = load(contents);
|
|
2565
|
-
} catch (error) {
|
|
2566
|
-
return {
|
|
2567
|
-
kind: "invalid",
|
|
2568
|
-
errors: [
|
|
2569
|
-
`config.yaml is not valid YAML: ${error instanceof Error ? error.message : String(error)}`
|
|
2570
|
-
]
|
|
2571
|
-
};
|
|
2572
|
-
}
|
|
2573
|
-
if (document === null || document === void 0) return { kind: "disabled" };
|
|
2574
|
-
if (!isPlainObject2(document)) {
|
|
2575
|
-
return { kind: "invalid", errors: ["config.yaml must be a YAML mapping."] };
|
|
2576
|
-
}
|
|
2577
|
-
const section = document[EXECUTION_ROUTING_SECTION];
|
|
2578
|
-
if (section === null || section === void 0) return { kind: "disabled" };
|
|
2579
|
-
const errors = [];
|
|
2580
|
-
if (!isPlainObject2(section)) {
|
|
2581
|
-
return {
|
|
2582
|
-
kind: "invalid",
|
|
2583
|
-
errors: [`config.yaml "${EXECUTION_ROUTING_SECTION}" must be a YAML mapping.`]
|
|
2584
|
-
};
|
|
2585
|
-
}
|
|
2586
|
-
for (const key of Object.keys(section)) {
|
|
2587
|
-
if (key !== "profiles" && key !== "resolver") {
|
|
2588
|
-
errors.push(`${EXECUTION_ROUTING_SECTION} has unknown key "${key}".`);
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
const rawProfiles = "profiles" in section && section.profiles == null ? {} : section.profiles;
|
|
2592
|
-
if (!("profiles" in section) || !isPlainObject2(rawProfiles)) {
|
|
2593
|
-
errors.push(`${EXECUTION_ROUTING_SECTION} requires a "profiles" mapping.`);
|
|
2594
|
-
return { kind: "invalid", errors };
|
|
2595
|
-
}
|
|
2596
|
-
const profiles = [];
|
|
2597
|
-
for (const [name, rawProfile] of Object.entries(rawProfiles)) {
|
|
2598
|
-
const profile = validateProfile(name, rawProfile, supportedHarnesses, errors);
|
|
2599
|
-
if (profile) profiles.push(profile);
|
|
2600
|
-
}
|
|
2601
|
-
let resolverScript;
|
|
2602
|
-
if ("resolver" in section) {
|
|
2603
|
-
const resolver = section.resolver;
|
|
2604
|
-
if (!isPlainObject2(resolver) || !isNonEmptyString(resolver.script)) {
|
|
2605
|
-
errors.push('resolver must be a mapping with a non-empty "script" path.');
|
|
2606
|
-
} else {
|
|
2607
|
-
for (const key of Object.keys(resolver)) {
|
|
2608
|
-
if (key !== "script") errors.push(`resolver has unknown key "${key}".`);
|
|
2609
|
-
}
|
|
2610
|
-
resolverScript = resolver.script;
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
if (errors.length > 0) return { kind: "invalid", errors };
|
|
2614
|
-
if (profiles.length === 0) return { kind: "disabled" };
|
|
2615
|
-
const config = { profiles };
|
|
2616
|
-
if (resolverScript !== void 0) config.resolverScript = resolverScript;
|
|
2617
|
-
return { kind: "config", config };
|
|
2618
|
-
};
|
|
2619
|
-
var validateAssignments = (rawMap, taskIds, profileNames) => {
|
|
2620
|
-
const errors = [];
|
|
2621
|
-
if (!isPlainObject2(rawMap)) {
|
|
2622
|
-
return {
|
|
2623
|
-
kind: "invalid",
|
|
2624
|
-
errors: ["assignment map must be a JSON object of task-ID to profile-name."]
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
const assignments = /* @__PURE__ */ new Map();
|
|
2628
|
-
const known = new Set(taskIds);
|
|
2629
|
-
for (const [rawId, rawProfile] of Object.entries(rawMap)) {
|
|
2630
|
-
if (!/^\d+$/.test(rawId.trim())) {
|
|
2631
|
-
errors.push(`assignment key "${rawId}" is not a task ID.`);
|
|
2632
|
-
continue;
|
|
2633
|
-
}
|
|
2634
|
-
const id = parseInt(rawId, 10);
|
|
2635
|
-
if (assignments.has(id)) {
|
|
2636
|
-
errors.push(`task ${id} is assigned more than once.`);
|
|
2637
|
-
continue;
|
|
2638
|
-
}
|
|
2639
|
-
if (!known.has(id)) {
|
|
2640
|
-
errors.push(`assignment references unknown task ID ${id}.`);
|
|
2641
|
-
continue;
|
|
2642
|
-
}
|
|
2643
|
-
if (typeof rawProfile !== "string" || !profileNames.includes(rawProfile)) {
|
|
2644
|
-
errors.push(`task ${id} is assigned unknown profile "${String(rawProfile)}".`);
|
|
2645
|
-
continue;
|
|
2646
|
-
}
|
|
2647
|
-
assignments.set(id, rawProfile);
|
|
2648
|
-
}
|
|
2649
|
-
for (const id of taskIds) {
|
|
2650
|
-
if (!assignments.has(id)) errors.push(`task ${id} has no profile assignment.`);
|
|
2651
|
-
}
|
|
2652
|
-
if (errors.length > 0) return { kind: "invalid", errors };
|
|
2653
|
-
return { kind: "assignments", assignments };
|
|
2654
|
-
};
|
|
2655
|
-
var writeExecutionProfileFrontmatter = (taskMarkdown, profile) => {
|
|
2656
|
-
const match = taskMarkdown.match(/^(---\r?\n)([\s\S]*?)(\r?\n---)/);
|
|
2657
|
-
if (!match) throw new Error("missing frontmatter");
|
|
2658
|
-
const opening = match[1];
|
|
2659
|
-
const frontmatter = match[2];
|
|
2660
|
-
const closing = match[3];
|
|
2661
|
-
if (opening === void 0 || frontmatter === void 0 || closing === void 0) {
|
|
2662
|
-
throw new Error("missing frontmatter");
|
|
2663
|
-
}
|
|
2664
|
-
const eol = frontmatter.includes("\r\n") ? "\r\n" : "\n";
|
|
2665
|
-
const lines = frontmatter.split(/\r?\n/);
|
|
2666
|
-
const kept = [];
|
|
2667
|
-
let inExecutionBlock = false;
|
|
2668
|
-
for (const line of lines) {
|
|
2669
|
-
if (/^execution_profile\s*:/.test(line)) continue;
|
|
2670
|
-
if (/^execution\s*:/.test(line)) {
|
|
2671
|
-
inExecutionBlock = true;
|
|
2672
|
-
continue;
|
|
2673
|
-
}
|
|
2674
|
-
if (inExecutionBlock && /^[ \t]/.test(line)) continue;
|
|
2675
|
-
inExecutionBlock = false;
|
|
2676
|
-
kept.push(line);
|
|
2677
|
-
}
|
|
2678
|
-
const newFrontmatter = [...kept, `execution_profile: ${JSON.stringify(profile)}`].join(eol);
|
|
2679
|
-
return `${opening}${newFrontmatter}${closing}${taskMarkdown.slice(match[0].length)}`;
|
|
2680
|
-
};
|
|
2681
|
-
|
|
2682
|
-
// src/skill-scripts/route-task-execution.ts
|
|
2683
|
-
var emit = (result, exitCode) => {
|
|
2684
|
-
process.stdout.write(`${JSON.stringify(result)}
|
|
2685
|
-
`);
|
|
2686
|
-
process.exit(exitCode);
|
|
2687
|
-
};
|
|
2688
|
-
var usage = () => emit(
|
|
2689
|
-
{
|
|
2690
|
-
kind: "infrastructure-failure",
|
|
2691
|
-
detail: "Usage: route-task-execution.cjs profiles <plan-id> | route-task-execution.cjs apply <plan-id> <assignment-json-file>"
|
|
2692
|
-
},
|
|
2693
|
-
2
|
|
2694
|
-
);
|
|
2695
|
-
var readTaskDocuments = (planDir) => {
|
|
2696
|
-
const tasksDir = path5.join(planDir, "tasks");
|
|
2697
|
-
let entries;
|
|
2698
|
-
try {
|
|
2699
|
-
entries = fs5.readdirSync(tasksDir, { withFileTypes: true });
|
|
2700
|
-
} catch {
|
|
2701
|
-
return { kind: "invalid", errors: [`no tasks directory at ${tasksDir}.`] };
|
|
2702
|
-
}
|
|
2703
|
-
const errors = [];
|
|
2704
|
-
const tasks = [];
|
|
2705
|
-
const seen = /* @__PURE__ */ new Map();
|
|
2706
|
-
const taskFiles = entries.filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
|
|
2707
|
-
for (const name of taskFiles) {
|
|
2708
|
-
const entry = { name };
|
|
2709
|
-
const file = path5.join(tasksDir, entry.name);
|
|
2710
|
-
const content = fs5.readFileSync(file, "utf8");
|
|
2711
|
-
const id = extractPlanId(content, file);
|
|
2712
|
-
if (id === null) {
|
|
2713
|
-
errors.push(`task file ${entry.name} has no integer id in its frontmatter.`);
|
|
2714
|
-
continue;
|
|
2715
|
-
}
|
|
2716
|
-
const duplicate = seen.get(id);
|
|
2717
|
-
if (duplicate !== void 0) {
|
|
2718
|
-
errors.push(`task id ${id} appears in both ${duplicate} and ${entry.name}.`);
|
|
2719
|
-
continue;
|
|
2720
|
-
}
|
|
2721
|
-
seen.set(id, entry.name);
|
|
2722
|
-
tasks.push({ id, file, content });
|
|
2723
|
-
}
|
|
2724
|
-
if (tasks.length === 0) errors.push("plan has no task files to route.");
|
|
2725
|
-
if (errors.length > 0) return { kind: "invalid", errors };
|
|
2726
|
-
return { kind: "tasks", tasks };
|
|
2727
|
-
};
|
|
2728
|
-
var main = () => {
|
|
2729
|
-
const [mode, planIdArg, ...rest] = process.argv.slice(2);
|
|
2730
|
-
if (mode !== "profiles" && mode !== "apply" || !planIdArg) usage();
|
|
2731
|
-
const resolved = resolvePlan(planIdArg);
|
|
2732
|
-
if (!resolved) {
|
|
2733
|
-
emit({ kind: "infrastructure-failure", detail: `plan "${planIdArg}" did not resolve.` }, 2);
|
|
2734
|
-
return;
|
|
2735
|
-
}
|
|
2736
|
-
const configResult = loadRoutingConfig(resolved.strikethrooRoot, SUPPORTED_HARNESSES);
|
|
2737
|
-
if (configResult.kind === "invalid") {
|
|
2738
|
-
emit({ kind: "invalid-config", errors: configResult.errors }, 1);
|
|
2739
|
-
}
|
|
2740
|
-
if (configResult.kind !== "config") {
|
|
2741
|
-
emit({ kind: configResult.kind }, 0);
|
|
2742
|
-
return;
|
|
2743
|
-
}
|
|
2744
|
-
const config = configResult.config;
|
|
2745
|
-
if (mode === "profiles") {
|
|
2746
|
-
emit(
|
|
2747
|
-
{
|
|
2748
|
-
kind: "profiles",
|
|
2749
|
-
profiles: config.profiles.map((profile) => ({
|
|
2750
|
-
name: profile.name,
|
|
2751
|
-
description: profile.description,
|
|
2752
|
-
targetCount: profile.targets.length
|
|
2753
|
-
})),
|
|
2754
|
-
customResolver: config.resolverScript !== void 0
|
|
2755
|
-
},
|
|
2756
|
-
0
|
|
2757
|
-
);
|
|
2758
|
-
}
|
|
2759
|
-
const [assignmentFile, ...extraArgs] = rest;
|
|
2760
|
-
if (!assignmentFile || extraArgs.length > 0) usage();
|
|
2761
|
-
const documents = readTaskDocuments(resolved.planDir);
|
|
2762
|
-
if (documents.kind === "invalid") {
|
|
2763
|
-
emit({ kind: "invalid-tasks", errors: documents.errors }, 1);
|
|
2764
|
-
return;
|
|
2765
|
-
}
|
|
2766
|
-
let rawMap;
|
|
2767
|
-
try {
|
|
2768
|
-
rawMap = JSON.parse(fs5.readFileSync(assignmentFile, "utf8"));
|
|
2769
|
-
} catch (error) {
|
|
2770
|
-
emit(
|
|
2771
|
-
{
|
|
2772
|
-
kind: "invalid-assignments",
|
|
2773
|
-
errors: [
|
|
2774
|
-
`could not read assignment map: ${error instanceof Error ? error.message : String(error)}`
|
|
2775
|
-
]
|
|
2776
|
-
},
|
|
2777
|
-
1
|
|
2778
|
-
);
|
|
2779
|
-
return;
|
|
2780
|
-
}
|
|
2781
|
-
const assignmentResult = validateAssignments(
|
|
2782
|
-
rawMap,
|
|
2783
|
-
documents.tasks.map((task) => task.id),
|
|
2784
|
-
config.profiles.map((profile) => profile.name)
|
|
2785
|
-
);
|
|
2786
|
-
if (assignmentResult.kind === "invalid") {
|
|
2787
|
-
emit({ kind: "invalid-assignments", errors: assignmentResult.errors }, 1);
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
const staged = [];
|
|
2791
|
-
for (const task of documents.tasks) {
|
|
2792
|
-
const profile = assignmentResult.assignments.get(task.id);
|
|
2793
|
-
if (!profile) {
|
|
2794
|
-
emit({ kind: "routing-failure", detail: `no profile assigned for task ${task.id}.` }, 1);
|
|
2795
|
-
return;
|
|
2796
|
-
}
|
|
2797
|
-
let next;
|
|
2798
|
-
try {
|
|
2799
|
-
next = writeExecutionProfileFrontmatter(task.content, profile);
|
|
2800
|
-
} catch (error) {
|
|
2801
|
-
emit(
|
|
2802
|
-
{
|
|
2803
|
-
kind: "routing-failure",
|
|
2804
|
-
detail: `task ${task.id} (${path5.basename(task.file)}): ${error instanceof Error ? error.message : String(error)}`
|
|
2805
|
-
},
|
|
2806
|
-
1
|
|
2807
|
-
);
|
|
2808
|
-
return;
|
|
2809
|
-
}
|
|
2810
|
-
if (!next.includes(`execution_profile: ${JSON.stringify(profile)}`)) {
|
|
2811
|
-
emit(
|
|
2812
|
-
{ kind: "routing-failure", detail: `task ${task.id} would not verify after routing.` },
|
|
2813
|
-
1
|
|
2814
|
-
);
|
|
2815
|
-
return;
|
|
2816
|
-
}
|
|
2817
|
-
staged.push({ task, next, profile });
|
|
2818
|
-
}
|
|
2819
|
-
const written = [];
|
|
2820
|
-
try {
|
|
2821
|
-
for (const { task, next } of staged) {
|
|
2822
|
-
fs5.writeFileSync(task.file, next);
|
|
2823
|
-
written.push(task);
|
|
2824
|
-
}
|
|
2825
|
-
for (const { task, next } of staged) {
|
|
2826
|
-
const reread = fs5.readFileSync(task.file, "utf8");
|
|
2827
|
-
if (reread !== next) {
|
|
2828
|
-
throw new Error(`task ${task.id} failed post-write verification.`);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
} catch (error) {
|
|
2832
|
-
for (const task of written) {
|
|
2833
|
-
try {
|
|
2834
|
-
fs5.writeFileSync(task.file, task.content);
|
|
2835
|
-
} catch {
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
emit(
|
|
2839
|
-
{
|
|
2840
|
-
kind: "infrastructure-failure",
|
|
2841
|
-
detail: `routing aborted and rolled back: ${error instanceof Error ? error.message : String(error)}`
|
|
2842
|
-
},
|
|
2843
|
-
2
|
|
2844
|
-
);
|
|
2845
|
-
return;
|
|
2846
|
-
}
|
|
2847
|
-
emit(
|
|
2848
|
-
{
|
|
2849
|
-
kind: "routed",
|
|
2850
|
-
tasks: staged.map(({ task, profile }) => ({
|
|
2851
|
-
id: task.id,
|
|
2852
|
-
file: task.file,
|
|
2853
|
-
executionProfile: profile
|
|
2854
|
-
}))
|
|
2855
|
-
},
|
|
2856
|
-
0
|
|
2857
|
-
);
|
|
2858
|
-
};
|
|
2859
|
-
try {
|
|
2860
|
-
main();
|
|
2861
|
-
} catch (error) {
|
|
2862
|
-
emit(
|
|
2863
|
-
{
|
|
2864
|
-
kind: "infrastructure-failure",
|
|
2865
|
-
detail: `execution routing failed: ${error instanceof Error ? error.message : String(error)}`
|
|
2866
|
-
},
|
|
2867
|
-
2
|
|
2868
|
-
);
|
|
2869
|
-
}
|
|
2870
|
-
/*! Bundled license information:
|
|
2871
|
-
|
|
2872
|
-
js-yaml/dist/js-yaml.mjs:
|
|
2873
|
-
(*! js-yaml 5.2.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
2874
|
-
*/
|