@hustle-together/api-dev-tools 3.0.0 → 3.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 (37) hide show
  1. package/README.md +71 -0
  2. package/bin/cli.js +184 -14
  3. package/demo/audio/generate-all-narrations.js +124 -59
  4. package/demo/audio/generate-narration.js +120 -56
  5. package/demo/audio/narration-adam-timing.json +3086 -2077
  6. package/demo/audio/narration-adam.mp3 +0 -0
  7. package/demo/audio/narration-creature-timing.json +3094 -2085
  8. package/demo/audio/narration-creature.mp3 +0 -0
  9. package/demo/audio/narration-gaming-timing.json +3091 -2082
  10. package/demo/audio/narration-gaming.mp3 +0 -0
  11. package/demo/audio/narration-hope-timing.json +3072 -2063
  12. package/demo/audio/narration-hope.mp3 +0 -0
  13. package/demo/audio/narration-mark-timing.json +3090 -2081
  14. package/demo/audio/narration-mark.mp3 +0 -0
  15. package/demo/audio/voices-manifest.json +16 -16
  16. package/demo/workflow-demo.html +1528 -411
  17. package/hooks/api-workflow-check.py +2 -0
  18. package/hooks/enforce-deep-research.py +180 -0
  19. package/hooks/enforce-disambiguation.py +149 -0
  20. package/hooks/enforce-documentation.py +187 -0
  21. package/hooks/enforce-environment.py +249 -0
  22. package/hooks/enforce-refactor.py +187 -0
  23. package/hooks/enforce-research.py +93 -46
  24. package/hooks/enforce-schema.py +186 -0
  25. package/hooks/enforce-scope.py +156 -0
  26. package/hooks/enforce-tdd-red.py +246 -0
  27. package/hooks/enforce-verify.py +186 -0
  28. package/hooks/verify-after-green.py +136 -6
  29. package/package.json +2 -1
  30. package/scripts/collect-test-results.ts +404 -0
  31. package/scripts/extract-parameters.ts +483 -0
  32. package/scripts/generate-test-manifest.ts +520 -0
  33. package/templates/CLAUDE-SECTION.md +84 -0
  34. package/templates/api-dev-state.json +45 -5
  35. package/templates/api-test/page.tsx +315 -0
  36. package/templates/api-test/test-structure/route.ts +269 -0
  37. package/templates/settings.json +36 -0
@@ -21,25 +21,22 @@ const MODEL_ID = 'eleven_turbo_v2_5'; // Fast, high-quality model
21
21
  // Format: [SECTION:id] marks a new section, [HIGHLIGHT:element-selector] marks what to highlight
