- Tighten all sections (279 -> 159 lines) without dropping rules. - Reorganize: git rules moved next to issues/PRs. - Defer contributor gate details to CONTRIBUTING.md. - Replace stale npx tsx test command with node (strip-only mode); add ./test.sh + e2e warning. - Releasing: explicit WebAuthn briefing step, no bash timeout, stop on partial publish failure. - Move LLM provider checklist to .pi/skills/add-llm-provider.md.
3.0 KiB
3.0 KiB
name, description
| name | description |
|---|---|
| add-llm-provider | Checklist for adding a new LLM provider to packages/ai. Covers core types, provider implementation, lazy registration, model generation, the full test matrix, coding-agent wiring, and docs. |
Adding a New LLM Provider (packages/ai)
A new provider touches multiple files. Work through these steps in order.
1. Core Types (packages/ai/src/types.ts)
- Add API identifier to
Apitype union (e.g."bedrock-converse-stream"). - Create options interface extending
StreamOptions. - Add mapping to
ApiOptionsMap. - Add provider name to
KnownProvidertype union.
2. Provider Implementation (packages/ai/src/providers/)
Create a provider file exporting:
stream<Provider>()returningAssistantMessageEventStream.streamSimple<Provider>()forSimpleStreamOptionsmapping.- Provider-specific options interface.
- Message/tool conversion functions.
- Response parsing that emits standardized events (
text,tool_call,thinking,usage,stop).
3. Provider Exports and Lazy Registration
- Add a package subpath export in
packages/ai/package.jsonpointing at./dist/providers/<provider>.js. - Add
export typere-exports inpackages/ai/src/index.tsfor provider option types that should remain available from the root entry. - Register the provider in
packages/ai/src/providers/register-builtins.tsvia lazy loader wrappers; do not statically import provider implementation modules there. - Add credential detection in
packages/ai/src/env-api-keys.ts.
4. Model Generation (packages/ai/scripts/generate-models.ts)
- Add logic to fetch/parse models from the provider source.
- Map to the standardized
Modelinterface.
5. Tests (packages/ai/test/)
- Always add the provider to
stream.test.tswith at least one representative model, even if it reuses an existing API impl such asopenai-completions. - Add the provider to the broader matrix where applicable:
tokens.test.ts,abort.test.ts,empty.test.ts,context-overflow.test.ts,unicode-surrogate.test.ts,tool-call-without-result.test.ts,image-tool-result.test.ts,total-tokens.test.ts,cross-provider-handoff.test.ts. - For
cross-provider-handoff.test.ts, add at least one provider/model pair. If the provider exposes multiple model families (e.g. GPT and Claude), add at least one pair per family. - For non-standard auth, create a utility (e.g.
bedrock-utils.ts) with credential detection.
6. Coding Agent (packages/coding-agent/)
src/core/model-resolver.ts: add default model ID todefaultModelPerProvider.src/core/provider-display-names.ts: add API-key login display name so/loginand related UI show the provider for built-in API-key auth.src/cli/args.ts: add env var documentation.README.md: add provider setup instructions.docs/providers.md: add setup instructions, env var, andauth.jsonkey.
7. Documentation
packages/ai/README.md: add to providers table, document options/auth, add env vars.packages/ai/CHANGELOG.md: add entry under## [Unreleased].