@join-pantheon/cli 0.36.0 → 0.37.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,49 +18,35 @@ Nobody switches tools. Nothing leaves your machine except messages.
18
18
  └─────────────────┘ └──────────────────┘ └─────────────────────┘
19
19
  ```
20
20
 
21
- ## Setup — two commands
21
+ <!-- getting-started:start (generated from src/onboard-copy.ts — npm run gen:copy) -->
22
+ ## Getting started
22
23
 
23
- ```bash
24
- # on each machine — no clone, no build:
25
- npm install -g @join-pantheon/cli
26
- ```
27
-
28
- Or run it without installing at all:
29
-
30
- ```bash
31
- npx @join-pantheon/cli # guided sign-in; it tells you what to run next
32
- ```
24
+ Paste one line into a terminal on your own computer. It brings its own Node.js,
25
+ needs no admin rights, asks for your email and a 6-digit code, creates your team
26
+ and connects the coding agents it finds.
33
27
 
34
- **First, verify your email (once per person):**
28
+ Mac or Linux (Terminal):
35
29
 
36
- ```bash
37
- pantheon signup --email you@work.com --username you # get a 6-digit code by email
38
- pantheon verify 123456 # confirm it
39
- ```
30
+ curl -fsSL https://relay.joinpantheon.network/install.sh | sh -s -- start
40
31
 
41
- That gives you a verified account and a unique username no one else can claim,
42
- across every space on the hosted relay. A second machine joins the same account
43
- with `pantheon login --email you@work.com`. See your devices and sign any of them
44
- out with `pantheon sessions`; every identity and membership event is in `pantheon
45
- audit`. (Self-hosting or on a LAN/tailnet? Accounts are optional there — skip
46
- signing up and point `start` at your own relay: `pantheon start --relay ws://<host>:8787`.)
32
+ Windows (Command Prompt or PowerShell):
47
33
 
48
- **Then, from your project's repo — or anywhere, if there is no repo yet (see below):**
34
+ powershell -NoProfile -Command "Set-Item Env:PANTHEON_ARGS 'start'; irm https://relay.joinpantheon.network/install.ps1 | iex"
49
35
 
50
- ```bash
51
- pantheon start
52
- ```
36
+ With Node.js 22.13 or newer: `npm install -g @join-pantheon/cli` then `pantheon start`.
37
+ Invited to a team? Use the line in your invite (`pantheon join <invite>`).
38
+ Then `pantheon invite` gives you a block to forward to each teammate.
53
39
 
54
- **Your teammate, from their clone of the project if they have one:**
40
+ What it changes:
55
41
 
56
- ```bash
57
- pantheon join pantheons://relay.joinpantheon.network/acme#C1qhJfdHBaPjuG3jF48vcqrP
58
- ```
42
+ - Installs Pantheon in your home folder (~/.pantheon), with its own Node.js. No admin rights.
43
+ - Adds Pantheon to the coding agents it finds (Claude Code, Codex, Cursor, GitHub Copilot, Kiro) and pre-approves Pantheon's own tools there, so your agent is not asked each time it uses one.
44
+ - Starts a background helper when you log in. By default a teammate's request can start your agent while you're away: it works in a separate copy of the repo and delivers on its own branch for you to review, and in a repo it may run your tests, commit and push that branch. Claude Code's runs are sandboxed; Codex, Cursor and Copilot runs are not.
45
+ - Shows desktop alerts for the decisions that are yours (and a menu bar on a Mac).
46
+ - Change any of it later with `pantheon setup`, or remove it all with `pantheon uninstall`.
47
+ <!-- getting-started:end -->
59
48
 
60
- On the hosted relay, `pantheon start` and `pantheon invite` also print the same invite as a link,
61
- `https://www.joinpantheon.network/join/acme#C1qhJfdHBaPjuG3jF48vcqrP`. Pasted into a chat it
62
- unfurls with the team's name and hands the recipient the line for their agent. The token stays in the
63
- URL fragment, which browsers never send to any server. `pantheon join` accepts either form.
49
+ ### What start and join set up
64
50
 
