specdx 0.4.0-alpha.6 → 0.4.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{changelog-XPX4LD7B.js → changelog-FJIQBEBB.js} +4 -4
  2. package/dist/{check-5GQPH66L.js → check-ULQYDDRD.js} +8 -6
  3. package/dist/check-ULQYDDRD.js.map +1 -0
  4. package/dist/{chunk-RVVQKLNL.js → chunk-7JXW2GTJ.js} +107 -14
  5. package/dist/chunk-7JXW2GTJ.js.map +1 -0
  6. package/dist/{chunk-VIYRGPX5.js → chunk-AKNPCB37.js} +64 -25
  7. package/dist/chunk-AKNPCB37.js.map +1 -0
  8. package/dist/{chunk-KAWB5K44.js → chunk-DAZCOUVK.js} +2 -2
  9. package/dist/{chunk-GTMNEGQG.js → chunk-IHTYAW7C.js} +4 -4
  10. package/dist/chunk-IHTYAW7C.js.map +1 -0
  11. package/dist/{chunk-UKSPVBYC.js → chunk-OTDEP6WZ.js} +106 -8
  12. package/dist/chunk-OTDEP6WZ.js.map +1 -0
  13. package/dist/{chunk-WQJLG5KJ.js → chunk-UZ2E6LX7.js} +2 -2
  14. package/dist/{diff-WH4KL2AK.js → diff-ZN2YTGE2.js} +4 -4
  15. package/dist/dist-4MXKMRHE.js +15 -0
  16. package/dist/{dist-ZOIXQ2UW.js → dist-HKVTEPU5.js} +11 -7
  17. package/dist/dist-HKVTEPU5.js.map +1 -0
  18. package/dist/{explain-JFKOAFCD.js → explain-QBV3AESQ.js} +3 -3
  19. package/dist/{generate-33LQORSQ.js → generate-7GNPT2WJ.js} +3 -3
  20. package/dist/{generate-story-EOU6CEHU.js → generate-story-EFHGINHA.js} +3 -3
  21. package/dist/{generate-test-plan-MRK5MFZA.js → generate-test-plan-BO7444RG.js} +3 -3
  22. package/dist/{graph-7PUHYZ5G.js → graph-5XINV7PT.js} +15 -5
  23. package/dist/graph-5XINV7PT.js.map +1 -0
  24. package/dist/index.js +177 -39
  25. package/dist/index.js.map +1 -1
  26. package/dist/{lint-KA4RRYY7.js → lint-PGA7JFKM.js} +10 -5
  27. package/dist/lint-PGA7JFKM.js.map +1 -0
  28. package/dist/main.js +16 -16
  29. package/dist/main.js.map +1 -1
  30. package/dist/{mcp-7PNSMMWB.js → mcp-QTIA76DS.js} +2 -2
  31. package/dist/{migrate-EGF6SSUE.js → migrate-4KF6GHLO.js} +3 -3
  32. package/dist/{pack-VONQOQFP.js → pack-DSOODXAN.js} +7 -6
  33. package/dist/{pack-VONQOQFP.js.map → pack-DSOODXAN.js.map} +1 -1
  34. package/dist/{ready-7YI7BYBE.js → ready-GTCDQOIC.js} +5 -5
  35. package/dist/skills/specdx-verify.md +9 -0
  36. package/dist/{status-ARUBEEOM.js → status-C3YDBH2L.js} +5 -5
  37. package/dist/{update-WD2YAEH4.js → update-ULMSL5XZ.js} +4 -4
  38. package/dist/validate-E7F3Q5BE.js +49 -0
  39. package/dist/validate-E7F3Q5BE.js.map +1 -0
  40. package/package.json +3 -3
  41. package/dist/check-5GQPH66L.js.map +0 -1
  42. package/dist/chunk-GTMNEGQG.js.map +0 -1
  43. package/dist/chunk-RVVQKLNL.js.map +0 -1
  44. package/dist/chunk-UKSPVBYC.js.map +0 -1
  45. package/dist/chunk-VIYRGPX5.js.map +0 -1
  46. package/dist/dist-U7CZLXM5.js +0 -11
  47. package/dist/dist-ZOIXQ2UW.js.map +0 -1
  48. package/dist/graph-7PUHYZ5G.js.map +0 -1
  49. package/dist/lint-KA4RRYY7.js.map +0 -1
  50. package/dist/validate-VPPQWEW5.js +0 -34
  51. package/dist/validate-VPPQWEW5.js.map +0 -1
  52. /package/dist/{changelog-XPX4LD7B.js.map → changelog-FJIQBEBB.js.map} +0 -0
  53. /package/dist/{chunk-KAWB5K44.js.map → chunk-DAZCOUVK.js.map} +0 -0
  54. /package/dist/{chunk-WQJLG5KJ.js.map → chunk-UZ2E6LX7.js.map} +0 -0
  55. /package/dist/{diff-WH4KL2AK.js.map → diff-ZN2YTGE2.js.map} +0 -0
  56. /package/dist/{dist-U7CZLXM5.js.map → dist-4MXKMRHE.js.map} +0 -0
  57. /package/dist/{explain-JFKOAFCD.js.map → explain-QBV3AESQ.js.map} +0 -0
  58. /package/dist/{generate-33LQORSQ.js.map → generate-7GNPT2WJ.js.map} +0 -0
  59. /package/dist/{generate-story-EOU6CEHU.js.map → generate-story-EFHGINHA.js.map} +0 -0
  60. /package/dist/{generate-test-plan-MRK5MFZA.js.map → generate-test-plan-BO7444RG.js.map} +0 -0
  61. /package/dist/{mcp-7PNSMMWB.js.map → mcp-QTIA76DS.js.map} +0 -0
  62. /package/dist/{migrate-EGF6SSUE.js.map → migrate-4KF6GHLO.js.map} +0 -0
  63. /package/dist/{ready-7YI7BYBE.js.map → ready-GTCDQOIC.js.map} +0 -0
  64. /package/dist/{status-ARUBEEOM.js.map → status-C3YDBH2L.js.map} +0 -0
  65. /package/dist/{update-WD2YAEH4.js.map → update-ULMSL5XZ.js.map} +0 -0
@@ -2,11 +2,11 @@ import {
2
2
  DEFAULT_DIFF_CONFIG,
3
3
  DiffError,
4
4
  diffBetweenRefs
5
- } from "./chunk-WQJLG5KJ.js";
5
+ } from "./chunk-UZ2E6LX7.js";
6
6
  import {
7
7
  loadConfig
8
- } from "./chunk-GTMNEGQG.js";
9
- import "./chunk-RVVQKLNL.js";
8
+ } from "./chunk-IHTYAW7C.js";
9
+ import "./chunk-7JXW2GTJ.js";
10
10
 
11
11
  // src/commands/changelog.ts
12
12
  import { defineCommand } from "citty";
@@ -90,4 +90,4 @@ export {
90
90
  changelog_default as default,
91
91
  runChangelog
92
92
  };
93
- //# sourceMappingURL=changelog-XPX4LD7B.js.map
93
+ //# sourceMappingURL=changelog-FJIQBEBB.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runCheck
3
- } from "./chunk-UKSPVBYC.js";
3
+ } from "./chunk-OTDEP6WZ.js";
4
4
  import {
5
5
  sharedArgs
6
6
  } from "./chunk-GAM4MXPC.js";
@@ -9,8 +9,8 @@ import {
9
9
  loadConfig,
10
10
  parseSpec,
11
11
  resolveGlob
12
- } from "./chunk-GTMNEGQG.js";
13
- import "./chunk-RVVQKLNL.js";
12
+ } from "./chunk-IHTYAW7C.js";
13
+ import "./chunk-7JXW2GTJ.js";
14
14
 
15
15
  // src/commands/check.ts
16
16
  import { defineCommand } from "citty";
