opencode-manifold 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3133 -263
- package/package.json +6 -2
- package/src/templates/agents/clerk.md +22 -0
- package/src/templates/agents/debug.md +16 -0
- package/src/templates/agents/junior-dev.md +14 -0
- package/src/templates/agents/manifold.md +53 -27
- package/src/templates/agents/senior-dev.md +14 -0
- package/src/templates/agents/todo.md +159 -0
- package/src/templates/config/opencode.json +5 -19
- package/src/templates/manifold/schema.md +76 -6
- package/src/templates/skills/clerk-orchestration/SKILL.md +31 -0
- package/src/templates/skills/manifold-workflow/SKILL.md +80 -18
- package/src/templates/skills/wiki-ingest/SKILL.md +14 -4
- package/src/templates/skills/wiki-query/SKILL.md +3 -4
package/dist/index.js
CHANGED
|
@@ -50,20 +50,49 @@ async function mergeOpencodeConfig(projectDir) {
|
|
|
50
50
|
}
|
|
51
51
|
const existing = JSON.parse(await readFile(configPath, "utf-8"));
|
|
52
52
|
let changed = false;
|
|
53
|
-
if (templateConfig.agent?.manifold
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
if (templateConfig.agent?.manifold?.skill) {
|
|
54
|
+
if (!existing.agent) {
|
|
55
|
+
existing.agent = {};
|
|
56
|
+
}
|
|
57
|
+
if (!existing.agent.manifold) {
|
|
58
|
+
existing.agent.manifold = {};
|
|
59
|
+
}
|
|
60
|
+
if (!existing.agent.manifold.skill) {
|
|
61
|
+
existing.agent.manifold.skill = templateConfig.agent.manifold.skill;
|
|
62
|
+
changed = true;
|
|
63
|
+
} else if (Array.isArray(existing.agent.manifold.skill) && Array.isArray(templateConfig.agent.manifold.skill)) {
|
|
64
|
+
const existingSkills = new Set(existing.agent.manifold.skill);
|
|
65
|
+
let addedSkill = false;
|
|
66
|
+
for (const skill of templateConfig.agent.manifold.skill) {
|
|
67
|
+
if (!existingSkills.has(skill)) {
|
|
68
|
+
existing.agent.manifold.skill.push(skill);
|
|
69
|
+
addedSkill = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (addedSkill) {
|
|
63
73
|
changed = true;
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
}
|
|
77
|
+
if (templateConfig.agent?.manifold?.skill) {
|
|
78
|
+
const skillsToAdd = templateConfig.agent.manifold.skill;
|
|
79
|
+
if (!existing.permission) {
|
|
80
|
+
existing.permission = {};
|
|
81
|
+
}
|
|
82
|
+
if (!existing.permission.skill) {
|
|
83
|
+
existing.permission.skill = {};
|
|
84
|
+
}
|
|
85
|
+
let permissionChanged = false;
|
|
86
|
+
for (const skill of skillsToAdd) {
|
|
87
|
+
if (existing.permission.skill[skill] === undefined) {
|
|
88
|
+
existing.permission.skill[skill] = "allow";
|
|
89
|
+
permissionChanged = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (permissionChanged) {
|
|
93
|
+
changed = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
67
96
|
if (changed) {
|
|
68
97
|
await writeFile(configPath, JSON.stringify(existing, null, 2));
|
|
69
98
|
}
|
|
@@ -149,13 +178,13 @@ async function initProject(directory, client) {
|
|
|
149
178
|
// src/tools/dispatch-task.ts
|
|
150
179
|
import { tool } from "@opencode-ai/plugin";
|
|
151
180
|
import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
152
|
-
import { existsSync as
|
|
153
|
-
import { join as
|
|
181
|
+
import { existsSync as existsSync5 } from "fs";
|
|
182
|
+
import { join as join5 } from "path";
|
|
154
183
|
|
|
155
184
|
// src/state-machine.ts
|
|
156
185
|
import { readFile as readFile3, writeFile as writeFile3, readdir as readdir2 } from "fs/promises";
|
|
157
|
-
import { existsSync as
|
|
158
|
-
import { join as
|
|
186
|
+
import { existsSync as existsSync4 } from "fs";
|
|
187
|
+
import { join as join4 } from "path";
|
|
159
188
|
|
|
160
189
|
// src/session-spawner.ts
|
|
161
190
|
async function waitForSessionIdle(client, sessionId, timeoutMs) {
|
|
@@ -357,280 +386,3113 @@ async function retryWithBackoff(fn, options) {
|
|
|
357
386
|
}
|
|
358
387
|
|
|
359
388
|
// src/graph.ts
|
|
360
|
-
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
389
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
361
390
|
import { existsSync as existsSync2 } from "fs";
|
|
362
|
-
import { join as join2 } from "path";
|
|
363
|
-
|
|
364
|
-
|
|
391
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
392
|
+
|
|
393
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
394
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
395
|
+
function isNothing(subject) {
|
|
396
|
+
return typeof subject === "undefined" || subject === null;
|
|
365
397
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
if (trimmed === "## Calls") {
|
|
385
|
-
inSection = "calls";
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
if (trimmed === "## Depends On") {
|
|
389
|
-
inSection = "dependsOn";
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
if (trimmed === "## Tasks That Edited") {
|
|
393
|
-
inSection = "tasks";
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
if (trimmed.startsWith("- [[") && trimmed.endsWith("]]")) {
|
|
397
|
-
const ref = trimmed.slice(4, -2).trim();
|
|
398
|
-
if (inSection === "calls") {
|
|
399
|
-
entry.calls.push(ref);
|
|
400
|
-
} else if (inSection === "dependsOn") {
|
|
401
|
-
entry.dependsOn.push(ref);
|
|
402
|
-
} else if (inSection === "tasks") {
|
|
403
|
-
entry.tasksThatEdited.push(ref);
|
|
404
|
-
}
|
|
405
|
-
} else if (trimmed.startsWith("- `") && trimmed.endsWith("`")) {
|
|
406
|
-
const ref = trimmed.slice(3, -1).trim();
|
|
407
|
-
if (inSection === "calls" && !entry.calls.includes(ref)) {
|
|
408
|
-
entry.calls.push(ref);
|
|
409
|
-
} else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref)) {
|
|
410
|
-
entry.dependsOn.push(ref);
|
|
411
|
-
}
|
|
412
|
-
} else if (trimmed.startsWith("- ")) {
|
|
413
|
-
const ref = trimmed.slice(2).trim();
|
|
414
|
-
if (inSection === "calls" && !entry.calls.includes(ref)) {
|
|
415
|
-
entry.calls.push(ref);
|
|
416
|
-
} else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref)) {
|
|
417
|
-
entry.dependsOn.push(ref);
|
|
418
|
-
} else if (inSection === "tasks" && !entry.tasksThatEdited.includes(ref)) {
|
|
419
|
-
entry.tasksThatEdited.push(ref);
|
|
420
|
-
}
|
|
398
|
+
function isObject(subject) {
|
|
399
|
+
return typeof subject === "object" && subject !== null;
|
|
400
|
+
}
|
|
401
|
+
function toArray(sequence) {
|
|
402
|
+
if (Array.isArray(sequence))
|
|
403
|
+
return sequence;
|
|
404
|
+
else if (isNothing(sequence))
|
|
405
|
+
return [];
|
|
406
|
+
return [sequence];
|
|
407
|
+
}
|
|
408
|
+
function extend(target, source) {
|
|
409
|
+
var index, length, key, sourceKeys;
|
|
410
|
+
if (source) {
|
|
411
|
+
sourceKeys = Object.keys(source);
|
|
412
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
413
|
+
key = sourceKeys[index];
|
|
414
|
+
target[key] = source[key];
|
|
421
415
|
}
|
|
422
416
|
}
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
return target;
|
|
418
|
+
}
|
|
419
|
+
function repeat(string, count) {
|
|
420
|
+
var result = "", cycle;
|
|
421
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
422
|
+
result += string;
|
|
425
423
|
}
|
|
426
|
-
return
|
|
424
|
+
return result;
|
|
427
425
|
}
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
` + entry.calls.map((c) => `- ${c}`).join(`
|
|
431
|
-
`) : `## Calls
|
|
432
|
-
`;
|
|
433
|
-
const dependsSection = entry.dependsOn.length > 0 ? `## Depends On
|
|
434
|
-
` + entry.dependsOn.map((d) => `- ${d}`).join(`
|
|
435
|
-
`) : `## Depends On
|
|
436
|
-
`;
|
|
437
|
-
const tasksSection = entry.tasksThatEdited.length > 0 ? `## Tasks That Edited
|
|
438
|
-
` + entry.tasksThatEdited.map((t) => `- [[${t}]]`).join(`
|
|
439
|
-
`) : `## Tasks That Edited
|
|
440
|
-
`;
|
|
441
|
-
return `# ${entry.filePath}
|
|
442
|
-
|
|
443
|
-
${callsSection}
|
|
444
|
-
|
|
445
|
-
${dependsSection}
|
|
446
|
-
|
|
447
|
-
${tasksSection}
|
|
448
|
-
`.trim();
|
|
426
|
+
function isNegativeZero(number) {
|
|
427
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
449
428
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
429
|
+
var isNothing_1 = isNothing;
|
|
430
|
+
var isObject_1 = isObject;
|
|
431
|
+
var toArray_1 = toArray;
|
|
432
|
+
var repeat_1 = repeat;
|
|
433
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
434
|
+
var extend_1 = extend;
|
|
435
|
+
var common = {
|
|
436
|
+
isNothing: isNothing_1,
|
|
437
|
+
isObject: isObject_1,
|
|
438
|
+
toArray: toArray_1,
|
|
439
|
+
repeat: repeat_1,
|
|
440
|
+
isNegativeZero: isNegativeZero_1,
|
|
441
|
+
extend: extend_1
|
|
442
|
+
};
|
|
443
|
+
function formatError(exception, compact) {
|
|
444
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
445
|
+
if (!exception.mark)
|
|
446
|
+
return message;
|
|
447
|
+
if (exception.mark.name) {
|
|
448
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
455
449
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
450
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
451
|
+
if (!compact && exception.mark.snippet) {
|
|
452
|
+
where += `
|
|
453
|
+
|
|
454
|
+
` + exception.mark.snippet;
|
|
461
455
|
}
|
|
456
|
+
return message + " " + where;
|
|
462
457
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
calls: [],
|
|
472
|
-
dependsOn: [],
|
|
473
|
-
tasksThatEdited: []
|
|
474
|
-
};
|
|
458
|
+
function YAMLException$1(reason, mark) {
|
|
459
|
+
Error.call(this);
|
|
460
|
+
this.name = "YAMLException";
|
|
461
|
+
this.reason = reason;
|
|
462
|
+
this.mark = mark;
|
|
463
|
+
this.message = formatError(this, false);
|
|
464
|
+
if (Error.captureStackTrace) {
|
|
465
|
+
Error.captureStackTrace(this, this.constructor);
|
|
475
466
|
} else {
|
|
476
|
-
|
|
477
|
-
filePath,
|
|
478
|
-
calls: calls || [],
|
|
479
|
-
dependsOn: dependsOn || [],
|
|
480
|
-
tasksThatEdited: []
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
if (calls) {
|
|
484
|
-
entry.calls = [...new Set([...entry.calls, ...calls])];
|
|
485
|
-
}
|
|
486
|
-
if (dependsOn) {
|
|
487
|
-
entry.dependsOn = [...new Set([...entry.dependsOn, ...dependsOn])];
|
|
488
|
-
}
|
|
489
|
-
if (!entry.tasksThatEdited.includes(taskId)) {
|
|
490
|
-
entry.tasksThatEdited.push(taskId);
|
|
467
|
+
this.stack = new Error().stack || "";
|
|
491
468
|
}
|
|
492
|
-
const content = formatGraphContent(entry);
|
|
493
|
-
await writeFile2(graphPath, content, "utf-8");
|
|
494
469
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
470
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
471
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
472
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
473
|
+
return this.name + ": " + formatError(this, compact);
|
|
474
|
+
};
|
|
475
|
+
var exception = YAMLException$1;
|
|
476
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
477
|
+
var head = "";
|
|
478
|
+
var tail = "";
|
|
479
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
480
|
+
if (position - lineStart > maxHalfLength) {
|
|
481
|
+
head = " ... ";
|
|
482
|
+
lineStart = position - maxHalfLength + head.length;
|
|
502
483
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
async function readState(directory) {
|
|
507
|
-
const statePath = join3(directory, "Manifold", "state.json");
|
|
508
|
-
if (existsSync3(statePath)) {
|
|
509
|
-
const content = await readFile3(statePath, "utf-8");
|
|
510
|
-
return JSON.parse(content);
|
|
484
|
+
if (lineEnd - position > maxHalfLength) {
|
|
485
|
+
tail = " ...";
|
|
486
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
511
487
|
}
|
|
512
488
|
return {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
loop_count: 0,
|
|
516
|
-
clerk_retry_count: 0,
|
|
517
|
-
scoped_prompt: null,
|
|
518
|
-
senior_output: null,
|
|
519
|
-
junior_response: null,
|
|
520
|
-
debug_suggestion: null,
|
|
521
|
-
loop_history: []
|
|
489
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
490
|
+
pos: position - lineStart + head.length
|
|
522
491
|
};
|
|
523
492
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
await writeFile3(statePath, JSON.stringify(state, null, 2));
|
|
493
|
+
function padStart(string, max) {
|
|
494
|
+
return common.repeat(" ", max - string.length) + string;
|
|
527
495
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
|
|
496
|
+
function makeSnippet(mark, options) {
|
|
497
|
+
options = Object.create(options || null);
|
|
498
|
+
if (!mark.buffer)
|
|
499
|
+
return null;
|
|
500
|
+
if (!options.maxLength)
|
|
501
|
+
options.maxLength = 79;
|
|
502
|
+
if (typeof options.indent !== "number")
|
|
503
|
+
options.indent = 1;
|
|
504
|
+
if (typeof options.linesBefore !== "number")
|
|
505
|
+
options.linesBefore = 3;
|
|
506
|
+
if (typeof options.linesAfter !== "number")
|
|
507
|
+
options.linesAfter = 2;
|
|
508
|
+
var re = /\r?\n|\r|\0/g;
|
|
509
|
+
var lineStarts = [0];
|
|
510
|
+
var lineEnds = [];
|
|
511
|
+
var match;
|
|
512
|
+
var foundLineNo = -1;
|
|
513
|
+
while (match = re.exec(mark.buffer)) {
|
|
514
|
+
lineEnds.push(match.index);
|
|
515
|
+
lineStarts.push(match.index + match[0].length);
|
|
516
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
517
|
+
foundLineNo = lineStarts.length - 2;
|
|
518
|
+
}
|
|
531
519
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
520
|
+
if (foundLineNo < 0)
|
|
521
|
+
foundLineNo = lineStarts.length - 1;
|
|
522
|
+
var result = "", i, line;
|
|
523
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
524
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
525
|
+
for (i = 1;i <= options.linesBefore; i++) {
|
|
526
|
+
if (foundLineNo - i < 0)
|
|
527
|
+
break;
|
|
528
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
529
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
530
|
+
` + result;
|
|
541
531
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
532
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
533
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
534
|
+
`;
|
|
535
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
536
|
+
`;
|
|
537
|
+
for (i = 1;i <= options.linesAfter; i++) {
|
|
538
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
539
|
+
break;
|
|
540
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
541
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
542
|
+
`;
|
|
553
543
|
}
|
|
544
|
+
return result.replace(/\n$/, "");
|
|
554
545
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
${state.senior_output}
|
|
580
|
-
|
|
581
|
-
Junior Developer's Approval Response:
|
|
582
|
-
${state.junior_response}
|
|
583
|
-
|
|
584
|
-
Loop History:
|
|
585
|
-
${buildLoopHistory(state)}
|
|
586
|
-
|
|
587
|
-
Please perform the following logging actions:
|
|
588
|
-
|
|
589
|
-
1. Create/Update Task File at \`Manifold/tasks/${taskId}.md\`:
|
|
590
|
-
- Header with date, status, loops, task description
|
|
591
|
-
- Scoped Prompt section
|
|
592
|
-
- Design Decisions section (extract from Senior's implementation reasoning)
|
|
593
|
-
- Files Touched section (extract file paths from Senior's implementation)
|
|
594
|
-
- Complete Loop History section
|
|
595
|
-
|
|
596
|
-
2. Update \`Manifold/index.md\`:
|
|
597
|
-
- Add entry under the plan's section:
|
|
598
|
-
\`- [[${taskId}]] — ${task.description} | ${date} | COMPLETED\`
|
|
599
|
-
|
|
600
|
-
3. Append to \`Manifold/log.md\`:
|
|
601
|
-
\`## [${date}] ${taskId} | ${task.description} | COMPLETED | ${state.loop_count} loops\`
|
|
602
|
-
|
|
603
|
-
4. Update graph files for each touched file:
|
|
604
|
-
- Read the implementation and identify all files that were created or modified
|
|
605
|
-
- For each file, create or update \`Manifold/graph/<graph-name>.md\`
|
|
606
|
-
- Add the task ID to the "Tasks That Edited" section
|
|
607
|
-
- Graph filename format: replace \`/\` and \`.\` with \`_\`, append \`.md\`
|
|
608
|
-
- Example: \`src/middleware/auth.ts\` → \`src_middleware_auth_ts.md\`
|
|
609
|
-
|
|
610
|
-
Extract the list of files touched from the Senior's implementation and include it in your response.`;
|
|
611
|
-
const clerkLoggingResult = await retryWithBackoff(() => spawnClerkSession(client, clerkLoggingPrompt, "clerk", settings.timeout), {
|
|
612
|
-
maxRetries: settings.maxRetries,
|
|
613
|
-
onRetry: (attempt, error) => {
|
|
614
|
-
client.app.log({
|
|
615
|
-
body: {
|
|
616
|
-
service: "opencode-manifold",
|
|
617
|
-
level: "warn",
|
|
618
|
-
message: `Clerk logging retry ${attempt}: ${error.message}`
|
|
619
|
-
}
|
|
546
|
+
var snippet = makeSnippet;
|
|
547
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
548
|
+
"kind",
|
|
549
|
+
"multi",
|
|
550
|
+
"resolve",
|
|
551
|
+
"construct",
|
|
552
|
+
"instanceOf",
|
|
553
|
+
"predicate",
|
|
554
|
+
"represent",
|
|
555
|
+
"representName",
|
|
556
|
+
"defaultStyle",
|
|
557
|
+
"styleAliases"
|
|
558
|
+
];
|
|
559
|
+
var YAML_NODE_KINDS = [
|
|
560
|
+
"scalar",
|
|
561
|
+
"sequence",
|
|
562
|
+
"mapping"
|
|
563
|
+
];
|
|
564
|
+
function compileStyleAliases(map) {
|
|
565
|
+
var result = {};
|
|
566
|
+
if (map !== null) {
|
|
567
|
+
Object.keys(map).forEach(function(style) {
|
|
568
|
+
map[style].forEach(function(alias) {
|
|
569
|
+
result[String(alias)] = style;
|
|
620
570
|
});
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return result;
|
|
574
|
+
}
|
|
575
|
+
function Type$1(tag, options) {
|
|
576
|
+
options = options || {};
|
|
577
|
+
Object.keys(options).forEach(function(name) {
|
|
578
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
579
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
621
580
|
}
|
|
622
581
|
});
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
582
|
+
this.options = options;
|
|
583
|
+
this.tag = tag;
|
|
584
|
+
this.kind = options["kind"] || null;
|
|
585
|
+
this.resolve = options["resolve"] || function() {
|
|
586
|
+
return true;
|
|
587
|
+
};
|
|
588
|
+
this.construct = options["construct"] || function(data) {
|
|
589
|
+
return data;
|
|
590
|
+
};
|
|
591
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
592
|
+
this.predicate = options["predicate"] || null;
|
|
593
|
+
this.represent = options["represent"] || null;
|
|
594
|
+
this.representName = options["representName"] || null;
|
|
595
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
596
|
+
this.multi = options["multi"] || false;
|
|
597
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
598
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
599
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
var type = Type$1;
|
|
603
|
+
function compileList(schema, name) {
|
|
604
|
+
var result = [];
|
|
605
|
+
schema[name].forEach(function(currentType) {
|
|
606
|
+
var newIndex = result.length;
|
|
607
|
+
result.forEach(function(previousType, previousIndex) {
|
|
608
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
609
|
+
newIndex = previousIndex;
|
|
629
610
|
}
|
|
630
611
|
});
|
|
631
|
-
|
|
612
|
+
result[newIndex] = currentType;
|
|
613
|
+
});
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
function compileMap() {
|
|
617
|
+
var result = {
|
|
618
|
+
scalar: {},
|
|
619
|
+
sequence: {},
|
|
620
|
+
mapping: {},
|
|
621
|
+
fallback: {},
|
|
622
|
+
multi: {
|
|
623
|
+
scalar: [],
|
|
624
|
+
sequence: [],
|
|
625
|
+
mapping: [],
|
|
626
|
+
fallback: []
|
|
627
|
+
}
|
|
628
|
+
}, index, length;
|
|
629
|
+
function collectType(type2) {
|
|
630
|
+
if (type2.multi) {
|
|
631
|
+
result.multi[type2.kind].push(type2);
|
|
632
|
+
result.multi["fallback"].push(type2);
|
|
633
|
+
} else {
|
|
634
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
635
|
+
}
|
|
632
636
|
}
|
|
633
|
-
|
|
637
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
638
|
+
arguments[index].forEach(collectType);
|
|
639
|
+
}
|
|
640
|
+
return result;
|
|
641
|
+
}
|
|
642
|
+
function Schema$1(definition) {
|
|
643
|
+
return this.extend(definition);
|
|
644
|
+
}
|
|
645
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
646
|
+
var implicit = [];
|
|
647
|
+
var explicit = [];
|
|
648
|
+
if (definition instanceof type) {
|
|
649
|
+
explicit.push(definition);
|
|
650
|
+
} else if (Array.isArray(definition)) {
|
|
651
|
+
explicit = explicit.concat(definition);
|
|
652
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
653
|
+
if (definition.implicit)
|
|
654
|
+
implicit = implicit.concat(definition.implicit);
|
|
655
|
+
if (definition.explicit)
|
|
656
|
+
explicit = explicit.concat(definition.explicit);
|
|
657
|
+
} else {
|
|
658
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
659
|
+
}
|
|
660
|
+
implicit.forEach(function(type$1) {
|
|
661
|
+
if (!(type$1 instanceof type)) {
|
|
662
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
663
|
+
}
|
|
664
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
665
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
666
|
+
}
|
|
667
|
+
if (type$1.multi) {
|
|
668
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
explicit.forEach(function(type$1) {
|
|
672
|
+
if (!(type$1 instanceof type)) {
|
|
673
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
var result = Object.create(Schema$1.prototype);
|
|
677
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
678
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
679
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
680
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
681
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
682
|
+
return result;
|
|
683
|
+
};
|
|
684
|
+
var schema = Schema$1;
|
|
685
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
686
|
+
kind: "scalar",
|
|
687
|
+
construct: function(data) {
|
|
688
|
+
return data !== null ? data : "";
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
692
|
+
kind: "sequence",
|
|
693
|
+
construct: function(data) {
|
|
694
|
+
return data !== null ? data : [];
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
698
|
+
kind: "mapping",
|
|
699
|
+
construct: function(data) {
|
|
700
|
+
return data !== null ? data : {};
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
var failsafe = new schema({
|
|
704
|
+
explicit: [
|
|
705
|
+
str,
|
|
706
|
+
seq,
|
|
707
|
+
map
|
|
708
|
+
]
|
|
709
|
+
});
|
|
710
|
+
function resolveYamlNull(data) {
|
|
711
|
+
if (data === null)
|
|
712
|
+
return true;
|
|
713
|
+
var max = data.length;
|
|
714
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
715
|
+
}
|
|
716
|
+
function constructYamlNull() {
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
function isNull(object) {
|
|
720
|
+
return object === null;
|
|
721
|
+
}
|
|
722
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
723
|
+
kind: "scalar",
|
|
724
|
+
resolve: resolveYamlNull,
|
|
725
|
+
construct: constructYamlNull,
|
|
726
|
+
predicate: isNull,
|
|
727
|
+
represent: {
|
|
728
|
+
canonical: function() {
|
|
729
|
+
return "~";
|
|
730
|
+
},
|
|
731
|
+
lowercase: function() {
|
|
732
|
+
return "null";
|
|
733
|
+
},
|
|
734
|
+
uppercase: function() {
|
|
735
|
+
return "NULL";
|
|
736
|
+
},
|
|
737
|
+
camelcase: function() {
|
|
738
|
+
return "Null";
|
|
739
|
+
},
|
|
740
|
+
empty: function() {
|
|
741
|
+
return "";
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
defaultStyle: "lowercase"
|
|
745
|
+
});
|
|
746
|
+
function resolveYamlBoolean(data) {
|
|
747
|
+
if (data === null)
|
|
748
|
+
return false;
|
|
749
|
+
var max = data.length;
|
|
750
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
751
|
+
}
|
|
752
|
+
function constructYamlBoolean(data) {
|
|
753
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
754
|
+
}
|
|
755
|
+
function isBoolean(object) {
|
|
756
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
757
|
+
}
|
|
758
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
759
|
+
kind: "scalar",
|
|
760
|
+
resolve: resolveYamlBoolean,
|
|
761
|
+
construct: constructYamlBoolean,
|
|
762
|
+
predicate: isBoolean,
|
|
763
|
+
represent: {
|
|
764
|
+
lowercase: function(object) {
|
|
765
|
+
return object ? "true" : "false";
|
|
766
|
+
},
|
|
767
|
+
uppercase: function(object) {
|
|
768
|
+
return object ? "TRUE" : "FALSE";
|
|
769
|
+
},
|
|
770
|
+
camelcase: function(object) {
|
|
771
|
+
return object ? "True" : "False";
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
defaultStyle: "lowercase"
|
|
775
|
+
});
|
|
776
|
+
function isHexCode(c) {
|
|
777
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
778
|
+
}
|
|
779
|
+
function isOctCode(c) {
|
|
780
|
+
return 48 <= c && c <= 55;
|
|
781
|
+
}
|
|
782
|
+
function isDecCode(c) {
|
|
783
|
+
return 48 <= c && c <= 57;
|
|
784
|
+
}
|
|
785
|
+
function resolveYamlInteger(data) {
|
|
786
|
+
if (data === null)
|
|
787
|
+
return false;
|
|
788
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
789
|
+
if (!max)
|
|
790
|
+
return false;
|
|
791
|
+
ch = data[index];
|
|
792
|
+
if (ch === "-" || ch === "+") {
|
|
793
|
+
ch = data[++index];
|
|
794
|
+
}
|
|
795
|
+
if (ch === "0") {
|
|
796
|
+
if (index + 1 === max)
|
|
797
|
+
return true;
|
|
798
|
+
ch = data[++index];
|
|
799
|
+
if (ch === "b") {
|
|
800
|
+
index++;
|
|
801
|
+
for (;index < max; index++) {
|
|
802
|
+
ch = data[index];
|
|
803
|
+
if (ch === "_")
|
|
804
|
+
continue;
|
|
805
|
+
if (ch !== "0" && ch !== "1")
|
|
806
|
+
return false;
|
|
807
|
+
hasDigits = true;
|
|
808
|
+
}
|
|
809
|
+
return hasDigits && ch !== "_";
|
|
810
|
+
}
|
|
811
|
+
if (ch === "x") {
|
|
812
|
+
index++;
|
|
813
|
+
for (;index < max; index++) {
|
|
814
|
+
ch = data[index];
|
|
815
|
+
if (ch === "_")
|
|
816
|
+
continue;
|
|
817
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
818
|
+
return false;
|
|
819
|
+
hasDigits = true;
|
|
820
|
+
}
|
|
821
|
+
return hasDigits && ch !== "_";
|
|
822
|
+
}
|
|
823
|
+
if (ch === "o") {
|
|
824
|
+
index++;
|
|
825
|
+
for (;index < max; index++) {
|
|
826
|
+
ch = data[index];
|
|
827
|
+
if (ch === "_")
|
|
828
|
+
continue;
|
|
829
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
830
|
+
return false;
|
|
831
|
+
hasDigits = true;
|
|
832
|
+
}
|
|
833
|
+
return hasDigits && ch !== "_";
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
if (ch === "_")
|
|
837
|
+
return false;
|
|
838
|
+
for (;index < max; index++) {
|
|
839
|
+
ch = data[index];
|
|
840
|
+
if (ch === "_")
|
|
841
|
+
continue;
|
|
842
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
843
|
+
return false;
|
|
844
|
+
}
|
|
845
|
+
hasDigits = true;
|
|
846
|
+
}
|
|
847
|
+
if (!hasDigits || ch === "_")
|
|
848
|
+
return false;
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
function constructYamlInteger(data) {
|
|
852
|
+
var value = data, sign = 1, ch;
|
|
853
|
+
if (value.indexOf("_") !== -1) {
|
|
854
|
+
value = value.replace(/_/g, "");
|
|
855
|
+
}
|
|
856
|
+
ch = value[0];
|
|
857
|
+
if (ch === "-" || ch === "+") {
|
|
858
|
+
if (ch === "-")
|
|
859
|
+
sign = -1;
|
|
860
|
+
value = value.slice(1);
|
|
861
|
+
ch = value[0];
|
|
862
|
+
}
|
|
863
|
+
if (value === "0")
|
|
864
|
+
return 0;
|
|
865
|
+
if (ch === "0") {
|
|
866
|
+
if (value[1] === "b")
|
|
867
|
+
return sign * parseInt(value.slice(2), 2);
|
|
868
|
+
if (value[1] === "x")
|
|
869
|
+
return sign * parseInt(value.slice(2), 16);
|
|
870
|
+
if (value[1] === "o")
|
|
871
|
+
return sign * parseInt(value.slice(2), 8);
|
|
872
|
+
}
|
|
873
|
+
return sign * parseInt(value, 10);
|
|
874
|
+
}
|
|
875
|
+
function isInteger(object) {
|
|
876
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
877
|
+
}
|
|
878
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
879
|
+
kind: "scalar",
|
|
880
|
+
resolve: resolveYamlInteger,
|
|
881
|
+
construct: constructYamlInteger,
|
|
882
|
+
predicate: isInteger,
|
|
883
|
+
represent: {
|
|
884
|
+
binary: function(obj) {
|
|
885
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
886
|
+
},
|
|
887
|
+
octal: function(obj) {
|
|
888
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
889
|
+
},
|
|
890
|
+
decimal: function(obj) {
|
|
891
|
+
return obj.toString(10);
|
|
892
|
+
},
|
|
893
|
+
hexadecimal: function(obj) {
|
|
894
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
defaultStyle: "decimal",
|
|
898
|
+
styleAliases: {
|
|
899
|
+
binary: [2, "bin"],
|
|
900
|
+
octal: [8, "oct"],
|
|
901
|
+
decimal: [10, "dec"],
|
|
902
|
+
hexadecimal: [16, "hex"]
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
var YAML_FLOAT_PATTERN = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?" + "|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?" + "|[-+]?\\.(?:inf|Inf|INF)" + "|\\.(?:nan|NaN|NAN))$");
|
|
906
|
+
function resolveYamlFloat(data) {
|
|
907
|
+
if (data === null)
|
|
908
|
+
return false;
|
|
909
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
return true;
|
|
913
|
+
}
|
|
914
|
+
function constructYamlFloat(data) {
|
|
915
|
+
var value, sign;
|
|
916
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
917
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
918
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
919
|
+
value = value.slice(1);
|
|
920
|
+
}
|
|
921
|
+
if (value === ".inf") {
|
|
922
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
923
|
+
} else if (value === ".nan") {
|
|
924
|
+
return NaN;
|
|
925
|
+
}
|
|
926
|
+
return sign * parseFloat(value, 10);
|
|
927
|
+
}
|
|
928
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
929
|
+
function representYamlFloat(object, style) {
|
|
930
|
+
var res;
|
|
931
|
+
if (isNaN(object)) {
|
|
932
|
+
switch (style) {
|
|
933
|
+
case "lowercase":
|
|
934
|
+
return ".nan";
|
|
935
|
+
case "uppercase":
|
|
936
|
+
return ".NAN";
|
|
937
|
+
case "camelcase":
|
|
938
|
+
return ".NaN";
|
|
939
|
+
}
|
|
940
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
941
|
+
switch (style) {
|
|
942
|
+
case "lowercase":
|
|
943
|
+
return ".inf";
|
|
944
|
+
case "uppercase":
|
|
945
|
+
return ".INF";
|
|
946
|
+
case "camelcase":
|
|
947
|
+
return ".Inf";
|
|
948
|
+
}
|
|
949
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
950
|
+
switch (style) {
|
|
951
|
+
case "lowercase":
|
|
952
|
+
return "-.inf";
|
|
953
|
+
case "uppercase":
|
|
954
|
+
return "-.INF";
|
|
955
|
+
case "camelcase":
|
|
956
|
+
return "-.Inf";
|
|
957
|
+
}
|
|
958
|
+
} else if (common.isNegativeZero(object)) {
|
|
959
|
+
return "-0.0";
|
|
960
|
+
}
|
|
961
|
+
res = object.toString(10);
|
|
962
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
963
|
+
}
|
|
964
|
+
function isFloat(object) {
|
|
965
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
966
|
+
}
|
|
967
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
968
|
+
kind: "scalar",
|
|
969
|
+
resolve: resolveYamlFloat,
|
|
970
|
+
construct: constructYamlFloat,
|
|
971
|
+
predicate: isFloat,
|
|
972
|
+
represent: representYamlFloat,
|
|
973
|
+
defaultStyle: "lowercase"
|
|
974
|
+
});
|
|
975
|
+
var json = failsafe.extend({
|
|
976
|
+
implicit: [
|
|
977
|
+
_null,
|
|
978
|
+
bool,
|
|
979
|
+
int,
|
|
980
|
+
float
|
|
981
|
+
]
|
|
982
|
+
});
|
|
983
|
+
var core = json;
|
|
984
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
985
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9]?)" + "-([0-9][0-9]?)" + "(?:[Tt]|[ \\t]+)" + "([0-9][0-9]?)" + ":([0-9][0-9])" + ":([0-9][0-9])" + "(?:\\.([0-9]*))?" + "(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + "(?::([0-9][0-9]))?))?$");
|
|
986
|
+
function resolveYamlTimestamp(data) {
|
|
987
|
+
if (data === null)
|
|
988
|
+
return false;
|
|
989
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
990
|
+
return true;
|
|
991
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
992
|
+
return true;
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
function constructYamlTimestamp(data) {
|
|
996
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
997
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
998
|
+
if (match === null)
|
|
999
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
1000
|
+
if (match === null)
|
|
1001
|
+
throw new Error("Date resolve error");
|
|
1002
|
+
year = +match[1];
|
|
1003
|
+
month = +match[2] - 1;
|
|
1004
|
+
day = +match[3];
|
|
1005
|
+
if (!match[4]) {
|
|
1006
|
+
return new Date(Date.UTC(year, month, day));
|
|
1007
|
+
}
|
|
1008
|
+
hour = +match[4];
|
|
1009
|
+
minute = +match[5];
|
|
1010
|
+
second = +match[6];
|
|
1011
|
+
if (match[7]) {
|
|
1012
|
+
fraction = match[7].slice(0, 3);
|
|
1013
|
+
while (fraction.length < 3) {
|
|
1014
|
+
fraction += "0";
|
|
1015
|
+
}
|
|
1016
|
+
fraction = +fraction;
|
|
1017
|
+
}
|
|
1018
|
+
if (match[9]) {
|
|
1019
|
+
tz_hour = +match[10];
|
|
1020
|
+
tz_minute = +(match[11] || 0);
|
|
1021
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
1022
|
+
if (match[9] === "-")
|
|
1023
|
+
delta = -delta;
|
|
1024
|
+
}
|
|
1025
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
1026
|
+
if (delta)
|
|
1027
|
+
date.setTime(date.getTime() - delta);
|
|
1028
|
+
return date;
|
|
1029
|
+
}
|
|
1030
|
+
function representYamlTimestamp(object) {
|
|
1031
|
+
return object.toISOString();
|
|
1032
|
+
}
|
|
1033
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
1034
|
+
kind: "scalar",
|
|
1035
|
+
resolve: resolveYamlTimestamp,
|
|
1036
|
+
construct: constructYamlTimestamp,
|
|
1037
|
+
instanceOf: Date,
|
|
1038
|
+
represent: representYamlTimestamp
|
|
1039
|
+
});
|
|
1040
|
+
function resolveYamlMerge(data) {
|
|
1041
|
+
return data === "<<" || data === null;
|
|
1042
|
+
}
|
|
1043
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
1044
|
+
kind: "scalar",
|
|
1045
|
+
resolve: resolveYamlMerge
|
|
1046
|
+
});
|
|
1047
|
+
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
1048
|
+
\r`;
|
|
1049
|
+
function resolveYamlBinary(data) {
|
|
1050
|
+
if (data === null)
|
|
1051
|
+
return false;
|
|
1052
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
1053
|
+
for (idx = 0;idx < max; idx++) {
|
|
1054
|
+
code = map2.indexOf(data.charAt(idx));
|
|
1055
|
+
if (code > 64)
|
|
1056
|
+
continue;
|
|
1057
|
+
if (code < 0)
|
|
1058
|
+
return false;
|
|
1059
|
+
bitlen += 6;
|
|
1060
|
+
}
|
|
1061
|
+
return bitlen % 8 === 0;
|
|
1062
|
+
}
|
|
1063
|
+
function constructYamlBinary(data) {
|
|
1064
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
1065
|
+
for (idx = 0;idx < max; idx++) {
|
|
1066
|
+
if (idx % 4 === 0 && idx) {
|
|
1067
|
+
result.push(bits >> 16 & 255);
|
|
1068
|
+
result.push(bits >> 8 & 255);
|
|
1069
|
+
result.push(bits & 255);
|
|
1070
|
+
}
|
|
1071
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
1072
|
+
}
|
|
1073
|
+
tailbits = max % 4 * 6;
|
|
1074
|
+
if (tailbits === 0) {
|
|
1075
|
+
result.push(bits >> 16 & 255);
|
|
1076
|
+
result.push(bits >> 8 & 255);
|
|
1077
|
+
result.push(bits & 255);
|
|
1078
|
+
} else if (tailbits === 18) {
|
|
1079
|
+
result.push(bits >> 10 & 255);
|
|
1080
|
+
result.push(bits >> 2 & 255);
|
|
1081
|
+
} else if (tailbits === 12) {
|
|
1082
|
+
result.push(bits >> 4 & 255);
|
|
1083
|
+
}
|
|
1084
|
+
return new Uint8Array(result);
|
|
1085
|
+
}
|
|
1086
|
+
function representYamlBinary(object) {
|
|
1087
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
1088
|
+
for (idx = 0;idx < max; idx++) {
|
|
1089
|
+
if (idx % 3 === 0 && idx) {
|
|
1090
|
+
result += map2[bits >> 18 & 63];
|
|
1091
|
+
result += map2[bits >> 12 & 63];
|
|
1092
|
+
result += map2[bits >> 6 & 63];
|
|
1093
|
+
result += map2[bits & 63];
|
|
1094
|
+
}
|
|
1095
|
+
bits = (bits << 8) + object[idx];
|
|
1096
|
+
}
|
|
1097
|
+
tail = max % 3;
|
|
1098
|
+
if (tail === 0) {
|
|
1099
|
+
result += map2[bits >> 18 & 63];
|
|
1100
|
+
result += map2[bits >> 12 & 63];
|
|
1101
|
+
result += map2[bits >> 6 & 63];
|
|
1102
|
+
result += map2[bits & 63];
|
|
1103
|
+
} else if (tail === 2) {
|
|
1104
|
+
result += map2[bits >> 10 & 63];
|
|
1105
|
+
result += map2[bits >> 4 & 63];
|
|
1106
|
+
result += map2[bits << 2 & 63];
|
|
1107
|
+
result += map2[64];
|
|
1108
|
+
} else if (tail === 1) {
|
|
1109
|
+
result += map2[bits >> 2 & 63];
|
|
1110
|
+
result += map2[bits << 4 & 63];
|
|
1111
|
+
result += map2[64];
|
|
1112
|
+
result += map2[64];
|
|
1113
|
+
}
|
|
1114
|
+
return result;
|
|
1115
|
+
}
|
|
1116
|
+
function isBinary(obj) {
|
|
1117
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
1118
|
+
}
|
|
1119
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
1120
|
+
kind: "scalar",
|
|
1121
|
+
resolve: resolveYamlBinary,
|
|
1122
|
+
construct: constructYamlBinary,
|
|
1123
|
+
predicate: isBinary,
|
|
1124
|
+
represent: representYamlBinary
|
|
1125
|
+
});
|
|
1126
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1127
|
+
var _toString$2 = Object.prototype.toString;
|
|
1128
|
+
function resolveYamlOmap(data) {
|
|
1129
|
+
if (data === null)
|
|
1130
|
+
return true;
|
|
1131
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1132
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1133
|
+
pair = object[index];
|
|
1134
|
+
pairHasKey = false;
|
|
1135
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
1136
|
+
return false;
|
|
1137
|
+
for (pairKey in pair) {
|
|
1138
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
1139
|
+
if (!pairHasKey)
|
|
1140
|
+
pairHasKey = true;
|
|
1141
|
+
else
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (!pairHasKey)
|
|
1146
|
+
return false;
|
|
1147
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
1148
|
+
objectKeys.push(pairKey);
|
|
1149
|
+
else
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
return true;
|
|
1153
|
+
}
|
|
1154
|
+
function constructYamlOmap(data) {
|
|
1155
|
+
return data !== null ? data : [];
|
|
1156
|
+
}
|
|
1157
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
1158
|
+
kind: "sequence",
|
|
1159
|
+
resolve: resolveYamlOmap,
|
|
1160
|
+
construct: constructYamlOmap
|
|
1161
|
+
});
|
|
1162
|
+
var _toString$1 = Object.prototype.toString;
|
|
1163
|
+
function resolveYamlPairs(data) {
|
|
1164
|
+
if (data === null)
|
|
1165
|
+
return true;
|
|
1166
|
+
var index, length, pair, keys, result, object = data;
|
|
1167
|
+
result = new Array(object.length);
|
|
1168
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1169
|
+
pair = object[index];
|
|
1170
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
1171
|
+
return false;
|
|
1172
|
+
keys = Object.keys(pair);
|
|
1173
|
+
if (keys.length !== 1)
|
|
1174
|
+
return false;
|
|
1175
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1176
|
+
}
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
function constructYamlPairs(data) {
|
|
1180
|
+
if (data === null)
|
|
1181
|
+
return [];
|
|
1182
|
+
var index, length, pair, keys, result, object = data;
|
|
1183
|
+
result = new Array(object.length);
|
|
1184
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1185
|
+
pair = object[index];
|
|
1186
|
+
keys = Object.keys(pair);
|
|
1187
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1188
|
+
}
|
|
1189
|
+
return result;
|
|
1190
|
+
}
|
|
1191
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
1192
|
+
kind: "sequence",
|
|
1193
|
+
resolve: resolveYamlPairs,
|
|
1194
|
+
construct: constructYamlPairs
|
|
1195
|
+
});
|
|
1196
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1197
|
+
function resolveYamlSet(data) {
|
|
1198
|
+
if (data === null)
|
|
1199
|
+
return true;
|
|
1200
|
+
var key, object = data;
|
|
1201
|
+
for (key in object) {
|
|
1202
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
1203
|
+
if (object[key] !== null)
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return true;
|
|
1208
|
+
}
|
|
1209
|
+
function constructYamlSet(data) {
|
|
1210
|
+
return data !== null ? data : {};
|
|
1211
|
+
}
|
|
1212
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
1213
|
+
kind: "mapping",
|
|
1214
|
+
resolve: resolveYamlSet,
|
|
1215
|
+
construct: constructYamlSet
|
|
1216
|
+
});
|
|
1217
|
+
var _default = core.extend({
|
|
1218
|
+
implicit: [
|
|
1219
|
+
timestamp,
|
|
1220
|
+
merge
|
|
1221
|
+
],
|
|
1222
|
+
explicit: [
|
|
1223
|
+
binary,
|
|
1224
|
+
omap,
|
|
1225
|
+
pairs,
|
|
1226
|
+
set
|
|
1227
|
+
]
|
|
1228
|
+
});
|
|
1229
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1230
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1231
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1232
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1233
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1234
|
+
var CHOMPING_CLIP = 1;
|
|
1235
|
+
var CHOMPING_STRIP = 2;
|
|
1236
|
+
var CHOMPING_KEEP = 3;
|
|
1237
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1238
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1239
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1240
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1241
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1242
|
+
function _class(obj) {
|
|
1243
|
+
return Object.prototype.toString.call(obj);
|
|
1244
|
+
}
|
|
1245
|
+
function is_EOL(c) {
|
|
1246
|
+
return c === 10 || c === 13;
|
|
1247
|
+
}
|
|
1248
|
+
function is_WHITE_SPACE(c) {
|
|
1249
|
+
return c === 9 || c === 32;
|
|
1250
|
+
}
|
|
1251
|
+
function is_WS_OR_EOL(c) {
|
|
1252
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1253
|
+
}
|
|
1254
|
+
function is_FLOW_INDICATOR(c) {
|
|
1255
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1256
|
+
}
|
|
1257
|
+
function fromHexCode(c) {
|
|
1258
|
+
var lc;
|
|
1259
|
+
if (48 <= c && c <= 57) {
|
|
1260
|
+
return c - 48;
|
|
1261
|
+
}
|
|
1262
|
+
lc = c | 32;
|
|
1263
|
+
if (97 <= lc && lc <= 102) {
|
|
1264
|
+
return lc - 97 + 10;
|
|
1265
|
+
}
|
|
1266
|
+
return -1;
|
|
1267
|
+
}
|
|
1268
|
+
function escapedHexLen(c) {
|
|
1269
|
+
if (c === 120) {
|
|
1270
|
+
return 2;
|
|
1271
|
+
}
|
|
1272
|
+
if (c === 117) {
|
|
1273
|
+
return 4;
|
|
1274
|
+
}
|
|
1275
|
+
if (c === 85) {
|
|
1276
|
+
return 8;
|
|
1277
|
+
}
|
|
1278
|
+
return 0;
|
|
1279
|
+
}
|
|
1280
|
+
function fromDecimalCode(c) {
|
|
1281
|
+
if (48 <= c && c <= 57) {
|
|
1282
|
+
return c - 48;
|
|
1283
|
+
}
|
|
1284
|
+
return -1;
|
|
1285
|
+
}
|
|
1286
|
+
function simpleEscapeSequence(c) {
|
|
1287
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
1288
|
+
` : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "
" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
1289
|
+
}
|
|
1290
|
+
function charFromCodepoint(c) {
|
|
1291
|
+
if (c <= 65535) {
|
|
1292
|
+
return String.fromCharCode(c);
|
|
1293
|
+
}
|
|
1294
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1295
|
+
}
|
|
1296
|
+
function setProperty(object, key, value) {
|
|
1297
|
+
if (key === "__proto__") {
|
|
1298
|
+
Object.defineProperty(object, key, {
|
|
1299
|
+
configurable: true,
|
|
1300
|
+
enumerable: true,
|
|
1301
|
+
writable: true,
|
|
1302
|
+
value
|
|
1303
|
+
});
|
|
1304
|
+
} else {
|
|
1305
|
+
object[key] = value;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
var simpleEscapeCheck = new Array(256);
|
|
1309
|
+
var simpleEscapeMap = new Array(256);
|
|
1310
|
+
for (i = 0;i < 256; i++) {
|
|
1311
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1312
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1313
|
+
}
|
|
1314
|
+
var i;
|
|
1315
|
+
function State$1(input, options) {
|
|
1316
|
+
this.input = input;
|
|
1317
|
+
this.filename = options["filename"] || null;
|
|
1318
|
+
this.schema = options["schema"] || _default;
|
|
1319
|
+
this.onWarning = options["onWarning"] || null;
|
|
1320
|
+
this.legacy = options["legacy"] || false;
|
|
1321
|
+
this.json = options["json"] || false;
|
|
1322
|
+
this.listener = options["listener"] || null;
|
|
1323
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1324
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1325
|
+
this.length = input.length;
|
|
1326
|
+
this.position = 0;
|
|
1327
|
+
this.line = 0;
|
|
1328
|
+
this.lineStart = 0;
|
|
1329
|
+
this.lineIndent = 0;
|
|
1330
|
+
this.firstTabInLine = -1;
|
|
1331
|
+
this.documents = [];
|
|
1332
|
+
}
|
|
1333
|
+
function generateError(state, message) {
|
|
1334
|
+
var mark = {
|
|
1335
|
+
name: state.filename,
|
|
1336
|
+
buffer: state.input.slice(0, -1),
|
|
1337
|
+
position: state.position,
|
|
1338
|
+
line: state.line,
|
|
1339
|
+
column: state.position - state.lineStart
|
|
1340
|
+
};
|
|
1341
|
+
mark.snippet = snippet(mark);
|
|
1342
|
+
return new exception(message, mark);
|
|
1343
|
+
}
|
|
1344
|
+
function throwError(state, message) {
|
|
1345
|
+
throw generateError(state, message);
|
|
1346
|
+
}
|
|
1347
|
+
function throwWarning(state, message) {
|
|
1348
|
+
if (state.onWarning) {
|
|
1349
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
var directiveHandlers = {
|
|
1353
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1354
|
+
var match, major, minor;
|
|
1355
|
+
if (state.version !== null) {
|
|
1356
|
+
throwError(state, "duplication of %YAML directive");
|
|
1357
|
+
}
|
|
1358
|
+
if (args.length !== 1) {
|
|
1359
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1360
|
+
}
|
|
1361
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1362
|
+
if (match === null) {
|
|
1363
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1364
|
+
}
|
|
1365
|
+
major = parseInt(match[1], 10);
|
|
1366
|
+
minor = parseInt(match[2], 10);
|
|
1367
|
+
if (major !== 1) {
|
|
1368
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1369
|
+
}
|
|
1370
|
+
state.version = args[0];
|
|
1371
|
+
state.checkLineBreaks = minor < 2;
|
|
1372
|
+
if (minor !== 1 && minor !== 2) {
|
|
1373
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1377
|
+
var handle, prefix;
|
|
1378
|
+
if (args.length !== 2) {
|
|
1379
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1380
|
+
}
|
|
1381
|
+
handle = args[0];
|
|
1382
|
+
prefix = args[1];
|
|
1383
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1384
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1385
|
+
}
|
|
1386
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1387
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1388
|
+
}
|
|
1389
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1390
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1391
|
+
}
|
|
1392
|
+
try {
|
|
1393
|
+
prefix = decodeURIComponent(prefix);
|
|
1394
|
+
} catch (err) {
|
|
1395
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1396
|
+
}
|
|
1397
|
+
state.tagMap[handle] = prefix;
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1401
|
+
var _position, _length, _character, _result;
|
|
1402
|
+
if (start < end) {
|
|
1403
|
+
_result = state.input.slice(start, end);
|
|
1404
|
+
if (checkJson) {
|
|
1405
|
+
for (_position = 0, _length = _result.length;_position < _length; _position += 1) {
|
|
1406
|
+
_character = _result.charCodeAt(_position);
|
|
1407
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1408
|
+
throwError(state, "expected valid JSON character");
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1412
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1413
|
+
}
|
|
1414
|
+
state.result += _result;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1418
|
+
var sourceKeys, key, index, quantity;
|
|
1419
|
+
if (!common.isObject(source)) {
|
|
1420
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1421
|
+
}
|
|
1422
|
+
sourceKeys = Object.keys(source);
|
|
1423
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
1424
|
+
key = sourceKeys[index];
|
|
1425
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1426
|
+
setProperty(destination, key, source[key]);
|
|
1427
|
+
overridableKeys[key] = true;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1432
|
+
var index, quantity;
|
|
1433
|
+
if (Array.isArray(keyNode)) {
|
|
1434
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1435
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
1436
|
+
if (Array.isArray(keyNode[index])) {
|
|
1437
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1438
|
+
}
|
|
1439
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1440
|
+
keyNode[index] = "[object Object]";
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1445
|
+
keyNode = "[object Object]";
|
|
1446
|
+
}
|
|
1447
|
+
keyNode = String(keyNode);
|
|
1448
|
+
if (_result === null) {
|
|
1449
|
+
_result = {};
|
|
1450
|
+
}
|
|
1451
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1452
|
+
if (Array.isArray(valueNode)) {
|
|
1453
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
1454
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1455
|
+
}
|
|
1456
|
+
} else {
|
|
1457
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1458
|
+
}
|
|
1459
|
+
} else {
|
|
1460
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1461
|
+
state.line = startLine || state.line;
|
|
1462
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1463
|
+
state.position = startPos || state.position;
|
|
1464
|
+
throwError(state, "duplicated mapping key");
|
|
1465
|
+
}
|
|
1466
|
+
setProperty(_result, keyNode, valueNode);
|
|
1467
|
+
delete overridableKeys[keyNode];
|
|
1468
|
+
}
|
|
1469
|
+
return _result;
|
|
1470
|
+
}
|
|
1471
|
+
function readLineBreak(state) {
|
|
1472
|
+
var ch;
|
|
1473
|
+
ch = state.input.charCodeAt(state.position);
|
|
1474
|
+
if (ch === 10) {
|
|
1475
|
+
state.position++;
|
|
1476
|
+
} else if (ch === 13) {
|
|
1477
|
+
state.position++;
|
|
1478
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1479
|
+
state.position++;
|
|
1480
|
+
}
|
|
1481
|
+
} else {
|
|
1482
|
+
throwError(state, "a line break is expected");
|
|
1483
|
+
}
|
|
1484
|
+
state.line += 1;
|
|
1485
|
+
state.lineStart = state.position;
|
|
1486
|
+
state.firstTabInLine = -1;
|
|
1487
|
+
}
|
|
1488
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1489
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1490
|
+
while (ch !== 0) {
|
|
1491
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1492
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1493
|
+
state.firstTabInLine = state.position;
|
|
1494
|
+
}
|
|
1495
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1496
|
+
}
|
|
1497
|
+
if (allowComments && ch === 35) {
|
|
1498
|
+
do {
|
|
1499
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1500
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1501
|
+
}
|
|
1502
|
+
if (is_EOL(ch)) {
|
|
1503
|
+
readLineBreak(state);
|
|
1504
|
+
ch = state.input.charCodeAt(state.position);
|
|
1505
|
+
lineBreaks++;
|
|
1506
|
+
state.lineIndent = 0;
|
|
1507
|
+
while (ch === 32) {
|
|
1508
|
+
state.lineIndent++;
|
|
1509
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1510
|
+
}
|
|
1511
|
+
} else {
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1516
|
+
throwWarning(state, "deficient indentation");
|
|
1517
|
+
}
|
|
1518
|
+
return lineBreaks;
|
|
1519
|
+
}
|
|
1520
|
+
function testDocumentSeparator(state) {
|
|
1521
|
+
var _position = state.position, ch;
|
|
1522
|
+
ch = state.input.charCodeAt(_position);
|
|
1523
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1524
|
+
_position += 3;
|
|
1525
|
+
ch = state.input.charCodeAt(_position);
|
|
1526
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1527
|
+
return true;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return false;
|
|
1531
|
+
}
|
|
1532
|
+
function writeFoldedLines(state, count) {
|
|
1533
|
+
if (count === 1) {
|
|
1534
|
+
state.result += " ";
|
|
1535
|
+
} else if (count > 1) {
|
|
1536
|
+
state.result += common.repeat(`
|
|
1537
|
+
`, count - 1);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1541
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1542
|
+
ch = state.input.charCodeAt(state.position);
|
|
1543
|
+
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) {
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
if (ch === 63 || ch === 45) {
|
|
1547
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1548
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1549
|
+
return false;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
state.kind = "scalar";
|
|
1553
|
+
state.result = "";
|
|
1554
|
+
captureStart = captureEnd = state.position;
|
|
1555
|
+
hasPendingContent = false;
|
|
1556
|
+
while (ch !== 0) {
|
|
1557
|
+
if (ch === 58) {
|
|
1558
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1559
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
} else if (ch === 35) {
|
|
1563
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1564
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1565
|
+
break;
|
|
1566
|
+
}
|
|
1567
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1568
|
+
break;
|
|
1569
|
+
} else if (is_EOL(ch)) {
|
|
1570
|
+
_line = state.line;
|
|
1571
|
+
_lineStart = state.lineStart;
|
|
1572
|
+
_lineIndent = state.lineIndent;
|
|
1573
|
+
skipSeparationSpace(state, false, -1);
|
|
1574
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1575
|
+
hasPendingContent = true;
|
|
1576
|
+
ch = state.input.charCodeAt(state.position);
|
|
1577
|
+
continue;
|
|
1578
|
+
} else {
|
|
1579
|
+
state.position = captureEnd;
|
|
1580
|
+
state.line = _line;
|
|
1581
|
+
state.lineStart = _lineStart;
|
|
1582
|
+
state.lineIndent = _lineIndent;
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
if (hasPendingContent) {
|
|
1587
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1588
|
+
writeFoldedLines(state, state.line - _line);
|
|
1589
|
+
captureStart = captureEnd = state.position;
|
|
1590
|
+
hasPendingContent = false;
|
|
1591
|
+
}
|
|
1592
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1593
|
+
captureEnd = state.position + 1;
|
|
1594
|
+
}
|
|
1595
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1596
|
+
}
|
|
1597
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1598
|
+
if (state.result) {
|
|
1599
|
+
return true;
|
|
1600
|
+
}
|
|
1601
|
+
state.kind = _kind;
|
|
1602
|
+
state.result = _result;
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1606
|
+
var ch, captureStart, captureEnd;
|
|
1607
|
+
ch = state.input.charCodeAt(state.position);
|
|
1608
|
+
if (ch !== 39) {
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
state.kind = "scalar";
|
|
1612
|
+
state.result = "";
|
|
1613
|
+
state.position++;
|
|
1614
|
+
captureStart = captureEnd = state.position;
|
|
1615
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1616
|
+
if (ch === 39) {
|
|
1617
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1618
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1619
|
+
if (ch === 39) {
|
|
1620
|
+
captureStart = state.position;
|
|
1621
|
+
state.position++;
|
|
1622
|
+
captureEnd = state.position;
|
|
1623
|
+
} else {
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
} else if (is_EOL(ch)) {
|
|
1627
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1628
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1629
|
+
captureStart = captureEnd = state.position;
|
|
1630
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1631
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1632
|
+
} else {
|
|
1633
|
+
state.position++;
|
|
1634
|
+
captureEnd = state.position;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1638
|
+
}
|
|
1639
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1640
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1641
|
+
ch = state.input.charCodeAt(state.position);
|
|
1642
|
+
if (ch !== 34) {
|
|
1643
|
+
return false;
|
|
1644
|
+
}
|
|
1645
|
+
state.kind = "scalar";
|
|
1646
|
+
state.result = "";
|
|
1647
|
+
state.position++;
|
|
1648
|
+
captureStart = captureEnd = state.position;
|
|
1649
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1650
|
+
if (ch === 34) {
|
|
1651
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1652
|
+
state.position++;
|
|
1653
|
+
return true;
|
|
1654
|
+
} else if (ch === 92) {
|
|
1655
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1656
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1657
|
+
if (is_EOL(ch)) {
|
|
1658
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1659
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1660
|
+
state.result += simpleEscapeMap[ch];
|
|
1661
|
+
state.position++;
|
|
1662
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1663
|
+
hexLength = tmp;
|
|
1664
|
+
hexResult = 0;
|
|
1665
|
+
for (;hexLength > 0; hexLength--) {
|
|
1666
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1667
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1668
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1669
|
+
} else {
|
|
1670
|
+
throwError(state, "expected hexadecimal character");
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
state.result += charFromCodepoint(hexResult);
|
|
1674
|
+
state.position++;
|
|
1675
|
+
} else {
|
|
1676
|
+
throwError(state, "unknown escape sequence");
|
|
1677
|
+
}
|
|
1678
|
+
captureStart = captureEnd = state.position;
|
|
1679
|
+
} else if (is_EOL(ch)) {
|
|
1680
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1681
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1682
|
+
captureStart = captureEnd = state.position;
|
|
1683
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1684
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1685
|
+
} else {
|
|
1686
|
+
state.position++;
|
|
1687
|
+
captureEnd = state.position;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1691
|
+
}
|
|
1692
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1693
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1694
|
+
ch = state.input.charCodeAt(state.position);
|
|
1695
|
+
if (ch === 91) {
|
|
1696
|
+
terminator = 93;
|
|
1697
|
+
isMapping = false;
|
|
1698
|
+
_result = [];
|
|
1699
|
+
} else if (ch === 123) {
|
|
1700
|
+
terminator = 125;
|
|
1701
|
+
isMapping = true;
|
|
1702
|
+
_result = {};
|
|
1703
|
+
} else {
|
|
1704
|
+
return false;
|
|
1705
|
+
}
|
|
1706
|
+
if (state.anchor !== null) {
|
|
1707
|
+
state.anchorMap[state.anchor] = _result;
|
|
1708
|
+
}
|
|
1709
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1710
|
+
while (ch !== 0) {
|
|
1711
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1712
|
+
ch = state.input.charCodeAt(state.position);
|
|
1713
|
+
if (ch === terminator) {
|
|
1714
|
+
state.position++;
|
|
1715
|
+
state.tag = _tag;
|
|
1716
|
+
state.anchor = _anchor;
|
|
1717
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1718
|
+
state.result = _result;
|
|
1719
|
+
return true;
|
|
1720
|
+
} else if (!readNext) {
|
|
1721
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1722
|
+
} else if (ch === 44) {
|
|
1723
|
+
throwError(state, "expected the node content, but found ','");
|
|
1724
|
+
}
|
|
1725
|
+
keyTag = keyNode = valueNode = null;
|
|
1726
|
+
isPair = isExplicitPair = false;
|
|
1727
|
+
if (ch === 63) {
|
|
1728
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1729
|
+
if (is_WS_OR_EOL(following)) {
|
|
1730
|
+
isPair = isExplicitPair = true;
|
|
1731
|
+
state.position++;
|
|
1732
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
_line = state.line;
|
|
1736
|
+
_lineStart = state.lineStart;
|
|
1737
|
+
_pos = state.position;
|
|
1738
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1739
|
+
keyTag = state.tag;
|
|
1740
|
+
keyNode = state.result;
|
|
1741
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1742
|
+
ch = state.input.charCodeAt(state.position);
|
|
1743
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1744
|
+
isPair = true;
|
|
1745
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1746
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1747
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1748
|
+
valueNode = state.result;
|
|
1749
|
+
}
|
|
1750
|
+
if (isMapping) {
|
|
1751
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1752
|
+
} else if (isPair) {
|
|
1753
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1754
|
+
} else {
|
|
1755
|
+
_result.push(keyNode);
|
|
1756
|
+
}
|
|
1757
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1758
|
+
ch = state.input.charCodeAt(state.position);
|
|
1759
|
+
if (ch === 44) {
|
|
1760
|
+
readNext = true;
|
|
1761
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1762
|
+
} else {
|
|
1763
|
+
readNext = false;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1767
|
+
}
|
|
1768
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1769
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1770
|
+
ch = state.input.charCodeAt(state.position);
|
|
1771
|
+
if (ch === 124) {
|
|
1772
|
+
folding = false;
|
|
1773
|
+
} else if (ch === 62) {
|
|
1774
|
+
folding = true;
|
|
1775
|
+
} else {
|
|
1776
|
+
return false;
|
|
1777
|
+
}
|
|
1778
|
+
state.kind = "scalar";
|
|
1779
|
+
state.result = "";
|
|
1780
|
+
while (ch !== 0) {
|
|
1781
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1782
|
+
if (ch === 43 || ch === 45) {
|
|
1783
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1784
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1785
|
+
} else {
|
|
1786
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1787
|
+
}
|
|
1788
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1789
|
+
if (tmp === 0) {
|
|
1790
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1791
|
+
} else if (!detectedIndent) {
|
|
1792
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1793
|
+
detectedIndent = true;
|
|
1794
|
+
} else {
|
|
1795
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1796
|
+
}
|
|
1797
|
+
} else {
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1802
|
+
do {
|
|
1803
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1804
|
+
} while (is_WHITE_SPACE(ch));
|
|
1805
|
+
if (ch === 35) {
|
|
1806
|
+
do {
|
|
1807
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1808
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
while (ch !== 0) {
|
|
1812
|
+
readLineBreak(state);
|
|
1813
|
+
state.lineIndent = 0;
|
|
1814
|
+
ch = state.input.charCodeAt(state.position);
|
|
1815
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1816
|
+
state.lineIndent++;
|
|
1817
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1818
|
+
}
|
|
1819
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1820
|
+
textIndent = state.lineIndent;
|
|
1821
|
+
}
|
|
1822
|
+
if (is_EOL(ch)) {
|
|
1823
|
+
emptyLines++;
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (state.lineIndent < textIndent) {
|
|
1827
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1828
|
+
state.result += common.repeat(`
|
|
1829
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1830
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1831
|
+
if (didReadContent) {
|
|
1832
|
+
state.result += `
|
|
1833
|
+
`;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
if (folding) {
|
|
1839
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1840
|
+
atMoreIndented = true;
|
|
1841
|
+
state.result += common.repeat(`
|
|
1842
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1843
|
+
} else if (atMoreIndented) {
|
|
1844
|
+
atMoreIndented = false;
|
|
1845
|
+
state.result += common.repeat(`
|
|
1846
|
+
`, emptyLines + 1);
|
|
1847
|
+
} else if (emptyLines === 0) {
|
|
1848
|
+
if (didReadContent) {
|
|
1849
|
+
state.result += " ";
|
|
1850
|
+
}
|
|
1851
|
+
} else {
|
|
1852
|
+
state.result += common.repeat(`
|
|
1853
|
+
`, emptyLines);
|
|
1854
|
+
}
|
|
1855
|
+
} else {
|
|
1856
|
+
state.result += common.repeat(`
|
|
1857
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1858
|
+
}
|
|
1859
|
+
didReadContent = true;
|
|
1860
|
+
detectedIndent = true;
|
|
1861
|
+
emptyLines = 0;
|
|
1862
|
+
captureStart = state.position;
|
|
1863
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1864
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1865
|
+
}
|
|
1866
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1867
|
+
}
|
|
1868
|
+
return true;
|
|
1869
|
+
}
|
|
1870
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1871
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1872
|
+
if (state.firstTabInLine !== -1)
|
|
1873
|
+
return false;
|
|
1874
|
+
if (state.anchor !== null) {
|
|
1875
|
+
state.anchorMap[state.anchor] = _result;
|
|
1876
|
+
}
|
|
1877
|
+
ch = state.input.charCodeAt(state.position);
|
|
1878
|
+
while (ch !== 0) {
|
|
1879
|
+
if (state.firstTabInLine !== -1) {
|
|
1880
|
+
state.position = state.firstTabInLine;
|
|
1881
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1882
|
+
}
|
|
1883
|
+
if (ch !== 45) {
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1887
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
detected = true;
|
|
1891
|
+
state.position++;
|
|
1892
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1893
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1894
|
+
_result.push(null);
|
|
1895
|
+
ch = state.input.charCodeAt(state.position);
|
|
1896
|
+
continue;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
_line = state.line;
|
|
1900
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1901
|
+
_result.push(state.result);
|
|
1902
|
+
skipSeparationSpace(state, true, -1);
|
|
1903
|
+
ch = state.input.charCodeAt(state.position);
|
|
1904
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1905
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1906
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1907
|
+
break;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
if (detected) {
|
|
1911
|
+
state.tag = _tag;
|
|
1912
|
+
state.anchor = _anchor;
|
|
1913
|
+
state.kind = "sequence";
|
|
1914
|
+
state.result = _result;
|
|
1915
|
+
return true;
|
|
1916
|
+
}
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1920
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1921
|
+
if (state.firstTabInLine !== -1)
|
|
1922
|
+
return false;
|
|
1923
|
+
if (state.anchor !== null) {
|
|
1924
|
+
state.anchorMap[state.anchor] = _result;
|
|
1925
|
+
}
|
|
1926
|
+
ch = state.input.charCodeAt(state.position);
|
|
1927
|
+
while (ch !== 0) {
|
|
1928
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1929
|
+
state.position = state.firstTabInLine;
|
|
1930
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1931
|
+
}
|
|
1932
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1933
|
+
_line = state.line;
|
|
1934
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1935
|
+
if (ch === 63) {
|
|
1936
|
+
if (atExplicitKey) {
|
|
1937
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1938
|
+
keyTag = keyNode = valueNode = null;
|
|
1939
|
+
}
|
|
1940
|
+
detected = true;
|
|
1941
|
+
atExplicitKey = true;
|
|
1942
|
+
allowCompact = true;
|
|
1943
|
+
} else if (atExplicitKey) {
|
|
1944
|
+
atExplicitKey = false;
|
|
1945
|
+
allowCompact = true;
|
|
1946
|
+
} else {
|
|
1947
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1948
|
+
}
|
|
1949
|
+
state.position += 1;
|
|
1950
|
+
ch = following;
|
|
1951
|
+
} else {
|
|
1952
|
+
_keyLine = state.line;
|
|
1953
|
+
_keyLineStart = state.lineStart;
|
|
1954
|
+
_keyPos = state.position;
|
|
1955
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1956
|
+
break;
|
|
1957
|
+
}
|
|
1958
|
+
if (state.line === _line) {
|
|
1959
|
+
ch = state.input.charCodeAt(state.position);
|
|
1960
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1961
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1962
|
+
}
|
|
1963
|
+
if (ch === 58) {
|
|
1964
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1965
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1966
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1967
|
+
}
|
|
1968
|
+
if (atExplicitKey) {
|
|
1969
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1970
|
+
keyTag = keyNode = valueNode = null;
|
|
1971
|
+
}
|
|
1972
|
+
detected = true;
|
|
1973
|
+
atExplicitKey = false;
|
|
1974
|
+
allowCompact = false;
|
|
1975
|
+
keyTag = state.tag;
|
|
1976
|
+
keyNode = state.result;
|
|
1977
|
+
} else if (detected) {
|
|
1978
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1979
|
+
} else {
|
|
1980
|
+
state.tag = _tag;
|
|
1981
|
+
state.anchor = _anchor;
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1984
|
+
} else if (detected) {
|
|
1985
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1986
|
+
} else {
|
|
1987
|
+
state.tag = _tag;
|
|
1988
|
+
state.anchor = _anchor;
|
|
1989
|
+
return true;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1993
|
+
if (atExplicitKey) {
|
|
1994
|
+
_keyLine = state.line;
|
|
1995
|
+
_keyLineStart = state.lineStart;
|
|
1996
|
+
_keyPos = state.position;
|
|
1997
|
+
}
|
|
1998
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1999
|
+
if (atExplicitKey) {
|
|
2000
|
+
keyNode = state.result;
|
|
2001
|
+
} else {
|
|
2002
|
+
valueNode = state.result;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
if (!atExplicitKey) {
|
|
2006
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
2007
|
+
keyTag = keyNode = valueNode = null;
|
|
2008
|
+
}
|
|
2009
|
+
skipSeparationSpace(state, true, -1);
|
|
2010
|
+
ch = state.input.charCodeAt(state.position);
|
|
2011
|
+
}
|
|
2012
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
2013
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
2014
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2015
|
+
break;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
if (atExplicitKey) {
|
|
2019
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2020
|
+
}
|
|
2021
|
+
if (detected) {
|
|
2022
|
+
state.tag = _tag;
|
|
2023
|
+
state.anchor = _anchor;
|
|
2024
|
+
state.kind = "mapping";
|
|
2025
|
+
state.result = _result;
|
|
2026
|
+
}
|
|
2027
|
+
return detected;
|
|
2028
|
+
}
|
|
2029
|
+
function readTagProperty(state) {
|
|
2030
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
2031
|
+
ch = state.input.charCodeAt(state.position);
|
|
2032
|
+
if (ch !== 33)
|
|
2033
|
+
return false;
|
|
2034
|
+
if (state.tag !== null) {
|
|
2035
|
+
throwError(state, "duplication of a tag property");
|
|
2036
|
+
}
|
|
2037
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2038
|
+
if (ch === 60) {
|
|
2039
|
+
isVerbatim = true;
|
|
2040
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2041
|
+
} else if (ch === 33) {
|
|
2042
|
+
isNamed = true;
|
|
2043
|
+
tagHandle = "!!";
|
|
2044
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2045
|
+
} else {
|
|
2046
|
+
tagHandle = "!";
|
|
2047
|
+
}
|
|
2048
|
+
_position = state.position;
|
|
2049
|
+
if (isVerbatim) {
|
|
2050
|
+
do {
|
|
2051
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2052
|
+
} while (ch !== 0 && ch !== 62);
|
|
2053
|
+
if (state.position < state.length) {
|
|
2054
|
+
tagName = state.input.slice(_position, state.position);
|
|
2055
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2056
|
+
} else {
|
|
2057
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2058
|
+
}
|
|
2059
|
+
} else {
|
|
2060
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2061
|
+
if (ch === 33) {
|
|
2062
|
+
if (!isNamed) {
|
|
2063
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2064
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2065
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
2066
|
+
}
|
|
2067
|
+
isNamed = true;
|
|
2068
|
+
_position = state.position + 1;
|
|
2069
|
+
} else {
|
|
2070
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2074
|
+
}
|
|
2075
|
+
tagName = state.input.slice(_position, state.position);
|
|
2076
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2077
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2081
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2082
|
+
}
|
|
2083
|
+
try {
|
|
2084
|
+
tagName = decodeURIComponent(tagName);
|
|
2085
|
+
} catch (err) {
|
|
2086
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
2087
|
+
}
|
|
2088
|
+
if (isVerbatim) {
|
|
2089
|
+
state.tag = tagName;
|
|
2090
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2091
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2092
|
+
} else if (tagHandle === "!") {
|
|
2093
|
+
state.tag = "!" + tagName;
|
|
2094
|
+
} else if (tagHandle === "!!") {
|
|
2095
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2096
|
+
} else {
|
|
2097
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2098
|
+
}
|
|
2099
|
+
return true;
|
|
2100
|
+
}
|
|
2101
|
+
function readAnchorProperty(state) {
|
|
2102
|
+
var _position, ch;
|
|
2103
|
+
ch = state.input.charCodeAt(state.position);
|
|
2104
|
+
if (ch !== 38)
|
|
2105
|
+
return false;
|
|
2106
|
+
if (state.anchor !== null) {
|
|
2107
|
+
throwError(state, "duplication of an anchor property");
|
|
2108
|
+
}
|
|
2109
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2110
|
+
_position = state.position;
|
|
2111
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2112
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2113
|
+
}
|
|
2114
|
+
if (state.position === _position) {
|
|
2115
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
2116
|
+
}
|
|
2117
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
2118
|
+
return true;
|
|
2119
|
+
}
|
|
2120
|
+
function readAlias(state) {
|
|
2121
|
+
var _position, alias, ch;
|
|
2122
|
+
ch = state.input.charCodeAt(state.position);
|
|
2123
|
+
if (ch !== 42)
|
|
2124
|
+
return false;
|
|
2125
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2126
|
+
_position = state.position;
|
|
2127
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2128
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2129
|
+
}
|
|
2130
|
+
if (state.position === _position) {
|
|
2131
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
2132
|
+
}
|
|
2133
|
+
alias = state.input.slice(_position, state.position);
|
|
2134
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2135
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2136
|
+
}
|
|
2137
|
+
state.result = state.anchorMap[alias];
|
|
2138
|
+
skipSeparationSpace(state, true, -1);
|
|
2139
|
+
return true;
|
|
2140
|
+
}
|
|
2141
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2142
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
2143
|
+
if (state.listener !== null) {
|
|
2144
|
+
state.listener("open", state);
|
|
2145
|
+
}
|
|
2146
|
+
state.tag = null;
|
|
2147
|
+
state.anchor = null;
|
|
2148
|
+
state.kind = null;
|
|
2149
|
+
state.result = null;
|
|
2150
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2151
|
+
if (allowToSeek) {
|
|
2152
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2153
|
+
atNewLine = true;
|
|
2154
|
+
if (state.lineIndent > parentIndent) {
|
|
2155
|
+
indentStatus = 1;
|
|
2156
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2157
|
+
indentStatus = 0;
|
|
2158
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2159
|
+
indentStatus = -1;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
if (indentStatus === 1) {
|
|
2164
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2165
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2166
|
+
atNewLine = true;
|
|
2167
|
+
allowBlockCollections = allowBlockStyles;
|
|
2168
|
+
if (state.lineIndent > parentIndent) {
|
|
2169
|
+
indentStatus = 1;
|
|
2170
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2171
|
+
indentStatus = 0;
|
|
2172
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2173
|
+
indentStatus = -1;
|
|
2174
|
+
}
|
|
2175
|
+
} else {
|
|
2176
|
+
allowBlockCollections = false;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
if (allowBlockCollections) {
|
|
2181
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2182
|
+
}
|
|
2183
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2184
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2185
|
+
flowIndent = parentIndent;
|
|
2186
|
+
} else {
|
|
2187
|
+
flowIndent = parentIndent + 1;
|
|
2188
|
+
}
|
|
2189
|
+
blockIndent = state.position - state.lineStart;
|
|
2190
|
+
if (indentStatus === 1) {
|
|
2191
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2192
|
+
hasContent = true;
|
|
2193
|
+
} else {
|
|
2194
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2195
|
+
hasContent = true;
|
|
2196
|
+
} else if (readAlias(state)) {
|
|
2197
|
+
hasContent = true;
|
|
2198
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2199
|
+
throwError(state, "alias node should not have any properties");
|
|
2200
|
+
}
|
|
2201
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2202
|
+
hasContent = true;
|
|
2203
|
+
if (state.tag === null) {
|
|
2204
|
+
state.tag = "?";
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (state.anchor !== null) {
|
|
2208
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
} else if (indentStatus === 0) {
|
|
2212
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
if (state.tag === null) {
|
|
2216
|
+
if (state.anchor !== null) {
|
|
2217
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2218
|
+
}
|
|
2219
|
+
} else if (state.tag === "?") {
|
|
2220
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
2221
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2222
|
+
}
|
|
2223
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
2224
|
+
type2 = state.implicitTypes[typeIndex];
|
|
2225
|
+
if (type2.resolve(state.result)) {
|
|
2226
|
+
state.result = type2.construct(state.result);
|
|
2227
|
+
state.tag = type2.tag;
|
|
2228
|
+
if (state.anchor !== null) {
|
|
2229
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2230
|
+
}
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
} else if (state.tag !== "!") {
|
|
2235
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2236
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2237
|
+
} else {
|
|
2238
|
+
type2 = null;
|
|
2239
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2240
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
2241
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2242
|
+
type2 = typeList[typeIndex];
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
if (!type2) {
|
|
2248
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2249
|
+
}
|
|
2250
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
2251
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
2252
|
+
}
|
|
2253
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
2254
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2255
|
+
} else {
|
|
2256
|
+
state.result = type2.construct(state.result, state.tag);
|
|
2257
|
+
if (state.anchor !== null) {
|
|
2258
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
if (state.listener !== null) {
|
|
2263
|
+
state.listener("close", state);
|
|
2264
|
+
}
|
|
2265
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2266
|
+
}
|
|
2267
|
+
function readDocument(state) {
|
|
2268
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2269
|
+
state.version = null;
|
|
2270
|
+
state.checkLineBreaks = state.legacy;
|
|
2271
|
+
state.tagMap = Object.create(null);
|
|
2272
|
+
state.anchorMap = Object.create(null);
|
|
2273
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2274
|
+
skipSeparationSpace(state, true, -1);
|
|
2275
|
+
ch = state.input.charCodeAt(state.position);
|
|
2276
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
hasDirectives = true;
|
|
2280
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2281
|
+
_position = state.position;
|
|
2282
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2283
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2284
|
+
}
|
|
2285
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2286
|
+
directiveArgs = [];
|
|
2287
|
+
if (directiveName.length < 1) {
|
|
2288
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2289
|
+
}
|
|
2290
|
+
while (ch !== 0) {
|
|
2291
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2292
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2293
|
+
}
|
|
2294
|
+
if (ch === 35) {
|
|
2295
|
+
do {
|
|
2296
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2297
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2298
|
+
break;
|
|
2299
|
+
}
|
|
2300
|
+
if (is_EOL(ch))
|
|
2301
|
+
break;
|
|
2302
|
+
_position = state.position;
|
|
2303
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2304
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2305
|
+
}
|
|
2306
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2307
|
+
}
|
|
2308
|
+
if (ch !== 0)
|
|
2309
|
+
readLineBreak(state);
|
|
2310
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2311
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2312
|
+
} else {
|
|
2313
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
skipSeparationSpace(state, true, -1);
|
|
2317
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2318
|
+
state.position += 3;
|
|
2319
|
+
skipSeparationSpace(state, true, -1);
|
|
2320
|
+
} else if (hasDirectives) {
|
|
2321
|
+
throwError(state, "directives end mark is expected");
|
|
2322
|
+
}
|
|
2323
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2324
|
+
skipSeparationSpace(state, true, -1);
|
|
2325
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2326
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2327
|
+
}
|
|
2328
|
+
state.documents.push(state.result);
|
|
2329
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2330
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2331
|
+
state.position += 3;
|
|
2332
|
+
skipSeparationSpace(state, true, -1);
|
|
2333
|
+
}
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
if (state.position < state.length - 1) {
|
|
2337
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2338
|
+
} else {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
function loadDocuments(input, options) {
|
|
2343
|
+
input = String(input);
|
|
2344
|
+
options = options || {};
|
|
2345
|
+
if (input.length !== 0) {
|
|
2346
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2347
|
+
input += `
|
|
2348
|
+
`;
|
|
2349
|
+
}
|
|
2350
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2351
|
+
input = input.slice(1);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
var state = new State$1(input, options);
|
|
2355
|
+
var nullpos = input.indexOf("\x00");
|
|
2356
|
+
if (nullpos !== -1) {
|
|
2357
|
+
state.position = nullpos;
|
|
2358
|
+
throwError(state, "null byte is not allowed in input");
|
|
2359
|
+
}
|
|
2360
|
+
state.input += "\x00";
|
|
2361
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2362
|
+
state.lineIndent += 1;
|
|
2363
|
+
state.position += 1;
|
|
2364
|
+
}
|
|
2365
|
+
while (state.position < state.length - 1) {
|
|
2366
|
+
readDocument(state);
|
|
2367
|
+
}
|
|
2368
|
+
return state.documents;
|
|
2369
|
+
}
|
|
2370
|
+
function loadAll$1(input, iterator, options) {
|
|
2371
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2372
|
+
options = iterator;
|
|
2373
|
+
iterator = null;
|
|
2374
|
+
}
|
|
2375
|
+
var documents = loadDocuments(input, options);
|
|
2376
|
+
if (typeof iterator !== "function") {
|
|
2377
|
+
return documents;
|
|
2378
|
+
}
|
|
2379
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
2380
|
+
iterator(documents[index]);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
function load$1(input, options) {
|
|
2384
|
+
var documents = loadDocuments(input, options);
|
|
2385
|
+
if (documents.length === 0) {
|
|
2386
|
+
return;
|
|
2387
|
+
} else if (documents.length === 1) {
|
|
2388
|
+
return documents[0];
|
|
2389
|
+
}
|
|
2390
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
2391
|
+
}
|
|
2392
|
+
var loadAll_1 = loadAll$1;
|
|
2393
|
+
var load_1 = load$1;
|
|
2394
|
+
var loader = {
|
|
2395
|
+
loadAll: loadAll_1,
|
|
2396
|
+
load: load_1
|
|
2397
|
+
};
|
|
2398
|
+
var _toString = Object.prototype.toString;
|
|
2399
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2400
|
+
var CHAR_BOM = 65279;
|
|
2401
|
+
var CHAR_TAB = 9;
|
|
2402
|
+
var CHAR_LINE_FEED = 10;
|
|
2403
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2404
|
+
var CHAR_SPACE = 32;
|
|
2405
|
+
var CHAR_EXCLAMATION = 33;
|
|
2406
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2407
|
+
var CHAR_SHARP = 35;
|
|
2408
|
+
var CHAR_PERCENT = 37;
|
|
2409
|
+
var CHAR_AMPERSAND = 38;
|
|
2410
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2411
|
+
var CHAR_ASTERISK = 42;
|
|
2412
|
+
var CHAR_COMMA = 44;
|
|
2413
|
+
var CHAR_MINUS = 45;
|
|
2414
|
+
var CHAR_COLON = 58;
|
|
2415
|
+
var CHAR_EQUALS = 61;
|
|
2416
|
+
var CHAR_GREATER_THAN = 62;
|
|
2417
|
+
var CHAR_QUESTION = 63;
|
|
2418
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2419
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2420
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2421
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2422
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2423
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2424
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2425
|
+
var ESCAPE_SEQUENCES = {};
|
|
2426
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2427
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2428
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2429
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2430
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2431
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2432
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2433
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2434
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2435
|
+
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
2436
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2437
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2438
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2439
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2440
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2441
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2442
|
+
"y",
|
|
2443
|
+
"Y",
|
|
2444
|
+
"yes",
|
|
2445
|
+
"Yes",
|
|
2446
|
+
"YES",
|
|
2447
|
+
"on",
|
|
2448
|
+
"On",
|
|
2449
|
+
"ON",
|
|
2450
|
+
"n",
|
|
2451
|
+
"N",
|
|
2452
|
+
"no",
|
|
2453
|
+
"No",
|
|
2454
|
+
"NO",
|
|
2455
|
+
"off",
|
|
2456
|
+
"Off",
|
|
2457
|
+
"OFF"
|
|
2458
|
+
];
|
|
2459
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2460
|
+
function compileStyleMap(schema2, map2) {
|
|
2461
|
+
var result, keys, index, length, tag, style, type2;
|
|
2462
|
+
if (map2 === null)
|
|
2463
|
+
return {};
|
|
2464
|
+
result = {};
|
|
2465
|
+
keys = Object.keys(map2);
|
|
2466
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
2467
|
+
tag = keys[index];
|
|
2468
|
+
style = String(map2[tag]);
|
|
2469
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2470
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2471
|
+
}
|
|
2472
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2473
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2474
|
+
style = type2.styleAliases[style];
|
|
2475
|
+
}
|
|
2476
|
+
result[tag] = style;
|
|
2477
|
+
}
|
|
2478
|
+
return result;
|
|
2479
|
+
}
|
|
2480
|
+
function encodeHex(character) {
|
|
2481
|
+
var string, handle, length;
|
|
2482
|
+
string = character.toString(16).toUpperCase();
|
|
2483
|
+
if (character <= 255) {
|
|
2484
|
+
handle = "x";
|
|
2485
|
+
length = 2;
|
|
2486
|
+
} else if (character <= 65535) {
|
|
2487
|
+
handle = "u";
|
|
2488
|
+
length = 4;
|
|
2489
|
+
} else if (character <= 4294967295) {
|
|
2490
|
+
handle = "U";
|
|
2491
|
+
length = 8;
|
|
2492
|
+
} else {
|
|
2493
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2494
|
+
}
|
|
2495
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2496
|
+
}
|
|
2497
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
2498
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
2499
|
+
function State(options) {
|
|
2500
|
+
this.schema = options["schema"] || _default;
|
|
2501
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2502
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2503
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2504
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2505
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2506
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2507
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2508
|
+
this.noRefs = options["noRefs"] || false;
|
|
2509
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2510
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2511
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2512
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2513
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2514
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2515
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2516
|
+
this.tag = null;
|
|
2517
|
+
this.result = "";
|
|
2518
|
+
this.duplicates = [];
|
|
2519
|
+
this.usedDuplicates = null;
|
|
2520
|
+
}
|
|
2521
|
+
function indentString(string, spaces) {
|
|
2522
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2523
|
+
while (position < length) {
|
|
2524
|
+
next = string.indexOf(`
|
|
2525
|
+
`, position);
|
|
2526
|
+
if (next === -1) {
|
|
2527
|
+
line = string.slice(position);
|
|
2528
|
+
position = length;
|
|
2529
|
+
} else {
|
|
2530
|
+
line = string.slice(position, next + 1);
|
|
2531
|
+
position = next + 1;
|
|
2532
|
+
}
|
|
2533
|
+
if (line.length && line !== `
|
|
2534
|
+
`)
|
|
2535
|
+
result += ind;
|
|
2536
|
+
result += line;
|
|
2537
|
+
}
|
|
2538
|
+
return result;
|
|
2539
|
+
}
|
|
2540
|
+
function generateNextLine(state, level) {
|
|
2541
|
+
return `
|
|
2542
|
+
` + common.repeat(" ", state.indent * level);
|
|
2543
|
+
}
|
|
2544
|
+
function testImplicitResolving(state, str2) {
|
|
2545
|
+
var index, length, type2;
|
|
2546
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
2547
|
+
type2 = state.implicitTypes[index];
|
|
2548
|
+
if (type2.resolve(str2)) {
|
|
2549
|
+
return true;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
return false;
|
|
2553
|
+
}
|
|
2554
|
+
function isWhitespace(c) {
|
|
2555
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2556
|
+
}
|
|
2557
|
+
function isPrintable(c) {
|
|
2558
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2559
|
+
}
|
|
2560
|
+
function isNsCharOrWhitespace(c) {
|
|
2561
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2562
|
+
}
|
|
2563
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2564
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2565
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2566
|
+
return (inblock ? cIsNsCharOrWhitespace : 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;
|
|
2567
|
+
}
|
|
2568
|
+
function isPlainSafeFirst(c) {
|
|
2569
|
+
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;
|
|
2570
|
+
}
|
|
2571
|
+
function isPlainSafeLast(c) {
|
|
2572
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2573
|
+
}
|
|
2574
|
+
function codePointAt(string, pos) {
|
|
2575
|
+
var first = string.charCodeAt(pos), second;
|
|
2576
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2577
|
+
second = string.charCodeAt(pos + 1);
|
|
2578
|
+
if (second >= 56320 && second <= 57343) {
|
|
2579
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
return first;
|
|
2583
|
+
}
|
|
2584
|
+
function needIndentIndicator(string) {
|
|
2585
|
+
var leadingSpaceRe = /^\n* /;
|
|
2586
|
+
return leadingSpaceRe.test(string);
|
|
2587
|
+
}
|
|
2588
|
+
var STYLE_PLAIN = 1;
|
|
2589
|
+
var STYLE_SINGLE = 2;
|
|
2590
|
+
var STYLE_LITERAL = 3;
|
|
2591
|
+
var STYLE_FOLDED = 4;
|
|
2592
|
+
var STYLE_DOUBLE = 5;
|
|
2593
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2594
|
+
var i2;
|
|
2595
|
+
var char = 0;
|
|
2596
|
+
var prevChar = null;
|
|
2597
|
+
var hasLineBreak = false;
|
|
2598
|
+
var hasFoldableLine = false;
|
|
2599
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2600
|
+
var previousLineBreak = -1;
|
|
2601
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2602
|
+
if (singleLineOnly || forceQuotes) {
|
|
2603
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2604
|
+
char = codePointAt(string, i2);
|
|
2605
|
+
if (!isPrintable(char)) {
|
|
2606
|
+
return STYLE_DOUBLE;
|
|
2607
|
+
}
|
|
2608
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2609
|
+
prevChar = char;
|
|
2610
|
+
}
|
|
2611
|
+
} else {
|
|
2612
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2613
|
+
char = codePointAt(string, i2);
|
|
2614
|
+
if (char === CHAR_LINE_FEED) {
|
|
2615
|
+
hasLineBreak = true;
|
|
2616
|
+
if (shouldTrackWidth) {
|
|
2617
|
+
hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2618
|
+
previousLineBreak = i2;
|
|
2619
|
+
}
|
|
2620
|
+
} else if (!isPrintable(char)) {
|
|
2621
|
+
return STYLE_DOUBLE;
|
|
2622
|
+
}
|
|
2623
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2624
|
+
prevChar = char;
|
|
2625
|
+
}
|
|
2626
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2627
|
+
}
|
|
2628
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2629
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2630
|
+
return STYLE_PLAIN;
|
|
2631
|
+
}
|
|
2632
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2633
|
+
}
|
|
2634
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2635
|
+
return STYLE_DOUBLE;
|
|
2636
|
+
}
|
|
2637
|
+
if (!forceQuotes) {
|
|
2638
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2639
|
+
}
|
|
2640
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2641
|
+
}
|
|
2642
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
2643
|
+
state.dump = function() {
|
|
2644
|
+
if (string.length === 0) {
|
|
2645
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2646
|
+
}
|
|
2647
|
+
if (!state.noCompatMode) {
|
|
2648
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2649
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
var indent = state.indent * Math.max(1, level);
|
|
2653
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2654
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2655
|
+
function testAmbiguity(string2) {
|
|
2656
|
+
return testImplicitResolving(state, string2);
|
|
2657
|
+
}
|
|
2658
|
+
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
2659
|
+
case STYLE_PLAIN:
|
|
2660
|
+
return string;
|
|
2661
|
+
case STYLE_SINGLE:
|
|
2662
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
2663
|
+
case STYLE_LITERAL:
|
|
2664
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2665
|
+
case STYLE_FOLDED:
|
|
2666
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2667
|
+
case STYLE_DOUBLE:
|
|
2668
|
+
return '"' + escapeString(string) + '"';
|
|
2669
|
+
default:
|
|
2670
|
+
throw new exception("impossible error: invalid scalar style");
|
|
2671
|
+
}
|
|
2672
|
+
}();
|
|
2673
|
+
}
|
|
2674
|
+
function blockHeader(string, indentPerLevel) {
|
|
2675
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2676
|
+
var clip = string[string.length - 1] === `
|
|
2677
|
+
`;
|
|
2678
|
+
var keep = clip && (string[string.length - 2] === `
|
|
2679
|
+
` || string === `
|
|
2680
|
+
`);
|
|
2681
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2682
|
+
return indentIndicator + chomp + `
|
|
2683
|
+
`;
|
|
2684
|
+
}
|
|
2685
|
+
function dropEndingNewline(string) {
|
|
2686
|
+
return string[string.length - 1] === `
|
|
2687
|
+
` ? string.slice(0, -1) : string;
|
|
2688
|
+
}
|
|
2689
|
+
function foldString(string, width) {
|
|
2690
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2691
|
+
var result = function() {
|
|
2692
|
+
var nextLF = string.indexOf(`
|
|
2693
|
+
`);
|
|
2694
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2695
|
+
lineRe.lastIndex = nextLF;
|
|
2696
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
2697
|
+
}();
|
|
2698
|
+
var prevMoreIndented = string[0] === `
|
|
2699
|
+
` || string[0] === " ";
|
|
2700
|
+
var moreIndented;
|
|
2701
|
+
var match;
|
|
2702
|
+
while (match = lineRe.exec(string)) {
|
|
2703
|
+
var prefix = match[1], line = match[2];
|
|
2704
|
+
moreIndented = line[0] === " ";
|
|
2705
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
2706
|
+
` : "") + foldLine(line, width);
|
|
2707
|
+
prevMoreIndented = moreIndented;
|
|
2708
|
+
}
|
|
2709
|
+
return result;
|
|
2710
|
+
}
|
|
2711
|
+
function foldLine(line, width) {
|
|
2712
|
+
if (line === "" || line[0] === " ")
|
|
2713
|
+
return line;
|
|
2714
|
+
var breakRe = / [^ ]/g;
|
|
2715
|
+
var match;
|
|
2716
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2717
|
+
var result = "";
|
|
2718
|
+
while (match = breakRe.exec(line)) {
|
|
2719
|
+
next = match.index;
|
|
2720
|
+
if (next - start > width) {
|
|
2721
|
+
end = curr > start ? curr : next;
|
|
2722
|
+
result += `
|
|
2723
|
+
` + line.slice(start, end);
|
|
2724
|
+
start = end + 1;
|
|
2725
|
+
}
|
|
2726
|
+
curr = next;
|
|
2727
|
+
}
|
|
2728
|
+
result += `
|
|
2729
|
+
`;
|
|
2730
|
+
if (line.length - start > width && curr > start) {
|
|
2731
|
+
result += line.slice(start, curr) + `
|
|
2732
|
+
` + line.slice(curr + 1);
|
|
2733
|
+
} else {
|
|
2734
|
+
result += line.slice(start);
|
|
2735
|
+
}
|
|
2736
|
+
return result.slice(1);
|
|
2737
|
+
}
|
|
2738
|
+
function escapeString(string) {
|
|
2739
|
+
var result = "";
|
|
2740
|
+
var char = 0;
|
|
2741
|
+
var escapeSeq;
|
|
2742
|
+
for (var i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2743
|
+
char = codePointAt(string, i2);
|
|
2744
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2745
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
2746
|
+
result += string[i2];
|
|
2747
|
+
if (char >= 65536)
|
|
2748
|
+
result += string[i2 + 1];
|
|
2749
|
+
} else {
|
|
2750
|
+
result += escapeSeq || encodeHex(char);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
return result;
|
|
2754
|
+
}
|
|
2755
|
+
function writeFlowSequence(state, level, object) {
|
|
2756
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2757
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2758
|
+
value = object[index];
|
|
2759
|
+
if (state.replacer) {
|
|
2760
|
+
value = state.replacer.call(object, String(index), value);
|
|
2761
|
+
}
|
|
2762
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2763
|
+
if (_result !== "")
|
|
2764
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
2765
|
+
_result += state.dump;
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
state.tag = _tag;
|
|
2769
|
+
state.dump = "[" + _result + "]";
|
|
2770
|
+
}
|
|
2771
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
2772
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2773
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2774
|
+
value = object[index];
|
|
2775
|
+
if (state.replacer) {
|
|
2776
|
+
value = state.replacer.call(object, String(index), value);
|
|
2777
|
+
}
|
|
2778
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2779
|
+
if (!compact || _result !== "") {
|
|
2780
|
+
_result += generateNextLine(state, level);
|
|
2781
|
+
}
|
|
2782
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2783
|
+
_result += "-";
|
|
2784
|
+
} else {
|
|
2785
|
+
_result += "- ";
|
|
2786
|
+
}
|
|
2787
|
+
_result += state.dump;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
state.tag = _tag;
|
|
2791
|
+
state.dump = _result || "[]";
|
|
2792
|
+
}
|
|
2793
|
+
function writeFlowMapping(state, level, object) {
|
|
2794
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2795
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2796
|
+
pairBuffer = "";
|
|
2797
|
+
if (_result !== "")
|
|
2798
|
+
pairBuffer += ", ";
|
|
2799
|
+
if (state.condenseFlow)
|
|
2800
|
+
pairBuffer += '"';
|
|
2801
|
+
objectKey = objectKeyList[index];
|
|
2802
|
+
objectValue = object[objectKey];
|
|
2803
|
+
if (state.replacer) {
|
|
2804
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2805
|
+
}
|
|
2806
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2807
|
+
continue;
|
|
2808
|
+
}
|
|
2809
|
+
if (state.dump.length > 1024)
|
|
2810
|
+
pairBuffer += "? ";
|
|
2811
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2812
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2813
|
+
continue;
|
|
2814
|
+
}
|
|
2815
|
+
pairBuffer += state.dump;
|
|
2816
|
+
_result += pairBuffer;
|
|
2817
|
+
}
|
|
2818
|
+
state.tag = _tag;
|
|
2819
|
+
state.dump = "{" + _result + "}";
|
|
2820
|
+
}
|
|
2821
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
2822
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2823
|
+
if (state.sortKeys === true) {
|
|
2824
|
+
objectKeyList.sort();
|
|
2825
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2826
|
+
objectKeyList.sort(state.sortKeys);
|
|
2827
|
+
} else if (state.sortKeys) {
|
|
2828
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
2829
|
+
}
|
|
2830
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2831
|
+
pairBuffer = "";
|
|
2832
|
+
if (!compact || _result !== "") {
|
|
2833
|
+
pairBuffer += generateNextLine(state, level);
|
|
2834
|
+
}
|
|
2835
|
+
objectKey = objectKeyList[index];
|
|
2836
|
+
objectValue = object[objectKey];
|
|
2837
|
+
if (state.replacer) {
|
|
2838
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2839
|
+
}
|
|
2840
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2841
|
+
continue;
|
|
2842
|
+
}
|
|
2843
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2844
|
+
if (explicitPair) {
|
|
2845
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2846
|
+
pairBuffer += "?";
|
|
2847
|
+
} else {
|
|
2848
|
+
pairBuffer += "? ";
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
pairBuffer += state.dump;
|
|
2852
|
+
if (explicitPair) {
|
|
2853
|
+
pairBuffer += generateNextLine(state, level);
|
|
2854
|
+
}
|
|
2855
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2856
|
+
continue;
|
|
2857
|
+
}
|
|
2858
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2859
|
+
pairBuffer += ":";
|
|
2860
|
+
} else {
|
|
2861
|
+
pairBuffer += ": ";
|
|
2862
|
+
}
|
|
2863
|
+
pairBuffer += state.dump;
|
|
2864
|
+
_result += pairBuffer;
|
|
2865
|
+
}
|
|
2866
|
+
state.tag = _tag;
|
|
2867
|
+
state.dump = _result || "{}";
|
|
2868
|
+
}
|
|
2869
|
+
function detectType(state, object, explicit) {
|
|
2870
|
+
var _result, typeList, index, length, type2, style;
|
|
2871
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2872
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
2873
|
+
type2 = typeList[index];
|
|
2874
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2875
|
+
if (explicit) {
|
|
2876
|
+
if (type2.multi && type2.representName) {
|
|
2877
|
+
state.tag = type2.representName(object);
|
|
2878
|
+
} else {
|
|
2879
|
+
state.tag = type2.tag;
|
|
2880
|
+
}
|
|
2881
|
+
} else {
|
|
2882
|
+
state.tag = "?";
|
|
2883
|
+
}
|
|
2884
|
+
if (type2.represent) {
|
|
2885
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2886
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2887
|
+
_result = type2.represent(object, style);
|
|
2888
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2889
|
+
_result = type2.represent[style](object, style);
|
|
2890
|
+
} else {
|
|
2891
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2892
|
+
}
|
|
2893
|
+
state.dump = _result;
|
|
2894
|
+
}
|
|
2895
|
+
return true;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
return false;
|
|
2899
|
+
}
|
|
2900
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2901
|
+
state.tag = null;
|
|
2902
|
+
state.dump = object;
|
|
2903
|
+
if (!detectType(state, object, false)) {
|
|
2904
|
+
detectType(state, object, true);
|
|
2905
|
+
}
|
|
2906
|
+
var type2 = _toString.call(state.dump);
|
|
2907
|
+
var inblock = block;
|
|
2908
|
+
var tagStr;
|
|
2909
|
+
if (block) {
|
|
2910
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2911
|
+
}
|
|
2912
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2913
|
+
if (objectOrArray) {
|
|
2914
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
2915
|
+
duplicate = duplicateIndex !== -1;
|
|
2916
|
+
}
|
|
2917
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2918
|
+
compact = false;
|
|
2919
|
+
}
|
|
2920
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2921
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2922
|
+
} else {
|
|
2923
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2924
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2925
|
+
}
|
|
2926
|
+
if (type2 === "[object Object]") {
|
|
2927
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2928
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2929
|
+
if (duplicate) {
|
|
2930
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2931
|
+
}
|
|
2932
|
+
} else {
|
|
2933
|
+
writeFlowMapping(state, level, state.dump);
|
|
2934
|
+
if (duplicate) {
|
|
2935
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
} else if (type2 === "[object Array]") {
|
|
2939
|
+
if (block && state.dump.length !== 0) {
|
|
2940
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2941
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2942
|
+
} else {
|
|
2943
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
2944
|
+
}
|
|
2945
|
+
if (duplicate) {
|
|
2946
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2947
|
+
}
|
|
2948
|
+
} else {
|
|
2949
|
+
writeFlowSequence(state, level, state.dump);
|
|
2950
|
+
if (duplicate) {
|
|
2951
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
} else if (type2 === "[object String]") {
|
|
2955
|
+
if (state.tag !== "?") {
|
|
2956
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2957
|
+
}
|
|
2958
|
+
} else if (type2 === "[object Undefined]") {
|
|
2959
|
+
return false;
|
|
2960
|
+
} else {
|
|
2961
|
+
if (state.skipInvalid)
|
|
2962
|
+
return false;
|
|
2963
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2964
|
+
}
|
|
2965
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2966
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
2967
|
+
if (state.tag[0] === "!") {
|
|
2968
|
+
tagStr = "!" + tagStr;
|
|
2969
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2970
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
2971
|
+
} else {
|
|
2972
|
+
tagStr = "!<" + tagStr + ">";
|
|
2973
|
+
}
|
|
2974
|
+
state.dump = tagStr + " " + state.dump;
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
return true;
|
|
2978
|
+
}
|
|
2979
|
+
function getDuplicateReferences(object, state) {
|
|
2980
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2981
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
2982
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
2983
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2984
|
+
}
|
|
2985
|
+
state.usedDuplicates = new Array(length);
|
|
2986
|
+
}
|
|
2987
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2988
|
+
var objectKeyList, index, length;
|
|
2989
|
+
if (object !== null && typeof object === "object") {
|
|
2990
|
+
index = objects.indexOf(object);
|
|
2991
|
+
if (index !== -1) {
|
|
2992
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2993
|
+
duplicatesIndexes.push(index);
|
|
2994
|
+
}
|
|
2995
|
+
} else {
|
|
2996
|
+
objects.push(object);
|
|
2997
|
+
if (Array.isArray(object)) {
|
|
2998
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2999
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
3000
|
+
}
|
|
3001
|
+
} else {
|
|
3002
|
+
objectKeyList = Object.keys(object);
|
|
3003
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
3004
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
function dump$1(input, options) {
|
|
3011
|
+
options = options || {};
|
|
3012
|
+
var state = new State(options);
|
|
3013
|
+
if (!state.noRefs)
|
|
3014
|
+
getDuplicateReferences(input, state);
|
|
3015
|
+
var value = input;
|
|
3016
|
+
if (state.replacer) {
|
|
3017
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
3018
|
+
}
|
|
3019
|
+
if (writeNode(state, 0, value, true, true))
|
|
3020
|
+
return state.dump + `
|
|
3021
|
+
`;
|
|
3022
|
+
return "";
|
|
3023
|
+
}
|
|
3024
|
+
var dump_1 = dump$1;
|
|
3025
|
+
var dumper = {
|
|
3026
|
+
dump: dump_1
|
|
3027
|
+
};
|
|
3028
|
+
function renamed(from, to) {
|
|
3029
|
+
return function() {
|
|
3030
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
3031
|
+
};
|
|
3032
|
+
}
|
|
3033
|
+
var Type = type;
|
|
3034
|
+
var Schema = schema;
|
|
3035
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
3036
|
+
var JSON_SCHEMA = json;
|
|
3037
|
+
var CORE_SCHEMA = core;
|
|
3038
|
+
var DEFAULT_SCHEMA = _default;
|
|
3039
|
+
var load = loader.load;
|
|
3040
|
+
var loadAll = loader.loadAll;
|
|
3041
|
+
var dump = dumper.dump;
|
|
3042
|
+
var YAMLException = exception;
|
|
3043
|
+
var types = {
|
|
3044
|
+
binary,
|
|
3045
|
+
float,
|
|
3046
|
+
map,
|
|
3047
|
+
null: _null,
|
|
3048
|
+
pairs,
|
|
3049
|
+
set,
|
|
3050
|
+
timestamp,
|
|
3051
|
+
bool,
|
|
3052
|
+
int,
|
|
3053
|
+
merge,
|
|
3054
|
+
omap,
|
|
3055
|
+
seq,
|
|
3056
|
+
str
|
|
3057
|
+
};
|
|
3058
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
3059
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
3060
|
+
var safeDump = renamed("safeDump", "dump");
|
|
3061
|
+
var jsYaml = {
|
|
3062
|
+
Type,
|
|
3063
|
+
Schema,
|
|
3064
|
+
FAILSAFE_SCHEMA,
|
|
3065
|
+
JSON_SCHEMA,
|
|
3066
|
+
CORE_SCHEMA,
|
|
3067
|
+
DEFAULT_SCHEMA,
|
|
3068
|
+
load,
|
|
3069
|
+
loadAll,
|
|
3070
|
+
dump,
|
|
3071
|
+
YAMLException,
|
|
3072
|
+
types,
|
|
3073
|
+
safeLoad,
|
|
3074
|
+
safeLoadAll,
|
|
3075
|
+
safeDump
|
|
3076
|
+
};
|
|
3077
|
+
|
|
3078
|
+
// src/graph.ts
|
|
3079
|
+
var ENCODE_MAP = { "/": "__SL__", ".": "__DT__" };
|
|
3080
|
+
var ENCODE_RE = /[/.]/g;
|
|
3081
|
+
function pathToGraphFilename(filePath) {
|
|
3082
|
+
return filePath.replace(ENCODE_RE, (ch) => ENCODE_MAP[ch]) + ".md";
|
|
3083
|
+
}
|
|
3084
|
+
function parseGraphContent(content) {
|
|
3085
|
+
const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
3086
|
+
if (fmMatch) {
|
|
3087
|
+
try {
|
|
3088
|
+
const fm = jsYaml.load(fmMatch[1]);
|
|
3089
|
+
if (fm && fm.filePath) {
|
|
3090
|
+
return {
|
|
3091
|
+
filePath: fm.filePath,
|
|
3092
|
+
calls: fm.calls || [],
|
|
3093
|
+
dependsOn: fm.dependsOn || [],
|
|
3094
|
+
tasksThatEdited: fm.tasksThatEdited || []
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
} catch {}
|
|
3098
|
+
}
|
|
3099
|
+
return parseLegacyContent(content);
|
|
3100
|
+
}
|
|
3101
|
+
function parseLegacyContent(content) {
|
|
3102
|
+
const lines = content.split(`
|
|
3103
|
+
`);
|
|
3104
|
+
const entry = {
|
|
3105
|
+
filePath: "",
|
|
3106
|
+
calls: [],
|
|
3107
|
+
dependsOn: [],
|
|
3108
|
+
tasksThatEdited: []
|
|
3109
|
+
};
|
|
3110
|
+
let inSection = null;
|
|
3111
|
+
for (const line of lines) {
|
|
3112
|
+
const trimmed = line.trim();
|
|
3113
|
+
if (trimmed.startsWith("# ") && !entry.filePath) {
|
|
3114
|
+
entry.filePath = trimmed.substring(2).trim();
|
|
3115
|
+
continue;
|
|
3116
|
+
}
|
|
3117
|
+
if (trimmed === "## Calls") {
|
|
3118
|
+
inSection = "calls";
|
|
3119
|
+
continue;
|
|
3120
|
+
}
|
|
3121
|
+
if (trimmed === "## Depends On") {
|
|
3122
|
+
inSection = "dependsOn";
|
|
3123
|
+
continue;
|
|
3124
|
+
}
|
|
3125
|
+
if (trimmed === "## Tasks That Edited") {
|
|
3126
|
+
inSection = "tasks";
|
|
3127
|
+
continue;
|
|
3128
|
+
}
|
|
3129
|
+
if (trimmed.startsWith("- [[") && trimmed.endsWith("]]")) {
|
|
3130
|
+
const ref = trimmed.slice(4, -2).trim();
|
|
3131
|
+
if (inSection === "calls")
|
|
3132
|
+
entry.calls.push(ref);
|
|
3133
|
+
else if (inSection === "dependsOn")
|
|
3134
|
+
entry.dependsOn.push(ref);
|
|
3135
|
+
else if (inSection === "tasks")
|
|
3136
|
+
entry.tasksThatEdited.push(ref);
|
|
3137
|
+
} else if (trimmed.startsWith("- `") && trimmed.endsWith("`")) {
|
|
3138
|
+
const ref = trimmed.slice(3, -1).trim();
|
|
3139
|
+
if (inSection === "calls" && !entry.calls.includes(ref))
|
|
3140
|
+
entry.calls.push(ref);
|
|
3141
|
+
else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref))
|
|
3142
|
+
entry.dependsOn.push(ref);
|
|
3143
|
+
} else if (trimmed.startsWith("- ")) {
|
|
3144
|
+
const ref = trimmed.slice(2).trim();
|
|
3145
|
+
if (inSection === "calls" && !entry.calls.includes(ref))
|
|
3146
|
+
entry.calls.push(ref);
|
|
3147
|
+
else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref))
|
|
3148
|
+
entry.dependsOn.push(ref);
|
|
3149
|
+
else if (inSection === "tasks" && !entry.tasksThatEdited.includes(ref))
|
|
3150
|
+
entry.tasksThatEdited.push(ref);
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
return entry.filePath ? entry : null;
|
|
3154
|
+
}
|
|
3155
|
+
function formatGraphContent(entry) {
|
|
3156
|
+
const fm = {
|
|
3157
|
+
filePath: entry.filePath,
|
|
3158
|
+
calls: entry.calls,
|
|
3159
|
+
dependsOn: entry.dependsOn,
|
|
3160
|
+
tasksThatEdited: entry.tasksThatEdited
|
|
3161
|
+
};
|
|
3162
|
+
const fmYaml = jsYaml.dump(fm, { lineWidth: -1, quotingType: "'", forceQuotes: false });
|
|
3163
|
+
const callsSection = entry.calls.length > 0 ? `## Calls
|
|
3164
|
+
` + entry.calls.map((c) => `- ${c}`).join(`
|
|
3165
|
+
`) : `## Calls
|
|
3166
|
+
`;
|
|
3167
|
+
const dependsSection = entry.dependsOn.length > 0 ? `## Depends On
|
|
3168
|
+
` + entry.dependsOn.map((d) => `- ${d}`).join(`
|
|
3169
|
+
`) : `## Depends On
|
|
3170
|
+
`;
|
|
3171
|
+
const tasksSection = entry.tasksThatEdited.length > 0 ? `## Tasks That Edited
|
|
3172
|
+
` + entry.tasksThatEdited.map((t) => `- [[${t}]]`).join(`
|
|
3173
|
+
`) : `## Tasks That Edited
|
|
3174
|
+
`;
|
|
3175
|
+
return `---
|
|
3176
|
+
${fmYaml.trim()}
|
|
3177
|
+
---
|
|
3178
|
+
|
|
3179
|
+
${callsSection}
|
|
3180
|
+
|
|
3181
|
+
${dependsSection}
|
|
3182
|
+
|
|
3183
|
+
${tasksSection}
|
|
3184
|
+
`.trim();
|
|
3185
|
+
}
|
|
3186
|
+
async function readGraphFile(directory, filePath) {
|
|
3187
|
+
const filename = pathToGraphFilename(filePath);
|
|
3188
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3189
|
+
if (!existsSync2(graphPath)) {
|
|
3190
|
+
return null;
|
|
3191
|
+
}
|
|
3192
|
+
try {
|
|
3193
|
+
const content = await readFile2(graphPath, "utf-8");
|
|
3194
|
+
return parseGraphContent(content);
|
|
3195
|
+
} catch {
|
|
3196
|
+
return null;
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
async function updateGraphFile(directory, filePath, taskId, calls, dependsOn) {
|
|
3200
|
+
const filename = pathToGraphFilename(filePath);
|
|
3201
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3202
|
+
let entry;
|
|
3203
|
+
if (existsSync2(graphPath)) {
|
|
3204
|
+
const existing = await readGraphFile(directory, filePath);
|
|
3205
|
+
entry = existing || {
|
|
3206
|
+
filePath,
|
|
3207
|
+
calls: [],
|
|
3208
|
+
dependsOn: [],
|
|
3209
|
+
tasksThatEdited: []
|
|
3210
|
+
};
|
|
3211
|
+
} else {
|
|
3212
|
+
entry = {
|
|
3213
|
+
filePath,
|
|
3214
|
+
calls: calls || [],
|
|
3215
|
+
dependsOn: dependsOn || [],
|
|
3216
|
+
tasksThatEdited: []
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
if (calls) {
|
|
3220
|
+
entry.calls = [...new Set([...entry.calls, ...calls])];
|
|
3221
|
+
}
|
|
3222
|
+
if (dependsOn) {
|
|
3223
|
+
entry.dependsOn = [...new Set([...entry.dependsOn, ...dependsOn])];
|
|
3224
|
+
}
|
|
3225
|
+
if (!entry.tasksThatEdited.includes(taskId)) {
|
|
3226
|
+
entry.tasksThatEdited.push(taskId);
|
|
3227
|
+
}
|
|
3228
|
+
const graphDir = dirname2(graphPath);
|
|
3229
|
+
if (!existsSync2(graphDir)) {
|
|
3230
|
+
await mkdir2(graphDir, { recursive: true });
|
|
3231
|
+
}
|
|
3232
|
+
const content = formatGraphContent(entry);
|
|
3233
|
+
await writeFile2(graphPath, content, "utf-8");
|
|
3234
|
+
}
|
|
3235
|
+
async function updateGraphFilesForTask(directory, taskId, files) {
|
|
3236
|
+
for (const file of files) {
|
|
3237
|
+
try {
|
|
3238
|
+
await updateGraphFile(directory, file, taskId);
|
|
3239
|
+
} catch (error) {
|
|
3240
|
+
console.error(`Failed to update graph for ${file}:`, error);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
async function replaceGraphCalls(directory, filePath, calls, dependsOn) {
|
|
3245
|
+
const filename = pathToGraphFilename(filePath);
|
|
3246
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3247
|
+
let entry;
|
|
3248
|
+
if (existsSync2(graphPath)) {
|
|
3249
|
+
const existing = await readGraphFile(directory, filePath);
|
|
3250
|
+
entry = existing || {
|
|
3251
|
+
filePath,
|
|
3252
|
+
calls: [],
|
|
3253
|
+
dependsOn: [],
|
|
3254
|
+
tasksThatEdited: []
|
|
3255
|
+
};
|
|
3256
|
+
} else {
|
|
3257
|
+
entry = {
|
|
3258
|
+
filePath,
|
|
3259
|
+
calls: [],
|
|
3260
|
+
dependsOn: [],
|
|
3261
|
+
tasksThatEdited: []
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
entry.calls = [...new Set(calls)];
|
|
3265
|
+
entry.dependsOn = [...new Set(dependsOn)];
|
|
3266
|
+
const graphDir = dirname2(graphPath);
|
|
3267
|
+
if (!existsSync2(graphDir)) {
|
|
3268
|
+
await mkdir2(graphDir, { recursive: true });
|
|
3269
|
+
}
|
|
3270
|
+
const content = formatGraphContent(entry);
|
|
3271
|
+
await writeFile2(graphPath, content, "utf-8");
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
// src/graph-sync.ts
|
|
3275
|
+
import Database from "better-sqlite3";
|
|
3276
|
+
import { existsSync as existsSync3 } from "fs";
|
|
3277
|
+
import { join as join3 } from "path";
|
|
3278
|
+
function openIndexDb(projectRoot) {
|
|
3279
|
+
const dbPath = join3(projectRoot, ".opencode", "index", "codebase.db");
|
|
3280
|
+
if (!existsSync3(dbPath)) {
|
|
3281
|
+
return null;
|
|
3282
|
+
}
|
|
3283
|
+
try {
|
|
3284
|
+
const db = new Database(dbPath, { readonly: true });
|
|
3285
|
+
db.pragma("journal_mode = WAL");
|
|
3286
|
+
return db;
|
|
3287
|
+
} catch {
|
|
3288
|
+
return null;
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
function getFileCallEdges(db, filePath, branch) {
|
|
3292
|
+
const calls = new Set;
|
|
3293
|
+
const dependsOn = new Set;
|
|
3294
|
+
const outEdges = db.prepare(`
|
|
3295
|
+
SELECT s_to.file_path AS target_file
|
|
3296
|
+
FROM call_edges ce
|
|
3297
|
+
INNER JOIN symbols s_from ON ce.from_symbol_id = s_from.id
|
|
3298
|
+
INNER JOIN branch_symbols bs ON s_from.id = bs.symbol_id AND bs.branch = ?
|
|
3299
|
+
LEFT JOIN symbols s_to ON ce.to_symbol_id = s_to.id
|
|
3300
|
+
WHERE s_from.file_path = ?
|
|
3301
|
+
AND ce.is_resolved = 1
|
|
3302
|
+
AND s_to.file_path IS NOT NULL
|
|
3303
|
+
AND s_to.file_path != ?
|
|
3304
|
+
`).all(branch, filePath, filePath);
|
|
3305
|
+
for (const row of outEdges) {
|
|
3306
|
+
if (row.target_file) {
|
|
3307
|
+
calls.add(row.target_file);
|
|
3308
|
+
dependsOn.add(row.target_file);
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
const unresolvedEdges = db.prepare(`
|
|
3312
|
+
SELECT DISTINCT ce.target_name
|
|
3313
|
+
FROM call_edges ce
|
|
3314
|
+
INNER JOIN symbols s_from ON ce.from_symbol_id = s_from.id
|
|
3315
|
+
INNER JOIN branch_symbols bs ON s_from.id = bs.symbol_id AND bs.branch = ?
|
|
3316
|
+
WHERE s_from.file_path = ?
|
|
3317
|
+
AND ce.is_resolved = 0
|
|
3318
|
+
`).all(branch, filePath);
|
|
3319
|
+
const symbolByName = db.prepare(`
|
|
3320
|
+
SELECT DISTINCT s.file_path
|
|
3321
|
+
FROM symbols s
|
|
3322
|
+
INNER JOIN branch_symbols bs ON s.id = bs.symbol_id AND bs.branch = ?
|
|
3323
|
+
WHERE s.name = ?
|
|
3324
|
+
AND s.file_path != ?
|
|
3325
|
+
`);
|
|
3326
|
+
for (const row of unresolvedEdges) {
|
|
3327
|
+
const candidates = symbolByName.all(branch, row.target_name, filePath);
|
|
3328
|
+
if (candidates.length === 1) {
|
|
3329
|
+
calls.add(candidates[0].file_path);
|
|
3330
|
+
dependsOn.add(candidates[0].file_path);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
return {
|
|
3334
|
+
calls: [...calls].sort(),
|
|
3335
|
+
dependsOn: [...dependsOn].sort()
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
function getCurrentBranch(db) {
|
|
3339
|
+
const row = db.prepare("SELECT value FROM metadata WHERE key = 'current_branch'").get();
|
|
3340
|
+
return row?.value || "main";
|
|
3341
|
+
}
|
|
3342
|
+
async function syncGraphFilesFromIndex(projectRoot, files) {
|
|
3343
|
+
const db = openIndexDb(projectRoot);
|
|
3344
|
+
if (!db) {
|
|
3345
|
+
return { synced: 0, skipped: files.length };
|
|
3346
|
+
}
|
|
3347
|
+
try {
|
|
3348
|
+
const branch = getCurrentBranch(db);
|
|
3349
|
+
let synced = 0;
|
|
3350
|
+
let skipped = 0;
|
|
3351
|
+
for (const filePath of files) {
|
|
3352
|
+
try {
|
|
3353
|
+
const edges = getFileCallEdges(db, filePath, branch);
|
|
3354
|
+
await replaceGraphCalls(projectRoot, filePath, edges.calls, edges.dependsOn);
|
|
3355
|
+
synced++;
|
|
3356
|
+
} catch {
|
|
3357
|
+
skipped++;
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
return { synced, skipped };
|
|
3361
|
+
} finally {
|
|
3362
|
+
db.close();
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
// src/state-machine.ts
|
|
3367
|
+
async function readState(directory) {
|
|
3368
|
+
const statePath = join4(directory, "Manifold", "state.json");
|
|
3369
|
+
if (existsSync4(statePath)) {
|
|
3370
|
+
const content = await readFile3(statePath, "utf-8");
|
|
3371
|
+
return JSON.parse(content);
|
|
3372
|
+
}
|
|
3373
|
+
return {
|
|
3374
|
+
current_task: null,
|
|
3375
|
+
state: "idle",
|
|
3376
|
+
loop_count: 0,
|
|
3377
|
+
clerk_retry_count: 0,
|
|
3378
|
+
scoped_prompt: null,
|
|
3379
|
+
senior_output: null,
|
|
3380
|
+
junior_response: null,
|
|
3381
|
+
debug_suggestion: null,
|
|
3382
|
+
loop_history: []
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
async function writeState(directory, state) {
|
|
3386
|
+
const statePath = join4(directory, "Manifold", "state.json");
|
|
3387
|
+
await writeFile3(statePath, JSON.stringify(state, null, 2));
|
|
3388
|
+
}
|
|
3389
|
+
function buildLoopHistory(state) {
|
|
3390
|
+
if (state.loop_history.length === 0) {
|
|
3391
|
+
return "No previous loops.";
|
|
3392
|
+
}
|
|
3393
|
+
return state.loop_history.map((entry, i2) => `### Loop ${i2 + 1}
|
|
3394
|
+
${entry}`).join(`
|
|
3395
|
+
|
|
3396
|
+
`);
|
|
3397
|
+
}
|
|
3398
|
+
async function readRecentTaskLogs(directory, count) {
|
|
3399
|
+
const tasksDir = join4(directory, "Manifold", "tasks");
|
|
3400
|
+
if (!existsSync4(tasksDir)) {
|
|
3401
|
+
return [];
|
|
3402
|
+
}
|
|
3403
|
+
try {
|
|
3404
|
+
const files = await readdir2(tasksDir);
|
|
3405
|
+
const mdFiles = files.filter((f) => f.endsWith(".md")).sort();
|
|
3406
|
+
const recentFiles = mdFiles.slice(-count);
|
|
3407
|
+
const tasks = await Promise.all(recentFiles.map(async (filename) => {
|
|
3408
|
+
const content = await readFile3(join4(tasksDir, filename), "utf-8");
|
|
3409
|
+
return { filename, content };
|
|
3410
|
+
}));
|
|
3411
|
+
return tasks;
|
|
3412
|
+
} catch {
|
|
3413
|
+
return [];
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
async function runClerkLoggingPhase(client, task, state, settings, directory) {
|
|
3417
|
+
state.state = "clerk_logging";
|
|
3418
|
+
await writeState(directory, state);
|
|
3419
|
+
await client.app.log({
|
|
3420
|
+
body: {
|
|
3421
|
+
service: "opencode-manifold",
|
|
3422
|
+
level: "info",
|
|
3423
|
+
message: "State: clerk_logging - Spawning Clerk for wiki logging"
|
|
3424
|
+
}
|
|
3425
|
+
});
|
|
3426
|
+
const taskId = `${task.slug}-${task.task_number.toString().padStart(3, "0")}`;
|
|
3427
|
+
const date = new Date().toISOString().split("T")[0];
|
|
3428
|
+
const clerkLoggingPrompt = `You are the Clerk. Log the completed task to the project wiki.
|
|
3429
|
+
|
|
3430
|
+
Task ID: ${taskId}
|
|
3431
|
+
Task Description: ${task.description}
|
|
3432
|
+
Date: ${date}
|
|
3433
|
+
Status: COMPLETED
|
|
3434
|
+
Loops: ${state.loop_count}
|
|
3435
|
+
|
|
3436
|
+
Scoped Prompt Used:
|
|
3437
|
+
${state.scoped_prompt}
|
|
3438
|
+
|
|
3439
|
+
Senior Developer's Final Implementation:
|
|
3440
|
+
${state.senior_output}
|
|
3441
|
+
|
|
3442
|
+
Junior Developer's Approval Response:
|
|
3443
|
+
${state.junior_response}
|
|
3444
|
+
|
|
3445
|
+
Loop History:
|
|
3446
|
+
${buildLoopHistory(state)}
|
|
3447
|
+
|
|
3448
|
+
Please perform the following logging actions:
|
|
3449
|
+
|
|
3450
|
+
1. Create/Update Task File at \`Manifold/tasks/${taskId}.md\`:
|
|
3451
|
+
- Header with date, status, loops, task description
|
|
3452
|
+
- Scoped Prompt section
|
|
3453
|
+
- Design Decisions section (extract from Senior's implementation reasoning)
|
|
3454
|
+
- Files Touched section (extract file paths from Senior's implementation)
|
|
3455
|
+
- Complete Loop History section
|
|
3456
|
+
|
|
3457
|
+
2. Update \`Manifold/index.md\`:
|
|
3458
|
+
- Add entry under the plan's section:
|
|
3459
|
+
\`- [[${taskId}]] — ${task.description} | ${date} | COMPLETED\`
|
|
3460
|
+
|
|
3461
|
+
3. Append to \`Manifold/log.md\`:
|
|
3462
|
+
\`## [${date}] ${taskId} | ${task.description} | COMPLETED | ${state.loop_count} loops\`
|
|
3463
|
+
|
|
3464
|
+
4. Update graph files for each touched file:
|
|
3465
|
+
- Read the implementation and identify all files that were created or modified
|
|
3466
|
+
- For each file, create or update \`Manifold/graph/<graph-name>.md\`
|
|
3467
|
+
- Add the task ID to the "Tasks That Edited" section
|
|
3468
|
+
- Do NOT populate "Calls" or "Depends On" sections — those are synced automatically from the codebase index
|
|
3469
|
+
- Graph filename format: replace \`/\` with \`__SL__\` and \`.\` with \`__DT__\`, append \`.md\`
|
|
3470
|
+
- Example: \`src/middleware/auth.ts\` → \`src__SL__middleware__SL__auth__DT__ts.md\`
|
|
3471
|
+
|
|
3472
|
+
Extract the list of files touched from the Senior's implementation and include it in your response.`;
|
|
3473
|
+
const clerkLoggingResult = await retryWithBackoff(() => spawnClerkSession(client, clerkLoggingPrompt, "clerk", settings.timeout), {
|
|
3474
|
+
maxRetries: settings.maxRetries,
|
|
3475
|
+
onRetry: (attempt, error) => {
|
|
3476
|
+
client.app.log({
|
|
3477
|
+
body: {
|
|
3478
|
+
service: "opencode-manifold",
|
|
3479
|
+
level: "warn",
|
|
3480
|
+
message: `Clerk logging retry ${attempt}: ${error.message}`
|
|
3481
|
+
}
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3485
|
+
if (!clerkLoggingResult.success) {
|
|
3486
|
+
await client.app.log({
|
|
3487
|
+
body: {
|
|
3488
|
+
service: "opencode-manifold",
|
|
3489
|
+
level: "error",
|
|
3490
|
+
message: `Clerk logging failed: ${clerkLoggingResult.error}. Task completed but wiki not updated.`
|
|
3491
|
+
}
|
|
3492
|
+
});
|
|
3493
|
+
return { files_changed: [] };
|
|
3494
|
+
}
|
|
3495
|
+
const filesChanged = extractFilesFromResponse(clerkLoggingResult.content);
|
|
634
3496
|
if (filesChanged.length > 0) {
|
|
635
3497
|
await client.app.log({
|
|
636
3498
|
body: {
|
|
@@ -648,6 +3510,14 @@ Extract the list of files touched from the Senior's implementation and include i
|
|
|
648
3510
|
message: `Graph files updated successfully`
|
|
649
3511
|
}
|
|
650
3512
|
});
|
|
3513
|
+
const syncResult = await syncGraphFilesFromIndex(directory, filesChanged);
|
|
3514
|
+
await client.app.log({
|
|
3515
|
+
body: {
|
|
3516
|
+
service: "opencode-manifold",
|
|
3517
|
+
level: "info",
|
|
3518
|
+
message: `Graph sync from codebase-index: ${syncResult.synced} synced, ${syncResult.skipped} skipped`
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
651
3521
|
} catch (error) {
|
|
652
3522
|
await client.app.log({
|
|
653
3523
|
body: {
|
|
@@ -1243,8 +4113,8 @@ function setPluginContext(client) {
|
|
|
1243
4113
|
pluginClient = client;
|
|
1244
4114
|
}
|
|
1245
4115
|
async function readSettings(directory) {
|
|
1246
|
-
const settingsPath =
|
|
1247
|
-
if (
|
|
4116
|
+
const settingsPath = join5(directory, "Manifold", "settings.json");
|
|
4117
|
+
if (existsSync5(settingsPath)) {
|
|
1248
4118
|
const content = await readFile4(settingsPath, "utf-8");
|
|
1249
4119
|
return JSON.parse(content);
|
|
1250
4120
|
}
|
|
@@ -1259,9 +4129,9 @@ async function readSettings(directory) {
|
|
|
1259
4129
|
};
|
|
1260
4130
|
}
|
|
1261
4131
|
async function updatePlansRegistry(directory, planFile) {
|
|
1262
|
-
const plansPath =
|
|
4132
|
+
const plansPath = join5(directory, "Manifold", "plans.json");
|
|
1263
4133
|
let plans = {};
|
|
1264
|
-
if (
|
|
4134
|
+
if (existsSync5(plansPath)) {
|
|
1265
4135
|
const content = await readFile4(plansPath, "utf-8");
|
|
1266
4136
|
plans = JSON.parse(content);
|
|
1267
4137
|
}
|