specdx 0.4.0-alpha.15 → 0.4.0-alpha.17
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/.claude-plugin/plugin.json +2 -2
- package/dist/{check-6ULNLONS.js → check-Q3QKTN2D.js} +4 -4
- package/dist/check-Q3QKTN2D.js.map +1 -0
- package/dist/{chunk-SDDTD4R3.js → chunk-TF7WSPFV.js} +31 -11
- package/dist/chunk-TF7WSPFV.js.map +1 -0
- package/dist/chunk-TJPPBM24.js +179 -0
- package/dist/chunk-TJPPBM24.js.map +1 -0
- package/dist/{diff-AWFDXYX4.js → diff-IEN6W4OG.js} +3 -3
- package/dist/diff-IEN6W4OG.js.map +1 -0
- package/dist/{dist-2YMKBA6A.js → dist-DVROIZAO.js} +2 -2
- package/dist/generate-GQPOLFP7.js +21 -0
- package/dist/generate-GQPOLFP7.js.map +1 -0
- package/dist/{generate-story-OV3PFJN6.js → generate-story-UJS37FHA.js} +2 -2
- package/dist/generate-story-UJS37FHA.js.map +1 -0
- package/dist/{generate-test-plan-OGWEIXR2.js → generate-test-plan-RQTSGQLR.js} +3 -3
- package/dist/generate-test-plan-RQTSGQLR.js.map +1 -0
- package/dist/{graph-KZDCVMLT.js → graph-OKUMHR3Q.js} +2 -2
- package/dist/graph-OKUMHR3Q.js.map +1 -0
- package/dist/index.js +39 -120
- package/dist/index.js.map +1 -1
- package/dist/{lint-A5AXYDSO.js → lint-VB5PV32N.js} +3 -3
- package/dist/lint-VB5PV32N.js.map +1 -0
- package/dist/main.js +7 -143
- package/dist/main.js.map +1 -1
- package/dist/{mcp-CWJKX27S.js → mcp-DADOVCEV.js} +3 -3
- package/dist/mcp-DADOVCEV.js.map +1 -0
- package/dist/{migrate-76BXVREF.js → migrate-LAMRDT3V.js} +3 -3
- package/dist/migrate-LAMRDT3V.js.map +1 -0
- package/dist/{pack-I5WFM6B6.js → pack-B3KYRKUR.js} +3 -3
- package/dist/pack-B3KYRKUR.js.map +1 -0
- package/dist/{ready-2M5HXTRZ.js → ready-C6YXJ47W.js} +2 -2
- package/dist/ready-C6YXJ47W.js.map +1 -0
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/SKILL.md +4 -0
- package/dist/skills/{specdx-onboard → core/specdx-onboard}/SKILL.md +7 -2
- package/dist/skills/{specdx-plan-from-spec → core/specdx-plan-from-spec}/SKILL.md +4 -0
- package/dist/skills/{specdx-pre-commit → core/specdx-pre-commit}/SKILL.md +4 -0
- package/dist/skills/{specdx-review-spec → core/specdx-review-spec}/SKILL.md +4 -0
- package/dist/skills/core/specdx-router/SKILL.md +67 -0
- package/dist/skills/{specdx-sprint-review → core/specdx-sprint-review}/SKILL.md +4 -0
- package/dist/skills/{specdx-start-task → core/specdx-start-task}/SKILL.md +4 -0
- package/dist/skills/{specdx-check-drift → experimental/specdx-check-drift}/SKILL.md +4 -0
- package/dist/skills/{specdx-verify → experimental/specdx-verify}/SKILL.md +4 -0
- package/dist/{skills-N7ZDWOJM.js → skills-LHFTTEJ7.js} +21 -11
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-QLG3ZKS7.js → status-BRLCD7NY.js} +2 -2
- package/dist/status-BRLCD7NY.js.map +1 -0
- package/dist/{update-HGZVLKSL.js → update-P6TQUI6H.js} +3 -3
- package/dist/update-P6TQUI6H.js.map +1 -0
- package/dist/{validate-HMOCZJ2M.js → validate-WIB246IE.js} +2 -2
- package/dist/validate-WIB246IE.js.map +1 -0
- package/package.json +5 -5
- package/dist/check-6ULNLONS.js.map +0 -1
- package/dist/chunk-SDDTD4R3.js.map +0 -1
- package/dist/diff-AWFDXYX4.js.map +0 -1
- package/dist/explain-M2VXXXGP.js +0 -113
- package/dist/explain-M2VXXXGP.js.map +0 -1
- package/dist/generate-XG52JCWH.js +0 -15
- package/dist/generate-XG52JCWH.js.map +0 -1
- package/dist/generate-story-OV3PFJN6.js.map +0 -1
- package/dist/generate-test-plan-OGWEIXR2.js.map +0 -1
- package/dist/graph-KZDCVMLT.js.map +0 -1
- package/dist/lint-A5AXYDSO.js.map +0 -1
- package/dist/mcp-CWJKX27S.js.map +0 -1
- package/dist/migrate-76BXVREF.js.map +0 -1
- package/dist/pack-I5WFM6B6.js.map +0 -1
- package/dist/ready-2M5HXTRZ.js.map +0 -1
- package/dist/skills-N7ZDWOJM.js.map +0 -1
- package/dist/status-QLG3ZKS7.js.map +0 -1
- package/dist/update-HGZVLKSL.js.map +0 -1
- package/dist/validate-HMOCZJ2M.js.map +0 -1
- /package/dist/{dist-2YMKBA6A.js.map → dist-DVROIZAO.js.map} +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/spec-type-reference.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-01-frontmatter.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-02-sections.md +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec}/references/step-03-finalize.md +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specdx",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.17",
|
|
4
4
|
"description": "Spec-driven development skills for Claude Code",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "umxr",
|
|
7
7
|
"url": "https://github.com/umxr"
|
|
8
8
|
},
|
|
9
|
-
"skills": "./dist/skills",
|
|
9
|
+
"skills": "./dist/skills/core",
|
|
10
10
|
"hooks": "./hooks/hooks.json"
|
|
11
11
|
}
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
import "./chunk-SJCIM4TC.js";
|
|
14
14
|
import "./chunk-5WRI5ZAA.js";
|
|
15
15
|
|
|
16
|
-
// src/commands/check.ts
|
|
16
|
+
// src/commands/experimental/check.ts
|
|
17
17
|
import { defineCommand } from "citty";
|
|
18
18
|
var check_default = defineCommand({
|
|
19
19
|
meta: {
|
|
20
20
|
name: "check",
|
|
21
|
-
description: "
|
|
21
|
+
description: "Check spec-to-implementation drift. Exit codes: 0 ok, 1 errors found, 3 nothing checkable (coverage not assessed)"
|
|
22
22
|
},
|
|
23
23
|
args: {
|
|
24
24
|
...sharedArgs,
|
|
@@ -26,7 +26,7 @@ var check_default = defineCommand({
|
|
|
26
26
|
framework: { type: "string", description: "Framework override: express, hono, nextjs" },
|
|
27
27
|
ai: {
|
|
28
28
|
type: "boolean",
|
|
29
|
-
description: "
|
|
29
|
+
description: "Use AI to assess findings (requires ANTHROPIC_API_KEY)"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
async run({ args }) {
|
|
@@ -134,4 +134,4 @@ var check_default = defineCommand({
|
|
|
134
134
|
export {
|
|
135
135
|
check_default as default
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=check-
|
|
137
|
+
//# sourceMappingURL=check-Q3QKTN2D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/experimental/check.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport type { CheckConfig } from \"@specdx/check\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport default defineCommand({\n meta: {\n name: \"check\",\n description:\n \"Check spec-to-implementation drift. Exit codes: 0 ok, 1 errors found, 3 nothing checkable (coverage not assessed)\",\n },\n args: {\n ...sharedArgs,\n spec: { type: \"string\", description: \"Check a specific spec by ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\n ai: {\n type: \"boolean\",\n description: \"Use AI to assess findings (requires ANTHROPIC_API_KEY)\",\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n logger.debug(\"Loading specs...\");\n\n // Resolve and parse all specs\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n if (args.spec && spec.frontmatter.id !== args.spec) continue;\n specs.push(spec);\n }\n }\n\n const checkConfig: CheckConfig = {\n ...config.check,\n ...(args.framework ? { framework: args.framework as CheckConfig[\"framework\"] } : {}),\n };\n\n logger.debug(`Checking ${specs.length} specs...`);\n const result = await runCheck(specs, configDir, checkConfig);\n\n // AI analysis (opt-in)\n if (args.ai) {\n const { analyzeWithAi } = await import(\"@specdx/check\");\n const aiResult = await analyzeWithAi(result.findings, args.spec ?? \"full suite check\");\n\n if (args.format === \"json\") {\n console.log(JSON.stringify({ ...result, ai: aiResult }, null, 2));\n } else {\n console.log(`\\n sdx check --ai — ${result.score.overall}% coverage\\n`);\n console.log(` AI Assessment: ${aiResult.summary}\\n`);\n\n for (const assessment of aiResult.assessments) {\n const finding = result.findings[assessment.findingIndex];\n if (!finding) continue;\n const icon = assessment.isRealIssue ? \"✗\" : \"✓\";\n const label = assessment.isRealIssue ? \"REAL\" : \"FALSE POSITIVE\";\n console.log(` ${icon} [${label}] ${finding.expected}`);\n console.log(` ${assessment.reasoning}`);\n if (assessment.suggestedFix) {\n console.log(` Fix: ${assessment.suggestedFix}`);\n }\n }\n console.log();\n }\n\n if (aiResult.assessments.some((a) => a.isRealIssue)) {\n process.exit(1);\n }\n return;\n }\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n } else {\n // Pretty format\n const headline = result.score.assessed\n ? `${result.score.overall}% implementation coverage`\n : \"coverage not assessed — no checkable surfaces found\";\n console.log(`\\n sdx check — ${headline}\\n`);\n\n for (const note of result.notes) {\n console.log(` ⚠ ${note}`);\n }\n if (result.notes.length > 0) console.log();\n\n if (args.verbose) {\n const fmt = (n: number | null) => (n === null ? \"not scanned\" : `${n} found`);\n console.log(` Scanned: framework=${result.scanned.framework ?? \"none detected\"}`);\n console.log(` routes: ${fmt(result.scanned.codeRoutes)}`);\n console.log(` types: ${fmt(result.scanned.codeTypes)}`);\n console.log(` tests: ${fmt(result.scanned.codeTests)}`);\n const artifacts =\n result.scanned.artifacts === null\n ? \"none declared\"\n : `${result.scanned.artifacts} verified`;\n const pending =\n result.scanned.artifactsPending > 0 ? `, ${result.scanned.artifactsPending} pending` : \"\";\n console.log(` artifacts: ${artifacts}${pending}\\n`);\n }\n\n for (const [category, stats] of Object.entries(result.score.byCategory)) {\n if (stats.total === 0) continue;\n console.log(` ${category} (${stats.matched}/${stats.total}):`);\n const categoryFindings = result.findings.filter(\n (f) => f.category === category.replace(/s$/, \"\"),\n );\n for (const f of categoryFindings) {\n const icon = f.severity === \"error\" ? \"✗\" : f.severity === \"warn\" ? \"⚠\" : \"ℹ\";\n const detail = f.actual ? ` — ${f.actual}` : \"\";\n const suggestion = f.suggestion ? ` (${f.suggestion})` : \"\";\n console.log(` ${icon} ${f.expected}${detail}${suggestion}`);\n }\n if (categoryFindings.length === 0) {\n console.log(\" ✓ all matched\");\n }\n }\n\n const errors = result.findings.filter((f) => f.severity === \"error\").length;\n const warnings = result.findings.filter((f) => f.severity === \"warn\").length;\n const info = result.findings.filter((f) => f.severity === \"info\").length;\n console.log(`\\n ${errors} errors, ${warnings} warnings, ${info} info\\n`);\n }\n\n if (result.findings.some((f) => f.severity === \"error\")) {\n process.exit(1);\n }\n // Distinct exit code so CI cannot mistake \"nothing was checkable\" for a pass\n if (!result.score.assessed) {\n process.exit(3);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAO9B,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACJ,GAAG;AAAA,IACH,MAAM,EAAE,MAAM,UAAU,aAAa,8BAA8B;AAAA,IACnE,WAAW,EAAE,MAAM,UAAU,aAAa,4CAA4C;AAAA,IACtF,IAAI;AAAA,MAC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KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,CAAC,OAAO,MAAM,UAAU;AAC1B,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -360,12 +360,18 @@ function allocate(specs, scores, options) {
|
|
|
360
360
|
for (const spec of specs) {
|
|
361
361
|
specMap.set(spec.frontmatter.id, spec);
|
|
362
362
|
}
|
|
363
|
+
function tokensOf(compressed) {
|
|
364
|
+
if (compressed.collapsed)
|
|
365
|
+
return countTokens(compressed.collapsedSummary ?? "");
|
|
366
|
+
return compressed.sections.reduce((sum, section) => sum + section.tokens, 0);
|
|
367
|
+
}
|
|
363
368
|
const items = [];
|
|
364
369
|
for (const score of scores) {
|
|
365
370
|
const spec = specMap.get(score.specId);
|
|
366
371
|
if (!spec)
|
|
367
372
|
continue;
|
|
368
373
|
let compressed;
|
|
374
|
+
let stale;
|
|
369
375
|
if (options.full) {
|
|
370
376
|
compressed = {
|
|
371
377
|
specId: score.specId,
|
|
@@ -381,20 +387,34 @@ function allocate(specs, scores, options) {
|
|
|
381
387
|
collapsed: false
|
|
382
388
|
};
|
|
383
389
|
} else {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
tokens += section.tokens;
|
|
390
|
+
const compress = (compression) => compressSpec(score.specId, String(spec.frontmatter.type), String(spec.frontmatter.title), spec.frontmatter.status, spec.frontmatter.updated, spec.parsedSections, compression);
|
|
391
|
+
compressed = compress({ ...options.compression, stableDays: 0 });
|
|
392
|
+
if (options.compression.stableDays > 0) {
|
|
393
|
+
const collapsed = compress(options.compression);
|
|
394
|
+
const collapsedTokens = tokensOf(collapsed);
|
|
395
|
+
if (collapsedTokens < tokensOf(compressed)) {
|
|
396
|
+
stale = { spec: collapsed, tokens: collapsedTokens };
|
|
397
|
+
}
|
|
393
398
|
}
|
|
394
399
|
}
|
|
395
|
-
items.push({
|
|
400
|
+
items.push({
|
|
401
|
+
compressed,
|
|
402
|
+
relevance: score.score,
|
|
403
|
+
tokens: tokensOf(compressed),
|
|
404
|
+
idMatched: score.idMatched ?? false,
|
|
405
|
+
stale
|
|
406
|
+
});
|
|
396
407
|
}
|
|
397
408
|
items.sort((a, b) => b.relevance - a.relevance || Number(b.idMatched) - Number(a.idMatched));
|
|
409
|
+
let projected = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
410
|
+
for (let i = items.length - 1; i >= 0 && projected > options.budget; i--) {
|
|
411
|
+
const item = items[i];
|
|
412
|
+
if (!item.stale)
|
|
413
|
+
continue;
|
|
414
|
+
projected -= item.tokens - item.stale.tokens;
|
|
415
|
+
item.compressed = item.stale.spec;
|
|
416
|
+
item.tokens = item.stale.tokens;
|
|
417
|
+
}
|
|
398
418
|
const totalTokens = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
399
419
|
const withinBudget = totalTokens <= options.budget;
|
|
400
420
|
const included = [];
|
|
@@ -664,4 +684,4 @@ function pack(specs, options, packConfig, graph) {
|
|
|
664
684
|
export {
|
|
665
685
|
pack
|
|
666
686
|
};
|
|
667
|
-
//# sourceMappingURL=chunk-
|
|
687
|
+
//# sourceMappingURL=chunk-TF7WSPFV.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 * Staleness-collapsed variant, spent only under budget pressure (issue #33).\n * Undefined when there is nothing to collapse, or in full mode.\n */\n stale?: { spec: CompressedSpec; tokens: number };\n }\n\n function tokensOf(compressed: CompressedSpec): number {\n if (compressed.collapsed) return countTokens(compressed.collapsedSummary ?? \"\");\n return compressed.sections.reduce((sum, section) => sum + section.tokens, 0);\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 let stale: ScoredCompressed[\"stale\"];\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 const compress = (compression: CompressionOptions): CompressedSpec =>\n 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 compression,\n );\n\n // Boilerplate stripping and superseded-ADR collapse are hygiene, not\n // budget management -- they apply either way. Only the staleness collapse\n // is held back until the budget actually needs it.\n compressed = compress({ ...options.compression, stableDays: 0 });\n\n if (options.compression.stableDays > 0) {\n const collapsed = compress(options.compression);\n const collapsedTokens = tokensOf(collapsed);\n if (collapsedTokens < tokensOf(compressed)) {\n stale = { spec: collapsed, tokens: collapsedTokens };\n }\n }\n }\n\n items.push({\n compressed,\n relevance: score.score,\n tokens: tokensOf(compressed),\n idMatched: score.idMatched ?? false,\n stale,\n });\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 // 4b. Collapse stale specs only while the budget is short, least relevant\n // first. Compression is a response to pressure: applied without it, the\n // caller asked for context and got stubs against a barely-touched budget.\n let projected = items.reduce((sum, item) => sum + item.tokens, 0);\n for (let i = items.length - 1; i >= 0 && projected > options.budget; i--) {\n const item = items[i]!;\n if (!item.stale) continue;\n projected -= item.tokens - item.stale.tokens;\n item.compressed = item.stale.spec;\n item.tokens = item.stale.tokens;\n }\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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AAGD,SAAS,SAAS,MAAY;AAC5B,SAAO,KACJ,MAAM,0BAA0B,EAChC,IAAI,CAAC,MAAM,EAAE,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,oBAAI,IAAG;AACvB,aAAW,QAAQ,cAAc;AAC/B,YAAQ,IAAI,KAAK,YAAY,IAAI,IAAI;EACvC;AAGA,QAAM,SAAS,QAAQ,QACnB,gBAAgB,SAAS,QAAQ,OAAO,aAAa,IACrD,WAAW,SAAS,QAAQ,MAAM,aAAa;AAGnD,QAAM,EAAE,OAAO,iBAAiB,MAAK,IAAK,SAAS,cAAc,QAAQ;IACvE,QAAQ;IACR;IACA;GACD;AAGD,QAAM,gBAAgB,CAAC,GAAG,oBAAoB,GAAG,eAAe;AAGhE,QAAM,SAAS;AACf,QAAM,QAAQ;AACd,QAAM,iBAAiB,mBAAmB;AAC1C,aAAW,OAAO,oBAAoB;AACpC,UAAM,YAAY,QAAQ;MACxB,QAAQ,IAAI;MACZ,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"]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REQUIRED_SECTIONS
|
|
3
|
+
} from "./chunk-SJCIM4TC.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/core/init.ts
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var TEMPLATE_SPECS = {
|
|
10
|
+
lightweight: [
|
|
11
|
+
{ filename: "prd.md", type: "prd" },
|
|
12
|
+
{ filename: "technical-design.md", type: "technical-design" }
|
|
13
|
+
],
|
|
14
|
+
bmad: [
|
|
15
|
+
{ filename: "prd.md", type: "prd" },
|
|
16
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
17
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
18
|
+
],
|
|
19
|
+
"api-first": [
|
|
20
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
21
|
+
{ filename: "api-contract.md", type: "api-contract" },
|
|
22
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
23
|
+
],
|
|
24
|
+
quick: [{ filename: "quick-spec.md", type: "quick-spec" }],
|
|
25
|
+
context: [{ filename: "project-context.md", type: "project-context" }]
|
|
26
|
+
};
|
|
27
|
+
var TEMPLATE_EXTRA_DIRS = {
|
|
28
|
+
lightweight: [],
|
|
29
|
+
bmad: ["specs/stories", "specs/adr"],
|
|
30
|
+
"api-first": [],
|
|
31
|
+
quick: [],
|
|
32
|
+
context: []
|
|
33
|
+
};
|
|
34
|
+
function specIdFromFilename(filename) {
|
|
35
|
+
return filename.replace(/\.md$/, "");
|
|
36
|
+
}
|
|
37
|
+
function specTitleFromType(type) {
|
|
38
|
+
return type.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
39
|
+
}
|
|
40
|
+
function buildSpecFile(filename, type, projectName, today) {
|
|
41
|
+
const id = specIdFromFilename(filename);
|
|
42
|
+
const title = `${specTitleFromType(type)} \u2014 ${projectName}`;
|
|
43
|
+
const sections = REQUIRED_SECTIONS[type];
|
|
44
|
+
const frontmatter = [
|
|
45
|
+
"---",
|
|
46
|
+
`id: ${id}`,
|
|
47
|
+
`type: ${type}`,
|
|
48
|
+
`title: "${title}"`,
|
|
49
|
+
`status: draft`,
|
|
50
|
+
`version: "0.1"`,
|
|
51
|
+
`created: "${today}"`,
|
|
52
|
+
`authors: ["author"]`,
|
|
53
|
+
"---"
|
|
54
|
+
].join("\n");
|
|
55
|
+
const body = sections.map((section) => `
|
|
56
|
+
## ${section}
|
|
57
|
+
|
|
58
|
+
<!-- placeholder -->`).join("\n");
|
|
59
|
+
return `${frontmatter}
|
|
60
|
+
${body}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
function buildConfigYaml(projectName, specs) {
|
|
64
|
+
const specEntries = specs.map(({ filename, type }) => {
|
|
65
|
+
const key = specIdFromFilename(filename);
|
|
66
|
+
return ` ${key}:
|
|
67
|
+
path: specs/${filename}
|
|
68
|
+
type: ${type}`;
|
|
69
|
+
}).join("\n");
|
|
70
|
+
return [`version: "1.0"`, `project:`, ` name: "${projectName}"`, `specs:`, specEntries].join("\n") + "\n";
|
|
71
|
+
}
|
|
72
|
+
async function scaffoldProject({
|
|
73
|
+
projectName,
|
|
74
|
+
template,
|
|
75
|
+
targetDir
|
|
76
|
+
}) {
|
|
77
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
78
|
+
const specsDir = join(targetDir, "specs");
|
|
79
|
+
await mkdir(specsDir, { recursive: true });
|
|
80
|
+
for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {
|
|
81
|
+
await mkdir(join(targetDir, extraDir), { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
const specs = TEMPLATE_SPECS[template];
|
|
84
|
+
for (const { filename, type } of specs) {
|
|
85
|
+
const content = buildSpecFile(filename, type, projectName, today);
|
|
86
|
+
await writeFile(join(specsDir, filename), content, "utf-8");
|
|
87
|
+
}
|
|
88
|
+
const configContent = buildConfigYaml(projectName, specs);
|
|
89
|
+
await writeFile(join(targetDir, "spec.config.yaml"), configContent, "utf-8");
|
|
90
|
+
}
|
|
91
|
+
var init_default = defineCommand({
|
|
92
|
+
meta: {
|
|
93
|
+
name: "init",
|
|
94
|
+
description: "Initialize a new specdx project with spec scaffolding"
|
|
95
|
+
},
|
|
96
|
+
args: {
|
|
97
|
+
name: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "Project name",
|
|
100
|
+
required: true
|
|
101
|
+
},
|
|
102
|
+
template: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "Template to use (lightweight, bmad, api-first)",
|
|
105
|
+
default: "lightweight"
|
|
106
|
+
},
|
|
107
|
+
dir: {
|
|
108
|
+
type: "string",
|
|
109
|
+
description: "Target directory",
|
|
110
|
+
default: "."
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
async run({ args }) {
|
|
114
|
+
const { name, template, dir } = args;
|
|
115
|
+
const validTemplates = ["lightweight", "bmad", "api-first", "quick", "context"];
|
|
116
|
+
if (!validTemplates.includes(template)) {
|
|
117
|
+
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
console.log(`Scaffolding "${name}" with template "${template}" in ${dir}...`);
|
|
121
|
+
await scaffoldProject({ projectName: name, template, targetDir: dir });
|
|
122
|
+
console.log(`Done! Project "${name}" scaffolded successfully.`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/commands/registry.ts
|
|
127
|
+
var CORE_COMMANDS = [
|
|
128
|
+
"init",
|
|
129
|
+
"lint",
|
|
130
|
+
"validate",
|
|
131
|
+
"graph",
|
|
132
|
+
"skills",
|
|
133
|
+
"pack",
|
|
134
|
+
"diff",
|
|
135
|
+
"status",
|
|
136
|
+
"ready",
|
|
137
|
+
"generate",
|
|
138
|
+
"generate story",
|
|
139
|
+
"mcp"
|
|
140
|
+
];
|
|
141
|
+
var EXPERIMENTAL_COMMANDS = ["check", "update", "migrate", "generate test-plan"];
|
|
142
|
+
var COMMAND_NAMES = [...CORE_COMMANDS, ...EXPERIMENTAL_COMMANDS];
|
|
143
|
+
function bucketOf(name) {
|
|
144
|
+
return EXPERIMENTAL_COMMANDS.includes(name) ? "experimental" : "core";
|
|
145
|
+
}
|
|
146
|
+
function labelled(name, cmd) {
|
|
147
|
+
if (bucketOf(name) === "core") return cmd;
|
|
148
|
+
const meta = cmd.meta;
|
|
149
|
+
if (typeof meta !== "object" || meta === null || "then" in meta) return cmd;
|
|
150
|
+
return {
|
|
151
|
+
...cmd,
|
|
152
|
+
meta: { ...meta, description: `[experimental] ${meta.description ?? ""}`.trim() }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function bucketed(name, load) {
|
|
156
|
+
return () => load().then((cmd) => labelled(name, cmd));
|
|
157
|
+
}
|
|
158
|
+
var subCommands = {
|
|
159
|
+
init: init_default,
|
|
160
|
+
lint: bucketed("lint", () => import("./lint-VB5PV32N.js").then((m) => m.default)),
|
|
161
|
+
validate: bucketed("validate", () => import("./validate-WIB246IE.js").then((m) => m.default)),
|
|
162
|
+
graph: bucketed("graph", () => import("./graph-OKUMHR3Q.js").then((m) => m.default)),
|
|
163
|
+
skills: bucketed("skills", () => import("./skills-LHFTTEJ7.js").then((m) => m.default)),
|
|
164
|
+
pack: bucketed("pack", () => import("./pack-B3KYRKUR.js").then((m) => m.default)),
|
|
165
|
+
diff: bucketed("diff", () => import("./diff-IEN6W4OG.js").then((m) => m.default)),
|
|
166
|
+
status: bucketed("status", () => import("./status-BRLCD7NY.js").then((m) => m.default)),
|
|
167
|
+
check: bucketed("check", () => import("./check-Q3QKTN2D.js").then((m) => m.default)),
|
|
168
|
+
ready: bucketed("ready", () => import("./ready-C6YXJ47W.js").then((m) => m.default)),
|
|
169
|
+
update: bucketed("update", () => import("./update-P6TQUI6H.js").then((m) => m.default)),
|
|
170
|
+
generate: bucketed("generate", () => import("./generate-GQPOLFP7.js").then((m) => m.default)),
|
|
171
|
+
migrate: bucketed("migrate", () => import("./migrate-LAMRDT3V.js").then((m) => m.default)),
|
|
172
|
+
mcp: bucketed("mcp", () => import("./mcp-DADOVCEV.js").then((m) => m.default))
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
labelled,
|
|
177
|
+
subCommands
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=chunk-TJPPBM24.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/init.ts","../src/commands/registry.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\n\nexport type Template = \"lightweight\" | \"bmad\" | \"api-first\" | \"quick\" | \"context\";\n\ninterface ScaffoldOptions {\n projectName: string;\n template: Template;\n targetDir: string;\n}\n\nconst TEMPLATE_SPECS: Record<\n Template,\n Array<{ filename: string; type: keyof typeof REQUIRED_SECTIONS }>\n> = {\n lightweight: [\n { filename: \"prd.md\", type: \"prd\" },\n { filename: \"technical-design.md\", type: \"technical-design\" },\n ],\n bmad: [\n { filename: \"prd.md\", type: \"prd\" },\n { filename: \"technical-design.md\", type: \"technical-design\" },\n { filename: \"test-plan.md\", type: \"test-plan\" },\n ],\n \"api-first\": [\n { filename: \"technical-design.md\", type: \"technical-design\" },\n { filename: \"api-contract.md\", type: \"api-contract\" },\n { filename: \"test-plan.md\", type: \"test-plan\" },\n ],\n quick: [{ filename: \"quick-spec.md\", type: \"quick-spec\" }],\n context: [{ filename: \"project-context.md\", type: \"project-context\" }],\n};\n\nconst TEMPLATE_EXTRA_DIRS: Record<Template, string[]> = {\n lightweight: [],\n bmad: [\"specs/stories\", \"specs/adr\"],\n \"api-first\": [],\n quick: [],\n context: [],\n};\n\nfunction specIdFromFilename(filename: string): string {\n return filename.replace(/\\.md$/, \"\");\n}\n\nfunction specTitleFromType(type: string): string {\n return type\n .split(\"-\")\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\nfunction buildSpecFile(\n filename: string,\n type: keyof typeof REQUIRED_SECTIONS,\n projectName: string,\n today: string,\n): string {\n const id = specIdFromFilename(filename);\n const title = `${specTitleFromType(type)} — ${projectName}`;\n const sections = REQUIRED_SECTIONS[type];\n\n const frontmatter = [\n \"---\",\n `id: ${id}`,\n `type: ${type}`,\n `title: \"${title}\"`,\n `status: draft`,\n `version: \"0.1\"`,\n `created: \"${today}\"`,\n `authors: [\"author\"]`,\n \"---\",\n ].join(\"\\n\");\n\n const body = sections.map((section) => `\\n## ${section}\\n\\n<!-- placeholder -->`).join(\"\\n\");\n\n return `${frontmatter}\\n${body}\\n`;\n}\n\nfunction buildConfigYaml(\n projectName: string,\n specs: Array<{ filename: string; type: string }>,\n): string {\n const specEntries = specs\n .map(({ filename, type }) => {\n const key = specIdFromFilename(filename);\n return ` ${key}:\\n path: specs/${filename}\\n type: ${type}`;\n })\n .join(\"\\n\");\n\n return (\n [`version: \"1.0\"`, `project:`, ` name: \"${projectName}\"`, `specs:`, specEntries].join(\"\\n\") +\n \"\\n\"\n );\n}\n\nexport async function scaffoldProject({\n projectName,\n template,\n targetDir,\n}: ScaffoldOptions): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n const specsDir = join(targetDir, \"specs\");\n\n // Create specs/ directory\n await mkdir(specsDir, { recursive: true });\n\n // Create extra template dirs (e.g., bmad needs stories/ and adr/)\n for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {\n await mkdir(join(targetDir, extraDir), { recursive: true });\n }\n\n const specs = TEMPLATE_SPECS[template];\n\n // Write spec files\n for (const { filename, type } of specs) {\n const content = buildSpecFile(filename, type, projectName, today);\n await writeFile(join(specsDir, filename), content, \"utf-8\");\n }\n\n // Write spec.config.yaml\n const configContent = buildConfigYaml(projectName, specs);\n await writeFile(join(targetDir, \"spec.config.yaml\"), configContent, \"utf-8\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"init\",\n description: \"Initialize a new specdx project with spec scaffolding\",\n },\n args: {\n name: {\n type: \"string\",\n description: \"Project name\",\n required: true,\n },\n template: {\n type: \"string\",\n description: \"Template to use (lightweight, bmad, api-first)\",\n default: \"lightweight\",\n },\n dir: {\n type: \"string\",\n description: \"Target directory\",\n default: \".\",\n },\n },\n async run({ args }) {\n const { name, template, dir } = args;\n const validTemplates: Template[] = [\"lightweight\", \"bmad\", \"api-first\", \"quick\", \"context\"];\n if (!validTemplates.includes(template as Template)) {\n console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(\", \")}`);\n process.exit(1);\n }\n console.log(`Scaffolding \"${name}\" with template \"${template}\" in ${dir}...`);\n await scaffoldProject({ projectName: name, template: template as Template, targetDir: dir });\n console.log(`Done! Project \"${name}\" scaffolded successfully.`);\n },\n});\n","import type { ArgsDef, CommandDef, SubCommandsDef } from \"citty\";\nimport initCommand from \"./core/init.js\";\n\n/**\n * Promoted commands — the set `--help` presents without a caveat.\n *\n * Promotion is the directory a command lives in, not an adjective someone\n * remembered to type into its description. `explain` and `changelog` both\n * drifted into the core surface precisely because the marker was a string.\n * Sub-commands are spelled the way a user types them.\n */\nexport const CORE_COMMANDS = [\n \"init\",\n \"lint\",\n \"validate\",\n \"graph\",\n \"skills\",\n \"pack\",\n \"diff\",\n \"status\",\n \"ready\",\n \"generate\",\n \"generate story\",\n \"mcp\",\n] as const;\n\n/** Commands whose output is not yet trusted enough to promote. */\nexport const EXPERIMENTAL_COMMANDS = [\"check\", \"update\", \"migrate\", \"generate test-plan\"] as const;\n\n/** Every command that ships, promoted or not. */\nexport const COMMAND_NAMES = [...CORE_COMMANDS, ...EXPERIMENTAL_COMMANDS];\n\nexport type CommandName = (typeof COMMAND_NAMES)[number];\n\n/** Bucket directory a command lives in, under `commands/`. */\nexport function bucketOf(name: string): \"core\" | \"experimental\" {\n return (EXPERIMENTAL_COMMANDS as readonly string[]).includes(name) ? \"experimental\" : \"core\";\n}\n\n/** Module path for a command, relative to `commands/`. */\nexport function moduleOf(name: string): string {\n return `${bucketOf(name)}/${name.replace(/ /g, \"-\")}.ts`;\n}\n\n/**\n * Prefix an experimental command's description with its caveat.\n *\n * Derived from the bucket, so no description in the tree spells `[experimental]`\n * itself and the two can never disagree.\n */\nexport function labelled<T extends ArgsDef>(name: string, cmd: CommandDef<T>): CommandDef<T> {\n if (bucketOf(name) === \"core\") return cmd;\n const meta = cmd.meta;\n // citty allows meta to be a function or promise. Ours are all plain objects,\n // and the conformance test asserts every experimental command renders the\n // caveat -- so a command that adopts lazy meta fails loudly rather than\n // shipping unlabelled.\n if (typeof meta !== \"object\" || meta === null || \"then\" in meta) return cmd;\n return {\n ...cmd,\n meta: { ...meta, description: `[experimental] ${meta.description ?? \"\"}`.trim() },\n };\n}\n\n/** Lazily load a command module and label it according to its bucket. */\nfunction bucketed<T extends ArgsDef>(\n name: string,\n load: () => Promise<CommandDef<T>>,\n): () => Promise<CommandDef<T>> {\n return () => load().then((cmd) => labelled(name, cmd));\n}\n\n/**\n * The `subCommands` map citty registers, keyed by the top-level names above.\n *\n * Typed as citty's own `SubCommandsDef` rather than a `Record<CommandName, ...>`:\n * `CommandDef` is invariant in its args, so a narrower annotation rejects every\n * command that declares args. The conformance test asserts the keys instead.\n */\nexport const subCommands: SubCommandsDef = {\n init: initCommand,\n lint: bucketed(\"lint\", () => import(\"./core/lint.js\").then((m) => m.default)),\n validate: bucketed(\"validate\", () => import(\"./core/validate.js\").then((m) => m.default)),\n graph: bucketed(\"graph\", () => import(\"./core/graph.js\").then((m) => m.default)),\n skills: bucketed(\"skills\", () => import(\"./core/skills.js\").then((m) => m.default)),\n pack: bucketed(\"pack\", () => import(\"./core/pack.js\").then((m) => m.default)),\n diff: bucketed(\"diff\", () => import(\"./core/diff.js\").then((m) => m.default)),\n status: bucketed(\"status\", () => import(\"./core/status.js\").then((m) => m.default)),\n check: bucketed(\"check\", () => import(\"./experimental/check.js\").then((m) => m.default)),\n ready: bucketed(\"ready\", () => import(\"./core/ready.js\").then((m) => m.default)),\n update: bucketed(\"update\", () => import(\"./experimental/update.js\").then((m) => m.default)),\n generate: bucketed(\"generate\", () => import(\"./core/generate.js\").then((m) => m.default)),\n migrate: bucketed(\"migrate\", () => import(\"./experimental/migrate.js\").then((m) => m.default)),\n mcp: bucketed(\"mcp\", () => import(\"./core/mcp.js\").then((m) => m.default)),\n};\n"],"mappings":";;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,iBAAiB;AACjC,SAAS,YA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AM,EAAE,OAAO,CAAC;AAAA,EAC/E,QAAQ,SAAS,UAAU,MAAM,OAAO,sBAA0B,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;AAAA,EAC1F,UAAU,SAAS,YAAY,MAAM,OAAO,wBAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;AAAA,EACxF,SAAS,SAAS,WAAW,MAAM,OAAO,uBAA2B,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;AAAA,EAC7F,KAAK,SAAS,OAAO,MAAM,OAAO,mBAAe,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;AAC3E;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import "./chunk-SJCIM4TC.js";
|
|
10
10
|
import "./chunk-5WRI5ZAA.js";
|
|
11
11
|
|
|
12
|
-
// src/commands/diff.ts
|
|
12
|
+
// src/commands/core/diff.ts
|
|
13
13
|
import { defineCommand } from "citty";
|
|
14
14
|
import { join } from "path";
|
|
15
15
|
|
|
@@ -62,7 +62,7 @@ function formatChangelog(result, baseRef, headRef) {
|
|
|
62
62
|
return lines.join("\n");
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// src/commands/diff.ts
|
|
65
|
+
// src/commands/core/diff.ts
|
|
66
66
|
async function runDiff(options) {
|
|
67
67
|
const configDir = process.cwd();
|
|
68
68
|
const config = await loadConfig(void 0, configDir);
|
|
@@ -185,4 +185,4 @@ export {
|
|
|
185
185
|
diff_default as default,
|
|
186
186
|
runDiff
|
|
187
187
|
};
|
|
188
|
-
//# sourceMappingURL=diff-
|
|
188
|
+
//# sourceMappingURL=diff-IEN6W4OG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/diff.ts","../src/formatters/changelog.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { join } from \"node:path\";\nimport { diffBetweenRefs, DEFAULT_DIFF_CONFIG, DiffError } from \"@specdx/diff\";\nimport { loadConfig } from \"@specdx/core\";\nimport { formatChangelog } from \"../../formatters/changelog.js\";\nimport type { DiffResult } from \"@specdx/diff\";\n\nexport interface RunDiffOptions {\n base?: string;\n head?: string;\n spec?: string;\n format?: string;\n /** Compare the base ref against the working tree instead of a head ref. */\n working?: boolean;\n}\n\nexport async function runDiff(options: RunDiffOptions): Promise<DiffResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;\n const headRef = options.head ?? \"HEAD\";\n\n const configPath = join(configDir, \"spec.config.yaml\");\n\n const result = await diffBetweenRefs(configPath, baseRef, headRef, {\n working: options.working ?? false,\n });\n\n if (options.spec) {\n result.diffs = result.diffs.filter((d) => d.specId === options.spec);\n result.impact = result.impact.filter((i) => i.changedSpec === options.spec);\n }\n\n return result;\n}\n\nexport default defineCommand({\n meta: { name: \"diff\", description: \"Show spec changes and downstream impact\" },\n args: {\n base: { type: \"string\", description: \"Base git ref (default: from config or 'main')\" },\n head: { type: \"string\", description: \"Head git ref (default: HEAD)\" },\n working: {\n type: \"boolean\",\n description: \"Compare the base ref against the working tree (includes uncommitted specs)\",\n default: false,\n },\n spec: { type: \"string\", description: \"Scope to a single spec ID\" },\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, changelog\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n try {\n try {\n const result = await runDiff({\n base: args.base,\n head: args.head,\n spec: args.spec,\n format: args.format,\n working: args.working,\n });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"changelog\") {\n const baseRef =\n args.base ?? (await loadConfig(undefined, process.cwd())).diff?.baseline_ref ?? \"main\";\n console.log(\n formatChangelog(result, baseRef, args.working ? \"working tree\" : (args.head ?? \"HEAD\")),\n );\n return;\n }\n\n // A ref-to-ref comparison cannot see the working tree, so an unqualified\n // \"no changes\" would be a false all-clear for anyone about to commit.\n const printUncommittedWarning = (): void => {\n if (result.uncommittedSpecFiles.length === 0) return;\n const count = result.uncommittedSpecFiles.length;\n console.log(\n `\\n \\u26a0 ${count} spec file(s) changed in the working tree are not covered by this comparison:`,\n );\n for (const file of result.uncommittedSpecFiles) {\n console.log(` ${file}`);\n }\n console.log(\" Run with --working to include them.\");\n };\n\n // Pretty format\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n console.log(\" \\u2713 No spec changes detected.\");\n printUncommittedWarning();\n return;\n }\n\n console.log(result.summary);\n console.log();\n\n for (const diff of result.diffs) {\n console.log(` ${diff.specId}:`);\n for (const fc of diff.frontmatter) {\n const detail =\n fc.before !== undefined || fc.after !== undefined\n ? ` (${String(fc.before)} \\u2192 ${String(fc.after)})`\n : \"\";\n console.log(` ${fc.type}: ${fc.field}${detail}`);\n }\n for (const sc of diff.sections) {\n console.log(` ${sc.type}: ${sc.heading}`);\n }\n }\n\n if (result.added.length > 0) {\n console.log(`\\n Added: ${result.added.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`\\n Removed: ${result.removed.join(\", \")}`);\n }\n\n if (result.impact.length > 0) {\n console.log(\"\\n Downstream Impact:\");\n for (const impact of result.impact) {\n for (const d of impact.downstream) {\n console.log(\n ` ${d.specId} \\u2014 staleness: ${d.staleness.toFixed(2)} \\u2014 ${d.reason}`,\n );\n }\n }\n }\n\n printUncommittedWarning();\n } catch (err) {\n if (err instanceof DiffError) {\n console.error(`\\n \\u2717 ${err.message}\\n`);\n process.exit(1);\n }\n throw err;\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n","import type { DiffResult } from \"@specdx/diff\";\n\n/**\n * Render a diff as a markdown changelog.\n *\n * Formerly the `specdx changelog` command, which ran the same comparison as\n * `diff` and differed only in presentation. It is a format, not a second\n * question, so it lives as `diff --format changelog`.\n */\nexport function formatChangelog(result: DiffResult, baseRef: string, headRef: string): string {\n const lines: string[] = [];\n lines.push(`## Spec Changes (${baseRef}..${headRef})\\n`);\n\n if (result.diffs.length > 0) {\n lines.push(\"### Modified\");\n for (const diff of result.diffs) {\n const sections = diff.sections.map((s) => s.heading).join(\", \");\n const versionChange = diff.frontmatter.find((f) => f.field === \"version\");\n const versionStr = versionChange\n ? ` (${String(versionChange.before)} → ${String(versionChange.after)})`\n : \"\";\n lines.push(`- **${diff.specId}**${versionStr} — ${sections || \"frontmatter only\"}`);\n }\n lines.push(\"\");\n }\n\n if (result.added.length > 0) {\n lines.push(\"### Added\");\n for (const id of result.added) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n if (result.removed.length > 0) {\n lines.push(\"### Removed\");\n for (const id of result.removed) {\n lines.push(`- **${id}**`);\n }\n lines.push(\"\");\n }\n\n const allDownstream = result.impact.flatMap((i) => i.downstream);\n if (allDownstream.length > 0) {\n lines.push(\"### Downstream Impact\");\n for (const d of allDownstream) {\n lines.push(`- ${d.specId} may be stale (${d.reason})`);\n }\n lines.push(\"\");\n }\n\n if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {\n lines.push(\"No spec changes detected.\\n\");\n }\n\n // The uncommitted warning matters most here: a changelog is usually written\n // at release time, when unstaged spec edits are easy to miss.\n if (result.uncommittedSpecFiles.length > 0) {\n lines.push(\n `> ⚠ ${result.uncommittedSpecFiles.length} spec file(s) changed in the working tree are not covered by this range.\\n`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;;;ACQd,SAAS,gBAAgB,QAAoB,SAAiB,SAAyB;AAC5F,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,oBAAoB,OAAO,KAAK,OAAO;AAAA,CAAK;AAEvD,MAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,UAAM,KAAK,cAAc;AACzB,eAAW,QAAQ,OAAO,OAAO;AAC/B,YAAM,WAAW,KAAK,SAAS,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MAAM,SAAS,GAAG;AAC3B,kBAAQ,IAAI;AAAA,WAAc,OAAO,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,QACrD;AACA,YAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,kBAAQ,IAAI;AAAA,aAAgB,OAAO,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,QACzD;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,kBAAQ,IAAI,wBAAwB;AACpC,qBAAW,UAAU,OAAO,QAAQ;AAClC,uBAAW,KAAK,OAAO,YAAY;AACjC,sBAAQ;AAAA,gBACN,OAAO,EAAE,MAAM,sBAAsB,EAAE,UAAU,QAAQ,CAAC,CAAC,WAAW,EAAE,MAAM;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,gCAAwB;AAAA,MAC1B,SAAS,KAAK;AACZ,YAAI,eAAe,WAAW;AAC5B,kBAAQ,MAAM;AAAA,WAAc,IAAI,OAAO;AAAA,CAAI;AAC3C,kBAAQ,KAAK,CAAC;AAAA,QAChB;AACA,cAAM;AAAA,MACR;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-PEC5LAVE.js";
|
|
4
4
|
import {
|
|
5
5
|
pack
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TF7WSPFV.js";
|
|
7
7
|
import {
|
|
8
8
|
createLintEngine,
|
|
9
9
|
getPreset
|
|
@@ -307,4 +307,4 @@ function createMcpServer() {
|
|
|
307
307
|
export {
|
|
308
308
|
createMcpServer
|
|
309
309
|
};
|
|
310
|
-
//# sourceMappingURL=dist-
|
|
310
|
+
//# sourceMappingURL=dist-DVROIZAO.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
labelled
|
|
3
|
+
} from "./chunk-TJPPBM24.js";
|
|
4
|
+
import "./chunk-SJCIM4TC.js";
|
|
5
|
+
import "./chunk-5WRI5ZAA.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/core/generate.ts
|
|
8
|
+
import { defineCommand } from "citty";
|
|
9
|
+
var generate_default = defineCommand({
|
|
10
|
+
meta: { name: "generate", description: "Generate spec stubs from existing specs" },
|
|
11
|
+
subCommands: {
|
|
12
|
+
story: () => import("./generate-story-UJS37FHA.js").then((m) => labelled("generate story", m.default)),
|
|
13
|
+
"test-plan": () => import("./generate-test-plan-RQTSGQLR.js").then(
|
|
14
|
+
(m) => labelled("generate test-plan", m.default)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
generate_default as default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=generate-GQPOLFP7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/generate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { labelled } from \"../registry.js\";\n\nexport default defineCommand({\n meta: { name: \"generate\", description: \"Generate spec stubs from existing specs\" },\n subCommands: {\n story: () => import(\"./generate-story.js\").then((m) => labelled(\"generate story\", m.default)),\n \"test-plan\": () =>\n import(\"../experimental/generate-test-plan.js\").then((m) =>\n labelled(\"generate test-plan\", m.default),\n ),\n },\n});\n"],"mappings":";;;;;;;AAAA,SAAS,qBAAqB;AAG9B,IAAO,mBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,YAAY,aAAa,0CAA0C;AAAA,EACjF,aAAa;AAAA,IACX,OAAO,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,SAAS,kBAAkB,EAAE,OAAO,CAAC;AAAA,IAC5F,aAAa,MACX,OAAO,kCAAuC,EAAE;AAAA,MAAK,CAAC,MACpD,SAAS,sBAAsB,EAAE,OAAO;AAAA,IAC1C;AAAA,EACJ;AACF,CAAC;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-SJCIM4TC.js";
|
|
10
10
|
import "./chunk-5WRI5ZAA.js";
|
|
11
11
|
|
|
12
|
-
// src/commands/generate-story.ts
|
|
12
|
+
// src/commands/core/generate-story.ts
|
|
13
13
|
import { defineCommand } from "citty";
|
|
14
14
|
import { writeFile, mkdir } from "fs/promises";
|
|
15
15
|
import { join } from "path";
|
|
@@ -194,4 +194,4 @@ export {
|
|
|
194
194
|
defineCommandExport,
|
|
195
195
|
generateStories
|
|
196
196
|
};
|
|
197
|
-
//# sourceMappingURL=generate-story-
|
|
197
|
+
//# sourceMappingURL=generate-story-UJS37FHA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/generate-story.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { writeFile, mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { REQUIRED_SECTIONS } from \"@specdx/schema\";\n\nexport interface GenerateStoriesOptions {\n configDir: string;\n from: string;\n outDir?: string;\n}\n\nexport interface GenerateStoriesResult {\n generated: string[];\n}\n\nfunction slugify(text: string): string {\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (slug.length <= 40) return slug;\n // Truncate on a word boundary so filenames don't end mid-word\n const cut = slug.slice(0, 40);\n const lastHyphen = cut.lastIndexOf(\"-\");\n return lastHyphen > 0 ? cut.slice(0, lastHyphen) : cut;\n}\n\nfunction detectStoriesDir(\n configDir: string,\n config: Awaited<ReturnType<typeof loadConfig>>,\n): string {\n for (const entry of Object.values(config.specs)) {\n if (entry.type === \"user-story\") {\n // Use the directory portion of the glob path\n const dirPart = entry.path.replace(/\\/[^/]*\\*.*$/, \"\").replace(/\\/[^/]*$/, \"\");\n // If path ends with *.md at a directory level, take that dir\n const match = entry.path.match(/^(.+?)\\/\\*/);\n if (match) {\n return join(configDir, match[1]!);\n }\n return join(configDir, dirPart);\n }\n }\n return join(configDir, \"specs/stories\");\n}\n\nfunction buildStoryFile(options: {\n featureNum: string;\n featureText: string;\n prdId: string;\n prdAuthors: string[];\n today: string;\n sections: string[];\n}): string {\n const { featureNum, featureText, prdId, prdAuthors, today, sections } = options;\n const storyId = `story-f${featureNum}`;\n const title = featureText.trim();\n const authorsYaml = JSON.stringify(prdAuthors);\n\n const frontmatter = [\n \"---\",\n `id: \"${storyId}\"`,\n `type: \"user-story\"`,\n `title: \"${title}\"`,\n `status: \"draft\"`,\n `version: \"0.1\"`,\n `created: \"${today}\"`,\n `authors: ${authorsYaml}`,\n `story_id: \"${storyId}\"`,\n `priority: \"medium\"`,\n `estimate: \"TBD\"`,\n `references:`,\n ` - id: \"${prdId}\"`,\n ` relationship: \"decomposed-into\"`,\n \"---\",\n ].join(\"\\n\");\n\n const bodyParts = sections.map((section) => {\n if (section === \"Description\") {\n return `\\n## ${section}\\n\\n${featureText.trim()}`;\n }\n if (section === \"Acceptance Criteria\") {\n return `\\n## ${section}\\n\\n- [ ] <!-- acceptance criterion -->`;\n }\n if (section === \"Dependencies\") {\n return `\\n## ${section}\\n\\nF${featureNum} from ${prdId}`;\n }\n return `\\n## ${section}\\n\\n<!-- placeholder -->`;\n });\n\n return `${frontmatter}\\n${bodyParts.join(\"\\n\")}\\n`;\n}\n\nexport async function generateStories(\n options: GenerateStoriesOptions,\n): Promise<GenerateStoriesResult> {\n const { configDir, from, outDir } = options;\n const config = await loadConfig(undefined, configDir);\n\n // Find the PRD spec file by ID\n let prdFilePath: string | undefined;\n for (const entry of Object.values(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n for (const file of files) {\n const parsed = await parseSpec(file);\n if (parsed.frontmatter.id === from) {\n prdFilePath = file;\n break;\n }\n }\n if (prdFilePath) break;\n }\n\n if (!prdFilePath) {\n throw new Error(`No spec with id \"${from}\" found in config.`);\n }\n\n const prd = await parseSpec(prdFilePath);\n\n // Find the Features section content\n const featuresSection = prd.parsedSections.find((s) => s.heading === \"Features\");\n if (!featuresSection) {\n return { generated: [] };\n }\n\n // Parse features using the required regex pattern\n const featureRegex = /\\*\\*F(\\d+)\\*\\*:\\s*(.+)/g;\n const features: Array<{ num: string; text: string }> = [];\n let match: RegExpExecArray | null;\n while ((match = featureRegex.exec(featuresSection.content)) !== null) {\n features.push({ num: match[1]!, text: match[2]! });\n }\n\n if (features.length === 0) {\n return { generated: [] };\n }\n\n const storiesDir = outDir ?? detectStoriesDir(configDir, config);\n await mkdir(storiesDir, { recursive: true });\n\n const today = new Date().toISOString().slice(0, 10);\n const prdAuthors = (prd.frontmatter.authors as string[] | undefined) ?? [];\n const sections = REQUIRED_SECTIONS[\"user-story\"];\n\n const generated: string[] = [];\n\n for (const feature of features) {\n const slug = slugify(feature.text);\n const filename = `story-f${feature.num}-${slug}.md`;\n const filePath = join(storiesDir, filename);\n\n const content = buildStoryFile({\n featureNum: feature.num,\n featureText: feature.text,\n prdId: from,\n prdAuthors,\n today,\n sections,\n });\n\n await writeFile(filePath, content, \"utf-8\");\n generated.push(filePath);\n }\n\n return { generated };\n}\n\nexport const defineCommandExport = defineCommand({\n meta: {\n name: \"generate story\",\n description: \"Generate user story stub files from a PRD's Features section\",\n },\n args: {\n from: {\n type: \"string\",\n description: \"Spec ID of the PRD to generate stories from\",\n required: true,\n },\n out: {\n type: \"string\",\n description: \"Output directory for story files (default: auto-detected from config)\",\n },\n quiet: {\n type: \"boolean\",\n description: \"Suppress output\",\n default: false,\n },\n verbose: {\n type: \"boolean\",\n description: \"Verbose output\",\n default: false,\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n\n try {\n const result = await generateStories({\n configDir: process.cwd(),\n from: args.from,\n outDir: args.out,\n });\n\n if (result.generated.length === 0) {\n logger.info(\"No features found in PRD — no story stubs generated.\");\n } else {\n logger.info(`Generated ${result.generated.length} story stub(s):`);\n for (const filePath of result.generated) {\n logger.info(` ${filePath}`);\n }\n }\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n\nexport default defineCommandExport;\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,aAAa;AACjC,SAAS,YAAY;AAcrB,SAAS,QAAQ,MAAsB;AACrC,QAAM,OAAO,KACV,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AACzB,MAAI,KAAK,UAAU,GAAI,QAAO;AAE9B,QAAM,MAAM,KAAK,MAAM,GAAG,EAAE;AAC5B,QAAM,aAAa,IAAI,YAAY,GAAG;AACtC,SAAO,aAAa,IAAI,IAAI,MAAM,GAAG,UAAU,IAAI;AACrD;AAEA,SAAS,iBACP,WACA,QACQ;AACR,aAAW,SAAS,OAAO,OAAO,OAAO,KAAK,GAAG;AAC/C,QAAI,MAAM,SAAS,cAAc;AAE/B,YAAM,UAAU,MAAM,KAAK,QAAQ,gBAAgB,EAAE,EAAE,QAAQ,YAAY,EAAE;AAE7E,YAAM,QAAQ,MAAM,KAAK,MAAM,YAAY;AAC3C,UAAI,OAAO;AACT,eAAO,KAAK,WAAW,MAAM,CAAC,CAAE;AAAA,MAClC;AACA,aAAO,KAAK,WAAW,OAAO;AAAA,IAChC;AAAA,EACF;AACA,SAAO,KAAK,WAAW,eAAe;AACxC;AAEA,SAAS,eAAe,SAOb;AACT,QAAM,EAAE,YAAY,aAAa,OAAO,YAAY,OAAO,SAAS,IAAI;AACxE,QAAM,UAAU,UAAU,UAAU;AACpC,QAAM,QAAQ,YAAY,KAAK;AAC/B,QAAM,cAAc,KAAK,UAAU,UAAU;AAE7C,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,QAAQ,OAAO;AAAA,IACf;AAAA,IACA,WAAW,KAAK;AAAA,IAChB;AAAA,IACA;AAAA,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AM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,aAAa,EAAE,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AAExE,QAAI;AACF,YAAM,SAAS,MAAM,gBAAgB;AAAA,QACnC,WAAW,QAAQ,IAAI;AAAA,QACvB,MAAM,KAAK;AAAA,QACX,QAAQ,KAAK;AAAA,MACf,CAAC;AAED,UAAI,OAAO,UAAU,WAAW,GAAG;AACjC,eAAO,KAAK,2DAAsD;AAAA,MACpE,OAAO;AACL,eAAO,KAAK,aAAa,OAAO,UAAU,MAAM,iBAAiB;AACjE,mBAAW,YAAY,OAAO,WAAW;AACvC,iBAAO,KAAK,KAAK,QAAQ,EAAE;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAED,IAAO,yBAAQ;","names":[]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import "./chunk-SJCIM4TC.js";
|
|
8
8
|
import "./chunk-5WRI5ZAA.js";
|
|
9
9
|
|
|
10
|
-
// src/commands/generate-test-plan.ts
|
|
10
|
+
// src/commands/experimental/generate-test-plan.ts
|
|
11
11
|
import { defineCommand } from "citty";
|
|
12
12
|
import { writeFile } from "fs/promises";
|
|
13
13
|
import { join } from "path";
|
|
@@ -118,7 +118,7 @@ ${body}`;
|
|
|
118
118
|
var generate_test_plan_default = defineCommand({
|
|
119
119
|
meta: {
|
|
120
120
|
name: "generate-test-plan",
|
|
121
|
-
description: "
|
|
121
|
+
description: "Generate a test plan stub from user stories"
|
|
122
122
|
},
|
|
123
123
|
args: {
|
|
124
124
|
from: {
|
|
@@ -157,4 +157,4 @@ export {
|
|
|
157
157
|
generate_test_plan_default as default,
|
|
158
158
|
generateTestPlan
|
|
159
159
|
};
|
|
160
|
-
//# sourceMappingURL=generate-test-plan-
|
|
160
|
+
//# sourceMappingURL=generate-test-plan-RQTSGQLR.js.map
|