specdx 0.4.0-alpha.1 → 0.4.0-alpha.10
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/LICENSE +21 -0
- package/dist/{changelog-OUP2RXWN.js → changelog-GR53T6IG.js} +18 -11
- package/dist/{changelog-OUP2RXWN.js.map → changelog-GR53T6IG.js.map} +1 -1
- package/dist/{check-3XQYO3HU.js → check-OMWCIY5D.js} +37 -10
- package/dist/check-OMWCIY5D.js.map +1 -0
- package/dist/{chunk-HMXUNURD.js → chunk-3GMYCATE.js} +50 -14
- package/dist/chunk-3GMYCATE.js.map +1 -0
- package/dist/{chunk-6BWZEAST.js → chunk-N77RNV7J.js} +161 -26
- package/dist/chunk-N77RNV7J.js.map +1 -0
- package/dist/{chunk-4THCEWAK.js → chunk-SDDTD4R3.js} +95 -10
- package/dist/chunk-SDDTD4R3.js.map +1 -0
- package/dist/{chunk-ZX4HVL5M.js → chunk-SJCIM4TC.js} +119 -17
- package/dist/chunk-SJCIM4TC.js.map +1 -0
- package/dist/{chunk-DDFLMRPC.js → chunk-VMMTEGYN.js} +15 -11
- package/dist/chunk-VMMTEGYN.js.map +1 -0
- package/dist/{chunk-PHR7AV6I.js → chunk-Z77VQUZ3.js} +156 -2
- package/dist/chunk-Z77VQUZ3.js.map +1 -0
- package/dist/diff-AUBYOQWU.js +107 -0
- package/dist/diff-AUBYOQWU.js.map +1 -0
- package/dist/{dist-QXLX77XG.js → dist-BXYQB2UO.js} +36 -9
- package/dist/dist-BXYQB2UO.js.map +1 -0
- package/dist/dist-RL2DT3ZE.js +15 -0
- package/dist/{explain-I7AQMEEH.js → explain-EUID6MZF.js} +35 -28
- package/dist/explain-EUID6MZF.js.map +1 -0
- package/dist/{generate-PC7BIB7G.js → generate-U3EFOCNS.js} +3 -3
- package/dist/{generate-story-7WHPPFHY.js → generate-story-U6FMQIYZ.js} +8 -4
- package/dist/generate-story-U6FMQIYZ.js.map +1 -0
- package/dist/{generate-test-plan-U5LMWGKX.js → generate-test-plan-HOCWDYKF.js} +11 -6
- package/dist/generate-test-plan-HOCWDYKF.js.map +1 -0
- package/dist/graph-TA54D4XA.js +102 -0
- package/dist/graph-TA54D4XA.js.map +1 -0
- package/dist/index.js +546 -156
- package/dist/index.js.map +1 -1
- package/dist/{lint-XPAFMLZN.js → lint-L5WOBD25.js} +17 -6
- package/dist/lint-L5WOBD25.js.map +1 -0
- package/dist/main.js +100 -16
- package/dist/main.js.map +1 -1
- package/dist/{mcp-6RCSHMXD.js → mcp-GNQQGD7X.js} +2 -2
- package/dist/{migrate-L7W5RHSS.js → migrate-YEJQWIMX.js} +4 -4
- package/dist/migrate-YEJQWIMX.js.map +1 -0
- package/dist/{pack-QCOXMURY.js → pack-AQH5XQUF.js} +7 -6
- package/dist/{pack-QCOXMURY.js.map → pack-AQH5XQUF.js.map} +1 -1
- package/dist/ready-DB5ORK2E.js +229 -0
- package/dist/ready-DB5ORK2E.js.map +1 -0
- package/dist/skills/specdx-check-drift.md +1 -1
- package/dist/skills/specdx-verify.md +12 -1
- package/dist/{status-EKWK47O5.js → status-3QUQMF4L.js} +46 -31
- package/dist/status-3QUQMF4L.js.map +1 -0
- package/dist/{update-HIWDDEZQ.js → update-PE2DPYDR.js} +5 -5
- package/dist/update-PE2DPYDR.js.map +1 -0
- package/dist/validate-YNZMV6KZ.js +86 -0
- package/dist/validate-YNZMV6KZ.js.map +1 -0
- package/hooks/session-start +0 -0
- package/package.json +49 -17
- package/dist/check-3XQYO3HU.js.map +0 -1
- package/dist/chunk-4THCEWAK.js.map +0 -1
- package/dist/chunk-6BWZEAST.js.map +0 -1
- package/dist/chunk-DDFLMRPC.js.map +0 -1
- package/dist/chunk-HMXUNURD.js.map +0 -1
- package/dist/chunk-PHR7AV6I.js.map +0 -1
- package/dist/chunk-ZX4HVL5M.js.map +0 -1
- package/dist/diff-275PLXYH.js +0 -100
- package/dist/diff-275PLXYH.js.map +0 -1
- package/dist/dist-PQCG2XXF.js +0 -11
- package/dist/dist-QXLX77XG.js.map +0 -1
- package/dist/explain-I7AQMEEH.js.map +0 -1
- package/dist/generate-story-7WHPPFHY.js.map +0 -1
- package/dist/generate-test-plan-U5LMWGKX.js.map +0 -1
- package/dist/graph-RCAPF55A.js +0 -54
- package/dist/graph-RCAPF55A.js.map +0 -1
- package/dist/lint-XPAFMLZN.js.map +0 -1
- package/dist/migrate-L7W5RHSS.js.map +0 -1
- package/dist/ready-ZXG74W7Y.js +0 -159
- package/dist/ready-ZXG74W7Y.js.map +0 -1
- package/dist/status-EKWK47O5.js.map +0 -1
- package/dist/update-HIWDDEZQ.js.map +0 -1
- package/dist/validate-N2WSG75W.js +0 -34
- package/dist/validate-N2WSG75W.js.map +0 -1
- /package/dist/{dist-PQCG2XXF.js.map → dist-RL2DT3ZE.js.map} +0 -0
- /package/dist/{generate-PC7BIB7G.js.map → generate-U3EFOCNS.js.map} +0 -0
- /package/dist/{mcp-6RCSHMXD.js.map → mcp-GNQQGD7X.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
countTokens
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
4
4
|
|
|
5
5
|
// ../pack/dist/resolver.js
|
|
6
6
|
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
@@ -86,6 +86,7 @@ var WEIGHT_TAGS = 3;
|
|
|
86
86
|
var WEIGHT_TITLE = 3;
|
|
87
87
|
var WEIGHT_SECTIONS = 2;
|
|
88
88
|
var WEIGHT_BODY = 1;
|
|
89
|
+
var ID_MATCH_MIN_LENGTH = 3;
|
|
89
90
|
var GRAPH_BOOST_FACTOR = 0.5;
|
|
90
91
|
var SCORE_THRESHOLD = 0.1;
|
|
91
92
|
function scoreSpecs(specs, task, graph) {
|
|
@@ -105,9 +106,15 @@ function scoreSpecs(specs, task, graph) {
|
|
|
105
106
|
}
|
|
106
107
|
const rawScores = /* @__PURE__ */ new Map();
|
|
107
108
|
const matchedMap = /* @__PURE__ */ new Map();
|
|
109
|
+
const idMatchedSet = /* @__PURE__ */ new Set();
|
|
110
|
+
const taskLower = (task ?? "").toLowerCase();
|
|
108
111
|
for (const [specId, spec] of specs) {
|
|
109
112
|
let weightedHits = 0;
|
|
110
113
|
const matched = /* @__PURE__ */ new Set();
|
|
114
|
+
const idLower = specId.toLowerCase();
|
|
115
|
+
if (idLower.length >= ID_MATCH_MIN_LENGTH && taskLower.includes(idLower)) {
|
|
116
|
+
idMatchedSet.add(specId);
|
|
117
|
+
}
|
|
111
118
|
for (const keyword of keywords) {
|
|
112
119
|
let hit = false;
|
|
113
120
|
const tags = spec.frontmatter.tags ?? [];
|
|
@@ -179,7 +186,8 @@ function scoreSpecs(specs, task, graph) {
|
|
|
179
186
|
const results = [];
|
|
180
187
|
for (const [specId] of specs) {
|
|
181
188
|
const combined = finalRawScores.get(specId) ?? 0;
|
|
182
|
-
const
|
|
189
|
+
const idMatched = idMatchedSet.has(specId);
|
|
190
|
+
const normalized = idMatched ? 1 : maxScore > 0 ? combined / maxScore : 0;
|
|
183
191
|
if (normalized < SCORE_THRESHOLD)
|
|
184
192
|
continue;
|
|
185
193
|
results.push({
|
|
@@ -187,10 +195,11 @@ function scoreSpecs(specs, task, graph) {
|
|
|
187
195
|
score: normalized,
|
|
188
196
|
rawScore: rawScores.get(specId) ?? 0,
|
|
189
197
|
matchedKeywords: [...matchedMap.get(specId) ?? []],
|
|
190
|
-
graphBoosted: boostedSet.has(specId)
|
|
198
|
+
graphBoosted: boostedSet.has(specId),
|
|
199
|
+
idMatched
|
|
191
200
|
});
|
|
192
201
|
}
|
|
193
|
-
results.sort((a, b) => b.score - a.score);
|
|
202
|
+
results.sort((a, b) => b.score - a.score || Number(b.idMatched ?? false) - Number(a.idMatched ?? false));
|
|
194
203
|
return results;
|
|
195
204
|
}
|
|
196
205
|
function scoreSpecsByIds(specs, specIds, graph) {
|
|
@@ -283,6 +292,69 @@ function compressSpec(specId, type, title, status, updatedDate, parsedSections,
|
|
|
283
292
|
}
|
|
284
293
|
|
|
285
294
|
// ../pack/dist/allocator.js
|
|
295
|
+
var HIGH_RELEVANCE = 0.75;
|
|
296
|
+
var MIN_TRIM_BUDGET = 150;
|
|
297
|
+
function omissionMarker(sections) {
|
|
298
|
+
const names = sections.map((s) => s.heading || "(untitled)");
|
|
299
|
+
const noun = names.length === 1 ? "section" : "sections";
|
|
300
|
+
return `[${names.length} ${noun} omitted to fit token budget: ${names.join(", ")}]`;
|
|
301
|
+
}
|
|
302
|
+
function trimToBudget(compressed, budget) {
|
|
303
|
+
const sections = compressed.sections;
|
|
304
|
+
let reserve = 0;
|
|
305
|
+
for (; ; ) {
|
|
306
|
+
const effective = budget - reserve;
|
|
307
|
+
const keep = new Array(sections.length).fill(false);
|
|
308
|
+
let used = 0;
|
|
309
|
+
let keptReal = false;
|
|
310
|
+
for (let i = 0; i < sections.length; i++) {
|
|
311
|
+
if (used + sections[i].tokens <= effective) {
|
|
312
|
+
keep[i] = true;
|
|
313
|
+
used += sections[i].tokens;
|
|
314
|
+
keptReal = true;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (!keptReal)
|
|
318
|
+
return null;
|
|
319
|
+
const runs = [];
|
|
320
|
+
for (let i = 0; i < sections.length; i++) {
|
|
321
|
+
if (keep[i])
|
|
322
|
+
continue;
|
|
323
|
+
const start = i;
|
|
324
|
+
const run = [];
|
|
325
|
+
while (i < sections.length && !keep[i]) {
|
|
326
|
+
run.push(sections[i]);
|
|
327
|
+
i++;
|
|
328
|
+
}
|
|
329
|
+
i--;
|
|
330
|
+
const marker = omissionMarker(run);
|
|
331
|
+
runs.push({ start, sections: run, marker, markerTokens: countTokens(marker) });
|
|
332
|
+
}
|
|
333
|
+
const markerTokens = runs.reduce((sum, r) => sum + r.markerTokens, 0);
|
|
334
|
+
if (markerTokens > reserve) {
|
|
335
|
+
reserve = markerTokens;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const out = [];
|
|
339
|
+
for (let i = 0; i < sections.length; i++) {
|
|
340
|
+
const run = runs.find((r) => r.start === i);
|
|
341
|
+
if (run) {
|
|
342
|
+
out.push({
|
|
343
|
+
heading: "",
|
|
344
|
+
content: run.marker,
|
|
345
|
+
tokens: run.markerTokens,
|
|
346
|
+
compressed: true,
|
|
347
|
+
originalTokens: run.sections.reduce((sum, s) => sum + s.tokens, 0),
|
|
348
|
+
omittedSections: run.sections.length
|
|
349
|
+
});
|
|
350
|
+
i += run.sections.length - 1;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
out.push(sections[i]);
|
|
354
|
+
}
|
|
355
|
+
return { spec: { ...compressed, sections: out }, tokens: used + markerTokens };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
286
358
|
function allocate(specs, scores, options) {
|
|
287
359
|
const specMap = /* @__PURE__ */ new Map();
|
|
288
360
|
for (const spec of specs) {
|
|
@@ -320,9 +392,9 @@ function allocate(specs, scores, options) {
|
|
|
320
392
|
tokens += section.tokens;
|
|
321
393
|
}
|
|
322
394
|
}
|
|
323
|
-
items.push({ compressed, relevance: score.score, tokens });
|
|
395
|
+
items.push({ compressed, relevance: score.score, tokens, idMatched: score.idMatched ?? false });
|
|
324
396
|
}
|
|
325
|
-
items.sort((a, b) => b.relevance - a.relevance);
|
|
397
|
+
items.sort((a, b) => b.relevance - a.relevance || Number(b.idMatched) - Number(a.idMatched));
|
|
326
398
|
const totalTokens = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
327
399
|
const withinBudget = totalTokens <= options.budget;
|
|
328
400
|
const included = [];
|
|
@@ -338,17 +410,28 @@ function allocate(specs, scores, options) {
|
|
|
338
410
|
if (usedTokens + item.tokens <= options.budget) {
|
|
339
411
|
included.push(item);
|
|
340
412
|
usedTokens += item.tokens;
|
|
341
|
-
|
|
342
|
-
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
const remaining = options.budget - usedTokens;
|
|
416
|
+
if ((item.idMatched || item.relevance >= HIGH_RELEVANCE) && remaining >= MIN_TRIM_BUDGET && !item.compressed.collapsed) {
|
|
417
|
+
const trimmed = trimToBudget(item.compressed, remaining);
|
|
418
|
+
if (trimmed) {
|
|
419
|
+
included.push({ ...item, compressed: trimmed.spec, tokens: trimmed.tokens });
|
|
420
|
+
usedTokens += trimmed.tokens;
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
343
423
|
}
|
|
424
|
+
excluded.push(item);
|
|
344
425
|
}
|
|
345
426
|
}
|
|
346
427
|
let sectionsCompressed = 0;
|
|
428
|
+
let sectionsOmitted = 0;
|
|
347
429
|
for (const item of included) {
|
|
348
430
|
for (const section of item.compressed.sections) {
|
|
349
431
|
if (section.compressed) {
|
|
350
432
|
sectionsCompressed++;
|
|
351
433
|
}
|
|
434
|
+
sectionsOmitted += section.omittedSections ?? 0;
|
|
352
435
|
}
|
|
353
436
|
}
|
|
354
437
|
const allocations = [];
|
|
@@ -378,6 +461,7 @@ function allocate(specs, scores, options) {
|
|
|
378
461
|
specsIncluded: included.length,
|
|
379
462
|
specsExcluded: excluded.length,
|
|
380
463
|
sectionsCompressed,
|
|
464
|
+
sectionsOmitted,
|
|
381
465
|
allocations
|
|
382
466
|
};
|
|
383
467
|
return {
|
|
@@ -392,7 +476,7 @@ function escapeXml(text) {
|
|
|
392
476
|
}
|
|
393
477
|
function formatXml(specs, stats) {
|
|
394
478
|
const lines = [];
|
|
395
|
-
lines.push(`<context budget="${stats.budget}" used="${stats.used}" specs="${stats.specsIncluded}" compressed="${stats.sectionsCompressed}">`);
|
|
479
|
+
lines.push(`<context budget="${stats.budget}" used="${stats.used}" specs="${stats.specsIncluded}" compressed="${stats.sectionsCompressed}" omitted="${stats.sectionsOmitted}">`);
|
|
396
480
|
for (const spec of specs) {
|
|
397
481
|
const alloc = stats.allocations.find((a) => a.specId === spec.specId);
|
|
398
482
|
const relevance = alloc?.relevance ?? 0;
|
|
@@ -451,6 +535,7 @@ function formatJson(specs, stats) {
|
|
|
451
535
|
const output = {
|
|
452
536
|
budget: stats.budget,
|
|
453
537
|
used: stats.used,
|
|
538
|
+
sectionsOmitted: stats.sectionsOmitted,
|
|
454
539
|
specs: specs.map((spec) => {
|
|
455
540
|
const alloc = stats.allocations.find((a) => a.specId === spec.specId);
|
|
456
541
|
const relevance = alloc?.relevance ?? 0;
|
|
@@ -579,4 +664,4 @@ function pack(specs, options, packConfig, graph) {
|
|
|
579
664
|
export {
|
|
580
665
|
pack
|
|
581
666
|
};
|
|
582
|
-
//# sourceMappingURL=chunk-
|
|
667
|
+
//# sourceMappingURL=chunk-SDDTD4R3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../pack/src/resolver.ts","../../pack/src/compressor.ts","../../pack/src/allocator.ts","../../pack/src/formatters/xml.ts","../../pack/src/formatters/markdown.ts","../../pack/src/formatters/json.ts","../../pack/src/index.ts"],"sourcesContent":["import type { ParsedSpec, DependencyGraph } from \"@specdx/core\";\nimport type { RelevanceScore } from \"./types.js\";\n\n/**\n * Common English stopwords to filter from task tokenization.\n */\nconst STOPWORDS = new Set([\n \"a\",\n \"an\",\n \"and\",\n \"are\",\n \"as\",\n \"at\",\n \"be\",\n \"but\",\n \"by\",\n \"do\",\n \"for\",\n \"from\",\n \"had\",\n \"has\",\n \"have\",\n \"he\",\n \"her\",\n \"his\",\n \"how\",\n \"i\",\n \"if\",\n \"in\",\n \"into\",\n \"is\",\n \"it\",\n \"its\",\n \"just\",\n \"me\",\n \"my\",\n \"no\",\n \"nor\",\n \"not\",\n \"of\",\n \"on\",\n \"or\",\n \"our\",\n \"out\",\n \"own\",\n \"say\",\n \"she\",\n \"so\",\n \"some\",\n \"such\",\n \"than\",\n \"that\",\n \"the\",\n \"their\",\n \"them\",\n \"then\",\n \"there\",\n \"these\",\n \"they\",\n \"this\",\n \"to\",\n \"too\",\n \"up\",\n \"us\",\n \"very\",\n \"was\",\n \"we\",\n \"were\",\n \"what\",\n \"when\",\n \"where\",\n \"which\",\n \"while\",\n \"who\",\n \"whom\",\n \"why\",\n \"will\",\n \"with\",\n \"would\",\n \"you\",\n \"your\",\n]);\n\n/** Tokenize a task string into lowercase keywords, dropping stopwords and short tokens. */\nfunction tokenize(task: string): string[] {\n return task\n .split(/[\\s\\-_/.,;:!?()[\\]{}'\"]+/)\n .map((t) => t.toLowerCase())\n .filter((t) => t.length > 1 && !STOPWORDS.has(t));\n}\n\n/** Field weights for keyword matching. */\nconst WEIGHT_TAGS = 3;\nconst WEIGHT_TITLE = 3;\nconst WEIGHT_SECTIONS = 2;\nconst WEIGHT_BODY = 1;\n\n/** Minimum id length considered for verbatim matching (avoids ids like \"a\"). */\nconst ID_MATCH_MIN_LENGTH = 3;\n\n/** Graph propagation factor for immediate neighbors. */\nconst GRAPH_BOOST_FACTOR = 0.5;\n\n/** Minimum normalized score to include a spec. */\nconst SCORE_THRESHOLD = 0.1;\n\n/**\n * Score specs by keyword relevance to a task string with graph propagation.\n *\n * - If no task or empty keywords after stopword removal, all specs get score 1.0.\n * - Keywords are matched with substring includes across weighted fields.\n * - Immediate graph neighbors of matching specs receive a boost.\n * - Results are normalized 0-1 and filtered by threshold.\n */\nexport function scoreSpecs(\n specs: Map<string, ParsedSpec>,\n task: string | undefined,\n graph: DependencyGraph,\n): RelevanceScore[] {\n const keywords = task ? tokenize(task) : [];\n\n // No keywords: all specs equally relevant\n if (keywords.length === 0) {\n const results: RelevanceScore[] = [];\n for (const specId of specs.keys()) {\n results.push({\n specId,\n score: 1.0,\n rawScore: 1.0,\n matchedKeywords: [],\n graphBoosted: false,\n });\n }\n return results;\n }\n\n // Score each spec by keyword hits across weighted fields\n const rawScores = new Map<string, number>();\n const matchedMap = new Map<string, Set<string>>();\n const idMatchedSet = new Set<string>();\n const taskLower = (task ?? \"\").toLowerCase();\n\n for (const [specId, spec] of specs) {\n let weightedHits = 0;\n const matched = new Set<string>();\n\n // Verbatim id match: a task that names a spec dominates keyword scoring\n const idLower = specId.toLowerCase();\n if (idLower.length >= ID_MATCH_MIN_LENGTH && taskLower.includes(idLower)) {\n idMatchedSet.add(specId);\n }\n\n for (const keyword of keywords) {\n let hit = false;\n\n // Tags (3x)\n const tags: unknown[] = (spec.frontmatter.tags as unknown[] | undefined) ?? [];\n for (const tag of tags) {\n if (typeof tag === \"string\" && tag.toLowerCase().includes(keyword)) {\n weightedHits += WEIGHT_TAGS;\n hit = true;\n break;\n }\n }\n\n // Title (3x)\n const title = spec.frontmatter.title;\n if (typeof title === \"string\" && title.toLowerCase().includes(keyword)) {\n weightedHits += WEIGHT_TITLE;\n hit = true;\n }\n\n // Sections (2x)\n for (const heading of spec.sections) {\n if (heading.toLowerCase().includes(keyword)) {\n weightedHits += WEIGHT_SECTIONS;\n hit = true;\n break;\n }\n }\n\n // Body content (1x)\n if (spec.content.toLowerCase().includes(keyword)) {\n weightedHits += WEIGHT_BODY;\n hit = true;\n }\n\n if (hit) {\n matched.add(keyword);\n }\n }\n\n const raw = weightedHits / keywords.length;\n rawScores.set(specId, raw);\n matchedMap.set(specId, matched);\n }\n\n // Graph propagation: boost immediate neighbors\n const boostScores = new Map<string, number>();\n const boostedSet = new Set<string>();\n\n for (const [specId, rawScore] of rawScores) {\n if (rawScore <= 0) continue;\n\n const boostAmount = rawScore * GRAPH_BOOST_FACTOR;\n\n // Find immediate neighbors from graph edges\n for (const edge of graph.edges) {\n let neighborId: string | undefined;\n if (edge.from === specId) {\n neighborId = edge.to;\n } else if (edge.to === specId) {\n neighborId = edge.from;\n }\n\n if (neighborId !== undefined && specs.has(neighborId)) {\n const existing = boostScores.get(neighborId) ?? 0;\n boostScores.set(neighborId, Math.max(existing, boostAmount));\n }\n }\n }\n\n // Combine raw + boost scores\n const finalRawScores = new Map<string, number>();\n for (const specId of specs.keys()) {\n const raw = rawScores.get(specId) ?? 0;\n const boost = boostScores.get(specId) ?? 0;\n const combined = raw + boost;\n finalRawScores.set(specId, combined);\n if (boost > 0 && raw === 0) {\n boostedSet.add(specId);\n }\n }\n\n // Find max for normalization\n let maxScore = 0;\n for (const score of finalRawScores.values()) {\n if (score > maxScore) maxScore = score;\n }\n\n // Build results, normalize, and filter. A spec the task names verbatim is\n // clamped to 1.0 — an explicit mention always outranks keyword inference —\n // without distorting the normalization of the other specs' scores.\n const results: RelevanceScore[] = [];\n for (const [specId] of specs) {\n const combined = finalRawScores.get(specId) ?? 0;\n const idMatched = idMatchedSet.has(specId);\n const normalized = idMatched ? 1.0 : maxScore > 0 ? combined / maxScore : 0;\n\n if (normalized < SCORE_THRESHOLD) continue;\n\n results.push({\n specId,\n score: normalized,\n rawScore: rawScores.get(specId) ?? 0,\n matchedKeywords: [...(matchedMap.get(specId) ?? [])],\n graphBoosted: boostedSet.has(specId),\n idMatched,\n });\n }\n\n // Sort descending by score; ties prefer specs the task named explicitly\n results.sort(\n (a, b) => b.score - a.score || Number(b.idMatched ?? false) - Number(a.idMatched ?? false),\n );\n\n return results;\n}\n\n/**\n * Score specs by explicit IDs. Named specs get 1.0, their transitive\n * upstream dependencies get 0.5.\n *\n * Throws if any specId is not found in the specs map.\n */\nexport function scoreSpecsByIds(\n specs: Map<string, ParsedSpec>,\n specIds: string[],\n graph: DependencyGraph,\n): RelevanceScore[] {\n // Validate all IDs exist\n for (const id of specIds) {\n if (!specs.has(id)) {\n const available = [...specs.keys()].join(\", \");\n throw new Error(`Unknown spec: \"${id}\". Available specs: ${available}`);\n }\n }\n\n const scoreMap = new Map<string, number>();\n\n // Named specs get 1.0\n for (const id of specIds) {\n scoreMap.set(id, 1.0);\n }\n\n // Upstream deps get 0.5 (unless already named at 1.0)\n for (const id of specIds) {\n const upstream = graph.getUpstream(id);\n for (const depId of upstream) {\n if (!scoreMap.has(depId) && specs.has(depId)) {\n scoreMap.set(depId, 0.5);\n }\n }\n }\n\n const results: RelevanceScore[] = [];\n for (const [specId, score] of scoreMap) {\n results.push({\n specId,\n score,\n rawScore: score,\n matchedKeywords: [],\n graphBoosted: score < 1.0,\n });\n }\n\n // Sort descending by score\n results.sort((a, b) => b.score - a.score);\n\n return results;\n}\n","import { countTokens } from \"@specdx/core\";\nimport type { ParsedSection } from \"@specdx/core\";\nimport type { CompressedSpec, CompressedSection, CompressionOptions } from \"./types.js\";\n\n/**\n * Returns true when `dateStr` is more than `days` days before now.\n * Returns false for invalid / missing dates (treat as fresh).\n */\nfunction isOlderThanDays(dateStr: string | undefined, days: number): boolean {\n if (!dateStr) return false;\n const ms = Date.parse(dateStr);\n if (Number.isNaN(ms)) return false;\n const diffMs = Date.now() - ms;\n return diffMs > days * 24 * 60 * 60 * 1000;\n}\n\n/**\n * Compress a single spec according to the provided options.\n */\nexport function compressSpec(\n specId: string,\n type: string,\n title: string,\n status: string | undefined,\n updatedDate: string | undefined,\n parsedSections: ParsedSection[],\n options: CompressionOptions,\n): CompressedSpec {\n // 1. Collapse superseded ADRs\n if (type === \"adr\" && status === \"superseded\" && options.collapseResolvedAdrs) {\n return {\n specId,\n type,\n title,\n sections: [],\n collapsed: true,\n collapsedSummary: `[ADR] ${title} — superseded`,\n };\n }\n\n // 2. Determine staleness\n const stale = options.stableDays > 0 && isOlderThanDays(updatedDate, options.stableDays);\n\n // 3. Process sections\n const boilerplateSet = new Set(options.boilerplateSections.map((s) => s.toLowerCase()));\n\n const sections: CompressedSection[] = [];\n\n for (const section of parsedSections) {\n // 3a. Strip boilerplate\n if (\n options.stripBoilerplate &&\n section.heading &&\n boilerplateSet.has(section.heading.toLowerCase())\n ) {\n continue;\n }\n\n // 3b. Collapse stale headed sections (preserve preamble)\n if (stale && section.heading) {\n const stub = `[Unchanged since ${updatedDate} — ${section.tokens} tokens omitted]`;\n sections.push({\n heading: section.heading,\n content: stub,\n tokens: countTokens(stub),\n compressed: true,\n originalTokens: section.tokens,\n });\n continue;\n }\n\n // 3c. Pass through unchanged\n sections.push({\n heading: section.heading,\n content: section.content,\n tokens: section.tokens,\n compressed: false,\n originalTokens: section.tokens,\n });\n }\n\n return {\n specId,\n type,\n title,\n sections,\n collapsed: false,\n };\n}\n","import { countTokens } from \"@specdx/core\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { compressSpec } from \"./compressor.js\";\nimport type {\n CompressedSpec,\n CompressionOptions,\n PackStats,\n RelevanceScore,\n SpecAllocation,\n} from \"./types.js\";\n\n/** Options for the token allocator. */\nexport interface AllocatorOptions {\n /** Maximum token budget. */\n budget: number;\n /** When true, include full spec content without compression. */\n full: boolean;\n /** Compression settings (used when `full` is false). */\n compression: CompressionOptions;\n}\n\n/** Result of the allocation pass. */\nexport interface AllocationResult {\n /** Compressed specs that fit within the budget. */\n specs: CompressedSpec[];\n /** Statistics about how the budget was spent. */\n stats: PackStats;\n}\n\n/** Relevance at or above which a spec is trimmed to fit rather than excluded. */\nconst HIGH_RELEVANCE = 0.75;\n\n/** Minimum remaining budget worth trimming into. */\nconst MIN_TRIM_BUDGET = 150;\n\n/** Build the marker text for a contiguous run of omitted sections. */\nfunction omissionMarker(sections: CompressedSpec[\"sections\"]): string {\n const names = sections.map((s) => s.heading || \"(untitled)\");\n const noun = names.length === 1 ? \"section\" : \"sections\";\n return `[${names.length} ${noun} omitted to fit token budget: ${names.join(\", \")}]`;\n}\n\n/**\n * Produce a variant of `compressed` that fits within `budget` by keeping\n * sections in order while they fit and replacing each contiguous run of\n * omitted sections with an explicit marker naming them. Marker cost is\n * reserved out of the budget before sections are kept, so markers are always\n * emitted — a trimmed spec must never read as complete (issue #12).\n * Returns null when not even one real section fits.\n */\nfunction trimToBudget(\n compressed: CompressedSpec,\n budget: number,\n): { spec: CompressedSpec; tokens: number } | null {\n const sections = compressed.sections;\n let reserve = 0;\n\n // The kept set only shrinks as the reserve grows, so this converges.\n for (;;) {\n const effective = budget - reserve;\n const keep: boolean[] = new Array(sections.length).fill(false);\n let used = 0;\n let keptReal = false;\n\n for (let i = 0; i < sections.length; i++) {\n if (used + sections[i]!.tokens <= effective) {\n keep[i] = true;\n used += sections[i]!.tokens;\n keptReal = true;\n }\n }\n\n if (!keptReal) return null;\n\n // Group omitted sections into contiguous runs and price their markers.\n interface OmittedRun {\n start: number;\n sections: CompressedSpec[\"sections\"];\n marker: string;\n markerTokens: number;\n }\n const runs: OmittedRun[] = [];\n for (let i = 0; i < sections.length; i++) {\n if (keep[i]) continue;\n const start = i;\n const run: CompressedSpec[\"sections\"] = [];\n while (i < sections.length && !keep[i]) {\n run.push(sections[i]!);\n i++;\n }\n i--;\n const marker = omissionMarker(run);\n runs.push({ start, sections: run, marker, markerTokens: countTokens(marker) });\n }\n\n const markerTokens = runs.reduce((sum, r) => sum + r.markerTokens, 0);\n if (markerTokens > reserve) {\n reserve = markerTokens;\n continue;\n }\n\n // Assemble output: kept sections in order, markers at each cut.\n const out: CompressedSpec[\"sections\"] = [];\n for (let i = 0; i < sections.length; i++) {\n const run = runs.find((r) => r.start === i);\n if (run) {\n out.push({\n heading: \"\",\n content: run.marker,\n tokens: run.markerTokens,\n compressed: true,\n originalTokens: run.sections.reduce((sum, s) => sum + s.tokens, 0),\n omittedSections: run.sections.length,\n });\n i += run.sections.length - 1;\n continue;\n }\n out.push(sections[i]!);\n }\n\n return { spec: { ...compressed, sections: out }, tokens: used + markerTokens };\n }\n}\n\n/**\n * Allocate a token budget across specs, sorted by relevance.\n *\n * 1. Build specId -> ParsedSpec map\n * 2. Compress each spec (or pass through in full mode)\n * 3. Calculate token counts\n * 4. Sort by relevance descending\n * 5. Greedily include specs until budget is exhausted\n * 6. Build stats\n */\nexport function allocate(\n specs: ParsedSpec[],\n scores: RelevanceScore[],\n options: AllocatorOptions,\n): AllocationResult {\n // 1. Build specId -> ParsedSpec map\n const specMap = new Map<string, ParsedSpec>();\n for (const spec of specs) {\n specMap.set(spec.frontmatter.id, spec);\n }\n\n // 2. Compress each scored spec and compute token counts\n interface ScoredCompressed {\n compressed: CompressedSpec;\n relevance: number;\n tokens: number;\n idMatched: boolean;\n }\n\n const items: ScoredCompressed[] = [];\n\n for (const score of scores) {\n const spec = specMap.get(score.specId);\n if (!spec) continue;\n\n let compressed: CompressedSpec;\n\n if (options.full) {\n // No compression: pass through sections unchanged\n compressed = {\n specId: score.specId,\n type: String(spec.frontmatter.type),\n title: String(spec.frontmatter.title),\n sections: spec.parsedSections.map((s) => ({\n heading: s.heading,\n content: s.content,\n tokens: s.tokens,\n compressed: false,\n originalTokens: s.tokens,\n })),\n collapsed: false,\n };\n } else {\n compressed = compressSpec(\n score.specId,\n String(spec.frontmatter.type),\n String(spec.frontmatter.title),\n spec.frontmatter.status as string | undefined,\n spec.frontmatter.updated as string | undefined,\n spec.parsedSections,\n options.compression,\n );\n }\n\n // 3. Calculate token count\n let tokens: number;\n if (compressed.collapsed) {\n tokens = countTokens(compressed.collapsedSummary ?? \"\");\n } else {\n tokens = 0;\n for (const section of compressed.sections) {\n tokens += section.tokens;\n }\n }\n\n items.push({ compressed, relevance: score.score, tokens, idMatched: score.idMatched ?? false });\n }\n\n // 4. Sort by relevance descending; ties prefer specs the task named explicitly\n items.sort((a, b) => b.relevance - a.relevance || Number(b.idMatched) - Number(a.idMatched));\n\n // 5. Greedy selection within budget\n const totalTokens = items.reduce((sum, item) => sum + item.tokens, 0);\n const withinBudget = totalTokens <= options.budget;\n\n const included: ScoredCompressed[] = [];\n const excluded: ScoredCompressed[] = [];\n let usedTokens = 0;\n\n if (withinBudget) {\n // Everything fits\n for (const item of items) {\n included.push(item);\n usedTokens += item.tokens;\n }\n } else {\n // Greedy: include from highest to lowest relevance. High-relevance specs\n // that don't fit are trimmed into the remaining budget before being\n // excluded — a task-named spec should never silently drop out.\n for (const item of items) {\n if (usedTokens + item.tokens <= options.budget) {\n included.push(item);\n usedTokens += item.tokens;\n continue;\n }\n const remaining = options.budget - usedTokens;\n if (\n (item.idMatched || item.relevance >= HIGH_RELEVANCE) &&\n remaining >= MIN_TRIM_BUDGET &&\n !item.compressed.collapsed\n ) {\n const trimmed = trimToBudget(item.compressed, remaining);\n if (trimmed) {\n included.push({ ...item, compressed: trimmed.spec, tokens: trimmed.tokens });\n usedTokens += trimmed.tokens;\n continue;\n }\n }\n excluded.push(item);\n }\n }\n\n // 6. Build stats\n let sectionsCompressed = 0;\n let sectionsOmitted = 0;\n for (const item of included) {\n for (const section of item.compressed.sections) {\n if (section.compressed) {\n sectionsCompressed++;\n }\n sectionsOmitted += section.omittedSections ?? 0;\n }\n }\n\n const allocations: SpecAllocation[] = [];\n\n // Add included specs\n for (const item of included) {\n allocations.push({\n specId: item.compressed.specId,\n type: item.compressed.type,\n relevance: item.relevance,\n tokens: item.tokens,\n compressed: item.compressed.collapsed || item.compressed.sections.some((s) => s.compressed),\n included: true,\n });\n }\n\n // Add excluded specs\n for (const item of excluded) {\n allocations.push({\n specId: item.compressed.specId,\n type: item.compressed.type,\n relevance: item.relevance,\n tokens: item.tokens,\n compressed: item.compressed.collapsed || item.compressed.sections.some((s) => s.compressed),\n included: false,\n });\n }\n\n const stats: PackStats = {\n budget: options.budget,\n used: usedTokens,\n specsIncluded: included.length,\n specsExcluded: excluded.length,\n sectionsCompressed,\n sectionsOmitted,\n allocations,\n };\n\n return {\n specs: included.map((item) => item.compressed),\n stats,\n };\n}\n","import type { CompressedSpec, PackStats } from \"../types.js\";\n\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\n/**\n * Format compressed specs as XML.\n *\n * @param specs - Compressed specs to render.\n * @param stats - Pack statistics with allocation details.\n * @returns An XML string representing the packed context.\n */\nexport function formatXml(specs: CompressedSpec[], stats: PackStats): string {\n const lines: string[] = [];\n\n lines.push(\n `<context budget=\"${stats.budget}\" used=\"${stats.used}\" specs=\"${stats.specsIncluded}\" compressed=\"${stats.sectionsCompressed}\" omitted=\"${stats.sectionsOmitted}\">`,\n );\n\n for (const spec of specs) {\n const alloc = stats.allocations.find((a) => a.specId === spec.specId);\n const relevance = alloc?.relevance ?? 0;\n const tokens = alloc?.tokens ?? 0;\n\n if (spec.collapsed) {\n lines.push(\n ` <spec id=\"${escapeXml(spec.specId)}\" type=\"${escapeXml(spec.type)}\" relevance=\"${relevance}\" tokens=\"${tokens}\" collapsed=\"true\">`,\n );\n lines.push(` ${escapeXml(spec.collapsedSummary ?? \"\")}`);\n lines.push(\" </spec>\");\n } else {\n lines.push(\n ` <spec id=\"${escapeXml(spec.specId)}\" type=\"${escapeXml(spec.type)}\" relevance=\"${relevance}\" tokens=\"${tokens}\">`,\n );\n for (const section of spec.sections) {\n const compressedAttr = section.compressed ? ' compressed=\"true\"' : \"\";\n lines.push(` <section name=\"${escapeXml(section.heading)}\"${compressedAttr}>`);\n lines.push(` ${escapeXml(section.content)}`);\n lines.push(\" </section>\");\n }\n lines.push(\" </spec>\");\n }\n }\n\n lines.push(\"</context>\");\n\n return lines.join(\"\\n\");\n}\n","import type { CompressedSpec, PackStats } from \"../types.js\";\n\n/**\n * Format compressed specs as Markdown.\n *\n * @param specs - Compressed specs to render.\n * @param stats - Pack statistics with allocation details.\n * @returns A Markdown string representing the packed context.\n */\nexport function formatMarkdown(specs: CompressedSpec[], stats: PackStats): string {\n const parts: string[] = [];\n\n for (let i = 0; i < specs.length; i++) {\n const spec = specs[i]!;\n const alloc = stats.allocations.find((a) => a.specId === spec.specId);\n const relevance = alloc?.relevance ?? 0;\n\n if (i > 0) {\n parts.push(\"---\");\n parts.push(\"\");\n }\n\n parts.push(`# ${spec.specId} (${spec.type}) [relevance: ${relevance}]`);\n parts.push(\"\");\n\n if (spec.collapsed) {\n parts.push(spec.collapsedSummary ?? \"\");\n parts.push(\"\");\n } else {\n for (const section of spec.sections) {\n if (section.heading) {\n parts.push(`## ${section.heading}`);\n parts.push(\"\");\n }\n parts.push(section.content);\n parts.push(\"\");\n }\n }\n }\n\n return parts.join(\"\\n\");\n}\n","import type { CompressedSpec, PackStats } from \"../types.js\";\n\ninterface JsonSection {\n name: string;\n content: string;\n compressed: boolean;\n}\n\ninterface JsonSpec {\n id: string;\n type: string;\n relevance: number;\n tokens: number;\n collapsed: boolean;\n summary?: string;\n sections: JsonSection[];\n}\n\ninterface JsonOutput {\n budget: number;\n used: number;\n sectionsOmitted: number;\n specs: JsonSpec[];\n}\n\n/**\n * Format compressed specs as a JSON string.\n *\n * @param specs - Compressed specs to render.\n * @param stats - Pack statistics with allocation details.\n * @returns A pretty-printed JSON string representing the packed context.\n */\nexport function formatJson(specs: CompressedSpec[], stats: PackStats): string {\n const output: JsonOutput = {\n budget: stats.budget,\n used: stats.used,\n sectionsOmitted: stats.sectionsOmitted,\n specs: specs.map((spec) => {\n const alloc = stats.allocations.find((a) => a.specId === spec.specId);\n const relevance = alloc?.relevance ?? 0;\n const tokens = alloc?.tokens ?? 0;\n\n const jsonSpec: JsonSpec = {\n id: spec.specId,\n type: spec.type,\n relevance,\n tokens,\n collapsed: spec.collapsed,\n sections: spec.sections.map((s) => ({\n name: s.heading,\n content: s.content,\n compressed: s.compressed,\n })),\n };\n\n if (spec.collapsed) {\n jsonSpec.summary = spec.collapsedSummary ?? \"\";\n }\n\n return jsonSpec;\n }),\n };\n\n return JSON.stringify(output, null, 2);\n}\n","import type { ParsedSpec, DependencyGraph } from \"@specdx/core\";\nimport type { PackConfig } from \"@specdx/schema\";\nimport type {\n PackOptions,\n PackResult,\n CompressionOptions,\n CompressedSpec,\n RelevanceScore,\n} from \"./types.js\";\nimport { scoreSpecs, scoreSpecsByIds } from \"./resolver.js\";\nimport { allocate } from \"./allocator.js\";\nimport { formatXml } from \"./formatters/xml.js\";\nimport { formatMarkdown } from \"./formatters/markdown.js\";\nimport { formatJson } from \"./formatters/json.js\";\n\nexport type {\n PackOptions,\n PackResult,\n PackStats,\n SpecAllocation,\n RelevanceScore,\n CompressedSpec,\n CompressedSection,\n CompressionOptions,\n} from \"./types.js\";\n\nexport { scoreSpecs, scoreSpecsByIds } from \"./resolver.js\";\nexport { allocate, type AllocatorOptions, type AllocationResult } from \"./allocator.js\";\nexport { compressSpec } from \"./compressor.js\";\nexport { formatXml } from \"./formatters/xml.js\";\nexport { formatMarkdown } from \"./formatters/markdown.js\";\nexport { formatJson } from \"./formatters/json.js\";\n\n/**\n * Default empty dependency graph used when none is provided.\n */\nfunction emptyGraph(): DependencyGraph {\n return {\n nodes: [],\n edges: [],\n topologicalSort: () => [],\n getDownstream: () => [],\n getUpstream: () => [],\n };\n}\n\n/**\n * Build CompressionOptions from PackConfig with sensible defaults.\n */\nfunction buildCompressionOptions(packConfig: PackConfig | undefined): CompressionOptions {\n const compression = packConfig?.compression;\n return {\n stripBoilerplate: compression?.strip_boilerplate ?? true,\n stableDays: compression?.stable_days ?? 7,\n collapseResolvedAdrs: compression?.collapse_resolved_adrs ?? true,\n boilerplateSections: packConfig?.boilerplate_sections ?? [\n \"Changelog\",\n \"Revision History\",\n \"Document History\",\n ],\n };\n}\n\n/**\n * Pack specs into a formatted context string within a token budget.\n *\n * Pipeline:\n * 1. Resolve relevance scores\n * 2. Allocate token budget across specs\n * 3. Format output in the requested format\n */\nexport function pack(\n specs: ParsedSpec[],\n options: PackOptions,\n packConfig: PackConfig | undefined,\n graph: DependencyGraph | undefined,\n): PackResult {\n // 1. Resolve defaults\n const budget = options.budget ?? packConfig?.max_tokens ?? 12000;\n const format = options.format ?? packConfig?.format ?? \"xml\";\n const full = options.full ?? false;\n const compression = buildCompressionOptions(packConfig);\n const resolvedGraph = graph ?? emptyGraph();\n\n // 2. Extract project-context specs and reserve budget\n const projectContextSpecs: ParsedSpec[] = [];\n const regularSpecs: ParsedSpec[] = [];\n for (const spec of specs) {\n if (spec.frontmatter.type === \"project-context\") {\n projectContextSpecs.push(spec);\n } else {\n regularSpecs.push(spec);\n }\n }\n\n let reservedTokens = 0;\n let reservedCompressed: CompressedSpec[] = [];\n if (projectContextSpecs.length > 0) {\n const maxReserved = Math.min(budget, 2000);\n const ctxScores: RelevanceScore[] = projectContextSpecs.map((s) => ({\n specId: s.frontmatter.id,\n score: 1.0,\n rawScore: 1.0,\n matchedKeywords: [],\n graphBoosted: false,\n }));\n const ctxResult = allocate(projectContextSpecs, ctxScores, {\n budget: maxReserved,\n full: true,\n compression,\n });\n reservedCompressed = ctxResult.specs;\n reservedTokens = ctxResult.stats.used;\n }\n\n const regularBudget = Math.max(0, budget - reservedTokens);\n\n // 3. Build spec map for resolver (regular specs only)\n const specMap = new Map<string, ParsedSpec>();\n for (const spec of regularSpecs) {\n specMap.set(spec.frontmatter.id, spec);\n }\n\n // 4. Stage 1 - Resolve\n const scores = options.specs\n ? scoreSpecsByIds(specMap, options.specs, resolvedGraph)\n : scoreSpecs(specMap, options.task, resolvedGraph);\n\n // 5. Stage 2 - Allocate\n const { specs: compressedSpecs, stats } = allocate(regularSpecs, scores, {\n budget: regularBudget,\n full,\n compression,\n });\n\n // 6. Combine project-context and regular specs\n const allCompressed = [...reservedCompressed, ...compressedSpecs];\n\n // Update stats to include reserved specs\n stats.budget = budget;\n stats.used += reservedTokens;\n stats.specsIncluded += reservedCompressed.length;\n for (const ctx of reservedCompressed) {\n stats.allocations.unshift({\n specId: ctx.specId,\n type: ctx.type,\n relevance: 1.0,\n tokens: reservedTokens,\n compressed: false,\n included: true,\n });\n }\n\n // 7. Dry run: return stats without output\n if (options.dryRun) {\n return { output: \"\", stats };\n }\n\n // 8. Stage 3 - Format\n let output: string;\n switch (format) {\n case \"markdown\":\n output = formatMarkdown(allCompressed, stats);\n break;\n case \"json\":\n output = formatJson(allCompressed, stats);\n break;\n default:\n output = formatXml(allCompressed, stats);\n break;\n }\n\n return { output, stats };\n}\n"],"mappings":";;;;;AAMA,IAAM,YAAY,oBAAI,IAAI;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA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ACZ,MAAM,IAAI;MACV,WAAW;MACX,QAAQ;MACR,YAAY;MACZ,UAAU;KACX;EACH;AAGA,MAAI,QAAQ,QAAQ;AAClB,WAAO,EAAE,QAAQ,IAAI,MAAK;EAC5B;AAGA,MAAI;AACJ,UAAQ,QAAQ;IACd,KAAK;AACH,eAAS,eAAe,eAAe,KAAK;AAC5C;IACF,KAAK;AACH,eAAS,WAAW,eAAe,KAAK;AACxC;IACF;AACE,eAAS,UAAU,eAAe,KAAK;AACvC;EACJ;AAEA,SAAO,EAAE,QAAQ,MAAK;AACxB;","names":["results"]}
|
|
@@ -10,6 +10,10 @@ var SPEC_TYPES = [
|
|
|
10
10
|
"quick-spec",
|
|
11
11
|
"project-context"
|
|
12
12
|
];
|
|
13
|
+
var DEPENDENCY_RELATIONSHIPS = {
|
|
14
|
+
"depends-on": "self-requires-target",
|
|
15
|
+
"implemented-by": "target-requires-self"
|
|
16
|
+
};
|
|
13
17
|
|
|
14
18
|
// ../schema/dist/sections.js
|
|
15
19
|
var REQUIRED_SECTIONS = {
|
|
@@ -41,30 +45,123 @@ var base_spec_default = {
|
|
|
41
45
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
42
46
|
type: "object",
|
|
43
47
|
properties: {
|
|
44
|
-
id: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
id: {
|
|
49
|
+
type: "string",
|
|
50
|
+
minLength: 1
|
|
51
|
+
},
|
|
52
|
+
type: {
|
|
53
|
+
type: "string",
|
|
54
|
+
enum: [
|
|
55
|
+
"prd",
|
|
56
|
+
"technical-design",
|
|
57
|
+
"user-story",
|
|
58
|
+
"test-plan",
|
|
59
|
+
"adr",
|
|
60
|
+
"api-contract",
|
|
61
|
+
"epic",
|
|
62
|
+
"quick-spec",
|
|
63
|
+
"project-context"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
title: {
|
|
67
|
+
type: "string",
|
|
68
|
+
minLength: 1
|
|
69
|
+
},
|
|
70
|
+
status: {
|
|
71
|
+
type: "string",
|
|
72
|
+
enum: [
|
|
73
|
+
"draft",
|
|
74
|
+
"review",
|
|
75
|
+
"approved",
|
|
76
|
+
"superseded"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
version: {
|
|
80
|
+
type: "string"
|
|
81
|
+
},
|
|
82
|
+
created: {
|
|
83
|
+
type: "string",
|
|
84
|
+
format: "date"
|
|
85
|
+
},
|
|
86
|
+
updated: {
|
|
87
|
+
type: "string",
|
|
88
|
+
format: "date"
|
|
89
|
+
},
|
|
90
|
+
authors: {
|
|
91
|
+
type: "array",
|
|
92
|
+
items: {
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
minItems: 1
|
|
96
|
+
},
|
|
97
|
+
tags: {
|
|
98
|
+
type: "array",
|
|
99
|
+
items: {
|
|
100
|
+
type: "string"
|
|
101
|
+
},
|
|
102
|
+
default: []
|
|
103
|
+
},
|
|
53
104
|
references: {
|
|
54
105
|
type: "array",
|
|
55
106
|
items: {
|
|
56
107
|
type: "object",
|
|
57
108
|
properties: {
|
|
58
|
-
id: {
|
|
59
|
-
|
|
109
|
+
id: {
|
|
110
|
+
type: "string"
|
|
111
|
+
},
|
|
112
|
+
relationship: {
|
|
113
|
+
type: "string",
|
|
114
|
+
enum: [
|
|
115
|
+
"implemented-by",
|
|
116
|
+
"decomposed-into",
|
|
117
|
+
"depends-on",
|
|
118
|
+
"supersedes",
|
|
119
|
+
"related-to"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
60
122
|
},
|
|
61
|
-
required: [
|
|
123
|
+
required: [
|
|
124
|
+
"id",
|
|
125
|
+
"relationship"
|
|
126
|
+
],
|
|
127
|
+
additionalProperties: false
|
|
128
|
+
},
|
|
129
|
+
default: []
|
|
130
|
+
},
|
|
131
|
+
artifacts: {
|
|
132
|
+
type: "array",
|
|
133
|
+
items: {
|
|
134
|
+
type: "object",
|
|
135
|
+
properties: {
|
|
136
|
+
path: {
|
|
137
|
+
type: "string",
|
|
138
|
+
minLength: 1
|
|
139
|
+
},
|
|
140
|
+
exports: {
|
|
141
|
+
type: "array",
|
|
142
|
+
items: {
|
|
143
|
+
type: "string",
|
|
144
|
+
minLength: 1
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
required: [
|
|
149
|
+
"path"
|
|
150
|
+
],
|
|
62
151
|
additionalProperties: false
|
|
63
152
|
},
|
|
64
153
|
default: []
|
|
65
154
|
}
|
|
66
155
|
},
|
|
67
|
-
required: [
|
|
156
|
+
required: [
|
|
157
|
+
"id",
|
|
158
|
+
"type",
|
|
159
|
+
"title",
|
|
160
|
+
"status",
|
|
161
|
+
"version",
|
|
162
|
+
"created",
|
|
163
|
+
"authors"
|
|
164
|
+
],
|
|
68
165
|
additionalProperties: true
|
|
69
166
|
};
|
|
70
167
|
|
|
@@ -89,7 +186,7 @@ var config_default = {
|
|
|
89
186
|
type: "object",
|
|
90
187
|
properties: {
|
|
91
188
|
path: { type: "string" },
|
|
92
|
-
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
|
|
189
|
+
type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"] },
|
|
93
190
|
required: { type: "boolean", default: false },
|
|
94
191
|
requires: { type: "array", items: { type: "string" } },
|
|
95
192
|
owner: { type: "string" }
|
|
@@ -298,9 +395,13 @@ var project_context_default = {
|
|
|
298
395
|
// ../schema/dist/validator.js
|
|
299
396
|
import * as addFormatsNs from "ajv-formats";
|
|
300
397
|
var addFormats = addFormatsNs.default ?? addFormatsNs;
|
|
398
|
+
var runtimeBaseSpecSchema = structuredClone(base_spec_default);
|
|
399
|
+
runtimeBaseSpecSchema.properties.type.enum = [...SPEC_TYPES];
|
|
400
|
+
var runtimeConfigSchema = structuredClone(config_default);
|
|
401
|
+
runtimeConfigSchema.properties.specs.additionalProperties.properties.type.enum = [...SPEC_TYPES];
|
|
301
402
|
var ajv = new AjvClass({ allErrors: true, strict: true });
|
|
302
403
|
addFormats(ajv, ["date"]);
|
|
303
|
-
ajv.addSchema(
|
|
404
|
+
ajv.addSchema(runtimeBaseSpecSchema);
|
|
304
405
|
var specValidators = {
|
|
305
406
|
prd: ajv.compile(prd_default),
|
|
306
407
|
"technical-design": ajv.compile(technical_design_default),
|
|
@@ -312,7 +413,7 @@ var specValidators = {
|
|
|
312
413
|
"quick-spec": ajv.compile(quick_spec_default),
|
|
313
414
|
"project-context": ajv.compile(project_context_default)
|
|
314
415
|
};
|
|
315
|
-
var configValidator = ajv.compile(
|
|
416
|
+
var configValidator = ajv.compile(runtimeConfigSchema);
|
|
316
417
|
function validateSpec(type, data) {
|
|
317
418
|
const validate = specValidators[type];
|
|
318
419
|
if (!validate) {
|
|
@@ -328,8 +429,9 @@ function validateConfig(data) {
|
|
|
328
429
|
|
|
329
430
|
export {
|
|
330
431
|
SPEC_TYPES,
|
|
432
|
+
DEPENDENCY_RELATIONSHIPS,
|
|
331
433
|
REQUIRED_SECTIONS,
|
|
332
434
|
validateSpec,
|
|
333
435
|
validateConfig
|
|
334
436
|
};
|
|
335
|
-
//# sourceMappingURL=chunk-
|
|
437
|
+
//# sourceMappingURL=chunk-SJCIM4TC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../schema/src/types.ts","../../schema/src/sections.ts","../../schema/src/validator.ts","../../schema/dist/schemas/base-spec.json","../../schema/dist/schemas/config.json","../../schema/dist/schemas/prd.json","../../schema/dist/schemas/technical-design.json","../../schema/dist/schemas/user-story.json","../../schema/dist/schemas/test-plan.json","../../schema/dist/schemas/adr.json","../../schema/dist/schemas/api-contract.json","../../schema/dist/schemas/epic.json","../../schema/dist/schemas/quick-spec.json","../../schema/dist/schemas/project-context.json"],"sourcesContent":["export const SPEC_TYPES = [\n \"prd\",\n \"technical-design\",\n \"user-story\",\n \"test-plan\",\n \"adr\",\n \"api-contract\",\n \"epic\",\n \"quick-spec\",\n \"project-context\",\n] as const;\nexport type SpecType = (typeof SPEC_TYPES)[number];\n\nexport const SPEC_STATUSES = [\"draft\", \"review\", \"approved\", \"superseded\"] as const;\nexport type SpecStatus = (typeof SPEC_STATUSES)[number];\n\n/**\n * Every relationship kind a spec may declare in frontmatter `references`.\n * Single source of truth — `base-spec.json`'s enum is drift-tested against it.\n */\nexport const SPEC_RELATIONSHIPS = [\n \"implemented-by\",\n \"decomposed-into\",\n \"depends-on\",\n \"supersedes\",\n \"related-to\",\n] as const;\nexport type SpecRelationship = (typeof SPEC_RELATIONSHIPS)[number];\n\n/**\n * Which relationship kinds imply a build dependency, and in which direction.\n *\n * Structural kinds are deliberately absent: `decomposed-into` describes a\n * parent/child split and `supersedes` describes lineage — neither means the\n * target depends on the source (issue #13). Declared here rather than in\n * `@specdx/core` so the taxonomy is versioned with the schema it belongs to\n * (ADR: references/requires unification).\n */\nexport const DEPENDENCY_RELATIONSHIPS: Partial<\n Record<SpecRelationship, \"self-requires-target\" | \"target-requires-self\">\n> = {\n \"depends-on\": \"self-requires-target\",\n \"implemented-by\": \"target-requires-self\",\n};\n\nexport interface SpecReference {\n id: string;\n relationship: SpecRelationship;\n}\n\n/** A checkable implementation artifact declared by a spec (issue #15). */\nexport interface SpecArtifact {\n /** Project-root-relative file path that must exist. */\n path: string;\n /** Names that must be exported from the file. */\n exports?: string[];\n}\n\nexport interface BaseSpec {\n id: string;\n type: SpecType;\n title: string;\n status: SpecStatus;\n version: string;\n created: string;\n updated?: string;\n authors: string[];\n tags?: string[];\n references?: SpecReference[];\n artifacts?: SpecArtifact[];\n}\n\nexport interface PrdSpec extends BaseSpec {\n type: \"prd\";\n}\nexport interface TechnicalDesignSpec extends BaseSpec {\n type: \"technical-design\";\n}\nexport interface UserStorySpec extends BaseSpec {\n type: \"user-story\";\n story_id: string;\n priority: \"critical\" | \"high\" | \"medium\" | \"low\";\n estimate: string;\n}\nexport interface TestPlanSpec extends BaseSpec {\n type: \"test-plan\";\n}\nexport interface AdrSpec extends BaseSpec {\n type: \"adr\";\n}\nexport interface ApiContractSpec extends BaseSpec {\n type: \"api-contract\";\n}\n\nexport interface EpicSpec extends BaseSpec {\n type: \"epic\";\n epic_id: string;\n priority: \"critical\" | \"high\" | \"medium\" | \"low\";\n}\n\nexport interface QuickSpecSpec extends BaseSpec {\n type: \"quick-spec\";\n}\n\nexport interface ProjectContextSpec extends BaseSpec {\n type: \"project-context\";\n}\n\nexport type Spec =\n | PrdSpec\n | TechnicalDesignSpec\n | UserStorySpec\n | TestPlanSpec\n | AdrSpec\n | ApiContractSpec\n | EpicSpec\n | QuickSpecSpec\n | ProjectContextSpec;\n\nexport interface SpecEntry {\n path: string;\n type: SpecType;\n required?: boolean;\n requires?: string[];\n owner?: string;\n}\n\nexport interface PackCompressionConfig {\n strip_boilerplate?: boolean;\n stable_days?: number;\n collapse_resolved_adrs?: boolean;\n}\n\nexport interface PackConfig {\n max_tokens?: number;\n format?: \"xml\" | \"markdown\" | \"json\";\n compression?: PackCompressionConfig;\n boilerplate_sections?: string[];\n}\n\nexport interface SdxConfig {\n version: string;\n project?: { name?: string; description?: string };\n specs: Record<string, SpecEntry>;\n lint?: {\n extends?: string;\n rules?: Record<string, unknown>;\n ignore?: string[];\n };\n pack?: PackConfig;\n diff?: {\n baseline_ref?: string;\n staleness_threshold_days?: number;\n ignore_paths?: string[];\n };\n ci?: {\n block_on?: (\"error\" | \"warn\" | \"info\")[];\n post_comment?: boolean;\n update_badge?: boolean;\n trigger_paths?: string[];\n };\n check?: {\n framework?: \"auto\" | \"express\" | \"hono\" | \"nextjs\";\n routes_dir?: string;\n app_dir?: string;\n types_dir?: string;\n tests_dir?: string;\n ignore?: string[];\n };\n}\n","import type { SpecType } from \"./types.js\";\n\nexport const REQUIRED_SECTIONS: Record<SpecType, string[]> = {\n prd: [\"Problem Statement\", \"Goals\", \"Non-Goals\", \"Features\", \"Success Criteria\"],\n \"technical-design\": [\n \"Overview\",\n \"Architecture\",\n \"Data Model\",\n \"API Design\",\n \"Dependencies\",\n \"Risks\",\n \"Open Questions\",\n ],\n \"user-story\": [\"Description\", \"Acceptance Criteria\", \"Dependencies\", \"Notes\"],\n \"test-plan\": [\"Scope\", \"Test Cases\", \"Coverage Matrix\", \"Edge Cases\"],\n adr: [\"Context\", \"Decision\", \"Status\", \"Consequences\"],\n \"api-contract\": [\"Endpoints\", \"Request/Response Schemas\", \"Auth\", \"Error Codes\"],\n epic: [\"Overview\", \"Stories\", \"Acceptance Criteria\", \"Dependencies\"],\n \"quick-spec\": [\"Intent\", \"Boundaries\", \"Tasks\"],\n \"project-context\": [\"Technology Stack\", \"Critical Implementation Rules\", \"Coding Patterns\"],\n};\n","import { Ajv as AjvClass, type ErrorObject } from \"ajv\";\nimport { SPEC_TYPES, type SpecType } from \"./types.js\";\n\nimport baseSpecSchema from \"./schemas/base-spec.json\" with { type: \"json\" };\nimport configSchema from \"./schemas/config.json\" with { type: \"json\" };\nimport prdSchema from \"./schemas/prd.json\" with { type: \"json\" };\nimport technicalDesignSchema from \"./schemas/technical-design.json\" with { type: \"json\" };\nimport userStorySchema from \"./schemas/user-story.json\" with { type: \"json\" };\nimport testPlanSchema from \"./schemas/test-plan.json\" with { type: \"json\" };\nimport adrSchema from \"./schemas/adr.json\" with { type: \"json\" };\nimport apiContractSchema from \"./schemas/api-contract.json\" with { type: \"json\" };\nimport epicSchema from \"./schemas/epic.json\" with { type: \"json\" };\nimport quickSpecSchema from \"./schemas/quick-spec.json\" with { type: \"json\" };\nimport projectContextSchema from \"./schemas/project-context.json\" with { type: \"json\" };\n\n// addFormats is CJS-only; access via the namespace default at runtime\n// The type cast is needed because TypeScript's NodeNext resolution exposes\n// the CJS module as a namespace without a callable default signature.\nimport * as addFormatsNs from \"ajv-formats\";\ntype AddFormatsPlugin = (ajv: AjvClass, formats?: unknown) => AjvClass;\nconst addFormats = ((addFormatsNs as unknown as { default?: AddFormatsPlugin }).default ??\n (addFormatsNs as unknown as AddFormatsPlugin)) as AddFormatsPlugin;\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ErrorObject[] | null;\n}\n\n// The JSON schemas duplicate the spec-type enum for editor and schema-store\n// consumers. At runtime SPEC_TYPES is the single source of truth: the enums are\n// overwritten before compilation so the JSON copies can never drift from the\n// TypeScript types (see issue #2 — a stale enum shipped in 0.4.0-alpha.2).\nconst runtimeBaseSpecSchema = structuredClone(baseSpecSchema);\nruntimeBaseSpecSchema.properties.type.enum = [...SPEC_TYPES];\nconst runtimeConfigSchema = structuredClone(configSchema);\nruntimeConfigSchema.properties.specs.additionalProperties.properties.type.enum = [...SPEC_TYPES];\n\nconst ajv = new AjvClass({ allErrors: true, strict: true });\naddFormats(ajv, [\"date\"]);\najv.addSchema(runtimeBaseSpecSchema);\n\nconst specValidators: Record<string, ReturnType<typeof ajv.compile>> = {\n prd: ajv.compile(prdSchema),\n \"technical-design\": ajv.compile(technicalDesignSchema),\n \"user-story\": ajv.compile(userStorySchema),\n \"test-plan\": ajv.compile(testPlanSchema),\n adr: ajv.compile(adrSchema),\n \"api-contract\": ajv.compile(apiContractSchema),\n epic: ajv.compile(epicSchema),\n \"quick-spec\": ajv.compile(quickSpecSchema),\n \"project-context\": ajv.compile(projectContextSchema),\n};\n\nconst configValidator = ajv.compile(runtimeConfigSchema);\n\nexport function validateSpec(type: SpecType, data: Record<string, unknown>): ValidationResult {\n const validate = specValidators[type];\n if (!validate) {\n return { valid: false, errors: [{ message: `Unknown spec type: \"${type}\"` } as ErrorObject] };\n }\n const valid = validate(data);\n return { valid: !!valid, errors: valid ? null : (validate.errors ?? null) };\n}\n\nexport function validateConfig(data: Record<string, unknown>): ValidationResult {\n const valid = configValidator(data);\n return { valid: !!valid, errors: valid ? null : (configValidator.errors ?? null) };\n}\n","{\n \"$id\": \"base-spec\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"minLength\": 1\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"prd\",\n \"technical-design\",\n \"user-story\",\n \"test-plan\",\n \"adr\",\n \"api-contract\",\n \"epic\",\n \"quick-spec\",\n \"project-context\"\n ]\n },\n \"title\": {\n \"type\": \"string\",\n \"minLength\": 1\n },\n \"status\": {\n \"type\": \"string\",\n \"enum\": [\n \"draft\",\n \"review\",\n \"approved\",\n \"superseded\"\n ]\n },\n \"version\": {\n \"type\": \"string\"\n },\n \"created\": {\n \"type\": \"string\",\n \"format\": \"date\"\n },\n \"updated\": {\n \"type\": \"string\",\n \"format\": \"date\"\n },\n \"authors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"minItems\": 1\n },\n \"tags\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"default\": []\n },\n \"references\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"relationship\": {\n \"type\": \"string\",\n \"enum\": [\n \"implemented-by\",\n \"decomposed-into\",\n \"depends-on\",\n \"supersedes\",\n \"related-to\"\n ]\n }\n },\n \"required\": [\n \"id\",\n \"relationship\"\n ],\n \"additionalProperties\": false\n },\n \"default\": []\n },\n \"artifacts\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": {\n \"type\": \"string\",\n \"minLength\": 1\n },\n \"exports\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\",\n \"minLength\": 1\n }\n }\n },\n \"required\": [\n \"path\"\n ],\n \"additionalProperties\": false\n },\n \"default\": []\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"title\",\n \"status\",\n \"version\",\n \"created\",\n \"authors\"\n ],\n \"additionalProperties\": true\n}\n","{\n \"$id\": \"sdx-config\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"version\": { \"type\": \"string\" },\n \"project\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": { \"type\": \"string\" },\n \"description\": { \"type\": \"string\" }\n },\n \"additionalProperties\": false\n },\n \"specs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": { \"type\": \"string\" },\n \"type\": { \"type\": \"string\", \"enum\": [\"prd\", \"technical-design\", \"user-story\", \"test-plan\", \"adr\", \"api-contract\", \"epic\", \"quick-spec\", \"project-context\"] },\n \"required\": { \"type\": \"boolean\", \"default\": false },\n \"requires\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } },\n \"owner\": { \"type\": \"string\" }\n },\n \"required\": [\"path\", \"type\"],\n \"additionalProperties\": false\n }\n },\n \"lint\": {\n \"type\": \"object\",\n \"properties\": {\n \"extends\": { \"type\": \"string\" },\n \"rules\": { \"type\": \"object\" },\n \"ignore\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"additionalProperties\": false\n },\n \"pack\": {\n \"type\": \"object\",\n \"properties\": {\n \"max_tokens\": { \"type\": \"integer\", \"minimum\": 1 },\n \"format\": { \"type\": \"string\", \"enum\": [\"xml\", \"markdown\", \"json\"] },\n \"compression\": {\n \"type\": \"object\",\n \"properties\": {\n \"strip_boilerplate\": { \"type\": \"boolean\" },\n \"stable_days\": { \"type\": \"integer\", \"minimum\": 0 },\n \"collapse_resolved_adrs\": { \"type\": \"boolean\" }\n },\n \"additionalProperties\": false\n },\n \"boilerplate_sections\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" }\n }\n },\n \"additionalProperties\": false\n },\n \"diff\": {\n \"type\": \"object\",\n \"properties\": {\n \"baseline_ref\": { \"type\": \"string\", \"default\": \"main\" },\n \"staleness_threshold_days\": { \"type\": \"integer\", \"minimum\": 1, \"default\": 14 },\n \"ignore_paths\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"additionalProperties\": false\n },\n \"ci\": {\n \"type\": \"object\",\n \"properties\": {\n \"block_on\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\", \"enum\": [\"error\", \"warn\", \"info\"] }\n },\n \"post_comment\": { \"type\": \"boolean\", \"default\": true },\n \"update_badge\": { \"type\": \"boolean\", \"default\": true },\n \"trigger_paths\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" }\n }\n },\n \"additionalProperties\": false\n },\n \"check\": {\n \"type\": \"object\",\n \"properties\": {\n \"framework\": {\n \"type\": \"string\",\n \"enum\": [\"auto\", \"express\", \"hono\", \"nextjs\"]\n },\n \"routes_dir\": { \"type\": \"string\" },\n \"app_dir\": { \"type\": \"string\" },\n \"types_dir\": { \"type\": \"string\" },\n \"tests_dir\": { \"type\": \"string\" },\n \"ignore\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" }\n }\n },\n \"additionalProperties\": false\n }\n },\n \"required\": [\"version\", \"specs\"],\n \"additionalProperties\": false\n}\n","{\n \"$id\": \"prd\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"prd\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"technical-design\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"technical-design\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"user-story\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"user-story\" },\n \"story_id\": { \"type\": \"string\", \"minLength\": 1 },\n \"priority\": { \"type\": \"string\", \"enum\": [\"critical\", \"high\", \"medium\", \"low\"] },\n \"estimate\": { \"type\": \"string\" }\n },\n \"required\": [\"type\", \"story_id\", \"priority\", \"estimate\"]\n }\n ]\n}\n","{\n \"$id\": \"test-plan\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"test-plan\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"adr\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"adr\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"api-contract\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"api-contract\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"epic\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"epic\" },\n \"epic_id\": { \"type\": \"string\", \"minLength\": 1 },\n \"priority\": { \"type\": \"string\", \"enum\": [\"critical\", \"high\", \"medium\", \"low\"] }\n },\n \"required\": [\"type\", \"epic_id\", \"priority\"]\n }\n ]\n}\n","{\n \"$id\": \"quick-spec\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"quick-spec\" }\n },\n \"required\": [\"type\"]\n }\n ]\n}\n","{\n \"$id\": \"project-context\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"project-context\" }\n },\n \"required\": [\"type\"]\n }\n ]\n}\n"],"mappings":";AAAO,IAAM,aAAa;EACxB;EACA;EACA;EACA;EACA;EACA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QAAQ,QAAQ,OAAQ,gBAAgB,UAAU,KAAK;AAClF;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
buildRelationResolver,
|
|
3
3
|
loadConfig,
|
|
4
4
|
parseSpecFromString
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Z77VQUZ3.js";
|
|
6
6
|
|
|
7
7
|
// ../diff/dist/types.js
|
|
8
8
|
var DEFAULT_DIFF_CONFIG = {
|
|
@@ -896,10 +896,10 @@ var STRUCTURAL_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
896
896
|
"API Design",
|
|
897
897
|
"Problem Statement"
|
|
898
898
|
]);
|
|
899
|
-
function bfsDistances(startId,
|
|
899
|
+
function bfsDistances(startId, relations) {
|
|
900
900
|
const distances = /* @__PURE__ */ new Map();
|
|
901
901
|
const queue = [];
|
|
902
|
-
for (const edge of
|
|
902
|
+
for (const edge of relations.edges) {
|
|
903
903
|
if (edge.from === startId) {
|
|
904
904
|
if (!distances.has(edge.to)) {
|
|
905
905
|
distances.set(edge.to, 1);
|
|
@@ -910,7 +910,7 @@ function bfsDistances(startId, graph) {
|
|
|
910
910
|
while (queue.length > 0) {
|
|
911
911
|
const item = queue.shift();
|
|
912
912
|
const currentDist = item.distance;
|
|
913
|
-
for (const edge of
|
|
913
|
+
for (const edge of relations.edges) {
|
|
914
914
|
if (edge.from === item.id && !distances.has(edge.to)) {
|
|
915
915
|
distances.set(edge.to, currentDist + 1);
|
|
916
916
|
queue.push({ id: edge.to, distance: currentDist + 1 });
|
|
@@ -927,8 +927,8 @@ function daysBetween(dateStr) {
|
|
|
927
927
|
function clamp(min, max, value) {
|
|
928
928
|
return Math.min(max, Math.max(min, value));
|
|
929
929
|
}
|
|
930
|
-
function analyzeImpact(changedSpecId, diff2,
|
|
931
|
-
const distanceMap = bfsDistances(changedSpecId,
|
|
930
|
+
function analyzeImpact(changedSpecId, diff2, relations, allSpecs, thresholdDays = 14) {
|
|
931
|
+
const distanceMap = bfsDistances(changedSpecId, relations);
|
|
932
932
|
if (distanceMap.size === 0) {
|
|
933
933
|
return {
|
|
934
934
|
changedSpec: changedSpecId,
|
|
@@ -1099,20 +1099,24 @@ async function diffBetweenRefs(configPath, baseRef, headRef) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
const added = changed.added.map((p) => specIdByPath.get(p)).filter((id) => id !== void 0);
|
|
1101
1101
|
const removed = changed.deleted.map((p) => specIdByPath.get(p)).filter((id) => id !== void 0);
|
|
1102
|
-
const graph = buildGraph(config);
|
|
1103
1102
|
const impact = [];
|
|
1104
1103
|
const allSpecs = [];
|
|
1105
|
-
|
|
1104
|
+
const specsByEntry = /* @__PURE__ */ new Map();
|
|
1105
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
1106
|
+
const forEntry = [];
|
|
1106
1107
|
try {
|
|
1107
1108
|
const content = gitShow(headRef, entry.path, projectRoot, repoRoot);
|
|
1108
1109
|
const parsed = await parseSpecFromString(content, entry.path);
|
|
1110
|
+
forEntry.push(parsed);
|
|
1109
1111
|
allSpecs.push(parsed);
|
|
1110
1112
|
} catch {
|
|
1111
1113
|
}
|
|
1114
|
+
specsByEntry.set(key, forEntry);
|
|
1112
1115
|
}
|
|
1116
|
+
const relations = buildRelationResolver(config, specsByEntry);
|
|
1113
1117
|
const thresholdDays = config.diff?.staleness_threshold_days ?? 14;
|
|
1114
1118
|
for (const diff2 of diffs) {
|
|
1115
|
-
const analysis = analyzeImpact(diff2.specId, diff2,
|
|
1119
|
+
const analysis = analyzeImpact(diff2.specId, diff2, relations, allSpecs, thresholdDays);
|
|
1116
1120
|
if (analysis.totalAffected > 0) {
|
|
1117
1121
|
impact.push(analysis);
|
|
1118
1122
|
}
|
|
@@ -1144,4 +1148,4 @@ export {
|
|
|
1144
1148
|
DiffError,
|
|
1145
1149
|
diffBetweenRefs
|
|
1146
1150
|
};
|
|
1147
|
-
//# sourceMappingURL=chunk-
|
|
1151
|
+
//# sourceMappingURL=chunk-VMMTEGYN.js.map
|