@phantomcodes/cli 1.4.1 → 1.4.3

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 (69) hide show
  1. package/README.md +99 -133
  2. package/dist/agents/command.d.mts +36 -0
  3. package/dist/agents/command.mjs +22 -10
  4. package/dist/agents/proxy.d.mts +44 -0
  5. package/dist/agents/proxy.mjs +4 -2
  6. package/dist/cli/app.d.mts +25 -0
  7. package/dist/cli/app.mjs +2 -2
  8. package/dist/cli/commands.d.mts +23 -0
  9. package/dist/cli/commands.mjs +106 -54
  10. package/dist/cli/help.d.mts +26 -0
  11. package/dist/cli/help.mjs +10 -6
  12. package/dist/cli/run.d.mts +2 -0
  13. package/dist/cli/screens.d.mts +171 -0
  14. package/dist/cli/screens.mjs +3 -3
  15. package/dist/cli/start.d.mts +34 -0
  16. package/dist/core/brand.d.mts +12 -0
  17. package/dist/core/errors.d.mts +27 -0
  18. package/dist/core/free.d.mts +13 -0
  19. package/dist/core/helpers.d.mts +75 -0
  20. package/dist/core/helpers.mjs +27 -2
  21. package/dist/core/motion.d.mts +47 -0
  22. package/dist/core/node-trust.d.mts +12 -0
  23. package/dist/core/pick.d.mts +86 -0
  24. package/dist/core/request.d.mts +64 -0
  25. package/dist/core/request.mjs +78 -29
  26. package/dist/core/secrets.d.mts +33 -0
  27. package/dist/core/shapes.d.mts +13 -0
  28. package/dist/core/state.d.mts +3 -0
  29. package/dist/core/style.d.mts +49 -0
  30. package/dist/core/version.d.mts +2 -0
  31. package/dist/core/version.mjs +1 -1
  32. package/dist/keys/command.d.mts +16 -0
  33. package/dist/keys/saved.d.mts +90 -0
  34. package/dist/keys/saved.mjs +6 -2
  35. package/dist/models/choice.d.mts +7 -0
  36. package/dist/models/choice.mjs +1 -1
  37. package/dist/models/command.d.mts +8 -0
  38. package/dist/models/list.d.mts +39 -0
  39. package/dist/phantom.d.mts +45 -0
  40. package/dist/receipts/command.d.mts +7 -0
  41. package/dist/receipts/receipts.d.mts +67 -0
  42. package/dist/receipts/receipts.mjs +15 -11
  43. package/dist/setup/agents.d.mts +149 -0
  44. package/dist/setup/agents.mjs +50 -37
  45. package/dist/setup/apply.d.mts +71 -0
  46. package/dist/setup/apply.mjs +7 -2
  47. package/dist/setup/command.d.mts +12 -0
  48. package/dist/setup/command.mjs +32 -5
  49. package/dist/setup/editors.d.mts +101 -0
  50. package/dist/setup/editors.mjs +6 -4
  51. package/dist/setup/legacy.d.mts +13 -0
  52. package/dist/setup/plan.d.mts +104 -0
  53. package/dist/setup/plan.mjs +5 -3
  54. package/dist/setup/screen.d.mts +30 -0
  55. package/dist/setup/screen.mjs +2 -2
  56. package/dist/setup/shared.d.mts +141 -0
  57. package/dist/setup/shared.mjs +8 -2
  58. package/dist/setup/was.d.mts +42 -0
  59. package/dist/setup/was.mjs +91 -0
  60. package/dist/spend/command.d.mts +5 -0
  61. package/dist/spend/lineup.d.mts +54 -0
  62. package/dist/spend/lineup.mjs +3 -2
  63. package/dist/spend/report.d.mts +105 -0
  64. package/dist/spend/report.mjs +2 -2
  65. package/dist/spend/routing.d.mts +72 -0
  66. package/dist/workspace/command.d.mts +59 -0
  67. package/dist/workspace/command.mjs +106 -52
  68. package/package.json +7 -7
  69. package/skills/phantom-ai/SKILL.md +40 -66
@@ -1,17 +1,13 @@
1
1
  ---
2
2
  name: phantom-ai
