@nanocollective/roster 0.1.0-beta.32 → 0.1.0-beta.34

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.
@@ -61,10 +61,10 @@ const STEP_COMMANDS = {
61
61
  "run once": (h) => `run ${h} --apply`,
62
62
  };
63
63
  /**
64
- * The steps that are writing, not wiring: a hosted portal can do these itself (the org's two
65
- * files on Org, the charter on Staff), so it offers that rather than a command.
64
+ * The steps a hosted portal can do itself, so it offers that rather than a command: the org's
65
+ * two files on Org, the charter on Staff, and a first run, which is a workflow dispatch.
66
66
  */
67
- export const IN_PORTAL = new Set(["business", "priorities", "write the charter"]);
67
+ export const IN_PORTAL = new Set(["business", "priorities", "write the charter", "run once"]);
68
68
 
69
69
  export function stepCommand(what, handle) {
70
70
  return STEP_COMMANDS[what]?.(handle) ?? "";
@@ -12,6 +12,7 @@ import { daysUntil, isFor, sortHome } from "../homesort.js";
12
12
  import { mdlite } from "../md.js";
13
13
  import { checkAll, notReady, ORG_STEPS, stepCommand } from "../readiness.js";
14
14
  import { commandLine } from "./notready.js";
15
+ import { runOnce } from "./runonce.js";
15
16
  import { parseReport } from "../report.js";
16
17
  import { icon, iconHTML, staffIcon } from "../icons.js";
17
18
  import { ensureInbox, stampCounts } from "../refresh.js";
@@ -637,11 +638,13 @@ function setupLeft(staff) {
637
638
  go({ view: "staff" });
638
639
  }
639
640
  : null;
640
- steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle), here]);
641
+ // A first run is a button anywhere: the same one Health has, right in the list.
642
+ const inline = what === "run once" ? s : null;
643
+ steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle), here, inline]);
641
644
  }
642
645
  }
643
646
  if (!steps.length) return null;
644
- const wiring = steps.filter(([, , here]) => !here).length;
647
+ const wiring = steps.filter(([, , here, inline]) => !here && !inline).length;
645
648
 
646
649
  const box = el("div", { className: "card homesetup" });
647
650
  box.append(el("b", { textContent: "Setup is not finished" }));
@@ -659,11 +662,16 @@ function setupLeft(staff) {
659
662
  el("p", { className: "sub homesetupor", textContent: "Or one at a time, in order:" }),
660
663
  );
661
664
  } else {
662
- box.append(el("p", { className: "sub", textContent: "Nobody runs until these are done." }));
665
+ box.append(
666
+ el("p", {
667
+ className: "sub",
668
+ textContent: S.hosted ? "Nobody runs until these are done, and each can be done here." : "Nobody runs until these are done.",
669
+ }),
670
+ );
663
671
  }
664
672
  const seen = new Set();
665
673
  const list = el("ol", { className: "homesetupsteps" });
