@oneie/cli 5.3.3 → 5.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "5.3.3",
3
+ "version": "5.3.5",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,4 +51,17 @@ export declare function provisionLocalWallet(opts: {
51
51
  addresses?: Record<string, string>;
52
52
  error?: string;
53
53
  }>;
54
+ /**
55
+ * The wallet lines of init's receipt. Every command in them must run as printed:
56
+ * `cli` is `npx oneie` unless this process came in through the `one` bin (under
57
+ * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
58
+ * whenever the vault is not in the folder `wallet open` / `wallet paper` default
59
+ * to (`init --dir X` seals it in X).
60
+ */
61
+ export declare function initWalletReceipt(wallet: Awaited<ReturnType<typeof provisionLocalWallet>>, o: {
62
+ workspace: string;
63
+ dir: string;
64
+ vaultDir: string;
65
+ cli: string;
66
+ }): Record<string, string>;
54
67
  export declare function initCmd(): Command;
package/dist/src/init.js CHANGED
@@ -15,6 +15,7 @@ import { writeKeyFolder } from './lib/keyfile.js';
15
15
  import { KEY_FILE, CONFIG_DIR, writeMachineKey } from './lib/paths.js';
16
16
  import { walletFor, writeKeysFile, registerAgentWallet, sealWallet, promptSecret } from './wallet.js';
17
17
  import { writeVaultFolder, vaultPath } from './lib/vaultfile.js';
18
+ import { cliPrefix } from './lib/invoked-as.js';
18
19
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
19
20
  function out(cmd, data) {
20
21
  const isJson = cmd.parent?.opts().json;
@@ -104,6 +105,27 @@ export async function provisionLocalWallet(opts) {
104
105
  return { ok: false, file: target, error: err.message };
105
106
  }
106
107
  }
108
+ /**
109
+ * The wallet lines of init's receipt. Every command in them must run as printed:
110
+ * `cli` is `npx oneie` unless this process came in through the `one` bin (under
111
+ * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
112
+ * whenever the vault is not in the folder `wallet open` / `wallet paper` default
113
+ * to (`init --dir X` seals it in X).
114
+ */
115
+ export function initWalletReceipt(wallet, o) {
116
+ const atVault = resolve(o.vaultDir) === resolve(o.dir) ? '' : ` --dir ${o.vaultDir}`;
117
+ return {
118
+ wallet: wallet.sealed
119
+ ? `${wallet.file} (sealed with your passphrase — \`${o.cli} wallet open${atVault}\` to read it, \`${o.cli} wallet paper${atVault}\` to back it up)`
120
+ : `${wallet.file} (0600 PLAINTEXT — the 24 words and keys; back it up, never commit it)`,
121
+ ...(wallet.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
122
+ ...(!wallet.ok ? { wallet_error: wallet.sealed === false
123
+ ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --from ${wallet.file}`
124
+ : wallet.sealed === true
125
+ ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --dir ${o.vaultDir}`
126
+ : `${wallet.error}` } : {}),
127
+ };
128
+ }
107
129
  export function initCmd() {
108
130
  const cmd = new Command('init')
109
131
  .description('Provision a new workspace in one command — no account required')
@@ -233,15 +255,7 @@ export function initCmd() {
233
255
  ...(expiresAt ? { expires: new Date(expiresAt * 1000).toISOString() } : {}),
234
256
  ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
235
257
  ...(inviteUrl ? { invite: inviteUrl } : {}),
236
- ...(wallet ? { wallet: wallet.sealed
237
- ? `${wallet.file} (sealed with your passphrase — \`one wallet open\` to read it, \`one wallet paper\` to back it up)`
238
- : `${wallet.file} (0600 PLAINTEXT — the 24 words and keys; back it up, never commit it)` } : {}),
239
- ...(wallet?.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
240
- ...(wallet && !wallet.ok ? { wallet_error: wallet.sealed === false
241
- ? `${wallet.error} — retry: one wallet register --kind agent --workspace ${workspace} --from ${wallet.file}`
242
- : wallet.sealed === true
243
- ? `${wallet.error} — retry: one wallet register --kind agent --workspace ${workspace} --dir ${vaultDir}`
244
- : `${wallet.error}` } : {}),
258
+ ...(wallet ? initWalletReceipt(wallet, { workspace, dir, vaultDir, cli: cliPrefix() }) : {}),
245
259
  ...(skills.length ? { skills: skills.join(', ') } : {}),
246
260
  });
247
261
  });
@@ -0,0 +1,2 @@
1
+ export type CliPrefix = 'one' | 'npx oneie';
2
+ export declare function cliPrefix(argv?: readonly string[]): CliPrefix;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * invoked-as.ts — how to spell a follow-up command so it runs as printed.
3
+ *
4
+ * The package ships two bins, `oneie` and `one`, but only a global install puts
5
+ * `one` on PATH. Under `npx oneie init` a hint reading `one wallet open` answers
6
+ * `command not found: one` (hit live 2026-10-04, oneie@5.3.3). So a hint says
7
+ * `one` only when THIS process was started through the `one` bin, and
8
+ * `npx oneie` otherwise — which runs from any shell, installed or not.
9
+ *
10
+ * Node keeps the bin's own name in argv[1] (a symlink is not resolved), so the
11
+ * basename is the whole test. A Windows `.cmd` shim never matches and falls
12
+ * back to `npx oneie`, which still runs.
13
+ */
14
+ import { basename } from 'node:path';
15
+ export function cliPrefix(argv = process.argv) {
16
+ return basename(argv[1] ?? '') === 'one' ? 'one' : 'npx oneie';
17
+ }
@@ -69,5 +69,20 @@ export declare function keychainRead(authPub: string): KeychainResult;
69
69
  * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
70
70
  * words is trivially copied out of sequence — a wallet that restores to the
71
71
  * wrong addresses with no error. Pure, so it is testable without a wallet.
72
+ *
73
+ * The derivation is printed, and named in the restore command, because the words
74
+ * carry no marker of their own: `wallet new --recover` with no `--derivation`
75
+ * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
76
+ * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
77
+ * different, empty wallet with no error. The paper alone must carry what restore
78
+ * needs, so the derivation is required here, not defaulted.
79
+ *
80
+ * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
81
+ * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
82
+ * command — nothing trailing — so it can be copied, and parsed by the test that
83
+ * follows it back to the same addresses (tests/paper-restore.test.ts).
72
84
  */
73
- export declare function paperSheet(mnemonic: string, addresses: Record<string, string>): string;
85
+ export declare function paperSheet(mnemonic: string, addresses: Record<string, string>, restore: {
86
+ derivation: 'v1' | 'v2';
87
+ cli: string;
88
+ }): string;
@@ -151,14 +151,44 @@ export function keychainRead(authPub) {
151
151
  return { ok: true, value: r.stdout.toString().trim() };
152
152
  }
153
153
  // ─── Paper ───────────────────────────────────────────────────────────────────
154
+ /**
155
+ * Where else the words open. Only v2 is BIP-39 at the standard paths, so only a v2
156
+ * sheet may name other wallets — v1 is ONE's own scheme and opens an empty account
157
+ * anywhere else. The wallet list is pinned against independent derivations at those
158
+ * paths in one.ie/web/tests/unit/wallet/sheet-other-wallets.test.ts.
159
+ */
160
+ function otherWallets(restore) {
161
+ if (restore.derivation === 'v2') {
162
+ return [
163
+ 'These words also open in: MetaMask (Ethereum), Phantom (Solana), Sui Wallet / Slush (Sui),',
164
+ ' Sparrow or BlueWallet (Bitcoin, native SegWit). The first account in each is the address above.',
165
+ ];
166
+ }
167
+ return [
168
+ `These words recover only with ONE tools (\`${restore.cli} wallet new --recover --derivation v1\``,
169
+ ' or `npx @oneie/recover --derivation v1`) — not in other wallets.',
170
+ ];
171
+ }
154
172
  /**
155
173
  * The 24 words laid out for transcription, numbered.
156
174
  *
157
175
  * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
158
176
  * words is trivially copied out of sequence — a wallet that restores to the
159
177
  * wrong addresses with no error. Pure, so it is testable without a wallet.
178
+ *
179
+ * The derivation is printed, and named in the restore command, because the words
180
+ * carry no marker of their own: `wallet new --recover` with no `--derivation`
181
+ * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
182
+ * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
183
+ * different, empty wallet with no error. The paper alone must carry what restore
184
+ * needs, so the derivation is required here, not defaulted.
185
+ *
186
+ * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
187
+ * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
188
+ * command — nothing trailing — so it can be copied, and parsed by the test that
189
+ * follows it back to the same addresses (tests/paper-restore.test.ts).
160
190
  */
161
- export function paperSheet(mnemonic, addresses) {
191
+ export function paperSheet(mnemonic, addresses, restore) {
162
192
  const words = mnemonic.trim().split(/\s+/);
163
193
  const rows = [];
164
194
  const half = Math.ceil(words.length / 2);
@@ -179,6 +209,13 @@ export function paperSheet(mnemonic, addresses) {
179
209
  'Receiving addresses (public — safe to share, this is how you get paid):',
180
210
  ...Object.entries(addresses).map(([chain, addr]) => ` ${chain.padEnd(5)} ${addr}`),
181
211
  '',
182
- 'Restore with: one wallet open --recover',
212
+ `Derivation: ${restore.derivation} (restore MUST name it — without it the same words open a different, empty wallet)`,
213
+ ...otherWallets(restore),
214
+ '',
215
+ `Restore with: ${restore.cli} wallet new --recover --derivation ${restore.derivation}`,
216
+ ' The words go in ONE_WALLET_MNEMONIC, set without echo first:',
217
+ ' read -rs ONE_WALLET_MNEMONIC && export ONE_WALLET_MNEMONIC',
218
+ ' Never on the command line — argv lands in shell history and in `ps`.',
219
+ `Offline, no ONE server: npx @oneie/recover --derivation ${restore.derivation}`,
183
220
  ].join('\n');
184
221
  }
@@ -96,6 +96,12 @@ export declare function addressesOnly(source: unknown): Record<string, string>;
96
96
  export declare function writeKeysFile(filePath: string, contents: string, accepted: boolean): void;
97
97
  /** Read a secret from the TTY with echo off. Never argv (world-readable in ps), never env. */
98
98
  export declare function promptSecret(prompt: string): Promise<string>;
99
+ /** The sheet `wallet paper` prints — unlock, then lay out what restore needs. */
100
+ export declare function paperFor(dir: string, io?: UnlockIO, cli?: string): Promise<{
101
+ sheet: string;
102
+ } | {
103
+ error: string;
104
+ }>;
99
105
  type Unlocked = {
100
106
  blob: VaultBlob;
101
107
  mnemonic: string;
@@ -7,6 +7,7 @@ import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file'
7
7
  import { proveAddresses } from '@oneie/sdk/address-proof';
8
8
  import { askPath } from './lib/api-path.js';
9
9
  import { wordsStdoutRefusal } from './lib/agent-env.js';
10
+ import { cliPrefix } from './lib/invoked-as.js';
10
11
  import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
11
12
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
12
13
  // Re-exported for existing callers/tests — canonical implementation now lives
@@ -354,7 +355,7 @@ export function walletCmd() {
354
355
  wrap,
355
356
  derivation,
356
357
  addresses,
357
- next: 'one wallet paper # write the 24 words down — this is the ONLY backup',
358
+ next: `${cliPrefix()} wallet paper${opts.dir === '.' ? '' : ` --dir ${opts.dir}`} # write the 24 words down — this is the ONLY backup`,
358
359
  });
359
360
  });
