@hustle-together/api-dev-tools 2.0.7 → 3.0.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 +283 -478
  2. package/bin/cli.js +55 -11
  3. package/commands/README.md +124 -251
  4. package/commands/api-create.md +318 -136
  5. package/commands/api-interview.md +252 -256
  6. package/commands/api-research.md +209 -234
  7. package/commands/api-verify.md +231 -0
  8. package/demo/audio/generate-all-narrations.js +516 -0
  9. package/demo/audio/generate-voice-previews.js +140 -0
  10. package/demo/audio/narration-adam-timing.json +3666 -0
  11. package/demo/audio/narration-adam.mp3 +0 -0
  12. package/demo/audio/narration-creature-timing.json +3666 -0
  13. package/demo/audio/narration-creature.mp3 +0 -0
  14. package/demo/audio/narration-gaming-timing.json +3666 -0
  15. package/demo/audio/narration-gaming.mp3 +0 -0
  16. package/demo/audio/narration-hope-timing.json +3666 -0
  17. package/demo/audio/narration-hope.mp3 +0 -0
  18. package/demo/audio/narration-mark-timing.json +3666 -0
  19. package/demo/audio/narration-mark.mp3 +0 -0
  20. package/demo/audio/previews/manifest.json +30 -0
  21. package/demo/audio/previews/preview-creature.mp3 +0 -0
  22. package/demo/audio/previews/preview-gaming.mp3 +0 -0
  23. package/demo/audio/previews/preview-hope.mp3 +0 -0
  24. package/demo/audio/previews/preview-mark.mp3 +0 -0
  25. package/demo/audio/voices-manifest.json +50 -0
  26. package/demo/hustle-together/blog/gemini-vs-claude-widgets.html +30 -28
  27. package/demo/hustle-together/blog/interview-driven-api-development.html +37 -23
  28. package/demo/hustle-together/index.html +142 -109
  29. package/demo/workflow-demo.html +1023 -558
  30. package/hooks/periodic-reground.py +154 -0
  31. package/hooks/session-startup.py +151 -0
  32. package/hooks/track-tool-use.py +109 -17
  33. package/hooks/verify-after-green.py +152 -0
  34. package/package.json +2 -2
  35. package/templates/api-dev-state.json +42 -7
  36. package/templates/research-index.json +6 -0
  37. package/templates/settings.json +23 -0
@@ -1,77 +1,154 @@
1
- # API Research - Documentation Discovery & Schema Extraction
1
+ # API Research - Adaptive Documentation Discovery v3.0
2
2
 
3
3
  **Usage:** `/api-research [library-or-service-name]`
4
4
 
5
- **Purpose:** Automatically research external APIs, SDKs, and libraries to discover ALL available parameters, options, and features.
5
+ **Purpose:** Research external APIs and SDKs using an adaptive, propose-approve flow (not shotgun searches).
6
6
 
7
- ## What This Command Does
7
+ ## Key Principle: Adaptive Research
8
8
 
9
- 1. **Searches for Official Documentation**
10
- - Official API docs
11
- - SDK/library documentation
12
- - GitHub repositories
13
- - npm package pages (if applicable)
9
+ **NOT shotgun research** - We don't blindly run 20 searches.
14
10
 
15
- 2. **Extracts Complete Schemas**
16
- - All request parameters (required + optional)
17
- - All response fields
18
- - Type definitions
19
- - Validation rules
20
- - Default values
11
+ **Adaptive flow:**
12
+ 1. Run 2-3 initial searches
13
+ 2. Summarize findings
14
+ 3. PROPOSE additional searches based on context
15
+ 4. User approves/modifies proposals
16
+ 5. Execute approved searches
17
+ 6. Repeat until complete
21
18
 
22
- 3. **Discovers Hidden Features**
23
- - Undocumented parameters (from source code)
24
- - Advanced configuration options
25
- - Beta/experimental features
26
- - Deprecated options to avoid
19
+ ## Research Phases
27
20
 
28
- 4. **Documents Integration Requirements**
29
- - Required environment variables
30
- - API key setup
31
- - Rate limits and quotas
32
- - Pricing/cost information
33
- - Version compatibility
21
+ ### Phase 1: Initial Discovery (Automatic)
34
22
 
35
- ## Research Process
23
+ Run 2-3 targeted searches:
24
+ ```
25
+ - Context7: "[library-name]" (if SDK/library)
26
+ - WebSearch: "[name] official documentation"
27
+ - WebSearch: "site:[domain] api reference" (if known domain)
28
+ ```
36
29
 
