@join-pantheon/cli 0.35.3-rc.1 → 0.36.0-rc.1

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.
@@ -85,6 +85,36 @@ export const SECRET_HOME_PATHS = [
85
85
  { rel: ".git-credentials", dir: false },
86
86
  { rel: ".claude/.credentials.json", dir: false },
87
87
  { rel: "AppData/Roaming/GitHub CLI", dir: true },
88
+ { rel: ".pypirc", dir: false, homeOnly: true },
89
+ { rel: ".gem/credentials", dir: false, homeOnly: true },
90
+ { rel: ".config/doctl", dir: true, homeOnly: true },
91
+ { rel: ".railway", dir: true, homeOnly: true },
92
+ { rel: ".fly", dir: true, homeOnly: true },
93
+ { rel: ".config/stripe", dir: true, homeOnly: true },
94
+ { rel: ".local/share/com.vercel.cli", dir: true, homeOnly: true },
95
+ { rel: "Library/Application Support/com.vercel.cli", dir: true, homeOnly: true },
96
+ { rel: ".vault-token", dir: false, homeOnly: true },
97
+ { rel: ".codex", dir: true, homeOnly: true },
98
+ { rel: ".copilot", dir: true, homeOnly: true },
99
+ { rel: ".config/github-copilot", dir: true, homeOnly: true },
100
+ { rel: ".cursor", dir: true, homeOnly: true },
101
+ { rel: ".config/cursor", dir: true, homeOnly: true },
102
+ { rel: ".gemini", dir: true, homeOnly: true },
103
+ { rel: ".kiro", dir: true, homeOnly: true },
104
+ { rel: ".mcp-auth", dir: true, homeOnly: true },
105
+ { rel: ".config/op", dir: true, homeOnly: true },
106
+ { rel: ".password-store", dir: true, homeOnly: true },
107
+ { rel: ".local/share/keyrings", dir: true, homeOnly: true },
108
+ { rel: ".zsh_history", dir: false, homeOnly: true },
109
+ { rel: ".bash_history", dir: false, homeOnly: true },
110
+ { rel: "Library/Application Support/Google/Chrome", dir: true, homeOnly: true },
111
+ { rel: "Library/Application Support/BraveSoftware", dir: true, homeOnly: true },
112
+ { rel: "Library/Application Support/Arc", dir: true, homeOnly: true },
113
+ { rel: "Library/Application Support/Firefox", dir: true, homeOnly: true },
114
+ { rel: ".config/google-chrome", dir: true, homeOnly: true },
115
+ { rel: ".config/chromium", dir: true, homeOnly: true },
116
+ { rel: ".config/BraveSoftware", dir: true, homeOnly: true },
117
+ { rel: ".mozilla", dir: true, homeOnly: true },
88
118
  ];
89
119
  export const GIT_DENY_RULES = [
90
120
  "Bash(git -c *)", "Bash(git -C *)", "Bash(git --config-env*)", "Bash(git --exec-path*)", "Bash(git --git-dir*)", "Bash(git --work-tree*)",
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ process.emitWarning = ((warning, ...rest) => {
8
8
  });
9
9
  import { randomBytes } from "node:crypto";
10
10
  import { emailSuggestion, gitConfigValue, isGithubNoreply, pantheonCommand, signinCommand, usernameSuggestion } from "./onboard-defaults.js";
11
- import { closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
11
+ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
12
12
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
13
13
  import { PantheonClient } from "./client.js";
14
14
  import { agentSpawn, CmdLineUnsafe } from "./which.js";
@@ -24,9 +24,9 @@ import { DEFAULT_REMINDER_MS, ensureNativeNotifier, HumanNotifier, hudBinaryPath
24
24
  import { linuxDesktopReachable } from "./notice-linux.js";
25
25
  import { desktopUnavailable, hostEnv } from "./host-env.js";
26
26
  import { commandState } from "./command-state.js";
27
- import { AGENT_SURFACES, applyProfileInit, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
27
+ import { AGENT_SURFACES, applyProfileInit, setupChosen, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
28
28
  import { runGuide, terminalIO, questionOrNull, parseSetupFlags, questionnaire, optOutsFrom, decisionAreasProblem, ALERT_WORDS, AUTOPILOT_WAKE_OFF } from "./setup-guide.js";
29
- import { APPROVED_ENV, unsandboxedRisk, beginApproval, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, whoIsAsking } from "./setup-changes.js";
29
+ import { APPROVED_ENV, unsandboxedRisk, beginApproval, agentLabel, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, whoIsAsking } from "./setup-changes.js";
30
30
  import { selectActs, formatAct, resolveRef } from "./history-view.js";
31
31
  import { doctor, ownProcesses, render, shareBlock } from "./doctor.js";
32
32
  import { FEEDBACK_ADDRESS } from "./feedback.js";
@@ -62,6 +62,7 @@ import { updateBanner } from "./update-check.js";
62
62
  import { inWokenRun } from "./worker-policy.js";
63
63
  import { childNodeFlags, joinInstructions, managedLayout, relayServesInstaller } from "./managed.js";
64
64
  import { spawn } from "node:child_process";
65
+ import { EXIT, exitCodeFor, exitReason, inviteRefusalCode } from "./exit-codes.js";
65
66
  import { QUEUED_SEND_DEADLINE_MS } from "./hud-queue.js";
66
67
  const argv = process.argv.slice(2);
67
68
  for (let i = argv.length - 1; i >= 1; i--) {
@@ -70,10 +71,33 @@ for (let i = argv.length - 1; i >= 1; i--) {
70
71
  argv.splice(i, 1, m[1], m[2]);
71
72
  }
72
73
  const cmd = argv[0] ?? "help";
74
+ const JSON_OUT = argv.includes("--json") && ["join", "start", "doctor", "status"].includes(cmd);
75
+ let jsonSaid = false;
76
+ function sayJson(o) {
77
+ if (jsonSaid)
78
+ return;
79
+ jsonSaid = true;
80
+ try {
81
+ writeSync(1, JSON.stringify(o) + "\n");
82
+ }
83
+ catch { }
84
+ }
85
+ if (JSON_OUT) {
86
+ console.log = (...a) => console.error(...a);
87
+ process.on("exit", (code) => sayJson({ status: code === 0 ? "ok" : code === EXIT.waiting ? "waiting" : "error", code, reason: exitReason(code) }));
88
+ }
73
89
  function signedQuery(cfg, method, path, params, at = Date.now()) {
74
- const full = { ...params, pubkey: cfg.publicKey, ts: at };
90
+ let aud;
91
+ try {
92
+ aud = new URL(cfg.relay.replace(/^ws/, "http")).host.toLowerCase();
93
+ }
94
+ catch {
95
+ aud = undefined;
96
+ }
97
+ const named = aud ? { ...params, aud } : params;
98
+ const full = { ...named, pubkey: cfg.publicKey, ts: at };
75
99
  const sig = signAccount(cfg.privateKey, method, path, full, at);
76
- return new URLSearchParams({ ...params, pubkey: cfg.publicKey, ts: String(at), sig }).toString();
100
+ return new URLSearchParams({ ...named, pubkey: cfg.publicKey, ts: String(at), sig }).toString();
77
101
  }
78
102
  async function signedFetch(cfg, method, path, params = {}) {
79
103
  const base = cfg.relay.replace(/^ws/, "http").replace(/\/+$/, "");
@@ -375,9 +399,12 @@ function keywordFlag(raw) {
375
399
  }
376
400
  return out;
377
401
  }
378
- function die(msg) {
379
- console.error(`pantheon: ${plainError(msg)}`);
380
- process.exit(1);
402
+ function die(msg, code = exitCodeFor(cmd, msg)) {
403
+ const said = plainError(msg);
404
+ console.error(`pantheon: ${said}`);
405
+ if (JSON_OUT)
406
+ sayJson({ status: "error", code, reason: exitReason(code), message: said.replace(/\x1b\[[0-9;]*m/g, "") });
407
+ process.exit(code);
381
408
  }
382
409
  function sameHost(a, b) {
383
410
  try {
@@ -916,6 +943,10 @@ async function printJoinSteps(invite, relay) {
916
943
  console.error(` ${C(l)}`);
917
944
  }
918
945
  console.error(D(` ${j.outro}`));
946
+ console.error(D(` ${j.agent.label}`));
947
+ for (const l of j.agent.lines)
948
+ console.error(` ${C(l)}`);
949
+ console.error(D(` ${j.agent.note}`));
919
950
  }
920
951
  const HUD_ACTION_MAX_AGE_MS = 30_000;
921
952
  function emptyThreadStep(goal) {
@@ -1421,8 +1452,11 @@ async function guidedSetup(cfg, project, opts = {}) {
1421
1452
  return { cancelled: false };
1422
1453
  }
1423
1454
  const interactive = guideAsks(preset);
1424
- if (!interactive && !opts.force)
1455
+ if (!interactive && !opts.force) {
1456
+ if (opts.finish && !SET_UP)
1457
+ recordUnconfirmedSetup(cfg);
1425
1458
  return { cancelled: false };
1459
+ }
1426
1460
  const rl = interactive ? createInterface({ input: process.stdin, output: process.stderr }) : null;
1427
1461
  const io = rl ? terminalIO(rl, (l) => console.error(l)) : null;
1428
1462
  const summary = !!io && !!opts.summary && !opts.founder;
@@ -1533,6 +1567,78 @@ async function guidedSetup(cfg, project, opts = {}) {
1533
1567
  }
1534
1568
  return { cancelled: false };
1535
1569
  }
1570
+ function recordUnconfirmedSetup(cfg) {
1571
+ try {
1572
+ const prof = loadProfile(cfg);
1573
+ if (prof.agent.wake_default !== undefined)
1574
+ return;
1575
+ const wake = wakeMode(prof);
1576
+ saveProfile({ ...prof, agent: { ...prof.agent, wake_enabled: wake !== "no", wake_default: wake, setup_confirmed: false } });
1577
+ markFirstSetup(askedByLabel(whoIsAsking()));
1578
+ }
1579
+ catch { }
1580
+ }
1581
+ function agentFlag() {
1582
+ const v = flag("agent");
1583
+ if (v === undefined)
1584
+ return undefined;
1585
+ if (!isAgentSurface(v))
1586
+ die(`usage: --agent takes ${AGENT_SURFACES.join(", ")}, not "${v}"`);
1587
+ return v;
1588
+ }
1589
+ async function applyAgentChoice(cfg, want) {
1590
+ if (!cfg || !want)
1591
+ return;
1592
+ const from = loadProfile(cfg).agent.primary_surface;
1593
+ if (from === want)
1594
+ return;
1595
+ if (!(await protectSetup([{ setting: "agent", from, to: want }], { replay: ["profile", "set", "--surface", want] })))
1596
+ return;
1597
+ const now = loadProfile(cfg);
1598
+ saveProfile({ ...now, agent: { ...now.agent, primary_surface: want } });
1599
+ console.error(` ${C("✓")} teammates' requests here go to ${agentLabel(want)} first`);
1600
+ }
1601
+ async function statusJson(ts) {
1602
+ const id = identity();
1603
+ const { userScopeWiring } = await import("./doctor.js");
1604
+ const teams = await Promise.all(ts.map(async (cfg) => {
1605
+ const c = new PantheonClient(cfg, undefined, { role: "cli" });
1606
+ const base = { name: cfg.space, id: cfg.spaceId ?? null, relay: cfg.relay, member: cfg.member };
1607
+ try {
1608
+ await Promise.race([c.connect(), new Promise((_, no) => setTimeout(() => no(new Error("timeout")), 8_000))]);
1609
+ await new Promise((r) => setTimeout(r, 350));
1610
+ const mine = c.obligations.filter((o) => o.owner === cfg.member || o.owner === `human:${cfg.member}`);
1611
+ return { ...base, connected: true, members: c.roster.filter((m) => m.id !== cfg.member).map((m) => ({ id: m.id, online: m.online })), waiting_on_you: mine.length };
1612
+ }
1613
+ catch (e) {
1614
+ return { ...base, connected: false, ...(c.pending ? { admitted: false } : {}), error: refusalOf(e)?.code ?? (e.message === "timeout" ? "TIMEOUT" : "UNREACHABLE") };
1615
+ }
1616
+ finally {
1617
+ c.dispose();
1618
+ }
1619
+ }));
1620
+ let agents = [];
1621
+ try {
1622
+ agents = userScopeWiring().map((w) => ({ agent: w.agent, state: w.state }));
1623
+ }
1624
+ catch { }
1625
+ let waiting = 0;
1626
+ try {
1627
+ waiting = loadPending().length;
1628
+ }
1629
+ catch { }
1630
+ const ready = !!ts.length && teams.every((t) => t.connected);
1631
+ return {
1632
+ status: ready ? "ready" : ts.length ? "left" : "not_set_up",
1633
+ version: VERSION,
1634
+ signed_in: !!id?.account,
1635
+ ...(id?.account ? { account: id.account.username } : {}),
1636
+ teams,
1637
+ agents,
1638
+ setup_changes_waiting: waiting,
1639
+ autopilot: await autopilotFacts(ts[0] ?? null),
1640
+ };
1641
+ }
1536
1642
  const STOPPED_ITEM = { says: "Your settings weren't chosen: you stopped at the settings screen (what was already set up is said above).", fix: "pantheon setup" };
1537
1643
  async function cancelledLines(cfg, rerun) {
1538
1644
  const { stoppedLines } = await import("./finish-line.js");
@@ -1563,6 +1669,9 @@ function setupStatusLines() {
1563
1669
  const last = lastChangeLine();
1564
1670
  if (last)
1565
1671
  out.push(D(` ${last} (pantheon changes --history)`));
1672
+ const cfg = load();
1673
+ if (cfg && loadProfile(cfg).agent.setup_confirmed === false)
1674
+ out.push(`\x1b[33mYour settings were never chosen:\x1b[0m Pantheon was set up without a terminal and took the defaults (who can wake this machine: ${wakeMode(loadProfile(cfg))}). ${D("Check them: pantheon setup")}`);
1566
1675
  return out.length ? [...out, ""] : [];
1567
1676
  }
1568
1677
  catch {
@@ -1789,6 +1898,32 @@ async function workerHeld() {
1789
1898
  return null;
1790
1899
  }
1791
1900
  }
1901
+ async function autopilotFacts(cfg) {
1902
+ const out = {};
1903
+ try {
1904
+ const p = loadPolicy();
1905
+ out.mode = effectiveMode(p);
1906
+ out.mode_chosen = !!p.mode;
1907
+ out.unsandboxed = unsandboxedAllowed(p);
1908
+ }
1909
+ catch { }
1910
+ if (cfg) {
1911
+ try {
1912
+ const prof = loadProfile(cfg);
1913
+ out.wake = wakeMode(prof);
1914
+ out.agent = prof.agent.primary_surface;
1915
+ out.confirmed = setupChosen(prof);
1916
+ }
1917
+ catch { }
1918
+ }
1919
+ try {
1920
+ out.commands = commandState({ project: process.cwd() }).level;
1921
+ }
1922
+ catch { }
1923
+ const w = await workerHeld();
1924
+ out.worker = w ? { installed: w.installed, running: w.loaded } : null;
1925
+ return out;
1926
+ }
1792
1927
  async function finishLine(tools, o) {
1793
1928
  const { finishItems, finishLines, finishMarker, SIGN_IN_RUN } = await import("./finish-line.js");
1794
1929
  const { teamWorkspaces } = await import("./worker-fleet.js");
@@ -1873,11 +2008,27 @@ async function finishLine(tools, o) {
1873
2008
  }
1874
2009
  catch { }
1875
2010
  }
2011
+ if (JSON_OUT) {
2012
+ const plain = (t) => t.replace(/\x1b\[[0-9;]*m/g, "").trim();
2013
+ sayJson({
2014
+ status: items.length ? "left" : "ready",
2015
+ code: typeof process.exitCode === "number" ? process.exitCode : 0,
2016
+ team: cfg?.space ?? null,
2017
+ member: cfg?.member ?? null,
2018
+ ...(o.invite ? { invite: o.invite } : {}),
2019
+ left: items.map((it) => ({ says: plain(it.says), fix: plain(it.fix) })),
2020
+ next: items.length ? items.map((it) => plain(it.fix)) : lines.slice(1).map(plain),
2021
+ autopilot: await autopilotFacts(cfg),
2022
+ });
2023
+ }
1876
2024
  }
1877
- const PLAIN = !!process.env["NO_COLOR"];
1878
- if (PLAIN) {
2025
+ const NO_COLOR = !!process.env["NO_COLOR"];
2026
+ const PLAIN = NO_COLOR || (!process.stdout.isTTY && !process.stderr.isTTY);
2027
+ {
1879
2028
  const SGR = /\x1b\[[0-9;]*m/g;
1880
2029
  for (const stream of [process.stdout, process.stderr]) {
2030
+ if (!NO_COLOR && stream.isTTY)
2031
+ continue;
1881
2032
  const write = stream.write.bind(stream);
1882
2033
  stream.write = ((chunk, ...rest) => write(typeof chunk === "string" ? chunk.replace(SGR, "") : chunk, ...rest));
1883
2034
  }
@@ -2060,8 +2211,8 @@ function usageFor(command, help) {
2060
2211
  return out.length ? out.join("\n") : null;
2061
2212
  }
2062
2213
  const COMMAND_FLAGS = {
2063
- start: "--space <name> --relay <url> --me <name> --port <n> --ttl <minutes> --no-worker --no-hook --no-notifications --no-menubar --reset --yes --new-team (a team even though you have a seat to bring here)\n and every setup answer as a flag (--name, --title, --wake, --commands, --alerts, --decides, --mode …): pantheon setup --questions",
2064
- join: "<invite link | line | code> --relay <url> --me <name> --no-worker --no-hook --no-notifications --no-menubar --reset --yes\n and every setup answer as a flag: pantheon setup --questions",
2214
+ start: "--space <name> --relay <url> --me <name> --port <n> --ttl <minutes> --no-worker --no-hook --no-notifications --no-menubar --reset --yes --new-team (a team even though you have a seat to bring here) --agent <claude-code|codex|cursor|copilot|kiro> --json (one object on stdout; exit codes: pantheon help exit-codes)\n and every setup answer as a flag (--name, --title, --wake, --commands, --alerts, --decides, --mode …): pantheon setup --questions",
2215
+ join: "<invite link | line | code> --relay <url> --me <name> --no-worker --no-hook --no-notifications --no-menubar --reset --yes --agent <claude-code|codex|cursor|copilot|kiro> --json (one object on stdout; exit codes: pantheon help exit-codes)\n and every setup answer as a flag: pantheon setup --questions",
2065
2216
  invite: "--list --revoke <token|all> --may-wake | --no-wake --ttl <minutes>",
2066
2217
  admit: "<member> --may-wake | --no-wake --revoke --forget --yes",
2067
2218
  wake: "allow <member> | deny <member> | list --space <team>",
@@ -2079,8 +2230,8 @@ const COMMAND_FLAGS = {
2079
2230
  logs: "[relay|worker|notifier|menubar] --follow --n <lines>",
2080
2231
  worker: "--agent <claude-code|codex|cursor|copilot|kiro|auto> --persona <name> --project <dir> --allow-bash --max-runs <n> --max-runs-day <n> --run-minutes <5-180> --grace <s> --once (token: --status --remove --no-check)",
2081
2232
  service: "install [relay|worker|notifier|menubar] | restart <kind> | uninstall <kind> --project <dir> --allow-bash --run-minutes <5-180> --fresh (a worker's flags from these alone, not kept)",
2082
- doctor: "--share --project <dir>",
2083
- status: "--clear-safety (once the safety warnings it shows are handled)",
2233
+ doctor: "--share --project <dir> --json",
2234
+ status: "--clear-safety (once the safety warnings it shows are handled) --json",
2084
2235
  relay: "--port <n> --host <address> --data <dir> (relay leftovers --data <dir> [--json]: read-only report)",
2085
2236
  use: "<team> --here --yes · pantheon use --unbind (this folder or repo bound to no team again)",
2086
2237
  repo: "add [--base <branch>] | list [--all] | find [<folder>] [--recents] [--yes]",
@@ -2088,11 +2239,21 @@ const COMMAND_FLAGS = {
2088
2239
  signin: "--relay <url>",
2089
2240
  signup: "--email <address> --username <name> --relay <url> --label <device name>",
2090
2241
  audit: "--space <team> --since <hours> --json",
2091
- setup: "--questions --mode <autopilot|here> (and every answer as a flag, with --yes)",
2242
+ setup: "--questions --mode <autopilot|here> --agent <claude-code|codex|cursor|copilot|kiro> (which agent answers teammates' requests here) (and every answer as a flag, with --yes)",
2092
2243
  mode: "[autopilot | here]",
2093
2244
  changes: "[list | review | approve <id> | keep <id>] --history",
2094
2245
  board: "--open --url --watch --keep --stop --focus <id> [--space <team>]",
2095
2246
  };
2247
+ const EXIT_CODES_HELP = `How pantheon join and start end (the words above the code say the same):
2248
+ 0 done: ready, or a short list of what is left (--json: "ready" or "left")
2249
+ 1 something else failed: the message says what
2250
+ 2 the command was not right: an unknown flag or command, a missing or bad value
2251
+ 3 waiting for a teammate (a seat move)
2252
+ 10 you need to sign in first: the message says how; the invite is still good
2253
+ 20 the invite cannot be used: unknown, revoked, expired or already used. Ask for a fresh one
2254
+ 21 the team is full (or your plan allows no more teams); the invite is still good
2255
+ 30 the relay could not be reached: run it again, and check your network or proxy
2256
+ Every other command exits 0, 1 or 2.`;
2096
2257
  const HELP_OPAQUE = new Set(["mcp", "hook", "pending", "tray-status", "help", "version", "-v", "--help", "-h"]);
2097
2258
  function rememberWorkingProxy() {
2098
2259
  try {
@@ -2166,6 +2327,10 @@ const EXTRA_FLAGS = "--action-id --agent-cmd --approve-all --ask-before-sending
2166
2327
  "--name --title --wake --commands --unsandboxed --alerts --decides --playbook --base --responsibilities --human-required --agent-can-decide --capabilities" +
2167
2328
  " --keep-tray-quit --direct" +
2168
2329
  " --headless";
2330
+ const FLAG_COMMANDS = {
2331
+ json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay"],
2332
+ agent: ["join", "start", "setup", "worker", "service", "init"],
2333
+ };
2169
2334
  const KNOWN_FLAGS = new Set([...`${Object.values(COMMAND_FLAGS).join(" ")} ${EXTRA_FLAGS}`.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]));
2170
2335
  function refuseUnknownFlags() {
2171
2336
  if (["mcp", "hook", "tray-status", "_menubar", "handle-uri"].includes(cmd))
@@ -2174,6 +2339,10 @@ function refuseUnknownFlags() {
2174
2339
  if (!/^--[a-z][a-z0-9-]*(?:=\S*)?$/i.test(a))
2175
2340
  continue;
2176
2341
  const name = a.slice(2).split("=")[0].toLowerCase();
2342
+ const only = FLAG_COMMANDS[name];
2343
+ if (only && !only.includes(cmd)) {
2344
+ die(`usage: pantheon ${cmd} has no ${a.split("=")[0]} — ${only.length > 1 ? `it is for ${only.slice(0, -1).join(", ")} and ${only.at(-1)}` : `it is for ${only[0]}`}.\n Nothing was run.`);
2345
+ }
2177
2346
  if (KNOWN_FLAGS.has(name))
2178
2347
  continue;
2179
2348
  const own = [...(COMMAND_FLAGS[cmd] ?? "").matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]);
@@ -2276,7 +2445,9 @@ async function main() {
2276
2445
  const port = Number(flag("port", "8787"));
2277
2446
  const setupFlags = parseSetupFlags(argv);
2278
2447
  if (setupFlags.errors.length)
2279
- die(setupFlags.errors.join("\n") + "\n pantheon setup --questions lists every answer");
2448
+ die(setupFlags.errors.join("\n") + "\n pantheon setup --questions lists every answer", EXIT.usage);
2449
+ const agentWant = agentFlag();
2450
+ await membershipGate();
2280
2451
  const wp = unattendedProject();
2281
2452
  const named = flag("space") ?? null;
2282
2453
  const startFile = loadAll();
@@ -2361,7 +2532,7 @@ async function main() {
2361
2532
  console.error(`\n\x1b[31m No team was created.\x1b[0m ${D("Fix the warning above, then run `pantheon start` again.")}`);
2362
2533
  if (r.relay)
2363
2534
  await r.relay.close().catch(() => { });
2364
- process.exit(1);
2535
+ process.exit(planWarning ? EXIT.teamFull : exitCodeFor("start", r.warnings.join("\n")));
2365
2536
  }
2366
2537
  if (r.invite) {
2367
2538
  const link = toJoinLink(fromInvite(r.invite));
@@ -2391,9 +2562,10 @@ async function main() {
2391
2562
  await bindReposHere(argv.includes("--yes"));
2392
2563
  await workerAfterBinding(wp.how);
2393
2564
  windowsOverridesForBoundRepos();
2565
+ await applyAgentChoice(load() ?? r.cfg, agentWant);
2394
2566
  }
2395
2567
  const guided = r.claimed ? await guidedSetup(load() ?? r.cfg, repoInfo(process.cwd())?.root ?? null, { preset: setupFlags.preset, force: Object.keys(setupFlags.preset).length > 0 || argv.includes("--yes"), founder: true, finish: true }) : { cancelled: false };
2396
- await finishLine(r.tools, { founder: true, preset: setupFlags.preset, extra: [
2568
+ await finishLine(r.tools, { founder: true, preset: setupFlags.preset, ...(r.invite ? { invite: toJoinLink(fromInvite(r.invite)) ?? r.invite } : {}), extra: [
2397
2569
  ...(guided.cancelled ? [STOPPED_ITEM] : []),
2398
2570
  ...(!r.reach.shareable && r.reach.hint ? [{ says: "Your team's relay address only works on this machine, so the invite above can't be used from your teammate's yet.", fix: r.reach.hint.replace(/^A teammate cannot reach it\.\s*/, "") }] : []),
2399
2571
  ] });
@@ -2573,14 +2745,15 @@ async function main() {
2573
2745
  const invite = argv[1] ?? die("usage: pantheon join <invite> (pantheons://host/space#token, https://www.joinpantheon.network/join/<team>#<token>, or just the code) [setup answers as flags — pantheon setup --questions]");
2574
2746
  const setupFlags = parseSetupFlags(argv);
2575
2747
  if (setupFlags.errors.length)
2576
- die(setupFlags.errors.join("\n") + "\n pantheon setup --questions lists every answer");
2748
+ die(setupFlags.errors.join("\n") + "\n pantheon setup --questions lists every answer", EXIT.usage);
2749
+ const agentWant = agentFlag();
2577
2750
  let parsed;
2578
2751
  try {
2579
2752
  parsed = fromInvite(invite);
2580
2753
  }
2581
2754
  catch (e) {
2582
2755
  if (!looksLikeInviteCode(invite))
2583
- die(e.message);
2756
+ die(e.message, EXIT.inviteUnusable);
2584
2757
  const named = flag("relay") ?? process.env.PANTHEON_RELAY;
2585
2758
  const candidates = (named ? [named] : [load()?.relay, DEFAULT_RELAY]).filter((r) => !!r);
2586
2759
  parsed = await resolveInviteCode(invite, candidates).catch(async (err) => {
@@ -2588,9 +2761,9 @@ async function main() {
2588
2761
  const rest = err.message.replace(/^INVITE_CODE_[A-Z]+:\s*/, "");
2589
2762
  if (c?.publicCa === false) {
2590
2763
  const x = interceptionExplanation(c);
2591
- die(`${x.why} — ${x.fix}.\n${rest.split("\n").slice(1).join("\n")}`);
2764
+ die(`${x.why} — ${x.fix}.\n${rest.split("\n").slice(1).join("\n")}`, EXIT.network);
2592
2765
  }
2593
- return die(rest);
2766
+ return die(rest, /INVITE_CODE_UNREACHABLE/.test(err.message) ? EXIT.network : EXIT.inviteUnusable);
2594
2767
  });
2595
2768
  console.error(D(`That was just the code — it opens "${parsed.space}" on ${new URL(parsed.relay).host}. Joining that team.\n`));
2596
2769
  }
@@ -2639,10 +2812,10 @@ async function main() {
2639
2812
  const m = e.message;
2640
2813
  const intercepted = await interceptedText(e, parsed.relay);
2641
2814
  if (intercepted)
2642
- die(intercepted);
2815
+ die(intercepted, EXIT.network);
2643
2816
  if (/BAD_INVITE/.test(m)) {
2644
2817
  const body = m.replace(/^BAD_INVITE:\s*/, "");
2645
- die(/\n/.test(body) || /fresh one|new invite/i.test(body) ? body : `${body}\n Ask your teammate for a fresh one: pantheon invite`);
2818
+ die(/\n/.test(body) || /fresh one|new invite/i.test(body) ? body : `${body}\n Ask your teammate for a fresh one: pantheon invite`, inviteRefusalCode(body));
2646
2819
  }
2647
2820
  if (/NO_SUCH_SPACE/.test(m))
2648
2821
  die(`${m}\n The relay answered, but has no team by that name — it was deleted, or the link was copied from somewhere else. Ask your teammate for a fresh invite.`);
@@ -2699,6 +2872,7 @@ async function main() {
2699
2872
  await workerAfterBinding(wp.how);
2700
2873
  windowsOverridesForBoundRepos();
2701
2874
  const joined = load();
2875
+ await applyAgentChoice(joined, agentWant);
2702
2876
  const guided = joined ? await guidedSetup(joined, repoInfo(process.cwd())?.root ?? null, { preset: setupFlags.preset, force: Object.keys(setupFlags.preset).length > 0 || argv.includes("--yes"), summary: true, finish: true }) : { cancelled: false };
2703
2877
  await finishLine(r.tools, { founder: false, preset: setupFlags.preset, ...(guided.cancelled ? { extra: [STOPPED_ITEM] } : {}) });
2704
2878
  return;
@@ -2839,7 +3013,7 @@ async function main() {
2839
3013
  }
2840
3014
  }
2841
3015
  const cur = load();
2842
- if (cur && loadProfile(cur).agent.wake_default === undefined)
3016
+ if (cur && !setupChosen(loadProfile(cur)))
2843
3017
  await guidedSetup(cur, repoInfo(process.cwd())?.root ?? null);
2844
3018
  reportWindows(r.from);
2845
3019
  return;
@@ -2880,7 +3054,7 @@ async function main() {
2880
3054
  console.error(` relay: ${D("shared with your teammates, so it is yours to time:")} launchctl kickstart -k gui/$(id -u)/dev.pantheon.relay`);
2881
3055
  const cfgNow = load();
2882
3056
  if (cfgNow) {
2883
- if (loadProfile(cfgNow).agent.wake_default === undefined)
3057
+ if (!setupChosen(loadProfile(cfgNow)))
2884
3058
  await guidedSetup(cfgNow, repoInfo(process.cwd())?.root ?? null);
2885
3059
  else
2886
3060
  console.error(D(`\n Your setup answers still apply — pantheon setup to change them.`));
@@ -2897,8 +3071,14 @@ async function main() {
2897
3071
  }
2898
3072
  const { preset, errors } = parseSetupFlags(argv);
2899
3073
  if (errors.length)
2900
- die(errors.join("\n") + "\n pantheon setup --questions lists every answer");
3074
+ die(errors.join("\n") + "\n pantheon setup --questions lists every answer", EXIT.usage);
3075
+ const agentWant = agentFlag();
2901
3076
  const cfg = need();
3077
+ await applyAgentChoice(cfg, agentWant);
3078
+ if (agentWant && !Object.keys(preset).length) {
3079
+ sayAgentReadiness(load() ?? cfg);
3080
+ return;
3081
+ }
2902
3082
  await guidedSetup(cfg, repoInfo(process.cwd())?.root ?? null, { force: true, preset, command: "setup" });
2903
3083
  sayAgentReadiness(load() ?? cfg);
2904
3084
  return;
@@ -3027,6 +3207,10 @@ async function main() {
3027
3207
  }
3028
3208
  client.close();
3029
3209
  };
3210
+ if (JSON_OUT) {
3211
+ sayJson(await statusJson(Object.keys(loadAll()?.spaces ?? {}).length ? targets() : []));
3212
+ return;
3213
+ }
3030
3214
  const ts = targets();
3031
3215
  {
3032
3216
  const problem = (() => { try {
@@ -4811,7 +4995,7 @@ async function main() {
4811
4995
  const m = findMembership(pf, flag("space")) ?? die(`you are not in a team called "${flag("space")}"`);
4812
4996
  const key = m.id.startsWith("legacy:") ? m.name : m.id;
4813
4997
  const prev = profile.spaces?.[key] ?? profile.spaces?.[m.name] ?? {};
4814
- const auth = { ...(prev.authority ?? {}) };
4998
+ const auth = { ...(prev.authority ?? profile.authority ?? {}) };
4815
4999
  for (const domain of humanRequired ?? [])
4816
5000
  auth[domain] = "human_required";
4817
5001
  for (const domain of agentCanDecide ?? [])
@@ -7182,6 +7366,13 @@ async function main() {
7182
7366
  if (!share)
7183
7367
  console.log(`${B("pantheon doctor")} ${D(dir)}\n`);
7184
7368
  const checks = await doctor(dir);
7369
+ if (JSON_OUT) {
7370
+ const { text, failed } = render(checks);
7371
+ console.error(text);
7372
+ const plain = (t) => t.replace(/\x1b\[[0-9;]*m/g, "");
7373
+ sayJson({ status: failed ? "fail" : "ok", code: failed ? 1 : 0, version: VERSION, checks: checks.map((c) => ({ level: c.level, name: c.name, detail: plain(c.detail), ...(c.fix ? { fix: plain(c.fix) } : {}) })) });
7374
+ process.exit(failed ? 1 : 0);
7375
+ }
7185
7376
  if (share) {
7186
7377
  console.log(shareBlock(checks));
7187
7378
  process.exit(checks.some((c) => c.level === "fail") ? 1 : 0);
@@ -7499,6 +7690,10 @@ async function main() {
7499
7690
  return;
7500
7691
  case "help": {
7501
7692
  const topic = argv[1] && argv[1] !== "all" && !argv[1].startsWith("-") ? argv[1] : null;
7693
+ if (topic === "exit-codes") {
7694
+ console.log(EXIT_CODES_HELP);
7695
+ return;
7696
+ }
7502
7697
  if (topic && (usageFor(topic, HELP_ALL) || COMMAND_FLAGS[topic])) {
7503
7698
  console.log(`${usageFor(topic, HELP_ALL) ?? ` pantheon ${topic}`}${COMMAND_FLAGS[topic] ? `\n\n${B("flags")}\n ${COMMAND_FLAGS[topic]}` : ""}`);
7504
7699
  return;
@@ -7515,7 +7710,7 @@ async function main() {
7515
7710
  const near = known.map((k) => ({ k, d: slipDistance(cmd, k) })).sort((x, y) => x.d - y.d)[0];
7516
7711
  console.error(`unknown command "${cmd}"${near && near.d <= 2 ? ` — did you mean: pantheon ${near.k}?` : ""}`);
7517
7712
  console.error(D("all commands: pantheon help · everything: pantheon help --all"));
7518
- process.exit(1);
7713
+ process.exit(EXIT.usage);
7519
7714
  }
7520
7715
  }
7521
7716
  }
package/dist/doctor.js CHANGED
@@ -5,7 +5,7 @@ import { instructionBudget } from "./mcp-instructions.js";
5
5
  import { describeWindows, scanMcpWindows } from "./mcp-windows.js";
6
6
  import { grantsSeen, measureMcp, toolsReport, HOST_STARTUP_ALLOWANCE_MS, STARTUP_WARN_MS } from "./measure.js";
7
7
  import { FEEDBACK_ADDRESS } from "./feedback.js";
8
- import { loadProfile, profileInitialized, reservedDomains, teamProfile, wakeMode } from "./profile.js";
8
+ import { loadProfile, profileInitialized, reservedDomains, setupChosen, teamProfile, wakeMode } from "./profile.js";
9
9
  import { inWokenRun, isApprovedWaker, loadPolicy, relayKnowsAdmitters, requestReadinessRecheck, unsandboxedAllowed } from "./worker-policy.js";
10
10
  import { commandState } from "./command-state.js";
11
11
  import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
@@ -341,6 +341,9 @@ export async function doctor(projectDir) {
341
341
  const vague = Object.keys(teamProfile(prof, cfg.spaceId, cfg.space).authority).filter((d) => isCatchAllDomain(d));
342
342
  if (vague.length)
343
343
  add("warn", "profile", `your profile claims ${vague.map((d) => `"${d}"`).join(", ")} — not a decision area, so no decision is ever routed by it`, "running pantheon setup drops it — name the areas you decide personally: pantheon setup --decides deployment,pricing (or --decides none); it is never published either way", "claims a catch-all decision area");
344
+ const dropped = Object.entries(prof.authority).filter(([d, mode]) => mode === "human_required" && !(d in teamProfile(prof, cfg.spaceId, cfg.space).authority)).map(([d]) => d);
345
+ if (dropped.length)
346
+ add("warn", "profile", `in "${cfg.space}" you no longer decide ${dropped.join(", ")} — you do everywhere else, and this team's own list leaves ${dropped.length === 1 ? "it" : "them"} out`, `to keep ${dropped.length === 1 ? "it" : "them"} yours here: pantheon profile set --space ${cfg.space} --human-required ${dropped.join(",")}`, `${dropped.length} reserved area${dropped.length === 1 ? "" : "s"} dropped in this team`);
344
347
  }
345
348
  else {
346
349
  add("warn", "profile", "no profile published — decisions cannot be routed to you, and a decision a teammate sends you arrives marked unverified", "pantheon profile set --name <you> --title <role> --human-required <domains you personally decide>", "none published");
@@ -708,7 +711,9 @@ export async function doctor(projectDir) {
708
711
  }
709
712
  const workerUp = workerRunningHere();
710
713
  const mode = wakeMode(loadProfile(cfg));
711
- const anyoneWhy = loadProfile(cfg).agent.wake_default === "anyone" ? "you chose \"anyone\"" : "\"anyone\" is the default";
714
+ const anyoneWhy = setupChosen(loadProfile(cfg)) && loadProfile(cfg).agent.wake_default === "anyone" ? "you chose \"anyone\"" : "\"anyone\" is the default";
715
+ if (loadProfile(cfg).agent.setup_confirmed === false)
716
+ add("warn", "setup", `set up without a terminal, so nobody here has chosen these settings yet (who can wake this machine: ${mode})`, "check them: pantheon setup", "defaults, not chosen");
712
717
  const policy = loadPolicy();
713
718
  const approvedHere = admittedPeers.filter((m) => isApprovedWaker(policy, [client.spaceId ?? cfg.spaceId, cfg.space], m.member));
714
719
  const teamKey = client.spaceId ?? cfg.spaceId ?? cfg.space;
@@ -0,0 +1,35 @@
1
+ export const EXIT = { failed: 1, usage: 2, waiting: 3, needsPerson: 10, inviteUnusable: 20, teamFull: 21, network: 30 };
2
+ export const CODED_COMMANDS = new Set(["join", "start"]);
3
+ export function exitCodeFor(command, msg) {
4
+ if (/^usage: |^unknown flag /.test(msg))
5
+ return EXIT.usage;
6
+ if (!CODED_COMMANDS.has(command))
7
+ return EXIT.failed;
8
+ if (/NOT_SIGNED_IN|^sign in first|^not signed in yet/.test(msg))
9
+ return EXIT.needsPerson;
10
+ if (/PLAN_LIMIT/.test(msg))
11
+ return EXIT.teamFull;
12
+ if (/BAD_INVITE/.test(msg))
13
+ return inviteRefusalCode(msg);
14
+ if (/NO_SUCH_SPACE|INVITE_CODE_UNKNOWN|^not a pantheon invite/.test(msg))
15
+ return EXIT.inviteUnusable;
16
+ if (/INVITE_CODE_UNREACHABLE|^cannot reach the relay|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|ECONNRESET|\btimeout\b|timed out/i.test(msg))
17
+ return EXIT.network;
18
+ return EXIT.failed;
19
+ }
20
+ export function inviteRefusalCode(msg) {
21
+ return /registered (?:here )?with a different key/.test(msg) ? EXIT.failed : EXIT.inviteUnusable;
22
+ }
23
+ export function exitReason(code) {
24
+ switch (code) {
25
+ case 0: return "ok";
26
+ case EXIT.usage: return "usage";
27
+ case EXIT.waiting: return "waiting";
28
+ case EXIT.needsPerson: return "needs_person";
29
+ case EXIT.inviteUnusable: return "invite_unusable";
30
+ case EXIT.teamFull: return "team_full";
31
+ case EXIT.network: return "network";
32
+ default: return "failed";
33
+ }
34
+ }
35
+ //# sourceMappingURL=exit-codes.js.map
@@ -18,7 +18,7 @@ export function isSecretPath(rel, dir) {
18
18
  const name = low.slice(low.lastIndexOf("/") + 1);
19
19
  if (!dir && SECRET_FILES.some((re) => re.test(name)))
20
20
  return true;
21
- return SECRET_HOME_PATHS.some((p) => p.dir === dir && (low === p.rel.toLowerCase() || low.endsWith(`/${p.rel.toLowerCase()}`)));
21
+ return SECRET_HOME_PATHS.some((p) => p.dir === dir && (low === p.rel.toLowerCase() || (!p.homeOnly && low.endsWith(`/${p.rel.toLowerCase()}`))));
22
22
  }
23
23
  const longPath = (p, os) => (os === "win32" ? win32.toNamespacedPath(p) : p);
24
24
  export const shown = (s) => s.replace(/\\\\\?\\UNC\\/gi, "\\\\").replace(/\\\\\?\\/g, "");
package/dist/managed.js CHANGED
@@ -251,9 +251,15 @@ export function joinInstructions(invite, relay, installers = true) {
251
251
  label: steps.length ? "Already have Node.js 22.13 or newer? This works too:" : "With Node.js 22.13 or newer (nodejs.org):",
252
252
  lines: ["npm i -g @join-pantheon/cli", link ? `pantheon join '${link}'` : `pantheon join ${invite}`],
253
253
  });
254
+ const joinLine = link ? `pantheon join '${link}'` : `pantheon join ${invite}`;
254
255
  return {
255
256
  intro: "You're invited to my Pantheon team. Paste the line for your computer into a terminal:",
256
257
  steps,
258
+ agent: {
259
+ label: "Or ask your coding agent (Claude Code, Codex, Cursor) to run:",
260
+ lines: ["npm i -g @join-pantheon/cli", `${joinLine} --json`],
261
+ note: "This needs Node.js 22.13 or newer. If join exits with code 10, you need to sign in once, and it says how.",
262
+ },
257
263
  outro: sh || win
258
264
  ? "It installs Pantheon (with its own Node, no admin rights), asks for your email, sends you a 6-digit code (check spam if it does not arrive), and sets up the coding agents on your computer."
259
265
  : "`pantheon join` asks for your email, sends you a 6-digit code (check spam if it does not arrive), and sets up the coding agents on your computer.",
package/dist/persona.js CHANGED
@@ -145,7 +145,12 @@ export function loadPersonas(projectDir = process.cwd(), home) {
145
145
  continue;
146
146
  }
147
147
  try {
148
- out.push(parsePersona(name, scope, file, readFileSync(file, "utf8")));
148
+ const p = parsePersona(name, scope, file, readFileSync(file, "utf8"));
149
+ if (scope === "project" && p.agent !== undefined && p.agent !== "claude-code") {
150
+ p.warnings.push(`agent: ${p.agent} is ignored — a persona committed to the repo cannot pick the agent; put it in a persona of your own (pantheon persona new --user)`);
151
+ delete p.agent;
152
+ }
153
+ out.push(p);
149
154
  }
150
155
  catch (e) {
151
156
  out.push({ name, scope, file, instructions: "", warnings: [`unreadable: ${e.message}`] });
@@ -225,7 +230,7 @@ export const PERSONA_TEMPLATE = `---
225
230
  # wake_by: alice, bob # only these peers' requests are handled by this persona
226
231
  # kinds: ANSWER, ACCEPT # ANSWER (asks), ACCEPT (verdicts), REVISE (objections), CONTINUE (replies/deliveries)
227
232
  # goals: launch-* # only goals whose id or title matches
228
- # agent: auto # claude-code | codex | cursor | copilot | kiro | auto
233
+ # agent: auto # claude-code | codex | cursor | copilot | kiro | auto — your own personas only (--user)
229
234
  ---
230
235
  Say how this worker should behave when it is woken while you are away — what it
231
236
  should take on, what it should refuse, and where its judgment ends and yours