specdx 0.2.0-alpha.3 → 0.3.0-alpha.1
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 +6 -0
- package/dist/changelog-NPN34DIO.js +86 -0
- package/dist/changelog-NPN34DIO.js.map +1 -0
- package/dist/{chunk-JLK2NNAF.js → chunk-276J7LR6.js} +12 -16
- package/dist/chunk-276J7LR6.js.map +1 -0
- package/dist/{lint-V42NAO3U.js → chunk-6DTOYCZ6.js} +4 -102
- package/dist/chunk-6DTOYCZ6.js.map +1 -0
- package/dist/chunk-AO3ZQKLJ.js +1147 -0
- package/dist/chunk-AO3ZQKLJ.js.map +1 -0
- package/dist/chunk-GAM4MXPC.js +15 -0
- package/dist/chunk-GAM4MXPC.js.map +1 -0
- package/dist/{chunk-CV2CHFFG.js → chunk-XLEN6ZYM.js} +29 -5
- package/dist/chunk-XLEN6ZYM.js.map +1 -0
- package/dist/diff-GWJONALU.js +100 -0
- package/dist/diff-GWJONALU.js.map +1 -0
- package/dist/explain-YXUILNEA.js +102 -0
- package/dist/explain-YXUILNEA.js.map +1 -0
- package/dist/{graph-G3ILOAV6.js → graph-OWQJWVSN.js} +7 -5
- package/dist/{graph-G3ILOAV6.js.map → graph-OWQJWVSN.js.map} +1 -1
- package/dist/index.js +1550 -6
- package/dist/index.js.map +1 -1
- package/dist/lint-CHWVBUV5.js +111 -0
- package/dist/lint-CHWVBUV5.js.map +1 -0
- package/dist/main.js +10 -6
- package/dist/main.js.map +1 -1
- package/dist/{pack-RWWFJSPV.js → pack-OJAC7JF2.js} +7 -5
- package/dist/{pack-RWWFJSPV.js.map → pack-OJAC7JF2.js.map} +1 -1
- package/dist/skills/spec-type-reference.md +57 -0
- package/dist/skills/{specdx-author-spec/SKILL.md → specdx-author-spec.md} +15 -1
- package/dist/skills/specdx-onboard.md +49 -0
- package/dist/skills/specdx-plan-from-spec.md +72 -0
- package/dist/skills/specdx-pre-commit.md +56 -0
- package/dist/skills/specdx-sprint-review.md +69 -0
- package/dist/skills/{specdx-start-task/SKILL.md → specdx-start-task.md} +1 -1
- package/dist/{skills-5XHJEKA2.js → skills-XJYTWGDK.js} +15 -9
- package/dist/skills-XJYTWGDK.js.map +1 -0
- package/dist/status-VMALGNS5.js +145 -0
- package/dist/status-VMALGNS5.js.map +1 -0
- package/dist/{validate-XZWUCAWU.js → validate-DOZZEZFC.js} +7 -5
- package/dist/{validate-XZWUCAWU.js.map → validate-DOZZEZFC.js.map} +1 -1
- package/hooks/hooks.json +8 -0
- package/hooks/run-hook.cmd +46 -0
- package/hooks/session-start +77 -0
- package/package.json +5 -2
- package/dist/chunk-CV2CHFFG.js.map +0 -1
- package/dist/chunk-JLK2NNAF.js.map +0 -1
- package/dist/lint-V42NAO3U.js.map +0 -1
- package/dist/skills-5XHJEKA2.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: specdx-plan-from-spec
|
|
3
|
+
description: "Use when the user asks to plan implementation, create a plan from specs, or says 'how should I build this', 'plan this', 'create an implementation plan', or 'what's the approach'. Generates a step-by-step plan grounded in project specs."
|
|
4
|
+
allowed-tools: Bash(npx specdx *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan From Spec
|
|
8
|
+
|
|
9
|
+
Generate an implementation plan grounded in the project's specs.
|
|
10
|
+
|
|
11
|
+
## Workflow
|
|
12
|
+
|
|
13
|
+
### Step 1: Load spec context
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx specdx pack --task "$ARGUMENTS" --format xml --full
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Replace `$ARGUMENTS` with the user's task description.
|
|
20
|
+
|
|
21
|
+
If the output is too large (over 8000 tokens), re-run without `--full`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx specdx pack --task "$ARGUMENTS" --format xml
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Step 2: Understand the specs
|
|
28
|
+
|
|
29
|
+
Read the packed output. Each `<spec>` has:
|
|
30
|
+
- `id` and `type` — what kind of spec
|
|
31
|
+
- `relevance` — how relevant to the task (0-1)
|
|
32
|
+
- Sections with the actual content
|
|
33
|
+
|
|
34
|
+
Focus on the highest-relevance specs first.
|
|
35
|
+
|
|
36
|
+
### Step 3: Generate the plan
|
|
37
|
+
|
|
38
|
+
Create a step-by-step implementation plan with:
|
|
39
|
+
|
|
40
|
+
1. **File targets** — which files to create or modify
|
|
41
|
+
2. **Dependency order** — what to build first based on the spec dependency graph
|
|
42
|
+
3. **Test expectations** — what tests to write for each step
|
|
43
|
+
4. **Spec references** — link each step back to the relevant spec section (e.g. "implements PRD Feature F2", "satisfies test-plan edge case 3")
|
|
44
|
+
|
|
45
|
+
### Step 4: Structure for execution
|
|
46
|
+
|
|
47
|
+
If the user has the superpowers plugin installed, structure the plan to be compatible with the `writing-plans` skill format:
|
|
48
|
+
|
|
49
|
+
- Use checkbox syntax (`- [ ]`) for each step
|
|
50
|
+
- Include exact file paths
|
|
51
|
+
- Include code snippets where helpful
|
|
52
|
+
- Group steps into logical tasks (2-5 minutes each)
|
|
53
|
+
|
|
54
|
+
If the user doesn't have superpowers, use a simpler numbered list format.
|
|
55
|
+
|
|
56
|
+
## Spec types and what they tell you
|
|
57
|
+
|
|
58
|
+
| Type | What to extract for the plan |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `prd` | Feature list (F1, F2...), success criteria, non-goals (what NOT to build) |
|
|
61
|
+
| `technical-design` | Architecture, data model, API design, dependencies, risks |
|
|
62
|
+
| `user-story` | Acceptance criteria, priority, estimate |
|
|
63
|
+
| `test-plan` | Test cases, coverage matrix, edge cases |
|
|
64
|
+
| `adr` | Decisions and constraints to respect |
|
|
65
|
+
| `api-contract` | Endpoints, schemas, auth requirements |
|
|
66
|
+
|
|
67
|
+
## How to use the context
|
|
68
|
+
|
|
69
|
+
1. **Reference specs** — mention feature IDs or spec sections when your plan relates to them
|
|
70
|
+
2. **Flag gaps** — if the task needs decisions not covered by any spec, say so
|
|
71
|
+
3. **Respect non-goals** — if the PRD says "not X", don't plan for X
|
|
72
|
+
4. **Note risks** — if the technical design lists risks relevant to the task, address them in the plan
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: specdx-pre-commit
|
|
3
|
+
description: "Use when the user is about to commit, mentions committing, or says 'let's commit', 'ready to commit', 'wrap up', or 'commit this'. Checks spec health and flags drift before committing."
|
|
4
|
+
allowed-tools: Bash(npx specdx *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pre-Commit Spec Check
|
|
8
|
+
|
|
9
|
+
Run spec health checks before committing to catch drift early.
|
|
10
|
+
|
|
11
|
+
<HARD-GATE>
|
|
12
|
+
Do NOT skip the diff step. Even if the user says "just commit", run the checks and surface the results before proceeding. Silent skipping leads to undetected spec drift.
|
|
13
|
+
</HARD-GATE>
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
### Step 1: Lint
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx specdx lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If lint errors are found, report them and ask the user to fix before committing.
|
|
24
|
+
|
|
25
|
+
### Step 2: Diff
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx specdx diff
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the command fails (e.g. no git history), skip this step and note it.
|
|
32
|
+
|
|
33
|
+
### Step 3: Present results
|
|
34
|
+
|
|
35
|
+
**If no spec changes detected:**
|
|
36
|
+
> "No spec changes — safe to commit."
|
|
37
|
+
|
|
38
|
+
**If changes detected, present a summary:**
|
|
39
|
+
- Which specs changed and what sections were modified
|
|
40
|
+
- Downstream specs that may need updating (with staleness scores)
|
|
41
|
+
- Whether any downstream specs are flagged as stale
|
|
42
|
+
|
|
43
|
+
### Step 4: Ask the user
|
|
44
|
+
|
|
45
|
+
> "Do you want to update downstream specs before committing, or proceed as-is?"
|
|
46
|
+
|
|
47
|
+
Respect the user's decision either way.
|
|
48
|
+
|
|
49
|
+
## Rationalizations to Resist
|
|
50
|
+
|
|
51
|
+
| Thought | Reality |
|
|
52
|
+
|---------|---------|
|
|
53
|
+
| "The user just wants to commit quickly" | A 5-second check prevents hours of drift debugging. |
|
|
54
|
+
| "There are no spec files in the diff" | Code changes can still drift from specs. Run the check. |
|
|
55
|
+
| "I already ran lint earlier" | Specs may have changed since. Run it again. |
|
|
56
|
+
| "The diff command failed, so skip everything" | Report the lint results at minimum. |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: specdx-sprint-review
|
|
3
|
+
description: "Use when the user asks for a summary, sprint review, spec health report, progress update, or says 'how are specs looking', 'spec health', or 'what changed'. Generates a shareable spec health report."
|
|
4
|
+
allowed-tools: Bash(npx specdx *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sprint Review — Spec Health Report
|
|
8
|
+
|
|
9
|
+
Generate a shareable summary of spec suite health and recent changes.
|
|
10
|
+
|
|
11
|
+
## Workflow
|
|
12
|
+
|
|
13
|
+
### Step 1: Get current health
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx specdx status --format json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Parse the JSON output to understand: project name, spec count, lint health (errors/warnings), stale specs, verdict.
|
|
20
|
+
|
|
21
|
+
### Step 2: Get recent changes
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx specdx diff --format json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If this fails (e.g. no git history or no baseline branch), skip and note "diff unavailable".
|
|
28
|
+
|
|
29
|
+
Parse the JSON to understand: which specs changed, sections modified, downstream impact.
|
|
30
|
+
|
|
31
|
+
### Step 3: Synthesise the report
|
|
32
|
+
|
|
33
|
+
Present a markdown report covering:
|
|
34
|
+
|
|
35
|
+
1. **Health verdict** — healthy/warnings/errors with spec count
|
|
36
|
+
2. **Lint status** — errors and warnings count
|
|
37
|
+
3. **Recent changes** — specs added, modified, or removed (from diff)
|
|
38
|
+
4. **Downstream impact** — which specs may need attention, staleness scores
|
|
39
|
+
5. **Stale specs** — any specs not updated past the threshold
|
|
40
|
+
6. **Recommended actions** — concrete suggestions (e.g. "technical-design hasn't been updated since prd changed 5 days ago")
|
|
41
|
+
|
|
42
|
+
### Step 4: Format for sharing
|
|
43
|
+
|
|
44
|
+
Present the report in clean markdown that can be pasted directly into Slack, a PR description, or a standup document.
|
|
45
|
+
|
|
46
|
+
## Reading the output
|
|
47
|
+
|
|
48
|
+
The `status --format json` output looks like:
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"project": "my-project",
|
|
52
|
+
"specCount": 3,
|
|
53
|
+
"byStatus": {"approved": 2, "draft": 1},
|
|
54
|
+
"lintHealth": {"errors": 0, "warnings": 2, "passing": 3},
|
|
55
|
+
"staleSpecs": [{"specId": "tech", "daysSinceUpdate": 15}],
|
|
56
|
+
"verdict": "warnings"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The `diff --format json` output looks like:
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"diffs": [{"specId": "prd", "summary": "prd: 1 field(s) changed, 1 section(s) changed"}],
|
|
64
|
+
"added": [],
|
|
65
|
+
"removed": [],
|
|
66
|
+
"impact": [{"changedSpec": "prd", "downstream": [{"specId": "tech", "staleness": 0.7}]}],
|
|
67
|
+
"summary": "1 spec changed, 1 downstream affected"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: specdx-start-task
|
|
3
|
-
description:
|
|
3
|
+
description: Use when the user describes work they're about to do, mentions implementing a feature, asks to start a task, or says 'implement', 'build', 'add', 'fix', or 'refactor'. Loads relevant spec context before coding.
|
|
4
4
|
allowed-tools: Bash(npx specdx *)
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -7,7 +7,14 @@ import { statSync } from "fs";
|
|
|
7
7
|
import { join, dirname } from "path";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
9
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
var
|
|
10
|
+
var SKILL_NAMES = [
|
|
11
|
+
"specdx-start-task",
|
|
12
|
+
"specdx-author-spec",
|
|
13
|
+
"specdx-pre-commit",
|
|
14
|
+
"specdx-sprint-review",
|
|
15
|
+
"specdx-plan-from-spec",
|
|
16
|
+
"specdx-onboard"
|
|
17
|
+
];
|
|
11
18
|
function getSkillSourceDir() {
|
|
12
19
|
const bundledPath = join(__dirname, "skills");
|
|
13
20
|
try {
|
|
@@ -19,13 +26,13 @@ function getSkillSourceDir() {
|
|
|
19
26
|
}
|
|
20
27
|
async function installSkills(projectDir) {
|
|
21
28
|
const sourceDir = getSkillSourceDir();
|
|
22
|
-
const
|
|
29
|
+
const commandsDir = join(projectDir, ".claude", "commands");
|
|
23
30
|
const installed = [];
|
|
24
31
|
const updated = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const targetPath = join(
|
|
32
|
+
await mkdir(commandsDir, { recursive: true });
|
|
33
|
+
for (const skillName of SKILL_NAMES) {
|
|
34
|
+
const sourcePath = join(sourceDir, `${skillName}.md`);
|
|
35
|
+
const targetPath = join(commandsDir, `${skillName}.md`);
|
|
29
36
|
const content = await readFile(sourcePath, "utf-8");
|
|
30
37
|
let exists = false;
|
|
31
38
|
try {
|
|
@@ -33,7 +40,6 @@ async function installSkills(projectDir) {
|
|
|
33
40
|
exists = true;
|
|
34
41
|
} catch {
|
|
35
42
|
}
|
|
36
|
-
await mkdir(targetDir, { recursive: true });
|
|
37
43
|
await writeFile(targetPath, content, "utf-8");
|
|
38
44
|
if (exists) {
|
|
39
45
|
updated.push(skillName);
|
|
@@ -67,7 +73,7 @@ var skills_default = defineCommand({
|
|
|
67
73
|
for (const file of result.installed) console.log(` \u2713 Installed ${file}`);
|
|
68
74
|
for (const file of result.updated) console.log(` \u2713 Updated ${file}`);
|
|
69
75
|
console.log(`
|
|
70
|
-
Skills installed to .claude/
|
|
76
|
+
Skills installed to .claude/commands/`);
|
|
71
77
|
} catch (err) {
|
|
72
78
|
console.error(`
|
|
73
79
|
\u2717 ${err.message}
|
|
@@ -81,4 +87,4 @@ var skills_default = defineCommand({
|
|
|
81
87
|
export {
|
|
82
88
|
skills_default as default
|
|
83
89
|
};
|
|
84
|
-
//# sourceMappingURL=skills-
|
|
90
|
+
//# sourceMappingURL=skills-XJYTWGDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/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 },\n async run({ args }) {\n try {\n const result = await installSkills(args.dir);\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/commands/`);\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 } from \"node:fs/promises\";\nimport { statSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/** Skill file names (without .md extension) */\nexport const SKILL_NAMES = [\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];\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\nexport async function installSkills(projectDir: string): Promise<InstallResult> {\n const sourceDir = getSkillSourceDir();\n const commandsDir = join(projectDir, \".claude\", \"commands\");\n const installed: string[] = [];\n const updated: string[] = [];\n\n await mkdir(commandsDir, { recursive: true });\n\n for (const skillName of SKILL_NAMES) {\n const sourcePath = join(sourceDir, `${skillName}.md`);\n const targetPath = join(commandsDir, `${skillName}.md`);\n\n const content = await readFile(sourcePath, \"utf-8\");\n\n // Check if target already exists\n let exists = false;\n try {\n await stat(targetPath);\n exists = true;\n } catch {\n // File doesn't exist\n }\n\n await writeFile(targetPath, content, \"utf-8\");\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,YAAY;AACjD,SAAS,gBAAgB;AACzB,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGjD,IAAM,cAAc;EACzB;EACA;EACA;EACA;EACA;EACA;;AAQF,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;AAEA,eAAsB,cAAc,YAAkB;AACpD,QAAM,YAAY,kBAAiB;AACnC,QAAM,cAAc,KAAK,YAAY,WAAW,UAAU;AAC1D,QAAM,YAAsB,CAAA;AAC5B,QAAM,UAAoB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,QAChB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLintEngine,
|
|
3
|
+
getPreset
|
|
4
|
+
} from "./chunk-6DTOYCZ6.js";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_DIFF_CONFIG
|
|
7
|
+
} from "./chunk-AO3ZQKLJ.js";
|
|
8
|
+
import {
|
|
9
|
+
buildGraph,
|
|
10
|
+
loadConfig,
|
|
11
|
+
parseSpec,
|
|
12
|
+
resolveGlob
|
|
13
|
+
} from "./chunk-276J7LR6.js";
|
|
14
|
+
import "./chunk-XLEN6ZYM.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/status.ts
|
|
17
|
+
import { defineCommand } from "citty";
|
|
18
|
+
async function runStatus(_options = {}) {
|
|
19
|
+
const configDir = process.cwd();
|
|
20
|
+
const config = await loadConfig(void 0, configDir);
|
|
21
|
+
const specs = [];
|
|
22
|
+
for (const [, entry] of Object.entries(config.specs)) {
|
|
23
|
+
const paths = await resolveGlob(entry.path, configDir);
|
|
24
|
+
for (const p of paths) {
|
|
25
|
+
const spec = await parseSpec(p);
|
|
26
|
+
specs.push({ spec, entry });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const byStatus = {};
|
|
30
|
+
for (const { spec } of specs) {
|
|
31
|
+
const status = spec.frontmatter.status || "unknown";
|
|
32
|
+
byStatus[status] = (byStatus[status] ?? 0) + 1;
|
|
33
|
+
}
|
|
34
|
+
const presetName = config.lint?.extends ?? "recommended";
|
|
35
|
+
const rules = getPreset(presetName);
|
|
36
|
+
let graph;
|
|
37
|
+
let graphError;
|
|
38
|
+
try {
|
|
39
|
+
graph = buildGraph(config);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
graphError = err.message;
|
|
42
|
+
}
|
|
43
|
+
const engine = createLintEngine({ rules, config, graph });
|
|
44
|
+
const lintResults = engine.lint(specs.map((s) => s.spec));
|
|
45
|
+
if (graphError) {
|
|
46
|
+
lintResults.diagnostics.push({
|
|
47
|
+
ruleId: "structure/no-circular-deps",
|
|
48
|
+
severity: "error",
|
|
49
|
+
message: graphError,
|
|
50
|
+
filePath: "spec.config.yaml"
|
|
51
|
+
});
|
|
52
|
+
lintResults.hasErrors = true;
|
|
53
|
+
}
|
|
54
|
+
const errors = lintResults.diagnostics.filter((d) => d.severity === "error").length;
|
|
55
|
+
const warnings = lintResults.diagnostics.filter((d) => d.severity === "warn").length;
|
|
56
|
+
const thresholdDays = config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;
|
|
57
|
+
const now = Date.now();
|
|
58
|
+
const staleSpecs = [];
|
|
59
|
+
for (const { spec, entry } of specs) {
|
|
60
|
+
const dateStr = spec.frontmatter.updated || spec.frontmatter.created;
|
|
61
|
+
if (dateStr) {
|
|
62
|
+
const daysSinceUpdate = Math.floor(
|
|
63
|
+
(now - new Date(dateStr).getTime()) / (1e3 * 60 * 60 * 24)
|
|
64
|
+
);
|
|
65
|
+
if (daysSinceUpdate > thresholdDays) {
|
|
66
|
+
staleSpecs.push({
|
|
67
|
+
specId: spec.frontmatter.id,
|
|
68
|
+
daysSinceUpdate,
|
|
69
|
+
owner: entry.owner
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const integrityIssues = [];
|
|
75
|
+
if (graphError) {
|
|
76
|
+
integrityIssues.push(graphError);
|
|
77
|
+
}
|
|
78
|
+
const refErrors = lintResults.diagnostics.filter(
|
|
79
|
+
(d) => d.ruleId === "structure/valid-references"
|
|
80
|
+
);
|
|
81
|
+
for (const d of refErrors) {
|
|
82
|
+
integrityIssues.push(d.message);
|
|
83
|
+
}
|
|
84
|
+
let verdict = "healthy";
|
|
85
|
+
if (errors > 0) verdict = "errors";
|
|
86
|
+
else if (warnings > 0 || staleSpecs.length > 0) verdict = "warnings";
|
|
87
|
+
return {
|
|
88
|
+
project: config.project?.name ?? "unknown",
|
|
89
|
+
specCount: specs.length,
|
|
90
|
+
byStatus,
|
|
91
|
+
lintHealth: { errors, warnings, passing: specs.length - errors },
|
|
92
|
+
staleSpecs,
|
|
93
|
+
integrityIssues,
|
|
94
|
+
verdict
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var status_default = defineCommand({
|
|
98
|
+
meta: { name: "status", description: "Show spec suite health overview" },
|
|
99
|
+
args: {
|
|
100
|
+
format: {
|
|
101
|
+
type: "string",
|
|
102
|
+
description: "Output format: pretty, json, github",
|
|
103
|
+
default: "pretty"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
async run({ args }) {
|
|
107
|
+
const result = await runStatus({ format: args.format });
|
|
108
|
+
if (args.format === "json") {
|
|
109
|
+
console.log(JSON.stringify(result, null, 2));
|
|
110
|
+
return;
|
|
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
|
+
);
|
|
117
|
+
}
|
|
118
|
+
for (const issue of result.integrityIssues) {
|
|
119
|
+
console.log(`::error::${issue}`);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" ? "\u26A0" : "\u2717";
|
|
124
|
+
console.log(`
|
|
125
|
+
${icon} ${result.project} \u2014 ${result.verdict}`);
|
|
126
|
+
console.log(
|
|
127
|
+
` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
128
|
+
);
|
|
129
|
+
console.log(` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`);
|
|
130
|
+
if (result.staleSpecs.length > 0) {
|
|
131
|
+
console.log(
|
|
132
|
+
` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
if (result.integrityIssues.length > 0) {
|
|
136
|
+
console.log(` Issues: ${result.integrityIssues.join("; ")}`);
|
|
137
|
+
}
|
|
138
|
+
console.log();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
export {
|
|
142
|
+
status_default as default,
|
|
143
|
+
runStatus
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=status-VMALGNS5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/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\n let verdict: \"healthy\" | \"warnings\" | \"errors\" = \"healthy\";\n if (errors > 0) verdict = \"errors\";\n else if (warnings > 0 || staleSpecs.length > 0) verdict = \"warnings\";\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 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 = result.verdict === \"healthy\" ? \"✓\" : result.verdict === \"warnings\" ? \"⚠\" : \"✗\";\n console.log(`\\n ${icon} ${result.project} — ${result.verdict}`);\n console.log(\n ` ${result.specCount} specs: ${Object.entries(result.byStatus)\n .map(([k, v]) => `${v} ${k}`)\n .join(\", \")}`,\n );\n console.log(` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`);\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 },\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,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AM,GAAG,CAAC,IAAI,CAAC,EAAE,EAC3B,KAAK,IAAI,CAAC;AAAA,IACf;AACA,YAAQ,IAAI,aAAa,OAAO,WAAW,MAAM,YAAY,OAAO,WAAW,QAAQ,WAAW;AAElG,QAAI,OAAO,WAAW,SAAS,GAAG;AAChC,cAAQ;AAAA,QACN,cAAc,OAAO,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,MAAM,KAAK,EAAE,eAAe,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,MAC9F;AAAA,IACF;AACA,QAAI,OAAO,gBAAgB,SAAS,GAAG;AACrC,cAAQ,IAAI,eAAe,OAAO,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,IAChE;AACA,YAAQ,IAAI;AAAA,EACd;AACF,CAAC;","names":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ConfigError,
|
|
3
|
-
loadConfig,
|
|
4
2
|
sharedArgs
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
3
|
+
} from "./chunk-GAM4MXPC.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigError,
|
|
6
|
+
loadConfig
|
|
7
|
+
} from "./chunk-276J7LR6.js";
|
|
8
|
+
import "./chunk-XLEN6ZYM.js";
|
|
7
9
|
|
|
8
10
|
// src/commands/validate.ts
|
|
9
11
|
import { defineCommand } from "citty";
|
|
@@ -29,4 +31,4 @@ var validate_default = defineCommand({
|
|
|
29
31
|
export {
|
|
30
32
|
validate_default as default
|
|
31
33
|
};
|
|
32
|
-
//# sourceMappingURL=validate-
|
|
34
|
+
//# sourceMappingURL=validate-DOZZEZFC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, ConfigError } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n try {\n const config = await loadConfig(undefined, process.cwd());\n console.log(` ✓ Config valid. ${Object.keys(config.specs).length} specs defined.`);\n } catch (err) {\n if (err instanceof ConfigError) {\n console.error(` ✗ Config invalid: ${err.message}`);\n if (err.errors) {\n for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, ConfigError } from \"@specdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n try {\n const config = await loadConfig(undefined, process.cwd());\n console.log(` ✓ Config valid. ${Object.keys(config.specs).length} specs defined.`);\n } catch (err) {\n if (err instanceof ConfigError) {\n console.error(` ✗ Config invalid: ${err.message}`);\n if (err.errors) {\n for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,IAAO,mBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,YAAY,aAAa,4BAA4B;AAAA,EACnE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,MAAM;AACV,QAAI;AACF,YAAM,SAAS,MAAM,WAAW,QAAW,QAAQ,IAAI,CAAC;AACxD,cAAQ,IAAI,0BAAqB,OAAO,KAAK,OAAO,KAAK,EAAE,MAAM,iBAAiB;AAAA,IACpF,SAAS,KAAK;AACZ,UAAI,eAAe,aAAa;AAC9B,gBAAQ,MAAM,4BAAuB,IAAI,OAAO,EAAE;AAClD,YAAI,IAAI,QAAQ;AACd,qBAAW,KAAK,IAAI,OAAQ,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,QACxE;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
: << 'CMDBLOCK'
|
|
2
|
+
@echo off
|
|
3
|
+
REM Cross-platform polyglot wrapper for hook scripts.
|
|
4
|
+
REM On Windows: cmd.exe runs the batch portion, which finds and calls bash.
|
|
5
|
+
REM On Unix: the shell interprets this as a script (: is a no-op in bash).
|
|
6
|
+
REM
|
|
7
|
+
REM Hook scripts use extensionless filenames (e.g. "session-start" not
|
|
8
|
+
REM "session-start.sh") so Claude Code's Windows auto-detection -- which
|
|
9
|
+
REM prepends "bash" to any command containing .sh -- doesn't interfere.
|
|
10
|
+
REM
|
|
11
|
+
REM Usage: run-hook.cmd <script-name> [args...]
|
|
12
|
+
|
|
13
|
+
if "%~1"=="" (
|
|
14
|
+
echo run-hook.cmd: missing script name >&2
|
|
15
|
+
exit /b 1
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
set "HOOK_DIR=%~dp0"
|
|
19
|
+
|
|
20
|
+
REM Try Git for Windows bash in standard locations
|
|
21
|
+
if exist "C:\Program Files\Git\bin\bash.exe" (
|
|
22
|
+
"C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
|
|
23
|
+
exit /b %ERRORLEVEL%
|
|
24
|
+
)
|
|
25
|
+
if exist "C:\Program Files (x86)\Git\bin\bash.exe" (
|
|
26
|
+
"C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
|
|
27
|
+
exit /b %ERRORLEVEL%
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin)
|
|
31
|
+
where bash >nul 2>nul
|
|
32
|
+
if %ERRORLEVEL% equ 0 (
|
|
33
|
+
bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
|
|
34
|
+
exit /b %ERRORLEVEL%
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
REM No bash found - exit silently rather than error
|
|
38
|
+
REM (plugin still works, just without SessionStart context injection)
|
|
39
|
+
exit /b 0
|
|
40
|
+
CMDBLOCK
|
|
41
|
+
|
|
42
|
+
# Unix: run the named script directly
|
|
43
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
44
|
+
SCRIPT_NAME="$1"
|
|
45
|
+
shift
|
|
46
|
+
exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SessionStart hook for specdx plugin
|
|
3
|
+
# Detects if the current project uses specdx and injects a lightweight summary.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# Search upward from $PWD for spec.config.yaml
|
|
8
|
+
find_config() {
|
|
9
|
+
local dir="$PWD"
|
|
10
|
+
while [ "$dir" != "/" ]; do
|
|
11
|
+
if [ -f "$dir/spec.config.yaml" ]; then
|
|
12
|
+
echo "$dir"
|
|
13
|
+
return 0
|
|
14
|
+
fi
|
|
15
|
+
dir="$(dirname "$dir")"
|
|
16
|
+
done
|
|
17
|
+
return 1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
PROJECT_ROOT="$(find_config 2>/dev/null)" || exit 0
|
|
21
|
+
|
|
22
|
+
# Escape string for JSON embedding using bash parameter substitution.
|
|
23
|
+
escape_for_json() {
|
|
24
|
+
local s="$1"
|
|
25
|
+
s="${s//\\/\\\\}"
|
|
26
|
+
s="${s//\"/\\\"}"
|
|
27
|
+
s="${s//$'\n'/\\n}"
|
|
28
|
+
s="${s//$'\r'/\\r}"
|
|
29
|
+
s="${s//$'\t'/\\t}"
|
|
30
|
+
printf '%s' "$s"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Determine specdx invocation: prefer local binary, fall back to npx
|
|
34
|
+
if command -v specdx >/dev/null 2>&1; then
|
|
35
|
+
SPECDX="specdx"
|
|
36
|
+
elif command -v npx >/dev/null 2>&1; then
|
|
37
|
+
SPECDX="npx --yes specdx"
|
|
38
|
+
else
|
|
39
|
+
# No way to run specdx — exit silently
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Run validate and graph from the project root; capture output gracefully.
|
|
44
|
+
# Filter npm warn lines (noise from pnpm workspace roots when using npx).
|
|
45
|
+
run_specdx() {
|
|
46
|
+
(cd "$1" && $SPECDX "${@:2}" 2>&1) | grep -v '^npm warn' || true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
validate_out="$(run_specdx "$PROJECT_ROOT" validate)" || validate_out="(validate failed)"
|
|
50
|
+
graph_out="$(run_specdx "$PROJECT_ROOT" graph)" || graph_out="(graph failed)"
|
|
51
|
+
|
|
52
|
+
# Build a compact summary (target: under 500 tokens)
|
|
53
|
+
summary="<specdx-context>
|
|
54
|
+
Project root: ${PROJECT_ROOT}
|
|
55
|
+
|
|
56
|
+
Validation:
|
|
57
|
+
${validate_out}
|
|
58
|
+
|
|
59
|
+
Dependency graph:
|
|
60
|
+
${graph_out}
|
|
61
|
+
</specdx-context>"
|
|
62
|
+
|
|
63
|
+
session_context="$(escape_for_json "$summary")"
|
|
64
|
+
|
|
65
|
+
# Output context injection as JSON.
|
|
66
|
+
# Claude Code hooks expect hookSpecificOutput.additionalContext.
|
|
67
|
+
# Cursor hooks expect additional_context.
|
|
68
|
+
# Emit only the field consumed by the current platform.
|
|
69
|
+
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
70
|
+
printf '{\n "additional_context": "%s"\n}\n' "$session_context"
|
|
71
|
+
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
|
|
72
|
+
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context"
|
|
73
|
+
else
|
|
74
|
+
printf '{\n "additional_context": "%s"\n}\n' "$session_context"
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specdx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"specdx": "./dist/main.js"
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist"
|
|
15
|
+
"dist",
|
|
16
|
+
".claude-plugin",
|
|
17
|
+
"hooks"
|
|
16
18
|
],
|
|
17
19
|
"scripts": {
|
|
18
20
|
"build": "tsup",
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@specdx/core": "workspace:*",
|
|
40
|
+
"@specdx/diff": "workspace:*",
|
|
38
41
|
"@specdx/lint": "workspace:*",
|
|
39
42
|
"@specdx/pack": "workspace:*",
|
|
40
43
|
"@specdx/schema": "workspace:*",
|