vibecode-anything 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +239 -67
  2. package/dist/cli.js +2140 -73
  3. package/dist/core/adapters.d.ts +26 -3
  4. package/dist/core/adapters.js +411 -25
  5. package/dist/core/agent-adapter.d.ts +67 -0
  6. package/dist/core/agent-adapter.js +312 -0
  7. package/dist/core/anti-cheat.d.ts +6 -0
  8. package/dist/core/anti-cheat.js +372 -0
  9. package/dist/core/badge.d.ts +18 -0
  10. package/dist/core/badge.js +360 -0
  11. package/dist/core/cache.d.ts +47 -0
  12. package/dist/core/cache.js +403 -0
  13. package/dist/core/ci-export.d.ts +35 -0
  14. package/dist/core/ci-export.js +796 -0
  15. package/dist/core/ci-formats.d.ts +21 -0
  16. package/dist/core/ci-formats.js +388 -0
  17. package/dist/core/client-codegen.d.ts +36 -0
  18. package/dist/core/client-codegen.js +2538 -0
  19. package/dist/core/compose.d.ts +71 -0
  20. package/dist/core/compose.js +1088 -0
  21. package/dist/core/docs-export.d.ts +37 -0
  22. package/dist/core/docs-export.js +2706 -0
  23. package/dist/core/doctor.d.ts +21 -1
  24. package/dist/core/doctor.js +234 -21
  25. package/dist/core/exec.d.ts +26 -2
  26. package/dist/core/exec.js +235 -8
  27. package/dist/core/fixtures.d.ts +153 -0
  28. package/dist/core/fixtures.js +2245 -0
  29. package/dist/core/format.d.ts +77 -0
  30. package/dist/core/format.js +632 -0
  31. package/dist/core/fs-snapshot.d.ts +37 -0
  32. package/dist/core/fs-snapshot.js +216 -0
  33. package/dist/core/graphql-export.d.ts +34 -0
  34. package/dist/core/graphql-export.js +2482 -0
  35. package/dist/core/har-export.d.ts +29 -0
  36. package/dist/core/har-export.js +988 -0
  37. package/dist/core/html-report.d.ts +27 -0
  38. package/dist/core/html-report.js +1535 -0
  39. package/dist/core/http-export.d.ts +31 -0
  40. package/dist/core/http-export.js +726 -0
  41. package/dist/core/impact.d.ts +80 -0
  42. package/dist/core/impact.js +1412 -0
  43. package/dist/core/lint.d.ts +38 -0
  44. package/dist/core/lint.js +1111 -0
  45. package/dist/core/load-export.d.ts +37 -0
  46. package/dist/core/load-export.js +1813 -0
  47. package/dist/core/mcp-export.d.ts +35 -0
  48. package/dist/core/mcp-export.js +1736 -0
  49. package/dist/core/mock-server.d.ts +47 -0
  50. package/dist/core/mock-server.js +1722 -0
  51. package/dist/core/openapi-export.d.ts +44 -0
  52. package/dist/core/openapi-export.js +1074 -0
  53. package/dist/core/parity.d.ts +6 -1
  54. package/dist/core/parity.js +36 -1
  55. package/dist/core/playwright-exporter.d.ts +23 -0
  56. package/dist/core/playwright-exporter.js +1343 -0
  57. package/dist/core/png.js +45 -9
  58. package/dist/core/regression.d.ts +54 -0
  59. package/dist/core/regression.js +529 -0
  60. package/dist/core/responsive.d.ts +86 -0
  61. package/dist/core/responsive.js +606 -0
  62. package/dist/core/run.d.ts +74 -0
  63. package/dist/core/run.js +696 -0
  64. package/dist/core/scheduler.d.ts +24 -0
  65. package/dist/core/scheduler.js +162 -0
  66. package/dist/core/schema-export.d.ts +29 -0
  67. package/dist/core/schema-export.js +2215 -0
  68. package/dist/core/schema.d.ts +3 -2
  69. package/dist/core/schema.js +460 -17
  70. package/dist/core/security.d.ts +233 -0
  71. package/dist/core/security.js +1839 -0
  72. package/dist/core/server-export.d.ts +38 -0
  73. package/dist/core/server-export.js +3198 -0
  74. package/dist/core/spec-writer.d.ts +9 -0
  75. package/dist/core/spec-writer.js +1202 -0
  76. package/dist/core/store.d.ts +11 -2
  77. package/dist/core/store.js +128 -8
  78. package/dist/core/target-map.d.ts +34 -0
  79. package/dist/core/target-map.js +262 -0
  80. package/dist/core/test-exporter.d.ts +25 -0
  81. package/dist/core/test-exporter.js +1918 -0
  82. package/dist/core/types.d.ts +182 -14
  83. package/dist/core/visual-semantic.d.ts +67 -0
  84. package/dist/core/visual-semantic.js +673 -0
  85. package/dist/core/visual.js +65 -16
  86. package/dist/core/watch.d.ts +28 -3
  87. package/dist/core/watch.js +222 -12
  88. package/dist/core/yaml.d.ts +5 -0
  89. package/dist/core/yaml.js +1009 -0
  90. package/dist/diagnostics/diagnose.d.ts +53 -0
  91. package/dist/diagnostics/diagnose.js +1083 -0
  92. package/dist/diagnostics/flake.d.ts +71 -0
  93. package/dist/diagnostics/flake.js +608 -0
  94. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  95. package/dist/diagnostics/mutation-audit.js +769 -0
  96. package/dist/diagnostics/spatial.d.ts +42 -0
  97. package/dist/diagnostics/spatial.js +346 -0
  98. package/dist/diagnostics/trends.d.ts +122 -0
  99. package/dist/diagnostics/trends.js +1190 -0
  100. package/dist/discovery/discover.d.ts +111 -0
  101. package/dist/discovery/discover.js +2017 -0
  102. package/dist/discovery/lock.d.ts +116 -0
  103. package/dist/discovery/lock.js +1505 -0
  104. package/dist/discovery/routes.d.ts +36 -0
  105. package/dist/discovery/routes.js +1494 -0
  106. package/dist/discovery/test-importer.d.ts +92 -0
  107. package/dist/discovery/test-importer.js +4952 -0
  108. package/dist/index.d.ts +123 -0
  109. package/dist/index.js +99 -0
  110. package/dist/ingestors/api-collections.d.ts +28 -0
  111. package/dist/ingestors/api-collections.js +2335 -0
  112. package/dist/ingestors/api-repo.d.ts +2 -1
  113. package/dist/ingestors/api-repo.js +483 -85
  114. package/dist/ingestors/asyncapi.d.ts +26 -0
  115. package/dist/ingestors/asyncapi.js +2105 -0
  116. package/dist/ingestors/bridges.d.ts +2 -0
  117. package/dist/ingestors/bridges.js +702 -0
  118. package/dist/ingestors/cli.d.ts +2 -1
  119. package/dist/ingestors/cli.js +234 -46
  120. package/dist/ingestors/curl.d.ts +14 -0
  121. package/dist/ingestors/curl.js +1024 -0
  122. package/dist/ingestors/graphql.d.ts +56 -0
  123. package/dist/ingestors/graphql.js +1852 -0
  124. package/dist/ingestors/http-file.d.ts +20 -0
  125. package/dist/ingestors/http-file.js +923 -0
  126. package/dist/ingestors/index.js +486 -6
  127. package/dist/ingestors/openrpc.d.ts +29 -0
  128. package/dist/ingestors/openrpc.js +1807 -0
  129. package/dist/ingestors/proto.d.ts +47 -0
  130. package/dist/ingestors/proto.js +2690 -0
  131. package/dist/ingestors/trace.d.ts +10 -0
  132. package/dist/ingestors/trace.js +599 -0
  133. package/dist/ingestors/video.d.ts +4 -1
  134. package/dist/ingestors/video.js +86 -36
  135. package/dist/ingestors/web.d.ts +16 -1
  136. package/dist/ingestors/web.js +474 -32
  137. package/dist/mcp/server.js +3532 -67
  138. package/dist/oracles/api-repo.js +102 -30
  139. package/dist/oracles/cli.js +65 -17
  140. package/dist/oracles/http-workflow.d.ts +68 -0
  141. package/dist/oracles/http-workflow.js +828 -0
  142. package/dist/oracles/image.js +178 -28
  143. package/dist/oracles/index.d.ts +3 -1
  144. package/dist/oracles/index.js +243 -14
  145. package/dist/oracles/perf-budget.d.ts +90 -0
  146. package/dist/oracles/perf-budget.js +1329 -0
  147. package/dist/oracles/stream.d.ts +94 -0
  148. package/dist/oracles/stream.js +1268 -0
  149. package/dist/oracles/ui-states.d.ts +49 -0
  150. package/dist/oracles/ui-states.js +894 -0
  151. package/dist/oracles/video.d.ts +1 -1
  152. package/dist/oracles/video.js +232 -16
  153. package/dist/oracles/web.js +464 -73
  154. package/dist/plugins/builtins.d.ts +12 -0
  155. package/dist/plugins/builtins.js +1052 -0
  156. package/dist/plugins/registry.d.ts +86 -0
  157. package/dist/plugins/registry.js +554 -0
  158. package/dist/setup/index.js +145 -33
  159. package/package.json +56 -47
  160. package/skills/vibecode-anything/SKILL.md +75 -52
