passport-bridge 0.16.13 → 0.16.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +15 -15
  2. package/dist/bridgeExchange.d.ts +7 -1
  3. package/dist/bridgeExchange.js +11 -2
  4. package/dist/cli.js +3 -1
  5. package/dist/cliActions.js +37 -18
  6. package/dist/cliArgs.js +14 -9
  7. package/dist/cliAutopilot.js +35 -14
  8. package/dist/cliAutopilotPolicy.d.ts +10 -0
  9. package/dist/cliAutopilotPolicy.js +28 -0
  10. package/dist/cliConnect.js +7 -6
  11. package/dist/cliDeadline.js +2 -1
  12. package/dist/cliEnv.js +5 -4
  13. package/dist/cliExec.js +13 -5
  14. package/dist/cliGuardState.d.ts +2 -0
  15. package/dist/cliGuardState.js +5 -1
  16. package/dist/cliHelp.d.ts +5 -4
  17. package/dist/cliHelp.js +2 -27
  18. package/dist/cliHook.js +6 -2
  19. package/dist/cliHookGuard.js +2 -2
  20. package/dist/cliHookInstall.d.ts +3 -0
  21. package/dist/cliHookInstall.js +17 -7
  22. package/dist/cliHookStatus.d.ts +2 -1
  23. package/dist/cliHookStatus.js +26 -17
  24. package/dist/cliInit.js +5 -3
  25. package/dist/cliKeys.d.ts +3 -0
  26. package/dist/cliKeys.js +59 -77
  27. package/dist/cliKeysShim.js +7 -5
  28. package/dist/cliLogin.js +44 -24
  29. package/dist/cliLogout.js +23 -7
  30. package/dist/cliMain.js +48 -20
  31. package/dist/cliOffline.d.ts +2 -2
  32. package/dist/cliOffline.js +31 -8
  33. package/dist/cliOutput.js +72 -42
  34. package/dist/cliReady.d.ts +2 -1
  35. package/dist/cliReady.js +9 -6
  36. package/dist/cliResult.js +1 -1
  37. package/dist/cliScan.js +10 -28
  38. package/dist/cliSessions.d.ts +3 -2
  39. package/dist/cliSessions.js +19 -17
  40. package/dist/cliSetup.js +6 -4
  41. package/dist/cliSetupLock.js +1 -0
  42. package/dist/cliSetupOrg.js +7 -5
  43. package/dist/cliStatus.d.ts +2 -4
  44. package/dist/cliStatus.js +55 -60
  45. package/dist/cliSuggest.d.ts +3 -2
  46. package/dist/cliSuggest.js +19 -6
  47. package/dist/cliSupport.d.ts +1 -1
  48. package/dist/cliSupport.js +3 -7
  49. package/dist/cliSync.js +2 -0
  50. package/dist/cliUndo.d.ts +3 -1
  51. package/dist/cliUndo.js +14 -11
  52. package/dist/cliWait.d.ts +3 -2
  53. package/dist/cliWait.js +10 -18
  54. package/dist/doctor.d.ts +4 -1
  55. package/dist/doctor.js +43 -24
  56. package/dist/execNoKey.d.ts +1 -1
  57. package/dist/execNoKey.js +3 -2
  58. package/dist/execShims.js +2 -2
  59. package/dist/hookFastPath.js +1 -0
  60. package/dist/initAutopilotStep.js +5 -4
  61. package/dist/initInstall.js +4 -3
  62. package/dist/initKeysStep.js +1 -1
  63. package/dist/initLocalSteps.js +4 -2
  64. package/dist/initOutro.d.ts +1 -3
  65. package/dist/initOutro.js +7 -15
  66. package/dist/initPlan.js +6 -6
  67. package/dist/initUi.d.ts +2 -4
  68. package/dist/initUi.js +8 -17
  69. package/dist/keysLocal.js +3 -3
  70. package/dist/keysSecret.d.ts +6 -0
  71. package/dist/keysSecret.js +43 -0
  72. package/dist/launcherFastPath.js +1 -0
  73. package/dist/loginFlow.d.ts +1 -1
  74. package/dist/loginFlow.js +4 -4
  75. package/dist/pathLines.d.ts +1 -0
  76. package/dist/pathLines.js +23 -0
  77. package/dist/pluginPin.d.ts +1 -1
  78. package/dist/pluginPin.js +1 -1
  79. package/dist/plural.d.ts +10 -0
  80. package/dist/plural.js +14 -0
  81. package/dist/term.d.ts +49 -5
  82. package/dist/term.js +200 -26
  83. package/dist/version.d.ts +1 -1
  84. package/dist/version.js +1 -1
  85. package/dist/waitingLine.js +2 -1
  86. package/npm-shrinkwrap.json +2 -2
  87. package/package.json +1 -1
