@join-pantheon/cli 0.37.2 → 0.38.0
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/dist/accounts.js +4 -0
- package/dist/admin-founder.js +5 -2
- package/dist/admin-pages.js +29 -2
- package/dist/cli.js +310 -39
- package/dist/crash-loop.js +207 -0
- package/dist/doctor.js +45 -1
- package/dist/email-templates.js +2 -2
- package/dist/email.js +2 -2
- package/dist/finish-line.js +25 -7
- package/dist/flag-signin.js +6 -2
- package/dist/folder-ask.js +104 -0
- package/dist/founder-stats.js +24 -1
- package/dist/home-guard.js +21 -0
- package/dist/home-safety.js +2 -0
- package/dist/install-stats.js +314 -0
- package/dist/machine.js +2 -0
- package/dist/mcp.js +37 -1
- package/dist/notice.js +127 -0
- package/dist/notifier.js +242 -15
- package/dist/onboard-copy.js +6 -2
- package/dist/pickup.js +11 -3
- package/dist/quickstart.js +41 -21
- package/dist/recover-offer.js +16 -5
- package/dist/relay.js +65 -12
- package/dist/service.js +5 -0
- package/dist/setup-changes.js +5 -0
- package/dist/setup-guide.js +25 -4
- package/dist/status-engine.js +1 -1
- package/dist/tray.js +9 -2
- package/dist/version-health.js +288 -0
- package/dist/win-host.js +2 -0
- package/dist/worker-policy.js +45 -3
- package/dist/worker.js +61 -24
- package/npm-shrinkwrap.json +13 -2
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -21,13 +21,13 @@ import { install, launcher, installForUser, windowsRepoOverrides, agentAsksOnce
|
|
|
21
21
|
import { Relay } from "./relay.js";
|
|
22
22
|
import { runMcp } from "./mcp.js";
|
|
23
23
|
import { Worker } from "./worker.js";
|
|
24
|
-
import { DEFAULT_REMINDER_MS, ensureNativeNotifier, HumanNotifier, hudBinaryPath, openInHere, runNotifiers, sendDesktopNotification } from "./notifier.js";
|
|
24
|
+
import { DEFAULT_REMINDER_MS, ensureNativeNotifier, HumanNotifier, hudBinaryPath, onlyNetworkFailures, openInHere, runNotifiers, sendDesktopNotification } from "./notifier.js";
|
|
25
25
|
import { linuxDesktopReachable } from "./notice-linux.js";
|
|
26
26
|
import { desktopUnavailable, hostEnv } from "./host-env.js";
|
|
27
27
|
import { commandState } from "./command-state.js";
|
|
28
|
-
import { AGENT_SURFACES, applyProfileInit, setupChosen, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
|
|
28
|
+
import { AGENT_SURFACES, applyProfileInit, decisionAlertsOn, setupChosen, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
|
|
29
29
|
import { runGuide, terminalIO, questionOrNull, parseSetupFlags, questionnaire, optOutsFrom, decisionAreasProblem, ALERT_WORDS, AUTOPILOT_WAKE_OFF } from "./setup-guide.js";
|
|
30
|
-
import { APPROVED_ENV, unsandboxedRisk, beginApproval, agentLabel, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, whoIsAsking } from "./setup-changes.js";
|
|
30
|
+
import { APPROVED_ENV, unsandboxedRisk, beginApproval, agentLabel, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, turnedOff, whoIsAsking } from "./setup-changes.js";
|
|
31
31
|
import { selectActs, formatAct, resolveRef } from "./history-view.js";
|
|
32
32
|
import { doctor, ownProcesses, render, shareBlock } from "./doctor.js";
|
|
33
33
|
import { FEEDBACK_ADDRESS } from "./feedback.js";
|
|
@@ -48,7 +48,7 @@ import { agentProblem, PROBLEM_LEAD } from "./readiness-alert.js";
|
|
|
48
48
|
import { stripControls } from "./notice.js";
|
|
49
49
|
import { awaitingDecision, pickupEstimate } from "./pickup.js";
|
|
50
50
|
import { loadPolicy, requestReadinessRecheck, unsandboxedAllowed, savePolicy, MODE_LABELS, AUTOPILOT_PLAN_NOTE, effectiveMode, parseMode, describeMode } from "./worker-policy.js";
|
|
51
|
-
import { alreadyMemberLine, askedLine, configureLines, fetchSeats, inUseLine, offerSeats, seatsForTeam, seatsToMove, startGate, RECOVER_WAITING_EXIT } from "./recover-offer.js";
|
|
51
|
+
import { alreadyMemberLine, askedLine, configureLines, fetchSeats, inUseLine, offerSeats, recoverCommand, seatsForTeam, seatsToMove, startGate, RECOVER_WAITING_EXIT } from "./recover-offer.js";
|
|
52
52
|
import { hyphenateSpaces, shellArg, teamNameProblem } from "./team-name.js";
|
|
53
53
|
import { folderRefusalHere, isTemporaryRefusal, projectFolderAnswer } from "./folder-guard.js";
|
|
54
54
|
import { borrowedHome, installService, serviceInstalled, serviceLogFile, serviceState, servicesUnavailable, uninstallService } from "./service.js";
|
|
@@ -93,7 +93,7 @@ if (PROMPTLESS) {
|
|
|
93
93
|
}
|
|
94
94
|
catch { }
|
|
95
95
|
}
|
|
96
|
-
const JSON_OUT = argv.includes("--json") && ["join", "start", "doctor", "status", "check"].includes(cmd);
|
|
96
|
+
const JSON_OUT = argv.includes("--json") && ["join", "start", "doctor", "status", "check", "setup"].includes(cmd) && !(cmd === "setup" && argv.includes("--questions"));
|
|
97
97
|
let jsonSaid = false;
|
|
98
98
|
function sayJson(o) {
|
|
99
99
|
if (jsonSaid)
|
|
@@ -669,12 +669,17 @@ async function workerAfterBinding(how) {
|
|
|
669
669
|
if (how === "off")
|
|
670
670
|
return;
|
|
671
671
|
const j = load();
|
|
672
|
-
|
|
672
|
+
const team = j?.spaceId;
|
|
673
|
+
if (!j || !team || wakeMode(loadProfile(j)) === "no")
|
|
673
674
|
return;
|
|
674
675
|
const { serviceInstalled, servicesUnavailable } = await import("./service.js");
|
|
675
676
|
if (servicesUnavailable(process.platform) || serviceInstalled("worker"))
|
|
676
677
|
return;
|
|
677
|
-
|
|
678
|
+
if (workerOffByPerson()) {
|
|
679
|
+
console.error(D(` your worker stays off, as you set it — teammates' requests wait for you. To turn it on: pantheon service install worker`));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const ws = (await import("./worker-fleet.js")).teamWorkspaces(loadAll(), team);
|
|
678
683
|
if (!ws.length)
|
|
679
684
|
return;
|
|
680
685
|
try {
|
|
@@ -683,49 +688,163 @@ async function workerAfterBinding(how) {
|
|
|
683
688
|
const { notLoadedWhy } = await import("./setup-guide.js");
|
|
684
689
|
const why = notLoadedWhy(installService("worker", ws[0].path, commandsOn ? ["--allow-bash"] : []));
|
|
685
690
|
if (why) {
|
|
686
|
-
console.error(`\x1b[33m ! the worker is installed but not running (${why}) — teammates' requests wait for you until it runs: pantheon service restart worker\x1b[0m`);
|
|
691
|
+
console.error(`\x1b[33m ! the worker is installed but not running (${why}) — teammates' requests wait for you until it runs: pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
687
692
|
return;
|
|
688
693
|
}
|
|
689
694
|
console.error(` ${C("✓")} worker on — serves ${ws.map((w) => w.name).join(", ")} while you are away${wakeMode(loadProfile(j)) === "approved" ? "; you are asked the first time each teammate needs it" : ""}${commandsOn ? "; a run may run tests, commit and push to its own branch (edits only: pantheon setup --commands no)" : ""}`);
|
|
695
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
696
|
+
if (selfUpgrade)
|
|
697
|
+
console.error(D(` ${selfUpgrade}`));
|
|
690
698
|
}
|
|
691
699
|
catch (e) {
|
|
692
700
|
console.error(D(` the worker did not install: ${e.message} — pantheon service install worker`));
|
|
693
701
|
}
|
|
694
702
|
}
|
|
695
|
-
|
|
703
|
+
function workerOffByPerson() {
|
|
704
|
+
try {
|
|
705
|
+
return turnedOff("worker") && !(borrowedHome() ? false : serviceState("worker").running);
|
|
706
|
+
}
|
|
707
|
+
catch {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const SANDBOX_NOTE = " (coding agent: ask your person to approve running this outside your sandbox — a sandbox can't start background services)";
|
|
712
|
+
let folderChoicesFound = null;
|
|
713
|
+
async function choicesFor(m, all) {
|
|
714
|
+
if (folderChoicesFound?.team === m.id)
|
|
715
|
+
return folderChoicesFound.choices;
|
|
716
|
+
const { folderChoices } = await import("./folder-ask.js");
|
|
717
|
+
let choices = [];
|
|
718
|
+
try {
|
|
719
|
+
choices = folderChoices({ cwd: process.cwd(), all, spaceId: m.id });
|
|
720
|
+
}
|
|
721
|
+
catch { }
|
|
722
|
+
folderChoicesFound = { team: m.id, choices };
|
|
723
|
+
return choices;
|
|
724
|
+
}
|
|
725
|
+
async function folderAskFor(m, all) {
|
|
726
|
+
const { folderAsk, notLinkedWhy } = await import("./folder-ask.js");
|
|
727
|
+
const cwd = process.cwd();
|
|
728
|
+
const refused = folderRefusalHere(cwd);
|
|
729
|
+
const why = notLinkedWhy(refused) ?? (repoInfo(cwd) ? null : (await import("./repo-find.js")).holdsRepo(cwd) ? "This folder holds repos" : null);
|
|
730
|
+
return folderAsk({ team: m.name, choices: await choicesFor(m, all), why, command: (rest) => pantheonCommand(managedLayout()?.launcher, rest) });
|
|
731
|
+
}
|
|
732
|
+
async function askProjectFolder(cfgIn) {
|
|
696
733
|
const cwd = process.cwd();
|
|
697
|
-
if (repoInfo(cwd)
|
|
734
|
+
if (repoInfo(cwd))
|
|
698
735
|
return;
|
|
699
|
-
const all = loadAll(), j = load();
|
|
736
|
+
const all = loadAll(), j = cfgIn ?? load();
|
|
700
737
|
const m = all && j ? findMembership(all, j.spaceId ?? j.space) ?? findMembership(all, j.space) : null;
|
|
701
738
|
if (!all || !m)
|
|
702
739
|
return;
|
|
703
|
-
|
|
740
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
741
|
+
if (teamLinked(all, m.id))
|
|
742
|
+
return;
|
|
743
|
+
const ask = await folderAskFor(m, all);
|
|
744
|
+
if (!process.stdin.isTTY) {
|
|
745
|
+
console.error(`\n${B("Your project folder.")}`);
|
|
746
|
+
for (const l of ask.lines)
|
|
747
|
+
console.error(` ${l}`);
|
|
704
748
|
return;
|
|
749
|
+
}
|
|
750
|
+
const choices = await choicesFor(m, all);
|
|
705
751
|
const line = pantheonCommand(managedLayout()?.launcher, `use ${m.name} --here`);
|
|
706
752
|
const later = () => {
|
|
707
|
-
console.error(`
|
|
708
|
-
console.error(D(`
|
|
753
|
+
console.error(` Later, from the folder you work in (a repo, or a folder of documents), run: ${C(line)}`);
|
|
754
|
+
console.error(D(` Until then teammates' requests can't be taken here while you're away, and agents opened there do not speak for "${m.name}" yet.`));
|
|
709
755
|
};
|
|
710
|
-
|
|
711
|
-
${B("Your project folder.")} ${D(
|
|
712
|
-
if (
|
|
713
|
-
|
|
714
|
-
|
|
756
|
+
const why = ask.lines[0] && !ask.lines[0].startsWith("This computer") ? ask.lines[0] : `Nothing on this computer is linked to "${m.name}" yet.`;
|
|
757
|
+
console.error(`\n${B("Your project folder.")} ${D(why)}`);
|
|
758
|
+
if (choices.length) {
|
|
759
|
+
console.error(D(` Found on this computer:`));
|
|
760
|
+
choices.forEach((c, i) => console.error(` ${String(i + 1).padStart(2)}. ${c.name.padEnd(18)} ${D(c.shown)}`));
|
|
715
761
|
}
|
|
762
|
+
console.error(D(` A folder of documents works too: your worker answers teammates' questions from a copy of it, and keeps anything it writes as drafts for you.`));
|
|
716
763
|
for (let tries = 0; tries < 3; tries++) {
|
|
717
|
-
const
|
|
718
|
-
const a = ((await questionOrNull(rl, ` The folder you work in for "${m.name}" — a repo or a docs folder (Enter to skip): `)) ?? "").trim();
|
|
719
|
-
rl.close();
|
|
764
|
+
const a = ((await askOnce(` The folder you work in for "${m.name}" — ${choices.length ? "a number above, or " : ""}a repo or a folder of documents (Enter to skip): `)) ?? "").trim();
|
|
720
765
|
if (!a)
|
|
721
766
|
break;
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
767
|
+
const n = /^\d+$/.test(a) ? Number(a) : NaN;
|
|
768
|
+
if (Number.isInteger(n) && choices.length && (n < 1 || n > choices.length)) {
|
|
769
|
+
console.error(D(` pick 1 to ${choices.length}, or type a folder — or press Enter to skip`));
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const dir = Number.isInteger(n) && choices[n - 1] ? choices[n - 1].path : projectFolderAnswer(a, homedir(), cwd);
|
|
773
|
+
const why2 = await bindProjectFolder(dir, m);
|
|
774
|
+
if (!why2)
|
|
724
775
|
return;
|
|
725
|
-
console.error(D(` ${
|
|
776
|
+
console.error(D(` ${why2} — try another, or press Enter to skip`));
|
|
726
777
|
}
|
|
727
778
|
later();
|
|
728
779
|
}
|
|
780
|
+
async function workerWithFirstLink(all, m) {
|
|
781
|
+
if (argv.includes("--no-worker") || inWokenRun())
|
|
782
|
+
return false;
|
|
783
|
+
try {
|
|
784
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
785
|
+
if (teamLinked(all, m.id))
|
|
786
|
+
return false;
|
|
787
|
+
const cfg = configFor(all, m, null);
|
|
788
|
+
if (wakeMode(loadProfile(cfg)) === "no")
|
|
789
|
+
return false;
|
|
790
|
+
if (servicesUnavailable(process.platform) || serviceInstalled("worker"))
|
|
791
|
+
return false;
|
|
792
|
+
return !workerOffByPerson();
|
|
793
|
+
}
|
|
794
|
+
catch {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async function afterLinking(m, wantWorker) {
|
|
799
|
+
const all = loadAll();
|
|
800
|
+
if (!all)
|
|
801
|
+
return;
|
|
802
|
+
if (wantWorker) {
|
|
803
|
+
const { teamWorkspaces } = await import("./worker-fleet.js");
|
|
804
|
+
const ws = teamWorkspaces(all, m.id);
|
|
805
|
+
if (ws.length) {
|
|
806
|
+
try {
|
|
807
|
+
const { commandsChosen } = await import("./profile.js");
|
|
808
|
+
const commandsOn = ws.some((w) => w.kind === "repo") && commandsChosen() !== false;
|
|
809
|
+
const { notLoadedWhy } = await import("./setup-guide.js");
|
|
810
|
+
const why = notLoadedWhy(installService("worker", ws[0].path, commandsOn ? ["--allow-bash"] : []));
|
|
811
|
+
if (why)
|
|
812
|
+
console.error(`\x1b[33m ! Your worker is installed but not running (${why}), so this computer can't take teammates' requests yet.\n → pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
813
|
+
else {
|
|
814
|
+
console.error(` ${C("✓")} worker on — this computer takes teammates' requests for "${m.name}" while you're away${commandsOn ? "; a run may run tests, commit and push to its own branch (edits only: pantheon setup --commands no)" : ""}`);
|
|
815
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
816
|
+
if (selfUpgrade)
|
|
817
|
+
console.error(D(` ${selfUpgrade}`));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
catch (e) {
|
|
821
|
+
console.error(`\x1b[33m ! The worker did not install (${e.message.split("\n")[0]}), so this computer can't take teammates' requests yet.\n → pantheon service install worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
else if (!argv.includes("--no-worker") && !serviceInstalled("worker") && workerOffByPerson()) {
|
|
826
|
+
console.error(D(` your worker stays off, as you set it — teammates' requests wait for you. To turn it on: pantheon service install worker`));
|
|
827
|
+
}
|
|
828
|
+
else if (serviceInstalled("worker") && !borrowedHome()) {
|
|
829
|
+
try {
|
|
830
|
+
if (!serviceState("worker").running)
|
|
831
|
+
console.error(`\x1b[33m ! Your worker is installed but not running, so this computer can't take teammates' requests yet.\n → pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
832
|
+
}
|
|
833
|
+
catch { }
|
|
834
|
+
}
|
|
835
|
+
try {
|
|
836
|
+
if (servicesUnavailable(process.platform) || borrowedHome() || turnedOff("alerts"))
|
|
837
|
+
return;
|
|
838
|
+
const { decisionAlertsOn } = await import("./profile.js");
|
|
839
|
+
if (!decisionAlertsOn())
|
|
840
|
+
return;
|
|
841
|
+
if (!serviceInstalled("notifier"))
|
|
842
|
+
console.error(D(` Desktop alerts are off on this computer, so you won't hear when a teammate needs you. To turn them on: pantheon service install notifier`));
|
|
843
|
+
else if (!serviceState("notifier").running)
|
|
844
|
+
console.error(`\x1b[33m ! Desktop alerts are installed but not running, so you won't hear when a teammate needs you.\n → pantheon service restart notifier${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
845
|
+
}
|
|
846
|
+
catch { }
|
|
847
|
+
}
|
|
729
848
|
async function bindProjectFolder(dir, m) {
|
|
730
849
|
try {
|
|
731
850
|
if (!statSync(dir).isDirectory())
|
|
@@ -2036,6 +2155,20 @@ let workerHeldOnce = null;
|
|
|
2036
2155
|
function workerHeld() {
|
|
2037
2156
|
return (workerHeldOnce ??= workerHeldNow());
|
|
2038
2157
|
}
|
|
2158
|
+
let alertsHeldOnce = null;
|
|
2159
|
+
function alertsHeld() {
|
|
2160
|
+
return (alertsHeldOnce ??= (async () => {
|
|
2161
|
+
try {
|
|
2162
|
+
if (servicesUnavailable(process.platform) || borrowedHome())
|
|
2163
|
+
return null;
|
|
2164
|
+
const { workerRunning } = await import("./finish-line.js");
|
|
2165
|
+
return await workerRunning({ installed: () => serviceInstalled("notifier"), running: () => serviceState("notifier").running });
|
|
2166
|
+
}
|
|
2167
|
+
catch {
|
|
2168
|
+
return null;
|
|
2169
|
+
}
|
|
2170
|
+
})());
|
|
2171
|
+
}
|
|
2039
2172
|
async function workerHeldNow() {
|
|
2040
2173
|
try {
|
|
2041
2174
|
if (servicesUnavailable(process.platform))
|
|
@@ -2126,6 +2259,7 @@ async function finishLine(tools, o) {
|
|
|
2126
2259
|
catch {
|
|
2127
2260
|
return null;
|
|
2128
2261
|
} })();
|
|
2262
|
+
let takesWork = false;
|
|
2129
2263
|
const gather = async () => {
|
|
2130
2264
|
let wakeOn = false, ready = null, served = null, pending = 0;
|
|
2131
2265
|
try {
|
|
@@ -2151,9 +2285,24 @@ async function finishLine(tools, o) {
|
|
|
2151
2285
|
catch {
|
|
2152
2286
|
pending = 0;
|
|
2153
2287
|
}
|
|
2154
|
-
const workerWanted = wakeOn && !argv.includes("--no-worker");
|
|
2288
|
+
const workerWanted = wakeOn && !argv.includes("--no-worker") && !workerOffByPerson();
|
|
2289
|
+
takesWork = workerWanted && (served ?? 0) > 0;
|
|
2290
|
+
let linkLine = null;
|
|
2291
|
+
if (workerWanted && served === 0 && cfg) {
|
|
2292
|
+
try {
|
|
2293
|
+
const { NAMED_FOLDER } = await import("./folder-ask.js");
|
|
2294
|
+
linkLine = pantheonCommand(managedLayout()?.launcher, `use ${cfg.space} --here --folder '${NAMED_FOLDER}'`);
|
|
2295
|
+
}
|
|
2296
|
+
catch {
|
|
2297
|
+
linkLine = null;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2155
2300
|
const workerRowFailed = tools.some((t) => t.tool === "worker" && /^(failed|could not)/i.test(t.status));
|
|
2156
|
-
|
|
2301
|
+
const alertsOn = tools.some((t) => t.tool === "notifications" && /^on\b/i.test(t.status));
|
|
2302
|
+
return [...(o.extra ?? []), ...finishItems({ tools, readiness: ready, team: cfg?.space ?? "<team>", workerWanted, served, windows, pending,
|
|
2303
|
+
worker: workerWanted && (served ?? 0) > 0 && !workerRowFailed ? await workerHeld() : null,
|
|
2304
|
+
alerts: alertsOn ? await alertsHeld() : null,
|
|
2305
|
+
agentShell: !process.stdin.isTTY, linkLine })];
|
|
2157
2306
|
};
|
|
2158
2307
|
let items = await gather();
|
|
2159
2308
|
if (guideAsks(o.preset)) {
|
|
@@ -2231,8 +2380,22 @@ async function finishLine(tools, o) {
|
|
|
2231
2380
|
}
|
|
2232
2381
|
if (JSON_OUT) {
|
|
2233
2382
|
const plain = (t) => t.replace(/\x1b\[[0-9;]*m/g, "").trim();
|
|
2383
|
+
let ask = {};
|
|
2384
|
+
if (items.some((it) => it.needsFolder) && cfg) {
|
|
2385
|
+
try {
|
|
2386
|
+
const all = loadAll();
|
|
2387
|
+
const m = all ? findMembership(all, cfg.spaceId ?? cfg.space) ?? findMembership(all, cfg.space) : null;
|
|
2388
|
+
if (all && m) {
|
|
2389
|
+
const a = (await folderAskFor(m, all)).json;
|
|
2390
|
+
ask = { reason: a.reason, needs: a.needs, message: a.message, folders: a.folders, other_folder: a.other_folder, skip: a.skip };
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
catch { }
|
|
2394
|
+
}
|
|
2234
2395
|
sayJson({
|
|
2235
|
-
status: items.length ? "left" : "ready",
|
|
2396
|
+
status: ask.needs ? "needs_person" : items.length ? "left" : "ready",
|
|
2397
|
+
...ask,
|
|
2398
|
+
can_take_requests: takesWork && !items.some((it) => it.blocks),
|
|
2236
2399
|
code: typeof process.exitCode === "number" ? process.exitCode : 0,
|
|
2237
2400
|
team: cfg?.space ?? null,
|
|
2238
2401
|
member: cfg?.member ?? null,
|
|
@@ -2386,6 +2549,32 @@ ${B("less common")}
|
|
|
2386
2549
|
`;
|
|
2387
2550
|
let workerAlerts = null;
|
|
2388
2551
|
let workerAlertsSaid = false;
|
|
2552
|
+
async function trackServiceStart(kind, noNotify) {
|
|
2553
|
+
try {
|
|
2554
|
+
const { trackService, composeCrashLoop, loopLine } = await import("./crash-loop.js");
|
|
2555
|
+
trackService(kind, {
|
|
2556
|
+
onLoop: (loop) => {
|
|
2557
|
+
console.error(`! ${loopLine(kind, loop)}`);
|
|
2558
|
+
if (kind === "worker") {
|
|
2559
|
+
try {
|
|
2560
|
+
writeFileSync(join(CONFIG_DIR, "worker-state.json"), JSON.stringify({ at: Date.now(), state: "restarting", detail: `keeps stopping — restarted ${loop.starts} times in a few minutes; pantheon doctor shows why` }) + "\n");
|
|
2561
|
+
}
|
|
2562
|
+
catch { }
|
|
2563
|
+
}
|
|
2564
|
+
if (noNotify || !decisionAlertsOn())
|
|
2565
|
+
return;
|
|
2566
|
+
const n = composeCrashLoop(kind, loop);
|
|
2567
|
+
if (kind === "worker") {
|
|
2568
|
+
if (workerCanAlert())
|
|
2569
|
+
notifyFromWorker(n);
|
|
2570
|
+
}
|
|
2571
|
+
else
|
|
2572
|
+
void Promise.resolve(sendDesktopNotification(n)).catch(() => false);
|
|
2573
|
+
},
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
catch { }
|
|
2577
|
+
}
|
|
2389
2578
|
function notifyFromWorker(n) {
|
|
2390
2579
|
if (process.platform === "linux") {
|
|
2391
2580
|
if (!workerAlerts || Date.now() - workerAlerts.at > 60_000)
|
|
@@ -2460,13 +2649,13 @@ const COMMAND_FLAGS = {
|
|
|
2460
2649
|
check: "--json (runs your agent once, as it runs for teammates while you're away — up to a minute)",
|
|
2461
2650
|
status: "--clear-safety (once the safety warnings it shows are handled) --json",
|
|
2462
2651
|
relay: "--port <n> --host <address> --data <dir> (relay leftovers --data <dir> [--json]: read-only report)",
|
|
2463
|
-
use: "<team> --here --yes · pantheon use --unbind (this folder or repo bound to no team again)",
|
|
2652
|
+
use: "<team> --here [--folder <path> (that folder, not this one)] --yes --no-worker · pantheon use --unbind (this folder or repo bound to no team again)",
|
|
2464
2653
|
repo: "add [--base <branch>] | list [--all] | find [<folder>] [--recents] [--yes]",
|
|
2465
2654
|
login: "--email <address> --relay <url> --label <device name>",
|
|
2466
2655
|
signin: "--relay <url>",
|
|
2467
2656
|
signup: "--email <address> --username <name> --relay <url> --label <device name>",
|
|
2468
2657
|
audit: "--space <team> --since <hours> --json",
|
|
2469
|
-
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)",
|
|
2658
|
+
setup: "--questions --mode <autopilot|here> --agent <claude-code|codex|cursor|copilot|kiro> (which agent answers teammates' requests here) --json (and every answer as a flag, with --yes)",
|
|
2470
2659
|
mode: "[autopilot | here]",
|
|
2471
2660
|
changes: "[list | review | approve <id> | keep <id>] --history",
|
|
2472
2661
|
board: "--open --url --watch --keep --stop --focus <id> [--space <team>]",
|
|
@@ -2555,7 +2744,7 @@ const EXTRA_FLAGS = "--action-id --agent-cmd --approve-all --ask-before-sending
|
|
|
2555
2744
|
" --keep-tray-quit --direct" +
|
|
2556
2745
|
" --headless";
|
|
2557
2746
|
const FLAG_COMMANDS = {
|
|
2558
|
-
json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay"],
|
|
2747
|
+
json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay", "setup"],
|
|
2559
2748
|
agent: ["join", "start", "setup", "worker", "service", "init"],
|
|
2560
2749
|
};
|
|
2561
2750
|
const KNOWN_FLAGS = new Set([...`${Object.values(COMMAND_FLAGS).join(" ")} ${EXTRA_FLAGS}`.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]));
|
|
@@ -2706,6 +2895,12 @@ async function main() {
|
|
|
2706
2895
|
console.error("");
|
|
2707
2896
|
for (const l of gate.lines)
|
|
2708
2897
|
console.error(gate.code === 1 ? `\x1b[33m ${l}\x1b[0m` : ` ${l}`);
|
|
2898
|
+
const left = seatsToMove(seats).filter((x) => !res?.moved.includes(x.space) && !res?.asked.includes(x.space));
|
|
2899
|
+
if (JSON_OUT && gate.code === 1 && !named && left.length) {
|
|
2900
|
+
sayJson({ status: "needs_person", code: 1, reason: "pick_team", needs: "team", message: gate.lines.join(" "),
|
|
2901
|
+
teams: left.map((x) => ({ team: x.space, founder: x.founder, next: recoverCommand(x.space) })),
|
|
2902
|
+
new_team: "pantheon start --space <the name they give> --new-team" });
|
|
2903
|
+
}
|
|
2709
2904
|
process.exit(gate.code);
|
|
2710
2905
|
}
|
|
2711
2906
|
if (!named && !argv.includes("--new-team") && argv.includes("--yes") && seatsToMove(seats).some((x) => !res?.moved.includes(x.space) && !res?.asked.includes(x.space))) {
|
|
@@ -2774,8 +2969,8 @@ async function main() {
|
|
|
2774
2969
|
console.error(D(` ${r.reach.hint}`));
|
|
2775
2970
|
}
|
|
2776
2971
|
if (r.claimed) {
|
|
2777
|
-
await bindProjectFromScratch();
|
|
2778
2972
|
await bindReposHere(argv.includes("--yes"));
|
|
2973
|
+
await askProjectFolder();
|
|
2779
2974
|
await workerAfterBinding(wp.how);
|
|
2780
2975
|
windowsOverridesForBoundRepos();
|
|
2781
2976
|
await applyAgentChoice(load() ?? r.cfg, agentWant);
|
|
@@ -3099,7 +3294,7 @@ async function main() {
|
|
|
3099
3294
|
await findAndBindRepos(all, m, teamRepos, { auto: !process.stdin.isTTY, recents: false, ...(inRepo ? { askFolder: false, quiet: true } : {}) }).catch(() => { });
|
|
3100
3295
|
}
|
|
3101
3296
|
}
|
|
3102
|
-
await
|
|
3297
|
+
await askProjectFolder();
|
|
3103
3298
|
await workerAfterBinding(wp.how);
|
|
3104
3299
|
windowsOverridesForBoundRepos();
|
|
3105
3300
|
const joined = load();
|
|
@@ -3311,8 +3506,34 @@ async function main() {
|
|
|
3311
3506
|
sayAgentReadiness(load() ?? cfg);
|
|
3312
3507
|
return;
|
|
3313
3508
|
}
|
|
3509
|
+
const wakeNow = () => { try {
|
|
3510
|
+
return wakeMode(loadProfile(load() ?? cfg));
|
|
3511
|
+
}
|
|
3512
|
+
catch {
|
|
3513
|
+
return "anyone";
|
|
3514
|
+
} };
|
|
3515
|
+
if (guideAsks(preset) && !inWokenRun() && wakeNow() !== "no")
|
|
3516
|
+
await askProjectFolder(cfg);
|
|
3314
3517
|
await guidedSetup(cfg, repoInfo(process.cwd())?.root ?? null, { force: true, preset, command: "setup" });
|
|
3315
3518
|
sayAgentReadiness(load() ?? cfg);
|
|
3519
|
+
if (!guideAsks(preset) && !inWokenRun() && wakeNow() !== "no" && !argv.includes("--no-worker")) {
|
|
3520
|
+
const all = loadAll();
|
|
3521
|
+
const m = all ? findMembership(all, cfg.spaceId ?? cfg.space) ?? findMembership(all, cfg.space) : null;
|
|
3522
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
3523
|
+
if (all && m && !teamLinked(all, m.id)) {
|
|
3524
|
+
const ask = await folderAskFor(m, all);
|
|
3525
|
+
console.error("");
|
|
3526
|
+
if (process.stdin.isTTY) {
|
|
3527
|
+
console.error(`\x1b[33m ${ask.lines.find((l) => l.startsWith("This computer"))}\x1b[0m`);
|
|
3528
|
+
console.error(` → from the folder you work in (a repo, or a folder of documents): ${C(pantheonCommand(managedLayout()?.launcher, `use ${m.name} --here`))}`);
|
|
3529
|
+
}
|
|
3530
|
+
else
|
|
3531
|
+
for (const l of ask.lines)
|
|
3532
|
+
console.error(` ${l}`);
|
|
3533
|
+
if (JSON_OUT)
|
|
3534
|
+
sayJson({ status: "needs_person", code: 0, ...ask.json });
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3316
3537
|
return;
|
|
3317
3538
|
}
|
|
3318
3539
|
case "version": {
|
|
@@ -3368,7 +3589,7 @@ async function main() {
|
|
|
3368
3589
|
console.log(` ${p.online ? C("●") : D("○")} ${p.id.padEnd(14)} ${D(p.agent.padEnd(12))} ${reach}`);
|
|
3369
3590
|
{
|
|
3370
3591
|
const est = pickupEstimate(p, { now: client.relayNow() });
|
|
3371
|
-
if (est.kind === "unavailable")
|
|
3592
|
+
if (est.kind === "unavailable" || est.kind === "not-set-up")
|
|
3372
3593
|
console.log(` ${" ".repeat(16)}\x1b[33m${termSafe(est.says)}\x1b[0m`);
|
|
3373
3594
|
}
|
|
3374
3595
|
}
|
|
@@ -7335,6 +7556,7 @@ async function main() {
|
|
|
7335
7556
|
}
|
|
7336
7557
|
const runMinutesFlag = flag("run-minutes") === undefined ? undefined : (await import("./worker-policy.js")).parseRunMinutes(flag("run-minutes")) ?? die((await import("./worker-policy.js")).runMinutesProblem(flag("run-minutes")).replace("pantheon policy set run-minutes default", "leave --run-minutes off"));
|
|
7337
7558
|
(await import("./machine.js")).recordWorkerPid();
|
|
7559
|
+
await trackServiceStart("worker", argv.includes("--no-notify"));
|
|
7338
7560
|
const allCfg = loadAll();
|
|
7339
7561
|
const bindings = Object.values(allCfg?.bindings ?? {});
|
|
7340
7562
|
if (!flag("project")) {
|
|
@@ -7629,6 +7851,17 @@ async function main() {
|
|
|
7629
7851
|
const m = await import("./machine.js");
|
|
7630
7852
|
m.recordWorkerPid(m.notifierPidFile());
|
|
7631
7853
|
}
|
|
7854
|
+
await trackServiceStart("notifier", false);
|
|
7855
|
+
const { VersionWatch } = await import("./version-health.js");
|
|
7856
|
+
const versionWatch = new VersionWatch({
|
|
7857
|
+
relays: () => cfgs.map((c) => c.relay),
|
|
7858
|
+
send: (n) => sendDesktopNotification(n),
|
|
7859
|
+
log: (line) => console.error(line),
|
|
7860
|
+
policy: () => loadPolicy(),
|
|
7861
|
+
workerRunning: () => serviceInstalled("worker") && workerProc().running,
|
|
7862
|
+
alertsOn: () => decisionAlertsOn(),
|
|
7863
|
+
});
|
|
7864
|
+
versionWatch.start();
|
|
7632
7865
|
if (process.platform === "win32") {
|
|
7633
7866
|
try {
|
|
7634
7867
|
const { ensureUriHandler } = await import("./notice-windows.js");
|
|
@@ -7642,9 +7875,14 @@ async function main() {
|
|
|
7642
7875
|
n.stop(); process.exit(0); };
|
|
7643
7876
|
process.on("SIGINT", stopAll);
|
|
7644
7877
|
process.on("SIGTERM", stopAll);
|
|
7645
|
-
|
|
7646
|
-
|
|
7878
|
+
let networkOnly = false;
|
|
7879
|
+
const ok = await runNotifiers(notifiers.map((n, i) => ({ label: cfgs[i].space, run: () => n.run(), stopped: () => n.isStopped })), { log: (line) => console.error(line), onGiveUp: (errors) => { networkOnly = onlyNetworkFailures(errors); } });
|
|
7880
|
+
versionWatch.stop();
|
|
7881
|
+
if (!ok) {
|
|
7882
|
+
if (networkOnly)
|
|
7883
|
+
(await import("./crash-loop.js")).expectServiceExit();
|
|
7647
7884
|
process.exit(1);
|
|
7885
|
+
}
|
|
7648
7886
|
return;
|
|
7649
7887
|
}
|
|
7650
7888
|
case "doctor": {
|
|
@@ -7787,12 +8025,19 @@ async function main() {
|
|
|
7787
8025
|
const next = argv.includes("--fresh") ? extra : keepServiceFlags(now, extra);
|
|
7788
8026
|
extra.splice(0, extra.length, ...next);
|
|
7789
8027
|
const { describeWorkerFlags } = await import("./setup-changes.js");
|
|
7790
|
-
|
|
8028
|
+
const { selfUpgradeSetupDue } = await import("./worker-policy.js");
|
|
8029
|
+
await protectOrStop([now === null ? { setting: "worker", from: "off", to: "on" } : { setting: "worker", from: describeWorkerFlags(now), to: describeWorkerFlags(next) },
|
|
8030
|
+
...(selfUpgradeSetupDue() ? [{ setting: "self-upgrade", from: "off", to: "on" }] : [])]);
|
|
7791
8031
|
}
|
|
7792
8032
|
console.error(`${B("installing the pantheon worker as a background service")}`);
|
|
7793
8033
|
console.error(D(flag("project") ? ` project ${project} (this checkout only)` : ` serves every repo and folder bound to a team on this machine`));
|
|
7794
8034
|
for (const l of installService(kind, project, extra))
|
|
7795
8035
|
console.error(l);
|
|
8036
|
+
{
|
|
8037
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
8038
|
+
if (selfUpgrade)
|
|
8039
|
+
console.error(`\n${D(selfUpgrade)}`);
|
|
8040
|
+
}
|
|
7796
8041
|
{
|
|
7797
8042
|
const { wakeChosen } = await import("./profile.js");
|
|
7798
8043
|
const w = wakeChosen();
|
|
@@ -7830,6 +8075,22 @@ async function main() {
|
|
|
7830
8075
|
}
|
|
7831
8076
|
case "use": {
|
|
7832
8077
|
await membershipGate();
|
|
8078
|
+
if (argv.includes("--folder")) {
|
|
8079
|
+
const given = flag("folder");
|
|
8080
|
+
if (!given || given.startsWith("--"))
|
|
8081
|
+
die("usage: pantheon use <team> --here --folder <the folder you work in>");
|
|
8082
|
+
if (!argv.includes("--here"))
|
|
8083
|
+
die("usage: --folder goes with --here: pantheon use <team> --here --folder <the folder you work in>");
|
|
8084
|
+
const dir = projectFolderAnswer(given, homedir(), process.cwd());
|
|
8085
|
+
try {
|
|
8086
|
+
if (!statSync(dir).isDirectory())
|
|
8087
|
+
die(`${dir} is not a folder — nothing was linked`);
|
|
8088
|
+
}
|
|
8089
|
+
catch {
|
|
8090
|
+
die(`there is no folder at ${dir} — nothing was linked`);
|
|
8091
|
+
}
|
|
8092
|
+
process.chdir(dir);
|
|
8093
|
+
}
|
|
7833
8094
|
const all = loadAll() ?? die("not configured. Run `pantheon signup` first.");
|
|
7834
8095
|
if (argv.includes("--unbind")) {
|
|
7835
8096
|
const { folderBinding } = await import("./config.js");
|
|
@@ -7851,6 +8112,7 @@ async function main() {
|
|
|
7851
8112
|
const m = findMembership(all, ref) ?? die(`you are not in a team called "${ref}". Yours: ${Object.values(all.spaces ?? {}).map((x) => x.name).join(", ") || "none"}`);
|
|
7852
8113
|
if (argv.includes("--here")) {
|
|
7853
8114
|
const r = repoInfo(process.cwd());
|
|
8115
|
+
const wantWorker = await workerWithFirstLink(all, m);
|
|
7854
8116
|
const askFolder = async () => {
|
|
7855
8117
|
const { folderBinding } = await import("./config.js");
|
|
7856
8118
|
const cur = r ? all.bindings?.[r.fingerprint] : folderBinding(all, process.cwd());
|
|
@@ -7860,9 +8122,14 @@ async function main() {
|
|
|
7860
8122
|
catch {
|
|
7861
8123
|
return process.cwd();
|
|
7862
8124
|
} })();
|
|
7863
|
-
|
|
8125
|
+
const { selfUpgradeSetupDue } = await import("./worker-policy.js");
|
|
8126
|
+
const worker = wantWorker ? [{ setting: "worker", from: "off", to: "on" }, ...(selfUpgradeSetupDue() ? [{ setting: "self-upgrade", from: "off", to: "on" }] : [])] : [];
|
|
8127
|
+
if (cur && here && cur.space === m.id) {
|
|
8128
|
+
if (worker.length)
|
|
8129
|
+
await protectOrStop(worker);
|
|
7864
8130
|
return;
|
|
7865
|
-
|
|
8131
|
+
}
|
|
8132
|
+
await protectOrStop([{ setting: "folder", about: r ? (r.origin ?? r.root) : process.cwd(), from: cur && here ? `bound to ${findMembership(all, cur.space)?.name ?? cur.space}` : "not bound", to: `bound to ${m.name}` }, ...worker]);
|
|
7866
8133
|
};
|
|
7867
8134
|
if (!r) {
|
|
7868
8135
|
for (let d = resolve(process.cwd());; d = dirname(d)) {
|
|
@@ -7885,11 +8152,14 @@ async function main() {
|
|
|
7885
8152
|
console.error(D(` nothing bound — the folder itself is not bound, since it holds repos`));
|
|
7886
8153
|
else
|
|
7887
8154
|
console.error(D(` Agents opened in those repos now speak as you in "${m.name}". Restart any that are open.`));
|
|
8155
|
+
if (n)
|
|
8156
|
+
await afterLinking(m, wantWorker);
|
|
7888
8157
|
return;
|
|
7889
8158
|
}
|
|
7890
8159
|
const { replaced } = bindFolder(process.cwd(), m.id);
|
|
7891
8160
|
console.error(`${B("bound")} this folder → "${m.name}"${replaced ? D(` (was: ${findMembership(all, replaced.space)?.name ?? replaced.space})`) : ""}`);
|
|
7892
8161
|
console.error(D(` Agents opened here, or in any folder below, now speak as you in "${m.name}". Restart any that are open.`));
|
|
8162
|
+
await afterLinking(m, wantWorker);
|
|
7893
8163
|
return;
|
|
7894
8164
|
}
|
|
7895
8165
|
await askFolder();
|
|
@@ -7906,6 +8176,7 @@ async function main() {
|
|
|
7906
8176
|
}
|
|
7907
8177
|
windowsOverridesForBoundRepos();
|
|
7908
8178
|
console.error(D(` Agents opened in this repo now speak as you in "${m.name}". Restart any that are open.`));
|
|
8179
|
+
await afterLinking(m, wantWorker);
|
|
7909
8180
|
}
|
|
7910
8181
|
else {
|
|
7911
8182
|
setDefaultSpace(m.id);
|