Context
PR #53 brought overall src/ coverage from 37% to 71%. The remaining low-coverage modules are the LLM adapter chat() and stream() implementations:
| Module |
Current Coverage |
src/llm/anthropic.ts |
6% |
src/llm/openai.ts |
9% |
src/llm/gemini.ts |
6% |
src/llm/copilot.ts |
0% |
What needs to be done
Mock the underlying SDK HTTP clients to test the adapter chat() and stream() methods without making real API calls:
- Anthropic adapter — mock
Anthropic.messages.create() and messages.stream(), verify toAnthropicMessages() / fromAnthropicContentBlock() round-trip
- OpenAI adapter — mock
OpenAI.chat.completions.create() for both stream: false and stream: true paths
- Gemini adapter — mock
GoogleGenerativeAI client
- Copilot adapter — mock OAuth device flow + chat completions
Approach
Use vi.mock() or vi.spyOn() to intercept SDK client methods. Each test should verify:
- Correct wire-format conversion (framework types → SDK types → framework types)
- Token usage extraction
- Tool call handling (including streaming tool call assembly)
- Error propagation (API errors, malformed responses)
- Abort signal forwarding
Priority
P2 — the conversion helpers (openai-common.ts) are already at 100% coverage. The untested code is mostly SDK call wrappers. Most likely to break on SDK version bumps, not on framework changes.
Context
PR #53 brought overall
src/coverage from 37% to 71%. The remaining low-coverage modules are the LLM adapterchat()andstream()implementations:src/llm/anthropic.tssrc/llm/openai.tssrc/llm/gemini.tssrc/llm/copilot.tsWhat needs to be done
Mock the underlying SDK HTTP clients to test the adapter
chat()andstream()methods without making real API calls:Anthropic.messages.create()andmessages.stream(), verifytoAnthropicMessages()/fromAnthropicContentBlock()round-tripOpenAI.chat.completions.create()for bothstream: falseandstream: truepathsGoogleGenerativeAIclientApproach
Use
vi.mock()orvi.spyOn()to intercept SDK client methods. Each test should verify:Priority
P2 — the conversion helpers (
openai-common.ts) are already at 100% coverage. The untested code is mostly SDK call wrappers. Most likely to break on SDK version bumps, not on framework changes.