specdx 0.4.0-alpha.2 → 0.4.0-alpha.20
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 +7 -2
- package/LICENSE +21 -0
- package/README.md +477 -0
- package/dist/{check-PZFBVQIP.js → check-GGQB3SHI.js} +36 -10
- package/dist/check-GGQB3SHI.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-CI7KYTC7.js +103 -0
- package/dist/chunk-CI7KYTC7.js.map +1 -0
- package/dist/chunk-FBMYBYFB.js +182 -0
- package/dist/chunk-FBMYBYFB.js.map +1 -0
- package/dist/{chunk-FZWT4HVX.js → chunk-MM325DR6.js} +156 -2
- package/dist/chunk-MM325DR6.js.map +1 -0
- package/dist/chunk-RY5CDUNN.js +2846 -0
- package/dist/chunk-RY5CDUNN.js.map +1 -0
- package/dist/{chunk-YRDOYUKF.js → chunk-T232GZ2L.js} +124 -19
- package/dist/chunk-T232GZ2L.js.map +1 -0
- package/dist/{chunk-PHWUK7TH.js → chunk-UZKOJL2N.js} +288 -50
- package/dist/chunk-UZKOJL2N.js.map +1 -0
- package/dist/{chunk-QEUZJWBY.js → chunk-ZB5R5SK5.js} +364 -59
- package/dist/chunk-ZB5R5SK5.js.map +1 -0
- package/dist/{chunk-YDU26YTH.js → chunk-ZIPGRLYE.js} +120 -16
- package/dist/chunk-ZIPGRLYE.js.map +1 -0
- package/dist/diff-PHEX3HUT.js +188 -0
- package/dist/diff-PHEX3HUT.js.map +1 -0
- package/dist/{dist-2B2MR5AM.js → dist-DQ6NNKZO.js} +53 -14
- package/dist/dist-DQ6NNKZO.js.map +1 -0
- package/dist/dist-RT3MTIUW.js +16 -0
- package/dist/dist-RT3MTIUW.js.map +1 -0
- package/dist/generate-5VO6M4PB.js +21 -0
- package/dist/generate-5VO6M4PB.js.map +1 -0
- package/dist/{generate-story-AOALIKSD.js → generate-story-CJMV2F5K.js} +48 -20
- package/dist/generate-story-CJMV2F5K.js.map +1 -0
- package/dist/{generate-test-plan-34L6RGOB.js → generate-test-plan-XBAFJKJI.js} +63 -10
- package/dist/generate-test-plan-XBAFJKJI.js.map +1 -0
- package/dist/graph-UZJMLX4J.js +103 -0
- package/dist/graph-UZJMLX4J.js.map +1 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +2635 -386
- package/dist/index.js.map +1 -1
- package/dist/{lint-XGVQ6LCP.js → lint-TVL2ILOQ.js} +20 -8
- package/dist/lint-TVL2ILOQ.js.map +1 -0
- package/dist/main.js +11 -146
- package/dist/main.js.map +1 -1
- package/dist/mcp-F7LJBZ4X.js +35 -0
- package/dist/mcp-F7LJBZ4X.js.map +1 -0
- package/dist/{migrate-KDJZQKP7.js → migrate-DEFCNOAH.js} +20 -8
- package/dist/migrate-DEFCNOAH.js.map +1 -0
- package/dist/{pack-OJ3CDZHD.js → pack-PNLD5AYW.js} +36 -11
- package/dist/pack-PNLD5AYW.js.map +1 -0
- package/dist/ready-2PHBPWJD.js +257 -0
- package/dist/ready-2PHBPWJD.js.map +1 -0
- package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
- package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
- package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
- package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
- package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
- package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
- package/dist/skills/core/specdx-router/SKILL.md +67 -0
- package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +5 -1
- package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
- package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
- package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +17 -2
- package/dist/skills-LHFTTEJ7.js +121 -0
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-JVIXK73H.js → status-UKLQV4AI.js} +48 -34
- package/dist/status-UKLQV4AI.js.map +1 -0
- package/dist/{update-HFLDULNJ.js → update-KLDLDQZM.js} +6 -5
- package/dist/update-KLDLDQZM.js.map +1 -0
- package/dist/validate-FXD5WS4C.js +87 -0
- package/dist/validate-FXD5WS4C.js.map +1 -0
- package/hooks/hooks.json +12 -6
- package/hooks/session-start +35 -3
- package/package.json +68 -21
- package/dist/changelog-G6XDIAZP.js +0 -86
- package/dist/changelog-G6XDIAZP.js.map +0 -1
- package/dist/check-PZFBVQIP.js.map +0 -1
- package/dist/chunk-7C3BAVCP.js +0 -1147
- package/dist/chunk-7C3BAVCP.js.map +0 -1
- package/dist/chunk-FZWT4HVX.js.map +0 -1
- package/dist/chunk-PHWUK7TH.js.map +0 -1
- package/dist/chunk-QEUZJWBY.js.map +0 -1
- package/dist/chunk-YDU26YTH.js.map +0 -1
- package/dist/chunk-YRDOYUKF.js.map +0 -1
- package/dist/diff-BEZARP53.js +0 -100
- package/dist/diff-BEZARP53.js.map +0 -1
- package/dist/dist-2B2MR5AM.js.map +0 -1
- package/dist/dist-WIK7F2PJ.js +0 -11
- package/dist/explain-PCZKDEM4.js +0 -102
- package/dist/explain-PCZKDEM4.js.map +0 -1
- package/dist/generate-OMEBJQFQ.js +0 -13
- package/dist/generate-OMEBJQFQ.js.map +0 -1
- package/dist/generate-story-AOALIKSD.js.map +0 -1
- package/dist/generate-test-plan-34L6RGOB.js.map +0 -1
- package/dist/graph-RR5UTY3R.js +0 -54
- package/dist/graph-RR5UTY3R.js.map +0 -1
- package/dist/lint-XGVQ6LCP.js.map +0 -1
- package/dist/mcp-GUFW37BE.js +0 -17
- package/dist/mcp-GUFW37BE.js.map +0 -1
- package/dist/migrate-KDJZQKP7.js.map +0 -1
- package/dist/pack-OJ3CDZHD.js.map +0 -1
- package/dist/ready-WTNO5W7C.js +0 -165
- package/dist/ready-WTNO5W7C.js.map +0 -1
- package/dist/skills-3GBBWZW2.js +0 -93
- package/dist/skills-3GBBWZW2.js.map +0 -1
- package/dist/status-JVIXK73H.js.map +0 -1
- package/dist/update-HFLDULNJ.js.map +0 -1
- package/dist/validate-O7W5YLR6.js +0 -34
- package/dist/validate-O7W5YLR6.js.map +0 -1
- /package/dist/{dist-WIK7F2PJ.js.map → chunk-5WRI5ZAA.js.map} +0 -0
- /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
- /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: specdx-verify
|
|
3
|
-
description: "Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
|
|
4
|
-
allowed-tools: Bash(npx specdx
|
|
3
|
+
description: "[experimental — built on specdx check, whose static analysis can be noisy] Use when the user says 'verify', 'check against spec', 'does this match the spec', 'review implementation', or after completing a feature. Runs spec-to-implementation analysis and reviews findings."
|
|
4
|
+
allowed-tools: Bash(npx specdx:*) Read
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Verify Implementation Against Specs
|
|
@@ -20,6 +20,17 @@ If the command fails with "ts-morph is required", tell the user to install it: `
|
|
|
20
20
|
|
|
21
21
|
If it fails with "No spec.config.yaml found", the project isn't set up with specdx. Stop and inform the user.
|
|
22
22
|
|
|
23
|
+
If it exits 3 ("coverage not assessed — no checkable surfaces"), the project has no extractable routes/types/tests — common outside Express/Hono/Next.js. Suggest declaring checkable artifacts in the relevant spec's frontmatter so check has something real to verify:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
artifacts:
|
|
27
|
+
- path: "middleware.ts"
|
|
28
|
+
- path: "src/lib/bots.ts"
|
|
29
|
+
exports: ["BOT_SIGNATURES"]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Declaring artifacts for work that is not built yet is safe: while the spec is `draft` or `review`, absent files report as *pending* (info, exit 0). They become enforceable errors when the spec status is `approved`. So write the declaration when you write the spec — do not wait for the implementation.
|
|
33
|
+
|
|
23
34
|
### Step 2: Load spec context
|
|
24
35
|
|
|
25
36
|
```bash
|
|
@@ -68,3 +79,7 @@ Do NOT skip Step 1. Always run `npx specdx check` before reviewing. Do not rely
|
|
|
68
79
|
| "There are too many findings to review" | Group by category, prioritize errors over warnings. Review all errors. |
|
|
69
80
|
| "The check failed, so skip it" | Report the failure. Partial results are still valuable. |
|
|
70
81
|
| "The user didn't ask for verification" | If you just finished implementing, verify. It's part of the job. |
|
|
82
|
+
|
|
83
|
+
## It's working if
|
|
84
|
+
|
|
85
|
+
Every error-level finding is either resolved or consciously accepted with a reason. Warnings from prose-heavy test plans are expected noise — say so rather than treating the score as a grade.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import "./chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/commands/core/skills.ts
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
|
|
6
|
+
// ../skills/dist/install.js
|
|
7
|
+
import { mkdir, writeFile, readFile, stat, readdir } from "fs/promises";
|
|
8
|
+
import { statSync } from "fs";
|
|
9
|
+
import { join, dirname, relative } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
var CORE_SKILL_NAMES = [
|
|
13
|
+
"specdx-router",
|
|
14
|
+
"specdx-start-task",
|
|
15
|
+
"specdx-author-spec",
|
|
16
|
+
"specdx-pre-commit",
|
|
17
|
+
"specdx-sprint-review",
|
|
18
|
+
"specdx-plan-from-spec",
|
|
19
|
+
"specdx-onboard",
|
|
20
|
+
"specdx-review-spec"
|
|
21
|
+
];
|
|
22
|
+
var EXPERIMENTAL_SKILL_NAMES = ["specdx-verify", "specdx-check-drift"];
|
|
23
|
+
var SKILL_NAMES = [...CORE_SKILL_NAMES, ...EXPERIMENTAL_SKILL_NAMES];
|
|
24
|
+
function bucketOf(skillName) {
|
|
25
|
+
return EXPERIMENTAL_SKILL_NAMES.includes(skillName) ? "experimental" : "core";
|
|
26
|
+
}
|
|
27
|
+
function getSkillSourceDir() {
|
|
28
|
+
const bundledPath = join(__dirname, "skills");
|
|
29
|
+
try {
|
|
30
|
+
statSync(bundledPath);
|
|
31
|
+
return bundledPath;
|
|
32
|
+
} catch {
|
|
33
|
+
return join(__dirname, "..", "skills");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function filesUnder(dir, base = dir) {
|
|
37
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
38
|
+
const files = [];
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
const full = join(dir, entry.name);
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
files.push(...await filesUnder(full, base));
|
|
43
|
+
} else {
|
|
44
|
+
files.push(relative(base, full));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return files;
|
|
48
|
+
}
|
|
49
|
+
async function installSkills(projectDir, options = {}) {
|
|
50
|
+
const sourceDir = getSkillSourceDir();
|
|
51
|
+
const skillsDir = join(projectDir, ".claude", "skills");
|
|
52
|
+
const installed = [];
|
|
53
|
+
const updated = [];
|
|
54
|
+
await mkdir(skillsDir, { recursive: true });
|
|
55
|
+
const names = options.experimental ? SKILL_NAMES : CORE_SKILL_NAMES;
|
|
56
|
+
for (const skillName of names) {
|
|
57
|
+
const sourcePath = join(sourceDir, bucketOf(skillName), skillName);
|
|
58
|
+
const targetPath = join(skillsDir, skillName);
|
|
59
|
+
let exists = false;
|
|
60
|
+
try {
|
|
61
|
+
await stat(join(targetPath, "SKILL.md"));
|
|
62
|
+
exists = true;
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
for (const file of await filesUnder(sourcePath)) {
|
|
66
|
+
const target = join(targetPath, file);
|
|
67
|
+
await mkdir(dirname(target), { recursive: true });
|
|
68
|
+
await writeFile(target, await readFile(join(sourcePath, file), "utf-8"), "utf-8");
|
|
69
|
+
}
|
|
70
|
+
if (exists) {
|
|
71
|
+
updated.push(skillName);
|
|
72
|
+
} else {
|
|
73
|
+
installed.push(skillName);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { installed, updated };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/commands/core/skills.ts
|
|
80
|
+
var skills_default = defineCommand({
|
|
81
|
+
meta: { name: "skills", description: "Manage specdx skills for AI coding tools" },
|
|
82
|
+
subCommands: {
|
|
83
|
+
install: defineCommand({
|
|
84
|
+
meta: { name: "install", description: "Install Claude Code skill files" },
|
|
85
|
+
args: {
|
|
86
|
+
dir: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: "Target directory (default: current directory)",
|
|
89
|
+
default: "."
|
|
90
|
+
},
|
|
91
|
+
experimental: {
|
|
92
|
+
type: "boolean",
|
|
93
|
+
description: "Also install experimental skills (built on the experimental check command)",
|
|
94
|
+
default: false
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async run({ args }) {
|
|
98
|
+
try {
|
|
99
|
+
const result = await installSkills(args.dir, { experimental: args.experimental });
|
|
100
|
+
if (result.installed.length === 0 && result.updated.length === 0) {
|
|
101
|
+
console.log(" No skill files to install.");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
for (const file of result.installed) console.log(` \u2713 Installed ${file}`);
|
|
105
|
+
for (const file of result.updated) console.log(` \u2713 Updated ${file}`);
|
|
106
|
+
console.log(`
|
|
107
|
+
Skills installed to .claude/skills/`);
|
|
108
|
+
} catch (err) {
|
|
109
|
+
console.error(`
|
|
110
|
+
\u2717 ${err.message}
|
|
111
|
+
`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export {
|
|
119
|
+
skills_default as default
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=skills-LHFTTEJ7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/skills.ts","../../skills/src/install.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { installSkills } from \"@specdx/skills\";\n\nexport default defineCommand({\n meta: { name: \"skills\", description: \"Manage specdx skills for AI coding tools\" },\n subCommands: {\n install: defineCommand({\n meta: { name: \"install\", description: \"Install Claude Code skill files\" },\n args: {\n dir: {\n type: \"string\",\n description: \"Target directory (default: current directory)\",\n default: \".\",\n },\n experimental: {\n type: \"boolean\",\n description: \"Also install experimental skills (built on the experimental check command)\",\n default: false,\n },\n },\n async run({ args }) {\n try {\n const result = await installSkills(args.dir, { experimental: args.experimental });\n if (result.installed.length === 0 && result.updated.length === 0) {\n console.log(\" No skill files to install.\");\n return;\n }\n for (const file of result.installed) console.log(` ✓ Installed ${file}`);\n for (const file of result.updated) console.log(` ✓ Updated ${file}`);\n console.log(`\\n Skills installed to .claude/skills/`);\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n }),\n },\n});\n","import { mkdir, writeFile, readFile, stat, readdir } from \"node:fs/promises\";\nimport { statSync } from \"node:fs\";\nimport { join, dirname, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Promoted skills — the set the Claude Code plugin ships and `skills install`\n * writes by default.\n *\n * Promotion is the directory a skill lives in, not an adjective in its\n * description. A string is easy to drift past; a folder is not.\n */\nexport const CORE_SKILL_NAMES = [\n \"specdx-router\",\n \"specdx-start-task\",\n \"specdx-author-spec\",\n \"specdx-pre-commit\",\n \"specdx-sprint-review\",\n \"specdx-plan-from-spec\",\n \"specdx-onboard\",\n \"specdx-review-spec\",\n];\n\n/** Skills built on `sdx check`, whose static analysis is noisy on prose specs. */\nexport const EXPERIMENTAL_SKILL_NAMES = [\"specdx-verify\", \"specdx-check-drift\"];\n\n/** Every skill that ships, promoted or not. */\nexport const SKILL_NAMES = [...CORE_SKILL_NAMES, ...EXPERIMENTAL_SKILL_NAMES];\n\n/** Bucket directory a skill lives in, under the skills root. */\nexport function bucketOf(skillName: string): \"core\" | \"experimental\" {\n return EXPERIMENTAL_SKILL_NAMES.includes(skillName) ? \"experimental\" : \"core\";\n}\n\nexport interface InstallResult {\n installed: string[];\n updated: string[];\n}\n\nfunction getSkillSourceDir(): string {\n // When bundled: skills at __dirname/skills (sibling of bundle)\n // In dev: skills at __dirname/../skills (sibling of src/)\n const bundledPath = join(__dirname, \"skills\");\n try {\n statSync(bundledPath);\n return bundledPath;\n } catch {\n return join(__dirname, \"..\", \"skills\");\n }\n}\n\n/** Every file under a directory, as paths relative to it. */\nasync function filesUnder(dir: string, base = dir): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = join(dir, entry.name);\n if (entry.isDirectory()) {\n files.push(...(await filesUnder(full, base)));\n } else {\n files.push(relative(base, full));\n }\n }\n return files;\n}\n\n/**\n * Install skills into a project's `.claude/skills/`.\n *\n * The Agent Skills specification defines a skill as a *directory* containing a\n * `SKILL.md`, so the whole directory is copied -- `references/` and any other\n * bundled resources included. Skills previously shipped as flat files under\n * `.claude/commands/`, which made them slash commands rather than skills.\n */\nexport interface InstallOptions {\n /** Include experimental skills. Off by default: only promoted skills ship. */\n experimental?: boolean;\n}\n\nexport async function installSkills(\n projectDir: string,\n options: InstallOptions = {},\n): Promise<InstallResult> {\n const sourceDir = getSkillSourceDir();\n const skillsDir = join(projectDir, \".claude\", \"skills\");\n const installed: string[] = [];\n const updated: string[] = [];\n\n await mkdir(skillsDir, { recursive: true });\n\n const names = options.experimental ? SKILL_NAMES : CORE_SKILL_NAMES;\n\n for (const skillName of names) {\n const sourcePath = join(sourceDir, bucketOf(skillName), skillName);\n const targetPath = join(skillsDir, skillName);\n\n let exists = false;\n try {\n await stat(join(targetPath, \"SKILL.md\"));\n exists = true;\n } catch {\n // Not installed yet\n }\n\n for (const file of await filesUnder(sourcePath)) {\n const target = join(targetPath, file);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, await readFile(join(sourcePath, file), \"utf-8\"), \"utf-8\");\n }\n\n if (exists) {\n updated.push(skillName);\n } else {\n installed.push(skillName);\n }\n }\n\n return { installed, updated };\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;;;ACA9B,SAAS,OAAO,WAAW,UAAU,MAAM,eAAe;AAC1D,SAAS,gBAAgB;AACzB,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AASjD,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIK,IAAM,2BAA2B,CAAC,iBAAiB,oBAAoB;AAGvE,IAAM,cAAc,CAAC,GAAG,kBAAkB,GAAG,wBAAwB;AAGtE,SAAU,SAAS,WAAiB;AACxC,SAAO,yBAAyB,SAAS,SAAS,IAAI,iBAAiB;AACzE;AAOA,SAAS,oBAAiB;AAGxB,QAAM,cAAc,KAAK,WAAW,QAAQ;AAC5C,MAAI;AACF,aAAS,WAAW;AACpB,WAAO;EACT,QAAQ;AACN,WAAO,KAAK,WAAW,MAAM,QAAQ;EACvC;AACF;AAGA,eAAe,WAAW,KAAa,OAAO,KAAG;AAC/C,QAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAI,CAAE;AAC1D,QAAM,QAAkB,CAAA;AACxB,aAAW,SAAS,SAAS;AAC3B,UAAM,OAAO,KAAK,KAAK,MAAM,IAAI;AACjC,QAAI,MAAM,YAAW,GAAI;AACvB,YAAM,KAAK,GAAI,MAAM,WAAW,MAAM,IA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N,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,YAAI;AACF,gBAAM,SAAS,MAAM,cAAc,KAAK,KAAK,EAAE,cAAc,KAAK,aAAa,CAAC;AAChF,cAAI,OAAO,UAAU,WAAW,KAAK,OAAO,QAAQ,WAAW,GAAG;AAChE,oBAAQ,IAAI,8BAA8B;AAC1C;AAAA,UACF;AACA,qBAAW,QAAQ,OAAO,UAAW,SAAQ,IAAI,sBAAiB,IAAI,EAAE;AACxE,qBAAW,QAAQ,OAAO,QAAS,SAAQ,IAAI,oBAAe,IAAI,EAAE;AACpE,kBAAQ,IAAI;AAAA,sCAAyC;AAAA,QACvD,SAAS,KAAK;AACZ,kBAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,kBAAQ,KAAK,CAAC;AAAA,QAChB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLintEngine,
|
|
3
3
|
getPreset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UZKOJL2N.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_DIFF_CONFIG
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RY5CDUNN.js";
|
|
8
8
|
import {
|
|
9
9
|
buildGraph,
|
|
10
10
|
loadConfig,
|
|
11
11
|
parseSpec,
|
|
12
12
|
resolveGlob
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-MM325DR6.js";
|
|
14
|
+
import "./chunk-ZIPGRLYE.js";
|
|
15
|
+
import "./chunk-5WRI5ZAA.js";
|
|
15
16
|
|
|
16
|
-
// src/commands/status.ts
|
|
17
|
+
// src/commands/core/status.ts
|
|
17
18
|
import { defineCommand } from "citty";
|
|
18
19
|
async function runStatus(_options = {}) {
|
|
19
20
|
const configDir = process.cwd();
|
|
@@ -84,6 +85,7 @@ async function runStatus(_options = {}) {
|
|
|
84
85
|
let verdict = "healthy";
|
|
85
86
|
if (errors > 0) verdict = "errors";
|
|
86
87
|
else if (warnings > 0 || staleSpecs.length > 0) verdict = "warnings";
|
|
88
|
+
else if (specs.length === 0) verdict = "unassessed";
|
|
87
89
|
return {
|
|
88
90
|
project: config.project?.name ?? "unknown",
|
|
89
91
|
specCount: specs.length,
|
|
@@ -104,44 +106,56 @@ var status_default = defineCommand({
|
|
|
104
106
|
}
|
|
105
107
|
},
|
|
106
108
|
async run({ args }) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (args.format === "github") {
|
|
113
|
-
for (const s of result.staleSpecs) {
|
|
114
|
-
console.log(
|
|
115
|
-
`::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
|
|
116
|
-
);
|
|
109
|
+
try {
|
|
110
|
+
const result = await runStatus({ format: args.format });
|
|
111
|
+
if (args.format === "json") {
|
|
112
|
+
console.log(JSON.stringify(result, null, 2));
|
|
113
|
+
return;
|
|
117
114
|
}
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
if (args.format === "github") {
|
|
116
|
+
for (const s of result.staleSpecs) {
|
|
117
|
+
console.log(
|
|
118
|
+
`::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
for (const issue of result.integrityIssues) {
|
|
122
|
+
console.log(`::error::${issue}`);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
120
125
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" ? "\u26A0" : "\u2717";
|
|
124
|
-
console.log(`
|
|
126
|
+
const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" || result.verdict === "unassessed" ? "\u26A0" : "\u2717";
|
|
127
|
+
console.log(`
|
|
125
128
|
${icon} ${result.project} \u2014 ${result.verdict}`);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
);
|
|
132
|
-
if (result.staleSpecs.length > 0) {
|
|
129
|
+
if (result.verdict === "unassessed") {
|
|
130
|
+
console.log(
|
|
131
|
+
" No specs resolved \u2014 nothing was assessed. Check the spec paths in spec.config.yaml."
|
|
132
|
+
);
|
|
133
|
+
}
|
|
133
134
|
console.log(
|
|
134
|
-
`
|
|
135
|
+
` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
135
136
|
);
|
|
137
|
+
console.log(
|
|
138
|
+
` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`
|
|
139
|
+
);
|
|
140
|
+
if (result.staleSpecs.length > 0) {
|
|
141
|
+
console.log(
|
|
142
|
+
` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (result.integrityIssues.length > 0) {
|
|
146
|
+
console.log(` Issues: ${result.integrityIssues.join("; ")}`);
|
|
147
|
+
}
|
|
148
|
+
console.log();
|
|
149
|
+
} catch (err) {
|
|
150
|
+
console.error(`
|
|
151
|
+
\u2717 ${err.message}
|
|
152
|
+
`);
|
|
153
|
+
process.exit(1);
|
|
136
154
|
}
|
|
137
|
-
if (result.integrityIssues.length > 0) {
|
|
138
|
-
console.log(` Issues: ${result.integrityIssues.join("; ")}`);
|
|
139
|
-
}
|
|
140
|
-
console.log();
|
|
141
155
|
}
|
|
142
156
|
});
|
|
143
157
|
export {
|
|
144
158
|
status_default as default,
|
|
145
159
|
runStatus
|
|
146
160
|
};
|
|
147
|
-
//# sourceMappingURL=status-
|
|
161
|
+
//# sourceMappingURL=status-UKLQV4AI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/status.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, buildGraph, resolveGlob } from \"@specdx/core\";\nimport { createLintEngine, getPreset } from \"@specdx/lint\";\nimport { DEFAULT_DIFF_CONFIG } from \"@specdx/diff\";\nimport type { StatusResult } from \"@specdx/diff\";\nimport type { ParsedSpec } from \"@specdx/core\";\n\nexport async function runStatus(_options: { format?: string } = {}): Promise<StatusResult> {\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n // Resolve and parse all specs\n const specs: { spec: ParsedSpec; entry: { path: string; owner?: string } }[] = [];\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 specs.push({ spec, entry: entry as { path: string; owner?: string } });\n }\n }\n\n // Count by status\n const byStatus: Record<string, number> = {};\n for (const { spec } of specs) {\n const status = (spec.frontmatter.status as string) || \"unknown\";\n byStatus[status] = (byStatus[status] ?? 0) + 1;\n }\n\n // Lint health\n const presetName = config.lint?.extends ?? \"recommended\";\n const rules = getPreset(presetName);\n\n let graph;\n let graphError: string | undefined;\n try {\n graph = buildGraph(config);\n } catch (err) {\n graphError = (err as Error).message;\n }\n\n const engine = createLintEngine({ rules, config, graph });\n const lintResults = engine.lint(specs.map((s) => s.spec));\n\n if (graphError) {\n lintResults.diagnostics.push({\n ruleId: \"structure/no-circular-deps\",\n severity: \"error\",\n message: graphError,\n filePath: \"spec.config.yaml\",\n });\n lintResults.hasErrors = true;\n }\n\n const errors = lintResults.diagnostics.filter((d) => d.severity === \"error\").length;\n const warnings = lintResults.diagnostics.filter((d) => d.severity === \"warn\").length;\n\n // Staleness\n const thresholdDays =\n config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;\n const now = Date.now();\n const staleSpecs: { specId: string; daysSinceUpdate: number; owner?: string }[] = [];\n for (const { spec, entry } of specs) {\n const dateStr =\n (spec.frontmatter.updated as string | undefined) ||\n (spec.frontmatter.created as string | undefined);\n if (dateStr) {\n const daysSinceUpdate = Math.floor(\n (now - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24),\n );\n if (daysSinceUpdate > thresholdDays) {\n staleSpecs.push({\n specId: spec.frontmatter.id as string,\n daysSinceUpdate,\n owner: entry.owner,\n });\n }\n }\n }\n\n // Integrity issues\n const integrityIssues: string[] = [];\n if (graphError) {\n integrityIssues.push(graphError);\n }\n const refErrors = lintResults.diagnostics.filter(\n (d) => d.ruleId === \"structure/valid-references\",\n );\n for (const d of refErrors) {\n integrityIssues.push(d.message);\n }\n\n // Verdict — an empty suite is unassessed, never a vacuous \"healthy\"\n let verdict: StatusResult[\"verdict\"] = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\n else if (specs.length === 0) verdict = \"unassessed\";\n\n return {\n project: config.project?.name ?? \"unknown\",\n specCount: specs.length,\n byStatus,\n lintHealth: { errors, warnings, passing: specs.length - errors },\n staleSpecs,\n integrityIssues,\n verdict,\n };\n}\n\nexport default defineCommand({\n meta: { name: \"status\", description: \"Show spec suite health overview\" },\n args: {\n format: {\n type: \"string\",\n description: \"Output format: pretty, json, github\",\n default: \"pretty\",\n },\n },\n async run({ args }) {\n try {\n const result = await runStatus({ format: args.format });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (args.format === \"github\") {\n for (const s of result.staleSpecs) {\n console.log(\n `::warning::Spec \"${s.specId}\" is stale (${s.daysSinceUpdate} days since update)`,\n );\n }\n for (const issue of result.integrityIssues) {\n console.log(`::error::${issue}`);\n }\n return;\n }\n\n // Pretty format\n const icon =\n result.verdict === \"healthy\"\n ? \"✓\"\n : result.verdict === \"warnings\" || result.verdict === \"unassessed\"\n ? \"⚠\"\n : \"✗\";\n console.log(`\\n ${icon} ${result.project} — ${result.verdict}`);\n if (result.verdict === \"unassessed\") {\n console.log(\n \" No specs resolved — nothing was assessed. Check the spec paths in spec.config.yaml.\",\n );\n }\n console.log(\n ` ${result.specCount} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(\n ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`,\n );\n\n if (result.staleSpecs.length > 0) {\n console.log(\n ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(\", \")}`,\n );\n }\n if (result.integrityIssues.length > 0) {\n console.log(` Issues: ${result.integrityIssues.join(\"; \")}`);\n }\n console.log();\n } catch (err) {\n console.error(`\\n ✗ ${(err as Error).message}\\n`);\n process.exit(1);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAO9B,eAAsB,UAAU,WAAgC,CAAC,GAA0B;AACzF,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAGpD,QAAM,QAAyE,CAAC;AAChF,aAAW,CAAC,EAAE,KAAK,KAAK,OAAO,QAAQ,OAAO,KAAK,GAAG;AACpD,UAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,SAAS;AACrD,eAAW,KAAK,OAAO;AACrB,YAAM,OAAO,MAAM,UAAU,CAAC;AAC9B,YAAM,KAAK,EAAE,MAAM,MAAiD,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,QAAM,WAAmC,CAAC;AAC1C,aAAW,EAAE,KAAK,KAAK,OAAO;AAC5B,UAAM,SAAU,KAAK,YAAY,UAAqB;AACtD,aAAS,MAAM,KAAK,SAAS,MAAM,KAAK,KAAK;AAAA,EAC/C;AAGA,QAAM,aAAa,OAAO,MAAM,WAAW;AAC3C,QAAM,QAAQ,UAAU,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,YAAQ,WAAW,MAAM;AAAA,EAC3B,SAAS,KAAK;AACZ,iBAAc,IA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,EAC7D,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,EAC3B,KAAK,IAAI,CAAC;AAAA,MACf;AACA,cAAQ;AAAA,QACN,aAAa,OAAO,WAAW,MAAM,YAAY,OAAO,WAAW,QAAQ;AAAA,MAC7E;AAEA,UAAI,OAAO,WAAW,SAAS,GAAG;AAChC,gBAAQ;AAAA,UACN,cAAc,OAAO,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,KAAK,EAAE,eAAe,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,QAC9F;AAAA,MACF;AACA,UAAI,OAAO,gBAAgB,SAAS,GAAG;AACrC,gBAAQ,IAAI,eAAe,OAAO,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,MAChE;AACA,cAAQ,IAAI;AAAA,IACd,SAAS,KAAK;AACZ,cAAQ,MAAM;AAAA,WAAU,IAAc,OAAO;AAAA,CAAI;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runCheck
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZB5R5SK5.js";
|
|
4
4
|
import {
|
|
5
5
|
sharedArgs
|
|
6
6
|
} from "./chunk-GAM4MXPC.js";
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
loadConfig,
|
|
10
10
|
parseSpec,
|
|
11
11
|
resolveGlob
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-MM325DR6.js";
|
|
13
|
+
import "./chunk-ZIPGRLYE.js";
|
|
14
|
+
import "./chunk-5WRI5ZAA.js";
|
|
14
15
|
|
|
15
|
-
// src/commands/update.ts
|
|
16
|
+
// src/commands/experimental/update.ts
|
|
16
17
|
import { defineCommand } from "citty";
|
|
17
18
|
function buildRouteAddition(actual) {
|
|
18
19
|
const parts = actual.trim().split(/\s+/);
|
|
@@ -129,4 +130,4 @@ export {
|
|
|
129
130
|
update_default as default,
|
|
130
131
|
generateUpdates
|
|
131
132
|
};
|
|
132
|
-
//# sourceMappingURL=update-
|
|
133
|
+
//# sourceMappingURL=update-KLDLDQZM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/experimental/update.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { Finding } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport interface UpdateSuggestion {\n specId: string;\n section: string;\n addition: string;\n reason: string;\n}\n\nexport interface GenerateUpdatesInput {\n findings: Finding[];\n}\n\nexport interface GenerateUpdatesResult {\n suggestions: UpdateSuggestion[];\n}\n\nfunction buildRouteAddition(actual: string): string {\n const parts = actual.trim().split(/\\s+/);\n const method = parts[0] ?? \"GET\";\n const path = parts[1] ?? actual;\n return `### ${method} ${path}\\nDescription placeholder.`;\n}\n\nfunction buildTypeAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nfunction buildTestAddition(actual: string): string {\n return `- ${actual}`;\n}\n\nexport function generateUpdates({ findings }: GenerateUpdatesInput): GenerateUpdatesResult {\n const suggestions: UpdateSuggestion[] = [];\n\n for (const finding of findings) {\n // Only act on extra findings — code has something the spec doesn't know about.\n // missing = code is wrong, spec is correct → skip.\n // mismatch = ambiguous → skip for now, let the user decide.\n if (finding.type !== \"extra\") continue;\n\n const actual = finding.actual ?? \"\";\n\n if (finding.category === \"route\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Endpoints\",\n addition: buildRouteAddition(actual),\n reason: `Route ${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"type\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Data Model\",\n addition: buildTypeAddition(actual),\n reason: `${actual} exists in code but is not documented in the spec.`,\n });\n } else if (finding.category === \"test\") {\n suggestions.push({\n specId: finding.specId,\n section: \"Test Cases\",\n addition: buildTestAddition(actual),\n reason: `Test case \"${actual}\" exists in code but is not listed in the spec.`,\n });\n }\n }\n\n return { suggestions };\n}\n\nfunction printSuggestionsPretty(suggestions: UpdateSuggestion[]): void {\n if (suggestions.length === 0) {\n console.log(\"\\n sdx update — no spec updates suggested\\n\");\n return;\n }\n\n console.log(`\\n sdx update — ${suggestions.length} suggested spec update(s)\\n`);\n\n // Group by specId\n const bySpec = new Map<string, UpdateSuggestion[]>();\n for (const s of suggestions) {\n const list = bySpec.get(s.specId) ?? [];\n list.push(s);\n bySpec.set(s.specId, list);\n }\n\n for (const [specId, items] of bySpec) {\n console.log(` ${specId}:`);\n for (const item of items) {\n console.log(` [${item.section}] ${item.reason}`);\n console.log(` Add:\\n ${item.addition.replace(/\\n/g, \"\\n \")}`);\n }\n console.log();\n }\n\n console.log(\" Note: --apply is not implemented in v1. Apply changes manually.\\n\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"update\",\n description: \"Suggest spec updates based on sdx check findings (--from-code)\",\n },\n args: {\n ...sharedArgs,\n \"from-code\": {\n type: \"boolean\",\n description: \"Generate suggestions from code drift (sdx check findings)\",\n default: true,\n },\n spec: { type: \"string\", description: \"Limit to a specific spec ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\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 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 logger.debug(`Running check on ${specs.length} specs...`);\n\n const checkConfig = {\n ...config.check,\n ...(args.framework\n ? { framework: args.framework as \"auto\" | \"express\" | \"hono\" | \"nextjs\" }\n : {}),\n };\n\n const checkResult = await runCheck(specs, configDir, checkConfig);\n const { suggestions } = generateUpdates({ findings: checkResult.findings });\n\n if (args.format === \"json\") {\n console.log(JSON.stringify({ suggestions }, null, 2));\n } else {\n printSuggestionsPretty(suggestions);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,SAAS,mBAAmB,QAAwB;AAClD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,KAAK;AACvC,QAAM,SAAS,MAAM,CAAC,KAAK;AAC3B,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,OAAO,MAAM,IAAI,IAAI;AAAA;AAC9B;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEA,SAAS,kBAAkB,QAAwB;AACjD,SAAO,KAAK,MAAM;AACpB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAgD;AACzF,QAAM,cAAkC,CAAC;AAEzC,aAAW,WAAW,UAAU;AAI9B,QAAI,QAAQ,SAAS,QAAS;AAE9B,UAAM,SAAS,QAAQ,UAAU;AAEjC,QAAI,QAAQ,aAAa,SAAS;AAChC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,mBAAmB,MAAM;AAAA,QACnC,QAAQ,SAAS,MAAM;AAAA,MACzB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB,MAAM;AAAA,QAClC,QAAQ,GAAG,MAAM;AAAA,MACnB,CAAC;AAAA,IACH,WAAW,QAAQ,aAAa,QAAQ;AACtC,kBAAY,KAAK;AAAA,QACf,QAAQ,QAAQ;AAAA,QAChB,SAAS;AAAA,QACT,UAAU,kBAAkB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AAQ,IAAI;AAC9B,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AAEpD,WAAO,MAAM,kBAAkB;AAE/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,WAAO,MAAM,oBAAoB,MAAM,MAAM,WAAW;AAExD,UAAM,cAAc;AAAA,MAClB,GAAG,OAAO;AAAA,MACV,GAAI,KAAK,YACL,EAAE,WAAW,KAAK,UAAoD,IACtE,CAAC;AAAA,IACP;AAEA,UAAM,cAAc,MAAM,SAAS,OAAO,WAAW,WAAW;AAChE,UAAM,EAAE,YAAY,IAAI,gBAAgB,EAAE,UAAU,YAAY,SAAS,CAAC;AAE1E,QAAI,KAAK,WAAW,QAAQ;AAC1B,cAAQ,IAAI,KAAK,UAAU,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAAA,IACtD,OAAO;AACL,6BAAuB,WAAW;AAAA,IACpC;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sharedArgs
|
|
3
|
+
} from "./chunk-GAM4MXPC.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigError,
|
|
6
|
+
GraphError,
|
|
7
|
+
buildGraph,
|
|
8
|
+
loadConfig,
|
|
9
|
+
resolveGlob
|
|
10
|
+
} from "./chunk-MM325DR6.js";
|
|
11
|
+
import "./chunk-ZIPGRLYE.js";
|
|
12
|
+
import "./chunk-5WRI5ZAA.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/core/validate.ts
|
|
15
|
+
import { defineCommand } from "citty";
|
|
16
|
+
async function runValidate(configDir) {
|
|
17
|
+
const warnings = [];
|
|
18
|
+
try {
|
|
19
|
+
const config = await loadConfig(void 0, configDir);
|
|
20
|
+
buildGraph(config);
|
|
21
|
+
let specFileCount = 0;
|
|
22
|
+
const missingRequired = [];
|
|
23
|
+
for (const [key, entry] of Object.entries(config.specs)) {
|
|
24
|
+
const files = await resolveGlob(entry.path, configDir);
|
|
25
|
+
specFileCount += files.length;
|
|
26
|
+
if (files.length > 0) continue;
|
|
27
|
+
if (entry.required) {
|
|
28
|
+
missingRequired.push(`"${key}" (${entry.path})`);
|
|
29
|
+
} else {
|
|
30
|
+
warnings.push(`spec entry "${key}" resolves to no files: ${entry.path}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (missingRequired.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
specCount: Object.keys(config.specs).length,
|
|
37
|
+
specFileCount,
|
|
38
|
+
warnings,
|
|
39
|
+
error: `required spec entry resolves to no files: ${missingRequired.join(", ")}`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (specFileCount === 0) {
|
|
43
|
+
warnings.push(
|
|
44
|
+
"no spec files found \u2014 every downstream check (lint, status, ready) would pass vacuously"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
valid: true,
|
|
49
|
+
specCount: Object.keys(config.specs).length,
|
|
50
|
+
specFileCount,
|
|
51
|
+
warnings
|
|
52
|
+
};
|
|
53
|
+
} catch (err) {
|
|
54
|
+
if (err instanceof ConfigError) {
|
|
55
|
+
return { valid: false, warnings, error: err.message, details: err.errors ?? void 0 };
|
|
56
|
+
}
|
|
57
|
+
if (err instanceof GraphError) {
|
|
58
|
+
return { valid: false, warnings, error: err.message };
|
|
59
|
+
}
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
var validate_default = defineCommand({
|
|
64
|
+
meta: { name: "validate", description: "Validate spec.config.yaml" },
|
|
65
|
+
args: { ...sharedArgs },
|
|
66
|
+
async run() {
|
|
67
|
+
const result = await runValidate(process.cwd());
|
|
68
|
+
if (result.valid) {
|
|
69
|
+
console.log(
|
|
70
|
+
` \u2713 Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`
|
|
71
|
+
);
|
|
72
|
+
for (const w of result.warnings) console.log(` \u26A0 ${w}`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
console.error(` \u2717 Config invalid: ${result.error}`);
|
|
76
|
+
for (const w of result.warnings) console.error(` \u26A0 ${w}`);
|
|
77
|
+
if (result.details) {
|
|
78
|
+
for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);
|
|
79
|
+
}
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
export {
|
|
84
|
+
validate_default as default,
|
|
85
|
+
runValidate
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=validate-FXD5WS4C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/core/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, buildGraph, resolveGlob, ConfigError, GraphError } from \"@specdx/core\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport interface ValidateResult {\n valid: boolean;\n /** Number of spec entries declared in the config. */\n specCount?: number;\n /** Number of spec files those entries actually resolve to. */\n specFileCount?: number;\n /** Non-fatal honesty notes: entries resolving to nothing, empty suite. */\n warnings: string[];\n error?: string;\n details?: unknown[];\n}\n\n/**\n * Validate spec.config.yaml: a schema-valid config, a buildable dependency\n * graph (issue #13), and declared spec paths that actually resolve. An entry\n * that matches no files makes every downstream verdict vacuous, so it is\n * reported here rather than silently flowing into lint/status/ready.\n */\nexport async function runValidate(configDir: string): Promise<ValidateResult> {\n const warnings: string[] = [];\n try {\n const config = await loadConfig(undefined, configDir);\n buildGraph(config);\n\n let specFileCount = 0;\n const missingRequired: string[] = [];\n for (const [key, entry] of Object.entries(config.specs)) {\n const files = await resolveGlob(entry.path, configDir);\n specFileCount += files.length;\n if (files.length > 0) continue;\n\n if ((entry as { required?: boolean }).required) {\n missingRequired.push(`\"${key}\" (${entry.path})`);\n } else {\n warnings.push(`spec entry \"${key}\" resolves to no files: ${entry.path}`);\n }\n }\n\n if (missingRequired.length > 0) {\n return {\n valid: false,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n error: `required spec entry resolves to no files: ${missingRequired.join(\", \")}`,\n };\n }\n\n if (specFileCount === 0) {\n warnings.push(\n \"no spec files found — every downstream check (lint, status, ready) would pass vacuously\",\n );\n }\n\n return {\n valid: true,\n specCount: Object.keys(config.specs).length,\n specFileCount,\n warnings,\n };\n } catch (err) {\n if (err instanceof ConfigError) {\n return { valid: false, warnings, error: err.message, details: err.errors ?? undefined };\n }\n if (err instanceof GraphError) {\n return { valid: false, warnings, error: err.message };\n }\n throw err;\n }\n}\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n const result = await runValidate(process.cwd());\n\n if (result.valid) {\n console.log(\n ` ✓ Config valid. ${result.specCount} spec entries, ${result.specFileCount} spec files.`,\n );\n for (const w of result.warnings) console.log(` ⚠ ${w}`);\n return;\n }\n\n console.error(` ✗ Config invalid: ${result.error}`);\n for (const w of result.warnings) console.error(` ⚠ ${w}`);\n if (result.details) {\n for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n },\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAsB9B,eAAsB,YAAY,WAA4C;AAC5E,QAAM,WAAqB,CAAC;AAC5B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAW,SAAS;AACpD,eAAW,MAAM;AAEjB,QAAI,gBAAgB;AACpB,UAAM,kBAA4B,CAAC;AACnC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,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,MAC7E;AACA,iBAAW,KAAK,OAAO,SAAU,SAAQ,IAAI,YAAO,CAAC,EAAE;AACvD;AAAA,IACF;AAEA,YAAQ,MAAM,4BAAuB,OAAO,KAAK,EAAE;AACnD,eAAW,KAAK,OAAO,SAAU,SAAQ,MAAM,YAAO,CAAC,EAAE;AACzD,QAAI,OAAO,SAAS;AAClB,iBAAW,KAAK,OAAO,QAAS,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,IAC5E;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;","names":[]}
|
package/hooks/hooks.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hooks":
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
8
14
|
}
|
package/hooks/session-start
CHANGED
|
@@ -30,8 +30,25 @@ escape_for_json() {
|
|
|
30
30
|
printf '%s' "$s"
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
# Determine specdx invocation
|
|
34
|
-
|
|
33
|
+
# Determine the specdx invocation.
|
|
34
|
+
#
|
|
35
|
+
# Order matters. Resolving `specdx` from PATH first meant the plugin ran
|
|
36
|
+
# whatever version happened to be installed globally -- a stale one reported
|
|
37
|
+
# the project's config as invalid, and that answer was injected into the
|
|
38
|
+
# session as fact. A plugin ships with its own CLI; it must run that one.
|
|
39
|
+
#
|
|
40
|
+
# 1. the CLI bundled in this very package (${CLAUDE_PLUGIN_ROOT}/dist/main.js)
|
|
41
|
+
# 2. the project's own devDependency, so a pinned version wins
|
|
42
|
+
# 3. PATH
|
|
43
|
+
# 4. npx, which resolves the registry's `latest` and needs the network
|
|
44
|
+
PLUGIN_MAIN="${CLAUDE_PLUGIN_ROOT:-${SCRIPT_ROOT:-}}"
|
|
45
|
+
[ -z "$PLUGIN_MAIN" ] && PLUGIN_MAIN="$(cd "$(dirname "$0")/.." && pwd)"
|
|
46
|
+
|
|
47
|
+
if [ -f "${PLUGIN_MAIN}/dist/main.js" ] && command -v node >/dev/null 2>&1; then
|
|
48
|
+
SPECDX="node ${PLUGIN_MAIN}/dist/main.js"
|
|
49
|
+
elif [ -x "${PROJECT_ROOT}/node_modules/.bin/specdx" ]; then
|
|
50
|
+
SPECDX="${PROJECT_ROOT}/node_modules/.bin/specdx"
|
|
51
|
+
elif command -v specdx >/dev/null 2>&1; then
|
|
35
52
|
SPECDX="specdx"
|
|
36
53
|
elif command -v npx >/dev/null 2>&1; then
|
|
37
54
|
SPECDX="npx --yes specdx"
|
|
@@ -46,8 +63,23 @@ run_specdx() {
|
|
|
46
63
|
(cd "$1" && $SPECDX "${@:2}" 2>&1) | grep -v '^npm warn' || true
|
|
47
64
|
}
|
|
48
65
|
|
|
66
|
+
# Keep the injected block bounded. `graph` grows with the suite -- one line per
|
|
67
|
+
# spec, plus one per reference edge, plus the "not reflected in config requires"
|
|
68
|
+
# advice -- so a large suite would silently spend a large part of the context
|
|
69
|
+
# window on a session summary. The cap is stated in lines rather than tokens
|
|
70
|
+
# because that is what this script can count.
|
|
71
|
+
MAX_GRAPH_LINES=40
|
|
72
|
+
|
|
73
|
+
truncate_lines() {
|
|
74
|
+
awk -v max="$1" '
|
|
75
|
+
NR <= max { print }
|
|
76
|
+
END { if (NR > max) printf " … %d more line(s) — run `specdx graph` for the rest\n", NR - max }
|
|
77
|
+
'
|
|
78
|
+
}
|
|
79
|
+
|
|
49
80
|
validate_out="$(run_specdx "$PROJECT_ROOT" validate)" || validate_out="(validate failed)"
|
|
50
|
-
graph_out="$(run_specdx "$PROJECT_ROOT" graph
|
|
81
|
+
graph_out="$(run_specdx "$PROJECT_ROOT" graph | truncate_lines "$MAX_GRAPH_LINES")" ||
|
|
82
|
+
graph_out="(graph failed)"
|
|
51
83
|
|
|
52
84
|
# Build a compact summary (target: under 500 tokens)
|
|
53
85
|
summary="<specdx-context>
|
package/package.json
CHANGED
|
@@ -1,28 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specdx",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.20",
|
|
4
|
+
"description": "Spec-driven development toolchain. Validate, lint, pack, and ship specs for LLM-assisted workflows.",
|
|
4
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Umar Gora (https://github.com/umxr)",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/umxr/specdx.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/umxr/specdx#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/umxr/specdx/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"spec",
|
|
19
|
+
"specification",
|
|
20
|
+
"prd",
|
|
21
|
+
"technical-design",
|
|
22
|
+
"api-contract",
|
|
23
|
+
"lint",
|
|
24
|
+
"validation",
|
|
25
|
+
"llm",
|
|
26
|
+
"ai",
|
|
27
|
+
"context-packing",
|
|
28
|
+
"spec-driven-development",
|
|
29
|
+
"claude-code"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
5
34
|
"bin": {
|
|
6
35
|
"specdx": "./dist/main.js"
|
|
7
36
|
},
|
|
8
37
|
"exports": {
|
|
9
38
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js"
|
|
12
41
|
}
|
|
13
42
|
},
|
|
14
43
|
"files": [
|
|
15
44
|
"dist",
|
|
16
45
|
".claude-plugin",
|
|
17
|
-
"hooks"
|
|
46
|
+
"hooks",
|
|
47
|
+
"README.md"
|
|
18
48
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"clean": "rm -rf dist *.tsbuildinfo"
|
|
24
|
-
},
|
|
25
49
|
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.27.0",
|
|
26
51
|
"ajv": "^8.18.0",
|
|
27
52
|
"ajv-formats": "^3.0.1",
|
|
28
53
|
"citty": "^0.2.1",
|
|
@@ -33,18 +58,40 @@
|
|
|
33
58
|
"tinyglobby": "^0.2.12",
|
|
34
59
|
"unified": "^11.0.0",
|
|
35
60
|
"unist-util-visit": "^5.0.0",
|
|
36
|
-
"yaml": "^2.7.0"
|
|
61
|
+
"yaml": "^2.7.0",
|
|
62
|
+
"zod": "^3.23.0"
|
|
37
63
|
},
|
|
38
64
|
"devDependencies": {
|
|
39
|
-
"@specdx/check": "workspace:*",
|
|
40
|
-
"@specdx/core": "workspace:*",
|
|
41
|
-
"@specdx/diff": "workspace:*",
|
|
42
|
-
"@specdx/lint": "workspace:*",
|
|
43
|
-
"@specdx/mcp": "workspace:*",
|
|
44
|
-
"@specdx/pack": "workspace:*",
|
|
45
|
-
"@specdx/schema": "workspace:*",
|
|
46
|
-
"@specdx/skills": "workspace:*",
|
|
47
65
|
"tsup": "^8.5.1",
|
|
48
|
-
"typescript": "^5.7.0"
|
|
66
|
+
"typescript": "^5.7.0",
|
|
67
|
+
"@specdx/check": "0.0.0",
|
|
68
|
+
"@specdx/core": "0.0.0",
|
|
69
|
+
"@specdx/diff": "0.0.0",
|
|
70
|
+
"@specdx/lint": "0.0.0",
|
|
71
|
+
"@specdx/mcp": "0.0.0",
|
|
72
|
+
"@specdx/schema": "0.0.0",
|
|
73
|
+
"@specdx/pack": "0.0.0",
|
|
74
|
+
"@specdx/skills": "0.0.0"
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"ts-morph": ">=20",
|
|
81
|
+
"@anthropic-ai/sdk": ">=0.30"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"ts-morph": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@anthropic-ai/sdk": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"typecheck": "tsc --noEmit",
|
|
94
|
+
"test": "vitest run",
|
|
95
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
49
96
|
}
|
|
50
|
-
}
|
|
97
|
+
}
|