3
- description: Use the phantom CLI to connect and run coding agents through Phantom AI, manage workspace funding and spending controls, and route models. Applies when the user requests Phantom inference or payment workflows.
3
+ description: Run the phantom CLI to sign in to Phantom AI, set up or start coding agents on it, add credit, cap what each key spends, and pick models. Use when the user asks for Phantom AI, phantom-1, or a payment or spending task in Phantom.
4
4
  ---
5
5
 
6
6
  # Phantom AI
7
7
 
8
- Phantom AI serves model inference at `https://phantom.codes/v1`. The Phantom CLI connects
9
- existing coding agents to that API, manages model routing to control costs, and
10
- handles workspace funding and controls. Run from an agent (output piped),
11
- commands print JSON; add `--table` for the human-readable screen. Unknown
12
- flags are refused, so check `phantom <command> --help` for the flag names.
8
+ Phantom AI is an OpenAI-compatible API at `https://phantom.codes/v1`. The Phantom CLI (`phantom`) connects coding agents to it, keeps the user's keys, adds credit to their workspace and sets each key's caps and models. When you run it, its output goes through a pipe, so commands print JSON; add `--table` to get the screen a person sees. phantom refuses flags it doesn't know, so check `phantom <command> --help` for the names.
13
9
 
14
- ## Connect and run
10
+ ## Start an agent for one run
15
11
 
16
12
  ```bash
17
13
  phantom login
@@ -21,23 +17,19 @@ phantom claude --key coding
21
17
  phantom pi
22
18
  ```
23
19
 
24
- Login uses browser device approval and saves a key privately; ask the user to
25
- complete approval themselves. For an existing key, have them run
26
- `phantom login --paste` locally, never paste it into chat.
27
- Agent configuration is temporary. The Phantom CLI flags go before agent arguments, or `--`.
20
+ `phantom login` opens a browser page where the user approves a short code, then saves a key on this computer. Ask the user to approve it themselves. If they already have a key, have them run `phantom login --paste` in their own terminal; never ask them to paste a key into chat.
21
+
22
+ `phantom codex`, `phantom claude` and `phantom pi` set the agent up for that run only. phantom's own flags go before the agent's arguments, with `--` between them:
28
23
 
29
24
  ```bash
30
25
  phantom codex --key coding -- exec "review this repository"
31
26
  ```
32
27
 
33
- Named-key selection uses `PHANTOM_KEY_NAME`, then `PHANTOM_API_KEY`, then the
34
- saved login key. An agent's explicit `--key` selects that local named key.
28
+ phantom picks the key in this order: the key saved under the name in `PHANTOM_KEY_NAME`, then `PHANTOM_API_KEY`, then the key `phantom login` saved. `--key <name>` on an agent command runs it on the key saved under that name.
35
29
 
36
- ## Connect existing agents for future runs
30
+ ## Set up the user's agents for later runs
37
31
 
38
- Offer saved setup when the user wants their installed agent to use Phantom AI
39
- without a phantom launcher. Ask whether they want saved setup or a temporary run;
40
- when their request already specifies one, follow it.
32
+ Saved setup changes the agent's own settings, so the user can start it as usual and it calls Phantom AI. Ask whether they want that or a one-run connection, unless their request already says which.
41
33
 
42
34
  ```bash
43
35
  phantom setup --dry-run --table
@@ -45,24 +37,20 @@ phantom setup
45
37
  phantom setup --restore
46
38
  ```
47
39
 
48
- Preview and show the configuration changes before applying the setup the user
49
- approves. Plain setup detects supported agents and asks before writing. Restart
50
- the agent or open a new terminal afterward. It keeps backups for restore.
51
- To connect only Codex, preview the targeted setup first:
40
+ Show the user the dry-run changes and apply only the setup they approve. Plain `phantom setup` finds the agents on the computer and asks before it writes. Afterward the user restarts the agent or opens a new terminal. Setup keeps a copy of each file it changes, and `phantom setup --restore` puts them back.
41
+
42
+ To set up only Codex, preview that first:
52
43
 
53
44
  ```bash
54
45
  phantom setup --agent codex --provider --dry-run --table
55
46
  phantom setup --agent codex --provider
56
47
  ```
57
48
 
