Skip to content

Commit 9033477

Browse files
jimgqyuclaude
andcommitted
feat: TUI /model launches coder --model, README CLAUDE.md → CODER.md
- session.ts: /model (no args) now uses withInkSuspended to launch `coder --model` external process, reusing the same radio-button selector from the CLI instead of the Ink-based ModelPicker overlay - README.md: update Configuration section to reflect new ModelEntry format (model: string[], price, provider/model-name), replace all CLAUDE.md references with CODER.md - docs/configuration.md: CLAUDE.md → CODER.md with compatibility note Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d483362 commit 9033477

3 files changed

Lines changed: 104 additions & 39 deletions

File tree

README.md

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
# Prerequisites: Node.js >= 18.0.0 (>= 22.0.0 recommended)
2525

2626
# Clone the repo
27-
git clone https://github.com/AgenticMatrix/Coder-Agent.git
28-
cd Coder-Agent
27+
git clone https://github.com/AgenticMatrix/CoderAgent.git
28+
cd CoderAgent
2929

3030
# One-click install (builds, links `coder` command globally, sets up config)
31-
./install.sh --local
31+
./install.sh
3232

33-
# Set your API key (DeepSeek by default)
34-
export DEEPSEEK_API_KEY="sk-your-key-here"
33+
# Set your model and API key (DeepSeek by default)
34+
coder --model
3535

3636
# Start coding
3737
coder
@@ -226,58 +226,79 @@ skills:
226226

227227
## Configuration
228228

229-
### Configuration
230-
231-
Coder Agent uses `~/.coder/settings.json` for persistent config, with environment variable overrides.
229+
Coder Agent uses `~/.coder/settings.json` for persistent config. Settings are auto-populated at runtime — no manual environment variable exports needed.
232230

233231
**Priority order:**
234-
1. CLI flags (`--model`, `--provider`)
235-
2. Environment variables (`CODER_BASE_URL`, `CODER_MODEL`, `CODER_AUTH_TOKEN`)
236-
3. `~/.coder/settings.json``model_list[]` + `env.*`
232+
1. CLI flags (`--model provider/model-name`)
233+
2. `~/.coder/settings.json``default_model` + `model_list[]` + `env.*`
234+
235+
**Quick setup:**
237236

238237
```bash
239-
# Set auth token (required)
240-
export CODER_AUTH_TOKEN="sk-your-key-here"
238+
# Interactive model selection (provider → model → auth token)
239+
coder --model
241240

242-
# Optional: override model and endpoint
243-
export CODER_MODEL="deepseek-chat"
244-
export CODER_BASE_URL="https://api.deepseek.com/anthropic"
241+
# Direct model set
242+
coder --model deepseek/deepseek-v4-pro
245243
```
246244

245+
Environment variables are auto-populated from settings.json at runtime. No need to manually export `CODER_AUTH_TOKEN`, `CODER_MODEL`, or `CODER_BASE_URL`.
246+
247247
### Model Switching
248248

249249
Switch models interactively:
250250
```bash
251251
coder --model # Interactive selection from model_list
252-
coder --model gpt-4o # Switch to a specific model by name
253252
```
254253

255254
### ~/.coder/settings.json
256255

257256
```json
258257
{
259258
"theme": "dark",
259+
"default_model": "deepseek/deepseek-v4-pro",
260260
"model_list": [
261261
{
262-
"name": "deepseek-v4",
263-
"model": "deepseek-chat",
262+
"model": ["deepseek-v4-pro", "deepseek-v4-flash", "deepseek-chat", "deepseek-reasoner"],
263+
"base_url": "https://api.deepseek.com/anthropic",
264+
"auth_token_env": "YOUR_DEEPSEEK_API_KEY",
265+
"provider": "deepseek",
266+
"price": {
267+
"input": 0.14,
268+
"output": 0.28,
269+
"currency": "USD",
270+
"unit": "1M tokens"
271+
}
272+
},
273+
{
274+
"model": ["claude-sonnet-2025", "opus-4.8"],
264275
"base_url": "https://api.deepseek.com/anthropic",
265-
"auth_token_env": "CODER_AUTH_TOKEN",
266-
"provider": "deepseek"
276+
"auth_token_env": "YOUR_ANTHROPIC_API_KEY",
277+
"provider": "anthropic",
278+
"price": {
279+
"input": 3.0,
280+
"output": 15.0,
281+
"currency": "USD",
282+
"unit": "1M tokens"
283+
}
267284
},
268285
{
269-
"name": "claude-sonnet-4-6",
270-
"model": "claude-sonnet-4-6",
271-
"base_url": "https://api.anthropic.com/v1",
272-
"auth_token_env": "CODER_AUTH_TOKEN",
273-
"provider": "anthropic"
286+
"model": ["gpt-4-turbo", "gpt-4o", "gpt-3.5-turbo"],
287+
"base_url": "https://api.openai.com/v1",
288+
"auth_token_env": "YOUR_OPENAI_API_KEY",
289+
"provider": "openai",
290+
"price": {
291+
"input": 10.0,
292+
"output": 30.0,
293+
"currency": "USD",
294+
"unit": "1M tokens"
295+
}
274296
}
275297
],
276-
"default_model": "deepseek-v4",
277298
"env": {
278-
"CODER_MODEL": "deepseek-chat",
299+
"CODER_MODEL": "deepseek-v4-pro",
279300
"CODER_BASE_URL": "https://api.deepseek.com/anthropic",
280-
"CODER_AUTH_TOKEN": ""
301+
"CODER_AUTH_TOKEN": "YOUR_DEEPSEEK_API_KEY"
281302
}
282303
}
283304
```
@@ -299,28 +320,28 @@ Place hook definitions in `~/.coder/hooks/*.json`:
299320

