@phantomcodes/cli 1.3.4 → 1.4.1

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
@@ -181,20 +181,6 @@ The dates are UTC days and the default is this month. `--workspace` lists every
181
181
  your workspace by name; without it you see the key you run as. The saving is an
182
182
  estimate: the same tokens at the frontier model's price today.
183
183
 
184
- A Pro ($20 a month) or Max ($100 a month) plan pays for `phantom-1` calls up to an amount
185
- of model cost in any 7 days, then your credit pays:
186
-
187
- ```bash
188
- phantom plan --table
189
- phantom plan pro
190
- phantom plan manage
191
- ```
192
-
193
- `plan` shows the key's plan and how much of the last 7 days it has paid for. `plan pro`
194
- and `plan max` print a Stripe Checkout link that puts the plan on this key and open it.
195
- `plan manage` opens Stripe's billing page, where the card changes, the plan switches and
196
- it cancels. A named model, not `phantom-1`, still spends credit.
197
-
198
184
  ## Commands
199
185
 
200
186
  | Task | Commands |
package/dist/cli/app.mjs CHANGED
@@ -35,7 +35,6 @@ export function mainMenu(s) {
35
35
  { label: 'Models', hint: 'phantom-1, free or zdr: what each can do, and pick one', value: { run: ['models'] } },
36
36
  { label: 'Choose models', hint: 'the model phantom-1 runs in each tier', value: { run: ['lineup', 'set'] } },
37
37
  { label: 'Keys', hint: 'list, new, limits, revoke', value: { open: 'keys' } },
38
- { label: 'Plan', hint: 'Pro or Max, instead of credit', value: { run: ['plan'] } },
39
38
  { label: 'Workspace', hint: 'balance, keys and latest calls together', value: { run: ['workspace'] } },
40
39
  { label: 'More', hint: 'setup, undo, routing, sign out, every command', value: { open: 'more' } },
41
40
  quit,
@@ -78,7 +77,6 @@ export function nextSteps(ran) {
78
77
  fund: [['Balance', ['balance']]],
79
78
  workspace: [['See my keys', ['keys']], ['Spend by key', ['spend', '--workspace']]],
80
79
  keys: [['New key', ['keys', 'create']], ['Set a spending limit', ['keys', 'set']], ['Revoke a key', ['keys', 'revoke']]],
81
- plan: [['Start Pro', ['plan', 'pro']], ['Start Max', ['plan', 'max']], ['Manage billing', ['plan', 'manage']]],
82
80
  models: [['Put it in my agents', ['setup']], ['Choose the model in each tier', ['lineup', 'set']]],
83
81
  route: [['See what a request would get', ['route', 'test']], ['Choose models', ['lineup', 'set']]],
84
82
  'setup --restore': [['Sign out, and forget saved keys', ['logout', '--all']]],
@@ -3,7 +3,6 @@ import { agentCommand } from "../agents/command.mjs";
3
3
  import { balanceCommand, keyCommand, loginCommand, logoutCommand } from "../keys/command.mjs";
4
4
  import { lineupCommand, routeCommand } from "../spend/command.mjs";
5
5
  import { spendCommand } from "../spend/report.mjs";
6
- import { planCommand } from "../plan/command.mjs";
7
6
  import { verifyCommand } from "../receipts/command.mjs";
8
7
  import { setupCommand } from "../setup/command.mjs";
9
8
  import { SETUP_MODEL } from "../setup/shared.mjs";
@@ -45,7 +44,8 @@ export const COMMANDS = [
45
44
  workspace payment --id <payment-id> check verified funding status
46
45
  workspace export --file <path> export private guest recovery; refuses overwrites
47
46
  workspace import --file <path> restore a guest, then issue replacement keys
48
- workspace revoke-access --id <id> revoke a browser, device or recovery credential`,
47
+ workspace revoke-access --id <id> revoke a browser, device or recovery credential
48
+ workspace delete [--yes] delete an empty workspace and forget it here (--yes: don't ask)`,
49
49
  },
50
50
  {
51
51
  name: 'fund', handler: fundDispatch, keyless: true,
@@ -96,15 +96,6 @@ export const COMMANDS = [
96
96
  help: ` spend [--from <date>] [--to <date>] what this key spent, by model and day, and what phantom-1
97
97
  saved; dates are UTC days as YYYY-MM-DD, default this month
98
98
  spend --workspace every key in the workspace by name (needs phantom login)`,
99
- },
100
- {
101
- name: 'plan', handler: planCommand,
102
- group: 'Money', summary: 'your Pro or Max plan: status, buy, manage',
103
- help: ` plan [status] this workspace's Pro or Max plan, how much of the week is used,
104
- and what each plan costs
105
- plan pro | max [--no-browser] open Stripe Checkout to put the plan on this workspace (every
106
- key in it); at a terminal, it says the price and asks first
107
- plan manage [--no-browser] the same for Stripe's billing page: card, switch plan, cancel`,
108
99
  },
109
100
  {
110
101
  name: 'key', advanced: true, handler: keyCommand, keyless: true,
package/dist/cli/help.mjs CHANGED
@@ -33,7 +33,7 @@ Flags:
33
33
  ${envHelp()}
34
34
  `.trim();
35
35
  /** The order commands take inside their group in the short help: the one most people need first. Others follow in list order. */
36
- const FIRST = ['setup', 'login', 'claude', 'codex', 'pi', 'balance', 'fund', 'spend', 'plan'];
36
+ const FIRST = ['setup', 'login', 'claude', 'codex', 'pi', 'balance', 'fund', 'spend'];
37
37
  const rank = (name) => (FIRST.includes(name) ? FIRST.indexOf(name) : FIRST.length);
38
38
  /** One row of the short help: a command name in its column, then what it does. */
39
39
  const helpRow = (name, summary) => ` ${name.padEnd(20)}${summary}`;
@@ -82,8 +82,6 @@ export function spendScreen(s, style = {}) {
82
82
  const range = `${day(s.from)} to ${day(s.to)}, UTC`;
83
83
  const lines = ['', ...caption(p, w, s.scope === 'workspace' ? 'WORKSPACE SPEND' : 'SPEND', p.dim(range))];
84
84
  lines.push(` ${p.bold(usd(s.total.spent_usd))} ${p.dim(`spent on ${plural(s.total.calls, 'call')}`)}`);
85
- if (s.total.plan_usd > 0)
86
- lines.push(` ${p.dim(`${usd(s.total.plan_usd)} of it paid by your plan`)}`);
87
85
  const r = s.routing;
88
86
  if (r.available && r.calls > 0) {
89
87
  // The site's comparison: what phantom-1 cost, in lime, against the same calls on the frontier model.
@@ -255,35 +253,6 @@ export function priceHint(c) {
255
253
  const context = c.context ? ` · ${Math.round(c.context / 1000)}k context` : '';
256
254
  return `${price}${context}${c.default ? ' · default' : ''}`;
257
255
  }
258
- /** `phantom plan`: the plan, as a lime pill, and how much of this week it has used, as a bar. */
259
- export function planScreen(pl, style = {}) {
260
- const p = paint(style.env ?? {}, Boolean(style.color));
261
- const w = ruleWidth(style);
262
- const lines = ['', ...caption(p, w, 'PLAN')];
263
- if (!pl.plan) {
264
- if (!pl.available)
265
- return [...lines, ' No plan, and plans are not open right now.'].join('\n');
266
- lines.push(' No plan. A plan pays for phantom-1 each week, in place of credit, for every key in this workspace.');
267
- if (pl.prices) {
268
- lines.push('');
269
- for (const name of ['pro', 'max']) {
270
- const o = pl.prices[name];
271
- lines.push(` ${p.bold((name === 'max' ? 'Max' : 'Pro').padEnd(6))}$${o.usd_per_month} a month ${p.dim(`pays for $${o.week_limit_usd} of model cost a week; past that, credit`)}`);
272
- }
273
- }
274
- lines.push(...next(p, 'Start one:', 'phantom plan pro'), ...(hintsHidden ? [] : [` ${p.dim(' or')} ${p.cyan('phantom plan max')}`]));
275
- return lines.join('\n');
276
- }
277
- const share = pl.week_limit_usd ? pl.week_used_usd / pl.week_limit_usd : 0;
278
- lines.push(` ${p.pill(` ${pl.plan === 'max' ? 'Max' : 'Pro'} `)} ${pl.status === 'active' ? p.lime('active') : p.yellow(pl.status ?? '')}`, '');
279
- lines.push(` ${p.dim('this week'.padEnd(12))}${bar(p, share, 24, share > 0.9 ? p.yellow : p.lime)} ${usd(pl.week_used_usd)} of ${usd(pl.week_limit_usd)}`);
280
- if (pl.resets_at)
281
- lines.push(` ${p.dim('room frees'.padEnd(12))}from ${day(pl.resets_at)}`);
282
- if (pl.renews_at)
283
- lines.push(` ${p.dim('renews'.padEnd(12))}${day(pl.renews_at)}`);
284
- lines.push(...next(p, 'Card, switch or cancel:', 'phantom plan manage'));
285
- return lines.join('\n');
286
- }
287
256
  /** A link to open in the browser (Stripe Checkout, billing, a wallet), with what it's for and the next step. */
288
257
  export function linkScreen(words, url, after, style = {}) {
289
258
  const p = paint(style.env ?? {}, Boolean(style.color));
@@ -128,7 +128,6 @@ const HINTS = [
128
128
  [/^(balance|left)$/, 'balance'],
129
129
  [/^(key|keys)$/, 'keys'],
130
130
  [/^(claude|codex)$/, 'claude'],
131
- [/^(plan|subscription|subscribe)$/, 'plan'],
132
131
  [/^(login|signin|sign)$/, 'login'],
133
132
  ];
134
133
  /** The command a sentence most likely means, from the first word in it that points at one, or null. */
@@ -27,7 +27,7 @@ export function showsScreen(input) {
27
27
  * the commands that take one (`phantom key show`), then any flags. For
28
28
  * example "Run phantom setup to sign in" matches `phantom setup` only.
29
29
  */
30
- const COMMAND_IN_TEXT = /\bphantom [a-z][a-z-]*(?:(?<=(?:key|keys|workspace|plan|route|route rule)) [a-z][a-z-]*)?(?: --?[a-z][a-z-]*(?: <[^>]+>)?)*/g;
30
+ const COMMAND_IN_TEXT = /\bphantom [a-z][a-z-]*(?:(?<=(?:key|keys|workspace|route|route rule)) [a-z][a-z-]*)?(?: --?[a-z][a-z-]*(?: <[^>]+>)?)*/g;
31
31
  /**
32
32
  * Prints an error to stderr as one line of JSON, `{"error":{...}}`, and
33
33
  * returns the exit code: 2 for a key the API rejected (401 or 403), the
@@ -81,7 +81,7 @@ export function apiError(status, json) {
81
81
  msg = typeof e.message === 'string' ? e.message : msg;
82
82
  }
83
83
  else if (typeof err === 'string') {
84
- // The plan routes answer { error: <code>, detail: <words> }.
84
+ // Some routes answer { error: <words> }; a detail, when one is sent, reads better.
85
85
  const detail = json.detail;
86
86
  msg = typeof detail === 'string' && detail ? detail : err;
87
87
  code = err;
@@ -1,2 +1,2 @@
1
1
  /** This release of phantom. `npm version` keeps it equal to the version in package.json. */
2
- export const VERSION = '1.3.4';
2
+ export const VERSION = '1.4.1';
package/dist/phantom.mjs CHANGED
@@ -20,7 +20,6 @@ export { PhantomApiError, CliError, die } from "./core/errors.mjs";
20
20
  export { getLineup, putLineup, resetLineup, LINEUP_TIERS } from "./spend/lineup.mjs";
21
21
  export { getRoute, putRoute, patchRoute, clearRoute, testRoute, parseCondition } from "./spend/routing.mjs";
22
22
  export { getSpend, tableSpend } from "./spend/report.mjs";
23
- export { getPlan, planCheckout, planPortal, tablePlan } from "./plan/command.mjs";
24
23
  export { checkReceipt, modelsMatch, verifyModel } from "./receipts/receipts.mjs";
25
24
  export { keychain } from "./core/secrets.mjs";
26
25
  export { keyId, keySource, resolveApiKey, readNamedKey, saveNamedKey, removeNamedKey, listNamedKeys, saveApiKey, removeApiKey } from "./keys/saved.mjs";
@@ -30,8 +30,6 @@ export function tableSpend(d) {
30
30
  `range ${s.from} to ${s.to} (UTC)`,
31
31
  `spent ${dollars(s.total.spent_usd)} (${calls(s.total.calls)})`,
32
32
  ];
33
- if (s.total.plan_usd > 0)
34
- lines.push(`paid by plan ${dollars(s.total.plan_usd)}`);
35
33
  if (!s.routing.available)
36
34
  lines.push(`phantom-1 saved not available: ${s.routing.reason}`);
37
35
  else if (s.routing.calls === 0)
@@ -399,6 +399,31 @@ export async function workspaceCommand(input) {
399
399
  : JSON.stringify(result) + '\n');
400
400
  return 0;
401
401
  }
402
+ if (command === 'delete') {
403
+ // Deleting takes the keys and saved sign-ins with it, so at a terminal it asks first and says what goes.
404
+ const pick = flags['yes'] ? null : pickIo(input);
405
+ if (pick) {
406
+ const go = await choose({ ...pick, esc: 'back' }, 'Delete this workspace?', [
407
+ {
408
+ label: 'Delete workspace',
409
+ hint: 'takes its keys and saved sign-ins with it; credit must be spent first and it cannot be undone',
410
+ value: true,
411
+ },
412
+ { label: 'Cancel', hint: 'keep it', value: false },
413
+ ], 1);
414
+ if (!go) {
415
+ io.stderr(' Nothing was changed.\n');
416
+ return 0;
417
+ }
418
+ }
419
+ const result = await wire(saved.base_url, 'DELETE', endpoint, undefined, saved.management_credential);
420
+ // The workspace is gone, so the credential saved here points at nothing.
421
+ removeSecret(credentialPath(env));
422
+ io.stdout(showsScreen(input)
423
+ ? `\n ${paint(env, colorOn(env, io.stdoutIsTTY)).lime('✓')} Workspace deleted. Its keys and saved sign-ins are gone.\n`
424
+ : JSON.stringify(result) + '\n');
425
+ return 0;
426
+ }
402
427
  if (command === 'revoke-access') {
403
428
  if (typeof flags.id !== 'string')
404
429
  die('Use --id <management-id> from phantom workspace status.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantomcodes/cli",
3
- "version": "1.3.4",
3
+ "version": "1.4.1",
4
4
  "description": "AI inference for your coding agents. Route models, control spending, and fund your workspace.",
5
5
  "keywords": [
6
6
  "phantom",
@@ -138,25 +138,14 @@ phantom spend --workspace --from 2026-09-01 --to 2026-09-30
138
138
  saved against its frontier model. `--workspace` shows every key in the workspace by
139
139
  name. Dates are UTC days (`YYYY-MM-DD`); the default is this month.
140
140
 
141
- ## Plans
142
-
143
- ```bash
144
- phantom plan --table
145
- phantom plan pro
146
- phantom plan manage
147
- ```
148
-
149
- A Pro or Max plan pays for `phantom-1` calls up to an amount of model cost in any 7 days,
150
- then the key's credit pays. `plan` shows the plan and the week's use. `plan pro` and
151
- `plan max` print a Stripe Checkout link (and open it unless `--no-browser`); the user
152
- pays there. `plan manage` opens Stripe's billing page. Naming a model, not `phantom-1`,
153
- still spends credit.
154
-
155
141
  ## Advanced tasks
156
142
 
157
143
  Use `phantom --help --all` for receipts, MCP and direct-key purchases.
158
144
  Export guest recovery with `phantom workspace export --file
159
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.
160
149
 
161
150
  ## Rules
162
151
 
@@ -1,91 +0,0 @@
1
- import { unknownSub } from "../cli/start.mjs";
2
- import { colorOn } from "../core/style.mjs";
3
- import { linkScreen, planScreen } from "../cli/screens.mjs";
4
- import { die } from "../core/errors.mjs";
5
- import { pickIo, showsScreen, openUrl, out } from "../core/helpers.mjs";
6
- import { choose } from "../core/pick.mjs";
7
- import { request } from "../core/request.mjs";
8
- import { savedManagement } from "../workspace/command.mjs";
9
- /** The plan of the key's workspace and its week (GET /plan). */
10
- export function getPlan(apiKey, baseUrl) {
11
- return request('GET', '/plan', apiKey, undefined, baseUrl);
12
- }
13
- /** A Stripe Checkout link that puts `plan` on the key's workspace (POST /plan/checkout). */
14
- export function planCheckout(apiKey, plan, baseUrl) {
15
- return request('POST', '/plan/checkout', apiKey, { plan }, baseUrl);
16
- }
17
- /**
18
- * A link to Stripe's billing page for a workspace's plan (POST /plan/portal).
19
- * It takes the workspace's management credential: an inference key gets 403.
20
- */
21
- export function planPortal(credential, baseUrl) {
22
- return request('POST', '/plan/portal', credential, undefined, baseUrl);
23
- }
24
- const dollars = (n) => `$${n.toFixed(2)}`;
25
- /** `--table` output for `plan`. */
26
- export function tablePlan(d) {
27
- const p = d;
28
- if (!p.plan) {
29
- return p.available
30
- ? 'plan none\nsubscribe phantom plan pro or phantom plan max'
31
- : 'plan none (plans are not available right now)';
32
- }
33
- const lines = [
34
- `plan ${p.plan === 'max' ? 'Max' : 'Pro'}, on this ${p.scope}`,
35
- `status ${p.status}`,
36
- `used ${dollars(p.week_used_usd)} of ${dollars(p.week_limit_usd)} in the last 7 days (model cost, before markup)`,
37
- ];
38
- if (p.resets_at)
39
- lines.push(`room starts to free up ${p.resets_at}`);
40
- if (p.renews_at)
41
- lines.push(`period ends ${p.renews_at}`);
42
- return lines.join('\n');
43
- }
44
- /**
45
- * `phantom plan`: the plan of the key's workspace and how much of the week is
46
- * used. `phantom plan pro|max` prints a Stripe Checkout link that puts the
47
- * plan on that workspace, and opens it unless `--no-browser`. `phantom plan
48
- * manage` does the same for Stripe's billing page, where the card changes, the
49
- * plan switches and it cancels; it sends the workspace credential `phantom
50
- * login` saved, since a key can't manage billing. Run by `run()`.
51
- */
52
- export async function planCommand(input) {
53
- const { io, apiKey, baseUrl, flags, subcommand, env } = input;
54
- const table = showsScreen(input);
55
- const style = { env, color: colorOn(env, io.stdoutIsTTY), opened: !flags['no-browser'] };
56
- const open = (url) => {
57
- if (!flags['no-browser'])
58
- openUrl(url);
59
- };
60
- if (subcommand === undefined || subcommand === 'status') {
61
- out(await getPlan(apiKey, baseUrl), table, (d) => planScreen(d, style), io.stdout);
62
- }
63
- else if (subcommand === 'pro' || subcommand === 'max') {
64
- // At a terminal, say what the plan costs and covers, and ask, before sending anyone to pay.
65
- const pick = pickIo(input);
66
- if (pick) {
67
- const offer = (await getPlan(apiKey, baseUrl)).prices?.[subcommand];
68
- const what = offer ? `$${offer.usd_per_month} a month for $${offer.week_limit_usd} of model cost a week, every key` : 'for every key in this workspace';
69
- const go = await choose(pick, `Start ${subcommand === 'max' ? 'Max' : 'Pro'}?`, [
70
- { label: 'Open Stripe to pay', hint: what, value: true },
71
- { label: 'Cancel', hint: 'nothing is charged', value: false },
72
- ]);
73
- if (!go) {
74
- io.stderr(' Nothing was charged.\n');
75
- return 0;
76
- }
77
- }
78
- const result = await planCheckout(apiKey, subcommand, baseUrl);
79
- out(result, table, (d) => linkScreen(`Start ${subcommand === 'max' ? 'Max' : 'Pro'} on Stripe`, d.checkout_url, ['Once it goes through:', 'phantom plan'], style), io.stdout);
80
- open(result.checkout_url);
81
- }
82
- else if (subcommand === 'manage') {
83
- const result = await planPortal(savedManagement(input) ?? apiKey, baseUrl);
84
- out(result, table, (d) => linkScreen('Manage billing on Stripe: card, switch plan, cancel', d.portal_url, null, style), io.stdout);
85
- open(result.portal_url);
86
- }
87
- else {
88
- die(unknownSub('plan', String(subcommand), ['status', 'pro', 'max', 'manage']), 'plan_usage');
89
- }
90
- return 0;
91
- }