@join-pantheon/cli 0.33.11 → 0.34.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.
@@ -105,12 +105,6 @@ export class Allowlist {
105
105
  this.founderName = d?.member ?? null;
106
106
  if (d?.how === "earliest")
107
107
  this.founderGuessed = "no member was admitted by themselves, so the earliest member to connect was taken";
108
- if (this.founderName) {
109
- try {
110
- this.flush();
111
- }
112
- catch { }
113
- }
114
108
  }
115
109
  }
116
110
  }
package/dist/store.js CHANGED
@@ -4,6 +4,8 @@ import { emptyRefusals } from "./admin-stats.js";
4
4
  import { pendingView, writerFor } from "./disk-writer.js";
5
5
  import { emptyUsage, parseUsage } from "./usage.js";
6
6
  export const USAGE_SAVE_MS = 5_000;
7
+ export const FIRST_CLAIMS_KEEP_MS = 31 * 86_400_000;
8
+ export const FIRST_CLAIMS_MAX = 5_000;
7
9
  export function ensurePrivateDir(dir) {
8
10
  mkdirSync(dir, { recursive: true, mode: 0o700 });
9
11
  try {
@@ -99,6 +101,17 @@ export class StateStore {
99
101
  refusals = emptyRefusals();
100
102
  headOf;
101
103
  rebuilt = null;
104
+ compactedThrough = null;
105
+ noteCompacted(ts) {
106
+ if (ts !== null && Number.isFinite(ts) && (this.compactedThrough === null || ts > this.compactedThrough))
107
+ this.compactedThrough = ts;
108
+ }
109
+ firstClaims = new Map();
110
+ noteFirstClaim(c) {
111
+ if (this.firstClaims.has(c.ob))
112
+ return;
113
+ this.firstClaims.set(c.ob, c);
114
+ }
102
115
  extra = {};
103
116
  usage = emptyUsage();
104
117
  usageFile;
@@ -179,7 +192,16 @@ export class StateStore {
179
192
  }
180
193
  for (const p of snap.profiles ?? [])
181
194
  profiles.set(p.member, p);
182
- const known = new Set(["v", "goals", "obligations", "profiles", "refusals", "ledger_head", "rebuilt", "saved_at"]);
195
+ const known = new Set(["v", "goals", "obligations", "profiles", "refusals", "ledger_head", "rebuilt", "first_claims", "compacted_through", "saved_at"]);
196
+ this.compactedThrough = typeof snap.compacted_through === "number" && Number.isFinite(snap.compacted_through) ? snap.compacted_through : null;
197
+ this.firstClaims = new Map();
198
+ if (Array.isArray(snap.first_claims)) {
199
+ for (const c of snap.first_claims) {
200
+ if (!c || typeof c !== "object" || typeof c.ob !== "string" || typeof c.ref !== "string" || typeof c.owner !== "string" || typeof c.at !== "number" || !Number.isFinite(c.at))
201
+ continue;
202
+ this.firstClaims.set(c.ob, { ob: c.ob, ref: c.ref, owner: c.owner, at: c.at, by: c.by === "worker" ? "worker" : "person" });
203
+ }
204
+ }
183
205
  this.extra = {};
184
206
  for (const [k, v] of Object.entries(snap))
185
207
  if (!known.has(k))
@@ -235,10 +257,23 @@ export class StateStore {
235
257
  ...(this.refusals.total ? { refusals: this.refusals } : {}),
236
258
  ...(this.headOf ? { ledger_head: this.headOf() } : {}),
237
259
  ...(this.rebuilt ? { rebuilt: this.rebuilt } : {}),
260
+ ...(this.firstClaims.size ? { first_claims: this.keptFirstClaims() } : {}),
261
+ ...(this.compactedThrough !== null ? { compacted_through: this.compactedThrough } : {}),
238
262
  saved_at: Date.now(),
239
263
  };
240
264
  writerFor(this.dir, this.stem).replace(this.file, JSON.stringify(snap, null, 2) + "\n");
241
265
  }
266
+ keptFirstClaims(now = Date.now()) {
267
+ for (const [k, c] of this.firstClaims)
268
+ if (now - c.at > FIRST_CLAIMS_KEEP_MS)
269
+ this.firstClaims.delete(k);
270
+ if (this.firstClaims.size > FIRST_CLAIMS_MAX) {
271
+ const drop = [...this.firstClaims.values()].sort((a, b) => a.at - b.at).slice(0, this.firstClaims.size - FIRST_CLAIMS_MAX);
272
+ for (const c of drop)
273
+ this.firstClaims.delete(c.ob);
274
+ }
275
+ return [...this.firstClaims.values()];
276
+ }
242
277
  close(goals, obligations, profiles) {
243
278
  if (this.timer) {
244
279
  clearTimeout(this.timer);
package/dist/tray.js CHANGED
@@ -20,6 +20,7 @@ import { pickupEstimate } from "./pickup.js";
20
20
  import { allDecisionsPrompt, decisionPrompt, decisionTitle, owedPrompt, stripCeremony, tidyIds, tidyLead, waitingPrompt, workerSummary } from "./decision-ui.js";
21
21
  import { loadProfile, SURFACE_BUNDLE_IDS } from "./profile.js";
22
22
  import { agentProblem, PROBLEM_LEAD } from "./readiness-alert.js";
23
+ import { claudeAppPresent, effectiveOpenIn } from "./open-in.js";
23
24
  const HERE = dirname(fileURLToPath(import.meta.url));
24
25
  export const trayBinaryPath = (home = CONFIG_DIR) => join(home, "bin", "pantheon-tray");
25
26
  export const traySourcePath = () => resolve(HERE, "..", "helper", "macos", "menubar.swift");
@@ -371,7 +372,19 @@ async function trayStatusOne(cfg, membershipId) {
371
372
  function machineFields(cfg, workerRunning = workerProc().running) {
372
373
  const profile = loadProfile(cfg);
373
374
  const surface = profile.agent.primary_surface;
374
- const surfaceName = surface === "claude-code" ? "Claude" : surface === "cursor" ? "Cursor" : surface === "copilot" ? "Copilot" : surface === "kiro" ? "Kiro" : "Codex";
375
+ const appHere = (() => { try {
376
+ return claudeAppPresent();
377
+ }
378
+ catch {
379
+ return false;
380
+ } })();
381
+ const openIn = (() => { try {
382
+ return effectiveOpenIn({ home: CONFIG_DIR, appPresent: () => appHere });
383
+ }
384
+ catch {
385
+ return "terminal";
386
+ } })();
387
+ const surfaceName = openIn === "app" ? "Claude app" : surface === "claude-code" ? "Claude" : surface === "cursor" ? "Cursor" : surface === "copilot" ? "Copilot" : surface === "kiro" ? "Kiro" : "Codex";
375
388
  const rawWorkerState = workerState();
376
389
  const problem = (() => { try {
377
390
  return agentProblem(CONFIG_DIR);
@@ -388,6 +401,8 @@ function machineFields(cfg, workerRunning = workerProc().running) {
388
401
  ...(problem ? { agent_problem: problem, agent_problem_lead: PROBLEM_LEAD, worker_state: `${PROBLEM_LEAD}: ${problem}` } : rawWorkerState ? { worker_state: workerSummary(rawWorkerState) } : {}),
389
402
  surface_name: surfaceName,
390
403
  surface_bundle_id: SURFACE_BUNDLE_IDS[surface],
404
+ open_in: openIn,
405
+ claude_app: appHere,
391
406
  };
392
407
  }
393
408
  function goneStatus(cfg, g, membershipId) {
@@ -246,7 +246,7 @@ export async function handleUri(args, d) {
246
246
  logUri(d.home, `${describeUri(p)}: queued ${action.action}`, now());
247
247
  const code = await d.runQueued(action.nonce);
248
248
  logUri(d.home, `${describeUri(p)}: explain --queued exited ${code}`, now());
249
- if (code !== 0 || p.host === "details")
249
+ if (code !== 0 || (p.host === "details" && !(d.opensInApp?.() ?? false)))
250
250
  await d.pause();
251
251
  return code;
252
252
  }
@@ -0,0 +1,190 @@
1
+ import { MARK, SEAL, cap, esc, head, pct, plural, rangeSeg, rangeWords, script, split, stackedColumns, steps, when } from "./admin-ui.js";
2
+ import { asOfHtml, signinShell, stateNoteHtml, stepSubs, threadOutcome } from "./admin-pages.js";
3
+ import { dur } from "./flow-stats.js";
4
+ export function renderViewerSignin(o) {
5
+ const hero = `<h1>See how your team's work moves.</h1>
6
+ <p>Read-only access to the Pantheon teams you were added to. You see who asked whom, who picked it up and how long it took.</p>
7
+ <ul class="points">
8
+ <li>Message text, code and files stay with the team.</li>
9
+ <li>You cannot send, approve or change anything.</li>
10
+ <li>Every visit is logged where the team and the relay's operator can see it.</li>
11
+ </ul>`;
12
+ const form = o.step === "email" ? `<form class="form" method="POST" action="/view/code">
13
+ <h2>Sign in</h2>
14
+ <p>No password. We email you a 6-digit code.</p>
15
+ <label for="email">Work email</label>
16
+ <input class="big" id="email" type="email" name="email" autocomplete="email" placeholder="you@company.com" value="${esc(o.email)}" required autofocus>
17
+ <button class="cta" type="submit">Email me a code</button>
18
+ ${o.error ? `<p class="err" role="alert">${esc(o.error)}</p>` : ""}
19
+ <p class="small">If this address was given access to a team, a code arrives within a minute. If it wasn't, nothing is sent and this page looks the same.</p>
20
+ </form>` : `<form class="form" method="POST" action="/view/verify">
21
+ <h2>Check your email</h2>
22
+ <p>If <b style="color:var(--text)">${esc(o.email)}</b> has access to a team, we sent it a code. It works for 10 minutes.</p>
23
+ <input type="hidden" name="email" value="${esc(o.email)}">
24
+ <label for="code">6-digit code</label>
25
+ <input class="big code" id="code" name="code" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required autofocus aria-describedby="code-help"${o.error ? ` aria-invalid="true"` : ""}>
26
+ <button class="cta" type="submit">Sign in</button>
27
+ ${o.error ? `<p class="err" role="alert">${esc(o.error)}</p>` : ""}
28
+ <p class="small" id="code-help">No code? Check spam, or wait a minute and <a href="/view/signin?email=${encodeURIComponent(o.email)}">ask for a new one</a>. <a href="/view/signin">Use a different email</a>.</p>
29
+ </form>`;
30
+ return signinShell({ title: "Pantheon team view", description: "Sign in with an emailed code to see the teams you were given read-only access to.", nonce: o.nonce, home: "/view", hero, form });
31
+ }
32
+ const shell = (o) => `${head({ title: o.title, description: o.description, nonce: o.nonce, refresh: o.refresh, refreshTo: o.refreshTo })}
33
+ <body>
34
+ <header class="top">
35
+ <a class="skip" href="#main">Skip to content</a>
36
+ <a class="lockup" href="/view">${MARK}<b>Pantheon</b></a>
37
+ <span class="ctx">${o.ctx}</span>
38
+ <div class="right"><span class="wrapc">${esc(o.email)}</span><button type="button" class="iconbtn" data-theme-toggle>Dark</button><form method="POST" action="/view/signout" class="inl"><input type="hidden" name="csrf" value="${esc(o.csrf)}"><button class="linkbtn">Sign out</button></form></div>
39
+ </header>
40
+ <main id="main">
41
+ ${o.body}
42
+ </main>
43
+ ${script(o.nonce)}
44
+ </body>
45
+ </html>`;
46
+ export function renderViewerNeedsHttps(o) {
47
+ return signinShell({
48
+ title: "Pantheon team view", description: "This relay needs HTTPS for viewer sign-in.", nonce: o.nonce, home: "/view",
49
+ hero: `<h1>This relay needs HTTPS for viewer sign-in.</h1><p>Sign-in keeps you signed in with a cookie that browsers send only over HTTPS. This page was opened over plain HTTP, so it would never stick.</p>`,
50
+ form: `<div class="form"><h2>What to do</h2><p>Open this page with <b style="color:var(--text)">https://</b> instead. If the relay has no HTTPS address, its operator needs to put it behind one (a proxy that terminates TLS and sets X-Forwarded-Proto) before viewers can sign in.</p></div>`,
51
+ });
52
+ }
53
+ export function renderViewerHome(o) {
54
+ return shell({
55
+ nonce: o.nonce, csrf: o.csrf, email: o.email, title: "Pantheon team view", description: "The teams you can see, read-only.", ctx: `<span class="chip plain">read-only</span>`,
56
+ body: `<section class="sec" style="margin-top:28px" aria-labelledby="h-teams"><div class="sechead"><h1 id="h-teams">Your teams</h1><p>read-only access</p></div>
57
+ <div class="card"><ul class="list">${o.teams.map((t) => `<li><span class="ic" aria-hidden="true">→</span><div class="t"><a class="tname" href="/view/team?name=${encodeURIComponent(t.name)}">${esc(t.name)}</a><span class="sub">access ends ${when(t.expiresAt, "date")}</span></div></li>`).join("") || `<li class="none"><div class="t">You have no team to see right now. Access ends on the date it was given for, or when it is revoked.</div></li>`}</ul></div></section>`,
58
+ });
59
+ }
60
+ export function renderViewerEnded(o) {
61
+ return shell({
62
+ nonce: o.nonce, csrf: o.csrf, email: o.email, title: "Pantheon team view", description: "Access ended.", ctx: `<span class="chip plain">read-only</span>`,
63
+ body: `<div class="privacy" role="note" style="margin-top:28px"><span aria-hidden="true">${SEAL}</span><div>Your access to this team has ended, or was never given. Ask the relay's operator if you need it again. <a href="/view">Your teams</a></div></div>`,
64
+ });
65
+ }
66
+ export const BUSY_RELOADS = 3;
67
+ export function renderViewerBusy(o) {
68
+ const page = `/view/team?name=${encodeURIComponent(o.team)}&range=${o.days}`;
69
+ const again = o.tries < BUSY_RELOADS;
70
+ const next = `${page}&busy=${o.tries + 1}`;
71
+ return shell({
72
+ nonce: o.nonce, csrf: o.csrf, email: o.email, title: "Pantheon team view", description: "Loading another page.", ctx: `<b>${esc(o.team)}</b> <span class="chip plain">read-only</span>`,
73
+ ...(again ? { refresh: 2, refreshTo: next } : {}),
74
+ body: `<div class="privacy" role="status" style="margin-top:28px"><span aria-hidden="true">${SEAL}</span><div>${again
75
+ ? `Loading another page for you, this one will reload in a moment. <a href="${esc(next)}">Reload now</a>`
76
+ : `Another page for you is still loading, so this one stopped reloading. <a href="${esc(page)}">Reload now</a> · <a href="/view">Back to your team</a>`}</div></div>`,
77
+ });
78
+ }
79
+ export function renderViewerUnreadable(o) {
80
+ return shell({
81
+ nonce: o.nonce, csrf: o.csrf, email: o.email, title: "Pantheon team view", description: "The team's history can't be read right now.", ctx: `<b>${esc(o.team)}</b> <span class="chip plain">read-only</span>`,
82
+ body: `<div class="privacy" role="alert" style="margin-top:28px"><span aria-hidden="true">${SEAL}</span><div>This team's history can't be read right now (<span class="mono">${esc(o.code)}</span>). Nothing is lost by waiting: try again in a few minutes. <a href="/view">Your teams</a></div></div>`,
83
+ });
84
+ }
85
+ export function renderViewerTeam(d) {
86
+ const f = d.flow, range = rangeWords(d.days);
87
+ const people = f.members.length;
88
+ const max = Math.max(1, ...Object.values(f.matrix.n).flatMap((r) => Object.values(r)));
89
+ const cell = (n, from, to) => {
90
+ if (!n)
91
+ return `<td class="z" aria-label="${esc(cap(from))} asked ${esc(cap(to))}: none">·</td>`;
92
+ const a = 0.18 + 0.82 * (n / max);
93
+ return `<td class="h" tabindex="0" data-tip="${plural(n, "ask")}|${esc(cap(from))} asked ${esc(cap(to))}" aria-label="${esc(cap(from))} asked ${esc(cap(to))}: ${n}" style="--a:${a.toFixed(2)}">${n}</td>`;
94
+ };
95
+ let top = null, ties = 0;
96
+ for (const [from, row] of Object.entries(f.matrix.n))
97
+ for (const [to, n] of Object.entries(row)) {
98
+ if (!top || n > top.n) {
99
+ top = { from, to, n };
100
+ ties = 0;
101
+ }
102
+ else if (n === top.n)
103
+ ties++;
104
+ }
105
+ const matrix = f.matrix.from.length ? `<table class="matrix" aria-label="Who asked whom, ${range}">
106
+ <thead><tr><th></th>${f.matrix.to.map((p) => `<th scope="col">${esc(cap(p))}</th>`).join("")}</tr></thead>
107
+ <tbody>${f.matrix.from.map((from) => `<tr><th scope="row" class="rowh">${esc(cap(from))}</th>${f.matrix.to.map((to) => from === to ? `<td class="self" aria-hidden="true"></td>` : cell(f.matrix.n[from]?.[to] ?? 0, from, to)).join("")}</tr>`).join("")}</tbody>
108
+ </table>` : `<p class="muted" style="margin:0">Nobody asked anyone ${range}.</p>`;
109
+ const waiting = f.waiting.map((w) => `<li><div class="t"><b>${esc(cap(w.owner))}</b> to decide${w.from && w.from !== w.owner ? `, asked by ${esc(cap(w.from))}'s agent` : ", escalated by their own agent"} <span class="num">${dur(w.ageMs)}</span> ago<span class="sub">${w.goalTitle ? `in ${esc(w.goalTitle)}` : "not in a goal"}${w.blocksGoal ? " · the goal is blocked until they answer" : ""}</span></div></li>`).join("");
110
+ const flowRows = f.threads.map((t) => {
111
+ const oc = threadOutcome(t, true);
112
+ return `<li><span class="ic" aria-hidden="true">→</span><div class="t">
113
+ <div class="row" style="gap:8px"><b>${t.kind === "decision" && t.from === t.to ? `${esc(cap(t.from))} escalated` : `${esc(cap(t.from))} → ${esc(cap(t.to))}`}</b> ${oc.chip} ${oc.role}</div>
114
+ <span class="sub">${t.goalTitle ? `in ${esc(t.goalTitle)} · ` : ""}<i class="hidden-text">message text hidden</i></span>
115
+ ${steps(stepSubs(t))}
116
+ <span class="sub">${esc(oc.text)}</span></div></li>`;
117
+ }).join("");
118
+ const pron = (who) => cap(who);
119
+ const carriedRows = f.carried.map((c) => `<tr><td class="span"><b class="who">${esc(cap(c.who))}</b><span class="sub">${esc(c.agent)}</span></td><td data-l="Asked" class="r num">${c.asked}</td><td data-l="Answered by" class="span">${split(c.byWorker, c.byPerson, c.asked, 140)}<span class="sub num">${c.byWorker} by their worker · ${c.byPerson} by ${esc(pron(c.who))} in person</span></td><td data-l="Median time to answer" class="r num">${c.medianMs !== null ? dur(c.medianMs) : `<span class="quiet">none yet</span>`}</td><td data-l="Open now" class="r num">${c.open || `<span class="quiet">0</span>`}</td></tr>`).join("");
120
+ const goalRows = f.goals.filter((g) => g.state !== "CLOSED").map((g) => `<tr><td class="span"><b>${esc(g.title)}</b>${g.worklist ? ` <span class="chip plain">worklist</span>` : ""}${g.why ? `<span class="sub">${g.state === "BLOCKED" ? "blocked " : ""}${esc(g.why)}</span>` : ""}</td><td data-l="State">${g.state === "OPEN" ? `<span class="chip">open</span>` : g.state === "STALLED" ? `<span class="chip line">${SEAL} out of acts</span>` : `<span class="chip line">${SEAL} blocked</span>`}</td><td data-l="Deadline">${g.deadline ? `${when(g.deadline, "full")}${g.overdueMs !== null ? ` <span class="chip line">overdue</span>` : ""}` : `<span class="quiet">none</span>`}</td><td data-l="Open items" class="r num">${g.open || `<span class="quiet">0</span>`}</td></tr>`).join("");
121
+ const openGoals = f.goals.filter((g) => g.state !== "CLOSED").length;
122
+ return shell({
123
+ nonce: d.nonce, csrf: d.csrf, email: d.email, title: `${d.team} · Pantheon team view`,
124
+ description: "Read-only view of how work moves in one team: who asked whom, who picked it up, how long it took, and what waits on a person.",
125
+ ctx: `<b style="color:var(--text);font-size:14px">${esc(d.team)}</b><span class="chip plain">read-only</span>`,
126
+ body: ` <div class="privacy" role="note">
127
+ <span aria-hidden="true">${SEAL}</span>
128
+ <div>You see who handed work to whom, who picked it up and how long it took. Message text, code and files stay with the team. The relay's operator added you on ${when(d.grantedAt, "date")}, and the team was told. Access ends ${when(d.expiresAt, "date")}.</div>
129
+ </div>
130
+
131
+ <div class="sechead" style="margin-top:24px">
132
+ <h1>How work moved ${range}</h1>
133
+ <div class="end">${rangeSeg((n) => `/view/team?name=${encodeURIComponent(d.team)}&range=${n}`, d.days)}</div>
134
+ </div>
135
+
136
+ <div class="grid2">
137
+ <section class="tile call" aria-labelledby="h-wait" style="padding:18px 20px">
138
+ <div class="l" id="h-wait">${SEAL} Waiting on a person</div>
139
+ <div class="v" style="font-size:56px;line-height:1;margin:8px 0 10px">${d.stateNote?.kind === "rebuild" ? "–" : f.waiting.length}</div>
140
+ <ul class="list" style="margin:0 -20px -18px;border-top:1px solid var(--line)">${waiting || `<li class="none"><div class="t">${d.stateNote?.kind === "rebuild" ? "Not shown until this team rebuilds (the next time a member connects)." : "No decision is waiting on anyone."}</div></li>`}</ul>
141
+ ${d.live && asOfHtml(d.asOf, d.now ?? Date.now()) ? `<p class="quiet" style="margin:10px 0 0;font-size:12px">${asOfHtml(d.asOf, d.now ?? Date.now())}; refreshes every 15 seconds</p>` : ""}
142
+ </section>
143
+ <div class="tiles" style="grid-template-columns:repeat(2,minmax(0,1fr));margin-top:0">
144
+ <div class="tile"><div class="l">Requests handed off</div><div class="v">${f.asks}${f.partial ? `<small>partial</small>` : ""}</div><div class="d">between ${plural(people, "person's agents", "people's agents")}</div></div>
145
+ <div class="tile"><div class="l">Answered</div><div class="v">${f.answered}${f.asks ? `<small>${pct(f.answered, f.asks)}%</small>` : ""}</div><div class="d">${f.medianAnswerMs !== null ? `median ${dur(f.medianAnswerMs)} to answer` : "nothing answered yet"}</div></div>
146
+ <div class="tile"><div class="l">Answered by a worker</div>${f.answered ? `<div class="v">${pct(f.answeredByWorker, f.answered)}%</div><div class="d">${f.answeredByWorker} of ${plural(f.answered, "answer")} came from a person's worker (an unattended agent)</div>` : `<div class="v">none yet</div><div class="d">nothing answered ${range}</div>`}</div>
147
+ <div class="tile"><div class="l">Delivered</div><div class="v">${f.delivered}</div><div class="d">each naming a branch and commit</div></div>
148
+ </div>
149
+ </div>
150
+
151
+ ${stateNoteHtml(d.stateNote, true)}
152
+ ${f.historyFrom ? `<p class="note">Partial: counts start ${when(f.historyFrom, "full")}. Older history in this range was compacted on the relay, so asks, answers and hand-offs before then are not counted.</p>` : ""}
153
+ <div class="grid2 sec">
154
+ <section class="card" aria-labelledby="h-flow">
155
+ <div class="sechead cardhead" style="margin-bottom:4px"><h2 id="h-flow">Recent hand-offs</h2><p>Ask, propose, contract, commit, delivered</p></div>
156
+ <ul class="list">${flowRows || `<li class="none"><div class="t">No hand-offs ${range}.</div></li>`}</ul>
157
+ </section>
158
+ <div class="stack">
159
+ <section class="card pad" aria-labelledby="h-who">
160
+ <div class="sechead" style="margin-bottom:10px"><h2 id="h-who">Who asked whom</h2><p>rows asked, columns were asked</p></div>
161
+ <div class="scroll">${matrix}</div>
162
+ ${top ? `<p class="note">Stronger teal means more asks. ${ties ? `The most from one person to another ${range} is ${plural(top.n, "request")}, shared by ${ties + 1} pairs (${esc(cap(top.from))} to ${esc(cap(top.to))} is one).` : `${esc(cap(top.from))} handed ${plural(top.n, "request")} to ${esc(cap(top.to))} ${range}, the most of any pair.`}</p>` : ""}
163
+ </section>
164
+ <section class="card pad" aria-labelledby="h-daily">
165
+ <div class="sechead" style="margin-bottom:4px"><h2 id="h-daily">Messages per day</h2><p>the last 14 UTC days</p></div>
166
+ ${stackedColumns({ days: d.series14, width: 520, height: 160, step: 3, label: `Messages per day for 14 days. ${f.messages.total} ${range}, ${f.messages.worker} by workers.` })}
167
+ </section>
168
+ </div>
169
+ </div>
170
+
171
+ <section class="sec" aria-labelledby="h-carry">
172
+ <div class="sechead"><h2 id="h-carry">Who carried the work</h2><p>requests each person was asked, and whether their worker or they answered</p></div>
173
+ <div class="card"><table class="rt">
174
+ <thead><tr><th>Asked of</th><th class="r">Asked</th><th>Answered by</th><th class="r">Median time to answer</th><th class="r">Open now</th></tr></thead>
175
+ <tbody>${carriedRows || `<tr><td colspan="5" class="empty">Nobody was asked anything ${range}.</td></tr>`}</tbody>
176
+ </table></div>
177
+ </section>
178
+
179
+ <section class="sec" aria-labelledby="h-goals">
180
+ <div class="sechead"><h2 id="h-goals">Goals in progress</h2><p>${openGoals} open</p></div>
181
+ <div class="card"><table class="rt">
182
+ <thead><tr><th>Goal</th><th>State</th><th>Deadline</th><th class="r">Open items</th></tr></thead>
183
+ <tbody>${goalRows || `<tr><td colspan="4" class="empty">No goal is open.</td></tr>`}</tbody>
184
+ </table></div>
185
+ </section>
186
+
187
+ <p class="note" style="margin-top:28px">This page reads the team's hand-off record on its Pantheon relay. Pantheon adds no tracking to make it. Your visits are logged (about one entry per 10 minutes), and the team and the relay's operator can see that log. Times are in your browser's time zone.</p>`,
188
+ });
189
+ }
190
+ //# sourceMappingURL=viewer-pages.js.map
@@ -8,7 +8,8 @@
8
8
  * Open in <tool> ▾ launches the chosen agent CLI with the question pre-filled
9
9
  * (the choice becomes the default), through a .command file
10
10
  * Terminal runs — no automation permission needed
11
- * Show details prints the act and the decision in Terminal
11
+ * Show details prints the act and the decision in Terminal — or, where this
12
+ * machine opens questions in the Claude app, explains it there
12
13
  * Fix it here (a failed run) opens a Terminal where the work is, steps shown
13
14
  * Sign in (your agent is signed out) opens a Terminal that asks, then signs it in
14
15
  * Show me how (no agent CLI, a sandbox that cannot start) shows this computer's steps
@@ -40,7 +41,8 @@ if args.count == 2, args[1] == "version" {
40
41
  exit(0)
41
42
  }
42
43
 
43
- struct Tool: Decodable { let id: String; let label: String; let kind: String?; let bundle: String?; let deeplink: String? }
44
+ /// via "pantheon": the click goes to `pantheon explain --queued --silent`, which opens the app with the whole question — no Terminal.
45
+ struct Tool: Decodable { let id: String; let label: String; let kind: String?; let bundle: String?; let deeplink: String?; let via: String? }
44
46
  struct Primary: Decodable { let label: String; let `default`: String; let tools: [Tool]; let prompt: String }
45
47
  struct Details: Decodable { let act: String?; let decision: String? }
46
48
  /// The one thing a person could do about a failed run: where, and which steps.
@@ -64,6 +66,8 @@ struct Notice: Decodable {
64
66
  let primary: Primary?
65
67
  let details: Details?
66
68
  let fix: Fix?
69
+ /** "app": this machine opens questions in the Claude app (open-in.ts) — Show details goes there too, never to Terminal */
70
+ let open_in: String?
67
71
  let change: Change?
68
72
  let run: RunRef?
69
73
  let review: Review?
@@ -184,15 +188,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
184
188
  }
185
189
 
186
190
  /// Remember the pick: the next notice opens here by default.
191
+ /// The ▾ pick, merged into the preference file: where questions open (`open_in`, set by
192
+ /// `pantheon open-in`) is the person's other choice and must survive a pick here.
187
193
  private func remember(_ tool: String) {
188
- guard !notice.bin_dir.isEmpty, let data = try? JSONSerialization.data(withJSONObject: ["tool": tool]) else { return }
189
- try? data.write(to: URL(fileURLWithPath: notice.bin_dir).appendingPathComponent(".hud-pref.json"), options: .atomic)
194
+ guard !notice.bin_dir.isEmpty else { return }
195
+ let url = URL(fileURLWithPath: notice.bin_dir).appendingPathComponent(".hud-pref.json")
196
+ var doc: [String: Any] = [:]
197
+ if let d = try? Data(contentsOf: url), let j = try? JSONSerialization.jsonObject(with: d) as? [String: Any] { doc = j }
198
+ doc["tool"] = tool
199
+ guard let data = try? JSONSerialization.data(withJSONObject: doc) else { return }
200
+ try? data.write(to: url, options: .atomic)
190
201
  }
191
202
 
192
203
  private func open(_ toolId: String) {
193
204
  guard let p = notice.primary else { return }
194
205
  remember(toolId)
195
206
  let tool = p.tools.first { $0.id == toolId }
207
+ if let t = tool, t.via == "pantheon", !notice.bin_dir.isEmpty {
208
+ runQuietly(["action": "open", "tool": toolId, "prompt": p.prompt, "decision": notice.details?.decision as Any, "act": notice.details?.act as Any, "space": notice.space as Any].compactMapValues { $0 is NSNull ? nil : $0 })
209
+ return
210
+ }
196
211
  if let t = tool, t.kind == "app" {
197
212
  // A deep link carries the question itself; an app without one gets it on the clipboard and comes to the front.
198
213
  if let template = t.deeplink, let encoded = p.prompt.addingPercentEncoding(withAllowedCharacters: .alphanumerics), let url = URL(string: template.replacingOccurrences(of: "{prompt}", with: encoded)) {
@@ -213,6 +228,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
213
228
  @objc func openDefault(_ sender: Any?) { open(notice.primary?.default ?? "") }
214
229
 
215
230
  @objc func showDetails(_ sender: Any?) {
231
+ if notice.open_in == "app", !notice.bin_dir.isEmpty {
232
+ runQuietly(["action": "details", "act": notice.details?.act as Any, "decision": notice.details?.decision as Any, "space": notice.space as Any].compactMapValues { $0 is NSNull ? nil : $0 })
233
+ return
234
+ }
216
235
  act(["action": "details", "act": notice.details?.act as Any, "decision": notice.details?.decision as Any, "space": notice.space as Any].compactMapValues { $0 is NSNull ? nil : $0 }, command: "pantheon-details.command")
217
236
  }
218
237
 
@@ -242,7 +261,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
242
261
  let quoted = "'" + bin.replacingOccurrences(of: "'", with: "'\\''") + "'"
243
262
  let p = Process()
244
263
  p.executableURL = URL(fileURLWithPath: "/bin/sh")
245
- p.arguments = ["-lc", "\(quoted) explain --queued >/dev/null 2>&1"] // login shell: PATH with node, as the user's own terminal has
264
+ // --silent: no Terminal is here, so where the CLI cannot open the Claude app it opens one itself.
265
+ p.arguments = ["-lc", "\(quoted) explain --queued --silent >/dev/null 2>&1"] // login shell: PATH with node, as the user's own terminal has
246
266
  try? p.run()
247
267
  NSApp.terminate(nil)
248
268
  }
@@ -75,6 +75,10 @@ struct TrayState {
75
75
  var agentProblemLead = "Unattended work can't run"
76
76
  var surfaceName = "agent"
77
77
  var surfaceBundleID = ""
78
+ /// where Explain and Show the thread open (open-in.ts): "app" is the Claude app, with no Terminal
79
+ var openIn = "terminal"
80
+ /// the Claude app is installed here, so the choice can be offered
81
+ var claudeApp = false
78
82
  var decisionsPrompt = ""
79
83
  var decisions: [(id: String, body: String, detail: String, prompt: String)] = []
80
84
  var items: [Item] = []
@@ -197,6 +201,8 @@ func fetchState() -> TrayState {
197
201
  if let lead = j["agent_problem_lead"] as? String, !lead.isEmpty { s.agentProblemLead = lead }
198
202
  s.surfaceName = j["surface_name"] as? String ?? "agent"
199
203
  s.surfaceBundleID = j["surface_bundle_id"] as? String ?? ""
204
+ s.openIn = j["open_in"] as? String ?? "terminal"
205
+ s.claudeApp = j["claude_app"] as? Bool ?? false
200
206
  s.decisionsPrompt = j["decisions_prompt"] as? String ?? ""
201
207
  s.spaces = j["spaces"] as? [String] ?? []
202
208
  for g in (j["gone_spaces"] as? [[String: Any]] ?? []) {
@@ -912,6 +918,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
912
918
  else if state.workerRunning { act("Pause unattended work", problem.isEmpty ? state.workerState : "can't run now") { [weak self] in self?.pauseWorker() } }
913
919
  else if state.workerInstalled { act("Resume unattended work", "paused") { [weak self] in self?.resumeWorker() } }
914
920
  else { note("Unattended work is not set up — pantheon service install worker") }
921
+ if state.claudeApp {
922
+ act(state.openIn == "app" ? "Open questions in Terminal instead" : "Open questions in the Claude app", state.openIn == "app" ? "now: Claude app" : "now: Terminal") { [weak self] in self?.toggleOpenIn() }
923
+ }
915
924
  }
916
925
  if let error = actionError { sep(); note(error) }
917
926
  sep()
@@ -1102,6 +1111,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
1102
1111
  details.submenu = submenu
1103
1112
  menu.addItem(details)
1104
1113
  menu.addItem(.separator())
1114
+ if state.configured && state.claudeApp {
1115
+ menu.addItem(makeItem(state.openIn == "app" ? "Open questions in Terminal instead" : "Open questions in the Claude app", #selector(toggleOpenIn)))
1116
+ }
1105
1117
  menu.addItem(makeItem("Open status in Terminal", #selector(openStatus)))
1106
1118
  menu.addItem(makeItem("Check connection in Terminal", #selector(openDoctor)))
1107
1119
  menu.addItem(makeItem("Refresh now", #selector(refreshNow)))
@@ -1572,7 +1584,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
1572
1584
  row1.addArrangedSubview(button(away ? "Bring back" : "Later", #selector(panelLater),
1573
1585
  away ? "Puts it back on the board now." : "Puts it away until 9:00 tomorrow, on this machine only. Nothing is sent; it is still owed."))
1574
1586
  }
1575
- row1.addArrangedSubview(button("Show the thread", #selector(panelThread), "Every act in this goal, in Terminal, from the team's folder."))
1587
+ row1.addArrangedSubview(button("Show the thread", #selector(panelThread), state.openIn == "app" ? "What happened in this goal, explained in the Claude app." : "Every act in this goal, in Terminal, from the team's folder."))
1576
1588
  rows.addArrangedSubview(row1)
1577
1589
 
1578
1590
  let row2 = NSStackView()
@@ -1923,6 +1935,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
1923
1935
  /// Open the agent with this item's question already written out.
1924
1936
  func openItem(_ item: Item) {
1925
1937
  copyPrompt(item)
1938
+ if state.openIn == "app" {
1939
+ // The Claude app, no Terminal: the CLI builds the whole question and opens it there.
1940
+ var payload: [String: Any] = ["action": "open", "prompt": item.prompt]
1941
+ if !item.space.isEmpty { payload["space"] = item.space }
1942
+ if item.isDecision { payload["decision"] = item.id }
1943
+ if !item.ref.isEmpty { payload["act"] = item.ref }
1944
+ if !item.goal.isEmpty { payload["goal"] = item.goal }
1945
+ quietExplain(payload, failing: "Could not open the Claude app. The question is copied; paste it into Claude.")
1946
+ return
1947
+ }
1926
1948
  if writeAction(["action": "open", "prompt": item.prompt]) {
1927
1949
  openCommand("pantheon-explain.command")
1928
1950
  } else {
@@ -1935,10 +1957,36 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
1935
1957
  if !item.ref.isEmpty { payload["act"] = item.ref }
1936
1958
  if !item.goal.isEmpty { payload["goal"] = item.goal }
1937
1959
  if item.isDecision { payload["decision"] = item.id }
1960
+ if state.openIn == "app" { quietExplain(payload, failing: "Could not open the Claude app. Open questions in Terminal instead, from this menu."); return }
1938
1961
  if writeAction(payload) { openCommand("pantheon-details.command") }
1939
1962
  else { reportFailure("Could not open Terminal. Run pantheon doctor to check your setup.") }
1940
1963
  }
1941
1964
 
1965
+ /// Write the action and run `pantheon explain --queued --silent` with no Terminal. Where the
1966
+ /// Claude app will not open, the CLI opens Terminal itself; only a failure of both is said here.
1967
+ private func quietExplain(_ payload: [String: Any], failing: String) {
1968
+ guard writeAction(payload) else { reportFailure(failing); return }
1969
+ DispatchQueue.global().async {
1970
+ let r = run(pantheonBin, ["explain", "--queued", "--silent"], timeout: 60)
1971
+ DispatchQueue.main.async { if r?.code != 0 { self.reportFailure(failing) } }
1972
+ }
1973
+ }
1974
+ /// Claude app or Terminal, for Explain and Show the thread: the person's own click, as `pantheon open-in` is.
1975
+ @objc private func toggleOpenIn() {
1976
+ let to = state.openIn == "app" ? "terminal" : "app"
1977
+ DispatchQueue.global().async {
1978
+ let r = run(pantheonBin, ["open-in", to], timeout: 20)
1979
+ DispatchQueue.main.async {
1980
+ if r?.code != 0 {
1981
+ // What the CLI said (a run in flight: "…or stop it now with: pantheon stop worker"), else a fixed line.
1982
+ let said = (r?.out ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
1983
+ self.reportFailure(said.isEmpty ? "Could not change where questions open. Run pantheon open-in \(to) in Terminal." : said)
1984
+ }
1985
+ self.refresh()
1986
+ }
1987
+ }
1988
+ }
1989
+
1942
1990
  /// Peers in the order their oldest unanswered thing arrived — longest wait first.
1943
1991
  private func orderedPeers(_ items: [Item]) -> [String] {
1944
1992
  var seen: [String] = []
@@ -2064,6 +2112,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
2064
2112
  ?? URL(fileURLWithPath: CommandLine.arguments[0]).deletingLastPathComponent().path
2065
2113
  do {
2066
2114
  try id.write(toFile: dir + "/.explain-id", atomically: true, encoding: .utf8)
2115
+ if state.openIn == "app" {
2116
+ DispatchQueue.global().async {
2117
+ let r = run(pantheonBin, ["explain", "--queued", "--silent"], timeout: 60)
2118
+ DispatchQueue.main.async { if r?.code != 0 { self.reportFailure("Could not open the Claude app. The question is copied; paste it into Claude.") } }
2119
+ }
2120
+ return
2121
+ }
2067
2122
  openCommand("pantheon-explain.command")
2068
2123
  } catch {
2069
2124
  reportFailure("Could not open your agent. The question is copied; paste it into your agent.")
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "format": 1,
3
- "built_at": "2026-10-14T11:53:40.645Z",
3
+ "built_at": "2026-10-15T09:14:55.514Z",
4
4
  "swiftc": "Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)",
5
5
  "helpers": {
6
6
  "pantheon-tray": {
7
7
  "source": "menubar.swift",
8
- "source_sha256": "41a787261a7b50ce12b8e846f698a3c3ab4861b17664a90e71f50abc7777c4d1",
9
- "sha256": "4e0c4e7f9006891593e8d9b73098e5055ba63a70946893eecca041c2d2e1aac3",
8
+ "source_sha256": "7f548530872c9f3d6dded680ca48264ab2ba9442dc6bc0e9de45bf5309446527",
9
+ "sha256": "36596524ba2afdd4da00e6ff417cc69a2508d9cf0909cd9da5c49f27b07cf15d",
10
10
  "archs": [
11
11
  "arm64",
12
12
  "x86_64"
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "pantheon-hud": {
18
18
  "source": "main.swift",
19
- "source_sha256": "eb2d10c53246bd705baf4698d0e637e42d3d7f84b1c325702e9c9f056344c83e",
20
- "sha256": "18d58739022b20539b57720511e9b9e7f3a2188dc8da77fe15ce0f6c83cd16d4",
19
+ "source_sha256": "73f2705c2ce54b766a3b9cb44a106e3b7490aac3fb86148603f402f95c9cf169",
20
+ "sha256": "a357865e2a5cc880673e92b9f7367cd2d7bb2f27977bdd2cff36a8d182044ff5",
21
21
  "archs": [
22
22
  "arm64",
23
23
  "x86_64"
Binary file
Binary file
@@ -110,7 +110,7 @@ $global:PT = @{
110
110
  dash = [string][char]0x2014; dot = [string][char]0x00B7; ellipsis = [string][char]0x2026
111
111
  state = @{
112
112
  loaded = $false; reachable = $false; configured = $false; relayOk = $false; decisionsOk = $true
113
- member = ''; space = ''; spaces = @(); need = 0; workerRunning = $false; workerInstalled = $false; agentProblem = ''; agentProblemLead = ''; gone = @()
113
+ member = ''; space = ''; spaces = @(); need = 0; workerRunning = $false; workerInstalled = $false; agentProblem = ''; agentProblemLead = ''; gone = @(); openIn = 'terminal'; claudeApp = $false
114
114
  }
115
115
  icons = @{}
116
116
  }
@@ -446,6 +446,8 @@ function global:Read-Status([string]$json) {
446
446
  decisionsOk = ($null -eq $j.decisions_ok -or [bool]$j.decisions_ok)
447
447
  member = [string]$j.member; space = [string]$j.space; spaces = @($j.spaces | Where-Object { $_ })
448
448
  need = $need; workerRunning = [bool]$j.worker_running; workerInstalled = [bool]$j.worker_installed
449
+ # Where Explain and Show details open (open-in.ts): the Claude app, with no console, or a terminal.
450
+ openIn = $(if ([string]$j.open_in -eq 'app') { 'app' } else { 'terminal' }); claudeApp = [bool]$j.claude_app
449
451
  # Why this computer cannot take requests, with the fix (signed out, no agent CLI): the heading, the icon and a menu line say it.
450
452
  agentProblem = $(if ($j.agent_problem -is [string]) { $p = ([string]$j.agent_problem) -replace '[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]', ''; if ($p.Length -gt 200) { $p.Substring(0, 199) + $PT.ellipsis } else { $p } } else { '' })
451
453
  agentProblemLead = $(if ($j.agent_problem_lead) { [string]$j.agent_problem_lead } else { "Unattended work can't run" })
@@ -659,6 +661,24 @@ function global:Watch-Board {
659
661
  }
660
662
  }
661
663
 
664
+ # Where questions open: run `pantheon open-in <to>` and, when it refuses (a run in flight), show what it said.
665
+ function global:Set-OpenIn([string]$to) {
666
+ try {
667
+ $p = [System.Diagnostics.Process]::Start((New-PantheonStart @('open-in', $to) $true))
668
+ $out = $p.StandardOutput.ReadToEndAsync()
669
+ if (-not $p.WaitForExit(20000)) { Write-TrayLog ('open-in ' + $to + ': still running after 20s'); return }
670
+ Write-TrayLog ('open-in ' + $to + ': exit ' + $p.ExitCode)
671
+ if ($p.ExitCode -ne 0) {
672
+ $said = ([string]$out.Result).Trim() -replace '[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]', ' '
673
+ if (-not $said) { $said = 'Could not change where questions open. Run: pantheon open-in ' + $to }
674
+ if ($said.Length -gt 250) { $said = $said.Substring(0, 249) + $PT.ellipsis }
675
+ try { $PT.tray.ShowBalloonTip(15000, 'Pantheon', $said, [System.Windows.Forms.ToolTipIcon]::Warning) } catch { }
676
+ }
677
+ $p.Dispose()
678
+ } catch { Write-TrayLog ('open-in ' + $to + ' failed: ' + $_.Exception.Message) }
679
+ $PT.nextCheck = (Get-Date).AddSeconds(2)
680
+ }
681
+
662
682
  function global:Invoke-Hidden([string[]]$words, [string]$what) {
663
683
  try {
664
684
  $p = [System.Diagnostics.Process]::Start((New-PantheonStart $words $false))
@@ -794,6 +814,11 @@ function global:Build-Menu {
794
814
  if ($s.workerRunning) { Add-MenuItem 'Pause unattended work' { Invoke-Hidden $PT.pauseArgs 'pause worker' } }
795
815
  elseif ($s.workerInstalled) { Add-MenuItem 'Resume unattended work' { Invoke-Hidden $PT.resumeArgs 'resume worker' } }
796
816
  else { Add-MenuItem 'Unattended work is not set up' $null $false $false }
817
+ # Claude app or a terminal, for Explain and Show details: the person's own click, as `pantheon open-in` is.
818
+ if ($s.configured -and $s.claudeApp) {
819
+ if ($s.openIn -eq 'app') { Add-MenuItem 'Open questions in a terminal instead' { Set-OpenIn 'terminal' } }
820
+ else { Add-MenuItem 'Open questions in the Claude app' { Set-OpenIn 'app' } }
821
+ }
797
822
  Add-MenuItem 'Status' { Open-PantheonConsole 'Pantheon status' 'status' }
798
823
  Add-MenuItem 'Doctor' { Open-PantheonConsole 'Pantheon doctor' 'doctor' }
799
824
  Add-MenuItem 'Refresh now' { $PT.nextCheck = Get-Date }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@join-pantheon/cli",
3
- "version": "0.33.11",
3
+ "version": "0.34.0-rc.1",
4
4
  "description": "Let your coding agent collaborate directly with your teammates' agents — ask, agree an interface, and deliver, without a human relaying messages.",
5
5
  "type": "module",
6
6
  "bin": {