framework-aidf 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/INSTALLATION.md +140 -0
  3. package/LICENSE +21 -0
  4. package/QODER.md +88 -0
  5. package/README.md +142 -2
  6. package/UTILISATION.md +188 -0
  7. package/assets/adapters/qoder/agents/aidf-orchestrator.md +30 -0
  8. package/assets/adapters/qoder/rules/00-core.md +28 -0
  9. package/assets/adapters/qoder/rules/10-security.md +33 -0
  10. package/assets/adapters/qoder/rules/20-context.md +39 -0
  11. package/assets/core/AGENTS.fragment.md +18 -0
  12. package/assets/core/AIDF.md +107 -0
  13. package/assets/docs/APPFLOW.md +66 -0
  14. package/assets/docs/BACKEND.md +71 -0
  15. package/assets/docs/CHANGELOG.md +25 -0
  16. package/assets/docs/CONVENTIONS.md +95 -0
  17. package/assets/docs/DECISIONS.md +60 -0
  18. package/assets/docs/PLAN.md +53 -0
  19. package/assets/docs/PRD.md +88 -0
  20. package/assets/docs/SECURITY.md +94 -0
  21. package/assets/docs/TRD.md +78 -0
  22. package/assets/docs/UI-UX.md +71 -0
  23. package/assets/docs/constitution.md +86 -0
  24. package/assets/hooks/audit.mjs +45 -0
  25. package/assets/hooks/session-context.mjs +53 -0
  26. package/assets/integrations/spec-kit/mapping.yaml +92 -0
  27. package/assets/knowledge/best-practices/testing.md +53 -0
  28. package/assets/knowledge/best-practices/web-dev-baseline.md +39 -0
  29. package/assets/knowledge/rules/api.md +45 -0
  30. package/assets/knowledge/rules/sql.md +44 -0
  31. package/assets/knowledge/rules/typescript.md +50 -0
  32. package/assets/knowledge/security-references/owasp-baseline.md +58 -0
  33. package/assets/registry/activation-map.yaml +83 -0
  34. package/assets/registry/dependencies.yaml +35 -0
  35. package/assets/registry/skills.yaml +541 -0
  36. package/assets/registry/sources.yaml +396 -0
  37. package/assets/schemas/architecture/v1.json +110 -0
  38. package/assets/schemas/constraints/v1.json +93 -0
  39. package/assets/schemas/decision/v1.json +106 -0
  40. package/assets/schemas/discovery/v1.json +91 -0
  41. package/assets/schemas/requirement/v1.json +136 -0
  42. package/assets/schemas/security/threat-model/v1.json +127 -0
  43. package/assets/schemas/test-plan/v1.json +108 -0
  44. package/assets/skills/aidf-architecture-review/SKILL.md +49 -0
  45. package/assets/skills/aidf-backend-implementation/SKILL.md +47 -0
  46. package/assets/skills/aidf-database-design/SKILL.md +48 -0
  47. package/assets/skills/aidf-devops-engineering/SKILL.md +41 -0
  48. package/assets/skills/aidf-documentation-maintenance/SKILL.md +41 -0
  49. package/assets/skills/aidf-frontend-implementation/SKILL.md +44 -0
  50. package/assets/skills/aidf-phase-transition/SKILL.md +48 -0
  51. package/assets/skills/aidf-product-analysis/SKILL.md +47 -0
  52. package/assets/skills/aidf-project-context/SKILL.md +57 -0
  53. package/assets/skills/aidf-requirements-engineering/SKILL.md +52 -0
  54. package/assets/skills/aidf-security-review/SKILL.md +57 -0
  55. package/assets/skills/aidf-testing-validation/SKILL.md +48 -0
  56. package/assets/skills/aidf-ui-ux-implementation/SKILL.md +43 -0
  57. package/assets/workflows/gates.yaml +232 -0
  58. package/assets/workflows/phases.yaml +161 -0
  59. package/bin/aidf.mjs +12 -0
  60. package/demo/run-demo.mjs +97 -0
  61. package/docs/aidf/ADR-001-artefacts-architectur.md +126 -0
  62. package/docs/aidf/ADR-002-requirements-registry.md +145 -0
  63. package/docs/aidf/ADR-003-traceability-chain.md +145 -0
  64. package/docs/aidf/ADR-004-markdown-generation.md +134 -0
  65. package/docs/aidf/ADR-005-validation-and-tests.md +170 -0
  66. package/docs/aidf/ADR-006-cli-commands.md +189 -0
  67. package/docs/aidf/ADR-007-compatibility-and-migration.md +119 -0
  68. package/docs/aidf/ADR-008-schema-versioning.md +115 -0
  69. package/docs/aidf/ADR-009-artefacts-scope.md +84 -0
  70. package/docs/aidf/ARCHITECTURE.md +137 -0
  71. package/docs/aidf/COMPATIBILITY.md +90 -0
  72. package/docs/aidf/DECISIONS.md +200 -0
  73. package/docs/aidf/FRAMEWORK.md +38 -0
  74. package/docs/aidf/IDE-QODER.md +61 -0
  75. package/docs/aidf/INSTALL.md +99 -0
  76. package/docs/aidf/INVENTORY.md +72 -0
  77. package/docs/aidf/L1-ARCHITECTURE-RAPPORT.md +353 -0
  78. package/docs/aidf/LIMITATIONS.md +69 -0
  79. package/docs/aidf/MATRICE-0.1.0-vers-0.2.0.md +155 -0
  80. package/docs/aidf/SECURITY.md +86 -0
  81. package/docs/aidf/SKILLS.md +78 -0
  82. package/docs/aidf/SPECKIT.md +67 -0
  83. package/docs/aidf/USAGE.md +113 -0
  84. package/docs/aidf/VALIDATION.md +55 -0
  85. package/package.json +37 -4
  86. package/src/cli.mjs +148 -0
  87. package/src/commands/artefacts.mjs +129 -0
  88. package/src/commands/config.mjs +130 -0
  89. package/src/commands/context.mjs +55 -0
  90. package/src/commands/decision.mjs +142 -0
  91. package/src/commands/design.mjs +141 -0
  92. package/src/commands/docs.mjs +133 -0
  93. package/src/commands/doctor.mjs +210 -0
  94. package/src/commands/evidence.mjs +178 -0
  95. package/src/commands/install.mjs +154 -0
  96. package/src/commands/release.mjs +214 -0
  97. package/src/commands/requirements.mjs +196 -0
  98. package/src/commands/resources.mjs +181 -0
  99. package/src/commands/scan.mjs +139 -0
  100. package/src/commands/security.mjs +97 -0
  101. package/src/commands/setup.mjs +68 -0
  102. package/src/commands/skills.mjs +204 -0
  103. package/src/commands/speckit.mjs +78 -0
  104. package/src/commands/tests.mjs +81 -0
  105. package/src/commands/traceability.mjs +116 -0
  106. package/src/commands/uninstall.mjs +238 -0
  107. package/src/commands/validate.mjs +84 -0
  108. package/src/commands/workflow.mjs +137 -0
  109. package/src/core/adapters/base.mjs +32 -0
  110. package/src/core/adapters/generic.mjs +70 -0
  111. package/src/core/adapters/index.mjs +24 -0
  112. package/src/core/adapters/opencode.mjs +115 -0
  113. package/src/core/adapters/qoder.mjs +228 -0
  114. package/src/core/artefacts/index.mjs +1 -0
  115. package/src/core/artefacts/validation.mjs +161 -0
  116. package/src/core/bootstrap.mjs +179 -0
  117. package/src/core/config.mjs +123 -0
  118. package/src/core/context.mjs +187 -0
  119. package/src/core/design-engineering/complexity-classifier.mjs +78 -0
  120. package/src/core/design-engineering/engine.mjs +197 -0
  121. package/src/core/design-engineering/fallback/mockups.mjs +221 -0
  122. package/src/core/design-engineering/fallback/wireframes.mjs +114 -0
  123. package/src/core/design-engineering/figma/validators.mjs +178 -0
  124. package/src/core/design-engineering/index.mjs +9 -0
  125. package/src/core/design-engineering/visual-parity/capture.mjs +172 -0
  126. package/src/core/detect.mjs +220 -0
  127. package/src/core/docsgen.mjs +175 -0
  128. package/src/core/evidence.mjs +210 -0
  129. package/src/core/installer.mjs +377 -0
  130. package/src/core/manifest.mjs +53 -0
  131. package/src/core/paths.mjs +94 -0
  132. package/src/core/requirements/index.mjs +13 -0
  133. package/src/core/requirements/registry.mjs +234 -0
  134. package/src/core/resource-inventory.mjs +434 -0
  135. package/src/core/resources.mjs +280 -0
  136. package/src/core/security/threat-model.mjs +235 -0
  137. package/src/core/skills.mjs +353 -0
  138. package/src/core/source-skills.mjs +213 -0
  139. package/src/core/speckit.mjs +195 -0
  140. package/src/core/technology-decision/analyzer-deterministic.mjs +240 -0
  141. package/src/core/technology-decision/engine.mjs +157 -0
  142. package/src/core/technology-decision/generator.mjs +204 -0
  143. package/src/core/technology-decision/index.mjs +17 -0
  144. package/src/core/technology-decision/options/index.mjs +10 -0
  145. package/src/core/testplan.mjs +176 -0
  146. package/src/core/traceability/chain.mjs +488 -0
  147. package/src/core/traceability/index.mjs +12 -0
  148. package/src/core/workflow.mjs +471 -0
  149. package/src/util/args.mjs +69 -0
  150. package/src/util/frontmatter.mjs +26 -0
  151. package/src/util/fsx.mjs +208 -0
  152. package/src/util/logger.mjs +74 -0
  153. package/src/util/text.mjs +66 -0
  154. package/src/util/yaml.mjs +379 -0
