@phantomcodes/cli 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/run.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { VERSION } from "../core/version.mjs";
2
2
  import { nodeTrustWarning } from "../core/node-trust.mjs";
3
- import { die, NO_KEY } from "../core/errors.mjs";
3
+ import { die } from "../core/errors.mjs";
4
4
  import { colorOn, fitText } from "../core/style.mjs";
5
5
  import { ALIASES, closestCommand, commandFromWords, startScreen } from "./start.mjs";
6
6
  import { BackToMenu } from "../core/pick.mjs";
7
7
  import { runApp } from "./app.mjs";
8
8
  import { handleError, parseFlags, pickIo } from "../core/helpers.mjs";
9
- import { resolveApiKey } from "../keys/saved.mjs";
9
+ import { noKeyMessage, resolveApiKey } from "../keys/saved.mjs";
10
10
  import { COMMANDS } from "./commands.mjs";
11
11
  import { HELP, PRIMARY_HELP } from "./help.mjs";
12
12
  import { LEGACY_SETUP_HINT, legacySetupFound } from "../setup/legacy.mjs";
@@ -101,7 +101,7 @@ export async function run(argv = process.argv.slice(2), env = process.env, io =
101
101
  (command.keyless?.some((flag) => own.slice(1).some((arg) => arg === flag || arg.startsWith(flag + '='))) ?? false);
102
102
  const apiKey = keyless ? '' : resolveApiKey(env);
103
103
  if (!apiKey && !keyless)
104
- die(NO_KEY);
104
+ die(noKeyMessage(env));
105
105
  const subcommand = argv[1] && !argv[1].startsWith('--') ? argv[1] : undefined;
106
106
  const flagArgs = subcommand ? argv.slice(2) : argv.slice(1);
107
107
  // Flags after -- belong to the agent phantom starts, so only the ones before it are checked.
@@ -1,2 +1,2 @@
1
1
  /** This release of phantom. `npm version` keeps it equal to the version in package.json. */
2
- export declare const VERSION = "1.6.1";
2
+ export declare const VERSION = "1.6.2";
@@ -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.6.1';
2
+ export const VERSION = '1.6.2';
@@ -65,6 +65,12 @@ export declare function listNamedKeys(env: Env): {
65
65
  id: string;
66
66
  }>;
67
67
  };
68
+ /**
69
+ * What to say when a command needs a key and has none. Keys saved only by
70
+ * name (`phantom login --save ci`) don't run unless PHANTOM_KEY_NAME names one,
71
+ * so the message lists them instead of saying there is no key at all.
72
+ */
73
+ export declare function noKeyMessage(env: Env): string;
68
74
  /** The default key, the one `phantom keys create` saves when no name is given, or null when none is saved. */
69
75
  export declare function defaultKey(env: Env): string | null;
70
76
  /** Saves the default key, the one used when neither PHANTOM_KEY_NAME nor PHANTOM_API_KEY is set. */
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { existsSync, readdirSync } from 'node:fs';
4
- import { die } from "../core/errors.mjs";
4
+ import { die, NO_KEY } from "../core/errors.mjs";
5
5
  import { stateDir } from "../core/state.mjs";
6
6
  import { writeSecret, readSecret, removeSecret } from "../core/secrets.mjs";
7
7
  /**
@@ -107,6 +107,18 @@ export function listNamedKeys(env) {
107
107
  .map((name) => ({ name, id: keyId(readSecret(env, path.join(dir, name))) }));
108
108
  return { keys };
109
109
  }
110
+ /**
111
+ * What to say when a command needs a key and has none. Keys saved only by
112
+ * name (`phantom login --save ci`) don't run unless PHANTOM_KEY_NAME names one,
113
+ * so the message lists them instead of saying there is no key at all.
114
+ */
115
+ export function noKeyMessage(env) {
116
+ const dir = path.join(stateDir(env), 'keys');
117
+ const names = existsSync(dir) ? readdirSync(dir).filter((n) => KEY_NAME.test(n)).sort() : [];
118
+ if (!names.length)
119
+ return NO_KEY;
120
+ return `No default Phantom key. Keys saved by name: ${names.join(', ')}. Run as one with PHANTOM_KEY_NAME=${names[0]}, or run phantom login to sign in.`;
121
+ }
110
122
  /** The default key, the one `phantom keys create` saves when no name is given, or null when none is saved. */
111
123
  export function defaultKey(env) {
112
124
  return existsSync(keyPath(env)) ? readSecret(env, keyPath(env)).trim() : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantomcodes/cli",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Connects Claude Code, Codex, pi and other coding agents to Phantom AI, an OpenAI-compatible API, and manages your keys, credit and spending caps from the terminal.",
5
5
  "keywords": [
6
6
  "phantom",