agentcage 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # agentcage
2
2
 
3
+ ```
4
+ ▄▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ █ ▄▄▄▄ ▄▄▄ ▄▄▄▄ ▄▄▄▄
5
+ ▄▄▄█ █ █ █▄▄▄ █ █ ▀█▀ █ ▄▄▄█ █ █ █▄▄▄
6
+ █▄▄█ ▀▀▀█ █▄▄▄ █ █ █▄▄ █▄▄▄ █▄▄█ ▀▀▀█ █▄▄▄
7
+ ▀▀▀▀ ▀▀▀▀
8
+ ```
9
+
3
10
  Isolated dev containers for AI coding agents. Each project gets its own Linux container. **The project source lives
4
11
  in a Docker volume, not in a folder mounted from your laptop**, so agents in the container can't see your other files. Each container can
5
12
  run an **OpenCode server** that the OpenCode Desktop app on your laptop connects to. The app is only the UI: every agent tool
@@ -14,24 +21,46 @@ You need **Docker** (Docker Desktop on Windows/macOS, Docker Engine on Linux), *
14
21
 
15
22
  ```bash
16
23
  npm install -g agentcage # also updates to the latest version
17
- agentcage doctor # checks everything above
18
24
  ```
19
25
 
20
- ## Create a container
26
+ ```bash
27
+ agentcage doctor # checks all the prerequisites.
28
+ ```
29
+
30
+
21
31
 
22
- Run `agentcage` and follow the dialog. It asks for:
32
+ ## Quickstart
33
+
34
+ Prerequisites:
35
+
36
+ - Node and Git installed
37
+ - Docker is running
38
+ - OpenCode installed
39
+
40
+ Run this in terminal:
41
+
42
+ ```bash
43
+ agentcage doctor # checks all the prerequisites.
44
+ agentcage # Starts the container-creation dialogue
45
+ ```
46
+
47
+ Follow the steps
48
+
49
+ ## Creating a container
50
+
51
+ Run `agentcage` . The wizard will ask you for this:
23
52
 
24
53
  1. **Where the project is:** a folder on this computer (copied once, including untracked files such as `.env.local`)