37
- ### Step 1: Find Official Sources
30
+ Present initial summary:
38
31
  ```
39
- - Web search for "[library-name] documentation"
40
- - Check npm registry for package info
41
- - Find GitHub repository
42
- - Look for TypeScript definitions
43
- - Search for community resources
32
+ ┌────────────────────────────────────────────────────────────┐
33
+ INITIAL RESEARCH: [library-name] │
34
+ │ │
35
+ Source │ Status │
36
+ ├─────────────────────┼────────────────────────────────────│
37
+ │ │ Official docs │ ✓ Found: [URL] │
38
+ │ │ API Reference │ ✓ REST v2 documented │
39
+ │ │ Auth method │ ✓ Bearer token / API key │
40
+ │ │ TypeScript types │ ? Not confirmed │
41
+ │ │ npm package │ ? Not searched │
42
+ │ │
43
+ │ Discovered parameters: 5 required, 12 optional │
44
+ │ │
45
+ │ Proceed to interview? [Y] │
46
+ │ Search more first? [n] → What? ____ │
47
+ └────────────────────────────────────────────────────────────┘
44
48
  ```
45
49
 
46
- ### Step 2: Deep Dive into Documentation
50
+ ### Phase 2: Deep Research (Proposed)
51
+
52
+ After interview, PROPOSE targeted searches based on user's selections:
53
+
47
54
  ```
48
- - Read API reference pages
49
- - Review SDK documentation
50
- - Check TypeScript type definitions (.d.ts files)
51
- - Look at example code
52
- - Find changelog for recent changes
55
+ ┌────────────────────────────────────────────────────────────┐
56
+ PROPOSED DEEP RESEARCH │
57
+ │ │
58
+ Based on interview answers, I recommend researching: │
59
+ │ │
60
+ │ [x] Error response format │
61
+ │ Reason: You selected "comprehensive error handling" │
62
+ │ │
63
+ │ [x] Rate limiting behavior │
64
+ │ Reason: You selected "short cache" / high frequency │
65
+ │ │
66
+ │ [ ] Webhook support │
67
+ │ Reason: You didn't select async/webhook features │
68
+ │ │
69
+ │ [x] SVG optimization options │
70
+ │ Reason: You selected SVG output format │
71
+ │ │
72
+ │ [x] Batch processing │
73
+ │ Reason: You mentioned "multiple domains at once" │
74
+ │ │
75
+ │ Approve these searches? [Y] │
76
+ │ Add more: ____ │
77
+ │ Skip and proceed: [n] │
78
+ └────────────────────────────────────────────────────────────┘
53
79
  ```
54
80
 
55
- ### Step 3: Source Code Analysis
81
+ ### Phase 3: Execute Approved Searches
82
+
83
+ Only run searches that were explicitly approved:
84
+ - Track which searches were proposed vs approved vs skipped
85
+ - Log everything to state file for transparency
86
+
87
+ ```json
88
+ {
89
+ "research_deep": {
90
+ "proposed_searches": [
91
+ "error response format",
92
+ "rate limiting behavior",
93
+ "webhook support",
94
+ "SVG optimization options",
95
+ "batch processing"
96
+ ],
97
+ "approved_searches": [
98
+ "error response format",
99
+ "rate limiting behavior",
100
+ "SVG optimization options",
101
+ "batch processing"
102
+ ],
103
+ "skipped_searches": [
104
+ "webhook support"
105
+ ]
106
+ }
107
+ }
56
108
  ```
57
- - Review actual implementation code
58
- - Check for undocumented parameters
59
- - Find default values in source
60
- - Identify validation logic
61
- - Discover error cases
109
+
110
+ ## Research Caching & Freshness
111
+
112
+ Research is cached in `.claude/research/[api-name]/`:
113
+
114
+ ```
115
+ .claude/research/
116
+ ├── brandfetch/
117
+ │ ├── 2025-12-08_initial.md # Timestamped snapshot
118
+ │ ├── 2025-12-08_deep.md # Deep research after interview
119
+ │ └── CURRENT.md # Latest (copy or symlink)
120
+ ├── vercel-ai-sdk/
121
+ │ ├── providers/ # Complex APIs get subfolders
122
+ │ │ ├── openai.md
123
+ │ │ ├── anthropic.md
124
+ │ │ └── groq.md
125
+ │ └── CURRENT.md
126
+ └── index.json # Catalog with freshness
127
+ ```
128
+
129
+ ### Freshness Tracking
130
+
131
+ ```json
132
+ {
133
+ "brandfetch": {
134
+ "last_updated": "2025-12-08",
135
+ "current_file": "brandfetch/CURRENT.md",
136
+ "days_old": 0,
137
+ "parameters_discovered": 7,
138
+ "source_urls": ["https://docs.brandfetch.com"]
139
+ }
140
+ }
62
141
  ```
63
142
 
64
- ### Step 4: Test & Verify
143
+ **Freshness Rule:** If research is >7 days old when referenced:
65
144
  ```
66
- - Check what parameters are actually used
67
- - Verify parameter names and types
68
- - Test edge cases
69
- - Document observed behavior
145
+ ⚠️ Research for "brandfetch" is 15 days old.
146
+ Re-research before using? [Y/n]
70
147
  ```
71
148
 
72
149
  ## Output Format
73
150
 
74
- Creates: `/src/v2/docs/research/[library-name].md`
151
+ Creates: `.claude/research/[library-name]/CURRENT.md`
75
152
 
76
153
  ```markdown
77
154
  # Research: [Library/Service Name]
@@ -79,6 +156,7 @@ Creates: `/src/v2/docs/research/[library-name].md`
79
156
  **Date:** [current-date]
80
157
  **Version:** [version-number]
81
158
  **Status:** Research Complete
159
+ **Freshness:** 0 days (valid for 7 days)
82
160
 
83
161
  ## 1. Official Documentation Links
84
162
  - Main docs: [URL]
@@ -112,155 +190,49 @@ Creates: `/src/v2/docs/research/[library-name].md`
112
190
  |-----------|------|---------|-------------|-------|
113
191
  | [name] | [type] | [default] | [desc] | [notes] |
114
192
 
115
- ### Zod Schema (Preliminary)
116
- ```typescript
117
- const RequestSchema = z.object({
118
- // Required
119
- requiredParam: z.string().min(1),
120
-
121
- // Optional with defaults
122
- optionalParam: z.string().default('default-value'),
123
-
124
- // Enums
125
- mode: z.enum(['option1', 'option2']).default('option1'),
126
-
127
- // Nested objects
128
- config: z.object({
129
- setting: z.boolean().default(true),
130
- }).optional(),
131
- });
132
- ```
193
+ ### Continuous Parameters (for test strategy)
194
+ | Parameter | Type | Range | Suggested Test Values |
195
+ |-----------|------|-------|----------------------|
196
+ | quality | number | 1-100 | 1, 50, 100 (boundary) |
197
+ | timeout | number | 1000-30000 | 1000, 15000, 30000 |
133
198
 
134
199
  ## 4. Complete Response Schema
135
200
  ### Success Response
136
- ```typescript
137
- interface SuccessResponse {
138
- [field]: [type]; // [description]
139
- }
140
- ```
201
+ [TypeScript interface]
141
202
 
142
203
  ### Error Response
143
- ```typescript
144
- interface ErrorResponse {
145
- error: string;
146
- code?: string;
147
- details?: unknown;
148
- }
149
- ```
150
-
151
- ### Zod Schema (Preliminary)
152
- ```typescript
153
- const ResponseSchema = z.object({
154
- // Response fields
155
- });
156
- ```
204
+ [TypeScript interface with error codes]
157
205
 
158
206
  ## 5. Features & Capabilities
159
- ### Core Features
160
- - [Feature 1]: [description]
161
- - [Feature 2]: [description]
162
-
163
- ### Advanced Features
164
- - [Advanced 1]: [description + how to enable]
165
- - [Advanced 2]: [description + how to enable]
207
+ ### Core Features (Discovered)
208
+ - [x] [Feature 1]: [description]
209
+ - [x] [Feature 2]: [description]
166
210
 
167
- ### Experimental/Beta Features
168
- - [Beta feature]: [description + stability notes]
211
+ ### Features NOT Implemented (Intentional)
212
+ - [ ] [Feature]: [reason for exclusion]
169
213
 
170
214
  ## 6. Limitations & Constraints
171
215
  - Rate limits: [details]
172
216
  - Size limits: [details]
173
217
  - Timeout: [details]
174
- - Quotas: [details]
175
- - Costs: [details]
176
-
177
- ## 7. Integration Notes
178
- ### Vercel AI SDK Integration
179
- [If using AI SDK, document integration patterns]
180
-
181
- ### Error Handling
182
- [Common errors and how to handle]
183
-
184
- ### Best Practices
185
- - [Practice 1]
186
- - [Practice 2]
187
-
188
- ## 8. Code Examples
189
- ### Basic Usage
190
- ```typescript
191
- [minimal example]
192
- ```
193
-
194
- ### Advanced Usage
195
- ```typescript
196
- [example with optional parameters]
197
- ```
198
-
199
- ### Error Handling
200
- ```typescript
201
- [example with try/catch]
202
- ```
203
218
 
204
- ## 9. Testing Considerations
205
- - [ ] Test basic success case
206
- - [ ] Test all optional parameters
207
- - [ ] Test validation failures
208
- - [ ] Test rate limiting
209
- - [ ] Test timeout scenarios
219
+ ## 7. Testing Considerations
220
+ - [ ] Test boundary values for continuous params
221
+ - [ ] Test all enum values
210
222
  - [ ] Test error responses
223
+ - [ ] Test rate limiting behavior
211
224
 
212
- ## 10. Version History & Changes
213
- [Notable changes in recent versions]
225
+ ## 8. Research Trail
226
+ ### Searches Performed
227
+ | Search | Tool | Found |
228
+ |--------|------|-------|
229
+ | "[name] documentation" | WebSearch | ✓ |
230
+ | "[name]" | Context7 | ✓ |
214
231
 
215
- ## 11. Related Resources
216
- - [Community examples]
217
- - [Blog posts]
218
- - [Stack Overflow discussions]
219
- - [Alternative libraries]
232
+ ### Proposed but Skipped
233
+ - "webhook support" - User declined, not needed
220
234
  ```