58
- Targeted provider setup applies without its own confirmation; run it only after
59
- the user approves the preview. Cursor needs manual settings steps; pi receives
60
- the skill only. Setup wires up a saved key through helpers or environment
61
- variables where supported; Cline stores it in a private config file.
62
- If the user requested a budget, verify that the key the configured agent uses
63
- has that cap. Creating a separate capped key does not change the default key.
49
+ `--agent <name> --provider` writes without asking, so run it only after the user approves the preview. For Cursor, setup prints steps the user follows in Cursor's settings; pi gets the skill only. Most agents read the key through `phantom key show` or the `PHANTOM_API_KEY` line setup adds to the shell startup file. Cline is the exception: setup writes the key into Cline's own settings file, which only the user can read.
50
+
51
+ If the user asked for a budget, check that the key their agent uses has that cap. Making a second key with a cap doesn't change the key the agent already uses.
64
52
 
65
- ## Fund a workspace
53
+ ## Add credit
66
54
 
67
55
  ```bash
68
56
  phantom fund --amount 10 --card
@@ -70,27 +58,23 @@ phantom fund --amount 10 --coin usdc
70
58
  phantom workspace payment --id <payment-id>
71
59
  ```
72
60
 
73
- Card checkout opens the payment URL in your browser. Crypto funding (`--coin usdc` on Solana, `--coin usdc-base` on Base)
74
- provides a Solana pay URL. Credit is available once confirmed. Check pending payments with
75
- `phantom workspace payment --id <id>`. Check balance anytime with `phantom balance`.
61
+ `--card` opens Stripe Checkout in the browser. `--coin usdc` pays in USDC on Solana and `--coin usdc-base` in USDC on Base; both return a payment link and a payment id. The credit appears once Stripe confirms the payment. `phantom workspace payment --id <payment-id>` says whether it has arrived, and `phantom balance` shows the key's credit.
76
62
 
77
- ## Control spending and keys
63
+ ## Cap what keys spend
78
64
 
79
65
  ```bash
80
66
  phantom keys create --save coding --limit 5
81
67
  phantom keys list
82
- phantom keys set --id <key-id> --budget 20 --period 30 --rate 1
83
- phantom keys revoke --id <key-id>
68
+ phantom keys set --id coding --budget 20 --period 30 --rate 1
69
+ phantom keys revoke --id coding
84
70
  phantom keys saved
85
71
  phantom keys rm <name>
86
72
  phantom balance
87
73
  ```
88
74
 
89
- Use the full ID from workspace key metadata. Key controls are enforced by the
90
- server; the rate is dollars per minute. Revocation preserves shared funds.
91
- `keys saved` lists local metadata; `keys rm` only forgets the local copy.
75
+ `--limit` caps a key's total spend, `--budget` its spend per `--period` days, and `--rate` its dollars per minute. The server enforces each cap. `--id` takes the key's name, its id, or the first 4 or more characters of its id, as `phantom keys list` shows them. Revoking a key turns it off for good; its credit stays in the workspace. `keys saved` lists the keys saved on this computer, and `keys rm` forgets one there while the key keeps working.
92
76
 
93
- ## Route models
77
+ ## Set rules for `auto`
94
78
 
95
79
  ```bash
96
80
  phantom route
@@ -99,8 +83,7 @@ phantom route rule add --if has_tools=true --use first
99
83
  phantom route test --table
100
84
  ```
101
85
 
102
- Routing affects `auto` requests. Use `PHANTOM_KEY_NAME=coding` to manage the same
103
- key used by an agent with `--key coding`. Route tests are free.
86
+ A route policy applies to requests for model `auto`. To change the policy of the key an agent runs with `--key coding`, set `PHANTOM_KEY_NAME=coding`. `phantom route test` costs nothing.
104
87
 
105
88
  ## Pick phantom-1, phantom-1:free or phantom-1:zdr
106
89
 
@@ -109,12 +92,9 @@ phantom models
109
92
  phantom models use phantom-1:zdr
