deepfish-ai 2.0.2 → 2.0.3
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 +143 -50
- package/dist/generate-skill.md +104 -0
- package/dist/generate-tool.md +88 -0
- package/dist/index.js +3764 -253
- package/dist/serve/pm2-server.js +3455 -65
- package/dist/view-learn-cache.md +65 -0
- package/package.json +19 -3
package/dist/serve/pm2-server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -29,6 +30,2801 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
30
|
mod
|
|
30
31
|
));
|
|
31
32
|
|
|
33
|
+
// node_modules/js-yaml/lib/common.js
|
|
34
|
+
var require_common = __commonJS({
|
|
35
|
+
"node_modules/js-yaml/lib/common.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
function isNothing(subject) {
|
|
38
|
+
return typeof subject === "undefined" || subject === null;
|
|
39
|
+
}
|
|
40
|
+
function isObject2(subject) {
|
|
41
|
+
return typeof subject === "object" && subject !== null;
|
|
42
|
+
}
|
|
43
|
+
function toArray(sequence) {
|
|
44
|
+
if (Array.isArray(sequence)) return sequence;
|
|
45
|
+
else if (isNothing(sequence)) return [];
|
|
46
|
+
return [sequence];
|
|
47
|
+
}
|
|
48
|
+
function extend2(target, source) {
|
|
49
|
+
var index, length, key, sourceKeys;
|
|
50
|
+
if (source) {
|
|
51
|
+
sourceKeys = Object.keys(source);
|
|
52
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
53
|
+
key = sourceKeys[index];
|
|
54
|
+
target[key] = source[key];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
function repeat(string4, count) {
|
|
60
|
+
var result = "", cycle;
|
|
61
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
62
|
+
result += string4;
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function isNegativeZero(number4) {
|
|
67
|
+
return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
|
|
68
|
+
}
|
|
69
|
+
module2.exports.isNothing = isNothing;
|
|
70
|
+
module2.exports.isObject = isObject2;
|
|
71
|
+
module2.exports.toArray = toArray;
|
|
72
|
+
module2.exports.repeat = repeat;
|
|
73
|
+
module2.exports.isNegativeZero = isNegativeZero;
|
|
74
|
+
module2.exports.extend = extend2;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// node_modules/js-yaml/lib/exception.js
|
|
79
|
+
var require_exception = __commonJS({
|
|
80
|
+
"node_modules/js-yaml/lib/exception.js"(exports2, module2) {
|
|
81
|
+
"use strict";
|
|
82
|
+
function formatError2(exception, compact) {
|
|
83
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
84
|
+
if (!exception.mark) return message;
|
|
85
|
+
if (exception.mark.name) {
|
|
86
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
87
|
+
}
|
|
88
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
89
|
+
if (!compact && exception.mark.snippet) {
|
|
90
|
+
where += "\n\n" + exception.mark.snippet;
|
|
91
|
+
}
|
|
92
|
+
return message + " " + where;
|
|
93
|
+
}
|
|
94
|
+
function YAMLException(reason, mark) {
|
|
95
|
+
Error.call(this);
|
|
96
|
+
this.name = "YAMLException";
|
|
97
|
+
this.reason = reason;
|
|
98
|
+
this.mark = mark;
|
|
99
|
+
this.message = formatError2(this, false);
|
|
100
|
+
if (Error.captureStackTrace) {
|
|
101
|
+
Error.captureStackTrace(this, this.constructor);
|
|
102
|
+
} else {
|
|
103
|
+
this.stack = new Error().stack || "";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
YAMLException.prototype = Object.create(Error.prototype);
|
|
107
|
+
YAMLException.prototype.constructor = YAMLException;
|
|
108
|
+
YAMLException.prototype.toString = function toString(compact) {
|
|
109
|
+
return this.name + ": " + formatError2(this, compact);
|
|
110
|
+
};
|
|
111
|
+
module2.exports = YAMLException;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// node_modules/js-yaml/lib/snippet.js
|
|
116
|
+
var require_snippet = __commonJS({
|
|
117
|
+
"node_modules/js-yaml/lib/snippet.js"(exports2, module2) {
|
|
118
|
+
"use strict";
|
|
119
|
+
var common = require_common();
|
|
120
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
121
|
+
var head = "";
|
|
122
|
+
var tail = "";
|
|
123
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
124
|
+
if (position - lineStart > maxHalfLength) {
|
|
125
|
+
head = " ... ";
|
|
126
|
+
lineStart = position - maxHalfLength + head.length;
|
|
127
|
+
}
|
|
128
|
+
if (lineEnd - position > maxHalfLength) {
|
|
129
|
+
tail = " ...";
|
|
130
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
134
|
+
pos: position - lineStart + head.length
|
|
135
|
+
// relative position
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function padStart(string4, max) {
|
|
139
|
+
return common.repeat(" ", max - string4.length) + string4;
|
|
140
|
+
}
|
|
141
|
+
function makeSnippet(mark, options) {
|
|
142
|
+
options = Object.create(options || null);
|
|
143
|
+
if (!mark.buffer) return null;
|
|
144
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
145
|
+
if (typeof options.indent !== "number") options.indent = 1;
|
|
146
|
+
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
147
|
+
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
148
|
+
var re = /\r?\n|\r|\0/g;
|
|
149
|
+
var lineStarts = [0];
|
|
150
|
+
var lineEnds = [];
|
|
151
|
+
var match;
|
|
152
|
+
var foundLineNo = -1;
|
|
153
|
+
while (match = re.exec(mark.buffer)) {
|
|
154
|
+
lineEnds.push(match.index);
|
|
155
|
+
lineStarts.push(match.index + match[0].length);
|
|
156
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
157
|
+
foundLineNo = lineStarts.length - 2;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
161
|
+
var result = "", i, line;
|
|
162
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
163
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
164
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
165
|
+
if (foundLineNo - i < 0) break;
|
|
166
|
+
line = getLine(
|
|
167
|
+
mark.buffer,
|
|
168
|
+
lineStarts[foundLineNo - i],
|
|
169
|
+
lineEnds[foundLineNo - i],
|
|
170
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
171
|
+
maxLineLength
|
|
172
|
+
);
|
|
173
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
174
|
+
}
|
|
175
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
176
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
177
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
178
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
179
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
180
|
+
line = getLine(
|
|
181
|
+
mark.buffer,
|
|
182
|
+
lineStarts[foundLineNo + i],
|
|
183
|
+
lineEnds[foundLineNo + i],
|
|
184
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
185
|
+
maxLineLength
|
|
186
|
+
);
|
|
187
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
188
|
+
}
|
|
189
|
+
return result.replace(/\n$/, "");
|
|
190
|
+
}
|
|
191
|
+
module2.exports = makeSnippet;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// node_modules/js-yaml/lib/type.js
|
|
196
|
+
var require_type = __commonJS({
|
|
197
|
+
"node_modules/js-yaml/lib/type.js"(exports2, module2) {
|
|
198
|
+
"use strict";
|
|
199
|
+
var YAMLException = require_exception();
|
|
200
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
201
|
+
"kind",
|
|
202
|
+
"multi",
|
|
203
|
+
"resolve",
|
|
204
|
+
"construct",
|
|
205
|
+
"instanceOf",
|
|
206
|
+
"predicate",
|
|
207
|
+
"represent",
|
|
208
|
+
"representName",
|
|
209
|
+
"defaultStyle",
|
|
210
|
+
"styleAliases"
|
|
211
|
+
];
|
|
212
|
+
var YAML_NODE_KINDS = [
|
|
213
|
+
"scalar",
|
|
214
|
+
"sequence",
|
|
215
|
+
"mapping"
|
|
216
|
+
];
|
|
217
|
+
function compileStyleAliases(map2) {
|
|
218
|
+
var result = {};
|
|
219
|
+
if (map2 !== null) {
|
|
220
|
+
Object.keys(map2).forEach(function(style) {
|
|
221
|
+
map2[style].forEach(function(alias) {
|
|
222
|
+
result[String(alias)] = style;
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
function Type(tag, options) {
|
|
229
|
+
options = options || {};
|
|
230
|
+
Object.keys(options).forEach(function(name) {
|
|
231
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
232
|
+
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
this.options = options;
|
|
236
|
+
this.tag = tag;
|
|
237
|
+
this.kind = options["kind"] || null;
|
|
238
|
+
this.resolve = options["resolve"] || function() {
|
|
239
|
+
return true;
|
|
240
|
+
};
|
|
241
|
+
this.construct = options["construct"] || function(data) {
|
|
242
|
+
return data;
|
|
243
|
+
};
|
|
244
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
245
|
+
this.predicate = options["predicate"] || null;
|
|
246
|
+
this.represent = options["represent"] || null;
|
|
247
|
+
this.representName = options["representName"] || null;
|
|
248
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
249
|
+
this.multi = options["multi"] || false;
|
|
250
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
251
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
252
|
+
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
module2.exports = Type;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// node_modules/js-yaml/lib/schema.js
|
|
260
|
+
var require_schema = __commonJS({
|
|
261
|
+
"node_modules/js-yaml/lib/schema.js"(exports2, module2) {
|
|
262
|
+
"use strict";
|
|
263
|
+
var YAMLException = require_exception();
|
|
264
|
+
var Type = require_type();
|
|
265
|
+
function compileList(schema, name) {
|
|
266
|
+
var result = [];
|
|
267
|
+
schema[name].forEach(function(currentType) {
|
|
268
|
+
var newIndex = result.length;
|
|
269
|
+
result.forEach(function(previousType, previousIndex) {
|
|
270
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
271
|
+
newIndex = previousIndex;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
result[newIndex] = currentType;
|
|
275
|
+
});
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
function compileMap() {
|
|
279
|
+
var result = {
|
|
280
|
+
scalar: {},
|
|
281
|
+
sequence: {},
|
|
282
|
+
mapping: {},
|
|
283
|
+
fallback: {},
|
|
284
|
+
multi: {
|
|
285
|
+
scalar: [],
|
|
286
|
+
sequence: [],
|
|
287
|
+
mapping: [],
|
|
288
|
+
fallback: []
|
|
289
|
+
}
|
|
290
|
+
}, index, length;
|
|
291
|
+
function collectType(type) {
|
|
292
|
+
if (type.multi) {
|
|
293
|
+
result.multi[type.kind].push(type);
|
|
294
|
+
result.multi["fallback"].push(type);
|
|
295
|
+
} else {
|
|
296
|
+
result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
300
|
+
arguments[index].forEach(collectType);
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
function Schema(definition) {
|
|
305
|
+
return this.extend(definition);
|
|
306
|
+
}
|
|
307
|
+
Schema.prototype.extend = function extend2(definition) {
|
|
308
|
+
var implicit = [];
|
|
309
|
+
var explicit = [];
|
|
310
|
+
if (definition instanceof Type) {
|
|
311
|
+
explicit.push(definition);
|
|
312
|
+
} else if (Array.isArray(definition)) {
|
|
313
|
+
explicit = explicit.concat(definition);
|
|
314
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
315
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
316
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
317
|
+
} else {
|
|
318
|
+
throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
319
|
+
}
|
|
320
|
+
implicit.forEach(function(type) {
|
|
321
|
+
if (!(type instanceof Type)) {
|
|
322
|
+
throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
323
|
+
}
|
|
324
|
+
if (type.loadKind && type.loadKind !== "scalar") {
|
|
325
|
+
throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
326
|
+
}
|
|
327
|
+
if (type.multi) {
|
|
328
|
+
throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
explicit.forEach(function(type) {
|
|
332
|
+
if (!(type instanceof Type)) {
|
|
333
|
+
throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
var result = Object.create(Schema.prototype);
|
|
337
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
338
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
339
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
340
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
341
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
342
|
+
return result;
|
|
343
|
+
};
|
|
344
|
+
module2.exports = Schema;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// node_modules/js-yaml/lib/type/str.js
|
|
349
|
+
var require_str = __commonJS({
|
|
350
|
+
"node_modules/js-yaml/lib/type/str.js"(exports2, module2) {
|
|
351
|
+
"use strict";
|
|
352
|
+
var Type = require_type();
|
|
353
|
+
module2.exports = new Type("tag:yaml.org,2002:str", {
|
|
354
|
+
kind: "scalar",
|
|
355
|
+
construct: function(data) {
|
|
356
|
+
return data !== null ? data : "";
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// node_modules/js-yaml/lib/type/seq.js
|
|
363
|
+
var require_seq = __commonJS({
|
|
364
|
+
"node_modules/js-yaml/lib/type/seq.js"(exports2, module2) {
|
|
365
|
+
"use strict";
|
|
366
|
+
var Type = require_type();
|
|
367
|
+
module2.exports = new Type("tag:yaml.org,2002:seq", {
|
|
368
|
+
kind: "sequence",
|
|
369
|
+
construct: function(data) {
|
|
370
|
+
return data !== null ? data : [];
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// node_modules/js-yaml/lib/type/map.js
|
|
377
|
+
var require_map = __commonJS({
|
|
378
|
+
"node_modules/js-yaml/lib/type/map.js"(exports2, module2) {
|
|
379
|
+
"use strict";
|
|
380
|
+
var Type = require_type();
|
|
381
|
+
module2.exports = new Type("tag:yaml.org,2002:map", {
|
|
382
|
+
kind: "mapping",
|
|
383
|
+
construct: function(data) {
|
|
384
|
+
return data !== null ? data : {};
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// node_modules/js-yaml/lib/schema/failsafe.js
|
|
391
|
+
var require_failsafe = __commonJS({
|
|
392
|
+
"node_modules/js-yaml/lib/schema/failsafe.js"(exports2, module2) {
|
|
393
|
+
"use strict";
|
|
394
|
+
var Schema = require_schema();
|
|
395
|
+
module2.exports = new Schema({
|
|
396
|
+
explicit: [
|
|
397
|
+
require_str(),
|
|
398
|
+
require_seq(),
|
|
399
|
+
require_map()
|
|
400
|
+
]
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// node_modules/js-yaml/lib/type/null.js
|
|
406
|
+
var require_null = __commonJS({
|
|
407
|
+
"node_modules/js-yaml/lib/type/null.js"(exports2, module2) {
|
|
408
|
+
"use strict";
|
|
409
|
+
var Type = require_type();
|
|
410
|
+
function resolveYamlNull(data) {
|
|
411
|
+
if (data === null) return true;
|
|
412
|
+
var max = data.length;
|
|
413
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
414
|
+
}
|
|
415
|
+
function constructYamlNull() {
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
function isNull(object2) {
|
|
419
|
+
return object2 === null;
|
|
420
|
+
}
|
|
421
|
+
module2.exports = new Type("tag:yaml.org,2002:null", {
|
|
422
|
+
kind: "scalar",
|
|
423
|
+
resolve: resolveYamlNull,
|
|
424
|
+
construct: constructYamlNull,
|
|
425
|
+
predicate: isNull,
|
|
426
|
+
represent: {
|
|
427
|
+
canonical: function() {
|
|
428
|
+
return "~";
|
|
429
|
+
},
|
|
430
|
+
lowercase: function() {
|
|
431
|
+
return "null";
|
|
432
|
+
},
|
|
433
|
+
uppercase: function() {
|
|
434
|
+
return "NULL";
|
|
435
|
+
},
|
|
436
|
+
camelcase: function() {
|
|
437
|
+
return "Null";
|
|
438
|
+
},
|
|
439
|
+
empty: function() {
|
|
440
|
+
return "";
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
defaultStyle: "lowercase"
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// node_modules/js-yaml/lib/type/bool.js
|
|
449
|
+
var require_bool = __commonJS({
|
|
450
|
+
"node_modules/js-yaml/lib/type/bool.js"(exports2, module2) {
|
|
451
|
+
"use strict";
|
|
452
|
+
var Type = require_type();
|
|
453
|
+
function resolveYamlBoolean(data) {
|
|
454
|
+
if (data === null) return false;
|
|
455
|
+
var max = data.length;
|
|
456
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
457
|
+
}
|
|
458
|
+
function constructYamlBoolean(data) {
|
|
459
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
460
|
+
}
|
|
461
|
+
function isBoolean(object2) {
|
|
462
|
+
return Object.prototype.toString.call(object2) === "[object Boolean]";
|
|
463
|
+
}
|
|
464
|
+
module2.exports = new Type("tag:yaml.org,2002:bool", {
|
|
465
|
+
kind: "scalar",
|
|
466
|
+
resolve: resolveYamlBoolean,
|
|
467
|
+
construct: constructYamlBoolean,
|
|
468
|
+
predicate: isBoolean,
|
|
469
|
+
represent: {
|
|
470
|
+
lowercase: function(object2) {
|
|
471
|
+
return object2 ? "true" : "false";
|
|
472
|
+
},
|
|
473
|
+
uppercase: function(object2) {
|
|
474
|
+
return object2 ? "TRUE" : "FALSE";
|
|
475
|
+
},
|
|
476
|
+
camelcase: function(object2) {
|
|
477
|
+
return object2 ? "True" : "False";
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
defaultStyle: "lowercase"
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// node_modules/js-yaml/lib/type/int.js
|
|
486
|
+
var require_int = __commonJS({
|
|
487
|
+
"node_modules/js-yaml/lib/type/int.js"(exports2, module2) {
|
|
488
|
+
"use strict";
|
|
489
|
+
var common = require_common();
|
|
490
|
+
var Type = require_type();
|
|
491
|
+
function isHexCode(c) {
|
|
492
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
493
|
+
}
|
|
494
|
+
function isOctCode(c) {
|
|
495
|
+
return 48 <= c && c <= 55;
|
|
496
|
+
}
|
|
497
|
+
function isDecCode(c) {
|
|
498
|
+
return 48 <= c && c <= 57;
|
|
499
|
+
}
|
|
500
|
+
function resolveYamlInteger(data) {
|
|
501
|
+
if (data === null) return false;
|
|
502
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
503
|
+
if (!max) return false;
|
|
504
|
+
ch = data[index];
|
|
505
|
+
if (ch === "-" || ch === "+") {
|
|
506
|
+
ch = data[++index];
|
|
507
|
+
}
|
|
508
|
+
if (ch === "0") {
|
|
509
|
+
if (index + 1 === max) return true;
|
|
510
|
+
ch = data[++index];
|
|
511
|
+
if (ch === "b") {
|
|
512
|
+
index++;
|
|
513
|
+
for (; index < max; index++) {
|
|
514
|
+
ch = data[index];
|
|
515
|
+
if (ch === "_") continue;
|
|
516
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
517
|
+
hasDigits = true;
|
|
518
|
+
}
|
|
519
|
+
return hasDigits && ch !== "_";
|
|
520
|
+
}
|
|
521
|
+
if (ch === "x") {
|
|
522
|
+
index++;
|
|
523
|
+
for (; index < max; index++) {
|
|
524
|
+
ch = data[index];
|
|
525
|
+
if (ch === "_") continue;
|
|
526
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
527
|
+
hasDigits = true;
|
|
528
|
+
}
|
|
529
|
+
return hasDigits && ch !== "_";
|
|
530
|
+
}
|
|
531
|
+
if (ch === "o") {
|
|
532
|
+
index++;
|
|
533
|
+
for (; index < max; index++) {
|
|
534
|
+
ch = data[index];
|
|
535
|
+
if (ch === "_") continue;
|
|
536
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
537
|
+
hasDigits = true;
|
|
538
|
+
}
|
|
539
|
+
return hasDigits && ch !== "_";
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (ch === "_") return false;
|
|
543
|
+
for (; index < max; index++) {
|
|
544
|
+
ch = data[index];
|
|
545
|
+
if (ch === "_") continue;
|
|
546
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
hasDigits = true;
|
|
550
|
+
}
|
|
551
|
+
if (!hasDigits || ch === "_") return false;
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
function constructYamlInteger(data) {
|
|
555
|
+
var value = data, sign = 1, ch;
|
|
556
|
+
if (value.indexOf("_") !== -1) {
|
|
557
|
+
value = value.replace(/_/g, "");
|
|
558
|
+
}
|
|
559
|
+
ch = value[0];
|
|
560
|
+
if (ch === "-" || ch === "+") {
|
|
561
|
+
if (ch === "-") sign = -1;
|
|
562
|
+
value = value.slice(1);
|
|
563
|
+
ch = value[0];
|
|
564
|
+
}
|
|
565
|
+
if (value === "0") return 0;
|
|
566
|
+
if (ch === "0") {
|
|
567
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
568
|
+
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
569
|
+
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
570
|
+
}
|
|
571
|
+
return sign * parseInt(value, 10);
|
|
572
|
+
}
|
|
573
|
+
function isInteger(object2) {
|
|
574
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 === 0 && !common.isNegativeZero(object2));
|
|
575
|
+
}
|
|
576
|
+
module2.exports = new Type("tag:yaml.org,2002:int", {
|
|
577
|
+
kind: "scalar",
|
|
578
|
+
resolve: resolveYamlInteger,
|
|
579
|
+
construct: constructYamlInteger,
|
|
580
|
+
predicate: isInteger,
|
|
581
|
+
represent: {
|
|
582
|
+
binary: function(obj) {
|
|
583
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
584
|
+
},
|
|
585
|
+
octal: function(obj) {
|
|
586
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
587
|
+
},
|
|
588
|
+
decimal: function(obj) {
|
|
589
|
+
return obj.toString(10);
|
|
590
|
+
},
|
|
591
|
+
/* eslint-disable max-len */
|
|
592
|
+
hexadecimal: function(obj) {
|
|
593
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
defaultStyle: "decimal",
|
|
597
|
+
styleAliases: {
|
|
598
|
+
binary: [2, "bin"],
|
|
599
|
+
octal: [8, "oct"],
|
|
600
|
+
decimal: [10, "dec"],
|
|
601
|
+
hexadecimal: [16, "hex"]
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
// node_modules/js-yaml/lib/type/float.js
|
|
608
|
+
var require_float = __commonJS({
|
|
609
|
+
"node_modules/js-yaml/lib/type/float.js"(exports2, module2) {
|
|
610
|
+
"use strict";
|
|
611
|
+
var common = require_common();
|
|
612
|
+
var Type = require_type();
|
|
613
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
614
|
+
// 2.5e4, 2.5 and integers
|
|
615
|
+
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
616
|
+
);
|
|
617
|
+
function resolveYamlFloat(data) {
|
|
618
|
+
if (data === null) return false;
|
|
619
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
620
|
+
// Probably should update regexp & check speed
|
|
621
|
+
data[data.length - 1] === "_") {
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
function constructYamlFloat(data) {
|
|
627
|
+
var value, sign;
|
|
628
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
629
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
630
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
631
|
+
value = value.slice(1);
|
|
632
|
+
}
|
|
633
|
+
if (value === ".inf") {
|
|
634
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
635
|
+
} else if (value === ".nan") {
|
|
636
|
+
return NaN;
|
|
637
|
+
}
|
|
638
|
+
return sign * parseFloat(value, 10);
|
|
639
|
+
}
|
|
640
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
641
|
+
function representYamlFloat(object2, style) {
|
|
642
|
+
var res;
|
|
643
|
+
if (isNaN(object2)) {
|
|
644
|
+
switch (style) {
|
|
645
|
+
case "lowercase":
|
|
646
|
+
return ".nan";
|
|
647
|
+
case "uppercase":
|
|
648
|
+
return ".NAN";
|
|
649
|
+
case "camelcase":
|
|
650
|
+
return ".NaN";
|
|
651
|
+
}
|
|
652
|
+
} else if (Number.POSITIVE_INFINITY === object2) {
|
|
653
|
+
switch (style) {
|
|
654
|
+
case "lowercase":
|
|
655
|
+
return ".inf";
|
|
656
|
+
case "uppercase":
|
|
657
|
+
return ".INF";
|
|
658
|
+
case "camelcase":
|
|
659
|
+
return ".Inf";
|
|
660
|
+
}
|
|
661
|
+
} else if (Number.NEGATIVE_INFINITY === object2) {
|
|
662
|
+
switch (style) {
|
|
663
|
+
case "lowercase":
|
|
664
|
+
return "-.inf";
|
|
665
|
+
case "uppercase":
|
|
666
|
+
return "-.INF";
|
|
667
|
+
case "camelcase":
|
|
668
|
+
return "-.Inf";
|
|
669
|
+
}
|
|
670
|
+
} else if (common.isNegativeZero(object2)) {
|
|
671
|
+
return "-0.0";
|
|
672
|
+
}
|
|
673
|
+
res = object2.toString(10);
|
|
674
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
675
|
+
}
|
|
676
|
+
function isFloat(object2) {
|
|
677
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 !== 0 || common.isNegativeZero(object2));
|
|
678
|
+
}
|
|
679
|
+
module2.exports = new Type("tag:yaml.org,2002:float", {
|
|
680
|
+
kind: "scalar",
|
|
681
|
+
resolve: resolveYamlFloat,
|
|
682
|
+
construct: constructYamlFloat,
|
|
683
|
+
predicate: isFloat,
|
|
684
|
+
represent: representYamlFloat,
|
|
685
|
+
defaultStyle: "lowercase"
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
// node_modules/js-yaml/lib/schema/json.js
|
|
691
|
+
var require_json = __commonJS({
|
|
692
|
+
"node_modules/js-yaml/lib/schema/json.js"(exports2, module2) {
|
|
693
|
+
"use strict";
|
|
694
|
+
module2.exports = require_failsafe().extend({
|
|
695
|
+
implicit: [
|
|
696
|
+
require_null(),
|
|
697
|
+
require_bool(),
|
|
698
|
+
require_int(),
|
|
699
|
+
require_float()
|
|
700
|
+
]
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
// node_modules/js-yaml/lib/schema/core.js
|
|
706
|
+
var require_core = __commonJS({
|
|
707
|
+
"node_modules/js-yaml/lib/schema/core.js"(exports2, module2) {
|
|
708
|
+
"use strict";
|
|
709
|
+
module2.exports = require_json();
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
// node_modules/js-yaml/lib/type/timestamp.js
|
|
714
|
+
var require_timestamp = __commonJS({
|
|
715
|
+
"node_modules/js-yaml/lib/type/timestamp.js"(exports2, module2) {
|
|
716
|
+
"use strict";
|
|
717
|
+
var Type = require_type();
|
|
718
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
719
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
720
|
+
);
|
|
721
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
722
|
+
"^([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]))?))?$"
|
|
723
|
+
);
|
|
724
|
+
function resolveYamlTimestamp(data) {
|
|
725
|
+
if (data === null) return false;
|
|
726
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
727
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
function constructYamlTimestamp(data) {
|
|
731
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date5;
|
|
732
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
733
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
734
|
+
if (match === null) throw new Error("Date resolve error");
|
|
735
|
+
year = +match[1];
|
|
736
|
+
month = +match[2] - 1;
|
|
737
|
+
day = +match[3];
|
|
738
|
+
if (!match[4]) {
|
|
739
|
+
return new Date(Date.UTC(year, month, day));
|
|
740
|
+
}
|
|
741
|
+
hour = +match[4];
|
|
742
|
+
minute = +match[5];
|
|
743
|
+
second = +match[6];
|
|
744
|
+
if (match[7]) {
|
|
745
|
+
fraction = match[7].slice(0, 3);
|
|
746
|
+
while (fraction.length < 3) {
|
|
747
|
+
fraction += "0";
|
|
748
|
+
}
|
|
749
|
+
fraction = +fraction;
|
|
750
|
+
}
|
|
751
|
+
if (match[9]) {
|
|
752
|
+
tz_hour = +match[10];
|
|
753
|
+
tz_minute = +(match[11] || 0);
|
|
754
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
755
|
+
if (match[9] === "-") delta = -delta;
|
|
756
|
+
}
|
|
757
|
+
date5 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
758
|
+
if (delta) date5.setTime(date5.getTime() - delta);
|
|
759
|
+
return date5;
|
|
760
|
+
}
|
|
761
|
+
function representYamlTimestamp(object2) {
|
|
762
|
+
return object2.toISOString();
|
|
763
|
+
}
|
|
764
|
+
module2.exports = new Type("tag:yaml.org,2002:timestamp", {
|
|
765
|
+
kind: "scalar",
|
|
766
|
+
resolve: resolveYamlTimestamp,
|
|
767
|
+
construct: constructYamlTimestamp,
|
|
768
|
+
instanceOf: Date,
|
|
769
|
+
represent: representYamlTimestamp
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
// node_modules/js-yaml/lib/type/merge.js
|
|
775
|
+
var require_merge = __commonJS({
|
|
776
|
+
"node_modules/js-yaml/lib/type/merge.js"(exports2, module2) {
|
|
777
|
+
"use strict";
|
|
778
|
+
var Type = require_type();
|
|
779
|
+
function resolveYamlMerge(data) {
|
|
780
|
+
return data === "<<" || data === null;
|
|
781
|
+
}
|
|
782
|
+
module2.exports = new Type("tag:yaml.org,2002:merge", {
|
|
783
|
+
kind: "scalar",
|
|
784
|
+
resolve: resolveYamlMerge
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// node_modules/js-yaml/lib/type/binary.js
|
|
790
|
+
var require_binary = __commonJS({
|
|
791
|
+
"node_modules/js-yaml/lib/type/binary.js"(exports2, module2) {
|
|
792
|
+
"use strict";
|
|
793
|
+
var Type = require_type();
|
|
794
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
795
|
+
function resolveYamlBinary(data) {
|
|
796
|
+
if (data === null) return false;
|
|
797
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
798
|
+
for (idx = 0; idx < max; idx++) {
|
|
799
|
+
code = map2.indexOf(data.charAt(idx));
|
|
800
|
+
if (code > 64) continue;
|
|
801
|
+
if (code < 0) return false;
|
|
802
|
+
bitlen += 6;
|
|
803
|
+
}
|
|
804
|
+
return bitlen % 8 === 0;
|
|
805
|
+
}
|
|
806
|
+
function constructYamlBinary(data) {
|
|
807
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
808
|
+
for (idx = 0; idx < max; idx++) {
|
|
809
|
+
if (idx % 4 === 0 && idx) {
|
|
810
|
+
result.push(bits >> 16 & 255);
|
|
811
|
+
result.push(bits >> 8 & 255);
|
|
812
|
+
result.push(bits & 255);
|
|
813
|
+
}
|
|
814
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
815
|
+
}
|
|
816
|
+
tailbits = max % 4 * 6;
|
|
817
|
+
if (tailbits === 0) {
|
|
818
|
+
result.push(bits >> 16 & 255);
|
|
819
|
+
result.push(bits >> 8 & 255);
|
|
820
|
+
result.push(bits & 255);
|
|
821
|
+
} else if (tailbits === 18) {
|
|
822
|
+
result.push(bits >> 10 & 255);
|
|
823
|
+
result.push(bits >> 2 & 255);
|
|
824
|
+
} else if (tailbits === 12) {
|
|
825
|
+
result.push(bits >> 4 & 255);
|
|
826
|
+
}
|
|
827
|
+
return new Uint8Array(result);
|
|
828
|
+
}
|
|
829
|
+
function representYamlBinary(object2) {
|
|
830
|
+
var result = "", bits = 0, idx, tail, max = object2.length, map2 = BASE64_MAP;
|
|
831
|
+
for (idx = 0; idx < max; idx++) {
|
|
832
|
+
if (idx % 3 === 0 && idx) {
|
|
833
|
+
result += map2[bits >> 18 & 63];
|
|
834
|
+
result += map2[bits >> 12 & 63];
|
|
835
|
+
result += map2[bits >> 6 & 63];
|
|
836
|
+
result += map2[bits & 63];
|
|
837
|
+
}
|
|
838
|
+
bits = (bits << 8) + object2[idx];
|
|
839
|
+
}
|
|
840
|
+
tail = max % 3;
|
|
841
|
+
if (tail === 0) {
|
|
842
|
+
result += map2[bits >> 18 & 63];
|
|
843
|
+
result += map2[bits >> 12 & 63];
|
|
844
|
+
result += map2[bits >> 6 & 63];
|
|
845
|
+
result += map2[bits & 63];
|
|
846
|
+
} else if (tail === 2) {
|
|
847
|
+
result += map2[bits >> 10 & 63];
|
|
848
|
+
result += map2[bits >> 4 & 63];
|
|
849
|
+
result += map2[bits << 2 & 63];
|
|
850
|
+
result += map2[64];
|
|
851
|
+
} else if (tail === 1) {
|
|
852
|
+
result += map2[bits >> 2 & 63];
|
|
853
|
+
result += map2[bits << 4 & 63];
|
|
854
|
+
result += map2[64];
|
|
855
|
+
result += map2[64];
|
|
856
|
+
}
|
|
857
|
+
return result;
|
|
858
|
+
}
|
|
859
|
+
function isBinary(obj) {
|
|
860
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
861
|
+
}
|
|
862
|
+
module2.exports = new Type("tag:yaml.org,2002:binary", {
|
|
863
|
+
kind: "scalar",
|
|
864
|
+
resolve: resolveYamlBinary,
|
|
865
|
+
construct: constructYamlBinary,
|
|
866
|
+
predicate: isBinary,
|
|
867
|
+
represent: representYamlBinary
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// node_modules/js-yaml/lib/type/omap.js
|
|
873
|
+
var require_omap = __commonJS({
|
|
874
|
+
"node_modules/js-yaml/lib/type/omap.js"(exports2, module2) {
|
|
875
|
+
"use strict";
|
|
876
|
+
var Type = require_type();
|
|
877
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
878
|
+
var _toString = Object.prototype.toString;
|
|
879
|
+
function resolveYamlOmap(data) {
|
|
880
|
+
if (data === null) return true;
|
|
881
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object2 = data;
|
|
882
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
883
|
+
pair = object2[index];
|
|
884
|
+
pairHasKey = false;
|
|
885
|
+
if (_toString.call(pair) !== "[object Object]") return false;
|
|
886
|
+
for (pairKey in pair) {
|
|
887
|
+
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
888
|
+
if (!pairHasKey) pairHasKey = true;
|
|
889
|
+
else return false;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (!pairHasKey) return false;
|
|
893
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
894
|
+
else return false;
|
|
895
|
+
}
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
function constructYamlOmap(data) {
|
|
899
|
+
return data !== null ? data : [];
|
|
900
|
+
}
|
|
901
|
+
module2.exports = new Type("tag:yaml.org,2002:omap", {
|
|
902
|
+
kind: "sequence",
|
|
903
|
+
resolve: resolveYamlOmap,
|
|
904
|
+
construct: constructYamlOmap
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
// node_modules/js-yaml/lib/type/pairs.js
|
|
910
|
+
var require_pairs = __commonJS({
|
|
911
|
+
"node_modules/js-yaml/lib/type/pairs.js"(exports2, module2) {
|
|
912
|
+
"use strict";
|
|
913
|
+
var Type = require_type();
|
|
914
|
+
var _toString = Object.prototype.toString;
|
|
915
|
+
function resolveYamlPairs(data) {
|
|
916
|
+
if (data === null) return true;
|
|
917
|
+
var index, length, pair, keys, result, object2 = data;
|
|
918
|
+
result = new Array(object2.length);
|
|
919
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
920
|
+
pair = object2[index];
|
|
921
|
+
if (_toString.call(pair) !== "[object Object]") return false;
|
|
922
|
+
keys = Object.keys(pair);
|
|
923
|
+
if (keys.length !== 1) return false;
|
|
924
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
925
|
+
}
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
function constructYamlPairs(data) {
|
|
929
|
+
if (data === null) return [];
|
|
930
|
+
var index, length, pair, keys, result, object2 = data;
|
|
931
|
+
result = new Array(object2.length);
|
|
932
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
933
|
+
pair = object2[index];
|
|
934
|
+
keys = Object.keys(pair);
|
|
935
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
936
|
+
}
|
|
937
|
+
return result;
|
|
938
|
+
}
|
|
939
|
+
module2.exports = new Type("tag:yaml.org,2002:pairs", {
|
|
940
|
+
kind: "sequence",
|
|
941
|
+
resolve: resolveYamlPairs,
|
|
942
|
+
construct: constructYamlPairs
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
// node_modules/js-yaml/lib/type/set.js
|
|
948
|
+
var require_set = __commonJS({
|
|
949
|
+
"node_modules/js-yaml/lib/type/set.js"(exports2, module2) {
|
|
950
|
+
"use strict";
|
|
951
|
+
var Type = require_type();
|
|
952
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
953
|
+
function resolveYamlSet(data) {
|
|
954
|
+
if (data === null) return true;
|
|
955
|
+
var key, object2 = data;
|
|
956
|
+
for (key in object2) {
|
|
957
|
+
if (_hasOwnProperty.call(object2, key)) {
|
|
958
|
+
if (object2[key] !== null) return false;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return true;
|
|
962
|
+
}
|
|
963
|
+
function constructYamlSet(data) {
|
|
964
|
+
return data !== null ? data : {};
|
|
965
|
+
}
|
|
966
|
+
module2.exports = new Type("tag:yaml.org,2002:set", {
|
|
967
|
+
kind: "mapping",
|
|
968
|
+
resolve: resolveYamlSet,
|
|
969
|
+
construct: constructYamlSet
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
// node_modules/js-yaml/lib/schema/default.js
|
|
975
|
+
var require_default = __commonJS({
|
|
976
|
+
"node_modules/js-yaml/lib/schema/default.js"(exports2, module2) {
|
|
977
|
+
"use strict";
|
|
978
|
+
module2.exports = require_core().extend({
|
|
979
|
+
implicit: [
|
|
980
|
+
require_timestamp(),
|
|
981
|
+
require_merge()
|
|
982
|
+
],
|
|
983
|
+
explicit: [
|
|
984
|
+
require_binary(),
|
|
985
|
+
require_omap(),
|
|
986
|
+
require_pairs(),
|
|
987
|
+
require_set()
|
|
988
|
+
]
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
// node_modules/js-yaml/lib/loader.js
|
|
994
|
+
var require_loader = __commonJS({
|
|
995
|
+
"node_modules/js-yaml/lib/loader.js"(exports2, module2) {
|
|
996
|
+
"use strict";
|
|
997
|
+
var common = require_common();
|
|
998
|
+
var YAMLException = require_exception();
|
|
999
|
+
var makeSnippet = require_snippet();
|
|
1000
|
+
var DEFAULT_SCHEMA = require_default();
|
|
1001
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1002
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1003
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1004
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1005
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1006
|
+
var CHOMPING_CLIP = 1;
|
|
1007
|
+
var CHOMPING_STRIP = 2;
|
|
1008
|
+
var CHOMPING_KEEP = 3;
|
|
1009
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1010
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1011
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1012
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1013
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1014
|
+
function _class(obj) {
|
|
1015
|
+
return Object.prototype.toString.call(obj);
|
|
1016
|
+
}
|
|
1017
|
+
function is_EOL(c) {
|
|
1018
|
+
return c === 10 || c === 13;
|
|
1019
|
+
}
|
|
1020
|
+
function is_WHITE_SPACE(c) {
|
|
1021
|
+
return c === 9 || c === 32;
|
|
1022
|
+
}
|
|
1023
|
+
function is_WS_OR_EOL(c) {
|
|
1024
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1025
|
+
}
|
|
1026
|
+
function is_FLOW_INDICATOR(c) {
|
|
1027
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1028
|
+
}
|
|
1029
|
+
function fromHexCode(c) {
|
|
1030
|
+
var lc;
|
|
1031
|
+
if (48 <= c && c <= 57) {
|
|
1032
|
+
return c - 48;
|
|
1033
|
+
}
|
|
1034
|
+
lc = c | 32;
|
|
1035
|
+
if (97 <= lc && lc <= 102) {
|
|
1036
|
+
return lc - 97 + 10;
|
|
1037
|
+
}
|
|
1038
|
+
return -1;
|
|
1039
|
+
}
|
|
1040
|
+
function escapedHexLen(c) {
|
|
1041
|
+
if (c === 120) {
|
|
1042
|
+
return 2;
|
|
1043
|
+
}
|
|
1044
|
+
if (c === 117) {
|
|
1045
|
+
return 4;
|
|
1046
|
+
}
|
|
1047
|
+
if (c === 85) {
|
|
1048
|
+
return 8;
|
|
1049
|
+
}
|
|
1050
|
+
return 0;
|
|
1051
|
+
}
|
|
1052
|
+
function fromDecimalCode(c) {
|
|
1053
|
+
if (48 <= c && c <= 57) {
|
|
1054
|
+
return c - 48;
|
|
1055
|
+
}
|
|
1056
|
+
return -1;
|
|
1057
|
+
}
|
|
1058
|
+
function simpleEscapeSequence(c) {
|
|
1059
|
+
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" : "";
|
|
1060
|
+
}
|
|
1061
|
+
function charFromCodepoint(c) {
|
|
1062
|
+
if (c <= 65535) {
|
|
1063
|
+
return String.fromCharCode(c);
|
|
1064
|
+
}
|
|
1065
|
+
return String.fromCharCode(
|
|
1066
|
+
(c - 65536 >> 10) + 55296,
|
|
1067
|
+
(c - 65536 & 1023) + 56320
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
function setProperty(object2, key, value) {
|
|
1071
|
+
if (key === "__proto__") {
|
|
1072
|
+
Object.defineProperty(object2, key, {
|
|
1073
|
+
configurable: true,
|
|
1074
|
+
enumerable: true,
|
|
1075
|
+
writable: true,
|
|
1076
|
+
value
|
|
1077
|
+
});
|
|
1078
|
+
} else {
|
|
1079
|
+
object2[key] = value;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
var simpleEscapeCheck = new Array(256);
|
|
1083
|
+
var simpleEscapeMap = new Array(256);
|
|
1084
|
+
for (i = 0; i < 256; i++) {
|
|
1085
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1086
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1087
|
+
}
|
|
1088
|
+
var i;
|
|
1089
|
+
function State(input, options) {
|
|
1090
|
+
this.input = input;
|
|
1091
|
+
this.filename = options["filename"] || null;
|
|
1092
|
+
this.schema = options["schema"] || DEFAULT_SCHEMA;
|
|
1093
|
+
this.onWarning = options["onWarning"] || null;
|
|
1094
|
+
this.legacy = options["legacy"] || false;
|
|
1095
|
+
this.json = options["json"] || false;
|
|
1096
|
+
this.listener = options["listener"] || null;
|
|
1097
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1098
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1099
|
+
this.length = input.length;
|
|
1100
|
+
this.position = 0;
|
|
1101
|
+
this.line = 0;
|
|
1102
|
+
this.lineStart = 0;
|
|
1103
|
+
this.lineIndent = 0;
|
|
1104
|
+
this.firstTabInLine = -1;
|
|
1105
|
+
this.documents = [];
|
|
1106
|
+
}
|
|
1107
|
+
function generateError(state, message) {
|
|
1108
|
+
var mark = {
|
|
1109
|
+
name: state.filename,
|
|
1110
|
+
buffer: state.input.slice(0, -1),
|
|
1111
|
+
// omit trailing \0
|
|
1112
|
+
position: state.position,
|
|
1113
|
+
line: state.line,
|
|
1114
|
+
column: state.position - state.lineStart
|
|
1115
|
+
};
|
|
1116
|
+
mark.snippet = makeSnippet(mark);
|
|
1117
|
+
return new YAMLException(message, mark);
|
|
1118
|
+
}
|
|
1119
|
+
function throwError(state, message) {
|
|
1120
|
+
throw generateError(state, message);
|
|
1121
|
+
}
|
|
1122
|
+
function throwWarning(state, message) {
|
|
1123
|
+
if (state.onWarning) {
|
|
1124
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
var directiveHandlers = {
|
|
1128
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1129
|
+
var match, major, minor;
|
|
1130
|
+
if (state.version !== null) {
|
|
1131
|
+
throwError(state, "duplication of %YAML directive");
|
|
1132
|
+
}
|
|
1133
|
+
if (args.length !== 1) {
|
|
1134
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1135
|
+
}
|
|
1136
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1137
|
+
if (match === null) {
|
|
1138
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1139
|
+
}
|
|
1140
|
+
major = parseInt(match[1], 10);
|
|
1141
|
+
minor = parseInt(match[2], 10);
|
|
1142
|
+
if (major !== 1) {
|
|
1143
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1144
|
+
}
|
|
1145
|
+
state.version = args[0];
|
|
1146
|
+
state.checkLineBreaks = minor < 2;
|
|
1147
|
+
if (minor !== 1 && minor !== 2) {
|
|
1148
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1152
|
+
var handle, prefix;
|
|
1153
|
+
if (args.length !== 2) {
|
|
1154
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1155
|
+
}
|
|
1156
|
+
handle = args[0];
|
|
1157
|
+
prefix = args[1];
|
|
1158
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1159
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1160
|
+
}
|
|
1161
|
+
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
1162
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1163
|
+
}
|
|
1164
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1165
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1166
|
+
}
|
|
1167
|
+
try {
|
|
1168
|
+
prefix = decodeURIComponent(prefix);
|
|
1169
|
+
} catch (err) {
|
|
1170
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1171
|
+
}
|
|
1172
|
+
state.tagMap[handle] = prefix;
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1176
|
+
var _position, _length2, _character, _result;
|
|
1177
|
+
if (start < end) {
|
|
1178
|
+
_result = state.input.slice(start, end);
|
|
1179
|
+
if (checkJson) {
|
|
1180
|
+
for (_position = 0, _length2 = _result.length; _position < _length2; _position += 1) {
|
|
1181
|
+
_character = _result.charCodeAt(_position);
|
|
1182
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1183
|
+
throwError(state, "expected valid JSON character");
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1187
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1188
|
+
}
|
|
1189
|
+
state.result += _result;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1193
|
+
var sourceKeys, key, index, quantity;
|
|
1194
|
+
if (!common.isObject(source)) {
|
|
1195
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1196
|
+
}
|
|
1197
|
+
sourceKeys = Object.keys(source);
|
|
1198
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1199
|
+
key = sourceKeys[index];
|
|
1200
|
+
if (!_hasOwnProperty.call(destination, key)) {
|
|
1201
|
+
setProperty(destination, key, source[key]);
|
|
1202
|
+
overridableKeys[key] = true;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1207
|
+
var index, quantity;
|
|
1208
|
+
if (Array.isArray(keyNode)) {
|
|
1209
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1210
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1211
|
+
if (Array.isArray(keyNode[index])) {
|
|
1212
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1213
|
+
}
|
|
1214
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1215
|
+
keyNode[index] = "[object Object]";
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1220
|
+
keyNode = "[object Object]";
|
|
1221
|
+
}
|
|
1222
|
+
keyNode = String(keyNode);
|
|
1223
|
+
if (_result === null) {
|
|
1224
|
+
_result = {};
|
|
1225
|
+
}
|
|
1226
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1227
|
+
if (Array.isArray(valueNode)) {
|
|
1228
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1229
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1230
|
+
}
|
|
1231
|
+
} else {
|
|
1232
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1233
|
+
}
|
|
1234
|
+
} else {
|
|
1235
|
+
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
1236
|
+
state.line = startLine || state.line;
|
|
1237
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1238
|
+
state.position = startPos || state.position;
|
|
1239
|
+
throwError(state, "duplicated mapping key");
|
|
1240
|
+
}
|
|
1241
|
+
setProperty(_result, keyNode, valueNode);
|
|
1242
|
+
delete overridableKeys[keyNode];
|
|
1243
|
+
}
|
|
1244
|
+
return _result;
|
|
1245
|
+
}
|
|
1246
|
+
function readLineBreak(state) {
|
|
1247
|
+
var ch;
|
|
1248
|
+
ch = state.input.charCodeAt(state.position);
|
|
1249
|
+
if (ch === 10) {
|
|
1250
|
+
state.position++;
|
|
1251
|
+
} else if (ch === 13) {
|
|
1252
|
+
state.position++;
|
|
1253
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1254
|
+
state.position++;
|
|
1255
|
+
}
|
|
1256
|
+
} else {
|
|
1257
|
+
throwError(state, "a line break is expected");
|
|
1258
|
+
}
|
|
1259
|
+
state.line += 1;
|
|
1260
|
+
state.lineStart = state.position;
|
|
1261
|
+
state.firstTabInLine = -1;
|
|
1262
|
+
}
|
|
1263
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1264
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1265
|
+
while (ch !== 0) {
|
|
1266
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1267
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1268
|
+
state.firstTabInLine = state.position;
|
|
1269
|
+
}
|
|
1270
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1271
|
+
}
|
|
1272
|
+
if (allowComments && ch === 35) {
|
|
1273
|
+
do {
|
|
1274
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1275
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1276
|
+
}
|
|
1277
|
+
if (is_EOL(ch)) {
|
|
1278
|
+
readLineBreak(state);
|
|
1279
|
+
ch = state.input.charCodeAt(state.position);
|
|
1280
|
+
lineBreaks++;
|
|
1281
|
+
state.lineIndent = 0;
|
|
1282
|
+
while (ch === 32) {
|
|
1283
|
+
state.lineIndent++;
|
|
1284
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1285
|
+
}
|
|
1286
|
+
} else {
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1291
|
+
throwWarning(state, "deficient indentation");
|
|
1292
|
+
}
|
|
1293
|
+
return lineBreaks;
|
|
1294
|
+
}
|
|
1295
|
+
function testDocumentSeparator(state) {
|
|
1296
|
+
var _position = state.position, ch;
|
|
1297
|
+
ch = state.input.charCodeAt(_position);
|
|
1298
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1299
|
+
_position += 3;
|
|
1300
|
+
ch = state.input.charCodeAt(_position);
|
|
1301
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1302
|
+
return true;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
return false;
|
|
1306
|
+
}
|
|
1307
|
+
function writeFoldedLines(state, count) {
|
|
1308
|
+
if (count === 1) {
|
|
1309
|
+
state.result += " ";
|
|
1310
|
+
} else if (count > 1) {
|
|
1311
|
+
state.result += common.repeat("\n", count - 1);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1315
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1316
|
+
ch = state.input.charCodeAt(state.position);
|
|
1317
|
+
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) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
if (ch === 63 || ch === 45) {
|
|
1321
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1322
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
state.kind = "scalar";
|
|
1327
|
+
state.result = "";
|
|
1328
|
+
captureStart = captureEnd = state.position;
|
|
1329
|
+
hasPendingContent = false;
|
|
1330
|
+
while (ch !== 0) {
|
|
1331
|
+
if (ch === 58) {
|
|
1332
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1333
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
} else if (ch === 35) {
|
|
1337
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1338
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1342
|
+
break;
|
|
1343
|
+
} else if (is_EOL(ch)) {
|
|
1344
|
+
_line = state.line;
|
|
1345
|
+
_lineStart = state.lineStart;
|
|
1346
|
+
_lineIndent = state.lineIndent;
|
|
1347
|
+
skipSeparationSpace(state, false, -1);
|
|
1348
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1349
|
+
hasPendingContent = true;
|
|
1350
|
+
ch = state.input.charCodeAt(state.position);
|
|
1351
|
+
continue;
|
|
1352
|
+
} else {
|
|
1353
|
+
state.position = captureEnd;
|
|
1354
|
+
state.line = _line;
|
|
1355
|
+
state.lineStart = _lineStart;
|
|
1356
|
+
state.lineIndent = _lineIndent;
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
if (hasPendingContent) {
|
|
1361
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1362
|
+
writeFoldedLines(state, state.line - _line);
|
|
1363
|
+
captureStart = captureEnd = state.position;
|
|
1364
|
+
hasPendingContent = false;
|
|
1365
|
+
}
|
|
1366
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1367
|
+
captureEnd = state.position + 1;
|
|
1368
|
+
}
|
|
1369
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1370
|
+
}
|
|
1371
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1372
|
+
if (state.result) {
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1375
|
+
state.kind = _kind;
|
|
1376
|
+
state.result = _result;
|
|
1377
|
+
return false;
|
|
1378
|
+
}
|
|
1379
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1380
|
+
var ch, captureStart, captureEnd;
|
|
1381
|
+
ch = state.input.charCodeAt(state.position);
|
|
1382
|
+
if (ch !== 39) {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
state.kind = "scalar";
|
|
1386
|
+
state.result = "";
|
|
1387
|
+
state.position++;
|
|
1388
|
+
captureStart = captureEnd = state.position;
|
|
1389
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1390
|
+
if (ch === 39) {
|
|
1391
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1392
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1393
|
+
if (ch === 39) {
|
|
1394
|
+
captureStart = state.position;
|
|
1395
|
+
state.position++;
|
|
1396
|
+
captureEnd = state.position;
|
|
1397
|
+
} else {
|
|
1398
|
+
return true;
|
|
1399
|
+
}
|
|
1400
|
+
} else if (is_EOL(ch)) {
|
|
1401
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1402
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1403
|
+
captureStart = captureEnd = state.position;
|
|
1404
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1405
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1406
|
+
} else {
|
|
1407
|
+
state.position++;
|
|
1408
|
+
captureEnd = state.position;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1412
|
+
}
|
|
1413
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1414
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1415
|
+
ch = state.input.charCodeAt(state.position);
|
|
1416
|
+
if (ch !== 34) {
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
state.kind = "scalar";
|
|
1420
|
+
state.result = "";
|
|
1421
|
+
state.position++;
|
|
1422
|
+
captureStart = captureEnd = state.position;
|
|
1423
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1424
|
+
if (ch === 34) {
|
|
1425
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1426
|
+
state.position++;
|
|
1427
|
+
return true;
|
|
1428
|
+
} else if (ch === 92) {
|
|
1429
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1430
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1431
|
+
if (is_EOL(ch)) {
|
|
1432
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1433
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1434
|
+
state.result += simpleEscapeMap[ch];
|
|
1435
|
+
state.position++;
|
|
1436
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1437
|
+
hexLength = tmp;
|
|
1438
|
+
hexResult = 0;
|
|
1439
|
+
for (; hexLength > 0; hexLength--) {
|
|
1440
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1441
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1442
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1443
|
+
} else {
|
|
1444
|
+
throwError(state, "expected hexadecimal character");
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
state.result += charFromCodepoint(hexResult);
|
|
1448
|
+
state.position++;
|
|
1449
|
+
} else {
|
|
1450
|
+
throwError(state, "unknown escape sequence");
|
|
1451
|
+
}
|
|
1452
|
+
captureStart = captureEnd = state.position;
|
|
1453
|
+
} else if (is_EOL(ch)) {
|
|
1454
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1455
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1456
|
+
captureStart = captureEnd = state.position;
|
|
1457
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1458
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1459
|
+
} else {
|
|
1460
|
+
state.position++;
|
|
1461
|
+
captureEnd = state.position;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1465
|
+
}
|
|
1466
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1467
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1468
|
+
ch = state.input.charCodeAt(state.position);
|
|
1469
|
+
if (ch === 91) {
|
|
1470
|
+
terminator = 93;
|
|
1471
|
+
isMapping = false;
|
|
1472
|
+
_result = [];
|
|
1473
|
+
} else if (ch === 123) {
|
|
1474
|
+
terminator = 125;
|
|
1475
|
+
isMapping = true;
|
|
1476
|
+
_result = {};
|
|
1477
|
+
} else {
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
if (state.anchor !== null) {
|
|
1481
|
+
state.anchorMap[state.anchor] = _result;
|
|
1482
|
+
}
|
|
1483
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1484
|
+
while (ch !== 0) {
|
|
1485
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1486
|
+
ch = state.input.charCodeAt(state.position);
|
|
1487
|
+
if (ch === terminator) {
|
|
1488
|
+
state.position++;
|
|
1489
|
+
state.tag = _tag;
|
|
1490
|
+
state.anchor = _anchor;
|
|
1491
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1492
|
+
state.result = _result;
|
|
1493
|
+
return true;
|
|
1494
|
+
} else if (!readNext) {
|
|
1495
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1496
|
+
} else if (ch === 44) {
|
|
1497
|
+
throwError(state, "expected the node content, but found ','");
|
|
1498
|
+
}
|
|
1499
|
+
keyTag = keyNode = valueNode = null;
|
|
1500
|
+
isPair = isExplicitPair = false;
|
|
1501
|
+
if (ch === 63) {
|
|
1502
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1503
|
+
if (is_WS_OR_EOL(following)) {
|
|
1504
|
+
isPair = isExplicitPair = true;
|
|
1505
|
+
state.position++;
|
|
1506
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
_line = state.line;
|
|
1510
|
+
_lineStart = state.lineStart;
|
|
1511
|
+
_pos = state.position;
|
|
1512
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1513
|
+
keyTag = state.tag;
|
|
1514
|
+
keyNode = state.result;
|
|
1515
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1516
|
+
ch = state.input.charCodeAt(state.position);
|
|
1517
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1518
|
+
isPair = true;
|
|
1519
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1520
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1521
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1522
|
+
valueNode = state.result;
|
|
1523
|
+
}
|
|
1524
|
+
if (isMapping) {
|
|
1525
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1526
|
+
} else if (isPair) {
|
|
1527
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1528
|
+
} else {
|
|
1529
|
+
_result.push(keyNode);
|
|
1530
|
+
}
|
|
1531
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1532
|
+
ch = state.input.charCodeAt(state.position);
|
|
1533
|
+
if (ch === 44) {
|
|
1534
|
+
readNext = true;
|
|
1535
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1536
|
+
} else {
|
|
1537
|
+
readNext = false;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1541
|
+
}
|
|
1542
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1543
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1544
|
+
ch = state.input.charCodeAt(state.position);
|
|
1545
|
+
if (ch === 124) {
|
|
1546
|
+
folding = false;
|
|
1547
|
+
} else if (ch === 62) {
|
|
1548
|
+
folding = true;
|
|
1549
|
+
} else {
|
|
1550
|
+
return false;
|
|
1551
|
+
}
|
|
1552
|
+
state.kind = "scalar";
|
|
1553
|
+
state.result = "";
|
|
1554
|
+
while (ch !== 0) {
|
|
1555
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1556
|
+
if (ch === 43 || ch === 45) {
|
|
1557
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1558
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1559
|
+
} else {
|
|
1560
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1561
|
+
}
|
|
1562
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1563
|
+
if (tmp === 0) {
|
|
1564
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1565
|
+
} else if (!detectedIndent) {
|
|
1566
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1567
|
+
detectedIndent = true;
|
|
1568
|
+
} else {
|
|
1569
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1570
|
+
}
|
|
1571
|
+
} else {
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1576
|
+
do {
|
|
1577
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1578
|
+
} while (is_WHITE_SPACE(ch));
|
|
1579
|
+
if (ch === 35) {
|
|
1580
|
+
do {
|
|
1581
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1582
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
while (ch !== 0) {
|
|
1586
|
+
readLineBreak(state);
|
|
1587
|
+
state.lineIndent = 0;
|
|
1588
|
+
ch = state.input.charCodeAt(state.position);
|
|
1589
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1590
|
+
state.lineIndent++;
|
|
1591
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1592
|
+
}
|
|
1593
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1594
|
+
textIndent = state.lineIndent;
|
|
1595
|
+
}
|
|
1596
|
+
if (is_EOL(ch)) {
|
|
1597
|
+
emptyLines++;
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1600
|
+
if (state.lineIndent < textIndent) {
|
|
1601
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1602
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1603
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1604
|
+
if (didReadContent) {
|
|
1605
|
+
state.result += "\n";
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
if (folding) {
|
|
1611
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1612
|
+
atMoreIndented = true;
|
|
1613
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1614
|
+
} else if (atMoreIndented) {
|
|
1615
|
+
atMoreIndented = false;
|
|
1616
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
1617
|
+
} else if (emptyLines === 0) {
|
|
1618
|
+
if (didReadContent) {
|
|
1619
|
+
state.result += " ";
|
|
1620
|
+
}
|
|
1621
|
+
} else {
|
|
1622
|
+
state.result += common.repeat("\n", emptyLines);
|
|
1623
|
+
}
|
|
1624
|
+
} else {
|
|
1625
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1626
|
+
}
|
|
1627
|
+
didReadContent = true;
|
|
1628
|
+
detectedIndent = true;
|
|
1629
|
+
emptyLines = 0;
|
|
1630
|
+
captureStart = state.position;
|
|
1631
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1632
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1633
|
+
}
|
|
1634
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1635
|
+
}
|
|
1636
|
+
return true;
|
|
1637
|
+
}
|
|
1638
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1639
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1640
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1641
|
+
if (state.anchor !== null) {
|
|
1642
|
+
state.anchorMap[state.anchor] = _result;
|
|
1643
|
+
}
|
|
1644
|
+
ch = state.input.charCodeAt(state.position);
|
|
1645
|
+
while (ch !== 0) {
|
|
1646
|
+
if (state.firstTabInLine !== -1) {
|
|
1647
|
+
state.position = state.firstTabInLine;
|
|
1648
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1649
|
+
}
|
|
1650
|
+
if (ch !== 45) {
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1654
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
detected = true;
|
|
1658
|
+
state.position++;
|
|
1659
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1660
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1661
|
+
_result.push(null);
|
|
1662
|
+
ch = state.input.charCodeAt(state.position);
|
|
1663
|
+
continue;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
_line = state.line;
|
|
1667
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1668
|
+
_result.push(state.result);
|
|
1669
|
+
skipSeparationSpace(state, true, -1);
|
|
1670
|
+
ch = state.input.charCodeAt(state.position);
|
|
1671
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1672
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1673
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
if (detected) {
|
|
1678
|
+
state.tag = _tag;
|
|
1679
|
+
state.anchor = _anchor;
|
|
1680
|
+
state.kind = "sequence";
|
|
1681
|
+
state.result = _result;
|
|
1682
|
+
return true;
|
|
1683
|
+
}
|
|
1684
|
+
return false;
|
|
1685
|
+
}
|
|
1686
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1687
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1688
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1689
|
+
if (state.anchor !== null) {
|
|
1690
|
+
state.anchorMap[state.anchor] = _result;
|
|
1691
|
+
}
|
|
1692
|
+
ch = state.input.charCodeAt(state.position);
|
|
1693
|
+
while (ch !== 0) {
|
|
1694
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1695
|
+
state.position = state.firstTabInLine;
|
|
1696
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1697
|
+
}
|
|
1698
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1699
|
+
_line = state.line;
|
|
1700
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1701
|
+
if (ch === 63) {
|
|
1702
|
+
if (atExplicitKey) {
|
|
1703
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1704
|
+
keyTag = keyNode = valueNode = null;
|
|
1705
|
+
}
|
|
1706
|
+
detected = true;
|
|
1707
|
+
atExplicitKey = true;
|
|
1708
|
+
allowCompact = true;
|
|
1709
|
+
} else if (atExplicitKey) {
|
|
1710
|
+
atExplicitKey = false;
|
|
1711
|
+
allowCompact = true;
|
|
1712
|
+
} else {
|
|
1713
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1714
|
+
}
|
|
1715
|
+
state.position += 1;
|
|
1716
|
+
ch = following;
|
|
1717
|
+
} else {
|
|
1718
|
+
_keyLine = state.line;
|
|
1719
|
+
_keyLineStart = state.lineStart;
|
|
1720
|
+
_keyPos = state.position;
|
|
1721
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
if (state.line === _line) {
|
|
1725
|
+
ch = state.input.charCodeAt(state.position);
|
|
1726
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1727
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1728
|
+
}
|
|
1729
|
+
if (ch === 58) {
|
|
1730
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1731
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1732
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1733
|
+
}
|
|
1734
|
+
if (atExplicitKey) {
|
|
1735
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1736
|
+
keyTag = keyNode = valueNode = null;
|
|
1737
|
+
}
|
|
1738
|
+
detected = true;
|
|
1739
|
+
atExplicitKey = false;
|
|
1740
|
+
allowCompact = false;
|
|
1741
|
+
keyTag = state.tag;
|
|
1742
|
+
keyNode = state.result;
|
|
1743
|
+
} else if (detected) {
|
|
1744
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1745
|
+
} else {
|
|
1746
|
+
state.tag = _tag;
|
|
1747
|
+
state.anchor = _anchor;
|
|
1748
|
+
return true;
|
|
1749
|
+
}
|
|
1750
|
+
} else if (detected) {
|
|
1751
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1752
|
+
} else {
|
|
1753
|
+
state.tag = _tag;
|
|
1754
|
+
state.anchor = _anchor;
|
|
1755
|
+
return true;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1759
|
+
if (atExplicitKey) {
|
|
1760
|
+
_keyLine = state.line;
|
|
1761
|
+
_keyLineStart = state.lineStart;
|
|
1762
|
+
_keyPos = state.position;
|
|
1763
|
+
}
|
|
1764
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1765
|
+
if (atExplicitKey) {
|
|
1766
|
+
keyNode = state.result;
|
|
1767
|
+
} else {
|
|
1768
|
+
valueNode = state.result;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
if (!atExplicitKey) {
|
|
1772
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1773
|
+
keyTag = keyNode = valueNode = null;
|
|
1774
|
+
}
|
|
1775
|
+
skipSeparationSpace(state, true, -1);
|
|
1776
|
+
ch = state.input.charCodeAt(state.position);
|
|
1777
|
+
}
|
|
1778
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1779
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
1780
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1781
|
+
break;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
if (atExplicitKey) {
|
|
1785
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1786
|
+
}
|
|
1787
|
+
if (detected) {
|
|
1788
|
+
state.tag = _tag;
|
|
1789
|
+
state.anchor = _anchor;
|
|
1790
|
+
state.kind = "mapping";
|
|
1791
|
+
state.result = _result;
|
|
1792
|
+
}
|
|
1793
|
+
return detected;
|
|
1794
|
+
}
|
|
1795
|
+
function readTagProperty(state) {
|
|
1796
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1797
|
+
ch = state.input.charCodeAt(state.position);
|
|
1798
|
+
if (ch !== 33) return false;
|
|
1799
|
+
if (state.tag !== null) {
|
|
1800
|
+
throwError(state, "duplication of a tag property");
|
|
1801
|
+
}
|
|
1802
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1803
|
+
if (ch === 60) {
|
|
1804
|
+
isVerbatim = true;
|
|
1805
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1806
|
+
} else if (ch === 33) {
|
|
1807
|
+
isNamed = true;
|
|
1808
|
+
tagHandle = "!!";
|
|
1809
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1810
|
+
} else {
|
|
1811
|
+
tagHandle = "!";
|
|
1812
|
+
}
|
|
1813
|
+
_position = state.position;
|
|
1814
|
+
if (isVerbatim) {
|
|
1815
|
+
do {
|
|
1816
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1817
|
+
} while (ch !== 0 && ch !== 62);
|
|
1818
|
+
if (state.position < state.length) {
|
|
1819
|
+
tagName = state.input.slice(_position, state.position);
|
|
1820
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1821
|
+
} else {
|
|
1822
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1823
|
+
}
|
|
1824
|
+
} else {
|
|
1825
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1826
|
+
if (ch === 33) {
|
|
1827
|
+
if (!isNamed) {
|
|
1828
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1829
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1830
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
1831
|
+
}
|
|
1832
|
+
isNamed = true;
|
|
1833
|
+
_position = state.position + 1;
|
|
1834
|
+
} else {
|
|
1835
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1839
|
+
}
|
|
1840
|
+
tagName = state.input.slice(_position, state.position);
|
|
1841
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1842
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1846
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1847
|
+
}
|
|
1848
|
+
try {
|
|
1849
|
+
tagName = decodeURIComponent(tagName);
|
|
1850
|
+
} catch (err) {
|
|
1851
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
1852
|
+
}
|
|
1853
|
+
if (isVerbatim) {
|
|
1854
|
+
state.tag = tagName;
|
|
1855
|
+
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
1856
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1857
|
+
} else if (tagHandle === "!") {
|
|
1858
|
+
state.tag = "!" + tagName;
|
|
1859
|
+
} else if (tagHandle === "!!") {
|
|
1860
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1861
|
+
} else {
|
|
1862
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1863
|
+
}
|
|
1864
|
+
return true;
|
|
1865
|
+
}
|
|
1866
|
+
function readAnchorProperty(state) {
|
|
1867
|
+
var _position, ch;
|
|
1868
|
+
ch = state.input.charCodeAt(state.position);
|
|
1869
|
+
if (ch !== 38) return false;
|
|
1870
|
+
if (state.anchor !== null) {
|
|
1871
|
+
throwError(state, "duplication of an anchor property");
|
|
1872
|
+
}
|
|
1873
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1874
|
+
_position = state.position;
|
|
1875
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1876
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1877
|
+
}
|
|
1878
|
+
if (state.position === _position) {
|
|
1879
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
1880
|
+
}
|
|
1881
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
function readAlias(state) {
|
|
1885
|
+
var _position, alias, ch;
|
|
1886
|
+
ch = state.input.charCodeAt(state.position);
|
|
1887
|
+
if (ch !== 42) return false;
|
|
1888
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1889
|
+
_position = state.position;
|
|
1890
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1891
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1892
|
+
}
|
|
1893
|
+
if (state.position === _position) {
|
|
1894
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
1895
|
+
}
|
|
1896
|
+
alias = state.input.slice(_position, state.position);
|
|
1897
|
+
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
|
1898
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1899
|
+
}
|
|
1900
|
+
state.result = state.anchorMap[alias];
|
|
1901
|
+
skipSeparationSpace(state, true, -1);
|
|
1902
|
+
return true;
|
|
1903
|
+
}
|
|
1904
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1905
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
|
|
1906
|
+
if (state.listener !== null) {
|
|
1907
|
+
state.listener("open", state);
|
|
1908
|
+
}
|
|
1909
|
+
state.tag = null;
|
|
1910
|
+
state.anchor = null;
|
|
1911
|
+
state.kind = null;
|
|
1912
|
+
state.result = null;
|
|
1913
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1914
|
+
if (allowToSeek) {
|
|
1915
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1916
|
+
atNewLine = true;
|
|
1917
|
+
if (state.lineIndent > parentIndent) {
|
|
1918
|
+
indentStatus = 1;
|
|
1919
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1920
|
+
indentStatus = 0;
|
|
1921
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1922
|
+
indentStatus = -1;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
if (indentStatus === 1) {
|
|
1927
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
1928
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1929
|
+
atNewLine = true;
|
|
1930
|
+
allowBlockCollections = allowBlockStyles;
|
|
1931
|
+
if (state.lineIndent > parentIndent) {
|
|
1932
|
+
indentStatus = 1;
|
|
1933
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1934
|
+
indentStatus = 0;
|
|
1935
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1936
|
+
indentStatus = -1;
|
|
1937
|
+
}
|
|
1938
|
+
} else {
|
|
1939
|
+
allowBlockCollections = false;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
if (allowBlockCollections) {
|
|
1944
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
1945
|
+
}
|
|
1946
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1947
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1948
|
+
flowIndent = parentIndent;
|
|
1949
|
+
} else {
|
|
1950
|
+
flowIndent = parentIndent + 1;
|
|
1951
|
+
}
|
|
1952
|
+
blockIndent = state.position - state.lineStart;
|
|
1953
|
+
if (indentStatus === 1) {
|
|
1954
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
1955
|
+
hasContent = true;
|
|
1956
|
+
} else {
|
|
1957
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
1958
|
+
hasContent = true;
|
|
1959
|
+
} else if (readAlias(state)) {
|
|
1960
|
+
hasContent = true;
|
|
1961
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
1962
|
+
throwError(state, "alias node should not have any properties");
|
|
1963
|
+
}
|
|
1964
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1965
|
+
hasContent = true;
|
|
1966
|
+
if (state.tag === null) {
|
|
1967
|
+
state.tag = "?";
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
if (state.anchor !== null) {
|
|
1971
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
} else if (indentStatus === 0) {
|
|
1975
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
if (state.tag === null) {
|
|
1979
|
+
if (state.anchor !== null) {
|
|
1980
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1981
|
+
}
|
|
1982
|
+
} else if (state.tag === "?") {
|
|
1983
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
1984
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
1985
|
+
}
|
|
1986
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1987
|
+
type = state.implicitTypes[typeIndex];
|
|
1988
|
+
if (type.resolve(state.result)) {
|
|
1989
|
+
state.result = type.construct(state.result);
|
|
1990
|
+
state.tag = type.tag;
|
|
1991
|
+
if (state.anchor !== null) {
|
|
1992
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1993
|
+
}
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
} else if (state.tag !== "!") {
|
|
1998
|
+
if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
1999
|
+
type = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2000
|
+
} else {
|
|
2001
|
+
type = null;
|
|
2002
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2003
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2004
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2005
|
+
type = typeList[typeIndex];
|
|
2006
|
+
break;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
if (!type) {
|
|
2011
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2012
|
+
}
|
|
2013
|
+
if (state.result !== null && type.kind !== state.kind) {
|
|
2014
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
2015
|
+
}
|
|
2016
|
+
if (!type.resolve(state.result, state.tag)) {
|
|
2017
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2018
|
+
} else {
|
|
2019
|
+
state.result = type.construct(state.result, state.tag);
|
|
2020
|
+
if (state.anchor !== null) {
|
|
2021
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
if (state.listener !== null) {
|
|
2026
|
+
state.listener("close", state);
|
|
2027
|
+
}
|
|
2028
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2029
|
+
}
|
|
2030
|
+
function readDocument(state) {
|
|
2031
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2032
|
+
state.version = null;
|
|
2033
|
+
state.checkLineBreaks = state.legacy;
|
|
2034
|
+
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
2035
|
+
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
2036
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2037
|
+
skipSeparationSpace(state, true, -1);
|
|
2038
|
+
ch = state.input.charCodeAt(state.position);
|
|
2039
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2040
|
+
break;
|
|
2041
|
+
}
|
|
2042
|
+
hasDirectives = true;
|
|
2043
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2044
|
+
_position = state.position;
|
|
2045
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2046
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2047
|
+
}
|
|
2048
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2049
|
+
directiveArgs = [];
|
|
2050
|
+
if (directiveName.length < 1) {
|
|
2051
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2052
|
+
}
|
|
2053
|
+
while (ch !== 0) {
|
|
2054
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2055
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2056
|
+
}
|
|
2057
|
+
if (ch === 35) {
|
|
2058
|
+
do {
|
|
2059
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2060
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2061
|
+
break;
|
|
2062
|
+
}
|
|
2063
|
+
if (is_EOL(ch)) break;
|
|
2064
|
+
_position = state.position;
|
|
2065
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2066
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2067
|
+
}
|
|
2068
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2069
|
+
}
|
|
2070
|
+
if (ch !== 0) readLineBreak(state);
|
|
2071
|
+
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
2072
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2073
|
+
} else {
|
|
2074
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
skipSeparationSpace(state, true, -1);
|
|
2078
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2079
|
+
state.position += 3;
|
|
2080
|
+
skipSeparationSpace(state, true, -1);
|
|
2081
|
+
} else if (hasDirectives) {
|
|
2082
|
+
throwError(state, "directives end mark is expected");
|
|
2083
|
+
}
|
|
2084
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2085
|
+
skipSeparationSpace(state, true, -1);
|
|
2086
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2087
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2088
|
+
}
|
|
2089
|
+
state.documents.push(state.result);
|
|
2090
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2091
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2092
|
+
state.position += 3;
|
|
2093
|
+
skipSeparationSpace(state, true, -1);
|
|
2094
|
+
}
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
if (state.position < state.length - 1) {
|
|
2098
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2099
|
+
} else {
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
function loadDocuments(input, options) {
|
|
2104
|
+
input = String(input);
|
|
2105
|
+
options = options || {};
|
|
2106
|
+
if (input.length !== 0) {
|
|
2107
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2108
|
+
input += "\n";
|
|
2109
|
+
}
|
|
2110
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2111
|
+
input = input.slice(1);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
var state = new State(input, options);
|
|
2115
|
+
var nullpos = input.indexOf("\0");
|
|
2116
|
+
if (nullpos !== -1) {
|
|
2117
|
+
state.position = nullpos;
|
|
2118
|
+
throwError(state, "null byte is not allowed in input");
|
|
2119
|
+
}
|
|
2120
|
+
state.input += "\0";
|
|
2121
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2122
|
+
state.lineIndent += 1;
|
|
2123
|
+
state.position += 1;
|
|
2124
|
+
}
|
|
2125
|
+
while (state.position < state.length - 1) {
|
|
2126
|
+
readDocument(state);
|
|
2127
|
+
}
|
|
2128
|
+
return state.documents;
|
|
2129
|
+
}
|
|
2130
|
+
function loadAll(input, iterator, options) {
|
|
2131
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2132
|
+
options = iterator;
|
|
2133
|
+
iterator = null;
|
|
2134
|
+
}
|
|
2135
|
+
var documents = loadDocuments(input, options);
|
|
2136
|
+
if (typeof iterator !== "function") {
|
|
2137
|
+
return documents;
|
|
2138
|
+
}
|
|
2139
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2140
|
+
iterator(documents[index]);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
function load2(input, options) {
|
|
2144
|
+
var documents = loadDocuments(input, options);
|
|
2145
|
+
if (documents.length === 0) {
|
|
2146
|
+
return void 0;
|
|
2147
|
+
} else if (documents.length === 1) {
|
|
2148
|
+
return documents[0];
|
|
2149
|
+
}
|
|
2150
|
+
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2151
|
+
}
|
|
2152
|
+
module2.exports.loadAll = loadAll;
|
|
2153
|
+
module2.exports.load = load2;
|
|
2154
|
+
}
|
|
2155
|
+
});
|
|
2156
|
+
|
|
2157
|
+
// node_modules/js-yaml/lib/dumper.js
|
|
2158
|
+
var require_dumper = __commonJS({
|
|
2159
|
+
"node_modules/js-yaml/lib/dumper.js"(exports2, module2) {
|
|
2160
|
+
"use strict";
|
|
2161
|
+
var common = require_common();
|
|
2162
|
+
var YAMLException = require_exception();
|
|
2163
|
+
var DEFAULT_SCHEMA = require_default();
|
|
2164
|
+
var _toString = Object.prototype.toString;
|
|
2165
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2166
|
+
var CHAR_BOM = 65279;
|
|
2167
|
+
var CHAR_TAB = 9;
|
|
2168
|
+
var CHAR_LINE_FEED = 10;
|
|
2169
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2170
|
+
var CHAR_SPACE = 32;
|
|
2171
|
+
var CHAR_EXCLAMATION = 33;
|
|
2172
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2173
|
+
var CHAR_SHARP = 35;
|
|
2174
|
+
var CHAR_PERCENT = 37;
|
|
2175
|
+
var CHAR_AMPERSAND = 38;
|
|
2176
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2177
|
+
var CHAR_ASTERISK = 42;
|
|
2178
|
+
var CHAR_COMMA = 44;
|
|
2179
|
+
var CHAR_MINUS = 45;
|
|
2180
|
+
var CHAR_COLON = 58;
|
|
2181
|
+
var CHAR_EQUALS = 61;
|
|
2182
|
+
var CHAR_GREATER_THAN = 62;
|
|
2183
|
+
var CHAR_QUESTION = 63;
|
|
2184
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2185
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2186
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2187
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2188
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2189
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2190
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2191
|
+
var ESCAPE_SEQUENCES = {};
|
|
2192
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2193
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2194
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2195
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2196
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2197
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2198
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2199
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2200
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2201
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2202
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2203
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2204
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2205
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2206
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2207
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2208
|
+
"y",
|
|
2209
|
+
"Y",
|
|
2210
|
+
"yes",
|
|
2211
|
+
"Yes",
|
|
2212
|
+
"YES",
|
|
2213
|
+
"on",
|
|
2214
|
+
"On",
|
|
2215
|
+
"ON",
|
|
2216
|
+
"n",
|
|
2217
|
+
"N",
|
|
2218
|
+
"no",
|
|
2219
|
+
"No",
|
|
2220
|
+
"NO",
|
|
2221
|
+
"off",
|
|
2222
|
+
"Off",
|
|
2223
|
+
"OFF"
|
|
2224
|
+
];
|
|
2225
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2226
|
+
function compileStyleMap(schema, map2) {
|
|
2227
|
+
var result, keys, index, length, tag, style, type;
|
|
2228
|
+
if (map2 === null) return {};
|
|
2229
|
+
result = {};
|
|
2230
|
+
keys = Object.keys(map2);
|
|
2231
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2232
|
+
tag = keys[index];
|
|
2233
|
+
style = String(map2[tag]);
|
|
2234
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2235
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2236
|
+
}
|
|
2237
|
+
type = schema.compiledTypeMap["fallback"][tag];
|
|
2238
|
+
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
2239
|
+
style = type.styleAliases[style];
|
|
2240
|
+
}
|
|
2241
|
+
result[tag] = style;
|
|
2242
|
+
}
|
|
2243
|
+
return result;
|
|
2244
|
+
}
|
|
2245
|
+
function encodeHex(character) {
|
|
2246
|
+
var string4, handle, length;
|
|
2247
|
+
string4 = character.toString(16).toUpperCase();
|
|
2248
|
+
if (character <= 255) {
|
|
2249
|
+
handle = "x";
|
|
2250
|
+
length = 2;
|
|
2251
|
+
} else if (character <= 65535) {
|
|
2252
|
+
handle = "u";
|
|
2253
|
+
length = 4;
|
|
2254
|
+
} else if (character <= 4294967295) {
|
|
2255
|
+
handle = "U";
|
|
2256
|
+
length = 8;
|
|
2257
|
+
} else {
|
|
2258
|
+
throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2259
|
+
}
|
|
2260
|
+
return "\\" + handle + common.repeat("0", length - string4.length) + string4;
|
|
2261
|
+
}
|
|
2262
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
2263
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
2264
|
+
function State(options) {
|
|
2265
|
+
this.schema = options["schema"] || DEFAULT_SCHEMA;
|
|
2266
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2267
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2268
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2269
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2270
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2271
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2272
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2273
|
+
this.noRefs = options["noRefs"] || false;
|
|
2274
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2275
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2276
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2277
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2278
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2279
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2280
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2281
|
+
this.tag = null;
|
|
2282
|
+
this.result = "";
|
|
2283
|
+
this.duplicates = [];
|
|
2284
|
+
this.usedDuplicates = null;
|
|
2285
|
+
}
|
|
2286
|
+
function indentString(string4, spaces) {
|
|
2287
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string4.length;
|
|
2288
|
+
while (position < length) {
|
|
2289
|
+
next = string4.indexOf("\n", position);
|
|
2290
|
+
if (next === -1) {
|
|
2291
|
+
line = string4.slice(position);
|
|
2292
|
+
position = length;
|
|
2293
|
+
} else {
|
|
2294
|
+
line = string4.slice(position, next + 1);
|
|
2295
|
+
position = next + 1;
|
|
2296
|
+
}
|
|
2297
|
+
if (line.length && line !== "\n") result += ind;
|
|
2298
|
+
result += line;
|
|
2299
|
+
}
|
|
2300
|
+
return result;
|
|
2301
|
+
}
|
|
2302
|
+
function generateNextLine(state, level) {
|
|
2303
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
2304
|
+
}
|
|
2305
|
+
function testImplicitResolving(state, str) {
|
|
2306
|
+
var index, length, type;
|
|
2307
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2308
|
+
type = state.implicitTypes[index];
|
|
2309
|
+
if (type.resolve(str)) {
|
|
2310
|
+
return true;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
return false;
|
|
2314
|
+
}
|
|
2315
|
+
function isWhitespace(c) {
|
|
2316
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2317
|
+
}
|
|
2318
|
+
function isPrintable(c) {
|
|
2319
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2320
|
+
}
|
|
2321
|
+
function isNsCharOrWhitespace(c) {
|
|
2322
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2323
|
+
}
|
|
2324
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2325
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2326
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2327
|
+
return (
|
|
2328
|
+
// ns-plain-safe
|
|
2329
|
+
(inblock ? (
|
|
2330
|
+
// c = flow-in
|
|
2331
|
+
cIsNsCharOrWhitespace
|
|
2332
|
+
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
function isPlainSafeFirst(c) {
|
|
2336
|
+
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2337
|
+
}
|
|
2338
|
+
function isPlainSafeLast(c) {
|
|
2339
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2340
|
+
}
|
|
2341
|
+
function codePointAt(string4, pos) {
|
|
2342
|
+
var first = string4.charCodeAt(pos), second;
|
|
2343
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string4.length) {
|
|
2344
|
+
second = string4.charCodeAt(pos + 1);
|
|
2345
|
+
if (second >= 56320 && second <= 57343) {
|
|
2346
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
return first;
|
|
2350
|
+
}
|
|
2351
|
+
function needIndentIndicator(string4) {
|
|
2352
|
+
var leadingSpaceRe = /^\n* /;
|
|
2353
|
+
return leadingSpaceRe.test(string4);
|
|
2354
|
+
}
|
|
2355
|
+
var STYLE_PLAIN = 1;
|
|
2356
|
+
var STYLE_SINGLE = 2;
|
|
2357
|
+
var STYLE_LITERAL = 3;
|
|
2358
|
+
var STYLE_FOLDED = 4;
|
|
2359
|
+
var STYLE_DOUBLE = 5;
|
|
2360
|
+
function chooseScalarStyle(string4, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2361
|
+
var i;
|
|
2362
|
+
var char = 0;
|
|
2363
|
+
var prevChar = null;
|
|
2364
|
+
var hasLineBreak = false;
|
|
2365
|
+
var hasFoldableLine = false;
|
|
2366
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2367
|
+
var previousLineBreak = -1;
|
|
2368
|
+
var plain = isPlainSafeFirst(codePointAt(string4, 0)) && isPlainSafeLast(codePointAt(string4, string4.length - 1));
|
|
2369
|
+
if (singleLineOnly || forceQuotes) {
|
|
2370
|
+
for (i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
|
|
2371
|
+
char = codePointAt(string4, i);
|
|
2372
|
+
if (!isPrintable(char)) {
|
|
2373
|
+
return STYLE_DOUBLE;
|
|
2374
|
+
}
|
|
2375
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2376
|
+
prevChar = char;
|
|
2377
|
+
}
|
|
2378
|
+
} else {
|
|
2379
|
+
for (i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
|
|
2380
|
+
char = codePointAt(string4, i);
|
|
2381
|
+
if (char === CHAR_LINE_FEED) {
|
|
2382
|
+
hasLineBreak = true;
|
|
2383
|
+
if (shouldTrackWidth) {
|
|
2384
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2385
|
+
i - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ";
|
|
2386
|
+
previousLineBreak = i;
|
|
2387
|
+
}
|
|
2388
|
+
} else if (!isPrintable(char)) {
|
|
2389
|
+
return STYLE_DOUBLE;
|
|
2390
|
+
}
|
|
2391
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2392
|
+
prevChar = char;
|
|
2393
|
+
}
|
|
2394
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ");
|
|
2395
|
+
}
|
|
2396
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2397
|
+
if (plain && !forceQuotes && !testAmbiguousType(string4)) {
|
|
2398
|
+
return STYLE_PLAIN;
|
|
2399
|
+
}
|
|
2400
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2401
|
+
}
|
|
2402
|
+
if (indentPerLevel > 9 && needIndentIndicator(string4)) {
|
|
2403
|
+
return STYLE_DOUBLE;
|
|
2404
|
+
}
|
|
2405
|
+
if (!forceQuotes) {
|
|
2406
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2407
|
+
}
|
|
2408
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2409
|
+
}
|
|
2410
|
+
function writeScalar(state, string4, level, iskey, inblock) {
|
|
2411
|
+
state.dump = (function() {
|
|
2412
|
+
if (string4.length === 0) {
|
|
2413
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2414
|
+
}
|
|
2415
|
+
if (!state.noCompatMode) {
|
|
2416
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string4) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string4)) {
|
|
2417
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string4 + '"' : "'" + string4 + "'";
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
var indent = state.indent * Math.max(1, level);
|
|
2421
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2422
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2423
|
+
function testAmbiguity(string5) {
|
|
2424
|
+
return testImplicitResolving(state, string5);
|
|
2425
|
+
}
|
|
2426
|
+
switch (chooseScalarStyle(
|
|
2427
|
+
string4,
|
|
2428
|
+
singleLineOnly,
|
|
2429
|
+
state.indent,
|
|
2430
|
+
lineWidth,
|
|
2431
|
+
testAmbiguity,
|
|
2432
|
+
state.quotingType,
|
|
2433
|
+
state.forceQuotes && !iskey,
|
|
2434
|
+
inblock
|
|
2435
|
+
)) {
|
|
2436
|
+
case STYLE_PLAIN:
|
|
2437
|
+
return string4;
|
|
2438
|
+
case STYLE_SINGLE:
|
|
2439
|
+
return "'" + string4.replace(/'/g, "''") + "'";
|
|
2440
|
+
case STYLE_LITERAL:
|
|
2441
|
+
return "|" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(string4, indent));
|
|
2442
|
+
case STYLE_FOLDED:
|
|
2443
|
+
return ">" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(foldString(string4, lineWidth), indent));
|
|
2444
|
+
case STYLE_DOUBLE:
|
|
2445
|
+
return '"' + escapeString(string4, lineWidth) + '"';
|
|
2446
|
+
default:
|
|
2447
|
+
throw new YAMLException("impossible error: invalid scalar style");
|
|
2448
|
+
}
|
|
2449
|
+
})();
|
|
2450
|
+
}
|
|
2451
|
+
function blockHeader(string4, indentPerLevel) {
|
|
2452
|
+
var indentIndicator = needIndentIndicator(string4) ? String(indentPerLevel) : "";
|
|
2453
|
+
var clip = string4[string4.length - 1] === "\n";
|
|
2454
|
+
var keep = clip && (string4[string4.length - 2] === "\n" || string4 === "\n");
|
|
2455
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2456
|
+
return indentIndicator + chomp + "\n";
|
|
2457
|
+
}
|
|
2458
|
+
function dropEndingNewline(string4) {
|
|
2459
|
+
return string4[string4.length - 1] === "\n" ? string4.slice(0, -1) : string4;
|
|
2460
|
+
}
|
|
2461
|
+
function foldString(string4, width) {
|
|
2462
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2463
|
+
var result = (function() {
|
|
2464
|
+
var nextLF = string4.indexOf("\n");
|
|
2465
|
+
nextLF = nextLF !== -1 ? nextLF : string4.length;
|
|
2466
|
+
lineRe.lastIndex = nextLF;
|
|
2467
|
+
return foldLine(string4.slice(0, nextLF), width);
|
|
2468
|
+
})();
|
|
2469
|
+
var prevMoreIndented = string4[0] === "\n" || string4[0] === " ";
|
|
2470
|
+
var moreIndented;
|
|
2471
|
+
var match;
|
|
2472
|
+
while (match = lineRe.exec(string4)) {
|
|
2473
|
+
var prefix = match[1], line = match[2];
|
|
2474
|
+
moreIndented = line[0] === " ";
|
|
2475
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2476
|
+
prevMoreIndented = moreIndented;
|
|
2477
|
+
}
|
|
2478
|
+
return result;
|
|
2479
|
+
}
|
|
2480
|
+
function foldLine(line, width) {
|
|
2481
|
+
if (line === "" || line[0] === " ") return line;
|
|
2482
|
+
var breakRe = / [^ ]/g;
|
|
2483
|
+
var match;
|
|
2484
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2485
|
+
var result = "";
|
|
2486
|
+
while (match = breakRe.exec(line)) {
|
|
2487
|
+
next = match.index;
|
|
2488
|
+
if (next - start > width) {
|
|
2489
|
+
end = curr > start ? curr : next;
|
|
2490
|
+
result += "\n" + line.slice(start, end);
|
|
2491
|
+
start = end + 1;
|
|
2492
|
+
}
|
|
2493
|
+
curr = next;
|
|
2494
|
+
}
|
|
2495
|
+
result += "\n";
|
|
2496
|
+
if (line.length - start > width && curr > start) {
|
|
2497
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2498
|
+
} else {
|
|
2499
|
+
result += line.slice(start);
|
|
2500
|
+
}
|
|
2501
|
+
return result.slice(1);
|
|
2502
|
+
}
|
|
2503
|
+
function escapeString(string4) {
|
|
2504
|
+
var result = "";
|
|
2505
|
+
var char = 0;
|
|
2506
|
+
var escapeSeq;
|
|
2507
|
+
for (var i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
|
|
2508
|
+
char = codePointAt(string4, i);
|
|
2509
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2510
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
2511
|
+
result += string4[i];
|
|
2512
|
+
if (char >= 65536) result += string4[i + 1];
|
|
2513
|
+
} else {
|
|
2514
|
+
result += escapeSeq || encodeHex(char);
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
return result;
|
|
2518
|
+
}
|
|
2519
|
+
function writeFlowSequence(state, level, object2) {
|
|
2520
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2521
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2522
|
+
value = object2[index];
|
|
2523
|
+
if (state.replacer) {
|
|
2524
|
+
value = state.replacer.call(object2, String(index), value);
|
|
2525
|
+
}
|
|
2526
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2527
|
+
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2528
|
+
_result += state.dump;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
state.tag = _tag;
|
|
2532
|
+
state.dump = "[" + _result + "]";
|
|
2533
|
+
}
|
|
2534
|
+
function writeBlockSequence(state, level, object2, compact) {
|
|
2535
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2536
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2537
|
+
value = object2[index];
|
|
2538
|
+
if (state.replacer) {
|
|
2539
|
+
value = state.replacer.call(object2, String(index), value);
|
|
2540
|
+
}
|
|
2541
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2542
|
+
if (!compact || _result !== "") {
|
|
2543
|
+
_result += generateNextLine(state, level);
|
|
2544
|
+
}
|
|
2545
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2546
|
+
_result += "-";
|
|
2547
|
+
} else {
|
|
2548
|
+
_result += "- ";
|
|
2549
|
+
}
|
|
2550
|
+
_result += state.dump;
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
state.tag = _tag;
|
|
2554
|
+
state.dump = _result || "[]";
|
|
2555
|
+
}
|
|
2556
|
+
function writeFlowMapping(state, level, object2) {
|
|
2557
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, pairBuffer;
|
|
2558
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2559
|
+
pairBuffer = "";
|
|
2560
|
+
if (_result !== "") pairBuffer += ", ";
|
|
2561
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
2562
|
+
objectKey = objectKeyList[index];
|
|
2563
|
+
objectValue = object2[objectKey];
|
|
2564
|
+
if (state.replacer) {
|
|
2565
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
2566
|
+
}
|
|
2567
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2568
|
+
continue;
|
|
2569
|
+
}
|
|
2570
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2571
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2572
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2573
|
+
continue;
|
|
2574
|
+
}
|
|
2575
|
+
pairBuffer += state.dump;
|
|
2576
|
+
_result += pairBuffer;
|
|
2577
|
+
}
|
|
2578
|
+
state.tag = _tag;
|
|
2579
|
+
state.dump = "{" + _result + "}";
|
|
2580
|
+
}
|
|
2581
|
+
function writeBlockMapping(state, level, object2, compact) {
|
|
2582
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2583
|
+
if (state.sortKeys === true) {
|
|
2584
|
+
objectKeyList.sort();
|
|
2585
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2586
|
+
objectKeyList.sort(state.sortKeys);
|
|
2587
|
+
} else if (state.sortKeys) {
|
|
2588
|
+
throw new YAMLException("sortKeys must be a boolean or a function");
|
|
2589
|
+
}
|
|
2590
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2591
|
+
pairBuffer = "";
|
|
2592
|
+
if (!compact || _result !== "") {
|
|
2593
|
+
pairBuffer += generateNextLine(state, level);
|
|
2594
|
+
}
|
|
2595
|
+
objectKey = objectKeyList[index];
|
|
2596
|
+
objectValue = object2[objectKey];
|
|
2597
|
+
if (state.replacer) {
|
|
2598
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
2599
|
+
}
|
|
2600
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2601
|
+
continue;
|
|
2602
|
+
}
|
|
2603
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2604
|
+
if (explicitPair) {
|
|
2605
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2606
|
+
pairBuffer += "?";
|
|
2607
|
+
} else {
|
|
2608
|
+
pairBuffer += "? ";
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
pairBuffer += state.dump;
|
|
2612
|
+
if (explicitPair) {
|
|
2613
|
+
pairBuffer += generateNextLine(state, level);
|
|
2614
|
+
}
|
|
2615
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2616
|
+
continue;
|
|
2617
|
+
}
|
|
2618
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2619
|
+
pairBuffer += ":";
|
|
2620
|
+
} else {
|
|
2621
|
+
pairBuffer += ": ";
|
|
2622
|
+
}
|
|
2623
|
+
pairBuffer += state.dump;
|
|
2624
|
+
_result += pairBuffer;
|
|
2625
|
+
}
|
|
2626
|
+
state.tag = _tag;
|
|
2627
|
+
state.dump = _result || "{}";
|
|
2628
|
+
}
|
|
2629
|
+
function detectType(state, object2, explicit) {
|
|
2630
|
+
var _result, typeList, index, length, type, style;
|
|
2631
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2632
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2633
|
+
type = typeList[index];
|
|
2634
|
+
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object2 === "object" && object2 instanceof type.instanceOf) && (!type.predicate || type.predicate(object2))) {
|
|
2635
|
+
if (explicit) {
|
|
2636
|
+
if (type.multi && type.representName) {
|
|
2637
|
+
state.tag = type.representName(object2);
|
|
2638
|
+
} else {
|
|
2639
|
+
state.tag = type.tag;
|
|
2640
|
+
}
|
|
2641
|
+
} else {
|
|
2642
|
+
state.tag = "?";
|
|
2643
|
+
}
|
|
2644
|
+
if (type.represent) {
|
|
2645
|
+
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2646
|
+
if (_toString.call(type.represent) === "[object Function]") {
|
|
2647
|
+
_result = type.represent(object2, style);
|
|
2648
|
+
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
2649
|
+
_result = type.represent[style](object2, style);
|
|
2650
|
+
} else {
|
|
2651
|
+
throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2652
|
+
}
|
|
2653
|
+
state.dump = _result;
|
|
2654
|
+
}
|
|
2655
|
+
return true;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
return false;
|
|
2659
|
+
}
|
|
2660
|
+
function writeNode(state, level, object2, block, compact, iskey, isblockseq) {
|
|
2661
|
+
state.tag = null;
|
|
2662
|
+
state.dump = object2;
|
|
2663
|
+
if (!detectType(state, object2, false)) {
|
|
2664
|
+
detectType(state, object2, true);
|
|
2665
|
+
}
|
|
2666
|
+
var type = _toString.call(state.dump);
|
|
2667
|
+
var inblock = block;
|
|
2668
|
+
var tagStr;
|
|
2669
|
+
if (block) {
|
|
2670
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2671
|
+
}
|
|
2672
|
+
var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
|
|
2673
|
+
if (objectOrArray) {
|
|
2674
|
+
duplicateIndex = state.duplicates.indexOf(object2);
|
|
2675
|
+
duplicate = duplicateIndex !== -1;
|
|
2676
|
+
}
|
|
2677
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2678
|
+
compact = false;
|
|
2679
|
+
}
|
|
2680
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2681
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2682
|
+
} else {
|
|
2683
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2684
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2685
|
+
}
|
|
2686
|
+
if (type === "[object Object]") {
|
|
2687
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2688
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2689
|
+
if (duplicate) {
|
|
2690
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2691
|
+
}
|
|
2692
|
+
} else {
|
|
2693
|
+
writeFlowMapping(state, level, state.dump);
|
|
2694
|
+
if (duplicate) {
|
|
2695
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
} else if (type === "[object Array]") {
|
|
2699
|
+
if (block && state.dump.length !== 0) {
|
|
2700
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2701
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2702
|
+
} else {
|
|
2703
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
2704
|
+
}
|
|
2705
|
+
if (duplicate) {
|
|
2706
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2707
|
+
}
|
|
2708
|
+
} else {
|
|
2709
|
+
writeFlowSequence(state, level, state.dump);
|
|
2710
|
+
if (duplicate) {
|
|
2711
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
} else if (type === "[object String]") {
|
|
2715
|
+
if (state.tag !== "?") {
|
|
2716
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2717
|
+
}
|
|
2718
|
+
} else if (type === "[object Undefined]") {
|
|
2719
|
+
return false;
|
|
2720
|
+
} else {
|
|
2721
|
+
if (state.skipInvalid) return false;
|
|
2722
|
+
throw new YAMLException("unacceptable kind of an object to dump " + type);
|
|
2723
|
+
}
|
|
2724
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2725
|
+
tagStr = encodeURI(
|
|
2726
|
+
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2727
|
+
).replace(/!/g, "%21");
|
|
2728
|
+
if (state.tag[0] === "!") {
|
|
2729
|
+
tagStr = "!" + tagStr;
|
|
2730
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2731
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
2732
|
+
} else {
|
|
2733
|
+
tagStr = "!<" + tagStr + ">";
|
|
2734
|
+
}
|
|
2735
|
+
state.dump = tagStr + " " + state.dump;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
return true;
|
|
2739
|
+
}
|
|
2740
|
+
function getDuplicateReferences(object2, state) {
|
|
2741
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2742
|
+
inspectNode(object2, objects, duplicatesIndexes);
|
|
2743
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2744
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2745
|
+
}
|
|
2746
|
+
state.usedDuplicates = new Array(length);
|
|
2747
|
+
}
|
|
2748
|
+
function inspectNode(object2, objects, duplicatesIndexes) {
|
|
2749
|
+
var objectKeyList, index, length;
|
|
2750
|
+
if (object2 !== null && typeof object2 === "object") {
|
|
2751
|
+
index = objects.indexOf(object2);
|
|
2752
|
+
if (index !== -1) {
|
|
2753
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2754
|
+
duplicatesIndexes.push(index);
|
|
2755
|
+
}
|
|
2756
|
+
} else {
|
|
2757
|
+
objects.push(object2);
|
|
2758
|
+
if (Array.isArray(object2)) {
|
|
2759
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2760
|
+
inspectNode(object2[index], objects, duplicatesIndexes);
|
|
2761
|
+
}
|
|
2762
|
+
} else {
|
|
2763
|
+
objectKeyList = Object.keys(object2);
|
|
2764
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2765
|
+
inspectNode(object2[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
function dump(input, options) {
|
|
2772
|
+
options = options || {};
|
|
2773
|
+
var state = new State(options);
|
|
2774
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2775
|
+
var value = input;
|
|
2776
|
+
if (state.replacer) {
|
|
2777
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
2778
|
+
}
|
|
2779
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
2780
|
+
return "";
|
|
2781
|
+
}
|
|
2782
|
+
module2.exports.dump = dump;
|
|
2783
|
+
}
|
|
2784
|
+
});
|
|
2785
|
+
|
|
2786
|
+
// node_modules/js-yaml/index.js
|
|
2787
|
+
var require_js_yaml = __commonJS({
|
|
2788
|
+
"node_modules/js-yaml/index.js"(exports2, module2) {
|
|
2789
|
+
"use strict";
|
|
2790
|
+
var loader = require_loader();
|
|
2791
|
+
var dumper = require_dumper();
|
|
2792
|
+
function renamed(from, to) {
|
|
2793
|
+
return function() {
|
|
2794
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
module2.exports.Type = require_type();
|
|
2798
|
+
module2.exports.Schema = require_schema();
|
|
2799
|
+
module2.exports.FAILSAFE_SCHEMA = require_failsafe();
|
|
2800
|
+
module2.exports.JSON_SCHEMA = require_json();
|
|
2801
|
+
module2.exports.CORE_SCHEMA = require_core();
|
|
2802
|
+
module2.exports.DEFAULT_SCHEMA = require_default();
|
|
2803
|
+
module2.exports.load = loader.load;
|
|
2804
|
+
module2.exports.loadAll = loader.loadAll;
|
|
2805
|
+
module2.exports.dump = dumper.dump;
|
|
2806
|
+
module2.exports.YAMLException = require_exception();
|
|
2807
|
+
module2.exports.types = {
|
|
2808
|
+
binary: require_binary(),
|
|
2809
|
+
float: require_float(),
|
|
2810
|
+
map: require_map(),
|
|
2811
|
+
null: require_null(),
|
|
2812
|
+
pairs: require_pairs(),
|
|
2813
|
+
set: require_set(),
|
|
2814
|
+
timestamp: require_timestamp(),
|
|
2815
|
+
bool: require_bool(),
|
|
2816
|
+
int: require_int(),
|
|
2817
|
+
merge: require_merge(),
|
|
2818
|
+
omap: require_omap(),
|
|
2819
|
+
seq: require_seq(),
|
|
2820
|
+
str: require_str()
|
|
2821
|
+
};
|
|
2822
|
+
module2.exports.safeLoad = renamed("safeLoad", "load");
|
|
2823
|
+
module2.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
2824
|
+
module2.exports.safeDump = renamed("safeDump", "dump");
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
|
|
32
2828
|
// node_modules/chardet/lib/fs/node.js
|
|
33
2829
|
var require_node = __commonJS({
|
|
34
2830
|
"node_modules/chardet/lib/fs/node.js"(exports2, module2) {
|
|
@@ -5607,10 +8403,10 @@ var require_lib = __commonJS({
|
|
|
5607
8403
|
exports2.analyse = analyse;
|
|
5608
8404
|
var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
|
|
5609
8405
|
let fd;
|
|
5610
|
-
const
|
|
8406
|
+
const fs20 = (0, node_1.default)();
|
|
5611
8407
|
const handler = (err, buffer) => {
|
|
5612
8408
|
if (fd) {
|
|
5613
|
-
|
|
8409
|
+
fs20.closeSync(fd);
|
|
5614
8410
|
}
|
|
5615
8411
|
if (err) {
|
|
5616
8412
|
reject(err);
|
|
@@ -5622,9 +8418,9 @@ var require_lib = __commonJS({
|
|
|
5622
8418
|
};
|
|
5623
8419
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
5624
8420
|
if (sampleSize > 0) {
|
|
5625
|
-
fd =
|
|
8421
|
+
fd = fs20.openSync(filepath, "r");
|
|
5626
8422
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
5627
|
-
|
|
8423
|
+
fs20.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
5628
8424
|
if (err) {
|
|
5629
8425
|
handler(err, null);
|
|
5630
8426
|
} else {
|
|
@@ -5636,22 +8432,22 @@ var require_lib = __commonJS({
|
|
|
5636
8432
|
});
|
|
5637
8433
|
return;
|
|
5638
8434
|
}
|
|
5639
|
-
|
|
8435
|
+
fs20.readFile(filepath, handler);
|
|
5640
8436
|
});
|
|
5641
8437
|
exports2.detectFile = detectFile;
|
|
5642
8438
|
var detectFileSync = (filepath, opts = {}) => {
|
|
5643
|
-
const
|
|
8439
|
+
const fs20 = (0, node_1.default)();
|
|
5644
8440
|
if (opts && opts.sampleSize) {
|
|
5645
|
-
const fd =
|
|
8441
|
+
const fd = fs20.openSync(filepath, "r");
|
|
5646
8442
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
5647
|
-
const bytesRead =
|
|
8443
|
+
const bytesRead = fs20.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
5648
8444
|
if (bytesRead < opts.sampleSize) {
|
|
5649
8445
|
sample = sample.subarray(0, bytesRead);
|
|
5650
8446
|
}
|
|
5651
|
-
|
|
8447
|
+
fs20.closeSync(fd);
|
|
5652
8448
|
return (0, exports2.detect)(sample);
|
|
5653
8449
|
}
|
|
5654
|
-
return (0, exports2.detect)(
|
|
8450
|
+
return (0, exports2.detect)(fs20.readFileSync(filepath));
|
|
5655
8451
|
};
|
|
5656
8452
|
exports2.detectFileSync = detectFileSync;
|
|
5657
8453
|
exports2.default = {
|
|
@@ -5760,6 +8556,9 @@ function getCodePath() {
|
|
|
5760
8556
|
}
|
|
5761
8557
|
return import_path2.default.resolve(dir, "../../../");
|
|
5762
8558
|
}
|
|
8559
|
+
function getWorkspacePath() {
|
|
8560
|
+
return WORKSPACE_DIR;
|
|
8561
|
+
}
|
|
5763
8562
|
function getConfigPath() {
|
|
5764
8563
|
return import_path2.default.join(HOME_DIR, "config.json5");
|
|
5765
8564
|
}
|
|
@@ -5773,6 +8572,10 @@ function getSessionPath(agentId) {
|
|
|
5773
8572
|
const sessionsPath = getSessionsPath();
|
|
5774
8573
|
return import_path2.default.join(sessionsPath, agentId);
|
|
5775
8574
|
}
|
|
8575
|
+
function getSessionMsgQueuePath(agentId) {
|
|
8576
|
+
const sessionDir = getSessionPath(agentId);
|
|
8577
|
+
return import_path2.default.join(sessionDir, "main-msg-queue.json");
|
|
8578
|
+
}
|
|
5776
8579
|
function getUserStorePath() {
|
|
5777
8580
|
const userPath = getUserPath();
|
|
5778
8581
|
const cachePath = import_path2.default.join(userPath, "cache");
|
|
@@ -5896,11 +8699,11 @@ async function startServer(options = {}) {
|
|
|
5896
8699
|
var import_ws2 = require("ws");
|
|
5897
8700
|
|
|
5898
8701
|
// src/cli/cli-utils/init-agent.ts
|
|
5899
|
-
var
|
|
5900
|
-
var
|
|
8702
|
+
var import_fs_extra17 = __toESM(require("fs-extra"));
|
|
8703
|
+
var import_path12 = __toESM(require("path"));
|
|
5901
8704
|
|
|
5902
8705
|
// src/agent/AIAgent/index.ts
|
|
5903
|
-
var
|
|
8706
|
+
var import_langchain15 = require("langchain");
|
|
5904
8707
|
var import_deepagents = require("deepagents");
|
|
5905
8708
|
|
|
5906
8709
|
// src/agent/AIAgent/utils/langgraph-checkpoint-filesystem/filesystem-saver.ts
|
|
@@ -6713,10 +9516,10 @@ function mergeDefs(...defs) {
|
|
|
6713
9516
|
function cloneDef(schema) {
|
|
6714
9517
|
return mergeDefs(schema._zod.def);
|
|
6715
9518
|
}
|
|
6716
|
-
function getElementAtPath(obj,
|
|
6717
|
-
if (!
|
|
9519
|
+
function getElementAtPath(obj, path14) {
|
|
9520
|
+
if (!path14)
|
|
6718
9521
|
return obj;
|
|
6719
|
-
return
|
|
9522
|
+
return path14.reduce((acc, key) => acc?.[key], obj);
|
|
6720
9523
|
}
|
|
6721
9524
|
function promiseAllObject(promisesObj) {
|
|
6722
9525
|
const keys = Object.keys(promisesObj);
|
|
@@ -7125,11 +9928,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
7125
9928
|
}
|
|
7126
9929
|
return false;
|
|
7127
9930
|
}
|
|
7128
|
-
function prefixIssues(
|
|
9931
|
+
function prefixIssues(path14, issues) {
|
|
7129
9932
|
return issues.map((iss) => {
|
|
7130
9933
|
var _a3;
|
|
7131
9934
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
7132
|
-
iss.path.unshift(
|
|
9935
|
+
iss.path.unshift(path14);
|
|
7133
9936
|
return iss;
|
|
7134
9937
|
});
|
|
7135
9938
|
}
|
|
@@ -7276,16 +10079,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7276
10079
|
}
|
|
7277
10080
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
7278
10081
|
const fieldErrors = { _errors: [] };
|
|
7279
|
-
const processError = (error52,
|
|
10082
|
+
const processError = (error52, path14 = []) => {
|
|
7280
10083
|
for (const issue2 of error52.issues) {
|
|
7281
10084
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
7282
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10085
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
7283
10086
|
} else if (issue2.code === "invalid_key") {
|
|
7284
|
-
processError({ issues: issue2.issues }, [...
|
|
10087
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
7285
10088
|
} else if (issue2.code === "invalid_element") {
|
|
7286
|
-
processError({ issues: issue2.issues }, [...
|
|
10089
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
7287
10090
|
} else {
|
|
7288
|
-
const fullpath = [...
|
|
10091
|
+
const fullpath = [...path14, ...issue2.path];
|
|
7289
10092
|
if (fullpath.length === 0) {
|
|
7290
10093
|
fieldErrors._errors.push(mapper(issue2));
|
|
7291
10094
|
} else {
|
|
@@ -7312,17 +10115,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7312
10115
|
}
|
|
7313
10116
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
7314
10117
|
const result = { errors: [] };
|
|
7315
|
-
const processError = (error52,
|
|
10118
|
+
const processError = (error52, path14 = []) => {
|
|
7316
10119
|
var _a3, _b;
|
|
7317
10120
|
for (const issue2 of error52.issues) {
|
|
7318
10121
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
7319
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10122
|
+
issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
|
|
7320
10123
|
} else if (issue2.code === "invalid_key") {
|
|
7321
|
-
processError({ issues: issue2.issues }, [...
|
|
10124
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
7322
10125
|
} else if (issue2.code === "invalid_element") {
|
|
7323
|
-
processError({ issues: issue2.issues }, [...
|
|
10126
|
+
processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
|
|
7324
10127
|
} else {
|
|
7325
|
-
const fullpath = [...
|
|
10128
|
+
const fullpath = [...path14, ...issue2.path];
|
|
7326
10129
|
if (fullpath.length === 0) {
|
|
7327
10130
|
result.errors.push(mapper(issue2));
|
|
7328
10131
|
continue;
|
|
@@ -7354,8 +10157,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7354
10157
|
}
|
|
7355
10158
|
function toDotPath(_path) {
|
|
7356
10159
|
const segs = [];
|
|
7357
|
-
const
|
|
7358
|
-
for (const seg of
|
|
10160
|
+
const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
10161
|
+
for (const seg of path14) {
|
|
7359
10162
|
if (typeof seg === "number")
|
|
7360
10163
|
segs.push(`[${seg}]`);
|
|
7361
10164
|
else if (typeof seg === "symbol")
|
|
@@ -20047,13 +22850,13 @@ function resolveRef(ref, ctx) {
|
|
|
20047
22850
|
if (!ref.startsWith("#")) {
|
|
20048
22851
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
20049
22852
|
}
|
|
20050
|
-
const
|
|
20051
|
-
if (
|
|
22853
|
+
const path14 = ref.slice(1).split("/").filter(Boolean);
|
|
22854
|
+
if (path14.length === 0) {
|
|
20052
22855
|
return ctx.rootSchema;
|
|
20053
22856
|
}
|
|
20054
22857
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
20055
|
-
if (
|
|
20056
|
-
const key =
|
|
22858
|
+
if (path14[0] === defsKey) {
|
|
22859
|
+
const key = path14[1];
|
|
20057
22860
|
if (!key || !ctx.defs[key]) {
|
|
20058
22861
|
throw new Error(`Reference not found: ${ref}`);
|
|
20059
22862
|
}
|
|
@@ -20467,6 +23270,14 @@ var import_eventemitter_super = require("eventemitter-super");
|
|
|
20467
23270
|
// src/agent/AIAgent/middleware/eventEmitMiddleware.ts
|
|
20468
23271
|
var import_langchain = require("langchain");
|
|
20469
23272
|
|
|
23273
|
+
// src/agent/AIAgent/utils/skill-parser.ts
|
|
23274
|
+
var fs5 = require("fs-extra");
|
|
23275
|
+
var path5 = require("path");
|
|
23276
|
+
var yaml = require_js_yaml();
|
|
23277
|
+
|
|
23278
|
+
// src/agent/AIAgent/system-prompt.ts
|
|
23279
|
+
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
23280
|
+
|
|
20470
23281
|
// src/agent/tools/executeCommand.ts
|
|
20471
23282
|
var import_child_process = require("child_process");
|
|
20472
23283
|
var import_chardet = __toESM(require_lib());
|
|
@@ -20535,7 +23346,7 @@ var executeCommandTool = (0, import_langchain2.tool)(
|
|
|
20535
23346
|
// src/agent/tools/executeJSCode.ts
|
|
20536
23347
|
var import_langchain3 = require("langchain");
|
|
20537
23348
|
var import_path5 = __toESM(require("path"));
|
|
20538
|
-
var
|
|
23349
|
+
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
20539
23350
|
var _require = require;
|
|
20540
23351
|
async function executeJSCode(code) {
|
|
20541
23352
|
logInfo("Executing JavaScript code: ");
|
|
@@ -20557,7 +23368,7 @@ async function executeJSCode(code) {
|
|
|
20557
23368
|
var getInstalledPackagesTool = (0, import_langchain3.tool)(
|
|
20558
23369
|
async () => {
|
|
20559
23370
|
const packageJson = import_path5.default.join(getCodePath(), "./package.json");
|
|
20560
|
-
const pkg =
|
|
23371
|
+
const pkg = import_fs_extra5.default.readJsonSync(packageJson);
|
|
20561
23372
|
return JSON.stringify(pkg.dependencies);
|
|
20562
23373
|
},
|
|
20563
23374
|
{
|
|
@@ -20569,7 +23380,7 @@ var getInstalledPackagesTool = (0, import_langchain3.tool)(
|
|
|
20569
23380
|
var checkPackageInstalledTool = (0, import_langchain3.tool)(
|
|
20570
23381
|
async ({ packageName }) => {
|
|
20571
23382
|
const packageJson = import_path5.default.join(getCodePath(), "./package.json");
|
|
20572
|
-
const pkg =
|
|
23383
|
+
const pkg = import_fs_extra5.default.readJsonSync(packageJson);
|
|
20573
23384
|
const installed = Object.prototype.hasOwnProperty.call(pkg.dependencies, packageName);
|
|
20574
23385
|
return installed ? `Package "${packageName}" is installed.` : `Package "${packageName}" is NOT installed.`;
|
|
20575
23386
|
},
|
|
@@ -20584,7 +23395,7 @@ var checkPackageInstalledTool = (0, import_langchain3.tool)(
|
|
|
20584
23395
|
var installPackageTool = (0, import_langchain3.tool)(
|
|
20585
23396
|
async ({ packageName }) => {
|
|
20586
23397
|
const packageJson = import_path5.default.join(getCodePath(), "./package.json");
|
|
20587
|
-
const pkg =
|
|
23398
|
+
const pkg = import_fs_extra5.default.readJsonSync(packageJson);
|
|
20588
23399
|
if (Object.prototype.hasOwnProperty.call(pkg.dependencies, packageName)) {
|
|
20589
23400
|
return `Package "${packageName}" is already installed.`;
|
|
20590
23401
|
}
|
|
@@ -20605,21 +23416,22 @@ var executeJSCodeTool = (0, import_langchain3.tool)(
|
|
|
20605
23416
|
},
|
|
20606
23417
|
{
|
|
20607
23418
|
name: "execute_js_code",
|
|
20608
|
-
description: `\
|
|
23419
|
+
description: `\u6267\u884C\u4E00\u6BB5Node.js\u4EE3\u7801\u5E76\u8FD4\u56DE\u6267\u884C\u7ED3\u679C\u3002\u6CE8\u610F\uFF1A\u4EE3\u7801\u5FC5\u987B\u5305\u542B\u4E00\u4E2A__main()\u51FD\u6570\u4F5C\u4E3A\u6267\u884C\u5165\u53E3\uFF0C__main()\u51FD\u6570\u5185\u5FC5\u987B\u662F\u4E00\u4E2A\u4F7F\u7528async\u524D\u7F00\u7684\u51FD\u6570\u3002\u793A\u4F8B\u4EE3\u7801\uFF1A
|
|
20609
23420
|
async function __main() {
|
|
20610
23421
|
const data = await fs.readFile("data.txt", "utf-8")
|
|
20611
23422
|
return data
|
|
20612
23423
|
}
|
|
20613
23424
|
`,
|
|
20614
23425
|
schema: external_exports.object({
|
|
20615
|
-
code: external_exports.string().describe("\u8981\u6267\u884C\
|
|
23426
|
+
code: external_exports.string().describe("\u8981\u6267\u884C\u7684Node.js\u4EE3\u7801")
|
|
20616
23427
|
})
|
|
20617
23428
|
}
|
|
20618
23429
|
);
|
|
23430
|
+
var packageTools = [getInstalledPackagesTool, checkPackageInstalledTool, installPackageTool, executeJSCodeTool];
|
|
20619
23431
|
|
|
20620
23432
|
// src/cli/cli-utils/UserCache.ts
|
|
20621
23433
|
var import_path6 = __toESM(require("path"));
|
|
20622
|
-
var
|
|
23434
|
+
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
20623
23435
|
var import_crypto = require("crypto");
|
|
20624
23436
|
var UserCache = class {
|
|
20625
23437
|
cacheDir;
|
|
@@ -20627,23 +23439,23 @@ var UserCache = class {
|
|
|
20627
23439
|
constructor() {
|
|
20628
23440
|
const cacheDir = getUserStorePath();
|
|
20629
23441
|
const catalog = import_path6.default.join(cacheDir, "catalog.json");
|
|
20630
|
-
|
|
23442
|
+
import_fs_extra6.default.ensureFileSync(catalog);
|
|
20631
23443
|
this.cacheDir = cacheDir;
|
|
20632
23444
|
this.catalogPath = catalog;
|
|
20633
23445
|
}
|
|
20634
23446
|
getCatalog() {
|
|
20635
|
-
return
|
|
23447
|
+
return import_fs_extra6.default.readJSONSync(this.catalogPath, { throws: false }) || [];
|
|
20636
23448
|
}
|
|
20637
23449
|
getCatalogFilePath() {
|
|
20638
23450
|
return this.catalogPath;
|
|
20639
23451
|
}
|
|
20640
23452
|
updateCatalog(catalog) {
|
|
20641
|
-
|
|
23453
|
+
import_fs_extra6.default.writeJSONSync(this.catalogPath, catalog);
|
|
20642
23454
|
}
|
|
20643
23455
|
add(description, content) {
|
|
20644
23456
|
const id = (0, import_crypto.randomUUID)();
|
|
20645
23457
|
const filePath = import_path6.default.join(this.cacheDir, `${id}.md`);
|
|
20646
|
-
|
|
23458
|
+
import_fs_extra6.default.writeFileSync(filePath, content, "utf-8");
|
|
20647
23459
|
const catalog = this.getCatalog();
|
|
20648
23460
|
catalog.push({ id, description });
|
|
20649
23461
|
this.updateCatalog(catalog);
|
|
@@ -20653,8 +23465,8 @@ var UserCache = class {
|
|
|
20653
23465
|
const item = catalog.find((item2) => item2.id === id);
|
|
20654
23466
|
if (item) {
|
|
20655
23467
|
const filePath = import_path6.default.join(this.cacheDir, `${id}.md`);
|
|
20656
|
-
if (
|
|
20657
|
-
return { description: item.description, content:
|
|
23468
|
+
if (import_fs_extra6.default.existsSync(filePath)) {
|
|
23469
|
+
return { description: item.description, content: import_fs_extra6.default.readFileSync(filePath, "utf-8") };
|
|
20658
23470
|
}
|
|
20659
23471
|
}
|
|
20660
23472
|
return { description: "", content: "" };
|
|
@@ -20678,8 +23490,8 @@ var UserCache = class {
|
|
|
20678
23490
|
catalog.splice(idx, 1);
|
|
20679
23491
|
this.updateCatalog(catalog);
|
|
20680
23492
|
const filePath = import_path6.default.join(this.cacheDir, `${id}.md`);
|
|
20681
|
-
if (
|
|
20682
|
-
|
|
23493
|
+
if (import_fs_extra6.default.existsSync(filePath)) {
|
|
23494
|
+
import_fs_extra6.default.removeSync(filePath);
|
|
20683
23495
|
}
|
|
20684
23496
|
return true;
|
|
20685
23497
|
}
|
|
@@ -20698,7 +23510,7 @@ var UserCache = class {
|
|
|
20698
23510
|
return false;
|
|
20699
23511
|
}
|
|
20700
23512
|
const filePath = import_path6.default.join(this.cacheDir, `${id}.md`);
|
|
20701
|
-
|
|
23513
|
+
import_fs_extra6.default.writeFileSync(filePath, content, "utf-8");
|
|
20702
23514
|
return true;
|
|
20703
23515
|
}
|
|
20704
23516
|
};
|
|
@@ -20776,22 +23588,583 @@ var getCatalogFilePathTool = (0, import_langchain4.tool)(
|
|
|
20776
23588
|
schema: external_exports.object({})
|
|
20777
23589
|
}
|
|
20778
23590
|
);
|
|
23591
|
+
var learnTools = [learnSelfTool, getLearnedDetailTool, updateLearnContentTool, getCatalogFilePathTool];
|
|
20779
23592
|
|
|
20780
23593
|
// src/agent/tools/mcp.ts
|
|
20781
23594
|
var import_mcp_adapters = require("@langchain/mcp-adapters");
|
|
20782
|
-
var
|
|
23595
|
+
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
20783
23596
|
|
|
20784
23597
|
// src/agent/tools/utils.ts
|
|
20785
23598
|
var import_langchain5 = require("langchain");
|
|
20786
|
-
var
|
|
23599
|
+
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
20787
23600
|
|
|
20788
|
-
// src/
|
|
23601
|
+
// src/agent/tools/edit.ts
|
|
23602
|
+
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
23603
|
+
var import_langchain6 = require("langchain");
|
|
23604
|
+
|
|
23605
|
+
// src/agent/tools/fileTools.ts
|
|
23606
|
+
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
23607
|
+
var import_path7 = __toESM(require("path"));
|
|
23608
|
+
var DEFAULT_MAX_OUTPUT = 6e4;
|
|
23609
|
+
var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
23610
|
+
".txt",
|
|
23611
|
+
".md",
|
|
23612
|
+
".json",
|
|
23613
|
+
".json5",
|
|
23614
|
+
".js",
|
|
23615
|
+
".jsx",
|
|
23616
|
+
".ts",
|
|
23617
|
+
".tsx",
|
|
23618
|
+
".mjs",
|
|
23619
|
+
".cjs",
|
|
23620
|
+
".css",
|
|
23621
|
+
".less",
|
|
23622
|
+
".scss",
|
|
23623
|
+
".html",
|
|
23624
|
+
".xml",
|
|
23625
|
+
".yaml",
|
|
23626
|
+
".yml",
|
|
23627
|
+
".toml",
|
|
23628
|
+
".ini",
|
|
23629
|
+
".env",
|
|
23630
|
+
".gitignore",
|
|
23631
|
+
".sql",
|
|
23632
|
+
".py",
|
|
23633
|
+
".java",
|
|
23634
|
+
".c",
|
|
23635
|
+
".cpp",
|
|
23636
|
+
".h",
|
|
23637
|
+
".hpp",
|
|
23638
|
+
".cs",
|
|
23639
|
+
".go",
|
|
23640
|
+
".rs",
|
|
23641
|
+
".php",
|
|
23642
|
+
".rb",
|
|
23643
|
+
".sh",
|
|
23644
|
+
".bat",
|
|
23645
|
+
".ps1",
|
|
23646
|
+
".vue",
|
|
23647
|
+
".svelte",
|
|
23648
|
+
".log",
|
|
23649
|
+
".csv"
|
|
23650
|
+
]);
|
|
23651
|
+
function resolveWorkspacePath(inputPath, cwd = getTrueCwd()) {
|
|
23652
|
+
if (!inputPath?.trim()) {
|
|
23653
|
+
throw new Error("\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
|
|
23654
|
+
}
|
|
23655
|
+
return import_path7.default.resolve(cwd, inputPath);
|
|
23656
|
+
}
|
|
23657
|
+
function normalizePathForMatch(filePath) {
|
|
23658
|
+
return filePath.replace(/\\/g, "/");
|
|
23659
|
+
}
|
|
23660
|
+
function truncateOutput(content, maxLength = DEFAULT_MAX_OUTPUT) {
|
|
23661
|
+
if (content.length <= maxLength) {
|
|
23662
|
+
return content;
|
|
23663
|
+
}
|
|
23664
|
+
return `${content.slice(0, maxLength)}
|
|
23665
|
+
|
|
23666
|
+
[\u5185\u5BB9\u5DF2\u622A\u65AD\uFF0C\u4EC5\u663E\u793A\u524D ${maxLength} \u4E2A\u5B57\u7B26\uFF0C\u603B\u957F\u5EA6 ${content.length} \u4E2A\u5B57\u7B26]`;
|
|
23667
|
+
}
|
|
23668
|
+
function isProbablyTextFile(filePath) {
|
|
23669
|
+
const ext = import_path7.default.extname(filePath).toLowerCase();
|
|
23670
|
+
const base = import_path7.default.basename(filePath).toLowerCase();
|
|
23671
|
+
return TEXT_FILE_EXTENSIONS.has(ext) || TEXT_FILE_EXTENSIONS.has(base) || base.startsWith(".env");
|
|
23672
|
+
}
|
|
23673
|
+
function globToRegExp(pattern) {
|
|
23674
|
+
const normalized = normalizePathForMatch(pattern);
|
|
23675
|
+
let regex = "^";
|
|
23676
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
23677
|
+
const char = normalized[i];
|
|
23678
|
+
const next = normalized[i + 1];
|
|
23679
|
+
if (char === "*") {
|
|
23680
|
+
if (next === "*") {
|
|
23681
|
+
const after = normalized[i + 2];
|
|
23682
|
+
if (after === "/") {
|
|
23683
|
+
regex += "(?:.*/)?";
|
|
23684
|
+
i += 2;
|
|
23685
|
+
} else {
|
|
23686
|
+
regex += ".*";
|
|
23687
|
+
i += 1;
|
|
23688
|
+
}
|
|
23689
|
+
} else {
|
|
23690
|
+
regex += "[^/]*";
|
|
23691
|
+
}
|
|
23692
|
+
} else if (char === "?") {
|
|
23693
|
+
regex += "[^/]";
|
|
23694
|
+
} else {
|
|
23695
|
+
regex += char.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
23696
|
+
}
|
|
23697
|
+
}
|
|
23698
|
+
regex += "$";
|
|
23699
|
+
return new RegExp(regex, "i");
|
|
23700
|
+
}
|
|
23701
|
+
function matchesGlob(relativePath, pattern) {
|
|
23702
|
+
return globToRegExp(pattern).test(normalizePathForMatch(relativePath));
|
|
23703
|
+
}
|
|
23704
|
+
async function walkFiles(rootDir, options = {}) {
|
|
23705
|
+
const files = [];
|
|
23706
|
+
const includeHidden = options.includeHidden ?? false;
|
|
23707
|
+
const maxFiles = options.maxFiles ?? 5e3;
|
|
23708
|
+
async function walk(currentDir) {
|
|
23709
|
+
if (files.length >= maxFiles) {
|
|
23710
|
+
return;
|
|
23711
|
+
}
|
|
23712
|
+
const entries = await import_fs_extra9.default.readdir(currentDir, { withFileTypes: true });
|
|
23713
|
+
for (const entry of entries) {
|
|
23714
|
+
if (files.length >= maxFiles) {
|
|
23715
|
+
return;
|
|
23716
|
+
}
|
|
23717
|
+
if (!includeHidden && entry.name.startsWith(".")) {
|
|
23718
|
+
continue;
|
|
23719
|
+
}
|
|
23720
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") {
|
|
23721
|
+
continue;
|
|
23722
|
+
}
|
|
23723
|
+
const fullPath = import_path7.default.join(currentDir, entry.name);
|
|
23724
|
+
if (entry.isDirectory()) {
|
|
23725
|
+
await walk(fullPath);
|
|
23726
|
+
} else if (entry.isFile()) {
|
|
23727
|
+
files.push(fullPath);
|
|
23728
|
+
}
|
|
23729
|
+
}
|
|
23730
|
+
}
|
|
23731
|
+
await walk(rootDir);
|
|
23732
|
+
return files;
|
|
23733
|
+
}
|
|
23734
|
+
function formatJson(data) {
|
|
23735
|
+
return JSON.stringify(data, null, 2);
|
|
23736
|
+
}
|
|
23737
|
+
|
|
23738
|
+
// src/agent/tools/edit.ts
|
|
23739
|
+
async function editFileByReplace(filePath, oldString, newString, replaceAll = false) {
|
|
23740
|
+
const absPath = resolveWorkspacePath(filePath);
|
|
23741
|
+
if (!await import_fs_extra10.default.pathExists(absPath)) {
|
|
23742
|
+
return `Edit error: \u6587\u4EF6\u4E0D\u5B58\u5728 ${absPath}`;
|
|
23743
|
+
}
|
|
23744
|
+
const content = await import_fs_extra10.default.readFile(absPath, "utf-8");
|
|
23745
|
+
const matches = content.split(oldString).length - 1;
|
|
23746
|
+
if (!oldString) {
|
|
23747
|
+
return "Edit error: oldString \u4E0D\u80FD\u4E3A\u7A7A";
|
|
23748
|
+
}
|
|
23749
|
+
if (matches === 0) {
|
|
23750
|
+
return "Edit error: \u672A\u627E\u5230 oldString\uFF0C\u8BF7\u5148\u8BFB\u53D6\u6587\u4EF6\u786E\u8BA4\u7CBE\u786E\u5185\u5BB9";
|
|
23751
|
+
}
|
|
23752
|
+
if (!replaceAll && matches > 1) {
|
|
23753
|
+
return `Edit error: oldString \u5339\u914D\u5230 ${matches} \u5904\u3002\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4F7F\u5176\u552F\u4E00\uFF0C\u6216\u8BBE\u7F6E replaceAll=true`;
|
|
23754
|
+
}
|
|
23755
|
+
const nextContent = replaceAll ? content.split(oldString).join(newString) : content.replace(oldString, newString);
|
|
23756
|
+
await import_fs_extra10.default.writeFile(absPath, nextContent, "utf-8");
|
|
23757
|
+
return `\u5DF2\u7F16\u8F91\u6587\u4EF6: ${absPath}\uFF0C\u66FF\u6362 ${replaceAll ? matches : 1} \u5904`;
|
|
23758
|
+
}
|
|
23759
|
+
var editFileTool = (0, import_langchain6.tool)(
|
|
23760
|
+
async ({ filePath, oldString, newString, replaceAll }) => editFileByReplace(filePath, oldString, newString, replaceAll),
|
|
23761
|
+
{
|
|
23762
|
+
name: "edit_file",
|
|
23763
|
+
description: "\u7F16\u8F91\u5DF2\u6709\u6587\u672C\u6587\u4EF6\uFF1A\u4F7F\u7528\u7CBE\u786E oldString \u66FF\u6362\u4E3A newString\u3002\u9ED8\u8BA4\u8981\u6C42 oldString \u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u4EE5\u907F\u514D\u8BEF\u6539\u3002",
|
|
23764
|
+
schema: external_exports.object({
|
|
23765
|
+
filePath: external_exports.string().describe("\u8981\u7F16\u8F91\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
|
|
23766
|
+
oldString: external_exports.string().describe("\u8981\u66FF\u6362\u7684\u539F\u59CB\u6587\u672C\uFF0C\u5FC5\u987B\u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF1B\u5EFA\u8BAE\u5305\u542B\u8DB3\u591F\u4E0A\u4E0B\u6587\u4FDD\u8BC1\u552F\u4E00"),
|
|
23767
|
+
newString: external_exports.string().describe("\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"),
|
|
23768
|
+
replaceAll: external_exports.boolean().default(false).describe("\u662F\u5426\u66FF\u6362\u5168\u90E8\u5339\u914D\u9879\uFF1B\u9ED8\u8BA4 false\uFF0C\u4EC5\u5141\u8BB8\u552F\u4E00\u5339\u914D")
|
|
23769
|
+
})
|
|
23770
|
+
}
|
|
23771
|
+
);
|
|
23772
|
+
|
|
23773
|
+
// src/agent/tools/glob.ts
|
|
23774
|
+
var import_path8 = __toESM(require("path"));
|
|
23775
|
+
var import_langchain7 = require("langchain");
|
|
23776
|
+
async function globFiles(pattern, cwd, maxResults = 200, includeHidden = false) {
|
|
23777
|
+
const rootDir = resolveWorkspacePath(cwd || ".");
|
|
23778
|
+
const allFiles = await walkFiles(rootDir, { includeHidden, maxFiles: Math.max(maxResults * 20, 1e3) });
|
|
23779
|
+
const normalizedPattern = normalizePathForMatch(pattern);
|
|
23780
|
+
const matches = allFiles.map((file2) => normalizePathForMatch(import_path8.default.relative(rootDir, file2))).filter((relativePath) => matchesGlob(relativePath, normalizedPattern)).slice(0, maxResults);
|
|
23781
|
+
return truncateOutput(formatJson({ cwd: rootDir, pattern, count: matches.length, files: matches }));
|
|
23782
|
+
}
|
|
23783
|
+
var globTool = (0, import_langchain7.tool)(
|
|
23784
|
+
async ({ pattern, cwd, maxResults, includeHidden }) => globFiles(pattern, cwd, maxResults, includeHidden),
|
|
23785
|
+
{
|
|
23786
|
+
name: "glob_files",
|
|
23787
|
+
description: "\u6309 glob \u6A21\u5F0F\u67E5\u627E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6\uFF0C\u4F8B\u5982 **/*.ts\u3001src/**/*.tsx\u3002\u9ED8\u8BA4\u5FFD\u7565\u9690\u85CF\u76EE\u5F55\u3001node_modules\u3001dist\u3001.git\u3002",
|
|
23788
|
+
schema: external_exports.object({
|
|
23789
|
+
pattern: external_exports.string().describe("glob \u6587\u4EF6\u5339\u914D\u6A21\u5F0F\uFF0C\u4F8B\u5982 **/*.ts \u6216 src/**/*.tsx"),
|
|
23790
|
+
cwd: external_exports.string().optional().describe("\u641C\u7D22\u6839\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"),
|
|
23791
|
+
maxResults: external_exports.number().default(200).describe("\u6700\u5927\u8FD4\u56DE\u6570\u91CF"),
|
|
23792
|
+
includeHidden: external_exports.boolean().default(false).describe("\u662F\u5426\u5305\u542B\u9690\u85CF\u6587\u4EF6\u6216\u9690\u85CF\u76EE\u5F55")
|
|
23793
|
+
})
|
|
23794
|
+
}
|
|
23795
|
+
);
|
|
23796
|
+
|
|
23797
|
+
// src/agent/tools/grep.ts
|
|
23798
|
+
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
23799
|
+
var import_path9 = __toESM(require("path"));
|
|
23800
|
+
var import_langchain8 = require("langchain");
|
|
23801
|
+
async function grepFiles(query, cwd, includePattern = "**/*", isRegexp = false, maxResults = 100, includeHidden = false) {
|
|
23802
|
+
const rootDir = resolveWorkspacePath(cwd || ".");
|
|
23803
|
+
const matcher = isRegexp ? new RegExp(query, "i") : null;
|
|
23804
|
+
const files = await walkFiles(rootDir, { includeHidden, maxFiles: Math.max(maxResults * 50, 1e3) });
|
|
23805
|
+
const matches = [];
|
|
23806
|
+
for (const file2 of files) {
|
|
23807
|
+
if (matches.length >= maxResults) break;
|
|
23808
|
+
const relativePath = normalizePathForMatch(import_path9.default.relative(rootDir, file2));
|
|
23809
|
+
if (!matchesGlob(relativePath, includePattern) || !isProbablyTextFile(file2)) {
|
|
23810
|
+
continue;
|
|
23811
|
+
}
|
|
23812
|
+
const content = await import_fs_extra11.default.readFile(file2, "utf-8").catch(() => "");
|
|
23813
|
+
const lines = content.split(/\r?\n/);
|
|
23814
|
+
for (let index = 0; index < lines.length; index++) {
|
|
23815
|
+
const line = lines[index];
|
|
23816
|
+
const ok = matcher ? matcher.test(line) : line.toLowerCase().includes(query.toLowerCase());
|
|
23817
|
+
if (ok) {
|
|
23818
|
+
matches.push({ filePath: relativePath, line: index + 1, text: line.trim() });
|
|
23819
|
+
if (matches.length >= maxResults) break;
|
|
23820
|
+
}
|
|
23821
|
+
}
|
|
23822
|
+
}
|
|
23823
|
+
return truncateOutput(formatJson({ cwd: rootDir, query, includePattern, count: matches.length, matches }));
|
|
23824
|
+
}
|
|
23825
|
+
var grepTool = (0, import_langchain8.tool)(
|
|
23826
|
+
async ({ query, cwd, includePattern, isRegexp, maxResults, includeHidden }) => grepFiles(query, cwd, includePattern, isRegexp, maxResults, includeHidden),
|
|
23827
|
+
{
|
|
23828
|
+
name: "grep_files",
|
|
23829
|
+
description: "\u5728\u6587\u672C\u6587\u4EF6\u4E2D\u641C\u7D22\u5185\u5BB9\uFF0C\u652F\u6301\u666E\u901A\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F\uFF0C\u53EF\u7528 includePattern \u9650\u5B9A\u6587\u4EF6\u8303\u56F4\u3002",
|
|
23830
|
+
schema: external_exports.object({
|
|
23831
|
+
query: external_exports.string().describe("\u8981\u641C\u7D22\u7684\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
23832
|
+
cwd: external_exports.string().optional().describe("\u641C\u7D22\u6839\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"),
|
|
23833
|
+
includePattern: external_exports.string().default("**/*").describe("\u9650\u5B9A\u641C\u7D22\u6587\u4EF6\u7684 glob \u6A21\u5F0F\uFF0C\u4F8B\u5982 src/**/*.ts"),
|
|
23834
|
+
isRegexp: external_exports.boolean().default(false).describe("query \u662F\u5426\u4E3A\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
23835
|
+
maxResults: external_exports.number().default(100).describe("\u6700\u5927\u8FD4\u56DE\u5339\u914D\u6570\u91CF"),
|
|
23836
|
+
includeHidden: external_exports.boolean().default(false).describe("\u662F\u5426\u5305\u542B\u9690\u85CF\u6587\u4EF6\u6216\u9690\u85CF\u76EE\u5F55")
|
|
23837
|
+
})
|
|
23838
|
+
}
|
|
23839
|
+
);
|
|
23840
|
+
|
|
23841
|
+
// src/agent/tools/question.ts
|
|
20789
23842
|
var import_inquirer = __toESM(require("inquirer"));
|
|
20790
|
-
var
|
|
23843
|
+
var import_langchain9 = require("langchain");
|
|
23844
|
+
async function askQuestion(question, type = "input", choices = []) {
|
|
23845
|
+
const promptType = type === "select" ? "list" : type;
|
|
23846
|
+
const answer = await import_inquirer.default.prompt([
|
|
23847
|
+
{
|
|
23848
|
+
name: "value",
|
|
23849
|
+
type: promptType,
|
|
23850
|
+
message: question,
|
|
23851
|
+
choices: type === "select" ? choices : void 0
|
|
23852
|
+
}
|
|
23853
|
+
]);
|
|
23854
|
+
const value = answer["value"];
|
|
23855
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
23856
|
+
}
|
|
23857
|
+
var questionTool = (0, import_langchain9.tool)(
|
|
23858
|
+
async ({ question, type, choices }) => askQuestion(question, type, choices),
|
|
23859
|
+
{
|
|
23860
|
+
name: "ask_question",
|
|
23861
|
+
description: "\u5F53\u7EE7\u7EED\u4EFB\u52A1\u5FC5\u987B\u83B7\u53D6\u7528\u6237\u6F84\u6E05\u3001\u786E\u8BA4\u6216\u9009\u62E9\u65F6\uFF0C\u5411\u7528\u6237\u53D1\u8D77\u547D\u4EE4\u884C\u63D0\u95EE\u5E76\u8FD4\u56DE\u7B54\u6848\u3002\u4E0D\u8981\u8BE2\u95EE\u5BC6\u7801\u3001\u5BC6\u94A5\u7B49\u654F\u611F\u4FE1\u606F\u3002",
|
|
23862
|
+
schema: external_exports.object({
|
|
23863
|
+
question: external_exports.string().describe("\u8981\u8BE2\u95EE\u7528\u6237\u7684\u95EE\u9898"),
|
|
23864
|
+
type: external_exports.enum(["input", "confirm", "select"]).default("input").describe("\u95EE\u9898\u7C7B\u578B\uFF1Ainput \u6587\u672C\u8F93\u5165\u3001confirm \u786E\u8BA4\u3001select \u5355\u9009"),
|
|
23865
|
+
choices: external_exports.array(external_exports.string()).default([]).describe("select \u5355\u9009\u9879\u5217\u8868\uFF1B\u975E select \u7C7B\u578B\u53EF\u4E3A\u7A7A")
|
|
23866
|
+
})
|
|
23867
|
+
}
|
|
23868
|
+
);
|
|
23869
|
+
|
|
23870
|
+
// src/agent/tools/read.ts
|
|
23871
|
+
var import_fs_extra12 = __toESM(require("fs-extra"));
|
|
23872
|
+
var import_iconv_lite2 = __toESM(require("iconv-lite"));
|
|
23873
|
+
var import_langchain10 = require("langchain");
|
|
23874
|
+
async function readFile(filePath, startLine = 1, endLine = -1, encoding) {
|
|
23875
|
+
const absPath = resolveWorkspacePath(filePath);
|
|
23876
|
+
if (!await import_fs_extra12.default.pathExists(absPath)) {
|
|
23877
|
+
return `Read error: \u6587\u4EF6\u4E0D\u5B58\u5728 ${absPath}`;
|
|
23878
|
+
}
|
|
23879
|
+
const stat = await import_fs_extra12.default.stat(absPath);
|
|
23880
|
+
if (!stat.isFile()) {
|
|
23881
|
+
return `Read error: \u8DEF\u5F84\u4E0D\u662F\u6587\u4EF6 ${absPath}`;
|
|
23882
|
+
}
|
|
23883
|
+
const buffer = await import_fs_extra12.default.readFile(absPath);
|
|
23884
|
+
const targetEncoding = encoding || getEncoding() || "utf-8";
|
|
23885
|
+
const content = import_iconv_lite2.default.decode(buffer, targetEncoding === "auto" ? "utf-8" : targetEncoding);
|
|
23886
|
+
const lines = content.split(/\r?\n/);
|
|
23887
|
+
const safeStart = Math.max(1, startLine || 1);
|
|
23888
|
+
const safeEnd = endLine && endLine > 0 ? Math.min(endLine, lines.length) : lines.length;
|
|
23889
|
+
if (safeStart > safeEnd) {
|
|
23890
|
+
return `Read error: \u884C\u53F7\u8303\u56F4\u65E0\u6548\uFF0C\u6587\u4EF6\u5171 ${lines.length} \u884C`;
|
|
23891
|
+
}
|
|
23892
|
+
const selected = lines.slice(safeStart - 1, safeEnd).map((line, index) => `${safeStart + index}: ${line}`).join("\n");
|
|
23893
|
+
return truncateOutput(formatJson({ filePath: absPath, totalLines: lines.length, startLine: safeStart, endLine: safeEnd, content: selected }));
|
|
23894
|
+
}
|
|
23895
|
+
var readFileTool = (0, import_langchain10.tool)(
|
|
23896
|
+
async ({ filePath, startLine, endLine, encoding }) => readFile(filePath, startLine, endLine, encoding),
|
|
23897
|
+
{
|
|
23898
|
+
name: "read_file",
|
|
23899
|
+
description: "\u8BFB\u53D6\u672C\u5730\u6587\u672C\u6587\u4EF6\u5185\u5BB9\u3002\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u53EF\u6307\u5B9A\u8D77\u6B62\u884C\u53F7\uFF1B\u8FD4\u56DE\u5E26\u884C\u53F7\u7684\u5185\u5BB9\u3002",
|
|
23900
|
+
schema: external_exports.object({
|
|
23901
|
+
filePath: external_exports.string().describe("\u8981\u8BFB\u53D6\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
|
|
23902
|
+
startLine: external_exports.number().default(1).describe("\u8D77\u59CB\u884C\u53F7\uFF0C\u9ED8\u8BA4 1"),
|
|
23903
|
+
endLine: external_exports.number().default(-1).describe("\u7ED3\u675F\u884C\u53F7\uFF0C-1 \u8868\u793A\u8BFB\u53D6\u5230\u6587\u4EF6\u672B\u5C3E"),
|
|
23904
|
+
encoding: external_exports.string().optional().describe("\u6587\u4EF6\u7F16\u7801\uFF0C\u4F8B\u5982 utf-8\u3001gbk\uFF1B\u4E0D\u586B\u5219\u4F7F\u7528\u5168\u5C40\u7F16\u7801\u914D\u7F6E")
|
|
23905
|
+
})
|
|
23906
|
+
}
|
|
23907
|
+
);
|
|
23908
|
+
|
|
23909
|
+
// src/agent/tools/semanticMemory.ts
|
|
23910
|
+
var import_fs_extra13 = __toESM(require("fs-extra"));
|
|
23911
|
+
var import_path10 = __toESM(require("path"));
|
|
23912
|
+
var import_langchain11 = require("langchain");
|
|
23913
|
+
var DEFAULT_MEMORY_MARKDOWN = `# \u7528\u6237\u8BED\u4E49\u8BB0\u5FC6
|
|
23914
|
+
|
|
23915
|
+
> \u8BE5\u6587\u4EF6\u7531\u8BED\u4E49\u8BB0\u5FC6\u5DE5\u5177\u7EF4\u62A4\u3002\u4EC5\u8BB0\u5F55\u53EF\u957F\u671F\u590D\u7528\u7684\u7528\u6237\u4FE1\u606F\u3001\u4E60\u60EF\u548C\u504F\u597D\uFF1B\u4E0D\u8981\u8BB0\u5F55\u5BC6\u7801\u3001\u5BC6\u94A5\u3001\u4EE4\u724C\u7B49\u654F\u611F\u4FE1\u606F\u3002
|
|
23916
|
+
|
|
23917
|
+
## \u7528\u6237\u79F0\u547C
|
|
23918
|
+
|
|
23919
|
+
## \u64CD\u4F5C\u4E60\u60EF
|
|
23920
|
+
|
|
23921
|
+
## \u7F16\u7801\u4E60\u60EF
|
|
23922
|
+
|
|
23923
|
+
## \u4E2A\u4EBA\u504F\u597D
|
|
23924
|
+
|
|
23925
|
+
## \u5176\u4ED6\u957F\u671F\u8BB0\u5FC6
|
|
23926
|
+
`;
|
|
23927
|
+
function getMemoryFilePath(runtimeMemoryFilePath) {
|
|
23928
|
+
return typeof runtimeMemoryFilePath === "string" && runtimeMemoryFilePath.trim() ? runtimeMemoryFilePath : void 0;
|
|
23929
|
+
}
|
|
23930
|
+
async function readSemanticMemory(memoryFilePath) {
|
|
23931
|
+
if (!memoryFilePath) {
|
|
23932
|
+
return "Semantic memory error: \u5F53\u524D\u8FD0\u884C\u4E0A\u4E0B\u6587\u672A\u63D0\u4F9B memoryFilePath\uFF0C\u65E0\u6CD5\u8BFB\u53D6\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6";
|
|
23933
|
+
}
|
|
23934
|
+
if (!await import_fs_extra13.default.pathExists(memoryFilePath)) {
|
|
23935
|
+
return DEFAULT_MEMORY_MARKDOWN;
|
|
23936
|
+
}
|
|
23937
|
+
return import_fs_extra13.default.readFile(memoryFilePath, "utf-8");
|
|
23938
|
+
}
|
|
23939
|
+
async function updateSemanticMemory(memoryFilePath, content) {
|
|
23940
|
+
if (!memoryFilePath) {
|
|
23941
|
+
return "Semantic memory error: \u5F53\u524D\u8FD0\u884C\u4E0A\u4E0B\u6587\u672A\u63D0\u4F9B memoryFilePath\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6";
|
|
23942
|
+
}
|
|
23943
|
+
await import_fs_extra13.default.ensureDir(import_path10.default.dirname(memoryFilePath));
|
|
23944
|
+
await import_fs_extra13.default.writeFile(memoryFilePath, `${content.trim()}
|
|
23945
|
+
`, "utf-8");
|
|
23946
|
+
return `\u5DF2\u66F4\u65B0\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6: ${memoryFilePath}`;
|
|
23947
|
+
}
|
|
23948
|
+
var readSemanticMemoryTool = (0, import_langchain11.tool)(
|
|
23949
|
+
async (_input, runtime) => {
|
|
23950
|
+
return readSemanticMemory(getMemoryFilePath(runtime.context?.memoryFilePath));
|
|
23951
|
+
},
|
|
23952
|
+
{
|
|
23953
|
+
name: "read_user_semantic_memory",
|
|
23954
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u6587\u4EF6\u3002\u51C6\u5907\u65B0\u589E\u3001\u4FEE\u6B63\u6216\u5408\u5E76\u7528\u6237\u957F\u671F\u504F\u597D\u524D\uFF0C\u5E94\u5148\u8C03\u7528\u672C\u5DE5\u5177\u8BFB\u53D6\u73B0\u6709\u5185\u5BB9\uFF0C\u907F\u514D\u91CD\u590D\u548C\u8986\u76D6\u5DF2\u6709\u4FE1\u606F\u3002\u82E5\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u4F1A\u8FD4\u56DE\u63A8\u8350\u7684 Markdown \u6A21\u677F\u3002",
|
|
23955
|
+
schema: external_exports.object({})
|
|
23956
|
+
}
|
|
23957
|
+
);
|
|
23958
|
+
var updateSemanticMemoryTool = (0, import_langchain11.tool)(
|
|
23959
|
+
async ({ content }, runtime) => {
|
|
23960
|
+
return updateSemanticMemory(getMemoryFilePath(runtime.context?.memoryFilePath), content);
|
|
23961
|
+
},
|
|
23962
|
+
{
|
|
23963
|
+
name: "update_user_semantic_memory",
|
|
23964
|
+
description: "\u8986\u76D6\u66F4\u65B0\u5F53\u524D\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u6587\u4EF6\u3002content \u5FC5\u987B\u662F\u5B8C\u6574\u7684 Markdown \u6587\u4EF6\u5185\u5BB9\uFF0C\u800C\u4E0D\u662F\u7247\u6BB5\u3002\u4EC5\u8BB0\u5F55\u660E\u786E\u3001\u7A33\u5B9A\u3001\u53EF\u957F\u671F\u590D\u7528\u7684\u4FE1\u606F\uFF0C\u4F8B\u5982\u7528\u6237\u79F0\u547C\u3001\u64CD\u4F5C\u4E60\u60EF\u3001\u7F16\u7801\u4E60\u60EF\u3001\u4E2A\u4EBA\u504F\u597D\u7B49\uFF1B\u4E0D\u8981\u8BB0\u5F55\u4E00\u6B21\u6027\u4EFB\u52A1\u4FE1\u606F\u3001\u4E34\u65F6\u4E0A\u4E0B\u6587\u3001\u63A8\u6D4B\u5185\u5BB9\u3001\u5BC6\u7801\u3001\u5BC6\u94A5\u3001\u4EE4\u724C\u3001\u9690\u79C1\u654F\u611F\u4FE1\u606F\u3002\u66F4\u65B0\u524D\u5E94\u5148\u8C03\u7528 read_user_semantic_memory \u8BFB\u53D6\u73B0\u6709\u5185\u5BB9\uFF0C\u7136\u540E\u5728\u4FDD\u7559\u5DF2\u6709\u6709\u6548\u8BB0\u5FC6\u7684\u57FA\u7840\u4E0A\u5408\u5E76\u65B0\u4FE1\u606F\uFF0C\u6309 Markdown \u6807\u9898\u548C\u5217\u8868\u6574\u7406\uFF0C\u5E76\u81EA\u884C\u53BB\u91CD\u3002",
|
|
23965
|
+
schema: external_exports.object({
|
|
23966
|
+
content: external_exports.string().describe("\u5B8C\u6574\u7684\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u5185\u5BB9\uFF0C\u9700\u4FDD\u7559\u5E76\u5408\u5E76\u5DF2\u6709\u6709\u6548\u8BB0\u5FC6\uFF0C\u6309\u5206\u7C7B\u6807\u9898\u548C\u5217\u8868\u9879\u7EC4\u7EC7")
|
|
23967
|
+
})
|
|
23968
|
+
}
|
|
23969
|
+
);
|
|
23970
|
+
var semanticMemoryTools = [readSemanticMemoryTool, updateSemanticMemoryTool];
|
|
20791
23971
|
|
|
20792
23972
|
// src/cli/cli-utils/TaskQueue.ts
|
|
23973
|
+
var import_crypto2 = require("crypto");
|
|
20793
23974
|
var import_dayjs = __toESM(require("dayjs"));
|
|
20794
|
-
var
|
|
23975
|
+
var import_fs_extra14 = __toESM(require("fs-extra"));
|
|
23976
|
+
var TaskQueue = class {
|
|
23977
|
+
taskFilePath;
|
|
23978
|
+
constructor(agent) {
|
|
23979
|
+
this.taskFilePath = getSessionMsgQueuePath(typeof agent === "string" ? agent : agent.id);
|
|
23980
|
+
}
|
|
23981
|
+
pushTask(taskStr) {
|
|
23982
|
+
const taskQueueItem = {
|
|
23983
|
+
id: (0, import_crypto2.randomUUID)(),
|
|
23984
|
+
taskStr,
|
|
23985
|
+
createTime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
23986
|
+
};
|
|
23987
|
+
const taskList = this.loadTasks();
|
|
23988
|
+
taskList.push(taskQueueItem);
|
|
23989
|
+
this.updateTasks(taskList);
|
|
23990
|
+
}
|
|
23991
|
+
loadTasks() {
|
|
23992
|
+
const tasks = import_fs_extra14.default.readJSONSync(this.taskFilePath, { throws: false }) || [];
|
|
23993
|
+
return tasks;
|
|
23994
|
+
}
|
|
23995
|
+
updateTasks(tasks) {
|
|
23996
|
+
import_fs_extra14.default.writeJSONSync(this.taskFilePath, tasks);
|
|
23997
|
+
}
|
|
23998
|
+
clearTasks() {
|
|
23999
|
+
this.updateTasks([]);
|
|
24000
|
+
}
|
|
24001
|
+
delTask(index) {
|
|
24002
|
+
const taskList = this.loadTasks();
|
|
24003
|
+
if (index >= 0 && index < taskList.length) {
|
|
24004
|
+
taskList.splice(index, 1);
|
|
24005
|
+
this.updateTasks(taskList);
|
|
24006
|
+
}
|
|
24007
|
+
}
|
|
24008
|
+
getTask() {
|
|
24009
|
+
const taskList = this.loadTasks();
|
|
24010
|
+
if (taskList.length === 0) {
|
|
24011
|
+
return null;
|
|
24012
|
+
}
|
|
24013
|
+
const task = taskList.shift();
|
|
24014
|
+
this.updateTasks(taskList);
|
|
24015
|
+
return task || null;
|
|
24016
|
+
}
|
|
24017
|
+
};
|
|
24018
|
+
|
|
24019
|
+
// src/agent/tools/task.ts
|
|
24020
|
+
var import_langchain12 = require("langchain");
|
|
24021
|
+
function getCurrentTaskQueue(agentId) {
|
|
24022
|
+
return agentId ? new TaskQueue(agentId) : null;
|
|
24023
|
+
}
|
|
24024
|
+
function manageTaskQueue(agentId, action, task, index) {
|
|
24025
|
+
const queue = getCurrentTaskQueue(agentId);
|
|
24026
|
+
if (!queue) {
|
|
24027
|
+
return "Task error: \u672A\u627E\u5230\u5F53\u524D\u4F1A\u8BDD\uFF0C\u8BF7\u5148\u521B\u5EFA agent \u4F1A\u8BDD";
|
|
24028
|
+
}
|
|
24029
|
+
if (action === "list") {
|
|
24030
|
+
return formatJson({ tasks: queue.loadTasks() });
|
|
24031
|
+
}
|
|
24032
|
+
if (action === "add") {
|
|
24033
|
+
if (!task?.trim()) {
|
|
24034
|
+
return "Task error: \u6DFB\u52A0\u4EFB\u52A1\u65F6 task \u4E0D\u80FD\u4E3A\u7A7A";
|
|
24035
|
+
}
|
|
24036
|
+
queue.pushTask(task.trim());
|
|
24037
|
+
return `\u5DF2\u6DFB\u52A0\u4EFB\u52A1: ${task.trim()}`;
|
|
24038
|
+
}
|
|
24039
|
+
if (action === "delete") {
|
|
24040
|
+
const tasks = queue.loadTasks();
|
|
24041
|
+
const safeIndex = Number(index);
|
|
24042
|
+
if (!Number.isInteger(safeIndex) || safeIndex < 1 || safeIndex > tasks.length) {
|
|
24043
|
+
return `Task error: \u4EFB\u52A1\u5E8F\u53F7\u65E0\u6548\uFF0C\u5F53\u524D\u4EFB\u52A1\u6570 ${tasks.length}`;
|
|
24044
|
+
}
|
|
24045
|
+
const removed = tasks[safeIndex - 1];
|
|
24046
|
+
queue.delTask(safeIndex - 1);
|
|
24047
|
+
return `\u5DF2\u5220\u9664\u4EFB\u52A1: [${removed.createTime}] ${removed.taskStr}`;
|
|
24048
|
+
}
|
|
24049
|
+
queue.clearTasks();
|
|
24050
|
+
return "\u5DF2\u6E05\u7A7A\u4EFB\u52A1\u961F\u5217";
|
|
24051
|
+
}
|
|
24052
|
+
var taskTool = (0, import_langchain12.tool)(
|
|
24053
|
+
async ({ action, task, index }, runtime) => {
|
|
24054
|
+
const agentId = runtime.context?.agentId || getAgentId();
|
|
24055
|
+
return manageTaskQueue(agentId, action, task, index);
|
|
24056
|
+
},
|
|
24057
|
+
{
|
|
24058
|
+
name: "manage_task_queue",
|
|
24059
|
+
description: "\u7BA1\u7406\u5F53\u524D agent \u4F1A\u8BDD\u4EFB\u52A1\u961F\u5217\uFF1A\u67E5\u770B\u3001\u6DFB\u52A0\u540E\u7EED\u4EFB\u52A1\u3001\u5220\u9664\u6307\u5B9A\u4EFB\u52A1\u6216\u6E05\u7A7A\u4EFB\u52A1\u3002\u6DFB\u52A0\u7684\u4EFB\u52A1\u4F1A\u5728\u5F53\u524D\u4EFB\u52A1\u7ED3\u675F\u540E\u7EE7\u7EED\u6267\u884C\u3002",
|
|
24060
|
+
schema: external_exports.object({
|
|
24061
|
+
action: external_exports.enum(["list", "add", "delete", "clear"]).describe("\u4EFB\u52A1\u961F\u5217\u64CD\u4F5C"),
|
|
24062
|
+
task: external_exports.string().optional().describe("action=add \u65F6\u8981\u6DFB\u52A0\u7684\u4EFB\u52A1\u5185\u5BB9"),
|
|
24063
|
+
index: external_exports.number().optional().describe("action=delete \u65F6\u8981\u5220\u9664\u7684\u4EFB\u52A1\u5E8F\u53F7\uFF0C\u4ECE 1 \u5F00\u59CB")
|
|
24064
|
+
})
|
|
24065
|
+
}
|
|
24066
|
+
);
|
|
24067
|
+
|
|
24068
|
+
// src/agent/tools/webfetch.ts
|
|
24069
|
+
var import_langchain13 = require("langchain");
|
|
24070
|
+
async function webFetch(url2, timeout = 3e4, maxLength = 6e4) {
|
|
24071
|
+
const controller = new AbortController();
|
|
24072
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
24073
|
+
try {
|
|
24074
|
+
const response = await fetch(url2, {
|
|
24075
|
+
method: "GET",
|
|
24076
|
+
headers: {
|
|
24077
|
+
"user-agent": "deepfish-ai/agent-tool",
|
|
24078
|
+
accept: "text/html,text/plain,application/json,application/xml,*/*"
|
|
24079
|
+
},
|
|
24080
|
+
signal: controller.signal
|
|
24081
|
+
});
|
|
24082
|
+
const contentType = response.headers.get("content-type") || "";
|
|
24083
|
+
const text = await response.text();
|
|
24084
|
+
return truncateOutput(
|
|
24085
|
+
JSON.stringify(
|
|
24086
|
+
{
|
|
24087
|
+
url: url2,
|
|
24088
|
+
status: response.status,
|
|
24089
|
+
ok: response.ok,
|
|
24090
|
+
contentType,
|
|
24091
|
+
body: text
|
|
24092
|
+
},
|
|
24093
|
+
null,
|
|
24094
|
+
2
|
|
24095
|
+
),
|
|
24096
|
+
maxLength
|
|
24097
|
+
);
|
|
24098
|
+
} catch (error51) {
|
|
24099
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
24100
|
+
return `Web fetch error: ${message}`;
|
|
24101
|
+
} finally {
|
|
24102
|
+
clearTimeout(timer);
|
|
24103
|
+
}
|
|
24104
|
+
}
|
|
24105
|
+
var webFetchTool = (0, import_langchain13.tool)(
|
|
24106
|
+
async ({ url: url2, timeout, maxLength }) => webFetch(url2, timeout, maxLength),
|
|
24107
|
+
{
|
|
24108
|
+
name: "web_fetch",
|
|
24109
|
+
description: "\u901A\u8FC7 HTTP GET \u83B7\u53D6\u7F51\u9875\u3001\u63A5\u53E3\u6216\u8FDC\u7A0B\u6587\u672C\u5185\u5BB9\uFF0C\u5E76\u8FD4\u56DE\u72B6\u6001\u7801\u3001content-type \u548C\u54CD\u5E94\u6B63\u6587\u3002",
|
|
24110
|
+
schema: external_exports.object({
|
|
24111
|
+
url: external_exports.string().url().describe("\u8981\u8BF7\u6C42\u7684\u5B8C\u6574 URL\uFF0C\u4F8B\u5982 https://example.com"),
|
|
24112
|
+
timeout: external_exports.number().default(3e4).describe("\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09"),
|
|
24113
|
+
maxLength: external_exports.number().default(6e4).describe("\u6700\u5927\u8FD4\u56DE\u5B57\u7B26\u6570\uFF0C\u8D85\u51FA\u4F1A\u622A\u65AD")
|
|
24114
|
+
})
|
|
24115
|
+
}
|
|
24116
|
+
);
|
|
24117
|
+
|
|
24118
|
+
// src/agent/tools/write.ts
|
|
24119
|
+
var import_fs_extra15 = __toESM(require("fs-extra"));
|
|
24120
|
+
var import_path11 = __toESM(require("path"));
|
|
24121
|
+
var import_langchain14 = require("langchain");
|
|
24122
|
+
async function writeFile(filePath, content, mode = "overwrite") {
|
|
24123
|
+
const absPath = resolveWorkspacePath(filePath);
|
|
24124
|
+
const exists = await import_fs_extra15.default.pathExists(absPath);
|
|
24125
|
+
if (mode === "create" && exists) {
|
|
24126
|
+
return `Write error: \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0Ccreate \u6A21\u5F0F\u4E0D\u4F1A\u8986\u76D6 ${absPath}`;
|
|
24127
|
+
}
|
|
24128
|
+
await import_fs_extra15.default.ensureDir(import_path11.default.dirname(absPath));
|
|
24129
|
+
if (mode === "append") {
|
|
24130
|
+
await import_fs_extra15.default.appendFile(absPath, content, "utf-8");
|
|
24131
|
+
return `\u5DF2\u8FFD\u52A0\u5199\u5165\u6587\u4EF6: ${absPath}`;
|
|
24132
|
+
}
|
|
24133
|
+
await import_fs_extra15.default.writeFile(absPath, content, "utf-8");
|
|
24134
|
+
return `${exists ? "\u5DF2\u8986\u76D6\u5199\u5165\u6587\u4EF6" : "\u5DF2\u521B\u5EFA\u6587\u4EF6"}: ${absPath}`;
|
|
24135
|
+
}
|
|
24136
|
+
var writeFileTool = (0, import_langchain14.tool)(
|
|
24137
|
+
async ({ filePath, content, mode }) => writeFile(filePath, content, mode),
|
|
24138
|
+
{
|
|
24139
|
+
name: "write_file",
|
|
24140
|
+
description: "\u5411\u672C\u5730\u6587\u4EF6\u5199\u5165\u6587\u672C\u5185\u5BB9\u3002\u53EF\u521B\u5EFA\u65B0\u6587\u4EF6\u3001\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\u6216\u8FFD\u52A0\u5185\u5BB9\uFF0C\u4F1A\u81EA\u52A8\u521B\u5EFA\u7236\u76EE\u5F55\u3002",
|
|
24141
|
+
schema: external_exports.object({
|
|
24142
|
+
filePath: external_exports.string().describe("\u76EE\u6807\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
|
|
24143
|
+
content: external_exports.string().describe("\u8981\u5199\u5165\u7684\u5B8C\u6574\u6587\u672C\u5185\u5BB9"),
|
|
24144
|
+
mode: external_exports.enum(["overwrite", "append", "create"]).default("overwrite").describe("\u5199\u5165\u6A21\u5F0F\uFF1Aoverwrite \u8986\u76D6\u3001append \u8FFD\u52A0\u3001create \u4EC5\u65B0\u5EFA")
|
|
24145
|
+
})
|
|
24146
|
+
}
|
|
24147
|
+
);
|
|
24148
|
+
|
|
24149
|
+
// src/agent/tools/index.ts
|
|
24150
|
+
var builtinTools = [
|
|
24151
|
+
taskTool,
|
|
24152
|
+
executeCommandTool,
|
|
24153
|
+
readFileTool,
|
|
24154
|
+
editFileTool,
|
|
24155
|
+
writeFileTool,
|
|
24156
|
+
globTool,
|
|
24157
|
+
grepTool,
|
|
24158
|
+
questionTool,
|
|
24159
|
+
webFetchTool,
|
|
24160
|
+
...packageTools,
|
|
24161
|
+
...semanticMemoryTools,
|
|
24162
|
+
...learnTools
|
|
24163
|
+
];
|
|
24164
|
+
|
|
24165
|
+
// src/cli/cli-core/skills.ts
|
|
24166
|
+
var import_inquirer2 = __toESM(require("inquirer"));
|
|
24167
|
+
var import_fs_extra16 = __toESM(require("fs-extra"));
|
|
20795
24168
|
|
|
20796
24169
|
// src/serve/service/agent-room/agent-client.ts
|
|
20797
24170
|
var import_ws = __toESM(require("ws"));
|
|
@@ -20806,23 +24179,40 @@ function removeSessionById(agentId) {
|
|
|
20806
24179
|
return;
|
|
20807
24180
|
}
|
|
20808
24181
|
const sessionDir = getSessionPath(agentId);
|
|
20809
|
-
|
|
24182
|
+
import_fs_extra17.default.removeSync(sessionDir);
|
|
20810
24183
|
const sessionsPath = getSessionsPath();
|
|
20811
|
-
const sessionsFilePath =
|
|
20812
|
-
if (!
|
|
24184
|
+
const sessionsFilePath = import_path12.default.join(sessionsPath, "sessions.json");
|
|
24185
|
+
if (!import_fs_extra17.default.pathExistsSync(sessionsFilePath)) {
|
|
20813
24186
|
logSuccess("Current session history cleared");
|
|
20814
24187
|
return;
|
|
20815
24188
|
}
|
|
20816
|
-
const content =
|
|
24189
|
+
const content = import_fs_extra17.default.readFileSync(sessionsFilePath, "utf-8");
|
|
20817
24190
|
const parsed = JSON.parse(content);
|
|
20818
24191
|
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
20819
24192
|
const existingSessionIndex = sessions.findIndex((s) => s.id === agentId);
|
|
20820
24193
|
if (existingSessionIndex !== -1) {
|
|
20821
24194
|
sessions.splice(existingSessionIndex, 1);
|
|
20822
|
-
|
|
24195
|
+
import_fs_extra17.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
|
|
20823
24196
|
}
|
|
20824
24197
|
logSuccess("Current session history cleared");
|
|
20825
24198
|
}
|
|
24199
|
+
function getAgentId() {
|
|
24200
|
+
const sessionsPath = getSessionsPath();
|
|
24201
|
+
const sessionsFilePath = import_path12.default.join(sessionsPath, "sessions.json");
|
|
24202
|
+
if (!import_fs_extra17.default.pathExistsSync(sessionsFilePath)) {
|
|
24203
|
+
return;
|
|
24204
|
+
}
|
|
24205
|
+
const content = import_fs_extra17.default.readFileSync(sessionsFilePath, "utf-8");
|
|
24206
|
+
const parsed = JSON.parse(content);
|
|
24207
|
+
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
24208
|
+
const workspace = getWorkspacePath();
|
|
24209
|
+
const existingSession = sessions.find((s) => s.workspace === workspace);
|
|
24210
|
+
if (existingSession) {
|
|
24211
|
+
const agentId = existingSession.id;
|
|
24212
|
+
return agentId;
|
|
24213
|
+
}
|
|
24214
|
+
return;
|
|
24215
|
+
}
|
|
20826
24216
|
|
|
20827
24217
|
// src/serve/service/agent-room/server.ts
|
|
20828
24218
|
var agents = /* @__PURE__ */ new Map();
|
|
@@ -20993,14 +24383,14 @@ function startAgentRoomServer(opts = {}) {
|
|
|
20993
24383
|
logWarning("[agent-room] Service already running");
|
|
20994
24384
|
return wss;
|
|
20995
24385
|
}
|
|
20996
|
-
const
|
|
24386
|
+
const path14 = opts.path ?? "/agent-room";
|
|
20997
24387
|
if (opts.httpServer) {
|
|
20998
|
-
wss = new import_ws2.WebSocketServer({ server: opts.httpServer, path:
|
|
20999
|
-
logSuccess(`[agent-room] started, path=${
|
|
24388
|
+
wss = new import_ws2.WebSocketServer({ server: opts.httpServer, path: path14 });
|
|
24389
|
+
logSuccess(`[agent-room] started, path=${path14}`);
|
|
21000
24390
|
} else {
|
|
21001
24391
|
const port = opts.port ?? PORT2;
|
|
21002
|
-
wss = new import_ws2.WebSocketServer({ port, path:
|
|
21003
|
-
logSuccess(`[agent-room] started: ws://localhost:${port}${
|
|
24392
|
+
wss = new import_ws2.WebSocketServer({ port, path: path14 });
|
|
24393
|
+
logSuccess(`[agent-room] started: ws://localhost:${port}${path14}`);
|
|
21004
24394
|
}
|
|
21005
24395
|
wss.on("connection", handleConnection);
|
|
21006
24396
|
return wss;
|