Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .ai-run/guides/integration/external-integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| OpenCode | Open-source AI assistant | SSO/API Key | Via CodeMie proxy |
| MCP Servers | Remote MCP tool servers | OAuth 2.0 (auto) | `codemie-mcp-proxy` |
| Enterprise SSO | Corporate auth | SAML/OAuth | `SSO_BASE_URL` |
| Anthropic Subscription | Claude via user's Anthropic account | None (subscription) | `anthropic-subscription` provider |

---

Expand Down Expand Up @@ -277,6 +278,43 @@ Claude Code injects `!bash` commands as synthetic `type:'user'` messages. The pr

---

## Anthropic Subscription Provider

The `anthropic-subscription` provider runs Claude Code against the user's own Anthropic subscription rather than a CodeMie-managed API key. Its model-selection pipeline differs from all other providers.

### Model Is Not Stored in the Profile

Setup omits the `model` field from the profile entirely when none is selected; an empty string is never persisted. The model is chosen per-session inside Claude Code (via `/model`).

| Concern | Behavior |
|---|---|
| Profile `model` field | Absent — conditionally omitted at setup, never stored as empty string |
| Launch banner model line | `CODEMIE_CLI_MODEL` value if set; else `'chosen per session by Claude Code / your Anthropic subscription'` |
| `models list` command | Prints an informational message; exits 0 — no CodeMie model catalog exists for this provider |

`file:src/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.ts:129`
`file:src/agents/core/launch-model-display.ts:13`
`file:src/cli/commands/models.ts:82`

### CODEMIE_CLI_MODEL Side-Channel

An explicit `-m/--model` flag writes `CODEMIE_CLI_MODEL` via `applyCliModelEnv()`, clearing any pre-existing value first (stale-shell guard). The `enrichArgs` hook for the `claude` agent reads this var and prepends `--model <value>` to the claude binary argv; a dedup guard prevents double injection when `--model` or `--model=` is already present. Without an explicit `-m`, the var is unset and Claude Code picks the model independently.

| Step | File | Line |
|---|---|---|
| Set by AgentCLI | `src/agents/core/AgentCLI.ts` | 210 |
| Implementation | `src/agents/core/cli-model-env.ts` | 1 |
| Consumed in enrichArgs | `src/providers/plugins/anthropic-subscription/anthropic-subscription.template.ts` | 103 |

This is the only provider that carries the CLI model via a side-channel env var. All other providers use the `CODEMIE_MODEL → ANTHROPIC_MODEL` pipeline or equivalent.

### Version-Prompt Policy

When installed Claude Code is newer than the CodeMie-verified pin, the upgrade/downgrade prompt defaults to `'continue'` for `anthropic-subscription` (keep the newer binary — model availability depends on it) and `'install'` for all other providers (downgrade to tested pin). The minimum-version hard block is unaffected.

`file:src/agents/core/version-prompt-policy.ts:1`
`file:src/agents/core/BaseAgentAdapter.ts:472`

## skills.sh Wrapper (`codemie skills`)

