@gitwhy-cli/whyspec 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/dist/adapters/agents-md.d.ts +13 -0
  4. package/dist/adapters/agents-md.d.ts.map +1 -0
  5. package/dist/adapters/agents-md.js +165 -0
  6. package/dist/adapters/agents-md.js.map +1 -0
  7. package/dist/adapters/claude-code.d.ts +13 -0
  8. package/dist/adapters/claude-code.d.ts.map +1 -0
  9. package/dist/adapters/claude-code.js +206 -0
  10. package/dist/adapters/claude-code.js.map +1 -0
  11. package/dist/adapters/cursor.d.ts +12 -0
  12. package/dist/adapters/cursor.d.ts.map +1 -0
  13. package/dist/adapters/cursor.js +220 -0
  14. package/dist/adapters/cursor.js.map +1 -0
  15. package/dist/adapters/types.d.ts +16 -0
  16. package/dist/adapters/types.d.ts.map +1 -0
  17. package/dist/adapters/types.js +19 -0
  18. package/dist/adapters/types.js.map +1 -0
  19. package/dist/cli/index.d.ts +3 -0
  20. package/dist/cli/index.d.ts.map +1 -0
  21. package/dist/cli/index.js +109 -0
  22. package/dist/cli/index.js.map +1 -0
  23. package/dist/commands/capture.d.ts +18 -0
  24. package/dist/commands/capture.d.ts.map +1 -0
  25. package/dist/commands/capture.js +85 -0
  26. package/dist/commands/capture.js.map +1 -0
  27. package/dist/commands/debug.d.ts +16 -0
  28. package/dist/commands/debug.d.ts.map +1 -0
  29. package/dist/commands/debug.js +74 -0
  30. package/dist/commands/debug.js.map +1 -0
  31. package/dist/commands/execute.d.ts +36 -0
  32. package/dist/commands/execute.d.ts.map +1 -0
  33. package/dist/commands/execute.js +110 -0
  34. package/dist/commands/execute.js.map +1 -0
  35. package/dist/commands/init.d.ts +14 -0
  36. package/dist/commands/init.d.ts.map +1 -0
  37. package/dist/commands/init.js +166 -0
  38. package/dist/commands/init.js.map +1 -0
  39. package/dist/commands/list.d.ts +23 -0
  40. package/dist/commands/list.d.ts.map +1 -0
  41. package/dist/commands/list.js +95 -0
  42. package/dist/commands/list.js.map +1 -0
  43. package/dist/commands/plan.d.ts +20 -0
  44. package/dist/commands/plan.d.ts.map +1 -0
  45. package/dist/commands/plan.js +48 -0
  46. package/dist/commands/plan.js.map +1 -0
  47. package/dist/commands/search.d.ts +12 -0
  48. package/dist/commands/search.d.ts.map +1 -0
  49. package/dist/commands/search.js +36 -0
  50. package/dist/commands/search.js.map +1 -0
  51. package/dist/commands/show.d.ts +25 -0
  52. package/dist/commands/show.d.ts.map +1 -0
  53. package/dist/commands/show.js +145 -0
  54. package/dist/commands/show.js.map +1 -0
  55. package/dist/commands/status.d.ts +29 -0
  56. package/dist/commands/status.d.ts.map +1 -0
  57. package/dist/commands/status.js +125 -0
  58. package/dist/commands/status.js.map +1 -0
  59. package/dist/commands/template.d.ts +14 -0
  60. package/dist/commands/template.d.ts.map +1 -0
  61. package/dist/commands/template.js +25 -0
  62. package/dist/commands/template.js.map +1 -0
  63. package/dist/core/categorize.d.ts +30 -0
  64. package/dist/core/categorize.d.ts.map +1 -0
  65. package/dist/core/categorize.js +72 -0
  66. package/dist/core/categorize.js.map +1 -0
  67. package/dist/core/config.d.ts +26 -0
  68. package/dist/core/config.d.ts.map +1 -0
  69. package/dist/core/config.js +52 -0
  70. package/dist/core/config.js.map +1 -0
  71. package/dist/core/context.d.ts +27 -0
  72. package/dist/core/context.d.ts.map +1 -0
  73. package/dist/core/context.js +75 -0
  74. package/dist/core/context.js.map +1 -0
  75. package/dist/core/search.d.ts +51 -0
  76. package/dist/core/search.d.ts.map +1 -0
  77. package/dist/core/search.js +235 -0
  78. package/dist/core/search.js.map +1 -0
  79. package/dist/core/storage.d.ts +36 -0
  80. package/dist/core/storage.d.ts.map +1 -0
  81. package/dist/core/storage.js +80 -0
  82. package/dist/core/storage.js.map +1 -0
  83. package/dist/core/templates.d.ts +28 -0
  84. package/dist/core/templates.d.ts.map +1 -0
  85. package/dist/core/templates.js +176 -0
  86. package/dist/core/templates.js.map +1 -0
  87. package/dist/ui/ascii-logo.d.ts +7 -0
  88. package/dist/ui/ascii-logo.d.ts.map +1 -0
  89. package/dist/ui/ascii-logo.js +15 -0
  90. package/dist/ui/ascii-logo.js.map +1 -0
  91. package/dist/ui/tool-picker.d.ts +13 -0
  92. package/dist/ui/tool-picker.d.ts.map +1 -0
  93. package/dist/ui/tool-picker.js +76 -0
  94. package/dist/ui/tool-picker.js.map +1 -0
  95. package/dist/ui/welcome.d.ts +4 -0
  96. package/dist/ui/welcome.d.ts.map +1 -0
  97. package/dist/ui/welcome.js +43 -0
  98. package/dist/ui/welcome.js.map +1 -0
  99. package/dist/utils/changes.d.ts +19 -0
  100. package/dist/utils/changes.d.ts.map +1 -0
  101. package/dist/utils/changes.js +63 -0
  102. package/dist/utils/changes.js.map +1 -0
  103. package/dist/utils/git.d.ts +28 -0
  104. package/dist/utils/git.d.ts.map +1 -0
  105. package/dist/utils/git.js +104 -0
  106. package/dist/utils/git.js.map +1 -0
  107. package/dist/utils/slugify.d.ts +12 -0
  108. package/dist/utils/slugify.d.ts.map +1 -0
  109. package/dist/utils/slugify.js +21 -0
  110. package/dist/utils/slugify.js.map +1 -0
  111. package/dist/utils/telemetry.d.ts +21 -0
  112. package/dist/utils/telemetry.d.ts.map +1 -0
  113. package/dist/utils/telemetry.js +32 -0
  114. package/dist/utils/telemetry.js.map +1 -0
  115. package/package.json +81 -0
  116. package/skills/whyspec-capture/SKILL.md +154 -0
  117. package/skills/whyspec-debug/SKILL.md +404 -0
  118. package/skills/whyspec-execute/SKILL.md +118 -0
  119. package/skills/whyspec-plan/SKILL.md +170 -0
  120. package/skills/whyspec-search/SKILL.md +69 -0
  121. package/skills/whyspec-show/SKILL.md +90 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gitwhy-cli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/gitwhy-cli/whyspec/main/assets/banner.png" alt="WhySpec — The Reasoning Layer" width="100%">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>Built by <a href="https://gitwhy.dev">GitWhy</a> with ❤️</strong>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/gitwhy-cli/whyspec/actions/workflows/ci.yml"><img src="https://github.com/gitwhy-cli/whyspec/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