@@ -0,0 +1,379 @@
1
+ /**
2
+ * Minimal YAML subset parser/dumper used by AIDF.
3
+ *
4
+ * Supported: nested maps, sequences (scalars and maps), inline arrays,
5
+ * quoted strings, booleans, null, numbers, block scalars (| and >).
6
+ * Not supported: anchors, aliases, tags, multi-document streams, flow maps.
7
+ * AIDF registries are written by AIDF itself; this parser is deliberately
8
+ * small and tested rather than a general-purpose YAML implementation.
9
+ */
10
+
11
+ class YamlError extends Error {
12
+ constructor(message, line) {
13
+ super(`${message}${line ? ` (line ${line})` : ''}`);
14
+ this.name = 'YamlError';
15
+ this.line = line;
16
+ }
17
+ }
18
+
19
+ function indentOf(line) {
20
+ const match = /^ */.exec(line);
21
+ return match ? match[0].length : 0;
22
+ }
23
+
24
+ function isBlank(line) {
25
+ return line.trim() === '';
26
+ }
27
+
28
+ function isComment(line) {
29
+ return line.trimStart().startsWith('#');
30
+ }
31
+
32
+ function stripInlineComment(text) {
33
+ let inSingle = false;
34
+ let inDouble = false;
35
+ for (let i = 0; i < text.length; i += 1) {
36
+ const ch = text[i];
37
+ if (ch === "'" && !inDouble) inSingle = !inSingle;
38
+ else if (ch === '"' && !inSingle) inDouble = !inDouble;
39
+ else if (ch === '#' && !inSingle && !inDouble && (i === 0 || /\s/.test(text[i - 1]))) {
40
+ return text.slice(0, i).trimEnd();
41
+ }
42
+ }
43
+ return text.trimEnd();
44
+ }
45
+
46
+ function splitKey(text) {
47
+ let inSingle = false;
48
+ let inDouble = false;
49
+ let depth = 0;
50
+ for (let i = 0; i < text.length; i += 1) {
51
+ const ch = text[i];
52
+ if (ch === "'" && !inDouble) inSingle = !inSingle;
53
+ else if (ch === '"' && !inSingle) inDouble = !inDouble;
54
+ else if (!inSingle && !inDouble) {
55
+ if (ch === '[' || ch === '{') depth += 1;
56
+ else if (ch === ']' || ch === '}') depth -= 1;
57
+ else if (ch === ':' && depth === 0) {
58
+ const next = text[i + 1];
59
+ if (next === undefined || next === ' ' || next === '\t') {
60
+ const rawKey = text.slice(0, i).trim();
61
+ const key = unquote(rawKey);
62
+ const rest = text.slice(i + 1).trim();
63
+ return { key, rest };
64
+ }
65
+ }
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+
71
+ function unquote(value) {
72
+ if (value.length >= 2) {
73
+ if (value.startsWith('"') && value.endsWith('"')) {
74
+ try {
75
+ return JSON.parse(value);
76
+ } catch {
77
+ return value.slice(1, -1);
78
+ }
79
+ }
80
+ if (value.startsWith("'") && value.endsWith("'")) {
81
+ return value.slice(1, -1).replace(/''/g, "'");
82
+ }
83
+ }
84
+ return value;
85
+ }
86
+
87
+ function splitFlow(text) {
88
+ const parts = [];
89
+ let current = '';
90
+ let inSingle = false;
91
+ let inDouble = false;
92
+ let depth = 0;
93
+ for (const ch of text) {
94
+ if (ch === "'" && !inDouble) inSingle = !inSingle;
95
+ else if (ch === '"' && !inSingle) inDouble = !inDouble;
96
+ if (!inSingle && !inDouble) {
97
+ if (ch === '[' || ch === '{') depth += 1;
98
+ if (ch === ']' || ch === '}') depth -= 1;
99
+ if (ch === ',' && depth === 0) {
100
+ parts.push(current.trim());
101
+ current = '';
102
+ continue;
103
+ }
104
+ }
105
+ current += ch;
106
+ }
107
+ if (current.trim() !== '' || parts.length > 0) parts.push(current.trim());
108
+ return parts.filter((p) => p !== '');
109
+ }
110
+
111
+ function parseScalar(raw) {
112
+ let text = stripInlineComment(raw).trim();
113
+ if (text === '') return '';
114
+ if (text === '~' || text.toLowerCase() === 'null') return null;
115
+ if (text.toLowerCase() === 'true') return true;
116
+ if (text.toLowerCase() === 'false') return false;
117
+ if (text.startsWith('[') && text.endsWith(']')) {
118
+ return splitFlow(text.slice(1, -1)).map((item) => parseScalar(item));
119
+ }
120
+ if (text.startsWith('{') && text.endsWith('}')) {
121
+ const inner = text.slice(1, -1).trim();
122
+ if (inner === '') return {};
123
+ const obj = {};
124
+ for (const part of splitFlow(inner)) {
125
+ const kv = splitKey(part);
126
+ if (!kv) throw new YamlError(`Invalid inline map entry: ${part}`);
127
+ obj[kv.key] = parseScalar(kv.rest);
128
+ }
129
+ return obj;
130
+ }
131
+ if (/^-?\d+$/.test(text)) return Number.parseInt(text, 10);
132
+ if (/^-?\d+\.\d+$/.test(text)) return Number.parseFloat(text);
133
+ if (
134
+ (text.startsWith('"') && text.endsWith('"')) ||
135
+ (text.startsWith("'") && text.endsWith("'"))
136
+ ) {
137
+ return unquote(text);
138
+ }
139
+ return text;
140
+ }
141
+
142
+ export function parseYaml(source) {
143
+ const text = String(source ?? '').replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n');
144
+ const lines = text.split('\n');
145
+ let index = 0;
146
+
147
+ function peek() {
148
+ while (index < lines.length) {
149
+ const line = lines[index];
150
+ if (isBlank(line) || isComment(line)) {
151
+ index += 1;
152
+ continue;
153
+ }
154
+ return { line, indent: indentOf(line), text: line.trim() };
155
+ }
156
+ return null;
157
+ }
158
+
159
+ function parseBlockScalar(parentIndent, style) {
160
+ const raw = [];
161
+ while (index < lines.length) {
162
+ const line = lines[index];
163
+ if (isBlank(line)) {
164
+ raw.push('');
165
+ index += 1;
166
+ continue;
167
+ }
168
+ if (indentOf(line) <= parentIndent) break;
169
+ raw.push(line);
170
+ index += 1;
171
+ }
172
+ while (raw.length > 0 && raw[raw.length - 1] === '') raw.pop();
173
+ const nonBlank = raw.filter((l) => l !== '');
174
+ const minIndent = nonBlank.length
175
+ ? Math.min(...nonBlank.map((l) => indentOf(l)))
176
+ : 0;
177
+ const dedented = raw.map((l) => (l === '' ? '' : l.slice(minIndent)));
178
+ let value;
179
+ if (style.startsWith('>')) {
180
+ value = dedented.reduce((acc, line) => {
181
+ if (line === '') return `${acc}\n`;
182
+ return acc === '' ? line : `${acc} ${line}`;
183
+ }, '');
184
+ } else {
185
+ value = dedented.join('\n');
186
+ }
187
+ if (!style.endsWith('-')) value += '\n';
188
+ return value;
189
+ }
190
+
191
+ function parseNode(indent) {
192
+ const token = peek();
193
+ if (!token || token.indent < indent) return null;
194
+ if (token.text.startsWith('- ') || token.text === '-') return parseSequence(token.indent);
195
+ return parseMapping(token.indent);
196
+ }
197
+
198
+ function parseMapping(indent, initial = null) {
199
+ const obj = {};
200
+ let first = initial;
201
+ for (;;) {
202
+ let text;
203
+ if (first) {
204
+ text = first;
205
+ first = null;
206
+ } else {
207
+ const token = peek();
208
+ if (!token || token.indent < indent) break;
209
+ if (token.indent > indent) {
210
+ throw new YamlError(`Unexpected indentation: "${token.text}"`, index + 1);
211
+ }
212
+ if (token.text.startsWith('- ') || token.text === '-') break;
213
+ text = token.text;
214
+ index += 1;
215
+ }
216
+ const kv = splitKey(text);
217
+ if (!kv) {
218
+ throw new YamlError(`Expected "key: value", got "${text}"`, index);
219
+ }
220
+ if (kv.rest === '') {
221
+ const next = peek();
222
+ if (next && next.indent > indent) {
223
+ obj[kv.key] = parseNode(next.indent);
224
+ } else {
225
+ obj[kv.key] = null;
226
+ }
227
+ } else if (/^[|>][-+]?$/.test(kv.rest)) {
228
+ obj[kv.key] = parseBlockScalar(indent, kv.rest);
229
+ } else {
230
+ obj[kv.key] = parseScalar(kv.rest);
231
+ }
232
+ }
233
+ return obj;
234
+ }
235
+
236
+ function parseSequence(indent) {
237
+ const arr = [];
238
+ for (;;) {
239
+ const token = peek();
240
+ if (!token || token.indent < indent) break;
241
+ if (token.indent > indent) {
242
+ throw new YamlError(`Unexpected indentation: "${token.text}"`, index + 1);
243
+ }
244
+ if (!(token.text.startsWith('- ') || token.text === '-')) break;
245
+ const rest = token.text === '-' ? '' : token.text.slice(2).trim();
246
+ index += 1;
247
+ if (rest === '') {
248
+ const next = peek();
249
+ arr.push(next && next.indent > indent ? parseNode(next.indent) : null);
250
+ continue;
251
+ }
252
+ if (/^[|>][-+]?$/.test(rest)) {
253
+ arr.push(parseBlockScalar(indent, rest));
254
+ continue;
255
+ }
256
+ if (splitKey(rest)) {
257
+ const virtualIndent = indent + 2;
258
+ const item = {};
259
+ // Parse the first entry of the inline map, then continue with siblings.
260
+ const kv = splitKey(rest);
261
+ if (kv.rest === '') {
262
+ const next = peek();
263
+ if (next && next.indent > virtualIndent) {
264
+ item[kv.key] = parseNode(next.indent);
265
+ } else if (next && next.indent === virtualIndent && !next.text.startsWith('-')) {
266
+ item[kv.key] = parseMapping(virtualIndent);
267
+ } else {
268
+ item[kv.key] = null;
269
+ }
270
+ } else if (/^[|>][-+]?$/.test(kv.rest)) {
271
+ item[kv.key] = parseBlockScalar(virtualIndent, kv.rest);
272
+ } else {
273
+ item[kv.key] = parseScalar(kv.rest);
274
+ }
275
+ const next = peek();
276
+ if (next && next.indent === virtualIndent && !next.text.startsWith('-')) {
277
+ Object.assign(item, parseMapping(virtualIndent));
278
+ } else if (next && next.indent > virtualIndent) {
279
+ throw new YamlError(`Unexpected indentation in sequence item: "${next.text}"`, index + 1);
280
+ }
281
+ arr.push(item);
282
+ continue;
283
+ }
284
+ arr.push(parseScalar(rest));
285
+ }
286
+ return arr;
287
+ }
288
+
289
+ const token = peek();
290
+ if (!token) return null;
291
+ const result = parseNode(token.indent);
292
+ const trailing = peek();
293
+ if (trailing) {
294
+ throw new YamlError(`Unexpected content: "${trailing.text}"`, index + 1);
295
+ }
296
+ return result;
297
+ }
298
+
299
+ function needsQuotes(value) {
300
+ if (value === '') return true;
301
+ if (/^[\s#\-?:,[\]{}&*!|>'"%@`]/.test(value)) return true;
302
+ if (/\s#|:\s|:$|\n/.test(value)) return true;
303
+ if (/^(true|false|null|~|-?\d+(\.\d+)?)$/i.test(value)) return true;
304
+ return false;
305
+ }
306
+
307
+ function quote(value) {
308
+ return `"${String(value).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
309
+ }
310
+
311
+ function dumpScalar(value) {
312
+ if (value === null || value === undefined) return 'null';
313
+ if (typeof value === 'boolean' || typeof value === 'number') return String(value);
314
+ const text = String(value);
315
+ if (text.includes('\n')) return null;
316
+ return needsQuotes(text) ? quote(text) : text;
317
+ }
318
+
319
+ function dumpValue(value, indent) {
320
+ const pad = ' '.repeat(indent);
321
+ if (Array.isArray(value)) {
322
+ if (value.length === 0) return '[]';
323
+ return value
324
+ .map((item) => {
325
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
326
+ const entries = Object.entries(item);
327
+ if (entries.length === 0) return `${pad}- {}`;
328
+ const [firstKey, firstValue] = entries[0];
329
+ const firstRendered = dumpValue(firstValue, indent + 2);
330
+ const head = firstRendered.startsWith('\n')
331
+ ? `${pad}- ${firstKey}:${firstRendered}`
332
+ : `${pad}- ${firstKey}: ${firstRendered}`;
333
+ const rest = entries.slice(1).map(([k, v]) => dumpEntry(k, v, indent + 2)).join('');
334
+ const rendered = `${head.endsWith('\n') ? head : `${head}\n`}${rest}`;
335
+ return rendered.endsWith('\n') ? rendered.slice(0, -1) : rendered;
336
+ }
337
+ const rendered = dumpValue(item, indent + 2);
338
+ if (Array.isArray(item)) return `${pad}-\n${rendered}`;
339
+ if (rendered.startsWith('\n')) return `${pad}-${rendered}`.replace(/\n$/, '');
340
+ return `${pad}- ${rendered}`;
341
+ })
342
+ .join('\n');
343
+ }
344
+ if (value !== null && typeof value === 'object') {
345
+ const entries = Object.entries(value);
346
+ if (entries.length === 0) return '{}';
347
+ return entries.map(([k, v]) => dumpEntry(k, v, indent)).join('');
348
+ }
349
+ return dumpScalar(value);
350
+ }
351
+
352
+ function dumpEntry(key, value, indent) {
353
+ const pad = ' '.repeat(indent);
354
+ const safeKey = /^[A-Za-z0-9_.-]+$/.test(key) ? key : quote(key);
355
+ if (Array.isArray(value)) {
356
+ if (value.length === 0) return `${pad}${safeKey}: []\n`;
357
+ const rendered = dumpValue(value, indent + 2);
358
+ return `${pad}${safeKey}:\n${rendered.endsWith('\n') ? rendered : `${rendered}\n`}`;
359
+ }
360
+ if (value !== null && typeof value === 'object') {
361
+ if (Object.keys(value).length === 0) return `${pad}${safeKey}: {}\n`;
362
+ const rendered = dumpValue(value, indent + 2);
363
+ return `${pad}${safeKey}:\n${rendered.endsWith('\n') ? rendered : `${rendered}\n`}`;
364
+ }
365
+ if (typeof value === 'string' && value.includes('\n')) {
366
+ const keepTrailingNewline = value.endsWith('\n');
367
+ const lines = value.replace(/\n$/, '').split('\n');
368
+ const body = lines.map((l) => `${pad} ${l}`).join('\n');
369
+ return `${pad}${safeKey}: ${keepTrailingNewline ? '|' : '|-'}\n${body}\n`;
370
+ }
371
+ return `${pad}${safeKey}: ${dumpScalar(value)}\n`;
372
+ }
373
+
374
+ export function dumpYaml(value) {
375
+ const rendered = dumpValue(value, 0);
376
+ return rendered.endsWith('\n') ? rendered : `${rendered}\n`;
377
+ }
378
+
379
+ export { YamlError };