@codemcp/workflows 6.20.2 → 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/packages/cli/dist/{chunk-4N42FFJE.js → chunk-QMPDZD7D.js} +117 -2674
- package/packages/cli/dist/{cli-MFHC7UWY.js → cli-CY4PLNWR.js} +475 -34
- package/packages/cli/dist/{dist-ISN3FRV4.js → dist-6BKGI5U7.js} +91 -8
- package/packages/cli/dist/{dist-TDV3DJ2J.js → dist-S4HQ3JQN.js} +3 -1
- package/packages/cli/dist/index.js +2 -2
- package/packages/cli/package.json +5 -2
- package/packages/cli/resources/templates/opencode-agents/coding.md.tmpl +13 -0
- package/packages/cli/resources/templates/opencode-agents/research.md.tmpl +13 -0
- package/packages/cli/resources/templates/opencode-agents/thinking.md.tmpl +13 -0
- package/packages/cli/resources/workflows/bugfix.yaml +6 -0
- package/packages/cli/resources/workflows/epcc.yaml +3 -0
- package/packages/cli/resources/workflows/greenfield.yaml +3 -0
- package/packages/cli/resources/workflows/pr-review.yaml +2 -0
- package/packages/cli/resources/workflows/qrspi.yaml +5 -0
- package/packages/cli/resources/workflows/tdd.yaml +3 -0
- package/packages/cli/resources/workflows/waterfall.yaml +3 -0
- package/packages/core/dist/capability-hint.d.ts +28 -0
- package/packages/core/dist/capability-hint.js +52 -0
- package/packages/core/dist/capability-hint.js.map +1 -0
- package/packages/core/dist/config-manager.d.ts +19 -0
- package/packages/core/dist/config-manager.js +26 -0
- package/packages/core/dist/config-manager.js.map +1 -1
- package/packages/core/dist/index.d.ts +1 -0
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/instruction-generator.js +7 -1
- package/packages/core/dist/instruction-generator.js.map +1 -1
- package/packages/core/dist/interfaces/instruction-generator.interface.d.ts +14 -0
- package/packages/core/dist/state-machine-types.d.ts +7 -0
- package/packages/core/dist/system-prompt-generator.js +26 -4
- package/packages/core/dist/system-prompt-generator.js.map +1 -1
- package/packages/core/package.json +1 -1
- package/packages/core/resources/templates/opencode-agents/coding.md.tmpl +13 -0
- package/packages/core/resources/templates/opencode-agents/research.md.tmpl +13 -0
- package/packages/core/resources/templates/opencode-agents/thinking.md.tmpl +13 -0
- package/packages/core/resources/workflows/bugfix.yaml +6 -0
- package/packages/core/resources/workflows/epcc.yaml +3 -0
- package/packages/core/resources/workflows/greenfield.yaml +3 -0
- package/packages/core/resources/workflows/pr-review.yaml +2 -0
- package/packages/core/resources/workflows/qrspi.yaml +5 -0
- package/packages/core/resources/workflows/tdd.yaml +3 -0
- package/packages/core/resources/workflows/waterfall.yaml +3 -0
- package/packages/docs/.vitepress/dist/404.html +1 -1
- package/packages/docs/.vitepress/dist/assets/user_capability-routing.md.DbNKvMiS.js +15 -0
- package/packages/docs/.vitepress/dist/assets/user_capability-routing.md.DbNKvMiS.lean.js +1 -0
- package/packages/docs/.vitepress/dist/dev/ARCHITECTURE.html +2 -2
- package/packages/docs/.vitepress/dist/dev/DEVELOPMENT.html +2 -2
- package/packages/docs/.vitepress/dist/dev/LOGGING.html +2 -2
- package/packages/docs/.vitepress/dist/dev/PUBLISHING.html +2 -2
- package/packages/docs/.vitepress/dist/hashmap.json +1 -1
- package/packages/docs/.vitepress/dist/index.html +2 -2
- package/packages/docs/.vitepress/dist/user/advanced-engineering.html +3 -3
- package/packages/docs/.vitepress/dist/user/agent-setup.html +3 -3
- package/packages/docs/.vitepress/dist/user/beads-integration.html +2 -2
- package/packages/docs/.vitepress/dist/user/capability-routing.html +40 -0
- package/packages/docs/.vitepress/dist/user/crowd-mcp-integration.html +2 -2
- package/packages/docs/.vitepress/dist/user/custom-workflows.html +2 -2
- package/packages/docs/.vitepress/dist/user/git-commit-feature.html +2 -2
- package/packages/docs/.vitepress/dist/user/how-it-works.html +2 -2
- package/packages/docs/.vitepress/dist/user/long-term-memory.html +2 -2
- package/packages/docs/.vitepress/dist/user/packaged-workflows.html +2 -2
- package/packages/docs/.vitepress/dist/user/tutorial.html +2 -2
- package/packages/docs/.vitepress/dist/user/workflow-selection.html +2 -2
- package/packages/docs/.vitepress/dist/workflows/adr.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/big-bang-conversion.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/boundary-testing.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/bugfix.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/bugfix.yaml +6 -0
- package/packages/docs/.vitepress/dist/workflows/business-analysis.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/c4-analysis.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/epcc.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/epcc.yaml +3 -0
- package/packages/docs/.vitepress/dist/workflows/game-beginner.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/greenfield.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/greenfield.yaml +3 -0
- package/packages/docs/.vitepress/dist/workflows/minor.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/posts.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/pr-review.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/pr-review.yaml +2 -0
- package/packages/docs/.vitepress/dist/workflows/qrspi.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/qrspi.yaml +5 -0
- package/packages/docs/.vitepress/dist/workflows/sdd-bugfix-crowd.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/sdd-bugfix.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/sdd-feature-crowd.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/sdd-feature.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/sdd-greenfield-crowd.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/sdd-greenfield.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/skilled-bugfix.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/skilled-epcc.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/skilled-greenfield.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/slides.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/tdd.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/tdd.yaml +3 -0
- package/packages/docs/.vitepress/dist/workflows/waterfall.html +1 -1
- package/packages/docs/.vitepress/dist/workflows/waterfall.yaml +3 -0
- package/packages/docs/.vitepress/dist/workflows.html +1 -1
- package/packages/docs/package.json +1 -1
- package/packages/mcp-server/dist/index.js +93 -8
- package/packages/mcp-server/package.json +1 -1
- package/packages/mcp-server/resources/templates/opencode-agents/coding.md.tmpl +13 -0
- package/packages/mcp-server/resources/templates/opencode-agents/research.md.tmpl +13 -0
- package/packages/mcp-server/resources/templates/opencode-agents/thinking.md.tmpl +13 -0
- package/packages/mcp-server/resources/workflows/bugfix.yaml +6 -0
- package/packages/mcp-server/resources/workflows/epcc.yaml +3 -0
- package/packages/mcp-server/resources/workflows/greenfield.yaml +3 -0
- package/packages/mcp-server/resources/workflows/pr-review.yaml +2 -0
- package/packages/mcp-server/resources/workflows/qrspi.yaml +5 -0
- package/packages/mcp-server/resources/workflows/tdd.yaml +3 -0
- package/packages/mcp-server/resources/workflows/waterfall.yaml +3 -0
- package/packages/opencode-plugin/dist/index.js +93 -8
- package/packages/opencode-plugin/package.json +1 -1
- package/packages/opencode-plugin/resources/templates/opencode-agents/coding.md.tmpl +13 -0
- package/packages/opencode-plugin/resources/templates/opencode-agents/research.md.tmpl +13 -0
- package/packages/opencode-plugin/resources/templates/opencode-agents/thinking.md.tmpl +13 -0
- package/packages/opencode-plugin/resources/workflows/bugfix.yaml +6 -0
- package/packages/opencode-plugin/resources/workflows/epcc.yaml +3 -0
- package/packages/opencode-plugin/resources/workflows/greenfield.yaml +3 -0
- package/packages/opencode-plugin/resources/workflows/pr-review.yaml +2 -0
- package/packages/opencode-plugin/resources/workflows/qrspi.yaml +5 -0
- package/packages/opencode-plugin/resources/workflows/tdd.yaml +3 -0
- package/packages/opencode-plugin/resources/workflows/waterfall.yaml +3 -0
- package/packages/opencode-tui-plugin/package.json +1 -1
- package/packages/visualizer/package.json +1 -1
- package/resources/state-machine-schema.json +4 -0
- package/resources/templates/opencode-agents/coding.md.tmpl +13 -0
- package/resources/templates/opencode-agents/research.md.tmpl +13 -0
- package/resources/templates/opencode-agents/thinking.md.tmpl +13 -0
- package/resources/workflows/bugfix.yaml +6 -0
- package/resources/workflows/epcc.yaml +3 -0
- package/resources/workflows/greenfield.yaml +3 -0
- package/resources/workflows/pr-review.yaml +2 -0
- package/resources/workflows/qrspi.yaml +5 -0
- package/resources/workflows/tdd.yaml +3 -0
- package/resources/workflows/waterfall.yaml +3 -0
|
@@ -4,2632 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// ../core/dist/state-machine-loader.js
|
|
6
6
|
import fs from "fs";
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/.pnpm/js-yaml@4.1.1/node_modules/js-yaml/dist/js-yaml.mjs
|
|
9
|
-
function isNothing(subject) {
|
|
10
|
-
return typeof subject === "undefined" || subject === null;
|
|
11
|
-
}
|
|
12
|
-
function isObject(subject) {
|
|
13
|
-
return typeof subject === "object" && subject !== null;
|
|
14
|
-
}
|
|
15
|
-
function toArray(sequence) {
|
|
16
|
-
if (Array.isArray(sequence)) return sequence;
|
|
17
|
-
else if (isNothing(sequence)) return [];
|
|
18
|
-
return [sequence];
|
|
19
|
-
}
|
|
20
|
-
function extend(target, source) {
|
|
21
|
-
var index, length, key, sourceKeys;
|
|
22
|
-
if (source) {
|
|
23
|
-
sourceKeys = Object.keys(source);
|
|
24
|
-
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
25
|
-
key = sourceKeys[index];
|
|
26
|
-
target[key] = source[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return target;
|
|
30
|
-
}
|
|
31
|
-
function repeat(string, count) {
|
|
32
|
-
var result = "", cycle;
|
|
33
|
-
for (cycle = 0; cycle < count; cycle += 1) {
|
|
34
|
-
result += string;
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
function isNegativeZero(number) {
|
|
39
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
40
|
-
}
|
|
41
|
-
var isNothing_1 = isNothing;
|
|
42
|
-
var isObject_1 = isObject;
|
|
43
|
-
var toArray_1 = toArray;
|
|
44
|
-
var repeat_1 = repeat;
|
|
45
|
-
var isNegativeZero_1 = isNegativeZero;
|
|
46
|
-
var extend_1 = extend;
|
|
47
|
-
var common = {
|
|
48
|
-
isNothing: isNothing_1,
|
|
49
|
-
isObject: isObject_1,
|
|
50
|
-
toArray: toArray_1,
|
|
51
|
-
repeat: repeat_1,
|
|
52
|
-
isNegativeZero: isNegativeZero_1,
|
|
53
|
-
extend: extend_1
|
|
54
|
-
};
|
|
55
|
-
function formatError(exception2, compact) {
|
|
56
|
-
var where = "", message = exception2.reason || "(unknown reason)";
|
|
57
|
-
if (!exception2.mark) return message;
|
|
58
|
-
if (exception2.mark.name) {
|
|
59
|
-
where += 'in "' + exception2.mark.name + '" ';
|
|
60
|
-
}
|
|
61
|
-
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
62
|
-
if (!compact && exception2.mark.snippet) {
|
|
63
|
-
where += "\n\n" + exception2.mark.snippet;
|
|
64
|
-
}
|
|
65
|
-
return message + " " + where;
|
|
66
|
-
}
|
|
67
|
-
function YAMLException$1(reason, mark) {
|
|
68
|
-
Error.call(this);
|
|
69
|
-
this.name = "YAMLException";
|
|
70
|
-
this.reason = reason;
|
|
71
|
-
this.mark = mark;
|
|
72
|
-
this.message = formatError(this, false);
|
|
73
|
-
if (Error.captureStackTrace) {
|
|
74
|
-
Error.captureStackTrace(this, this.constructor);
|
|
75
|
-
} else {
|
|
76
|
-
this.stack = new Error().stack || "";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
80
|
-
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
81
|
-
YAMLException$1.prototype.toString = function toString(compact) {
|
|
82
|
-
return this.name + ": " + formatError(this, compact);
|
|
83
|
-
};
|
|
84
|
-
var exception = YAMLException$1;
|
|
85
|
-
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
86
|
-
var head = "";
|
|
87
|
-
var tail = "";
|
|
88
|
-
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
89
|
-
if (position - lineStart > maxHalfLength) {
|
|
90
|
-
head = " ... ";
|
|
91
|
-
lineStart = position - maxHalfLength + head.length;
|
|
92
|
-
}
|
|
93
|
-
if (lineEnd - position > maxHalfLength) {
|
|
94
|
-
tail = " ...";
|
|
95
|
-
lineEnd = position + maxHalfLength - tail.length;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
99
|
-
pos: position - lineStart + head.length
|
|
100
|
-
// relative position
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function padStart(string, max) {
|
|
104
|
-
return common.repeat(" ", max - string.length) + string;
|
|
105
|
-
}
|
|
106
|
-
function makeSnippet(mark, options) {
|
|
107
|
-
options = Object.create(options || null);
|
|
108
|
-
if (!mark.buffer) return null;
|
|
109
|
-
if (!options.maxLength) options.maxLength = 79;
|
|
110
|
-
if (typeof options.indent !== "number") options.indent = 1;
|
|
111
|
-
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
112
|
-
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
113
|
-
var re = /\r?\n|\r|\0/g;
|
|
114
|
-
var lineStarts = [0];
|
|
115
|
-
var lineEnds = [];
|
|
116
|
-
var match;
|
|
117
|
-
var foundLineNo = -1;
|
|
118
|
-
while (match = re.exec(mark.buffer)) {
|
|
119
|
-
lineEnds.push(match.index);
|
|
120
|
-
lineStarts.push(match.index + match[0].length);
|
|
121
|
-
if (mark.position <= match.index && foundLineNo < 0) {
|
|
122
|
-
foundLineNo = lineStarts.length - 2;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
126
|
-
var result = "", i, line;
|
|
127
|
-
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
128
|
-
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
129
|
-
for (i = 1; i <= options.linesBefore; i++) {
|
|
130
|
-
if (foundLineNo - i < 0) break;
|
|
131
|
-
line = getLine(
|
|
132
|
-
mark.buffer,
|
|
133
|
-
lineStarts[foundLineNo - i],
|
|
134
|
-
lineEnds[foundLineNo - i],
|
|
135
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
136
|
-
maxLineLength
|
|
137
|
-
);
|
|
138
|
-
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
139
|
-
}
|
|
140
|
-
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
141
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
142
|
-
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
143
|
-
for (i = 1; i <= options.linesAfter; i++) {
|
|
144
|
-
if (foundLineNo + i >= lineEnds.length) break;
|
|
145
|
-
line = getLine(
|
|
146
|
-
mark.buffer,
|
|
147
|
-
lineStarts[foundLineNo + i],
|
|
148
|
-
lineEnds[foundLineNo + i],
|
|
149
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
150
|
-
maxLineLength
|
|
151
|
-
);
|
|
152
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
153
|
-
}
|
|
154
|
-
return result.replace(/\n$/, "");
|
|
155
|
-
}
|
|
156
|
-
var snippet = makeSnippet;
|
|
157
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
158
|
-
"kind",
|
|
159
|
-
"multi",
|
|
160
|
-
"resolve",
|
|
161
|
-
"construct",
|
|
162
|
-
"instanceOf",
|
|
163
|
-
"predicate",
|
|
164
|
-
"represent",
|
|
165
|
-
"representName",
|
|
166
|
-
"defaultStyle",
|
|
167
|
-
"styleAliases"
|
|
168
|
-
];
|
|
169
|
-
var YAML_NODE_KINDS = [
|
|
170
|
-
"scalar",
|
|
171
|
-
"sequence",
|
|
172
|
-
"mapping"
|
|
173
|
-
];
|
|
174
|
-
function compileStyleAliases(map2) {
|
|
175
|
-
var result = {};
|
|
176
|
-
if (map2 !== null) {
|
|
177
|
-
Object.keys(map2).forEach(function(style) {
|
|
178
|
-
map2[style].forEach(function(alias) {
|
|
179
|
-
result[String(alias)] = style;
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
function Type$1(tag, options) {
|
|
186
|
-
options = options || {};
|
|
187
|
-
Object.keys(options).forEach(function(name) {
|
|
188
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
189
|
-
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
this.options = options;
|
|
193
|
-
this.tag = tag;
|
|
194
|
-
this.kind = options["kind"] || null;
|
|
195
|
-
this.resolve = options["resolve"] || function() {
|
|
196
|
-
return true;
|
|
197
|
-
};
|
|
198
|
-
this.construct = options["construct"] || function(data) {
|
|
199
|
-
return data;
|
|
200
|
-
};
|
|
201
|
-
this.instanceOf = options["instanceOf"] || null;
|
|
202
|
-
this.predicate = options["predicate"] || null;
|
|
203
|
-
this.represent = options["represent"] || null;
|
|
204
|
-
this.representName = options["representName"] || null;
|
|
205
|
-
this.defaultStyle = options["defaultStyle"] || null;
|
|
206
|
-
this.multi = options["multi"] || false;
|
|
207
|
-
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
208
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
209
|
-
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
var type = Type$1;
|
|
213
|
-
function compileList(schema2, name) {
|
|
214
|
-
var result = [];
|
|
215
|
-
schema2[name].forEach(function(currentType) {
|
|
216
|
-
var newIndex = result.length;
|
|
217
|
-
result.forEach(function(previousType, previousIndex) {
|
|
218
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
219
|
-
newIndex = previousIndex;
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
result[newIndex] = currentType;
|
|
223
|
-
});
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
function compileMap() {
|
|
227
|
-
var result = {
|
|
228
|
-
scalar: {},
|
|
229
|
-
sequence: {},
|
|
230
|
-
mapping: {},
|
|
231
|
-
fallback: {},
|
|
232
|
-
multi: {
|
|
233
|
-
scalar: [],
|
|
234
|
-
sequence: [],
|
|
235
|
-
mapping: [],
|
|
236
|
-
fallback: []
|
|
237
|
-
}
|
|
238
|
-
}, index, length;
|
|
239
|
-
function collectType(type2) {
|
|
240
|
-
if (type2.multi) {
|
|
241
|
-
result.multi[type2.kind].push(type2);
|
|
242
|
-
result.multi["fallback"].push(type2);
|
|
243
|
-
} else {
|
|
244
|
-
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
248
|
-
arguments[index].forEach(collectType);
|
|
249
|
-
}
|
|
250
|
-
return result;
|
|
251
|
-
}
|
|
252
|
-
function Schema$1(definition) {
|
|
253
|
-
return this.extend(definition);
|
|
254
|
-
}
|
|
255
|
-
Schema$1.prototype.extend = function extend2(definition) {
|
|
256
|
-
var implicit = [];
|
|
257
|
-
var explicit = [];
|
|
258
|
-
if (definition instanceof type) {
|
|
259
|
-
explicit.push(definition);
|
|
260
|
-
} else if (Array.isArray(definition)) {
|
|
261
|
-
explicit = explicit.concat(definition);
|
|
262
|
-
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
263
|
-
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
264
|
-
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
265
|
-
} else {
|
|
266
|
-
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
267
|
-
}
|
|
268
|
-
implicit.forEach(function(type$1) {
|
|
269
|
-
if (!(type$1 instanceof type)) {
|
|
270
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
271
|
-
}
|
|
272
|
-
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
273
|
-
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
274
|
-
}
|
|
275
|
-
if (type$1.multi) {
|
|
276
|
-
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
explicit.forEach(function(type$1) {
|
|
280
|
-
if (!(type$1 instanceof type)) {
|
|
281
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
var result = Object.create(Schema$1.prototype);
|
|
285
|
-
result.implicit = (this.implicit || []).concat(implicit);
|
|
286
|
-
result.explicit = (this.explicit || []).concat(explicit);
|
|
287
|
-
result.compiledImplicit = compileList(result, "implicit");
|
|
288
|
-
result.compiledExplicit = compileList(result, "explicit");
|
|
289
|
-
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
290
|
-
return result;
|
|
291
|
-
};
|
|
292
|
-
var schema = Schema$1;
|
|
293
|
-
var str = new type("tag:yaml.org,2002:str", {
|
|
294
|
-
kind: "scalar",
|
|
295
|
-
construct: function(data) {
|
|
296
|
-
return data !== null ? data : "";
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
var seq = new type("tag:yaml.org,2002:seq", {
|
|
300
|
-
kind: "sequence",
|
|
301
|
-
construct: function(data) {
|
|
302
|
-
return data !== null ? data : [];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
var map = new type("tag:yaml.org,2002:map", {
|
|
306
|
-
kind: "mapping",
|
|
307
|
-
construct: function(data) {
|
|
308
|
-
return data !== null ? data : {};
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
var failsafe = new schema({
|
|
312
|
-
explicit: [
|
|
313
|
-
str,
|
|
314
|
-
seq,
|
|
315
|
-
map
|
|
316
|
-
]
|
|
317
|
-
});
|
|
318
|
-
function resolveYamlNull(data) {
|
|
319
|
-
if (data === null) return true;
|
|
320
|
-
var max = data.length;
|
|
321
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
322
|
-
}
|
|
323
|
-
function constructYamlNull() {
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
function isNull(object) {
|
|
327
|
-
return object === null;
|
|
328
|
-
}
|
|
329
|
-
var _null = new type("tag:yaml.org,2002:null", {
|
|
330
|
-
kind: "scalar",
|
|
331
|
-
resolve: resolveYamlNull,
|
|
332
|
-
construct: constructYamlNull,
|
|
333
|
-
predicate: isNull,
|
|
334
|
-
represent: {
|
|
335
|
-
canonical: function() {
|
|
336
|
-
return "~";
|
|
337
|
-
},
|
|
338
|
-
lowercase: function() {
|
|
339
|
-
return "null";
|
|
340
|
-
},
|
|
341
|
-
uppercase: function() {
|
|
342
|
-
return "NULL";
|
|
343
|
-
},
|
|
344
|
-
camelcase: function() {
|
|
345
|
-
return "Null";
|
|
346
|
-
},
|
|
347
|
-
empty: function() {
|
|
348
|
-
return "";
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
defaultStyle: "lowercase"
|
|
352
|
-
});
|
|
353
|
-
function resolveYamlBoolean(data) {
|
|
354
|
-
if (data === null) return false;
|
|
355
|
-
var max = data.length;
|
|
356
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
357
|
-
}
|
|
358
|
-
function constructYamlBoolean(data) {
|
|
359
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
360
|
-
}
|
|
361
|
-
function isBoolean(object) {
|
|
362
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
363
|
-
}
|
|
364
|
-
var bool = new type("tag:yaml.org,2002:bool", {
|
|
365
|
-
kind: "scalar",
|
|
366
|
-
resolve: resolveYamlBoolean,
|
|
367
|
-
construct: constructYamlBoolean,
|
|
368
|
-
predicate: isBoolean,
|
|
369
|
-
represent: {
|
|
370
|
-
lowercase: function(object) {
|
|
371
|
-
return object ? "true" : "false";
|
|
372
|
-
},
|
|
373
|
-
uppercase: function(object) {
|
|
374
|
-
return object ? "TRUE" : "FALSE";
|
|
375
|
-
},
|
|
376
|
-
camelcase: function(object) {
|
|
377
|
-
return object ? "True" : "False";
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
defaultStyle: "lowercase"
|
|
381
|
-
});
|
|
382
|
-
function isHexCode(c) {
|
|
383
|
-
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
384
|
-
}
|
|
385
|
-
function isOctCode(c) {
|
|
386
|
-
return 48 <= c && c <= 55;
|
|
387
|
-
}
|
|
388
|
-
function isDecCode(c) {
|
|
389
|
-
return 48 <= c && c <= 57;
|
|
390
|
-
}
|
|
391
|
-
function resolveYamlInteger(data) {
|
|
392
|
-
if (data === null) return false;
|
|
393
|
-
var max = data.length, index = 0, hasDigits = false, ch;
|
|
394
|
-
if (!max) return false;
|
|
395
|
-
ch = data[index];
|
|
396
|
-
if (ch === "-" || ch === "+") {
|
|
397
|
-
ch = data[++index];
|
|
398
|
-
}
|
|
399
|
-
if (ch === "0") {
|
|
400
|
-
if (index + 1 === max) return true;
|
|
401
|
-
ch = data[++index];
|
|
402
|
-
if (ch === "b") {
|
|
403
|
-
index++;
|
|
404
|
-
for (; index < max; index++) {
|
|
405
|
-
ch = data[index];
|
|
406
|
-
if (ch === "_") continue;
|
|
407
|
-
if (ch !== "0" && ch !== "1") return false;
|
|
408
|
-
hasDigits = true;
|
|
409
|
-
}
|
|
410
|
-
return hasDigits && ch !== "_";
|
|
411
|
-
}
|
|
412
|
-
if (ch === "x") {
|
|
413
|
-
index++;
|
|
414
|
-
for (; index < max; index++) {
|
|
415
|
-
ch = data[index];
|
|
416
|
-
if (ch === "_") continue;
|
|
417
|
-
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
418
|
-
hasDigits = true;
|
|
419
|
-
}
|
|
420
|
-
return hasDigits && ch !== "_";
|
|
421
|
-
}
|
|
422
|
-
if (ch === "o") {
|
|
423
|
-
index++;
|
|
424
|
-
for (; index < max; index++) {
|
|
425
|
-
ch = data[index];
|
|
426
|
-
if (ch === "_") continue;
|
|
427
|
-
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
428
|
-
hasDigits = true;
|
|
429
|
-
}
|
|
430
|
-
return hasDigits && ch !== "_";
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
if (ch === "_") return false;
|
|
434
|
-
for (; index < max; index++) {
|
|
435
|
-
ch = data[index];
|
|
436
|
-
if (ch === "_") continue;
|
|
437
|
-
if (!isDecCode(data.charCodeAt(index))) {
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
hasDigits = true;
|
|
441
|
-
}
|
|
442
|
-
if (!hasDigits || ch === "_") return false;
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
function constructYamlInteger(data) {
|
|
446
|
-
var value = data, sign = 1, ch;
|
|
447
|
-
if (value.indexOf("_") !== -1) {
|
|
448
|
-
value = value.replace(/_/g, "");
|
|
449
|
-
}
|
|
450
|
-
ch = value[0];
|
|
451
|
-
if (ch === "-" || ch === "+") {
|
|
452
|
-
if (ch === "-") sign = -1;
|
|
453
|
-
value = value.slice(1);
|
|
454
|
-
ch = value[0];
|
|
455
|
-
}
|
|
456
|
-
if (value === "0") return 0;
|
|
457
|
-
if (ch === "0") {
|
|
458
|
-
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
459
|
-
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
460
|
-
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
461
|
-
}
|
|
462
|
-
return sign * parseInt(value, 10);
|
|
463
|
-
}
|
|
464
|
-
function isInteger(object) {
|
|
465
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
466
|
-
}
|
|
467
|
-
var int = new type("tag:yaml.org,2002:int", {
|
|
468
|
-
kind: "scalar",
|
|
469
|
-
resolve: resolveYamlInteger,
|
|
470
|
-
construct: constructYamlInteger,
|
|
471
|
-
predicate: isInteger,
|
|
472
|
-
represent: {
|
|
473
|
-
binary: function(obj) {
|
|
474
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
475
|
-
},
|
|
476
|
-
octal: function(obj) {
|
|
477
|
-
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
478
|
-
},
|
|
479
|
-
decimal: function(obj) {
|
|
480
|
-
return obj.toString(10);
|
|
481
|
-
},
|
|
482
|
-
/* eslint-disable max-len */
|
|
483
|
-
hexadecimal: function(obj) {
|
|
484
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
485
|
-
}
|
|
486
|
-
},
|
|
487
|
-
defaultStyle: "decimal",
|
|
488
|
-
styleAliases: {
|
|
489
|
-
binary: [2, "bin"],
|
|
490
|
-
octal: [8, "oct"],
|
|
491
|
-
decimal: [10, "dec"],
|
|
492
|
-
hexadecimal: [16, "hex"]
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
var YAML_FLOAT_PATTERN = new RegExp(
|
|
496
|
-
// 2.5e4, 2.5 and integers
|
|
497
|
-
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
498
|
-
);
|
|
499
|
-
function resolveYamlFloat(data) {
|
|
500
|
-
if (data === null) return false;
|
|
501
|
-
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
502
|
-
// Probably should update regexp & check speed
|
|
503
|
-
data[data.length - 1] === "_") {
|
|
504
|
-
return false;
|
|
505
|
-
}
|
|
506
|
-
return true;
|
|
507
|
-
}
|
|
508
|
-
function constructYamlFloat(data) {
|
|
509
|
-
var value, sign;
|
|
510
|
-
value = data.replace(/_/g, "").toLowerCase();
|
|
511
|
-
sign = value[0] === "-" ? -1 : 1;
|
|
512
|
-
if ("+-".indexOf(value[0]) >= 0) {
|
|
513
|
-
value = value.slice(1);
|
|
514
|
-
}
|
|
515
|
-
if (value === ".inf") {
|
|
516
|
-
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
517
|
-
} else if (value === ".nan") {
|
|
518
|
-
return NaN;
|
|
519
|
-
}
|
|
520
|
-
return sign * parseFloat(value, 10);
|
|
521
|
-
}
|
|
522
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
523
|
-
function representYamlFloat(object, style) {
|
|
524
|
-
var res;
|
|
525
|
-
if (isNaN(object)) {
|
|
526
|
-
switch (style) {
|
|
527
|
-
case "lowercase":
|
|
528
|
-
return ".nan";
|
|
529
|
-
case "uppercase":
|
|
530
|
-
return ".NAN";
|
|
531
|
-
case "camelcase":
|
|
532
|
-
return ".NaN";
|
|
533
|
-
}
|
|
534
|
-
} else if (Number.POSITIVE_INFINITY === object) {
|
|
535
|
-
switch (style) {
|
|
536
|
-
case "lowercase":
|
|
537
|
-
return ".inf";
|
|
538
|
-
case "uppercase":
|
|
539
|
-
return ".INF";
|
|
540
|
-
case "camelcase":
|
|
541
|
-
return ".Inf";
|
|
542
|
-
}
|
|
543
|
-
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
544
|
-
switch (style) {
|
|
545
|
-
case "lowercase":
|
|
546
|
-
return "-.inf";
|
|
547
|
-
case "uppercase":
|
|
548
|
-
return "-.INF";
|
|
549
|
-
case "camelcase":
|
|
550
|
-
return "-.Inf";
|
|
551
|
-
}
|
|
552
|
-
} else if (common.isNegativeZero(object)) {
|
|
553
|
-
return "-0.0";
|
|
554
|
-
}
|
|
555
|
-
res = object.toString(10);
|
|
556
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
557
|
-
}
|
|
558
|
-
function isFloat(object) {
|
|
559
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
560
|
-
}
|
|
561
|
-
var float = new type("tag:yaml.org,2002:float", {
|
|
562
|
-
kind: "scalar",
|
|
563
|
-
resolve: resolveYamlFloat,
|
|
564
|
-
construct: constructYamlFloat,
|
|
565
|
-
predicate: isFloat,
|
|
566
|
-
represent: representYamlFloat,
|
|
567
|
-
defaultStyle: "lowercase"
|
|
568
|
-
});
|
|
569
|
-
var json = failsafe.extend({
|
|
570
|
-
implicit: [
|
|
571
|
-
_null,
|
|
572
|
-
bool,
|
|
573
|
-
int,
|
|
574
|
-
float
|
|
575
|
-
]
|
|
576
|
-
});
|
|
577
|
-
var core = json;
|
|
578
|
-
var YAML_DATE_REGEXP = new RegExp(
|
|
579
|
-
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
580
|
-
);
|
|
581
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
582
|
-
"^([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]))?))?$"
|
|
583
|
-
);
|
|
584
|
-
function resolveYamlTimestamp(data) {
|
|
585
|
-
if (data === null) return false;
|
|
586
|
-
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
587
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
function constructYamlTimestamp(data) {
|
|
591
|
-
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
592
|
-
match = YAML_DATE_REGEXP.exec(data);
|
|
593
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
594
|
-
if (match === null) throw new Error("Date resolve error");
|
|
595
|
-
year = +match[1];
|
|
596
|
-
month = +match[2] - 1;
|
|
597
|
-
day = +match[3];
|
|
598
|
-
if (!match[4]) {
|
|
599
|
-
return new Date(Date.UTC(year, month, day));
|
|
600
|
-
}
|
|
601
|
-
hour = +match[4];
|
|
602
|
-
minute = +match[5];
|
|
603
|
-
second = +match[6];
|
|
604
|
-
if (match[7]) {
|
|
605
|
-
fraction = match[7].slice(0, 3);
|
|
606
|
-
while (fraction.length < 3) {
|
|
607
|
-
fraction += "0";
|
|
608
|
-
}
|
|
609
|
-
fraction = +fraction;
|
|
610
|
-
}
|
|
611
|
-
if (match[9]) {
|
|
612
|
-
tz_hour = +match[10];
|
|
613
|
-
tz_minute = +(match[11] || 0);
|
|
614
|
-
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
615
|
-
if (match[9] === "-") delta = -delta;
|
|
616
|
-
}
|
|
617
|
-
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
618
|
-
if (delta) date.setTime(date.getTime() - delta);
|
|
619
|
-
return date;
|
|
620
|
-
}
|
|
621
|
-
function representYamlTimestamp(object) {
|
|
622
|
-
return object.toISOString();
|
|
623
|
-
}
|
|
624
|
-
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
625
|
-
kind: "scalar",
|
|
626
|
-
resolve: resolveYamlTimestamp,
|
|
627
|
-
construct: constructYamlTimestamp,
|
|
628
|
-
instanceOf: Date,
|
|
629
|
-
represent: representYamlTimestamp
|
|
630
|
-
});
|
|
631
|
-
function resolveYamlMerge(data) {
|
|
632
|
-
return data === "<<" || data === null;
|
|
633
|
-
}
|
|
634
|
-
var merge = new type("tag:yaml.org,2002:merge", {
|
|
635
|
-
kind: "scalar",
|
|
636
|
-
resolve: resolveYamlMerge
|
|
637
|
-
});
|
|
638
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
639
|
-
function resolveYamlBinary(data) {
|
|
640
|
-
if (data === null) return false;
|
|
641
|
-
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
642
|
-
for (idx = 0; idx < max; idx++) {
|
|
643
|
-
code = map2.indexOf(data.charAt(idx));
|
|
644
|
-
if (code > 64) continue;
|
|
645
|
-
if (code < 0) return false;
|
|
646
|
-
bitlen += 6;
|
|
647
|
-
}
|
|
648
|
-
return bitlen % 8 === 0;
|
|
649
|
-
}
|
|
650
|
-
function constructYamlBinary(data) {
|
|
651
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
652
|
-
for (idx = 0; idx < max; idx++) {
|
|
653
|
-
if (idx % 4 === 0 && idx) {
|
|
654
|
-
result.push(bits >> 16 & 255);
|
|
655
|
-
result.push(bits >> 8 & 255);
|
|
656
|
-
result.push(bits & 255);
|
|
657
|
-
}
|
|
658
|
-
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
659
|
-
}
|
|
660
|
-
tailbits = max % 4 * 6;
|
|
661
|
-
if (tailbits === 0) {
|
|
662
|
-
result.push(bits >> 16 & 255);
|
|
663
|
-
result.push(bits >> 8 & 255);
|
|
664
|
-
result.push(bits & 255);
|
|
665
|
-
} else if (tailbits === 18) {
|
|
666
|
-
result.push(bits >> 10 & 255);
|
|
667
|
-
result.push(bits >> 2 & 255);
|
|
668
|
-
} else if (tailbits === 12) {
|
|
669
|
-
result.push(bits >> 4 & 255);
|
|
670
|
-
}
|
|
671
|
-
return new Uint8Array(result);
|
|
672
|
-
}
|
|
673
|
-
function representYamlBinary(object) {
|
|
674
|
-
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
675
|
-
for (idx = 0; idx < max; idx++) {
|
|
676
|
-
if (idx % 3 === 0 && idx) {
|
|
677
|
-
result += map2[bits >> 18 & 63];
|
|
678
|
-
result += map2[bits >> 12 & 63];
|
|
679
|
-
result += map2[bits >> 6 & 63];
|
|
680
|
-
result += map2[bits & 63];
|
|
681
|
-
}
|
|
682
|
-
bits = (bits << 8) + object[idx];
|
|
683
|
-
}
|
|
684
|
-
tail = max % 3;
|
|
685
|
-
if (tail === 0) {
|
|
686
|
-
result += map2[bits >> 18 & 63];
|
|
687
|
-
result += map2[bits >> 12 & 63];
|
|
688
|
-
result += map2[bits >> 6 & 63];
|
|
689
|
-
result += map2[bits & 63];
|
|
690
|
-
} else if (tail === 2) {
|
|
691
|
-
result += map2[bits >> 10 & 63];
|
|
692
|
-
result += map2[bits >> 4 & 63];
|
|
693
|
-
result += map2[bits << 2 & 63];
|
|
694
|
-
result += map2[64];
|
|
695
|
-
} else if (tail === 1) {
|
|
696
|
-
result += map2[bits >> 2 & 63];
|
|
697
|
-
result += map2[bits << 4 & 63];
|
|
698
|
-
result += map2[64];
|
|
699
|
-
result += map2[64];
|
|
700
|
-
}
|
|
701
|
-
return result;
|
|
702
|
-
}
|
|
703
|
-
function isBinary(obj) {
|
|
704
|
-
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
705
|
-
}
|
|
706
|
-
var binary = new type("tag:yaml.org,2002:binary", {
|
|
707
|
-
kind: "scalar",
|
|
708
|
-
resolve: resolveYamlBinary,
|
|
709
|
-
construct: constructYamlBinary,
|
|
710
|
-
predicate: isBinary,
|
|
711
|
-
represent: representYamlBinary
|
|
712
|
-
});
|
|
713
|
-
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
714
|
-
var _toString$2 = Object.prototype.toString;
|
|
715
|
-
function resolveYamlOmap(data) {
|
|
716
|
-
if (data === null) return true;
|
|
717
|
-
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
718
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
719
|
-
pair = object[index];
|
|
720
|
-
pairHasKey = false;
|
|
721
|
-
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
722
|
-
for (pairKey in pair) {
|
|
723
|
-
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
724
|
-
if (!pairHasKey) pairHasKey = true;
|
|
725
|
-
else return false;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
if (!pairHasKey) return false;
|
|
729
|
-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
730
|
-
else return false;
|
|
731
|
-
}
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
function constructYamlOmap(data) {
|
|
735
|
-
return data !== null ? data : [];
|
|
736
|
-
}
|
|
737
|
-
var omap = new type("tag:yaml.org,2002:omap", {
|
|
738
|
-
kind: "sequence",
|
|
739
|
-
resolve: resolveYamlOmap,
|
|
740
|
-
construct: constructYamlOmap
|
|
741
|
-
});
|
|
742
|
-
var _toString$1 = Object.prototype.toString;
|
|
743
|
-
function resolveYamlPairs(data) {
|
|
744
|
-
if (data === null) return true;
|
|
745
|
-
var index, length, pair, keys, result, object = data;
|
|
746
|
-
result = new Array(object.length);
|
|
747
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
748
|
-
pair = object[index];
|
|
749
|
-
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
750
|
-
keys = Object.keys(pair);
|
|
751
|
-
if (keys.length !== 1) return false;
|
|
752
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
753
|
-
}
|
|
754
|
-
return true;
|
|
755
|
-
}
|
|
756
|
-
function constructYamlPairs(data) {
|
|
757
|
-
if (data === null) return [];
|
|
758
|
-
var index, length, pair, keys, result, object = data;
|
|
759
|
-
result = new Array(object.length);
|
|
760
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
761
|
-
pair = object[index];
|
|
762
|
-
keys = Object.keys(pair);
|
|
763
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
764
|
-
}
|
|
765
|
-
return result;
|
|
766
|
-
}
|
|
767
|
-
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
768
|
-
kind: "sequence",
|
|
769
|
-
resolve: resolveYamlPairs,
|
|
770
|
-
construct: constructYamlPairs
|
|
771
|
-
});
|
|
772
|
-
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
773
|
-
function resolveYamlSet(data) {
|
|
774
|
-
if (data === null) return true;
|
|
775
|
-
var key, object = data;
|
|
776
|
-
for (key in object) {
|
|
777
|
-
if (_hasOwnProperty$2.call(object, key)) {
|
|
778
|
-
if (object[key] !== null) return false;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return true;
|
|
782
|
-
}
|
|
783
|
-
function constructYamlSet(data) {
|
|
784
|
-
return data !== null ? data : {};
|
|
785
|
-
}
|
|
786
|
-
var set = new type("tag:yaml.org,2002:set", {
|
|
787
|
-
kind: "mapping",
|
|
788
|
-
resolve: resolveYamlSet,
|
|
789
|
-
construct: constructYamlSet
|
|
790
|
-
});
|
|
791
|
-
var _default = core.extend({
|
|
792
|
-
implicit: [
|
|
793
|
-
timestamp,
|
|
794
|
-
merge
|
|
795
|
-
],
|
|
796
|
-
explicit: [
|
|
797
|
-
binary,
|
|
798
|
-
omap,
|
|
799
|
-
pairs,
|
|
800
|
-
set
|
|
801
|
-
]
|
|
802
|
-
});
|
|
803
|
-
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
804
|
-
var CONTEXT_FLOW_IN = 1;
|
|
805
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
806
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
807
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
808
|
-
var CHOMPING_CLIP = 1;
|
|
809
|
-
var CHOMPING_STRIP = 2;
|
|
810
|
-
var CHOMPING_KEEP = 3;
|
|
811
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
812
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
813
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
814
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
815
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
816
|
-
function _class(obj) {
|
|
817
|
-
return Object.prototype.toString.call(obj);
|
|
818
|
-
}
|
|
819
|
-
function is_EOL(c) {
|
|
820
|
-
return c === 10 || c === 13;
|
|
821
|
-
}
|
|
822
|
-
function is_WHITE_SPACE(c) {
|
|
823
|
-
return c === 9 || c === 32;
|
|
824
|
-
}
|
|
825
|
-
function is_WS_OR_EOL(c) {
|
|
826
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
827
|
-
}
|
|
828
|
-
function is_FLOW_INDICATOR(c) {
|
|
829
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
830
|
-
}
|
|
831
|
-
function fromHexCode(c) {
|
|
832
|
-
var lc;
|
|
833
|
-
if (48 <= c && c <= 57) {
|
|
834
|
-
return c - 48;
|
|
835
|
-
}
|
|
836
|
-
lc = c | 32;
|
|
837
|
-
if (97 <= lc && lc <= 102) {
|
|
838
|
-
return lc - 97 + 10;
|
|
839
|
-
}
|
|
840
|
-
return -1;
|
|
841
|
-
}
|
|
842
|
-
function escapedHexLen(c) {
|
|
843
|
-
if (c === 120) {
|
|
844
|
-
return 2;
|
|
845
|
-
}
|
|
846
|
-
if (c === 117) {
|
|
847
|
-
return 4;
|
|
848
|
-
}
|
|
849
|
-
if (c === 85) {
|
|
850
|
-
return 8;
|
|
851
|
-
}
|
|
852
|
-
return 0;
|
|
853
|
-
}
|
|
854
|
-
function fromDecimalCode(c) {
|
|
855
|
-
if (48 <= c && c <= 57) {
|
|
856
|
-
return c - 48;
|
|
857
|
-
}
|
|
858
|
-
return -1;
|
|
859
|
-
}
|
|
860
|
-
function simpleEscapeSequence(c) {
|
|
861
|
-
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
862
|
-
}
|
|
863
|
-
function charFromCodepoint(c) {
|
|
864
|
-
if (c <= 65535) {
|
|
865
|
-
return String.fromCharCode(c);
|
|
866
|
-
}
|
|
867
|
-
return String.fromCharCode(
|
|
868
|
-
(c - 65536 >> 10) + 55296,
|
|
869
|
-
(c - 65536 & 1023) + 56320
|
|
870
|
-
);
|
|
871
|
-
}
|
|
872
|
-
function setProperty(object, key, value) {
|
|
873
|
-
if (key === "__proto__") {
|
|
874
|
-
Object.defineProperty(object, key, {
|
|
875
|
-
configurable: true,
|
|
876
|
-
enumerable: true,
|
|
877
|
-
writable: true,
|
|
878
|
-
value
|
|
879
|
-
});
|
|
880
|
-
} else {
|
|
881
|
-
object[key] = value;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
var simpleEscapeCheck = new Array(256);
|
|
885
|
-
var simpleEscapeMap = new Array(256);
|
|
886
|
-
for (i = 0; i < 256; i++) {
|
|
887
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
888
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
889
|
-
}
|
|
890
|
-
var i;
|
|
891
|
-
function State$1(input, options) {
|
|
892
|
-
this.input = input;
|
|
893
|
-
this.filename = options["filename"] || null;
|
|
894
|
-
this.schema = options["schema"] || _default;
|
|
895
|
-
this.onWarning = options["onWarning"] || null;
|
|
896
|
-
this.legacy = options["legacy"] || false;
|
|
897
|
-
this.json = options["json"] || false;
|
|
898
|
-
this.listener = options["listener"] || null;
|
|
899
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
900
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
901
|
-
this.length = input.length;
|
|
902
|
-
this.position = 0;
|
|
903
|
-
this.line = 0;
|
|
904
|
-
this.lineStart = 0;
|
|
905
|
-
this.lineIndent = 0;
|
|
906
|
-
this.firstTabInLine = -1;
|
|
907
|
-
this.documents = [];
|
|
908
|
-
}
|
|
909
|
-
function generateError(state, message) {
|
|
910
|
-
var mark = {
|
|
911
|
-
name: state.filename,
|
|
912
|
-
buffer: state.input.slice(0, -1),
|
|
913
|
-
// omit trailing \0
|
|
914
|
-
position: state.position,
|
|
915
|
-
line: state.line,
|
|
916
|
-
column: state.position - state.lineStart
|
|
917
|
-
};
|
|
918
|
-
mark.snippet = snippet(mark);
|
|
919
|
-
return new exception(message, mark);
|
|
920
|
-
}
|
|
921
|
-
function throwError(state, message) {
|
|
922
|
-
throw generateError(state, message);
|
|
923
|
-
}
|
|
924
|
-
function throwWarning(state, message) {
|
|
925
|
-
if (state.onWarning) {
|
|
926
|
-
state.onWarning.call(null, generateError(state, message));
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
var directiveHandlers = {
|
|
930
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
931
|
-
var match, major, minor;
|
|
932
|
-
if (state.version !== null) {
|
|
933
|
-
throwError(state, "duplication of %YAML directive");
|
|
934
|
-
}
|
|
935
|
-
if (args.length !== 1) {
|
|
936
|
-
throwError(state, "YAML directive accepts exactly one argument");
|
|
937
|
-
}
|
|
938
|
-
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
939
|
-
if (match === null) {
|
|
940
|
-
throwError(state, "ill-formed argument of the YAML directive");
|
|
941
|
-
}
|
|
942
|
-
major = parseInt(match[1], 10);
|
|
943
|
-
minor = parseInt(match[2], 10);
|
|
944
|
-
if (major !== 1) {
|
|
945
|
-
throwError(state, "unacceptable YAML version of the document");
|
|
946
|
-
}
|
|
947
|
-
state.version = args[0];
|
|
948
|
-
state.checkLineBreaks = minor < 2;
|
|
949
|
-
if (minor !== 1 && minor !== 2) {
|
|
950
|
-
throwWarning(state, "unsupported YAML version of the document");
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
954
|
-
var handle, prefix;
|
|
955
|
-
if (args.length !== 2) {
|
|
956
|
-
throwError(state, "TAG directive accepts exactly two arguments");
|
|
957
|
-
}
|
|
958
|
-
handle = args[0];
|
|
959
|
-
prefix = args[1];
|
|
960
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
961
|
-
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
962
|
-
}
|
|
963
|
-
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
964
|
-
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
965
|
-
}
|
|
966
|
-
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
967
|
-
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
968
|
-
}
|
|
969
|
-
try {
|
|
970
|
-
prefix = decodeURIComponent(prefix);
|
|
971
|
-
} catch (err) {
|
|
972
|
-
throwError(state, "tag prefix is malformed: " + prefix);
|
|
973
|
-
}
|
|
974
|
-
state.tagMap[handle] = prefix;
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
function captureSegment(state, start, end, checkJson) {
|
|
978
|
-
var _position, _length, _character, _result;
|
|
979
|
-
if (start < end) {
|
|
980
|
-
_result = state.input.slice(start, end);
|
|
981
|
-
if (checkJson) {
|
|
982
|
-
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
983
|
-
_character = _result.charCodeAt(_position);
|
|
984
|
-
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
985
|
-
throwError(state, "expected valid JSON character");
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
989
|
-
throwError(state, "the stream contains non-printable characters");
|
|
990
|
-
}
|
|
991
|
-
state.result += _result;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
995
|
-
var sourceKeys, key, index, quantity;
|
|
996
|
-
if (!common.isObject(source)) {
|
|
997
|
-
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
998
|
-
}
|
|
999
|
-
sourceKeys = Object.keys(source);
|
|
1000
|
-
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1001
|
-
key = sourceKeys[index];
|
|
1002
|
-
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1003
|
-
setProperty(destination, key, source[key]);
|
|
1004
|
-
overridableKeys[key] = true;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1009
|
-
var index, quantity;
|
|
1010
|
-
if (Array.isArray(keyNode)) {
|
|
1011
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1012
|
-
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1013
|
-
if (Array.isArray(keyNode[index])) {
|
|
1014
|
-
throwError(state, "nested arrays are not supported inside keys");
|
|
1015
|
-
}
|
|
1016
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1017
|
-
keyNode[index] = "[object Object]";
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1022
|
-
keyNode = "[object Object]";
|
|
1023
|
-
}
|
|
1024
|
-
keyNode = String(keyNode);
|
|
1025
|
-
if (_result === null) {
|
|
1026
|
-
_result = {};
|
|
1027
|
-
}
|
|
1028
|
-
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1029
|
-
if (Array.isArray(valueNode)) {
|
|
1030
|
-
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1031
|
-
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1032
|
-
}
|
|
1033
|
-
} else {
|
|
1034
|
-
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1035
|
-
}
|
|
1036
|
-
} else {
|
|
1037
|
-
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1038
|
-
state.line = startLine || state.line;
|
|
1039
|
-
state.lineStart = startLineStart || state.lineStart;
|
|
1040
|
-
state.position = startPos || state.position;
|
|
1041
|
-
throwError(state, "duplicated mapping key");
|
|
1042
|
-
}
|
|
1043
|
-
setProperty(_result, keyNode, valueNode);
|
|
1044
|
-
delete overridableKeys[keyNode];
|
|
1045
|
-
}
|
|
1046
|
-
return _result;
|
|
1047
|
-
}
|
|
1048
|
-
function readLineBreak(state) {
|
|
1049
|
-
var ch;
|
|
1050
|
-
ch = state.input.charCodeAt(state.position);
|
|
1051
|
-
if (ch === 10) {
|
|
1052
|
-
state.position++;
|
|
1053
|
-
} else if (ch === 13) {
|
|
1054
|
-
state.position++;
|
|
1055
|
-
if (state.input.charCodeAt(state.position) === 10) {
|
|
1056
|
-
state.position++;
|
|
1057
|
-
}
|
|
1058
|
-
} else {
|
|
1059
|
-
throwError(state, "a line break is expected");
|
|
1060
|
-
}
|
|
1061
|
-
state.line += 1;
|
|
1062
|
-
state.lineStart = state.position;
|
|
1063
|
-
state.firstTabInLine = -1;
|
|
1064
|
-
}
|
|
1065
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1066
|
-
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1067
|
-
while (ch !== 0) {
|
|
1068
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1069
|
-
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1070
|
-
state.firstTabInLine = state.position;
|
|
1071
|
-
}
|
|
1072
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1073
|
-
}
|
|
1074
|
-
if (allowComments && ch === 35) {
|
|
1075
|
-
do {
|
|
1076
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1077
|
-
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1078
|
-
}
|
|
1079
|
-
if (is_EOL(ch)) {
|
|
1080
|
-
readLineBreak(state);
|
|
1081
|
-
ch = state.input.charCodeAt(state.position);
|
|
1082
|
-
lineBreaks++;
|
|
1083
|
-
state.lineIndent = 0;
|
|
1084
|
-
while (ch === 32) {
|
|
1085
|
-
state.lineIndent++;
|
|
1086
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1087
|
-
}
|
|
1088
|
-
} else {
|
|
1089
|
-
break;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1093
|
-
throwWarning(state, "deficient indentation");
|
|
1094
|
-
}
|
|
1095
|
-
return lineBreaks;
|
|
1096
|
-
}
|
|
1097
|
-
function testDocumentSeparator(state) {
|
|
1098
|
-
var _position = state.position, ch;
|
|
1099
|
-
ch = state.input.charCodeAt(_position);
|
|
1100
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1101
|
-
_position += 3;
|
|
1102
|
-
ch = state.input.charCodeAt(_position);
|
|
1103
|
-
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1104
|
-
return true;
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
function writeFoldedLines(state, count) {
|
|
1110
|
-
if (count === 1) {
|
|
1111
|
-
state.result += " ";
|
|
1112
|
-
} else if (count > 1) {
|
|
1113
|
-
state.result += common.repeat("\n", count - 1);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1117
|
-
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1118
|
-
ch = state.input.charCodeAt(state.position);
|
|
1119
|
-
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1120
|
-
return false;
|
|
1121
|
-
}
|
|
1122
|
-
if (ch === 63 || ch === 45) {
|
|
1123
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1124
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1125
|
-
return false;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
state.kind = "scalar";
|
|
1129
|
-
state.result = "";
|
|
1130
|
-
captureStart = captureEnd = state.position;
|
|
1131
|
-
hasPendingContent = false;
|
|
1132
|
-
while (ch !== 0) {
|
|
1133
|
-
if (ch === 58) {
|
|
1134
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1135
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
} else if (ch === 35) {
|
|
1139
|
-
preceding = state.input.charCodeAt(state.position - 1);
|
|
1140
|
-
if (is_WS_OR_EOL(preceding)) {
|
|
1141
|
-
break;
|
|
1142
|
-
}
|
|
1143
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1144
|
-
break;
|
|
1145
|
-
} else if (is_EOL(ch)) {
|
|
1146
|
-
_line = state.line;
|
|
1147
|
-
_lineStart = state.lineStart;
|
|
1148
|
-
_lineIndent = state.lineIndent;
|
|
1149
|
-
skipSeparationSpace(state, false, -1);
|
|
1150
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1151
|
-
hasPendingContent = true;
|
|
1152
|
-
ch = state.input.charCodeAt(state.position);
|
|
1153
|
-
continue;
|
|
1154
|
-
} else {
|
|
1155
|
-
state.position = captureEnd;
|
|
1156
|
-
state.line = _line;
|
|
1157
|
-
state.lineStart = _lineStart;
|
|
1158
|
-
state.lineIndent = _lineIndent;
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
if (hasPendingContent) {
|
|
1163
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1164
|
-
writeFoldedLines(state, state.line - _line);
|
|
1165
|
-
captureStart = captureEnd = state.position;
|
|
1166
|
-
hasPendingContent = false;
|
|
1167
|
-
}
|
|
1168
|
-
if (!is_WHITE_SPACE(ch)) {
|
|
1169
|
-
captureEnd = state.position + 1;
|
|
1170
|
-
}
|
|
1171
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1172
|
-
}
|
|
1173
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1174
|
-
if (state.result) {
|
|
1175
|
-
return true;
|
|
1176
|
-
}
|
|
1177
|
-
state.kind = _kind;
|
|
1178
|
-
state.result = _result;
|
|
1179
|
-
return false;
|
|
1180
|
-
}
|
|
1181
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1182
|
-
var ch, captureStart, captureEnd;
|
|
1183
|
-
ch = state.input.charCodeAt(state.position);
|
|
1184
|
-
if (ch !== 39) {
|
|
1185
|
-
return false;
|
|
1186
|
-
}
|
|
1187
|
-
state.kind = "scalar";
|
|
1188
|
-
state.result = "";
|
|
1189
|
-
state.position++;
|
|
1190
|
-
captureStart = captureEnd = state.position;
|
|
1191
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1192
|
-
if (ch === 39) {
|
|
1193
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1194
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1195
|
-
if (ch === 39) {
|
|
1196
|
-
captureStart = state.position;
|
|
1197
|
-
state.position++;
|
|
1198
|
-
captureEnd = state.position;
|
|
1199
|
-
} else {
|
|
1200
|
-
return true;
|
|
1201
|
-
}
|
|
1202
|
-
} else if (is_EOL(ch)) {
|
|
1203
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1204
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1205
|
-
captureStart = captureEnd = state.position;
|
|
1206
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1207
|
-
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1208
|
-
} else {
|
|
1209
|
-
state.position++;
|
|
1210
|
-
captureEnd = state.position;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1214
|
-
}
|
|
1215
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1216
|
-
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1217
|
-
ch = state.input.charCodeAt(state.position);
|
|
1218
|
-
if (ch !== 34) {
|
|
1219
|
-
return false;
|
|
1220
|
-
}
|
|
1221
|
-
state.kind = "scalar";
|
|
1222
|
-
state.result = "";
|
|
1223
|
-
state.position++;
|
|
1224
|
-
captureStart = captureEnd = state.position;
|
|
1225
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1226
|
-
if (ch === 34) {
|
|
1227
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1228
|
-
state.position++;
|
|
1229
|
-
return true;
|
|
1230
|
-
} else if (ch === 92) {
|
|
1231
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1232
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1233
|
-
if (is_EOL(ch)) {
|
|
1234
|
-
skipSeparationSpace(state, false, nodeIndent);
|
|
1235
|
-
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1236
|
-
state.result += simpleEscapeMap[ch];
|
|
1237
|
-
state.position++;
|
|
1238
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1239
|
-
hexLength = tmp;
|
|
1240
|
-
hexResult = 0;
|
|
1241
|
-
for (; hexLength > 0; hexLength--) {
|
|
1242
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1243
|
-
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1244
|
-
hexResult = (hexResult << 4) + tmp;
|
|
1245
|
-
} else {
|
|
1246
|
-
throwError(state, "expected hexadecimal character");
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
state.result += charFromCodepoint(hexResult);
|
|
1250
|
-
state.position++;
|
|
1251
|
-
} else {
|
|
1252
|
-
throwError(state, "unknown escape sequence");
|
|
1253
|
-
}
|
|
1254
|
-
captureStart = captureEnd = state.position;
|
|
1255
|
-
} else if (is_EOL(ch)) {
|
|
1256
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1257
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1258
|
-
captureStart = captureEnd = state.position;
|
|
1259
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1260
|
-
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1261
|
-
} else {
|
|
1262
|
-
state.position++;
|
|
1263
|
-
captureEnd = state.position;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1267
|
-
}
|
|
1268
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1269
|
-
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1270
|
-
ch = state.input.charCodeAt(state.position);
|
|
1271
|
-
if (ch === 91) {
|
|
1272
|
-
terminator = 93;
|
|
1273
|
-
isMapping = false;
|
|
1274
|
-
_result = [];
|
|
1275
|
-
} else if (ch === 123) {
|
|
1276
|
-
terminator = 125;
|
|
1277
|
-
isMapping = true;
|
|
1278
|
-
_result = {};
|
|
1279
|
-
} else {
|
|
1280
|
-
return false;
|
|
1281
|
-
}
|
|
1282
|
-
if (state.anchor !== null) {
|
|
1283
|
-
state.anchorMap[state.anchor] = _result;
|
|
1284
|
-
}
|
|
1285
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1286
|
-
while (ch !== 0) {
|
|
1287
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1288
|
-
ch = state.input.charCodeAt(state.position);
|
|
1289
|
-
if (ch === terminator) {
|
|
1290
|
-
state.position++;
|
|
1291
|
-
state.tag = _tag;
|
|
1292
|
-
state.anchor = _anchor;
|
|
1293
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1294
|
-
state.result = _result;
|
|
1295
|
-
return true;
|
|
1296
|
-
} else if (!readNext) {
|
|
1297
|
-
throwError(state, "missed comma between flow collection entries");
|
|
1298
|
-
} else if (ch === 44) {
|
|
1299
|
-
throwError(state, "expected the node content, but found ','");
|
|
1300
|
-
}
|
|
1301
|
-
keyTag = keyNode = valueNode = null;
|
|
1302
|
-
isPair = isExplicitPair = false;
|
|
1303
|
-
if (ch === 63) {
|
|
1304
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1305
|
-
if (is_WS_OR_EOL(following)) {
|
|
1306
|
-
isPair = isExplicitPair = true;
|
|
1307
|
-
state.position++;
|
|
1308
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
_line = state.line;
|
|
1312
|
-
_lineStart = state.lineStart;
|
|
1313
|
-
_pos = state.position;
|
|
1314
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1315
|
-
keyTag = state.tag;
|
|
1316
|
-
keyNode = state.result;
|
|
1317
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1318
|
-
ch = state.input.charCodeAt(state.position);
|
|
1319
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1320
|
-
isPair = true;
|
|
1321
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1322
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1323
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1324
|
-
valueNode = state.result;
|
|
1325
|
-
}
|
|
1326
|
-
if (isMapping) {
|
|
1327
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1328
|
-
} else if (isPair) {
|
|
1329
|
-
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1330
|
-
} else {
|
|
1331
|
-
_result.push(keyNode);
|
|
1332
|
-
}
|
|
1333
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1334
|
-
ch = state.input.charCodeAt(state.position);
|
|
1335
|
-
if (ch === 44) {
|
|
1336
|
-
readNext = true;
|
|
1337
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1338
|
-
} else {
|
|
1339
|
-
readNext = false;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1343
|
-
}
|
|
1344
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1345
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1346
|
-
ch = state.input.charCodeAt(state.position);
|
|
1347
|
-
if (ch === 124) {
|
|
1348
|
-
folding = false;
|
|
1349
|
-
} else if (ch === 62) {
|
|
1350
|
-
folding = true;
|
|
1351
|
-
} else {
|
|
1352
|
-
return false;
|
|
1353
|
-
}
|
|
1354
|
-
state.kind = "scalar";
|
|
1355
|
-
state.result = "";
|
|
1356
|
-
while (ch !== 0) {
|
|
1357
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1358
|
-
if (ch === 43 || ch === 45) {
|
|
1359
|
-
if (CHOMPING_CLIP === chomping) {
|
|
1360
|
-
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1361
|
-
} else {
|
|
1362
|
-
throwError(state, "repeat of a chomping mode identifier");
|
|
1363
|
-
}
|
|
1364
|
-
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1365
|
-
if (tmp === 0) {
|
|
1366
|
-
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1367
|
-
} else if (!detectedIndent) {
|
|
1368
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1369
|
-
detectedIndent = true;
|
|
1370
|
-
} else {
|
|
1371
|
-
throwError(state, "repeat of an indentation width identifier");
|
|
1372
|
-
}
|
|
1373
|
-
} else {
|
|
1374
|
-
break;
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1378
|
-
do {
|
|
1379
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1380
|
-
} while (is_WHITE_SPACE(ch));
|
|
1381
|
-
if (ch === 35) {
|
|
1382
|
-
do {
|
|
1383
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1384
|
-
} while (!is_EOL(ch) && ch !== 0);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
while (ch !== 0) {
|
|
1388
|
-
readLineBreak(state);
|
|
1389
|
-
state.lineIndent = 0;
|
|
1390
|
-
ch = state.input.charCodeAt(state.position);
|
|
1391
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1392
|
-
state.lineIndent++;
|
|
1393
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1394
|
-
}
|
|
1395
|
-
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1396
|
-
textIndent = state.lineIndent;
|
|
1397
|
-
}
|
|
1398
|
-
if (is_EOL(ch)) {
|
|
1399
|
-
emptyLines++;
|
|
1400
|
-
continue;
|
|
1401
|
-
}
|
|
1402
|
-
if (state.lineIndent < textIndent) {
|
|
1403
|
-
if (chomping === CHOMPING_KEEP) {
|
|
1404
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1405
|
-
} else if (chomping === CHOMPING_CLIP) {
|
|
1406
|
-
if (didReadContent) {
|
|
1407
|
-
state.result += "\n";
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
break;
|
|
1411
|
-
}
|
|
1412
|
-
if (folding) {
|
|
1413
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1414
|
-
atMoreIndented = true;
|
|
1415
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1416
|
-
} else if (atMoreIndented) {
|
|
1417
|
-
atMoreIndented = false;
|
|
1418
|
-
state.result += common.repeat("\n", emptyLines + 1);
|
|
1419
|
-
} else if (emptyLines === 0) {
|
|
1420
|
-
if (didReadContent) {
|
|
1421
|
-
state.result += " ";
|
|
1422
|
-
}
|
|
1423
|
-
} else {
|
|
1424
|
-
state.result += common.repeat("\n", emptyLines);
|
|
1425
|
-
}
|
|
1426
|
-
} else {
|
|
1427
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1428
|
-
}
|
|
1429
|
-
didReadContent = true;
|
|
1430
|
-
detectedIndent = true;
|
|
1431
|
-
emptyLines = 0;
|
|
1432
|
-
captureStart = state.position;
|
|
1433
|
-
while (!is_EOL(ch) && ch !== 0) {
|
|
1434
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1435
|
-
}
|
|
1436
|
-
captureSegment(state, captureStart, state.position, false);
|
|
1437
|
-
}
|
|
1438
|
-
return true;
|
|
1439
|
-
}
|
|
1440
|
-
function readBlockSequence(state, nodeIndent) {
|
|
1441
|
-
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1442
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1443
|
-
if (state.anchor !== null) {
|
|
1444
|
-
state.anchorMap[state.anchor] = _result;
|
|
1445
|
-
}
|
|
1446
|
-
ch = state.input.charCodeAt(state.position);
|
|
1447
|
-
while (ch !== 0) {
|
|
1448
|
-
if (state.firstTabInLine !== -1) {
|
|
1449
|
-
state.position = state.firstTabInLine;
|
|
1450
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1451
|
-
}
|
|
1452
|
-
if (ch !== 45) {
|
|
1453
|
-
break;
|
|
1454
|
-
}
|
|
1455
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1456
|
-
if (!is_WS_OR_EOL(following)) {
|
|
1457
|
-
break;
|
|
1458
|
-
}
|
|
1459
|
-
detected = true;
|
|
1460
|
-
state.position++;
|
|
1461
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1462
|
-
if (state.lineIndent <= nodeIndent) {
|
|
1463
|
-
_result.push(null);
|
|
1464
|
-
ch = state.input.charCodeAt(state.position);
|
|
1465
|
-
continue;
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
_line = state.line;
|
|
1469
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1470
|
-
_result.push(state.result);
|
|
1471
|
-
skipSeparationSpace(state, true, -1);
|
|
1472
|
-
ch = state.input.charCodeAt(state.position);
|
|
1473
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1474
|
-
throwError(state, "bad indentation of a sequence entry");
|
|
1475
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1476
|
-
break;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
if (detected) {
|
|
1480
|
-
state.tag = _tag;
|
|
1481
|
-
state.anchor = _anchor;
|
|
1482
|
-
state.kind = "sequence";
|
|
1483
|
-
state.result = _result;
|
|
1484
|
-
return true;
|
|
1485
|
-
}
|
|
1486
|
-
return false;
|
|
1487
|
-
}
|
|
1488
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1489
|
-
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1490
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1491
|
-
if (state.anchor !== null) {
|
|
1492
|
-
state.anchorMap[state.anchor] = _result;
|
|
1493
|
-
}
|
|
1494
|
-
ch = state.input.charCodeAt(state.position);
|
|
1495
|
-
while (ch !== 0) {
|
|
1496
|
-
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1497
|
-
state.position = state.firstTabInLine;
|
|
1498
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1499
|
-
}
|
|
1500
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1501
|
-
_line = state.line;
|
|
1502
|
-
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1503
|
-
if (ch === 63) {
|
|
1504
|
-
if (atExplicitKey) {
|
|
1505
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1506
|
-
keyTag = keyNode = valueNode = null;
|
|
1507
|
-
}
|
|
1508
|
-
detected = true;
|
|
1509
|
-
atExplicitKey = true;
|
|
1510
|
-
allowCompact = true;
|
|
1511
|
-
} else if (atExplicitKey) {
|
|
1512
|
-
atExplicitKey = false;
|
|
1513
|
-
allowCompact = true;
|
|
1514
|
-
} else {
|
|
1515
|
-
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1516
|
-
}
|
|
1517
|
-
state.position += 1;
|
|
1518
|
-
ch = following;
|
|
1519
|
-
} else {
|
|
1520
|
-
_keyLine = state.line;
|
|
1521
|
-
_keyLineStart = state.lineStart;
|
|
1522
|
-
_keyPos = state.position;
|
|
1523
|
-
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1524
|
-
break;
|
|
1525
|
-
}
|
|
1526
|
-
if (state.line === _line) {
|
|
1527
|
-
ch = state.input.charCodeAt(state.position);
|
|
1528
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1529
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1530
|
-
}
|
|
1531
|
-
if (ch === 58) {
|
|
1532
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1533
|
-
if (!is_WS_OR_EOL(ch)) {
|
|
1534
|
-
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1535
|
-
}
|
|
1536
|
-
if (atExplicitKey) {
|
|
1537
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1538
|
-
keyTag = keyNode = valueNode = null;
|
|
1539
|
-
}
|
|
1540
|
-
detected = true;
|
|
1541
|
-
atExplicitKey = false;
|
|
1542
|
-
allowCompact = false;
|
|
1543
|
-
keyTag = state.tag;
|
|
1544
|
-
keyNode = state.result;
|
|
1545
|
-
} else if (detected) {
|
|
1546
|
-
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1547
|
-
} else {
|
|
1548
|
-
state.tag = _tag;
|
|
1549
|
-
state.anchor = _anchor;
|
|
1550
|
-
return true;
|
|
1551
|
-
}
|
|
1552
|
-
} else if (detected) {
|
|
1553
|
-
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1554
|
-
} else {
|
|
1555
|
-
state.tag = _tag;
|
|
1556
|
-
state.anchor = _anchor;
|
|
1557
|
-
return true;
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1561
|
-
if (atExplicitKey) {
|
|
1562
|
-
_keyLine = state.line;
|
|
1563
|
-
_keyLineStart = state.lineStart;
|
|
1564
|
-
_keyPos = state.position;
|
|
1565
|
-
}
|
|
1566
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1567
|
-
if (atExplicitKey) {
|
|
1568
|
-
keyNode = state.result;
|
|
1569
|
-
} else {
|
|
1570
|
-
valueNode = state.result;
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
if (!atExplicitKey) {
|
|
1574
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1575
|
-
keyTag = keyNode = valueNode = null;
|
|
1576
|
-
}
|
|
1577
|
-
skipSeparationSpace(state, true, -1);
|
|
1578
|
-
ch = state.input.charCodeAt(state.position);
|
|
1579
|
-
}
|
|
1580
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1581
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
1582
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1583
|
-
break;
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
if (atExplicitKey) {
|
|
1587
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1588
|
-
}
|
|
1589
|
-
if (detected) {
|
|
1590
|
-
state.tag = _tag;
|
|
1591
|
-
state.anchor = _anchor;
|
|
1592
|
-
state.kind = "mapping";
|
|
1593
|
-
state.result = _result;
|
|
1594
|
-
}
|
|
1595
|
-
return detected;
|
|
1596
|
-
}
|
|
1597
|
-
function readTagProperty(state) {
|
|
1598
|
-
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1599
|
-
ch = state.input.charCodeAt(state.position);
|
|
1600
|
-
if (ch !== 33) return false;
|
|
1601
|
-
if (state.tag !== null) {
|
|
1602
|
-
throwError(state, "duplication of a tag property");
|
|
1603
|
-
}
|
|
1604
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1605
|
-
if (ch === 60) {
|
|
1606
|
-
isVerbatim = true;
|
|
1607
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1608
|
-
} else if (ch === 33) {
|
|
1609
|
-
isNamed = true;
|
|
1610
|
-
tagHandle = "!!";
|
|
1611
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1612
|
-
} else {
|
|
1613
|
-
tagHandle = "!";
|
|
1614
|
-
}
|
|
1615
|
-
_position = state.position;
|
|
1616
|
-
if (isVerbatim) {
|
|
1617
|
-
do {
|
|
1618
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1619
|
-
} while (ch !== 0 && ch !== 62);
|
|
1620
|
-
if (state.position < state.length) {
|
|
1621
|
-
tagName = state.input.slice(_position, state.position);
|
|
1622
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1623
|
-
} else {
|
|
1624
|
-
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1625
|
-
}
|
|
1626
|
-
} else {
|
|
1627
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1628
|
-
if (ch === 33) {
|
|
1629
|
-
if (!isNamed) {
|
|
1630
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1631
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1632
|
-
throwError(state, "named tag handle cannot contain such characters");
|
|
1633
|
-
}
|
|
1634
|
-
isNamed = true;
|
|
1635
|
-
_position = state.position + 1;
|
|
1636
|
-
} else {
|
|
1637
|
-
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1641
|
-
}
|
|
1642
|
-
tagName = state.input.slice(_position, state.position);
|
|
1643
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1644
|
-
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1648
|
-
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1649
|
-
}
|
|
1650
|
-
try {
|
|
1651
|
-
tagName = decodeURIComponent(tagName);
|
|
1652
|
-
} catch (err) {
|
|
1653
|
-
throwError(state, "tag name is malformed: " + tagName);
|
|
1654
|
-
}
|
|
1655
|
-
if (isVerbatim) {
|
|
1656
|
-
state.tag = tagName;
|
|
1657
|
-
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
1658
|
-
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1659
|
-
} else if (tagHandle === "!") {
|
|
1660
|
-
state.tag = "!" + tagName;
|
|
1661
|
-
} else if (tagHandle === "!!") {
|
|
1662
|
-
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1663
|
-
} else {
|
|
1664
|
-
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1665
|
-
}
|
|
1666
|
-
return true;
|
|
1667
|
-
}
|
|
1668
|
-
function readAnchorProperty(state) {
|
|
1669
|
-
var _position, ch;
|
|
1670
|
-
ch = state.input.charCodeAt(state.position);
|
|
1671
|
-
if (ch !== 38) return false;
|
|
1672
|
-
if (state.anchor !== null) {
|
|
1673
|
-
throwError(state, "duplication of an anchor property");
|
|
1674
|
-
}
|
|
1675
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1676
|
-
_position = state.position;
|
|
1677
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1678
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1679
|
-
}
|
|
1680
|
-
if (state.position === _position) {
|
|
1681
|
-
throwError(state, "name of an anchor node must contain at least one character");
|
|
1682
|
-
}
|
|
1683
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
1684
|
-
return true;
|
|
1685
|
-
}
|
|
1686
|
-
function readAlias(state) {
|
|
1687
|
-
var _position, alias, ch;
|
|
1688
|
-
ch = state.input.charCodeAt(state.position);
|
|
1689
|
-
if (ch !== 42) return false;
|
|
1690
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1691
|
-
_position = state.position;
|
|
1692
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1693
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1694
|
-
}
|
|
1695
|
-
if (state.position === _position) {
|
|
1696
|
-
throwError(state, "name of an alias node must contain at least one character");
|
|
1697
|
-
}
|
|
1698
|
-
alias = state.input.slice(_position, state.position);
|
|
1699
|
-
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
1700
|
-
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1701
|
-
}
|
|
1702
|
-
state.result = state.anchorMap[alias];
|
|
1703
|
-
skipSeparationSpace(state, true, -1);
|
|
1704
|
-
return true;
|
|
1705
|
-
}
|
|
1706
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1707
|
-
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
1708
|
-
if (state.listener !== null) {
|
|
1709
|
-
state.listener("open", state);
|
|
1710
|
-
}
|
|
1711
|
-
state.tag = null;
|
|
1712
|
-
state.anchor = null;
|
|
1713
|
-
state.kind = null;
|
|
1714
|
-
state.result = null;
|
|
1715
|
-
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1716
|
-
if (allowToSeek) {
|
|
1717
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1718
|
-
atNewLine = true;
|
|
1719
|
-
if (state.lineIndent > parentIndent) {
|
|
1720
|
-
indentStatus = 1;
|
|
1721
|
-
} else if (state.lineIndent === parentIndent) {
|
|
1722
|
-
indentStatus = 0;
|
|
1723
|
-
} else if (state.lineIndent < parentIndent) {
|
|
1724
|
-
indentStatus = -1;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
if (indentStatus === 1) {
|
|
1729
|
-
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
1730
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1731
|
-
atNewLine = true;
|
|
1732
|
-
allowBlockCollections = allowBlockStyles;
|
|
1733
|
-
if (state.lineIndent > parentIndent) {
|
|
1734
|
-
indentStatus = 1;
|
|
1735
|
-
} else if (state.lineIndent === parentIndent) {
|
|
1736
|
-
indentStatus = 0;
|
|
1737
|
-
} else if (state.lineIndent < parentIndent) {
|
|
1738
|
-
indentStatus = -1;
|
|
1739
|
-
}
|
|
1740
|
-
} else {
|
|
1741
|
-
allowBlockCollections = false;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
if (allowBlockCollections) {
|
|
1746
|
-
allowBlockCollections = atNewLine || allowCompact;
|
|
1747
|
-
}
|
|
1748
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1749
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1750
|
-
flowIndent = parentIndent;
|
|
1751
|
-
} else {
|
|
1752
|
-
flowIndent = parentIndent + 1;
|
|
1753
|
-
}
|
|
1754
|
-
blockIndent = state.position - state.lineStart;
|
|
1755
|
-
if (indentStatus === 1) {
|
|
1756
|
-
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
1757
|
-
hasContent = true;
|
|
1758
|
-
} else {
|
|
1759
|
-
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
1760
|
-
hasContent = true;
|
|
1761
|
-
} else if (readAlias(state)) {
|
|
1762
|
-
hasContent = true;
|
|
1763
|
-
if (state.tag !== null || state.anchor !== null) {
|
|
1764
|
-
throwError(state, "alias node should not have any properties");
|
|
1765
|
-
}
|
|
1766
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1767
|
-
hasContent = true;
|
|
1768
|
-
if (state.tag === null) {
|
|
1769
|
-
state.tag = "?";
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
if (state.anchor !== null) {
|
|
1773
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
} else if (indentStatus === 0) {
|
|
1777
|
-
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
if (state.tag === null) {
|
|
1781
|
-
if (state.anchor !== null) {
|
|
1782
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1783
|
-
}
|
|
1784
|
-
} else if (state.tag === "?") {
|
|
1785
|
-
if (state.result !== null && state.kind !== "scalar") {
|
|
1786
|
-
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
1787
|
-
}
|
|
1788
|
-
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1789
|
-
type2 = state.implicitTypes[typeIndex];
|
|
1790
|
-
if (type2.resolve(state.result)) {
|
|
1791
|
-
state.result = type2.construct(state.result);
|
|
1792
|
-
state.tag = type2.tag;
|
|
1793
|
-
if (state.anchor !== null) {
|
|
1794
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1795
|
-
}
|
|
1796
|
-
break;
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
} else if (state.tag !== "!") {
|
|
1800
|
-
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
1801
|
-
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
1802
|
-
} else {
|
|
1803
|
-
type2 = null;
|
|
1804
|
-
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
1805
|
-
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1806
|
-
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1807
|
-
type2 = typeList[typeIndex];
|
|
1808
|
-
break;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
if (!type2) {
|
|
1813
|
-
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
1814
|
-
}
|
|
1815
|
-
if (state.result !== null && type2.kind !== state.kind) {
|
|
1816
|
-
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
1817
|
-
}
|
|
1818
|
-
if (!type2.resolve(state.result, state.tag)) {
|
|
1819
|
-
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
1820
|
-
} else {
|
|
1821
|
-
state.result = type2.construct(state.result, state.tag);
|
|
1822
|
-
if (state.anchor !== null) {
|
|
1823
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
if (state.listener !== null) {
|
|
1828
|
-
state.listener("close", state);
|
|
1829
|
-
}
|
|
1830
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
1831
|
-
}
|
|
1832
|
-
function readDocument(state) {
|
|
1833
|
-
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
1834
|
-
state.version = null;
|
|
1835
|
-
state.checkLineBreaks = state.legacy;
|
|
1836
|
-
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
1837
|
-
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
1838
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1839
|
-
skipSeparationSpace(state, true, -1);
|
|
1840
|
-
ch = state.input.charCodeAt(state.position);
|
|
1841
|
-
if (state.lineIndent > 0 || ch !== 37) {
|
|
1842
|
-
break;
|
|
1843
|
-
}
|
|
1844
|
-
hasDirectives = true;
|
|
1845
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1846
|
-
_position = state.position;
|
|
1847
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1848
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1849
|
-
}
|
|
1850
|
-
directiveName = state.input.slice(_position, state.position);
|
|
1851
|
-
directiveArgs = [];
|
|
1852
|
-
if (directiveName.length < 1) {
|
|
1853
|
-
throwError(state, "directive name must not be less than one character in length");
|
|
1854
|
-
}
|
|
1855
|
-
while (ch !== 0) {
|
|
1856
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1857
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1858
|
-
}
|
|
1859
|
-
if (ch === 35) {
|
|
1860
|
-
do {
|
|
1861
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1862
|
-
} while (ch !== 0 && !is_EOL(ch));
|
|
1863
|
-
break;
|
|
1864
|
-
}
|
|
1865
|
-
if (is_EOL(ch)) break;
|
|
1866
|
-
_position = state.position;
|
|
1867
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1868
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1869
|
-
}
|
|
1870
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
1871
|
-
}
|
|
1872
|
-
if (ch !== 0) readLineBreak(state);
|
|
1873
|
-
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
1874
|
-
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
1875
|
-
} else {
|
|
1876
|
-
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
skipSeparationSpace(state, true, -1);
|
|
1880
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
1881
|
-
state.position += 3;
|
|
1882
|
-
skipSeparationSpace(state, true, -1);
|
|
1883
|
-
} else if (hasDirectives) {
|
|
1884
|
-
throwError(state, "directives end mark is expected");
|
|
1885
|
-
}
|
|
1886
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
1887
|
-
skipSeparationSpace(state, true, -1);
|
|
1888
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1889
|
-
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
1890
|
-
}
|
|
1891
|
-
state.documents.push(state.result);
|
|
1892
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1893
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
1894
|
-
state.position += 3;
|
|
1895
|
-
skipSeparationSpace(state, true, -1);
|
|
1896
|
-
}
|
|
1897
|
-
return;
|
|
1898
|
-
}
|
|
1899
|
-
if (state.position < state.length - 1) {
|
|
1900
|
-
throwError(state, "end of the stream or a document separator is expected");
|
|
1901
|
-
} else {
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
function loadDocuments(input, options) {
|
|
1906
|
-
input = String(input);
|
|
1907
|
-
options = options || {};
|
|
1908
|
-
if (input.length !== 0) {
|
|
1909
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
1910
|
-
input += "\n";
|
|
1911
|
-
}
|
|
1912
|
-
if (input.charCodeAt(0) === 65279) {
|
|
1913
|
-
input = input.slice(1);
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
var state = new State$1(input, options);
|
|
1917
|
-
var nullpos = input.indexOf("\0");
|
|
1918
|
-
if (nullpos !== -1) {
|
|
1919
|
-
state.position = nullpos;
|
|
1920
|
-
throwError(state, "null byte is not allowed in input");
|
|
1921
|
-
}
|
|
1922
|
-
state.input += "\0";
|
|
1923
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
1924
|
-
state.lineIndent += 1;
|
|
1925
|
-
state.position += 1;
|
|
1926
|
-
}
|
|
1927
|
-
while (state.position < state.length - 1) {
|
|
1928
|
-
readDocument(state);
|
|
1929
|
-
}
|
|
1930
|
-
return state.documents;
|
|
1931
|
-
}
|
|
1932
|
-
function loadAll$1(input, iterator, options) {
|
|
1933
|
-
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
1934
|
-
options = iterator;
|
|
1935
|
-
iterator = null;
|
|
1936
|
-
}
|
|
1937
|
-
var documents = loadDocuments(input, options);
|
|
1938
|
-
if (typeof iterator !== "function") {
|
|
1939
|
-
return documents;
|
|
1940
|
-
}
|
|
1941
|
-
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
1942
|
-
iterator(documents[index]);
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
function load$1(input, options) {
|
|
1946
|
-
var documents = loadDocuments(input, options);
|
|
1947
|
-
if (documents.length === 0) {
|
|
1948
|
-
return void 0;
|
|
1949
|
-
} else if (documents.length === 1) {
|
|
1950
|
-
return documents[0];
|
|
1951
|
-
}
|
|
1952
|
-
throw new exception("expected a single document in the stream, but found more");
|
|
1953
|
-
}
|
|
1954
|
-
var loadAll_1 = loadAll$1;
|
|
1955
|
-
var load_1 = load$1;
|
|
1956
|
-
var loader = {
|
|
1957
|
-
loadAll: loadAll_1,
|
|
1958
|
-
load: load_1
|
|
1959
|
-
};
|
|
1960
|
-
var _toString = Object.prototype.toString;
|
|
1961
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1962
|
-
var CHAR_BOM = 65279;
|
|
1963
|
-
var CHAR_TAB = 9;
|
|
1964
|
-
var CHAR_LINE_FEED = 10;
|
|
1965
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
1966
|
-
var CHAR_SPACE = 32;
|
|
1967
|
-
var CHAR_EXCLAMATION = 33;
|
|
1968
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
1969
|
-
var CHAR_SHARP = 35;
|
|
1970
|
-
var CHAR_PERCENT = 37;
|
|
1971
|
-
var CHAR_AMPERSAND = 38;
|
|
1972
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
1973
|
-
var CHAR_ASTERISK = 42;
|
|
1974
|
-
var CHAR_COMMA = 44;
|
|
1975
|
-
var CHAR_MINUS = 45;
|
|
1976
|
-
var CHAR_COLON = 58;
|
|
1977
|
-
var CHAR_EQUALS = 61;
|
|
1978
|
-
var CHAR_GREATER_THAN = 62;
|
|
1979
|
-
var CHAR_QUESTION = 63;
|
|
1980
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
1981
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
1982
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
1983
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
1984
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
1985
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
1986
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
1987
|
-
var ESCAPE_SEQUENCES = {};
|
|
1988
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
1989
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
1990
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
1991
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
1992
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
1993
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
1994
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
1995
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
1996
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
1997
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
1998
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
1999
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2000
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2001
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2002
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2003
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2004
|
-
"y",
|
|
2005
|
-
"Y",
|
|
2006
|
-
"yes",
|
|
2007
|
-
"Yes",
|
|
2008
|
-
"YES",
|
|
2009
|
-
"on",
|
|
2010
|
-
"On",
|
|
2011
|
-
"ON",
|
|
2012
|
-
"n",
|
|
2013
|
-
"N",
|
|
2014
|
-
"no",
|
|
2015
|
-
"No",
|
|
2016
|
-
"NO",
|
|
2017
|
-
"off",
|
|
2018
|
-
"Off",
|
|
2019
|
-
"OFF"
|
|
2020
|
-
];
|
|
2021
|
-
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2022
|
-
function compileStyleMap(schema2, map2) {
|
|
2023
|
-
var result, keys, index, length, tag, style, type2;
|
|
2024
|
-
if (map2 === null) return {};
|
|
2025
|
-
result = {};
|
|
2026
|
-
keys = Object.keys(map2);
|
|
2027
|
-
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2028
|
-
tag = keys[index];
|
|
2029
|
-
style = String(map2[tag]);
|
|
2030
|
-
if (tag.slice(0, 2) === "!!") {
|
|
2031
|
-
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2032
|
-
}
|
|
2033
|
-
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2034
|
-
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2035
|
-
style = type2.styleAliases[style];
|
|
2036
|
-
}
|
|
2037
|
-
result[tag] = style;
|
|
2038
|
-
}
|
|
2039
|
-
return result;
|
|
2040
|
-
}
|
|
2041
|
-
function encodeHex(character) {
|
|
2042
|
-
var string, handle, length;
|
|
2043
|
-
string = character.toString(16).toUpperCase();
|
|
2044
|
-
if (character <= 255) {
|
|
2045
|
-
handle = "x";
|
|
2046
|
-
length = 2;
|
|
2047
|
-
} else if (character <= 65535) {
|
|
2048
|
-
handle = "u";
|
|
2049
|
-
length = 4;
|
|
2050
|
-
} else if (character <= 4294967295) {
|
|
2051
|
-
handle = "U";
|
|
2052
|
-
length = 8;
|
|
2053
|
-
} else {
|
|
2054
|
-
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2055
|
-
}
|
|
2056
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2057
|
-
}
|
|
2058
|
-
var QUOTING_TYPE_SINGLE = 1;
|
|
2059
|
-
var QUOTING_TYPE_DOUBLE = 2;
|
|
2060
|
-
function State(options) {
|
|
2061
|
-
this.schema = options["schema"] || _default;
|
|
2062
|
-
this.indent = Math.max(1, options["indent"] || 2);
|
|
2063
|
-
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2064
|
-
this.skipInvalid = options["skipInvalid"] || false;
|
|
2065
|
-
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2066
|
-
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2067
|
-
this.sortKeys = options["sortKeys"] || false;
|
|
2068
|
-
this.lineWidth = options["lineWidth"] || 80;
|
|
2069
|
-
this.noRefs = options["noRefs"] || false;
|
|
2070
|
-
this.noCompatMode = options["noCompatMode"] || false;
|
|
2071
|
-
this.condenseFlow = options["condenseFlow"] || false;
|
|
2072
|
-
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2073
|
-
this.forceQuotes = options["forceQuotes"] || false;
|
|
2074
|
-
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2075
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2076
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2077
|
-
this.tag = null;
|
|
2078
|
-
this.result = "";
|
|
2079
|
-
this.duplicates = [];
|
|
2080
|
-
this.usedDuplicates = null;
|
|
2081
|
-
}
|
|
2082
|
-
function indentString(string, spaces) {
|
|
2083
|
-
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2084
|
-
while (position < length) {
|
|
2085
|
-
next = string.indexOf("\n", position);
|
|
2086
|
-
if (next === -1) {
|
|
2087
|
-
line = string.slice(position);
|
|
2088
|
-
position = length;
|
|
2089
|
-
} else {
|
|
2090
|
-
line = string.slice(position, next + 1);
|
|
2091
|
-
position = next + 1;
|
|
2092
|
-
}
|
|
2093
|
-
if (line.length && line !== "\n") result += ind;
|
|
2094
|
-
result += line;
|
|
2095
|
-
}
|
|
2096
|
-
return result;
|
|
2097
|
-
}
|
|
2098
|
-
function generateNextLine(state, level) {
|
|
2099
|
-
return "\n" + common.repeat(" ", state.indent * level);
|
|
2100
|
-
}
|
|
2101
|
-
function testImplicitResolving(state, str2) {
|
|
2102
|
-
var index, length, type2;
|
|
2103
|
-
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2104
|
-
type2 = state.implicitTypes[index];
|
|
2105
|
-
if (type2.resolve(str2)) {
|
|
2106
|
-
return true;
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
return false;
|
|
2110
|
-
}
|
|
2111
|
-
function isWhitespace(c) {
|
|
2112
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2113
|
-
}
|
|
2114
|
-
function isPrintable(c) {
|
|
2115
|
-
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2116
|
-
}
|
|
2117
|
-
function isNsCharOrWhitespace(c) {
|
|
2118
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2119
|
-
}
|
|
2120
|
-
function isPlainSafe(c, prev, inblock) {
|
|
2121
|
-
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2122
|
-
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2123
|
-
return (
|
|
2124
|
-
// ns-plain-safe
|
|
2125
|
-
(inblock ? (
|
|
2126
|
-
// c = flow-in
|
|
2127
|
-
cIsNsCharOrWhitespace
|
|
2128
|
-
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2129
|
-
);
|
|
2130
|
-
}
|
|
2131
|
-
function isPlainSafeFirst(c) {
|
|
2132
|
-
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2133
|
-
}
|
|
2134
|
-
function isPlainSafeLast(c) {
|
|
2135
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2136
|
-
}
|
|
2137
|
-
function codePointAt(string, pos) {
|
|
2138
|
-
var first = string.charCodeAt(pos), second;
|
|
2139
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2140
|
-
second = string.charCodeAt(pos + 1);
|
|
2141
|
-
if (second >= 56320 && second <= 57343) {
|
|
2142
|
-
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
return first;
|
|
2146
|
-
}
|
|
2147
|
-
function needIndentIndicator(string) {
|
|
2148
|
-
var leadingSpaceRe = /^\n* /;
|
|
2149
|
-
return leadingSpaceRe.test(string);
|
|
2150
|
-
}
|
|
2151
|
-
var STYLE_PLAIN = 1;
|
|
2152
|
-
var STYLE_SINGLE = 2;
|
|
2153
|
-
var STYLE_LITERAL = 3;
|
|
2154
|
-
var STYLE_FOLDED = 4;
|
|
2155
|
-
var STYLE_DOUBLE = 5;
|
|
2156
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2157
|
-
var i;
|
|
2158
|
-
var char = 0;
|
|
2159
|
-
var prevChar = null;
|
|
2160
|
-
var hasLineBreak = false;
|
|
2161
|
-
var hasFoldableLine = false;
|
|
2162
|
-
var shouldTrackWidth = lineWidth !== -1;
|
|
2163
|
-
var previousLineBreak = -1;
|
|
2164
|
-
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2165
|
-
if (singleLineOnly || forceQuotes) {
|
|
2166
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2167
|
-
char = codePointAt(string, i);
|
|
2168
|
-
if (!isPrintable(char)) {
|
|
2169
|
-
return STYLE_DOUBLE;
|
|
2170
|
-
}
|
|
2171
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2172
|
-
prevChar = char;
|
|
2173
|
-
}
|
|
2174
|
-
} else {
|
|
2175
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2176
|
-
char = codePointAt(string, i);
|
|
2177
|
-
if (char === CHAR_LINE_FEED) {
|
|
2178
|
-
hasLineBreak = true;
|
|
2179
|
-
if (shouldTrackWidth) {
|
|
2180
|
-
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2181
|
-
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2182
|
-
previousLineBreak = i;
|
|
2183
|
-
}
|
|
2184
|
-
} else if (!isPrintable(char)) {
|
|
2185
|
-
return STYLE_DOUBLE;
|
|
2186
|
-
}
|
|
2187
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2188
|
-
prevChar = char;
|
|
2189
|
-
}
|
|
2190
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2191
|
-
}
|
|
2192
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2193
|
-
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2194
|
-
return STYLE_PLAIN;
|
|
2195
|
-
}
|
|
2196
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2197
|
-
}
|
|
2198
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2199
|
-
return STYLE_DOUBLE;
|
|
2200
|
-
}
|
|
2201
|
-
if (!forceQuotes) {
|
|
2202
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2203
|
-
}
|
|
2204
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2205
|
-
}
|
|
2206
|
-
function writeScalar(state, string, level, iskey, inblock) {
|
|
2207
|
-
state.dump = (function() {
|
|
2208
|
-
if (string.length === 0) {
|
|
2209
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2210
|
-
}
|
|
2211
|
-
if (!state.noCompatMode) {
|
|
2212
|
-
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2213
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
var indent = state.indent * Math.max(1, level);
|
|
2217
|
-
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2218
|
-
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2219
|
-
function testAmbiguity(string2) {
|
|
2220
|
-
return testImplicitResolving(state, string2);
|
|
2221
|
-
}
|
|
2222
|
-
switch (chooseScalarStyle(
|
|
2223
|
-
string,
|
|
2224
|
-
singleLineOnly,
|
|
2225
|
-
state.indent,
|
|
2226
|
-
lineWidth,
|
|
2227
|
-
testAmbiguity,
|
|
2228
|
-
state.quotingType,
|
|
2229
|
-
state.forceQuotes && !iskey,
|
|
2230
|
-
inblock
|
|
2231
|
-
)) {
|
|
2232
|
-
case STYLE_PLAIN:
|
|
2233
|
-
return string;
|
|
2234
|
-
case STYLE_SINGLE:
|
|
2235
|
-
return "'" + string.replace(/'/g, "''") + "'";
|
|
2236
|
-
case STYLE_LITERAL:
|
|
2237
|
-
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2238
|
-
case STYLE_FOLDED:
|
|
2239
|
-
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2240
|
-
case STYLE_DOUBLE:
|
|
2241
|
-
return '"' + escapeString(string) + '"';
|
|
2242
|
-
default:
|
|
2243
|
-
throw new exception("impossible error: invalid scalar style");
|
|
2244
|
-
}
|
|
2245
|
-
})();
|
|
2246
|
-
}
|
|
2247
|
-
function blockHeader(string, indentPerLevel) {
|
|
2248
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2249
|
-
var clip = string[string.length - 1] === "\n";
|
|
2250
|
-
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2251
|
-
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2252
|
-
return indentIndicator + chomp + "\n";
|
|
2253
|
-
}
|
|
2254
|
-
function dropEndingNewline(string) {
|
|
2255
|
-
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2256
|
-
}
|
|
2257
|
-
function foldString(string, width) {
|
|
2258
|
-
var lineRe = /(\n+)([^\n]*)/g;
|
|
2259
|
-
var result = (function() {
|
|
2260
|
-
var nextLF = string.indexOf("\n");
|
|
2261
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2262
|
-
lineRe.lastIndex = nextLF;
|
|
2263
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2264
|
-
})();
|
|
2265
|
-
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2266
|
-
var moreIndented;
|
|
2267
|
-
var match;
|
|
2268
|
-
while (match = lineRe.exec(string)) {
|
|
2269
|
-
var prefix = match[1], line = match[2];
|
|
2270
|
-
moreIndented = line[0] === " ";
|
|
2271
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2272
|
-
prevMoreIndented = moreIndented;
|
|
2273
|
-
}
|
|
2274
|
-
return result;
|
|
2275
|
-
}
|
|
2276
|
-
function foldLine(line, width) {
|
|
2277
|
-
if (line === "" || line[0] === " ") return line;
|
|
2278
|
-
var breakRe = / [^ ]/g;
|
|
2279
|
-
var match;
|
|
2280
|
-
var start = 0, end, curr = 0, next = 0;
|
|
2281
|
-
var result = "";
|
|
2282
|
-
while (match = breakRe.exec(line)) {
|
|
2283
|
-
next = match.index;
|
|
2284
|
-
if (next - start > width) {
|
|
2285
|
-
end = curr > start ? curr : next;
|
|
2286
|
-
result += "\n" + line.slice(start, end);
|
|
2287
|
-
start = end + 1;
|
|
2288
|
-
}
|
|
2289
|
-
curr = next;
|
|
2290
|
-
}
|
|
2291
|
-
result += "\n";
|
|
2292
|
-
if (line.length - start > width && curr > start) {
|
|
2293
|
-
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2294
|
-
} else {
|
|
2295
|
-
result += line.slice(start);
|
|
2296
|
-
}
|
|
2297
|
-
return result.slice(1);
|
|
2298
|
-
}
|
|
2299
|
-
function escapeString(string) {
|
|
2300
|
-
var result = "";
|
|
2301
|
-
var char = 0;
|
|
2302
|
-
var escapeSeq;
|
|
2303
|
-
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2304
|
-
char = codePointAt(string, i);
|
|
2305
|
-
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2306
|
-
if (!escapeSeq && isPrintable(char)) {
|
|
2307
|
-
result += string[i];
|
|
2308
|
-
if (char >= 65536) result += string[i + 1];
|
|
2309
|
-
} else {
|
|
2310
|
-
result += escapeSeq || encodeHex(char);
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
return result;
|
|
2314
|
-
}
|
|
2315
|
-
function writeFlowSequence(state, level, object) {
|
|
2316
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2317
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2318
|
-
value = object[index];
|
|
2319
|
-
if (state.replacer) {
|
|
2320
|
-
value = state.replacer.call(object, String(index), value);
|
|
2321
|
-
}
|
|
2322
|
-
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2323
|
-
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2324
|
-
_result += state.dump;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
state.tag = _tag;
|
|
2328
|
-
state.dump = "[" + _result + "]";
|
|
2329
|
-
}
|
|
2330
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2331
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2332
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2333
|
-
value = object[index];
|
|
2334
|
-
if (state.replacer) {
|
|
2335
|
-
value = state.replacer.call(object, String(index), value);
|
|
2336
|
-
}
|
|
2337
|
-
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2338
|
-
if (!compact || _result !== "") {
|
|
2339
|
-
_result += generateNextLine(state, level);
|
|
2340
|
-
}
|
|
2341
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2342
|
-
_result += "-";
|
|
2343
|
-
} else {
|
|
2344
|
-
_result += "- ";
|
|
2345
|
-
}
|
|
2346
|
-
_result += state.dump;
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
state.tag = _tag;
|
|
2350
|
-
state.dump = _result || "[]";
|
|
2351
|
-
}
|
|
2352
|
-
function writeFlowMapping(state, level, object) {
|
|
2353
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2354
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2355
|
-
pairBuffer = "";
|
|
2356
|
-
if (_result !== "") pairBuffer += ", ";
|
|
2357
|
-
if (state.condenseFlow) pairBuffer += '"';
|
|
2358
|
-
objectKey = objectKeyList[index];
|
|
2359
|
-
objectValue = object[objectKey];
|
|
2360
|
-
if (state.replacer) {
|
|
2361
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2362
|
-
}
|
|
2363
|
-
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2364
|
-
continue;
|
|
2365
|
-
}
|
|
2366
|
-
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2367
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2368
|
-
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2369
|
-
continue;
|
|
2370
|
-
}
|
|
2371
|
-
pairBuffer += state.dump;
|
|
2372
|
-
_result += pairBuffer;
|
|
2373
|
-
}
|
|
2374
|
-
state.tag = _tag;
|
|
2375
|
-
state.dump = "{" + _result + "}";
|
|
2376
|
-
}
|
|
2377
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2378
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2379
|
-
if (state.sortKeys === true) {
|
|
2380
|
-
objectKeyList.sort();
|
|
2381
|
-
} else if (typeof state.sortKeys === "function") {
|
|
2382
|
-
objectKeyList.sort(state.sortKeys);
|
|
2383
|
-
} else if (state.sortKeys) {
|
|
2384
|
-
throw new exception("sortKeys must be a boolean or a function");
|
|
2385
|
-
}
|
|
2386
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2387
|
-
pairBuffer = "";
|
|
2388
|
-
if (!compact || _result !== "") {
|
|
2389
|
-
pairBuffer += generateNextLine(state, level);
|
|
2390
|
-
}
|
|
2391
|
-
objectKey = objectKeyList[index];
|
|
2392
|
-
objectValue = object[objectKey];
|
|
2393
|
-
if (state.replacer) {
|
|
2394
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2395
|
-
}
|
|
2396
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2397
|
-
continue;
|
|
2398
|
-
}
|
|
2399
|
-
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2400
|
-
if (explicitPair) {
|
|
2401
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2402
|
-
pairBuffer += "?";
|
|
2403
|
-
} else {
|
|
2404
|
-
pairBuffer += "? ";
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
pairBuffer += state.dump;
|
|
2408
|
-
if (explicitPair) {
|
|
2409
|
-
pairBuffer += generateNextLine(state, level);
|
|
2410
|
-
}
|
|
2411
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2412
|
-
continue;
|
|
2413
|
-
}
|
|
2414
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2415
|
-
pairBuffer += ":";
|
|
2416
|
-
} else {
|
|
2417
|
-
pairBuffer += ": ";
|
|
2418
|
-
}
|
|
2419
|
-
pairBuffer += state.dump;
|
|
2420
|
-
_result += pairBuffer;
|
|
2421
|
-
}
|
|
2422
|
-
state.tag = _tag;
|
|
2423
|
-
state.dump = _result || "{}";
|
|
2424
|
-
}
|
|
2425
|
-
function detectType(state, object, explicit) {
|
|
2426
|
-
var _result, typeList, index, length, type2, style;
|
|
2427
|
-
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2428
|
-
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2429
|
-
type2 = typeList[index];
|
|
2430
|
-
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2431
|
-
if (explicit) {
|
|
2432
|
-
if (type2.multi && type2.representName) {
|
|
2433
|
-
state.tag = type2.representName(object);
|
|
2434
|
-
} else {
|
|
2435
|
-
state.tag = type2.tag;
|
|
2436
|
-
}
|
|
2437
|
-
} else {
|
|
2438
|
-
state.tag = "?";
|
|
2439
|
-
}
|
|
2440
|
-
if (type2.represent) {
|
|
2441
|
-
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2442
|
-
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2443
|
-
_result = type2.represent(object, style);
|
|
2444
|
-
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2445
|
-
_result = type2.represent[style](object, style);
|
|
2446
|
-
} else {
|
|
2447
|
-
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2448
|
-
}
|
|
2449
|
-
state.dump = _result;
|
|
2450
|
-
}
|
|
2451
|
-
return true;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
return false;
|
|
2455
|
-
}
|
|
2456
|
-
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2457
|
-
state.tag = null;
|
|
2458
|
-
state.dump = object;
|
|
2459
|
-
if (!detectType(state, object, false)) {
|
|
2460
|
-
detectType(state, object, true);
|
|
2461
|
-
}
|
|
2462
|
-
var type2 = _toString.call(state.dump);
|
|
2463
|
-
var inblock = block;
|
|
2464
|
-
var tagStr;
|
|
2465
|
-
if (block) {
|
|
2466
|
-
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2467
|
-
}
|
|
2468
|
-
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2469
|
-
if (objectOrArray) {
|
|
2470
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2471
|
-
duplicate = duplicateIndex !== -1;
|
|
2472
|
-
}
|
|
2473
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2474
|
-
compact = false;
|
|
2475
|
-
}
|
|
2476
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2477
|
-
state.dump = "*ref_" + duplicateIndex;
|
|
2478
|
-
} else {
|
|
2479
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2480
|
-
state.usedDuplicates[duplicateIndex] = true;
|
|
2481
|
-
}
|
|
2482
|
-
if (type2 === "[object Object]") {
|
|
2483
|
-
if (block && Object.keys(state.dump).length !== 0) {
|
|
2484
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2485
|
-
if (duplicate) {
|
|
2486
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2487
|
-
}
|
|
2488
|
-
} else {
|
|
2489
|
-
writeFlowMapping(state, level, state.dump);
|
|
2490
|
-
if (duplicate) {
|
|
2491
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
|
-
} else if (type2 === "[object Array]") {
|
|
2495
|
-
if (block && state.dump.length !== 0) {
|
|
2496
|
-
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2497
|
-
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2498
|
-
} else {
|
|
2499
|
-
writeBlockSequence(state, level, state.dump, compact);
|
|
2500
|
-
}
|
|
2501
|
-
if (duplicate) {
|
|
2502
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2503
|
-
}
|
|
2504
|
-
} else {
|
|
2505
|
-
writeFlowSequence(state, level, state.dump);
|
|
2506
|
-
if (duplicate) {
|
|
2507
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
} else if (type2 === "[object String]") {
|
|
2511
|
-
if (state.tag !== "?") {
|
|
2512
|
-
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2513
|
-
}
|
|
2514
|
-
} else if (type2 === "[object Undefined]") {
|
|
2515
|
-
return false;
|
|
2516
|
-
} else {
|
|
2517
|
-
if (state.skipInvalid) return false;
|
|
2518
|
-
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2519
|
-
}
|
|
2520
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
2521
|
-
tagStr = encodeURI(
|
|
2522
|
-
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2523
|
-
).replace(/!/g, "%21");
|
|
2524
|
-
if (state.tag[0] === "!") {
|
|
2525
|
-
tagStr = "!" + tagStr;
|
|
2526
|
-
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2527
|
-
tagStr = "!!" + tagStr.slice(18);
|
|
2528
|
-
} else {
|
|
2529
|
-
tagStr = "!<" + tagStr + ">";
|
|
2530
|
-
}
|
|
2531
|
-
state.dump = tagStr + " " + state.dump;
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
return true;
|
|
2535
|
-
}
|
|
2536
|
-
function getDuplicateReferences(object, state) {
|
|
2537
|
-
var objects = [], duplicatesIndexes = [], index, length;
|
|
2538
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
2539
|
-
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2540
|
-
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2541
|
-
}
|
|
2542
|
-
state.usedDuplicates = new Array(length);
|
|
2543
|
-
}
|
|
2544
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2545
|
-
var objectKeyList, index, length;
|
|
2546
|
-
if (object !== null && typeof object === "object") {
|
|
2547
|
-
index = objects.indexOf(object);
|
|
2548
|
-
if (index !== -1) {
|
|
2549
|
-
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2550
|
-
duplicatesIndexes.push(index);
|
|
2551
|
-
}
|
|
2552
|
-
} else {
|
|
2553
|
-
objects.push(object);
|
|
2554
|
-
if (Array.isArray(object)) {
|
|
2555
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2556
|
-
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2557
|
-
}
|
|
2558
|
-
} else {
|
|
2559
|
-
objectKeyList = Object.keys(object);
|
|
2560
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2561
|
-
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
function dump$1(input, options) {
|
|
2568
|
-
options = options || {};
|
|
2569
|
-
var state = new State(options);
|
|
2570
|
-
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2571
|
-
var value = input;
|
|
2572
|
-
if (state.replacer) {
|
|
2573
|
-
value = state.replacer.call({ "": value }, "", value);
|
|
2574
|
-
}
|
|
2575
|
-
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
2576
|
-
return "";
|
|
2577
|
-
}
|
|
2578
|
-
var dump_1 = dump$1;
|
|
2579
|
-
var dumper = {
|
|
2580
|
-
dump: dump_1
|
|
2581
|
-
};
|
|
2582
|
-
function renamed(from, to) {
|
|
2583
|
-
return function() {
|
|
2584
|
-
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2585
|
-
};
|
|
2586
|
-
}
|
|
2587
|
-
var Type = type;
|
|
2588
|
-
var Schema = schema;
|
|
2589
|
-
var FAILSAFE_SCHEMA = failsafe;
|
|
2590
|
-
var JSON_SCHEMA = json;
|
|
2591
|
-
var CORE_SCHEMA = core;
|
|
2592
|
-
var DEFAULT_SCHEMA = _default;
|
|
2593
|
-
var load = loader.load;
|
|
2594
|
-
var loadAll = loader.loadAll;
|
|
2595
|
-
var dump = dumper.dump;
|
|
2596
|
-
var YAMLException = exception;
|
|
2597
|
-
var types = {
|
|
2598
|
-
binary,
|
|
2599
|
-
float,
|
|
2600
|
-
map,
|
|
2601
|
-
null: _null,
|
|
2602
|
-
pairs,
|
|
2603
|
-
set,
|
|
2604
|
-
timestamp,
|
|
2605
|
-
bool,
|
|
2606
|
-
int,
|
|
2607
|
-
merge,
|
|
2608
|
-
omap,
|
|
2609
|
-
seq,
|
|
2610
|
-
str
|
|
2611
|
-
};
|
|
2612
|
-
var safeLoad = renamed("safeLoad", "load");
|
|
2613
|
-
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
2614
|
-
var safeDump = renamed("safeDump", "dump");
|
|
2615
|
-
var jsYaml = {
|
|
2616
|
-
Type,
|
|
2617
|
-
Schema,
|
|
2618
|
-
FAILSAFE_SCHEMA,
|
|
2619
|
-
JSON_SCHEMA,
|
|
2620
|
-
CORE_SCHEMA,
|
|
2621
|
-
DEFAULT_SCHEMA,
|
|
2622
|
-
load,
|
|
2623
|
-
loadAll,
|
|
2624
|
-
dump,
|
|
2625
|
-
YAMLException,
|
|
2626
|
-
types,
|
|
2627
|
-
safeLoad,
|
|
2628
|
-
safeLoadAll,
|
|
2629
|
-
safeDump
|
|
2630
|
-
};
|
|
2631
|
-
|
|
2632
|
-
// ../core/dist/state-machine-loader.js
|
|
7
|
+
import yaml from "js-yaml";
|
|
2633
8
|
import path from "path";
|
|
2634
9
|
import { fileURLToPath } from "url";
|
|
2635
10
|
import { createRequire } from "module";
|
|
@@ -2723,9 +98,9 @@ var Logger = class _Logger {
|
|
|
2723
98
|
return level >= this.getCurrentLogLevel();
|
|
2724
99
|
}
|
|
2725
100
|
formatMessage(level, message, context) {
|
|
2726
|
-
const
|
|
101
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2727
102
|
const contextStr = context ? ` ${JSON.stringify(context)}` : "";
|
|
2728
|
-
return `[${
|
|
103
|
+
return `[${timestamp}] ${level.toUpperCase()} [${this.component}] ${message}${contextStr}`;
|
|
2729
104
|
}
|
|
2730
105
|
/**
|
|
2731
106
|
* Send log message to registered sink if available
|
|
@@ -2878,7 +253,7 @@ var StateMachineLoader = class {
|
|
|
2878
253
|
loadFromFile(filePath) {
|
|
2879
254
|
try {
|
|
2880
255
|
const yamlContent = fs.readFileSync(path.resolve(filePath), "utf8");
|
|
2881
|
-
const stateMachine =
|
|
256
|
+
const stateMachine = yaml.load(yamlContent);
|
|
2882
257
|
this.validateStateMachine(stateMachine);
|
|
2883
258
|
this.validPhases = new Set(Object.keys(stateMachine.states));
|
|
2884
259
|
this.stateMachine = stateMachine;
|
|
@@ -3056,6 +431,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
3056
431
|
// ../core/dist/config-manager.js
|
|
3057
432
|
import fs2 from "fs";
|
|
3058
433
|
import path2 from "path";
|
|
434
|
+
import yaml2 from "js-yaml";
|
|
3059
435
|
var logger3 = createLogger("ConfigManager");
|
|
3060
436
|
var ConfigManager = class {
|
|
3061
437
|
static CONFIG_FILENAME = "config.yaml";
|
|
@@ -3072,15 +448,16 @@ var ConfigManager = class {
|
|
|
3072
448
|
}
|
|
3073
449
|
try {
|
|
3074
450
|
const configContent = fs2.readFileSync(configPath, "utf-8");
|
|
3075
|
-
const config =
|
|
451
|
+
const config = yaml2.load(configContent);
|
|
3076
452
|
this.validateConfig(config, configPath);
|
|
3077
453
|
logger3.info("Loaded project configuration", {
|
|
3078
454
|
configPath,
|
|
3079
|
-
enabledWorkflows: config.enabled_workflows?.length || 0
|
|
455
|
+
enabledWorkflows: config.enabled_workflows?.length || 0,
|
|
456
|
+
capabilityModels: config.capability_models ? Object.keys(config.capability_models).length : 0
|
|
3080
457
|
});
|
|
3081
458
|
return config;
|
|
3082
459
|
} catch (error) {
|
|
3083
|
-
if (error instanceof
|
|
460
|
+
if (error instanceof yaml2.YAMLException) {
|
|
3084
461
|
throw new Error(`Invalid YAML in config file ${configPath}: ${error.message}`);
|
|
3085
462
|
}
|
|
3086
463
|
throw new Error(`Failed to load config file ${configPath}: ${error}`);
|
|
@@ -3106,6 +483,23 @@ var ConfigManager = class {
|
|
|
3106
483
|
}
|
|
3107
484
|
}
|
|
3108
485
|
}
|
|
486
|
+
if (config.capability_models !== void 0) {
|
|
487
|
+
if (typeof config.capability_models !== "object" || config.capability_models === null || Array.isArray(config.capability_models)) {
|
|
488
|
+
throw new Error(`Invalid config file ${configPath}: capability_models must be an object`);
|
|
489
|
+
}
|
|
490
|
+
for (const [key, entry] of Object.entries(config.capability_models)) {
|
|
491
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
492
|
+
throw new Error(`Invalid config file ${configPath}: capability_models entry '${key}' must be an object`);
|
|
493
|
+
}
|
|
494
|
+
const { model, agent } = entry;
|
|
495
|
+
if (model !== void 0 && (typeof model !== "string" || model.trim() === "")) {
|
|
496
|
+
throw new Error(`Invalid config file ${configPath}: capability_models entry '${key}' model must be a non-empty string`);
|
|
497
|
+
}
|
|
498
|
+
if (agent !== void 0 && (typeof agent !== "string" || agent.trim() === "")) {
|
|
499
|
+
throw new Error(`Invalid config file ${configPath}: capability_models entry '${key}' agent must be a non-empty string`);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
3109
503
|
}
|
|
3110
504
|
};
|
|
3111
505
|
|
|
@@ -4246,7 +1640,7 @@ var PlanManager = class {
|
|
|
4246
1640
|
* Generate initial plan file content based on state machine definition
|
|
4247
1641
|
*/
|
|
4248
1642
|
generateInitialPlanContent(projectName, branchInfo) {
|
|
4249
|
-
const
|
|
1643
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
4250
1644
|
if (!this.stateMachine) {
|
|
4251
1645
|
throw new Error("State machine not set. This should not happen as state machine is always loaded.");
|
|
4252
1646
|
}
|
|
@@ -4255,7 +1649,7 @@ var PlanManager = class {
|
|
|
4255
1649
|
const documentationUrl = this.generateWorkflowDocumentationUrl(this.stateMachine.name);
|
|
4256
1650
|
let content = `# Development Plan: ${projectName}${branchInfo}
|
|
4257
1651
|
|
|
4258
|
-
*Generated on ${
|
|
1652
|
+
*Generated on ${timestamp} by Vibe Feature MCP*
|
|
4259
1653
|
*Workflow: ${documentationUrl ? "[" + this.stateMachine.name + "](" + documentationUrl + ")" : this.stateMachine.name}*
|
|
4260
1654
|
|
|
4261
1655
|
## Goal
|
|
@@ -4565,7 +1959,7 @@ var ConversationManager = class {
|
|
|
4565
1959
|
projectPath,
|
|
4566
1960
|
gitBranch
|
|
4567
1961
|
});
|
|
4568
|
-
const
|
|
1962
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4569
1963
|
const sanitizedBranch = gitBranch.replace(/[/\\]/g, "-");
|
|
4570
1964
|
const planFileName = gitBranch === "main" || gitBranch === "master" ? "development-plan.md" : `development-plan-${sanitizedBranch}.md`;
|
|
4571
1965
|
const planFilePath = resolve2(projectPath, ".vibe", planFileName);
|
|
@@ -4580,8 +1974,8 @@ var ConversationManager = class {
|
|
|
4580
1974
|
workflowName,
|
|
4581
1975
|
requireReviewsBeforePhaseTransition: false,
|
|
4582
1976
|
// Default to false for new conversations
|
|
4583
|
-
createdAt:
|
|
4584
|
-
updatedAt:
|
|
1977
|
+
createdAt: timestamp,
|
|
1978
|
+
updatedAt: timestamp,
|
|
4585
1979
|
...this.currentSessionMetadata && {
|
|
4586
1980
|
sessionMetadata: this.currentSessionMetadata
|
|
4587
1981
|
}
|
|
@@ -4607,9 +2001,9 @@ var ConversationManager = class {
|
|
|
4607
2001
|
return `${projectName}-${cleanBranch}-p423k1`;
|
|
4608
2002
|
}
|
|
4609
2003
|
let hash = 0;
|
|
4610
|
-
const
|
|
4611
|
-
for (let i = 0; i <
|
|
4612
|
-
const char =
|
|
2004
|
+
const str = `${projectPath}:${gitBranch}`;
|
|
2005
|
+
for (let i = 0; i < str.length; i++) {
|
|
2006
|
+
const char = str.charCodeAt(i);
|
|
4613
2007
|
hash = (hash << 5) - hash + char;
|
|
4614
2008
|
hash = hash & hash;
|
|
4615
2009
|
}
|
|
@@ -4838,8 +2232,8 @@ var TemplateManager = class {
|
|
|
4838
2232
|
/**
|
|
4839
2233
|
* Load and render a template
|
|
4840
2234
|
*/
|
|
4841
|
-
async loadTemplate(
|
|
4842
|
-
const templatePath = join3(this.templatesPath,
|
|
2235
|
+
async loadTemplate(type, template) {
|
|
2236
|
+
const templatePath = join3(this.templatesPath, type, template);
|
|
4843
2237
|
const templateFilePath = `${templatePath}.md`;
|
|
4844
2238
|
try {
|
|
4845
2239
|
try {
|
|
@@ -4852,8 +2246,8 @@ var TemplateManager = class {
|
|
|
4852
2246
|
const content = await readFile2(templateFilePath, "utf-8");
|
|
4853
2247
|
return { content };
|
|
4854
2248
|
} catch (error) {
|
|
4855
|
-
logger9.error(`Failed to load template: ${
|
|
4856
|
-
throw new Error(`Template not found: ${
|
|
2249
|
+
logger9.error(`Failed to load template: ${type}/${template}`, error);
|
|
2250
|
+
throw new Error(`Template not found: ${type}/${template}. Tried: ${templatePath} (directory) and ${templateFilePath} (file)`);
|
|
4857
2251
|
}
|
|
4858
2252
|
}
|
|
4859
2253
|
/**
|
|
@@ -4919,8 +2313,8 @@ var TemplateManager = class {
|
|
|
4919
2313
|
design: []
|
|
4920
2314
|
};
|
|
4921
2315
|
try {
|
|
4922
|
-
for (const [
|
|
4923
|
-
const typePath = join3(this.templatesPath,
|
|
2316
|
+
for (const [type, templates] of Object.entries(result)) {
|
|
2317
|
+
const typePath = join3(this.templatesPath, type);
|
|
4924
2318
|
try {
|
|
4925
2319
|
const entries = await readdir(typePath, { withFileTypes: true });
|
|
4926
2320
|
for (const entry of entries) {
|
|
@@ -4933,7 +2327,7 @@ var TemplateManager = class {
|
|
|
4933
2327
|
}
|
|
4934
2328
|
templates.sort();
|
|
4935
2329
|
} catch (error) {
|
|
4936
|
-
logger9.warn(`Failed to scan templates for type: ${
|
|
2330
|
+
logger9.warn(`Failed to scan templates for type: ${type}`, {
|
|
4937
2331
|
typePath,
|
|
4938
2332
|
error: error instanceof Error ? error.message : String(error)
|
|
4939
2333
|
});
|
|
@@ -4987,9 +2381,9 @@ var ProjectDocsManager = class {
|
|
|
4987
2381
|
/**
|
|
4988
2382
|
* Get the target filename for a document type
|
|
4989
2383
|
*/
|
|
4990
|
-
async getDocumentFilename(
|
|
2384
|
+
async getDocumentFilename(type, sourcePath) {
|
|
4991
2385
|
const extension = await this.getDocumentExtension(sourcePath);
|
|
4992
|
-
return extension === "" ?
|
|
2386
|
+
return extension === "" ? type : `${type}${extension}`;
|
|
4993
2387
|
}
|
|
4994
2388
|
/**
|
|
4995
2389
|
* Get paths for all project documents
|
|
@@ -5185,9 +2579,9 @@ var ProjectDocsManager = class {
|
|
|
5185
2579
|
/**
|
|
5186
2580
|
* Create a single document from template
|
|
5187
2581
|
*/
|
|
5188
|
-
async createDocument(
|
|
2582
|
+
async createDocument(type, template, documentPath, docsPath) {
|
|
5189
2583
|
try {
|
|
5190
|
-
const templateResult = await this.templateManager.loadTemplate(
|
|
2584
|
+
const templateResult = await this.templateManager.loadTemplate(type, template);
|
|
5191
2585
|
await writeFile2(documentPath, templateResult.content, "utf-8");
|
|
5192
2586
|
if (templateResult.additionalFiles) {
|
|
5193
2587
|
for (const file of templateResult.additionalFiles) {
|
|
@@ -5197,9 +2591,9 @@ var ProjectDocsManager = class {
|
|
|
5197
2591
|
await writeFile2(filePath, file.content.toString());
|
|
5198
2592
|
}
|
|
5199
2593
|
}
|
|
5200
|
-
this.logger.debug(`Created ${
|
|
2594
|
+
this.logger.debug(`Created ${type} document`, { documentPath, template });
|
|
5201
2595
|
} catch (error) {
|
|
5202
|
-
this.logger.error(`Failed to create ${
|
|
2596
|
+
this.logger.error(`Failed to create ${type} document`, error, {
|
|
5203
2597
|
documentPath,
|
|
5204
2598
|
template
|
|
5205
2599
|
});
|
|
@@ -5238,11 +2632,11 @@ var ProjectDocsManager = class {
|
|
|
5238
2632
|
/**
|
|
5239
2633
|
* Read a project document - returns the path for LLM to read as needed
|
|
5240
2634
|
*/
|
|
5241
|
-
async readDocument(projectPath,
|
|
2635
|
+
async readDocument(projectPath, type) {
|
|
5242
2636
|
const docsInfo = await this.getProjectDocsInfo(projectPath);
|
|
5243
|
-
const documentPath = docsInfo[
|
|
5244
|
-
if (!docsInfo[
|
|
5245
|
-
throw new Error(`${
|
|
2637
|
+
const documentPath = docsInfo[type].path;
|
|
2638
|
+
if (!docsInfo[type].exists) {
|
|
2639
|
+
throw new Error(`${type} document not found: ${documentPath}`);
|
|
5246
2640
|
}
|
|
5247
2641
|
return documentPath;
|
|
5248
2642
|
}
|
|
@@ -5256,9 +2650,9 @@ var ProjectDocsManager = class {
|
|
|
5256
2650
|
/**
|
|
5257
2651
|
* Check if a document is a symlink
|
|
5258
2652
|
*/
|
|
5259
|
-
async isSymlink(projectPath,
|
|
2653
|
+
async isSymlink(projectPath, type) {
|
|
5260
2654
|
const paths = this.getDocumentPaths(projectPath);
|
|
5261
|
-
const documentPath = paths[
|
|
2655
|
+
const documentPath = paths[type];
|
|
5262
2656
|
try {
|
|
5263
2657
|
const stats = await lstat(documentPath);
|
|
5264
2658
|
return stats.isSymbolicLink();
|
|
@@ -5411,8 +2805,8 @@ var FileDetectionManager = class {
|
|
|
5411
2805
|
/**
|
|
5412
2806
|
* Determine confidence level for a match
|
|
5413
2807
|
*/
|
|
5414
|
-
getConfidence(fileName,
|
|
5415
|
-
if (fileName.includes(
|
|
2808
|
+
getConfidence(fileName, type) {
|
|
2809
|
+
if (fileName.includes(type.toLowerCase())) {
|
|
5416
2810
|
return "high";
|
|
5417
2811
|
}
|
|
5418
2812
|
if (fileName.includes("readme")) {
|
|
@@ -6241,6 +3635,31 @@ var BeadsStateManager = class {
|
|
|
6241
3635
|
}
|
|
6242
3636
|
};
|
|
6243
3637
|
|
|
3638
|
+
// ../core/dist/capability-hint.js
|
|
3639
|
+
var CAPABILITY_DESCRIPTIONS = {
|
|
3640
|
+
thinking: "deep reasoning, complex planning",
|
|
3641
|
+
research: "fast information gathering and browsing"
|
|
3642
|
+
};
|
|
3643
|
+
function formatCapabilityHint(capability, config) {
|
|
3644
|
+
if (!capability) {
|
|
3645
|
+
return "";
|
|
3646
|
+
}
|
|
3647
|
+
const description = CAPABILITY_DESCRIPTIONS[capability];
|
|
3648
|
+
const label = description ? `Capability hint: This phase requires ${capability} capability (${description}).` : `Capability hint: This phase requires ${capability} capability.`;
|
|
3649
|
+
const model = config?.model;
|
|
3650
|
+
const agent = config?.agent;
|
|
3651
|
+
if (agent && model) {
|
|
3652
|
+
return `${label} When launching subagents, use agent: ${agent} (model: ${model}).`;
|
|
3653
|
+
}
|
|
3654
|
+
if (agent) {
|
|
3655
|
+
return `${label} When launching subagents, use agent: ${agent}.`;
|
|
3656
|
+
}
|
|
3657
|
+
if (model) {
|
|
3658
|
+
return `${label} When launching subagents, prefer model: ${model}.`;
|
|
3659
|
+
}
|
|
3660
|
+
return label;
|
|
3661
|
+
}
|
|
3662
|
+
|
|
6244
3663
|
// ../core/dist/interaction-logger.js
|
|
6245
3664
|
var logger12 = createLogger("InteractionLogger");
|
|
6246
3665
|
var InteractionLogger = class {
|
|
@@ -6271,20 +3690,20 @@ var InteractionLogger = class {
|
|
|
6271
3690
|
currentPhase
|
|
6272
3691
|
});
|
|
6273
3692
|
try {
|
|
6274
|
-
const
|
|
3693
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
6275
3694
|
const log = {
|
|
6276
3695
|
conversationId,
|
|
6277
3696
|
toolName,
|
|
6278
3697
|
inputParams: JSON.stringify(inputParams),
|
|
6279
3698
|
responseData: JSON.stringify(responseData),
|
|
6280
3699
|
currentPhase,
|
|
6281
|
-
timestamp
|
|
3700
|
+
timestamp
|
|
6282
3701
|
};
|
|
6283
3702
|
await this.database.logInteraction(log);
|
|
6284
3703
|
logger12.info("Interaction logged successfully", {
|
|
6285
3704
|
conversationId,
|
|
6286
3705
|
toolName,
|
|
6287
|
-
timestamp
|
|
3706
|
+
timestamp
|
|
6288
3707
|
});
|
|
6289
3708
|
} catch (error) {
|
|
6290
3709
|
logger12.error("Failed to log interaction", error, {
|
|
@@ -6367,7 +3786,7 @@ var InstructionGenerator = class {
|
|
|
6367
3786
|
* Enhance base instructions with context-specific information
|
|
6368
3787
|
*/
|
|
6369
3788
|
async enhanceInstructions(baseInstructions, context) {
|
|
6370
|
-
const { phase, conversationContext, allowedFilePatterns } = context;
|
|
3789
|
+
const { phase, conversationContext, allowedFilePatterns, requiredCapability, capabilityConfig } = context;
|
|
6371
3790
|
const phaseName = capitalizePhase(phase);
|
|
6372
3791
|
let workflowSection = `---
|
|
6373
3792
|
### YOU MUST FOLLOW THESE INSTRUCTIONS:
|
|
@@ -6382,6 +3801,12 @@ var InstructionGenerator = class {
|
|
|
6382
3801
|
if (allowedFilePatterns && allowedFilePatterns.length > 0 && !allowedFilePatterns.includes("**/*") && !allowedFilePatterns.includes("*")) {
|
|
6383
3802
|
workflowSection += `
|
|
6384
3803
|
- Files allowed: \`${allowedFilePatterns.join("`, `")}\``;
|
|
3804
|
+
}
|
|
3805
|
+
const capabilityHint = formatCapabilityHint(requiredCapability, capabilityConfig);
|
|
3806
|
+
if (capabilityHint) {
|
|
3807
|
+
workflowSection += `
|
|
3808
|
+
|
|
3809
|
+
${capabilityHint}`;
|
|
6385
3810
|
}
|
|
6386
3811
|
workflowSection += "\n\nCall `whats_next()` after user messages.";
|
|
6387
3812
|
return `## ${phaseName} Phase
|
|
@@ -6404,13 +3829,35 @@ function generateSystemPrompt(stateMachine) {
|
|
|
6404
3829
|
function generateSimpleSystemPrompt(_stateMachine) {
|
|
6405
3830
|
logger13.debug("Generating system prompt");
|
|
6406
3831
|
const systemPrompt = `
|
|
6407
|
-
You are
|
|
3832
|
+
You are a structured, workflow-driven agent. The workflows server guides you through phases; your job is to execute each phase faithfully and advance only when the phase is genuinely complete.
|
|
3833
|
+
|
|
3834
|
+
## Core loop
|
|
3835
|
+
|
|
3836
|
+
After every user message, call \`whats_next()\`. It returns a JSON object with an \`instructions\` field. Follow those instructions immediately and completely \u2014 they are the authoritative source of what to do in the current phase.
|
|
3837
|
+
|
|
3838
|
+
The response also returns a \`plan_file_path\`. That file is your persistent memory for the session. Read it at the start of each phase. Update it as directed by the instructions.
|
|
6408
3839
|
|
|
6409
|
-
|
|
3840
|
+
## Before acting
|
|
6410
3841
|
|
|
6411
|
-
|
|
3842
|
+
If the user's message is ambiguous or could be interpreted in more than one way, ask a clarifying question before calling \`whats_next()\`. State what is unclear and what you need to know. Do not silently pick an interpretation and proceed.
|
|
6412
3843
|
|
|
6413
|
-
|
|
3844
|
+
Once intent is clear, state your assumptions explicitly before starting work. Surface tradeoffs. If a simpler approach exists than what was asked, say so.
|
|
3845
|
+
|
|
3846
|
+
## Scope discipline
|
|
3847
|
+
|
|
3848
|
+
Do the minimum the current phase instructions require. Do not do work that belongs to a later phase. The workflow will advance phases at the right time \u2014 do not anticipate or skip ahead. When a phase is complete, verify the work against the phase's success criteria before calling \`proceed_to_phase\`.
|
|
3849
|
+
|
|
3850
|
+
## Subagent delegation
|
|
3851
|
+
|
|
3852
|
+
### Capability hints
|
|
3853
|
+
When \`whats_next()\` includes a capability hint in its instructions (e.g. \`Capability hint: This phase requires thinking capability\`):
|
|
3854
|
+
- If your platform supports switching to a specific model or agent, do so as indicated by the hint.
|
|
3855
|
+
- Otherwise, decompose the phase work into independent, atomic, self-contained tasks and delegate each to a subagent of the indicated capability type (research, thinking, or coding). Collect and integrate results before proceeding.
|
|
3856
|
+
|
|
3857
|
+
### Reviews
|
|
3858
|
+
When \`conduct_review\` is called and returns review perspectives, always delegate the review to a thinking-specialized subagent. Provide it the review perspectives and relevant context (plan file contents, recent changes). Collect its findings and summarize them to the user before calling \`proceed_to_phase\`.
|
|
3859
|
+
|
|
3860
|
+
## Task management
|
|
6414
3861
|
|
|
6415
3862
|
Do not use your own task management tools.`;
|
|
6416
3863
|
logger13.info("System prompt generated successfully", {
|
|
@@ -6444,12 +3891,8 @@ export {
|
|
|
6444
3891
|
TaskBackendManager,
|
|
6445
3892
|
BeadsIntegration,
|
|
6446
3893
|
BeadsStateManager,
|
|
3894
|
+
formatCapabilityHint,
|
|
6447
3895
|
InteractionLogger,
|
|
6448
3896
|
InstructionGenerator,
|
|
6449
3897
|
generateSystemPrompt
|
|
6450
3898
|
};
|
|
6451
|
-
/*! Bundled license information:
|
|
6452
|
-
|
|
6453
|
-
js-yaml/dist/js-yaml.mjs:
|
|
6454
|
-
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
6455
|
-
*/
|