360
361
  cmd.command('open')
@@ -380,7 +381,7 @@ export function walletCmd() {
380
381
  process.exitCode = 1;
381
382
  return;
382
383
  }
383
- const r = await unlock(opts.dir);
384
+ const r = await paperFor(opts.dir);
384
385
  if ('error' in r) {
385
386
  out(cmd, { ok: false, error: r.error });
386
387
  return;
@@ -388,7 +389,7 @@ export function walletCmd() {
388
389
  // Straight to stdout, never through out(): a --json receipt carrying 24
389
390
  // words would put the whole wallet into any pipeline or CI log that
390
391
  // captured it.
391
- process.stdout.write(paperSheet(r.mnemonic, r.addresses) + '\n');
392
+ process.stdout.write(r.sheet + '\n');
392
393
  });
393
394
  cmd.command('keychain')
394
395
  .description('Move this wallet behind Touch ID — stores its passphrase in Apple Keychain so biometrics open it')
@@ -569,6 +570,15 @@ export async function promptSecret(prompt) {
569
570
  orig('\n');
570
571
  }
571
572
  }
573
+ /** The sheet `wallet paper` prints — unlock, then lay out what restore needs. */
574
+ export async function paperFor(dir, io = terminalIO(), cli = cliPrefix()) {
575
+ const r = await unlock(dir, io);
576
+ if ('error' in r)
577
+ return { error: r.error };
578
+ // The vault's OWN marker, read the way unlock derived the addresses above — an
579
+ // absent marker is v1 — so the sheet names the derivation those addresses are.
580
+ return { sheet: paperSheet(r.mnemonic, r.addresses, { derivation: readDerivation(r.blob.derivation), cli }) };
581
+ }
572
582
  const terminalIO = () => ({
573
583
  interactive: Boolean(process.stdin.isTTY), readPassphrase: promptSecret, readKeychain: keychainRead,
574
584
  });