Catalog-agnostic thin wrapper around the upstream `skills` npm CLI. Discovery, ranking, and source classification are out of scope for this CLI.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"task": "Add Anthropic Subscription model access support (EPMCDME-14341): stale-env clearing, per-session model display in launch banner, subscription-aware version-prompt defaults, buildConfig model-omit fix, moonshot guard, and three pure-helper extractions across agent core, CLI commands, and provider plugin layers.",
"generated": "2026-08-31T00:00:00Z",
"dimensions": {
"component_scope": {
"score": 4,
"label": "L",
"affected": "AgentCLI, BaseAgentAdapter, cli-model-env helper, launch-model-display helper, version-prompt-policy helper, models CLI command, setup CLI command, setup-ui utilities, AnthropicSubscriptionTemplate, AnthropicSubscriptionSetupSteps",
"layers": "Agent-Tool, Workflow, CLI, Service, Provider-Plugin"
},
"requirements_clarity": {
"score": 2,
"label": "S",
"status": "Clear",
"gaps": "Three code-review fix-ups (stale-env clear, buildConfig omit, moonshot guard) emerged during review rather than upfront; all were low-risk additive changes fully resolved before merge — no unresolved gaps remain"
},
"technical_risk": {
"score": 4,
"label": "L",
"risk_factors": "Authentication flow touched in AnthropicSubscriptionSetupSteps (Claude browser login orchestration, CodeMie SSO auth); template.ts beforeRun removes ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY and runs the Claude extension installer; moonshot guard deletes ANTHROPIC_DEFAULT_*_MODEL and CLAUDE_CODE_SUBAGENT_MODEL to prevent cross-provider contamination",
"mitigation": "All auth changes are additive conditional branches bounded to the anthropic-subscription provider code path; pure-helper extractions (cli-model-env.ts, launch-model-display.ts, version-prompt-policy.ts) are trivially reversible; existing AgentCLI and BaseAgentAdapter patterns reused throughout with no structural changes to those base classes"
},
"file_change_estimate": {
"score": 6,
"label": "XXL",
"modified_files": 7,
"modified_file_list": [
"src/agents/core/AgentCLI.ts",
"src/agents/core/BaseAgentAdapter.ts",
"src/cli/commands/models.ts",
"src/cli/commands/setup.ts",
"src/providers/integration/setup-ui.ts",
"src/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.ts",
"src/providers/plugins/anthropic-subscription/anthropic-subscription.template.ts"
],
"new_files": 11,
"new_file_list": [
"src/agents/core/cli-model-env.ts",
"src/agents/core/launch-model-display.ts",
"src/agents/core/version-prompt-policy.ts",
"8 test files (names not provided in changed_files input; ~3 new for the new helpers + ~5 updated for modified sources)"
],
"affected_dirs": [
"src/agents/core",
"src/cli/commands",
"src/providers/integration",
"src/providers/plugins/anthropic-subscription"
]
},
"dependencies": {
"score": 1,
"label": "XS",
"new_packages": [],
"version_changes": []
},
"affected_layers": {
"score": 4,
"label": "L",
"layers_changed": ["CLI", "Service", "Agent-Tool", "Provider-Plugin"],
"schema_migration": false,
"cross_system": false
}
},
"total": 21,
"size": "L",
"band_range": "21-26",
"files_changed": 18,
"routing": "brainstorming",
"key_reasoning": [
{
"dimension": "file_change_estimate",
"reason": "diffstat N=18 maps to 16+ = XXL: 7 modified source files (AgentCLI.ts, BaseAgentAdapter.ts, models.ts, setup.ts, setup-ui.ts, anthropic-subscription.setup-steps.ts, anthropic-subscription.template.ts) + 3 new pure-helper modules (cli-model-env.ts, launch-model-display.ts, version-prompt-policy.ts) + 8 test files"
},
{
"dimension": "component_scope",
"reason": "Bumped M (3) to L (4) by 'affects multiple agents' red flag: applyCliModelEnv() inserted into AgentCLI.ts runs on every agent launch regardless of provider; four distinct component clusters touched: agent core base classes (AgentCLI + BaseAgentAdapter), three new pure-helper modules, two CLI commands, and the full anthropic-subscription plugin (template + setup-steps)"
},
{
"dimension": "technical_risk",
"reason": "Bumped M (3) to L (4) by 'affects authentication or authorization' red flag: AnthropicSubscriptionSetupSteps orchestrates Claude browser login and CodeMie SSO auth; template.ts beforeRun hook removes ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY before the Claude process starts and invokes the extension installer; moonshot guard targets ANTHROPIC_DEFAULT_*_MODEL and CLAUDE_CODE_SUBAGENT_MODEL to block cross-provider contamination"
},
{
"dimension": "affected_layers",
"reason": "Four distinct architectural layers: CLI (models.ts + setup.ts commands), Service (setup-ui.ts provider-integration utilities), Agent-Tool/Workflow (AgentCLI + BaseAgentAdapter base classes + three helpers), Provider-Plugin (anthropic-subscription template and setup-steps) — exceeds the M threshold of 2-3 layers; no persistence/migration layer involved"
}
],
"red_flags_applied": [
"Component Scope bumped from M (3) to L (4): applyCliModelEnv() call added to AgentCLI.ts handleRun() runs on every agent launch path — 'affects multiple workflows or agents' red flag.",
"Technical Risk bumped from M (3) to L (4): AnthropicSubscriptionSetupSteps orchestrates Claude browser login and CodeMie SSO authentication; template.ts beforeRun removes Anthropic auth env vars from the spawned process environment — 'affects authentication or authorization' red flag."
],
"split_recommendation": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"schema": 1,
"gate": "code-review.check",
"decision": "approve",
"confidence": "high",
"risk_flags": [],
"rationale": "All three prior blocking findings resolved against the fix-up diff (6 files, +91/-6). CR-001: applyCliModelEnv deletes CODEMIE_CLI_MODEL before the conditional set, closing the stale-shell-value leak, with a test covering the shell-preset case. CR-002: buildConfig omits the model field for an empty model and a buildConfig('')->undefined test was added. CR-003: moonshot regression guard added and passing. No new high-risk issue introduced by the fix-up (env helper is a pure delete-then-set; buildConfig spread is clean; remainder is test-only), so no confirmation pass was required. Full unit suite 3969/3969, lint and typecheck clean.",
"business_review": [
{"criterion": "subscription --model reaches claude; no --model -> default (CS1+CS2)", "status": "pass", "notes": "CR-001 fix removes the stale-value leak; no --model now reliably yields Claude Code default."},
{"criterion": "setup not asked for a model; per-session summary (CS6)", "status": "pass", "notes": "CR-002 fix: buildConfig stores no model field."},
{"criterion": "D4 tests included", "status": "pass", "notes": "Test-plan items 2 and 5 now implemented."}
],
"standards_review": [
{"standard": "git-workflow (Conventional Commits + ticket ref)", "status": "pass", "notes": "Fix-up: fix(agents), fix(providers), test(providers), all with Refs: EPMCDME-14341."},
{"standard": "code-quality", "status": "pass"},
{"standard": "security", "status": "pass"}
],
"finding_status": [
{"id": "CR-001", "status": "resolved", "notes": "applyCliModelEnv clears before set; tested including shell-preset case."},
{"id": "CR-002", "status": "resolved", "notes": "buildConfig omits model field when empty; buildConfig('')->undefined tested."},
{"id": "CR-003", "status": "resolved", "notes": "moonshot regression guard added and passing."}
],
"findings": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"schema": 1,
"gate": "code-review.final",
"decision": "request-changes",
"confidence": "high",
"risk_flags": [],
"rationale": "Three lenses ran (blind, edge-case, acceptance); the edge-case lens (repo access) cleared all functional concerns except one confirmed by two lenses. One real correctness bug (CR-001: stale shell CODEMIE_CLI_MODEL leaks into a no---model subscription launch, violating the D3 contract and the 'no --model -> Claude Code default' AC) and two approved-plan test gaps (CR-003 moonshot regression guard; CR-002 buildConfig-empty test + field-omit cleanliness). Dismissed 3 non-issues: --model= dedup form and dual-provider-source (edge-case verified safe for real invocation paths), and an untyped-params false positive from an abbreviated blind-lens diff. Standards clean: 5 Conventional commits with Refs: EPMCDME-14341, code-quality and security pass.",
"business_review": [
{"criterion": "subscription --model reaches claude; no --model -> default (CS1+CS2)", "status": "partial", "notes": "Set path correct; missing clear-before-set lets a shell-preset value leak (CR-001)."},
{"criterion": "model stated to user at launch (CS4)", "status": "pass"},
{"criterion": "setup not asked for a model; per-session summary (CS6)", "status": "partial", "notes": "Prompt skipped and summary wired; buildConfig still returns model:'' and test-plan item 5 unmet (CR-002)."},
{"criterion": "models list explains source, no unsupported error (CS5)", "status": "pass"},
{"criterion": "version: newer->continue default; older note; below-min unchanged; subscription-scoped (CS3/D2)", "status": "pass"},
{"criterion": "D1 no entitlement logic; refusal relayed", "status": "pass"},
{"criterion": "D4 tests included", "status": "partial", "notes": "Items 2 (moonshot guard) and 5 (buildConfig-empty) missing (CR-002, CR-003)."}
],
"standards_review": [
{"standard": "git-workflow (Conventional Commits + ticket ref)", "status": "pass", "notes": "5 feat(scope) commits, subjects <100, Refs: EPMCDME-14341 on all."},
{"standard": "code-quality", "status": "pass", "notes": "ESM .js imports, explicit return types on new exports, no any, why-only comments."},
{"standard": "security", "status": "pass", "notes": "No secrets/injection/unsafe process handling; CODEMIE_CLI_MODEL is a model-id string."}
],
"findings": [
{
"id": "CR-001",
"severity": "major",
"triage": "patch",
"file": "src/agents/core/AgentCLI.ts",
"line": 205,
"problem": "CODEMIE_CLI_MODEL is set only when options.model is truthy but never cleared first. A value already present in process.env (e.g. shell-exported) survives into anthropic-subscription enrichArgs on a launch with no --model.",
"impact": "Violates the D3 env-var contract ('only when the user passed -m/--model this launch') and the AC 'no --model -> Claude Code default': a stale value is silently injected as --model while the banner still shows the per-session phrase.",
"recommendation": "Add `delete process.env.CODEMIE_CLI_MODEL;` immediately before the conditional set so each launch starts clean."
},
{
"id": "CR-002",
"severity": "major",
"triage": "patch",
"file": "src/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.ts",
"line": 126,
"problem": "buildConfig still returns model: selectedModel, so the subscription profile persists model:'' rather than omitting the field; spec CS6 says 'stores no model' and test-plan item 5 (buildConfig stores no model) is unimplemented. Functionally inert at runtime (edge-case lens verified) but leaves an empty-string in persisted config.",
"impact": "Spec-fidelity gap and an empty-string-in-config value that can surface on a get->update round-trip; the new behavior is untested.",
"recommendation": "Omit the field for an empty model: `...(selectedModel ? { model: selectedModel } : {})`; add a test asserting buildConfig(creds, '').model is undefined."
},
{
"id": "CR-003",
"severity": "major",
"triage": "patch",
"file": "src/providers/plugins/moonshot-subscription/__tests__/moonshot-subscription.template.test.ts",
"line": 1,
"problem": "Spec test-plan item 2 (moonshot-subscription enrichArgs unaffected by CODEMIE_CLI_MODEL) has no test. Scope was verified manually (0 moonshot files changed) but the regression guard the plan committed to is absent.",
"impact": "No automated guard that the new CODEMIE_CLI_MODEL mechanism stays anthropic-subscription-only; a future shared-base edit could regress moonshot silently.",
"recommendation": "Add a test setting CODEMIE_CLI_MODEL and asserting the moonshot template does not inject --model (unchanged args)."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"schema": 1,
"task": "Fix anthropic-subscription model passthrough, setup messaging, models-list message, and version-prompt default in the @codemieai/code CLI.",
"generated": "2026-08-31T00:00:00Z",
"dimensions": {
"component_scope": { "score": 4, "label": "L" },
"requirements_clarity": { "score": 2, "label": "S" },
"technical_risk": { "score": 3, "label": "M" },
"file_change_estimate": { "score": 3, "label": "M" },
"dependencies": { "score": 1, "label": "XS" },
"affected_layers": { "score": 3, "label": "M" }
},
"total": 16,
"size": "M",
"routing": "brainstorming",
"key_reasoning": [
{
"dimension": "component_scope",
"reason": "Four change sites across three layers: Provider template (anthropic-subscription.template.ts — enrichArgs injection of --model and conditional exportEnvVars blank), Core shared adapter (BaseAgentAdapter.ts — version-prompt default flip from 'install' to 'continue'), and CLI Workflow (models.ts subscription message, setup.ts/setup-ui.ts setup messaging). BaseAgentAdapter is a core shared utility consumed by every agent plugin and provider; the single-line default flip has blast radius across all providers and agents. Red flag applied: touches core shared utility — bumped from M to L."
}
],
"red_flags_applied": [
"Component Scope bumped from M (3) to L (4): BaseAgentAdapter.ts is a core shared utility used by all agent plugins and providers; version-prompt default flip affects every provider's version-check code path."
],
"split_recommendation": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"ts":"2026-08-31T00:00:00Z","gate_id":"spec.approved","mode":"hitl","verdict":{"decision":"approve","rationale":"User approved spec with 6 change sites, CODEMIE_CLI_MODEL passthrough, subscription-scoped version flip, tests included","follow_ups":[],"confidence":"high","source":"hitl"},"escalated":false,"prior_context":{"question":"spec.approved","phase":3,"risk_flags":[],"artifact_refs":["spec.md"]}}
{"ts":"2026-08-31T00:00:00Z","gate_id":"plan.approved","mode":"hitl","verdict":{"decision":"approve","rationale":"User approved 6-task TDD plan; every impl task test-first with exact anchors and pure-helper extractions","follow_ups":[],"confidence":"high","source":"hitl"},"escalated":false,"prior_context":{"question":"plan.approved","phase":4,"risk_flags":[],"artifact_refs":["plan.md"]}}
{"ts":"2026-08-31T00:00:00Z","gate_id":"code-review.final","mode":"hitl","verdict":{"decision":"request-changes","rationale":"User chose to fix all 3 findings then re-check","follow_ups":["CR-001","CR-002","CR-003"],"confidence":"high","source":"hitl"},"escalated":false,"prior_context":{"question":"code-review.final","phase":6,"risk_flags":[],"artifact_refs":["code-review.diff","code-review-final.json"]},"prior_orchestrator_verdict":{"decision":"request-changes","confidence":"high","findings":["CR-001","CR-002","CR-003"]}}
{"ts":"2026-08-31T00:00:00Z","gate_id":"code-review.check","mode":"hitl","verdict":{"decision":"approve","rationale":"All 3 findings resolved; no new issues; suite 3969/3969","follow_ups":[],"confidence":"high","source":"hitl"},"escalated":false,"prior_context":{"question":"code-review.check","phase":6,"risk_flags":[],"artifact_refs":["code-review-check.diff","code-review-check.json"]},"prior_orchestrator_verdict":{"decision":"approve","confidence":"high","finding_status":"CR-001 resolved, CR-002 resolved, CR-003 resolved"}}
Loading
Loading