65
51
  Signed in, `pantheon start` puts your space on the hosted relay, so that link works from any
66
52
  network — no tunnel, no VPN. The space is named after the folder you run it from (your repo,
@@ -77,7 +63,7 @@ That's it — one command each sets up the **whole machine**: a relay and space
77
63
  every Conductor window, nothing to commit), the wake-up hook so an agent finishes what a peer is
78
64
  waiting for, the **worker** so the machine answers the team even while its human is away (on by
79
65
  default when run inside a git repo; `--no-worker` opts out), native decision alerts, and the menu bar. Each command
80
- ends with a "You're set" summary, then a short guided setup on a terminal: two questions — your
66
+ ends with "You're ready" or a short list of what is left, after a short guided setup on a terminal: two questions — your
81
67
  name and your role — and one screen of defaults to keep or change: your teammates can hand work to
82
68
  your machine while you are away, that work runs your tests and commits to its own branch so it
83
69
  arrives ready to review, whichever agent you use (Claude Code, Codex, Cursor or Copilot) answers
package/dist/accounts.js CHANGED
@@ -42,6 +42,23 @@ export const VIEWER_SESSION_MAX_MS = 7 * 86_400_000;
42
42
  export const ADMIN_SESSION_MS = 12 * 3_600_000;
43
43
  const newId = (p) => `${p}_${randomBytes(9).toString("base64url")}`;
44
44
  const sha = (s) => createHash("sha256").update(s).digest("hex");
45
+ export const LINK_WRONG_PER_HOUR = 3;
46
+ export const LINK_WORDS = ("acorn amber anchor apple arrow aspen atlas autumn badge bagel bamboo banjo barley basil beacon beaver " +
47
+ "berry bison blanket blossom bonfire bramble breeze brick bridge brook bubble bucket buffalo bugle butter cabin " +
48
+ "cactus camel candle canoe canyon carbon carrot castle cedar cello chalk cherry chess cider cinder citrus clover " +
49
+ "cobalt cocoa comet compass copper coral cotton coyote crane crayon cricket crystal cuckoo cypress daisy delta " +
50
+ "denim desert dingo dolphin domino dragon drum dune eagle easel echo ember emerald falcon fennel fern ferry " +
51
+ "fiddle fig finch fjord flame flint forest fossil fox galaxy garden garnet gecko geyser ginger glacier globe " +
52
+ "goose granite grape gravel guitar gull hammer harbor harp hazel heron hickory honey hornet husky iris island " +
53
+ "ivory jade jasmine jelly juniper kayak kettle kiwi koala lagoon lantern lark lava lemon lilac lily linen " +
54
+ "lizard llama lobster locket lotus lunar lynx magnet mango maple marble meadow melon meteor mint mitten mocha " +
55
+ "monsoon moose mosaic moss muffin nectar nickel nutmeg oasis ocean olive onyx orbit orchid otter owl oyster " +
56
+ "paddle panda papaya parrot pebble pecan pelican pepper piano pickle pine pistachio planet plum pollen pony poppy " +
57
+ "prairie prism puffin pumpkin quartz quill rabbit radar radish raven reef ribbon river robin rocket rose ruby " +
58
+ "saddle saffron salmon sandal sapphire satin scarf seal sequoia shell sierra silver sloth snowflake sparrow spruce " +
59
+ "squid star stork summit sunset swan tango teapot thistle thunder tiger timber toast topaz tornado trout tulip " +
60
+ "tundra turnip turtle umbrella valley velvet violet volcano waffle walnut walrus willow wombat yarrow yeti zebra " +
61
+ "zephyr zinnia badger dove peach vanilla").split(" ");
45
62
  export function normalizeEmail(email) {
46
63
  return email.trim().toLowerCase();
47
64
  }
@@ -133,6 +150,17 @@ export class Accounts {
133
150
  created_at INTEGER NOT NULL,
134
151
  PRIMARY KEY (email, pending_pubkey)
135
152
  );