666
- for (const [what, cmd, here] of steps) {
674
+ for (const [what, cmd, here, inline] of steps) {
667
675
  // The credential is the org's, so two staff members missing it is one step.
668
676
  if (cmd && seen.has(cmd)) continue;
669
677
  seen.add(cmd);
@@ -674,6 +682,8 @@ function setupLeft(staff) {
674
682
  const write = el("button", { className: "ghbtn sm", textContent: "Write it here" });
675
683
  write.onclick = here;
676
684
  label.append(" ", write);
685
+ } else if (S.hosted && inline) {
686
+ row.append(runOnce({ staff: inline.handle, name: inline.name, onDone: (ok) => ok && render() }));
677
687
  } else if (S.hosted && cmd) row.append(commandLine(cmd));
678
688
  list.append(row);
679
689
  }
@@ -14,6 +14,7 @@ import { refreshAll } from "../refresh.js";
14
14
  import { S } from "../state.js";
15
15
  import { charterModes, hireFlow, line, rolePicker } from "./hire.js";
16
16
  import { commandLine } from "./notready.js";
17
+ import { runOnce } from "./runonce.js";
17
18
 
18
19
  /**
19
20
  * Resolves once nothing is loading and `node` has stopped changing for a moment, or after a few
@@ -223,6 +224,10 @@ export function viewStaff(m, o = {}) {
223
224
  warn.append(el("div", { className: "row" }, [write]));
224
225
  }
225
226
  warn.append(...cmds.map(commandLine));
227
+ // Once a run is all that is left, it is a button here like everywhere else.
228
+ if (left.length === 1 && left[0] === "run once") {
229
+ warn.append(runOnce({ staff: s.handle, name: s.name, onDone: (ok) => ok && refreshAll() }));
230
+ }
226
231
  }
227
232
  });
228
233
  d.append(warn);
@@ -820,7 +820,7 @@ __export(compose_exports, {
820
820
  handlesList: () => handlesList,
821
821
  humanSentence: () => humanSentence,
822
822
  parseYaml: () => parseYaml,
823
- readHumans: () => readHumans2,
823
+ readHumans: () => readHumans,
824
824
  render: () => render
825
825
  });
826
826
  import * as nodeFs from "fs";
@@ -1008,7 +1008,7 @@ function lookup2(ctx, path) {
1008
1008
  function truthy(v) {
1009
1009
  return !(v === void 0 || v === null || v === false || v === "" || Array.isArray(v) && v.length === 0);
1010
1010
  }
1011
- function readHumans2(org) {
1011
+ function readHumans(org) {
1012
1012
  const listed = Array.isArray(org?.humans) ? org.humans : org?.humans ? [org.humans] : [];
1013
1013
  const out = [];
1014
1014
  for (const entry of [...listed, org?.human].filter(Boolean)) {
@@ -1019,15 +1019,15 @@ function readHumans2(org) {
1019
1019
  out.push({
1020
1020
  github,
1021
1021
  name: name || github,
1022
- marker: String(entry.marker ?? "").trim() || defaultMarker2(name || github),
1022
+ marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
1023
1023
  role: entry.role ?? void 0,
1024
- ...handlesOf2(entry.handles).length ? { handles: handlesOf2(entry.handles) } : {},
1024
+ ...handlesOf(entry.handles).length ? { handles: handlesOf(entry.handles) } : {},
1025
1025
  ...entry.view_only === true ? { viewOnly: true } : {}
1026
1026
  });
1027
1027
  }
1028
1028
  return out;
1029
1029
  }
1030
- function handlesOf2(v) {
1030
+ function handlesOf(v) {
1031
1031
  const list2 = Array.isArray(v) ? v : v ? String(v).split(",") : [];
1032
1032
  return list2.map((x) => String(x ?? "").trim()).filter(Boolean);
1033
1033
  }
@@ -1043,7 +1043,7 @@ function humanSentence(humans) {
1043
1043
  if (parts.length < 2) return parts[0] ?? "";
1044
1044
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
1045
1045
  }
1046
- function defaultMarker2(name) {
1046
+ function defaultMarker(name) {
1047
1047
  return String(name).trim().split(/[\s-]+/)[0].toLowerCase().replace(/[^a-z0-9]/g, "") || "human";
1048
1048
  }
1049
1049
  function compose({
@@ -1101,7 +1101,7 @@ function compose({
1101
1101
  }
1102
1102
  const inflightFile = join3(runDir ?? join3(brainsDir, ".roster-run"), "inflight.md");
1103
1103
  const inflight = existsSync5(inflightFile) ? readFileSync6(inflightFile, "utf8").trim() : "";
1104
- const everyone = readHumans2(org);
1104
+ const everyone = readHumans(org);
1105
1105
  const humans = everyone.filter((h) => !h.viewOnly);
1106
1106
  const ctx = {
1107
1107
  org,
@@ -1301,123 +1301,6 @@ function splitRepo(repo) {
1301
1301
  return { owner, name };
1302
1302
  }
1303
1303
 
1304
- // src/lib/humans.ts
1305
- function readHumans(org) {
1306
- const listed = Array.isArray(org?.humans) ? org.humans : org?.humans ? [org.humans] : [];
1307
- const raw = [...listed, org?.human].filter(Boolean);
1308
- const out = [];
1309
- for (const entry of raw) {
1310
- const github = String(entry.github ?? entry.login ?? "").trim();
1311
- const name = String(entry.name ?? github).trim();
1312
- if (!github && !name) continue;
1313
- if (github && out.some((h) => h.github.toLowerCase() === github.toLowerCase())) continue;
1314
- out.push({
1315
- github,
1316
- name: name || github,
1317
- marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
1318
- role: entry.role === void 0 || entry.role === null ? void 0 : String(entry.role),
1319
- ...handlesOf(entry.handles).length ? { handles: handlesOf(entry.handles) } : {},
1320
- ...entry.view_only === true ? { viewOnly: true } : {}
1321
- });
1322
- }
1323
- return out;
1324
- }
1325
- function handlesOf(v) {
1326
- const list2 = Array.isArray(v) ? v : v ? String(v).split(",") : [];
1327
- return list2.map((x) => String(x ?? "").trim()).filter(Boolean);
1328
- }
1329
- function staffHumans(org) {
1330
- return readHumans(org).filter((h) => !h.viewOnly);
1331
- }
1332
- function isViewOnly(org, login) {
1333
- const l = login.toLowerCase();
1334
- return readHumans(org).some((h) => h.viewOnly && h.github.toLowerCase() === l);
1335
- }
1336
- function defaultMarker(name) {
1337
- return String(name).trim().split(/[\s-]+/)[0].toLowerCase().replace(/[^a-z0-9]/g, "") || "human";
1338
- }
1339
- var clean = (v) => String(v ?? "").replace(/[,{}[\]#"'\n\r]/g, " ").replace(/\s+/g, " ").trim();
1340
- var LOGIN_RE = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;
1341
- function tidyPeople(input) {
1342
- const people = [];
1343
- for (const p of input) {
1344
- const github = clean(p.github).replace(/^@/, "");
1345
- const name = clean(p.name) || github;
1346
- if (!github && !name) continue;
1347
- if (!LOGIN_RE.test(github))
1348
- return { people, error: `"${github || name}" is not a GitHub login` };
1349
- if (people.some((h) => h.github.toLowerCase() === github.toLowerCase())) {
1350
- return { people, error: `@${github} is in the list twice` };
1351
- }
1352
- const marker = (clean(p.marker) || defaultMarker(name || github)).toLowerCase().replace(/[^a-z0-9-]/g, "");
1353
- if (people.some((h) => h.marker === marker)) {
1354
- return {
1355
- people,
1356
- error: `two people would share the label "${marker}"; give one a different label`
1357
- };
1358
- }
1359
- const handles = (Array.isArray(p.handles) ? p.handles : String(p.handles ?? "").split(",")).map(clean).filter(Boolean);
1360
- people.push({
1361
- github,
1362
- name,
1363
- marker,
1364
- ...clean(p.role) ? { role: clean(p.role) } : {},
1365
- ...handles.length ? { handles } : {},
1366
- ...p.view_only === true ? { viewOnly: true } : {}
1367
- });
1368
- }
1369
- if (!people.some((h) => !h.viewOnly)) {
1370
- return {
1371
- people,
1372
- error: "someone has to be able to wake the staff: one person cannot be read-only"
1373
- };
1374
- }
1375
- return { people };
1376
- }
1377
- function writeHumans(text2, people) {
1378
- const lines = text2.split("\n");
1379
- const block = [
1380
- "humans:",
1381
- ...people.map((h) => {
1382
- const parts = [`name: ${h.name}`, `github: ${h.github}`, `marker: ${h.marker}`];
1383
- if (h.role) parts.push(`role: ${h.role}`);
1384
- if (h.handles?.length) parts.push(`handles: [${h.handles.join(", ")}]`);
1385
- if (h.viewOnly) parts.push("view_only: true");
1386
- return ` - { ${parts.join(", ")} }`;
1387
- })
1388
- ];
1389
- const out = [];
1390
- let at = -1;
1391
- for (let i = 0; i < lines.length; i++) {
1392
- if (/^humans?:/.test(lines[i])) {
1393
- if (at < 0) at = out.length;
1394
- while (i + 1 < lines.length) {
1395
- const next = lines[i + 1];
1396
- const more = /^\s+\S/.test(next) || /^\s*$/.test(next) && nextIsIndented(lines, i + 1);
1397
- if (!more) break;
1398
- i++;
1399
- }
1400
- continue;
1401
- }
1402
- out.push(lines[i]);
1403
- }
1404
- if (at < 0) {
1405
- const name = out.findIndex((l) => /^name:/.test(l));
1406
- at = name >= 0 ? name + 1 : out.length;
1407
- out.splice(at, 0, "");
1408
- at++;
1409
- }
1410
- out.splice(at, 0, ...block);
1411
- return out.join("\n");
1412
- }
1413
- function nextIsIndented(lines, from) {
1414
- for (let j = from; j < lines.length; j++) {
1415
- if (/^\s*$/.test(lines[j])) continue;
1416
- return /^\s+\S/.test(lines[j]);
1417
- }
1418
- return false;
1419
- }
1420
-
1421
1304
  // src/lib/archive.ts
1422
1305
  async function inflate(bytes, format) {
1423
1306
  try {
@@ -1881,7 +1764,16 @@ async function signedIn(req, url, cfg, doFetch = fetch) {
1881
1764
  }
1882
1765
  });
1883
1766
  const login = (await me.json().catch(() => ({}))).login ?? "";
1884
- if (!login || !await cfg.allowed(login, grant.access_token)) {
1767
+ const verdict = login ? await cfg.allowed(login, grant.access_token) : "no";
1768
+ if (verdict === "unknown") {
1769
+ await revoke(grant.access_token, cfg, doFetch);
1770
+ return page(
1771
+ 503,
1772
+ "GitHub did not answer",
1773
+ `<p>Signing in reads org.yaml from GitHub, and that did not work just now. Try again in a minute.</p><a class="back" href="/">Back to sign in</a>`
1774
+ );
1775
+ }
1776
+ if (verdict !== true && verdict !== "yes") {
1885
1777
  await revoke(grant.access_token, cfg, doFetch);
1886
1778
  return page(
1887
1779
  403,
@@ -3722,6 +3614,123 @@ ${bars}`;
3722
3614
  import { execFileSync as execFileSync2 } from "child_process";
3723
3615
  import { join as join13, relative as relative3 } from "path";
3724
3616
 
3617
+ // src/lib/humans.ts
3618
+ function readHumans2(org) {
3619
+ const listed = Array.isArray(org?.humans) ? org.humans : org?.humans ? [org.humans] : [];
3620
+ const raw = [...listed, org?.human].filter(Boolean);
3621
+ const out = [];
3622
+ for (const entry of raw) {
3623
+ const github = String(entry.github ?? entry.login ?? "").trim();
3624
+ const name = String(entry.name ?? github).trim();
3625
+ if (!github && !name) continue;
3626
+ if (github && out.some((h) => h.github.toLowerCase() === github.toLowerCase())) continue;
3627
+ out.push({
3628
+ github,
3629
+ name: name || github,
3630
+ marker: String(entry.marker ?? "").trim() || defaultMarker2(name || github),
3631
+ role: entry.role === void 0 || entry.role === null ? void 0 : String(entry.role),
3632
+ ...handlesOf2(entry.handles).length ? { handles: handlesOf2(entry.handles) } : {},
3633
+ ...entry.view_only === true ? { viewOnly: true } : {}
3634
+ });
3635
+ }
3636
+ return out;
3637
+ }
3638
+ function handlesOf2(v) {
3639
+ const list2 = Array.isArray(v) ? v : v ? String(v).split(",") : [];
3640
+ return list2.map((x) => String(x ?? "").trim()).filter(Boolean);
3641
+ }
3642
+ function staffHumans(org) {
3643
+ return readHumans2(org).filter((h) => !h.viewOnly);
3644
+ }
3645
+ function isViewOnly(org, login) {
3646
+ const l = login.toLowerCase();
3647
+ return readHumans2(org).some((h) => h.viewOnly && h.github.toLowerCase() === l);
3648
+ }
3649
+ function defaultMarker2(name) {
3650
+ return String(name).trim().split(/[\s-]+/)[0].toLowerCase().replace(/[^a-z0-9]/g, "") || "human";
3651
+ }
3652
+ var clean = (v) => String(v ?? "").replace(/[,{}[\]#"'\n\r]/g, " ").replace(/\s+/g, " ").trim();
3653
+ var LOGIN_RE = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;
3654
+ function tidyPeople(input) {
3655
+ const people = [];
3656
+ for (const p of input) {
3657
+ const github = clean(p.github).replace(/^@/, "");
3658
+ const name = clean(p.name) || github;
3659
+ if (!github && !name) continue;
3660
+ if (!LOGIN_RE.test(github))
3661
+ return { people, error: `"${github || name}" is not a GitHub login` };
3662
+ if (people.some((h) => h.github.toLowerCase() === github.toLowerCase())) {
3663
+ return { people, error: `@${github} is in the list twice` };
3664
+ }
3665
+ const marker = (clean(p.marker) || defaultMarker2(name || github)).toLowerCase().replace(/[^a-z0-9-]/g, "");
3666
+ if (people.some((h) => h.marker === marker)) {
3667
+ return {
3668
+ people,
3669
+ error: `two people would share the label "${marker}"; give one a different label`
3670
+ };
3671
+ }
3672
+ const handles = (Array.isArray(p.handles) ? p.handles : String(p.handles ?? "").split(",")).map(clean).filter(Boolean);
3673
+ people.push({
3674
+ github,
3675
+ name,
3676
+ marker,
3677
+ ...clean(p.role) ? { role: clean(p.role) } : {},
3678
+ ...handles.length ? { handles } : {},
3679
+ ...p.view_only === true ? { viewOnly: true } : {}
3680
+ });
3681
+ }
3682
+ if (!people.some((h) => !h.viewOnly)) {
3683
+ return {
3684
+ people,
3685
+ error: "someone has to be able to wake the staff: one person cannot be read-only"
3686
+ };
3687
+ }
3688
+ return { people };
3689
+ }
3690
+ function writeHumans(text2, people) {
3691
+ const lines = text2.split("\n");
3692
+ const block = [
3693
+ "humans:",
3694
+ ...people.map((h) => {
3695
+ const parts = [`name: ${h.name}`, `github: ${h.github}`, `marker: ${h.marker}`];
3696
+ if (h.role) parts.push(`role: ${h.role}`);
3697
+ if (h.handles?.length) parts.push(`handles: [${h.handles.join(", ")}]`);
3698
+ if (h.viewOnly) parts.push("view_only: true");
3699
+ return ` - { ${parts.join(", ")} }`;
3700
+ })
3701
+ ];
3702
+ const out = [];
3703
+ let at = -1;
3704
+ for (let i = 0; i < lines.length; i++) {
3705
+ if (/^humans?:/.test(lines[i])) {
3706
+ if (at < 0) at = out.length;
3707
+ while (i + 1 < lines.length) {
3708
+ const next = lines[i + 1];
3709
+ const more = /^\s+\S/.test(next) || /^\s*$/.test(next) && nextIsIndented(lines, i + 1);
3710
+ if (!more) break;
3711
+ i++;
3712
+ }
3713
+ continue;
3714
+ }
3715
+ out.push(lines[i]);
3716
+ }
3717
+ if (at < 0) {
3718
+ const name = out.findIndex((l) => /^name:/.test(l));
3719
+ at = name >= 0 ? name + 1 : out.length;
3720
+ out.splice(at, 0, "");
3721
+ at++;
3722
+ }
3723
+ out.splice(at, 0, ...block);
3724
+ return out.join("\n");
3725
+ }
3726
+ function nextIsIndented(lines, from) {
3727
+ for (let j = from; j < lines.length; j++) {
3728
+ if (/^\s*$/.test(lines[j])) continue;
3729
+ return /^\s+\S/.test(lines[j]);
3730
+ }
3731
+ return false;
3732
+ }
3733
+
3725
3734
  // src/lib/memory.ts
3726
3735
  import { join as join12 } from "path";
3727
3736
  var FACT_RE = /^- \*\*`([^`]+)`\*\*\s*·\s*(.*)$/;
@@ -4001,7 +4010,7 @@ function buildExport(ws, org, parseYaml3, opts = {}) {
4001
4010
  opsName: ws.opsName,
4002
4011
  human: humans[0] ?? org.human ?? {},
4003
4012
  humans,
4004
- people: readHumans(org),
4013
+ people: readHumans2(org),
4005
4014
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4006
4015
  staff
4007
4016
  };
@@ -5372,12 +5381,13 @@ async function ready(c, opts = {}) {
5372
5381
  ]);
5373
5382
  return { org, brains, results: [{ dir: portal2.opsName, ...ops }, ...results] };
5374
5383
  }
5375
- async function readOrgFor(portal2, gh) {
5384
+ async function humanVerdict(portal2, gh, login) {
5376
5385
  const ops = await portal2.snapshots.refresh(gh, `${portal2.org}/${portal2.opsName}`, {
5377
5386
  force: true
5378
5387
  });
5379
- if (!ops.ok) return null;
5380
- return readOrg(portal2.ws.opsDir, parseYaml2);
5388
+ if (!ops.ok) return ops.status === 401 || ops.status === 404 ? "no" : "unknown";
5389
+ const org = readOrg(portal2.ws.opsDir, parseYaml2);
5390
+ return readHumans2(org).some((h) => h.github?.toLowerCase() === login.toLowerCase()) ? "yes" : "no";
5381
5391
  }
5382
5392
  var DOCS = /* @__PURE__ */ new Set(["/api/docs", "/api/docsearch", "/api/doc", "/api/docasset"]);
5383
5393
  var localLogin = null;
@@ -7734,16 +7744,16 @@ function clientFor2(token2) {
7734
7744
  }
7735
7745
  return gh;
7736
7746
  }
7737
- async function isHuman(p, login, token2) {
7738
- const org = await readOrgFor(p, clientFor2(token2));
7739
- if (!org) return false;
7740
- return readHumans(org).some((h) => h.github?.toLowerCase() === login.toLowerCase());
7741
- }
7747
+ var RETRY_MS = 3e4;
7742
7748
  async function stillHuman(p, login, token2) {
7743
7749
  const at = confirmed.get(login) ?? 0;
7744
7750
  if (Date.now() - at < RECHECK_MS) return true;
7745
- if (!await isHuman(p, login, token2)) return false;
7746
- confirmed.set(login, Date.now());
7751
+ const verdict = await humanVerdict(p, clientFor2(token2), login);
7752
+ if (verdict === "no") {
7753
+ confirmed.delete(login);
7754
+ return false;
7755
+ }
7756
+ confirmed.set(login, verdict === "yes" ? Date.now() : Date.now() - RECHECK_MS + RETRY_MS);
7747
7757
  return true;
7748
7758
  }
7749
7759
  var worker_default = {
@@ -7755,7 +7765,7 @@ var worker_default = {
7755
7765
  clientId: env.GITHUB_CLIENT_ID,
7756
7766
  clientSecret: env.GITHUB_CLIENT_SECRET,
7757
7767
  sessionKey: env.SESSION_KEY,
7758
- allowed: (login, token2) => isHuman(p, login, token2)
7768
+ allowed: (login, token2) => humanVerdict(p, clientFor2(token2), login)
7759
7769
  };
7760
7770
  if (path === "/auth/login") return startSignIn(url, auth);
7761
7771
  const name = env.ROSTER_NAME || env.ROSTER_ORG;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanocollective/roster",
3
- "version": "0.1.0-beta.32",
3
+ "version": "0.1.0-beta.34",
4
4
  "description": "An agent-run org, powered by GitHub. Scaffold AI staff members whose brain is a repo.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -338,6 +338,13 @@ jobs:
338
338
  cache: pnpm
339
339
  cache-dependency-path: ${{ steps.plan.outputs.package_json }}
340
340
 
341
+ # setup-node saves pnpm's store when the job ends, and fails the run if the store is not
342
+ # there. A session that never installs anything (a CMO's, mostly) never creates it, so a
343
+ # run whose work all succeeded was reported as failed. An empty store is nothing to save.
344
+ - name: Make sure pnpm's store exists
345
+ if: steps.plan.outputs.needs_node == 'true'
346
+ run: mkdir -p "$(pnpm store path --silent)"
347
+
341
348
  # A status issue lasts a week. The first daily run of a week opens the new one, pins it and
342
349
  # moves staff.yaml on, before the prompt is composed from staff.yaml; the prompt is told
343
350
  # which earlier week still needs its summary. `daily` only: a mention is not a session.
@@ -61,10 +61,10 @@ const STEP_COMMANDS = {
61
61
  "run once": (h) => `run ${h} --apply`,
62
62
  };
63
63
  /**
64
- * The steps that are writing, not wiring: a hosted portal can do these itself (the org's two
65
- * files on Org, the charter on Staff), so it offers that rather than a command.
64
+ * The steps a hosted portal can do itself, so it offers that rather than a command: the org's
65
+ * two files on Org, the charter on Staff, and a first run, which is a workflow dispatch.
66
66
  */
67
- export const IN_PORTAL = new Set(["business", "priorities", "write the charter"]);
67
+ export const IN_PORTAL = new Set(["business", "priorities", "write the charter", "run once"]);
68
68
 
69
69
  export function stepCommand(what, handle) {
70
70
  return STEP_COMMANDS[what]?.(handle) ?? "";
@@ -12,6 +12,7 @@ import { daysUntil, isFor, sortHome } from "../homesort.js";
12
12
  import { mdlite } from "../md.js";
13
13
  import { checkAll, notReady, ORG_STEPS, stepCommand } from "../readiness.js";
14
14
  import { commandLine } from "./notready.js";
15
+ import { runOnce } from "./runonce.js";
15
16
  import { parseReport } from "../report.js";
16
17
  import { icon, iconHTML, staffIcon } from "../icons.js";
17
18
  import { ensureInbox, stampCounts } from "../refresh.js";
@@ -637,11 +638,13 @@ function setupLeft(staff) {
637
638
  go({ view: "staff" });
638
639
  }
639
640
  : null;
640
- steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle), here]);
641
+ // A first run is a button anywhere: the same one Health has, right in the list.
642
+ const inline = what === "run once" ? s : null;
643
+ steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle), here, inline]);
641
644
  }