package/dist/cliEnv.js CHANGED
@@ -19,7 +19,8 @@ import { readCliPolicy } from "./cliPolicy.js";
19
19
  import { NODE_LINK_FS } from "./envLinkFs.js";
20
20
  import { detectLinks } from "./envResolve.js";
21
21
  import { vendorName } from "./envTarget.js";
22
- import { columns, wrapText } from "./initUi.js";
22
+ import { columns } from "./initUi.js";
23
+ import { wrap } from "./term.js";
23
24
  import { callerFrom, failure, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
24
25
  const HOW = {
25
26
  flag: "flag",
@@ -57,8 +58,8 @@ function environmentCell(row) {
57
58
  const HEADER = ["App", "Resource", "How", "Environment"];
58
59
  /** A row too wide for the table: the app and resource, then how and where. */
59
60
  function stacked(row, width) {
60
- const detail = wrapText(`${row.how}, ${environmentCell(row)}`, Math.max(20, width - 2)).map((line) => ` ${line}`);
61
- return [...wrapText(`${row.vendor} ${row.resource}`, width), ...detail];
61
+ const detail = wrap(`${row.how}, ${environmentCell(row)}`, Math.max(20, width - 2)).map((line) => ` ${line}`);
62
+ return [...wrap(`${row.vendor} ${row.resource}`, width), ...detail];
62
63
  }
63
64
  function whereHere(runtime, deps) {
64
65
  const cwd = deps.cwd ?? process.cwd();
@@ -105,7 +106,7 @@ export function envTableLines(rows, width = Number.POSITIVE_INFINITY) {
105
106
  const body = columns([HEADER, ...cells], width) ?? rows.flatMap((row) => stacked(row, width));
106
107
  const notes = rows
107
108
  .filter((row) => row.note)
108
- .flatMap((row) => wrapText(`${row.vendor} ${row.resource}: ${row.note}`, width));
109
+ .flatMap((row) => wrap(`${row.vendor} ${row.resource}: ${row.note}`, width));
109
110
  return [...body, ...notes];
110
111
  }
111
112
  async function setEnvironment(args, runtime, deps) {
package/dist/cliExec.js CHANGED
@@ -40,6 +40,7 @@ import { findVendorBinary, removeShims } from "./execShims.js";
40
40
  import { approvalLink, hashLink } from "./webLinks.js";
41
41
  import { workspaceOfToken } from "./tokenWorkspace.js";
42
42
  import { declinedLine, waitingParts } from "./waitingLine.js";
43
+ import { countOf } from "./plural.js";
43
44
  export const EXEC_AUTHORIZE_PATH = "/api/my/exec/authorize";
44
45
  export const EXEC_RESULT_PATH = "/api/my/exec/result";
45
46
  export const EXEC_WAIT_DEFAULT_SECONDS = 100;
@@ -253,8 +254,9 @@ async function post(client, body, runtime, ms, binary) {
253
254
  }
254
255
  /** Ctrl-C while waiting: the request stays open in Passport. */
255
256
  export function stillOpen(approvalId) {
256
- return failure(`The request is still open. Run passport wait ${approvalId} to keep waiting, then run the command again.`, 4, "approval_pending", {
257
+ return failure("The request is still open. Keep waiting, then run the command again.", 4, "approval_pending", {
257
258
  approvalId,
259
+ hint: `Run: passport wait ${approvalId}`,
258
260
  next: [{ argv: ["passport", "wait", approvalId], description: "Keep waiting for this approval." }]
259
261
  });
260
262
  }
@@ -264,8 +266,9 @@ async function waitFor(client, approvalId, seconds, runtime, now) {
264
266
  for (;;) {
265
267
  const left = Math.ceil((deadline - now()) / 1000);
266
268
  if (left <= 0) {
267
- return failure(`Still waiting for approval. Run \`passport wait ${approvalId}\`, then run the command again, or continue with other work.`, 4, "approval_pending", {
269
+ return failure("Still waiting for approval. Keep waiting, then run the command again, or continue with other work.", 4, "approval_pending", {
268
270
  approvalId,
271
+ hint: `Run: passport wait ${approvalId}`,
269
272
  next: [{ argv: ["passport", "wait", approvalId], description: "Keep waiting for this approval." }]
270
273
  });
271
274
  }
@@ -281,7 +284,10 @@ async function waitFor(client, approvalId, seconds, runtime, now) {
281
284
  catch {
282
285
  if (runtime.signal.aborted)
283
286
  return stillOpen(approvalId);
284
- return failure(`Passport couldn't be reached while waiting. Run \`passport wait ${approvalId}\` when you're back online.`, 1, "offline", { approvalId });
287
+ return failure("Passport couldn't be reached while waiting. Keep waiting once you're back online.", 1, "offline", {
288
+ approvalId,
289
+ hint: `Run: passport wait ${approvalId}`
290
+ });
285
291
  }
286
292
  if (!response.ok) {
287
293
  return failure(await safeApiError(response, "Passport couldn't read that approval."), 1, "server", {
@@ -388,7 +394,7 @@ export function waitingLine(message, seconds) {
388
394
  const match = message.match(/^(.*?)\s*Waiting for approval from (.+?)\. Run `passport wait/);
389
395
  const lead = match?.[1] ? `${match[1]} ` : "";
390
396
  const who = match?.[2] ?? "a person";
391
- return `${lead}Waiting up to ${seconds} seconds for ${who}. Approve it on your phone or in Passport.`;
397
+ return `${lead}Waiting up to ${countOf(seconds, "second")} for ${who}. Approve it on your phone or in Passport.`;
392
398
  }
393
399
  /** The approval's page in the web app, from the signed-in profile. */
394
400
  function approvalUrl(auth, approvalId) {
@@ -499,7 +505,9 @@ export async function exec(args, runtime, deps = {}) {
499
505
  const credential = checkedCredential(vendor, decided.credential?.env);
500
506
  remember(true);
501
507
  if (bool(args, "verbose") && typeof decided.credential?.label === "string") {
502
- runtime.stderr.write(`Passport: ${decided.credential.label.slice(0, 120)}.\n`);
508
+ // "Your stored Railway key" reads "Passport: used your stored Railway key."
509
+ const label = decided.credential.label.slice(0, 120);
510
+ runtime.stderr.write(`Passport: used ${label.charAt(0).toLowerCase()}${label.slice(1)}.\n`);
503
511
  }
504
512
  let code;
505
513
  const startedAt = (deps.now ?? Date.now)();
@@ -47,6 +47,8 @@ export declare function problemFix(kind: ProblemKind, client?: string): ProblemF
47
47
  /** The fix for a local guard state, or null when there's nothing to do. */
48
48
  export declare function guardStateFix(state: GuardState | null, client: GuardClient): ProblemFix | null;
49
49
  export declare function fixLine(fix: ProblemFix): string;
50
+ /** A fix on a terminal: the sentence, then "Run: <command>" on its own line. */
51
+ export declare function fixLines(fix: ProblemFix): string;
50
52
  export type OfflineDecision = "ask" | "block" | "allow";
51
53
  export type OfflineRow = "production" | "staging" | "development" | "other";
52
54
  /** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
@@ -58,7 +58,7 @@ export function agentLink(client) {
58
58
  }
59
59
  export function problemFix(kind, client) {
60
60
  const agent = client ? agentLink(client) : "#agents";
61
- const install = `passport hook install --client ${client ?? "claude-code"} --guard --apply`;
61
+ const install = `passport hook install --agent ${client ?? "claude-code"} --guard --apply`;
62
62
  const guardDocs = `${DOCS_BASE}/member/cli-hook#guard-health`;
63
63
  switch (kind) {
64
64
  case "guard-off":
@@ -101,6 +101,10 @@ export function guardStateFix(state, client) {
101
101
  export function fixLine(fix) {
102
102
  return fix.command ? `${fix.text} Run: ${fix.command}` : fix.text;
103
103
  }
104
+ /** A fix on a terminal: the sentence, then "Run: <command>" on its own line. */
105
+ export function fixLines(fix) {
106
+ return fix.command ? `${fix.text}\nRun: ${fix.command}` : fix.text;
107
+ }
104
108
  /** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
105
109
  * in shared/guardContract.ts); used only without a fresh policy. */
106
110
  export const OFFLINE_DEFAULT = "ask";
package/dist/cliHelp.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * `passport help` on a terminal: the same text, wrapped to the real width.
3
- * A line too long for the terminal wraps under its own description column
4
- * (" status Show …", " --yes accept …"), and a usage line keeps each
5
- * `[--flag <value>]` whole. Piped and `--json` help are unchanged.
2
+ * `passport help` on a terminal: the same text, laid out to the real width by
3
+ * the shared renderer (term.ts `layout`). A line too long for the terminal
4
+ * wraps under its own description column (" status Show …", " --yes
5
+ * accept …"), and a usage line keeps each `[--flag <value>]` whole. Piped and
6
+ * `--json` help are unchanged.
6
7
  */
7
8
  import type { ParsedArgs } from "./cliArgs.js";
8
9
  import type { CommandResult, Runtime } from "./cliSupport.js";
package/dist/cliHelp.js CHANGED
@@ -1,32 +1,7 @@
1
1
  import { helpResult } from "./cliOutput.js";
2
- import { termOf, visibleLength, wrap } from "./term.js";
3
- const NBSP = " ";
4
- /** Spaces inside `[…]` and `<…>` stay, so an option never splits from its value. */
5
- function keepGroups(line) {
6
- return line.replace(/\[[^\]]*\]|<[^>]*>/g, (group) => group.replace(/ /g, NBSP));
7
- }
2
+ import { layout, termOf } from "./term.js";
8
3
  export function layoutHelp(text, term) {
9
- if (!Number.isFinite(term.width))
10
- return text;
11
- return text
12
- .split("\n")
13
- .flatMap((line) => {
14
- if (visibleLength(line) <= term.width)
15
- return [line];
16
- // " status Show …" or " --yes accept …": hang under the description.
17
- const column = line.match(/^(\s*\S+(?: \S+)*?\s{2,})\S/);
18
- if (column && column[1].length < term.width / 2) {
19
- const lead = column[1];
20
- return wrap(keepGroups(line.slice(lead.length)), term.width, lead, " ".repeat(lead.length));
21
- }
22
- const indent = line.match(/^\s*/)[0];
23
- // A usage line hangs its options under the command, an option line its
24
- // description under the option; prose keeps its indent.
25
- const hang = /^\s*(?:passport|npx) /.test(line) ? " " : /^\s+-/.test(line) ? " " : "";
26
- return wrap(keepGroups(line.trimStart()), term.width, indent, `${indent}${hang}`);
27
- })
28
- .map((line) => line.split(NBSP).join(" "))
29
- .join("\n");
4
+ return layout(text, term.width, { groups: true });
30
5
  }
31
6
  export function help(args, runtime) {
32
7
  const result = helpResult(args);
package/dist/cliHook.js CHANGED
@@ -538,8 +538,12 @@ export async function hook(args, runtime, deps = {}) {
538
538
  return hookRegistration(action, value(args, "client"), args, runtime);
539
539
  }
540
540
  if (action !== undefined && action !== "guard" && action !== "flush") {
541
- const { failure } = await import("./cliSupport.js");
542
- return failure("Use passport hook, hook guard, hook install, hook uninstall, or hook status.", 6, "usage");
541
+ const [{ failure }, { unknownSubcommand }] = await Promise.all([
542
+ import("./cliSupport.js"),
543
+ import("./cliSuggest.js")
544
+ ]);
545
+ const unknown = unknownSubcommand("hook", action, ["install", "uninstall", "status"]);
546
+ return failure(unknown.message, 6, "usage", unknown.next ? { next: unknown.next } : {});
543
547
  }
544
548
  try {
545
549
  if (action === "guard")
@@ -13,7 +13,7 @@
13
13
  * With a v1 policy (an older server) or none at all, the guard keeps its old
14
14
  * shape: ask or deny, never allow.
15
15
  */
16
- import { decideAction, decisionRank, envLabel } from "./cliAutopilotPolicy.js";
16
+ import { causeSentence, decideAction, decisionRank, envLabel } from "./cliAutopilotPolicy.js";
17
17
  import { reportedEnvironment } from "./cliHookEnvironment.js";
18
18
  import { placementOf, resolveTarget, targetNote } from "./envResolve.js";
19
19
  import { NODE_LINK_FS } from "./envLinkFs.js";
@@ -415,7 +415,7 @@ export function denyMessage(decision, owner) {
415
415
  : `${owner ? `Ask ${owner} to run it` : "Ask an admin to run it"}, or request an exception in Passport.`;
416
416
  const deciding = decision.findings[0];
417
417
  const from = deciding?.from && !deciding.project ? ` (${decision.label}, from ${deciding.from})` : "";
418
- return `Blocked by Passport: ${decision.cause.label}${from}. ${next}`;
418
+ return `${causeSentence("block", decision.cause.label)}${from}. ${next}`;
419
419
  }
420
420
  return `Passport: your Autopilot rules block ${decision.label}. Change this in Passport › Rules.`;
421
421
  }
@@ -58,6 +58,9 @@ export type Change = {
58
58
  event: string;
59
59
  command: string;
60
60
  };
61
+ /** A hook's command as a person reads it: "passport hook guard", not the
62
+ * absolute paths of node and the CLI (those show with --verbose). */
63
+ export declare function shownHookCommand(command: string, verbose: boolean): string;
61
64
  /** What `passport init` would change to turn on audit + guard for one agent. */
62
65
  export type GuardInstallPlan = {
63
66
  client: HookClient;
@@ -22,6 +22,7 @@ import { syncNative } from "./nativeSync.js";
22
22
  import { credentialDir } from "./credentialStorage.js";
23
23
  import { launcherPath } from "./initInstall.js";
24
24
  import { failure } from "./cliSupport.js";
25
+ import { countOf } from "./plural.js";
25
26
  export const HOOK_CLIENTS = ["claude-code", "codex", "cursor"];
26
27
  const SETTINGS_MAX_BYTES = 1024 * 1024;
27
28
  const HOOK_TIMEOUT_SECONDS = 5;
@@ -326,16 +327,25 @@ const LIMITS_LINE = "It can't see inside scripts, aliases, or make targets.";
326
327
  const CODEX_TRUST_LINE = "Next: Open Codex → /hooks and trust Passport's hooks.";
327
328
  /** What the guard does in Codex, in plain words (status, install, init). */
328
329
  export const CODEX_BLOCK_ONLY = "Codex can't show Passport's questions, so Passport blocks a command your rules ask about and tells you how to approve it.";
329
- function planLines(changes) {
330
+ /** A hook's command as a person reads it: "passport hook guard", not the
331
+ * absolute paths of node and the CLI (those show with --verbose). */
332
+ export function shownHookCommand(command, verbose) {
333
+ if (verbose)
334
+ return command.split(" ").map(displayPath).join(" ");
335
+ return command.replace(/^(?:"?\S*node(?:\.exe)?"?\s+)?"?\S*passport(?:\.js|\.mjs|\.cmd)?"?(?=\s)/, "passport");
336
+ }
337
+ function planLines(changes, verbose) {
330
338
  const width = Math.max(...changes.map((change) => change.event.length));
331
- return changes.map((change) => ` ${change.action.padEnd(6)} ${change.event.padEnd(width)} ${change.command}`);
339
+ return changes.map((change) =>
340
+ // copy-style-allow double-space: preview columns line up
341
+ ` ${change.action.padEnd(6)} ${change.event.padEnd(width)} ${shownHookCommand(change.command, verbose)}`);
332
342
  }
333
- function previewResult(spec, action, path, changes, guard) {
343
+ function previewResult(spec, action, path, changes, guard, verbose = false) {
334
344
  return {
335
345
  json: { preview: true, action, client: spec.id, path, guard, changes },
336
346
  human: [
337
347
  `Would change ${spec.name}:`,
338
- ...planLines(changes),
348
+ ...planLines(changes, verbose),
339
349
  ...(action === "uninstall" ? ["Other hooks stay as they are."] : []),
340
350
  `File: ${displayPath(path)}`,
341
351
  "Re-run with --apply to make this change."
@@ -403,7 +413,7 @@ function installClient(spec, args, runtime) {
403
413
  };
404
414
  }
405
415
  if (!bool(args, "apply"))
406
- return previewResult(spec, "install", path, changes, guard);
416
+ return previewResult(spec, "install", path, changes, guard, bool(args, "verbose"));
407
417
  let next = settings;
408
418
  for (const entry of wanted)
409
419
  next = withEntry(spec, next, entry, entry.command);
@@ -441,7 +451,7 @@ function uninstallClient(spec, args, runtime) {
441
451
  };
442
452
  }
443
453
  if (!bool(args, "apply"))
444
- return previewResult(spec, "uninstall", path, changes, guardOnly);
454
+ return previewResult(spec, "uninstall", path, changes, guardOnly, bool(args, "verbose"));
445
455
  writeSettings(path, withoutEntries(spec, settings, kinds));
446
456
  const stillAudits = guardOnly && registered(spec, settings, "audit") !== null;
447
457
  const allowlist = removeAllowlist(spec.id, runtime.env);
@@ -464,7 +474,7 @@ function removeAllowlist(client, env) {
464
474
  try {
465
475
  const agents = client === "cursor" ? ["cursor", "cursor-cli"] : [client];
466
476
  const removed = syncNative(null, { env, remove: true, agents: [...agents] }).reduce((sum, change) => sum + change.removed.length, 0);
467
- return removed ? `${removed} ${removed === 1 ? "entry" : "entries"}` : null;
477
+ return removed ? countOf(removed, "entry", "entries") : null;
468
478
  }
469
479
  catch {
470
480
  return null;
@@ -13,6 +13,7 @@ export declare function localGuardStates(env: Env): Promise<{
13
13
  label: string | null;
14
14
  fix: ProblemFix | null;
15
15
  }[]>;
16
- /** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem. */
16
+ /** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem,
17
+ * and its command on a line of its own: "Run: passport hook install …". */
17
18
  export declare function guardFixLines(states: Awaited<ReturnType<typeof localGuardStates>>): string[];
18
19
  export declare function hookStatus(args: ParsedArgs, runtime: Runtime): Promise<CommandResult>;
@@ -5,23 +5,24 @@
5
5
  */
6
6
  import { bool, value } from "./cliArgs.js";
7
7
  import { guardClientReports } from "./cliGuardHealth.js";
8
- import { GUARD_CLIENT_LABEL, GUARD_STATE_LABEL, fixLine, guardStateFix, localGuardState } from "./cliGuardState.js";
8
+ import { GUARD_CLIENT_LABEL, GUARD_STATE_LABEL, fixLines, guardStateFix, localGuardState } from "./cliGuardState.js";
9
9
  import { CODEX_BLOCK_ONLY, HOOK_CLIENTS, agentHookStatus, displayPath } from "./cliHookInstall.js";
10
10
  import { readCliPolicy } from "./cliPolicy.js";
11
11
  import { readCreds } from "./credentials.js";
12
12
  import { failure, selectStoredProfile } from "./cliSupport.js";
13
13
  import { VERSION } from "./version.js";
14
+ import { countOf } from "./plural.js";
14
15
  function ageText(ms) {
15
16
  const minutes = Math.floor(ms / 60_000);
16
17
  if (minutes < 1)
17
18
  return "just now";
18
19
  if (minutes < 60)
19
- return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
20
+ return `${countOf(minutes, "minute")} ago`;
20
21
  const hours = Math.floor(minutes / 60);
21
22
  if (hours < 48)
22
- return `${hours} hour${hours === 1 ? "" : "s"} ago`;
23
+ return `${countOf(hours, "hour")} ago`;
23
24
  const days = Math.floor(hours / 24);
24
- return `${days} days ago`;
25
+ return `${countOf(days, "day")} ago`;
25
26
  }
26
27
  function policyStatus(args, env, now) {
27
28
  let profile;
@@ -38,8 +39,8 @@ function policyStatus(args, env, now) {
38
39
  const line = !profile
39
40
  ? "Rules: built-in, asks before destructive commands (not signed in)."
40
41
  : !cached
41
- ? "Rules: built-in until synced. Run passport status to sync."
42
- : `${cached.version === 2 ? "Autopilot rules" : "Rules"}: synced ${ageText(ageMs ?? 0)} for ${profile}.`;
42
+ ? "Rules: built-in until synced.\nRun: passport status"
43
+ : `${cached.version === 2 ? "Autopilot rules" : "Rules"}: synced ${ageText(ageMs ?? 0)}.`;
43
44
  return {
44
45
  json: {
45
46
  profile: profile ?? null,
@@ -65,10 +66,20 @@ export async function localGuardStates(env) {
65
66
  };
66
67
  });
67
68
  }
68
- /** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem. */
69
+ /** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem,
70
+ * and its command on a line of its own: "Run: passport hook install …". */
69
71
  export function guardFixLines(states) {
70
- return states.flatMap((entry) => (entry.fix ? [`${GUARD_CLIENT_LABEL[entry.client]}: ${fixLine(entry.fix)}`] : []));
72
+ return states.flatMap((entry) => entry.fix ? `${GUARD_CLIENT_LABEL[entry.client]}: ${fixLines(entry.fix)}`.split("\n") : []);
71
73
  }
74
+ /** How an agent's hooks read in the list: "Audit and guard", "Not installed". */
75
+ const MODE_WORDS = {
76
+ "audit + guard": "Audit and guard",
77
+ audit: "Audit",
78
+ guard: "Guard",
79
+ "via plugin": "Via the Passport plugin",
80
+ "not installed": "Not installed",
81
+ unreadable: "Couldn't read its settings"
82
+ };
72
83
  export async function hookStatus(args, runtime) {
73
84
  if (value(args, "client"))
74
85
  return failure("passport hook status takes no --agent.", 6, "usage");
@@ -88,17 +99,15 @@ export async function hookStatus(args, runtime) {
88
99
  const policy = policyStatus(args, runtime.env, Date.now());
89
100
  const disabled = runtime.env.PASSPORT_HOOK_DISABLED === "1";
90
101
  const nameWidth = Math.max(...agents.map((agent) => agent.name.length));
91
- const modeWidth = Math.max(...agents.map((agent) => agent.mode.length));
92
- const guardText = (agent) => (agent.guardLabel ? `Guard ${agent.guardLabel}` : "");
93
- const guardWidth = Math.max(...agents.map((agent) => guardText(agent).length));
102
+ // "Audit and guard · On": what's installed, then the guard's state.
103
+ const stateText = (agent) => {
104
+ const mode = MODE_WORDS[agent.mode] ?? agent.mode;
105
+ return agent.guardLabel ? `${mode} · ${agent.guardLabel}` : mode;
106
+ };
107
+ const stateWidth = Math.max(...agents.map((agent) => stateText(agent).length));
94
108
  const codexGuarded = agents.some((agent) => agent.client === "codex" && agent.guard);
95
109
  const lines = [
96
- ...agents.map((agent) => [
97
- agent.name.padEnd(nameWidth),
98
- agent.mode.padEnd(modeWidth),
99
- guardText(agent).padEnd(guardWidth),
100
- displayPath(agent.path)
101
- ].join(" ")),
110
+ ...agents.map((agent) => [agent.name.padEnd(nameWidth), stateText(agent).padEnd(stateWidth), displayPath(agent.path)].join(" ")),
102
111
  "",
103
112
  policy.line,
104
113
  ...(codexGuarded ? [CODEX_BLOCK_ONLY] : []),
package/dist/cliInit.js CHANGED
@@ -31,6 +31,7 @@ import { APP_BY_CLI, APP_BY_PROVIDER, APP_LABELS, INIT_APPS, PASSPORT_CLOUD, hea
31
31
  import { InitPaused, InitScreen, listOf, processTerminal } from "./initUi.js";
32
32
  import { outro } from "./initOutro.js";
33
33
  import { ensureOneLinerRuntime, oneLinerNodeProblem } from "./nodeVersion.js";
34
+ import { countOf } from "./plural.js";
34
35
  import { runScan } from "./scan.js";
35
36
  import { workspaceOfToken } from "./tokenWorkspace.js";
36
37
  export { APP_LABELS, INIT_APPS, PASSPORT_CLOUD };
@@ -224,7 +225,7 @@ export class Init {
224
225
  detected.apps = await this.soft("apps", "Apps", () => detectApps(this));
225
226
  detected.keys = await this.soft("keys", "Keys", async () => (await import("./initKeysStep.js")).detectKeys(this));
226
227
  detected.autopilot = await this.soft("autopilot", "Autopilot", () => detectAutopilot(this));
227
- detected.environments = await this.soft("environments", "Environments", () => detectEnvironments(this));
228
+ detected.environments = await this.soft("environments", "Where", () => detectEnvironments(this));
228
229
  detected.agents = await this.soft("agents", "Agents", () => detectAgentsPlan(this));
229
230
  detected.guard = await this.soft("guard", "Guard", () => detectGuard(this));
230
231
  this.screen.idle();
@@ -309,10 +310,11 @@ export class Init {
309
310
  return;
310
311
  }
311
312
  const findings = this.scan.report.findings;
312
- const providers = [...new Set(findings.map((finding) => finding.provider))];
313
+ // Key names read the same everywhere: alphabetical, joined with "and".
314
+ const providers = [...new Set(findings.map((finding) => finding.provider))].sort((a, b) => a.localeCompare(b));
313
315
  const shownProviders = providers.length > 4 ? [...providers.slice(0, 3), `${providers.length - 3} more`] : providers;
314
316
  const line = findings.length
315
- ? `${findings.length} ${findings.length === 1 ? "key" : "keys"} your agents can reach: ${providers.length > 4 ? listOf(shownProviders) : shownProviders.join(", ")}`
317
+ ? `${countOf(findings.length, "key")} your agents can reach: ${listOf(shownProviders)}`
316
318
  : "No keys found. You can still connect apps.";
317
319
  // The scan's own last line of defense applies here too.
318
320
  this.screen.step("Scan", this.scan.leaks(line) ? "Found keys your agents can reach." : line);
package/dist/cliKeys.d.ts CHANGED
@@ -65,6 +65,9 @@ export type MoveSummary = {
65
65
  };
66
66
  /** The computer's name people recognize: "Ramish's MacBook Pro", else its host. */
67
67
  export declare function computerName(platform?: NodeJS.Platform): string;
68
+ /** When a key was last used: "used 3 min ago", "not used yet". `passport
69
+ * status` and `passport keys` say it the same way. */
70
+ export declare function keyUse(lastUsedAt: number | null | undefined, now: number): string;
68
71
  /** Keys still here, by provider, and the .env files Passport leaves alone. */
69
72
  export declare function scanCounts(scan: ScanResult): {
70
73
  remaining: Record<string, number>;