AGENT SKILL
kit-provider-adapters
Add or change a model provider (Anthropic, OpenAI, xAI, OpenAI-compatible/local) or an external agent driver (Claude Code, Codex, Grok, ACP) in Kit — streaming, tool calls, errors, cost and tests. Use for any work in crates/kit-providers or crates/kit-agents.
- License 许可
- MIT
- 所属仓库
- Zwin-ux/kit
- 最近更新
- 2026-11-02
- Stars
- ★ 0
- Forks
- 2
01 前言 Front Matter
- name
- kit-provider-adapters
- description
- Add or change a model provider (Anthropic, OpenAI, xAI, OpenAI-compatible/local) or an external agent driver (Claude Code, Codex, Grok, ACP) in Kit — streaming, tool calls, errors, cost and tests. Use for any work in crates/kit-providers or crates/kit-agents.
03 SKILL.md 正文
Kit provider adapters and harness drivers
The design is docs/PRD.md §6. Two kinds of adapter, two crates:
| Kind | Crate | Interface | Example |
|---|---|---|---|
| Model provider (Kit's own agent) | crates/kit-providers |
Provider trait: models(), stream(Request) -> EventStream |
anthropic.rs, openai_compatible.rs |
| External agent driver (harness) | crates/kit-agents |
Agent trait: probe(), spawn() → AgentHandle; events become KitEvent |
claude.rs, codex.rs, grok.rs |
Rules
- Check the real docs, never guess a flag. Record the doc URL and the date in a comment above the
invocation, and the CLI version you tested against. Upstream flags change:
codex --full-autoandcodex mcp-serverwere removed in 2026. - One file per provider or driver, ≤ 600 lines. Shared SSE parsing and retry live in one module.
- Prompts never go on argv (Windows
cmdinjection and length limits). Use stdin, a prompt file the tool's published docs list, or the protocol (ACP). - No shells. Spawn the real executable; on Windows resolve
.cmdshims to their entry point as the existing adapters do. - Auth stays where it is. Providers: env var → OS keychain (
kit:<provider>) →key_command. Drivers: the tool's own login, checked with its status command (claude auth status,codex login status). Never read another tool's credential file. Never log a key; keys never enter a tool's environment. - Errors map to the closed set:
Auth,RateLimited{retry_after},ContextOverflow,Transient,BadRequest,Fatal. The user sees the class in words and the fix. - Cost: use the provider's reported cost when there is one (xAI ticks, Claude
total_cost_usd, Grok's reported cost); otherwise compute from usage ×prices.tomland mark it≈. Never sum Claudetotal_cost_usdacross resumes (it already includes earlier spend). - Context window comes from the provider, never a default guess.
- Published docs beat repo docs. A flag found only in a tool's repo or user guide, not on its published CLI reference, is unverified: don't depend on it until a live check against the released CLI passes.
Tests (required)
- Recorded streams: capture real responses once (success, tool call, rate limit, context overflow,
auth failure), strip keys and personal data, and commit them under the crate's fixtures folder
(
crates/kit-agents/src/fixtures/for drivers). CI replays them; CI never calls a real API. - Live tests go behind the
livecargo feature and are run by hand with a budget. - Drivers: replay a transcript through the parser, and use a fake binary (see
crates/kit-cli/tests/land_cli.rs) for exit codes, kill, resume and a version whose stream changed shape, which must fail loudly with the version named. - Run
cargo test -p kitctl-providers -p kitctl-agentsand the 3-OS CI before calling it done.
04 同仓库更多 Skills
concepts
暂无简介
★ 0
write-tests
Add focused tests for important project behavior.
★ 0
workspace-setup
Set up monorepo and multi-package workspaces for agents and humans.
★ 0
ship-checklist
Run a practical pre-ship checklist for an app release.
★ 0
project-setup
Set up a clean project baseline for agents and humans.
★ 0
pr-ready
Prepare a clear pull request summary, test plan, and risk notes.
★ 0