@@ -585,7 +595,7 @@ const terminalIO = () => ({
585
595
  export async function unlock(dir, io = terminalIO()) {
586
596
  const raw = readVaultFolder(dir);
587
597
  if (!raw)
588
- return { error: `no wallet at ${vaultPath(dir)} — run \`one wallet new\`` };
598
+ return { error: `no wallet at ${vaultPath(dir)} — run \`${cliPrefix()} wallet new\`` };
589
599
  const blob = raw;
590
600
  let passphrase;
591
601
  if (blob.wrap === 'keychain') {
@@ -596,7 +606,7 @@ export async function unlock(dir, io = terminalIO()) {
596
606
  }
597
607
  else {
598
608
  if (!io.interactive) {
599
- return { error: `wallet_passphrase_unavailable: the wallet at ${vaultPath(dir)} is sealed with a passphrase typed at a terminal, and stdin is not one. Run this at a terminal, or move the wallet behind Touch ID with \`one wallet keychain\`` };
609
+ return { error: `wallet_passphrase_unavailable: the wallet at ${vaultPath(dir)} is sealed with a passphrase typed at a terminal, and stdin is not one. Run this at a terminal, or move the wallet behind Touch ID with \`${cliPrefix()} wallet keychain\`` };
600
610
  }
601
611
  passphrase = await io.readPassphrase('Passphrase: ');
602
612
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "5.3.3",
3
+ "version": "5.3.5",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {