specdx 0.4.0-alpha.17 → 0.4.0-alpha.19
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 +1 -1
- package/README.md +477 -0
- package/dist/{check-Q3QKTN2D.js → check-PRQNMBOE.js} +5 -5
- package/dist/{chunk-PEC5LAVE.js → chunk-5MYELBKF.js} +56 -21
- package/dist/chunk-5MYELBKF.js.map +1 -0
- package/dist/{chunk-V7JOVK6D.js → chunk-BD6UDHYW.js} +194 -39
- package/dist/chunk-BD6UDHYW.js.map +1 -0
- package/dist/{chunk-TJPPBM24.js → chunk-ERRUYMZO.js} +21 -18
- package/dist/chunk-ERRUYMZO.js.map +1 -0
- package/dist/{chunk-Z77VQUZ3.js → chunk-MM325DR6.js} +2 -2
- package/dist/chunk-RDNEANZB.js +103 -0
- package/dist/chunk-RDNEANZB.js.map +1 -0
- package/dist/{chunk-4HPWTWBL.js → chunk-RY5CDUNN.js} +12 -7
- package/dist/chunk-RY5CDUNN.js.map +1 -0
- package/dist/{chunk-TF7WSPFV.js → chunk-T232GZ2L.js} +2 -2
- package/dist/{chunk-SJCIM4TC.js → chunk-ZIPGRLYE.js} +3 -1
- package/dist/chunk-ZIPGRLYE.js.map +1 -0
- package/dist/{diff-IEN6W4OG.js → diff-PHEX3HUT.js} +4 -4
- package/dist/{dist-DVROIZAO.js → dist-M7X5RJB3.js} +19 -11
- package/dist/dist-M7X5RJB3.js.map +1 -0
- package/dist/{dist-SWJSMLIP.js → dist-X4CSVKKR.js} +2 -2
- package/dist/{generate-GQPOLFP7.js → generate-FIMBI2NW.js} +5 -5
- package/dist/{generate-story-UJS37FHA.js → generate-story-5TPTJA7B.js} +41 -18
- package/dist/generate-story-5TPTJA7B.js.map +1 -0
- package/dist/{generate-test-plan-RQTSGQLR.js → generate-test-plan-XBAFJKJI.js} +58 -9
- package/dist/generate-test-plan-XBAFJKJI.js.map +1 -0
- package/dist/{graph-OKUMHR3Q.js → graph-UZJMLX4J.js} +3 -3
- package/dist/index.d.ts +171 -0
- package/dist/index.js +201 -41
- package/dist/index.js.map +1 -1
- package/dist/{lint-VB5PV32N.js → lint-PUAQ2UL6.js} +4 -4
- package/dist/main.js +5 -90
- package/dist/main.js.map +1 -1
- package/dist/{mcp-DADOVCEV.js → mcp-WTO5PDIS.js} +6 -3
- package/dist/mcp-WTO5PDIS.js.map +1 -0
- package/dist/{migrate-LAMRDT3V.js → migrate-DEFCNOAH.js} +18 -7
- package/dist/migrate-DEFCNOAH.js.map +1 -0
- package/dist/{pack-B3KYRKUR.js → pack-PNLD5AYW.js} +4 -4
- package/dist/{ready-C6YXJ47W.js → ready-XIO2IPRE.js} +15 -6
- package/dist/ready-XIO2IPRE.js.map +1 -0
- package/dist/skills/core/specdx-author-spec/SKILL.md +1 -1
- package/dist/skills/core/specdx-author-spec/references/step-02-sections.md +41 -0
- package/dist/skills/core/specdx-router/SKILL.md +2 -2
- package/dist/skills/experimental/specdx-check-drift/SKILL.md +1 -1
- package/dist/skills/experimental/specdx-verify/SKILL.md +1 -1
- package/dist/{status-BRLCD7NY.js → status-BXOYBOH6.js} +5 -5
- package/dist/{update-P6TQUI6H.js → update-ELXABLVS.js} +4 -4
- package/dist/{validate-WIB246IE.js → validate-FXD5WS4C.js} +3 -3
- package/hooks/hooks.json +1 -1
- package/hooks/session-start +35 -3
- package/package.json +19 -6
- package/dist/chunk-4HPWTWBL.js.map +0 -1
- package/dist/chunk-PEC5LAVE.js.map +0 -1
- package/dist/chunk-SJCIM4TC.js.map +0 -1
- package/dist/chunk-TJPPBM24.js.map +0 -1
- package/dist/chunk-V7JOVK6D.js.map +0 -1
- package/dist/dist-DVROIZAO.js.map +0 -1
- package/dist/generate-story-UJS37FHA.js.map +0 -1
- package/dist/generate-test-plan-RQTSGQLR.js.map +0 -1
- package/dist/mcp-DADOVCEV.js.map +0 -1
- package/dist/migrate-LAMRDT3V.js.map +0 -1
- package/dist/ready-C6YXJ47W.js.map +0 -1
- /package/dist/{check-Q3QKTN2D.js.map → check-PRQNMBOE.js.map} +0 -0
- /package/dist/{chunk-Z77VQUZ3.js.map → chunk-MM325DR6.js.map} +0 -0
- /package/dist/{chunk-TF7WSPFV.js.map → chunk-T232GZ2L.js.map} +0 -0
- /package/dist/{diff-IEN6W4OG.js.map → diff-PHEX3HUT.js.map} +0 -0
- /package/dist/{dist-SWJSMLIP.js.map → dist-X4CSVKKR.js.map} +0 -0
- /package/dist/{generate-GQPOLFP7.js.map → generate-FIMBI2NW.js.map} +0 -0
- /package/dist/{graph-OKUMHR3Q.js.map → graph-UZJMLX4J.js.map} +0 -0
- /package/dist/{lint-VB5PV32N.js.map → lint-PUAQ2UL6.js.map} +0 -0
- /package/dist/{pack-B3KYRKUR.js.map → pack-PNLD5AYW.js.map} +0 -0
- /package/dist/{status-BRLCD7NY.js.map → status-BXOYBOH6.js.map} +0 -0
- /package/dist/{update-P6TQUI6H.js.map → update-ELXABLVS.js.map} +0 -0
- /package/dist/{validate-WIB246IE.js.map → validate-FXD5WS4C.js.map} +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
type Template = "lightweight" | "bmad" | "api-first" | "quick" | "context";
|
|
2
|
+
interface ScaffoldOptions {
|
|
3
|
+
projectName: string;
|
|
4
|
+
template: Template;
|
|
5
|
+
targetDir: string;
|
|
6
|
+
}
|
|
7
|
+
declare function scaffoldProject({ projectName, template, targetDir, }: ScaffoldOptions): Promise<void>;
|
|
8
|
+
|
|
9
|
+
type Severity = "error" | "warn" | "info";
|
|
10
|
+
interface Diagnostic {
|
|
11
|
+
ruleId: string;
|
|
12
|
+
severity: Severity;
|
|
13
|
+
message: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
line?: number;
|
|
16
|
+
section?: string;
|
|
17
|
+
}
|
|
18
|
+
interface LintResults {
|
|
19
|
+
diagnostics: Diagnostic[];
|
|
20
|
+
hasErrors: boolean;
|
|
21
|
+
hasWarnings: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RunLintOptions {
|
|
25
|
+
configDir: string;
|
|
26
|
+
specPath?: string;
|
|
27
|
+
preset?: "minimal" | "recommended" | "strict";
|
|
28
|
+
}
|
|
29
|
+
/** Lint results plus whether anything was actually linted (vacuous-pass audit). */
|
|
30
|
+
interface RunLintResults extends LintResults {
|
|
31
|
+
/** Number of specs linted. */
|
|
32
|
+
specCount: number;
|
|
33
|
+
/** False when no specs resolved — "no diagnostics" is then not a pass. */
|
|
34
|
+
assessed: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare function runLint(options: RunLintOptions): Promise<RunLintResults>;
|
|
37
|
+
|
|
38
|
+
/** Statistics about how the budget was allocated. */
|
|
39
|
+
interface PackStats {
|
|
40
|
+
/** Total token budget. */
|
|
41
|
+
budget: number;
|
|
42
|
+
/** Tokens actually used. */
|
|
43
|
+
used: number;
|
|
44
|
+
/** Number of specs included in the output. */
|
|
45
|
+
specsIncluded: number;
|
|
46
|
+
/** Number of specs excluded due to budget or relevance. */
|
|
47
|
+
specsExcluded: number;
|
|
48
|
+
/** Number of sections that were compressed. */
|
|
49
|
+
sectionsCompressed: number;
|
|
50
|
+
/** Number of sections omitted entirely to fit the budget. */
|
|
51
|
+
sectionsOmitted: number;
|
|
52
|
+
/** Per-spec allocation details. */
|
|
53
|
+
allocations: SpecAllocation[];
|
|
54
|
+
}
|
|
55
|
+
/** Result returned by the pack operation. */
|
|
56
|
+
interface PackResult {
|
|
57
|
+
/** The formatted output string. */
|
|
58
|
+
output: string;
|
|
59
|
+
/** Statistics about the pack run. */
|
|
60
|
+
stats: PackStats;
|
|
61
|
+
}
|
|
62
|
+
/** Token allocation detail for a single spec. */
|
|
63
|
+
interface SpecAllocation {
|
|
64
|
+
/** Identifier of the spec. */
|
|
65
|
+
specId: string;
|
|
66
|
+
/** Spec type (e.g. "adr", "rfc", "runbook"). */
|
|
67
|
+
type: string;
|
|
68
|
+
/** Computed relevance score (0-1). */
|
|
69
|
+
relevance: number;
|
|
70
|
+
/** Tokens allocated to this spec. */
|
|
71
|
+
tokens: number;
|
|
72
|
+
/** Whether this spec was compressed. */
|
|
73
|
+
compressed: boolean;
|
|
74
|
+
/** Whether this spec was included in the output. */
|
|
75
|
+
included: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface RunPackOptions {
|
|
79
|
+
configDir: string;
|
|
80
|
+
task?: string;
|
|
81
|
+
specs?: string[];
|
|
82
|
+
budget?: number;
|
|
83
|
+
format?: "xml" | "markdown" | "json";
|
|
84
|
+
full?: boolean;
|
|
85
|
+
dryRun?: boolean;
|
|
86
|
+
}
|
|
87
|
+
declare function runPack(options: RunPackOptions): Promise<PackResult & {
|
|
88
|
+
specsResolved: number;
|
|
89
|
+
}>;
|
|
90
|
+
|
|
91
|
+
type FieldChangeType = "added" | "removed" | "modified" | "broken-reference";
|
|
92
|
+
interface FieldChange {
|
|
93
|
+
field: string;
|
|
94
|
+
type: FieldChangeType;
|
|
95
|
+
before?: unknown;
|
|
96
|
+
after?: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface SectionChange {
|
|
99
|
+
heading: string;
|
|
100
|
+
type: "added" | "removed" | "modified";
|
|
101
|
+
contentDiff?: string;
|
|
102
|
+
}
|
|
103
|
+
interface SpecDiff {
|
|
104
|
+
specId: string;
|
|
105
|
+
filePath: string;
|
|
106
|
+
frontmatter: FieldChange[];
|
|
107
|
+
sections: SectionChange[];
|
|
108
|
+
summary: string;
|
|
109
|
+
}
|
|
110
|
+
interface DownstreamImpact {
|
|
111
|
+
specId: string;
|
|
112
|
+
filePath: string;
|
|
113
|
+
distance: number;
|
|
114
|
+
lastUpdated: string | null;
|
|
115
|
+
staleness: number;
|
|
116
|
+
reason: string;
|
|
117
|
+
}
|
|
118
|
+
interface ImpactAnalysis {
|
|
119
|
+
changedSpec: string;
|
|
120
|
+
downstream: DownstreamImpact[];
|
|
121
|
+
totalAffected: number;
|
|
122
|
+
}
|
|
123
|
+
interface DiffResult {
|
|
124
|
+
diffs: SpecDiff[];
|
|
125
|
+
added: string[];
|
|
126
|
+
removed: string[];
|
|
127
|
+
impact: ImpactAnalysis[];
|
|
128
|
+
summary: string;
|
|
129
|
+
/**
|
|
130
|
+
* Spec files changed in the working tree but not covered by the comparison.
|
|
131
|
+
*
|
|
132
|
+
* A ref-to-ref diff cannot see uncommitted work, so reporting "no changes"
|
|
133
|
+
* without this would be a false all-clear. Always empty in working mode,
|
|
134
|
+
* where those changes are part of the comparison.
|
|
135
|
+
*/
|
|
136
|
+
uncommittedSpecFiles: string[];
|
|
137
|
+
}
|
|
138
|
+
interface StatusResult {
|
|
139
|
+
project: string;
|
|
140
|
+
specCount: number;
|
|
141
|
+
byStatus: Record<string, number>;
|
|
142
|
+
lintHealth: {
|
|
143
|
+
errors: number;
|
|
144
|
+
warnings: number;
|
|
145
|
+
passing: number;
|
|
146
|
+
};
|
|
147
|
+
staleSpecs: {
|
|
148
|
+
specId: string;
|
|
149
|
+
daysSinceUpdate: number;
|
|
150
|
+
owner?: string;
|
|
151
|
+
}[];
|
|
152
|
+
integrityIssues: string[];
|
|
153
|
+
/** "unassessed" when the suite resolved to zero specs — never a vacuous "healthy". */
|
|
154
|
+
verdict: "healthy" | "warnings" | "errors" | "unassessed";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface RunDiffOptions {
|
|
158
|
+
base?: string;
|
|
159
|
+
head?: string;
|
|
160
|
+
spec?: string;
|
|
161
|
+
format?: string;
|
|
162
|
+
/** Compare the base ref against the working tree instead of a head ref. */
|
|
163
|
+
working?: boolean;
|
|
164
|
+
}
|
|
165
|
+
declare function runDiff(options: RunDiffOptions): Promise<DiffResult>;
|
|
166
|
+
|
|
167
|
+
declare function runStatus(_options?: {
|
|
168
|
+
format?: string;
|
|
169
|
+
}): Promise<StatusResult>;
|
|
170
|
+
|
|
171
|
+
export { runDiff, runLint, runPack, runStatus, scaffoldProject };
|
package/dist/index.js
CHANGED
|
@@ -1545,7 +1545,7 @@ var require_picomatch2 = __commonJS({
|
|
|
1545
1545
|
// src/commands/core/init.ts
|
|
1546
1546
|
import { defineCommand } from "citty";
|
|
1547
1547
|
import { mkdir, writeFile } from "fs/promises";
|
|
1548
|
-
import { join } from "path";
|
|
1548
|
+
import { join, basename, resolve } from "path";
|
|
1549
1549
|
|
|
1550
1550
|
// ../schema/dist/types.js
|
|
1551
1551
|
var SPEC_TYPES = [
|
|
@@ -2059,6 +2059,9 @@ async function scaffoldProject({
|
|
|
2059
2059
|
const configContent = buildConfigYaml(projectName, specs);
|
|
2060
2060
|
await writeFile(join(targetDir, "spec.config.yaml"), configContent, "utf-8");
|
|
2061
2061
|
}
|
|
2062
|
+
function defaultProjectName(dir) {
|
|
2063
|
+
return basename(resolve(dir)) || "my-project";
|
|
2064
|
+
}
|
|
2062
2065
|
var init_default = defineCommand({
|
|
2063
2066
|
meta: {
|
|
2064
2067
|
name: "init",
|
|
@@ -2067,8 +2070,7 @@ var init_default = defineCommand({
|
|
|
2067
2070
|
args: {
|
|
2068
2071
|
name: {
|
|
2069
2072
|
type: "string",
|
|
2070
|
-
description: "Project name"
|
|
2071
|
-
required: true
|
|
2073
|
+
description: "Project name (default: the target directory's name)"
|
|
2072
2074
|
},
|
|
2073
2075
|
template: {
|
|
2074
2076
|
type: "string",
|
|
@@ -2082,12 +2084,13 @@ var init_default = defineCommand({
|
|
|
2082
2084
|
}
|
|
2083
2085
|
},
|
|
2084
2086
|
async run({ args }) {
|
|
2085
|
-
const {
|
|
2087
|
+
const { template, dir } = args;
|
|
2086
2088
|
const validTemplates = ["lightweight", "bmad", "api-first", "quick", "context"];
|
|
2087
2089
|
if (!validTemplates.includes(template)) {
|
|
2088
2090
|
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
2089
2091
|
process.exit(1);
|
|
2090
2092
|
}
|
|
2093
|
+
const name = args.name || defaultProjectName(dir);
|
|
2091
2094
|
console.log(`Scaffolding "${name}" with template "${template}" in ${dir}...`);
|
|
2092
2095
|
await scaffoldProject({ projectName: name, template, targetDir: dir });
|
|
2093
2096
|
console.log(`Done! Project "${name}" scaffolded successfully.`);
|
|
@@ -2484,7 +2487,7 @@ function createLogger(options) {
|
|
|
2484
2487
|
|
|
2485
2488
|
// ../core/dist/preset.js
|
|
2486
2489
|
import { readFile as readFile3 } from "fs/promises";
|
|
2487
|
-
import { resolve, isAbsolute as isAbsolute2 } from "path";
|
|
2490
|
+
import { resolve as resolve2, isAbsolute as isAbsolute2 } from "path";
|
|
2488
2491
|
|
|
2489
2492
|
// ../lint/dist/engine.js
|
|
2490
2493
|
function createLintEngine(options) {
|
|
@@ -2512,6 +2515,18 @@ function createLintEngine(options) {
|
|
|
2512
2515
|
}
|
|
2513
2516
|
|
|
2514
2517
|
// ../lint/dist/rules/valid-frontmatter.js
|
|
2518
|
+
function readablePath(instancePath) {
|
|
2519
|
+
return instancePath.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
2520
|
+
}
|
|
2521
|
+
function describeValidationError(err) {
|
|
2522
|
+
const path = readablePath(err.instancePath ?? "");
|
|
2523
|
+
const allowed = err.params?.allowedValues;
|
|
2524
|
+
let detail = err.message ?? JSON.stringify(err);
|
|
2525
|
+
if (Array.isArray(allowed) && allowed.length > 0) {
|
|
2526
|
+
detail += `: ${allowed.map((v) => JSON.stringify(v)).join(", ")}`;
|
|
2527
|
+
}
|
|
2528
|
+
return path ? `${path} ${detail}` : detail;
|
|
2529
|
+
}
|
|
2515
2530
|
var validFrontmatterRule = {
|
|
2516
2531
|
id: "structure/valid-frontmatter",
|
|
2517
2532
|
description: "Frontmatter matches the schema for the declared spec type",
|
|
@@ -2523,7 +2538,7 @@ var validFrontmatterRule = {
|
|
|
2523
2538
|
return errors.map((err) => ({
|
|
2524
2539
|
ruleId: "structure/valid-frontmatter",
|
|
2525
2540
|
severity: "error",
|
|
2526
|
-
message: `Invalid frontmatter: ${
|
|
2541
|
+
message: `Invalid frontmatter: ${describeValidationError(err)}`,
|
|
2527
2542
|
filePath: context.spec.filePath
|
|
2528
2543
|
}));
|
|
2529
2544
|
}
|
|
@@ -2583,7 +2598,110 @@ var noCircularDepsRule = {
|
|
|
2583
2598
|
};
|
|
2584
2599
|
|
|
2585
2600
|
// ../lint/dist/rules/story-coverage.js
|
|
2586
|
-
var
|
|
2601
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
2602
|
+
"a",
|
|
2603
|
+
"an",
|
|
2604
|
+
"the",
|
|
2605
|
+
"and",
|
|
2606
|
+
"or",
|
|
2607
|
+
"of",
|
|
2608
|
+
"to",
|
|
2609
|
+
"for",
|
|
2610
|
+
"with",
|
|
2611
|
+
"its",
|
|
2612
|
+
"it",
|
|
2613
|
+
"in",
|
|
2614
|
+
"on",
|
|
2615
|
+
"at",
|
|
2616
|
+
"by",
|
|
2617
|
+
"from",
|
|
2618
|
+
"into",
|
|
2619
|
+
"every",
|
|
2620
|
+
"each",
|
|
2621
|
+
"that",
|
|
2622
|
+
"this",
|
|
2623
|
+
"be",
|
|
2624
|
+
"is",
|
|
2625
|
+
"are",
|
|
2626
|
+
"as",
|
|
2627
|
+
"can",
|
|
2628
|
+
"will",
|
|
2629
|
+
"must",
|
|
2630
|
+
"so",
|
|
2631
|
+
"their",
|
|
2632
|
+
"them",
|
|
2633
|
+
"when",
|
|
2634
|
+
"which",
|
|
2635
|
+
"who"
|
|
2636
|
+
]);
|
|
2637
|
+
var OVERLAP_THRESHOLD = 0.5;
|
|
2638
|
+
var REFERENCED_THRESHOLD = 0.34;
|
|
2639
|
+
function tokenise(text) {
|
|
2640
|
+
const words = text.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").split(/\s+/).filter((w) => w.length > 2 && !STOPWORDS.has(w)).map((w) => w.length > 3 && w.endsWith("s") && !w.endsWith("ss") ? w.slice(0, -1) : w);
|
|
2641
|
+
return new Set(words);
|
|
2642
|
+
}
|
|
2643
|
+
function extractFeatureSection(content) {
|
|
2644
|
+
const lines = content.split("\n");
|
|
2645
|
+
const start = lines.findIndex((l) => /^##\s+Features\s*$/.test(l.trim()));
|
|
2646
|
+
if (start === -1)
|
|
2647
|
+
return null;
|
|
2648
|
+
const body = [];
|
|
2649
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
2650
|
+
if (/^##\s/.test(lines[i]))
|
|
2651
|
+
break;
|
|
2652
|
+
body.push(lines[i]);
|
|
2653
|
+
}
|
|
2654
|
+
return body.join("\n");
|
|
2655
|
+
}
|
|
2656
|
+
function parseFeatures(content) {
|
|
2657
|
+
return parseFeatureEntries(content).map((f) => f.text);
|
|
2658
|
+
}
|
|
2659
|
+
function parseFeatureEntries(content) {
|
|
2660
|
+
const section = extractFeatureSection(content);
|
|
2661
|
+
if (section === null)
|
|
2662
|
+
return [];
|
|
2663
|
+
const ID_PREFIX = /^\*{0,2}F(\d+)\*{0,2}\s*[:.-]\s*/i;
|
|
2664
|
+
const features = [];
|
|
2665
|
+
for (const rawLine of section.split("\n")) {
|
|
2666
|
+
const line = rawLine.trim();
|
|
2667
|
+
if (!line)
|
|
2668
|
+
continue;
|
|
2669
|
+
const bullet = /^[-*]\s+(.*)$/.exec(line);
|
|
2670
|
+
const text = bullet ? (bullet[1] ?? "").trim() : ID_PREFIX.test(line) ? line : "";
|
|
2671
|
+
if (!text)
|
|
2672
|
+
continue;
|
|
2673
|
+
const idMatch = ID_PREFIX.exec(text);
|
|
2674
|
+
const stripped = text.replace(ID_PREFIX, "").trim();
|
|
2675
|
+
if (stripped)
|
|
2676
|
+
features.push({ text: stripped, num: idMatch?.[1] });
|
|
2677
|
+
}
|
|
2678
|
+
return features;
|
|
2679
|
+
}
|
|
2680
|
+
function overlap(featureTokens, storyTokens) {
|
|
2681
|
+
if (featureTokens.size === 0)
|
|
2682
|
+
return 0;
|
|
2683
|
+
let shared = 0;
|
|
2684
|
+
for (const token of featureTokens)
|
|
2685
|
+
if (storyTokens.has(token))
|
|
2686
|
+
shared++;
|
|
2687
|
+
return shared / featureTokens.size;
|
|
2688
|
+
}
|
|
2689
|
+
function referencesSpec(story, specId) {
|
|
2690
|
+
const refs = story.frontmatter.references;
|
|
2691
|
+
if (!Array.isArray(refs))
|
|
2692
|
+
return false;
|
|
2693
|
+
return refs.some((r) => r?.id === specId);
|
|
2694
|
+
}
|
|
2695
|
+
function uncoveredFeatures(features, stories, prdId) {
|
|
2696
|
+
const scored = stories.map((story) => ({
|
|
2697
|
+
tokens: tokenise(`${String(story.frontmatter.title ?? "")} ${story.content}`),
|
|
2698
|
+
threshold: referencesSpec(story, prdId) ? REFERENCED_THRESHOLD : OVERLAP_THRESHOLD
|
|
2699
|
+
}));
|
|
2700
|
+
return features.filter((feature) => {
|
|
2701
|
+
const featureTokens = tokenise(feature);
|
|
2702
|
+
return !scored.some((s) => overlap(featureTokens, s.tokens) >= s.threshold);
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2587
2705
|
var storyCoverageRule = {
|
|
2588
2706
|
id: "completeness/story-coverage",
|
|
2589
2707
|
description: "Every feature listed in a PRD has at least one corresponding user story",
|
|
@@ -2591,17 +2709,11 @@ var storyCoverageRule = {
|
|
|
2591
2709
|
run(context) {
|
|
2592
2710
|
if (context.spec.frontmatter.type !== "prd")
|
|
2593
2711
|
return [];
|
|
2594
|
-
const features =
|
|
2595
|
-
let match;
|
|
2596
|
-
const re = new RegExp(FEATURE_PATTERN.source, "g");
|
|
2597
|
-
while ((match = re.exec(context.spec.content)) !== null) {
|
|
2598
|
-
features.push(match[1].trim());
|
|
2599
|
-
}
|
|
2712
|
+
const features = parseFeatures(context.spec.content);
|
|
2600
2713
|
if (features.length === 0)
|
|
2601
2714
|
return [];
|
|
2602
2715
|
const stories = context.allSpecs.filter((s) => s.frontmatter.type === "user-story");
|
|
2603
|
-
|
|
2604
|
-
return features.filter((feature) => !storyContent.toLowerCase().includes(feature.toLowerCase())).map((feature) => ({
|
|
2716
|
+
return uncoveredFeatures(features, stories, context.spec.frontmatter.id).map((feature) => ({
|
|
2605
2717
|
ruleId: "completeness/story-coverage",
|
|
2606
2718
|
severity: "warn",
|
|
2607
2719
|
message: `Feature "${feature}" has no corresponding user story`,
|
|
@@ -2803,8 +2915,6 @@ var EDGE_CASE_KEYWORDS = [
|
|
|
2803
2915
|
"reject",
|
|
2804
2916
|
"unauthorized",
|
|
2805
2917
|
"forbidden",
|
|
2806
|
-
"404",
|
|
2807
|
-
"500",
|
|
2808
2918
|
"missing",
|
|
2809
2919
|
"malformed",
|
|
2810
2920
|
"overflow",
|
|
@@ -2814,8 +2924,18 @@ var EDGE_CASE_KEYWORDS = [
|
|
|
2814
2924
|
"fallback",
|
|
2815
2925
|
"crash",
|
|
2816
2926
|
"nonexistent",
|
|
2817
|
-
"corrupt"
|
|
2927
|
+
"corrupt",
|
|
2928
|
+
// Vocabulary that names a failure without using any of the words above.
|
|
2929
|
+
"conflict",
|
|
2930
|
+
"denied",
|
|
2931
|
+
"expired",
|
|
2932
|
+
"not found",
|
|
2933
|
+
"retry",
|
|
2934
|
+
"rate limit",
|
|
2935
|
+
"unavailable",
|
|
2936
|
+
"unprocessable"
|
|
2818
2937
|
];
|
|
2938
|
+
var ERROR_STATUS_CODE = /\b[45]\d{2}\b/;
|
|
2819
2939
|
var edgeCaseCoverageRule = {
|
|
2820
2940
|
id: "completeness/edge-case-coverage",
|
|
2821
2941
|
description: "Flag user stories or test plans that don't mention error states or edge cases",
|
|
@@ -2825,7 +2945,7 @@ var edgeCaseCoverageRule = {
|
|
|
2825
2945
|
if (type !== "user-story" && type !== "test-plan")
|
|
2826
2946
|
return [];
|
|
2827
2947
|
const content = context.spec.content.toLowerCase();
|
|
2828
|
-
const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw));
|
|
2948
|
+
const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);
|
|
2829
2949
|
if (hasEdgeCases)
|
|
2830
2950
|
return [];
|
|
2831
2951
|
return [
|
|
@@ -2896,7 +3016,7 @@ var namingConventionsRule = {
|
|
|
2896
3016
|
};
|
|
2897
3017
|
|
|
2898
3018
|
// ../lint/dist/rules/threat-coverage.js
|
|
2899
|
-
var
|
|
3019
|
+
var STOPWORDS2 = /* @__PURE__ */ new Set(["the", "and", "for", "with", "from", "that", "this", "into", "via"]);
|
|
2900
3020
|
function extractThreats(content) {
|
|
2901
3021
|
const parts = content.split(/^(?=## )/m);
|
|
2902
3022
|
const threats = [];
|
|
@@ -2909,7 +3029,7 @@ function extractThreats(content) {
|
|
|
2909
3029
|
return threats;
|
|
2910
3030
|
}
|
|
2911
3031
|
function extractKeyTerms(text) {
|
|
2912
|
-
return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !
|
|
3032
|
+
return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !STOPWORDS2.has(w));
|
|
2913
3033
|
}
|
|
2914
3034
|
var threatCoverageRule = {
|
|
2915
3035
|
id: "security/threat-coverage",
|
|
@@ -2986,13 +3106,48 @@ var noPlaceholderSectionsRule = {
|
|
|
2986
3106
|
}
|
|
2987
3107
|
};
|
|
2988
3108
|
|
|
3109
|
+
// ../lint/dist/rules/id-matches-config-key.js
|
|
3110
|
+
import { basename as basename2 } from "path";
|
|
3111
|
+
var idMatchesConfigKeyRule = {
|
|
3112
|
+
id: "structure/id-matches-config-key",
|
|
3113
|
+
description: "A spec's frontmatter id should match the key it is registered under in the config",
|
|
3114
|
+
severity: "warn",
|
|
3115
|
+
run(context) {
|
|
3116
|
+
const { spec, config } = context;
|
|
3117
|
+
if (!config)
|
|
3118
|
+
return [];
|
|
3119
|
+
const id = spec.frontmatter.id;
|
|
3120
|
+
if (typeof id !== "string" || id.length === 0)
|
|
3121
|
+
return [];
|
|
3122
|
+
const specFile = basename2(spec.filePath);
|
|
3123
|
+
const candidates = Object.entries(config.specs).filter(([, entry]) => {
|
|
3124
|
+
const target = basename2(entry.path);
|
|
3125
|
+
return !target.includes("*") && target === specFile;
|
|
3126
|
+
});
|
|
3127
|
+
if (candidates.length !== 1)
|
|
3128
|
+
return [];
|
|
3129
|
+
const key = candidates[0][0];
|
|
3130
|
+
if (key === id)
|
|
3131
|
+
return [];
|
|
3132
|
+
return [
|
|
3133
|
+
{
|
|
3134
|
+
ruleId: "structure/id-matches-config-key",
|
|
3135
|
+
severity: "warn",
|
|
3136
|
+
message: `Spec declares id "${id}" but is registered in spec.config.yaml as "${key}". Frontmatter references resolve against "${id}" and config requires against "${key}", so the dependency graph shows them as two things. Rename one so they agree.`,
|
|
3137
|
+
filePath: spec.filePath
|
|
3138
|
+
}
|
|
3139
|
+
];
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
|
|
2989
3143
|
// ../lint/dist/rules/index.js
|
|
2990
3144
|
var structureRules = [
|
|
2991
3145
|
validFrontmatterRule,
|
|
2992
3146
|
requiredSectionsRule,
|
|
2993
3147
|
validReferencesRule,
|
|
2994
3148
|
noCircularDepsRule,
|
|
2995
|
-
singleProjectContextRule
|
|
3149
|
+
singleProjectContextRule,
|
|
3150
|
+
idMatchesConfigKeyRule
|
|
2996
3151
|
];
|
|
2997
3152
|
var contentRules = [
|
|
2998
3153
|
storyCoverageRule,
|
|
@@ -3138,7 +3293,7 @@ var lint_default = defineCommand2({
|
|
|
3138
3293
|
import { defineCommand as defineCommand3 } from "citty";
|
|
3139
3294
|
|
|
3140
3295
|
// ../pack/dist/resolver.js
|
|
3141
|
-
var
|
|
3296
|
+
var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
3142
3297
|
"a",
|
|
3143
3298
|
"an",
|
|
3144
3299
|
"and",
|
|
@@ -3215,7 +3370,7 @@ var STOPWORDS2 = /* @__PURE__ */ new Set([
|
|
|
3215
3370
|
"your"
|
|
3216
3371
|
]);
|
|
3217
3372
|
function tokenize(task) {
|
|
3218
|
-
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !
|
|
3373
|
+
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !STOPWORDS3.has(t));
|
|
3219
3374
|
}
|
|
3220
3375
|
var WEIGHT_TAGS = 3;
|
|
3221
3376
|
var WEIGHT_TITLE = 3;
|
|
@@ -4416,8 +4571,8 @@ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep
|
|
|
4416
4571
|
} else if (endKeep) {
|
|
4417
4572
|
var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
|
|
4418
4573
|
var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
4419
|
-
var
|
|
4420
|
-
deletion.value = removeSuffix(deletion.value,
|
|
4574
|
+
var overlap2 = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
4575
|
+
deletion.value = removeSuffix(deletion.value, overlap2);
|
|
4421
4576
|
} else if (startKeep) {
|
|
4422
4577
|
var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
|
|
4423
4578
|
var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
@@ -4994,13 +5149,18 @@ function checkCrossReferences(allSpecs, removedIds) {
|
|
|
4994
5149
|
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
4995
5150
|
import { execSync as execSync2 } from "child_process";
|
|
4996
5151
|
import { readFileSync, realpathSync } from "fs";
|
|
4997
|
-
import { dirname as dirname2, relative, resolve as
|
|
5152
|
+
import { dirname as dirname2, relative, resolve as resolve3, sep } from "path";
|
|
4998
5153
|
function getRepoRoot(cwd) {
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5154
|
+
let root;
|
|
5155
|
+
try {
|
|
5156
|
+
root = execSync2("git rev-parse --show-toplevel", {
|
|
5157
|
+
cwd,
|
|
5158
|
+
encoding: "utf-8",
|
|
5159
|
+
stdio: "pipe"
|
|
5160
|
+
}).trim();
|
|
5161
|
+
} catch {
|
|
5162
|
+
throw new DiffError("diff compares specs across git history, and this directory is not inside a git repository. Run `git init` first, or run diff from a checked-out project.");
|
|
5163
|
+
}
|
|
5004
5164
|
return realpathSync(root);
|
|
5005
5165
|
}
|
|
5006
5166
|
function validateRef(ref, cwd) {
|
|
@@ -5011,7 +5171,7 @@ function validateRef(ref, cwd) {
|
|
|
5011
5171
|
}
|
|
5012
5172
|
}
|
|
5013
5173
|
function gitShow(ref, filePath, projectRoot, repoRoot) {
|
|
5014
|
-
const relPath = relative(repoRoot,
|
|
5174
|
+
const relPath = relative(repoRoot, resolve3(projectRoot, filePath));
|
|
5015
5175
|
try {
|
|
5016
5176
|
return execSync2(`git show ${ref}:${relPath}`, {
|
|
5017
5177
|
cwd: repoRoot,
|
|
@@ -5028,7 +5188,7 @@ function toPosix(p) {
|
|
|
5028
5188
|
function buildEntryMatchers(specPathsByKey, projectRoot, repoRoot) {
|
|
5029
5189
|
return [...specPathsByKey].map(([key, specPath]) => ({
|
|
5030
5190
|
key,
|
|
5031
|
-
isMatch: (0, import_picomatch.default)(toPosix(relative(repoRoot,
|
|
5191
|
+
isMatch: (0, import_picomatch.default)(toPosix(relative(repoRoot, resolve3(projectRoot, specPath))))
|
|
5032
5192
|
}));
|
|
5033
5193
|
}
|
|
5034
5194
|
function getChangedSpecFiles(baseRef, headRef, matchers, projectRoot, repoRoot) {
|
|
@@ -5055,7 +5215,7 @@ function getChangedSpecFiles(baseRef, headRef, matchers, projectRoot, repoRoot)
|
|
|
5055
5215
|
if (!entry)
|
|
5056
5216
|
continue;
|
|
5057
5217
|
const changed = {
|
|
5058
|
-
path: relative(projectRoot,
|
|
5218
|
+
path: relative(projectRoot, resolve3(repoRoot, filePath)),
|
|
5059
5219
|
entryKey: entry.key
|
|
5060
5220
|
};
|
|
5061
5221
|
if (status === "M") {
|
|
@@ -5086,7 +5246,7 @@ function listSpecFilesAtRef(ref, matchers, projectRoot, repoRoot) {
|
|
|
5086
5246
|
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
5087
5247
|
if (!entry)
|
|
5088
5248
|
continue;
|
|
5089
|
-
byEntry.get(entry.key)?.push(relative(projectRoot,
|
|
5249
|
+
byEntry.get(entry.key)?.push(relative(projectRoot, resolve3(repoRoot, filePath)));
|
|
5090
5250
|
}
|
|
5091
5251
|
return byEntry;
|
|
5092
5252
|
}
|
|
@@ -5108,7 +5268,7 @@ function listSpecFilesInWorktree(matchers, projectRoot, repoRoot) {
|
|
|
5108
5268
|
const entry = matchers.find((m) => m.isMatch(filePath));
|
|
5109
5269
|
if (!entry)
|
|
5110
5270
|
continue;
|
|
5111
|
-
byEntry.get(entry.key)?.push(relative(projectRoot,
|
|
5271
|
+
byEntry.get(entry.key)?.push(relative(projectRoot, resolve3(repoRoot, filePath)));
|
|
5112
5272
|
}
|
|
5113
5273
|
return byEntry;
|
|
5114
5274
|
}
|
|
@@ -5122,7 +5282,7 @@ function worktreeSide(matchers, projectRoot, repoRoot) {
|
|
|
5122
5282
|
return {
|
|
5123
5283
|
read: (path) => {
|
|
5124
5284
|
try {
|
|
5125
|
-
return readFileSync(
|
|
5285
|
+
return readFileSync(resolve3(projectRoot, path), "utf-8");
|
|
5126
5286
|
} catch {
|
|
5127
5287
|
throw new DiffError(`Cannot read "${path}" in the working tree`);
|
|
5128
5288
|
}
|
|
@@ -5151,7 +5311,7 @@ function getChangedSpecFilesInWorktree(baseRef, matchers, projectRoot, repoRoot)
|
|
|
5151
5311
|
return;
|
|
5152
5312
|
seen.add(filePath);
|
|
5153
5313
|
const changed = {
|
|
5154
|
-
path: relative(projectRoot,
|
|
5314
|
+
path: relative(projectRoot, resolve3(repoRoot, filePath)),
|
|
5155
5315
|
entryKey: entry.key
|
|
5156
5316
|
};
|
|
5157
5317
|
if (status === "M")
|
|
@@ -5208,7 +5368,7 @@ function listUncommittedSpecFiles(matchers, projectRoot, repoRoot) {
|
|
|
5208
5368
|
const filePath = (renamed ?? rawPath).replace(/^"|"$/g, "");
|
|
5209
5369
|
if (!matchers.some((m) => m.isMatch(filePath)))
|
|
5210
5370
|
continue;
|
|
5211
|
-
files.push(relative(projectRoot,
|
|
5371
|
+
files.push(relative(projectRoot, resolve3(repoRoot, filePath)));
|
|
5212
5372
|
}
|
|
5213
5373
|
return files;
|
|
5214
5374
|
}
|
|
@@ -5225,7 +5385,7 @@ async function specIdsFrom(files, read) {
|
|
|
5225
5385
|
return ids;
|
|
5226
5386
|
}
|
|
5227
5387
|
async function diffBetweenRefs(configPath, baseRef, headRef, options = {}) {
|
|
5228
|
-
const projectRoot = realpathSync(dirname2(
|
|
5388
|
+
const projectRoot = realpathSync(dirname2(resolve3(configPath)));
|
|
5229
5389
|
const repoRoot = getRepoRoot(projectRoot);
|
|
5230
5390
|
validateRef(baseRef, projectRoot);
|
|
5231
5391
|
if (!options.working)
|