claude-profile: remove provider-yaml system, embed model config in profiles

Provider selection phase removed; Anthropic driver→model_id is now
hardcoded in the script and non-Anthropic profiles supply provider.env
(MODEL_ID, ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY_FILE).

Test suite baseline changes 58 → 41 assertions: the 17 dropped
assertions covered the removed provider-yaml selection phase, not
retained behaviour.

Includes refactor-derived memory: decisions (provider architecture,
driver enforcement via --model), bash gotchas (read -rp under set -e,
never eval user config), process lessons.
This commit is contained in:
Paul O'Reilly
2026-06-12 21:26:07 +12:00
parent c0a2110ee6
commit 9e13b7f096
16 changed files with 271 additions and 398 deletions

View File

@@ -2,42 +2,45 @@
## Status
**Provider support added. 58 dryrun assertions passing. MiniMax token provisioned. NOT yet exercised in a real `claude` launch.**
**Provider selection removed. Model config embedded in profiles via `provider.env`. 41 dryrun assertions passing.**
## What's done
| Component | State |
|---|---|
| Profile + mode + provider picker (phases 1-3) | Done, 58 dryrun assertions passing |
| Profile + mode picker (phases 1-2) | Done, 41 dryrun assertions passing |
| 5 mode files with `escalates_to` frontmatter | Done |
| 5 provider files (4 Anthropic + minimax-sonnet) | Done (`data/claude-profile/providers/`) |
| `active-mode.env` written on every launch | Done (includes `CLAUDE_PROVIDER`) |
| MiniMax token decrypted + stored | Done (`~/.claude-secrets/minimax-auth-token`, 600 perms) |
| `provider.env` for non-Anthropic profiles | Done (`~/.claude-oreillyit-minimax/provider.env`) |
| Driver→model_id hardcoded for Anthropic | Done (haiku/sonnet/opus/opus-1m) |
| `active-mode.env` written on every launch | Done (no longer includes `CLAUDE_PROVIDER` or `CLAUDE_TIME_HORIZON`) |
| statusline.sh — `[Sonnet→Opus] deep · topic` format | Done (reads `CLAUDE_CONFIG_DIR/active-mode.env`) |
| Root CLAUDE.md — auto-select project from cwd or `CLAUDE_PROJECT` | Done |
| Preset support (`presets.yaml`) | Done (example at `data/claude-profile/presets.yaml.example`) |
| `COLORTERM=truecolor` exported before launch | Done |
## Architecture change: providers → profiles
Previously, provider selection was a separate interactive phase (profile → mode → provider). Now:
- **Anthropic profiles** need no extra config — the driver (from mode frontmatter) maps directly to an Anthropic model ID
- **Non-Anthropic profiles** put a `provider.env` file in their profile directory with `MODEL_ID`, `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY_FILE`, and any extra env vars
- **Different providers = different profiles** (e.g., `oreillyit-anthropic` vs `oreillyit-minimax`)
## Next session — recommended order
1. **Install the symlink** (if not already done):
```bash
ln -sf "$HOME/dev/claude/small-scripts/scripts/claude-profile" "$HOME/sbin/claude-profile"
ln -sf "$HOME/dev/claude/projects/small-scripts/scripts/claude-profile" "$HOME/sbin/claude-profile"
```
2. **Real-launch test — Anthropic first:** `claude-profile oreillyit --mode chat` (press Enter to accept default anthropic-haiku). Verify:
2. **Real-launch test — Anthropic:** `claude-profile oreillyit-anthropic --mode chat`. Verify:
- Mode body appears in system prompt
- Status bar shows `[Haiku] chat` format
- `~/.claude-oreillyit/active-mode.env` has `CLAUDE_PROVIDER=anthropic-haiku`
3. **MiniMax launch test:** `claude-profile oreillyit --mode quick --provider minimax-sonnet`. Verify:
- `~/.claude-oreillyit-anthropic/active-mode.env` has no `CLAUDE_PROVIDER` or `CLAUDE_TIME_HORIZON`
3. **MiniMax launch test:** `claude-profile oreillyit-minimax --mode quick`. Verify:
- Claude starts and is responsive
- `ANTHROPIC_BASE_URL` is set to MiniMax endpoint (check via a "what model are you?" prompt)
4. **If anything's off**, `tests/test-claude-profile.sh` is the fast feedback loop
## Adding new providers
Drop a new `data/claude-profile/providers/<name>.yaml` file. For third-party providers:
- Decrypt credentials and store the raw token in `~/.claude-secrets/<provider>-auth-token`
- Provider YAML needs: `base_url`, `api_key_env`, `api_key_file`, and any `extra_env` flags the provider requires
## Remaining follow-ups (from FUTURE.md)
1. **`bg-model-call` wrapper** — `deep` and `hybrid` modes reference it but it doesn't exist yet. Own spec + script entry.
@@ -50,3 +53,4 @@ Drop a new `data/claude-profile/providers/<name>.yaml` file. For third-party pro
- **`CLAUDE_CONFIG_DIR` must be exported** by claude-profile before `exec claude`. The statusline hook inherits it from the claude process environment.
- **`read -rp` under `set -e` exits silently if stdin is not a TTY.** The picker guards all interactive reads with `[[ -t 0 ]]`. See `memory/gotchas-bash.md`.
- **MiniMax token is in `~/.claude-secrets/`** — gitignored, plaintext, 600 perms. The SOPS-encrypted version in agent-runtimes is for container agents only.
- **`provider.env` uses `ANTHROPIC_API_KEY_FILE`** — the script reads the file and exports `ANTHROPIC_API_KEY`. The env var name is always `ANTHROPIC_API_KEY` (not configurable per-provider).