feat: add review_code tool handler

This commit is contained in:
2026-06-12 09:20:09 +01:00
parent 4c3776e2ce
commit 8e95ea0e5f
5 changed files with 506 additions and 9 deletions
+17 -3
View File
@@ -7,7 +7,7 @@ ChatGPT MCP Server
## Status
Planning complete.
Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete. Task 4.1 complete. Task 4.2 complete.
Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete. Task 4.1 complete. Task 4.2 complete. Task 4.3 complete.
## Current Phase
@@ -32,6 +32,8 @@ Phase 4 - Tool Handlers
- Task 3.6 — debug_issue prompt builder (`src/prompts/debug-issue.js`, `test/prompts/debug-issue.test.js`) ✅
- Task 3.7 — architecture_review prompt builder (`src/prompts/architecture-review.js`, `test/prompts/architecture-review.test.js`) ✅
- Task 4.1 — ask_chatgpt MCP tool handler (`src/tools/ask-chatgpt.js`, `test/tools/ask-chatgpt.test.js`) ✅
- Task 4.2 — review_plan MCP tool handler (`src/tools/review-plan.js`, `test/tools/review-plan.test.js`) ✅
- Task 4.3 — review_code MCP tool handler (`src/tools/review-code.js`, `test/tools/review-code.test.js`) ✅
## Phase 3 Completion Summary
@@ -81,9 +83,21 @@ Implemented `src/tools/review-plan.js` with dependency-injected handler and 28 o
- Every path returns structured `{ ok, answer|error, warnings }` — never throws to caller
- 28 tests mirroring 4.1 structure with one additional test verifying buildReviewPlanPrompt is called with budget.input
**Task 4.3 — review_code MCP Tool Handler ✅**
Implemented `src/tools/review-code.js` with dependency-injected handler and 28 orchestration-only tests in `test/tools/review-code.test.js`.
**Key design decisions:**
- Execution order: validate → loadConfig → checkContextBudget → buildReviewCodePrompt → createOpenAIClient → sendOpenAIResponse
- All external deps injected (loadConfig, createOpenAIClient, sendOpenAIResponse); internal utilities imported directly
- OpenAI errors pass through `String(err)` unchanged — no wrapping or reformatting
- Budget check short-circuits before prompt building or client creation
- Every path returns structured `{ ok, answer|error, warnings }` — never throws to caller
- 28 tests mirroring 4.1/4.2 structure with one test verifying buildReviewCodePrompt is called with budget.input
**Next pending task:**
- Task 4.3review_code tool handler (`src/tools/review-code.js`, `test/tools/review-code.test.js`)
- Task 4.4debug_issue tool handler (`src/tools/debug-issue.js`, `test/tools/debug-issue.test.js`)
**Not done yet (Phase 4):**
- No MCP tool registration
- Other tool handlers (review_code, debug_issue, architecture_review)
- Other tool handlers (debug_issue, architecture_review)