642
645
  }
643
646
  if (!steps.length) return null;
644
- const wiring = steps.filter(([, , here]) => !here).length;
647
+ const wiring = steps.filter(([, , here, inline]) => !here && !inline).length;
645
648
 
646
649
  const box = el("div", { className: "card homesetup" });
647
650
  box.append(el("b", { textContent: "Setup is not finished" }));
@@ -659,11 +662,16 @@ function setupLeft(staff) {
659
662
  el("p", { className: "sub homesetupor", textContent: "Or one at a time, in order:" }),
660
663
  );
661
664
  } else {
662
- box.append(el("p", { className: "sub", textContent: "Nobody runs until these are done." }));
665
+ box.append(
666
+ el("p", {
667
+ className: "sub",
668
+ textContent: S.hosted ? "Nobody runs until these are done, and each can be done here." : "Nobody runs until these are done.",
669
+ }),
670
+ );
663
671
  }
664
672
  const seen = new Set();
665
673
  const list = el("ol", { className: "homesetupsteps" });
666
- for (const [what, cmd, here] of steps) {
674
+ for (const [what, cmd, here, inline] of steps) {
667
675
  // The credential is the org's, so two staff members missing it is one step.
668
676
  if (cmd && seen.has(cmd)) continue;
669
677
  seen.add(cmd);
@@ -674,6 +682,8 @@ function setupLeft(staff) {
674
682
  const write = el("button", { className: "ghbtn sm", textContent: "Write it here" });
675
683
  write.onclick = here;
676
684
  label.append(" ", write);
685
+ } else if (S.hosted && inline) {
686
+ row.append(runOnce({ staff: inline.handle, name: inline.name, onDone: (ok) => ok && render() }));
677
687
  } else if (S.hosted && cmd) row.append(commandLine(cmd));
678
688
  list.append(row);
679
689
  }
@@ -14,6 +14,7 @@ import { refreshAll } from "../refresh.js";
14
14
  import { S } from "../state.js";
15
15
  import { charterModes, hireFlow, line, rolePicker } from "./hire.js";
16
16
  import { commandLine } from "./notready.js";
17
+ import { runOnce } from "./runonce.js";
17
18
 
18
19
  /**
19
20
  * Resolves once nothing is loading and `node` has stopped changing for a moment, or after a few
@@ -223,6 +224,10 @@ export function viewStaff(m, o = {}) {
223
224
  warn.append(el("div", { className: "row" }, [write]));
224
225
  }
225
226
  warn.append(...cmds.map(commandLine));
227
+ // Once a run is all that is left, it is a button here like everywhere else.
228
+ if (left.length === 1 && left[0] === "run once") {
229
+ warn.append(runOnce({ staff: s.handle, name: s.name, onDone: (ok) => ok && refreshAll() }));
230
+ }
226
231
  }
227
232
  });
228
233
  d.append(warn);