221
235
 
222
- ## Usage Examples
223
-
224
- ### Research an AI SDK
225
- ```bash
226
- /api-research vercel-ai-sdk-generateText
227
- ```
228
-
229
- ### Research an External API
230
- ```bash
231
- /api-research firecrawl-api
232
- ```
233
-
234
- ### Research a Library
235
- ```bash
236
- /api-research anthropic-sdk
237
- ```
238
-
239
- ## Research Workflow
240
-
241
- 1. **Execute command**: `/api-research [name]`
242
- 2. **I search and analyze**: Web search → Documentation → Source code
243
- 3. **Document everything**: Create comprehensive research doc
244
- 4. **Review together**: You verify accuracy and completeness
245
- 5. **Use in implementation**: Reference during TDD cycle
246
-
247
- ## Why This Matters
248
-
249
- Without thorough research:
250
- - ❌ Miss optional parameters that users need
251
- - ❌ Don't test edge cases properly
252
- - ❌ Implement wrong validation rules
253
- - ❌ Create brittle integrations
254
-
255
- With thorough research:
256
- - ✅ Know ALL available options
257
- - ✅ Test comprehensively
258
- - ✅ Proper validation
259
- - ✅ Robust implementation
260
- - ✅ Better documentation
261
-
262
- ---
263
-
264
236
  ## Research-First Schema Design (MANDATORY)
265
237
 
266
238
  ### The Anti-Pattern: Schema-First Development
@@ -271,86 +243,89 @@ With thorough research:
271
243
  - ❌ Say "I think it supports..." without verification
272
244
  - ❌ Build schemas from memory instead of documentation
273
245
 
274
- **Real Example of Failure:**
275
- - User asked: "What providers does Vercel AI Gateway support?"
276
- - AI answered from memory: "Groq not in gateway"
277
- - Reality: Groq has 4 models in the gateway (Llama variants)
278
- - Root cause: No research was done before answering
279
-
280
246
  ### The Correct Pattern: Research-First
281
247
 
282
248
  **ALWAYS DO THIS:**
283
249
 