@@ -0,0 +1,1009 @@
1
+ import { VibecodeError } from "./errors.js";
2
+ const MAX_YAML_BYTES = 4 * 1024 * 1024;
3
+ const MAX_YAML_DEPTH = 32;
4
+ const INT_DEC_RE = /^[+-]?(?:0|[1-9][0-9]*)$/;
5
+ const INT_HEX_RE = /^0x[0-9a-fA-F]+$/;
6
+ const INT_OCT_RE = /^0o[0-7]+$/;
7
+ const FLOAT_RE = /^[+-]?(?:\.[0-9]+|[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)$/;
8
+ const POS_INF_RE = /^[+]?\.(?:inf|Inf|INF)$/;
9
+ const NEG_INF_RE = /^-\.(?:inf|Inf|INF)$/;
10
+ const NAN_RE = /^\.(?:nan|NaN|NAN)$/;
11
+ const BLOCK_SCALAR_HEADER_RE = /^([|>])(?:([+-])([1-9])?|([1-9])([+-])?)?$/;
12
+ function fail(lineNo, message) {
13
+ throw new VibecodeError("CONTRACT_INVALID", `YAML parse error at line ${lineNo}: ${message}`);
14
+ }
15
+ function setSafeProp(obj, key, value) {
16
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
17
+ Object.defineProperty(obj, key, {
18
+ value,
19
+ writable: true,
20
+ enumerable: true,
21
+ configurable: true
22
+ });
23
+ }
24
+ else {
25
+ obj[key] = value;
26
+ }
27
+ }
28
+ function countIndent(line, lineNo) {
29
+ let i = 0;
30
+ while (i < line.length) {
31
+ const ch = line[i];
32
+ if (ch === " ") {
33
+ i++;
34
+ }
35
+ else if (ch === "\t") {
36
+ fail(lineNo, "Tabs are not allowed in YAML indentation");
37
+ }
38
+ else {
39
+ break;
40
+ }
41
+ }
42
+ return i;
43
+ }
44
+ function isBlankLine(line) {
45
+ for (let i = 0; i < line.length; i++) {
46
+ if (line[i] !== " " && line[i] !== "\t")
47
+ return false;
48
+ }
49
+ return true;
50
+ }
51
+ function isDocStart(trimmed) {
52
+ return trimmed === "---" || trimmed.startsWith("--- ") || trimmed.startsWith("---\t");
53
+ }
54
+ function isDocEnd(trimmed) {
55
+ return trimmed === "..." || trimmed.startsWith("... ") || trimmed.startsWith("...\t");
56
+ }
57
+ function isSequenceText(text) {
58
+ return text === "-" || text.startsWith("- ") || text.startsWith("-\t");
59
+ }
60
+ function stripInlineComment(segment) {
61
+ let inSingle = false;
62
+ let inDouble = false;
63
+ for (let i = 0; i < segment.length; i++) {
64
+ const ch = segment[i];
65
+ if (inSingle) {
66
+ if (ch === "'") {
67
+ if (segment[i + 1] === "'") {
68
+ i++;
69
+ }
70
+ else {
71
+ inSingle = false;
72
+ }
73
+ }
74
+ continue;
75
+ }
76
+ if (inDouble) {
77
+ if (ch === "\\") {
78
+ i++;
79
+ }
80
+ else if (ch === "\"") {
81
+ inDouble = false;
82
+ }
83
+ continue;
84
+ }
85
+ if (ch === "'") {
86
+ inSingle = true;
87
+ }
88
+ else if (ch === "\"") {
89
+ inDouble = true;
90
+ }
91
+ else if (ch === "#" && (i === 0 || segment[i - 1] === " " || segment[i - 1] === "\t")) {
92
+ return { text: segment.slice(0, i).trimEnd(), hadComment: true };
93
+ }
94
+ }
95
+ return { text: segment.trimEnd(), hadComment: false };
96
+ }
97
+ function parseHexEscape(text, start, digits, lineNo) {
98
+ const hex = text.slice(start, start + digits);
99
+ if (hex.length !== digits || !/^[0-9a-fA-F]+$/.test(hex)) {
100
+ fail(lineNo, `Invalid hex escape sequence in double-quoted string`);
101
+ }
102
+ const code = Number.parseInt(hex, 16);
103
+ if (code > 0x10ffff) {
104
+ fail(lineNo, `Unicode code point out of range in double-quoted string`);
105
+ }
106
+ return { value: String.fromCodePoint(code), nextPos: start + digits };
107
+ }
108
+ function scanDoubleQuoted(text, start, lineNo) {
109
+ let out = "";
110
+ let i = start + 1;
111
+ while (i < text.length) {
112
+ const ch = text[i];
113
+ if (ch === "\"") {
114
+ return { value: out, endIndex: i + 1 };
115
+ }
116
+ if (ch === "\\") {
117
+ i++;
118
+ if (i >= text.length) {
119
+ fail(lineNo, "Unterminated escape sequence in double-quoted string");
120
+ }
121
+ const esc = text[i];
122
+ switch (esc) {
123
+ case "\"":
124
+ out += "\"";
125
+ i++;
126
+ break;
127
+ case "\\":
128
+ out += "\\";
129
+ i++;
130
+ break;
131
+ case "/":
132
+ out += "/";
133
+ i++;
134
+ break;
135
+ case "n":
136
+ out += "\n";
137
+ i++;
138
+ break;
139
+ case "r":
140
+ out += "\r";
141
+ i++;
142
+ break;
143
+ case "t":
144
+ out += "\t";
145
+ i++;
146
+ break;
147
+ case "b":
148
+ out += "\b";
149
+ i++;
150
+ break;
151
+ case "f":
152
+ out += "\f";
153
+ i++;
154
+ break;
155
+ case "0":
156
+ out += "\0";
157
+ i++;
158
+ break;
159
+ case "a":
160
+ out += "\x07";
161
+ i++;
162
+ break;
163
+ case "v":
164
+ out += "\x0b";
165
+ i++;
166
+ break;
167
+ case "e":
168
+ out += "\x1b";
169
+ i++;
170
+ break;
171
+ case " ":
172
+ out += " ";
173
+ i++;
174
+ break;
175
+ case "N":
176
+ out += "\u0085";
177
+ i++;
178
+ break;
179
+ case "_":
180
+ out += "\u00a0";
181
+ i++;
182
+ break;
183
+ case "L":
184
+ out += "\u2028";
185
+ i++;
186
+ break;
187
+ case "P":
188
+ out += "\u2029";
189
+ i++;
190
+ break;
191
+ case "x": {
192
+ const parsed = parseHexEscape(text, i + 1, 2, lineNo);
193
+ out += parsed.value;
194
+ i = parsed.nextPos;
195
+ break;
196
+ }
197
+ case "u": {
198
+ const parsed = parseHexEscape(text, i + 1, 4, lineNo);
199
+ out += parsed.value;
200
+ i = parsed.nextPos;
201
+ break;
202
+ }
203
+ case "U": {
204
+ const parsed = parseHexEscape(text, i + 1, 8, lineNo);
205
+ out += parsed.value;
206
+ i = parsed.nextPos;
207
+ break;
208
+ }
209
+ default:
210
+ fail(lineNo, `Invalid escape sequence "\\${esc}" in double-quoted string`);
211
+ }
212
+ continue;
213
+ }
214
+ out += ch;
215
+ i++;
216
+ }
217
+ fail(lineNo, "Unterminated double-quoted string");
218
+ }
219
+ function scanSingleQuoted(text, start, lineNo) {
220
+ let out = "";
221
+ let i = start + 1;
222
+ while (i < text.length) {
223
+ const ch = text[i];
224
+ if (ch === "'") {
225
+ if (text[i + 1] === "'") {
226
+ out += "'";
227
+ i += 2;
228
+ continue;
229
+ }
230
+ return { value: out, endIndex: i + 1 };
231
+ }
232
+ out += ch;
233
+ i++;
234
+ }
235
+ fail(lineNo, "Unterminated single-quoted string");
236
+ }
237
+ function parsePlainScalar(raw, lineNo, allowFlowColon = false) {
238
+ const s = raw.trim();
239
+ if (s === "" || s === "~" || s === "null" || s === "Null" || s === "NULL")
240
+ return null;
241
+ if (s === "true" || s === "True" || s === "TRUE")
242
+ return true;
243
+ if (s === "false" || s === "False" || s === "FALSE")
244
+ return false;
245
+ if (!allowFlowColon && /:[ \t]/.test(s)) {
246
+ fail(lineNo, `Unexpected ": " in unquoted scalar "${s}"`);
247
+ }
248
+ if (INT_DEC_RE.test(s)) {
249
+ const n = Number(s);
250
+ if (Number.isFinite(n))
251
+ return n === 0 ? 0 : n;
252
+ }
253
+ if (INT_HEX_RE.test(s))
254
+ return Number.parseInt(s, 16);
255
+ if (INT_OCT_RE.test(s))
256
+ return Number.parseInt(s.slice(2), 8);
257
+ if (FLOAT_RE.test(s)) {
258
+ const n = Number(s);
259
+ if (Number.isFinite(n))
260
+ return n;
261
+ }
262
+ if (POS_INF_RE.test(s))
263
+ return Infinity;
264
+ if (NEG_INF_RE.test(s))
265
+ return -Infinity;
266
+ if (NAN_RE.test(s))
267
+ return Number.NaN;
268
+ return s;
269
+ }
270
+ function splitBlockMappingLine(content, lineNo) {
271
+ if (content.length === 0)
272
+ return null;
273
+ if (content[0] === "[" || content[0] === "{")
274
+ return null;
275
+ if (isSequenceText(content))
276
+ return null;
277
+ if (content[0] === "\"") {
278
+ const quoted = scanDoubleQuoted(content, 0, lineNo);
279
+ let pos = quoted.endIndex;
280
+ while (pos < content.length && content[pos] === " ")
281
+ pos++;
282
+ if (content[pos] === ":" && (pos + 1 === content.length || content[pos + 1] === " " || content[pos + 1] === "\t")) {
283
+ return { key: quoted.value, rawValue: content.slice(pos + 1).trimStart(), keyQuoted: true };
284
+ }
285
+ return null;
286
+ }
287
+ if (content[0] === "'") {
288
+ const quoted = scanSingleQuoted(content, 0, lineNo);
289
+ let pos = quoted.endIndex;
290
+ while (pos < content.length && content[pos] === " ")
291
+ pos++;
292
+ if (content[pos] === ":" && (pos + 1 === content.length || content[pos + 1] === " " || content[pos + 1] === "\t")) {
293
+ return { key: quoted.value, rawValue: content.slice(pos + 1).trimStart(), keyQuoted: true };
294
+ }
295
+ return null;
296
+ }
297
+ for (let i = 0; i < content.length; i++) {
298
+ const ch = content[i];
299
+ if (ch === "#" && (i === 0 || content[i - 1] === " " || content[i - 1] === "\t")) {
300
+ return null;
301
+ }
302
+ if (ch === ":" && (i + 1 === content.length || content[i + 1] === " " || content[i + 1] === "\t")) {
303
+ const rawKey = content.slice(0, i).trim();
304
+ if (rawKey.length === 0) {
305
+ fail(lineNo, "Empty mapping key");
306
+ }
307
+ return { key: rawKey, rawValue: content.slice(i + 1).trimStart(), keyQuoted: false };
308
+ }
309
+ }
310
+ return null;
311
+ }
312
+ function skipIgnorable(state) {
313
+ while (state.index < state.lines.length) {
314
+ const line = state.lines[state.index];
315
+ if (isBlankLine(line)) {
316
+ state.index++;
317
+ continue;
318
+ }
319
+ const lineNo = state.index + 1;
320
+ const indent = countIndent(line, lineNo);
321
+ const trimmed = line.slice(indent);
322
+ if (trimmed.startsWith("#")) {
323
+ state.index++;
324
+ continue;
325
+ }
326
+ break;
327
+ }
328
+ }
329
+ function flowSkipWsAndComments(cur) {
330
+ while (cur.lineIdx < cur.lines.length) {
331
+ const line = cur.lines[cur.lineIdx];
332
+ while (cur.col < line.length && (line[cur.col] === " " || line[cur.col] === "\t")) {
333
+ cur.col++;
334
+ }
335
+ if (cur.col < line.length && line[cur.col] === "#") {
336
+ cur.col = line.length;
337
+ }
338
+ if (cur.col >= line.length) {
339
+ cur.lineIdx++;
340
+ cur.col = 0;
341
+ if (cur.lineIdx < cur.lines.length) {
342
+ const nextLine = cur.lines[cur.lineIdx];
343
+ if (!isBlankLine(nextLine)) {
344
+ cur.col = countIndent(nextLine, cur.lineIdx + 1);
345
+ }
346
+ }
347
+ continue;
348
+ }
349
+ break;
350
+ }
351
+ }
352
+ function flowPeek(cur) {
353
+ flowSkipWsAndComments(cur);
354
+ if (cur.lineIdx >= cur.lines.length)
355
+ return null;
356
+ return cur.lines[cur.lineIdx][cur.col] ?? null;
357
+ }
358
+ function parseFlowDoubleQuoted(cur) {
359
+ const startLine = cur.lineIdx + 1;
360
+ const line = cur.lines[cur.lineIdx];
361
+ const parsed = scanDoubleQuoted(line, cur.col, startLine);
362
+ cur.col = parsed.endIndex;
363
+ return parsed.value;
364
+ }
365
+ function parseFlowSingleQuoted(cur) {
366
+ const startLine = cur.lineIdx + 1;
367
+ const line = cur.lines[cur.lineIdx];
368
+ const parsed = scanSingleQuoted(line, cur.col, startLine);
369
+ cur.col = parsed.endIndex;
370
+ return parsed.value;
371
+ }
372
+ function parseFlowPlainScalar(cur, inMapping) {
373
+ const line = cur.lines[cur.lineIdx];
374
+ const start = cur.col;
375
+ while (cur.col < line.length) {
376
+ const ch = line[cur.col];
377
+ if (ch === "," || ch === "[" || ch === "]" || ch === "{" || ch === "}") {
378
+ break;
379
+ }
380
+ if (ch === "#" && (cur.col === start || line[cur.col - 1] === " " || line[cur.col - 1] === "\t")) {
381
+ break;
382
+ }
383
+ if (inMapping && ch === ":") {
384
+ const next = line[cur.col + 1];
385
+ if (next === undefined ||
386
+ next === " " ||
387
+ next === "\t" ||
388
+ next === "," ||
389
+ next === "]" ||
390
+ next === "}" ||
391
+ next === "[" ||
392
+ next === "{") {
393
+ break;
394
+ }
395
+ }
396
+ cur.col++;
397
+ }
398
+ return line.slice(start, cur.col).trim();
399
+ }
400
+ function parseFlowValue(cur, depth, inMapping) {
401
+ if (depth > MAX_YAML_DEPTH) {
402
+ fail(cur.lineIdx + 1, `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
403
+ }
404
+ const ch = flowPeek(cur);
405
+ if (ch === null) {
406
+ fail(Math.min(cur.lineIdx + 1, cur.lines.length), "Unexpected end of input inside flow collection");
407
+ }
408
+ if (ch === "[")
409
+ return parseFlowArray(cur, depth + 1);
410
+ if (ch === "{")
411
+ return parseFlowObject(cur, depth + 1);
412
+ if (ch === "\"")
413
+ return parseFlowDoubleQuoted(cur);
414
+ if (ch === "'")
415
+ return parseFlowSingleQuoted(cur);
416
+ if (ch === "]" || ch === "}" || ch === ",") {
417
+ fail(cur.lineIdx + 1, `Unexpected "${ch}" in flow collection`);
418
+ }
419
+ const raw = parseFlowPlainScalar(cur, inMapping);
420
+ return parsePlainScalar(raw, cur.lineIdx + 1, false);
421
+ }
422
+ function parseFlowArray(cur, depth) {
423
+ if (depth > MAX_YAML_DEPTH) {
424
+ fail(cur.lineIdx + 1, `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
425
+ }
426
+ const startLine = cur.lineIdx + 1;
427
+ cur.col++; // consume '['
428
+ const items = [];
429
+ while (true) {
430
+ const ch = flowPeek(cur);
431
+ if (ch === null) {
432
+ fail(startLine, "Unterminated flow array '['");
433
+ }
434
+ if (ch === "]") {
435
+ cur.col++;
436
+ return items;
437
+ }
438
+ if (ch === ",") {
439
+ fail(cur.lineIdx + 1, "Unexpected ',' in flow array");
440
+ }
441
+ items.push(parseFlowValue(cur, depth, false));
442
+ const sep = flowPeek(cur);
443
+ if (sep === ",") {
444
+ cur.col++;
445
+ // allow optional trailing comma before ']'
446
+ if (flowPeek(cur) === "]") {
447
+ cur.col++;
448
+ return items;
449
+ }
450
+ }
451
+ else if (sep === "]") {
452
+ cur.col++;
453
+ return items;
454
+ }
455
+ else {
456
+ fail(cur.lineIdx + 1, `Expected ',' or ']' in flow array, found '${sep ?? "EOF"}'`);
457
+ }
458
+ }
459
+ }
460
+ function parseFlowObject(cur, depth) {
461
+ if (depth > MAX_YAML_DEPTH) {
462
+ fail(cur.lineIdx + 1, `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
463
+ }
464
+ const startLine = cur.lineIdx + 1;
465
+ cur.col++; // consume '{'
466
+ const obj = {};
467
+ while (true) {
468
+ const ch = flowPeek(cur);
469
+ if (ch === null) {
470
+ fail(startLine, "Unterminated flow object '{'");
471
+ }
472
+ if (ch === "}") {
473
+ cur.col++;
474
+ return obj;
475
+ }
476
+ if (ch === "," || ch === "]") {
477
+ fail(cur.lineIdx + 1, `Unexpected '${ch}' in flow object`);
478
+ }
479
+ let key;
480
+ if (ch === "\"") {
481
+ key = parseFlowDoubleQuoted(cur);
482
+ }
483
+ else if (ch === "'") {
484
+ key = parseFlowSingleQuoted(cur);
485
+ }
486
+ else {
487
+ const rawKey = parseFlowPlainScalar(cur, true);
488
+ if (rawKey.length === 0) {
489
+ fail(cur.lineIdx + 1, "Empty key in flow object");
490
+ }
491
+ key = rawKey;
492
+ }
493
+ const colon = flowPeek(cur);
494
+ if (colon !== ":") {
495
+ fail(cur.lineIdx + 1, `Expected ':' after key "${key}" in flow object`);
496
+ }
497
+ cur.col++; // consume ':'
498
+ const nextCh = flowPeek(cur);
499
+ let value;
500
+ if (nextCh === "," || nextCh === "}") {
501
+ value = null;
502
+ }
503
+ else {
504
+ value = parseFlowValue(cur, depth, true);
505
+ }
506
+ setSafeProp(obj, key, value);
507
+ const sep = flowPeek(cur);
508
+ if (sep === ",") {
509
+ cur.col++;
510
+ if (flowPeek(cur) === "}") {
511
+ cur.col++;
512
+ return obj;
513
+ }
514
+ }
515
+ else if (sep === "}") {
516
+ cur.col++;
517
+ return obj;
518
+ }
519
+ else {
520
+ fail(cur.lineIdx + 1, `Expected ',' or '}' in flow object, found '${sep ?? "EOF"}'`);
521
+ }
522
+ }
523
+ }
524
+ function parseFlowFromBlock(state, lineIdx, startCol, depth) {
525
+ const cur = { lines: state.lines, lineIdx, col: startCol };
526
+ const value = parseFlowValue(cur, depth, false);
527
+ const trailingLine = cur.lines[cur.lineIdx] ?? "";
528
+ const trailing = stripInlineComment(trailingLine.slice(cur.col)).text.trim();
529
+ if (trailing.length > 0) {
530
+ fail(cur.lineIdx + 1, `Unexpected trailing content "${trailing}" after flow collection`);
531
+ }
532
+ state.index = cur.lineIdx + 1;
533
+ return value;
534
+ }
535
+ function parseBlockScalarHeader(rawHeader, lineNo) {
536
+ const { text } = stripInlineComment(rawHeader);
537
+ const trimmed = text.trim();
538
+ const match = BLOCK_SCALAR_HEADER_RE.exec(trimmed);
539
+ if (!match) {
540
+ fail(lineNo, `Invalid block scalar header "${trimmed}"`);
541
+ }
542
+ const style = match[1];
543
+ const chompChar = match[2] || match[5] || "";
544
+ const indentChar = match[3] || match[4] || "";
545
+ const chomp = chompChar === "-" ? "strip" : chompChar === "+" ? "keep" : "clip";
546
+ const explicitIndent = indentChar ? Number.parseInt(indentChar, 10) : null;
547
+ return { style, chomp, explicitIndent };
548
+ }
549
+ function parseBlockScalar(state, rawHeader, parentIndent, headerLineNo) {
550
+ const { style, chomp, explicitIndent } = parseBlockScalarHeader(rawHeader, headerLineNo);
551
+ let contentIndent = explicitIndent !== null ? Math.max(0, parentIndent) + explicitIndent : null;
552
+ const rawCollected = [];
553
+ let maxLeadingBlankSpaces = 0;
554
+ let seenNonEmpty = false;
555
+ while (state.index < state.lines.length) {
556
+ const line = state.lines[state.index];
557
+ const lineNo = state.index + 1;
558
+ if (isBlankLine(line)) {
559
+ let sp = 0;
560
+ while (sp < line.length && line[sp] === " ")
561
+ sp++;
562
+ if (!seenNonEmpty) {
563
+ if (sp > maxLeadingBlankSpaces)
564
+ maxLeadingBlankSpaces = sp;
565
+ }
566
+ rawCollected.push({ line, empty: true, spaces: sp });
567
+ state.index++;
568
+ continue;
569
+ }
570
+ // Count leading spaces, rejecting tabs in structural indentation before contentIndent.
571
+ let spaces = 0;
572
+ while (spaces < line.length) {
573
+ const ch = line[spaces];
574
+ if (ch === " ") {
575
+ spaces++;
576
+ }
577
+ else if (ch === "\t") {
578
+ if (contentIndent === null || spaces < contentIndent) {
579
+ fail(lineNo, "Tabs are not allowed in YAML indentation");
580
+ }
581
+ break;
582
+ }
583
+ else {
584
+ break;
585
+ }
586
+ }
587
+ if (spaces === 0) {
588
+ const trimmed = line.trim();
589
+ if (isDocStart(trimmed) || isDocEnd(trimmed)) {
590
+ break;
591
+ }
592
+ }
593
+ if (contentIndent === null) {
594
+ if (spaces <= parentIndent) {
595
+ break;
596
+ }
597
+ if (maxLeadingBlankSpaces > spaces) {
598
+ fail(lineNo, "Leading empty line in block scalar is more indented than content");
599
+ }
600
+ contentIndent = spaces;
601
+ }
602
+ else if (spaces < contentIndent) {
603
+ break;
604
+ }
605
+ seenNonEmpty = true;
606
+ rawCollected.push({ line, empty: false, spaces });
607
+ state.index++;
608
+ }
609
+ // Separate trailing blank lines.
610
+ let trailingEmptyCount = 0;
611
+ while (rawCollected.length > 0 && rawCollected[rawCollected.length - 1].empty) {
612
+ rawCollected.pop();
613
+ trailingEmptyCount++;
614
+ }
615
+ if (rawCollected.length === 0) {
616
+ if (chomp === "keep")
617
+ return "\n".repeat(trailingEmptyCount);
618
+ return "";
619
+ }
620
+ const effectiveIndent = contentIndent ?? 0;
621
+ const lines = rawCollected.map((entry) => entry.empty
622
+ ? entry.line.length > effectiveIndent ? entry.line.slice(effectiveIndent) : ""
623
+ : entry.line.slice(effectiveIndent));
624
+ let body;
625
+ if (style === "|") {
626
+ body = lines.join("\n");
627
+ }
628
+ else {
629
+ body = foldBlockLines(lines);
630
+ }
631
+ if (chomp === "strip")
632
+ return body;
633
+ if (chomp === "clip")
634
+ return `${body}\n`;
635
+ return `${body}\n${"\n".repeat(trailingEmptyCount)}`;
636
+ }
637
+ function isMoreIndented(line) {
638
+ return line.length > 0 && (line[0] === " " || line[0] === "\t");
639
+ }
640
+ function foldBlockLines(lines) {
641
+ // Preserve any leading empty lines verbatim.
642
+ let idx = 0;
643
+ let out = "";
644
+ while (idx < lines.length && lines[idx] === "") {
645
+ out += "\n";
646
+ idx++;
647
+ }
648
+ if (idx >= lines.length)
649
+ return out;
650
+ out += lines[idx];
651
+ let prev = lines[idx];
652
+ idx++;
653
+ while (idx < lines.length) {
654
+ let emptyCount = 0;
655
+ while (idx < lines.length && lines[idx] === "") {
656
+ emptyCount++;
657
+ idx++;
658
+ }
659
+ if (idx >= lines.length)
660
+ break;
661
+ const curr = lines[idx];
662
+ const prevNormal = !isMoreIndented(prev);
663
+ const currNormal = !isMoreIndented(curr);
664
+ if (prevNormal && currNormal) {
665
+ out += emptyCount === 0 ? " " : "\n".repeat(emptyCount);
666
+ }
667
+ else {
668
+ out += "\n".repeat(emptyCount + 1);
669
+ }
670
+ out += curr;
671
+ prev = curr;
672
+ idx++;
673
+ }
674
+ return out;
675
+ }
676
+ function parseQuotedScalarLine(rawValue, lineNo) {
677
+ const quote = rawValue[0];
678
+ const parsed = quote === "\""
679
+ ? scanDoubleQuoted(rawValue, 0, lineNo)
680
+ : scanSingleQuoted(rawValue, 0, lineNo);
681
+ const trailing = stripInlineComment(rawValue.slice(parsed.endIndex)).text.trim();
682
+ if (trailing.length > 0) {
683
+ fail(lineNo, `Unexpected trailing content "${trailing}" after quoted scalar`);
684
+ }
685
+ return parsed.value;
686
+ }
687
+ function parseInlineValue(state, rawValue, lineIdx, parentIndent, depth) {
688
+ const lineNo = lineIdx + 1;
689
+ const trimmedStart = rawValue.trimStart();
690
+ if (trimmedStart.length === 0) {
691
+ state.index = lineIdx + 1;
692
+ return parseNestedAfterEmpty(state, parentIndent, depth);
693
+ }
694
+ // Comment-only value on the key line means the value is nested on subsequent lines (or null).
695
+ if (trimmedStart[0] === "#") {
696
+ state.index = lineIdx + 1;
697
+ return parseNestedAfterEmpty(state, parentIndent, depth);
698
+ }
699
+ // Block scalar header.
700
+ if (trimmedStart[0] === "|" || trimmedStart[0] === ">") {
701
+ state.index = lineIdx + 1;
702
+ return parseBlockScalar(state, trimmedStart, parentIndent, lineNo);
703
+ }
704
+ // Flow array or flow object (possibly multiline).
705
+ if (trimmedStart[0] === "[" || trimmedStart[0] === "{") {
706
+ const line = state.lines[lineIdx];
707
+ const startCol = line.length - rawValue.length + (rawValue.length - trimmedStart.length);
708
+ return parseFlowFromBlock(state, lineIdx, startCol, depth);
709
+ }
710
+ // Quoted string scalar.
711
+ if (trimmedStart[0] === "\"" || trimmedStart[0] === "'") {
712
+ state.index = lineIdx + 1;
713
+ return parseQuotedScalarLine(trimmedStart, lineNo);
714
+ }
715
+ // Unexpected stray flow closing delimiter.
716
+ if (trimmedStart[0] === "]" || trimmedStart[0] === "}" || trimmedStart[0] === ",") {
717
+ fail(lineNo, `Unexpected "${trimmedStart[0]}" at start of value`);
718
+ }
719
+ // Plain scalar (possibly continuing onto more-indented plain lines).
720
+ const stripped = stripInlineComment(trimmedStart);
721
+ let combined = stripped.text.trim();
722
+ state.index = lineIdx + 1;
723
+ if (!stripped.hadComment && !/:[ \t]/.test(combined)) {
724
+ while (state.index < state.lines.length) {
725
+ // Count blank lines ahead before deciding whether a continuation line follows.
726
+ let lookahead = state.index;
727
+ let blankLines = 0;
728
+ while (lookahead < state.lines.length && isBlankLine(state.lines[lookahead])) {
729
+ blankLines++;
730
+ lookahead++;
731
+ }
732
+ if (lookahead >= state.lines.length)
733
+ break;
734
+ const nextLine = state.lines[lookahead];
735
+ const nextLineNo = lookahead + 1;
736
+ const nextIndent = countIndent(nextLine, nextLineNo);
737
+ const nextText = nextLine.slice(nextIndent);
738
+ if (nextText.startsWith("#"))
739
+ break;
740
+ if (nextIndent === 0 && (isDocStart(nextText) || isDocEnd(nextText)))
741
+ break;
742
+ if (nextIndent <= parentIndent)
743
+ break;
744
+ if (isSequenceText(nextText))
745
+ break;
746
+ if (splitBlockMappingLine(nextText, nextLineNo) !== null)
747
+ break;
748
+ const cont = stripInlineComment(nextText);
749
+ const contText = cont.text.trim();
750
+ if (/:[ \t]/.test(contText))
751
+ break;
752
+ combined += blankLines > 0 ? `${"\n".repeat(blankLines)}${contText}` : ` ${contText}`;
753
+ state.index = lookahead + 1;
754
+ if (cont.hadComment)
755
+ break;
756
+ }
757
+ }
758
+ return parsePlainScalar(combined, lineNo, false);
759
+ }
760
+ function parseNestedAfterEmpty(state, parentIndent, depth) {
761
+ skipIgnorable(state);
762
+ if (state.index >= state.lines.length)
763
+ return null;
764
+ const line = state.lines[state.index];
765
+ const lineNo = state.index + 1;
766
+ const nextIndent = countIndent(line, lineNo);
767
+ const nextText = line.slice(nextIndent);
768
+ if (nextIndent === 0 && (isDocStart(nextText) || isDocEnd(nextText)))
769
+ return null;
770
+ // YAML 1.2 allows indent-less block sequences directly under a mapping key at the same indent.
771
+ if (nextIndent === parentIndent && isSequenceText(nextText)) {
772
+ return parseBlockSequence(state, nextIndent, depth + 1);
773
+ }
774
+ if (nextIndent <= parentIndent) {
775
+ return null;
776
+ }
777
+ return parseBlockNode(state, nextIndent, depth + 1);
778
+ }
779
+ function parseBlockMapping(state, mapIndent, depth, inlineFirst) {
780
+ if (depth > MAX_YAML_DEPTH) {
781
+ fail((inlineFirst?.lineNo ?? state.index + 1), `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
782
+ }
783
+ const obj = {};
784
+ if (inlineFirst) {
785
+ const split = splitBlockMappingLine(inlineFirst.rest, inlineFirst.lineNo);
786
+ if (!split) {
787
+ fail(inlineFirst.lineNo, `Expected mapping entry`);
788
+ }
789
+ const val = parseInlineValue(state, split.rawValue, inlineFirst.lineNo - 1, mapIndent, depth);
790
+ setSafeProp(obj, split.key, val);
791
+ }
792
+ while (true) {
793
+ skipIgnorable(state);
794
+ if (state.index >= state.lines.length)
795
+ break;
796
+ const lineIdx = state.index;
797
+ const lineNo = lineIdx + 1;
798
+ const line = state.lines[lineIdx];
799
+ const indent = countIndent(line, lineNo);
800
+ const content = line.slice(indent);
801
+ if (indent === 0 && (isDocStart(content) || isDocEnd(content))) {
802
+ break;
803
+ }
804
+ if (indent < mapIndent) {
805
+ break;
806
+ }
807
+ if (indent > mapIndent) {
808
+ fail(lineNo, `Unexpected indentation (expected ${mapIndent}, found ${indent})`);
809
+ }
810
+ const split = splitBlockMappingLine(content, lineNo);
811
+ if (!split) {
812
+ break;
813
+ }
814
+ const val = parseInlineValue(state, split.rawValue, lineIdx, mapIndent, depth);
815
+ setSafeProp(obj, split.key, val);
816
+ }
817
+ return obj;
818
+ }
819
+ function parseBlockSequence(state, seqIndent, depth, inlineFirst) {
820
+ if (depth > MAX_YAML_DEPTH) {
821
+ fail((inlineFirst?.lineNo ?? state.index + 1), `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
822
+ }
823
+ const items = [];
824
+ let pendingInline = inlineFirst;
825
+ while (true) {
826
+ let lineIdx;
827
+ let lineNo;
828
+ let content;
829
+ let dashIndent;
830
+ if (pendingInline) {
831
+ lineIdx = pendingInline.lineNo - 1;
832
+ lineNo = pendingInline.lineNo;
833
+ content = pendingInline.rest;
834
+ dashIndent = pendingInline.indent;
835
+ pendingInline = undefined;
836
+ }
837
+ else {
838
+ skipIgnorable(state);
839
+ if (state.index >= state.lines.length)
840
+ break;
841
+ lineIdx = state.index;
842
+ lineNo = lineIdx + 1;
843
+ const line = state.lines[lineIdx];
844
+ dashIndent = countIndent(line, lineNo);
845
+ content = line.slice(dashIndent);
846
+ if (dashIndent === 0 && (isDocStart(content) || isDocEnd(content))) {
847
+ break;
848
+ }
849
+ if (dashIndent < seqIndent) {
850
+ break;
851
+ }
852
+ if (dashIndent > seqIndent) {
853
+ fail(lineNo, `Unexpected indentation in sequence (expected ${seqIndent}, found ${dashIndent})`);
854
+ }
855
+ if (!isSequenceText(content)) {
856
+ break;
857
+ }
858
+ }
859
+ // Consume '-' and measure spacing after '-'.
860
+ let afterDashPos = 1;
861
+ while (afterDashPos < content.length && content[afterDashPos] === " ") {
862
+ afterDashPos++;
863
+ }
864
+ if (afterDashPos < content.length && content[afterDashPos] === "\t") {
865
+ fail(lineNo, "Tabs are not allowed in YAML indentation");
866
+ }
867
+ const rest = content.slice(afterDashPos);
868
+ const contentCol = dashIndent + afterDashPos;
869
+ if (rest.length === 0 || rest.startsWith("#")) {
870
+ state.index = lineIdx + 1;
871
+ skipIgnorable(state);
872
+ if (state.index >= state.lines.length) {
873
+ items.push(null);
874
+ break;
875
+ }
876
+ const nextLine = state.lines[state.index];
877
+ const nextLineNo = state.index + 1;
878
+ const nextIndent = countIndent(nextLine, nextLineNo);
879
+ const nextText = nextLine.slice(nextIndent);
880
+ if (nextIndent === 0 && (isDocStart(nextText) || isDocEnd(nextText))) {
881
+ items.push(null);
882
+ break;
883
+ }
884
+ if (nextIndent <= seqIndent) {
885
+ items.push(null);
886
+ }
887
+ else {
888
+ items.push(parseBlockNode(state, nextIndent, depth + 1));
889
+ }
890
+ continue;
891
+ }
892
+ if (isSequenceText(rest)) {
893
+ items.push(parseBlockSequence(state, contentCol, depth + 1, { indent: contentCol, rest, lineNo }));
894
+ continue;
895
+ }
896
+ if (rest[0] === "|" || rest[0] === ">") {
897
+ state.index = lineIdx + 1;
898
+ items.push(parseBlockScalar(state, rest, seqIndent, lineNo));
899
+ continue;
900
+ }
901
+ if (rest[0] === "[" || rest[0] === "{") {
902
+ items.push(parseFlowFromBlock(state, lineIdx, contentCol, depth));
903
+ continue;
904
+ }
905
+ if (splitBlockMappingLine(rest, lineNo) !== null) {
906
+ items.push(parseBlockMapping(state, contentCol, depth + 1, { indent: contentCol, rest, lineNo }));
907
+ continue;
908
+ }
909
+ items.push(parseInlineValue(state, rest, lineIdx, seqIndent, depth));
910
+ }
911
+ return items;
912
+ }
913
+ function parseBlockNode(state, indent, depth) {
914
+ if (depth > MAX_YAML_DEPTH) {
915
+ fail(state.index + 1, `Maximum YAML nesting depth (${MAX_YAML_DEPTH}) exceeded`);
916
+ }
917
+ const lineIdx = state.index;
918
+ const lineNo = lineIdx + 1;
919
+ const line = state.lines[lineIdx];
920
+ const content = line.slice(indent);
921
+ if (isSequenceText(content)) {
922
+ return parseBlockSequence(state, indent, depth);
923
+ }
924
+ if (content[0] === "[" || content[0] === "{") {
925
+ return parseFlowFromBlock(state, lineIdx, indent, depth);
926
+ }
927
+ if (content[0] === "|" || content[0] === ">") {
928
+ state.index = lineIdx + 1;
929
+ return parseBlockScalar(state, content, indent - 1, lineNo);
930
+ }
931
+ if (splitBlockMappingLine(content, lineNo) !== null) {
932
+ return parseBlockMapping(state, indent, depth);
933
+ }
934
+ return parseInlineValue(state, content, lineIdx, indent - 1, depth);
935
+ }
936
+ /**
937
+ * Parse a YAML 1.2 document (OpenAPI 3.x / Swagger 2.0 subset) with zero runtime dependencies.
938
+ * Enforces 4 MB input size limit, max nesting depth of 32, and strict indentation/syntax checks.
939
+ */
940
+ export function parseYaml(text) {
941
+ if (typeof text !== "string") {
942
+ throw new VibecodeError("CONTRACT_INVALID", "YAML input must be a string");
943
+ }
944
+ const normalized = text.startsWith("\uFEFF") ? text.slice(1) : text;
945
+ if (normalized.length > MAX_YAML_BYTES || Buffer.byteLength(normalized, "utf8") > MAX_YAML_BYTES) {
946
+ throw new VibecodeError("CONTRACT_INVALID", `YAML input exceeds maximum allowed size of ${MAX_YAML_BYTES} bytes`);
947
+ }
948
+ const unified = normalized.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
949
+ const lines = (unified.endsWith("\n") ? unified.slice(0, -1) : unified).split("\n");
950
+ const state = { lines, index: 0 };
951
+ // Skip leading comments, blank lines, and optional YAML directives before document start.
952
+ skipIgnorable(state);
953
+ while (state.index < state.lines.length) {
954
+ const line = state.lines[state.index];
955
+ const lineNo = state.index + 1;
956
+ const indent = countIndent(line, lineNo);
957
+ const content = line.slice(indent);
958
+ if (indent === 0 && content.startsWith("%")) {
959
+ state.index++;
960
+ skipIgnorable(state);
961
+ continue;
962
+ }
963
+ break;
964
+ }
965
+ if (state.index >= state.lines.length)
966
+ return null;
967
+ let root = null;
968
+ const firstIdx = state.index;
969
+ const firstLineNo = firstIdx + 1;
970
+ const firstLine = state.lines[firstIdx];
971
+ const firstIndent = countIndent(firstLine, firstLineNo);
972
+ const firstContent = firstLine.slice(firstIndent);
973
+ if (firstIndent === 0 && isDocEnd(firstContent)) {
974
+ return null;
975
+ }
976
+ if (firstIndent === 0 && isDocStart(firstContent)) {
977
+ const afterMarker = firstContent.slice(3).trimStart();
978
+ if (afterMarker.length === 0 || afterMarker.startsWith("#")) {
979
+ state.index = firstIdx + 1;
980
+ skipIgnorable(state);
981
+ if (state.index >= state.lines.length)
982
+ return null;
983
+ const nextLine = state.lines[state.index];
984
+ const nextLineNo = state.index + 1;
985
+ const nextIndent = countIndent(nextLine, nextLineNo);
986
+ const nextContent = nextLine.slice(nextIndent);
987
+ if (nextIndent === 0 && isDocEnd(nextContent))
988
+ return null;
989
+ root = parseBlockNode(state, nextIndent, 1);
990
+ }
991
+ else {
992
+ root = parseInlineValue(state, afterMarker, firstIdx, -1, 1);
993
+ }
994
+ }
995
+ else {
996
+ root = parseBlockNode(state, firstIndent, 1);
997
+ }
998
+ skipIgnorable(state);
999
+ if (state.index < state.lines.length) {
1000
+ const remLine = state.lines[state.index];
1001
+ const remLineNo = state.index + 1;
1002
+ const remIndent = countIndent(remLine, remLineNo);
1003
+ const remContent = remLine.slice(remIndent);
1004
+ if (!(remIndent === 0 && isDocEnd(remContent))) {
1005
+ fail(remLineNo, `Unexpected content "${remContent.slice(0, 40)}"`);
1006
+ }
1007
+ }
1008
+ return root;
1009
+ }