153
+ CREATE TABLE IF NOT EXISTS link_confirms (
154
+ token_hash TEXT PRIMARY KEY,
155
+ email TEXT NOT NULL,
156
+ pending_pubkey TEXT NOT NULL,
157
+ words TEXT NOT NULL,
158
+ label TEXT,
159
+ ip TEXT,
160
+ expires_at INTEGER NOT NULL,
161
+ created_at INTEGER NOT NULL,
162
+ voided INTEGER NOT NULL DEFAULT 0
163
+ );
136
164
  CREATE TABLE IF NOT EXISTS verify_failures (
137
165
  email TEXT PRIMARY KEY,
138
166
  window_start INTEGER NOT NULL,
@@ -355,6 +383,7 @@ export class Accounts {
355
383
  pending_label = excluded.pending_label, expires_at = excluded.expires_at,
356
384
  attempts = 0, created_at = excluded.created_at
357
385
  `).run(e, sha(code), purpose, purpose === "signup" ? normalizeUsername(opts.username) : null, key, opts.label, t + CODE_TTL_MS, t);
386
+ this.db.prepare("DELETE FROM link_confirms WHERE email = ? AND pending_pubkey = ?").run(e, key);
358
387
  return { ok: true, code };
359
388
  }
360
389
  failsOf(key, t = now()) {
@@ -408,6 +437,10 @@ export class Accounts {
408
437
  this.noteFail(netId, t);
409
438
  return { ok: false, reason: "bad_code", tries_left: Math.max(0, MAX_ATTEMPTS - v.attempts - 1) };
410
439
  }
440
+ return this.completeVerification(e, v, ip, keyId);
441
+ }
442
+ completeVerification(e, v, ip, keyId) {
443
+ const where = "email = ? AND pending_pubkey = ?";
411
444
  const run = this.db.prepare.bind(this.db);
412
445
  this.db.exec("BEGIN");
413
446
  try {
@@ -433,6 +466,10 @@ export class Accounts {
433
466
  }
434
467
  else {
435
468
  account = this.accountByEmail(e);
469
+ if (!account || account.status !== "active") {
470
+ this.db.exec("ROLLBACK");
471
+ return { ok: false, reason: "suspended" };
472
+ }
436
473
  }
437
474
  const device = this.bindDevice(account.id, v.pending_pubkey, v.pending_label ?? "a device");
438
475
  const session = this.openSession(account.id, device.id, "", ip);
@@ -443,6 +480,10 @@ export class Accounts {
443
480
  run("DELETE FROM verifications_by_device WHERE email = ? AND purpose != 'viewer'").run(e);
444
481
  else
445
482
  run(`DELETE FROM verifications_by_device WHERE ${where}`).run(e, v.pending_pubkey);
483
+ if (v.purpose === "signup")
484
+ run("DELETE FROM link_confirms WHERE email = ?").run(e);
485
+ else
486
+ run(`DELETE FROM link_confirms WHERE ${where}`).run(e, v.pending_pubkey);
446
487
  run("DELETE FROM verify_failures WHERE email = ?").run(keyId);
447
488
  this.db.exec("COMMIT");
448
489
  this.audit({ actor_account: account.id, event: v.purpose === "signup" ? "email_verified" : "login", target: device.fingerprint, ip });
@@ -453,6 +494,58 @@ export class Accounts {
453
494
  throw err;
454
495
  }
455
496
  }
497
+ startLink(email, pubkey, o) {
498
+ const e = normalizeEmail(email);
499
+ const v = this.db.prepare("SELECT expires_at FROM verifications_by_device WHERE email = ? AND pending_pubkey = ? AND purpose != 'viewer'").get(e, pubkey);
500
+ if (!v)
501
+ return null;
502
+ const token = randomBytes(16).toString("base64url");
503
+ const words = `${LINK_WORDS[randomInt(0, LINK_WORDS.length)]} ${LINK_WORDS[randomInt(0, LINK_WORDS.length)]}`;
504
+ this.db.prepare("DELETE FROM link_confirms WHERE email = ? AND pending_pubkey = ?").run(e, pubkey);
505
+ this.db.prepare("INSERT INTO link_confirms (token_hash, email, pending_pubkey, words, label, ip, expires_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
506
+ .run(sha(token), e, pubkey, words, o.label.slice(0, 60), o.ip, v.expires_at, now());
507
+ return { token, words };
508
+ }
509
+ linkStillLive(r) {
510
+ const v = this.db.prepare("SELECT expires_at FROM verifications_by_device WHERE email = ? AND pending_pubkey = ? AND purpose != 'viewer'").get(r.email, r.pending_pubkey);
511
+ return !!v && v.expires_at === r.expires_at;
512
+ }
513
+ linkInfo(token) {
514
+ const r = this.db.prepare("SELECT * FROM link_confirms WHERE token_hash = ?").get(sha(token));
515
+ if (!r || r.voided || now() > r.expires_at || !this.linkStillLive(r))
516
+ return null;
517
+ return { label: r.label ?? "a device", ip: r.ip ?? "", created_at: r.created_at, email: r.email };
518
+ }
519
+ confirmLink(token, typed, ip) {
520
+ const r = this.db.prepare("SELECT * FROM link_confirms WHERE token_hash = ?").get(sha(token));
521
+ if (!r || r.voided || now() > r.expires_at || !this.linkStillLive(r))
522
+ return { ok: false, reason: "no_link" };
523
+ const words = typed.toLowerCase().replace(/[^a-z]+/g, " ").trim();
524
+ if (!/^[a-z]+ [a-z]+$/.test(words))
525
+ return { ok: false, reason: "empty" };
526
+ const lockId = `link:${r.email}`;
527
+ if (this.failsOf(lockId) >= LINK_WRONG_PER_HOUR)
528
+ return { ok: false, reason: "links_locked" };
529
+ const want = Buffer.from(sha(r.words)), got = Buffer.from(sha(words));
530
+ if (!(want.length === got.length && timingSafeEqual(want, got))) {
531
+ this.db.prepare("UPDATE link_confirms SET voided = 1 WHERE token_hash = ?").run(r.token_hash);
532
+ this.noteFail(lockId);
533
+ return { ok: false, reason: "wrong_words" };
534
+ }
535
+ const v = this.db.prepare("SELECT * FROM verifications_by_device WHERE email = ? AND pending_pubkey = ? AND purpose != 'viewer'").get(r.email, r.pending_pubkey);
536
+ if (!v || now() > v.expires_at)
537
+ return { ok: false, reason: "no_link" };
538
+ if (this.deviceOfOtherAccount(r.email, r.pending_pubkey))
539
+ return { ok: false, reason: "device_other_account" };
540
+ return this.completeVerification(r.email, v, ip, `key:${r.email}|${r.pending_pubkey}`);
541
+ }
542
+ pendingFor(pubkey) {
543
+ return !!this.db.prepare("SELECT 1 FROM verifications_by_device WHERE pending_pubkey = ? AND purpose != 'viewer' AND expires_at > ?").get(pubkey, now());
544
+ }
545
+ signedInDevice(pubkey) {
546
+ const d = this.deviceByPubkey(pubkey);
547
+ return d ? this.accountById(d.account_id) : null;
548
+ }
456
549
  deviceOfOtherAccount(email, pubkey) {
457
550
  const dev = this.deviceByPubkey(pubkey);
458
551
  if (!dev)
@@ -543,6 +636,7 @@ export class Accounts {
543
636
  try {
544
637
  this.db.prepare("UPDATE spaces SET owner_deleted_at = ? WHERE owner_account = ?").run(now(), accountId);
545
638
  this.db.prepare("DELETE FROM accounts WHERE id = ?").run(accountId);
639
+ this.db.prepare("DELETE FROM link_confirms WHERE email = ?").run(acct.email);
546
640
  this.db.exec("COMMIT");
547
641
  }
548
642
  catch (e) {
@@ -888,6 +982,7 @@ export class Accounts {
888
982
  const sCut = now() - sessionDays * 86_400_000;
889
983
  this.db.prepare("DELETE FROM sessions WHERE ended_at IS NOT NULL AND ended_at < ?").run(now() - 7 * 86_400_000);
890
984
  const s = this.db.prepare("DELETE FROM sessions WHERE last_seen < ?").run(sCut);
985
+ this.db.prepare("DELETE FROM link_confirms WHERE expires_at < ? OR voided = 1").run(now());
891
986
  let a = { changes: 0 };
892
987
  if (auditDays > 0)
893
988
  a = this.db.prepare("DELETE FROM audit WHERE ts < ?").run(now() - auditDays * 86_400_000);
@@ -0,0 +1,115 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { randomBytes } from "node:crypto";
3
+ import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
4
+ import { homedir, tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { agentById, headlessSpawn, materializeSpawnFiles, resolveBinary } from "./agents.js";
7
+ import { claudeTokenForRun } from "./agent-token.js";
8
+ import { detectClaudeFeatures } from "./claude-confine.js";
9
+ import { CONFIG_DIR } from "./config.js";
10
+ import { proxyEnvFor } from "./network.js";
11
+ import { agentSpawn } from "./which.js";
12
+ import { agentBaseEnv } from "./worker.js";
13
+ export const CHECK_TIMEOUT_MS = 60_000;
14
+ export const CHECK_PROMPT = "This is Pantheon's setup check. Call the pantheon_status tool once, then reply with exactly the text it returned and nothing else.";
15
+ function runIt(s, cwd, timeoutMs) {
16
+ return new Promise((resolve) => {
17
+ let out = "", timedOut = false, done = false;
18
+ const finish = (code) => { if (done)
19
+ return; done = true; clearTimeout(t); clearTimeout(grace); unhook?.(); resolve({ out, code, timedOut }); };
20
+ let unhook;
21
+ const win = process.platform === "win32";
22
+ const env = { ...agentBaseEnv(process.env, proxyEnvFor()), ...s.env };
23
+ let sp;
24
+ try {
25
+ sp = agentSpawn(s.command, s.args);
26
+ }
27
+ catch (e) {
28
+ out = e.message;
29
+ finish(null);
30
+ return;
31
+ }
32
+ const p = spawn(sp.command, sp.args, { cwd, env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true, detached: !win, ...sp.options });
33
+ const cap = (d) => { if (out.length < 200_000)
34
+ out += d.toString(); };
35
+ p.stdout?.on("data", cap);
36
+ p.stderr?.on("data", cap);
37
+ let grace;
38
+ const kill = () => {
39
+ try {
40
+ if (win && p.pid)
41
+ spawnSync("taskkill", ["/T", "/F", "/PID", String(p.pid)], { windowsHide: true });
42
+ else if (p.pid)
43
+ process.kill(-p.pid, "SIGKILL");
44
+ }
45
+ catch {
46
+ try {
47
+ p.kill("SIGKILL");
48
+ }
49
+ catch { }
50
+ }
51
+ };
52
+ const t = setTimeout(() => { timedOut = true; kill(); grace = setTimeout(() => finish(null), 2_000); }, timeoutMs);
53
+ const onSignal = (sig) => { kill(); process.off("exit", onExit); process.exit(sig === "SIGINT" ? 130 : 143); };
54
+ const onExit = () => kill();
55
+ const onInt = () => onSignal("SIGINT"), onTerm = () => onSignal("SIGTERM");
56
+ process.once("SIGINT", onInt);
57
+ process.once("SIGTERM", onTerm);
58
+ process.once("exit", onExit);
59
+ unhook = () => { process.off("SIGINT", onInt); process.off("SIGTERM", onTerm); process.off("exit", onExit); };
60
+ p.on("error", (e) => { out += `\n${e.message}`; finish(null); });
61
+ p.on("exit", (code) => { grace = setTimeout(() => { kill(); finish(code); }, 1_000); });
62
+ p.on("close", (code) => finish(code));
63
+ });
64
+ }
65
+ export async function checkAgent(cfg, deps) {
66
+ const now = deps.now ?? Date.now;
67
+ const r = deps.readiness();
68
+ if (!r.ok || !r.agent)
69
+ return { ok: false, agent: r.agent ?? null, says: r.says || "No agent here can take teammates' requests while you're away.", fix: r.fix || "pantheon doctor says why" };
70
+ const backend = agentById(r.agent);
71
+ const binary = backend ? (deps.binary ?? resolveBinary)(backend) : null;
72
+ if (!backend || !binary)
73
+ return { ok: false, agent: r.agent, says: `${backend?.label ?? r.agent} was not found on this machine.`, fix: r.fix || "install it, then run: pantheon check" };
74
+ const word = randomBytes(9).toString("hex");
75
+ const dir = mkdtempSync(join(tmpdir(), "pantheon-check-"));
76
+ const cleanup = () => { try {
77
+ rmSync(dir, { recursive: true, force: true });
78
+ }
79
+ catch { } };
80
+ process.once("exit", cleanup);
81
+ const work = join(dir, "work"), runHome = join(dir, "home");
82
+ mkdirSync(work, { mode: 0o700 });
83
+ mkdirSync(runHome, { mode: 0o700 });
84
+ const t0 = now();
85
+ try {
86
+ const token = backend.id === "claude-code" ? claudeTokenForRun() : null;
87
+ const features = backend.id === "claude-code" ? (deps.claudeFeatures ?? detectClaudeFeatures)(binary) : null;
88
+ const home = homedir();
89
+ const s = headlessSpawn({
90
+ backend, binary, prompt: CHECK_PROMPT, worktree: work, cfg, branch: "pantheon-check", allowBash: false, selfTest: word, runHome,
91
+ ...(token ? { claudeToken: token } : {}),
92
+ ...(features ? { claude: { features, pantheonHome: CONFIG_DIR, home, userSettings: join(home, ".claude", "settings.json") } } : {}),
93
+ });
94
+ materializeSpawnFiles(work, s, runHome);
95
+ const res = await (deps.run ?? runIt)(s, work, deps.timeoutMs ?? CHECK_TIMEOUT_MS);
96
+ const seconds = Math.max(1, Math.round((now() - t0) / 1000));
97
+ if (res.out.includes(word))
98
+ return { ok: true, agent: backend.label, seconds };
99
+ const tail = res.out.trim().split("\n").slice(-3).join(" ").slice(0, 300);
100
+ if (res.timedOut)
101
+ return { ok: false, agent: backend.label, seconds, says: `${backend.label} did not answer within ${Math.round((deps.timeoutMs ?? CHECK_TIMEOUT_MS) / 1000)} seconds.`, fix: "run pantheon check again; if it repeats, pantheon doctor" };
102
+ if (/log ?in|sign ?in|authenticat|unauthori[sz]ed|credential|api key/i.test(res.out)) {
103
+ return { ok: false, agent: backend.label, seconds, says: `${backend.label} is not signed in for runs without you.`, fix: r.fix || `sign ${backend.label} in, then run: pantheon check` };
104
+ }
105
+ return { ok: false, agent: backend.label, seconds, says: `${backend.label} ran but did not reach Pantheon's tools${tail ? ` (it said: ${tail})` : ""}.`, fix: "pantheon doctor — then pantheon check again" };
106
+ }
107
+ catch (e) {
108
+ return { ok: false, agent: backend.label, says: `${backend.label} could not be started: ${e.message.split("\n")[0]}`, fix: "pantheon doctor" };
109
+ }
110
+ finally {
111
+ process.off("exit", cleanup);
112
+ cleanup();
113
+ }
114
+ }
115
+ //# sourceMappingURL=agent-check.js.map
package/dist/agents.js CHANGED
@@ -683,6 +683,7 @@ export function headlessSpawn(opts) {
683
683
  ...(opts.base ? { PANTHEON_BASE: opts.base } : {}),
684
684
  ...(opts.goal ? { PANTHEON_GOAL: opts.goal } : {}),
685
685
  ...(home ? { PANTHEON_HOME: home } : {}),
686
+ ...(opts.selfTest ? { PANTHEON_MCP_SELFTEST: opts.selfTest } : {}),
686
687
  };
687
688
  if (opts.backend.id === "claude-code") {
688
689
  const mcpCfg = join(opts.worktree, ".pantheon-mcp.json");