@phantomcodes/cli 1.6.2 → 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 -114
- 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/setup/agents.mjs
DELETED
|
@@ -1,886 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
-
import { die } from "../core/errors.mjs";
|
|
6
|
-
import { resolveApiKey } from "../keys/saved.mjs";
|
|
7
|
-
import { SETUP_MODEL, agentBaseUrl, readText, configHome, onPath, phantomCommand, offResult, unreadable, SETUP_MARK, SETUP_CONTEXT_WINDOW, claudeModelName, } from "./shared.mjs";
|
|
8
|
-
import { readJsonWas, restoreJsonChanges, trackJsonChanges } from "./was.mjs";
|
|
9
|
-
import { jsonObject, jsonEdit, tomlSet, tomlRemoveOurs, yamlSetTop, yamlAddModel, yamlRemoveOurs } from "./editors.mjs";
|
|
10
|
-
/** The most output a model call may ask for, for agents that need a number. */
|
|
11
|
-
const SETUP_OUTPUT_TOKENS = 32_000;
|
|
12
|
-
/** A JSON edit's result, or '' when only `$schema` (or nothing) is left, so `off` deletes a file phantom made. */
|
|
13
|
-
function unlessEmpty(file, after) {
|
|
14
|
-
const left = jsonObject(file, after);
|
|
15
|
-
return Object.keys(left).every((k) => k === '$schema') ? '' : after;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The edit that writes `changes` to a JSON settings file, with a record of what the keys in `tracked` held
|
|
19
|
-
* before ({@link trackJsonChanges}), so `--provider off` can put those values back.
|
|
20
|
-
*/
|
|
21
|
-
function jsonOn(env, file, text, changes, tracked = changes.map(([p]) => p)) {
|
|
22
|
-
const was = trackJsonChanges(jsonObject(file, text), readJsonWas(env, file), changes, tracked);
|
|
23
|
-
return { file, after: jsonEdit(file, text, changes), was };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The text of a JSON settings file after `--provider off`: `removals` (what the agent's own off step finds that
|
|
27
|
-
* looks like phantom's) with each recorded key put back ({@link restoreJsonChanges}).
|
|
28
|
-
*/
|
|
29
|
-
function jsonOffText(env, file, text, removals, tidy = []) {
|
|
30
|
-
const record = readJsonWas(env, file);
|
|
31
|
-
return jsonEdit(file, text, restoreJsonChanges(jsonObject(file, text), record, removals, tidy));
|
|
32
|
-
}
|
|
33
|
-
// ── Manual Provider Helper ───────────────────────────────────────────────────
|
|
34
|
-
/** An agent whose model settings live on its own settings screen: setup prints the steps. */
|
|
35
|
-
export function manualProvider(where, steps, note) {
|
|
36
|
-
return (ctx, off) => ({
|
|
37
|
-
edits: [],
|
|
38
|
-
// The note is something to know, not a step to do, so it shows apart from the numbered steps.
|
|
39
|
-
result: { settings: where, on: false, warnings: off || !note ? [] : [note], manual: off ? [`Remove the Phantom AI settings in ${where}.`] : steps(ctx) },
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
// ── Codex ────────────────────────────────────────────────────────────────────
|
|
43
|
-
/** Codex's folder: `$CODEX_HOME`, else `~/.codex`. */
|
|
44
|
-
export function codexDir(env, home) {
|
|
45
|
-
return env.CODEX_HOME?.trim() ? env.CODEX_HOME : path.join(home, '.codex');
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Codex: `config.toml` in Codex's folder gets a `phantom` model provider at
|
|
49
|
-
* `/codex/v1` that reads the key from PHANTOM_API_KEY (as Vercel's writes a
|
|
50
|
-
* `vercel` provider with `env_key`). phantom also writes the model, and Phantom
|
|
51
|
-
* AI's model list at `/codex/v1/models`, which Codex 0.156 reads only with
|
|
52
|
-
* `[features] api_key_model_discovery`.
|
|
53
|
-
*/
|
|
54
|
-
export function codexProvider(ctx, off) {
|
|
55
|
-
const file = path.join(codexDir(ctx.env, ctx.home), 'config.toml');
|
|
56
|
-
const text = readText(file);
|
|
57
|
-
if (off)
|
|
58
|
-
return offResult('Codex', file, text, text === null ? null : tomlRemoveOurs(file, text));
|
|
59
|
-
const base = agentBaseUrl(ctx.env, 'codex');
|
|
60
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
61
|
-
let t = tomlSet(file, text ?? '', [], 'model', JSON.stringify(model));
|
|
62
|
-
t = tomlSet(file, t, [], 'model_provider', '"phantom"');
|
|
63
|
-
const provider = [
|
|
64
|
-
['name', 'Phantom AI'],
|
|
65
|
-
['base_url', base],
|
|
66
|
-
['wire_api', 'responses'],
|
|
67
|
-
['env_key', 'PHANTOM_API_KEY'],
|
|
68
|
-
['model_catalog_url', `${base}/models`],
|
|
69
|
-
];
|
|
70
|
-
for (const [k, v] of provider)
|
|
71
|
-
t = tomlSet(file, t, ['model_providers', 'phantom'], k, JSON.stringify(v));
|
|
72
|
-
t = tomlSet(file, t, ['features'], 'api_key_model_discovery', 'true');
|
|
73
|
-
return { edits: [{ file, after: t }], result: { settings: file, on: true, base_url: base, model, warnings: [] } };
|
|
74
|
-
}
|
|
75
|
-
// ── Claude Code ──────────────────────────────────────────────────────────────
|
|
76
|
-
/** Claude Code's folder: `$CLAUDE_CONFIG_DIR`, else `~/.claude`. */
|
|
77
|
-
export function claudeDir(env, home) {
|
|
78
|
-
return env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR : path.join(home, '.claude');
|
|
79
|
-
}
|
|
80
|
-
/** The plan behind {@link claudeProvider}. */
|
|
81
|
-
export function claudePlan(env, opts) {
|
|
82
|
-
const file = path.join(claudeDir(env, env.HOME || os.homedir()), 'settings.json');
|
|
83
|
-
const text = readText(file);
|
|
84
|
-
const settings = jsonObject(file, text);
|
|
85
|
-
const ours = typeof settings.apiKeyHelper === 'string' && /(?:pai|phantom).* key show$/.test(settings.apiKeyHelper);
|
|
86
|
-
const vars = { ...(settings.env ?? {}) };
|
|
87
|
-
if (opts.off) {
|
|
88
|
-
const mine = ['ANTHROPIC_BASE_URL', 'ENABLE_TOOL_SEARCH', 'ANTHROPIC_MODEL', 'ANTHROPIC_DEFAULT_HAIKU_MODEL', 'CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY', ...(vars.ANTHROPIC_API_KEY === '' ? ['ANTHROPIC_API_KEY'] : [])];
|
|
89
|
-
// Without a record (setup from an older phantom) every key phantom writes is removed; with one,
|
|
90
|
-
// each key goes back to what the user had.
|
|
91
|
-
const removals = [[['apiKeyHelper'], undefined], ...mine.filter((k) => k in vars).map((k) => [['env', k], undefined])];
|
|
92
|
-
return {
|
|
93
|
-
edits: text === null || !ours ? [] : [{ file, after: jsonOffText(env, file, text, removals, [['env']]), was: null }],
|
|
94
|
-
result: { settings: file, on: false, warnings: ours ? [] : ['Claude Code was not set to Phantom AI by phantom; nothing changed'] },
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (!resolveApiKey(env))
|
|
98
|
-
die('No Phantom key yet to give Claude Code. Run phantom login to sign in, then run this again.', 'no_key');
|
|
99
|
-
const baseUrl = agentBaseUrl(env, 'claude-code');
|
|
100
|
-
// `phantom` if it's installed, else this very phantom by absolute path: Claude Code
|
|
101
|
-
// runs the helper outside this shell, so a relative or npx path won't do.
|
|
102
|
-
const set = {
|
|
103
|
-
ANTHROPIC_BASE_URL: baseUrl,
|
|
104
|
-
// Empty, as Vercel's setup writes it, so an ANTHROPIC_API_KEY in the shell
|
|
105
|
-
// can't win over the Phantom key: the settings file outranks the shell.
|
|
106
|
-
ANTHROPIC_API_KEY: '',
|
|
107
|
-
ENABLE_TOOL_SEARCH: 'true',
|
|
108
|
-
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: '1',
|
|
109
|
-
// phantom-1 unless a model is named, as Codex gets: it runs free until there is credit.
|
|
110
|
-
ANTHROPIC_MODEL: claudeModelName(opts.model ?? SETUP_MODEL),
|
|
111
|
-
// Claude Code's background calls (titles, summaries) and its Explore agent, which reads the
|
|
112
|
-
// user's code, use the haiku model. It follows the chosen model, so a zero data retention
|
|
113
|
-
// choice (phantom-1:zdr) covers them too. Through phantom-1 they run on Standard instead of Claude Haiku.
|
|
114
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: claudeModelName(opts.model ?? SETUP_MODEL),
|
|
115
|
-
};
|
|
116
|
-
const changes = [[['apiKeyHelper'], `${phantomCommand(opts.onPath ?? onPath)} key show`], ...Object.entries(set).map(([k, v]) => [['env', k], v])];
|
|
117
|
-
// A token outranks apiKeyHelper, and would send a non-Phantom key.
|
|
118
|
-
const warnings = env.ANTHROPIC_AUTH_TOKEN ? ['ANTHROPIC_AUTH_TOKEN is set in this shell and overrides the Phantom key; unset it before running claude'] : [];
|
|
119
|
-
if (opts.model?.replace(/^claude-code\//, '') === 'auto')
|
|
120
|
-
warnings.push('auto runs what the key\'s route policy picks; set one with: phantom route set --models a,b');
|
|
121
|
-
return { edits: [jsonOn(env, file, text, changes)], result: { settings: file, on: true, base_url: baseUrl, model: set.ANTHROPIC_MODEL ?? vars.ANTHROPIC_MODEL, warnings } };
|
|
122
|
-
}
|
|
123
|
-
// ── Copilot ──────────────────────────────────────────────────────────────────
|
|
124
|
-
/** GitHub Copilot CLI's folder: `$COPILOT_HOME`, else `~/.copilot`. */
|
|
125
|
-
export function copilotDir(env, home) {
|
|
126
|
-
return env.COPILOT_HOME?.trim() ? env.COPILOT_HOME : path.join(home, '.copilot');
|
|
127
|
-
}
|
|
128
|
-
/** GitHub Copilot CLI: set up by the shell block alone, as Vercel's setup does. Its variables are in {@link SetupAgentSpec.shellEnv}. */
|
|
129
|
-
export function copilotProvider(ctx, off) {
|
|
130
|
-
return off
|
|
131
|
-
? { edits: [], result: { settings: ctx.shellRc, on: false, warnings: [] } }
|
|
132
|
-
: {
|
|
133
|
-
edits: [],
|
|
134
|
-
result: {
|
|
135
|
-
settings: ctx.shellRc,
|
|
136
|
-
on: true,
|
|
137
|
-
base_url: agentBaseUrl(ctx.env, 'coding-agent'),
|
|
138
|
-
model: ctx.model ?? SETUP_MODEL,
|
|
139
|
-
warnings: ['GitHub Copilot CLI reads its settings from the shell; open a new terminal before running it'],
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
// ── opencode ─────────────────────────────────────────────────────────────────
|
|
144
|
-
/** opencode's config file: `opencode.json` (or `.jsonc`) in `$XDG_CONFIG_HOME/opencode`, else `~/.config/opencode`. */
|
|
145
|
-
export function opencodeFile(env, home) {
|
|
146
|
-
const dir = path.join(configHome(env, home), 'opencode');
|
|
147
|
-
return existsSync(path.join(dir, 'opencode.jsonc')) ? path.join(dir, 'opencode.jsonc') : path.join(dir, 'opencode.json');
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* opencode: a `phantom` provider at `/coding-agent/v1` whose key is
|
|
151
|
-
* `{env:PHANTOM_API_KEY}`. Like Vercel's setup, it pins no model unless
|
|
152
|
-
* `--model` asks; pick `phantom/<model>` in opencode.
|
|
153
|
-
*/
|
|
154
|
-
export function opencodeProvider(ctx, off) {
|
|
155
|
-
const file = opencodeFile(ctx.env, ctx.home);
|
|
156
|
-
const text = readText(file);
|
|
157
|
-
const config = jsonObject(file, text);
|
|
158
|
-
if (off) {
|
|
159
|
-
const ours = Boolean(config.provider?.phantom);
|
|
160
|
-
const changes = [Object.keys(config.provider ?? {}).length === 1 ? [['provider'], undefined] : [['provider', 'phantom'], undefined]];
|
|
161
|
-
if (typeof config.model === 'string' && config.model.startsWith('phantom/'))
|
|
162
|
-
changes.push([['model'], undefined]);
|
|
163
|
-
return offResult('opencode', file, text, ours ? unlessEmpty(file, jsonOffText(ctx.env, file, text, changes)) : text, true);
|
|
164
|
-
}
|
|
165
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
166
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
167
|
-
const changes = [
|
|
168
|
-
...(!text?.trim() ? [[['$schema'], 'https://opencode.ai/config.json']] : []),
|
|
169
|
-
[
|
|
170
|
-
['provider', 'phantom'],
|
|
171
|
-
{ npm: '@ai-sdk/openai-compatible', name: 'Phantom AI', options: { baseURL: base, apiKey: '{env:PHANTOM_API_KEY}' }, models: { [model]: { name: model } } },
|
|
172
|
-
],
|
|
173
|
-
...(ctx.model ? [[['model'], `phantom/${ctx.model}`]] : []),
|
|
174
|
-
];
|
|
175
|
-
return {
|
|
176
|
-
edits: [jsonOn(ctx.env, file, text, changes, [['model']])],
|
|
177
|
-
result: { settings: file, on: true, base_url: base, ...(ctx.model ? { model: `phantom/${ctx.model}` } : {}), warnings: ctx.model ? [] : [`Pick phantom/${model} with /models in opencode`] },
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
// ── Continue ─────────────────────────────────────────────────────────────────
|
|
181
|
-
/**
|
|
182
|
-
* Continue: `~/.continue/config.yaml` gets a model at `/coding-agent/v1`,
|
|
183
|
-
* first in `models:` so the `cn` CLI starts with it, with the key from
|
|
184
|
-
* `${{ secrets.PHANTOM_API_KEY }}`. Like Vercel's setup it also writes
|
|
185
|
-
* `.onboarding_complete` beside it, so `cn`'s first-run questions don't
|
|
186
|
-
* replace the list.
|
|
187
|
-
*/
|
|
188
|
-
export function continueProvider(ctx, off) {
|
|
189
|
-
const file = path.join(ctx.home, '.continue', 'config.yaml');
|
|
190
|
-
const text = readText(file);
|
|
191
|
-
if (off)
|
|
192
|
-
return offResult('Continue', file, text, text === null ? null : yamlRemoveOurs(file, text));
|
|
193
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
194
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
195
|
-
const after = yamlAddModel(file, text, [`- name: Phantom AI ${model}`, 'provider: openai', `model: ${model}`, `apiBase: ${base}`, 'apiKey: ${{ secrets.PHANTOM_API_KEY }}'], ['name: Local Config', 'version: 1.0.0', 'schema: v1']);
|
|
196
|
-
const marker = path.join(ctx.home, '.continue', '.onboarding_complete');
|
|
197
|
-
return {
|
|
198
|
-
edits: [{ file, after }, { file: marker, after: readText(marker) ?? `${new Date().toISOString()}\n` }],
|
|
199
|
-
result: { settings: file, on: true, base_url: base, model, warnings: [] },
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
// ── Goose ────────────────────────────────────────────────────────────────────
|
|
203
|
-
/**
|
|
204
|
-
* Goose, as Vercel's setup does it: a custom provider file,
|
|
205
|
-
* `custom_providers/custom_phantom.json` in Goose's folder, at
|
|
206
|
-
* `/coding-agent/v1/chat/completions` with the key from PHANTOM_API_KEY, and
|
|
207
|
-
* GOOSE_PROVIDER and GOOSE_MODEL in Goose's `config.yaml`, which the desktop
|
|
208
|
-
* app reads too.
|
|
209
|
-
*/
|
|
210
|
-
export function gooseProvider(ctx, off) {
|
|
211
|
-
const dir = path.join(configHome(ctx.env, ctx.home), 'goose');
|
|
212
|
-
const config = path.join(dir, 'config.yaml');
|
|
213
|
-
const file = path.join(dir, 'custom_providers', 'custom_phantom.json');
|
|
214
|
-
const text = readText(file);
|
|
215
|
-
const yaml = readText(config);
|
|
216
|
-
if (off) {
|
|
217
|
-
const after = yaml === null ? null : yamlRemoveOurs(config, yaml);
|
|
218
|
-
const edits = [...(text === null ? [] : [{ file, after: null }]), ...(yaml !== null && after !== yaml ? [{ file: config, after: after || null }] : [])];
|
|
219
|
-
return { edits, result: { settings: config, on: false, warnings: edits.length ? [] : ['Goose was not set to Phantom AI by phantom; nothing changed'] } };
|
|
220
|
-
}
|
|
221
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
222
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
223
|
-
const provider = {
|
|
224
|
-
name: 'custom_phantom',
|
|
225
|
-
engine: 'openai',
|
|
226
|
-
display_name: 'Phantom AI',
|
|
227
|
-
description: 'Phantom AI, set up by phantom',
|
|
228
|
-
api_key_env: 'PHANTOM_API_KEY',
|
|
229
|
-
base_url: `${base}/chat/completions`,
|
|
230
|
-
models: [{ name: model, context_limit: SETUP_CONTEXT_WINDOW }],
|
|
231
|
-
supports_streaming: true,
|
|
232
|
-
requires_auth: true,
|
|
233
|
-
};
|
|
234
|
-
const yamlAfter = yamlSetTop(config, yamlSetTop(config, yaml, 'GOOSE_PROVIDER', 'custom_phantom'), 'GOOSE_MODEL', model);
|
|
235
|
-
return {
|
|
236
|
-
edits: [
|
|
237
|
-
{ file, after: jsonEdit(file, text, Object.entries(provider).map(([k, v]) => [[k], v])) },
|
|
238
|
-
{ file: config, after: yamlAfter },
|
|
239
|
-
],
|
|
240
|
-
result: { settings: config, on: true, base_url: base, model, warnings: [] },
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
// ── Aider ────────────────────────────────────────────────────────────────────
|
|
244
|
-
/**
|
|
245
|
-
* Aider, as Vercel's setup does it: `~/.aider.conf.yml` gets
|
|
246
|
-
* `openai-api-base` at `/coding-agent/v1` and the model as `openai/<model>`,
|
|
247
|
-
* `~/.aider.model.metadata.json` and `~/.aider.model.settings.yml` tell Aider
|
|
248
|
-
* the model's context window and edit format, and the key comes from
|
|
249
|
-
* AIDER_OPENAI_API_KEY in the shell block.
|
|
250
|
-
*/
|
|
251
|
-
export function aiderProvider(ctx, off) {
|
|
252
|
-
const conf = path.join(ctx.home, '.aider.conf.yml');
|
|
253
|
-
const meta = path.join(ctx.home, '.aider.model.metadata.json');
|
|
254
|
-
const settingsFile = path.join(ctx.home, '.aider.model.settings.yml');
|
|
255
|
-
const [confText, metaText, setText] = [readText(conf), readText(meta), readText(settingsFile)];
|
|
256
|
-
const id = `openai/${ctx.model ?? SETUP_MODEL}`;
|
|
257
|
-
const metadata = jsonObject(meta, metaText);
|
|
258
|
-
if (off) {
|
|
259
|
-
const edits = [];
|
|
260
|
-
const confAfter = confText === null ? null : yamlRemoveOurs(conf, confText);
|
|
261
|
-
if (confText !== null && confAfter !== confText)
|
|
262
|
-
edits.push({ file: conf, after: confAfter || null });
|
|
263
|
-
const setAfter = setText === null ? null : yamlRemoveOurs(settingsFile, setText);
|
|
264
|
-
if (setText !== null && setAfter !== setText)
|
|
265
|
-
edits.push({ file: settingsFile, after: setAfter || null });
|
|
266
|
-
const ours = Object.keys(metadata).filter((k) => [metadata[k]].some((m) => m?.phantom === true || m?.pai === true));
|
|
267
|
-
if (ours.length)
|
|
268
|
-
edits.push({ file: meta, after: ours.length === Object.keys(metadata).length ? null : jsonEdit(meta, metaText, ours.map((k) => [[k], undefined])) });
|
|
269
|
-
return { edits, result: { settings: conf, on: false, warnings: edits.length ? [] : ['Aider was not set to Phantom AI by phantom; nothing changed'] } };
|
|
270
|
-
}
|
|
271
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
272
|
-
const confAfter = yamlSetTop(conf, yamlSetTop(conf, confText, 'openai-api-base', base), 'model', id);
|
|
273
|
-
// `phantom: true` marks the entries phantom wrote, so off removes only those.
|
|
274
|
-
const metaAfter = jsonEdit(meta, metaText, [[[id], { max_input_tokens: SETUP_CONTEXT_WINDOW, litellm_provider: 'openai', mode: 'chat', phantom: true }]]);
|
|
275
|
-
const setBase = setText === null ? '' : yamlRemoveOurs(settingsFile, setText);
|
|
276
|
-
const entry = [`- name: ${id}`, ' edit_format: diff', ' use_repo_map: true'].map((l) => `${l} ${SETUP_MARK}`);
|
|
277
|
-
const setAfter = (setBase === '' ? [] : [setBase.replace(/\n$/, '')]).concat(entry).join('\n') + '\n';
|
|
278
|
-
return {
|
|
279
|
-
edits: [
|
|
280
|
-
{ file: conf, after: confAfter },
|
|
281
|
-
{ file: meta, after: metaAfter },
|
|
282
|
-
{ file: settingsFile, after: setAfter },
|
|
283
|
-
],
|
|
284
|
-
result: { settings: conf, on: true, base_url: base, model: id, warnings: ['Aider reads its key from the shell; open a new terminal before running it'] },
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Cline, as Vercel's setup does it: `~/.cline/data/settings/providers.json`
|
|
289
|
-
* (mode 600), which Cline's CLI and editor extension share, gets an OpenAI
|
|
290
|
-
* Compatible provider at `/coding-agent/v1` and is made the one Cline uses.
|
|
291
|
-
* Cline reads its key only from this file, with no variable or command to
|
|
292
|
-
* point it at, so this is the one config phantom writes the key into. After
|
|
293
|
-
* `phantom keys rotate`, run setup again to update it.
|
|
294
|
-
*/
|
|
295
|
-
export function clineProvider(ctx, off) {
|
|
296
|
-
const file = path.join(ctx.home, '.cline', 'data', 'settings', 'providers.json');
|
|
297
|
-
const text = readText(file);
|
|
298
|
-
const data = jsonObject(file, text);
|
|
299
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
300
|
-
const current = data.providers?.['openai-compatible'];
|
|
301
|
-
const ours = Boolean(current?.settings?.baseUrl && /\/coding-agent\/v1$/.test(current.settings.baseUrl) && current.settings.baseUrl.startsWith(base.replace(/\/coding-agent\/v1$/, '')));
|
|
302
|
-
if (off) {
|
|
303
|
-
const changes = [[['providers', 'openai-compatible'], undefined]];
|
|
304
|
-
if (data.lastUsedProvider === 'openai-compatible')
|
|
305
|
-
changes.push([['lastUsedProvider'], undefined]);
|
|
306
|
-
return offResult('Cline', file, text, ours ? jsonOffText(ctx.env, file, text, changes) : text, true);
|
|
307
|
-
}
|
|
308
|
-
if (current && !ours)
|
|
309
|
-
unreadable(file, `already has an OpenAI Compatible provider at ${current.settings?.baseUrl ?? 'another address'}, which phantom leaves alone`);
|
|
310
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
311
|
-
const entry = {
|
|
312
|
-
settings: { provider: 'openai-compatible', apiKey: resolveApiKey(ctx.env), model, baseUrl: base, contextWindow: SETUP_CONTEXT_WINDOW },
|
|
313
|
-
updatedAt: new Date().toISOString(),
|
|
314
|
-
tokenSource: 'manual',
|
|
315
|
-
};
|
|
316
|
-
// A rerun with the same settings keeps the old timestamp, so nothing changes.
|
|
317
|
-
if (current && isDeepStrictEqual({ ...current, updatedAt: '' }, { ...entry, updatedAt: '' }))
|
|
318
|
-
entry.updatedAt = current.updatedAt;
|
|
319
|
-
const changes = [
|
|
320
|
-
...(text === null ? [[['version'], 1]] : []),
|
|
321
|
-
[['lastUsedProvider'], 'openai-compatible'],
|
|
322
|
-
[['providers', 'openai-compatible'], entry],
|
|
323
|
-
];
|
|
324
|
-
return {
|
|
325
|
-
edits: [{ ...jsonOn(ctx.env, file, text, changes, [['lastUsedProvider']]), mode: 0o600 }],
|
|
326
|
-
result: {
|
|
327
|
-
settings: file,
|
|
328
|
-
on: true,
|
|
329
|
-
base_url: base,
|
|
330
|
-
model,
|
|
331
|
-
warnings: ['Cline keeps the key in this file (mode 600); run phantom setup --agent cline --provider again after phantom keys rotate', 'In the editor extension, pick OpenAI Compatible under Settings, API Provider'],
|
|
332
|
-
},
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
// ── Gemini CLI ───────────────────────────────────────────────────────────────
|
|
336
|
-
/** Gemini CLI's folder: `.gemini` in `$GEMINI_CLI_HOME`, else in the home folder. */
|
|
337
|
-
export function geminiDir(env, home) {
|
|
338
|
-
return path.join(env.GEMINI_CLI_HOME?.trim() ? env.GEMINI_CLI_HOME : home, '.gemini');
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Gemini CLI speaks Google's API, which Phantom AI serves at `/gemini-cli`.
|
|
342
|
-
* The shell block sets GOOGLE_GEMINI_BASE_URL to it and GEMINI_API_KEY to
|
|
343
|
-
* the Phantom key; `settings.json` in Gemini CLI's folder picks API key
|
|
344
|
-
* sign-in (`security.auth.selectedType`) and the model (`model.name`).
|
|
345
|
-
* `--provider off` takes out a phantom model; the sign-in choice stays, and
|
|
346
|
-
* `phantom setup --restore` puts the file back as it was.
|
|
347
|
-
*/
|
|
348
|
-
export function geminiProvider(ctx, off) {
|
|
349
|
-
const file = path.join(geminiDir(ctx.env, ctx.home), 'settings.json');
|
|
350
|
-
const text = readText(file);
|
|
351
|
-
const settings = jsonObject(file, text);
|
|
352
|
-
if (off) {
|
|
353
|
-
const ours = typeof settings.model?.name === 'string' && settings.model.name.startsWith('phantom-');
|
|
354
|
-
const alone = Object.keys(settings.model ?? {}).length === 1;
|
|
355
|
-
const removals = ours ? [[alone ? ['model'] : ['model', 'name'], undefined]] : [];
|
|
356
|
-
// With a record the sign-in choice goes back too; without one (older setup) it stays, as before.
|
|
357
|
-
return offResult('Gemini CLI', file, text, text === null ? null : jsonOffText(ctx.env, file, text, removals), true);
|
|
358
|
-
}
|
|
359
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
360
|
-
const changes = [
|
|
361
|
-
[['security', 'auth', 'selectedType'], 'gemini-api-key'],
|
|
362
|
-
[['model', 'name'], model],
|
|
363
|
-
];
|
|
364
|
-
return {
|
|
365
|
-
edits: [jsonOn(ctx.env, file, text, changes)],
|
|
366
|
-
result: {
|
|
367
|
-
settings: file,
|
|
368
|
-
on: true,
|
|
369
|
-
base_url: agentBaseUrl(ctx.env, 'gemini-cli'),
|
|
370
|
-
model,
|
|
371
|
-
warnings: ['Gemini CLI reads its key from the shell; open a new terminal before running it. Other programs that read GEMINI_API_KEY get the Phantom key too'],
|
|
372
|
-
},
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
// ── Crush ────────────────────────────────────────────────────────────────────
|
|
376
|
-
/** Crush's config folder: `$CRUSH_GLOBAL_CONFIG`, else `crush` in the config folder. */
|
|
377
|
-
export function crushDir(env, home) {
|
|
378
|
-
return env.CRUSH_GLOBAL_CONFIG?.trim() ? env.CRUSH_GLOBAL_CONFIG : path.join(configHome(env, home), 'crush');
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Crush: `crush.json` in Crush's config folder gets a `phantom` provider at
|
|
382
|
-
* `/coding-agent/v1` whose key is `$PHANTOM_API_KEY`, which Crush expands
|
|
383
|
-
* when it loads, and phantom-1 as both its large and small model. Crush 0.99
|
|
384
|
-
* reads this file beside a `crushrc`.
|
|
385
|
-
*/
|
|
386
|
-
export function crushProvider(ctx, off) {
|
|
387
|
-
const file = path.join(crushDir(ctx.env, ctx.home), 'crush.json');
|
|
388
|
-
const text = readText(file);
|
|
389
|
-
const config = jsonObject(file, text);
|
|
390
|
-
const sizes = ['large', 'small'];
|
|
391
|
-
if (off) {
|
|
392
|
-
if (!config.providers?.phantom)
|
|
393
|
-
return offResult('Crush', file, text, text);
|
|
394
|
-
const changes = [Object.keys(config.providers).length === 1 ? [['providers'], undefined] : [['providers', 'phantom'], undefined]];
|
|
395
|
-
const mine = Object.keys(config.models ?? {}).filter((k) => sizes.includes(k) && config.models?.[k]?.provider === 'phantom');
|
|
396
|
-
if (mine.length && mine.length === Object.keys(config.models ?? {}).length)
|
|
397
|
-
changes.push([['models'], undefined]);
|
|
398
|
-
else
|
|
399
|
-
for (const k of mine)
|
|
400
|
-
changes.push([['models', k], undefined]);
|
|
401
|
-
return offResult('Crush', file, text, unlessEmpty(file, jsonOffText(ctx.env, file, text, changes)), true);
|
|
402
|
-
}
|
|
403
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
404
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
405
|
-
const changes = [
|
|
406
|
-
...(!text?.trim() ? [[['$schema'], 'https://charm.land/crush.json']] : []),
|
|
407
|
-
[
|
|
408
|
-
['providers', 'phantom'],
|
|
409
|
-
{
|
|
410
|
-
name: 'Phantom AI',
|
|
411
|
-
type: 'openai-compat',
|
|
412
|
-
base_url: base,
|
|
413
|
-
api_key: '$PHANTOM_API_KEY',
|
|
414
|
-
models: [{ id: model, name: model, context_window: SETUP_CONTEXT_WINDOW, default_max_tokens: SETUP_OUTPUT_TOKENS }],
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
...sizes.map((size) => [['models', size], { provider: 'phantom', model }]),
|
|
418
|
-
];
|
|
419
|
-
return { edits: [jsonOn(ctx.env, file, text, changes, sizes.map((size) => ['models', size]))], result: { settings: file, on: true, base_url: base, model, warnings: [] } };
|
|
420
|
-
}
|
|
421
|
-
// ── Qwen Code ────────────────────────────────────────────────────────────────
|
|
422
|
-
/** Qwen Code's folder: `$QWEN_HOME`, else `~/.qwen`. */
|
|
423
|
-
export function qwenDir(env, home) {
|
|
424
|
-
return env.QWEN_HOME?.trim() ? env.QWEN_HOME : path.join(home, '.qwen');
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Qwen Code: `settings.json` in its folder gets a model under
|
|
428
|
-
* `modelProviders.openai` at `/coding-agent/v1` that reads its key from
|
|
429
|
-
* PHANTOM_API_KEY (`envKey`), is picked as the model (`model.name`), and the
|
|
430
|
-
* OpenAI-compatible sign-in (`security.auth.selectedType`), so Qwen Code
|
|
431
|
-
* starts without asking. Its other models stay.
|
|
432
|
-
*/
|
|
433
|
-
export function qwenProvider(ctx, off) {
|
|
434
|
-
const file = path.join(qwenDir(ctx.env, ctx.home), 'settings.json');
|
|
435
|
-
const text = readText(file);
|
|
436
|
-
const config = jsonObject(file, text);
|
|
437
|
-
const list = config.modelProviders?.openai ?? [];
|
|
438
|
-
if (!Array.isArray(list))
|
|
439
|
-
unreadable(file, 'has modelProviders.openai as something other than a list');
|
|
440
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
441
|
-
const ours = (m) => m?.baseUrl === base;
|
|
442
|
-
const others = list.filter((m) => !ours(m));
|
|
443
|
-
const mineIds = list.filter(ours).map((m) => m.id);
|
|
444
|
-
if (off) {
|
|
445
|
-
if (others.length === list.length)
|
|
446
|
-
return offResult('Qwen Code', file, text, text);
|
|
447
|
-
const changes = [];
|
|
448
|
-
if (others.length)
|
|
449
|
-
changes.push([['modelProviders', 'openai'], others]);
|
|
450
|
-
else
|
|
451
|
-
changes.push(Object.keys(config.modelProviders ?? {}).length === 1 ? [['modelProviders'], undefined] : [['modelProviders', 'openai'], undefined]);
|
|
452
|
-
if (mineIds.includes(config.model?.name))
|
|
453
|
-
changes.push(Object.keys(config.model ?? {}).length === 1 ? [['model'], undefined] : [['model', 'name'], undefined]);
|
|
454
|
-
return offResult('Qwen Code', file, text, unlessEmpty(file, jsonOffText(ctx.env, file, text, changes)), true);
|
|
455
|
-
}
|
|
456
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
457
|
-
const entry = { id: model, name: `Phantom AI ${model}`, baseUrl: base, envKey: 'PHANTOM_API_KEY', generationConfig: { contextWindowSize: SETUP_CONTEXT_WINDOW } };
|
|
458
|
-
const changes = [
|
|
459
|
-
[['modelProviders', 'openai'], [entry, ...others]],
|
|
460
|
-
[['security', 'auth', 'selectedType'], 'openai'],
|
|
461
|
-
[['model', 'name'], model],
|
|
462
|
-
];
|
|
463
|
-
const tracked = [['security', 'auth', 'selectedType'], ['model', 'name']];
|
|
464
|
-
return { edits: [jsonOn(ctx.env, file, text, changes, tracked)], result: { settings: file, on: true, base_url: base, model, warnings: [] } };
|
|
465
|
-
}
|
|
466
|
-
// ── Kilo Code ────────────────────────────────────────────────────────────────
|
|
467
|
-
/** Kilo Code's config file: `kilo.jsonc` (or `kilo.json`) in `$XDG_CONFIG_HOME/kilo`, else `~/.config/kilo`. */
|
|
468
|
-
export function kiloFile(env, home) {
|
|
469
|
-
const dir = path.join(configHome(env, home), 'kilo');
|
|
470
|
-
return existsSync(path.join(dir, 'kilo.jsonc')) ? path.join(dir, 'kilo.jsonc') : path.join(dir, 'kilo.json');
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Kilo Code's CLI, a fork of opencode: its global config gets the same
|
|
474
|
-
* `phantom` provider opencode does, with the key as `{env:PHANTOM_API_KEY}`,
|
|
475
|
-
* and `phantom/<model>` as the model. Kilo resolves `{env:...}` only in the
|
|
476
|
-
* global file, which is the one written here.
|
|
477
|
-
*/
|
|
478
|
-
export function kiloProvider(ctx, off) {
|
|
479
|
-
const file = kiloFile(ctx.env, ctx.home);
|
|
480
|
-
const text = readText(file);
|
|
481
|
-
const config = jsonObject(file, text);
|
|
482
|
-
if (off) {
|
|
483
|
-
if (!config.provider?.phantom)
|
|
484
|
-
return offResult('Kilo Code', file, text, text);
|
|
485
|
-
const changes = [Object.keys(config.provider).length === 1 ? [['provider'], undefined] : [['provider', 'phantom'], undefined]];
|
|
486
|
-
if (typeof config.model === 'string' && config.model.startsWith('phantom/'))
|
|
487
|
-
changes.push([['model'], undefined]);
|
|
488
|
-
return offResult('Kilo Code', file, text, unlessEmpty(file, jsonOffText(ctx.env, file, text, changes)), true);
|
|
489
|
-
}
|
|
490
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
491
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
492
|
-
const changes = [
|
|
493
|
-
...(!text?.trim() ? [[['$schema'], 'https://app.kilo.ai/config.json']] : []),
|
|
494
|
-
[
|
|
495
|
-
['provider', 'phantom'],
|
|
496
|
-
{
|
|
497
|
-
npm: '@ai-sdk/openai-compatible',
|
|
498
|
-
name: 'Phantom AI',
|
|
499
|
-
options: { baseURL: base, apiKey: '{env:PHANTOM_API_KEY}' },
|
|
500
|
-
// Kilo turns off compaction for a model without limits.
|
|
501
|
-
models: { [model]: { name: model, tool_call: true, reasoning: true, limit: { context: SETUP_CONTEXT_WINDOW, output: SETUP_OUTPUT_TOKENS } } },
|
|
502
|
-
},
|
|
503
|
-
],
|
|
504
|
-
[['model'], `phantom/${model}`],
|
|
505
|
-
];
|
|
506
|
-
return { edits: [jsonOn(ctx.env, file, text, changes, [['model']])], result: { settings: file, on: true, base_url: base, model: `phantom/${model}`, warnings: [] } };
|
|
507
|
-
}
|
|
508
|
-
// ── Kimi Code ────────────────────────────────────────────────────────────────
|
|
509
|
-
/** Kimi Code's folder: `$KIMI_CODE_HOME`, else `~/.kimi-code`. */
|
|
510
|
-
export function kimiDir(env, home) {
|
|
511
|
-
return env.KIMI_CODE_HOME?.trim() ? env.KIMI_CODE_HOME : path.join(home, '.kimi-code');
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Kimi Code CLI: `config.toml` in its folder gets a `phantom` provider at
|
|
515
|
-
* `/coding-agent/v1` that reads its key from PHANTOM_API_KEY
|
|
516
|
-
* (`api_key_env`), a `phantom/<model>` model, and that model as
|
|
517
|
-
* `default_model`. Each run starts from the file without phantom's lines, so
|
|
518
|
-
* a new `--model` replaces the old one.
|
|
519
|
-
*/
|
|
520
|
-
export function kimiProvider(ctx, off) {
|
|
521
|
-
const file = path.join(kimiDir(ctx.env, ctx.home), 'config.toml');
|
|
522
|
-
const text = readText(file);
|
|
523
|
-
const before = text === null ? null : tomlRemoveOurs(file, text);
|
|
524
|
-
if (off)
|
|
525
|
-
return offResult('Kimi Code', file, text, before);
|
|
526
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
527
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
528
|
-
const alias = `phantom/${model}`;
|
|
529
|
-
let t = tomlSet(file, before ?? '', [], 'default_model', JSON.stringify(alias));
|
|
530
|
-
for (const [k, v] of [['type', '"openai"'], ['base_url', JSON.stringify(base)], ['api_key_env', '"PHANTOM_API_KEY"']])
|
|
531
|
-
t = tomlSet(file, t, ['providers', 'phantom'], k, v);
|
|
532
|
-
for (const [k, v] of [['provider', '"phantom"'], ['model', JSON.stringify(model)], ['max_context_size', String(SETUP_CONTEXT_WINDOW)], ['capabilities', '["thinking", "tool_use"]']]) {
|
|
533
|
-
t = tomlSet(file, t, ['models', alias], k, v);
|
|
534
|
-
}
|
|
535
|
-
return { edits: [{ file, after: t }], result: { settings: file, on: true, base_url: base, model: alias, warnings: [] } };
|
|
536
|
-
}
|
|
537
|
-
// ── Droid ────────────────────────────────────────────────────────────────────
|
|
538
|
-
/** The name phantom gives its model in Droid. Droid calls it `custom:Phantom-AI-<n>`. */
|
|
539
|
-
const DROID_NAME = 'Phantom AI';
|
|
540
|
-
/**
|
|
541
|
-
* Factory's Droid: `~/.factory/settings.json` gets a custom model at
|
|
542
|
-
* `/coding-agent/v1` (chat completions) with the key as `${PHANTOM_API_KEY}`,
|
|
543
|
-
* which Droid expands, and that model as `model`. Droid names a custom
|
|
544
|
-
* model by its place in `customModels`, so phantom's goes last, or stays
|
|
545
|
-
* where it was, and the user's own keep their names.
|
|
546
|
-
*/
|
|
547
|
-
export function droidProvider(ctx, off) {
|
|
548
|
-
const file = path.join(ctx.home, '.factory', 'settings.json');
|
|
549
|
-
const text = readText(file);
|
|
550
|
-
const config = jsonObject(file, text);
|
|
551
|
-
const list = config.customModels ?? [];
|
|
552
|
-
if (!Array.isArray(list))
|
|
553
|
-
unreadable(file, 'has customModels as something other than a list');
|
|
554
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
555
|
-
const at = list.findIndex((m) => m?.baseUrl === base);
|
|
556
|
-
const mine = (m) => typeof m === 'string' && m.startsWith(`custom:${DROID_NAME.replace(/ /g, '-')}-`);
|
|
557
|
-
if (off) {
|
|
558
|
-
if (at === -1)
|
|
559
|
-
return offResult('Droid', file, text, text);
|
|
560
|
-
const rest = list.filter((_, i) => i !== at);
|
|
561
|
-
const changes = [[['customModels'], rest.length ? rest : undefined]];
|
|
562
|
-
if (mine(config.model))
|
|
563
|
-
changes.push([['model'], undefined]);
|
|
564
|
-
return offResult('Droid', file, text, unlessEmpty(file, jsonOffText(ctx.env, file, text, changes)), true);
|
|
565
|
-
}
|
|
566
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
567
|
-
const entry = { model, displayName: DROID_NAME, baseUrl: base, apiKey: '${PHANTOM_API_KEY}', provider: 'generic-chat-completion-api', maxOutputTokens: SETUP_OUTPUT_TOKENS };
|
|
568
|
-
const index = at === -1 ? list.length : at;
|
|
569
|
-
const next = [...list];
|
|
570
|
-
next[index] = entry;
|
|
571
|
-
const id = `custom:${DROID_NAME.replace(/ /g, '-')}-${index}`;
|
|
572
|
-
const changes = [
|
|
573
|
-
[['customModels'], next],
|
|
574
|
-
[['model'], id],
|
|
575
|
-
];
|
|
576
|
-
return { edits: [jsonOn(ctx.env, file, text, changes, [['model']])], result: { settings: file, on: true, base_url: base, model: id, warnings: [] } };
|
|
577
|
-
}
|
|
578
|
-
// ── Mistral Vibe ─────────────────────────────────────────────────────────────
|
|
579
|
-
/**
|
|
580
|
-
* Mistral Vibe: `~/.vibe/config.toml` gets a `phantom` provider at
|
|
581
|
-
* `/coding-agent/v1` that reads its key from PHANTOM_API_KEY
|
|
582
|
-
* (`api_key_env_var`), a model on it, and that model as `active_model`.
|
|
583
|
-
* Providers and models are lists of tables (`[[providers]]`), so phantom's
|
|
584
|
-
* go at the end as marked lines, which `--provider off` takes out again.
|
|
585
|
-
*/
|
|
586
|
-
export function vibeProvider(ctx, off) {
|
|
587
|
-
const file = path.join(ctx.home, '.vibe', 'config.toml');
|
|
588
|
-
const text = readText(file);
|
|
589
|
-
const before = text === null ? null : tomlRemoveOurs(file, text);
|
|
590
|
-
if (off)
|
|
591
|
-
return offResult('Mistral Vibe', file, text, before);
|
|
592
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
593
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
594
|
-
const block = [
|
|
595
|
-
'[[providers]]',
|
|
596
|
-
'name = "phantom"',
|
|
597
|
-
`api_base = ${JSON.stringify(base)}`,
|
|
598
|
-
'api_key_env_var = "PHANTOM_API_KEY"',
|
|
599
|
-
'backend = "generic"',
|
|
600
|
-
'api_style = "openai"',
|
|
601
|
-
'',
|
|
602
|
-
'[[models]]',
|
|
603
|
-
`name = ${JSON.stringify(model)}`,
|
|
604
|
-
'provider = "phantom"',
|
|
605
|
-
`alias = ${JSON.stringify(model)}`,
|
|
606
|
-
].map((l) => (l ? `${l} ${SETUP_MARK}` : l));
|
|
607
|
-
const body = (before ?? '').replace(/\s*$/, '');
|
|
608
|
-
const t = tomlSet(file, `${body ? `${body}\n\n` : ''}${block.join('\n')}\n`, [], 'active_model', JSON.stringify(model));
|
|
609
|
-
return { edits: [{ file, after: t }], result: { settings: file, on: true, base_url: base, model, warnings: [] } };
|
|
610
|
-
}
|
|
611
|
-
// ── Zed ──────────────────────────────────────────────────────────────────────
|
|
612
|
-
/**
|
|
613
|
-
* Zed's agent panel: `settings.json` in Zed's config folder gets an OpenAI
|
|
614
|
-
* compatible provider named `phantom` at `/coding-agent/v1`, and its model
|
|
615
|
-
* as the agent's default. Zed reads the key for a provider named `phantom`
|
|
616
|
-
* from PHANTOM_API_KEY by itself, so no key goes in the file.
|
|
617
|
-
*/
|
|
618
|
-
export function zedProvider(ctx, off) {
|
|
619
|
-
const file = path.join(configHome(ctx.env, ctx.home), 'zed', 'settings.json');
|
|
620
|
-
const text = readText(file);
|
|
621
|
-
const config = jsonObject(file, text);
|
|
622
|
-
if (off) {
|
|
623
|
-
if (!config.language_models?.openai_compatible?.phantom)
|
|
624
|
-
return offResult('Zed', file, text, text);
|
|
625
|
-
const changes = [[['language_models', 'openai_compatible', 'phantom'], undefined]];
|
|
626
|
-
if (config.agent?.default_model?.provider === 'phantom')
|
|
627
|
-
changes.push([['agent', 'default_model'], undefined]);
|
|
628
|
-
return offResult('Zed', file, text, jsonOffText(ctx.env, file, text, changes, [['language_models', 'openai_compatible']]), true);
|
|
629
|
-
}
|
|
630
|
-
const base = agentBaseUrl(ctx.env, 'coding-agent');
|
|
631
|
-
const model = ctx.model ?? SETUP_MODEL;
|
|
632
|
-
const changes = [
|
|
633
|
-
[
|
|
634
|
-
['language_models', 'openai_compatible', 'phantom'],
|
|
635
|
-
{ api_url: base, available_models: [{ name: model, display_name: `Phantom AI ${model}`, max_tokens: SETUP_CONTEXT_WINDOW, capabilities: { tools: true } }] },
|
|
636
|
-
],
|
|
637
|
-
[['agent', 'default_model'], { provider: 'phantom', model }],
|
|
638
|
-
];
|
|
639
|
-
return {
|
|
640
|
-
edits: [jsonOn(ctx.env, file, text, changes, [['agent', 'default_model']])],
|
|
641
|
-
result: { settings: file, on: true, base_url: base, model, warnings: ['Zed reads PHANTOM_API_KEY from your login shell; quit and reopen Zed'] },
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
// ── Registry ─────────────────────────────────────────────────────────────────
|
|
645
|
-
/**
|
|
646
|
-
* The agents `phantom setup` knows, in the order setup runs them. Adding an agent
|
|
647
|
-
* is one entry here and its name in {@link SetupAgent}: help, errors and
|
|
648
|
-
* `--agent` read their names from this list.
|
|
649
|
-
* @deprecated Compatibility export. Use {@link planSetup}, {@link applySetup}, and {@link restoreSetup} for agent setup.
|
|
650
|
-
*/
|
|
651
|
-
export const SETUP_AGENTS = {
|
|
652
|
-
/** pi. It uses the CLI through the skill. */
|
|
653
|
-
pi: {
|
|
654
|
-
label: 'pi',
|
|
655
|
-
/** ~/.pi */
|
|
656
|
-
home: '.pi',
|
|
657
|
-
/** ~/.agents/skills */
|
|
658
|
-
skills: '.agents/skills',
|
|
659
|
-
},
|
|
660
|
-
/** Codex. */
|
|
661
|
-
codex: {
|
|
662
|
-
label: 'Codex',
|
|
663
|
-
/** ~/.codex, or $CODEX_HOME */
|
|
664
|
-
home: '.codex',
|
|
665
|
-
detect: (env, home) => existsSync(codexDir(env, home)),
|
|
666
|
-
/** ~/.agents/skills */
|
|
667
|
-
skills: '.agents/skills',
|
|
668
|
-
provider: codexProvider,
|
|
669
|
-
shellEnv: () => ({}),
|
|
670
|
-
},
|
|
671
|
-
/** Claude Code. Needs no shell block: it runs `phantom key show` itself. */
|
|
672
|
-
claude: {
|
|
673
|
-
label: 'Claude Code',
|
|
674
|
-
/** ~/.claude, or $CLAUDE_CONFIG_DIR */
|
|
675
|
-
home: '.claude',
|
|
676
|
-
detect: (env, home) => existsSync(claudeDir(env, home)),
|
|
677
|
-
/** ~/.claude/skills */
|
|
678
|
-
skills: '.claude/skills',
|
|
679
|
-
provider: (ctx, off) => claudePlan(ctx.env, { off, model: ctx.model, onPath: ctx.onPath }),
|
|
680
|
-
},
|
|
681
|
-
/** Cursor. Its models are set on its settings screen; the shell block gives it PHANTOM_API_KEY to copy. */
|
|
682
|
-
cursor: {
|
|
683
|
-
label: 'Cursor',
|
|
684
|
-
/** ~/.cursor */
|
|
685
|
-
home: '.cursor',
|
|
686
|
-
/** ~/.cursor/skills */
|
|
687
|
-
skills: '.cursor/skills',
|
|
688
|
-
// Three short steps; the key gets copied without being shown (phantom's menu has "Copy my key").
|
|
689
|
-
provider: manualProvider('Cursor Settings, Models', (ctx) => [
|
|
690
|
-
'Open Cursor Settings (Cmd+Shift+J on macOS), then Models.',
|
|
691
|
-
`Paste your Phantom AI key under OpenAI API Key (copy it with "Copy my key" in phantom's menu, or phantom keys show --copy), then turn on Override OpenAI Base URL and set it to ${agentBaseUrl(ctx.env, 'cursor')}`,
|
|
692
|
-
`Under Add model, add ${ctx.model ?? SETUP_MODEL}.`,
|
|
693
|
-
], "While the override is on, Cursor's own non-OpenAI models stop working; turn it off to go back. Tab completions never use your key."),
|
|
694
|
-
shellEnv: () => ({}),
|
|
695
|
-
},
|
|
696
|
-
/** opencode. */
|
|
697
|
-
opencode: {
|
|
698
|
-
label: 'opencode',
|
|
699
|
-
/** ~/.config/opencode/opencode.json, or under $XDG_CONFIG_HOME */
|
|
700
|
-
home: '.config/opencode/opencode.json',
|
|
701
|
-
detect: (env, home) => existsSync(opencodeFile(env, home)),
|
|
702
|
-
provider: opencodeProvider,
|
|
703
|
-
shellEnv: () => ({}),
|
|
704
|
-
},
|
|
705
|
-
/** Continue, in the `cn` CLI and the editor. */
|
|
706
|
-
continue: {
|
|
707
|
-
label: 'Continue',
|
|
708
|
-
/** ~/.continue */
|
|
709
|
-
home: '.continue',
|
|
710
|
-
provider: continueProvider,
|
|
711
|
-
shellEnv: () => ({}),
|
|
712
|
-
},
|
|
713
|
-
/** Goose. */
|
|
714
|
-
goose: {
|
|
715
|
-
label: 'Goose',
|
|
716
|
-
/** ~/.config/goose, or under $XDG_CONFIG_HOME */
|
|
717
|
-
home: '.config/goose',
|
|
718
|
-
detect: (env, home) => existsSync(path.join(configHome(env, home), 'goose')),
|
|
719
|
-
provider: gooseProvider,
|
|
720
|
-
shellEnv: () => ({}),
|
|
721
|
-
},
|
|
722
|
-
/** Aider. */
|
|
723
|
-
aider: {
|
|
724
|
-
label: 'Aider',
|
|
725
|
-
/** ~/.aider, or ~/.aider.conf.yml */
|
|
726
|
-
home: '.aider',
|
|
727
|
-
detect: (env, home) => existsSync(path.join(home, '.aider')) || existsSync(path.join(home, '.aider.conf.yml')),
|
|
728
|
-
provider: aiderProvider,
|
|
729
|
-
shellEnv: () => ({ AIDER_OPENAI_API_KEY: '$PHANTOM_API_KEY' }),
|
|
730
|
-
},
|
|
731
|
-
/** GitHub Copilot CLI. Set up by its COPILOT_PROVIDER_ variables, which make it use a model provider of your own. */
|
|
732
|
-
copilot: {
|
|
733
|
-
label: 'GitHub Copilot CLI',
|
|
734
|
-
/** ~/.copilot, or $COPILOT_HOME */
|
|
735
|
-
home: '.copilot',
|
|
736
|
-
detect: (env, home) => existsSync(copilotDir(env, home)),
|
|
737
|
-
provider: copilotProvider,
|
|
738
|
-
shellEnv: (ctx) => ({
|
|
739
|
-
COPILOT_PROVIDER_BASE_URL: agentBaseUrl(ctx.env, 'coding-agent'),
|
|
740
|
-
COPILOT_PROVIDER_API_KEY: '$PHANTOM_API_KEY',
|
|
741
|
-
COPILOT_MODEL: ctx.model ?? SETUP_MODEL,
|
|
742
|
-
}),
|
|
743
|
-
},
|
|
744
|
-
/** Cline, in its CLI and editor extension. */
|
|
745
|
-
cline: {
|
|
746
|
-
label: 'Cline',
|
|
747
|
-
/** ~/.cline */
|
|
748
|
-
home: '.cline',
|
|
749
|
-
provider: clineProvider,
|
|
750
|
-
},
|
|
751
|
-
/** Gemini CLI. Its address and key come from the shell block; settings.json picks the sign-in and model. */
|
|
752
|
-
gemini: {
|
|
753
|
-
label: 'Gemini CLI',
|
|
754
|
-
/** ~/.gemini, or under $GEMINI_CLI_HOME */
|
|
755
|
-
home: '.gemini',
|
|
756
|
-
detect: (env, home) => existsSync(geminiDir(env, home)),
|
|
757
|
-
/** ~/.agents/skills, which Gemini CLI reads as well as ~/.gemini/skills */
|
|
758
|
-
skills: '.agents/skills',
|
|
759
|
-
provider: geminiProvider,
|
|
760
|
-
shellEnv: (ctx) => ({
|
|
761
|
-
GOOGLE_GEMINI_BASE_URL: agentBaseUrl(ctx.env, 'gemini-cli'),
|
|
762
|
-
GEMINI_API_KEY: '$PHANTOM_API_KEY',
|
|
763
|
-
}),
|
|
764
|
-
},
|
|
765
|
-
/** Crush. */
|
|
766
|
-
crush: {
|
|
767
|
-
label: 'Crush',
|
|
768
|
-
/** ~/.config/crush, or $CRUSH_GLOBAL_CONFIG */
|
|
769
|
-
home: '.config/crush',
|
|
770
|
-
detect: (env, home) => existsSync(crushDir(env, home)),
|
|
771
|
-
/** ~/.agents/skills */
|
|
772
|
-
skills: '.agents/skills',
|
|
773
|
-
provider: crushProvider,
|
|
774
|
-
shellEnv: () => ({}),
|
|
775
|
-
},
|
|
776
|
-
/** Qwen Code. */
|
|
777
|
-
qwen: {
|
|
778
|
-
label: 'Qwen Code',
|
|
779
|
-
/** ~/.qwen, or $QWEN_HOME */
|
|
780
|
-
home: '.qwen',
|
|
781
|
-
detect: (env, home) => existsSync(qwenDir(env, home)),
|
|
782
|
-
/** ~/.agents/skills */
|
|
783
|
-
skills: '.agents/skills',
|
|
784
|
-
provider: qwenProvider,
|
|
785
|
-
shellEnv: () => ({}),
|
|
786
|
-
},
|
|
787
|
-
/** Kilo Code's CLI. */
|
|
788
|
-
kilo: {
|
|
789
|
-
label: 'Kilo Code',
|
|
790
|
-
/** ~/.config/kilo, or under $XDG_CONFIG_HOME */
|
|
791
|
-
home: '.config/kilo',
|
|
792
|
-
detect: (env, home) => existsSync(path.join(configHome(env, home), 'kilo')),
|
|
793
|
-
/** ~/.agents/skills */
|
|
794
|
-
skills: '.agents/skills',
|
|
795
|
-
provider: kiloProvider,
|
|
796
|
-
shellEnv: () => ({}),
|
|
797
|
-
},
|
|
798
|
-
/** Kimi Code CLI. */
|
|
799
|
-
kimi: {
|
|
800
|
-
label: 'Kimi Code',
|
|
801
|
-
/** ~/.kimi-code, or $KIMI_CODE_HOME */
|
|
802
|
-
home: '.kimi-code',
|
|
803
|
-
detect: (env, home) => existsSync(kimiDir(env, home)),
|
|
804
|
-
/** ~/.agents/skills */
|
|
805
|
-
skills: '.agents/skills',
|
|
806
|
-
provider: kimiProvider,
|
|
807
|
-
shellEnv: () => ({}),
|
|
808
|
-
},
|
|
809
|
-
/** Factory's Droid. */
|
|
810
|
-
droid: {
|
|
811
|
-
label: 'Droid',
|
|
812
|
-
/** ~/.factory */
|
|
813
|
-
home: '.factory',
|
|
814
|
-
/** ~/.factory/skills */
|
|
815
|
-
skills: '.factory/skills',
|
|
816
|
-
provider: droidProvider,
|
|
817
|
-
shellEnv: () => ({}),
|
|
818
|
-
},
|
|
819
|
-
/** Mistral Vibe. */
|
|
820
|
-
vibe: {
|
|
821
|
-
label: 'Mistral Vibe',
|
|
822
|
-
/** ~/.vibe */
|
|
823
|
-
home: '.vibe',
|
|
824
|
-
provider: vibeProvider,
|
|
825
|
-
shellEnv: () => ({}),
|
|
826
|
-
},
|
|
827
|
-
/** Zed's agent panel. It reads PHANTOM_API_KEY from the login shell. */
|
|
828
|
-
zed: {
|
|
829
|
-
label: 'Zed',
|
|
830
|
-
/** ~/.config/zed, or under $XDG_CONFIG_HOME */
|
|
831
|
-
home: '.config/zed',
|
|
832
|
-
detect: (env, home) => existsSync(path.join(configHome(env, home), 'zed')),
|
|
833
|
-
/** ~/.agents/skills */
|
|
834
|
-
skills: '.agents/skills',
|
|
835
|
-
provider: zedProvider,
|
|
836
|
-
shellEnv: () => ({}),
|
|
837
|
-
},
|
|
838
|
-
/** VS Code's chat. Its Custom Endpoint models are added on its Language Models screen. */
|
|
839
|
-
vscode: {
|
|
840
|
-
label: 'VS Code',
|
|
841
|
-
/** ~/.vscode */
|
|
842
|
-
home: '.vscode',
|
|
843
|
-
provider: manualProvider('VS Code, Chat: Manage Language Models', (ctx) => [
|
|
844
|
-
'In VS Code, run Chat: Manage Language Models from the Command Palette, then Add Models, Custom Endpoint.',
|
|
845
|
-
'Name the group Phantom AI, paste your Phantom AI key (copy it with "Copy my key" in phantom\'s menu, or phantom keys show --copy), and pick Chat Completions.',
|
|
846
|
-
`In the chatLanguageModels.json file VS Code opens, set the model's id to ${ctx.model ?? SETUP_MODEL}, its url to ${agentBaseUrl(ctx.env, 'coding-agent')}/chat/completions, and toolCalling to true, then save.`,
|
|
847
|
-
]),
|
|
848
|
-
},
|
|
849
|
-
/** JetBrains AI Assistant, in IntelliJ IDEA, PyCharm and the other JetBrains editors. */
|
|
850
|
-
jetbrains: {
|
|
851
|
-
label: 'JetBrains AI Assistant',
|
|
852
|
-
/** ~/Library/Application Support/JetBrains on macOS, ~/.config/JetBrains elsewhere */
|
|
853
|
-
home: 'Library/Application Support/JetBrains',
|
|
854
|
-
detect: (env, home) => existsSync(path.join(home, 'Library', 'Application Support', 'JetBrains')) || existsSync(path.join(configHome(env, home), 'JetBrains')),
|
|
855
|
-
provider: manualProvider('Settings, Tools, AI Assistant, Providers & API keys', (ctx) => [
|
|
856
|
-
'In your JetBrains editor, open Settings, then Tools, AI Assistant, Providers & API keys.',
|
|
857
|
-
`Under OpenAI-compatible, set the URL to ${agentBaseUrl(ctx.env, 'coding-agent')}, paste your Phantom AI key (copy it with "Copy my key" in phantom's menu, or phantom keys show --copy), and turn on Tool calling.`,
|
|
858
|
-
`Pick ${ctx.model ?? SETUP_MODEL} in the AI Assistant chat.`,
|
|
859
|
-
]),
|
|
860
|
-
},
|
|
861
|
-
/** Warp. Its custom inference endpoint is set on its settings screen. */
|
|
862
|
-
warp: {
|
|
863
|
-
label: 'Warp',
|
|
864
|
-
/** ~/.warp */
|
|
865
|
-
home: '.warp',
|
|
866
|
-
provider: manualProvider('Warp Settings', (ctx) => [
|
|
867
|
-
'In Warp, open Settings and search for "inference endpoint".',
|
|
868
|
-
`Set the endpoint to ${agentBaseUrl(ctx.env, 'coding-agent')}, paste your Phantom AI key (copy it with "Copy my key" in phantom's menu, or phantom keys show --copy), and add the model ${ctx.model ?? SETUP_MODEL}.`,
|
|
869
|
-
], 'Warp uses a custom endpoint for agents that run on this computer only.'),
|
|
870
|
-
},
|
|
871
|
-
/** Trae. Its custom models are added on its settings screen. */
|
|
872
|
-
trae: {
|
|
873
|
-
label: 'Trae',
|
|
874
|
-
/** ~/.trae */
|
|
875
|
-
home: '.trae',
|
|
876
|
-
provider: manualProvider('Trae Settings, Models', (ctx) => [
|
|
877
|
-
'In Trae, open Settings, then Models, Add Model, Custom Model.',
|
|
878
|
-
`Pick the OpenAI API format, set the request URL to ${agentBaseUrl(ctx.env, 'coding-agent')}, the model id to ${ctx.model ?? SETUP_MODEL}, and paste your Phantom AI key (copy it with "Copy my key" in phantom's menu, or phantom keys show --copy).`,
|
|
879
|
-
]),
|
|
880
|
-
},
|
|
881
|
-
};
|
|
882
|
-
export const SETUP_NAMES = Object.keys(SETUP_AGENTS);
|
|
883
|
-
/** `a, b or c`. */
|
|
884
|
-
export function orList(items) {
|
|
885
|
-
return items.length < 2 ? items.join('') : `${items.slice(0, -1).join(', ')} or ${items[items.length - 1]}`;
|
|
886
|
-
}
|