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/cliUndo.d.ts CHANGED
@@ -20,7 +20,9 @@ export declare function backupAge(takenAt: number, now?: number): string;
20
20
  export declare function undoWindowLeft(expiresAt: number, now?: number): string;
21
21
  export type UndoDependencies = AutopilotDependencies & {
22
22
  /** The terminal that asks; tests script it. */
23
- terminal?: Pick<InitTerminal, "interactive" | "unicode" | "question">;
23
+ terminal?: Pick<InitTerminal, "interactive" | "unicode" | "question"> & {
24
+ color?: boolean;
25
+ };
24
26
  };
25
27
  type Option = {
26
28
  id: string;
package/dist/cliUndo.js CHANGED
@@ -14,6 +14,8 @@ import { api, json } from "./cliAutopilot.js";
14
14
  import { failure, safeApiError, timeoutMs } from "./cliSupport.js";
15
15
  import { processTerminal } from "./initUi.js";
16
16
  import { askYesNo } from "./cliAsk.js";
17
+ import { mark as markOf } from "./term.js";
18
+ import { countOf } from "./plural.js";
17
19
  /* Checked copies of shared/undoContract.ts (the CLI can't import shared/);
18
20
  * cliUndo.test.ts fails if they drift. */
19
21
  export const UNDO_RETENTION_DAYS = 7;
@@ -24,12 +26,12 @@ export function backupAge(takenAt, now = Date.now()) {
24
26
  if (minutes < 1)
25
27
  return "just now";
26
28
  if (minutes < 60)
27
- return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
29
+ return `${countOf(minutes, "minute")} ago`;
28
30
  const hours = Math.round(minutes / 60);
29
31
  if (hours < 24)
30
- return `${hours} hour${hours === 1 ? "" : "s"} ago`;
32
+ return `${countOf(hours, "hour")} ago`;
31
33
  const days = Math.round(hours / 24);
32
- return `${days} day${days === 1 ? "" : "s"} ago`;
34
+ return `${countOf(days, "day")} ago`;
33
35
  }
34
36
  /** "Undo available for 6 more days", "Undo available for 3 more hours". */
35
37
  export function undoWindowLeft(expiresAt, now = Date.now()) {
@@ -39,12 +41,12 @@ export function undoWindowLeft(expiresAt, now = Date.now()) {
39
41
  const hours = Math.floor(left / 3_600_000);
40
42
  if (hours >= 24) {
41
43
  const days = Math.floor(hours / 24);
42
- return `Undo available for ${days} more day${days === 1 ? "" : "s"}.`;
44
+ return `Undo available for ${countOf(days, "more day")}.`;
43
45
  }
44
46
  if (hours >= 1)
45
- return `Undo available for ${hours} more hour${hours === 1 ? "" : "s"}.`;
47
+ return `Undo available for ${countOf(hours, "more hour")}.`;
46
48
  const minutes = Math.max(1, Math.floor(left / 60_000));
47
- return `Undo available for ${minutes} more minute${minutes === 1 ? "" : "s"}.`;
49
+ return `Undo available for ${countOf(minutes, "more minute")}.`;
48
50
  }
49
51
  const ACTION_ID = /^[A-Za-z0-9_-]{1,80}$/;
50
52
  const OPTION_ID = /^[a-z-]{1,40}$/;
@@ -176,7 +178,7 @@ async function load(client, requested, args, runtime) {
176
178
  }
177
179
  const body = (await fetchPreview(client, "/api/my/undo/last", args, runtime));
178
180
  if (typeof body.actionId !== "string" || !ACTION_ID.test(body.actionId)) {
179
- return failure(`Nothing to undo. ${UNDO_WORKS}`, 6, "no_backup");
181
+ return failure(`Nothing to undo. Passport keeps backups for ${UNDO_RETENTION_DAYS} days.`, 6, "no_backup");
180
182
  }
181
183
  const actionId = body.actionId;
182
184
  return {
@@ -233,7 +235,7 @@ function steps(raw) {
233
235
  .slice(0, 20);
234
236
  }
235
237
  /** What the server answered, as this command's result or failure. */
236
- function outcome(result, preview, option, unicode) {
238
+ function outcome(result, preview, option, term) {
237
239
  const { actionId } = preview;
238
240
  const status = typeof result.status === "string" ? result.status : "failed";
239
241
  const message = clean(result.message, 400) ?? "Passport couldn't run the undo.";
@@ -241,8 +243,9 @@ function outcome(result, preview, option, unicode) {
241
243
  const chosen = preview.options.length > 1 ? option.id : undefined;
242
244
  if (status === "pending") {
243
245
  const again = `passport undo ${actionId}${chosen ? ` --option ${chosen}` : ""} --yes`;
244
- return failure(/passport undo/.test(message) ? message : `${message} Once it's approved, run \`${again}\`.`, 4, "approval_pending", {
246
+ return failure(/passport undo/.test(message) ? message : `${message} Once it's approved, run the undo again.`, 4, "approval_pending", {
245
247
  ...(approvalId ? { approvalId } : {}),
248
+ ...(/passport undo/.test(message) ? {} : { hint: `Run: ${again}` }),
246
249
  next: [
247
250
  ...(approvalId
248
251
  ? [{ argv: ["passport", "wait", approvalId], description: "Wait for a person to approve the undo." }]
@@ -256,7 +259,7 @@ function outcome(result, preview, option, unicode) {
256
259
  if (status === "declined")
257
260
  return failure(message, 5, "approval_denied", approvalId ? { approvalId } : {});
258
261
  const ran = steps(result.steps);
259
- const mark = (ok) => (unicode ? (ok ? "✓" : "✗") : ok ? "+" : "x");
262
+ const mark = (ok) => markOf({ color: term.color ?? false, unicode: term.unicode }, ok ? "done" : "fail");
260
263
  const undoActionId = typeof result.undoActionId === "string" && ACTION_ID.test(result.undoActionId) ? result.undoActionId : undefined;
261
264
  return {
262
265
  json: { actionId, status, message, steps: ran, option: option.id, ...(undoActionId ? { undoActionId } : {}) },
@@ -303,5 +306,5 @@ export async function undo(args, runtime, deps = {}) {
303
306
  });
304
307
  if (response.status === 404)
305
308
  return failure(await safeApiError(response, NO_BACKUP), 6, "no_backup");
306
- return outcome(await json(response, NO_BACKUP), preview, confirmed.option, terminal.unicode);
309
+ return outcome(await json(response, NO_BACKUP), preview, confirmed.option, terminal);
307
310
  }
package/dist/cliWait.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `passport wait <approval-id> [--timeout <sec>]`: wait for a person to
3
- * decide an approval request. On a terminal it prints the approval link at
4
- * once and keeps one live line ("Waiting for Erin · 1:32 left"); piped, one
3
+ * decide an approval request. Once Passport says it is still waiting, on a
4
+ * terminal it prints the approval link and keeps one live line ("Waiting for
5
+ * Erin · 1:32 left"); piped, one
5
6
  * line once Passport says it's still pending. Light on purpose: it loads
6
7
  * before anything prints.
7
8
  */
package/dist/cliWait.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `passport wait <approval-id> [--timeout <sec>]`: wait for a person to
3
- * decide an approval request. On a terminal it prints the approval link at
4
- * once and keeps one live line ("Waiting for Erin · 1:32 left"); piped, one
3
+ * decide an approval request. Once Passport says it is still waiting, on a
4
+ * terminal it prints the approval link and keeps one live line ("Waiting for
5
+ * Erin · 1:32 left"); piped, one
5
6
  * line once Passport says it's still pending. Light on purpose: it loads
6
7
  * before anything prints.
7
8
  */
@@ -9,6 +10,7 @@ import { bool, value } from "./cliArgs.js";
9
10
  import { CliFailure, failure, resolveCliAuth, safeApiError, sleep } from "./cliSupport.js";
10
11
  import { workspaceOfToken } from "./tokenWorkspace.js";
11
12
  import { approvalLink } from "./webLinks.js";
13
+ import { countOf } from "./plural.js";
12
14
  /** Long enough to be useful, short enough for an agent's default 2-minute
13
15
  * command timeout. */
14
16
  export const WAIT_DEFAULT_SECONDS = 100;
@@ -83,14 +85,12 @@ export async function wait(args, runtime, deps = {}) {
83
85
  env: runtime.env,
84
86
  seconds: Math.max(0, Math.ceil((deadline - now()) / 1000)),
85
87
  ...(url ? { url } : {}),
86
- pipedLine: `Waiting for a decision on ${id} (up to ${totalSeconds} seconds).`,
88
+ pipedLine: `Waiting for a decision on ${id} (up to ${countOf(totalSeconds, "second")}).`,
87
89
  now
88
90
  });
89
91
  };
90
- // Before the API client loads (it brings the MCP SDK), so the first line
91
- // is on screen within a moment; only when there's a sign-in to wait with.
92
- if (runtime.stderr.isTTY && (deps.api || signedIn(args, runtime)))
93
- await announce();
92
+ // The link and the countdown come only once Passport says the request is
93
+ // still waiting: never for one that doesn't exist or is already decided.
94
94
  const { api, json } = await import("./cliMemberCall.js");
95
95
  const client = api(args, runtime, deps, (WAIT_POLL_SECONDS + 10) * 1000, true);
96
96
  try {
@@ -160,21 +160,13 @@ function approvalUrlFor(args, runtime, origin, id) {
160
160
  }
161
161
  return approvalLink(endpoint, id, workspace || undefined) ?? undefined;
162
162
  }
163
- function signedIn(args, runtime) {
164
- try {
165
- resolveCliAuth(args, runtime.env);
166
- return true;
167
- }
168
- catch {
169
- return false;
170
- }
171
- }
172
163
  /** Out of time, or Ctrl-C: the request is still open in Passport. */
173
164
  function stillWaiting(id, interrupted) {
174
165
  return failure(interrupted
175
- ? `The request is still open. Run passport wait ${id} to keep waiting.`
176
- : `Still waiting for approval. Run \`passport wait ${id}\` again, or continue with other work.`, 4, "approval_pending", {
166
+ ? "The request is still open. Keep waiting any time."
167
+ : "Still waiting for approval. Keep waiting, or continue with other work.", 4, "approval_pending", {
177
168
  approvalId: id,
169
+ hint: `Run: passport wait ${id}`,
178
170
  next: [{ argv: ["passport", "wait", id], description: "Keep waiting for this approval." }]
179
171
  });
180
172
  }
package/dist/doctor.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type Term } from "./term.js";
1
2
  export type DoctorStatus = "pass" | "warn" | "fail" | "skip";
2
3
  export type DoctorCheck = {
3
4
  id: string;
@@ -30,5 +31,7 @@ type DoctorOptions = {
30
31
  };
31
32
  export declare function nodeRuntimeSupported(version: string): boolean;
32
33
  export declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
33
- export declare function formatDoctorReport(report: DoctorReport): string;
34
+ /** Nobody is signed in here: not a fault to fix, just the next step. */
35
+ export declare function signedOut(report: DoctorReport): boolean;
36
+ export declare function formatDoctorReport(report: DoctorReport, term?: Pick<Term, "color" | "unicode">): string;
34
37
  export {};
package/dist/doctor.js CHANGED
@@ -3,6 +3,13 @@ import { readBoundedUtf8File } from "./boundedFile.js";
3
3
  import { CliGateway, CLI_PROTOCOL_TOOLS, MIN_CLI_SERVER_VERSION } from "./cliClient.js";
4
4
  import { activeProfilePath, assertProfileName, credsPath } from "./credentials.js";
5
5
  import { ensurePrivateDirectory } from "./credentialStorage.js";
6
+ import { countOf } from "./plural.js";
7
+ import { mark } from "./term.js";
8
+ /** Piped: the house marks without color. */
9
+ const PLAIN = { color: false, unicode: true };
10
+ const SIGN_IN = "Run: passport login";
11
+ const NO_SIGN_IN = "No sign-in is saved on this computer.";
12
+ const NO_PROFILE = "No usable profile is configured.";
6
13
  const DOCTOR_CREDENTIAL_MAX_BYTES = 1024 * 1024;
7
14
  const DOCTOR_ACTIVE_PROFILE_MAX_BYTES = 512;
8
15
  function check(checks, id, status, summary, action) {
@@ -26,8 +33,8 @@ function inspectStore(checks, agentMode) {
26
33
  check(checks, "credential_store", agentMode && missing ? "skip" : "fail", missing
27
34
  ? agentMode
28
35
  ? "No local credential store is needed in agent-key mode."
29
- : "No local credential store exists."
30
- : "The credential store could not be inspected.", missing && !agentMode ? "Run `passport login`, or `passport init` to set up step by step." : undefined);
36
+ : NO_SIGN_IN
37
+ : "The credential store could not be inspected.", missing && !agentMode ? SIGN_IN : undefined);
31
38
  return { profiles: empty, count: 0 };
32
39
  }
33
40
  if (stat.isSymbolicLink() || !stat.isFile()) {
@@ -84,10 +91,10 @@ function inspectStore(checks, agentMode) {
84
91
  }
85
92
  const count = Object.keys(profiles).length;
86
93
  if (invalid.length) {
87
- check(checks, "credential_store", "fail", `The credential store contains ${invalid.length} invalid profile record${invalid.length === 1 ? "" : "s"}.`, "Remove the damaged record or recreate the store with `passport login`.");
94
+ check(checks, "credential_store", "fail", `The credential store has ${countOf(invalid.length, "damaged profile")}.`, "Remove the damaged profile, or sign in again to replace it.\nRun: passport login");
88
95
  }
89
96
  else {
90
- check(checks, "credential_store", "pass", `Credential store parsed cleanly with ${count} profile${count === 1 ? "" : "s"}.`);
97
+ check(checks, "credential_store", "pass", `Your saved sign-ins are readable: ${countOf(count, "profile")}.`);
91
98
  }
92
99
  return { profiles, count };
93
100
  }
@@ -127,10 +134,10 @@ function inspectActiveProfile(checks, store) {
127
134
  return undefined;
128
135
  }
129
136
  if (!store.profiles[active]) {
130
- check(checks, "active_profile", "fail", `The active profile "${active}" is not stored.`, "Run `passport profiles`, then `passport use <name>`.");
137
+ check(checks, "active_profile", "fail", `The active profile, ${active}, isn't saved on this computer.`, "Run `passport profiles`, then `passport use <name>`.");
131
138
  return undefined;
132
139
  }
133
- check(checks, "active_profile", "pass", `Active profile is "${active}".`);
140
+ check(checks, "active_profile", "pass", `Active profile: ${active}.`);
134
141
  return active;
135
142
  }
136
143
  function errorText(error, redact) {
@@ -183,7 +190,7 @@ export async function runDoctor(options) {
183
190
  try {
184
191
  const normalized = options.normalizeEndpoint(options.env.PASSPORT_ENDPOINT);
185
192
  auth = { kind: "agent-key", endpoint: normalized, agentKey: options.env.PASSPORT_AGENT_KEY };
186
- check(checks, "auth_config", "pass", "Agent-key environment variables are complete (secret value not shown).");
193
+ check(checks, "auth_config", "pass", "PASSPORT_AGENT_KEY and PASSPORT_ENDPOINT are both set.");
187
194
  }
188
195
  catch (error) {
189
196
  check(checks, "auth_config", "fail", errorText(error, options.redactError), "Set PASSPORT_ENDPOINT to the HTTPS workspace MCP endpoint.");
@@ -194,24 +201,20 @@ export async function runDoctor(options) {
194
201
  const names = Object.keys(store.profiles).sort();
195
202
  const candidate = selectedProfileCandidate(options, store, active);
196
203
  if (!candidate) {
197
- check(checks, "auth_config", "fail", names.length > 1
198
- ? `No profile was selected from ${names.length} stored profiles.`
199
- : "No usable profile is configured.", names.length > 1
200
- ? "Run `passport profiles`, then `passport use <name>` or retry with `--profile <name>`."
201
- : "Run `passport login`, or `passport init` to set up step by step.");
204
+ check(checks, "auth_config", "fail", names.length > 1 ? `No profile was selected from ${names.length} stored profiles.` : NO_PROFILE, names.length > 1 ? "Pick one, or add --profile <name>.\nRun: passport use <name>" : SIGN_IN);
202
205
  }
203
206
  else {
204
207
  try {
205
208
  assertProfileName(candidate);
206
209
  const saved = store.profiles[candidate];
207
210
  if (!saved) {
208
- check(checks, "auth_config", "fail", "The selected profile does not exist or is malformed.", "Choose another profile or run `passport login` to recreate it.");
211
+ check(checks, "auth_config", "fail", "The selected profile does not exist or is malformed.", "Pick another profile, or sign in again.\nRun: passport login");
209
212
  }
210
213
  else {
211
214
  const normalized = options.normalizeEndpoint(saved.endpoint);
212
215
  selectedProfile = candidate;
213
216
  auth = { kind: "profile", endpoint: normalized, profile: candidate, refreshToken: saved.refreshToken };
214
- check(checks, "auth_config", "pass", `Profile "${candidate}" has a credential and a secure endpoint (secret value not shown).`);
217
+ check(checks, "auth_config", "pass", `Profile ${candidate} has a saved sign-in for ${new URL(normalized).host}.`);
215
218
  }
216
219
  }
217
220
  catch (error) {
@@ -222,8 +225,8 @@ export async function runDoctor(options) {
222
225
  let endpointOrigin;
223
226
  let server;
224
227
  if (!auth) {
225
- check(checks, "server_reachability", "skip", "Server checks were skipped because authentication is not configured.");
226
- check(checks, "server_protocol", "skip", "CLI protocol checks were skipped.");
228
+ check(checks, "server_reachability", "skip", "Skipped the server checks: not signed in.");
229
+ check(checks, "server_protocol", "skip", "Skipped checking that this CLI and the server match.");
227
230
  }
228
231
  else {
229
232
  endpointOrigin = new URL(auth.endpoint).origin;
@@ -252,12 +255,12 @@ export async function runDoctor(options) {
252
255
  }
253
256
  catch (error) {
254
257
  check(checks, "authentication", "fail", `Authenticated MCP handshake failed: ${errorText(error, options.redactError)}`, auth.kind === "profile"
255
- ? "Run `passport login` to refresh this profile, then retry."
258
+ ? "Sign in again, then try this once more.\nRun: passport login"
256
259
  : "Verify PASSPORT_AGENT_KEY and its workspace access.");
257
260
  check(checks, "server_protocol", "skip", "CLI protocol checks could not run because the authenticated handshake failed.");
258
261
  }
259
262
  if (gateway) {
260
- check(checks, "authentication", "pass", `Authenticated as ${auth.kind === "profile" ? `profile "${auth.profile}"` : "an agent key"} (credential value not shown).`);
263
+ check(checks, "authentication", "pass", `Passport accepted ${auth.kind === "profile" ? `the sign-in for ${auth.profile}` : "the agent key"}.`);
261
264
  try {
262
265
  const protocol = await gateway.protocolDiagnostics();
263
266
  const safeServer = protocol.server
@@ -305,14 +308,30 @@ export async function runDoctor(options) {
305
308
  checks
306
309
  };
307
310
  }
308
- export function formatDoctorReport(report) {
309
- const icon = { pass: "✓", warn: "!", fail: "✗", skip: "-" };
311
+ const MARK_OF = { pass: "done", warn: "warn", fail: "fail", skip: "skip" };
312
+ /** Nobody is signed in here: not a fault to fix, just the next step. */
313
+ export function signedOut(report) {
314
+ const failed = report.checks.filter((item) => item.status === "fail");
315
+ return (!report.ok &&
316
+ report.auth === "none" &&
317
+ report.profileCount === 0 &&
318
+ failed.every((item) => item.summary === NO_SIGN_IN || item.summary === NO_PROFILE));
319
+ }
320
+ export function formatDoctorReport(report, term = PLAIN) {
310
321
  const lines = [`Passport doctor ${report.version}`];
322
+ const shown = new Set();
311
323
  for (const item of report.checks) {
312
- lines.push(`${icon[item.status]} ${item.summary}`);
313
- if (item.action)
314
- lines.push(` Fix: ${item.action}`);
324
+ lines.push(`${mark(term, MARK_OF[item.status])} ${item.summary}`);
325
+ // Each fix once, under the first check it fixes.
326
+ if (item.action && !shown.has(item.action)) {
327
+ shown.add(item.action);
328
+ lines.push(...item.action.split("\n").map((line) => ` ${line}`));
329
+ }
315
330
  }
316
- lines.push(report.ok ? "Healthy: all required checks passed." : "Needs attention: fix the failed checks above.");
331
+ lines.push(report.ok
332
+ ? "Healthy: all required checks passed."
333
+ : signedOut(report)
334
+ ? "Not signed in to Passport."
335
+ : "Needs attention: fix the failed checks above.");
317
336
  return lines.join("\n");
318
337
  }
@@ -2,7 +2,7 @@
2
2
  * `passport exec` with no key in Passport. Passport can't see this computer,
3
3
  * so its answer says to add one in Apps; when this computer still has the
4
4
  * CLI's own sign-in, the fix is one command here instead:
5
- * "Run passport keys move railway". Read here only; nothing is sent.
5
+ * "Run: passport keys move railway". Read here only; nothing is sent.
6
6
  */
7
7
  import { CliFailure, type Runtime } from "./cliSupport.js";
8
8
  import { type ExecVendor } from "./execVendors.js";
package/dist/execNoKey.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * `passport exec` with no key in Passport. Passport can't see this computer,
3
3
  * so its answer says to add one in Apps; when this computer still has the
4
4
  * CLI's own sign-in, the fix is one command here instead:
5
- * "Run passport keys move railway". Read here only; nothing is sent.
5
+ * "Run: passport keys move railway". Read here only; nothing is sent.
6
6
  */
7
7
  import { CliFailure } from "./cliSupport.js";
8
8
  import { EXEC_VENDOR_NAMES } from "./execVendors.js";
@@ -13,7 +13,8 @@ export function keyHereFailure(error, vendor, runtime, home) {
13
13
  if (!here)
14
14
  return error;
15
15
  const name = EXEC_VENDOR_NAMES[vendor];
16
- return new CliFailure(`No ${name} key in Passport yet, but this computer has one. Run passport keys move ${vendor}`, 3, "no_key", {
16
+ return new CliFailure(`No ${name} key in Passport yet, but this computer has one.`, 3, "no_key", {
17
+ hint: `Run: passport keys move ${vendor}`,
17
18
  next: [
18
19
  { argv: ["passport", "keys", "move", vendor], description: `Move this computer's ${name} key into Passport.` }
19
20
  ]
package/dist/execShims.js CHANGED
@@ -249,10 +249,10 @@ export function shimPathAdvice(shims, env, platform = process.platform) {
249
249
  const home = env.HOME || homedir();
250
250
  const line = pathLine(shimDir(), env, home, platform);
251
251
  if (shims.some((shim) => shim.state === "not_on_path"))
252
- return `${line}, then open a new terminal.`;
252
+ return line;
253
253
  const shadowed = shims.find((shim) => shim.state === "shadowed");
254
254
  if (shadowed) {
255
- return `Your PATH finds the ${EXEC_VENDOR_NAMES[shadowed.vendor]} CLI before Passport's folder. ${line}, then open a new terminal.`;
255
+ return `Your PATH finds the ${EXEC_VENDOR_NAMES[shadowed.vendor]} CLI before Passport's folder. ${line}`;
256
256
  }
257
257
  return undefined;
258
258
  }
@@ -64,6 +64,7 @@ export const FAST_PROBES = [
64
64
  "npx tsc --noEmit",
65
65
  "node --test",
66
66
  "pytest -q",
67
+ // copy-style-allow three-dots: go's own package pattern, not prose
67
68
  "go test ./...",
68
69
  "cargo test",
69
70
  "cargo check",
@@ -221,13 +221,14 @@ export function environmentLines(plan, width) {
221
221
  lines.push(...wrap(namesByApp(entries), width, ENV_LABEL[kind].padEnd(pad), " ".repeat(pad)));
222
222
  }
223
223
  if (unplaced.length) {
224
- lines.push(...wrap(`Treated as Production until placed: ${namesByApp(unplaced)}. Change it in Rules.`, width));
224
+ const pronoun = unplaced.length === 1 ? "it" : "them";
225
+ lines.push(...wrap(`Treated as Production until placed: ${namesByApp(unplaced)}. Change ${pronoun} in Rules.`, width));
225
226
  }
226
227
  for (const row of plan.project) {
227
228
  const kind = ENV_LABEL[row.kind] ?? row.kind;
228
229
  const note = row.assumed && !namedForItsKind(row.resource, row.kind) ? `${kind} until placed` : kind;
229
230
  const how = row.how === "unreadable" ? `unreadable: ${row.note ?? ""}` : row.how;
230
- lines.push(...wrap(`This folder: ${row.vendor} ${row.resource} · ${how} · ${note}`, width));
231
+ lines.push(...wrap(`This folder: ${row.vendor} ${row.resource} (${how}), counted as ${note}`, width));
231
232
  }
232
233
  return lines;
233
234
  }
@@ -357,7 +358,7 @@ export async function applyAutopilot(s, plan, mode) {
357
358
  changed = true;
358
359
  s.summary.changed = true;
359
360
  }
360
- s.autopilotSummary = `Autopilot on. You'll be asked only for ${askedFor(presets)}.`;
361
+ s.autopilotSummary = `Autopilot on: asks only for ${askedFor(presets)}`;
361
362
  s.record("autopilot", changed ? "done" : "already_set_up", {
362
363
  presets,
363
364
  floors: view.floors
@@ -387,7 +388,7 @@ function allowlists(s, policy) {
387
388
  }));
388
389
  if (touched.length) {
389
390
  s.allowlistsTouched = touched.map((change) => change.name);
390
- s.screen.result("done", `Added your everyday commands to ${listOf(touched.map((change) => change.name))}'s own allowlist, so tests, builds, and commits run without a prompt.`, "Autopilot");
391
+ s.screen.result("done", `Added your everyday commands to the allowlists in ${listOf(touched.map((change) => change.name))}, so tests, builds, and commits run without a prompt.`, "Autopilot");
391
392
  }
392
393
  }
393
394
  catch {
@@ -509,11 +509,12 @@ export function isOtherPassportInstall(path, version) {
509
509
  /** One line a person can paste to put `passport` on PATH. Printed, never run. */
510
510
  export function pathLine(binDir, env, home, platform) {
511
511
  if (platform === "win32")
512
- return `Add ${binDir} to your PATH to run passport from any terminal.`;
512
+ return `Add ${binDir} to your PATH to run Passport from any terminal.`;
513
513
  const shown = binDir === home || binDir.startsWith(`${home}/`) ? `$HOME${binDir.slice(home.length)}` : binDir;
514
514
  const shell = basename(env.SHELL ?? "");
515
515
  if (shell === "fish")
516
- return `Add passport to your shell: fish_add_path ${shown.replace("$HOME", "~")}`;
516
+ return `${PATH_LEAD}: fish_add_path ${shown.replace("$HOME", "~")}`;
517
517
  const rc = shell === "bash" ? (platform === "darwin" ? "~/.bash_profile" : "~/.bashrc") : "~/.zshrc";
518
- return `Add passport to your shell: echo 'export PATH="${shown}:$PATH"' >> ${rc}`;
518
+ return `${PATH_LEAD}: echo 'export PATH="${shown}:$PATH"' >> ${rc}`;
519
519
  }
520
+ const PATH_LEAD = "Add Passport's folder to your PATH, then open a new terminal";
@@ -35,7 +35,7 @@ export async function detectKeys(s) {
35
35
  }
36
36
  const plan = {
37
37
  local,
38
- names: [...new Set(local.map((key) => EXEC_VENDOR_NAMES[key.vendor]))],
38
+ names: [...new Set(local.map((key) => EXEC_VENDOR_NAMES[key.vendor]))].sort((a, b) => a.localeCompare(b)),
39
39
  support: "ok",
40
40
  envFiles
41
41
  };
@@ -203,7 +203,9 @@ export async function applyAgents(s, plan, mode) {
203
203
  }
204
204
  /** Claude Desktop's custom connector: copy its URL, never print a key. */
205
205
  export function desktopLine(copied) {
206
- return `Claude Desktop: Settings → Connectors → Add custom connector → paste the URL${copied ? " (copied)" : ""}`;
206
+ return copied
207
+ ? "Claude Desktop: paste the copied URL in Settings → Connectors → Add custom connector"
208
+ : "Claude Desktop: paste the URL in Settings → Connectors → Add custom connector";
207
209
  }
208
210
  /** Put Claude Desktop's connector URL on the clipboard. Returns whether it did. */
209
211
  export function copyDesktopUrl(s, plan) {
@@ -325,7 +327,7 @@ async function guardSetup(s, plan, mode) {
325
327
  return;
326
328
  }
327
329
  // Copying the CLI holds the event loop for a second or two: say so first.
328
- s.screen.working("Installing a stable copy of passport for the hooks…", "Guard", true);
330
+ s.screen.working("Installing a stable copy of Passport for the hooks…", "Guard", true);
329
331
  let stable;
330
332
  try {
331
333
  stable = (s.deps.install ?? ensureStableCommand)(installContext(s));
@@ -4,7 +4,5 @@ import { type InitSession, type Summary } from "./initState.js";
4
4
  export declare function rotateOldKeysLine(summary: Pick<Summary, "steps">): string | undefined;
5
5
  /** A ✓ list of what's true now, what's left for the person, and one next command. */
6
6
  export declare function outro(s: InitSession): void;
7
- /** "Next: add passport to your shell:" and the command, on its own line and
8
- * never broken. Too narrow for the `echo … >> ~/.zshrc` form, it names the
9
- * file and the shorter line to add to it. */
7
+ /** What to do next about PATH: the step, then the command on its own line. */
10
8
  export declare function pathNext(line: string, width: number): string[];
package/dist/initOutro.js CHANGED
@@ -12,6 +12,7 @@ import { EXEC_TOKEN_PAGES, EXEC_VENDOR_NAMES } from "./execVendors.js";
12
12
  import { AGENT_NAMES } from "./initAgents.js";
13
13
  import { CODEX_BLOCK_ONLY } from "./cliHookInstall.js";
14
14
  import { pathLine } from "./initInstall.js";
15
+ import { pathLines } from "./pathLines.js";
15
16
  import { desktopLine } from "./initLocalSteps.js";
16
17
  import { TRY_IT, appLabel } from "./initState.js";
17
18
  import { listOf } from "./initUi.js";
@@ -105,9 +106,9 @@ export function outro(s) {
105
106
  function agentFollowUps(s) {
106
107
  const items = [];
107
108
  if (s.codexNext)
108
- items.push(warn(`Codex: sign in to Passport once: ${s.codexNext}`));
109
+ items.push(warn(`Codex: sign in to Passport once.\nRun: ${s.codexNext}`));
109
110
  if (s.codexTrust)
110
- items.push(warn(`Codex: open Codex → /hooks and trust Passport's hooks. ${CODEX_BLOCK_ONLY}`));
111
+ items.push(warn(`Codex: Open Codex → /hooks and trust Passport's hooks. ${CODEX_BLOCK_ONLY}`));
111
112
  const rows = (s.summary.steps.agents?.agents ?? []);
112
113
  if (s.terminal.interactive && rows.some((row) => row.agent === "claude" && row.status === "needs_attention")) {
113
114
  items.push(warn(desktopLine(Boolean(s.desktopCopied))));
@@ -124,25 +125,16 @@ function nextCommand(s, waiting) {
124
125
  return pathNext(line, s.terminal.width);
125
126
  }
126
127
  if (waiting && !s.terminal.interactive)
127
- return ["Next: passport connect --wait 300"];
128
+ return ["Run: passport connect --wait 300"];
128
129
  const agent = s.agentsReady[0];
129
130
  if (agent && s.newlyAddedClaudeCode) {
130
131
  const app = s.connected[0] ?? s.candidates[0];
131
132
  const ask = app ? TRY_IT[app] : "list your Passport tools";
132
133
  return wrap(`Next: in Claude Code, run /mcp to sign in, then ask it to ${ask}.`, s.terminal.width);
133
134
  }
134
- return ["Next: passport status"];
135
+ return ["Run: passport status"];
135
136
  }
136
- /** "Next: add passport to your shell:" and the command, on its own line and
137
- * never broken. Too narrow for the `echo … >> ~/.zshrc` form, it names the
138
- * file and the shorter line to add to it. */
137
+ /** What to do next about PATH: the step, then the command on its own line. */
139
138
  export function pathNext(line, width) {
140
- const [lead, command] = line.split(": ");
141
- if (!command)
142
- return [`Next: ${line}`];
143
- const appended = command.match(/^echo 'export PATH="\$HOME(\/[^"]+):\$PATH"' >> (\S+)$/);
144
- if (appended && 2 + command.length > width) {
145
- return [`Next: add this line to ${appended[2]}:`, ` export PATH=~${appended[1]}:$PATH`];
146
- }
147
- return [`Next: ${lead.charAt(0).toLowerCase()}${lead.slice(1)}:`, ` ${command}`];
139
+ return pathLines(line, width);
148
140
  }
package/dist/initPlan.js CHANGED
@@ -72,7 +72,7 @@ function planKeys(b, keys, options) {
72
72
  b.will("keys", `Move your ${listOf(keys.names)} ${one ? "key" : "keys"} into Passport and sign ${one ? "that CLI" : "those CLIs"} out on this computer`);
73
73
  }
74
74
  else {
75
- b.kept("keys", `Your ${listOf(keys.names)} ${one ? "key stays" : "keys stay"} on this computer. Move ${one ? "it" : "them"} any time: passport keys move`);
75
+ b.kept("keys", `Your ${listOf(keys.names)} ${one ? "key stays" : "keys stay"} on this computer. Move ${one ? "it" : "them"} any time.\nRun: passport keys move`);
76
76
  }
77
77
  }
78
78
  for (const file of keys?.envFiles ?? [])
@@ -103,7 +103,7 @@ function planDesktop(b, agents, options) {
103
103
  if (options.interactive)
104
104
  b.will("agents", "Copy the Claude Desktop connector URL for you to paste");
105
105
  else
106
- b.you("agents", `Claude Desktop: Settings → Connectors → Add custom connector → paste ${agents.context?.url ?? "the URL"}`);
106
+ b.you("agents", `Claude Desktop: in Settings → Connectors → Add custom connector, paste ${agents.context?.url ?? "the URL"}`);
107
107
  }
108
108
  function planGuard(b, s, guard) {
109
109
  if (!guard || guard.skipped)
@@ -170,13 +170,13 @@ export function showPlan(s, d, plan) {
170
170
  });
171
171
  };
172
172
  screen.gap();
173
- section("Will", plan.will);
173
+ section("Plan", plan.will);
174
174
  if (plan.edits.length) {
175
175
  screen.endStep();
176
176
  screen.step("Edits", `${listOf(plan.edits)}. Keeps a backup of each.`);
177
177
  }
178
- section("Already set up", plan.alreadySetUp, "done");
179
- section("Not changed", plan.notChanged, "skip");
178
+ section("Done", plan.alreadySetUp, "done");
179
+ section("Kept", plan.notChanged, "skip");
180
180
  section("You do", plan.youDo, "warn");
181
181
  const autopilot = d.autopilot;
182
182
  if (autopilot?.kind === "autopilot") {
@@ -187,7 +187,7 @@ export function showPlan(s, d, plan) {
187
187
  }
188
188
  if (d.environments && (d.environments.status === "ok" || d.environments.project.length)) {
189
189
  screen.endStep();
190
- screen.block(environmentLines(d.environments, screen.contentWidth), "Environments");
190
+ screen.block(environmentLines(d.environments, screen.contentWidth), "Where");
191
191
  }
192
192
  screen.endStep();
193
193
  }
package/dist/initUi.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Runtime } from "./cliSupport.js";
2
2
  import { supportsUnicode, visibleLength, type Mark as TermMark } from "./term.js";
3
3
  export { supportsUnicode, visibleLength };
4
- export declare const LABEL_WIDTH = 10;
4
+ export declare const LABEL_WIDTH = 11;
5
5
  export declare const CONTINUATION: string;
6
6
  export type Mark = Extract<TermMark, "done" | "skip" | "warn" | "wait">;
7
7
  export declare class InitPaused extends Error {
@@ -43,8 +43,6 @@ export type TerminalInput = NodeJS.ReadableStream & {
43
43
  export declare function discardTypeAhead(stdin: TerminalInput, ms?: number): Promise<boolean>;
44
44
  /** The real terminal behind a Runtime. */
45
45
  export declare function processTerminal(runtime: Runtime, platform: NodeJS.Platform, json: boolean): InitTerminal;
46
- /** Word-wrap without breaking a URL, path, or `passport` command. */
47
- export declare function wrapText(text: string, width: number): string[];
48
46
  /**
49
47
  * Rows of cells padded so the columns line up, two spaces apart. Null when the
50
48
  * widest row doesn't fit in `width`: the caller lays those rows out another way.
@@ -83,7 +81,7 @@ export declare class InitScreen {
83
81
  private get liveColumns();
84
82
  header(): void;
85
83
  /** The lead of a step's first row: ` Apps `, or a row of its own for
86
- * a label wider than the column ("Environments"). */
84
+ * a label wider than the column. */
87
85
  private leadFor;
88
86
  private emit;
89
87
  /** Something new is on screen; the activity clock starts again. */