Implement Phase 2: Core API Integration

- Add Claude API client with Anthropic SDK
  - Retry logic with exponential backoff (3 attempts)
  - Handle auth errors, rate limits, and server errors
  - Architecture classification with JSON parsing
  - Research query generation from architecture
- Add Perplexity API client with native fetch
  - Retry logic with exponential backoff
  - Parse responses with sources and citations
  - Execute multiple research queries
- Add prompt templates for architecture classification
- Add default query generation as fallback
- Add ArchitectureGenerator combining Claude + Perplexity
- Add 44 new tests (80 total, all passing)

All Phase 2 acceptance criteria met:
- Claude client sends prompts and retries on failure
- Perplexity client searches and parses with sources
- Architecture classification returns valid JSON
- Research queries generated (4-6 per architecture)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-01-10 12:17:42 +00:00
parent 606f27d6bb
commit ae0165a802
11 changed files with 1643 additions and 28 deletions

View File

@@ -1,37 +1,40 @@
---
active: true
iteration: 1
max_iterations: 30
completion_promise: "PHASE_1_COMPLETE"
started_at: "2026-01-10T12:00:45Z"
max_iterations: 40
completion_promise: "PHASE_2_COMPLETE"
started_at: "2026-01-10T12:10:57Z"
---
Execute Phase 1 - Foundation from PROMPT.md.
Execute Phase 2 - Core API Integration from PROMPT.md.
You are building the Ralph PRD Generator CLI tool.
Phase 1 is complete. Now implement Phase 2.
Read PROMPT.md for full specification.
Read prd.json for feature tracking.
Read CLAUDE.md for project configuration.
Read PROMPT.md for API specifications.
Read prd.json for Phase 2 features.
Phase 1 tasks:
1. Set up TypeScript project with all dependencies
2. Configure tsup, vitest, eslint
3. Implement CLI framework with Commander.js
4. Implement config management for API key storage
5. Create basic project structure
6. Write tests for config and CLI
Phase 2 tasks:
1. Claude API client with Anthropic SDK
2. Perplexity API client with fetch
3. Architecture classification prompt and parser
4. Research query generation
5. Tests for all API clients
API Integration notes:
- Use environment variables for API keys during testing
- Implement retry logic with 3 attempts and exponential backoff
- Handle rate limits gracefully
- Parse JSON responses safely
For each feature:
1. Write tests first
1. Write tests first using mocked API calls
2. Implement the feature
3. Run: npm run build && npm run test && npm run lint
4. If all pass, update prd.json by setting passes to true for completed features
5. Commit with descriptive message
6. Append progress to progress.txt
3. Verify: npm run build && npm run test && npm run lint
4. Update prd.json when feature passes
5. Commit and log progress
When ALL Phase 1 features in prd.json have passes set to true:
Output <promise>PHASE_1_COMPLETE</promise>
When ALL Phase 2 features pass:
Output <promise>PHASE_2_COMPLETE</promise>
If blocked after 10 attempts on same issue:
Document in progress.txt and output <promise>PHASE_1_BLOCKED</promise>
If blocked:
Output <promise>PHASE_2_BLOCKED</promise>