feat(core): provider extends + 6 presets (Anthropic-compat + multi-account)#28
Open
Codename-11 wants to merge 1 commit into
Open
feat(core): provider extends + 6 presets (Anthropic-compat + multi-account)#28Codename-11 wants to merge 1 commit into
extends + 6 presets (Anthropic-compat + multi-account)#28Codename-11 wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
extends?: \"claude\" | \"codex\" | \"gemini\" | \"opencode\"(andenv,models,label,command) toProviderConfigso a profile can inherit a builtin adapter and layer overrides on top.packages/core/src/provider-presets.ts(allextends: \"claude\"for this drop):CLAUDE_CONFIG_DIRfor multi-accountresolveProvider(profile)helper inpackages/core/src/config.tsperforms idempotent shallow merge (profile wins over preset/adapter-defaults;envis shallow-merged key-by-key).arc provider set --preset <id>applies a preset (explicit--modeletc. still win);arc provider presetsnow prints both the new extends-style presets and the existing OpenAI-compat presets;arc provider showrendersextends,models, andenv.No changes to daemon, client SDK, or the
openai-compatauth path. New fields are all additive / optional.Test plan
npx tsc --noEmitpasses cleannpx 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 withextends,env, andmodelscolumnsarc create my-prof ... && arc provider set my-prof --preset zai-glm && arc provider show my-prof- roundtrips through~/.arc/config.jsonand renders merged viewCo-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com