archondev 0.1.0 → 1.2.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/README.md +84 -51
- package/dist/auth-2QIFQZTL.js +12 -0
- package/dist/bug-DXLBBW3U.js +10 -0
- package/dist/{chunk-R6IMTNKV.js → chunk-2CFO5GVH.js} +0 -35
- package/dist/chunk-A7QU6JC6.js +119 -0
- package/dist/chunk-CAYCSBNX.js +202 -0
- package/dist/chunk-EDP55FCI.js +485 -0
- package/dist/chunk-I4ZVNLNO.js +4648 -0
- package/dist/chunk-IMZN36GC.js +159 -0
- package/dist/chunk-JBKFAD4M.js +650 -0
- package/dist/chunk-MOZHC2GX.js +351 -0
- package/dist/chunk-PK3OQVBG.js +91 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/chunk-SMR7JQK6.js +399 -0
- package/dist/chunk-UDBFDXJI.js +696 -0
- package/dist/chunk-UG2ZZ7CM.js +737 -0
- package/dist/chunk-VKM3HAHW.js +832 -0
- package/dist/chunk-WCCBJSNI.js +62 -0
- package/dist/code-review-FSTYDHNG.js +16 -0
- package/dist/execute-LYID2ODD.js +13 -0
- package/dist/index.js +1250 -7206
- package/dist/keys-EL3FUM5O.js +15 -0
- package/dist/list-VXMVEIL5.js +13 -0
- package/dist/{parser-D6PBQUJH.js → parser-M4DI7A24.js} +2 -1
- package/dist/plan-7VSFESVD.js +16 -0
- package/dist/preferences-PL2ON5VY.js +17 -0
- package/dist/review-3R6QXAXQ.js +27 -0
- package/package.json +21 -1
|
@@ -0,0 +1,4648 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadAtom
|
|
3
|
+
} from "./chunk-EDP55FCI.js";
|
|
4
|
+
import {
|
|
5
|
+
ArchitectureParser
|
|
6
|
+
} from "./chunk-2CFO5GVH.js";
|
|
7
|
+
import {
|
|
8
|
+
transitionAtom
|
|
9
|
+
} from "./chunk-MOZHC2GX.js";
|
|
10
|
+
import {
|
|
11
|
+
AnthropicClient,
|
|
12
|
+
getDefaultModel
|
|
13
|
+
} from "./chunk-A7QU6JC6.js";
|
|
14
|
+
import {
|
|
15
|
+
__commonJS,
|
|
16
|
+
__require,
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-QGM4M3NI.js";
|
|
19
|
+
|
|
20
|
+
// node_modules/js-yaml/lib/js-yaml/common.js
|
|
21
|
+
var require_common = __commonJS({
|
|
22
|
+
"node_modules/js-yaml/lib/js-yaml/common.js"(exports, module) {
|
|
23
|
+
"use strict";
|
|
24
|
+
function isNothing(subject) {
|
|
25
|
+
return typeof subject === "undefined" || subject === null;
|
|
26
|
+
}
|
|
27
|
+
function isObject(subject) {
|
|
28
|
+
return typeof subject === "object" && subject !== null;
|
|
29
|
+
}
|
|
30
|
+
function toArray(sequence) {
|
|
31
|
+
if (Array.isArray(sequence)) return sequence;
|
|
32
|
+
else if (isNothing(sequence)) return [];
|
|
33
|
+
return [sequence];
|
|
34
|
+
}
|
|
35
|
+
function extend(target, source) {
|
|
36
|
+
var index, length, key, sourceKeys;
|
|
37
|
+
if (source) {
|
|
38
|
+
sourceKeys = Object.keys(source);
|
|
39
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
40
|
+
key = sourceKeys[index];
|
|
41
|
+
target[key] = source[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
function repeat(string, count) {
|
|
47
|
+
var result = "", cycle;
|
|
48
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
49
|
+
result += string;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function isNegativeZero(number) {
|
|
54
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
55
|
+
}
|
|
56
|
+
module.exports.isNothing = isNothing;
|
|
57
|
+
module.exports.isObject = isObject;
|
|
58
|
+
module.exports.toArray = toArray;
|
|
59
|
+
module.exports.repeat = repeat;
|
|
60
|
+
module.exports.isNegativeZero = isNegativeZero;
|
|
61
|
+
module.exports.extend = extend;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// node_modules/js-yaml/lib/js-yaml/exception.js
|
|
66
|
+
var require_exception = __commonJS({
|
|
67
|
+
"node_modules/js-yaml/lib/js-yaml/exception.js"(exports, module) {
|
|
68
|
+
"use strict";
|
|
69
|
+
function YAMLException(reason, mark) {
|
|
70
|
+
Error.call(this);
|
|
71
|
+
this.name = "YAMLException";
|
|
72
|
+
this.reason = reason;
|
|
73
|
+
this.mark = mark;
|
|
74
|
+
this.message = (this.reason || "(unknown reason)") + (this.mark ? " " + this.mark.toString() : "");
|
|
75
|
+
if (Error.captureStackTrace) {
|
|
76
|
+
Error.captureStackTrace(this, this.constructor);
|
|
77
|
+
} else {
|
|
78
|
+
this.stack = new Error().stack || "";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
YAMLException.prototype = Object.create(Error.prototype);
|
|
82
|
+
YAMLException.prototype.constructor = YAMLException;
|
|
83
|
+
YAMLException.prototype.toString = function toString(compact) {
|
|
84
|
+
var result = this.name + ": ";
|
|
85
|
+
result += this.reason || "(unknown reason)";
|
|
86
|
+
if (!compact && this.mark) {
|
|
87
|
+
result += " " + this.mark.toString();
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
module.exports = YAMLException;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// node_modules/js-yaml/lib/js-yaml/mark.js
|
|
96
|
+
var require_mark = __commonJS({
|
|
97
|
+
"node_modules/js-yaml/lib/js-yaml/mark.js"(exports, module) {
|
|
98
|
+
"use strict";
|
|
99
|
+
var common = require_common();
|
|
100
|
+
function Mark(name, buffer, position, line, column) {
|
|
101
|
+
this.name = name;
|
|
102
|
+
this.buffer = buffer;
|
|
103
|
+
this.position = position;
|
|
104
|
+
this.line = line;
|
|
105
|
+
this.column = column;
|
|
106
|
+
}
|
|
107
|
+
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
|
108
|
+
var head, start, tail, end, snippet;
|
|
109
|
+
if (!this.buffer) return null;
|
|
110
|
+
indent = indent || 4;
|
|
111
|
+
maxLength = maxLength || 75;
|
|
112
|
+
head = "";
|
|
113
|
+
start = this.position;
|
|
114
|
+
while (start > 0 && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(start - 1)) === -1) {
|
|
115
|
+
start -= 1;
|
|
116
|
+
if (this.position - start > maxLength / 2 - 1) {
|
|
117
|
+
head = " ... ";
|
|
118
|
+
start += 5;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
tail = "";
|
|
123
|
+
end = this.position;
|
|
124
|
+
while (end < this.buffer.length && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
|
|
125
|
+
end += 1;
|
|
126
|
+
if (end - this.position > maxLength / 2 - 1) {
|
|
127
|
+
tail = " ... ";
|
|
128
|
+
end -= 5;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
snippet = this.buffer.slice(start, end);
|
|
133
|
+
return common.repeat(" ", indent) + head + snippet + tail + "\n" + common.repeat(" ", indent + this.position - start + head.length) + "^";
|
|
134
|
+
};
|
|
135
|
+
Mark.prototype.toString = function toString(compact) {
|
|
136
|
+
var snippet, where = "";
|
|
137
|
+
if (this.name) {
|
|
138
|
+
where += 'in "' + this.name + '" ';
|
|
139
|
+
}
|
|
140
|
+
where += "at line " + (this.line + 1) + ", column " + (this.column + 1);
|
|
141
|
+
if (!compact) {
|
|
142
|
+
snippet = this.getSnippet();
|
|
143
|
+
if (snippet) {
|
|
144
|
+
where += ":\n" + snippet;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return where;
|
|
148
|
+
};
|
|
149
|
+
module.exports = Mark;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// node_modules/js-yaml/lib/js-yaml/type.js
|
|
154
|
+
var require_type = __commonJS({
|
|
155
|
+
"node_modules/js-yaml/lib/js-yaml/type.js"(exports, module) {
|
|
156
|
+
"use strict";
|
|
157
|
+
var YAMLException = require_exception();
|
|
158
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
159
|
+
"kind",
|
|
160
|
+
"resolve",
|
|
161
|
+
"construct",
|
|
162
|
+
"instanceOf",
|
|
163
|
+
"predicate",
|
|
164
|
+
"represent",
|
|
165
|
+
"defaultStyle",
|
|
166
|
+
"styleAliases"
|
|
167
|
+
];
|
|
168
|
+
var YAML_NODE_KINDS = [
|
|
169
|
+
"scalar",
|
|
170
|
+
"sequence",
|
|
171
|
+
"mapping"
|
|
172
|
+
];
|
|
173
|
+
function compileStyleAliases(map) {
|
|
174
|
+
var result = {};
|
|
175
|
+
if (map !== null) {
|
|
176
|
+
Object.keys(map).forEach(function(style) {
|
|
177
|
+
map[style].forEach(function(alias) {
|
|
178
|
+
result[String(alias)] = style;
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
function Type(tag, options) {
|
|
185
|
+
options = options || {};
|
|
186
|
+
Object.keys(options).forEach(function(name) {
|
|
187
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
188
|
+
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
this.tag = tag;
|
|
192
|
+
this.kind = options["kind"] || null;
|
|
193
|
+
this.resolve = options["resolve"] || function() {
|
|
194
|
+
return true;
|
|
195
|
+
};
|
|
196
|
+
this.construct = options["construct"] || function(data) {
|
|
197
|
+
return data;
|
|
198
|
+
};
|
|
199
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
200
|
+
this.predicate = options["predicate"] || null;
|
|
201
|
+
this.represent = options["represent"] || null;
|
|
202
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
203
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
204
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
205
|
+
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
module.exports = Type;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// node_modules/js-yaml/lib/js-yaml/schema.js
|
|
213
|
+
var require_schema = __commonJS({
|
|
214
|
+
"node_modules/js-yaml/lib/js-yaml/schema.js"(exports, module) {
|
|
215
|
+
"use strict";
|
|
216
|
+
var common = require_common();
|
|
217
|
+
var YAMLException = require_exception();
|
|
218
|
+
var Type = require_type();
|
|
219
|
+
function compileList(schema, name, result) {
|
|
220
|
+
var exclude = [];
|
|
221
|
+
schema.include.forEach(function(includedSchema) {
|
|
222
|
+
result = compileList(includedSchema, name, result);
|
|
223
|
+
});
|
|
224
|
+
schema[name].forEach(function(currentType) {
|
|
225
|
+
result.forEach(function(previousType, previousIndex) {
|
|
226
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
|
|
227
|
+
exclude.push(previousIndex);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
result.push(currentType);
|
|
231
|
+
});
|
|
232
|
+
return result.filter(function(type, index) {
|
|
233
|
+
return exclude.indexOf(index) === -1;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function compileMap() {
|
|
237
|
+
var result = {
|
|
238
|
+
scalar: {},
|
|
239
|
+
sequence: {},
|
|
240
|
+
mapping: {},
|
|
241
|
+
fallback: {}
|
|
242
|
+
}, index, length;
|
|
243
|
+
function collectType(type) {
|
|
244
|
+
result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
|
245
|
+
}
|
|
246
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
247
|
+
arguments[index].forEach(collectType);
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
function Schema(definition) {
|
|
252
|
+
this.include = definition.include || [];
|
|
253
|
+
this.implicit = definition.implicit || [];
|
|
254
|
+
this.explicit = definition.explicit || [];
|
|
255
|
+
this.implicit.forEach(function(type) {
|
|
256
|
+
if (type.loadKind && type.loadKind !== "scalar") {
|
|
257
|
+
throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
this.compiledImplicit = compileList(this, "implicit", []);
|
|
261
|
+
this.compiledExplicit = compileList(this, "explicit", []);
|
|
262
|
+
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
|
263
|
+
}
|
|
264
|
+
Schema.DEFAULT = null;
|
|
265
|
+
Schema.create = function createSchema() {
|
|
266
|
+
var schemas, types;
|
|
267
|
+
switch (arguments.length) {
|
|
268
|
+
case 1:
|
|
269
|
+
schemas = Schema.DEFAULT;
|
|
270
|
+
types = arguments[0];
|
|
271
|
+
break;
|
|
272
|
+
case 2:
|
|
273
|
+
schemas = arguments[0];
|
|
274
|
+
types = arguments[1];
|
|
275
|
+
break;
|
|
276
|
+
default:
|
|
277
|
+
throw new YAMLException("Wrong number of arguments for Schema.create function");
|
|
278
|
+
}
|
|
279
|
+
schemas = common.toArray(schemas);
|
|
280
|
+
types = common.toArray(types);
|
|
281
|
+
if (!schemas.every(function(schema) {
|
|
282
|
+
return schema instanceof Schema;
|
|
283
|
+
})) {
|
|
284
|
+
throw new YAMLException("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");
|
|
285
|
+
}
|
|
286
|
+
if (!types.every(function(type) {
|
|
287
|
+
return type instanceof Type;
|
|
288
|
+
})) {
|
|
289
|
+
throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
290
|
+
}
|
|
291
|
+
return new Schema({
|
|
292
|
+
include: schemas,
|
|
293
|
+
explicit: types
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
module.exports = Schema;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// node_modules/js-yaml/lib/js-yaml/type/str.js
|
|
301
|
+
var require_str = __commonJS({
|
|
302
|
+
"node_modules/js-yaml/lib/js-yaml/type/str.js"(exports, module) {
|
|
303
|
+
"use strict";
|
|
304
|
+
var Type = require_type();
|
|
305
|
+
module.exports = new Type("tag:yaml.org,2002:str", {
|
|
306
|
+
kind: "scalar",
|
|
307
|
+
construct: function(data) {
|
|
308
|
+
return data !== null ? data : "";
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// node_modules/js-yaml/lib/js-yaml/type/seq.js
|
|
315
|
+
var require_seq = __commonJS({
|
|
316
|
+
"node_modules/js-yaml/lib/js-yaml/type/seq.js"(exports, module) {
|
|
317
|
+
"use strict";
|
|
318
|
+
var Type = require_type();
|
|
319
|
+
module.exports = new Type("tag:yaml.org,2002:seq", {
|
|
320
|
+
kind: "sequence",
|
|
321
|
+
construct: function(data) {
|
|
322
|
+
return data !== null ? data : [];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// node_modules/js-yaml/lib/js-yaml/type/map.js
|
|
329
|
+
var require_map = __commonJS({
|
|
330
|
+
"node_modules/js-yaml/lib/js-yaml/type/map.js"(exports, module) {
|
|
331
|
+
"use strict";
|
|
332
|
+
var Type = require_type();
|
|
333
|
+
module.exports = new Type("tag:yaml.org,2002:map", {
|
|
334
|
+
kind: "mapping",
|
|
335
|
+
construct: function(data) {
|
|
336
|
+
return data !== null ? data : {};
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
|
|
343
|
+
var require_failsafe = __commonJS({
|
|
344
|
+
"node_modules/js-yaml/lib/js-yaml/schema/failsafe.js"(exports, module) {
|
|
345
|
+
"use strict";
|
|
346
|
+
var Schema = require_schema();
|
|
347
|
+
module.exports = new Schema({
|
|
348
|
+
explicit: [
|
|
349
|
+
require_str(),
|
|
350
|
+
require_seq(),
|
|
351
|
+
require_map()
|
|
352
|
+
]
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// node_modules/js-yaml/lib/js-yaml/type/null.js
|
|
358
|
+
var require_null = __commonJS({
|
|
359
|
+
"node_modules/js-yaml/lib/js-yaml/type/null.js"(exports, module) {
|
|
360
|
+
"use strict";
|
|
361
|
+
var Type = require_type();
|
|
362
|
+
function resolveYamlNull(data) {
|
|
363
|
+
if (data === null) return true;
|
|
364
|
+
var max = data.length;
|
|
365
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
366
|
+
}
|
|
367
|
+
function constructYamlNull() {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
function isNull(object) {
|
|
371
|
+
return object === null;
|
|
372
|
+
}
|
|
373
|
+
module.exports = new Type("tag:yaml.org,2002:null", {
|
|
374
|
+
kind: "scalar",
|
|
375
|
+
resolve: resolveYamlNull,
|
|
376
|
+
construct: constructYamlNull,
|
|
377
|
+
predicate: isNull,
|
|
378
|
+
represent: {
|
|
379
|
+
canonical: function() {
|
|
380
|
+
return "~";
|
|
381
|
+
},
|
|
382
|
+
lowercase: function() {
|
|
383
|
+
return "null";
|
|
384
|
+
},
|
|
385
|
+
uppercase: function() {
|
|
386
|
+
return "NULL";
|
|
387
|
+
},
|
|
388
|
+
camelcase: function() {
|
|
389
|
+
return "Null";
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
defaultStyle: "lowercase"
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// node_modules/js-yaml/lib/js-yaml/type/bool.js
|
|
398
|
+
var require_bool = __commonJS({
|
|
399
|
+
"node_modules/js-yaml/lib/js-yaml/type/bool.js"(exports, module) {
|
|
400
|
+
"use strict";
|
|
401
|
+
var Type = require_type();
|
|
402
|
+
function resolveYamlBoolean(data) {
|
|
403
|
+
if (data === null) return false;
|
|
404
|
+
var max = data.length;
|
|
405
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
406
|
+
}
|
|
407
|
+
function constructYamlBoolean(data) {
|
|
408
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
409
|
+
}
|
|
410
|
+
function isBoolean(object) {
|
|
411
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
412
|
+
}
|
|
413
|
+
module.exports = new Type("tag:yaml.org,2002:bool", {
|
|
414
|
+
kind: "scalar",
|
|
415
|
+
resolve: resolveYamlBoolean,
|
|
416
|
+
construct: constructYamlBoolean,
|
|
417
|
+
predicate: isBoolean,
|
|
418
|
+
represent: {
|
|
419
|
+
lowercase: function(object) {
|
|
420
|
+
return object ? "true" : "false";
|
|
421
|
+
},
|
|
422
|
+
uppercase: function(object) {
|
|
423
|
+
return object ? "TRUE" : "FALSE";
|
|
424
|
+
},
|
|
425
|
+
camelcase: function(object) {
|
|
426
|
+
return object ? "True" : "False";
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
defaultStyle: "lowercase"
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// node_modules/js-yaml/lib/js-yaml/type/int.js
|
|
435
|
+
var require_int = __commonJS({
|
|
436
|
+
"node_modules/js-yaml/lib/js-yaml/type/int.js"(exports, module) {
|
|
437
|
+
"use strict";
|
|
438
|
+
var common = require_common();
|
|
439
|
+
var Type = require_type();
|
|
440
|
+
function isHexCode(c) {
|
|
441
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
442
|
+
}
|
|
443
|
+
function isOctCode(c) {
|
|
444
|
+
return 48 <= c && c <= 55;
|
|
445
|
+
}
|
|
446
|
+
function isDecCode(c) {
|
|
447
|
+
return 48 <= c && c <= 57;
|
|
448
|
+
}
|
|
449
|
+
function resolveYamlInteger(data) {
|
|
450
|
+
if (data === null) return false;
|
|
451
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
452
|
+
if (!max) return false;
|
|
453
|
+
ch = data[index];
|
|
454
|
+
if (ch === "-" || ch === "+") {
|
|
455
|
+
ch = data[++index];
|
|
456
|
+
}
|
|
457
|
+
if (ch === "0") {
|
|
458
|
+
if (index + 1 === max) return true;
|
|
459
|
+
ch = data[++index];
|
|
460
|
+
if (ch === "b") {
|
|
461
|
+
index++;
|
|
462
|
+
for (; index < max; index++) {
|
|
463
|
+
ch = data[index];
|
|
464
|
+
if (ch === "_") continue;
|
|
465
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
466
|
+
hasDigits = true;
|
|
467
|
+
}
|
|
468
|
+
return hasDigits && ch !== "_";
|
|
469
|
+
}
|
|
470
|
+
if (ch === "x") {
|
|
471
|
+
index++;
|
|
472
|
+
for (; index < max; index++) {
|
|
473
|
+
ch = data[index];
|
|
474
|
+
if (ch === "_") continue;
|
|
475
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
476
|
+
hasDigits = true;
|
|
477
|
+
}
|
|
478
|
+
return hasDigits && ch !== "_";
|
|
479
|
+
}
|
|
480
|
+
for (; index < max; index++) {
|
|
481
|
+
ch = data[index];
|
|
482
|
+
if (ch === "_") continue;
|
|
483
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
484
|
+
hasDigits = true;
|
|
485
|
+
}
|
|
486
|
+
return hasDigits && ch !== "_";
|
|
487
|
+
}
|
|
488
|
+
if (ch === "_") return false;
|
|
489
|
+
for (; index < max; index++) {
|
|
490
|
+
ch = data[index];
|
|
491
|
+
if (ch === "_") continue;
|
|
492
|
+
if (ch === ":") break;
|
|
493
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
hasDigits = true;
|
|
497
|
+
}
|
|
498
|
+
if (!hasDigits || ch === "_") return false;
|
|
499
|
+
if (ch !== ":") return true;
|
|
500
|
+
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
501
|
+
}
|
|
502
|
+
function constructYamlInteger(data) {
|
|
503
|
+
var value = data, sign = 1, ch, base, digits = [];
|
|
504
|
+
if (value.indexOf("_") !== -1) {
|
|
505
|
+
value = value.replace(/_/g, "");
|
|
506
|
+
}
|
|
507
|
+
ch = value[0];
|
|
508
|
+
if (ch === "-" || ch === "+") {
|
|
509
|
+
if (ch === "-") sign = -1;
|
|
510
|
+
value = value.slice(1);
|
|
511
|
+
ch = value[0];
|
|
512
|
+
}
|
|
513
|
+
if (value === "0") return 0;
|
|
514
|
+
if (ch === "0") {
|
|
515
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
516
|
+
if (value[1] === "x") return sign * parseInt(value, 16);
|
|
517
|
+
return sign * parseInt(value, 8);
|
|
518
|
+
}
|
|
519
|
+
if (value.indexOf(":") !== -1) {
|
|
520
|
+
value.split(":").forEach(function(v) {
|
|
521
|
+
digits.unshift(parseInt(v, 10));
|
|
522
|
+
});
|
|
523
|
+
value = 0;
|
|
524
|
+
base = 1;
|
|
525
|
+
digits.forEach(function(d) {
|
|
526
|
+
value += d * base;
|
|
527
|
+
base *= 60;
|
|
528
|
+
});
|
|
529
|
+
return sign * value;
|
|
530
|
+
}
|
|
531
|
+
return sign * parseInt(value, 10);
|
|
532
|
+
}
|
|
533
|
+
function isInteger(object) {
|
|
534
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
535
|
+
}
|
|
536
|
+
module.exports = new Type("tag:yaml.org,2002:int", {
|
|
537
|
+
kind: "scalar",
|
|
538
|
+
resolve: resolveYamlInteger,
|
|
539
|
+
construct: constructYamlInteger,
|
|
540
|
+
predicate: isInteger,
|
|
541
|
+
represent: {
|
|
542
|
+
binary: function(obj) {
|
|
543
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
544
|
+
},
|
|
545
|
+
octal: function(obj) {
|
|
546
|
+
return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1);
|
|
547
|
+
},
|
|
548
|
+
decimal: function(obj) {
|
|
549
|
+
return obj.toString(10);
|
|
550
|
+
},
|
|
551
|
+
/* eslint-disable max-len */
|
|
552
|
+
hexadecimal: function(obj) {
|
|
553
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
defaultStyle: "decimal",
|
|
557
|
+
styleAliases: {
|
|
558
|
+
binary: [2, "bin"],
|
|
559
|
+
octal: [8, "oct"],
|
|
560
|
+
decimal: [10, "dec"],
|
|
561
|
+
hexadecimal: [16, "hex"]
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
// node_modules/js-yaml/lib/js-yaml/type/float.js
|
|
568
|
+
var require_float = __commonJS({
|
|
569
|
+
"node_modules/js-yaml/lib/js-yaml/type/float.js"(exports, module) {
|
|
570
|
+
"use strict";
|
|
571
|
+
var common = require_common();
|
|
572
|
+
var Type = require_type();
|
|
573
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
574
|
+
// 2.5e4, 2.5 and integers
|
|
575
|
+
"^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
576
|
+
);
|
|
577
|
+
function resolveYamlFloat(data) {
|
|
578
|
+
if (data === null) return false;
|
|
579
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
580
|
+
// Probably should update regexp & check speed
|
|
581
|
+
data[data.length - 1] === "_") {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
function constructYamlFloat(data) {
|
|
587
|
+
var value, sign, base, digits;
|
|
588
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
589
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
590
|
+
digits = [];
|
|
591
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
592
|
+
value = value.slice(1);
|
|
593
|
+
}
|
|
594
|
+
if (value === ".inf") {
|
|
595
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
596
|
+
} else if (value === ".nan") {
|
|
597
|
+
return NaN;
|
|
598
|
+
} else if (value.indexOf(":") >= 0) {
|
|
599
|
+
value.split(":").forEach(function(v) {
|
|
600
|
+
digits.unshift(parseFloat(v, 10));
|
|
601
|
+
});
|
|
602
|
+
value = 0;
|
|
603
|
+
base = 1;
|
|
604
|
+
digits.forEach(function(d) {
|
|
605
|
+
value += d * base;
|
|
606
|
+
base *= 60;
|
|
607
|
+
});
|
|
608
|
+
return sign * value;
|
|
609
|
+
}
|
|
610
|
+
return sign * parseFloat(value, 10);
|
|
611
|
+
}
|
|
612
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
613
|
+
function representYamlFloat(object, style) {
|
|
614
|
+
var res;
|
|
615
|
+
if (isNaN(object)) {
|
|
616
|
+
switch (style) {
|
|
617
|
+
case "lowercase":
|
|
618
|
+
return ".nan";
|
|
619
|
+
case "uppercase":
|
|
620
|
+
return ".NAN";
|
|
621
|
+
case "camelcase":
|
|
622
|
+
return ".NaN";
|
|
623
|
+
}
|
|
624
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
625
|
+
switch (style) {
|
|
626
|
+
case "lowercase":
|
|
627
|
+
return ".inf";
|
|
628
|
+
case "uppercase":
|
|
629
|
+
return ".INF";
|
|
630
|
+
case "camelcase":
|
|
631
|
+
return ".Inf";
|
|
632
|
+
}
|
|
633
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
634
|
+
switch (style) {
|
|
635
|
+
case "lowercase":
|
|
636
|
+
return "-.inf";
|
|
637
|
+
case "uppercase":
|
|
638
|
+
return "-.INF";
|
|
639
|
+
case "camelcase":
|
|
640
|
+
return "-.Inf";
|
|
641
|
+
}
|
|
642
|
+
} else if (common.isNegativeZero(object)) {
|
|
643
|
+
return "-0.0";
|
|
644
|
+
}
|
|
645
|
+
res = object.toString(10);
|
|
646
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
647
|
+
}
|
|
648
|
+
function isFloat(object) {
|
|
649
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
650
|
+
}
|
|
651
|
+
module.exports = new Type("tag:yaml.org,2002:float", {
|
|
652
|
+
kind: "scalar",
|
|
653
|
+
resolve: resolveYamlFloat,
|
|
654
|
+
construct: constructYamlFloat,
|
|
655
|
+
predicate: isFloat,
|
|
656
|
+
represent: representYamlFloat,
|
|
657
|
+
defaultStyle: "lowercase"
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// node_modules/js-yaml/lib/js-yaml/schema/json.js
|
|
663
|
+
var require_json = __commonJS({
|
|
664
|
+
"node_modules/js-yaml/lib/js-yaml/schema/json.js"(exports, module) {
|
|
665
|
+
"use strict";
|
|
666
|
+
var Schema = require_schema();
|
|
667
|
+
module.exports = new Schema({
|
|
668
|
+
include: [
|
|
669
|
+
require_failsafe()
|
|
670
|
+
],
|
|
671
|
+
implicit: [
|
|
672
|
+
require_null(),
|
|
673
|
+
require_bool(),
|
|
674
|
+
require_int(),
|
|
675
|
+
require_float()
|
|
676
|
+
]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
// node_modules/js-yaml/lib/js-yaml/schema/core.js
|
|
682
|
+
var require_core = __commonJS({
|
|
683
|
+
"node_modules/js-yaml/lib/js-yaml/schema/core.js"(exports, module) {
|
|
684
|
+
"use strict";
|
|
685
|
+
var Schema = require_schema();
|
|
686
|
+
module.exports = new Schema({
|
|
687
|
+
include: [
|
|
688
|
+
require_json()
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
// node_modules/js-yaml/lib/js-yaml/type/timestamp.js
|
|
695
|
+
var require_timestamp = __commonJS({
|
|
696
|
+
"node_modules/js-yaml/lib/js-yaml/type/timestamp.js"(exports, module) {
|
|
697
|
+
"use strict";
|
|
698
|
+
var Type = require_type();
|
|
699
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
700
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
701
|
+
);
|
|
702
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
703
|
+
"^([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]))?))?$"
|
|
704
|
+
);
|
|
705
|
+
function resolveYamlTimestamp(data) {
|
|
706
|
+
if (data === null) return false;
|
|
707
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
708
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
function constructYamlTimestamp(data) {
|
|
712
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
713
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
714
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
715
|
+
if (match === null) throw new Error("Date resolve error");
|
|
716
|
+
year = +match[1];
|
|
717
|
+
month = +match[2] - 1;
|
|
718
|
+
day = +match[3];
|
|
719
|
+
if (!match[4]) {
|
|
720
|
+
return new Date(Date.UTC(year, month, day));
|
|
721
|
+
}
|
|
722
|
+
hour = +match[4];
|
|
723
|
+
minute = +match[5];
|
|
724
|
+
second = +match[6];
|
|
725
|
+
if (match[7]) {
|
|
726
|
+
fraction = match[7].slice(0, 3);
|
|
727
|
+
while (fraction.length < 3) {
|
|
728
|
+
fraction += "0";
|
|
729
|
+
}
|
|
730
|
+
fraction = +fraction;
|
|
731
|
+
}
|
|
732
|
+
if (match[9]) {
|
|
733
|
+
tz_hour = +match[10];
|
|
734
|
+
tz_minute = +(match[11] || 0);
|
|
735
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
736
|
+
if (match[9] === "-") delta = -delta;
|
|
737
|
+
}
|
|
738
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
739
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
740
|
+
return date;
|
|
741
|
+
}
|
|
742
|
+
function representYamlTimestamp(object) {
|
|
743
|
+
return object.toISOString();
|
|
744
|
+
}
|
|
745
|
+
module.exports = new Type("tag:yaml.org,2002:timestamp", {
|
|
746
|
+
kind: "scalar",
|
|
747
|
+
resolve: resolveYamlTimestamp,
|
|
748
|
+
construct: constructYamlTimestamp,
|
|
749
|
+
instanceOf: Date,
|
|
750
|
+
represent: representYamlTimestamp
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
// node_modules/js-yaml/lib/js-yaml/type/merge.js
|
|
756
|
+
var require_merge = __commonJS({
|
|
757
|
+
"node_modules/js-yaml/lib/js-yaml/type/merge.js"(exports, module) {
|
|
758
|
+
"use strict";
|
|
759
|
+
var Type = require_type();
|
|
760
|
+
function resolveYamlMerge(data) {
|
|
761
|
+
return data === "<<" || data === null;
|
|
762
|
+
}
|
|
763
|
+
module.exports = new Type("tag:yaml.org,2002:merge", {
|
|
764
|
+
kind: "scalar",
|
|
765
|
+
resolve: resolveYamlMerge
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
// node_modules/js-yaml/lib/js-yaml/type/binary.js
|
|
771
|
+
var require_binary = __commonJS({
|
|
772
|
+
"node_modules/js-yaml/lib/js-yaml/type/binary.js"(exports, module) {
|
|
773
|
+
"use strict";
|
|
774
|
+
var NodeBuffer;
|
|
775
|
+
try {
|
|
776
|
+
_require = __require;
|
|
777
|
+
NodeBuffer = _require("buffer").Buffer;
|
|
778
|
+
} catch (__) {
|
|
779
|
+
}
|
|
780
|
+
var _require;
|
|
781
|
+
var Type = require_type();
|
|
782
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
783
|
+
function resolveYamlBinary(data) {
|
|
784
|
+
if (data === null) return false;
|
|
785
|
+
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
|
786
|
+
for (idx = 0; idx < max; idx++) {
|
|
787
|
+
code = map.indexOf(data.charAt(idx));
|
|
788
|
+
if (code > 64) continue;
|
|
789
|
+
if (code < 0) return false;
|
|
790
|
+
bitlen += 6;
|
|
791
|
+
}
|
|
792
|
+
return bitlen % 8 === 0;
|
|
793
|
+
}
|
|
794
|
+
function constructYamlBinary(data) {
|
|
795
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
|
|
796
|
+
for (idx = 0; idx < max; idx++) {
|
|
797
|
+
if (idx % 4 === 0 && idx) {
|
|
798
|
+
result.push(bits >> 16 & 255);
|
|
799
|
+
result.push(bits >> 8 & 255);
|
|
800
|
+
result.push(bits & 255);
|
|
801
|
+
}
|
|
802
|
+
bits = bits << 6 | map.indexOf(input.charAt(idx));
|
|
803
|
+
}
|
|
804
|
+
tailbits = max % 4 * 6;
|
|
805
|
+
if (tailbits === 0) {
|
|
806
|
+
result.push(bits >> 16 & 255);
|
|
807
|
+
result.push(bits >> 8 & 255);
|
|
808
|
+
result.push(bits & 255);
|
|
809
|
+
} else if (tailbits === 18) {
|
|
810
|
+
result.push(bits >> 10 & 255);
|
|
811
|
+
result.push(bits >> 2 & 255);
|
|
812
|
+
} else if (tailbits === 12) {
|
|
813
|
+
result.push(bits >> 4 & 255);
|
|
814
|
+
}
|
|
815
|
+
if (NodeBuffer) {
|
|
816
|
+
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
|
|
817
|
+
}
|
|
818
|
+
return result;
|
|
819
|
+
}
|
|
820
|
+
function representYamlBinary(object) {
|
|
821
|
+
var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
|
|
822
|
+
for (idx = 0; idx < max; idx++) {
|
|
823
|
+
if (idx % 3 === 0 && idx) {
|
|
824
|
+
result += map[bits >> 18 & 63];
|
|
825
|
+
result += map[bits >> 12 & 63];
|
|
826
|
+
result += map[bits >> 6 & 63];
|
|
827
|
+
result += map[bits & 63];
|
|
828
|
+
}
|
|
829
|
+
bits = (bits << 8) + object[idx];
|
|
830
|
+
}
|
|
831
|
+
tail = max % 3;
|
|
832
|
+
if (tail === 0) {
|
|
833
|
+
result += map[bits >> 18 & 63];
|
|
834
|
+
result += map[bits >> 12 & 63];
|
|
835
|
+
result += map[bits >> 6 & 63];
|
|
836
|
+
result += map[bits & 63];
|
|
837
|
+
} else if (tail === 2) {
|
|
838
|
+
result += map[bits >> 10 & 63];
|
|
839
|
+
result += map[bits >> 4 & 63];
|
|
840
|
+
result += map[bits << 2 & 63];
|
|
841
|
+
result += map[64];
|
|
842
|
+
} else if (tail === 1) {
|
|
843
|
+
result += map[bits >> 2 & 63];
|
|
844
|
+
result += map[bits << 4 & 63];
|
|
845
|
+
result += map[64];
|
|
846
|
+
result += map[64];
|
|
847
|
+
}
|
|
848
|
+
return result;
|
|
849
|
+
}
|
|
850
|
+
function isBinary(object) {
|
|
851
|
+
return NodeBuffer && NodeBuffer.isBuffer(object);
|
|
852
|
+
}
|
|
853
|
+
module.exports = new Type("tag:yaml.org,2002:binary", {
|
|
854
|
+
kind: "scalar",
|
|
855
|
+
resolve: resolveYamlBinary,
|
|
856
|
+
construct: constructYamlBinary,
|
|
857
|
+
predicate: isBinary,
|
|
858
|
+
represent: representYamlBinary
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
// node_modules/js-yaml/lib/js-yaml/type/omap.js
|
|
864
|
+
var require_omap = __commonJS({
|
|
865
|
+
"node_modules/js-yaml/lib/js-yaml/type/omap.js"(exports, module) {
|
|
866
|
+
"use strict";
|
|
867
|
+
var Type = require_type();
|
|
868
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
869
|
+
var _toString = Object.prototype.toString;
|
|
870
|
+
function resolveYamlOmap(data) {
|
|
871
|
+
if (data === null) return true;
|
|
872
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
873
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
874
|
+
pair = object[index];
|
|
875
|
+
pairHasKey = false;
|
|
876
|
+
if (_toString.call(pair) !== "[object Object]") return false;
|
|
877
|
+
for (pairKey in pair) {
|
|
878
|
+
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
879
|
+
if (!pairHasKey) pairHasKey = true;
|
|
880
|
+
else return false;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if (!pairHasKey) return false;
|
|
884
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
885
|
+
else return false;
|
|
886
|
+
}
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
function constructYamlOmap(data) {
|
|
890
|
+
return data !== null ? data : [];
|
|
891
|
+
}
|
|
892
|
+
module.exports = new Type("tag:yaml.org,2002:omap", {
|
|
893
|
+
kind: "sequence",
|
|
894
|
+
resolve: resolveYamlOmap,
|
|
895
|
+
construct: constructYamlOmap
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// node_modules/js-yaml/lib/js-yaml/type/pairs.js
|
|
901
|
+
var require_pairs = __commonJS({
|
|
902
|
+
"node_modules/js-yaml/lib/js-yaml/type/pairs.js"(exports, module) {
|
|
903
|
+
"use strict";
|
|
904
|
+
var Type = require_type();
|
|
905
|
+
var _toString = Object.prototype.toString;
|
|
906
|
+
function resolveYamlPairs(data) {
|
|
907
|
+
if (data === null) return true;
|
|
908
|
+
var index, length, pair, keys, result, object = data;
|
|
909
|
+
result = new Array(object.length);
|
|
910
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
911
|
+
pair = object[index];
|
|
912
|
+
if (_toString.call(pair) !== "[object Object]") return false;
|
|
913
|
+
keys = Object.keys(pair);
|
|
914
|
+
if (keys.length !== 1) return false;
|
|
915
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
916
|
+
}
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
function constructYamlPairs(data) {
|
|
920
|
+
if (data === null) return [];
|
|
921
|
+
var index, length, pair, keys, result, object = data;
|
|
922
|
+
result = new Array(object.length);
|
|
923
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
924
|
+
pair = object[index];
|
|
925
|
+
keys = Object.keys(pair);
|
|
926
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
927
|
+
}
|
|
928
|
+
return result;
|
|
929
|
+
}
|
|
930
|
+
module.exports = new Type("tag:yaml.org,2002:pairs", {
|
|
931
|
+
kind: "sequence",
|
|
932
|
+
resolve: resolveYamlPairs,
|
|
933
|
+
construct: constructYamlPairs
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
// node_modules/js-yaml/lib/js-yaml/type/set.js
|
|
939
|
+
var require_set = __commonJS({
|
|
940
|
+
"node_modules/js-yaml/lib/js-yaml/type/set.js"(exports, module) {
|
|
941
|
+
"use strict";
|
|
942
|
+
var Type = require_type();
|
|
943
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
944
|
+
function resolveYamlSet(data) {
|
|
945
|
+
if (data === null) return true;
|
|
946
|
+
var key, object = data;
|
|
947
|
+
for (key in object) {
|
|
948
|
+
if (_hasOwnProperty.call(object, key)) {
|
|
949
|
+
if (object[key] !== null) return false;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
function constructYamlSet(data) {
|
|
955
|
+
return data !== null ? data : {};
|
|
956
|
+
}
|
|
957
|
+
module.exports = new Type("tag:yaml.org,2002:set", {
|
|
958
|
+
kind: "mapping",
|
|
959
|
+
resolve: resolveYamlSet,
|
|
960
|
+
construct: constructYamlSet
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
// node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
|
|
966
|
+
var require_default_safe = __commonJS({
|
|
967
|
+
"node_modules/js-yaml/lib/js-yaml/schema/default_safe.js"(exports, module) {
|
|
968
|
+
"use strict";
|
|
969
|
+
var Schema = require_schema();
|
|
970
|
+
module.exports = new Schema({
|
|
971
|
+
include: [
|
|
972
|
+
require_core()
|
|
973
|
+
],
|
|
974
|
+
implicit: [
|
|
975
|
+
require_timestamp(),
|
|
976
|
+
require_merge()
|
|
977
|
+
],
|
|
978
|
+
explicit: [
|
|
979
|
+
require_binary(),
|
|
980
|
+
require_omap(),
|
|
981
|
+
require_pairs(),
|
|
982
|
+
require_set()
|
|
983
|
+
]
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
// node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
|
|
989
|
+
var require_undefined = __commonJS({
|
|
990
|
+
"node_modules/js-yaml/lib/js-yaml/type/js/undefined.js"(exports, module) {
|
|
991
|
+
"use strict";
|
|
992
|
+
var Type = require_type();
|
|
993
|
+
function resolveJavascriptUndefined() {
|
|
994
|
+
return true;
|
|
995
|
+
}
|
|
996
|
+
function constructJavascriptUndefined() {
|
|
997
|
+
return void 0;
|
|
998
|
+
}
|
|
999
|
+
function representJavascriptUndefined() {
|
|
1000
|
+
return "";
|
|
1001
|
+
}
|
|
1002
|
+
function isUndefined(object) {
|
|
1003
|
+
return typeof object === "undefined";
|
|
1004
|
+
}
|
|
1005
|
+
module.exports = new Type("tag:yaml.org,2002:js/undefined", {
|
|
1006
|
+
kind: "scalar",
|
|
1007
|
+
resolve: resolveJavascriptUndefined,
|
|
1008
|
+
construct: constructJavascriptUndefined,
|
|
1009
|
+
predicate: isUndefined,
|
|
1010
|
+
represent: representJavascriptUndefined
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
// node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
|
|
1016
|
+
var require_regexp = __commonJS({
|
|
1017
|
+
"node_modules/js-yaml/lib/js-yaml/type/js/regexp.js"(exports, module) {
|
|
1018
|
+
"use strict";
|
|
1019
|
+
var Type = require_type();
|
|
1020
|
+
function resolveJavascriptRegExp(data) {
|
|
1021
|
+
if (data === null) return false;
|
|
1022
|
+
if (data.length === 0) return false;
|
|
1023
|
+
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1024
|
+
if (regexp[0] === "/") {
|
|
1025
|
+
if (tail) modifiers = tail[1];
|
|
1026
|
+
if (modifiers.length > 3) return false;
|
|
1027
|
+
if (regexp[regexp.length - modifiers.length - 1] !== "/") return false;
|
|
1028
|
+
}
|
|
1029
|
+
return true;
|
|
1030
|
+
}
|
|
1031
|
+
function constructJavascriptRegExp(data) {
|
|
1032
|
+
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1033
|
+
if (regexp[0] === "/") {
|
|
1034
|
+
if (tail) modifiers = tail[1];
|
|
1035
|
+
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
|
1036
|
+
}
|
|
1037
|
+
return new RegExp(regexp, modifiers);
|
|
1038
|
+
}
|
|
1039
|
+
function representJavascriptRegExp(object) {
|
|
1040
|
+
var result = "/" + object.source + "/";
|
|
1041
|
+
if (object.global) result += "g";
|
|
1042
|
+
if (object.multiline) result += "m";
|
|
1043
|
+
if (object.ignoreCase) result += "i";
|
|
1044
|
+
return result;
|
|
1045
|
+
}
|
|
1046
|
+
function isRegExp(object) {
|
|
1047
|
+
return Object.prototype.toString.call(object) === "[object RegExp]";
|
|
1048
|
+
}
|
|
1049
|
+
module.exports = new Type("tag:yaml.org,2002:js/regexp", {
|
|
1050
|
+
kind: "scalar",
|
|
1051
|
+
resolve: resolveJavascriptRegExp,
|
|
1052
|
+
construct: constructJavascriptRegExp,
|
|
1053
|
+
predicate: isRegExp,
|
|
1054
|
+
represent: representJavascriptRegExp
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
// node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
|
1060
|
+
var require_function = __commonJS({
|
|
1061
|
+
"node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports, module) {
|
|
1062
|
+
"use strict";
|
|
1063
|
+
var esprima;
|
|
1064
|
+
try {
|
|
1065
|
+
_require = __require;
|
|
1066
|
+
esprima = _require("esprima");
|
|
1067
|
+
} catch (_) {
|
|
1068
|
+
if (typeof window !== "undefined") esprima = window.esprima;
|
|
1069
|
+
}
|
|
1070
|
+
var _require;
|
|
1071
|
+
var Type = require_type();
|
|
1072
|
+
function resolveJavascriptFunction(data) {
|
|
1073
|
+
if (data === null) return false;
|
|
1074
|
+
try {
|
|
1075
|
+
var source = "(" + data + ")", ast = esprima.parse(source, { range: true });
|
|
1076
|
+
if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
return true;
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
function constructJavascriptFunction(data) {
|
|
1085
|
+
var source = "(" + data + ")", ast = esprima.parse(source, { range: true }), params = [], body;
|
|
1086
|
+
if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
|
|
1087
|
+
throw new Error("Failed to resolve function");
|
|
1088
|
+
}
|
|
1089
|
+
ast.body[0].expression.params.forEach(function(param) {
|
|
1090
|
+
params.push(param.name);
|
|
1091
|
+
});
|
|
1092
|
+
body = ast.body[0].expression.body.range;
|
|
1093
|
+
if (ast.body[0].expression.body.type === "BlockStatement") {
|
|
1094
|
+
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
|
1095
|
+
}
|
|
1096
|
+
return new Function(params, "return " + source.slice(body[0], body[1]));
|
|
1097
|
+
}
|
|
1098
|
+
function representJavascriptFunction(object) {
|
|
1099
|
+
return object.toString();
|
|
1100
|
+
}
|
|
1101
|
+
function isFunction(object) {
|
|
1102
|
+
return Object.prototype.toString.call(object) === "[object Function]";
|
|
1103
|
+
}
|
|
1104
|
+
module.exports = new Type("tag:yaml.org,2002:js/function", {
|
|
1105
|
+
kind: "scalar",
|
|
1106
|
+
resolve: resolveJavascriptFunction,
|
|
1107
|
+
construct: constructJavascriptFunction,
|
|
1108
|
+
predicate: isFunction,
|
|
1109
|
+
represent: representJavascriptFunction
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
// node_modules/js-yaml/lib/js-yaml/schema/default_full.js
|
|
1115
|
+
var require_default_full = __commonJS({
|
|
1116
|
+
"node_modules/js-yaml/lib/js-yaml/schema/default_full.js"(exports, module) {
|
|
1117
|
+
"use strict";
|
|
1118
|
+
var Schema = require_schema();
|
|
1119
|
+
module.exports = Schema.DEFAULT = new Schema({
|
|
1120
|
+
include: [
|
|
1121
|
+
require_default_safe()
|
|
1122
|
+
],
|
|
1123
|
+
explicit: [
|
|
1124
|
+
require_undefined(),
|
|
1125
|
+
require_regexp(),
|
|
1126
|
+
require_function()
|
|
1127
|
+
]
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// node_modules/js-yaml/lib/js-yaml/loader.js
|
|
1133
|
+
var require_loader = __commonJS({
|
|
1134
|
+
"node_modules/js-yaml/lib/js-yaml/loader.js"(exports, module) {
|
|
1135
|
+
"use strict";
|
|
1136
|
+
var common = require_common();
|
|
1137
|
+
var YAMLException = require_exception();
|
|
1138
|
+
var Mark = require_mark();
|
|
1139
|
+
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
1140
|
+
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
1141
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1142
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1143
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1144
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1145
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1146
|
+
var CHOMPING_CLIP = 1;
|
|
1147
|
+
var CHOMPING_STRIP = 2;
|
|
1148
|
+
var CHOMPING_KEEP = 3;
|
|
1149
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1150
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1151
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1152
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1153
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1154
|
+
function _class(obj) {
|
|
1155
|
+
return Object.prototype.toString.call(obj);
|
|
1156
|
+
}
|
|
1157
|
+
function is_EOL(c) {
|
|
1158
|
+
return c === 10 || c === 13;
|
|
1159
|
+
}
|
|
1160
|
+
function is_WHITE_SPACE(c) {
|
|
1161
|
+
return c === 9 || c === 32;
|
|
1162
|
+
}
|
|
1163
|
+
function is_WS_OR_EOL(c) {
|
|
1164
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1165
|
+
}
|
|
1166
|
+
function is_FLOW_INDICATOR(c) {
|
|
1167
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1168
|
+
}
|
|
1169
|
+
function fromHexCode(c) {
|
|
1170
|
+
var lc;
|
|
1171
|
+
if (48 <= c && c <= 57) {
|
|
1172
|
+
return c - 48;
|
|
1173
|
+
}
|
|
1174
|
+
lc = c | 32;
|
|
1175
|
+
if (97 <= lc && lc <= 102) {
|
|
1176
|
+
return lc - 97 + 10;
|
|
1177
|
+
}
|
|
1178
|
+
return -1;
|
|
1179
|
+
}
|
|
1180
|
+
function escapedHexLen(c) {
|
|
1181
|
+
if (c === 120) {
|
|
1182
|
+
return 2;
|
|
1183
|
+
}
|
|
1184
|
+
if (c === 117) {
|
|
1185
|
+
return 4;
|
|
1186
|
+
}
|
|
1187
|
+
if (c === 85) {
|
|
1188
|
+
return 8;
|
|
1189
|
+
}
|
|
1190
|
+
return 0;
|
|
1191
|
+
}
|
|
1192
|
+
function fromDecimalCode(c) {
|
|
1193
|
+
if (48 <= c && c <= 57) {
|
|
1194
|
+
return c - 48;
|
|
1195
|
+
}
|
|
1196
|
+
return -1;
|
|
1197
|
+
}
|
|
1198
|
+
function simpleEscapeSequence(c) {
|
|
1199
|
+
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" : "";
|
|
1200
|
+
}
|
|
1201
|
+
function charFromCodepoint(c) {
|
|
1202
|
+
if (c <= 65535) {
|
|
1203
|
+
return String.fromCharCode(c);
|
|
1204
|
+
}
|
|
1205
|
+
return String.fromCharCode(
|
|
1206
|
+
(c - 65536 >> 10) + 55296,
|
|
1207
|
+
(c - 65536 & 1023) + 56320
|
|
1208
|
+
);
|
|
1209
|
+
}
|
|
1210
|
+
function setProperty(object, key, value) {
|
|
1211
|
+
if (key === "__proto__") {
|
|
1212
|
+
Object.defineProperty(object, key, {
|
|
1213
|
+
configurable: true,
|
|
1214
|
+
enumerable: true,
|
|
1215
|
+
writable: true,
|
|
1216
|
+
value
|
|
1217
|
+
});
|
|
1218
|
+
} else {
|
|
1219
|
+
object[key] = value;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
var simpleEscapeCheck = new Array(256);
|
|
1223
|
+
var simpleEscapeMap = new Array(256);
|
|
1224
|
+
for (i = 0; i < 256; i++) {
|
|
1225
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1226
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1227
|
+
}
|
|
1228
|
+
var i;
|
|
1229
|
+
function State(input, options) {
|
|
1230
|
+
this.input = input;
|
|
1231
|
+
this.filename = options["filename"] || null;
|
|
1232
|
+
this.schema = options["schema"] || DEFAULT_FULL_SCHEMA;
|
|
1233
|
+
this.onWarning = options["onWarning"] || null;
|
|
1234
|
+
this.legacy = options["legacy"] || false;
|
|
1235
|
+
this.json = options["json"] || false;
|
|
1236
|
+
this.listener = options["listener"] || null;
|
|
1237
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1238
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1239
|
+
this.length = input.length;
|
|
1240
|
+
this.position = 0;
|
|
1241
|
+
this.line = 0;
|
|
1242
|
+
this.lineStart = 0;
|
|
1243
|
+
this.lineIndent = 0;
|
|
1244
|
+
this.documents = [];
|
|
1245
|
+
}
|
|
1246
|
+
function generateError(state, message) {
|
|
1247
|
+
return new YAMLException(
|
|
1248
|
+
message,
|
|
1249
|
+
new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart)
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
function throwError(state, message) {
|
|
1253
|
+
throw generateError(state, message);
|
|
1254
|
+
}
|
|
1255
|
+
function throwWarning(state, message) {
|
|
1256
|
+
if (state.onWarning) {
|
|
1257
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
var directiveHandlers = {
|
|
1261
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1262
|
+
var match, major, minor;
|
|
1263
|
+
if (state.version !== null) {
|
|
1264
|
+
throwError(state, "duplication of %YAML directive");
|
|
1265
|
+
}
|
|
1266
|
+
if (args.length !== 1) {
|
|
1267
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1268
|
+
}
|
|
1269
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1270
|
+
if (match === null) {
|
|
1271
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1272
|
+
}
|
|
1273
|
+
major = parseInt(match[1], 10);
|
|
1274
|
+
minor = parseInt(match[2], 10);
|
|
1275
|
+
if (major !== 1) {
|
|
1276
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1277
|
+
}
|
|
1278
|
+
state.version = args[0];
|
|
1279
|
+
state.checkLineBreaks = minor < 2;
|
|
1280
|
+
if (minor !== 1 && minor !== 2) {
|
|
1281
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1285
|
+
var handle, prefix;
|
|
1286
|
+
if (args.length !== 2) {
|
|
1287
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1288
|
+
}
|
|
1289
|
+
handle = args[0];
|
|
1290
|
+
prefix = args[1];
|
|
1291
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1292
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1293
|
+
}
|
|
1294
|
+
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
1295
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1296
|
+
}
|
|
1297
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1298
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1299
|
+
}
|
|
1300
|
+
state.tagMap[handle] = prefix;
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1304
|
+
var _position, _length, _character, _result;
|
|
1305
|
+
if (start < end) {
|
|
1306
|
+
_result = state.input.slice(start, end);
|
|
1307
|
+
if (checkJson) {
|
|
1308
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1309
|
+
_character = _result.charCodeAt(_position);
|
|
1310
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1311
|
+
throwError(state, "expected valid JSON character");
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1315
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1316
|
+
}
|
|
1317
|
+
state.result += _result;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1321
|
+
var sourceKeys, key, index, quantity;
|
|
1322
|
+
if (!common.isObject(source)) {
|
|
1323
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1324
|
+
}
|
|
1325
|
+
sourceKeys = Object.keys(source);
|
|
1326
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1327
|
+
key = sourceKeys[index];
|
|
1328
|
+
if (!_hasOwnProperty.call(destination, key)) {
|
|
1329
|
+
setProperty(destination, key, source[key]);
|
|
1330
|
+
overridableKeys[key] = true;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
|
|
1335
|
+
var index, quantity;
|
|
1336
|
+
if (Array.isArray(keyNode)) {
|
|
1337
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1338
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1339
|
+
if (Array.isArray(keyNode[index])) {
|
|
1340
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1341
|
+
}
|
|
1342
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1343
|
+
keyNode[index] = "[object Object]";
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1348
|
+
keyNode = "[object Object]";
|
|
1349
|
+
}
|
|
1350
|
+
keyNode = String(keyNode);
|
|
1351
|
+
if (_result === null) {
|
|
1352
|
+
_result = {};
|
|
1353
|
+
}
|
|
1354
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1355
|
+
if (Array.isArray(valueNode)) {
|
|
1356
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1357
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1358
|
+
}
|
|
1359
|
+
} else {
|
|
1360
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1361
|
+
}
|
|
1362
|
+
} else {
|
|
1363
|
+
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
1364
|
+
state.line = startLine || state.line;
|
|
1365
|
+
state.position = startPos || state.position;
|
|
1366
|
+
throwError(state, "duplicated mapping key");
|
|
1367
|
+
}
|
|
1368
|
+
setProperty(_result, keyNode, valueNode);
|
|
1369
|
+
delete overridableKeys[keyNode];
|
|
1370
|
+
}
|
|
1371
|
+
return _result;
|
|
1372
|
+
}
|
|
1373
|
+
function readLineBreak(state) {
|
|
1374
|
+
var ch;
|
|
1375
|
+
ch = state.input.charCodeAt(state.position);
|
|
1376
|
+
if (ch === 10) {
|
|
1377
|
+
state.position++;
|
|
1378
|
+
} else if (ch === 13) {
|
|
1379
|
+
state.position++;
|
|
1380
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1381
|
+
state.position++;
|
|
1382
|
+
}
|
|
1383
|
+
} else {
|
|
1384
|
+
throwError(state, "a line break is expected");
|
|
1385
|
+
}
|
|
1386
|
+
state.line += 1;
|
|
1387
|
+
state.lineStart = state.position;
|
|
1388
|
+
}
|
|
1389
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1390
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1391
|
+
while (ch !== 0) {
|
|
1392
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1393
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1394
|
+
}
|
|
1395
|
+
if (allowComments && ch === 35) {
|
|
1396
|
+
do {
|
|
1397
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1398
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1399
|
+
}
|
|
1400
|
+
if (is_EOL(ch)) {
|
|
1401
|
+
readLineBreak(state);
|
|
1402
|
+
ch = state.input.charCodeAt(state.position);
|
|
1403
|
+
lineBreaks++;
|
|
1404
|
+
state.lineIndent = 0;
|
|
1405
|
+
while (ch === 32) {
|
|
1406
|
+
state.lineIndent++;
|
|
1407
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1408
|
+
}
|
|
1409
|
+
} else {
|
|
1410
|
+
break;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1414
|
+
throwWarning(state, "deficient indentation");
|
|
1415
|
+
}
|
|
1416
|
+
return lineBreaks;
|
|
1417
|
+
}
|
|
1418
|
+
function testDocumentSeparator(state) {
|
|
1419
|
+
var _position = state.position, ch;
|
|
1420
|
+
ch = state.input.charCodeAt(_position);
|
|
1421
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1422
|
+
_position += 3;
|
|
1423
|
+
ch = state.input.charCodeAt(_position);
|
|
1424
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1425
|
+
return true;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
return false;
|
|
1429
|
+
}
|
|
1430
|
+
function writeFoldedLines(state, count) {
|
|
1431
|
+
if (count === 1) {
|
|
1432
|
+
state.result += " ";
|
|
1433
|
+
} else if (count > 1) {
|
|
1434
|
+
state.result += common.repeat("\n", count - 1);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1438
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1439
|
+
ch = state.input.charCodeAt(state.position);
|
|
1440
|
+
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) {
|
|
1441
|
+
return false;
|
|
1442
|
+
}
|
|
1443
|
+
if (ch === 63 || ch === 45) {
|
|
1444
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1445
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
state.kind = "scalar";
|
|
1450
|
+
state.result = "";
|
|
1451
|
+
captureStart = captureEnd = state.position;
|
|
1452
|
+
hasPendingContent = false;
|
|
1453
|
+
while (ch !== 0) {
|
|
1454
|
+
if (ch === 58) {
|
|
1455
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1456
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
} else if (ch === 35) {
|
|
1460
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1461
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1465
|
+
break;
|
|
1466
|
+
} else if (is_EOL(ch)) {
|
|
1467
|
+
_line = state.line;
|
|
1468
|
+
_lineStart = state.lineStart;
|
|
1469
|
+
_lineIndent = state.lineIndent;
|
|
1470
|
+
skipSeparationSpace(state, false, -1);
|
|
1471
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1472
|
+
hasPendingContent = true;
|
|
1473
|
+
ch = state.input.charCodeAt(state.position);
|
|
1474
|
+
continue;
|
|
1475
|
+
} else {
|
|
1476
|
+
state.position = captureEnd;
|
|
1477
|
+
state.line = _line;
|
|
1478
|
+
state.lineStart = _lineStart;
|
|
1479
|
+
state.lineIndent = _lineIndent;
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
if (hasPendingContent) {
|
|
1484
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1485
|
+
writeFoldedLines(state, state.line - _line);
|
|
1486
|
+
captureStart = captureEnd = state.position;
|
|
1487
|
+
hasPendingContent = false;
|
|
1488
|
+
}
|
|
1489
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1490
|
+
captureEnd = state.position + 1;
|
|
1491
|
+
}
|
|
1492
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1493
|
+
}
|
|
1494
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1495
|
+
if (state.result) {
|
|
1496
|
+
return true;
|
|
1497
|
+
}
|
|
1498
|
+
state.kind = _kind;
|
|
1499
|
+
state.result = _result;
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1503
|
+
var ch, captureStart, captureEnd;
|
|
1504
|
+
ch = state.input.charCodeAt(state.position);
|
|
1505
|
+
if (ch !== 39) {
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
state.kind = "scalar";
|
|
1509
|
+
state.result = "";
|
|
1510
|
+
state.position++;
|
|
1511
|
+
captureStart = captureEnd = state.position;
|
|
1512
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1513
|
+
if (ch === 39) {
|
|
1514
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1515
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1516
|
+
if (ch === 39) {
|
|
1517
|
+
captureStart = state.position;
|
|
1518
|
+
state.position++;
|
|
1519
|
+
captureEnd = state.position;
|
|
1520
|
+
} else {
|
|
1521
|
+
return true;
|
|
1522
|
+
}
|
|
1523
|
+
} else if (is_EOL(ch)) {
|
|
1524
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1525
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1526
|
+
captureStart = captureEnd = state.position;
|
|
1527
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1528
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1529
|
+
} else {
|
|
1530
|
+
state.position++;
|
|
1531
|
+
captureEnd = state.position;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1535
|
+
}
|
|
1536
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1537
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1538
|
+
ch = state.input.charCodeAt(state.position);
|
|
1539
|
+
if (ch !== 34) {
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
state.kind = "scalar";
|
|
1543
|
+
state.result = "";
|
|
1544
|
+
state.position++;
|
|
1545
|
+
captureStart = captureEnd = state.position;
|
|
1546
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1547
|
+
if (ch === 34) {
|
|
1548
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1549
|
+
state.position++;
|
|
1550
|
+
return true;
|
|
1551
|
+
} else if (ch === 92) {
|
|
1552
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1553
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1554
|
+
if (is_EOL(ch)) {
|
|
1555
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1556
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1557
|
+
state.result += simpleEscapeMap[ch];
|
|
1558
|
+
state.position++;
|
|
1559
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1560
|
+
hexLength = tmp;
|
|
1561
|
+
hexResult = 0;
|
|
1562
|
+
for (; hexLength > 0; hexLength--) {
|
|
1563
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1564
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1565
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1566
|
+
} else {
|
|
1567
|
+
throwError(state, "expected hexadecimal character");
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
state.result += charFromCodepoint(hexResult);
|
|
1571
|
+
state.position++;
|
|
1572
|
+
} else {
|
|
1573
|
+
throwError(state, "unknown escape sequence");
|
|
1574
|
+
}
|
|
1575
|
+
captureStart = captureEnd = state.position;
|
|
1576
|
+
} else if (is_EOL(ch)) {
|
|
1577
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1578
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1579
|
+
captureStart = captureEnd = state.position;
|
|
1580
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1581
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1582
|
+
} else {
|
|
1583
|
+
state.position++;
|
|
1584
|
+
captureEnd = state.position;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1588
|
+
}
|
|
1589
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1590
|
+
var readNext = true, _line, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = {}, keyNode, keyTag, valueNode, ch;
|
|
1591
|
+
ch = state.input.charCodeAt(state.position);
|
|
1592
|
+
if (ch === 91) {
|
|
1593
|
+
terminator = 93;
|
|
1594
|
+
isMapping = false;
|
|
1595
|
+
_result = [];
|
|
1596
|
+
} else if (ch === 123) {
|
|
1597
|
+
terminator = 125;
|
|
1598
|
+
isMapping = true;
|
|
1599
|
+
_result = {};
|
|
1600
|
+
} else {
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
if (state.anchor !== null) {
|
|
1604
|
+
state.anchorMap[state.anchor] = _result;
|
|
1605
|
+
}
|
|
1606
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1607
|
+
while (ch !== 0) {
|
|
1608
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1609
|
+
ch = state.input.charCodeAt(state.position);
|
|
1610
|
+
if (ch === terminator) {
|
|
1611
|
+
state.position++;
|
|
1612
|
+
state.tag = _tag;
|
|
1613
|
+
state.anchor = _anchor;
|
|
1614
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1615
|
+
state.result = _result;
|
|
1616
|
+
return true;
|
|
1617
|
+
} else if (!readNext) {
|
|
1618
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1619
|
+
}
|
|
1620
|
+
keyTag = keyNode = valueNode = null;
|
|
1621
|
+
isPair = isExplicitPair = false;
|
|
1622
|
+
if (ch === 63) {
|
|
1623
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1624
|
+
if (is_WS_OR_EOL(following)) {
|
|
1625
|
+
isPair = isExplicitPair = true;
|
|
1626
|
+
state.position++;
|
|
1627
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
_line = state.line;
|
|
1631
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1632
|
+
keyTag = state.tag;
|
|
1633
|
+
keyNode = state.result;
|
|
1634
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1635
|
+
ch = state.input.charCodeAt(state.position);
|
|
1636
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1637
|
+
isPair = true;
|
|
1638
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1639
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1640
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1641
|
+
valueNode = state.result;
|
|
1642
|
+
}
|
|
1643
|
+
if (isMapping) {
|
|
1644
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
|
|
1645
|
+
} else if (isPair) {
|
|
1646
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
|
|
1647
|
+
} else {
|
|
1648
|
+
_result.push(keyNode);
|
|
1649
|
+
}
|
|
1650
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1651
|
+
ch = state.input.charCodeAt(state.position);
|
|
1652
|
+
if (ch === 44) {
|
|
1653
|
+
readNext = true;
|
|
1654
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1655
|
+
} else {
|
|
1656
|
+
readNext = false;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1660
|
+
}
|
|
1661
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1662
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1663
|
+
ch = state.input.charCodeAt(state.position);
|
|
1664
|
+
if (ch === 124) {
|
|
1665
|
+
folding = false;
|
|
1666
|
+
} else if (ch === 62) {
|
|
1667
|
+
folding = true;
|
|
1668
|
+
} else {
|
|
1669
|
+
return false;
|
|
1670
|
+
}
|
|
1671
|
+
state.kind = "scalar";
|
|
1672
|
+
state.result = "";
|
|
1673
|
+
while (ch !== 0) {
|
|
1674
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1675
|
+
if (ch === 43 || ch === 45) {
|
|
1676
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1677
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1678
|
+
} else {
|
|
1679
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1680
|
+
}
|
|
1681
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1682
|
+
if (tmp === 0) {
|
|
1683
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1684
|
+
} else if (!detectedIndent) {
|
|
1685
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1686
|
+
detectedIndent = true;
|
|
1687
|
+
} else {
|
|
1688
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1689
|
+
}
|
|
1690
|
+
} else {
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1695
|
+
do {
|
|
1696
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1697
|
+
} while (is_WHITE_SPACE(ch));
|
|
1698
|
+
if (ch === 35) {
|
|
1699
|
+
do {
|
|
1700
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1701
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
while (ch !== 0) {
|
|
1705
|
+
readLineBreak(state);
|
|
1706
|
+
state.lineIndent = 0;
|
|
1707
|
+
ch = state.input.charCodeAt(state.position);
|
|
1708
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1709
|
+
state.lineIndent++;
|
|
1710
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1711
|
+
}
|
|
1712
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1713
|
+
textIndent = state.lineIndent;
|
|
1714
|
+
}
|
|
1715
|
+
if (is_EOL(ch)) {
|
|
1716
|
+
emptyLines++;
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
if (state.lineIndent < textIndent) {
|
|
1720
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1721
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1722
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1723
|
+
if (didReadContent) {
|
|
1724
|
+
state.result += "\n";
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
if (folding) {
|
|
1730
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1731
|
+
atMoreIndented = true;
|
|
1732
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1733
|
+
} else if (atMoreIndented) {
|
|
1734
|
+
atMoreIndented = false;
|
|
1735
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
1736
|
+
} else if (emptyLines === 0) {
|
|
1737
|
+
if (didReadContent) {
|
|
1738
|
+
state.result += " ";
|
|
1739
|
+
}
|
|
1740
|
+
} else {
|
|
1741
|
+
state.result += common.repeat("\n", emptyLines);
|
|
1742
|
+
}
|
|
1743
|
+
} else {
|
|
1744
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1745
|
+
}
|
|
1746
|
+
didReadContent = true;
|
|
1747
|
+
detectedIndent = true;
|
|
1748
|
+
emptyLines = 0;
|
|
1749
|
+
captureStart = state.position;
|
|
1750
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1751
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1752
|
+
}
|
|
1753
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1754
|
+
}
|
|
1755
|
+
return true;
|
|
1756
|
+
}
|
|
1757
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1758
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1759
|
+
if (state.anchor !== null) {
|
|
1760
|
+
state.anchorMap[state.anchor] = _result;
|
|
1761
|
+
}
|
|
1762
|
+
ch = state.input.charCodeAt(state.position);
|
|
1763
|
+
while (ch !== 0) {
|
|
1764
|
+
if (ch !== 45) {
|
|
1765
|
+
break;
|
|
1766
|
+
}
|
|
1767
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1768
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1769
|
+
break;
|
|
1770
|
+
}
|
|
1771
|
+
detected = true;
|
|
1772
|
+
state.position++;
|
|
1773
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1774
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1775
|
+
_result.push(null);
|
|
1776
|
+
ch = state.input.charCodeAt(state.position);
|
|
1777
|
+
continue;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
_line = state.line;
|
|
1781
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1782
|
+
_result.push(state.result);
|
|
1783
|
+
skipSeparationSpace(state, true, -1);
|
|
1784
|
+
ch = state.input.charCodeAt(state.position);
|
|
1785
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1786
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1787
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
if (detected) {
|
|
1792
|
+
state.tag = _tag;
|
|
1793
|
+
state.anchor = _anchor;
|
|
1794
|
+
state.kind = "sequence";
|
|
1795
|
+
state.result = _result;
|
|
1796
|
+
return true;
|
|
1797
|
+
}
|
|
1798
|
+
return false;
|
|
1799
|
+
}
|
|
1800
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1801
|
+
var following, allowCompact, _line, _pos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = {}, keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1802
|
+
if (state.anchor !== null) {
|
|
1803
|
+
state.anchorMap[state.anchor] = _result;
|
|
1804
|
+
}
|
|
1805
|
+
ch = state.input.charCodeAt(state.position);
|
|
1806
|
+
while (ch !== 0) {
|
|
1807
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1808
|
+
_line = state.line;
|
|
1809
|
+
_pos = state.position;
|
|
1810
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1811
|
+
if (ch === 63) {
|
|
1812
|
+
if (atExplicitKey) {
|
|
1813
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
1814
|
+
keyTag = keyNode = valueNode = null;
|
|
1815
|
+
}
|
|
1816
|
+
detected = true;
|
|
1817
|
+
atExplicitKey = true;
|
|
1818
|
+
allowCompact = true;
|
|
1819
|
+
} else if (atExplicitKey) {
|
|
1820
|
+
atExplicitKey = false;
|
|
1821
|
+
allowCompact = true;
|
|
1822
|
+
} else {
|
|
1823
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1824
|
+
}
|
|
1825
|
+
state.position += 1;
|
|
1826
|
+
ch = following;
|
|
1827
|
+
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1828
|
+
if (state.line === _line) {
|
|
1829
|
+
ch = state.input.charCodeAt(state.position);
|
|
1830
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1831
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1832
|
+
}
|
|
1833
|
+
if (ch === 58) {
|
|
1834
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1835
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1836
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1837
|
+
}
|
|
1838
|
+
if (atExplicitKey) {
|
|
1839
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
1840
|
+
keyTag = keyNode = valueNode = null;
|
|
1841
|
+
}
|
|
1842
|
+
detected = true;
|
|
1843
|
+
atExplicitKey = false;
|
|
1844
|
+
allowCompact = false;
|
|
1845
|
+
keyTag = state.tag;
|
|
1846
|
+
keyNode = state.result;
|
|
1847
|
+
} else if (detected) {
|
|
1848
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1849
|
+
} else {
|
|
1850
|
+
state.tag = _tag;
|
|
1851
|
+
state.anchor = _anchor;
|
|
1852
|
+
return true;
|
|
1853
|
+
}
|
|
1854
|
+
} else if (detected) {
|
|
1855
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1856
|
+
} else {
|
|
1857
|
+
state.tag = _tag;
|
|
1858
|
+
state.anchor = _anchor;
|
|
1859
|
+
return true;
|
|
1860
|
+
}
|
|
1861
|
+
} else {
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1865
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1866
|
+
if (atExplicitKey) {
|
|
1867
|
+
keyNode = state.result;
|
|
1868
|
+
} else {
|
|
1869
|
+
valueNode = state.result;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (!atExplicitKey) {
|
|
1873
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
|
|
1874
|
+
keyTag = keyNode = valueNode = null;
|
|
1875
|
+
}
|
|
1876
|
+
skipSeparationSpace(state, true, -1);
|
|
1877
|
+
ch = state.input.charCodeAt(state.position);
|
|
1878
|
+
}
|
|
1879
|
+
if (state.lineIndent > nodeIndent && ch !== 0) {
|
|
1880
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
1881
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1882
|
+
break;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
if (atExplicitKey) {
|
|
1886
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
1887
|
+
}
|
|
1888
|
+
if (detected) {
|
|
1889
|
+
state.tag = _tag;
|
|
1890
|
+
state.anchor = _anchor;
|
|
1891
|
+
state.kind = "mapping";
|
|
1892
|
+
state.result = _result;
|
|
1893
|
+
}
|
|
1894
|
+
return detected;
|
|
1895
|
+
}
|
|
1896
|
+
function readTagProperty(state) {
|
|
1897
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1898
|
+
ch = state.input.charCodeAt(state.position);
|
|
1899
|
+
if (ch !== 33) return false;
|
|
1900
|
+
if (state.tag !== null) {
|
|
1901
|
+
throwError(state, "duplication of a tag property");
|
|
1902
|
+
}
|
|
1903
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1904
|
+
if (ch === 60) {
|
|
1905
|
+
isVerbatim = true;
|
|
1906
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1907
|
+
} else if (ch === 33) {
|
|
1908
|
+
isNamed = true;
|
|
1909
|
+
tagHandle = "!!";
|
|
1910
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1911
|
+
} else {
|
|
1912
|
+
tagHandle = "!";
|
|
1913
|
+
}
|
|
1914
|
+
_position = state.position;
|
|
1915
|
+
if (isVerbatim) {
|
|
1916
|
+
do {
|
|
1917
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1918
|
+
} while (ch !== 0 && ch !== 62);
|
|
1919
|
+
if (state.position < state.length) {
|
|
1920
|
+
tagName = state.input.slice(_position, state.position);
|
|
1921
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1922
|
+
} else {
|
|
1923
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1924
|
+
}
|
|
1925
|
+
} else {
|
|
1926
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1927
|
+
if (ch === 33) {
|
|
1928
|
+
if (!isNamed) {
|
|
1929
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1930
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1931
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
1932
|
+
}
|
|
1933
|
+
isNamed = true;
|
|
1934
|
+
_position = state.position + 1;
|
|
1935
|
+
} else {
|
|
1936
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1940
|
+
}
|
|
1941
|
+
tagName = state.input.slice(_position, state.position);
|
|
1942
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1943
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1947
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1948
|
+
}
|
|
1949
|
+
if (isVerbatim) {
|
|
1950
|
+
state.tag = tagName;
|
|
1951
|
+
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
1952
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1953
|
+
} else if (tagHandle === "!") {
|
|
1954
|
+
state.tag = "!" + tagName;
|
|
1955
|
+
} else if (tagHandle === "!!") {
|
|
1956
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1957
|
+
} else {
|
|
1958
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1959
|
+
}
|
|
1960
|
+
return true;
|
|
1961
|
+
}
|
|
1962
|
+
function readAnchorProperty(state) {
|
|
1963
|
+
var _position, ch;
|
|
1964
|
+
ch = state.input.charCodeAt(state.position);
|
|
1965
|
+
if (ch !== 38) return false;
|
|
1966
|
+
if (state.anchor !== null) {
|
|
1967
|
+
throwError(state, "duplication of an anchor property");
|
|
1968
|
+
}
|
|
1969
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1970
|
+
_position = state.position;
|
|
1971
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1972
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1973
|
+
}
|
|
1974
|
+
if (state.position === _position) {
|
|
1975
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
1976
|
+
}
|
|
1977
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
1978
|
+
return true;
|
|
1979
|
+
}
|
|
1980
|
+
function readAlias(state) {
|
|
1981
|
+
var _position, alias, ch;
|
|
1982
|
+
ch = state.input.charCodeAt(state.position);
|
|
1983
|
+
if (ch !== 42) return false;
|
|
1984
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1985
|
+
_position = state.position;
|
|
1986
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1987
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1988
|
+
}
|
|
1989
|
+
if (state.position === _position) {
|
|
1990
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
1991
|
+
}
|
|
1992
|
+
alias = state.input.slice(_position, state.position);
|
|
1993
|
+
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
|
1994
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1995
|
+
}
|
|
1996
|
+
state.result = state.anchorMap[alias];
|
|
1997
|
+
skipSeparationSpace(state, true, -1);
|
|
1998
|
+
return true;
|
|
1999
|
+
}
|
|
2000
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2001
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, type, flowIndent, blockIndent;
|
|
2002
|
+
if (state.listener !== null) {
|
|
2003
|
+
state.listener("open", state);
|
|
2004
|
+
}
|
|
2005
|
+
state.tag = null;
|
|
2006
|
+
state.anchor = null;
|
|
2007
|
+
state.kind = null;
|
|
2008
|
+
state.result = null;
|
|
2009
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2010
|
+
if (allowToSeek) {
|
|
2011
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2012
|
+
atNewLine = true;
|
|
2013
|
+
if (state.lineIndent > parentIndent) {
|
|
2014
|
+
indentStatus = 1;
|
|
2015
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2016
|
+
indentStatus = 0;
|
|
2017
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2018
|
+
indentStatus = -1;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
if (indentStatus === 1) {
|
|
2023
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2024
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2025
|
+
atNewLine = true;
|
|
2026
|
+
allowBlockCollections = allowBlockStyles;
|
|
2027
|
+
if (state.lineIndent > parentIndent) {
|
|
2028
|
+
indentStatus = 1;
|
|
2029
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2030
|
+
indentStatus = 0;
|
|
2031
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2032
|
+
indentStatus = -1;
|
|
2033
|
+
}
|
|
2034
|
+
} else {
|
|
2035
|
+
allowBlockCollections = false;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
if (allowBlockCollections) {
|
|
2040
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2041
|
+
}
|
|
2042
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2043
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2044
|
+
flowIndent = parentIndent;
|
|
2045
|
+
} else {
|
|
2046
|
+
flowIndent = parentIndent + 1;
|
|
2047
|
+
}
|
|
2048
|
+
blockIndent = state.position - state.lineStart;
|
|
2049
|
+
if (indentStatus === 1) {
|
|
2050
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2051
|
+
hasContent = true;
|
|
2052
|
+
} else {
|
|
2053
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2054
|
+
hasContent = true;
|
|
2055
|
+
} else if (readAlias(state)) {
|
|
2056
|
+
hasContent = true;
|
|
2057
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2058
|
+
throwError(state, "alias node should not have any properties");
|
|
2059
|
+
}
|
|
2060
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2061
|
+
hasContent = true;
|
|
2062
|
+
if (state.tag === null) {
|
|
2063
|
+
state.tag = "?";
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
if (state.anchor !== null) {
|
|
2067
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
} else if (indentStatus === 0) {
|
|
2071
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
if (state.tag !== null && state.tag !== "!") {
|
|
2075
|
+
if (state.tag === "?") {
|
|
2076
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
2077
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2078
|
+
}
|
|
2079
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2080
|
+
type = state.implicitTypes[typeIndex];
|
|
2081
|
+
if (type.resolve(state.result)) {
|
|
2082
|
+
state.result = type.construct(state.result);
|
|
2083
|
+
state.tag = type.tag;
|
|
2084
|
+
if (state.anchor !== null) {
|
|
2085
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2086
|
+
}
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
} else if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2091
|
+
type = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2092
|
+
if (state.result !== null && type.kind !== state.kind) {
|
|
2093
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
2094
|
+
}
|
|
2095
|
+
if (!type.resolve(state.result)) {
|
|
2096
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2097
|
+
} else {
|
|
2098
|
+
state.result = type.construct(state.result);
|
|
2099
|
+
if (state.anchor !== null) {
|
|
2100
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
} else {
|
|
2104
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
if (state.listener !== null) {
|
|
2108
|
+
state.listener("close", state);
|
|
2109
|
+
}
|
|
2110
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2111
|
+
}
|
|
2112
|
+
function readDocument(state) {
|
|
2113
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2114
|
+
state.version = null;
|
|
2115
|
+
state.checkLineBreaks = state.legacy;
|
|
2116
|
+
state.tagMap = {};
|
|
2117
|
+
state.anchorMap = {};
|
|
2118
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2119
|
+
skipSeparationSpace(state, true, -1);
|
|
2120
|
+
ch = state.input.charCodeAt(state.position);
|
|
2121
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2122
|
+
break;
|
|
2123
|
+
}
|
|
2124
|
+
hasDirectives = true;
|
|
2125
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2126
|
+
_position = state.position;
|
|
2127
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2128
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2129
|
+
}
|
|
2130
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2131
|
+
directiveArgs = [];
|
|
2132
|
+
if (directiveName.length < 1) {
|
|
2133
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2134
|
+
}
|
|
2135
|
+
while (ch !== 0) {
|
|
2136
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2137
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2138
|
+
}
|
|
2139
|
+
if (ch === 35) {
|
|
2140
|
+
do {
|
|
2141
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2142
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2143
|
+
break;
|
|
2144
|
+
}
|
|
2145
|
+
if (is_EOL(ch)) break;
|
|
2146
|
+
_position = state.position;
|
|
2147
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2148
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2149
|
+
}
|
|
2150
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2151
|
+
}
|
|
2152
|
+
if (ch !== 0) readLineBreak(state);
|
|
2153
|
+
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
2154
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2155
|
+
} else {
|
|
2156
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
skipSeparationSpace(state, true, -1);
|
|
2160
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2161
|
+
state.position += 3;
|
|
2162
|
+
skipSeparationSpace(state, true, -1);
|
|
2163
|
+
} else if (hasDirectives) {
|
|
2164
|
+
throwError(state, "directives end mark is expected");
|
|
2165
|
+
}
|
|
2166
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2167
|
+
skipSeparationSpace(state, true, -1);
|
|
2168
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2169
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2170
|
+
}
|
|
2171
|
+
state.documents.push(state.result);
|
|
2172
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2173
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2174
|
+
state.position += 3;
|
|
2175
|
+
skipSeparationSpace(state, true, -1);
|
|
2176
|
+
}
|
|
2177
|
+
return;
|
|
2178
|
+
}
|
|
2179
|
+
if (state.position < state.length - 1) {
|
|
2180
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2181
|
+
} else {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
function loadDocuments(input, options) {
|
|
2186
|
+
input = String(input);
|
|
2187
|
+
options = options || {};
|
|
2188
|
+
if (input.length !== 0) {
|
|
2189
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2190
|
+
input += "\n";
|
|
2191
|
+
}
|
|
2192
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2193
|
+
input = input.slice(1);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
var state = new State(input, options);
|
|
2197
|
+
var nullpos = input.indexOf("\0");
|
|
2198
|
+
if (nullpos !== -1) {
|
|
2199
|
+
state.position = nullpos;
|
|
2200
|
+
throwError(state, "null byte is not allowed in input");
|
|
2201
|
+
}
|
|
2202
|
+
state.input += "\0";
|
|
2203
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2204
|
+
state.lineIndent += 1;
|
|
2205
|
+
state.position += 1;
|
|
2206
|
+
}
|
|
2207
|
+
while (state.position < state.length - 1) {
|
|
2208
|
+
readDocument(state);
|
|
2209
|
+
}
|
|
2210
|
+
return state.documents;
|
|
2211
|
+
}
|
|
2212
|
+
function loadAll(input, iterator, options) {
|
|
2213
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2214
|
+
options = iterator;
|
|
2215
|
+
iterator = null;
|
|
2216
|
+
}
|
|
2217
|
+
var documents = loadDocuments(input, options);
|
|
2218
|
+
if (typeof iterator !== "function") {
|
|
2219
|
+
return documents;
|
|
2220
|
+
}
|
|
2221
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2222
|
+
iterator(documents[index]);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
function load(input, options) {
|
|
2226
|
+
var documents = loadDocuments(input, options);
|
|
2227
|
+
if (documents.length === 0) {
|
|
2228
|
+
return void 0;
|
|
2229
|
+
} else if (documents.length === 1) {
|
|
2230
|
+
return documents[0];
|
|
2231
|
+
}
|
|
2232
|
+
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2233
|
+
}
|
|
2234
|
+
function safeLoadAll(input, iterator, options) {
|
|
2235
|
+
if (typeof iterator === "object" && iterator !== null && typeof options === "undefined") {
|
|
2236
|
+
options = iterator;
|
|
2237
|
+
iterator = null;
|
|
2238
|
+
}
|
|
2239
|
+
return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
|
2240
|
+
}
|
|
2241
|
+
function safeLoad(input, options) {
|
|
2242
|
+
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
|
2243
|
+
}
|
|
2244
|
+
module.exports.loadAll = loadAll;
|
|
2245
|
+
module.exports.load = load;
|
|
2246
|
+
module.exports.safeLoadAll = safeLoadAll;
|
|
2247
|
+
module.exports.safeLoad = safeLoad;
|
|
2248
|
+
}
|
|
2249
|
+
});
|
|
2250
|
+
|
|
2251
|
+
// node_modules/js-yaml/lib/js-yaml/dumper.js
|
|
2252
|
+
var require_dumper = __commonJS({
|
|
2253
|
+
"node_modules/js-yaml/lib/js-yaml/dumper.js"(exports, module) {
|
|
2254
|
+
"use strict";
|
|
2255
|
+
var common = require_common();
|
|
2256
|
+
var YAMLException = require_exception();
|
|
2257
|
+
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
2258
|
+
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
2259
|
+
var _toString = Object.prototype.toString;
|
|
2260
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2261
|
+
var CHAR_TAB = 9;
|
|
2262
|
+
var CHAR_LINE_FEED = 10;
|
|
2263
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2264
|
+
var CHAR_SPACE = 32;
|
|
2265
|
+
var CHAR_EXCLAMATION = 33;
|
|
2266
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2267
|
+
var CHAR_SHARP = 35;
|
|
2268
|
+
var CHAR_PERCENT = 37;
|
|
2269
|
+
var CHAR_AMPERSAND = 38;
|
|
2270
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2271
|
+
var CHAR_ASTERISK = 42;
|
|
2272
|
+
var CHAR_COMMA = 44;
|
|
2273
|
+
var CHAR_MINUS = 45;
|
|
2274
|
+
var CHAR_COLON = 58;
|
|
2275
|
+
var CHAR_EQUALS = 61;
|
|
2276
|
+
var CHAR_GREATER_THAN = 62;
|
|
2277
|
+
var CHAR_QUESTION = 63;
|
|
2278
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2279
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2280
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2281
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2282
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2283
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2284
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2285
|
+
var ESCAPE_SEQUENCES = {};
|
|
2286
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2287
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2288
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2289
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2290
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2291
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2292
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2293
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2294
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2295
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2296
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2297
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2298
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2299
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2300
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2301
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2302
|
+
"y",
|
|
2303
|
+
"Y",
|
|
2304
|
+
"yes",
|
|
2305
|
+
"Yes",
|
|
2306
|
+
"YES",
|
|
2307
|
+
"on",
|
|
2308
|
+
"On",
|
|
2309
|
+
"ON",
|
|
2310
|
+
"n",
|
|
2311
|
+
"N",
|
|
2312
|
+
"no",
|
|
2313
|
+
"No",
|
|
2314
|
+
"NO",
|
|
2315
|
+
"off",
|
|
2316
|
+
"Off",
|
|
2317
|
+
"OFF"
|
|
2318
|
+
];
|
|
2319
|
+
function compileStyleMap(schema, map) {
|
|
2320
|
+
var result, keys, index, length, tag, style, type;
|
|
2321
|
+
if (map === null) return {};
|
|
2322
|
+
result = {};
|
|
2323
|
+
keys = Object.keys(map);
|
|
2324
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2325
|
+
tag = keys[index];
|
|
2326
|
+
style = String(map[tag]);
|
|
2327
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2328
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2329
|
+
}
|
|
2330
|
+
type = schema.compiledTypeMap["fallback"][tag];
|
|
2331
|
+
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
2332
|
+
style = type.styleAliases[style];
|
|
2333
|
+
}
|
|
2334
|
+
result[tag] = style;
|
|
2335
|
+
}
|
|
2336
|
+
return result;
|
|
2337
|
+
}
|
|
2338
|
+
function encodeHex(character) {
|
|
2339
|
+
var string, handle, length;
|
|
2340
|
+
string = character.toString(16).toUpperCase();
|
|
2341
|
+
if (character <= 255) {
|
|
2342
|
+
handle = "x";
|
|
2343
|
+
length = 2;
|
|
2344
|
+
} else if (character <= 65535) {
|
|
2345
|
+
handle = "u";
|
|
2346
|
+
length = 4;
|
|
2347
|
+
} else if (character <= 4294967295) {
|
|
2348
|
+
handle = "U";
|
|
2349
|
+
length = 8;
|
|
2350
|
+
} else {
|
|
2351
|
+
throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2352
|
+
}
|
|
2353
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2354
|
+
}
|
|
2355
|
+
function State(options) {
|
|
2356
|
+
this.schema = options["schema"] || DEFAULT_FULL_SCHEMA;
|
|
2357
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2358
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2359
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2360
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2361
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2362
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2363
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2364
|
+
this.noRefs = options["noRefs"] || false;
|
|
2365
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2366
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2367
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2368
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2369
|
+
this.tag = null;
|
|
2370
|
+
this.result = "";
|
|
2371
|
+
this.duplicates = [];
|
|
2372
|
+
this.usedDuplicates = null;
|
|
2373
|
+
}
|
|
2374
|
+
function indentString(string, spaces) {
|
|
2375
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2376
|
+
while (position < length) {
|
|
2377
|
+
next = string.indexOf("\n", position);
|
|
2378
|
+
if (next === -1) {
|
|
2379
|
+
line = string.slice(position);
|
|
2380
|
+
position = length;
|
|
2381
|
+
} else {
|
|
2382
|
+
line = string.slice(position, next + 1);
|
|
2383
|
+
position = next + 1;
|
|
2384
|
+
}
|
|
2385
|
+
if (line.length && line !== "\n") result += ind;
|
|
2386
|
+
result += line;
|
|
2387
|
+
}
|
|
2388
|
+
return result;
|
|
2389
|
+
}
|
|
2390
|
+
function generateNextLine(state, level) {
|
|
2391
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
2392
|
+
}
|
|
2393
|
+
function testImplicitResolving(state, str) {
|
|
2394
|
+
var index, length, type;
|
|
2395
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2396
|
+
type = state.implicitTypes[index];
|
|
2397
|
+
if (type.resolve(str)) {
|
|
2398
|
+
return true;
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
return false;
|
|
2402
|
+
}
|
|
2403
|
+
function isWhitespace(c) {
|
|
2404
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2405
|
+
}
|
|
2406
|
+
function isPrintable(c) {
|
|
2407
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== 65279 || 65536 <= c && c <= 1114111;
|
|
2408
|
+
}
|
|
2409
|
+
function isNsChar(c) {
|
|
2410
|
+
return isPrintable(c) && !isWhitespace(c) && c !== 65279 && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2411
|
+
}
|
|
2412
|
+
function isPlainSafe(c, prev) {
|
|
2413
|
+
return isPrintable(c) && c !== 65279 && 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_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
|
|
2414
|
+
}
|
|
2415
|
+
function isPlainSafeFirst(c) {
|
|
2416
|
+
return isPrintable(c) && c !== 65279 && !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;
|
|
2417
|
+
}
|
|
2418
|
+
function needIndentIndicator(string) {
|
|
2419
|
+
var leadingSpaceRe = /^\n* /;
|
|
2420
|
+
return leadingSpaceRe.test(string);
|
|
2421
|
+
}
|
|
2422
|
+
var STYLE_PLAIN = 1;
|
|
2423
|
+
var STYLE_SINGLE = 2;
|
|
2424
|
+
var STYLE_LITERAL = 3;
|
|
2425
|
+
var STYLE_FOLDED = 4;
|
|
2426
|
+
var STYLE_DOUBLE = 5;
|
|
2427
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
|
2428
|
+
var i;
|
|
2429
|
+
var char, prev_char;
|
|
2430
|
+
var hasLineBreak = false;
|
|
2431
|
+
var hasFoldableLine = false;
|
|
2432
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2433
|
+
var previousLineBreak = -1;
|
|
2434
|
+
var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
|
|
2435
|
+
if (singleLineOnly) {
|
|
2436
|
+
for (i = 0; i < string.length; i++) {
|
|
2437
|
+
char = string.charCodeAt(i);
|
|
2438
|
+
if (!isPrintable(char)) {
|
|
2439
|
+
return STYLE_DOUBLE;
|
|
2440
|
+
}
|
|
2441
|
+
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2442
|
+
plain = plain && isPlainSafe(char, prev_char);
|
|
2443
|
+
}
|
|
2444
|
+
} else {
|
|
2445
|
+
for (i = 0; i < string.length; i++) {
|
|
2446
|
+
char = string.charCodeAt(i);
|
|
2447
|
+
if (char === CHAR_LINE_FEED) {
|
|
2448
|
+
hasLineBreak = true;
|
|
2449
|
+
if (shouldTrackWidth) {
|
|
2450
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2451
|
+
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2452
|
+
previousLineBreak = i;
|
|
2453
|
+
}
|
|
2454
|
+
} else if (!isPrintable(char)) {
|
|
2455
|
+
return STYLE_DOUBLE;
|
|
2456
|
+
}
|
|
2457
|
+
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2458
|
+
plain = plain && isPlainSafe(char, prev_char);
|
|
2459
|
+
}
|
|
2460
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2461
|
+
}
|
|
2462
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2463
|
+
return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
|
|
2464
|
+
}
|
|
2465
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2466
|
+
return STYLE_DOUBLE;
|
|
2467
|
+
}
|
|
2468
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2469
|
+
}
|
|
2470
|
+
function writeScalar(state, string, level, iskey) {
|
|
2471
|
+
state.dump = (function() {
|
|
2472
|
+
if (string.length === 0) {
|
|
2473
|
+
return "''";
|
|
2474
|
+
}
|
|
2475
|
+
if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
|
2476
|
+
return "'" + string + "'";
|
|
2477
|
+
}
|
|
2478
|
+
var indent = state.indent * Math.max(1, level);
|
|
2479
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2480
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2481
|
+
function testAmbiguity(string2) {
|
|
2482
|
+
return testImplicitResolving(state, string2);
|
|
2483
|
+
}
|
|
2484
|
+
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
|
2485
|
+
case STYLE_PLAIN:
|
|
2486
|
+
return string;
|
|
2487
|
+
case STYLE_SINGLE:
|
|
2488
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
2489
|
+
case STYLE_LITERAL:
|
|
2490
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2491
|
+
case STYLE_FOLDED:
|
|
2492
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2493
|
+
case STYLE_DOUBLE:
|
|
2494
|
+
return '"' + escapeString(string, lineWidth) + '"';
|
|
2495
|
+
default:
|
|
2496
|
+
throw new YAMLException("impossible error: invalid scalar style");
|
|
2497
|
+
}
|
|
2498
|
+
})();
|
|
2499
|
+
}
|
|
2500
|
+
function blockHeader(string, indentPerLevel) {
|
|
2501
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2502
|
+
var clip = string[string.length - 1] === "\n";
|
|
2503
|
+
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2504
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2505
|
+
return indentIndicator + chomp + "\n";
|
|
2506
|
+
}
|
|
2507
|
+
function dropEndingNewline(string) {
|
|
2508
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2509
|
+
}
|
|
2510
|
+
function foldString(string, width) {
|
|
2511
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2512
|
+
var result = (function() {
|
|
2513
|
+
var nextLF = string.indexOf("\n");
|
|
2514
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2515
|
+
lineRe.lastIndex = nextLF;
|
|
2516
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
2517
|
+
})();
|
|
2518
|
+
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2519
|
+
var moreIndented;
|
|
2520
|
+
var match;
|
|
2521
|
+
while (match = lineRe.exec(string)) {
|
|
2522
|
+
var prefix = match[1], line = match[2];
|
|
2523
|
+
moreIndented = line[0] === " ";
|
|
2524
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2525
|
+
prevMoreIndented = moreIndented;
|
|
2526
|
+
}
|
|
2527
|
+
return result;
|
|
2528
|
+
}
|
|
2529
|
+
function foldLine(line, width) {
|
|
2530
|
+
if (line === "" || line[0] === " ") return line;
|
|
2531
|
+
var breakRe = / [^ ]/g;
|
|
2532
|
+
var match;
|
|
2533
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2534
|
+
var result = "";
|
|
2535
|
+
while (match = breakRe.exec(line)) {
|
|
2536
|
+
next = match.index;
|
|
2537
|
+
if (next - start > width) {
|
|
2538
|
+
end = curr > start ? curr : next;
|
|
2539
|
+
result += "\n" + line.slice(start, end);
|
|
2540
|
+
start = end + 1;
|
|
2541
|
+
}
|
|
2542
|
+
curr = next;
|
|
2543
|
+
}
|
|
2544
|
+
result += "\n";
|
|
2545
|
+
if (line.length - start > width && curr > start) {
|
|
2546
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2547
|
+
} else {
|
|
2548
|
+
result += line.slice(start);
|
|
2549
|
+
}
|
|
2550
|
+
return result.slice(1);
|
|
2551
|
+
}
|
|
2552
|
+
function escapeString(string) {
|
|
2553
|
+
var result = "";
|
|
2554
|
+
var char, nextChar;
|
|
2555
|
+
var escapeSeq;
|
|
2556
|
+
for (var i = 0; i < string.length; i++) {
|
|
2557
|
+
char = string.charCodeAt(i);
|
|
2558
|
+
if (char >= 55296 && char <= 56319) {
|
|
2559
|
+
nextChar = string.charCodeAt(i + 1);
|
|
2560
|
+
if (nextChar >= 56320 && nextChar <= 57343) {
|
|
2561
|
+
result += encodeHex((char - 55296) * 1024 + nextChar - 56320 + 65536);
|
|
2562
|
+
i++;
|
|
2563
|
+
continue;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2567
|
+
result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
|
|
2568
|
+
}
|
|
2569
|
+
return result;
|
|
2570
|
+
}
|
|
2571
|
+
function writeFlowSequence(state, level, object) {
|
|
2572
|
+
var _result = "", _tag = state.tag, index, length;
|
|
2573
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2574
|
+
if (writeNode(state, level, object[index], false, false)) {
|
|
2575
|
+
if (index !== 0) _result += "," + (!state.condenseFlow ? " " : "");
|
|
2576
|
+
_result += state.dump;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
state.tag = _tag;
|
|
2580
|
+
state.dump = "[" + _result + "]";
|
|
2581
|
+
}
|
|
2582
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
2583
|
+
var _result = "", _tag = state.tag, index, length;
|
|
2584
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2585
|
+
if (writeNode(state, level + 1, object[index], true, true)) {
|
|
2586
|
+
if (!compact || index !== 0) {
|
|
2587
|
+
_result += generateNextLine(state, level);
|
|
2588
|
+
}
|
|
2589
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2590
|
+
_result += "-";
|
|
2591
|
+
} else {
|
|
2592
|
+
_result += "- ";
|
|
2593
|
+
}
|
|
2594
|
+
_result += state.dump;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
state.tag = _tag;
|
|
2598
|
+
state.dump = _result || "[]";
|
|
2599
|
+
}
|
|
2600
|
+
function writeFlowMapping(state, level, object) {
|
|
2601
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2602
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2603
|
+
pairBuffer = "";
|
|
2604
|
+
if (index !== 0) pairBuffer += ", ";
|
|
2605
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
2606
|
+
objectKey = objectKeyList[index];
|
|
2607
|
+
objectValue = object[objectKey];
|
|
2608
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2609
|
+
continue;
|
|
2610
|
+
}
|
|
2611
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2612
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2613
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2614
|
+
continue;
|
|
2615
|
+
}
|
|
2616
|
+
pairBuffer += state.dump;
|
|
2617
|
+
_result += pairBuffer;
|
|
2618
|
+
}
|
|
2619
|
+
state.tag = _tag;
|
|
2620
|
+
state.dump = "{" + _result + "}";
|
|
2621
|
+
}
|
|
2622
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
2623
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2624
|
+
if (state.sortKeys === true) {
|
|
2625
|
+
objectKeyList.sort();
|
|
2626
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2627
|
+
objectKeyList.sort(state.sortKeys);
|
|
2628
|
+
} else if (state.sortKeys) {
|
|
2629
|
+
throw new YAMLException("sortKeys must be a boolean or a function");
|
|
2630
|
+
}
|
|
2631
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2632
|
+
pairBuffer = "";
|
|
2633
|
+
if (!compact || index !== 0) {
|
|
2634
|
+
pairBuffer += generateNextLine(state, level);
|
|
2635
|
+
}
|
|
2636
|
+
objectKey = objectKeyList[index];
|
|
2637
|
+
objectValue = object[objectKey];
|
|
2638
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2639
|
+
continue;
|
|
2640
|
+
}
|
|
2641
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2642
|
+
if (explicitPair) {
|
|
2643
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2644
|
+
pairBuffer += "?";
|
|
2645
|
+
} else {
|
|
2646
|
+
pairBuffer += "? ";
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
pairBuffer += state.dump;
|
|
2650
|
+
if (explicitPair) {
|
|
2651
|
+
pairBuffer += generateNextLine(state, level);
|
|
2652
|
+
}
|
|
2653
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2654
|
+
continue;
|
|
2655
|
+
}
|
|
2656
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2657
|
+
pairBuffer += ":";
|
|
2658
|
+
} else {
|
|
2659
|
+
pairBuffer += ": ";
|
|
2660
|
+
}
|
|
2661
|
+
pairBuffer += state.dump;
|
|
2662
|
+
_result += pairBuffer;
|
|
2663
|
+
}
|
|
2664
|
+
state.tag = _tag;
|
|
2665
|
+
state.dump = _result || "{}";
|
|
2666
|
+
}
|
|
2667
|
+
function detectType(state, object, explicit) {
|
|
2668
|
+
var _result, typeList, index, length, type, style;
|
|
2669
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2670
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2671
|
+
type = typeList[index];
|
|
2672
|
+
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
|
|
2673
|
+
state.tag = explicit ? type.tag : "?";
|
|
2674
|
+
if (type.represent) {
|
|
2675
|
+
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2676
|
+
if (_toString.call(type.represent) === "[object Function]") {
|
|
2677
|
+
_result = type.represent(object, style);
|
|
2678
|
+
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
2679
|
+
_result = type.represent[style](object, style);
|
|
2680
|
+
} else {
|
|
2681
|
+
throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2682
|
+
}
|
|
2683
|
+
state.dump = _result;
|
|
2684
|
+
}
|
|
2685
|
+
return true;
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
return false;
|
|
2689
|
+
}
|
|
2690
|
+
function writeNode(state, level, object, block, compact, iskey) {
|
|
2691
|
+
state.tag = null;
|
|
2692
|
+
state.dump = object;
|
|
2693
|
+
if (!detectType(state, object, false)) {
|
|
2694
|
+
detectType(state, object, true);
|
|
2695
|
+
}
|
|
2696
|
+
var type = _toString.call(state.dump);
|
|
2697
|
+
if (block) {
|
|
2698
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2699
|
+
}
|
|
2700
|
+
var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
|
|
2701
|
+
if (objectOrArray) {
|
|
2702
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
2703
|
+
duplicate = duplicateIndex !== -1;
|
|
2704
|
+
}
|
|
2705
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2706
|
+
compact = false;
|
|
2707
|
+
}
|
|
2708
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2709
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2710
|
+
} else {
|
|
2711
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2712
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2713
|
+
}
|
|
2714
|
+
if (type === "[object Object]") {
|
|
2715
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2716
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2717
|
+
if (duplicate) {
|
|
2718
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2719
|
+
}
|
|
2720
|
+
} else {
|
|
2721
|
+
writeFlowMapping(state, level, state.dump);
|
|
2722
|
+
if (duplicate) {
|
|
2723
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
} else if (type === "[object Array]") {
|
|
2727
|
+
var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
|
|
2728
|
+
if (block && state.dump.length !== 0) {
|
|
2729
|
+
writeBlockSequence(state, arrayLevel, state.dump, compact);
|
|
2730
|
+
if (duplicate) {
|
|
2731
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2732
|
+
}
|
|
2733
|
+
} else {
|
|
2734
|
+
writeFlowSequence(state, arrayLevel, state.dump);
|
|
2735
|
+
if (duplicate) {
|
|
2736
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
} else if (type === "[object String]") {
|
|
2740
|
+
if (state.tag !== "?") {
|
|
2741
|
+
writeScalar(state, state.dump, level, iskey);
|
|
2742
|
+
}
|
|
2743
|
+
} else {
|
|
2744
|
+
if (state.skipInvalid) return false;
|
|
2745
|
+
throw new YAMLException("unacceptable kind of an object to dump " + type);
|
|
2746
|
+
}
|
|
2747
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2748
|
+
state.dump = "!<" + state.tag + "> " + state.dump;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return true;
|
|
2752
|
+
}
|
|
2753
|
+
function getDuplicateReferences(object, state) {
|
|
2754
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2755
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
2756
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2757
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2758
|
+
}
|
|
2759
|
+
state.usedDuplicates = new Array(length);
|
|
2760
|
+
}
|
|
2761
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2762
|
+
var objectKeyList, index, length;
|
|
2763
|
+
if (object !== null && typeof object === "object") {
|
|
2764
|
+
index = objects.indexOf(object);
|
|
2765
|
+
if (index !== -1) {
|
|
2766
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2767
|
+
duplicatesIndexes.push(index);
|
|
2768
|
+
}
|
|
2769
|
+
} else {
|
|
2770
|
+
objects.push(object);
|
|
2771
|
+
if (Array.isArray(object)) {
|
|
2772
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2773
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2774
|
+
}
|
|
2775
|
+
} else {
|
|
2776
|
+
objectKeyList = Object.keys(object);
|
|
2777
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2778
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
function dump(input, options) {
|
|
2785
|
+
options = options || {};
|
|
2786
|
+
var state = new State(options);
|
|
2787
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2788
|
+
if (writeNode(state, 0, input, true, true)) return state.dump + "\n";
|
|
2789
|
+
return "";
|
|
2790
|
+
}
|
|
2791
|
+
function safeDump(input, options) {
|
|
2792
|
+
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
|
2793
|
+
}
|
|
2794
|
+
module.exports.dump = dump;
|
|
2795
|
+
module.exports.safeDump = safeDump;
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
|
|
2799
|
+
// node_modules/js-yaml/lib/js-yaml.js
|
|
2800
|
+
var require_js_yaml = __commonJS({
|
|
2801
|
+
"node_modules/js-yaml/lib/js-yaml.js"(exports, module) {
|
|
2802
|
+
"use strict";
|
|
2803
|
+
var loader = require_loader();
|
|
2804
|
+
var dumper = require_dumper();
|
|
2805
|
+
function deprecated(name) {
|
|
2806
|
+
return function() {
|
|
2807
|
+
throw new Error("Function " + name + " is deprecated and cannot be used.");
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
module.exports.Type = require_type();
|
|
2811
|
+
module.exports.Schema = require_schema();
|
|
2812
|
+
module.exports.FAILSAFE_SCHEMA = require_failsafe();
|
|
2813
|
+
module.exports.JSON_SCHEMA = require_json();
|
|
2814
|
+
module.exports.CORE_SCHEMA = require_core();
|
|
2815
|
+
module.exports.DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
2816
|
+
module.exports.DEFAULT_FULL_SCHEMA = require_default_full();
|
|
2817
|
+
module.exports.load = loader.load;
|
|
2818
|
+
module.exports.loadAll = loader.loadAll;
|
|
2819
|
+
module.exports.safeLoad = loader.safeLoad;
|
|
2820
|
+
module.exports.safeLoadAll = loader.safeLoadAll;
|
|
2821
|
+
module.exports.dump = dumper.dump;
|
|
2822
|
+
module.exports.safeDump = dumper.safeDump;
|
|
2823
|
+
module.exports.YAMLException = require_exception();
|
|
2824
|
+
module.exports.MINIMAL_SCHEMA = require_failsafe();
|
|
2825
|
+
module.exports.SAFE_SCHEMA = require_default_safe();
|
|
2826
|
+
module.exports.DEFAULT_SCHEMA = require_default_full();
|
|
2827
|
+
module.exports.scan = deprecated("scan");
|
|
2828
|
+
module.exports.parse = deprecated("parse");
|
|
2829
|
+
module.exports.compose = deprecated("compose");
|
|
2830
|
+
module.exports.addConstructor = deprecated("addConstructor");
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2833
|
+
|
|
2834
|
+
// node_modules/js-yaml/index.js
|
|
2835
|
+
var require_js_yaml2 = __commonJS({
|
|
2836
|
+
"node_modules/js-yaml/index.js"(exports, module) {
|
|
2837
|
+
"use strict";
|
|
2838
|
+
var yaml2 = require_js_yaml();
|
|
2839
|
+
module.exports = yaml2;
|
|
2840
|
+
}
|
|
2841
|
+
});
|
|
2842
|
+
|
|
2843
|
+
// src/cli/execute.ts
|
|
2844
|
+
import chalk2 from "chalk";
|
|
2845
|
+
import { existsSync as existsSync7 } from "fs";
|
|
2846
|
+
import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
2847
|
+
import { join as join3 } from "path";
|
|
2848
|
+
import { execSync as execSync3 } from "child_process";
|
|
2849
|
+
import { createInterface } from "readline";
|
|
2850
|
+
|
|
2851
|
+
// src/core/conflicts/checker.ts
|
|
2852
|
+
import { stat } from "fs/promises";
|
|
2853
|
+
import { existsSync } from "fs";
|
|
2854
|
+
var ConflictChecker = class {
|
|
2855
|
+
architecture;
|
|
2856
|
+
constructor(architecture) {
|
|
2857
|
+
this.architecture = architecture;
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* Check for conflicts between plan and current codebase state
|
|
2861
|
+
*/
|
|
2862
|
+
async checkConflicts(plan, options = {}) {
|
|
2863
|
+
const cwd = options.cwd ?? process.cwd();
|
|
2864
|
+
const conflicts = [];
|
|
2865
|
+
const recommendations = [];
|
|
2866
|
+
const fileConflicts = await this.checkFileConflicts(
|
|
2867
|
+
plan.files_to_modify,
|
|
2868
|
+
cwd,
|
|
2869
|
+
options.planCreatedAt
|
|
2870
|
+
);
|
|
2871
|
+
conflicts.push(...fileConflicts);
|
|
2872
|
+
const archConflicts = this.checkArchitectureConsistency(plan);
|
|
2873
|
+
conflicts.push(...archConflicts);
|
|
2874
|
+
if (options.checkDependencies !== false) {
|
|
2875
|
+
const depConflicts = this.checkDependencyImpact(plan);
|
|
2876
|
+
conflicts.push(...depConflicts);
|
|
2877
|
+
}
|
|
2878
|
+
const semanticConflicts = this.checkSemanticConflicts(plan);
|
|
2879
|
+
conflicts.push(...semanticConflicts);
|
|
2880
|
+
if (conflicts.some((c) => c.type === "FILE_MODIFIED")) {
|
|
2881
|
+
recommendations.push("Review modified files and re-plan if necessary");
|
|
2882
|
+
}
|
|
2883
|
+
if (conflicts.some((c) => c.type === "ARCHITECTURAL")) {
|
|
2884
|
+
recommendations.push("Update ARCHITECTURE.md or adjust plan to respect boundaries");
|
|
2885
|
+
}
|
|
2886
|
+
if (conflicts.some((c) => c.type === "DEPENDENCY")) {
|
|
2887
|
+
recommendations.push("Coordinate with dependent components before proceeding");
|
|
2888
|
+
}
|
|
2889
|
+
const blockerCount = conflicts.filter((c) => c.severity === "BLOCKER").length;
|
|
2890
|
+
return {
|
|
2891
|
+
hasConflicts: conflicts.length > 0,
|
|
2892
|
+
blockerCount,
|
|
2893
|
+
conflicts,
|
|
2894
|
+
recommendations,
|
|
2895
|
+
checkedAt: /* @__PURE__ */ new Date()
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Check if files have been modified since plan creation
|
|
2900
|
+
*/
|
|
2901
|
+
async checkFileConflicts(files, cwd, planCreatedAt) {
|
|
2902
|
+
const conflicts = [];
|
|
2903
|
+
for (const filePath of files) {
|
|
2904
|
+
const fullPath = `${cwd}/${filePath}`;
|
|
2905
|
+
if (!existsSync(fullPath)) {
|
|
2906
|
+
continue;
|
|
2907
|
+
}
|
|
2908
|
+
try {
|
|
2909
|
+
const fileStat = await stat(fullPath);
|
|
2910
|
+
if (planCreatedAt && fileStat.mtime > planCreatedAt) {
|
|
2911
|
+
conflicts.push({
|
|
2912
|
+
type: "FILE_MODIFIED",
|
|
2913
|
+
severity: "WARNING",
|
|
2914
|
+
path: filePath,
|
|
2915
|
+
message: `File ${filePath} was modified after plan creation`,
|
|
2916
|
+
recommendation: "Review the changes and update plan if necessary"
|
|
2917
|
+
});
|
|
2918
|
+
}
|
|
2919
|
+
} catch {
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
return conflicts;
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Check plan against architecture constraints
|
|
2926
|
+
*/
|
|
2927
|
+
checkArchitectureConsistency(plan) {
|
|
2928
|
+
const conflicts = [];
|
|
2929
|
+
for (const invariant of this.architecture.invariants) {
|
|
2930
|
+
if (invariant.severity === "BLOCKING") {
|
|
2931
|
+
const matchingFiles = plan.files_to_modify.filter(
|
|
2932
|
+
(f) => this.matchesScope(f, invariant.scope)
|
|
2933
|
+
);
|
|
2934
|
+
if (matchingFiles.length > 0 && invariant.match) {
|
|
2935
|
+
conflicts.push({
|
|
2936
|
+
type: "ARCHITECTURAL",
|
|
2937
|
+
severity: "WARNING",
|
|
2938
|
+
message: `Files may trigger invariant ${invariant.id}: ${invariant.rule}`,
|
|
2939
|
+
recommendation: `Ensure code doesn't match pattern: ${invariant.match}`
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
for (const protectedPath of this.architecture.protectedPaths) {
|
|
2945
|
+
const matchingFiles = plan.files_to_modify.filter(
|
|
2946
|
+
(f) => this.matchesPattern(f, protectedPath.pattern)
|
|
2947
|
+
);
|
|
2948
|
+
if (matchingFiles.length > 0) {
|
|
2949
|
+
conflicts.push({
|
|
2950
|
+
type: "ARCHITECTURAL",
|
|
2951
|
+
severity: protectedPath.level === "HARD" ? "BLOCKER" : "WARNING",
|
|
2952
|
+
path: matchingFiles[0],
|
|
2953
|
+
message: `Protected path: ${protectedPath.reason}`,
|
|
2954
|
+
recommendation: protectedPath.level === "HARD" ? `Approval required from ${protectedPath.approvalRequired ?? "architect"}` : "Review changes carefully"
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
return conflicts;
|
|
2959
|
+
}
|
|
2960
|
+
/**
|
|
2961
|
+
* Check impact on dependent components
|
|
2962
|
+
*/
|
|
2963
|
+
checkDependencyImpact(plan) {
|
|
2964
|
+
const conflicts = [];
|
|
2965
|
+
const affectedComponents = /* @__PURE__ */ new Set();
|
|
2966
|
+
for (const filePath of plan.files_to_modify) {
|
|
2967
|
+
for (const component of this.architecture.components) {
|
|
2968
|
+
if (component.paths.some((p) => this.matchesPattern(filePath, p))) {
|
|
2969
|
+
affectedComponents.add(component.id);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
for (const component of this.architecture.components) {
|
|
2974
|
+
if (component.dependsOn) {
|
|
2975
|
+
for (const dep of component.dependsOn) {
|
|
2976
|
+
if (affectedComponents.has(dep.component)) {
|
|
2977
|
+
if (dep.coupling === "TIGHT") {
|
|
2978
|
+
conflicts.push({
|
|
2979
|
+
type: "DEPENDENCY",
|
|
2980
|
+
severity: "WARNING",
|
|
2981
|
+
message: `Component ${component.name} has TIGHT coupling to ${dep.component}`,
|
|
2982
|
+
recommendation: `Changes may affect ${component.name}: ${dep.reason ?? "Review carefully"}`
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
return conflicts;
|
|
2990
|
+
}
|
|
2991
|
+
/**
|
|
2992
|
+
* Check for semantic conflicts (cross-boundary changes)
|
|
2993
|
+
*/
|
|
2994
|
+
checkSemanticConflicts(plan) {
|
|
2995
|
+
const conflicts = [];
|
|
2996
|
+
const componentBoundaries = /* @__PURE__ */ new Map();
|
|
2997
|
+
for (const filePath of plan.files_to_modify) {
|
|
2998
|
+
for (const component of this.architecture.components) {
|
|
2999
|
+
if (component.paths.some((p) => this.matchesPattern(filePath, p))) {
|
|
3000
|
+
componentBoundaries.set(component.id, component);
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
const modifiedComponents = Array.from(componentBoundaries.values());
|
|
3005
|
+
const hasPublicApi = modifiedComponents.some((c) => c.boundary === "PUBLIC_API");
|
|
3006
|
+
const hasInternal = modifiedComponents.some((c) => c.boundary === "INTERNAL");
|
|
3007
|
+
const hasInfrastructure = modifiedComponents.some((c) => c.boundary === "INFRASTRUCTURE");
|
|
3008
|
+
if (hasPublicApi && hasInfrastructure) {
|
|
3009
|
+
conflicts.push({
|
|
3010
|
+
type: "SEMANTIC",
|
|
3011
|
+
severity: "INFO",
|
|
3012
|
+
message: "Changes span from PUBLIC_API to INFRASTRUCTURE layers",
|
|
3013
|
+
recommendation: "Consider splitting into smaller atoms"
|
|
3014
|
+
});
|
|
3015
|
+
}
|
|
3016
|
+
for (const component of modifiedComponents) {
|
|
3017
|
+
if (component.forbiddenImports) {
|
|
3018
|
+
for (const forbidden of component.forbiddenImports) {
|
|
3019
|
+
conflicts.push({
|
|
3020
|
+
type: "SEMANTIC",
|
|
3021
|
+
severity: "INFO",
|
|
3022
|
+
message: `Component ${component.name} forbids imports from: ${forbidden.pattern}`,
|
|
3023
|
+
recommendation: forbidden.reason
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
return conflicts;
|
|
3029
|
+
}
|
|
3030
|
+
matchesPattern(path, pattern) {
|
|
3031
|
+
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
3032
|
+
return new RegExp(`^${regexPattern}$`).test(path);
|
|
3033
|
+
}
|
|
3034
|
+
matchesScope(path, scope) {
|
|
3035
|
+
if (!scope || scope === "*") return true;
|
|
3036
|
+
return this.matchesPattern(path, scope) || path.startsWith(scope);
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
|
|
3040
|
+
// src/core/gates/runner.ts
|
|
3041
|
+
import { execSync } from "child_process";
|
|
3042
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
3043
|
+
import { existsSync as existsSync2 } from "fs";
|
|
3044
|
+
import chalk from "chalk";
|
|
3045
|
+
var QualityGateRunner = class {
|
|
3046
|
+
cwd;
|
|
3047
|
+
verbose;
|
|
3048
|
+
constructor(config = {}) {
|
|
3049
|
+
this.cwd = config.cwd ?? process.cwd();
|
|
3050
|
+
this.verbose = config.verbose ?? false;
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Run a sequence of quality gates
|
|
3054
|
+
*/
|
|
3055
|
+
async runGates(gateTypes) {
|
|
3056
|
+
const results = [];
|
|
3057
|
+
const startTime = Date.now();
|
|
3058
|
+
for (const gate of gateTypes) {
|
|
3059
|
+
const result = await this.runGate(gate);
|
|
3060
|
+
results.push(result);
|
|
3061
|
+
if (!result.passed) {
|
|
3062
|
+
return {
|
|
3063
|
+
allPassed: false,
|
|
3064
|
+
results,
|
|
3065
|
+
failedAt: gate,
|
|
3066
|
+
totalDurationMs: Date.now() - startTime
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
return {
|
|
3071
|
+
allPassed: true,
|
|
3072
|
+
results,
|
|
3073
|
+
totalDurationMs: Date.now() - startTime
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Run a single quality gate
|
|
3078
|
+
*/
|
|
3079
|
+
async runGate(gate) {
|
|
3080
|
+
const startTime = Date.now();
|
|
3081
|
+
try {
|
|
3082
|
+
const output = await this.executeGate(gate);
|
|
3083
|
+
return {
|
|
3084
|
+
gate,
|
|
3085
|
+
passed: true,
|
|
3086
|
+
output,
|
|
3087
|
+
durationMs: Date.now() - startTime
|
|
3088
|
+
};
|
|
3089
|
+
} catch (error) {
|
|
3090
|
+
return {
|
|
3091
|
+
gate,
|
|
3092
|
+
passed: false,
|
|
3093
|
+
output: error instanceof Error ? error.message : String(error),
|
|
3094
|
+
durationMs: Date.now() - startTime
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
/**
|
|
3099
|
+
* Execute a specific gate type
|
|
3100
|
+
*/
|
|
3101
|
+
async executeGate(gate) {
|
|
3102
|
+
switch (gate) {
|
|
3103
|
+
case "ARCHITECTURE":
|
|
3104
|
+
return this.runArchitectureGate();
|
|
3105
|
+
case "SYNTAX":
|
|
3106
|
+
return this.runSyntaxGate();
|
|
3107
|
+
case "LINT":
|
|
3108
|
+
return this.runLintGate();
|
|
3109
|
+
case "UNIT":
|
|
3110
|
+
return this.runUnitGate();
|
|
3111
|
+
case "INTEGRATION":
|
|
3112
|
+
return this.runIntegrationGate();
|
|
3113
|
+
case "ACCEPTANCE":
|
|
3114
|
+
return "Acceptance gate - manual verification required";
|
|
3115
|
+
case "REVIEW":
|
|
3116
|
+
return "Review gate - manual review required";
|
|
3117
|
+
case "E2E":
|
|
3118
|
+
return this.runE2EGate();
|
|
3119
|
+
default:
|
|
3120
|
+
throw new Error(`Unknown gate type: ${gate}`);
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
/**
|
|
3124
|
+
* Architecture gate - check ARCHITECTURE.md constraints
|
|
3125
|
+
*/
|
|
3126
|
+
async runArchitectureGate() {
|
|
3127
|
+
const archPath = `${this.cwd}/ARCHITECTURE.md`;
|
|
3128
|
+
if (!existsSync2(archPath)) {
|
|
3129
|
+
return "No ARCHITECTURE.md found - skipping";
|
|
3130
|
+
}
|
|
3131
|
+
return "Architecture constraints checked";
|
|
3132
|
+
}
|
|
3133
|
+
/**
|
|
3134
|
+
* Syntax gate - run TypeScript typecheck
|
|
3135
|
+
*/
|
|
3136
|
+
async runSyntaxGate() {
|
|
3137
|
+
const pkgPath = `${this.cwd}/package.json`;
|
|
3138
|
+
if (!existsSync2(pkgPath)) {
|
|
3139
|
+
return "No package.json found - skipping syntax check";
|
|
3140
|
+
}
|
|
3141
|
+
const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
|
|
3142
|
+
if (pkg.scripts?.["typecheck"]) {
|
|
3143
|
+
return this.runCommand("npm run typecheck");
|
|
3144
|
+
} else if (existsSync2(`${this.cwd}/tsconfig.json`)) {
|
|
3145
|
+
return this.runCommand("npx tsc --noEmit");
|
|
3146
|
+
}
|
|
3147
|
+
return "No TypeScript configuration found - skipping";
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
* Lint gate - run ESLint
|
|
3151
|
+
*/
|
|
3152
|
+
async runLintGate() {
|
|
3153
|
+
const pkgPath = `${this.cwd}/package.json`;
|
|
3154
|
+
if (!existsSync2(pkgPath)) {
|
|
3155
|
+
return "No package.json found - skipping lint";
|
|
3156
|
+
}
|
|
3157
|
+
const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
|
|
3158
|
+
if (pkg.scripts?.["lint"]) {
|
|
3159
|
+
return this.runCommand("npm run lint");
|
|
3160
|
+
}
|
|
3161
|
+
return "No lint script found - skipping";
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* Unit test gate - run Jest/Vitest
|
|
3165
|
+
*/
|
|
3166
|
+
async runUnitGate() {
|
|
3167
|
+
const pkgPath = `${this.cwd}/package.json`;
|
|
3168
|
+
if (!existsSync2(pkgPath)) {
|
|
3169
|
+
return "No package.json found - skipping tests";
|
|
3170
|
+
}
|
|
3171
|
+
const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
|
|
3172
|
+
if (pkg.scripts?.["test"]) {
|
|
3173
|
+
return this.runCommand("npm run test");
|
|
3174
|
+
}
|
|
3175
|
+
return "No test script found - skipping";
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Integration test gate
|
|
3179
|
+
*/
|
|
3180
|
+
async runIntegrationGate() {
|
|
3181
|
+
const pkgPath = `${this.cwd}/package.json`;
|
|
3182
|
+
if (!existsSync2(pkgPath)) {
|
|
3183
|
+
return "No package.json found - skipping integration tests";
|
|
3184
|
+
}
|
|
3185
|
+
const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
|
|
3186
|
+
if (pkg.scripts?.["test:integration"]) {
|
|
3187
|
+
return this.runCommand("npm run test:integration");
|
|
3188
|
+
}
|
|
3189
|
+
return "No integration test script found - skipping";
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* E2E test gate
|
|
3193
|
+
*/
|
|
3194
|
+
async runE2EGate() {
|
|
3195
|
+
const pkgPath = `${this.cwd}/package.json`;
|
|
3196
|
+
if (!existsSync2(pkgPath)) {
|
|
3197
|
+
return "No package.json found - skipping E2E tests";
|
|
3198
|
+
}
|
|
3199
|
+
const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
|
|
3200
|
+
if (pkg.scripts?.["test:e2e"]) {
|
|
3201
|
+
return this.runCommand("npm run test:e2e");
|
|
3202
|
+
}
|
|
3203
|
+
return "No E2E test script found - skipping";
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Run a shell command
|
|
3207
|
+
*/
|
|
3208
|
+
runCommand(command) {
|
|
3209
|
+
try {
|
|
3210
|
+
const output = execSync(command, {
|
|
3211
|
+
cwd: this.cwd,
|
|
3212
|
+
encoding: "utf-8",
|
|
3213
|
+
stdio: this.verbose ? "inherit" : "pipe"
|
|
3214
|
+
});
|
|
3215
|
+
return output.toString();
|
|
3216
|
+
} catch (error) {
|
|
3217
|
+
if (error && typeof error === "object" && "stderr" in error) {
|
|
3218
|
+
throw new Error(error.stderr);
|
|
3219
|
+
}
|
|
3220
|
+
throw error;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
/**
|
|
3224
|
+
* Print gate results to console
|
|
3225
|
+
*/
|
|
3226
|
+
printResults(results) {
|
|
3227
|
+
console.log("\nQuality Gate Results:");
|
|
3228
|
+
console.log("\u2500".repeat(40));
|
|
3229
|
+
for (const result of results.results) {
|
|
3230
|
+
const icon = result.passed ? chalk.green("\u2713") : chalk.red("\u2717");
|
|
3231
|
+
const time = `${result.durationMs}ms`;
|
|
3232
|
+
console.log(`${icon} ${result.gate.padEnd(15)} ${chalk.dim(time)}`);
|
|
3233
|
+
}
|
|
3234
|
+
console.log("\u2500".repeat(40));
|
|
3235
|
+
if (results.allPassed) {
|
|
3236
|
+
console.log(chalk.green("All gates passed!"));
|
|
3237
|
+
} else {
|
|
3238
|
+
console.log(chalk.red(`Failed at: ${results.failedAt}`));
|
|
3239
|
+
}
|
|
3240
|
+
console.log(`Total time: ${results.totalDurationMs}ms`);
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
3243
|
+
|
|
3244
|
+
// src/core/learning/capture.ts
|
|
3245
|
+
import { readFile as readFile3, writeFile, appendFile } from "fs/promises";
|
|
3246
|
+
import { existsSync as existsSync3 } from "fs";
|
|
3247
|
+
var PROGRESS_HEADER = `# ArchonDev Progress Log
|
|
3248
|
+
|
|
3249
|
+
Started: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
3250
|
+
|
|
3251
|
+
---
|
|
3252
|
+
|
|
3253
|
+
## Codebase Patterns
|
|
3254
|
+
|
|
3255
|
+
---
|
|
3256
|
+
|
|
3257
|
+
`;
|
|
3258
|
+
var PATTERN_SECTION_MARKER = "## Codebase Patterns";
|
|
3259
|
+
var SECTION_SEPARATOR = "\n---\n";
|
|
3260
|
+
var LearningCapture = class {
|
|
3261
|
+
progressPath;
|
|
3262
|
+
constructor(progressPath = "progress.txt") {
|
|
3263
|
+
this.progressPath = progressPath;
|
|
3264
|
+
}
|
|
3265
|
+
/**
|
|
3266
|
+
* Append learning from an atom execution to progress.txt
|
|
3267
|
+
*/
|
|
3268
|
+
async appendLearning(atom, execution) {
|
|
3269
|
+
try {
|
|
3270
|
+
await this.ensureProgressFile();
|
|
3271
|
+
const captured = this.extractLearnings(atom, execution);
|
|
3272
|
+
const entry = this.formatEntry(atom, execution, captured);
|
|
3273
|
+
if (captured.hasReusablePatterns) {
|
|
3274
|
+
await this.addPatterns(captured.patterns);
|
|
3275
|
+
}
|
|
3276
|
+
await appendFile(this.progressPath, entry);
|
|
3277
|
+
return {
|
|
3278
|
+
success: true,
|
|
3279
|
+
entriesAdded: captured.learnings.length,
|
|
3280
|
+
patternsAdded: captured.patterns.length,
|
|
3281
|
+
filePath: this.progressPath
|
|
3282
|
+
};
|
|
3283
|
+
} catch (error) {
|
|
3284
|
+
return {
|
|
3285
|
+
success: false,
|
|
3286
|
+
entriesAdded: 0,
|
|
3287
|
+
patternsAdded: 0,
|
|
3288
|
+
filePath: this.progressPath,
|
|
3289
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
/**
|
|
3294
|
+
* Ensure progress.txt exists with initial header
|
|
3295
|
+
*/
|
|
3296
|
+
async ensureProgressFile() {
|
|
3297
|
+
if (!existsSync3(this.progressPath)) {
|
|
3298
|
+
await writeFile(this.progressPath, PROGRESS_HEADER);
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
/**
|
|
3302
|
+
* Extract learnings from atom and execution
|
|
3303
|
+
*/
|
|
3304
|
+
extractLearnings(atom, execution) {
|
|
3305
|
+
const learnings = [];
|
|
3306
|
+
const patterns = [];
|
|
3307
|
+
if (execution.planRisks && execution.planRisks.length > 0) {
|
|
3308
|
+
for (const risk of execution.planRisks) {
|
|
3309
|
+
if (this.isReusablePattern(risk)) {
|
|
3310
|
+
patterns.push({
|
|
3311
|
+
type: "WARNING",
|
|
3312
|
+
content: risk
|
|
3313
|
+
});
|
|
3314
|
+
} else {
|
|
3315
|
+
learnings.push({
|
|
3316
|
+
type: "WARNING",
|
|
3317
|
+
content: `Risk identified: ${risk}`
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
if (execution.conflictsDetected && execution.conflictsDetected.length > 0) {
|
|
3323
|
+
for (const conflict of execution.conflictsDetected) {
|
|
3324
|
+
learnings.push({
|
|
3325
|
+
type: "GOTCHA",
|
|
3326
|
+
content: `Conflict (${conflict.type}): ${conflict.message}`
|
|
3327
|
+
});
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
if (execution.qualityGateResults) {
|
|
3331
|
+
const failures = execution.qualityGateResults.filter((r) => !r.passed);
|
|
3332
|
+
for (const failure of failures) {
|
|
3333
|
+
const insight = this.extractGateFailureInsight(failure);
|
|
3334
|
+
if (insight) {
|
|
3335
|
+
learnings.push({
|
|
3336
|
+
type: "GOTCHA",
|
|
3337
|
+
content: `${failure.gate} failure: ${insight}`
|
|
3338
|
+
});
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
if (execution.executionNotes) {
|
|
3343
|
+
const notePatterns = this.extractPatternsFromNotes(execution.executionNotes);
|
|
3344
|
+
patterns.push(...notePatterns);
|
|
3345
|
+
}
|
|
3346
|
+
if (!execution.success && execution.errorMessage) {
|
|
3347
|
+
learnings.push({
|
|
3348
|
+
type: "GOTCHA",
|
|
3349
|
+
content: `Execution failed: ${execution.errorMessage}`
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
const filePatterns = this.identifyFilePatterns(execution.filesChanged);
|
|
3353
|
+
if (filePatterns) {
|
|
3354
|
+
patterns.push({
|
|
3355
|
+
type: "CONVENTION",
|
|
3356
|
+
content: filePatterns
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
return {
|
|
3360
|
+
learnings,
|
|
3361
|
+
patterns,
|
|
3362
|
+
hasReusablePatterns: patterns.length > 0
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
/**
|
|
3366
|
+
* Check if a pattern is reusable (not specific to this atom)
|
|
3367
|
+
*/
|
|
3368
|
+
isReusablePattern(text) {
|
|
3369
|
+
const reusableIndicators = [
|
|
3370
|
+
"always",
|
|
3371
|
+
"never",
|
|
3372
|
+
"must",
|
|
3373
|
+
"should",
|
|
3374
|
+
"convention",
|
|
3375
|
+
"pattern",
|
|
3376
|
+
"prefer",
|
|
3377
|
+
"avoid",
|
|
3378
|
+
"use",
|
|
3379
|
+
"don't",
|
|
3380
|
+
"do not"
|
|
3381
|
+
];
|
|
3382
|
+
const lowerText = text.toLowerCase();
|
|
3383
|
+
return reusableIndicators.some((indicator) => lowerText.includes(indicator));
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* Extract actionable insight from gate failure
|
|
3387
|
+
*/
|
|
3388
|
+
extractGateFailureInsight(failure) {
|
|
3389
|
+
if (!failure.output) return null;
|
|
3390
|
+
const lines = failure.output.split("\n");
|
|
3391
|
+
for (const line of lines) {
|
|
3392
|
+
if (line.includes("error") || line.includes("Error") || line.includes("TS")) {
|
|
3393
|
+
return line.trim().substring(0, 200);
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
return failure.output.substring(0, 100);
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Extract patterns from execution notes
|
|
3400
|
+
*/
|
|
3401
|
+
extractPatternsFromNotes(notes) {
|
|
3402
|
+
const patterns = [];
|
|
3403
|
+
const lines = notes.split("\n");
|
|
3404
|
+
for (const line of lines) {
|
|
3405
|
+
const trimmed = line.trim();
|
|
3406
|
+
if (trimmed.startsWith("Pattern:") || trimmed.startsWith("Convention:")) {
|
|
3407
|
+
patterns.push({
|
|
3408
|
+
type: "PATTERN",
|
|
3409
|
+
content: trimmed.replace(/^(Pattern|Convention):\s*/i, "")
|
|
3410
|
+
});
|
|
3411
|
+
} else if (trimmed.startsWith("Gotcha:") || trimmed.startsWith("Warning:")) {
|
|
3412
|
+
patterns.push({
|
|
3413
|
+
type: "GOTCHA",
|
|
3414
|
+
content: trimmed.replace(/^(Gotcha|Warning):\s*/i, "")
|
|
3415
|
+
});
|
|
3416
|
+
} else if (trimmed.startsWith("Tip:")) {
|
|
3417
|
+
patterns.push({
|
|
3418
|
+
type: "TIP",
|
|
3419
|
+
content: trimmed.replace(/^Tip:\s*/i, "")
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
return patterns;
|
|
3424
|
+
}
|
|
3425
|
+
/**
|
|
3426
|
+
* Identify patterns from the files that were changed
|
|
3427
|
+
*/
|
|
3428
|
+
identifyFilePatterns(files) {
|
|
3429
|
+
if (files.length === 0) return null;
|
|
3430
|
+
const layers = /* @__PURE__ */ new Set();
|
|
3431
|
+
for (const file of files) {
|
|
3432
|
+
if (file.includes("/cli/")) layers.add("cli");
|
|
3433
|
+
if (file.includes("/agents/")) layers.add("agents");
|
|
3434
|
+
if (file.includes("/core/")) layers.add("core");
|
|
3435
|
+
if (file.includes("/db/")) layers.add("db");
|
|
3436
|
+
if (file.includes("/api/")) layers.add("api");
|
|
3437
|
+
if (file.includes("/utils/")) layers.add("utils");
|
|
3438
|
+
}
|
|
3439
|
+
if (layers.size >= 3) {
|
|
3440
|
+
return `Multi-layer change pattern: ${Array.from(layers).join(", ")} layers modified together`;
|
|
3441
|
+
}
|
|
3442
|
+
const hasTests = files.some((f) => f.includes(".test.") || f.includes(".spec."));
|
|
3443
|
+
const hasSource = files.some((f) => !f.includes(".test.") && !f.includes(".spec."));
|
|
3444
|
+
if (hasTests && hasSource) {
|
|
3445
|
+
return "Test-alongside-source pattern: tests co-located with implementation";
|
|
3446
|
+
}
|
|
3447
|
+
return null;
|
|
3448
|
+
}
|
|
3449
|
+
/**
|
|
3450
|
+
* Format the progress entry
|
|
3451
|
+
*/
|
|
3452
|
+
formatEntry(atom, execution, captured) {
|
|
3453
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3454
|
+
const parts = [];
|
|
3455
|
+
parts.push(`
|
|
3456
|
+
## ${timestamp} - ${atom.externalId}`);
|
|
3457
|
+
if (execution.threadUrl) {
|
|
3458
|
+
parts.push(`Thread: ${execution.threadUrl}`);
|
|
3459
|
+
}
|
|
3460
|
+
parts.push("");
|
|
3461
|
+
parts.push("**What was implemented:**");
|
|
3462
|
+
parts.push(`- ${atom.title}`);
|
|
3463
|
+
if (atom.description) {
|
|
3464
|
+
parts.push(`- ${atom.description}`);
|
|
3465
|
+
}
|
|
3466
|
+
if (execution.planSteps && execution.planSteps.length > 0) {
|
|
3467
|
+
parts.push("");
|
|
3468
|
+
parts.push("**Plan steps executed:**");
|
|
3469
|
+
for (const step of execution.planSteps) {
|
|
3470
|
+
parts.push(`- ${step}`);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
parts.push("");
|
|
3474
|
+
parts.push("**Files changed:**");
|
|
3475
|
+
for (const file of execution.filesChanged) {
|
|
3476
|
+
parts.push(`- ${file}`);
|
|
3477
|
+
}
|
|
3478
|
+
if (captured.learnings.length > 0) {
|
|
3479
|
+
parts.push("");
|
|
3480
|
+
parts.push("**Learnings for future iterations:**");
|
|
3481
|
+
for (const learning of captured.learnings) {
|
|
3482
|
+
parts.push(`- [${learning.type}] ${learning.content}`);
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
if (execution.conflictsDetected && execution.conflictsDetected.length > 0) {
|
|
3486
|
+
parts.push("");
|
|
3487
|
+
parts.push("**Conflicts encountered:**");
|
|
3488
|
+
for (const conflict of execution.conflictsDetected) {
|
|
3489
|
+
parts.push(`- [${conflict.severity}] ${conflict.message}`);
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
if (execution.qualityGateResults) {
|
|
3493
|
+
const failures = execution.qualityGateResults.filter((r) => !r.passed);
|
|
3494
|
+
if (failures.length > 0) {
|
|
3495
|
+
parts.push("");
|
|
3496
|
+
parts.push("**Quality gate failures:**");
|
|
3497
|
+
for (const failure of failures) {
|
|
3498
|
+
parts.push(`- ${failure.gate}: ${failure.output?.substring(0, 100) ?? "Failed"}`);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
if (!execution.success) {
|
|
3503
|
+
parts.push("");
|
|
3504
|
+
parts.push(`**Status:** FAILED - ${execution.errorMessage ?? "Unknown error"}`);
|
|
3505
|
+
}
|
|
3506
|
+
parts.push("");
|
|
3507
|
+
parts.push("---");
|
|
3508
|
+
return parts.join("\n");
|
|
3509
|
+
}
|
|
3510
|
+
/**
|
|
3511
|
+
* Add patterns to the Codebase Patterns section
|
|
3512
|
+
*/
|
|
3513
|
+
async addPatterns(patterns) {
|
|
3514
|
+
if (patterns.length === 0) return;
|
|
3515
|
+
const content = await readFile3(this.progressPath, "utf-8");
|
|
3516
|
+
const patternSectionIndex = content.indexOf(PATTERN_SECTION_MARKER);
|
|
3517
|
+
if (patternSectionIndex === -1) return;
|
|
3518
|
+
const sectionEndIndex = content.indexOf(SECTION_SEPARATOR, patternSectionIndex + PATTERN_SECTION_MARKER.length);
|
|
3519
|
+
if (sectionEndIndex === -1) return;
|
|
3520
|
+
const newPatterns = patterns.map((p) => `- ${p.content}`).join("\n");
|
|
3521
|
+
const before = content.substring(0, sectionEndIndex);
|
|
3522
|
+
const after = content.substring(sectionEndIndex);
|
|
3523
|
+
const existingPatterns = before.substring(patternSectionIndex);
|
|
3524
|
+
const uniquePatterns = patterns.filter((p) => !existingPatterns.includes(p.content)).map((p) => `- ${p.content}`).join("\n");
|
|
3525
|
+
if (uniquePatterns.length === 0) return;
|
|
3526
|
+
const updated = before + "\n" + uniquePatterns + after;
|
|
3527
|
+
await writeFile(this.progressPath, updated);
|
|
3528
|
+
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Get the path to the progress file
|
|
3531
|
+
*/
|
|
3532
|
+
getProgressPath() {
|
|
3533
|
+
return this.progressPath;
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
|
|
3537
|
+
// src/core/learning/agents-md.ts
|
|
3538
|
+
import { readFile as readFile4, writeFile as writeFile2, appendFile as appendFile2, mkdir } from "fs/promises";
|
|
3539
|
+
import { existsSync as existsSync4 } from "fs";
|
|
3540
|
+
import { dirname, join } from "path";
|
|
3541
|
+
var AGENTS_MD_HEADER = `# AGENTS.md
|
|
3542
|
+
|
|
3543
|
+
This file contains learned patterns and conventions for this directory.
|
|
3544
|
+
|
|
3545
|
+
`;
|
|
3546
|
+
var AgentsMdUpdater = class {
|
|
3547
|
+
cwd;
|
|
3548
|
+
constructor(cwd = process.cwd()) {
|
|
3549
|
+
this.cwd = cwd;
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Update AGENTS.md files in directories containing modified files
|
|
3553
|
+
*/
|
|
3554
|
+
async updateAgentsMd(atom, execution, modifiedFiles) {
|
|
3555
|
+
try {
|
|
3556
|
+
const knowledge = this.extractKnowledge(atom, execution);
|
|
3557
|
+
if (!this.hasValuableKnowledge(knowledge)) {
|
|
3558
|
+
return {
|
|
3559
|
+
success: true,
|
|
3560
|
+
filesUpdated: [],
|
|
3561
|
+
filesCreated: [],
|
|
3562
|
+
learningsAdded: 0
|
|
3563
|
+
};
|
|
3564
|
+
}
|
|
3565
|
+
const directories = this.getUniqueDirectories(modifiedFiles);
|
|
3566
|
+
const filesUpdated = [];
|
|
3567
|
+
const filesCreated = [];
|
|
3568
|
+
let learningsAdded = 0;
|
|
3569
|
+
for (const dir of directories) {
|
|
3570
|
+
const result = await this.updateDirectoryAgentsMd(dir, knowledge);
|
|
3571
|
+
if (result.updated) {
|
|
3572
|
+
filesUpdated.push(result.path);
|
|
3573
|
+
} else if (result.created) {
|
|
3574
|
+
filesCreated.push(result.path);
|
|
3575
|
+
}
|
|
3576
|
+
learningsAdded += result.learningsAdded;
|
|
3577
|
+
}
|
|
3578
|
+
return {
|
|
3579
|
+
success: true,
|
|
3580
|
+
filesUpdated,
|
|
3581
|
+
filesCreated,
|
|
3582
|
+
learningsAdded
|
|
3583
|
+
};
|
|
3584
|
+
} catch (error) {
|
|
3585
|
+
return {
|
|
3586
|
+
success: false,
|
|
3587
|
+
filesUpdated: [],
|
|
3588
|
+
filesCreated: [],
|
|
3589
|
+
learningsAdded: 0,
|
|
3590
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
/**
|
|
3595
|
+
* Extract reusable knowledge from atom and execution
|
|
3596
|
+
*/
|
|
3597
|
+
extractKnowledge(atom, execution) {
|
|
3598
|
+
const patterns = [];
|
|
3599
|
+
const conventions = [];
|
|
3600
|
+
const gotchas = [];
|
|
3601
|
+
const dependencies = [];
|
|
3602
|
+
const testingApproaches = [];
|
|
3603
|
+
if (atom.plan) {
|
|
3604
|
+
for (const step of atom.plan.steps) {
|
|
3605
|
+
if (this.isConvention(step)) {
|
|
3606
|
+
conventions.push({ type: "CONVENTION", content: step });
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
if (atom.plan.dependencies && atom.plan.dependencies.length > 0) {
|
|
3610
|
+
dependencies.push(...atom.plan.dependencies);
|
|
3611
|
+
}
|
|
3612
|
+
for (const risk of atom.plan.risks) {
|
|
3613
|
+
if (this.isReusableGotcha(risk)) {
|
|
3614
|
+
gotchas.push({ type: "GOTCHA", content: risk });
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
if (execution.executionNotes) {
|
|
3619
|
+
const extracted = this.extractFromNotes(execution.executionNotes);
|
|
3620
|
+
patterns.push(...extracted.patterns);
|
|
3621
|
+
conventions.push(...extracted.conventions);
|
|
3622
|
+
gotchas.push(...extracted.gotchas);
|
|
3623
|
+
testingApproaches.push(...extracted.testingApproaches);
|
|
3624
|
+
}
|
|
3625
|
+
if (execution.qualityGateResults) {
|
|
3626
|
+
const gateInsights = this.extractGateInsights(execution.qualityGateResults);
|
|
3627
|
+
gotchas.push(...gateInsights);
|
|
3628
|
+
}
|
|
3629
|
+
if (execution.conflictsDetected && execution.conflictsDetected.length > 0) {
|
|
3630
|
+
for (const conflict of execution.conflictsDetected) {
|
|
3631
|
+
if (conflict.type === "ARCHITECTURAL" || conflict.type === "SEMANTIC") {
|
|
3632
|
+
gotchas.push({
|
|
3633
|
+
type: "GOTCHA",
|
|
3634
|
+
content: conflict.message
|
|
3635
|
+
});
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
return {
|
|
3640
|
+
patterns,
|
|
3641
|
+
conventions,
|
|
3642
|
+
gotchas,
|
|
3643
|
+
dependencies,
|
|
3644
|
+
testingApproaches
|
|
3645
|
+
};
|
|
3646
|
+
}
|
|
3647
|
+
/**
|
|
3648
|
+
* Check if a step describes a convention
|
|
3649
|
+
*/
|
|
3650
|
+
isConvention(text) {
|
|
3651
|
+
const conventionIndicators = [
|
|
3652
|
+
"use index.ts",
|
|
3653
|
+
"export from",
|
|
3654
|
+
"follow pattern",
|
|
3655
|
+
"use result type",
|
|
3656
|
+
"prefer",
|
|
3657
|
+
"convention:",
|
|
3658
|
+
"always use",
|
|
3659
|
+
"naming:"
|
|
3660
|
+
];
|
|
3661
|
+
const lower = text.toLowerCase();
|
|
3662
|
+
return conventionIndicators.some((ind) => lower.includes(ind));
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Check if a risk is a reusable gotcha
|
|
3666
|
+
*/
|
|
3667
|
+
isReusableGotcha(text) {
|
|
3668
|
+
const gotchaIndicators = [
|
|
3669
|
+
"watch out",
|
|
3670
|
+
"careful",
|
|
3671
|
+
"don't forget",
|
|
3672
|
+
"remember to",
|
|
3673
|
+
"gotcha:",
|
|
3674
|
+
"warning:",
|
|
3675
|
+
"important:",
|
|
3676
|
+
"note:",
|
|
3677
|
+
"avoid",
|
|
3678
|
+
"never"
|
|
3679
|
+
];
|
|
3680
|
+
const lower = text.toLowerCase();
|
|
3681
|
+
return gotchaIndicators.some((ind) => lower.includes(ind));
|
|
3682
|
+
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Extract knowledge from execution notes
|
|
3685
|
+
*/
|
|
3686
|
+
extractFromNotes(notes) {
|
|
3687
|
+
const patterns = [];
|
|
3688
|
+
const conventions = [];
|
|
3689
|
+
const gotchas = [];
|
|
3690
|
+
const testingApproaches = [];
|
|
3691
|
+
const lines = notes.split("\n");
|
|
3692
|
+
for (const line of lines) {
|
|
3693
|
+
const trimmed = line.trim();
|
|
3694
|
+
if (trimmed.startsWith("Pattern:")) {
|
|
3695
|
+
patterns.push({
|
|
3696
|
+
type: "PATTERN",
|
|
3697
|
+
content: trimmed.replace(/^Pattern:\s*/i, "")
|
|
3698
|
+
});
|
|
3699
|
+
} else if (trimmed.startsWith("Convention:")) {
|
|
3700
|
+
conventions.push({
|
|
3701
|
+
type: "CONVENTION",
|
|
3702
|
+
content: trimmed.replace(/^Convention:\s*/i, "")
|
|
3703
|
+
});
|
|
3704
|
+
} else if (trimmed.startsWith("Gotcha:") || trimmed.startsWith("Warning:")) {
|
|
3705
|
+
gotchas.push({
|
|
3706
|
+
type: "GOTCHA",
|
|
3707
|
+
content: trimmed.replace(/^(Gotcha|Warning):\s*/i, "")
|
|
3708
|
+
});
|
|
3709
|
+
} else if (trimmed.startsWith("Test:") || trimmed.startsWith("Testing:")) {
|
|
3710
|
+
testingApproaches.push(trimmed.replace(/^Test(ing)?:\s*/i, ""));
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
return { patterns, conventions, gotchas, testingApproaches };
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* Extract gotchas from quality gate results
|
|
3717
|
+
*/
|
|
3718
|
+
extractGateInsights(results) {
|
|
3719
|
+
const gotchas = [];
|
|
3720
|
+
for (const result of results) {
|
|
3721
|
+
if (!result.passed && result.output) {
|
|
3722
|
+
const insight = this.extractActionableInsight(result.output);
|
|
3723
|
+
if (insight) {
|
|
3724
|
+
gotchas.push({
|
|
3725
|
+
type: "GOTCHA",
|
|
3726
|
+
content: `${result.gate}: ${insight}`
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
return gotchas;
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Extract actionable insight from error output
|
|
3735
|
+
*/
|
|
3736
|
+
extractActionableInsight(output) {
|
|
3737
|
+
const lines = output.split("\n");
|
|
3738
|
+
for (const line of lines) {
|
|
3739
|
+
if (line.includes("error TS") || line.includes("ESLint:")) {
|
|
3740
|
+
const match = line.match(/(TS\d+|[a-z-]+\/[a-z-]+)/i);
|
|
3741
|
+
if (match) {
|
|
3742
|
+
return `Check for ${match[1]} - ${line.substring(0, 100)}`;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
return null;
|
|
3747
|
+
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Check if knowledge is valuable enough to save
|
|
3750
|
+
*/
|
|
3751
|
+
hasValuableKnowledge(knowledge) {
|
|
3752
|
+
return knowledge.patterns.length > 0 || knowledge.conventions.length > 0 || knowledge.gotchas.length > 0 || knowledge.testingApproaches.length > 0;
|
|
3753
|
+
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Get unique directories from file paths
|
|
3756
|
+
*/
|
|
3757
|
+
getUniqueDirectories(files) {
|
|
3758
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
3759
|
+
for (const file of files) {
|
|
3760
|
+
const dir = dirname(file);
|
|
3761
|
+
if (dir && dir !== ".") {
|
|
3762
|
+
dirs.add(dir);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
return Array.from(dirs);
|
|
3766
|
+
}
|
|
3767
|
+
/**
|
|
3768
|
+
* Update or create AGENTS.md in a directory
|
|
3769
|
+
*/
|
|
3770
|
+
async updateDirectoryAgentsMd(dir, knowledge) {
|
|
3771
|
+
const agentsMdPath = join(this.cwd, dir, "AGENTS.md");
|
|
3772
|
+
const parentAgentsMd = await this.findParentAgentsMd(dir);
|
|
3773
|
+
let learningsAdded = 0;
|
|
3774
|
+
if (existsSync4(agentsMdPath)) {
|
|
3775
|
+
learningsAdded = await this.appendToAgentsMd(agentsMdPath, knowledge);
|
|
3776
|
+
return { path: agentsMdPath, updated: true, created: false, learningsAdded };
|
|
3777
|
+
}
|
|
3778
|
+
if (parentAgentsMd) {
|
|
3779
|
+
learningsAdded = await this.appendToAgentsMd(parentAgentsMd, knowledge, dir);
|
|
3780
|
+
return { path: parentAgentsMd, updated: true, created: false, learningsAdded };
|
|
3781
|
+
}
|
|
3782
|
+
const totalKnowledge = knowledge.patterns.length + knowledge.conventions.length + knowledge.gotchas.length + knowledge.testingApproaches.length;
|
|
3783
|
+
if (totalKnowledge >= 2) {
|
|
3784
|
+
await this.createAgentsMd(agentsMdPath, knowledge);
|
|
3785
|
+
learningsAdded = totalKnowledge;
|
|
3786
|
+
return { path: agentsMdPath, updated: false, created: true, learningsAdded };
|
|
3787
|
+
}
|
|
3788
|
+
return { path: agentsMdPath, updated: false, created: false, learningsAdded: 0 };
|
|
3789
|
+
}
|
|
3790
|
+
/**
|
|
3791
|
+
* Find AGENTS.md in parent directories
|
|
3792
|
+
*/
|
|
3793
|
+
async findParentAgentsMd(dir) {
|
|
3794
|
+
let currentDir = dirname(dir);
|
|
3795
|
+
while (currentDir && currentDir !== "." && currentDir !== "/") {
|
|
3796
|
+
const agentsMdPath = join(this.cwd, currentDir, "AGENTS.md");
|
|
3797
|
+
if (existsSync4(agentsMdPath)) {
|
|
3798
|
+
return agentsMdPath;
|
|
3799
|
+
}
|
|
3800
|
+
currentDir = dirname(currentDir);
|
|
3801
|
+
}
|
|
3802
|
+
return null;
|
|
3803
|
+
}
|
|
3804
|
+
/**
|
|
3805
|
+
* Append knowledge to existing AGENTS.md
|
|
3806
|
+
*/
|
|
3807
|
+
async appendToAgentsMd(path, knowledge, subdir) {
|
|
3808
|
+
const existing = await readFile4(path, "utf-8");
|
|
3809
|
+
const additions = [];
|
|
3810
|
+
let count = 0;
|
|
3811
|
+
const prefix = subdir ? `[${subdir}] ` : "";
|
|
3812
|
+
if (knowledge.patterns.length > 0) {
|
|
3813
|
+
const newPatterns = knowledge.patterns.filter((p) => !existing.includes(p.content));
|
|
3814
|
+
if (newPatterns.length > 0) {
|
|
3815
|
+
if (!existing.includes("## Patterns")) {
|
|
3816
|
+
additions.push("\n## Patterns\n");
|
|
3817
|
+
}
|
|
3818
|
+
for (const pattern of newPatterns) {
|
|
3819
|
+
additions.push(`- ${prefix}${pattern.content}`);
|
|
3820
|
+
count++;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
if (knowledge.conventions.length > 0) {
|
|
3825
|
+
const newConventions = knowledge.conventions.filter((c) => !existing.includes(c.content));
|
|
3826
|
+
if (newConventions.length > 0) {
|
|
3827
|
+
if (!existing.includes("## Conventions")) {
|
|
3828
|
+
additions.push("\n## Conventions\n");
|
|
3829
|
+
}
|
|
3830
|
+
for (const convention of newConventions) {
|
|
3831
|
+
additions.push(`- ${prefix}${convention.content}`);
|
|
3832
|
+
count++;
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
if (knowledge.gotchas.length > 0) {
|
|
3837
|
+
const newGotchas = knowledge.gotchas.filter((g) => !existing.includes(g.content));
|
|
3838
|
+
if (newGotchas.length > 0) {
|
|
3839
|
+
if (!existing.includes("## Gotchas")) {
|
|
3840
|
+
additions.push("\n## Gotchas\n");
|
|
3841
|
+
}
|
|
3842
|
+
for (const gotcha of newGotchas) {
|
|
3843
|
+
additions.push(`- ${prefix}${gotcha.content}`);
|
|
3844
|
+
count++;
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
if (knowledge.testingApproaches.length > 0) {
|
|
3849
|
+
const newTesting = knowledge.testingApproaches.filter((t) => !existing.includes(t));
|
|
3850
|
+
if (newTesting.length > 0) {
|
|
3851
|
+
if (!existing.includes("## Testing")) {
|
|
3852
|
+
additions.push("\n## Testing\n");
|
|
3853
|
+
}
|
|
3854
|
+
for (const approach of newTesting) {
|
|
3855
|
+
additions.push(`- ${prefix}${approach}`);
|
|
3856
|
+
count++;
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
if (additions.length > 0) {
|
|
3861
|
+
await appendFile2(path, "\n" + additions.join("\n"));
|
|
3862
|
+
}
|
|
3863
|
+
return count;
|
|
3864
|
+
}
|
|
3865
|
+
/**
|
|
3866
|
+
* Create new AGENTS.md file
|
|
3867
|
+
*/
|
|
3868
|
+
async createAgentsMd(path, knowledge) {
|
|
3869
|
+
const parts = [AGENTS_MD_HEADER];
|
|
3870
|
+
if (knowledge.patterns.length > 0) {
|
|
3871
|
+
parts.push("## Patterns\n");
|
|
3872
|
+
for (const pattern of knowledge.patterns) {
|
|
3873
|
+
parts.push(`- ${pattern.content}`);
|
|
3874
|
+
}
|
|
3875
|
+
parts.push("");
|
|
3876
|
+
}
|
|
3877
|
+
if (knowledge.conventions.length > 0) {
|
|
3878
|
+
parts.push("## Conventions\n");
|
|
3879
|
+
for (const convention of knowledge.conventions) {
|
|
3880
|
+
parts.push(`- ${convention.content}`);
|
|
3881
|
+
}
|
|
3882
|
+
parts.push("");
|
|
3883
|
+
}
|
|
3884
|
+
if (knowledge.gotchas.length > 0) {
|
|
3885
|
+
parts.push("## Gotchas\n");
|
|
3886
|
+
for (const gotcha of knowledge.gotchas) {
|
|
3887
|
+
parts.push(`- ${gotcha.content}`);
|
|
3888
|
+
}
|
|
3889
|
+
parts.push("");
|
|
3890
|
+
}
|
|
3891
|
+
if (knowledge.testingApproaches.length > 0) {
|
|
3892
|
+
parts.push("## Testing\n");
|
|
3893
|
+
for (const approach of knowledge.testingApproaches) {
|
|
3894
|
+
parts.push(`- ${approach}`);
|
|
3895
|
+
}
|
|
3896
|
+
parts.push("");
|
|
3897
|
+
}
|
|
3898
|
+
const dir = dirname(path);
|
|
3899
|
+
if (!existsSync4(dir)) {
|
|
3900
|
+
await mkdir(dir, { recursive: true });
|
|
3901
|
+
}
|
|
3902
|
+
await writeFile2(path, parts.join("\n"));
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3905
|
+
|
|
3906
|
+
// src/agents/executor.ts
|
|
3907
|
+
import { readFile as readFile5, writeFile as writeFile3, mkdir as mkdir2 } from "fs/promises";
|
|
3908
|
+
import { existsSync as existsSync5 } from "fs";
|
|
3909
|
+
import { dirname as dirname2 } from "path";
|
|
3910
|
+
import { execSync as execSync2 } from "child_process";
|
|
3911
|
+
var SYSTEM_PROMPT = `You are the Executor, an expert software engineer responsible for implementing approved plans.
|
|
3912
|
+
|
|
3913
|
+
Your role:
|
|
3914
|
+
- Follow the plan steps precisely
|
|
3915
|
+
- Generate complete, working code
|
|
3916
|
+
- Respect architecture boundaries and invariants
|
|
3917
|
+
- Include proper error handling
|
|
3918
|
+
- Follow existing code patterns and conventions
|
|
3919
|
+
|
|
3920
|
+
For each file you need to modify, output in this format:
|
|
3921
|
+
|
|
3922
|
+
\`\`\`diff:path/to/file.ts
|
|
3923
|
+
--- a/path/to/file.ts
|
|
3924
|
+
+++ b/path/to/file.ts
|
|
3925
|
+
@@ -1,10 +1,15 @@
|
|
3926
|
+
// Show the complete new file content
|
|
3927
|
+
// For new files, show full content
|
|
3928
|
+
// For modifications, show complete updated content
|
|
3929
|
+
\`\`\`
|
|
3930
|
+
|
|
3931
|
+
Guidelines:
|
|
3932
|
+
- Output COMPLETE file contents, not partial patches
|
|
3933
|
+
- Include all necessary imports
|
|
3934
|
+
- Follow TypeScript strict mode conventions
|
|
3935
|
+
- Do not add unnecessary comments
|
|
3936
|
+
- Match the codebase's existing style`;
|
|
3937
|
+
var ExecutorAgent = class {
|
|
3938
|
+
client;
|
|
3939
|
+
config;
|
|
3940
|
+
constructor(config, apiKey) {
|
|
3941
|
+
this.config = {
|
|
3942
|
+
provider: "anthropic",
|
|
3943
|
+
model: config?.model ?? getDefaultModel("executor"),
|
|
3944
|
+
maxTokens: config?.maxTokens ?? 8192,
|
|
3945
|
+
temperature: config?.temperature ?? 0.2
|
|
3946
|
+
// Low temperature for consistent code
|
|
3947
|
+
};
|
|
3948
|
+
this.client = new AnthropicClient(this.config, apiKey);
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Execute an approved plan
|
|
3952
|
+
*/
|
|
3953
|
+
async executeAtom(atom, plan, architecture, cwd = process.cwd()) {
|
|
3954
|
+
const userMessage = await this.buildPrompt(atom, plan, architecture, cwd);
|
|
3955
|
+
const response = await this.client.chat(SYSTEM_PROMPT, userMessage, {
|
|
3956
|
+
temperature: 0.2,
|
|
3957
|
+
maxTokens: 8192
|
|
3958
|
+
});
|
|
3959
|
+
const diffs = this.parseDiffs(response.content);
|
|
3960
|
+
const violations = this.checkArchitectureViolations(diffs, plan, architecture);
|
|
3961
|
+
if (violations.length > 0) {
|
|
3962
|
+
return {
|
|
3963
|
+
success: false,
|
|
3964
|
+
diffs,
|
|
3965
|
+
usage: response.usage,
|
|
3966
|
+
qualityChecksPassed: false,
|
|
3967
|
+
errorMessage: `Architecture violations: ${violations.join(", ")}`,
|
|
3968
|
+
rollbackPerformed: false
|
|
3969
|
+
};
|
|
3970
|
+
}
|
|
3971
|
+
const originalContents = /* @__PURE__ */ new Map();
|
|
3972
|
+
try {
|
|
3973
|
+
for (const diff of diffs) {
|
|
3974
|
+
const fullPath = `${cwd}/${diff.path}`;
|
|
3975
|
+
if (existsSync5(fullPath)) {
|
|
3976
|
+
originalContents.set(diff.path, await readFile5(fullPath, "utf-8"));
|
|
3977
|
+
} else {
|
|
3978
|
+
originalContents.set(diff.path, null);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
for (const diff of diffs) {
|
|
3982
|
+
const fullPath = `${cwd}/${diff.path}`;
|
|
3983
|
+
if (diff.operation === "DELETE") {
|
|
3984
|
+
continue;
|
|
3985
|
+
}
|
|
3986
|
+
const dir = dirname2(fullPath);
|
|
3987
|
+
if (!existsSync5(dir)) {
|
|
3988
|
+
await mkdir2(dir, { recursive: true });
|
|
3989
|
+
}
|
|
3990
|
+
await writeFile3(fullPath, diff.newContent);
|
|
3991
|
+
}
|
|
3992
|
+
const qualityChecksPassed = await this.runQualityChecks(cwd);
|
|
3993
|
+
if (!qualityChecksPassed) {
|
|
3994
|
+
await this.rollback(cwd, originalContents, diffs);
|
|
3995
|
+
return {
|
|
3996
|
+
success: false,
|
|
3997
|
+
diffs,
|
|
3998
|
+
usage: response.usage,
|
|
3999
|
+
qualityChecksPassed: false,
|
|
4000
|
+
errorMessage: "Quality checks failed - changes rolled back",
|
|
4001
|
+
rollbackPerformed: true
|
|
4002
|
+
};
|
|
4003
|
+
}
|
|
4004
|
+
return {
|
|
4005
|
+
success: true,
|
|
4006
|
+
diffs,
|
|
4007
|
+
usage: response.usage,
|
|
4008
|
+
qualityChecksPassed: true,
|
|
4009
|
+
rollbackPerformed: false
|
|
4010
|
+
};
|
|
4011
|
+
} catch (error) {
|
|
4012
|
+
await this.rollback(cwd, originalContents, diffs);
|
|
4013
|
+
return {
|
|
4014
|
+
success: false,
|
|
4015
|
+
diffs,
|
|
4016
|
+
usage: response.usage,
|
|
4017
|
+
qualityChecksPassed: false,
|
|
4018
|
+
errorMessage: error instanceof Error ? error.message : "Unknown error",
|
|
4019
|
+
rollbackPerformed: true
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
/**
|
|
4024
|
+
* Build the execution prompt
|
|
4025
|
+
*/
|
|
4026
|
+
async buildPrompt(atom, plan, architecture, cwd) {
|
|
4027
|
+
const parts = [];
|
|
4028
|
+
parts.push("# Atom to Implement");
|
|
4029
|
+
parts.push(`**Title:** ${atom.title}`);
|
|
4030
|
+
parts.push("");
|
|
4031
|
+
parts.push("**Acceptance Criteria:**");
|
|
4032
|
+
atom.acceptanceCriteria.forEach((ac, i) => parts.push(`${i + 1}. ${ac}`));
|
|
4033
|
+
parts.push("");
|
|
4034
|
+
parts.push("# Approved Plan");
|
|
4035
|
+
parts.push("");
|
|
4036
|
+
parts.push("**Steps:**");
|
|
4037
|
+
plan.steps.forEach((step, i) => parts.push(`${i + 1}. ${step}`));
|
|
4038
|
+
parts.push("");
|
|
4039
|
+
parts.push("**Files to Modify:**");
|
|
4040
|
+
plan.files_to_modify.forEach((f) => parts.push(`- ${f}`));
|
|
4041
|
+
parts.push("");
|
|
4042
|
+
parts.push("# Current File Contents");
|
|
4043
|
+
for (const filePath of plan.files_to_modify) {
|
|
4044
|
+
const fullPath = `${cwd}/${filePath}`;
|
|
4045
|
+
if (existsSync5(fullPath)) {
|
|
4046
|
+
try {
|
|
4047
|
+
const content = await readFile5(fullPath, "utf-8");
|
|
4048
|
+
parts.push(`
|
|
4049
|
+
## ${filePath}`);
|
|
4050
|
+
parts.push("```typescript");
|
|
4051
|
+
parts.push(content);
|
|
4052
|
+
parts.push("```");
|
|
4053
|
+
} catch {
|
|
4054
|
+
parts.push(`
|
|
4055
|
+
## ${filePath}`);
|
|
4056
|
+
parts.push("(File exists but could not be read)");
|
|
4057
|
+
}
|
|
4058
|
+
} else {
|
|
4059
|
+
parts.push(`
|
|
4060
|
+
## ${filePath}`);
|
|
4061
|
+
parts.push("(New file - does not exist yet)");
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
parts.push("");
|
|
4065
|
+
parts.push("# Architecture Constraints");
|
|
4066
|
+
if (architecture.invariants.length > 0) {
|
|
4067
|
+
parts.push("**Invariants (DO NOT violate):**");
|
|
4068
|
+
architecture.invariants.forEach((inv) => {
|
|
4069
|
+
parts.push(`- ${inv.rule}`);
|
|
4070
|
+
});
|
|
4071
|
+
}
|
|
4072
|
+
parts.push("");
|
|
4073
|
+
parts.push("# Your Task");
|
|
4074
|
+
parts.push("Implement the plan by generating the file changes.");
|
|
4075
|
+
parts.push("Output complete file contents for each file using the diff format.");
|
|
4076
|
+
return parts.join("\n");
|
|
4077
|
+
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Parse diffs from AI response
|
|
4080
|
+
*/
|
|
4081
|
+
parseDiffs(content) {
|
|
4082
|
+
const diffs = [];
|
|
4083
|
+
const diffPattern = /```diff:([^\n]+)\n([\s\S]*?)```/g;
|
|
4084
|
+
let match;
|
|
4085
|
+
while ((match = diffPattern.exec(content)) !== null) {
|
|
4086
|
+
const path = match[1]?.trim();
|
|
4087
|
+
const diffContent = match[2];
|
|
4088
|
+
if (!path || !diffContent) continue;
|
|
4089
|
+
const lines = diffContent.split("\n");
|
|
4090
|
+
const contentLines = [];
|
|
4091
|
+
let inContent = false;
|
|
4092
|
+
for (const line of lines) {
|
|
4093
|
+
if (line.startsWith("@@")) {
|
|
4094
|
+
inContent = true;
|
|
4095
|
+
continue;
|
|
4096
|
+
}
|
|
4097
|
+
if (inContent) {
|
|
4098
|
+
if (line.startsWith("+")) {
|
|
4099
|
+
contentLines.push(line.substring(1));
|
|
4100
|
+
} else if (line.startsWith(" ")) {
|
|
4101
|
+
contentLines.push(line.substring(1));
|
|
4102
|
+
} else if (!line.startsWith("-")) {
|
|
4103
|
+
contentLines.push(line);
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
const newContent = contentLines.join("\n");
|
|
4108
|
+
diffs.push({
|
|
4109
|
+
path,
|
|
4110
|
+
operation: "MODIFY",
|
|
4111
|
+
// Assume modify, could detect create/delete
|
|
4112
|
+
newContent
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
const codePattern = /```(?:typescript|ts|javascript|js)\n\/\/ File: ([^\n]+)\n([\s\S]*?)```/g;
|
|
4116
|
+
while ((match = codePattern.exec(content)) !== null) {
|
|
4117
|
+
const path = match[1]?.trim();
|
|
4118
|
+
const codeContent = match[2];
|
|
4119
|
+
if (!path || !codeContent) continue;
|
|
4120
|
+
if (!diffs.some((d) => d.path === path)) {
|
|
4121
|
+
diffs.push({
|
|
4122
|
+
path,
|
|
4123
|
+
operation: "MODIFY",
|
|
4124
|
+
newContent: codeContent
|
|
4125
|
+
});
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
return diffs;
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* Check for architecture violations
|
|
4132
|
+
*/
|
|
4133
|
+
checkArchitectureViolations(diffs, plan, architecture) {
|
|
4134
|
+
const violations = [];
|
|
4135
|
+
for (const diff of diffs) {
|
|
4136
|
+
const isAllowed = plan.files_to_modify.some(
|
|
4137
|
+
(allowed) => diff.path === allowed || diff.path.startsWith(allowed.replace("/**", "/"))
|
|
4138
|
+
);
|
|
4139
|
+
if (!isAllowed) {
|
|
4140
|
+
violations.push(`File ${diff.path} is outside the allowed paths`);
|
|
4141
|
+
}
|
|
4142
|
+
for (const protectedPath of architecture.protectedPaths) {
|
|
4143
|
+
if (this.matchesPattern(diff.path, protectedPath.pattern)) {
|
|
4144
|
+
if (protectedPath.level === "HARD") {
|
|
4145
|
+
violations.push(`File ${diff.path} is protected (${protectedPath.reason})`);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
for (const invariant of architecture.invariants) {
|
|
4150
|
+
if (invariant.match && invariant.severity === "BLOCKING") {
|
|
4151
|
+
const regex = new RegExp(invariant.match);
|
|
4152
|
+
if (regex.test(diff.newContent)) {
|
|
4153
|
+
violations.push(`Invariant ${invariant.id} violated: ${invariant.rule}`);
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
return violations;
|
|
4159
|
+
}
|
|
4160
|
+
matchesPattern(path, pattern) {
|
|
4161
|
+
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
4162
|
+
return new RegExp(`^${regexPattern}$`).test(path);
|
|
4163
|
+
}
|
|
4164
|
+
/**
|
|
4165
|
+
* Run quality checks (typecheck, lint)
|
|
4166
|
+
*/
|
|
4167
|
+
async runQualityChecks(cwd) {
|
|
4168
|
+
try {
|
|
4169
|
+
const pkgPath = `${cwd}/package.json`;
|
|
4170
|
+
if (existsSync5(pkgPath)) {
|
|
4171
|
+
const pkg = JSON.parse(await readFile5(pkgPath, "utf-8"));
|
|
4172
|
+
if (pkg.scripts?.["typecheck"]) {
|
|
4173
|
+
execSync2("npm run typecheck", { cwd, stdio: "pipe" });
|
|
4174
|
+
} else if (pkg.scripts?.["build"]) {
|
|
4175
|
+
execSync2("npm run build", { cwd, stdio: "pipe" });
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
return true;
|
|
4179
|
+
} catch {
|
|
4180
|
+
return false;
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
/**
|
|
4184
|
+
* Rollback changes
|
|
4185
|
+
*/
|
|
4186
|
+
async rollback(cwd, originalContents, diffs) {
|
|
4187
|
+
for (const diff of diffs) {
|
|
4188
|
+
const fullPath = `${cwd}/${diff.path}`;
|
|
4189
|
+
const original = originalContents.get(diff.path);
|
|
4190
|
+
if (original === null) {
|
|
4191
|
+
try {
|
|
4192
|
+
const { unlink } = await import("fs/promises");
|
|
4193
|
+
await unlink(fullPath);
|
|
4194
|
+
} catch {
|
|
4195
|
+
}
|
|
4196
|
+
} else if (original !== void 0) {
|
|
4197
|
+
await writeFile3(fullPath, original);
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
};
|
|
4202
|
+
|
|
4203
|
+
// src/core/environments/types.ts
|
|
4204
|
+
var DEFAULT_ENVIRONMENTS = {
|
|
4205
|
+
development: {
|
|
4206
|
+
autoApprove: true,
|
|
4207
|
+
qualityGates: ["ARCHITECTURE", "SYNTAX", "UNIT"]
|
|
4208
|
+
},
|
|
4209
|
+
staging: {
|
|
4210
|
+
autoApprove: false,
|
|
4211
|
+
qualityGates: ["ARCHITECTURE", "SYNTAX", "LINT", "UNIT", "INTEGRATION"]
|
|
4212
|
+
},
|
|
4213
|
+
production: {
|
|
4214
|
+
autoApprove: false,
|
|
4215
|
+
requiresManualPromotion: true,
|
|
4216
|
+
qualityGates: ["ARCHITECTURE", "SYNTAX", "LINT", "UNIT", "INTEGRATION", "ACCEPTANCE", "REVIEW", "E2E"]
|
|
4217
|
+
}
|
|
4218
|
+
};
|
|
4219
|
+
|
|
4220
|
+
// src/core/environments/config.ts
|
|
4221
|
+
var import_js_yaml = __toESM(require_js_yaml2(), 1);
|
|
4222
|
+
import { existsSync as existsSync6 } from "fs";
|
|
4223
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
4224
|
+
import { join as join2 } from "path";
|
|
4225
|
+
var VALID_GATES = [
|
|
4226
|
+
"ARCHITECTURE",
|
|
4227
|
+
"SYNTAX",
|
|
4228
|
+
"LINT",
|
|
4229
|
+
"UNIT",
|
|
4230
|
+
"INTEGRATION",
|
|
4231
|
+
"ACCEPTANCE",
|
|
4232
|
+
"REVIEW",
|
|
4233
|
+
"E2E"
|
|
4234
|
+
];
|
|
4235
|
+
var EnvironmentConfigLoader = class {
|
|
4236
|
+
cwd;
|
|
4237
|
+
constructor(cwd = process.cwd()) {
|
|
4238
|
+
this.cwd = cwd;
|
|
4239
|
+
}
|
|
4240
|
+
async loadConfig() {
|
|
4241
|
+
const configPath = join2(this.cwd, "archon.config.yaml");
|
|
4242
|
+
if (existsSync6(configPath)) {
|
|
4243
|
+
return this.loadFromConfigFile(configPath);
|
|
4244
|
+
}
|
|
4245
|
+
const archPath = join2(this.cwd, "ARCHITECTURE.md");
|
|
4246
|
+
if (existsSync6(archPath)) {
|
|
4247
|
+
return this.loadFromArchitecture(archPath);
|
|
4248
|
+
}
|
|
4249
|
+
return DEFAULT_ENVIRONMENTS;
|
|
4250
|
+
}
|
|
4251
|
+
async loadFromConfigFile(configPath) {
|
|
4252
|
+
const content = await readFile6(configPath, "utf-8");
|
|
4253
|
+
const config = import_js_yaml.default.load(content);
|
|
4254
|
+
if (!config.environments) {
|
|
4255
|
+
return DEFAULT_ENVIRONMENTS;
|
|
4256
|
+
}
|
|
4257
|
+
return this.validateAndNormalize(config.environments);
|
|
4258
|
+
}
|
|
4259
|
+
async loadFromArchitecture(archPath) {
|
|
4260
|
+
const content = await readFile6(archPath, "utf-8");
|
|
4261
|
+
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
4262
|
+
if (!frontmatterMatch?.[1]) {
|
|
4263
|
+
return DEFAULT_ENVIRONMENTS;
|
|
4264
|
+
}
|
|
4265
|
+
const frontmatter = import_js_yaml.default.load(frontmatterMatch[1]);
|
|
4266
|
+
if (!frontmatter.environments) {
|
|
4267
|
+
return DEFAULT_ENVIRONMENTS;
|
|
4268
|
+
}
|
|
4269
|
+
return this.validateAndNormalize(frontmatter.environments);
|
|
4270
|
+
}
|
|
4271
|
+
validateAndNormalize(envs) {
|
|
4272
|
+
const result = {
|
|
4273
|
+
development: this.normalizeEnvConfig(envs.development, DEFAULT_ENVIRONMENTS.development),
|
|
4274
|
+
production: this.normalizeEnvConfig(envs.production, DEFAULT_ENVIRONMENTS.production)
|
|
4275
|
+
};
|
|
4276
|
+
if (envs.staging) {
|
|
4277
|
+
result.staging = this.normalizeEnvConfig(envs.staging, DEFAULT_ENVIRONMENTS.staging);
|
|
4278
|
+
}
|
|
4279
|
+
return result;
|
|
4280
|
+
}
|
|
4281
|
+
normalizeEnvConfig(config, defaultConfig) {
|
|
4282
|
+
if (!config && !defaultConfig) {
|
|
4283
|
+
return DEFAULT_ENVIRONMENTS.development;
|
|
4284
|
+
}
|
|
4285
|
+
const baseConfig = defaultConfig ?? DEFAULT_ENVIRONMENTS.development;
|
|
4286
|
+
if (!config) {
|
|
4287
|
+
return baseConfig;
|
|
4288
|
+
}
|
|
4289
|
+
const qualityGates = (config.qualityGates ?? baseConfig.qualityGates).filter((gate) => VALID_GATES.includes(gate));
|
|
4290
|
+
return {
|
|
4291
|
+
autoApprove: config.autoApprove ?? baseConfig.autoApprove,
|
|
4292
|
+
qualityGates,
|
|
4293
|
+
requiresManualPromotion: config.requiresManualPromotion ?? baseConfig.requiresManualPromotion
|
|
4294
|
+
};
|
|
4295
|
+
}
|
|
4296
|
+
getEnvironmentConfig(environments, envName) {
|
|
4297
|
+
const config = environments[envName];
|
|
4298
|
+
if (!config) {
|
|
4299
|
+
throw new Error(`Unknown environment: ${envName}`);
|
|
4300
|
+
}
|
|
4301
|
+
return config;
|
|
4302
|
+
}
|
|
4303
|
+
isValidEnvironment(envName) {
|
|
4304
|
+
return envName === "development" || envName === "staging" || envName === "production";
|
|
4305
|
+
}
|
|
4306
|
+
};
|
|
4307
|
+
|
|
4308
|
+
// src/core/environments/validator.ts
|
|
4309
|
+
var ENVIRONMENT_ORDER = ["development", "staging", "production"];
|
|
4310
|
+
var EnvironmentValidator = class {
|
|
4311
|
+
environments;
|
|
4312
|
+
constructor(environments) {
|
|
4313
|
+
this.environments = environments;
|
|
4314
|
+
}
|
|
4315
|
+
canExecuteInEnvironment(atom, targetEnv, currentEnv) {
|
|
4316
|
+
const envConfig = this.environments[targetEnv];
|
|
4317
|
+
if (!envConfig) {
|
|
4318
|
+
return { allowed: false, reason: `Unknown environment: ${targetEnv}` };
|
|
4319
|
+
}
|
|
4320
|
+
if (targetEnv === "production" && envConfig.requiresManualPromotion) {
|
|
4321
|
+
if (!currentEnv || currentEnv === "development") {
|
|
4322
|
+
return {
|
|
4323
|
+
allowed: false,
|
|
4324
|
+
reason: "Production requires manual promotion. Use: archon promote <atom-id> --to=production"
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
if (atom.status !== "READY" && atom.status !== "DONE") {
|
|
4329
|
+
return { allowed: false, reason: `Atom status must be READY or DONE, got: ${atom.status}` };
|
|
4330
|
+
}
|
|
4331
|
+
return { allowed: true };
|
|
4332
|
+
}
|
|
4333
|
+
canPromoteTo(fromEnv, toEnv) {
|
|
4334
|
+
const fromIndex = ENVIRONMENT_ORDER.indexOf(fromEnv);
|
|
4335
|
+
const toIndex = ENVIRONMENT_ORDER.indexOf(toEnv);
|
|
4336
|
+
if (fromIndex === -1) {
|
|
4337
|
+
return { allowed: false, reason: `Unknown source environment: ${fromEnv}` };
|
|
4338
|
+
}
|
|
4339
|
+
if (toIndex === -1) {
|
|
4340
|
+
return { allowed: false, reason: `Unknown target environment: ${toEnv}` };
|
|
4341
|
+
}
|
|
4342
|
+
if (toIndex <= fromIndex) {
|
|
4343
|
+
return {
|
|
4344
|
+
allowed: false,
|
|
4345
|
+
reason: `Cannot promote from ${fromEnv} to ${toEnv}. Promotion must go forward.`
|
|
4346
|
+
};
|
|
4347
|
+
}
|
|
4348
|
+
if (toIndex - fromIndex > 1 && this.environments.staging) {
|
|
4349
|
+
return {
|
|
4350
|
+
allowed: false,
|
|
4351
|
+
reason: `Cannot skip staging. Promote to staging first.`
|
|
4352
|
+
};
|
|
4353
|
+
}
|
|
4354
|
+
return { allowed: true };
|
|
4355
|
+
}
|
|
4356
|
+
validatePromotion(atom, toEnv, lastExecutedEnv) {
|
|
4357
|
+
if (atom.status !== "DONE") {
|
|
4358
|
+
return {
|
|
4359
|
+
success: false,
|
|
4360
|
+
atomId: atom.id,
|
|
4361
|
+
fromEnvironment: lastExecutedEnv ?? "development",
|
|
4362
|
+
toEnvironment: toEnv,
|
|
4363
|
+
message: `Atom must be DONE to promote. Current status: ${atom.status}`
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4366
|
+
const fromEnv = lastExecutedEnv ?? "development";
|
|
4367
|
+
const canPromote = this.canPromoteTo(fromEnv, toEnv);
|
|
4368
|
+
if (!canPromote.allowed) {
|
|
4369
|
+
return {
|
|
4370
|
+
success: false,
|
|
4371
|
+
atomId: atom.id,
|
|
4372
|
+
fromEnvironment: fromEnv,
|
|
4373
|
+
toEnvironment: toEnv,
|
|
4374
|
+
message: canPromote.reason ?? "Promotion not allowed"
|
|
4375
|
+
};
|
|
4376
|
+
}
|
|
4377
|
+
return {
|
|
4378
|
+
success: true,
|
|
4379
|
+
atomId: atom.id,
|
|
4380
|
+
fromEnvironment: fromEnv,
|
|
4381
|
+
toEnvironment: toEnv,
|
|
4382
|
+
message: `Atom ${atom.externalId} promoted from ${fromEnv} to ${toEnv}`
|
|
4383
|
+
};
|
|
4384
|
+
}
|
|
4385
|
+
getNextEnvironment(currentEnv) {
|
|
4386
|
+
const currentIndex = ENVIRONMENT_ORDER.indexOf(currentEnv);
|
|
4387
|
+
if (currentIndex === -1 || currentIndex >= ENVIRONMENT_ORDER.length - 1) {
|
|
4388
|
+
return null;
|
|
4389
|
+
}
|
|
4390
|
+
const nextEnv = ENVIRONMENT_ORDER[currentIndex + 1];
|
|
4391
|
+
if (!nextEnv) {
|
|
4392
|
+
return null;
|
|
4393
|
+
}
|
|
4394
|
+
if (nextEnv === "staging" && !this.environments.staging) {
|
|
4395
|
+
return "production";
|
|
4396
|
+
}
|
|
4397
|
+
return nextEnv;
|
|
4398
|
+
}
|
|
4399
|
+
};
|
|
4400
|
+
|
|
4401
|
+
// src/cli/execute.ts
|
|
4402
|
+
var ATOMS_DIR = ".archon/atoms";
|
|
4403
|
+
function createPrompt() {
|
|
4404
|
+
const rl = createInterface({
|
|
4405
|
+
input: process.stdin,
|
|
4406
|
+
output: process.stdout
|
|
4407
|
+
});
|
|
4408
|
+
return {
|
|
4409
|
+
ask: (question) => new Promise((resolve) => {
|
|
4410
|
+
rl.question(question, resolve);
|
|
4411
|
+
}),
|
|
4412
|
+
close: () => rl.close()
|
|
4413
|
+
};
|
|
4414
|
+
}
|
|
4415
|
+
async function execute(atomId, options) {
|
|
4416
|
+
const prompt = createPrompt();
|
|
4417
|
+
const cwd = process.cwd();
|
|
4418
|
+
try {
|
|
4419
|
+
console.log(chalk2.dim(`Loading atom ${atomId}...`));
|
|
4420
|
+
const atom = await loadAtom(atomId);
|
|
4421
|
+
if (!atom) {
|
|
4422
|
+
console.error(chalk2.red(`Atom ${atomId} not found.`));
|
|
4423
|
+
console.log(chalk2.dim(`Use "archon list" to see available atoms.`));
|
|
4424
|
+
process.exit(1);
|
|
4425
|
+
}
|
|
4426
|
+
const envLoader = new EnvironmentConfigLoader(cwd);
|
|
4427
|
+
const targetEnvName = options.env ?? "development";
|
|
4428
|
+
if (!envLoader.isValidEnvironment(targetEnvName)) {
|
|
4429
|
+
console.error(chalk2.red(`Invalid environment: ${targetEnvName}`));
|
|
4430
|
+
console.log(chalk2.dim("Valid environments: development, staging, production"));
|
|
4431
|
+
process.exit(1);
|
|
4432
|
+
}
|
|
4433
|
+
const envConfigs = await envLoader.loadConfig();
|
|
4434
|
+
const envConfig = envLoader.getEnvironmentConfig(envConfigs, targetEnvName);
|
|
4435
|
+
const validator = new EnvironmentValidator(envConfigs);
|
|
4436
|
+
console.log(chalk2.dim(`Environment: ${targetEnvName}`));
|
|
4437
|
+
const envState = await loadAtomEnvironmentState(atomId, cwd);
|
|
4438
|
+
const executionCheck = validator.canExecuteInEnvironment(atom, targetEnvName, envState?.lastExecutedEnv);
|
|
4439
|
+
if (!executionCheck.allowed) {
|
|
4440
|
+
console.error(chalk2.red(executionCheck.reason ?? "Execution not allowed"));
|
|
4441
|
+
process.exit(1);
|
|
4442
|
+
}
|
|
4443
|
+
if (atom.status === "DONE" && targetEnvName === envState?.lastExecutedEnv) {
|
|
4444
|
+
console.log(chalk2.yellow(`Atom ${atomId} has already been executed in ${targetEnvName}.`));
|
|
4445
|
+
return;
|
|
4446
|
+
}
|
|
4447
|
+
if (atom.status === "IN_PROGRESS") {
|
|
4448
|
+
console.log(chalk2.yellow(`Atom ${atomId} is already in progress.`));
|
|
4449
|
+
const answer = await prompt.ask("Continue anyway? (y/N): ");
|
|
4450
|
+
if (answer.toLowerCase() !== "y") {
|
|
4451
|
+
return;
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
if (atom.status !== "READY" && atom.status !== "IN_PROGRESS" && atom.status !== "DONE") {
|
|
4455
|
+
console.error(chalk2.red(`Atom ${atomId} is not ready for execution.`));
|
|
4456
|
+
console.log(chalk2.dim(`Status: ${atom.status}. Only READY or DONE atoms can be executed.`));
|
|
4457
|
+
process.exit(1);
|
|
4458
|
+
}
|
|
4459
|
+
if (!atom.plan) {
|
|
4460
|
+
console.error(chalk2.red(`Atom ${atomId} has no plan.`));
|
|
4461
|
+
console.log(chalk2.dim(`Run "archon plan" to create a plan first.`));
|
|
4462
|
+
process.exit(1);
|
|
4463
|
+
}
|
|
4464
|
+
const archPath = join3(cwd, "ARCHITECTURE.md");
|
|
4465
|
+
if (!existsSync7(archPath)) {
|
|
4466
|
+
console.error(chalk2.red("ARCHITECTURE.md not found."));
|
|
4467
|
+
process.exit(1);
|
|
4468
|
+
}
|
|
4469
|
+
const parser = new ArchitectureParser(archPath);
|
|
4470
|
+
const parseResult = await parser.parse();
|
|
4471
|
+
if (!parseResult.success || !parseResult.schema) {
|
|
4472
|
+
console.error(chalk2.red("Failed to parse ARCHITECTURE.md."));
|
|
4473
|
+
process.exit(1);
|
|
4474
|
+
}
|
|
4475
|
+
if (!options.skipConflictCheck) {
|
|
4476
|
+
console.log(chalk2.dim("\nChecking for conflicts..."));
|
|
4477
|
+
const conflictChecker = new ConflictChecker(parseResult.schema);
|
|
4478
|
+
const conflictReport = await conflictChecker.checkConflicts(atom.plan, {
|
|
4479
|
+
cwd,
|
|
4480
|
+
planCreatedAt: atom.createdAt
|
|
4481
|
+
});
|
|
4482
|
+
if (conflictReport.hasConflicts) {
|
|
4483
|
+
console.log(chalk2.yellow(`
|
|
4484
|
+
\u26A0 ${conflictReport.conflicts.length} conflict(s) detected:`));
|
|
4485
|
+
for (const conflict of conflictReport.conflicts) {
|
|
4486
|
+
const icon = conflict.severity === "BLOCKER" ? chalk2.red("\u2717") : chalk2.yellow("\u26A0");
|
|
4487
|
+
console.log(` ${icon} [${conflict.type}] ${conflict.message}`);
|
|
4488
|
+
}
|
|
4489
|
+
if (conflictReport.blockerCount > 0) {
|
|
4490
|
+
console.log(chalk2.red(`
|
|
4491
|
+
${conflictReport.blockerCount} blocking conflict(s) found.`));
|
|
4492
|
+
const answer = await prompt.ask("Continue anyway? (y/N): ");
|
|
4493
|
+
if (answer.toLowerCase() !== "y") {
|
|
4494
|
+
console.log(chalk2.dim("Execution aborted."));
|
|
4495
|
+
return;
|
|
4496
|
+
}
|
|
4497
|
+
} else {
|
|
4498
|
+
console.log(chalk2.dim("\nRecommendations:"));
|
|
4499
|
+
for (const rec of conflictReport.recommendations) {
|
|
4500
|
+
console.log(chalk2.dim(` - ${rec}`));
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
} else {
|
|
4504
|
+
console.log(chalk2.green("\u2713 No conflicts detected"));
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
try {
|
|
4508
|
+
transitionAtom(atom, "IN_PROGRESS");
|
|
4509
|
+
} catch (error) {
|
|
4510
|
+
console.error(chalk2.red("Failed to update atom status."));
|
|
4511
|
+
console.error(chalk2.dim(error instanceof Error ? error.message : "Unknown error"));
|
|
4512
|
+
process.exit(1);
|
|
4513
|
+
}
|
|
4514
|
+
await saveAtom(atom);
|
|
4515
|
+
console.log(chalk2.blue("\n\u{1F680} Executing plan..."));
|
|
4516
|
+
const executor = new ExecutorAgent();
|
|
4517
|
+
const executionResult = await executor.executeAtom(atom, atom.plan, parseResult.schema, cwd);
|
|
4518
|
+
const filesChanged = executionResult.diffs.map((d) => d.path);
|
|
4519
|
+
if (!executionResult.success) {
|
|
4520
|
+
console.log(chalk2.red("\n\u274C Execution failed"));
|
|
4521
|
+
console.log(chalk2.red(executionResult.errorMessage ?? "Unknown error"));
|
|
4522
|
+
if (executionResult.rollbackPerformed) {
|
|
4523
|
+
console.log(chalk2.yellow("Changes have been rolled back."));
|
|
4524
|
+
}
|
|
4525
|
+
transitionAtom(atom, "FAILED");
|
|
4526
|
+
atom.errorMessage = executionResult.errorMessage ?? "Execution failed";
|
|
4527
|
+
await saveAtom(atom);
|
|
4528
|
+
await captureLearnings(atom, {
|
|
4529
|
+
atomId: atom.id,
|
|
4530
|
+
atomTitle: atom.title,
|
|
4531
|
+
filesChanged,
|
|
4532
|
+
success: false,
|
|
4533
|
+
errorMessage: executionResult.errorMessage
|
|
4534
|
+
});
|
|
4535
|
+
process.exit(1);
|
|
4536
|
+
}
|
|
4537
|
+
console.log(chalk2.green("\u2713 Plan executed successfully"));
|
|
4538
|
+
console.log(chalk2.dim(`Files modified: ${filesChanged.length}`));
|
|
4539
|
+
for (const file of filesChanged) {
|
|
4540
|
+
console.log(chalk2.dim(` - ${file}`));
|
|
4541
|
+
}
|
|
4542
|
+
if (!options.skipGates) {
|
|
4543
|
+
console.log(chalk2.dim(`
|
|
4544
|
+
Running quality gates for ${targetEnvName}...`));
|
|
4545
|
+
console.log(chalk2.dim(`Gates: ${envConfig.qualityGates.join(", ")}`));
|
|
4546
|
+
const gateRunner = new QualityGateRunner({ cwd, verbose: false });
|
|
4547
|
+
const gateResult = await gateRunner.runGates(envConfig.qualityGates);
|
|
4548
|
+
gateRunner.printResults(gateResult);
|
|
4549
|
+
if (!gateResult.allPassed) {
|
|
4550
|
+
console.log(chalk2.red("\n\u274C Quality gates failed"));
|
|
4551
|
+
console.log(chalk2.yellow("Rolling back changes..."));
|
|
4552
|
+
try {
|
|
4553
|
+
execSync3("git checkout -- .", { cwd, stdio: "pipe" });
|
|
4554
|
+
console.log(chalk2.yellow("Changes rolled back."));
|
|
4555
|
+
} catch {
|
|
4556
|
+
console.log(chalk2.red("Failed to rollback. Please manually revert changes."));
|
|
4557
|
+
}
|
|
4558
|
+
transitionAtom(atom, "FAILED");
|
|
4559
|
+
atom.errorMessage = `Quality gate failed: ${gateResult.failedAt}`;
|
|
4560
|
+
await saveAtom(atom);
|
|
4561
|
+
await captureLearnings(atom, {
|
|
4562
|
+
atomId: atom.id,
|
|
4563
|
+
atomTitle: atom.title,
|
|
4564
|
+
filesChanged,
|
|
4565
|
+
qualityGateResults: gateResult.results.map((r) => ({
|
|
4566
|
+
gate: r.gate,
|
|
4567
|
+
passed: r.passed,
|
|
4568
|
+
output: r.output
|
|
4569
|
+
})),
|
|
4570
|
+
success: false,
|
|
4571
|
+
errorMessage: `Quality gate failed: ${gateResult.failedAt}`
|
|
4572
|
+
});
|
|
4573
|
+
process.exit(1);
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
console.log(chalk2.dim("\nCommitting changes..."));
|
|
4577
|
+
try {
|
|
4578
|
+
const commitMessage = `feat: [${atom.externalId}] - ${atom.title}`;
|
|
4579
|
+
execSync3(`git add -A`, { cwd, stdio: "pipe" });
|
|
4580
|
+
execSync3(`git commit -m "${commitMessage}"`, { cwd, stdio: "pipe" });
|
|
4581
|
+
console.log(chalk2.green(`\u2713 Committed: ${commitMessage}`));
|
|
4582
|
+
} catch (error) {
|
|
4583
|
+
console.log(chalk2.yellow("No changes to commit or git commit failed."));
|
|
4584
|
+
}
|
|
4585
|
+
transitionAtom(atom, "TESTING");
|
|
4586
|
+
transitionAtom(atom, "DONE");
|
|
4587
|
+
await saveAtom(atom);
|
|
4588
|
+
await saveAtomEnvironmentState(atomId, cwd, {
|
|
4589
|
+
lastExecutedEnv: targetEnvName,
|
|
4590
|
+
promotedTo: envState?.promotedTo ?? []
|
|
4591
|
+
});
|
|
4592
|
+
console.log(chalk2.dim("\nCapturing learnings..."));
|
|
4593
|
+
const executionSummary = {
|
|
4594
|
+
atomId: atom.id,
|
|
4595
|
+
atomTitle: atom.title,
|
|
4596
|
+
filesChanged,
|
|
4597
|
+
planSteps: atom.plan.steps,
|
|
4598
|
+
planRisks: atom.plan.risks,
|
|
4599
|
+
success: true
|
|
4600
|
+
};
|
|
4601
|
+
await captureLearnings(atom, executionSummary);
|
|
4602
|
+
const agentsMdUpdater = new AgentsMdUpdater(cwd);
|
|
4603
|
+
const agentsMdResult = await agentsMdUpdater.updateAgentsMd(atom, executionSummary, filesChanged);
|
|
4604
|
+
if (agentsMdResult.filesCreated.length > 0 || agentsMdResult.filesUpdated.length > 0) {
|
|
4605
|
+
console.log(chalk2.dim(`Updated ${agentsMdResult.filesUpdated.length + agentsMdResult.filesCreated.length} AGENTS.md file(s)`));
|
|
4606
|
+
}
|
|
4607
|
+
console.log(chalk2.green("\n\u2705 Atom executed successfully!"));
|
|
4608
|
+
console.log(chalk2.dim(`Atom: ${atom.externalId}`));
|
|
4609
|
+
console.log(chalk2.dim(`Status: ${atom.status}`));
|
|
4610
|
+
console.log(chalk2.dim(`Files changed: ${filesChanged.length}`));
|
|
4611
|
+
} finally {
|
|
4612
|
+
prompt.close();
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
async function saveAtom(atom) {
|
|
4616
|
+
const atomsDir = join3(process.cwd(), ATOMS_DIR);
|
|
4617
|
+
const atomFile = join3(atomsDir, `${atom.externalId}.json`);
|
|
4618
|
+
await writeFile4(atomFile, JSON.stringify(atom, null, 2));
|
|
4619
|
+
}
|
|
4620
|
+
async function captureLearnings(atom, execution) {
|
|
4621
|
+
try {
|
|
4622
|
+
const learningCapture = new LearningCapture("progress.txt");
|
|
4623
|
+
const result = await learningCapture.appendLearning(atom, execution);
|
|
4624
|
+
if (result.success) {
|
|
4625
|
+
console.log(chalk2.dim(`Learnings captured: ${result.entriesAdded} entries, ${result.patternsAdded} patterns`));
|
|
4626
|
+
}
|
|
4627
|
+
} catch {
|
|
4628
|
+
console.log(chalk2.dim("Failed to capture learnings (non-critical)."));
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
async function loadAtomEnvironmentState(atomId, cwd) {
|
|
4632
|
+
const stateFile = join3(cwd, ATOMS_DIR, `${atomId}.env.json`);
|
|
4633
|
+
if (!existsSync7(stateFile)) {
|
|
4634
|
+
return null;
|
|
4635
|
+
}
|
|
4636
|
+
const content = await readFile7(stateFile, "utf-8");
|
|
4637
|
+
return JSON.parse(content);
|
|
4638
|
+
}
|
|
4639
|
+
async function saveAtomEnvironmentState(atomId, cwd, state) {
|
|
4640
|
+
const stateFile = join3(cwd, ATOMS_DIR, `${atomId}.env.json`);
|
|
4641
|
+
await writeFile4(stateFile, JSON.stringify(state, null, 2));
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
export {
|
|
4645
|
+
EnvironmentConfigLoader,
|
|
4646
|
+
EnvironmentValidator,
|
|
4647
|
+
execute
|
|
4648
|
+
};
|