Skip to content

feat(core): provider extends + 6 presets (Anthropic-compat + multi-account)#28

Open
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/provider-extends-presets
Open

feat(core): provider extends + 6 presets (Anthropic-compat + multi-account)#28
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/provider-extends-presets

Conversation

@Codename-11
Copy link
Copy Markdown
Owner

Summary

  • Adds extends?: \"claude\" | \"codex\" | \"gemini\" | \"opencode\" (and env, models, label, command) to ProviderConfig so a profile can inherit a builtin adapter and layer overrides on top.
  • Ships 6 presets via packages/core/src/provider-presets.ts (all extends: \"claude\" for this drop):
    • zai-glm - Z.AI Anthropic-compat endpoint + GLM-4.6
    • qwen-max - Alibaba DashScope Anthropic-compat + Qwen Max/Plus
    • deepseek-chat - DeepSeek Anthropic-compat + chat/reasoner
    • ollama-claude-local - local Ollama Anthropic-compat loopback
    • claude-work / claude-personal - split CLAUDE_CONFIG_DIR for multi-account
  • New resolveProvider(profile) helper in packages/core/src/config.ts performs idempotent shallow merge (profile wins over preset/adapter-defaults; env is shallow-merged key-by-key).
  • CLI: arc provider set --preset <id> applies a preset (explicit --model etc. still win); arc provider presets now prints both the new extends-style presets and the existing OpenAI-compat presets; arc provider show renders extends, models, and env.

No changes to daemon, client SDK, or the openai-compat auth path. New fields are all additive / optional.

Test plan

  • npx tsc --noEmit passes clean
  • npx vitest run tests/provider-extends.test.ts - 18 cases green (preset lookup, merge semantics, CLI write path)
  • ARC_DIR=$(mktemp -d) npx tsx src/index.ts provider presets - prints all 6 presets with extends, env, and models columns
  • arc create my-prof ... && arc provider set my-prof --preset zai-glm && arc provider show my-prof - roundtrips through ~/.arc/config.json and renders merged view

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

…ek, ollama, claude-work/personal)

Adds an `extends` field to `ProviderConfig` so a profile can inherit a
builtin adapter (claude/codex/gemini/opencode) and layer env/model/command
overrides on top. Ships 6 presets for the common adapter-extension cases:

- zai-glm: Z.AI Anthropic-compat endpoint + GLM-4.6
- qwen-max: Alibaba DashScope Anthropic-compat + Qwen Max/Plus
- deepseek-chat: DeepSeek Anthropic-compat + chat/reasoner models
- ollama-claude-local: local Ollama Anthropic-compat loopback
- claude-work / claude-personal: split CLAUDE_CONFIG_DIR for multi-account

Changes:
- packages/core/src/types.ts: ProviderConfig gains `extends`, `env`,
  `models`, `label`, `command` (all optional + additive). `baseUrl` is now
  optional since adapter-extending profiles don't need one. `ProviderExtends`
  type union covers the four builtin adapters.
- packages/core/src/provider-presets.ts: new — `providerPresets` map +
  `getProviderPreset` / `listProviderPresets` helpers.
- packages/core/src/config.ts: new `resolveProvider(profile)` — idempotent
  shallow merge of adapter defaults or preset base under the profile's own
  values; `env` is shallow-merged key-by-key (profile wins); `models`
  replaced only when profile sets it explicitly.
- packages/core/src/index.ts: re-exports `providerPresets`,
  `listProviderPresets`, `getProviderPreset`, `ProviderExtends`.
- packages/cli/src/commands/provider.ts: `arc provider set --preset <id>`
  copies the preset into the profile (explicit flags still win);
  `arc provider presets` now prints both the new extends-style presets
  and the legacy OpenAI-compat presets; `arc provider show` uses
  `resolveProvider` and renders `extends` + env when present.
- packages/cli/src/cli.ts: wire `--preset` flag on `arc provider set`.

Tests: new `tests/provider-extends.test.ts` (18 cases) covering preset
lookup, `resolveProvider` merge semantics (idempotent, scalar override,
env shallow-merge, unknown-extends fallback, no mutation), and the CLI
`--preset` write/validate path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant