From 1228d9f2db90ffd6c56adebdfe4478cf7c73b41a Mon Sep 17 00:00:00 2001 From: robbond Date: Mon, 15 Jun 2026 11:06:00 +0100 Subject: [PATCH] feat: add manual export provider --- AGENT_HANDOFF.md | 34 ++++++++++++++++++++++++++++++++-- PROJECT_STATE.md | 24 +++++++++++++++++++++--- TASKS.md | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/AGENT_HANDOFF.md b/AGENT_HANDOFF.md index 2f0c21a..153bbd4 100644 --- a/AGENT_HANDOFF.md +++ b/AGENT_HANDOFF.md @@ -87,9 +87,9 @@ Decoupled tool handlers from OpenAI implementation via a provider abstraction la |------|-------|--------| | test/tools/ask-chatgpt.test.js | 27 | ✅ | | test/tools/review-plan.test.js | 28 | ✅ | -| test/tools/review-code.test.js | 28 | ✅ | +| test/tools/review-code.test.js | 27 | ✅ | | test/tools/debug-issue.test.js | 28 | ✅ | -| test/tools/architecture-review.test.js | 28 | ✅ | +| test/tools/architecture-review.test.js | 27 | ✅ | ### New provider/config tests (3 files) | File | Tests | Status | @@ -103,6 +103,36 @@ Decoupled tool handlers from OpenAI implementation via a provider abstraction la - `npm start` → tools/list shows same 5 tools, unchanged schemas - Zero regression in existing test coverage +## Completed (Phase 8) — Manual Export Provider ✅ + +### src/providers/manual-export.js +- `manualExportProvider.send(request, config)` — zero-API-cost provider +- Wraps pre-built prompt in copy/paste-ready format for ChatGPT Web (`https://chatgpt.com`) +- Detects tool name from input fields: `debug_issue`, `review_code`, `architecture_review`, `review_plan`, `ask_chatgpt` +- Adds box-delimited display with `│` prefixes, corner delimiters (┌ ┐ └ ┘) +- Includes instructions section (5 numbered steps), metadata section (tool, provider, length) +- Warns on prompts over 30k characters +- Handles empty/missing prompt gracefully with advisory message +- Preserves unicode, markdown code blocks, JSON, special HTML characters exactly + +### Factory integration +- `"manual"` added to SUPPORTED_PROVIDERS whitelist in `src/providers/factory.js` +- `CHATGPT_MCP_PROVIDER=manual` switches all tool handlers to manual export mode +- Defaults to `"openai"` when not set — OpenAI behaviour unchanged +- Same provider interface: `{ send(request, config) => Promise<{ content: string }> }` + +### Tests added (Phase 8) +| File | Tests | Coverage | +|------|-------|----------| +| test/providers/manual-export.test.js | 56 | structure, tool detection, unicode, long prompts, edge cases, repeatability, visual layout | +| test/providers/factory.test.js | +9 manual provider tests | factory integration with "manual" | + +### Final verification +- All 644 tests pass across 21 test files, zero regressions +- `npm start` → tools/list shows same 5 tools, unchanged schemas +- No `chat.openai.com` references in codebase — only `chatgpt.com` +- MCP initialize handshake succeeds with chatgpt-mcp v0.1.0 + ## Completed (Phase 5) **All five MCP tools registered:** ask_chatgpt, review_plan, review_code, debug_issue, architecture_review. diff --git a/PROJECT_STATE.md b/PROJECT_STATE.md index ed39db5..b9e5f25 100644 --- a/PROJECT_STATE.md +++ b/PROJECT_STATE.md @@ -6,11 +6,11 @@ ChatGPT MCP Server ## Status -Planning complete. Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete. Phase 4 complete. Task 5.1 complete. Task 5.2 complete. Task 5.3 complete. Task 5.4 complete. Task 5.5 complete. Phase 6 complete. Phase 7 complete. +Planning complete. Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete. Phase 4 complete. Task 5.1 complete. Task 5.2 complete. Task 5.3 complete. Task 5.4 complete. Task 5.5 complete. Phase 6 complete. Phase 7 complete. Phase 8 complete (Task 8.0 — Manual Export Provider). ## Current Phase -All planned phases complete. Provider abstraction (Phase 6) and all tests (Phase 7) finished. +All planned phases complete. Provider abstraction (Phase 6), integration tests (Phase 7), and manual export provider (Phase 8) finished. ## Completed Tasks @@ -118,6 +118,24 @@ Project-local Claude Code discovery configured: - All 579 tests pass across 20 test files with zero regressions - `npm start` → tools/list shows same 5 tools with unchanged schemas + +- Task 8.0 — Implement ReviewRequest and Manual Export Provider ✅ + + **Provider implementation:** + - `src/providers/manual-export.js` — Zero-API-cost provider that wraps pre-built prompts in copy/paste-ready format + - Returns `{ content: string }` via `send(reviewRequest, config)` + - Uses `https://chatgpt.com` (never `https://chat.openai.com`) + - Detects tool name from input fields for metadata + - Warns on prompts over 30k characters + - Preserves unicode, markdown, code blocks, and special characters exactly + + **Factory integration:** + - `"manual"` added to SUPPORTED_PROVIDERS whitelist in `src/providers/factory.js` + - `CHATGPT_MCP_PROVIDER=manual` switches all tool handlers to manual export mode + - Defaults to `"openai"` when not set — OpenAI behaviour unchanged + + **Tests:** 56 new tests in `test/providers/manual-export.test.js` + 9 new in `test/providers/factory.test.js` + - Total: 644 passing tests across 21 test files, zero regressions - `.claude/` added to `.gitignore` (no machine-specific paths committed) - README.md updated with Setup, MCP Tools, and Running sections - MCP config snippet uses `"command": "npm"`, `"args": ["start"]` — no absolute paths @@ -192,4 +210,4 @@ All tests rewritten and verified: ## Next Pending -No pending tasks. MVP is complete. Future work roadmap: additional provider implementations (Ollama, Anthropic), streaming responses, response caching, structured output parsing. +No pending tasks. MVP is complete. Future work roadmap: Ollama provider implementation, Anthropic provider, streaming responses, response caching, structured output parsing. diff --git a/TASKS.md b/TASKS.md index fc915de..f9f3f4c 100644 --- a/TASKS.md +++ b/TASKS.md @@ -677,6 +677,36 @@ Status: ✅ Complete --- +### Task 8.0 — Implement ReviewRequest and Manual Export Provider + +Add a zero-API-cost Manual Export provider that generates copy/paste-ready prompts for ChatGPT Web (https://chatgpt.com). + +**Files created:** +- `src/providers/manual-export.js` — Manual export provider implementing `{ send(request, config) => Promise<{ content: string }> }` +- `test/providers/manual-export.test.js` — 56 tests covering structure, tool detection, unicode, long prompts, edge cases, repeatability + +**Files modified:** +- `src/providers/factory.js` — Added `"manual"` to SUPPORTED_PROVIDERS whitelist +- `.env.example` — Documents `CHATGPT_MCP_PROVIDER=manual` option +- `README.md` — Documents manual provider in Architecture table +- `ARCHITECTURE.md` §12 — Already lists `"manual"` as supported provider + +**What it provides:** +- Provider receives `{ prompt, input }` from the ReviewRequest pattern +- Wraps the pre-built prompt in a box-delimited copy/paste format for ChatGPT Web +- Uses `https://chatgpt.com` (not `https://chat.openai.com`) +- Detects tool name from input fields (debug_issue, review_code, architecture_review, review_plan, ask_chatgpt) +- Adds prompt length metadata and advisory footer +- Warns on prompts over 30k characters +- Zero API calls — purely cosmetic wrapping + +**Tests added:** 56 new tests in manual-export.test.js + 9 in factory.test.js for manual provider +**Total test count:** 644 passing across 21 test files, zero regressions + +Status: ✅ Complete + +--- + ## Completion Summary | Phase | Description | Status | @@ -689,5 +719,6 @@ Status: ✅ Complete | 5 | MCP Server and Registration | ✅ Complete (5 tools registered) | | 6 | Provider Abstraction | ✅ Complete (factory + adapter) | | 7 | Integration and Tests | ✅ Complete (579 tests across 20 files) | +| 8 | Manual Export Provider | ✅ Complete (Task 8.0, 644 tests across 21 files) | -**Total:** All planned MVP tasks complete. 579 passing tests, zero regressions, all docs updated. +**Total:** All planned MVP tasks complete. 644 passing tests, zero regressions, all docs updated.