110
93
  ```
111
94
 
112
- `phantom models` lists Phantom's three models with the jobs each can do and the
113
- model behind each job. `phantom-1` does every job; `phantom-1:free` is chat at $0;
114
- `phantom-1:zdr` is chat on providers that keep no data. `models use` sets the model
115
- `phantom claude`, `phantom codex`, `phantom pi` and the next `phantom setup` start on.
95
+ `phantom models` lists Phantom's three models, the jobs each can do and the model behind each job. `phantom-1` does every job, `phantom-1:free` is chat at $0, and `phantom-1:zdr` is chat on providers that keep none of the user's data. `models use` sets the model that `phantom claude`, `phantom codex`, `phantom pi` and the next `phantom setup` start on.
116
96
 
117
- ## Pick phantom-1's models
97
+ ## Pick the model in each tier
118
98
 
119
99
  ```bash
120
100
  phantom lineup --table
@@ -122,10 +102,7 @@ phantom lineup set --frontier <model> --economy-fallback <model>
122
102
  phantom lineup reset
123
103
  ```
124
104
 
125
- Each tier (economy, standard, frontier) takes a model from its own choices, which
126
- `phantom lineup` lists. A fallback is the model to try when the tier's model fails.
127
- `default` in place of a model puts that tier back to its default. `lineup set`
128
- keeps the tiers you don't name.
105
+ phantom-1 sorts each request into a tier: economy, standard or frontier. The lineup sets the model each tier runs, from the choices `phantom lineup` lists, and a fallback to try when that model fails. `default` in place of a model puts the tier back to its default. `lineup set` keeps the tiers you don't name.
129
106
 
130
107
  ## See what was spent
131
108
 
@@ -134,24 +111,21 @@ phantom spend --table
134
111
  phantom spend --workspace --from 2026-09-01 --to 2026-09-30
135
112
  ```
136
113
 
137
- `spend` shows what the key spent by model and day, and an estimate of what `phantom-1`
138
- saved against its frontier model. `--workspace` shows every key in the workspace by
139
- name. Dates are UTC days (`YYYY-MM-DD`); the default is this month.
114
+ `phantom spend` shows what the key spent by model and day, and an estimate of what `phantom-1` saved compared with running every call on its frontier model. `--workspace` shows every key in the workspace by name. Dates are UTC days (`YYYY-MM-DD`), and the default is this month.
115
+
116
+ ## Recovery, receipts and deleting a workspace
117
+
118
+ `phantom --help --all` lists every command, including `phantom verify` for receipts, and the environment variables.
140
119
 
141
- ## Advanced tasks
120
+ A guest workspace has no account; whoever holds its recovery file controls it. Save that file with `phantom workspace export --file <path>`, only to a private place.
142
121
 
143
- Use `phantom --help --all` for receipts, MCP and direct-key purchases.
144
- Export guest recovery with `phantom workspace export --file
145
- <path>` only to a private destination. Recovery grants workspace management access.
146
- Delete an empty workspace with `phantom workspace delete`: it takes the workspace's keys
147
- and saved sign-ins with it, asks first (`--yes` skips the question), and refuses while the
148
- workspace holds credit, a running request or a payment in progress.
122
+ `phantom workspace delete` deletes an empty workspace, with its keys and saved sign-ins. It asks first (`--yes` skips the question). The server refuses while the workspace holds credit, has a request running or has a payment in progress.
149
123
 
150
- ## Rules
124
+ ## Rules for running phantom
151
125
 
152
- - Never print, log or repeat API keys, wallet secrets, management credentials or recovery files. `phantom keys show` is for shell integration, not model context.
153
- - Use CLI commands to manage state; do not manually edit or delete its files.
154
- - Ask before payments the user has not requested. Existing task approval covers only the requested payment and amount.
155
- - Run permanent `phantom setup` changes only when requested; otherwise preview with `--dry-run`.
156
- - Use a user's existing subscription agent when they request that workflow. Phantom inference requires their intent.
157
- - Exit code 2 means a rejected key; report it rather than retrying unchanged credentials.
126
+ - Never print, log or repeat API keys, wallet secrets, management credentials or recovery files. `phantom keys show` is for shell use, not for your context.
127
+ - Change phantom's state with its commands. Don't edit or delete its files by hand.
128
+ - Ask before any payment the user hasn't asked for. Their approval covers only the payment and amount they named.
129
+ - Make lasting `phantom setup` changes only when the user asks; otherwise preview with `--dry-run`.
130
+ - If the user wants to keep using their agent's own subscription, do that. Send their agent's calls to Phantom only when they ask for it.
131
+ - Exit code 2 means the server rejected the key. Report it; don't retry with the same key.