11
+ <a href="https://github.com/gitwhy-cli/whyspec/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="license"></a>
12
+ <a href="https://discord.gg/2X5X5XeFyT"><img src="https://img.shields.io/badge/discord-join-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
13
+ </p>
14
+
15
+ **Spec-driven development that captures reasoning.**
16
+
17
+ A spec-driven context engineering framework for AI coding agents like Claude Code, Cursor, Copilot, and more.
18
+
19
+ ## Our Vision
20
+
21
+ > Code tells you **what** was built. Tests tell you **how** it works. Only reasoning tells you **why** it exists.
22
+
23
+ - **Plan before coding** — surface decisions upfront
24
+ - **Capture after coding** — record what actually happened
25
+ - **Track the delta** — see what changed and what surprised you
26
+
27
+ In an era where AI writes most of the code, the human contribution isn't the syntax — it's the judgment. WhySpec preserves that judgment so it survives beyond the chat session that created it.
28
+
29
+ ## See it in action
30
+
31
+ ```
32
+ You: /whyspec:plan add-jwt-auth
33
+ AI: Created .gitwhy/changes/add-jwt-auth/
34
+ ✓ intent.md — why this change exists
35
+ ✓ design.md — approach + 3 decisions to make
36
+ ✓ tasks.md — verification-first checklist
37
+ Decision Bridge: 3 open questions to resolve.
38
+
39
+ You: /whyspec:execute add-jwt-auth
40
+ AI: Implementing with full context...
41
+ ✓ 1. Add token verification middleware
42
+ ✓ 2. Create login endpoint with bcrypt
43
+ ✓ 3. Wire up protected routes
44
+ All tasks complete! 3 decisions resolved.
45
+
46
+ You: /whyspec:capture add-jwt-auth
47
+ AI: Decision Bridge resolved:
48
+ ✓ Token storage: httpOnly cookie (XSS > CSRF)
49
+ ✓ Hashing: bcrypt (Node.js ecosystem)
50
+ ⚠ SURPRISE: Added 2FA (security review)
51
+ Saved to ctx_a1b2c3d4.md
52
+ ```
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ npm install -g @gitwhy-cli/whyspec
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```bash
63
+ cd your-project
64
+ whyspec init # Set up WhySpec
65
+ # Then use /whyspec:plan in Claude Code, or /whyspec-plan in Cursor
66
+ ```
67
+
68
+ That's it. WhySpec teaches your AI agent to plan before coding and capture reasoning after.
69
+
70
+ ## Docs
71
+
72
+ → [Getting Started](docs/getting-started.md): first steps<br>
73
+ → [Commands](docs/commands.md): slash commands & skills<br>
74
+ → [CLI](docs/cli.md): terminal reference<br>
75
+ → [Concepts](docs/concepts.md): Decision Bridge, context IDs, philosophy<br>
76
+ → [Supported Agents](docs/supported-tools.md): agent integrations & install paths<br>
77
+ → [Workflows](docs/workflows.md): common patterns<br>
78
+ → [GitWhy Integration](docs/gitwhy.md): SaaS platform & team sharing
79
+
80
+ ## Cross-Agent Support
81
+
82
+ | AI Agent | Integration | How |
83
+ |---------|------------|-----|
84
+ | **Claude Code** | Native skills | `.claude/skills/whyspec-*/SKILL.md` |
85
+ | **Cursor** | Slash commands | `.cursor/commands/whyspec-*.md` |
86
+ | **GitHub Copilot** | Project instructions | `AGENTS.md` |
87
+ | **Codex CLI** | Project instructions | `AGENTS.md` |
88
+ | **Windsurf** | Project instructions | `AGENTS.md` |
89
+ | **Cline** | Project instructions | `AGENTS.md` |
90
+ | **Amazon Q** | Project instructions | `AGENTS.md` |
91
+ | **RooCode** | Project instructions | `AGENTS.md` |
92
+
93
+ Run `whyspec init` and select your tools. WhySpec generates the right config for each.
94
+
95
+ ## Works With
96
+
97
+ WhySpec is complementary to existing AI coding tools. It fills the reasoning gap they leave open.
98
+
99
+ | Tool | What it owns | WhySpec adds |
100
+ |------|-------------|--------------|
101
+ | **OpenSpec** | Planning before code | Reasoning capture *after* code |
102
+ | **GSD** | Deep planning + execution | Decision Bridge: plan vs outcome tracking |
103
+ | **gstack** | Sprint lifecycle (review, QA, ship) | Persistent WHY behind each change |
104
+
105
+ WhySpec works **alongside** all three. Use them for planning and execution. Use WhySpec for reasoning.
106
+
107
+ ## Contributing
108
+
109
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and PR guidelines.
110
+
111
+ ## License
112
+
113
+ [MIT](LICENSE) -- free forever. Go capture some reasoning.
@@ -0,0 +1,13 @@
1
+ import { GeneratedFile } from "./types.js";
2
+ /**
3
+ * Generate AGENTS.md for AI tools that read project-root instruction files.
4
+ *
5
+ * Targets: GitHub Copilot, Windsurf, Cline, Amazon Q, RooCode, Codex CLI.
6
+ * Single comprehensive file with CLI-as-oracle pattern, example workflow,
7
+ * and Decision Bridge explanation.
8
+ *
9
+ * @param projectRoot - Optional project root prefix for paths (default: "")
10
+ * @returns Array of GeneratedFile objects (always 1 file)
11
+ */
12
+ export declare function generateAgentsMd(projectRoot?: string): GeneratedFile[];
13
+ //# sourceMappingURL=agents-md.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents-md.d.ts","sourceRoot":"","sources":["../../src/adapters/agents-md.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGd,MAAM,YAAY,CAAC;AAsJpB;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,GAAE,MAAW,GACvB,aAAa,EAAE,CASjB"}
@@ -0,0 +1,165 @@
1
+ import { WHYSPEC_COMMANDS, COMMAND_DESCRIPTIONS, } from "./types.js";
2
+ /**
3
+ * Generate the AGENTS.md content.
4
+ *
5
+ * This single file is read by GitHub Copilot, Windsurf, Cline, Amazon Q,
6
+ * RooCode, Codex CLI, and other AI coding agents that look for project-root
7
+ * instruction files.
8
+ */
9
+ function getAgentsMdContent() {
10
+ // Build the commands table
11
+ const commandRows = WHYSPEC_COMMANDS.map((cmd) => `| \`whyspec ${cmd} --json\` | ${COMMAND_DESCRIPTIONS[cmd]} |`).join("\n");
12
+ return `# WhySpec — The Reasoning Layer for AI Coding
13
+
14
+ WhySpec captures WHY code was built the way it was, not just what was built or how to build it. It tracks how reasoning evolves from intent to outcome through the **Decision Bridge**: the plan PREDICTS decisions before coding, the capture RECORDS decisions after coding, and the delta reveals what was anticipated, what changed, and what was surprising.
15
+
16
+ ## Commands
17
+
18
+ | Command | Description |
19
+ |---------|-------------|
20
+ ${commandRows}
21
+
22
+ ## How to Use WhySpec (CLI-as-Oracle Pattern)
23
+
24
+ WhySpec follows the CLI-as-oracle pattern: call the CLI with \`--json\` and parse the structured response. The CLI handles path creation, validation, and project context. You handle content generation.
25
+
26
+ ### Calling the CLI
27
+
28
+ Always use the \`--json\` flag when calling WhySpec commands:
29
+
30
+ \`\`\`bash
31
+ whyspec plan --json "add-jwt-auth"
32
+ \`\`\`
33
+
34
+ Example JSON response:
35
+
36
+ \`\`\`json
37
+ {
38
+ "path": ".gitwhy/changes/add-jwt-auth",
39
+ "templates": {
40
+ "intent": "## Why This Change Exists\\n...",
41
+ "design": "## Approach\\n...",
42
+ "tasks": "## Verification\\n..."
43
+ },
44
+ "context": { "project": "my-app", "branch": "feat/auth" }
45
+ }
46
+ \`\`\`
47
+
48
+ Parse the response and use the returned paths and templates to create or read files.
49
+
50
+ ### Reading CLI Output
51
+
52
+ \`\`\`bash
53
+ # Get execution context (reads plan files)
54
+ whyspec execute --json "add-jwt-auth"
55
+
56
+ # Get capture template with linked commits
57
+ whyspec capture --json "add-jwt-auth"
58
+
59
+ # View full change story with Decision Bridge delta
60
+ whyspec show --json "add-jwt-auth"
61
+
62
+ # Search past decisions
63
+ whyspec search --json "token expiry"
64
+
65
+ # Create debug session with related contexts
66
+ whyspec debug --json "login-fails-safari"
67
+ \`\`\`
68
+
69
+ ## Example Workflow: Plan, Execute, Capture
70
+
71
+ ### Step 1: Plan (before coding)
72
+
73
+ \`\`\`bash
74
+ whyspec plan --json "add-jwt-auth"
75
+ \`\`\`
76
+
77
+ Ask the developer forcing questions, then create three files:
78
+ - **intent.md** — Why this change exists, decisions to make, success criteria
79
+ - **design.md** — Technical approach, trade-offs, questions to resolve
80
+ - **tasks.md** — Verification criteria first, then implementation checklist
81
+
82
+ The "Decisions to Make" section in design.md is the BEFORE side of the Decision Bridge:
83
+ \`\`\`markdown
84
+ ## Decisions to Make
85
+ - [ ] Token storage: cookie vs localStorage?
86
+ - [ ] Hashing algorithm: bcrypt vs argon2?
87
+ - [ ] Session model: JWT vs server-side?
88
+ \`\`\`
89
+
90
+ ### Step 2: Execute (during coding)
91
+
92
+ \`\`\`bash
93
+ whyspec execute --json "add-jwt-auth"
94
+ \`\`\`
95
+
96
+ Read intent.md and design.md for context. Work through tasks.md, marking each task complete. Commit atomically per task.
97
+
98
+ ### Step 3: Capture (after coding)
99
+
100
+ \`\`\`bash
101
+ whyspec capture --json "add-jwt-auth"
102
+ \`\`\`
103
+
104
+ Record the reasoning behind what was built:
105
+ - Map each "Decision to Make" → "Decision Made" with rationale
106
+ - Capture surprises — decisions NOT in the original plan
107
+ - Include rejected alternatives and trade-offs
108
+
109
+ The AFTER side of the Decision Bridge:
110
+ \`\`\`markdown
111
+ ## Decisions Made
112
+ - [x] Token storage: httpOnly cookie — XSS protection outweighs CSRF complexity
113
+ - [x] Hashing: bcrypt — Better library support in Node.js ecosystem
114
+ - [x] JWT (stateless) — No session store needed for MVP
115
+ SURPRISE: Added 2FA — Security review required it (not in original plan)
116
+ \`\`\`
117
+
118
+ ## The Decision Bridge
119
+
120
+ The Decision Bridge is WhySpec's core differentiator. It tracks how decisions evolve:
121
+
122
+ | Phase | What it captures | File |
123
+ |-------|-----------------|------|
124
+ | **Before** (plan) | Decisions TO MAKE — questions, options, trade-offs | design.md |
125
+ | **After** (capture) | Decisions MADE — choices, rationale, surprises | ctx_*.md |
126
+ | **Delta** (show) | What changed — anticipated vs actual vs surprising | computed |
127
+
128
+ Use \`whyspec show --json "<name>"\` to see the full Decision Bridge delta for any change.
129
+
130
+ ## Debugging with WhySpec
131
+
132
+ WhySpec debug sessions follow the scientific method:
133
+
134
+ 1. **Symptoms** — Expected vs actual behavior
135
+ 2. **Past context search** — Check if anyone reasoned about this area before
136
+ 3. **Hypotheses** — 3+ falsifiable hypotheses
137
+ 4. **Investigation** — Test each hypothesis with evidence
138
+ 5. **Root cause** — Prove diagnosis before fixing (Iron Law: no fix without root cause)
139
+ 6. **Fix and capture** — Apply fix, then capture the debugging reasoning
140
+
141
+ ---
142
+
143
+ *This file is read by GitHub Copilot, Windsurf, Cline, Amazon Q, RooCode, Codex CLI, and other AI coding agents that support project-level instruction files.*
144
+ `;
145
+ }
146
+ /**
147
+ * Generate AGENTS.md for AI tools that read project-root instruction files.
148
+ *
149
+ * Targets: GitHub Copilot, Windsurf, Cline, Amazon Q, RooCode, Codex CLI.
150
+ * Single comprehensive file with CLI-as-oracle pattern, example workflow,
151
+ * and Decision Bridge explanation.
152
+ *
153
+ * @param projectRoot - Optional project root prefix for paths (default: "")
154
+ * @returns Array of GeneratedFile objects (always 1 file)
155
+ */
156
+ export function generateAgentsMd(projectRoot = "") {
157
+ const prefix = projectRoot ? `${projectRoot}/` : "";
158
+ return [
159
+ {
160
+ path: `${prefix}AGENTS.md`,
161
+ content: getAgentsMdContent(),
162
+ },
163
+ ];
164
+ }
165
+ //# sourceMappingURL=agents-md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents-md.js","sourceRoot":"","sources":["../../src/adapters/agents-md.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,SAAS,kBAAkB;IACzB,2BAA2B;IAC3B,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CACtC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,GAAG,eAAe,oBAAoB,CAAC,GAAG,CAAC,IAAI,CACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO;;;;;;;;EAQP,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4HZ,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,cAAsB,EAAE;IAExB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpD,OAAO;QACL;YACE,IAAI,EAAE,GAAG,MAAM,WAAW;YAC1B,OAAO,EAAE,kBAAkB,EAAE;SAC9B;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { GeneratedFile } from "./types.js";
2
+ /**
3
+ * Generate Claude Code skill files for all 6 WhySpec commands.
4
+ *
5
+ * Creates .claude/skills/whyspec-<command>/SKILL.md with:
6
+ * - YAML frontmatter (name, description)
7
+ * - Placeholder instructions showing the CLI-as-oracle pattern
8
+ *
9
+ * @param projectRoot - Optional project root prefix for paths (default: "")
10
+ * @returns Array of GeneratedFile objects
11
+ */
12
+ export declare function generateClaudeCodeSkills(projectRoot?: string): GeneratedFile[];
13
+ //# sourceMappingURL=claude-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAId,MAAM,YAAY,CAAC;AAyLpB;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,GAAE,MAAW,GACvB,aAAa,EAAE,CAmBjB"}
@@ -0,0 +1,206 @@
1
+ import { WHYSPEC_COMMANDS, COMMAND_DESCRIPTIONS, } from "./types.js";
2
+ /**
3
+ * Generate the placeholder instructions for each WhySpec command skill.
4
+ * These are filled with real content by Agent 5 (skill authoring).
5
+ * The placeholders show the CLI-as-oracle pattern so the skill is functional
6
+ * even before Agent 5 enriches it.
7
+ */
8
+ function getSkillInstructions(command) {
9
+ switch (command) {
10
+ case "plan":
11
+ return `# WhySpec Plan
12
+
13
+ Use this skill when the developer wants to plan a change before coding.
14
+
15
+ ## Workflow
16
+
17
+ 1. Ask the developer 2-3 forcing questions:
18
+ - "What problem does this solve?"
19
+ - "What constraints exist?"
20
+ - "How will you know it works?"
21
+
22
+ 2. Call the CLI to create the change folder:
23
+ \`\`\`bash
24
+ whyspec plan --json "<change-name>"
25
+ \`\`\`
26
+
27
+ 3. Parse the JSON response to get the folder path and templates.
28
+
29
+ 4. Create three files in the change folder:
30
+ - **intent.md** — Why this change exists, decisions to make, constraints, success criteria
31
+ - **design.md** — Technical approach, trade-off matrix, architecture, questions to resolve
32
+ - **tasks.md** — Verification criteria (defined FIRST), then implementation checklist
33
+
34
+ 5. The "Decisions to Make" section in design.md is the BEFORE side of the Decision Bridge.
35
+ These will be resolved by /whyspec:capture after implementation.
36
+
37
+ ## Important
38
+ - Always call the CLI first — it handles path creation and validation.
39
+ - Capture COMPLETE reasoning, not abbreviated summaries.
40
+ - Every decision-to-make should be a checkbox: \`- [ ] Token storage: cookie vs localStorage?\``;
41
+ case "execute":
42
+ return `# WhySpec Execute
43
+
44
+ Use this skill when the developer wants to implement a planned change.
45
+
46
+ ## Workflow
47
+
48
+ 1. Call the CLI to get the execution context:
49
+ \`\`\`bash
50
+ whyspec execute --json "<change-name>"
51
+ \`\`\`
52
+
53
+ 2. Parse the JSON response to get intent, design, tasks, and progress.
54
+
55
+ 3. Read intent.md and design.md for WHY context — understand the goal before coding.
56
+
57
+ 4. Work through tasks.md sequentially:
58
+ - Show progress: "Working on task 3/7: <description>"
59
+ - Implement the code changes
60
+ - Mark each task complete: \`- [ ]\` → \`- [x]\` in tasks.md
61
+ - Commit atomically (one commit per task or logical unit)
62
+
63
+ 5. On completion, prompt: "Ready to capture reasoning? Run /whyspec:capture"
64
+
65
+ ## Important
66
+ - Use intent.md as context while implementing — it contains the WHY.
67
+ - Track deviations from the plan — surprises are valuable for capture.
68
+ - Do not skip tasks or mark them done without implementing.`;
69
+ case "capture":
70
+ return `# WhySpec Capture
71
+
72
+ Use this skill when the developer wants to save reasoning after coding.
73
+
74
+ ## Workflow
75
+
76
+ 1. Call the CLI to get the capture template and metadata:
77
+ \`\`\`bash
78
+ whyspec capture --json "<change-name>"
79
+ \`\`\`
80
+
81
+ 2. Parse the JSON response to get the template, linked commits, and files changed.
82
+
83
+ 3. Read intent.md and design.md from the change folder.
84
+
85
+ 4. Create a ctx_<id>.md file in the change folder using the GitWhy SaaS XML format:
86
+ - Map each "Decision to Make" from design.md → "Decisions Made" with rationale
87
+ - Map each "Question to Resolve" → resolved answer
88
+ - Capture "Surprises" — decisions NOT in the plan
89
+ - Include story, rejected alternatives, trade-offs, verification, risks
90
+
91
+ 5. This completes the Decision Bridge: plan PREDICTED decisions, capture RECORDS them.
92
+
93
+ ## Important
94
+ - The context file uses \`<context>\` XML tags (GitWhy SaaS format).
95
+ - Include ALL decisions, not just the ones from the plan.
96
+ - Surprises (unplanned decisions) are the most valuable part of the capture.`;
97
+ case "show":
98
+ return `# WhySpec Show
99
+
100
+ Use this skill when the developer wants to view the full story of a change.
101
+
102
+ ## Workflow
103
+
104
+ 1. Call the CLI to get the full change data:
105
+ \`\`\`bash
106
+ whyspec show --json "<change-name>"
107
+ \`\`\`
108
+
109
+ 2. Parse the JSON response containing intent, design, tasks, context, and Decision Bridge delta.
110
+
111
+ 3. Display the change story in sections:
112
+ - **Intent** — WHY (from intent.md)
113
+ - **Design** — HOW (from design.md)
114
+ - **Tasks** — WHAT (from tasks.md with completion status)
115
+ - **Context** — REASONING (from ctx_<id>.md)
116
+ - **Decision Bridge Delta** — Decisions to Make vs Decisions Made, highlighting changes and surprises
117
+
118
+ ## Important
119
+ - The Decision Bridge delta is the unique value — always show it.
120
+ - If context hasn't been captured yet, show intent + design + tasks and suggest running /whyspec:capture.`;
121
+ case "search":
122
+ return `# WhySpec Search
123
+
124
+ Use this skill when the developer wants to find past decisions and reasoning.
125
+
126
+ ## Workflow
127
+
128
+ 1. Call the CLI to search across all changes:
129
+ \`\`\`bash
130
+ whyspec search --json "<query>"
131
+ \`\`\`
132
+
133
+ 2. Parse the JSON response containing scored results with snippets.
134
+
135
+ 3. Display results ranked by relevance:
136
+ - Title matches score highest (100 points)
137
+ - Reasoning/decision matches score next (30 points)
138
+ - File path matches score lower (20 points)
139
+
140
+ 4. For each result, show: title, change name, score, and a relevant snippet.
141
+
142
+ ## Important
143
+ - Search covers both active changes and archived ones.
144
+ - Search also finds intent.md and design.md — not just captured contexts.
145
+ - Use this before starting new work: "Has anyone reasoned about this area before?"`;
146
+ case "debug":
147
+ return `# WhySpec Debug
148
+
149
+ Use this skill when the developer is investigating a bug.
150
+
151
+ ## Workflow
152
+
153
+ 1. Call the CLI to create a debug session:
154
+ \`\`\`bash
155
+ whyspec debug --json "<bug-description>"
156
+ \`\`\`
157
+
158
+ 2. Parse the JSON response to get the debug folder path and related past contexts.
159
+
160
+ 3. Follow the scientific method:
161
+ - **Symptoms** — Expected vs actual behavior, error messages, reproduction steps
162
+ - **Related contexts** — Search past decisions in this area (from CLI response)
163
+ - **Hypotheses** — Form 3+ falsifiable hypotheses with "what would prove this wrong?"
164
+ - **Investigation** — Test each hypothesis with evidence gathering
165
+ - **Root cause** — Prove the diagnosis BEFORE proposing a fix (Iron Law)
166
+ - **Fix** — Apply the fix and verify
167
+ - **Prevention** — How to prevent this class of bug in the future
168
+
169
+ 4. Create debug.md with the full investigation trail.
170
+
171
+ 5. Auto-prompt: "Ready to capture debug reasoning? Run /whyspec:capture"
172
+
173
+ ## Important
174
+ - No fix without root cause — this is the Iron Law.
175
+ - Check related past contexts BEFORE forming hypotheses — past decisions inform better hypotheses.
176
+ - The debug.md persists across sessions so investigation survives context resets.`;
177
+ }
178
+ }
179
+ /**
180
+ * Generate Claude Code skill files for all 6 WhySpec commands.
181
+ *
182
+ * Creates .claude/skills/whyspec-<command>/SKILL.md with:
183
+ * - YAML frontmatter (name, description)
184
+ * - Placeholder instructions showing the CLI-as-oracle pattern
185
+ *
186
+ * @param projectRoot - Optional project root prefix for paths (default: "")
187
+ * @returns Array of GeneratedFile objects
188
+ */
189
+ export function generateClaudeCodeSkills(projectRoot = "") {
190
+ const prefix = projectRoot ? `${projectRoot}/` : "";
191
+ return WHYSPEC_COMMANDS.map((command) => {
192
+ const frontmatter = [
193
+ "---",
194
+ `name: whyspec-${command}`,
195
+ `description: ${COMMAND_DESCRIPTIONS[command]}`,
196
+ "---",
197
+ ].join("\n");
198
+ const instructions = getSkillInstructions(command);
199
+ const content = `${frontmatter}\n\n${instructions}\n`;
200
+ return {
201
+ path: `${prefix}.claude/skills/whyspec-${command}/SKILL.md`,
202
+ content,
203
+ };
204
+ });
205
+ }
206
+ //# sourceMappingURL=claude-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,OAAuB;IACnD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM;YACT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gGA6BmF,CAAC;QAE7F,KAAK,SAAS;YACZ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;4DA0B+C,CAAC;QAEzD,KAAK,SAAS;YACZ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0BgE,CAAC;QAE1E,KAAK,MAAM;YACT,OAAO;;;;;;;;;;;;;;;;;;;;;;0GAsB6F,CAAC;QAEvG,KAAK,QAAQ;YACX,OAAO;;;;;;;;;;;;;;;;;;;;;;;mFAuBsE,CAAC;QAEhF,KAAK,OAAO;YACV,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFA6BqE,CAAC;IACjF,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,cAAsB,EAAE;IAExB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,WAAW,GAAG;YAClB,KAAK;YACL,iBAAiB,OAAO,EAAE;YAC1B,gBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE;YAC/C,KAAK;SACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,GAAG,WAAW,OAAO,YAAY,IAAI,CAAC;QAEtD,OAAO;YACL,IAAI,EAAE,GAAG,MAAM,0BAA0B,OAAO,WAAW;YAC3D,OAAO;SACR,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { GeneratedFile } from "./types.js";
2
+ /**
3
+ * Generate Cursor custom slash command files for all 6 WhySpec commands.
4
+ *
5
+ * Creates .cursor/commands/whyspec-<command>.md files — plain markdown
6
+ * that Cursor discovers automatically as slash commands.
7
+ *
8
+ * @param projectRoot - Optional project root prefix for paths (default: "")
9
+ * @returns Array of GeneratedFile objects
10
+ */
11
+ export declare function generateCursorCommands(projectRoot?: string): GeneratedFile[];
12
+ //# sourceMappingURL=cursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAId,MAAM,YAAY,CAAC;AAkNpB;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,GAAE,MAAW,GACvB,aAAa,EAAE,CAOjB"}