@@ -49,7 +49,7 @@ var check_default = defineCommand({
49
49
  logger.debug(`Checking ${specs.length} specs...`);
50
50
  const result = await runCheck(specs, configDir, checkConfig);
51
51
  if (args.ai) {
52
- const { analyzeWithAi } = await import("./dist-U7CZLXM5.js");
52
+ const { analyzeWithAi } = await import("./dist-4MXKMRHE.js");
53
53
  const aiResult = await analyzeWithAi(result.findings, args.spec ?? "full suite check");
54
54
  if (args.format === "json") {
55
55
  console.log(JSON.stringify({ ...result, ai: aiResult }, null, 2));
@@ -93,7 +93,9 @@ var check_default = defineCommand({
93
93
  console.log(` Scanned: framework=${result.scanned.framework ?? "none detected"}`);
94
94
  console.log(` routes: ${fmt(result.scanned.codeRoutes)}`);
95
95
  console.log(` types: ${fmt(result.scanned.codeTypes)}`);
96
- console.log(` tests: ${fmt(result.scanned.codeTests)}
96
+ console.log(` tests: ${fmt(result.scanned.codeTests)}`);
97
+ const artifacts = result.scanned.artifacts === null ? "none declared" : `${result.scanned.artifacts} verified`;
98
+ console.log(` artifacts: ${artifacts}
97
99
  `);
98
100
  }
99
101
  for (const [category, stats] of Object.entries(result.score.byCategory)) {
@@ -130,4 +132,4 @@ var check_default = defineCommand({
130
132
  export {
131
133
  check_default as default
132
134
  };
133
- //# sourceMappingURL=check-5GQPH66L.js.map
135
+ //# sourceMappingURL=check-ULQYDDRD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/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 \"[experimental] 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: \"[experimental] 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 console.log(` artifacts: ${artifacts}\\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.type === \"extra\" ? \"ℹ\" : f.severity === \"error\" ? \"✗\" : \"⚠\";\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,MACF,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,aAAa,EAAE,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;AACxE,UAAM,YAAY,QAAQ,IAAI;AAC9B,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAEpD,WAAO,MAAM,kBAAkB;AAG/B,UAAM,QAAsB,CAAC;AAC7B,eAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,YAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,iBAAW,KAAK,OAAO;AACrB,cAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAI,KAAK,QAAQ,KAAK,YAAY,OAAO,KAAK,KAAM;AACpD,cAAM,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,cAA2B;AAAA,MAC/B,GAAG,OAAO;AAAA,MACV,GAAI,KAAK,YAAY,EAAE,WAAW,KAAK,UAAsC,IAAI,CAAC;AAAA,IACpF;AAEA,WAAO,MAAM,YAAY,MAAM,MAAM,WAAW;AAChD,UAAM,SAAS,MAAM,SAAS,OAAO,WAAW,WAAW;AAG3D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,CAAC,MAAM,EAAE,aAAa,OAAO,EAAE;AACrE,YAAM,WAAW,OAAO,SAAS,OAAO,CAAC,MAAM,EAAE,aAAa,MAAM,EAAE;AACtE,YAAM,OAAO,OAAO,SAAS,OAAO,CAAC,MAAM,EAAE,aAAa,MAAM,EAAE;AAClE,cAAQ,IAAI;AAAA,IAAO,MAAM,YAAY,QAAQ,cAAc,IAAI;AAAA,CAAS;AAAA,IAC1E;AAEA,QAAI,OAAO,SAAS,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO,GAAG;AACvD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,CAAC,OAAO,MAAM,UAAU;AAC1B,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -41,30 +41,123 @@ var base_spec_default = {
41
41
  $schema: "http://json-schema.org/draft-07/schema#",
42
42
  type: "object",
43
43
  properties: {
44
- id: { type: "string", minLength: 1 },
45
- type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract", "epic", "quick-spec", "project-context"] },
46
- title: { type: "string", minLength: 1 },
47
- status: { type: "string", enum: ["draft", "review", "approved", "superseded"] },
48
- version: { type: "string" },
49
- created: { type: "string", format: "date" },
50
- updated: { type: "string", format: "date" },
51
- authors: { type: "array", items: { type: "string" }, minItems: 1 },
52
- tags: { type: "array", items: { type: "string" }, default: [] },
44
+ id: {
45
+ type: "string",
46
+ minLength: 1
47
+ },
48
+ type: {
49
+ type: "string",
50
+ enum: [
51
+ "prd",
52
+ "technical-design",
53
+ "user-story",
54
+ "test-plan",
55
+ "adr",
56
+ "api-contract",
57
+ "epic",
58
+ "quick-spec",
59
+ "project-context"
60
+ ]
61
+ },
62
+ title: {
63
+ type: "string",
64
+ minLength: 1
65
+ },
66
+ status: {
67
+ type: "string",
68
+ enum: [
69
+ "draft",
70
+ "review",
71
+ "approved",
72
+ "superseded"
73
+ ]
74
+ },
75
+ version: {
76
+ type: "string"
77
+ },
78
+ created: {
79
+ type: "string",
80
+ format: "date"
81
+ },
82
+ updated: {
83
+ type: "string",
84
+ format: "date"
85
+ },
86
+ authors: {
87
+ type: "array",
88
+ items: {
89
+ type: "string"
90
+ },
91
+ minItems: 1
92
+ },
93
+ tags: {
94
+ type: "array",
95
+ items: {
96
+ type: "string"
97
+ },
98
+ default: []
99
+ },
53
100
  references: {
54
101
  type: "array",
55
102
  items: {
56
103
  type: "object",
57
104
  properties: {
58
- id: { type: "string" },
59
- relationship: { type: "string", enum: ["implemented-by", "decomposed-into", "depends-on", "supersedes", "related-to"] }
105
+ id: {
106
+ type: "string"
107
+ },
108
+ relationship: {
109
+ type: "string",
110
+ enum: [
111
+ "implemented-by",
112
+ "decomposed-into",
113
+ "depends-on",
114
+ "supersedes",
115
+ "related-to"
116
+ ]
117
+ }
118
+ },
119
+ required: [
120
+ "id",
121
+ "relationship"
122
+ ],
123
+ additionalProperties: false
124
+ },
125
+ default: []
126
+ },
127
+ artifacts: {
128
+ type: "array",
129
+ items: {
130
+ type: "object",
131
+ properties: {
132
+ path: {
133
+ type: "string",
134
+ minLength: 1
135
+ },
136
+ exports: {
137
+ type: "array",
138
+ items: {
139
+ type: "string",
140
+ minLength: 1
141
+ }
142
+ }
60
143
  },
61
- required: ["id", "relationship"],
144
+ required: [
145
+ "path"
146
+ ],
62
147
  additionalProperties: false
63
148
  },
64
149
  default: []
65
150
  }
66
151
  },
67
- required: ["id", "type", "title", "status", "version", "created", "authors"],
152
+ required: [
153
+ "id",
154
+ "type",
155
+ "title",
156
+ "status",
157
+ "version",
158
+ "created",
159
+ "authors"
160
+ ],
68
161
  additionalProperties: true
69
162
  };
70
163
 
@@ -336,4 +429,4 @@ export {
336
429
  validateSpec,
337
430
  validateConfig
338
431
  };
339
- //# sourceMappingURL=chunk-RVVQKLNL.js.map
432
+ //# sourceMappingURL=chunk-7JXW2GTJ.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\nexport interface SpecReference {\n id: string;\n relationship: \"implemented-by\" | \"decomposed-into\" | \"depends-on\" | \"supersedes\" | \"related-to\";\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;EACA;EACA;EACA;;;;ACPK,IAAM,oBAAgD;EAC3D,KAAK,CAAC,qBAAqB,SAAS,aAAa,YAAY,kBAAkB;EAC/E,oBAAoB;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF,cAAc,CAAC,eAAe,uBAAuB,gBAA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31 +294,66 @@ function compressSpec(specId, type, title, status, updatedDate, parsedSections,
294
294
  // ../pack/dist/allocator.js
295
295
  var HIGH_RELEVANCE = 0.75;
296
296
  var MIN_TRIM_BUDGET = 150;
297
- var OMITTED_MARKER = "[section omitted to fit token budget]";
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
+ }
298
302
  function trimToBudget(compressed, budget) {
299
- const markerTokens = countTokens(OMITTED_MARKER);
300
- const kept = [];
301
- let used = 0;
302
- let keptReal = false;
303
- for (const section of compressed.sections) {
304
- if (used + section.tokens <= budget) {
305
- kept.push(section);
306
- used += section.tokens;
307
- keptReal = true;
308
- } else if (used + markerTokens <= budget) {
309
- kept.push({
310
- heading: section.heading,
311
- content: OMITTED_MARKER,
312
- tokens: markerTokens,
313
- compressed: true,
314
- originalTokens: section.tokens
315
- });
316
- used += markerTokens;
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]);
317
354
  }
355
+ return { spec: { ...compressed, sections: out }, tokens: used + markerTokens };
318
356
  }
319
- if (!keptReal)
320
- return null;
321
- return { spec: { ...compressed, sections: kept }, tokens: used };
322
357
  }
323
358
  function allocate(specs, scores, options) {
324
359
  const specMap = /* @__PURE__ */ new Map();
@@ -390,11 +425,13 @@ function allocate(specs, scores, options) {
390
425
  }
391
426
  }
392
427
  let sectionsCompressed = 0;
428
+ let sectionsOmitted = 0;
393
429
  for (const item of included) {
394
430
  for (const section of item.compressed.sections) {
395
431
  if (section.compressed) {
396
432
  sectionsCompressed++;
397
433
  }
434
+ sectionsOmitted += section.omittedSections ?? 0;
398
435
  }
399
436
  }
400
437
  const allocations = [];
@@ -424,6 +461,7 @@ function allocate(specs, scores, options) {
424
461
  specsIncluded: included.length,
425
462
  specsExcluded: excluded.length,
426
463
  sectionsCompressed,
464
+ sectionsOmitted,
427
465
  allocations
428
466
  };
429
467
  return {
@@ -438,7 +476,7 @@ function escapeXml(text) {
438
476
  }
439
477
  function formatXml(specs, stats) {
440
478
  const lines = [];
441
- 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}">`);
442
480
  for (const spec of specs) {
443
481
  const alloc = stats.allocations.find((a) => a.specId === spec.specId);
444
482
  const relevance = alloc?.relevance ?? 0;
@@ -497,6 +535,7 @@ function formatJson(specs, stats) {
497
535
  const output = {
498
536
  budget: stats.budget,
499
537
  used: stats.used,
538
+ sectionsOmitted: stats.sectionsOmitted,
500
539
  specs: specs.map((spec) => {
501
540
  const alloc = stats.allocations.find((a) => a.specId === spec.specId);
502
541
  const relevance = alloc?.relevance ?? 0;
@@ -625,4 +664,4 @@ function pack(specs, options, packConfig, graph) {
625
664
  export {
626
665
  pack
627
666
  };
628
- //# sourceMappingURL=chunk-VIYRGPX5.js.map
667
+ //# sourceMappingURL=chunk-AKNPCB37.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, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\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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Y;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"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REQUIRED_SECTIONS
3
- } from "./chunk-RVVQKLNL.js";
3
+ } from "./chunk-7JXW2GTJ.js";
4
4
 
5
5
  // ../lint/dist/engine.js
6
6
  function createLintEngine(options) {
@@ -493,4 +493,4 @@ export {
493
493
  createLintEngine,
494
494
  getPreset
495
495
  };
496
- //# sourceMappingURL=chunk-KAWB5K44.js.map
496
+ //# sourceMappingURL=chunk-DAZCOUVK.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  validateConfig,
3
3
  validateSpec
4
- } from "./chunk-RVVQKLNL.js";
4
+ } from "./chunk-7JXW2GTJ.js";
5
5
 
6
6
  // ../core/dist/config.js
7
7
  import { readFile } from "fs/promises";
@@ -264,7 +264,6 @@ function buildGraph(config) {
264
264
  }
265
265
  var DEPENDENCY_RELATIONSHIPS = {
266
266
  "depends-on": "self-requires-target",
267
- "decomposed-into": "target-requires-self",
268
267
  "implemented-by": "target-requires-self"
269
268
  };
270
269
  function collectReferenceEdges(specs) {
@@ -305,7 +304,8 @@ function findUnreflectedReferences(referenceEdges, idToEntry, graph) {
305
304
  const requiringEntry = direction === "self-requires-target" ? selfEntry : targetEntry;
306
305
  const requiredEntry = direction === "self-requires-target" ? targetEntry : selfEntry;
307
306
  if (!configEdges.has(`${requiredEntry}\u2192${requiringEntry}`)) {
308
- missing.push({ edge, requiringEntry, requiredEntry });
307
+ const createsCycle = graph.getDownstream(requiringEntry).includes(requiredEntry);
308
+ missing.push({ edge, requiringEntry, requiredEntry, createsCycle });
309
309
  }
310
310
  }
311
311
  return missing;
@@ -347,4 +347,4 @@ export {
347
347
  resolveGlob,
348
348
  createLogger
349
349
  };
350
- //# sourceMappingURL=chunk-GTMNEGQG.js.map
350
+ //# sourceMappingURL=chunk-IHTYAW7C.js.map