@callstack/apex 0.3.2 → 0.4.2

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.
Files changed (3) hide show
  1. package/README.md +71 -45
  2. package/dist/cli.js +884 -601
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,10 +1,25 @@
1
1
  # Apex CLI
2
2
 
3
3
  Configures the AI coding assistants on your machine to use
4
- [Callstack Apex](https://apex.callstack.com/) (`callstack/Apex`).
4
+ [Callstack Apex](https://apex.callstack.com/) through Vercel AI Gateway (`callstack/apex`) or the
5
+ Callstack portal (`callstack/Apex`).
5
6
 
6
- `apex init` detects the assistants on your machine, lets you pick which ones to configure,
7
- shows every change it wants to make, and only then writes. Nothing changes until you say so.
7
+ `apex init` asks which gateway serves Apex, detects the assistants on your machine, lets you pick
8
+ which ones to configure, shows every change it wants to make, and only then writes. Nothing
9
+ changes until you say so.
10
+
11
+ ## Gateways
12
+
13
+ | Gateway | `--provider` | Model | Key |
14
+ | --- | --- | --- | --- |
15
+ | Vercel AI Gateway | `vercel` | `callstack/apex` | `AI_GATEWAY_API_KEY` |
16
+ | Callstack portal | `callstack` | `callstack/Apex` | `CALLSTACK_AUTH_TOKEN` |
17
+
18
+ `apex init` asks which one to use. Without `--provider`, the default is the gateway whose key is
19
+ already set in your shell, and Vercel AI Gateway when neither or both are. `apex detect` and
20
+ `apex run` pick the gateway the same way, so `apex run codex` launches whatever you set up last as
21
+ long as only that key is exported. Each gateway gets its own provider entry in every config, so
22
+ switching gateways adds a provider next to the old one instead of rewriting it.
8
23
 
9
24
  ## Install
10
25
 
@@ -30,25 +45,26 @@ undo your configs, so run `apex undo` first if you want them back.
30
45
  | `apex init --apply` | Writes the planned changes without asking | Yes |
31
46
  | `apex undo` | Reverts the most recent Apex CLI setup, with the same preview and confirmation | Only after you confirm |
32
47
  | `apex undo --list` | Shows recorded setups and which are already undone (`--json` prints the journal) | No |
33
- | `apex run <assistant> [-- <args>]` | Launches the assistant with the gateway, model and credentials in the child environment | No |
48
+ | `apex run [--provider <id>] <assistant> [-- <args>]` | Launches the assistant with the gateway, model and credentials in the child environment | No |
34
49
  | `apex completion <zsh\|bash\|fish>` | Prints a shell completion script | No |
35
50
 
36
51
  Each command accepts only its own flags, and `--help` and the shell completions list exactly those:
37
52
 
38
53
  | Command | Flags |
39
54
  | --- | --- |
40
- | `init` | `--assistants <ids>`, `--no-interactive`, `--apply`, `--no-diff`, `--json`, `--help` |
41
- | `detect` | `--json`, `--help` |
55
+ | `init` | `--assistants <ids>`, `--provider <id>`, `--no-interactive`, `--apply`, `--no-diff`, `--json`, `--help` |
56
+ | `detect` | `--provider <id>`, `--json`, `--help` |
57
+ | `run` | `--provider <id>`, right before or after the assistant |
42
58
  | `undo` | `--no-interactive`, `--apply`, `--no-diff`, `--json`, `--list`, `--help` |
43
59
 
44
60
  `apex init --wat` fails fast, and so does a flag in the wrong command
45
61
  (`apex detect --no-diff`). Only `--apply` writes, so there is no "preview *and* write" to argue
46
62
  about. `--assistants <ids>` is a comma list of `opencode`, `codex`,
47
- `claude`, `pi`, `cursor`, `copilot`, `ai-sdk`.
63
+ `claude`, `pi`, `cursor`, `copilot`, `ai-sdk`. `--provider <id>` is `vercel` or `callstack`.
48
64
 
49
65
  Non-interactive callers (`--no-interactive`, `--json`, pipes, CI) never get a prompt and never
50
66
  have files changed unless they also pass `--apply`. `--json` prints a machine-readable plan with
51
- `mode`, `applied`, `appliedPaths`, per-file `changes` and `nextSteps` instead of the human UI. If a
67
+ `mode`, `provider`, `model`, `envVar`, `applied`, `appliedPaths`, per-file `changes` and `nextSteps` instead of the human UI. If a
52
68
  write fails halfway through a batch, the payload still reports what already landed plus the `error`,
53
69
  and the exit code is 1.
54
70
 
@@ -64,15 +80,15 @@ apex completion fish > ~/.config/fish/completions/apex.fish
64
80
 
65
81
  ```
66
82
  ┌────────────────────────────────────────────────────────────────────────────┐
67
- │ Apex CLI · Configure callstack/Apex for your favorite harness │
83
+ │ Apex CLI · Configure Apex for your favorite harness │
68
84
  │ │
69
85
  │ Nothing is written until you confirm. │
70
86
  └────────────────────────────────────────────────────────────────────────────┘
71
87
  │
72
- ◆ Set up callstack/Apex for which assistants? (space toggles, enter confirms)
73
- │ OpenCode, Codex
88
+ ◇ Which gateway should your assistants use for Apex?
89
+ │ Vercel AI Gateway
74
90
  │
75
- ◇ Set up callstack/Apex for which assistants? (space toggles, enter confirms)
91
+ ◇ Set up callstack/apex for which assistants? (space toggles, enter confirms)
76
92
  │ OpenCode, Codex
77
93
 
78
94
 
@@ -87,15 +103,15 @@ apex completion fish > ~/.config/fish/completions/apex.fish
87
103
  - "theme": "dark"
88
104
  + "theme": "dark",
89
105
  + "provider": {
90
- + "callstack.ai": { … }
106
+ + "apex-vercel": { … }
91
107
  + }
92
108
  }
93
109
 
94
- Create ~/.codex/callstack_ai.config.toml
110
+ Create ~/.codex/apex_vercel.config.toml
95
111
  --- /dev/null
96
- +++ ~/.codex/callstack_ai.config.toml
112
+ +++ ~/.codex/apex_vercel.config.toml
97
113
  @@ -0,0 +1,10 @@
98
- +model_provider = "callstack_ai"
114
+ +model_provider = "apex_vercel"
99
115
 
100
116
  Existing files get a .apex-backup-<id> copy first. (dimmed)
101
117
  │
@@ -105,24 +121,25 @@ apex completion fish > ~/.config/fish/completions/apex.fish
105
121
 
106
122
  Environment
107
123
 
108
- ✓ CALLSTACK_AUTH_TOKEN is set in this shell
124
+ ✓ AI_GATEWAY_API_KEY is set in this shell
109
125
  Apex CLI never reads, stores or logs the key itself.
110
126
 
111
127
 
112
- Use these commands to run callstack/Apex with your selected harnesses:
128
+ Use these commands to run callstack/apex with your selected harnesses:
113
129
 
114
- apex run opencode opencode --model callstack.ai/callstack/Apex (dimmed)
115
- apex run codex codex --profile callstack_ai
130
+ apex run opencode opencode --model apex-vercel/callstack/apex (dimmed)
131
+ apex run codex codex --profile apex_vercel
116
132
 
117
- ...or pick "callstack/Apex" from the UI when setting up manually.
118
- For more instructions, visit:
119
- https://app.notion.com/p/callstack/Apex-how-to-use-it-36d5d027c0f880e99d03d1c37a77382f
133
+ ...or pick "callstack/apex" from the UI when setting up manually.
134
+ For more instructions, visit: https://vercel.com/docs/ai-gateway/coding-agents
120
135
 
121
136
  If you want to undo the changes, run apex undo
122
137
  ```
123
- `Environment` only shows the `export CALLSTACK_AUTH_TOKEN=…` line while the variable is missing; once
124
- it is set you get a green `✓ CALLSTACK_AUTH_TOKEN is set in this shell` instead. The closing block shows
125
- what each `apex run` expands to, links the guide (the URL is never folded, so it stays clickable), and
138
+ `Environment` only shows the `export AI_GATEWAY_API_KEY=…` line (and, for Vercel AI Gateway, where to
139
+ create a key) while the variable is missing; once it is set you get a green
140
+ `✓ AI_GATEWAY_API_KEY is set in this shell` instead. The Callstack portal shows `CALLSTACK_AUTH_TOKEN`. The closing block shows
141
+ what each `apex run` expands to, links the gateway's guide (Vercel's coding-agents docs or the Callstack portal guide; the URL is never
142
+ folded, so it stays clickable), and
126
143
  mentions `apex undo` only when something was actually written.
127
144
 
128
145
  The diff is the change list: it only shows the lines that actually move, paths are shortened to
@@ -143,15 +160,17 @@ their own backup first, so an undo is itself reversible. Apex CLI records each b
143
160
 
144
161
  ## Integrations
145
162
 
163
+ Names below are Vercel AI Gateway / Callstack portal.
164
+
146
165
  | Assistant | Configuration | Behavior |
147
166
  | --- | --- | --- |
148
- | OpenCode | `~/.config/opencode/opencode.json` or `.jsonc` | Adds `provider.callstack.ai`, OpenAI-compatible transport, model and environment-key reference; preserves the default model. A config already in OpenCode 2's `providers` format gets the v2 entry instead, and you add the key with `/connect`. |
149
- | Codex 0.134.0+ | `~/.codex/callstack_ai.config.toml` | Adds a self-contained Responses API provider/profile; leaves base config and default model untouched. |
150
- | Claude Code | `~/.claude/settings.json` | Merges attribution flag only; use `apex run claude` for gateway credentials and model selection. |
151
- | Pi | `~/.pi/agent/models.json` and `settings.json` | Adds `providers.callstack` with Chat Completions, Apex and `$CALLSTACK_AUTH_TOKEN`; saves `medium` as Apex's per-model thinking default for direct launches. Preserves other models and their defaults. Requires a Pi version supporting `$VAR` key interpolation and `modelThinkingLevels`. |
152
- | Cursor | Guided setup | Prints endpoint, API-key and custom-model steps; does not modify private editor storage. |
167
+ | OpenCode | `~/.config/opencode/opencode.json` or `.jsonc` | Adds `provider.apex-vercel` / `provider.callstack.ai`, OpenAI-compatible transport, model and environment-key reference; preserves the default model. A config already in OpenCode 2's `providers` format gets the v2 entry instead, and you add the key with `/connect`. |
168
+ | Codex 0.134.0+ | `~/.codex/apex_vercel.config.toml` / `callstack_ai.config.toml` | Adds a self-contained Responses API provider/profile (Vercel's Codex endpoint `/codex/v1`); leaves base config and default model untouched. |
169
+ | Claude Code | `~/.claude/settings.json` | Merges attribution flag only; use `apex run claude` for gateway credentials and model selection (Vercel's Claude Code endpoint `/claude-code`). |
170
+ | Pi | `~/.pi/agent/models.json` and `settings.json` | Adds `providers.apex-vercel` / `providers.callstack` with Chat Completions, Apex and `$AI_GATEWAY_API_KEY` / `$CALLSTACK_AUTH_TOKEN`; saves `medium` as Apex's per-model thinking default for direct launches. Preserves other models and their defaults. Requires a Pi version supporting `$VAR` key interpolation and `modelThinkingLevels`. |
171
+ | Cursor | Guided setup | Prints endpoint (Vercel's Cursor endpoint `/cursor/v1`), API-key and custom-model steps; does not modify private editor storage. |
153
172
  | VS Code / Copilot | Guided setup | Detects VS Code, not whether Copilot is installed; prints custom-endpoint steps and model JSON, retaining the editor-generated secret reference. |
154
- | Vercel AI SDK / Eve | Guided setup | Detected from the `package.json` in the directory you run Apex CLI from (`ai`, `@ai-sdk/openai` or `eve`); prints the connector snippet, which reads the key from `CALLSTACK_AUTH_TOKEN`. Nothing is written into the project. |
173
+ | Vercel AI SDK / Eve | Guided setup | Detected from the `package.json` in the directory you run Apex CLI from (`ai`, `@ai-sdk/openai` or `eve`); prints the connector snippet, which reads the key from `AI_GATEWAY_API_KEY` or `CALLSTACK_AUTH_TOKEN` (Vercel AI Gateway uses its general `/v1` endpoint here, since an app is not a coding agent). Nothing is written into the project. |
155
174
 
156
175
  Apex configs declare tool calling, image input, and the supported
157
176
  `none`/`low`/`medium`/`xhigh` reasoning efforts (default `medium`) where supported.
@@ -163,8 +182,8 @@ reserve.
163
182
  Pi's per-model default applies to fresh direct launches and model selection; `apex run pi` also
164
183
  selects `medium` explicitly. Resumed Pi sessions retain their saved thinking level.
165
184
 
166
- The gateway model ID, authentication, `medium` default, and `off` → `none` translation remain
167
- Callstack-specific.
185
+ The model ID and key depend on the gateway you pick; the `medium` default and `off` → `none`
186
+ translation are Apex-specific.
168
187
 
169
188
  | Harness | Context field | Output field | Official reference |
170
189
  | --- | --- | --- | --- |
@@ -197,16 +216,20 @@ avoid shell interpolation; launch the configured assistant directly or use WSL.
197
216
 
198
217
  ## Authentication
199
218
 
200
- Provide `CALLSTACK_AUTH_TOKEN` through your shell or a secret manager. Apex CLI never prompts for,
201
- logs, stores or validates the key, and never writes it to a config file; configs only reference it.
202
- A hidden prompt keeps it out of your shell history:
219
+ Provide `AI_GATEWAY_API_KEY` (Vercel AI Gateway) or `CALLSTACK_AUTH_TOKEN` (Callstack portal)
220
+ through your shell or a secret manager. Create a Vercel key on the AI Gateway page of your Vercel
221
+ dashboard. Apex CLI never prompts for, logs, stores or validates the key, and never writes it to a
222
+ config file; configs only reference it. A hidden prompt keeps it out of your shell history:
203
223
 
204
224
  ```bash
205
- read -r -s -p 'Callstack API key: ' CALLSTACK_AUTH_TOKEN; echo
206
- export CALLSTACK_AUTH_TOKEN
225
+ read -r -s -p 'AI Gateway API key: ' AI_GATEWAY_API_KEY; echo
226
+ export AI_GATEWAY_API_KEY
207
227
  apex run codex
208
228
  ```
209
229
 
230
+ With both keys exported, `apex run` uses Vercel AI Gateway; pass `--provider callstack` for the
231
+ portal: `apex run --provider callstack codex`.
232
+
210
233
  Other launchers: `apex run opencode`, `apex run claude`, `apex run pi`, `apex run codex -- --help`.
211
234
  Launchers pass extra arguments through unchanged (without a shell), can be overridden by explicit
212
235
  user arguments, and never run `init`. `apex run claude` sets the gateway URL, token, attribution
@@ -221,7 +244,7 @@ Apex CLI will not break what you already have.
221
244
  - It copies a file next to itself before it edits that file, so you can always put the old one back.
222
245
  - It keeps your comments, your other settings, and your default model.
223
246
  - It never asks for your API key, writes it down, or sends it anywhere. You keep it in
224
- `CALLSTACK_AUTH_TOKEN`, and the CLI prints `<redacted>` wherever a secret would show.
247
+ `AI_GATEWAY_API_KEY` or `CALLSTACK_AUTH_TOKEN`, and the CLI prints `<redacted>` wherever a secret would show.
225
248
  - If a config file is broken, set up another way, or a link to somewhere else, Apex CLI stops and
226
249
  tells you. It does not overwrite it.
227
250
  - `apex undo` gives your old setup back. It only touches files that still match what Apex CLI wrote.
@@ -229,15 +252,16 @@ Apex CLI will not break what you already have.
229
252
  How that works underneath:
230
253
 
231
254
  - Previews print paths and key/value changes, never secrets.
232
- - All selected configurations are parsed before any write. Malformed files and symlinked files or
233
- directories are refused, and one bad assistant blocks the
234
- whole batch instead of half-applying it.
255
+ - All selected configurations are parsed before any write. Malformed files, symlinked files and
256
+ dangling links are refused, and one bad assistant blocks the whole batch instead of half-applying
257
+ it. Symlinked directories, such as Stow-managed dotfiles, are followed; the `.apex-backup-*` copies
258
+ then land in your dotfiles repo, so add `*.apex-backup-*` to its `.gitignore`.
235
259
  - The dedicated Codex Apex profile's owned keys are upgraded rather than rejected as conflicts;
236
260
  the base `config.toml` and other profiles remain untouched.
237
- - JSON/JSONC edits preserve comments and unrelated keys. The Callstack endpoint is set to the
261
+ - JSON/JSONC edits preserve comments and unrelated keys. The gateway endpoint is set to the
238
262
  documented one. A key the assistant already has (in OpenCode's own key store, or in Pi's
239
263
  `models.json`, where Apex CLI 0.2 put them) is kept, so upgrading never leaves an assistant
240
- without a key; otherwise the config references `CALLSTACK_AUTH_TOKEN`.
264
+ without a key; otherwise the config references `AI_GATEWAY_API_KEY` or `CALLSTACK_AUTH_TOKEN`.
241
265
  - Writes use same-directory temporary files plus rename with mode `0600` (new directories `0700`),
242
266
  and abort if the file changed on disk between planning and saving. This is not a lock or a
243
267
  multi-file transaction: a later I/O failure can leave earlier writes applied. `apex undo`
@@ -254,6 +278,8 @@ How that works underneath:
254
278
  (separate profile files for 0.134.0+; provider is placed in that profile).
255
279
  - OpenCode v1 configuration: `https://dev.opencode.ai/docs/config/`
256
280
  (JSONC and `{env:VARIABLE}` support).
281
+ - Vercel AI Gateway for coding agents: `https://vercel.com/docs/ai-gateway/coding-agents`
282
+ (per-agent endpoints; Apex is listed as `callstack/apex`).
257
283
  - Pi custom models: `https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/models.md`
258
284
  (`$VARIABLE` key interpolation; bare uppercase names are literals in current docs).
259
285