Add Cohere provider (native streaming + tool use)
Summary
Add a first-class Cohere provider with native streaming and tool calling. pi_agent_rust ships this as one of its 10 native providers; jcode does not currently support Cohere at all.
Reference: pi_agent_rust src/providers/cohere.rs and the provider list.
Why
Current state in jcode
src/provider/ lists Anthropic, OpenAI, Gemini, Bedrock, etc. No cohere.rs.
--provider CLI doc string in src/cli/args.rs does not list cohere.
- No
COHERE_API_KEY detection in src/cli/login/ flows.
Implementation checklist
1. Provider implementation
2. Models
3. Auth + login
4. CLI surface
5. Error handling
6. Telemetry
Testing
Unit
Live test (gated)
Manual
Acceptance criteria
jcode --provider cohere -m command-r-plus run "..." works.
- Streaming, tool-call, and reasoning blocks all render in the TUI.
jcode auth-test --provider cohere returns a clean OK.
cargo test cohere passes; cargo clippy --all-targets -- -D warnings clean.
References
Implementation notes addendum (Devin gap-analysis pass, 2026-05-21)
Verified jcode code paths
- Provider scaffolding mirrors existing native providers in
src/provider/ (e.g. src/provider/anthropic.rs, src/provider/openai.rs, src/provider/claude.rs, src/provider/gemini.rs).
- Provider catalog:
src/provider_catalog.rs + crates/jcode-provider-metadata/src/catalog.rs.
- Streaming SSE parser:
src/transport/ (reuse, do not write a new one).
- Per-provider tests pattern:
tests/integration/<provider>.rs (offline fixtures via recorded JSON streams).
Cohere API specifics
- API: Cohere v2
chat/completions (https://api.cohere.com/v2/chat).
- Auth:
Authorization: Bearer <api-key> from env CO_API_KEY (also accept COHERE_API_KEY for compat).
- Streaming: Server-Sent Events; event types include
message-start, content-delta, tool-call-start, tool-call-delta, tool-call-end, message-end. Map to jcode's internal stream events.
- Tool use: Cohere has native
tools array in the request; pass jcode's tool schemas through unchanged.
- Models to register at launch:
command-r-plus, command-r, command-r-08-2024, command-a-03-2025 (most recent at issue-time). Source via https://api.cohere.com/v1/models.
Acceptance criteria
jcode --provider cohere --model command-r-plus "..." works end-to-end.
- Streaming output renders incrementally.
- Tool calls work (test with
read).
jcode --list-providers includes Cohere.
- Token/cost accounting populated.
- Tests cover one streamed response and one tool-call round-trip via offline fixtures.
Cross-references
Reference
Add Cohere provider (native streaming + tool use)
Summary
Add a first-class Cohere provider with native streaming and tool calling.
pi_agent_rustships this as one of its 10 native providers; jcode does not currently support Cohere at all.Reference:
pi_agent_rustsrc/providers/cohere.rsand the provider list.Why
Current state in jcode
src/provider/lists Anthropic, OpenAI, Gemini, Bedrock, etc. Nocohere.rs.--providerCLI doc string insrc/cli/args.rsdoes not listcohere.COHERE_API_KEYdetection insrc/cli/login/flows.Implementation checklist
1. Provider implementation
src/provider/cohere.rsimplementing theProvidertrait:Bearer $COHERE_API_KEY.https://api.cohere.com/v2/chat(or v2/chat-stream).event: ...+data: ...).ToolCall { name, args }to Cohere'sparametersblock; map results back fromtool_results.tool_planif present as a thinking block.src/provider/mod.rsregistry and theProviderChoiceenum.2. Models
command-r-08-2024,command-r-plus-08-2024,command-a-03-2025. Context windows: 128k for r/r+ and 256k for a. Pull these intosrc/provider_catalog.rs.jcode model list --provider cohere.3. Auth + login
COHERE_API_KEYenv var.jcode login --provider cohereflow: prompt for API key (with--api-key/--api-key-stdin), store via the standard auth.json mechanism.Coheretoauth-testcovered providers.4. CLI surface
--providerdoc string insrc/cli/args.rsto includecohere.README.mdprovider list.5. Error handling
auth-test), 429 → rate-limit (apply existing retry/backoff), 400 withinvalid_argument→ log + redacted payload preview.6. Telemetry
Testing
Unit
Live test (gated)
live_tests::test_coherebehindJCODE_LIVE=1. Asserts a known short response with one tool call.Manual
jcode login --provider cohere, thenjcode -m command-r-plus run "List files in src/"and verify a working tool call.Acceptance criteria
jcode --provider cohere -m command-r-plus run "..."works.jcode auth-test --provider coherereturns a clean OK.cargo test coherepasses;cargo clippy --all-targets -- -D warningsclean.References
pi_agent_rust: Cohere provider source.Implementation notes addendum (Devin gap-analysis pass, 2026-05-21)
Verified jcode code paths
src/provider/(e.g.src/provider/anthropic.rs,src/provider/openai.rs,src/provider/claude.rs,src/provider/gemini.rs).src/provider_catalog.rs+crates/jcode-provider-metadata/src/catalog.rs.src/transport/(reuse, do not write a new one).tests/integration/<provider>.rs(offline fixtures via recorded JSON streams).Cohere API specifics
chat/completions(https://api.cohere.com/v2/chat).Authorization: Bearer <api-key>from envCO_API_KEY(also acceptCOHERE_API_KEYfor compat).message-start,content-delta,tool-call-start,tool-call-delta,tool-call-end,message-end. Map to jcode's internal stream events.toolsarray in the request; pass jcode's tool schemas through unchanged.command-r-plus,command-r,command-r-08-2024,command-a-03-2025(most recent at issue-time). Source viahttps://api.cohere.com/v1/models.Acceptance criteria
jcode --provider cohere --model command-r-plus "..."works end-to-end.read).jcode --list-providersincludes Cohere.Cross-references
Reference