300321
Supported events: `SessionStart`, `UserPromptSubmit`, `PreMessage`, `PostMessage`, `PreToolUse`, `PostToolUse`, `PostToolBatch`, `Stop`, `StopFailure`, `PreCompact`, `PostCompact`, `PermissionRequest`, `PermissionDenied`, `Notification`, `SubagentStart`, `SubagentStop`, and more.
301322

302-
### Project Configuration (CLAUDE.md)
323+
### Project Configuration (CODER.md)
303324

304-
Place a `CLAUDE.md` file in your project root for project-specific instructions. Coder Agent automatically loads this as context at the start of every session:
325+
Place a `CODER.md` file in your project root for project-specific instructions. Coder Agent automatically loads this as context at the start of every session:
305326

306327
```markdown
307328
# Project Overview
308329

309-
This is a Next.js e-commerce application with Prisma ORM and PostgreSQL.
330+
This is a Node.js microservice with PostgreSQL and Redis.
310331

311332
## Architecture
312-
- `src/app/`Next.js App Router pages
313-
- `src/components/` — Shared React components
333+
- `src/app/`Application entry points
334+
- `src/components/` — Shared components
314335
- `src/lib/` — Utilities and business logic
315-
- `prisma/` — Database schema and migrations
336+
- `db/` — Database schema and migrations
316337

317338
## Conventions
318339
- Use TypeScript strict mode
319-
- Tests use Vitest with React Testing Library
340+
- Tests use Vitest
320341
- API routes follow RESTful conventions
321342
```
322343

323-
Use `/init` in an interactive session to have Coder Agent auto-generate a `CLAUDE.md` for your project.
344+
Use `/init` in an interactive session to have Coder Agent auto-generate a `CODER.md` for your project.
324345

325346
---
326347

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,5 @@ compactThreshold: 0.7 # Start compacting at 126K tokens
304304
### Multiple Projects
305305

306306
Configuration is global (`~/.coder/settings.json`), but project-specific
307-
instructions go in `CLAUDE.md` at the project root. The agent reads this
307+
instructions go in `CODER.md` at the project root (also supports `CLAUDE.md` and `CODEBUDDY.md` for compatibility). The agent reads this
308308
file at the start of every session.

packages/cli/src/app/slash/commands/session.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import { readFile } from 'node:fs/promises'
2+
import { homedir } from 'node:os'
3+
import { join } from 'node:path'
4+
5+
import { withInkSuspended } from '@coder/tui'
6+
17
import { attachedImageNotice, introMsg, toTranscriptMessages } from '../../../domain/messages.js'
28
import { TUI_SESSION_MODEL_FLAG } from '../../../domain/slash.js'
39
import type {
@@ -10,6 +16,7 @@ import type {
1016
SessionUsageResponse,
1117
VoiceToggleResponse
1218
} from '../../../gateway/types.js'
19+
import { launchCoderCommand } from '../../../lib/externalCli.js'
1320
import { formatVoiceRecordKey, parseVoiceRecordKey } from '../../../lib/platform.js'
1421
import { fmtK } from '../../../lib/text.js'
1522
import type { PanelSection } from '../../../types.js'
@@ -69,7 +76,44 @@ export const sessionCommands: SlashCommand[] = [
6976
}
7077

7178
if (!arg.trim()) {
72-
return patchOverlayState({ modelPicker: true })
79+
// Launch coder --model as external process (same radio-button selector as CLI)
80+
ctx.transcript.sys('launching model selector…')
81+
patchUiState({ status: 'model setup…' })
82+
83+
void withInkSuspended(async () => {
84+
const result = await launchCoderCommand(['--model'])
85+
86+
if (result.error) {
87+
ctx.transcript.sys(`error launching coder: ${result.error}`)
88+
patchUiState({ status: 'ready' })
89+
return
90+
}
91+
92+
if (result.code !== 0) {
93+
ctx.transcript.sys(`coder --model exited with code ${result.code}`)
94+
patchUiState({ status: 'ready' })
95+
return
96+
}
97+
98+
// Read updated settings.json to get the new model
99+
try {
100+
const settingsPath = join(homedir(), '.coder', 'settings.json')
101+
const raw = await readFile(settingsPath, 'utf-8')
102+
const settings = JSON.parse(raw)
103+
const model = settings.default_model ?? 'unknown'
104+
ctx.transcript.sys(`model → ${model}`)
105+
patchUiState(state => ({
106+
...state,
107+
status: 'ready',
108+
info: state.info ? { ...state.info, model } : { model, skills: {}, tools: {} }
109+
}))
110+
} catch {
111+
ctx.transcript.sys('model updated')
112+
patchUiState({ status: 'ready' })
113+
}
114+
})
115+
116+
return
73117
}
74118

75119
ctx.gateway

0 commit comments

Comments
 (0)