@phantomcodes/cli 1.6.3 → 1.7.0
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 +138 -117
- package/bin/phantom.mjs +37 -2
- package/dist/agents/command.d.mts +8 -27
- package/dist/agents/command.mjs +323 -59
- package/dist/agents/login.d.mts +3 -0
- package/dist/agents/login.mjs +97 -0
- package/dist/agents/opencode-check.d.mts +15 -0
- package/dist/agents/opencode-check.mjs +193 -0
- package/dist/agents/phantom-key.d.mts +7 -0
- package/dist/agents/phantom-key.mjs +40 -0
- package/dist/agents/proxy.d.mts +26 -28
- package/dist/agents/proxy.mjs +225 -33
- package/dist/chatgpt/command.d.mts +2 -0
- package/dist/chatgpt/command.mjs +119 -0
- package/dist/chatgpt/session.d.mts +87 -0
- package/dist/chatgpt/session.mjs +253 -0
- package/dist/cli/accounts.d.mts +21 -0
- package/dist/cli/accounts.mjs +96 -0
- package/dist/cli/app.d.mts +4 -24
- package/dist/cli/app.mjs +224 -139
- package/dist/cli/commands.d.mts +1 -16
- package/dist/cli/commands.mjs +144 -239
- package/dist/cli/help.d.mts +0 -19
- package/dist/cli/help.mjs +30 -55
- package/dist/cli/run.mjs +35 -79
- package/dist/cli/start.d.mts +2 -31
- package/dist/cli/start.mjs +13 -116
- package/dist/core/brand.d.mts +0 -7
- package/dist/core/brand.mjs +0 -8
- package/dist/core/errors.d.mts +0 -16
- package/dist/core/errors.mjs +0 -16
- package/dist/core/helpers.d.mts +0 -46
- package/dist/core/helpers.mjs +1 -64
- package/dist/core/node-trust.d.mts +0 -5
- package/dist/core/node-trust.mjs +0 -6
- package/dist/core/pick.d.mts +7 -55
- package/dist/core/pick.mjs +49 -106
- package/dist/core/request.d.mts +0 -46
- package/dist/core/request.mjs +1 -60
- package/dist/core/secrets.d.mts +0 -4
- package/dist/core/secrets.mjs +0 -10
- package/dist/core/state.d.mts +3 -1
- package/dist/core/state.mjs +147 -4
- package/dist/core/style.d.mts +0 -27
- package/dist/core/style.mjs +0 -20
- package/dist/core/version.d.mts +1 -2
- package/dist/core/version.mjs +1 -2
- package/dist/local/accounts.d.mts +25 -0
- package/dist/local/accounts.mjs +40 -0
- package/dist/local/agent-headers.d.mts +7 -0
- package/dist/local/agent-headers.mjs +44 -0
- package/dist/local/chatgpt-plan.d.mts +147 -0
- package/dist/local/chatgpt-plan.mjs +384 -0
- package/dist/local/command.d.mts +24 -0
- package/dist/local/command.mjs +211 -0
- package/dist/local/config.d.mts +49 -0
- package/dist/local/config.mjs +168 -0
- package/dist/local/decide.d.mts +37 -0
- package/dist/local/decide.mjs +201 -0
- package/dist/local/failure-signs.d.mts +4 -0
- package/dist/local/failure-signs.mjs +99 -0
- package/dist/local/keys.d.mts +32 -0
- package/dist/local/keys.mjs +239 -0
- package/dist/local/models.d.mts +53 -0
- package/dist/local/models.mjs +117 -0
- package/dist/local/replay.d.mts +59 -0
- package/dist/local/replay.mjs +143 -0
- package/dist/local/report.d.mts +43 -0
- package/dist/local/report.mjs +153 -0
- package/dist/local/request-log.d.mts +53 -0
- package/dist/local/request-log.mjs +69 -0
- package/dist/local/retry-after.d.mts +3 -0
- package/dist/local/retry-after.mjs +28 -0
- package/dist/local/rust-router.d.mts +39 -0
- package/dist/local/rust-router.mjs +54 -0
- package/dist/local/server.d.mts +27 -0
- package/dist/local/server.mjs +449 -0
- package/dist/local/status-line.d.mts +17 -0
- package/dist/local/status-line.mjs +81 -0
- package/dist/local/tiers.d.mts +3 -0
- package/dist/local/tiers.mjs +137 -0
- package/dist/local/traces.d.mts +69 -0
- package/dist/local/traces.mjs +341 -0
- package/dist/phantom.d.mts +0 -37
- package/dist/phantom.mjs +0 -31
- package/package.json +15 -9
- package/skills/phantom-ai/SKILL.md +28 -97
- package/dist/cli/screens.d.mts +0 -177
- package/dist/cli/screens.mjs +0 -398
- package/dist/core/free.d.mts +0 -13
- package/dist/core/free.mjs +0 -14
- package/dist/core/motion.d.mts +0 -47
- package/dist/core/motion.mjs +0 -156
- package/dist/core/shapes.d.mts +0 -13
- package/dist/core/shapes.mjs +0 -1
- package/dist/keys/command.d.mts +0 -16
- package/dist/keys/command.mjs +0 -143
- package/dist/keys/saved.d.mts +0 -96
- package/dist/keys/saved.mjs +0 -169
- package/dist/models/choice.d.mts +0 -7
- package/dist/models/choice.mjs +0 -27
- package/dist/models/command.d.mts +0 -8
- package/dist/models/command.mjs +0 -66
- package/dist/models/list.d.mts +0 -39
- package/dist/models/list.mjs +0 -39
- package/dist/receipts/command.d.mts +0 -7
- package/dist/receipts/command.mjs +0 -41
- package/dist/receipts/receipts.d.mts +0 -76
- package/dist/receipts/receipts.mjs +0 -118
- package/dist/setup/agents.d.mts +0 -149
- package/dist/setup/agents.mjs +0 -886
- package/dist/setup/apply.d.mts +0 -85
- package/dist/setup/apply.mjs +0 -301
- package/dist/setup/command.d.mts +0 -12
- package/dist/setup/command.mjs +0 -307
- package/dist/setup/editors.d.mts +0 -108
- package/dist/setup/editors.mjs +0 -500
- package/dist/setup/legacy.d.mts +0 -13
- package/dist/setup/legacy.mjs +0 -36
- package/dist/setup/plan.d.mts +0 -104
- package/dist/setup/plan.mjs +0 -132
- package/dist/setup/screen.d.mts +0 -30
- package/dist/setup/screen.mjs +0 -260
- package/dist/setup/shared.d.mts +0 -141
- package/dist/setup/shared.mjs +0 -88
- package/dist/setup/was.d.mts +0 -42
- package/dist/setup/was.mjs +0 -91
- package/dist/spend/command.d.mts +0 -5
- package/dist/spend/command.mjs +0 -235
- package/dist/spend/lineup.d.mts +0 -61
- package/dist/spend/lineup.mjs +0 -39
- package/dist/spend/reason.d.mts +0 -5
- package/dist/spend/reason.mjs +0 -60
- package/dist/spend/report.d.mts +0 -105
- package/dist/spend/report.mjs +0 -68
- package/dist/spend/routing.d.mts +0 -74
- package/dist/spend/routing.mjs +0 -57
- package/dist/workspace/command.d.mts +0 -59
- package/dist/workspace/command.mjs +0 -871
package/dist/cli/commands.mjs
CHANGED
|
@@ -1,244 +1,149 @@
|
|
|
1
|
-
import { workspaceCommand, workspaceLogin, forgetWorkspace } from "../workspace/command.mjs";
|
|
2
1
|
import { agentCommand } from "../agents/command.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { spendCommand } from "../spend/report.mjs";
|
|
6
|
-
import { verifyCommand } from "../receipts/command.mjs";
|
|
7
|
-
import { setupCommand } from "../setup/command.mjs";
|
|
8
|
-
import { SETUP_MODEL } from "../setup/shared.mjs";
|
|
9
|
-
import { modelsCommand } from "../models/command.mjs";
|
|
10
|
-
import { SETUP_NAMES } from "../setup/agents.mjs";
|
|
11
|
-
/** The short `--help`'s headings, in the order they print. */
|
|
12
|
-
export const HELP_GROUPS = ['Start', 'Run', 'Money', 'Keys', 'Routing', 'More'];
|
|
13
|
-
async function loginDispatch(input) {
|
|
14
|
-
const { subcommand, flags } = input;
|
|
15
|
-
// `phantom login google` or `login github`: a word that isn't a key means the usual browser sign-in, not "that is not a key".
|
|
16
|
-
if (subcommand && !subcommand.startsWith('sk-'))
|
|
17
|
-
return workspaceLogin({ ...input, subcommand: undefined });
|
|
18
|
-
return subcommand || flags.paste ? loginCommand(input) : workspaceLogin(input);
|
|
19
|
-
}
|
|
20
|
-
async function logoutDispatch(input) {
|
|
21
|
-
const forgot = await forgetWorkspace(input.env, input.baseUrl);
|
|
22
|
-
return logoutCommand(input, forgot);
|
|
23
|
-
}
|
|
24
|
-
async function fundDispatch(input) {
|
|
25
|
-
const { flags } = input;
|
|
26
|
-
void flags.amount;
|
|
27
|
-
void flags.card;
|
|
28
|
-
void flags.coin;
|
|
29
|
-
void flags['no-browser'];
|
|
30
|
-
return workspaceCommand({ ...input, subcommand: 'fund' });
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The definitions used by CLI dispatch, help, and generated documentation.
|
|
34
|
-
* `run()` reads each command's flags from its `help`, so every flag a command
|
|
35
|
-
* takes must appear there as `--name`.
|
|
36
|
-
*/
|
|
2
|
+
import { loginCommand, logoutCommand } from "../agents/login.mjs";
|
|
3
|
+
import { configCommand, replayCommand, reportCommand } from "../local/command.mjs";
|
|
37
4
|
export const COMMANDS = [
|
|
38
5
|
{
|
|
39
|
-
name: '
|
|
40
|
-
|
|
41
|
-
help: `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
a
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
key
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
group: 'Routing', summary: 'the model phantom-1 runs in each tier',
|
|
182
|
-
help: ` lineup [get] the model phantom-1 runs in each tier, and the
|
|
183
|
-
models you can pick from
|
|
184
|
-
lineup set --standard <model> pick the model for a tier; "default" puts the
|
|
185
|
-
[--frontier <model>] tier back to its default
|
|
186
|
-
[--standard-fallback <model>]
|
|
187
|
-
[--frontier-fallback <model>]
|
|
188
|
-
the model to try when a tier's model fails
|
|
189
|
-
lineup reset every tier back to its default`,
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: 'models', handler: modelsCommand, keyless: true,
|
|
193
|
-
group: 'Routing', summary: 'phantom-1, free or zdr: what each can do, and which your agents use',
|
|
194
|
-
help: ` models what phantom-1, phantom-1:free and phantom-1:private
|
|
195
|
-
can do, and the model behind each job; at a
|
|
196
|
-
terminal, pick one
|
|
197
|
-
models use <id> start your agents on it, without the menu`,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'logout', handler: logoutDispatch, keyless: true,
|
|
201
|
-
group: 'More', summary: 'sign out on this computer',
|
|
202
|
-
help: ` logout sign out: forget workspace access and the
|
|
203
|
-
default saved key
|
|
204
|
-
logout --all also forget every key saved here by name`,
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: 'setup', handler: setupCommand, keyless: true,
|
|
208
|
-
group: 'Start', summary: 'sign in and connect your coding agents',
|
|
209
|
-
help: ` setup find your agents, install the skill in each, and
|
|
210
|
-
point their model calls at Phantom AI; it shows
|
|
211
|
-
each file's changes and asks first. With no key
|
|
212
|
-
yet, it signs you in first (at a terminal)
|
|
213
|
-
[--yes] don't ask
|
|
214
|
-
[--no-browser] print the sign-in link instead of opening it
|
|
215
|
-
[--dry-run] show the changes without making them
|
|
216
|
-
[--diff] show every line each file gains or loses
|
|
217
|
-
[--no-shell] leave your shell startup file alone and print
|
|
218
|
-
the lines to add yourself
|
|
219
|
-
[--limit <USD|none>] cap what this key can spend each month
|
|
220
|
-
[--json] print JSON at a terminal too (a pipe always gets JSON)
|
|
221
|
-
[--model <id>] the model each agent starts on (default ${SETUP_MODEL})
|
|
222
|
-
setup --agent <name> install the skill for one agent, without asking:
|
|
223
|
-
${SETUP_NAMES.join(', ')} or all
|
|
224
|
-
setup [--agent <name>] --provider point that agent's model calls at Phantom AI;
|
|
225
|
-
--provider off takes phantom's settings out and
|
|
226
|
-
puts back what they replaced
|
|
227
|
-
setup --restore [--agent <name>] put back the files setup changed, from the
|
|
228
|
-
.phantom.bak copies it kept. A file you
|
|
229
|
-
edited since keeps your edits: only
|
|
230
|
-
Phantom's own lines come out. It also
|
|
231
|
-
removes the settings.json.bak copy setup
|
|
232
|
-
made for Claude Code and Gemini`,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
name: 'verify', advanced: true, handler: verifyCommand, keyless: ['--receipt'],
|
|
236
|
-
group: 'More', summary: 'check a signed receipt',
|
|
237
|
-
help: ` verify --model <id> make one small call and check that its signed
|
|
238
|
-
receipt names the model you asked for (costs a
|
|
239
|
-
fraction of a cent). For phantom-1, phantom-1:free,
|
|
240
|
-
phantom-1:private or auto it checks the receipt's
|
|
241
|
-
requested model, since the model that ran varies
|
|
242
|
-
verify --receipt <receipt> check a receipt you already have`,
|
|
6
|
+
name: 'pi', handler: agentCommand,
|
|
7
|
+
summary: 'start pi, routed on this computer by phantom-1',
|
|
8
|
+
help: ` pi [--server] [--key <name>] -- <pi arguments>
|
|
9
|
+
start pi. With routing set up (phantom config),
|
|
10
|
+
phantom-1 on this computer sends each request to
|
|
11
|
+
the account and model local.json names for its
|
|
12
|
+
tier. --server sends it through Phantom's server
|
|
13
|
+
instead, on PHANTOM_API_KEY; --key picks a key an
|
|
14
|
+
older phantom saved by name. phantom/phantom-1
|
|
15
|
+
joins your pi model scope for the run. Ctrl+S
|
|
16
|
+
in /scoped-models saves it into pi's
|
|
17
|
+
settings.json; remove it there for plain pi`,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'opencode', handler: agentCommand,
|
|
21
|
+
summary: 'start OpenCode, routed on this computer by phantom-1',
|
|
22
|
+
help: ` opencode [--server] [--key <name>] -- <opencode arguments>
|
|
23
|
+
start OpenCode, the same way phantom pi starts
|
|
24
|
+
pi: with routing set up (phantom config),
|
|
25
|
+
phantom-1 on this computer sends each request to
|
|
26
|
+
the account and model local.json names for its
|
|
27
|
+
tier. OpenCode gets a provider for this run
|
|
28
|
+
only, and your OpenCode config file is left as
|
|
29
|
+
it is. phantom stops before starting it when
|
|
30
|
+
your OpenCode settings (in this folder, a
|
|
31
|
+
folder you name, or the folder of a session
|
|
32
|
+
named with -s) would let it call another
|
|
33
|
+
provider, even one with no key yet, or would
|
|
34
|
+
change the run's provider. Not covered:
|
|
35
|
+
OpenCode plugins run their own code and can
|
|
36
|
+
make their own calls, and config you change
|
|
37
|
+
during the run (opencode reload) isn't
|
|
38
|
+
checked. A later plain opencode -c, outside
|
|
39
|
+
phantom, continues on your own default model.
|
|
40
|
+
--server sends it through Phantom's server
|
|
41
|
+
instead, on PHANTOM_API_KEY. For one answer:
|
|
42
|
+
phantom opencode -- run "<prompt>"`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'codex', handler: agentCommand,
|
|
46
|
+
summary: "start Codex, through Phantom's server for now",
|
|
47
|
+
help: ` codex [--key <name>] -- <codex arguments>
|
|
48
|
+
start Codex through Phantom's server, on
|
|
49
|
+
PHANTOM_API_KEY (or --key, a key an older phantom
|
|
50
|
+
saved by name). With a ChatGPT sign-in (phantom
|
|
51
|
+
config), openai/ models run on your ChatGPT plan`,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'claude', handler: agentCommand,
|
|
55
|
+
summary: "start Claude Code, through Phantom's server for now",
|
|
56
|
+
help: ` claude [--key <name>] -- <claude arguments>
|
|
57
|
+
start Claude Code through Phantom's server, on
|
|
58
|
+
PHANTOM_API_KEY (or --key, a key an older phantom
|
|
59
|
+
saved by name)`,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'login', handler: loginCommand,
|
|
63
|
+
summary: 'sign in to Phantom and save your key',
|
|
64
|
+
help: ` login [--no-browser] sign in to Phantom in the browser and save your
|
|
65
|
+
Phantom key on this computer (the macOS Keychain
|
|
66
|
+
on a Mac). phantom prints a link and a code: check
|
|
67
|
+
the page shows the same code, then approve.
|
|
68
|
+
--no-browser only prints the link, so you can
|
|
69
|
+
open it on another device. phantom claude and
|
|
70
|
+
phantom codex run on this key, and start this
|
|
71
|
+
sign-in themselves when there is none`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'logout', handler: logoutCommand,
|
|
75
|
+
summary: 'remove the saved Phantom key from this computer',
|
|
76
|
+
help: ` logout remove the key phantom login saved from this
|
|
77
|
+
computer. The key still works until you revoke
|
|
78
|
+
it on the website (/keys)`,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'config', handler: configCommand,
|
|
82
|
+
summary: 'Standard, Frontier and providers',
|
|
83
|
+
help: ` config the settings screen, at a terminal: Standard
|
|
84
|
+
and Frontier (one list of every connected
|
|
85
|
+
provider's models, and a fallback), and
|
|
86
|
+
Providers (ChatGPT, Z.ai and the Gateway: sign
|
|
87
|
+
in, or a key)
|
|
88
|
+
|
|
89
|
+
For scripts and agents:
|
|
90
|
+
config --standard <account>:<model> [--frontier <account>:<model>]
|
|
91
|
+
[--standard-fallback <account>:<model>|none]
|
|
92
|
+
[--frontier-fallback <account>:<model>|none]
|
|
93
|
+
set each tier's account and model, such as
|
|
94
|
+
--standard zai:glm-5.4; the model is checked
|
|
95
|
+
against the account's list
|
|
96
|
+
config --sensitivity balanced|conservative|strict
|
|
97
|
+
how soon the router moves a task up to
|
|
98
|
+
Frontier and how long it stays (default
|
|
99
|
+
balanced; strict moves up soonest), from
|
|
100
|
+
the next phantom pi
|
|
101
|
+
config --trial on|off when the router moves a task up to
|
|
102
|
+
Frontier, flip a coin: the task runs
|
|
103
|
+
there or stays on Standard, so whole
|
|
104
|
+
tasks can be compared (default off)
|
|
105
|
+
config --traces on|off save the full prompt and answer of every
|
|
106
|
+
request, on this computer only, in
|
|
107
|
+
local/traces beside local.json (off by
|
|
108
|
+
default), from the next phantom pi. They
|
|
109
|
+
hold your messages and code. Delete them
|
|
110
|
+
with rm -r on that folder
|
|
111
|
+
config show the tiers, where each key comes from and
|
|
112
|
+
whether it is found (never the key), and the
|
|
113
|
+
ChatGPT sign-in
|
|
114
|
+
config models [<account>] the models each account offers
|
|
115
|
+
config key set <account> [--stdin]
|
|
116
|
+
save an account's key in phantom (the macOS
|
|
117
|
+
Keychain on a Mac): asks with hidden typing,
|
|
118
|
+
or reads it from stdin with --stdin
|
|
119
|
+
config key use-keychain <account> --service <name> [--keychain-account <name>]
|
|
120
|
+
read the key from a Keychain item you already
|
|
121
|
+
have, without copying it (macOS)
|
|
122
|
+
config key rm <account> forget the account's key; a Keychain item stays
|
|
123
|
+
config chatgpt login [--no-browser] | logout
|
|
124
|
+
sign in with ChatGPT in the browser, so a tier
|
|
125
|
+
can run on your ChatGPT plan (--no-browser
|
|
126
|
+
prints the link), or sign out`,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'report', handler: reportCommand,
|
|
130
|
+
summary: 'what routing did',
|
|
131
|
+
help: ` report [--since <when>] sum up the saved requests: tiers, each account
|
|
132
|
+
and model's tokens and times, reasons,
|
|
133
|
+
tasks, fallbacks and failures. <when>
|
|
134
|
+
is 1h, 1d, 7d or a date such as 2026-11-28`,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'replay', handler: replayCommand,
|
|
138
|
+
summary: 'try other routing settings on saved traces',
|
|
139
|
+
help: ` replay [--since <when>] [--sensitivity balanced|conservative|strict]
|
|
140
|
+
[--max-move-up-tokens <n>]
|
|
141
|
+
run the saved traces (phantom config --traces
|
|
142
|
+
on) through phantom-1's tier decision again,
|
|
143
|
+
on this computer with no model calls: first
|
|
144
|
+
with the settings each was recorded with (a
|
|
145
|
+
self-check), then with the ones given. Prints
|
|
146
|
+
the requests that change tier and the Frontier
|
|
147
|
+
share before and after`,
|
|
243
148
|
},
|
|
244
149
|
];
|
package/dist/cli/help.d.mts
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
/** One entry in {@link ENV_VARS}. */
|
|
2
1
|
export type EnvVar = {
|
|
3
|
-
/** The variable's name. */
|
|
4
2
|
name: string;
|
|
5
|
-
/** What it does, in a few words, for HELP and the reference. */
|
|
6
3
|
about: string;
|
|
7
|
-
/** Holds a secret: keep it out of files, logs and the model's context. */
|
|
8
4
|
secret?: boolean;
|
|
9
|
-
/** Read from the environment only, on purpose: no flag or tool argument can set it. */
|
|
10
|
-
envOnly?: boolean;
|
|
11
|
-
/** Limits what an agent can spend. */
|
|
12
|
-
cap?: boolean;
|
|
13
5
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Every environment variable phantom reads. The Environment section of HELP is
|
|
16
|
-
* built from this list.
|
|
17
|
-
*/
|
|
18
6
|
export declare const ENV_VARS: readonly EnvVar[];
|
|
19
|
-
/** Full command reference, printed by `phantom --help --all`. */
|
|
20
7
|
export declare const HELP: string;
|
|
21
|
-
/**
|
|
22
|
-
* The help printed by default: each command in one line, under a heading for
|
|
23
|
-
* what it's for, so it fits on one screen. The three agents share one row.
|
|
24
|
-
* `phantom <command> --help` and `--help --all` keep the full usage.
|
|
25
|
-
*/
|
|
26
|
-
export declare const PRIMARY_HELP: string;
|
package/dist/cli/help.mjs
CHANGED
|
@@ -1,62 +1,37 @@
|
|
|
1
|
+
// docs: `phantom --help`: what phantom is for, one line per command, what it saves on this computer (the request log, and traces only when turned on), and every environment variable phantom reads (ENV_VARS). Each command's own usage is in commands.mts
|
|
1
2
|
import { DEFAULT_BASE_URL } from "../core/request.mjs";
|
|
2
|
-
import { COMMANDS
|
|
3
|
-
/**
|
|
4
|
-
* Every environment variable phantom reads. The Environment section of HELP is
|
|
5
|
-
* built from this list.
|
|
6
|
-
*/
|
|
3
|
+
import { COMMANDS } from "./commands.mjs";
|
|
7
4
|
export const ENV_VARS = [
|
|
8
|
-
{ name: 'PHANTOM_API_KEY', about:
|
|
9
|
-
{ name: 'PHANTOM_KEY_NAME', about: '
|
|
10
|
-
{ name: 'PHANTOM_BASE_URL', about: `
|
|
11
|
-
{ name: 'PHANTOM_STATE_DIR', about: 'where phantom keeps keys (default ~/.config/phantom
|
|
5
|
+
{ name: 'PHANTOM_API_KEY', about: "a Phantom AI key, for codex, claude, and pi or opencode --server, on Phantom's server", secret: true },
|
|
6
|
+
{ name: 'PHANTOM_KEY_NAME', about: 'use a key an older phantom saved by name; wins over PHANTOM_API_KEY' },
|
|
7
|
+
{ name: 'PHANTOM_BASE_URL', about: `Phantom's server, https:// only (default ${DEFAULT_BASE_URL})` },
|
|
8
|
+
{ name: 'PHANTOM_STATE_DIR', about: 'where phantom keeps local.json and keys (default ~/.config/phantom)' },
|
|
12
9
|
{ name: 'PHANTOM_KEYCHAIN', about: '0 saves keys to files instead of the macOS Keychain; 1 uses the Keychain on any system, which fails where /usr/bin/security is missing' },
|
|
13
10
|
{ name: 'PAI_KEYCHAIN', about: 'the old name of PHANTOM_KEYCHAIN, read when PHANTOM_KEYCHAIN is unset' },
|
|
11
|
+
{ name: 'PHANTOM_ROUTER_DIR', about: 'a built routers/phantom-1/router/ folder, for phantom-1 to pick tiers with the router' },
|
|
14
12
|
];
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const width = Math.max(...ENV_VARS.map((v) => v.name.length)) + 2;
|
|
19
|
-
const lines = ENV_VARS.map((v) => ` ${v.name.padEnd(width)}${v.about}${v.envOnly ? ' (environment only)' : ''}`);
|
|
20
|
-
return ['Environment:', ...lines].join('\n');
|
|
21
|
-
}
|
|
22
|
-
/** Full command reference, printed by `phantom --help --all`. */
|
|
23
|
-
export const HELP = `
|
|
24
|
-
${TITLE}
|
|
25
|
-
|
|
26
|
-
Commands:
|
|
27
|
-
${COMMANDS.map((command) => command.help).join('\n')}
|
|
28
|
-
|
|
29
|
-
Flags:
|
|
30
|
-
--table draw the screen for people, even in a pipe
|
|
31
|
-
--json print JSON, even at a terminal
|
|
32
|
-
--help, -h print help and run nothing
|
|
33
|
-
--all with --help, also list the advanced commands
|
|
34
|
-
--version, -v print the version
|
|
35
|
-
|
|
36
|
-
${envHelp()}
|
|
37
|
-
`.trim();
|
|
38
|
-
/** The order commands take inside their group in the short help: the one most people need first. Others follow in list order. */
|
|
39
|
-
const FIRST = ['setup', 'login', 'claude', 'codex', 'pi', 'balance', 'fund', 'spend'];
|
|
40
|
-
const rank = (name) => (FIRST.includes(name) ? FIRST.indexOf(name) : FIRST.length);
|
|
41
|
-
/** One row of the short help: a command name in its column, then what it does. */
|
|
42
|
-
const helpRow = (name, summary) => ` ${name.padEnd(20)}${summary}`;
|
|
43
|
-
/**
|
|
44
|
-
* The help printed by default: each command in one line, under a heading for
|
|
45
|
-
* what it's for, so it fits on one screen. The three agents share one row.
|
|
46
|
-
* `phantom <command> --help` and `--help --all` keep the full usage.
|
|
47
|
-
*/
|
|
48
|
-
export const PRIMARY_HELP = [
|
|
49
|
-
TITLE,
|
|
13
|
+
const row = (command, about) => ` ${command.padEnd(22)}${about}`;
|
|
14
|
+
export const HELP = [
|
|
15
|
+
'phantom: routes your coding agents to your own accounts',
|
|
50
16
|
'',
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'phantom
|
|
60
|
-
'
|
|
61
|
-
'
|
|
17
|
+
row('phantom', 'a list to pick from: start pi or OpenCode, Settings, or Report'),
|
|
18
|
+
...COMMANDS.map((c) => row(`phantom ${c.name}`, c.summary)),
|
|
19
|
+
'',
|
|
20
|
+
'phantom <command> --help shows its usage and flags.',
|
|
21
|
+
'',
|
|
22
|
+
'What phantom saves, on this computer only, in ~/.config/phantom/local (or PHANTOM_STATE_DIR/local):',
|
|
23
|
+
' requests.jsonl one line per request: tiers, models, times, tokens; never message text',
|
|
24
|
+
' traces/ off unless you run phantom config --traces on: then, from the next',
|
|
25
|
+
' phantom pi, the full prompt and answer of every request, your code',
|
|
26
|
+
' included. --traces off stops it from the next phantom pi (one',
|
|
27
|
+
' already running keeps saving); rm -r that folder deletes them',
|
|
28
|
+
'',
|
|
29
|
+
'Flags:',
|
|
30
|
+
' --table draw the screen for people, even in a pipe',
|
|
31
|
+
' --json print JSON, even at a terminal',
|
|
32
|
+
' --help, -h print help and run nothing',
|
|
33
|
+
' --version, -v print the version',
|
|
34
|
+
'',
|
|
35
|
+
'Environment:',
|
|
36
|
+
...ENV_VARS.map((v) => ` ${v.name.padEnd(Math.max(...ENV_VARS.map((e) => e.name.length)) + 2)}${v.about}`),
|
|
62
37
|
].join('\n');
|