@oevery/rsp 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -17
- package/README.zh-CN.md +25 -18
- package/dist/{chunk-TSUDEX5Y.mjs → chunk-HFSTLCCK.mjs} +1261 -319
- package/dist/cli.mjs +1129 -2350
- package/dist/{entry-GIDNR7CJ.mjs → entry-RIJQ2X46.mjs} +122 -36
- package/package.json +32 -24
- package/skills/rsp/SKILL.md +43 -38
- package/skills/rsp/references/closeout.md +38 -0
- package/skills/rsp/references/context-migration.md +22 -0
- package/skills/rsp/references/control-outcome.md +3 -29
- package/skills/rsp/references/coordination-recovery.md +25 -0
- package/skills/rsp/references/coordination-review.md +15 -0
- package/skills/rsp/references/coordination.md +59 -0
- package/skills/rsp/references/durable-review.md +60 -12
- package/skills/rsp/references/focus-continuation.md +8 -4
- package/skills/rsp/references/groups-dependencies.md +6 -4
- package/skills/rsp/references/response-language.md +2 -0
- package/skills/rsp/references/setup-repair.md +37 -7
- package/skills/rsp/references/work-model.md +27 -0
- package/skills/rsp-commit/SKILL.md +76 -31
- package/skills/rsp-commit/references/message.md +34 -0
- package/skills/rsp-doc/SKILL.md +65 -0
- package/skills/rsp-doc/agents/openai.yaml +3 -0
- package/skills/rsp-doc/references/artifact-lenses.md +43 -0
- package/skills/rsp-doc/references/release-communication.md +39 -0
- package/skills/rsp-doc/references/skill-authoring.md +36 -0
- package/skills/rsp-implement/SKILL.md +56 -25
- package/skills/rsp-implement/references/diagnosis.md +10 -0
- package/skills/rsp-implement/references/finding-resolution.md +21 -0
- package/skills/rsp-implement/references/test-first.md +7 -0
- package/skills/rsp-review/SKILL.md +46 -45
- package/skills/rsp-review/references/code-review.md +23 -8
- package/skills/rsp-review/references/document-review.md +25 -8
- package/skills/rsp-review/references/release-communication.md +21 -0
- package/skills/{rsp-structural-audit/references/structural-lenses.md → rsp-review/references/structural-review.md} +5 -5
- package/skills/rsp-shape/SKILL.md +24 -45
- package/skills/rsp-shape/references/complex-shaping.md +3 -1
- package/skills/rsp-shape/references/deep-clarification.md +4 -4
- package/skills/rsp-shape/references/domain-modeling.md +13 -0
- package/skills/rsp-shape/references/module-seams.md +13 -0
- package/skills/rsp-shape/references/planning.md +42 -0
- package/skills/{rsp-design → rsp-shape}/references/reversible-exploration.md +2 -2
- package/skills/rsp-verify/SKILL.md +44 -12
- package/dist/chunk-7HXQNBIG.mjs +0 -871
- package/dist/chunk-JOMFFQRG.mjs +0 -99
- package/dist/chunk-QM2UVPQK.mjs +0 -375
- package/dist/entry-YAW3PYFA.mjs +0 -174
- package/rules/rsp-rules.md +0 -48
- package/skills/rsp/references/implementation-evidence.md +0 -12
- package/skills/rsp/references/managed-routing.md +0 -45
- package/skills/rsp-design/SKILL.md +0 -53
- package/skills/rsp-design/references/domain-modeling.md +0 -11
- package/skills/rsp-design/references/module-seams.md +0 -11
- package/skills/rsp-diagnose/SKILL.md +0 -48
- package/skills/rsp-manage/SKILL.md +0 -101
- package/skills/rsp-manage/references/closeout.md +0 -13
- package/skills/rsp-manage/references/delegation.md +0 -47
- package/skills/rsp-manage/references/interruption-recovery.md +0 -19
- package/skills/rsp-manage/references/review-convergence.md +0 -9
- package/skills/rsp-release-docs/SKILL.md +0 -77
- package/skills/rsp-release-docs/references/convention-discovery.md +0 -65
- package/skills/rsp-release-docs/references/evidence-and-surfaces.md +0 -21
- package/skills/rsp-release-docs/references/output-contracts.md +0 -97
- package/skills/rsp-release-docs/references/publication-lifecycle.md +0 -28
- package/skills/rsp-resolve-findings/SKILL.md +0 -61
- package/skills/rsp-structural-audit/SKILL.md +0 -71
- package/skills/rsp-tdd/SKILL.md +0 -56
package/dist/chunk-7HXQNBIG.mjs
DELETED
|
@@ -1,871 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/core/config.ts
|
|
4
|
-
import { readFile } from "fs/promises";
|
|
5
|
-
import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import pc from "picocolors";
|
|
8
|
-
import { parseDocument, stringify, visit } from "yaml";
|
|
9
|
-
|
|
10
|
-
// src/core/content.ts
|
|
11
|
-
import { parse } from "yaml";
|
|
12
|
-
|
|
13
|
-
// src/core/document-model.ts
|
|
14
|
-
var CHANGE_DOCUMENT_SCHEMA = {
|
|
15
|
-
titlePrefix: "# Change:",
|
|
16
|
-
sections: [
|
|
17
|
-
{ id: "proposal", heading: "Proposal" },
|
|
18
|
-
{ id: "spec", heading: "Spec" },
|
|
19
|
-
{ id: "design", heading: "Design" },
|
|
20
|
-
{ id: "tasks", heading: "Tasks" },
|
|
21
|
-
{ id: "verify", heading: "Verify" },
|
|
22
|
-
{ id: "blockers", heading: "Blockers" }
|
|
23
|
-
]
|
|
24
|
-
};
|
|
25
|
-
var GROUP_BRIEF_DOCUMENT_SCHEMA = {
|
|
26
|
-
titlePrefix: "# Change Group:",
|
|
27
|
-
sections: [
|
|
28
|
-
{ id: "goal", heading: "Goal" },
|
|
29
|
-
{ id: "scope", heading: "Scope" },
|
|
30
|
-
{ id: "sharedConstraints", heading: "Shared Constraints" },
|
|
31
|
-
{ id: "slices", heading: "Slices" },
|
|
32
|
-
{ id: "completionConditions", heading: "Completion Conditions" },
|
|
33
|
-
{ id: "durableOutcomes", heading: "Durable Outcomes" },
|
|
34
|
-
{ id: "blockers", heading: "Blockers" }
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
var DocumentSectionCardinalityError = class extends Error {
|
|
38
|
-
constructor(sectionId, count) {
|
|
39
|
-
super(`document must contain exactly one ${sectionId} section; found ${count}`);
|
|
40
|
-
this.sectionId = sectionId;
|
|
41
|
-
this.count = count;
|
|
42
|
-
this.name = "DocumentSectionCardinalityError";
|
|
43
|
-
}
|
|
44
|
-
sectionId;
|
|
45
|
-
count;
|
|
46
|
-
};
|
|
47
|
-
function parseRspDocument(source, schema) {
|
|
48
|
-
const definitionsByHeading = new Map(schema.sections.map((definition) => [definition.heading, definition]));
|
|
49
|
-
const observedHeadings = collectLevelTwoHeadings(source);
|
|
50
|
-
const sections = /* @__PURE__ */ new Map();
|
|
51
|
-
const unknownHeadings = [];
|
|
52
|
-
for (let index = 0; index < observedHeadings.length; index++) {
|
|
53
|
-
const observed = observedHeadings[index];
|
|
54
|
-
const definition = definitionsByHeading.get(observed.heading);
|
|
55
|
-
if (!definition) {
|
|
56
|
-
unknownHeadings.push(observed.heading);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const nextHeading = observedHeadings[index + 1];
|
|
60
|
-
const bodyEnd = nextHeading ? lineBreakStart(source, nextHeading.start) : source.length;
|
|
61
|
-
const section = {
|
|
62
|
-
id: definition.id,
|
|
63
|
-
heading: definition.heading,
|
|
64
|
-
canonical: observed.canonical,
|
|
65
|
-
body: source.slice(observed.end, bodyEnd).trim(),
|
|
66
|
-
headingStart: observed.start,
|
|
67
|
-
headingEnd: observed.end,
|
|
68
|
-
bodyStart: observed.end,
|
|
69
|
-
bodyEnd
|
|
70
|
-
};
|
|
71
|
-
const matches = sections.get(definition.id) ?? [];
|
|
72
|
-
matches.push(section);
|
|
73
|
-
sections.set(definition.id, matches);
|
|
74
|
-
}
|
|
75
|
-
const missingSections = schema.sections.filter((definition) => !sections.has(definition.id)).map((definition) => definition.id);
|
|
76
|
-
const duplicateSections = schema.sections.filter((definition) => (sections.get(definition.id)?.length ?? 0) > 1).map((definition) => definition.id);
|
|
77
|
-
const titleOccurrences = collectDocumentTitles(source, schema.titlePrefix);
|
|
78
|
-
const titles = titleOccurrences.map((title) => title.value);
|
|
79
|
-
return {
|
|
80
|
-
source,
|
|
81
|
-
schema,
|
|
82
|
-
title: titles[0] ?? null,
|
|
83
|
-
titles,
|
|
84
|
-
titleOccurrences,
|
|
85
|
-
sections,
|
|
86
|
-
unknownHeadings,
|
|
87
|
-
missingSections,
|
|
88
|
-
duplicateSections
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function getDocumentTitles(document, compatibility = "broad") {
|
|
92
|
-
if (compatibility === "broad")
|
|
93
|
-
return document.titles;
|
|
94
|
-
return document.titleOccurrences.filter((title) => compatibility === "identity" ? title.identityCompatible : title.spaced).map((title) => title.value);
|
|
95
|
-
}
|
|
96
|
-
function getDocumentTitle(document, compatibility = "broad") {
|
|
97
|
-
return getDocumentTitles(document, compatibility)[0] ?? null;
|
|
98
|
-
}
|
|
99
|
-
function getDocumentSections(document, sectionId) {
|
|
100
|
-
return document.sections.get(sectionId) ?? [];
|
|
101
|
-
}
|
|
102
|
-
function getDocumentSection(document, sectionId) {
|
|
103
|
-
return getDocumentSections(document, sectionId)[0];
|
|
104
|
-
}
|
|
105
|
-
function getDocumentSectionBody(document, sectionId) {
|
|
106
|
-
return getDocumentSection(document, sectionId)?.body ?? "";
|
|
107
|
-
}
|
|
108
|
-
function getDocumentSectionDefinitionByHeading(schema, heading) {
|
|
109
|
-
return schema.sections.find((candidate) => candidate.heading === heading);
|
|
110
|
-
}
|
|
111
|
-
function getCanonicalSectionHeadings(schema) {
|
|
112
|
-
return schema.sections.map((section) => section.heading);
|
|
113
|
-
}
|
|
114
|
-
function renderDocumentSectionHeading(schema, sectionId) {
|
|
115
|
-
const definition = schema.sections.find((candidate) => candidate.id === sectionId);
|
|
116
|
-
if (!definition)
|
|
117
|
-
throw new Error(`unknown document section: ${sectionId}`);
|
|
118
|
-
return `## ${definition.heading}`;
|
|
119
|
-
}
|
|
120
|
-
function renderDocumentTitle(schema, title) {
|
|
121
|
-
return `${schema.titlePrefix} ${title}`;
|
|
122
|
-
}
|
|
123
|
-
function appendDocumentSectionItem(document, sectionId, item) {
|
|
124
|
-
const matches = getDocumentSections(document, sectionId);
|
|
125
|
-
if (matches.length !== 1)
|
|
126
|
-
throw new DocumentSectionCardinalityError(sectionId, matches.length);
|
|
127
|
-
const insertAt = matches[0].bodyEnd;
|
|
128
|
-
const before = document.source.slice(0, insertAt);
|
|
129
|
-
const separator = before.endsWith("\n\n") ? "" : before.endsWith("\n") ? "\n" : "\n\n";
|
|
130
|
-
return `${before}${separator}${item}
|
|
131
|
-
${document.source.slice(insertAt)}`;
|
|
132
|
-
}
|
|
133
|
-
function collectLevelTwoHeadings(source) {
|
|
134
|
-
const headings = [];
|
|
135
|
-
const pattern = /^## ([^\r\n]+)\r?$/gm;
|
|
136
|
-
let match;
|
|
137
|
-
while ((match = pattern.exec(source)) !== null) {
|
|
138
|
-
const heading = match[1].trimEnd();
|
|
139
|
-
headings.push({
|
|
140
|
-
heading,
|
|
141
|
-
canonical: heading === match[1],
|
|
142
|
-
start: match.index,
|
|
143
|
-
end: match.index + match[0].length
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return headings;
|
|
147
|
-
}
|
|
148
|
-
function collectDocumentTitles(source, prefix) {
|
|
149
|
-
const titles = [];
|
|
150
|
-
for (const line of source.split(/\r?\n/)) {
|
|
151
|
-
const trimmed = line.trim();
|
|
152
|
-
if (!trimmed.startsWith(prefix))
|
|
153
|
-
continue;
|
|
154
|
-
const identity = line.startsWith(prefix) ? line.slice(prefix.length).match(/^\s+(\S+)\s*$/) : null;
|
|
155
|
-
titles.push({
|
|
156
|
-
value: trimmed.slice(prefix.length).trim(),
|
|
157
|
-
identityCompatible: identity !== null,
|
|
158
|
-
spaced: line.startsWith(`${prefix} `)
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return titles;
|
|
162
|
-
}
|
|
163
|
-
function lineBreakStart(source, headingStart) {
|
|
164
|
-
if (headingStart > 0 && source[headingStart - 1] === "\n")
|
|
165
|
-
return headingStart - 1;
|
|
166
|
-
return headingStart;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// src/core/content.ts
|
|
170
|
-
function parseYamlText(text) {
|
|
171
|
-
const parsed = parse(text);
|
|
172
|
-
if (parsed === null || parsed === void 0)
|
|
173
|
-
return {};
|
|
174
|
-
if (typeof parsed !== "object" || Array.isArray(parsed))
|
|
175
|
-
throw new Error("YAML document must be a mapping/object");
|
|
176
|
-
return parsed;
|
|
177
|
-
}
|
|
178
|
-
function parseFrontmatter(content) {
|
|
179
|
-
const m = content.match(/^---\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)\r?\n/);
|
|
180
|
-
if (!m)
|
|
181
|
-
return null;
|
|
182
|
-
return parseYamlText(m[1]);
|
|
183
|
-
}
|
|
184
|
-
function countCheckboxes(content) {
|
|
185
|
-
const todo = (content.match(/\[ \]/g) || []).length;
|
|
186
|
-
const progress = (content.match(/\[\/\]/g) || []).length;
|
|
187
|
-
const done = (content.match(/\[x\]/g) || []).length;
|
|
188
|
-
const dropped = (content.match(/\[-\]/g) || []).length;
|
|
189
|
-
return { todo, progress, done, dropped, total: todo + progress + done + dropped };
|
|
190
|
-
}
|
|
191
|
-
function classifyVerifyCheckboxes(sectionText) {
|
|
192
|
-
const buckets = collectVerifyCheckboxLines(sectionText);
|
|
193
|
-
return {
|
|
194
|
-
required: countCheckboxes([...buckets.required, ...buckets.unclassified].join("\n")),
|
|
195
|
-
optional: countCheckboxes(buckets.optional.join("\n")),
|
|
196
|
-
unclassified: countCheckboxes(buckets.unclassified.join("\n")),
|
|
197
|
-
legacy: buckets.legacy
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function collectVerifyCheckboxLines(sectionText) {
|
|
201
|
-
const required = [];
|
|
202
|
-
const optional = [];
|
|
203
|
-
const unclassified = [];
|
|
204
|
-
let current = "unclassified";
|
|
205
|
-
let sawClassificationHeading = false;
|
|
206
|
-
for (const line of sectionText.split("\n")) {
|
|
207
|
-
const heading = line.match(/^###\s+(Required|Optional)\s*$/i);
|
|
208
|
-
if (heading) {
|
|
209
|
-
current = heading[1].toLowerCase();
|
|
210
|
-
sawClassificationHeading = true;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (!/^- \[[ /x-]\]/i.test(line.trim()))
|
|
214
|
-
continue;
|
|
215
|
-
if (current === "required")
|
|
216
|
-
required.push(line);
|
|
217
|
-
else if (current === "optional")
|
|
218
|
-
optional.push(line);
|
|
219
|
-
else
|
|
220
|
-
unclassified.push(line);
|
|
221
|
-
}
|
|
222
|
-
return { required, optional, unclassified, legacy: unclassified.length > 0 || !sawClassificationHeading };
|
|
223
|
-
}
|
|
224
|
-
function getOpenCheckboxes(sectionText) {
|
|
225
|
-
return sectionText.split("\n").map((line) => line.trim()).filter((line) => /^- \[[ /]\]/.test(line));
|
|
226
|
-
}
|
|
227
|
-
function extractBlockerLines(content) {
|
|
228
|
-
const document = parseRspDocument(content, CHANGE_DOCUMENT_SCHEMA);
|
|
229
|
-
return normalizeBlockerBody(getDocumentSectionBody(document, "blockers"));
|
|
230
|
-
}
|
|
231
|
-
function hasMeaningfulBlockerBody(body) {
|
|
232
|
-
return hasMeaningfulBlockerLines(normalizeBlockerBody(body));
|
|
233
|
-
}
|
|
234
|
-
function normalizeBlockerBody(body) {
|
|
235
|
-
return body.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
236
|
-
}
|
|
237
|
-
function hasMeaningfulBlockers(content) {
|
|
238
|
-
return hasMeaningfulBlockerLines(extractBlockerLines(content));
|
|
239
|
-
}
|
|
240
|
-
function isEmptyBlockerLine(line) {
|
|
241
|
-
const normalized = line.trim();
|
|
242
|
-
return /^none[.。]?$/i.test(normalized) || /^[-*]\s*(?:none[.。]?)?$/i.test(normalized);
|
|
243
|
-
}
|
|
244
|
-
function hasMeaningfulBlockerLines(lines) {
|
|
245
|
-
if (lines.length === 0)
|
|
246
|
-
return false;
|
|
247
|
-
return lines.some((line) => !isEmptyBlockerLine(line));
|
|
248
|
-
}
|
|
249
|
-
function detectDeltaSections(content) {
|
|
250
|
-
const document = parseRspDocument(content, CHANGE_DOCUMENT_SCHEMA);
|
|
251
|
-
const body = getDocumentSectionBody(document, "spec");
|
|
252
|
-
return {
|
|
253
|
-
added: /^###\s*ADDED/im.test(body),
|
|
254
|
-
modified: /^###\s*MODIFIED/im.test(body),
|
|
255
|
-
removed: /^###\s*REMOVED/im.test(body)
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function parseScenarios(content) {
|
|
259
|
-
const scenarios = [];
|
|
260
|
-
const regex = /^#{3,4}\s*Scenario:\s*(.+)$/gim;
|
|
261
|
-
let match;
|
|
262
|
-
while ((match = regex.exec(content)) !== null) {
|
|
263
|
-
const heading = match[1].trim();
|
|
264
|
-
const startPos = match.index + match[0].length;
|
|
265
|
-
const restContent = content.slice(startPos);
|
|
266
|
-
const nextSection = restContent.match(/^#{3,4}\s/m);
|
|
267
|
-
const block = nextSection ? restContent.slice(0, nextSection.index) : restContent;
|
|
268
|
-
const steps = block.split("\n").map((s) => s.trim()).filter((s) => s.startsWith("-") && /GIVEN|WHEN|THEN|AND|BUT/i.test(s)).map((s) => s.replace(/^[-*]\s*/, ""));
|
|
269
|
-
if (steps.length > 0)
|
|
270
|
-
scenarios.push({ heading, steps });
|
|
271
|
-
}
|
|
272
|
-
return scenarios;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/core/decisions.ts
|
|
276
|
-
import { existsSync } from "fs";
|
|
277
|
-
import { mkdir, readdir as readdir2, realpath, stat } from "fs/promises";
|
|
278
|
-
import { dirname, isAbsolute, join as join2, posix, relative, resolve, sep } from "path";
|
|
279
|
-
|
|
280
|
-
// src/core/managed-path.ts
|
|
281
|
-
import { lstatSync } from "fs";
|
|
282
|
-
import { readdir, writeFile } from "fs/promises";
|
|
283
|
-
import { join } from "path";
|
|
284
|
-
var ManagedPathError = class extends Error {
|
|
285
|
-
constructor(path, message) {
|
|
286
|
-
super(message);
|
|
287
|
-
this.path = path;
|
|
288
|
-
this.name = "ManagedPathError";
|
|
289
|
-
}
|
|
290
|
-
path;
|
|
291
|
-
};
|
|
292
|
-
function inspectManagedDirectory(path, label, options = {}) {
|
|
293
|
-
try {
|
|
294
|
-
const stats = lstatSync(path);
|
|
295
|
-
if (stats.isDirectory())
|
|
296
|
-
return { exists: true, issue: null };
|
|
297
|
-
return {
|
|
298
|
-
exists: true,
|
|
299
|
-
issue: new ManagedPathError(path, `${label} must be a real directory: ${path}`)
|
|
300
|
-
};
|
|
301
|
-
} catch (error) {
|
|
302
|
-
if (error.code === "ENOENT") {
|
|
303
|
-
if (options.allowMissing)
|
|
304
|
-
return { exists: false, issue: null };
|
|
305
|
-
return {
|
|
306
|
-
exists: false,
|
|
307
|
-
issue: new ManagedPathError(path, `${label} must be a real directory: ${path}`)
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
311
|
-
return {
|
|
312
|
-
exists: false,
|
|
313
|
-
issue: new ManagedPathError(path, `unable to inspect ${label} ${path}: ${message}`)
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
function requireManagedDirectory(path, label, options = {}) {
|
|
318
|
-
const inspection = inspectManagedDirectory(path, label, options);
|
|
319
|
-
if (inspection.issue)
|
|
320
|
-
throw inspection.issue;
|
|
321
|
-
return inspection.exists;
|
|
322
|
-
}
|
|
323
|
-
function inspectManagedFile(path, label, options = {}) {
|
|
324
|
-
try {
|
|
325
|
-
const stats = lstatSync(path);
|
|
326
|
-
if (stats.isFile())
|
|
327
|
-
return { exists: true, issue: null };
|
|
328
|
-
return {
|
|
329
|
-
exists: true,
|
|
330
|
-
issue: new ManagedPathError(path, `${label} must be a regular file: ${path}`)
|
|
331
|
-
};
|
|
332
|
-
} catch (error) {
|
|
333
|
-
if (error.code === "ENOENT") {
|
|
334
|
-
if (options.allowMissing)
|
|
335
|
-
return { exists: false, issue: null };
|
|
336
|
-
return {
|
|
337
|
-
exists: false,
|
|
338
|
-
issue: new ManagedPathError(path, `${label} must be a regular file: ${path}`)
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
342
|
-
return {
|
|
343
|
-
exists: false,
|
|
344
|
-
issue: new ManagedPathError(path, `unable to inspect ${label} ${path}: ${message}`)
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
function requireManagedFile(path, label, options = {}) {
|
|
349
|
-
const inspection = inspectManagedFile(path, label, options);
|
|
350
|
-
if (inspection.issue)
|
|
351
|
-
throw inspection.issue;
|
|
352
|
-
return inspection.exists;
|
|
353
|
-
}
|
|
354
|
-
async function ensureManagedFile(path, content, label) {
|
|
355
|
-
if (requireManagedFile(path, label, { allowMissing: true }))
|
|
356
|
-
return false;
|
|
357
|
-
await writeFile(path, content, { flag: "wx" });
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
async function writeManagedFile(path, content, label) {
|
|
361
|
-
const exists = requireManagedFile(path, label, { allowMissing: true });
|
|
362
|
-
if (exists)
|
|
363
|
-
await writeFile(path, content);
|
|
364
|
-
else
|
|
365
|
-
await writeFile(path, content, { flag: "wx" });
|
|
366
|
-
}
|
|
367
|
-
function resolveManagedDirectoryChain(root, segments, label) {
|
|
368
|
-
requireManagedDirectory(root, `${label} root`);
|
|
369
|
-
let current = root;
|
|
370
|
-
for (const segment of segments) {
|
|
371
|
-
if (!segment || segment === "." || segment === ".." || segment.includes("/") || segment.includes("\\"))
|
|
372
|
-
throw new ManagedPathError(current, `${label} contains an invalid directory segment: ${segment}`);
|
|
373
|
-
current = join(current, segment);
|
|
374
|
-
requireManagedDirectory(current, label, { allowMissing: true });
|
|
375
|
-
}
|
|
376
|
-
return current;
|
|
377
|
-
}
|
|
378
|
-
async function inspectManagedFileTree(root, label, options = {}) {
|
|
379
|
-
const result = { rootExists: false, files: [], issues: [] };
|
|
380
|
-
const rootInspection = inspectManagedDirectory(root, `${label} root`, options);
|
|
381
|
-
if (rootInspection.issue) {
|
|
382
|
-
result.issues.push(rootInspection.issue);
|
|
383
|
-
return result;
|
|
384
|
-
}
|
|
385
|
-
if (!rootInspection.exists)
|
|
386
|
-
return result;
|
|
387
|
-
result.rootExists = true;
|
|
388
|
-
await collectManagedFiles(root, label, result);
|
|
389
|
-
result.files.sort();
|
|
390
|
-
return result;
|
|
391
|
-
}
|
|
392
|
-
async function collectManagedFiles(directory, label, result) {
|
|
393
|
-
let entries;
|
|
394
|
-
try {
|
|
395
|
-
entries = await readdir(directory, { withFileTypes: true });
|
|
396
|
-
} catch (error) {
|
|
397
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
398
|
-
result.issues.push(new ManagedPathError(directory, `unable to inspect the ${label} tree at ${directory}: ${message}`));
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
402
|
-
if (entry.name.startsWith("."))
|
|
403
|
-
continue;
|
|
404
|
-
const path = join(directory, entry.name);
|
|
405
|
-
if (entry.isDirectory()) {
|
|
406
|
-
await collectManagedFiles(path, label, result);
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
if (entry.isFile()) {
|
|
410
|
-
result.files.push(path);
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
result.issues.push(new ManagedPathError(path, `unsupported entry in the ${label} tree: ${path}`));
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// src/core/decisions.ts
|
|
418
|
-
var DEFAULT_DECISION_RECORDS_PATH = ".rsp/specs/decisions";
|
|
419
|
-
function normalizeDecisionRecordsPath(pathValue) {
|
|
420
|
-
return posix.normalize(pathValue.trim().replace(/\\/g, "/")).replace(/^\.\//, "").replace(/\/$/, "");
|
|
421
|
-
}
|
|
422
|
-
function validateDecisionRecordsPath(pathValue) {
|
|
423
|
-
if (typeof pathValue !== "string" || pathValue.trim() === "")
|
|
424
|
-
return 'config.yaml field "decisions.path" must be a non-empty string';
|
|
425
|
-
const raw = pathValue.trim();
|
|
426
|
-
const portable = raw.replace(/\\/g, "/");
|
|
427
|
-
if (isAbsolute(raw) || posix.isAbsolute(portable) || /^[a-z]:[\\/]/i.test(raw))
|
|
428
|
-
return 'config.yaml field "decisions.path" must be project-relative';
|
|
429
|
-
const normalized = normalizeDecisionRecordsPath(raw);
|
|
430
|
-
if (normalized === "." || normalized === ".." || normalized.startsWith("../"))
|
|
431
|
-
return 'config.yaml field "decisions.path" must stay inside the Host Project';
|
|
432
|
-
if ((normalized === ".rsp" || normalized.startsWith(".rsp/")) && normalized !== DEFAULT_DECISION_RECORDS_PATH)
|
|
433
|
-
return `config.yaml field "decisions.path" must use ${DEFAULT_DECISION_RECORDS_PATH} or a path outside .rsp/`;
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
function getDecisionRecordsConfigIssue(config) {
|
|
437
|
-
if (!("decisions" in config))
|
|
438
|
-
return null;
|
|
439
|
-
const decisions = config.decisions;
|
|
440
|
-
if (!decisions || typeof decisions !== "object" || Array.isArray(decisions))
|
|
441
|
-
return 'config.yaml field "decisions" must be a mapping with one path';
|
|
442
|
-
const keys = Object.keys(decisions);
|
|
443
|
-
if (keys.length !== 1 || keys[0] !== "path")
|
|
444
|
-
return 'config.yaml field "decisions" supports only "path"';
|
|
445
|
-
return validateDecisionRecordsPath(decisions.path);
|
|
446
|
-
}
|
|
447
|
-
function resolveDecisionRecordsPath(config) {
|
|
448
|
-
const configured = config.decisions?.path;
|
|
449
|
-
return configured && validateDecisionRecordsPath(configured) === null ? normalizeDecisionRecordsPath(configured) : DEFAULT_DECISION_RECORDS_PATH;
|
|
450
|
-
}
|
|
451
|
-
async function ensureDecisionRecordsDirectory(pathValue) {
|
|
452
|
-
const filesystemError = await validateDecisionRecordsFilesystemPath(pathValue);
|
|
453
|
-
if (filesystemError)
|
|
454
|
-
throw new Error(filesystemError);
|
|
455
|
-
const existed = existsSync(pathValue);
|
|
456
|
-
await mkdir(pathValue, { recursive: true });
|
|
457
|
-
const entries = await readdir2(pathValue);
|
|
458
|
-
if (entries.length === 0) {
|
|
459
|
-
await ensureManagedFile(join2(pathValue, ".gitkeep"), "", "Decision Record placeholder");
|
|
460
|
-
return true;
|
|
461
|
-
}
|
|
462
|
-
if (entries.includes(".gitkeep"))
|
|
463
|
-
requireManagedFile(join2(pathValue, ".gitkeep"), "Decision Record placeholder");
|
|
464
|
-
return !existed;
|
|
465
|
-
}
|
|
466
|
-
async function validateDecisionRecordsFilesystemPath(pathValue, cwd = process.cwd()) {
|
|
467
|
-
const projectRoot = await realpath(cwd);
|
|
468
|
-
const targetPath = resolve(projectRoot, pathValue);
|
|
469
|
-
let existingAncestor = targetPath;
|
|
470
|
-
while (!existsSync(existingAncestor)) {
|
|
471
|
-
const parent = dirname(existingAncestor);
|
|
472
|
-
if (parent === existingAncestor)
|
|
473
|
-
return `Decision Record path "${pathValue}" has no accessible Host Project ancestor`;
|
|
474
|
-
existingAncestor = parent;
|
|
475
|
-
}
|
|
476
|
-
const resolvedAncestor = await realpath(existingAncestor);
|
|
477
|
-
const rel = relative(projectRoot, resolvedAncestor);
|
|
478
|
-
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel))
|
|
479
|
-
return `Decision Record path "${pathValue}" resolves outside the Host Project through ${existingAncestor}`;
|
|
480
|
-
if (existsSync(targetPath) && !(await stat(targetPath)).isDirectory())
|
|
481
|
-
return `Decision Record path "${pathValue}" must be a directory`;
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// src/core/config.ts
|
|
486
|
-
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
487
|
-
var PKG_ROOT = join3(__dirname, "..");
|
|
488
|
-
var RSP_DIR = ".rsp";
|
|
489
|
-
var RSP_RULES_PATH = join3(RSP_DIR, "rsp-rules.md");
|
|
490
|
-
var OBSOLETE_RSP_RULES_PATH = join3(RSP_DIR, "rules", "rsp-rules.md");
|
|
491
|
-
var CHANGES_DIR = join3(RSP_DIR, "changes");
|
|
492
|
-
var FOCUS_DIR = join3(RSP_DIR, "focus.d");
|
|
493
|
-
var MAX_FOCUS_CAPSULE_BYTES = 4096;
|
|
494
|
-
var ARCHIVES_DIR = join3(RSP_DIR, "archives");
|
|
495
|
-
var LOCK_PATH = join3(RSP_DIR, ".lock");
|
|
496
|
-
var CONFIG_PATH = join3(RSP_DIR, "config.yaml");
|
|
497
|
-
var VALID_KINDS = ["feature", "fix", "refactor", "docs", "ops", "research"];
|
|
498
|
-
var DEFAULT_REQUIRED_SECTIONS = getCanonicalSectionHeadings(CHANGE_DOCUMENT_SCHEMA);
|
|
499
|
-
var LEGACY_MISSING_CONFIG_MANAGE_POLICY = { activation: "explicit", closeout: "local" };
|
|
500
|
-
var INVALID_CONFIG_MANAGE_POLICY = { activation: "explicit", closeout: "manual" };
|
|
501
|
-
var CONFIG_DEFAULTS = {
|
|
502
|
-
kinds: [],
|
|
503
|
-
decisions: { path: ".rsp/specs/decisions" },
|
|
504
|
-
language: { default: "en" },
|
|
505
|
-
manage: { activation: "auto", closeout: "local" }
|
|
506
|
-
};
|
|
507
|
-
function generateConfigTemplate(config = {}) {
|
|
508
|
-
const kinds = config.kinds ?? CONFIG_DEFAULTS.kinds;
|
|
509
|
-
const decisions = { ...CONFIG_DEFAULTS.decisions, ...config.decisions };
|
|
510
|
-
const manage = { ...CONFIG_DEFAULTS.manage, ...config.manage };
|
|
511
|
-
const language = { ...CONFIG_DEFAULTS.language, ...config.language };
|
|
512
|
-
const kindsYaml = stringify(kinds).trimEnd();
|
|
513
|
-
const renderedKinds = kinds.length === 0 ? `kinds: ${kindsYaml}` : `kinds:
|
|
514
|
-
${kindsYaml.split("\n").map((line) => ` ${line}`).join("\n")}`;
|
|
515
|
-
const artifactsLine = language.artifacts ? ` artifacts: ${stringify(language.artifacts).trim()}` : " # artifacts: zh-CN";
|
|
516
|
-
const commitLine = language.commit ? ` commit: ${stringify(language.commit).trim()}` : " # commit: zh-CN";
|
|
517
|
-
return `# RSP project configuration
|
|
518
|
-
# An empty kinds list retains the built-in defaults.
|
|
519
|
-
# A non-empty kinds list replaces the built-in defaults; it does not extend them.
|
|
520
|
-
# Every entry must be a unique non-empty string.
|
|
521
|
-
#
|
|
522
|
-
# Built-in defaults:
|
|
523
|
-
# kinds: ${VALID_KINDS.join(", ")}
|
|
524
|
-
#
|
|
525
|
-
${renderedKinds}
|
|
526
|
-
|
|
527
|
-
# Decision Records default to .rsp/specs/decisions.
|
|
528
|
-
decisions:
|
|
529
|
-
path: ${stringify(decisions.path).trim()}
|
|
530
|
-
|
|
531
|
-
# New projects default to automatic Manage routing with local closeout.
|
|
532
|
-
# Use activation: explicit to require a named managed request.
|
|
533
|
-
# closeout accepts manual, lifecycle, or local; local routes a qualified clean terminal non-small boundary to one local commit but never push or publication.
|
|
534
|
-
manage:
|
|
535
|
-
activation: ${manage.activation}
|
|
536
|
-
closeout: ${manage.closeout}
|
|
537
|
-
|
|
538
|
-
# Set one shared project default for durable artifact and commit prose.
|
|
539
|
-
# Response language remains user/session-owned and is never read from this project mapping.
|
|
540
|
-
language:
|
|
541
|
-
default: ${stringify(language.default).trim()}
|
|
542
|
-
${artifactsLine}
|
|
543
|
-
${commitLine}
|
|
544
|
-
`;
|
|
545
|
-
}
|
|
546
|
-
var MANAGE_ACTIVATIONS = ["explicit", "auto"];
|
|
547
|
-
var MANAGE_CLOSEOUTS = ["manual", "lifecycle", "local"];
|
|
548
|
-
function reconcileRspConfigDefaults(raw) {
|
|
549
|
-
const document = parseDocument(raw);
|
|
550
|
-
if (document.errors.length > 0)
|
|
551
|
-
throw new Error(document.errors.map((error) => error.message).join("; "));
|
|
552
|
-
const parsed = parseYamlText(raw);
|
|
553
|
-
const issues = validateRspConfig(parsed);
|
|
554
|
-
if (issues.length > 0)
|
|
555
|
-
throw new Error(issues.join("; "));
|
|
556
|
-
const added = collectMissingConfigDefaults(parsed);
|
|
557
|
-
const customComments = hasCustomConfigComments(document, parsed);
|
|
558
|
-
if (customComments) {
|
|
559
|
-
backfillConfigDocument(document, parsed);
|
|
560
|
-
}
|
|
561
|
-
if (customComments && added.length === 0)
|
|
562
|
-
return { content: raw, added, changed: false };
|
|
563
|
-
const content = customComments ? String(document) : generateConfigTemplate(parsed);
|
|
564
|
-
return { content, added, changed: content !== raw };
|
|
565
|
-
}
|
|
566
|
-
function collectMissingConfigDefaults(parsed) {
|
|
567
|
-
const added = [];
|
|
568
|
-
if (!("kinds" in parsed))
|
|
569
|
-
added.push("kinds");
|
|
570
|
-
if (!("decisions" in parsed) || !hasNestedKey(parsed.decisions, "path"))
|
|
571
|
-
added.push("decisions.path");
|
|
572
|
-
if (!("language" in parsed))
|
|
573
|
-
added.push("language.default");
|
|
574
|
-
if (!("manage" in parsed)) {
|
|
575
|
-
added.push("manage.activation", "manage.closeout");
|
|
576
|
-
} else {
|
|
577
|
-
if (!hasNestedKey(parsed.manage, "activation"))
|
|
578
|
-
added.push("manage.activation");
|
|
579
|
-
if (!hasNestedKey(parsed.manage, "closeout"))
|
|
580
|
-
added.push("manage.closeout");
|
|
581
|
-
}
|
|
582
|
-
return added;
|
|
583
|
-
}
|
|
584
|
-
function backfillConfigDocument(document, parsed) {
|
|
585
|
-
if (!("kinds" in parsed))
|
|
586
|
-
document.set("kinds", [...CONFIG_DEFAULTS.kinds]);
|
|
587
|
-
if (!("decisions" in parsed))
|
|
588
|
-
document.set("decisions", { path: CONFIG_DEFAULTS.decisions.path });
|
|
589
|
-
else if (!hasNestedKey(parsed.decisions, "path"))
|
|
590
|
-
document.setIn(["decisions", "path"], CONFIG_DEFAULTS.decisions.path);
|
|
591
|
-
if (!("language" in parsed))
|
|
592
|
-
document.set("language", { default: CONFIG_DEFAULTS.language.default });
|
|
593
|
-
if (!("manage" in parsed)) {
|
|
594
|
-
document.set("manage", { ...CONFIG_DEFAULTS.manage });
|
|
595
|
-
} else {
|
|
596
|
-
if (!hasNestedKey(parsed.manage, "activation"))
|
|
597
|
-
document.setIn(["manage", "activation"], CONFIG_DEFAULTS.manage.activation);
|
|
598
|
-
if (!hasNestedKey(parsed.manage, "closeout"))
|
|
599
|
-
document.setIn(["manage", "closeout"], CONFIG_DEFAULTS.manage.closeout);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function hasNestedKey(value, key) {
|
|
603
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value) && key in value);
|
|
604
|
-
}
|
|
605
|
-
var LEGACY_GENERATED_CONFIG_COMMENTS = /* @__PURE__ */ new Set([
|
|
606
|
-
"Omit kinds or use [] to retain the built-in defaults.",
|
|
607
|
-
"New projects default to automatic Manage routing with lifecycle-only closeout.",
|
|
608
|
-
"Self-host automatic Manage routing with bounded deterministic local commits; push and publication stay explicit.",
|
|
609
|
-
"Set exactly one project-relative authoritative directory when the Host Project already owns Decision Records elsewhere.",
|
|
610
|
-
"kinds:",
|
|
611
|
-
"decisions:",
|
|
612
|
-
"path: docs/adr",
|
|
613
|
-
...VALID_KINDS.map((kind) => `- ${kind}`)
|
|
614
|
-
]);
|
|
615
|
-
function hasCustomConfigComments(document, parsed) {
|
|
616
|
-
const generated = new Set(collectConfigComments(parseDocument(generateConfigTemplate(parsed))));
|
|
617
|
-
for (const comment of LEGACY_GENERATED_CONFIG_COMMENTS)
|
|
618
|
-
generated.add(comment);
|
|
619
|
-
return collectConfigComments(document).some((comment) => !generated.has(comment));
|
|
620
|
-
}
|
|
621
|
-
function collectConfigComments(document) {
|
|
622
|
-
const comments = [];
|
|
623
|
-
const append = (value) => {
|
|
624
|
-
if (!value)
|
|
625
|
-
return;
|
|
626
|
-
for (const line of value.split("\n")) {
|
|
627
|
-
const comment = line.trim();
|
|
628
|
-
if (comment)
|
|
629
|
-
comments.push(comment);
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
append(document.commentBefore);
|
|
633
|
-
append(document.comment);
|
|
634
|
-
visit(document, {
|
|
635
|
-
Node(_key, node) {
|
|
636
|
-
append(node.commentBefore);
|
|
637
|
-
append(node.comment);
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
return comments;
|
|
641
|
-
}
|
|
642
|
-
var _configCache = null;
|
|
643
|
-
async function loadRspConfig() {
|
|
644
|
-
const inspection = await inspectRspConfig();
|
|
645
|
-
if (inspection.issues.length > 0)
|
|
646
|
-
throw new Error(inspection.issues.join("; "));
|
|
647
|
-
return inspection.config;
|
|
648
|
-
}
|
|
649
|
-
async function inspectRspConfig(cwd = process.cwd()) {
|
|
650
|
-
cwd = resolve2(cwd);
|
|
651
|
-
if (_configCache?.cwd === cwd)
|
|
652
|
-
return _configCache.inspection;
|
|
653
|
-
const configPath = join3(cwd, CONFIG_PATH);
|
|
654
|
-
const configFile = inspectManagedFile(configPath, "config file", { allowMissing: true });
|
|
655
|
-
if (configFile.issue)
|
|
656
|
-
throw configFile.issue;
|
|
657
|
-
if (!configFile.exists) {
|
|
658
|
-
const inspection2 = { config: {}, issues: [] };
|
|
659
|
-
_configCache = { cwd, inspection: inspection2 };
|
|
660
|
-
return inspection2;
|
|
661
|
-
}
|
|
662
|
-
const raw = await readFile(configPath, "utf-8");
|
|
663
|
-
const parsed = parseYamlText(raw);
|
|
664
|
-
const issues = validateRspConfig(parsed);
|
|
665
|
-
const decisions = parsed.decisions && typeof parsed.decisions === "object" && !Array.isArray(parsed.decisions) ? parsed.decisions : void 0;
|
|
666
|
-
const decisionPath = decisions?.path;
|
|
667
|
-
const manageValue = parsed.manage && typeof parsed.manage === "object" && !Array.isArray(parsed.manage) ? parsed.manage : void 0;
|
|
668
|
-
const languageValue = parsed.language && typeof parsed.language === "object" && !Array.isArray(parsed.language) ? parsed.language : void 0;
|
|
669
|
-
const activation = MANAGE_ACTIVATIONS.includes(manageValue?.activation) ? manageValue?.activation : void 0;
|
|
670
|
-
const closeout = MANAGE_CLOSEOUTS.includes(manageValue?.closeout) ? manageValue?.closeout : void 0;
|
|
671
|
-
const kinds = Array.isArray(parsed.kinds) && parsed.kinds.every((value) => typeof value === "string" && value.trim() !== "") ? parsed.kinds.map((value) => value.trim()) : void 0;
|
|
672
|
-
const decisionRecordsIssue = getDecisionRecordsConfigIssue(parsed);
|
|
673
|
-
const inspection = {
|
|
674
|
-
config: {
|
|
675
|
-
kinds,
|
|
676
|
-
decisions: decisionRecordsIssue === null && validateDecisionRecordsPath(decisionPath) === null ? { path: normalizeDecisionRecordsPath(String(decisionPath)) } : void 0,
|
|
677
|
-
manage: manageValue ? { activation, closeout } : void 0,
|
|
678
|
-
language: parseLanguageConfig(languageValue)
|
|
679
|
-
},
|
|
680
|
-
issues
|
|
681
|
-
};
|
|
682
|
-
_configCache = { cwd, inspection };
|
|
683
|
-
return inspection;
|
|
684
|
-
}
|
|
685
|
-
function validateRspConfig(parsed) {
|
|
686
|
-
const issues = [];
|
|
687
|
-
const supported = /* @__PURE__ */ new Set(["kinds", "decisions", "manage", "language"]);
|
|
688
|
-
for (const key of Object.keys(parsed)) {
|
|
689
|
-
if (key === "required_sections") {
|
|
690
|
-
issues.push('config.yaml field "required_sections" is no longer supported');
|
|
691
|
-
} else if (!supported.has(key)) {
|
|
692
|
-
issues.push(`config.yaml field "${key}" is not supported`);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
if ("kinds" in parsed) {
|
|
696
|
-
if (!Array.isArray(parsed.kinds)) {
|
|
697
|
-
issues.push('config.yaml field "kinds" must be a YAML list');
|
|
698
|
-
} else if (!parsed.kinds.every((value) => typeof value === "string" && value.trim() !== "")) {
|
|
699
|
-
issues.push('config.yaml field "kinds" must contain only non-empty strings');
|
|
700
|
-
} else {
|
|
701
|
-
const kinds = parsed.kinds.map((value) => value.trim());
|
|
702
|
-
const duplicates = [...new Set(kinds.filter((value, index) => kinds.indexOf(value) !== index))];
|
|
703
|
-
if (duplicates.length > 0)
|
|
704
|
-
issues.push(`config.yaml field "kinds" contains duplicate entries: ${duplicates.join(", ")}`);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
const decisionRecordsIssue = getDecisionRecordsConfigIssue(parsed);
|
|
708
|
-
if (decisionRecordsIssue)
|
|
709
|
-
issues.push(decisionRecordsIssue);
|
|
710
|
-
if ("manage" in parsed) {
|
|
711
|
-
if (!parsed.manage || typeof parsed.manage !== "object" || Array.isArray(parsed.manage)) {
|
|
712
|
-
issues.push('config.yaml field "manage" must be a YAML mapping');
|
|
713
|
-
} else {
|
|
714
|
-
const manage = parsed.manage;
|
|
715
|
-
const supportedManageFields = /* @__PURE__ */ new Set(["activation", "closeout"]);
|
|
716
|
-
for (const key of Object.keys(manage)) {
|
|
717
|
-
if (!supportedManageFields.has(key))
|
|
718
|
-
issues.push(`config.yaml field "manage.${key}" is not supported`);
|
|
719
|
-
}
|
|
720
|
-
if ("activation" in manage && !MANAGE_ACTIVATIONS.includes(manage.activation))
|
|
721
|
-
issues.push('config.yaml field "manage.activation" must be one of: explicit, auto');
|
|
722
|
-
if ("closeout" in manage && !MANAGE_CLOSEOUTS.includes(manage.closeout))
|
|
723
|
-
issues.push('config.yaml field "manage.closeout" must be one of: manual, lifecycle, local');
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
if ("language" in parsed) {
|
|
727
|
-
if (!parsed.language || typeof parsed.language !== "object" || Array.isArray(parsed.language)) {
|
|
728
|
-
issues.push('config.yaml field "language" must be a YAML mapping');
|
|
729
|
-
} else {
|
|
730
|
-
const language = parsed.language;
|
|
731
|
-
const supportedLanguageFields = /* @__PURE__ */ new Set(["default", "artifacts", "commit"]);
|
|
732
|
-
for (const key of Object.keys(language)) {
|
|
733
|
-
if (!supportedLanguageFields.has(key))
|
|
734
|
-
issues.push(`config.yaml field "language.${key}" is not supported`);
|
|
735
|
-
}
|
|
736
|
-
if (!("default" in language))
|
|
737
|
-
issues.push('config.yaml field "language.default" is required when language is configured');
|
|
738
|
-
for (const key of supportedLanguageFields) {
|
|
739
|
-
if (key in language && canonicalizeLanguageTag(language[key]) === null)
|
|
740
|
-
issues.push(`config.yaml field "language.${key}" must be a non-empty valid BCP 47 language tag`);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return issues;
|
|
745
|
-
}
|
|
746
|
-
function clearConfigCache() {
|
|
747
|
-
_configCache = null;
|
|
748
|
-
}
|
|
749
|
-
function resolveKinds(config) {
|
|
750
|
-
return config.kinds && config.kinds.length > 0 ? config.kinds : [...VALID_KINDS];
|
|
751
|
-
}
|
|
752
|
-
function resolveRequiredSections(_config) {
|
|
753
|
-
return [...DEFAULT_REQUIRED_SECTIONS];
|
|
754
|
-
}
|
|
755
|
-
function resolveManagePolicy(config, options = {}) {
|
|
756
|
-
if (options.configValid === false)
|
|
757
|
-
return { ...INVALID_CONFIG_MANAGE_POLICY };
|
|
758
|
-
return {
|
|
759
|
-
activation: config.manage?.activation ?? LEGACY_MISSING_CONFIG_MANAGE_POLICY.activation,
|
|
760
|
-
closeout: config.manage?.closeout ?? LEGACY_MISSING_CONFIG_MANAGE_POLICY.closeout
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
function resolveLanguagePolicy(config, options = {}) {
|
|
764
|
-
if (options.configValid === false || !config.language)
|
|
765
|
-
return { artifacts: null, commit: null };
|
|
766
|
-
return {
|
|
767
|
-
artifacts: config.language.artifacts ?? config.language.default,
|
|
768
|
-
commit: config.language.commit ?? config.language.default
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
function parseLanguageConfig(value) {
|
|
772
|
-
if (!value)
|
|
773
|
-
return void 0;
|
|
774
|
-
const defaultLanguage = canonicalizeLanguageTag(value.default);
|
|
775
|
-
if (defaultLanguage === null)
|
|
776
|
-
return void 0;
|
|
777
|
-
const artifacts = canonicalizeLanguageTag(value.artifacts);
|
|
778
|
-
const commit = canonicalizeLanguageTag(value.commit);
|
|
779
|
-
return {
|
|
780
|
-
default: defaultLanguage,
|
|
781
|
-
artifacts: artifacts ?? void 0,
|
|
782
|
-
commit: commit ?? void 0
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
function canonicalizeLanguageTag(value) {
|
|
786
|
-
if (typeof value !== "string" || value.trim() === "")
|
|
787
|
-
return null;
|
|
788
|
-
try {
|
|
789
|
-
return Intl.getCanonicalLocales(value.trim())[0] ?? null;
|
|
790
|
-
} catch {
|
|
791
|
-
return null;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
async function getVersion() {
|
|
795
|
-
const { version } = JSON.parse(await readFile(join3(PKG_ROOT, "package.json"), "utf-8"));
|
|
796
|
-
return version;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// src/core/output.ts
|
|
800
|
-
import pc2 from "picocolors";
|
|
801
|
-
function toErrorMessage(error) {
|
|
802
|
-
return error instanceof Error ? error.message : String(error);
|
|
803
|
-
}
|
|
804
|
-
function emitJson(data, options = {}) {
|
|
805
|
-
const indentation = options.compact ? void 0 : 2;
|
|
806
|
-
process.stdout.write(`${JSON.stringify(data, null, indentation)}
|
|
807
|
-
`);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
export {
|
|
811
|
-
CHANGE_DOCUMENT_SCHEMA,
|
|
812
|
-
GROUP_BRIEF_DOCUMENT_SCHEMA,
|
|
813
|
-
DocumentSectionCardinalityError,
|
|
814
|
-
parseRspDocument,
|
|
815
|
-
getDocumentTitles,
|
|
816
|
-
getDocumentTitle,
|
|
817
|
-
getDocumentSections,
|
|
818
|
-
getDocumentSectionBody,
|
|
819
|
-
getDocumentSectionDefinitionByHeading,
|
|
820
|
-
getCanonicalSectionHeadings,
|
|
821
|
-
renderDocumentSectionHeading,
|
|
822
|
-
renderDocumentTitle,
|
|
823
|
-
appendDocumentSectionItem,
|
|
824
|
-
parseFrontmatter,
|
|
825
|
-
countCheckboxes,
|
|
826
|
-
classifyVerifyCheckboxes,
|
|
827
|
-
collectVerifyCheckboxLines,
|
|
828
|
-
getOpenCheckboxes,
|
|
829
|
-
extractBlockerLines,
|
|
830
|
-
hasMeaningfulBlockerBody,
|
|
831
|
-
hasMeaningfulBlockers,
|
|
832
|
-
isEmptyBlockerLine,
|
|
833
|
-
detectDeltaSections,
|
|
834
|
-
parseScenarios,
|
|
835
|
-
ManagedPathError,
|
|
836
|
-
inspectManagedDirectory,
|
|
837
|
-
requireManagedDirectory,
|
|
838
|
-
inspectManagedFile,
|
|
839
|
-
requireManagedFile,
|
|
840
|
-
ensureManagedFile,
|
|
841
|
-
writeManagedFile,
|
|
842
|
-
resolveManagedDirectoryChain,
|
|
843
|
-
inspectManagedFileTree,
|
|
844
|
-
DEFAULT_DECISION_RECORDS_PATH,
|
|
845
|
-
resolveDecisionRecordsPath,
|
|
846
|
-
ensureDecisionRecordsDirectory,
|
|
847
|
-
validateDecisionRecordsFilesystemPath,
|
|
848
|
-
pc,
|
|
849
|
-
PKG_ROOT,
|
|
850
|
-
RSP_DIR,
|
|
851
|
-
RSP_RULES_PATH,
|
|
852
|
-
OBSOLETE_RSP_RULES_PATH,
|
|
853
|
-
CHANGES_DIR,
|
|
854
|
-
FOCUS_DIR,
|
|
855
|
-
MAX_FOCUS_CAPSULE_BYTES,
|
|
856
|
-
ARCHIVES_DIR,
|
|
857
|
-
LOCK_PATH,
|
|
858
|
-
CONFIG_PATH,
|
|
859
|
-
generateConfigTemplate,
|
|
860
|
-
reconcileRspConfigDefaults,
|
|
861
|
-
loadRspConfig,
|
|
862
|
-
inspectRspConfig,
|
|
863
|
-
clearConfigCache,
|
|
864
|
-
resolveKinds,
|
|
865
|
-
resolveRequiredSections,
|
|
866
|
-
resolveManagePolicy,
|
|
867
|
-
resolveLanguagePolicy,
|
|
868
|
-
getVersion,
|
|
869
|
-
toErrorMessage,
|
|
870
|
-
emitJson
|
|
871
|
-
};
|