25
- or a git URL (cloned).
26
- 2. **A name** for the container.
54
+ or a git URL (cloned).
55
+ 2. **A name** for the container. The Docker container, OpenCode server and OpenCode project get the prefix `ac-` (see [Settings](#settings)).
27
56
  3. **Git push access** (if the project has a remote). See [Git push access](#git-push-access).
28
57
  4. **AI agents:** OpenCode (on by default) and/or Claude Code.
29
58
  5. **Extra dev tools:** Python, GitHub CLI, pnpm. Node 24 and uv are always included.
30
59
  6. **Model providers for OpenCode** (Anthropic, OpenAI, OpenRouter, Google, Groq). After the build, OpenCode asks for each
31
- API key in your terminal.
60
+ API key in your terminal. Additional Providers can be added later.
32
61
  7. **An IDE** to open the container in when it's ready (Cursor, VS Code, Antigravity).
33
62
 
34
- Then it builds the container, adds it to OpenCode Desktop as server **ac-<name>** with the project
63
+ Then it builds the container, adds it to OpenCode Desktop as server **ac-<name>** (a green project) with the project
35
64
  `/workspaces/<name>` already open, and opens the IDE.
36
65
 
37
66
  The same works without the dialog:
@@ -41,6 +70,8 @@ agentcage new ~/code/my-project --tools opencode,claude-code --git forward --ide
41
70
  AGENTCAGE_GIT_TOKEN=github_pat_... agentcage new https://github.com/me/repo.git --git token --yes
42
71
  ```
43
72
 
73
+
74
+
44
75
  ## Commands
45
76
 
46
77
  ```bash
@@ -55,6 +86,7 @@ agentcage upgrade <name> # rebuild with the Desktop app's OpenCode versio
55
86
  agentcage stop <name>
56
87
  agentcage remove <name> # delete container, volumes and config
57
88
  agentcage version # installed version and the latest on npm
89
+ agentcage settings # project color and name prefixes for new containers
58
90
  agentcage doctor
59
91
  agentcage adopt <name> # import a container made by the old bash scripts in legacy/
60
92
  ```
@@ -62,20 +94,32 @@ agentcage adopt <name> # import a container made by the old bash script
62
94
  Container config lives in `~/.agentcage/<name>/` (`container.json` and the generated `.devcontainer/`). `node_modules`, `.venv` and
63
95
  `.next` are not copied. Instead the container runs `npm ci` / `uv sync` for every lockfile it finds.
64
96
 
97
+ ## Settings
98
+
99
+ `agentcage settings` (or **Settings** in the menu) edits `~/.agentcage/settings.json`. Settings apply to containers
100
+ created afterwards.
101
+
102
+ | Setting | Default | |
103
+ | --- | --- | --- |
104
+ | OpenCode project color | `green` | also gray (OpenCode's default), pink, blue, red, purple, yellow, orange, cyan |
105
+ | Docker container prefix | `ac-` | container and volume names, e.g. `ac-myproject`, `ac-myproject-src` |
106
+ | OpenCode server prefix | `ac-` | the server's name in OpenCode Desktop |
107
+ | OpenCode project prefix | `ac-` | the project's name in OpenCode (the folder stays `/workspaces/<name>`) |
108
+
65
109
  ## Git push access
66
110
 
67
111
  The copy in the container is separate from your laptop's, so changes leave the container via **git push**. The dialog offers two ways:
68
112
 
69
113
  - **A token for this repo only (recommended).** The dialog shows how to create one: a fine-grained GitHub token limited to
70
- the repo with *Contents: read and write*, a GitLab project access token, or a Bitbucket repository access token. The token
71
- is stored with git's credential store in the container's home volume and used for this repo only. The repo's git config clears
72
- any other credential helper, including the one an attached IDE forwards.
73
- Cursor and VS Code still forward your **SSH agent**. To close that path too, set
74
- `"dev.containers.copyGitConfig": false` and `"dev.containers.gitCredentialHelperConfigLocation": "none"` in the IDE's
75
- settings and turn off SSH agent forwarding.
114
+ the repo with *Contents: read and write*, a GitLab project access token, or a Bitbucket repository access token. The token
115
+ is stored with git's credential store in the container's home volume and used for this repo only. The repo's git config clears
116
+ any other credential helper, including the one an attached IDE forwards.
117
+ Cursor and VS Code still forward your **SSH agent**. To close that path too, set
118
+ `"dev.containers.copyGitConfig": false` and `"dev.containers.gitCredentialHelperConfigLocation": "none"` in the IDE's
119
+ settings and turn off SSH agent forwarding.
76
120
  - **Skip: use your IDE's forwarded credentials.** While Cursor or VS Code is attached, your laptop's git credentials and
77
- SSH agent are forwarded into the container, so pushing from the IDE just works. **While the IDE is attached, any agent in the
78
- container can use them to push to every repository you have access to.** When no IDE is attached, the container can't push at all.
121
+ SSH agent are forwarded into the container, so pushing from the IDE just works. **While the IDE is attached, any agent in the
122
+ container can use them to push to every repository you have access to.** When no IDE is attached, the container can't push at all.
79
123
 
80
124
  For a git URL, token mode clones inside a throwaway container with the token. Forward mode clones on your laptop with your
81
125
  own git credentials, then copies the repo in. Both work with private repos. Your git name and email are copied into the container.
@@ -99,12 +143,14 @@ never on your laptop, and survive rebuilds.
99
143
  ## What is and isn't isolated
100
144
 
101
145
  - ✅ No host folders mounted, no Docker socket, not privileged. The OpenCode server is published only on `127.0.0.1` and
102
- requires a random password.
146
+ requires a random password.
103
147
  - ⚠️ The container has internet access and can reach services on your laptop via `host.docker.internal`.
104
148
  - ⚠️ Secrets you copy in (for example `.env.local`) and provider keys can be read by agents. Use dev and test keys.
105
149
  - ⚠️ An attached IDE forwards your SSH agent, and in forward mode your git credentials (see above).
106
150
  - ⚠️ Use the IDE for editing, diffs and git. Its built-in AI agent runs outside the container's isolation, so run agents through
107
- OpenCode or Claude Code in the container.
151
+ OpenCode or Claude Code in the container.
152
+
153
+
108
154
 
109
155
  ## Platform notes
110
156
 
@@ -118,31 +164,33 @@ The setup dialog should let the user choose the backend: **plain Docker containe
118
164
  (`sbx`). We tested `sbx` v0.48.0 on Windows 11 with the `alversjo-maps` repo:
119
165
 
120
166
  **What works, and is better than plain Docker**
167
+
121
168
  - Each sandbox is a microVM with its own kernel. Installed without admin rights (`winget install Docker.sbx`), created in ~10 s.
122
169
  - `sbx create --clone opencode <repo>` gives the agent a private clone. Commits made in the sandbox are fetched on the host
123
- through a `sandbox-<name>` git remote, without touching the working tree. Only the clone is visible inside.
170
+ through a `sandbox-<name>` git remote, without touching the working tree. Only the clone is visible inside.
124
171
  - Provider keys via `sbx secret set anthropic --sandbox <name>` (also openai, openrouter, google, groq, xai...). The sandbox
125
- only sees `proxy-managed` placeholders; a host proxy injects the real key, so keys never enter the sandbox.
172
+ only sees `proxy-managed` placeholders; a host proxy injects the real key, so keys never enter the sandbox.
126
173
  - A repo-scoped GitHub token works the same way: `sbx secret set github --sandbox <name>`. By default a sandbox has no GitHub
127
- access.
174
+ access.
128
175
  - `-p 127.0.0.1:4200:4096` publishes the OpenCode server port. OpenCode 2.0.23 served the Desktop/web UI from the sandbox
129
- with the password.
176
+ with the password.
130
177
  - Network policies (open / balanced / locked down) with a per-sandbox network log.
131
178
  - The image already has Node 22, uv, Python 3, git, gh, sudo and a Docker daemon. IDEs connect over SSH (`sbx setup ssh`,
132
- then Remote-SSH to `<name>.sbx`; not tested yet).
179
+ then Remote-SSH to `<name>.sbx`; not tested yet).
133
180
 
134
181
  **What is missing for our use**
182
+
135
183
  1. **OpenCode version:** the image ships OpenCode 1.18.32 (`opencode-ai`, first on PATH). Desktop 2.0.23 needs a matching
136
- server, so a kit or template must install `@opencode/cli@<desktop version>`.
184
+ server, so a kit or template must install `@opencode/cli@<desktop version>`.
137
185
  2. **Server lifetime:** the sandbox's agent is the OpenCode TUI and `sbx exec` has no detached mode. `opencode serve` started
138
- with `nohup` dies when the exec session ends. It only stays up while a foreground `sbx exec ... opencode serve` runs on the
186
+ with `nohup` dies when the exec session ends. It only stays up while a foreground `sbx exec ... opencode serve` runs on the
139
187
  host. A kit must start the server at sandbox boot (to be tested).
140
188
  3. **Desktop registration** is still ours (the `drafts.sqlite` write), and the workspace path is the host path
141
- (`/c/Users/...`), not `/workspaces/<name>`.
189
+ (`/c/Users/...`), not `/workspaces/<name>`.
142
190
  4. **SSH agent forwarding is on by default:** the host's SSH keys were listed inside the sandbox. That is the cross-repo risk
143
- we want to avoid, so it must be turned off or warned about.
191
+ we want to avoid, so it must be turned off or warned about.
144
192
  5. **Requirements:** Docker account sign-in for every user, macOS on Apple silicon only, Ubuntu 24.04+ with KVM only,
145
- Windows 11 with Hypervisor Platform.
193
+ Windows 11 with Hypervisor Platform.
146
194
  6. OpenCode API keys: `opencode auth login` only accepts keys interactively, but with `sbx secret` this is not needed.
147
195
 
148
196
  **Plan:** add a `backend: docker | sbx` choice to the dialog and `container.json`. The `sbx` backend maps our steps to
@@ -152,4 +200,4 @@ registration stay the same.
152
200
 
153
201
  ## Legacy
154
202
 
155
- `legacy/` holds the original bash scripts this tool replaces. `agentcage adopt <name>` takes over a container they created.
203
+ `legacy/` holds the original bash scripts this tool replaces. `agentcage adopt <name>` takes over a container they created.
package/bin/agentcage.js CHANGED
@@ -3,7 +3,7 @@ import { readFileSync } from 'node:fs';
3
3
  import { parseArgs } from 'node:util';
4
4
  import * as p from '@clack/prompts';
5
5
  import { adoptContainer, listContainers, loadContainer, removeContainer, saveContainer, state, up, writeDevcontainer, openIde, ws } from '../src/container.js';
6
- import { ask, connectionInfo, newWizard, providerFlow, registerFlow } from '../src/wizard.js';
6
+ import { ask, connectionInfo, newWizard, providerFlow, registerFlow, settingsWizard } from '../src/wizard.js';
7
7
  import { detectDesktop, latestVersion } from '../src/opencode.js';
8
8
  import { ok, run } from '../src/run.js';
9
9
 
@@ -23,9 +23,11 @@ const HELP = `agentcage: isolated dev containers for AI coding agents
23
23
  agentcage provider <name> add model provider API keys to OpenCode in the container
24
24
  agentcage upgrade <name> rebuild with the Desktop app's OpenCode version (volumes kept)
25
25
  agentcage remove <name> delete container, volumes and config
26
- agentcage version installed version, and the latest on npm (update: npm i -g agentcage@latest)
26
+ agentcage settings project color and name prefixes for new containers
27
+ agentcage version | -v installed version, and the latest on npm (update: npm i -g agentcage@latest)
27
28
  agentcage doctor check Docker, Node and OpenCode Desktop
28
29
  agentcage adopt <name> import a container made by the old devbox bash scripts
30
+ agentcage help | -h this help
29
31
 
30
32
  In token mode, a token can also be passed in the AGENTCAGE_GIT_TOKEN environment variable.`;
31
33
 
@@ -49,6 +51,7 @@ async function start(b) {
49
51
  }
50
52
 
51
53
  const commands = {
54
+ settings: settingsWizard,
52
55
  async version() {
53
56
  const v = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
54
57
  const latest = await fetch('https://registry.npmjs.org/agentcage/latest').then(r => r.json()).then(j => j.version, () => undefined);
@@ -103,7 +106,10 @@ const commands = {
103
106
  const containers = listContainers();
104
107
  if (!containers.length) return newWizard();
105
108
  p.intro('agentcage');
106
- const pick = await ask(p.select({ message: 'What do you want to do?', options: [{ value: '', label: 'Create a new container' }, ...containers.map(b => ({ value: b.name, label: b.name, hint: state(b) }))] }));
109
+ // '-settings' can't clash with a container name (names start with a letter or digit)
110
+ const pick = await ask(p.select({ message: 'What do you want to do?', options: [{ value: '', label: 'Create a new container' },
111
+ ...containers.map(b => ({ value: b.name, label: b.name, hint: state(b) })), { value: '-settings', label: 'Settings' }] }));
112
+ if (pick === '-settings') return settingsWizard();
107
113
  if (!pick) return newWizard();
108
114
  const action = await ask(p.select({ message: pick, options: [
109
115
  { value: 'start', label: 'Start and show connection details' }, { value: 'open', label: 'Open in IDE' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcage",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Isolated dev containers for AI coding agents (OpenCode, Claude Code), connected to OpenCode Desktop",
5
5
  "type": "module",
6
6
  "bin": {
package/src/container.js CHANGED
@@ -7,6 +7,7 @@ import { randomBytes } from 'node:crypto';
7
7
  import { createServer } from 'node:net';
8
8
  import { devcontainer, launch, ok, run, runSync } from './run.js';
9
9
  import { TOOLS } from './catalog.js';
10
+ import { loadSettings } from './settings.js';
10
11
  import { copyIdentity, isGitUrl, parseRemote, seed, setupToken } from './git.js';
11
12
 
12
13
  export const ROOT = join(homedir(), '.agentcage');
@@ -32,7 +33,10 @@ export const listContainers = () => (existsSync(ROOT) ? readdirSync(ROOT).filter
32
33
 
33
34
  export const cleanName = s => s.replace(/\.git\/?$/, '').replace(/[\\/:]+$/, '').replace(/.*[:\\/]/, '')
34
35
  .toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
35
- export const nameTaken = n => hasContainer(n) || ok('docker', ['inspect', `ac-${n}`]) || ok('docker', ['volume', 'inspect', `ac-${n}-src`]);
36
+ export function nameTaken(n) {
37
+ const px = loadSettings().containerPrefix;
38
+ return hasContainer(n) || ok('docker', ['inspect', px + n]) || ok('docker', ['volume', 'inspect', `${px}${n}-src`]);
39
+ }
36
40
 
37
41
  const bindable = port => new Promise(r => {
38
42
  const s = createServer().once('error', () => r(false)).listen(port, '127.0.0.1', () => s.close(() => r(true)));
@@ -72,10 +76,10 @@ export const state = b => runSync('docker', ['inspect', '-f', '{{.State.Status}}
72
76
 
73
77
  // o: { src, name, tools, git: 'token'|'forward'|'none', token, opencodeVersion }. step(label, fn) shows progress.
74
78
  export async function createContainer(o, step = (_, f) => f()) {
75
- const { name } = o, src = isGitUrl(o.src) ? o.src : resolve(o.src);
79
+ const { name } = o, src = isGitUrl(o.src) ? o.src : resolve(o.src), s = loadSettings(), px = s.containerPrefix;
76
80
  const b = {
77
- name, dir: join(ROOT, name), container: `ac-${name}`,
78
- volumes: { src: `ac-${name}-src`, home: `ac-${name}-home` },
81
+ name, dir: join(ROOT, name), container: px + name, serverName: s.serverPrefix + name, projectName: s.projectPrefix + name, color: s.color,
82
+ volumes: { src: `${px}${name}-src`, home: `${px}${name}-home` },
79
83
  port: await freePort(), password: randomBytes(16).toString('hex'),
80
84
  source: src, git: o.git, tools: o.tools, opencodeVersion: o.opencodeVersion, created: new Date().toISOString(),
81
85
  };
package/src/opencode.js CHANGED
@@ -3,6 +3,7 @@ import { copyFileSync, existsSync, readFileSync, readdirSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { ok, run, runSync } from './run.js';
6
+ import { loadSettings } from './settings.js';
6
7
 
7
8
  const P = process.platform, H = homedir(), E = process.env;
8
9
  const DATA_DIR = P === 'win32' ? join(E.APPDATA ?? '', 'ai.opencode.desktop')
@@ -43,7 +44,7 @@ export async function connectDesktop(container) {
43
44
  const row = d.prepare("select value from state where name='opencode.global.dat' and key='server'").get();
44
45
  const s = { list: [], hidden: {}, projects: {}, lastProject: {}, recentlyClosed: {}, ...(row && JSON.parse(row.value)) };
45
46
  const urlOf = x => (typeof x === 'string' ? x : x.http?.url ?? x.url);
46
- s.list = s.list.filter(x => urlOf(x) !== url).concat({ type: 'http', http: { url, password: container.password }, displayName: `ac-${container.name}` });
47
+ s.list = s.list.filter(x => urlOf(x) !== url).concat({ type: 'http', http: { url, password: container.password }, displayName: serverName(container) });
47
48
  s.projects[url] = [{ worktree: dir, expanded: true }];
48
49
  s.lastProject[url] = dir;
49
50
  d.prepare(`insert into state(name, key, value, updated_at) values ('opencode.global.dat', 'server', ?, ?)
@@ -51,6 +52,25 @@ export async function connectDesktop(container) {
51
52
  d.close();
52
53
  }
53
54
 
55
+ // Names stored at creation; containers made before the settings existed use the current settings
56
+ export const serverName = c => c.serverName ?? loadSettings().serverPrefix + c.name;
57
+
58
+ // Sets the project's name and icon color in the container's OpenCode server. Asking about the folder creates the project first.
59
+ // The server starts in the background after `devcontainer up`, so retry for ~30 s.
60
+ export async function setupProject(c) {
61
+ const s = loadSettings(), name = c.projectName ?? s.projectPrefix + c.name, color = c.color ?? s.color;
62
+ const base = `http://127.0.0.1:${c.port}/api`, dir = `/workspaces/${c.name}`;
63
+ const api = (path, init) => fetch(base + path, { ...init, headers: { authorization: `Basic ${Buffer.from(`opencode:${c.password}`).toString('base64')}`, 'content-type': 'application/json' } })
64
+ .then(r => (r.ok ? r.json() : Promise.reject(new Error(`OpenCode API ${path}: HTTP ${r.status}`))));
65
+ for (let i = 0; ; i++) {
66
+ try {
67
+ await api(`/vcs?location[directory]=${encodeURIComponent(dir)}`);
68
+ const { id } = (await api('/project')).find(x => x.canonical === dir);
69
+ return await api(`/project/${id}`, { method: 'PATCH', body: JSON.stringify({ name, icon: { color } }) });
70
+ } catch (e) { if (i >= 15) throw e; await new Promise(r => setTimeout(r, 2000)); }
71
+ }
72
+ }
73
+
54
74
  // OpenCode only reads API keys from an interactive terminal, so hand the terminal to its own prompt inside the container.
55
75
  // The key goes straight into the container's home volume and never passes through agentcage or the host.
56
76
  export const loginProvider = (container, provider) =>
@@ -0,0 +1,19 @@
1
+ // User settings (~/.agentcage/settings.json). Missing keys fall back to the defaults.
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { join } from 'node:path';
5
+
6
+ const FILE = join(homedir(), '.agentcage', 'settings.json');
7
+ // Project icon colors OpenCode Desktop can show (others render as gray). green first: our default, gray: OpenCode's.
8
+ export const COLORS = ['green', 'gray', 'pink', 'blue', 'red', 'purple', 'yellow', 'orange', 'cyan'];
9
+ export const DEFAULTS = { color: 'green', containerPrefix: 'ac-', serverPrefix: 'ac-', projectPrefix: 'ac-' };
10
+ export const LABELS = {
11
+ color: 'OpenCode project color', containerPrefix: 'Docker container prefix',
12
+ serverPrefix: 'OpenCode server prefix', projectPrefix: 'OpenCode project prefix',
13
+ };
14
+
15
+ export const loadSettings = () => ({ ...DEFAULTS, ...(existsSync(FILE) && JSON.parse(readFileSync(FILE, 'utf8'))) });
16
+ export function saveSettings(s) {
17
+ mkdirSync(join(FILE, '..'), { recursive: true });
18
+ writeFileSync(FILE, JSON.stringify(s, null, 2) + '\n');
19
+ }
package/src/wizard.js CHANGED
@@ -5,8 +5,9 @@ import { join } from 'node:path';
5
5
  import { AGENTS, DEV_TOOLS, PROVIDERS, hostInfo } from './catalog.js';
6
6
  import { cleanName, createContainer, nameTaken, openIde, ws } from './container.js';
7
7
  import { isGitUrl, localRemote, parseRemote } from './git.js';
8
- import { connectDesktop, desktopRunning, detectDesktop, latestVersion, loginProvider } from './opencode.js';
8
+ import { connectDesktop, desktopRunning, detectDesktop, latestVersion, loginProvider, serverName, setupProject } from './opencode.js';
9
9
  import { ok, runSync } from './run.js';
10
+ import { COLORS, DEFAULTS, LABELS, loadSettings, saveSettings } from './settings.js';
10
11
 
11
12
  export const ask = async q => {
12
13
  const v = await q;
@@ -51,7 +52,7 @@ export async function registerFlow(b, interactive = true) {
51
52
  if (!go) return p.log.info(`Later: agentcage connect ${b.name}`);
52
53
  }
53
54
  await connectDesktop(b);
54
- p.log.success(`OpenCode Desktop: added server "ac-${b.name}" with project ${ws(b)}`);
55
+ p.log.success(`OpenCode Desktop: added server "${serverName(b)}" with project ${ws(b)}`);
55
56
  }
56
57
 
57
58
  // Hands the terminal to OpenCode's own key prompt for each provider
@@ -77,8 +78,10 @@ export async function newWizard(f = {}) {
77
78
  : p.text({ message: 'Repository URL', placeholder: 'https://github.com/owner/repo.git', validate: v => (isGitUrl(v ?? '') ? undefined : 'Enter an https:// or git@ URL') }));
78
79
  if (!isGitUrl(src) && !existsSync(src)) throw new Error(`Folder not found: ${src}`);
79
80
 
81
+ const s = loadSettings(), px = v => (v ? `"${v}"` : 'none');
82
+ if (!f.yes) p.log.info(`Name prefixes: Docker container ${px(s.containerPrefix)}, OpenCode server ${px(s.serverPrefix)}, OpenCode project ${px(s.projectPrefix)}. Change with: agentcage settings`);
80
83
  const nameOk = v => (!/^[a-z0-9][a-z0-9-]*$/.test(v ?? '') ? 'Use lowercase letters, digits and -' : nameTaken(v) ? `A container named '${v}' already exists` : undefined);
81
- const name = await pick(f.name, cleanName(src), () => ask(p.text({ message: 'Container name (the Docker container and the OpenCode server get the prefix "ac-")', initialValue: cleanName(src), validate: nameOk })));
84
+ const name = await pick(f.name, cleanName(src), () => ask(p.text({ message: 'Container name', initialValue: cleanName(src), validate: nameOk })));
82
85
  if (nameOk(name)) throw new Error(nameOk(name));
83
86
 
84
87
  // Git push access
@@ -132,12 +135,29 @@ export async function newWizard(f = {}) {
132
135
  process.exit(1);
133
136
  }
134
137
  if (providers.length) await providerFlow(b, providers);
138
+ if (oc) await setupProject(b).catch(e => p.log.warn(`Could not set the project name and color in OpenCode: ${e.message}`));
135
139
  if (oc) await registerFlow(b, !f.yes);
136
140
  if (ide !== 'none') { openIde(b, ide); p.log.success('Opening the IDE attached to the container'); }
137
141
  p.outro([
138
142
  `Container '${name}' is ready.`,
139
- oc && `OpenCode Desktop: select "ac-${name}" and start a session. Only sessions on that server are isolated.`,
143
+ oc && `OpenCode Desktop: select "${serverName(b)}" and start a session. Only sessions on that server are isolated.`,
140
144
  tools.includes('claude-code') && `Claude Code: agentcage shell ${name}, then run claude to log in.`,
141
145
  `Shell: agentcage shell ${name} IDE: agentcage open ${name}`,
142
146
  ].filter(Boolean).join('\n'));
143
147
  }
148
+
149
+ // Edit user settings one at a time until Done. They apply to containers created afterwards.
150
+ export async function settingsWizard() {
151
+ p.intro('agentcage · settings');
152
+ const s = loadSettings();
153
+ for (;;) {
154
+ const key = await ask(p.select({ message: 'Which setting? (applies to new containers)', options: [
155
+ ...Object.keys(DEFAULTS).map(k => ({ value: k, label: LABELS[k], hint: s[k] === '' ? 'none' : s[k] })), { value: '', label: 'Done' }] }));
156
+ if (!key) break;
157
+ s[key] = await ask(key === 'color'
158
+ ? p.select({ message: LABELS.color, initialValue: s.color, options: COLORS.map(c => ({ value: c, label: c, hint: c === 'gray' ? "OpenCode's default" : undefined })) })
159
+ : p.text({ message: `${LABELS[key]} (empty for none)`, initialValue: s[key], defaultValue: '', validate: v => (/^[a-z0-9-]*$/.test(v ?? '') ? undefined : 'Use lowercase letters, digits and -') }));
160
+ saveSettings(s);
161
+ }
162
+ p.outro('Settings saved.');
163
+ }