284
- **Step 1: Research the Source of Truth**
285
- - Use Context7 (`mcp__context7__resolve-library-id` + `get-library-docs`) for SDK docs
286
- - Use WebSearch for official provider documentation
287
- - Query APIs directly when possible (don't assume)
288
- - Check GitHub repositories for current implementation
289
-
290
- **Step 2: Build Schema FROM Research**
291
- - Interface fields emerge from discovered capabilities
292
- - Every field has a source (docs, SDK types, API response)
293
- - Don't guess - verify each capability
294
- - Document where each field came from
250
+ 1. **Research the Source of Truth**
251
+ - Use Context7 for SDK docs
252
+ - Use WebSearch for official docs
253
+ - Check GitHub for current implementation
295
254
 
296
- **Step 3: Verify with Actual Calls**
297
- - Test capabilities before marking them supported
298
- - Investigate skipped tests - they're bugs, not features
299
- - No "should work" - prove it works
300
- - All tests must pass, not be skipped
255
+ 2. **Build Schema FROM Research**
256
+ - Interface fields emerge from discovered capabilities
257
+ - Every field has a source (docs, SDK types, API response)
258
+ - Don't guess - verify each capability
301
259
 
302
- ### Mandatory Checklist Before Answering ANY External API Question
260
+ 3. **Verify with Phase 9**
261
+ - After implementation, re-research
262
+ - Compare docs to implementation
263
+ - Fix gaps or document intentional omissions
303
264
 
304
- Before responding to questions about APIs, SDKs, or external services:
265
+ ## Research Query Tracking
305
266
 
306
- ```
307
- [ ] Did I use Context7 to get current documentation?
308
- [ ] Did I use WebSearch for official docs?
309
- [ ] Did I verify the information is current (not training data)?
310
- [ ] Am I stating facts from research, not memory?
311
- [ ] Have I cited my sources?
312
- ```
313
-
314
- ### Research Query Tracking
315
-
316
- All research is now tracked in `.claude/api-dev-state.json`:
267
+ All research is tracked in `.claude/api-dev-state.json`:
317
268
 
318
269
  ```json
319
270
  {
320
271
  "research_queries": [
321
272
  {
322
- "timestamp": "2025-12-07T...",
273
+ "timestamp": "2025-12-08T...",
323
274
  "tool": "WebSearch",
324
- "query": "Vercel AI Gateway Groq providers",
325
- "terms": ["vercel", "gateway", "groq", "providers"]
275
+ "query": "Brandfetch API documentation",
276
+ "terms": ["brandfetch", "api", "documentation"]
326
277
  },
327
278
  {
328
- "timestamp": "2025-12-07T...",
279
+ "timestamp": "2025-12-08T...",
329
280
  "tool": "mcp__context7__get-library-docs",
330
- "library": "@ai-sdk/gateway",
331
- "terms": ["@ai-sdk/gateway"]
281
+ "library": "brandfetch",
282
+ "terms": ["brandfetch"]
283
+ }
284
+ ],
285
+ "phases": {
286
+ "research_initial": {
287
+ "status": "complete",
288
+ "sources": [...],
289
+ "summary_approved": true
290
+ },
291
+ "research_deep": {
292
+ "status": "complete",
293
+ "proposed_searches": [...],
294
+ "approved_searches": [...],
295
+ "skipped_searches": [...]
332
296
  }
333
- ]
297
+ }
334
298
  }
335
299
  ```
336
300
 
337
- This allows verification that specific topics were actually researched before answering.
301
+ ## Usage Examples
302
+
303
+ ### Research with full flow
304
+ ```bash
305
+ /api-research brandfetch
306
+ # → Initial search (2-3 queries)
307
+ # → Present summary, ask to proceed
308
+ # → Interview happens (separate phase)
309
+ # → Propose deep research based on interview
310
+ # → User approves/modifies
311
+ # → Execute approved searches
312
+ # → Cache results with freshness tracking
313
+ ```
338
314
 
339
315
  <claude-commands-template>
340
316
  ## Research Guidelines
341
317
 
342
- 1. **Read actual code** - TypeScript definitions reveal truth
343
- 2. **Test assumptions** - Verify parameters actually work
344
- 3. **Document sources** - Track ALL links for future reference
345
- 4. **Check versions** - Note version-specific features
346
- 5. **Find examples** - Real code > documentation
347
- 6. **Look for gotchas** - Common mistakes, limitations, bugs
318
+ 1. **Start minimal** - 2-3 searches, not 20
319
+ 2. **Propose before executing** - User controls depth
320
+ 3. **Track everything** - State file logs all searches
321
+ 4. **Cache with freshness** - 7-day validity
322
+ 5. **Cite sources** - Every claim has a URL
323
+ 6. **Distinguish proposed vs approved** - Transparency
348
324
 
349
325
  ## Integration with API Development
350
326
 
351
- After research:
352
- - Use in `/api-interview` to ask informed questions
353
- - Reference in `/api-create` for schema creation
354
- - Base tests on discovered parameters
355
- - Update if API changes
327
+ - Phase 2 of `/api-create` uses this for initial research
328
+ - Phase 4 uses adaptive proposal flow
329
+ - Phase 9 (Verify) triggers re-research
330
+ - Freshness check prevents stale data
356
331
  </claude-commands-template>