22
22
  const NARRATION_SCRIPT = `
23
23
  [SECTION:intro]
24
- Welcome to Hustle API Dev Tools.
24
+ Welcome to Hustle API Dev Tools, version three point oh.
25
25
 
26
26
  [HIGHLIGHT:#hustleBrand]
27
- This package enforces a structured workflow for AI-assisted API development.
27
+ This package enforces a structured, twelve-phase workflow for AI-assisted API development.
28
28
 
29
29
  [HIGHLIGHT:[data-phase="research"]]
30
- First, you research. No assumptions. No training data. Real documentation.
30
+ Research first. No assumptions. No training data. Real documentation from Context7 and web search.
31
31
 
32
32
  [HIGHLIGHT:[data-phase="interview"]]
33
- Then you interview. The AI asks YOU questions with structured options based on what it learned.
33
+ Interview second. The AI asks YOU questions with structured options based on what it actually found.
34
34
 
35
35
  [HIGHLIGHT:[data-phase="test"]]
36
- Next, you write tests first. Red, green, refactor. No implementation without a failing test.
37
-
38
- [HIGHLIGHT:[data-phase="code"]]
39
- Only then do you write code. Minimal. Just enough to pass the tests.
36
+ Test before code. Red, green, refactor. No implementation without a failing test.
40
37
 
41
38
  [HIGHLIGHT:[data-phase="docs"]]
42
- Finally, documentation. Every endpoint documented with real examples and schemas.
39
+ Document everything. Every endpoint documented with real examples and schemas.
43
40
 
44
41
  The philosophy is simple: Hustle together. Share resources. Build stronger.
45
42
 
@@ -48,72 +45,136 @@ The philosophy is simple: Hustle together. Share resources. Build stronger.
48
45
  Let's talk about the problem. What goes wrong when AI builds APIs without structure?
49
46
 
50
47
  [HIGHLIGHT:.gap-item:nth-child(1)]
51
- Gap one: AI doesn't use your exact words. You say Vercel AI Gateway but it searches for Vercel AI SDK. Wrong library. Wrong documentation. Wrong code.
48
+ Gap one: AI doesn't use your exact words. You say Brandfetch API but it searches for something else. Wrong library. Wrong documentation.
52
49
 
53
50
  [HIGHLIGHT:.gap-item:nth-child(2)]
54
- Gap two: AI claims files are updated without proof. It says I've updated the file but there's no git diff. No verification. You're trusting on faith.
51
+ Gap two: Generic questions. Without research first, the AI asks template questions instead of specific ones based on actual API capabilities.
55
52
 
56
53
  [HIGHLIGHT:.gap-item:nth-child(3)]
57
- Gap three: Skipped tests are accepted. The AI runs tests, some fail, and it moves on. We can fix those later. Those later fixes never come.
54
+ Gap three: Memory-based implementation. After research, the AI forgets what it learned and implements from training data instead.
58
55
 
59
56
  [HIGHLIGHT:.gap-item:nth-child(4)]
60
- Gap four: Tasks marked complete without verification. The AI says Done but the feature doesn't work. No one actually checked.
57
+ Gap four: No verification after tests pass. The AI writes code that passes tests but doesn't match the actual documentation.
61
58
 
62
59
  [HIGHLIGHT:.gap-item:nth-child(5)]
63
- Gap five: Environment variable mismatch. Tests pass locally but fail in production. The AI used different values than what's actually deployed.
60
+ Gap five: Context dilution. After many turns, the AI forgets project structure, documentation locations, and workflow requirements.
64
61
 
65
- These gaps compound. One wrong assumption leads to another. By the time you notice, you've built on a broken foundation.
62
+ These gaps compound. Version three solves all of them with loop-back architecture and continuous re-grounding.
66
63
 
67
64
  [SECTION:solution]
68
65
  [HIGHLIGHT:#solution h2]
69
66
  The solution is enforcement. Python hooks that intercept every tool call.
70
67
 
71
68
  [HIGHLIGHT:.hook-box:nth-child(1)]
72
- PreToolUse hooks run before Claude can write or edit any file. They check: Did you research first? Did you interview the user? Did you write a failing test?
69
+ PreToolUse hooks run before Claude writes any file. They inject interview decisions as reminders and block writes without research.
73
70
 
74
71
  [HIGHLIGHT:.hook-box:nth-child(2)]
75
- PostToolUse hooks run after research and interviews. They track what was learned. They log every query. They build a paper trail.
72
+ PostToolUse hooks track tool usage and trigger verification. After tests pass, they force Phase nine: re-read the documentation.
76
73
 
77
74
  [HIGHLIGHT:.hook-box:nth-child(3)]
78
- The Stop hook runs when Claude tries to mark a task complete. It checks: Are all phases done? Did tests pass? Is documentation updated? If not, blocked.
75
+ The Stop hook blocks completion if any phase is incomplete. No more premature "done" declarations.
76
+
77
+ [HIGHLIGHT:.hook-box:nth-child(4)]
78
+ SessionStart and periodic hooks re-inject context every seven turns to prevent dilution in long sessions.
79
79
 
80
80
  This isn't about limiting AI. It's about holding it to the same standards we hold ourselves.
81
81
 
82
- [SECTION:workflow]
83
- [HIGHLIGHT:#workflow h2]
84
- The workflow has ten phases. Let's walk through each one.
82
+ [SECTION:phases]
83
+ [HIGHLIGHT:#phases h2]
84
+ The workflow now has twelve phases. Two new ones in version three.
85
+
86
+ [HIGHLIGHT:[data-phase="0"]]
87
+ Phase zero: Disambiguation. When you say Vercel AI, do you mean the SDK or the Gateway? We clarify before researching.
88
+
89
+ [HIGHLIGHT:[data-phase="1"]]
90
+ Phase one: Scope. Confirm we understand what you want to build.
91
+
92
+ [HIGHLIGHT:[data-phase="2"]]
93
+ Phase two: Initial research. Context7 and web search. Find the real documentation.
94
+
95
+ [HIGHLIGHT:[data-phase="3"]]
96
+ Phase three: Interview. Questions generated FROM research findings. Not generic templates.
97
+
98
+ [HIGHLIGHT:[data-phase="4"]]
99
+ Phase four: Deep research. Based on your interview answers, we propose targeted follow-up searches. Adaptive, not shotgun.
100
+
101
+ [HIGHLIGHT:[data-phase="5"]]
102
+ Phase five: Schema. Define Zod schemas based on research plus interview decisions.
103
+
104
+ [HIGHLIGHT:[data-phase="6"]]
105
+ Phase six: Environment. Verify API keys exist before writing code.
106
+
107
+ [HIGHLIGHT:[data-phase="7"]]
108
+ Phase seven: TDD Red. Write failing tests. Define success before implementation.
109
+
110
+ [HIGHLIGHT:[data-phase="8"]]
111
+ Phase eight: TDD Green. Minimal code to pass tests. Interview decisions injected by hooks.
112
+
113
+ [HIGHLIGHT:[data-phase="9"]]
114
+ Phase nine: Verify. This is new. Re-read the original documentation and compare to implementation. Find gaps. Loop back if needed.
115
+
116
+ [HIGHLIGHT:[data-phase="10"]]
117
+ Phase ten: Refactor. Clean up code while tests stay green.
85
118
 
86
- [HIGHLIGHT:.workflow-phase:nth-child(1)]
87
- Phase one: Scope. Define what you're building. What's the endpoint? What does it do?
119
+ [HIGHLIGHT:[data-phase="11"]]
120
+ Phase eleven: Documentation. Update OpenAPI spec and test manifest.
88
121
 
89
- [HIGHLIGHT:.workflow-phase:nth-child(2)]
90
- Phase two: Initial research. Use Context7 or web search. Find the real documentation. No guessing.
122
+ [HIGHLIGHT:[data-phase="12"]]
123
+ Phase twelve: Complete. Final verification by the Stop hook.
91
124
 
92
- [HIGHLIGHT:.workflow-phase:nth-child(3)]
93
- Phase three: Interview. Ask the user questions with multiple choice options. What provider? What format? What error handling?
125
+ Every phase can loop back. If verification finds gaps, we return to Red and write tests for missing features.
94
126
 
95
- [HIGHLIGHT:.workflow-phase:nth-child(4)]
96
- Phase four: Deep research. Based on interview answers, research specific APIs and SDKs.
127
+ [SECTION:demo]
128
+ [HIGHLIGHT:#demo h2]
129
+ Let's watch a real example. Creating a Brandfetch API endpoint.
97
130
 
98
- [HIGHLIGHT:.workflow-phase:nth-child(5)]
99
- Phase five: Schema design. Define request and response schemas with Zod. Types before code.
131
+ [HIGHLIGHT:[data-step="0"]]
132
+ The user types /api-create brandfetch. The twelve-phase workflow begins.
100
133
 
101
- [HIGHLIGHT:.workflow-phase:nth-child(6)]
102
- Phase six: Environment setup. Check API keys. Verify environment variables. Test connectivity.
134
+ [HIGHLIGHT:[data-step="1"]]
135
+ Claude confirms scope. We're building an endpoint to fetch brand assets by domain.
103
136
 
104
- [HIGHLIGHT:.workflow-phase:nth-child(7)]
105
- Phase seven: Red. Write a failing test. Define what success looks like before writing any implementation.
137
+ [HIGHLIGHT:[data-step="2"]]
138
+ Initial research. Claude uses Context7 to find the SDK documentation. WebSearch finds rate limits and response formats.
106
139
 
107
- [HIGHLIGHT:.workflow-phase:nth-child(8)]
108
- Phase eight: Green. Write minimal code to pass the test. No extra features. No premature optimization.
140
+ [HIGHLIGHT:[data-step="3"]]
141
+ Interview begins. But notice: the questions are specific to what Claude actually found. What's the primary purpose? Options come from the documentation.
109
142
 
110
- [HIGHLIGHT:.workflow-phase:nth-child(9)]
111
- Phase nine: Refactor. Clean up the code. Extract utilities. Improve readability. Tests stay green.
143
+ [HIGHLIGHT:[data-step="4"]]
144
+ User selects: Full brand kit with logos, colors, and fonts.
112
145
 
113
- [HIGHLIGHT:.workflow-phase:nth-child(10)]
114
- Phase ten: Documentation. Update OpenAPI spec. Add to test manifest. Include real examples.
146
+ [HIGHLIGHT:[data-step="5"]]
147
+ More questions. How should API keys be handled? User selects server environment variables only.
115
148
 
116
- Only when all ten phases are complete can the workflow finish.
149
+ [HIGHLIGHT:[data-step="7"]]
150
+ Deep research. Based on your selections, Claude proposes specific searches for the full brand response format.
151
+
152
+ [HIGHLIGHT:[data-step="8"]]
153
+ Schema created. Zod types based on research plus interview decisions.
154
+
155
+ [HIGHLIGHT:[data-step="9"]]
156
+ Environment check. The hook verifies BRANDFETCH_API_KEY exists.
157
+
158
+ [HIGHLIGHT:[data-step="10"]]
159
+ TDD Red. Claude writes twelve failing test cases.
160
+
161
+ [HIGHLIGHT:[data-step="11"]]
162
+ TDD Green. Implementation begins. Watch the hook inject interview decisions.
163
+
164
+ [HIGHLIGHT:[data-step="12"]]
165
+ The hook reminds Claude: Remember user decisions. Purpose: full brand kit. API key handling: server only.
166
+
167
+ [HIGHLIGHT:[data-step="13"]]
168
+ Phase nine: Verify. Claude re-reads the Brandfetch documentation and compares to implementation. All features accounted for.
169
+
170
+ [HIGHLIGHT:[data-step="14"]]
171
+ Refactor. Code cleaned up. Tests still pass.
172
+
173
+ [HIGHLIGHT:[data-step="15"]]
174
+ Documentation updated. API test manifest and OpenAPI spec.
175
+
176
+ [HIGHLIGHT:[data-step="16"]]
177
+ Complete. All twelve phases verified. Four files created. Twelve tests passing.
117
178
 
118
179
  [SECTION:installation]
119
180
  [HIGHLIGHT:#installation h2]
@@ -122,33 +183,29 @@ Installation takes one command.
122
183
  [HIGHLIGHT:.install-command]
123
184
  Run npx @hustle-together/api-dev-tools. That's it.
124
185
 
125
- The CLI copies slash commands to your .claude/commands folder. Red, green, refactor, cycle, and the API development commands.
186
+ The CLI copies slash commands, Python hooks, and settings. It creates the research cache folder and updates your CLAUDE.md with workflow documentation.
126
187
 
127
- It copies Python hooks to .claude/hooks. These are the enforcers. The gatekeepers.
188
+ Version three adds automatic CLAUDE.md updates so Claude understands the workflow in your project.
128
189
 
129
- It merges settings into your settings.json. Hooks are registered. Permissions are configured.
130
-
131
- And it offers to add the Context7 MCP server for live documentation lookup.
132
-
133
- Your project is now enforced. Every API you build follows the workflow.
190
+ Your project is now enforced. Every API follows the twelve-phase workflow.
134
191
 
135
192
  [SECTION:credits]
136
193
  [HIGHLIGHT:#credits h2]
137
194
  This project builds on the work of others.
138
195
 
139
- The TDD workflow commands are based on @wbern/claude-instructions by William Bernmalm. The red, green, refactor pattern that makes AI development rigorous.
196
+ The TDD workflow is based on @wbern/claude-instructions by William Bernmalm.
140
197
 
141
- The interview methodology is inspired by Anthropic's Interviewer approach. Structured discovery before implementation.
198
+ Context7 provides live documentation lookup. Current docs, not stale training data.
142
199
 
143
- And Context7 provides live documentation lookup. Current docs, not stale training data.
200
+ And the interview methodology ensures questions come from research, not templates.
144
201
 
145
202
  Thank you to the Claude Code community. Together, we're making AI development better.
146
203
 
147
204
  [SECTION:outro]
148
205
  [HIGHLIGHT:#intro]
149
- Hustle API Dev Tools. Research first. Interview second. Test before code. Document everything.
206
+ Hustle API Dev Tools version three. Twelve phases. Loop-back architecture. Continuous verification.
150
207
 
151
- Build together. Share resources. Grow stronger.
208
+ Research first. Questions FROM findings. Verify after green. Document always.
152
209
 
153
210
  Install it now with npx @hustle-together/api-dev-tools.
154
211
  `.trim();
@@ -186,11 +243,18 @@ function parseMarkers(script) {
186
243
  }
187
244
 
188
245
  // Check for highlight marker
189
- const highlightMatch = line.match(/\[HIGHLIGHT:([^\]]+)\]/);
246
+ // Use a more robust regex that handles nested brackets like [data-phase="0"]
247
+ const highlightMatch = line.match(/\[HIGHLIGHT:(.+?)\]$/);
190
248
  if (highlightMatch) {
249
+ // Extract the selector - handle double brackets for attribute selectors
250
+ let selector = highlightMatch[1];
251
+ // If selector starts with [ but doesn't end with ], add the closing bracket
252
+ if (selector.startsWith('[') && !selector.endsWith(']')) {
253
+ selector = selector + ']';
254
+ }
191
255
  markers.push({
192
256
  type: 'highlight',
193
- selector: highlightMatch[1],
257
+ selector: selector,
194
258
  section: currentSection,
195
259
  charPosition
196
260
  });