@nanocollective/roster 0.1.0-alpha.9 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +6 -0
  2. package/dist/cli.js +4079 -1950
  3. package/dist/worker/assets/assets/css/base.css +312 -0
  4. package/dist/worker/assets/assets/css/brain.css +116 -0
  5. package/dist/worker/assets/assets/css/diff.css +33 -0
  6. package/dist/worker/assets/assets/css/graph.css +39 -0
  7. package/dist/worker/assets/assets/css/health.css +75 -0
  8. package/dist/worker/assets/assets/css/home.css +101 -0
  9. package/dist/worker/assets/assets/css/inbox.css +199 -0
  10. package/dist/worker/assets/assets/css/layout.css +175 -0
  11. package/dist/worker/assets/assets/css/markdown.css +96 -0
  12. package/dist/worker/assets/assets/css/runs.css +13 -0
  13. package/dist/worker/assets/assets/css/search.css +48 -0
  14. package/dist/worker/assets/assets/css/setup.css +194 -0
  15. package/dist/worker/assets/assets/js/api.js +161 -0
  16. package/dist/worker/assets/assets/js/app.js +465 -0
  17. package/dist/worker/assets/assets/js/dialog.js +196 -0
  18. package/dist/worker/assets/assets/js/dom.js +131 -0
  19. package/dist/worker/assets/assets/js/homesort.js +174 -0
  20. package/dist/worker/assets/assets/js/icons.js +142 -0
  21. package/dist/worker/assets/assets/js/inflight.js +18 -0
  22. package/dist/worker/assets/assets/js/lightbox.js +273 -0
  23. package/dist/worker/assets/assets/js/md.js +406 -0
  24. package/dist/worker/assets/assets/js/mdedit.js +84 -0
  25. package/dist/worker/assets/assets/js/mention.js +264 -0
  26. package/dist/worker/assets/assets/js/readiness.js +70 -0
  27. package/dist/worker/assets/assets/js/refresh.js +197 -0
  28. package/dist/worker/assets/assets/js/router.js +20 -0
  29. package/dist/worker/assets/assets/js/search.js +366 -0
  30. package/dist/worker/assets/assets/js/state.js +213 -0
  31. package/dist/worker/assets/assets/js/textdiff.js +96 -0
  32. package/dist/worker/assets/assets/js/views/app.js +145 -0
  33. package/dist/worker/assets/assets/js/views/brain.js +260 -0
  34. package/dist/worker/assets/assets/js/views/changed.js +157 -0
  35. package/dist/worker/assets/assets/js/views/checklist.js +115 -0
  36. package/dist/worker/assets/assets/js/views/credential.js +84 -0
  37. package/dist/worker/assets/assets/js/views/docs.js +174 -0
  38. package/dist/worker/assets/assets/js/views/files.js +139 -0
  39. package/dist/worker/assets/assets/js/views/graph.js +436 -0
  40. package/dist/worker/assets/assets/js/views/health.js +304 -0
  41. package/dist/worker/assets/assets/js/views/hire.js +593 -0
  42. package/dist/worker/assets/assets/js/views/home.js +585 -0
  43. package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
  44. package/dist/worker/assets/assets/js/views/memory.js +150 -0
  45. package/dist/worker/assets/assets/js/views/org.js +195 -0
  46. package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
  47. package/dist/worker/assets/assets/js/views/paste.js +216 -0
  48. package/dist/worker/assets/assets/js/views/prompt.js +457 -0
  49. package/dist/worker/assets/assets/js/views/repos.js +97 -0
  50. package/dist/worker/assets/assets/js/views/runonce.js +94 -0
  51. package/dist/worker/assets/assets/js/views/runs.js +182 -0
  52. package/dist/worker/assets/assets/js/views/setup.js +557 -0
  53. package/dist/worker/assets/assets/js/views/staff.js +291 -0
  54. package/dist/worker/assets/assets/js/views/todo.js +62 -0
  55. package/dist/worker/assets/assets/js/yaml.js +134 -0
  56. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  57. package/dist/worker/assets/docs-images/home.jpg +0 -0
  58. package/dist/worker/assets/docs-images/org.jpg +0 -0
  59. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  60. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  61. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  62. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  63. package/dist/worker/assets/index.html +82 -0
  64. package/dist/worker/index.js +4442 -0
  65. package/docs/README.md +2 -2
  66. package/docs/architecture.md +1 -1
  67. package/docs/charters/analyst.md +65 -0
  68. package/docs/charters/community.md +63 -0
  69. package/docs/charters/designer.md +65 -0
  70. package/docs/charters/devops.md +65 -0
  71. package/docs/charters/pm.md +70 -0
  72. package/docs/charters/qa.md +65 -0
  73. package/docs/charters/writer.md +63 -0
  74. package/docs/commands.md +9 -3
  75. package/docs/concepts.md +33 -20
  76. package/docs/cost.md +3 -3
  77. package/docs/developing.md +27 -9
  78. package/docs/doctor-codes.md +3 -1
  79. package/docs/export.md +2 -0
  80. package/docs/getting-started.md +44 -27
  81. package/docs/hosting.md +89 -43
  82. package/docs/images/brain.jpg +0 -0
  83. package/docs/images/home.jpg +0 -0
  84. package/docs/images/org.jpg +0 -0
  85. package/docs/images/prompt.jpg +0 -0
  86. package/docs/images/staff.jpg +0 -0
  87. package/docs/manual-steps.md +3 -2
  88. package/docs/org-yaml.md +3 -0
  89. package/docs/portal.md +143 -45
  90. package/docs/prompts.md +6 -0
  91. package/docs/security.md +57 -11
  92. package/docs/session-workflow.md +14 -0
  93. package/docs/staff-yaml.md +17 -1
  94. package/docs/upgrading.md +3 -3
  95. package/docs/writing-a-charter.md +19 -6
  96. package/package.json +4 -3
  97. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
  98. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
  99. package/templates/brain/staff.yaml +4 -1
  100. package/templates/briefs/amend.md +4 -3
  101. package/templates/briefs/priorities.md +46 -0
  102. package/templates/ops/.github/workflows/session.yaml +137 -3
  103. package/templates/ops/compose.mjs +35 -8
  104. package/templates/ops/org/operating.md +29 -10
  105. package/templates/ops/prompts/daily.md +23 -4
  106. package/templates/ops/prompts/mention.md +19 -0
  107. package/templates/ops/run-record.mjs +5 -3
  108. package/templates/portal/css/base.css +34 -0
  109. package/templates/portal/css/health.css +14 -1
  110. package/templates/portal/css/home.css +101 -0
  111. package/templates/portal/css/inbox.css +21 -4
  112. package/templates/portal/css/layout.css +29 -3
  113. package/templates/portal/css/markdown.css +19 -0
  114. package/templates/portal/css/search.css +48 -0
  115. package/templates/portal/css/setup.css +79 -4
  116. package/templates/portal/index.html +15 -9
  117. package/templates/portal/js/api.js +30 -4
  118. package/templates/portal/js/app.js +90 -7
  119. package/templates/portal/js/dialog.js +36 -0
  120. package/templates/portal/js/homesort.js +174 -0
  121. package/templates/portal/js/icons.js +41 -0
  122. package/templates/portal/js/inflight.js +18 -0
  123. package/templates/portal/js/md.js +5 -2
  124. package/templates/portal/js/mdedit.js +84 -0
  125. package/templates/portal/js/readiness.js +70 -0
  126. package/templates/portal/js/refresh.js +10 -2
  127. package/templates/portal/js/search.js +366 -0
  128. package/templates/portal/js/state.js +11 -5
  129. package/templates/portal/js/views/app.js +1 -2
  130. package/templates/portal/js/views/brain.js +1 -1
  131. package/templates/portal/js/views/checklist.js +19 -4
  132. package/templates/portal/js/views/credential.js +42 -51
  133. package/templates/portal/js/views/health.js +11 -6
  134. package/templates/portal/js/views/hire.js +593 -0
  135. package/templates/portal/js/views/home.js +585 -0
  136. package/templates/portal/js/views/inbox.js +237 -68
  137. package/templates/portal/js/views/org.js +31 -111
  138. package/templates/portal/js/views/orgedit.js +240 -0
  139. package/templates/portal/js/views/paste.js +111 -66
  140. package/templates/portal/js/views/prompt.js +94 -40
  141. package/templates/portal/js/views/repos.js +10 -10
  142. package/templates/portal/js/views/runs.js +21 -4
  143. package/templates/portal/js/views/setup.js +130 -163
  144. package/templates/portal/js/views/staff.js +181 -301
  145. package/templates/portal/js/views/todo.js +62 -0
@@ -8,28 +8,34 @@
8
8
  import {
9
9
  checkOrg,
10
10
  createTenant,
11
- fileUrl,
12
11
  getAccess,
13
12
  getOrg,
14
13
  getSetup,
15
14
  joinOrg,
16
15
  planTenant,
17
- saveFile,
18
16
  setAccess,
19
17
  } from "../api.js";
20
- import { $, el, esc, grow, toClipboard } from "../dom.js";
18
+ import { $, el, esc, toClipboard } from "../dom.js";
21
19
  import { go } from "../router.js";
22
20
  import { S as App } from "../state.js";
21
+ import { checkAll, notReady, progress, sentence } from "../readiness.js";
23
22
  import { checklist } from "./checklist.js";
23
+ import { businessForm, prioritiesForm } from "./orgedit.js";
24
24
  import { credentialPanel } from "./credential.js";
25
25
  import { repoPicker } from "./repos.js";
26
- import { paste } from "./paste.js";
26
+ import { todo } from "./todo.js";
27
27
 
28
28
  let S = null; // /api/setup/status, refreshed after anything that changes the world
29
29
 
30
30
  /* Where the doctor checklist is drawn on this screen, so a save can re-run it. Left stale, it
31
31
  went on saying business.stub after business.md had been saved, until "Check again". */
32
32
  let healthHost = null;
33
+ let healthStep = null;
34
+
35
+ /* What the "What is left" cards already ask for. Doctor reporting them as well, right after a
36
+ successful create, read as the create having failed. */
37
+ const COVERED = ["business", "business.stub", "priorities", "priorities.stub", "actions-access", "secrets", "agent"];
38
+ const HEALTH = { skip: COVERED, hideWhenClean: true };
33
39
 
34
40
  /* Each "what is left" step that is a file, by id, so a save can mark it done in place rather
35
41
  than repainting the page and throwing away the diff somebody is still reading. */
@@ -55,46 +61,52 @@ export async function viewGettingStarted(main) {
55
61
  S = await getSetup();
56
62
  // Somebody may have clicked elsewhere while GitHub was answering.
57
63
  if (App.view !== "setup") return;
58
- sub.textContent =
59
- "What is still to do before " + (App.data?.name ?? "this org") + " runs well. Each step " +
60
- "reads the world rather than remembering a click, so it is safe to leave and come back.";
61
-
62
- if (!App.data?.staff?.length) {
63
- const next = step(1, "Hire your first staff member", false);
64
- const hire = el("button", { className: "btn primary", textContent: "Hire someone" });
65
- hire.onclick = () => go({ view: "staff" });
66
- next.append(
67
- el("p", {
68
- textContent:
69
- "Nothing runs until somebody is hired. Hiring creates their repo, their workflows and " +
70
- "their pinned issue; the GitHub App and the charter follow on their card.",
71
- }),
72
- el("div", { className: "row" }, [hire]),
73
- );
74
- main.append(next);
64
+ await checkAll();
65
+ if (App.view !== "setup") return;
66
+ const p = progress();
67
+ sub.textContent = (p ? `${p.done} of ${p.total} done. ` : "") + "Work through these in order.";
68
+ const list = afterCreate();
69
+
70
+ // Somebody hired but not ready to run is the most important thing left, so it comes first.
71
+ for (const s of notReady().reverse()) {
72
+ const t = todo("!", "Finish setting up " + s.name, false);
73
+ t.hint("Still to do: " + sentence(App.readiness?.[s.handle] ?? []) + ".");
74
+ const cont = el("button", { className: "btn primary", textContent: "Continue" });
75
+ cont.onclick = () => {
76
+ App.staffOpen = { handle: s.handle, name: s.name, dir: s.dir };
77
+ go({ view: "staff" });
78
+ };
79
+ t.body.append(el("div", { className: "row" }, [cont]));
80
+ list.prepend(t.card);
75
81
  }
82
+ main.append(list);
76
83
 
77
- main.append(afterCreate(App.data?.staff?.length ? 1 : 2));
78
-
79
- const health = step(App.data?.staff?.length ? 2 : 3, "What doctor still says", false);
84
+ const health = step("!", "Other problems", false);
80
85
  healthHost = el("div", { style: "margin-top:12px" });
81
86
  health.append(healthHost);
82
87
  main.append(health);
83
- checklist(healthHost, {});
88
+ healthStep = health;
89
+ checklist(healthHost, { ...HEALTH, onEmpty: () => health.remove() });
84
90
  }
85
91
 
86
92
  /** Whether the sidebar offers Getting started: while anything is left, or while it is open. */
87
93
  export function paintSetupNav() {
88
94
  const nav = $("#setupnav");
89
95
  if (!nav) return;
90
- nav.hidden = !App.data?.unfinished?.length && App.view !== "setup";
96
+ // Hosted, there is no setting up from here: that is done in roster portal on your machine.
97
+ nav.hidden =
98
+ Boolean(App.hosted) ||
99
+ (!App.data?.unfinished?.length && !notReady().length && App.view !== "setup");
100
+ const count = $("#setupcount");
101
+ const p = progress();
102
+ if (count) count.textContent = p ? `${p.done}/${p.total}` : "";
91
103
  }
92
104
 
93
105
  /* After a save: the checklist and the step list are both derived from disk, so both are asked
94
106
  again rather than updated by hand. The sidebar's list comes from /api/org, which is the one
95
107
  the portal already reads. */
96
108
  async function recheck() {
97
- if (healthHost) checklist(healthHost, {});
109
+ if (healthHost) checklist(healthHost, { ...HEALTH, onEmpty: () => healthStep?.remove() });
98
110
  try {
99
111
  S = await getSetup();
100
112
  for (const [id, mark] of fileSteps) mark(!(S.tenant.left ?? []).includes(id));
@@ -120,9 +132,7 @@ function render(main) {
120
132
  el("p", {
121
133
  className: "sub",
122
134
  textContent:
123
- "Sign in with gh, choose the organisation and the agent, then what is left: a setting " +
124
- "roster tries for you, the agent's credential, the repos your staff work in, and the two " +
125
- "files only you can write. Nothing is created until you have read the plan.",
135
+ "Choose an organisation and a coding agent. Nothing is created until you press Create it.",
126
136
  }),
127
137
  );
128
138
 
@@ -132,7 +142,11 @@ function render(main) {
132
142
 
133
143
  /* Drawn whenever a tenant exists, not only in the seconds after creating one. Setup takes
134
144
  days: the repo picker and the two manual steps have to still be here tomorrow. */
135
- if (S.tenant.found) main.append(afterCreate(3));
145
+ if (S.tenant.found) {
146
+ const rest = step(3, "Finish setting up", false);
147
+ rest.append(afterCreate());
148
+ main.append(rest);
149
+ }
136
150
  }
137
151
 
138
152
  /* ---------------------------------- 1 · gh ---------------------------------- */
@@ -148,8 +162,7 @@ function stepGh() {
148
162
  el("p", {
149
163
  className: "sub",
150
164
  textContent:
151
- "roster does everything through your own gh, so it holds no token of its own. Run this " +
152
- "in a terminal, then reload:",
165
+ "Run this in a terminal, then reload:",
153
166
  }),
154
167
  el("pre", { className: "cmd", textContent: "gh auth login" }),
155
168
  );
@@ -170,13 +183,9 @@ function stepOrg(main) {
170
183
  el("p", {
171
184
  className: "sub",
172
185
  textContent:
173
- "Reload the page to open the portal. Anything below that is still undone stays under " +
174
- "Getting started in the sidebar until it is.",
186
+ "Finish the steps below. They stay under Getting started in the sidebar until they're done.",
175
187
  }),
176
188
  );
177
- healthHost = el("div", { style: "margin-top:12px" });
178
- card.append(healthHost);
179
- checklist(healthHost, {});
180
189
  return card;
181
190
  }
182
191
 
@@ -206,8 +215,7 @@ function stepOrg(main) {
206
215
  orgWrap.append(
207
216
  el("small", {
208
217
  textContent:
209
- "Repos are created here. GitHub has no API for creating an organisation, so make one on " +
210
- "github.com first if you need to.",
218
+ "Don't have one? Create it on github.com first.",
211
219
  }),
212
220
  );
213
221
  form.append(orgWrap);
@@ -250,8 +258,8 @@ function stepOrg(main) {
250
258
  });
251
259
  other.input.addEventListener("change", look);
252
260
 
253
- const name = field("name", "What the business is called", "", "Shown to the agents. Defaults to the org.");
254
- const human = field("human", "Your GitHub login", S.gh.login ?? "", "The person the agents answer to.");
261
+ const name = field("name", "What the business is called", "", "Defaults to the organisation name.");
262
+ const human = field("human", "Your GitHub login", S.gh.login ?? "", "The person the staff report to.");
255
263
 
256
264
  card.append(form);
257
265
  const agentHead = el("h3", { textContent: "Which coding agent runs a session" });
@@ -264,7 +272,7 @@ function stepOrg(main) {
264
272
  const opt = el("label", { className: "choice" });
265
273
  const radio = el("input", { name: "agent", value: a.id, checked: i === 0 });
266
274
  radio.setAttribute("type", "radio");
267
- opt.append(radio, el("b", { textContent: a.label }), el("small", { textContent: a.note }));
275
+ opt.append(radio, el("b", { textContent: a.label }));
268
276
  opt.append(el("code", { textContent: a.tokenEnv }));
269
277
  agents.append(opt);
270
278
  });
@@ -272,8 +280,7 @@ function stepOrg(main) {
272
280
  const agentNote = el("p", {
273
281
  className: "sub",
274
282
  textContent:
275
- "Anything else works too: a runner is an install command, a run command and the name of " +
276
- "the secret holding its credential. Write those three into org.yaml afterwards.",
283
+ "Using a different agent? Pick any of these, then set it in org.yaml afterwards.",
277
284
  });
278
285
  card.append(agentNote);
279
286
 
@@ -349,26 +356,20 @@ function stepOrg(main) {
349
356
  out.replaceChildren(el("p", { className: "sub", textContent: "Working…" }));
350
357
  try {
351
358
  const result = await planTenant(p);
352
- out.replaceChildren();
353
- out.append(
354
- el("p", {
355
- textContent:
356
- `${result.files.length} files in ${result.dir}, and one private repo, ${p.org}/roster-ops, ` +
357
- "with its Actions access set so every repo in the org can call its workflow. If GitHub " +
358
- "refuses that, you get the reason and the page to click.",
359
- }),
360
- );
361
- const list = el("div", { className: "filelist" });
362
- for (const f of result.files) list.append(el("code", { textContent: "+ " + f }));
363
- out.append(list);
364
- out.append(
365
- el("p", {
366
- className: "sub",
367
- textContent:
368
- "org/business.md arrives as questions, not prose. Answering it is the next step and " +
369
- "it is the one that decides whether any of this is worth running.",
370
- }),
371
- );
359
+ const steps = el("ol", { className: "plansteps" }, [
360
+ el("li", { textContent: `Create a private repo, ${p.org}/roster-ops, to hold the org's shared settings.` }),
361
+ el("li", { textContent: `Put a copy of it in ${result.dir}.` }),
362
+ el("li", { textContent: `Let the other repos in ${p.org} run its workflow.` }),
363
+ ]);
364
+ const files = el("details", { className: "planfiles" }, [
365
+ el("summary", { textContent: `The ${result.files.length} files it writes` }),
366
+ el("div", { className: "filelist" }, result.files.map((f) => el("code", { textContent: f }))),
367
+ ]);
368
+ const next = el("p", {
369
+ className: "sub",
370
+ textContent: "After that: describe the business, set this month's priorities, and hire your first staff member.",
371
+ });
372
+ out.replaceChildren(el("p", { textContent: "Create it will:" }), steps, files, next);
372
373
  go.hidden = false;
373
374
  } catch (err) {
374
375
  out.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
@@ -398,42 +399,66 @@ function stepOrg(main) {
398
399
 
399
400
  /* ------------------------- 5 · the two GitHub insists on ------------------------- */
400
401
 
401
- function afterCreate(n) {
402
+ function afterCreate() {
402
403
  fileSteps.clear();
403
- const card = step(n, "What is left", false);
404
- card.append(
405
- el("p", {
406
- textContent:
407
- "The first is a setting roster tries for you. The last two are the files that decide " +
408
- "whether any of this is worth running, and only you can write them.",
409
- }),
410
- );
411
- card.append(accessStep());
412
- card.append(credentialPanel());
404
+ const list = el("div", { className: "todos" });
405
+ const left = S.tenant.left ?? [];
406
+ const staffCount = App.data?.staff?.length ?? 0;
407
+ let n = 0;
413
408
 
414
409
  if (S.tenant.org) {
415
- card.append(repoPicker({ org: S.tenant.org, known: S.tenant.repos ?? [] }));
410
+ const repos = todo(++n, "Choose the repos your staff work on", (S.tenant.products ?? []).length > 0);
411
+ repos.hint("Pick at least one. Staff open pull requests there, and you review them.");
412
+ repos.body.append(
413
+ repoPicker({ org: S.tenant.org, known: S.tenant.repos ?? [], bare: true, onAdded: () => repos.setDone(true) }),
414
+ );
415
+ list.append(repos.card);
416
416
  }
417
417
 
418
- const business = fileStep(
419
- "business",
420
- "Answer org/business.md",
421
- "It ships as questions. It is composed into the top of every prompt, every run, and an " +
422
- "agent that cannot answer them writes work that is plausible and generic.",
418
+ const business = todo(++n, "Describe the business", !left.includes("business"));
419
+ business.hint("A few short answers. Every staff member reads them before they start work.");
420
+ business.body.append(
421
+ businessForm({
422
+ path: opsName() + "/org/business.md",
423
+ name: App.data?.name ?? S.tenant.name ?? S.tenant.org,
424
+ onSaved: () => (business.setDone(true), recheck()),
425
+ }),
423
426
  );
424
- // The copy-a-prompt loop, which is the whole answer to "how do I write this file".
425
- business.append(paste({ kind: "discover", title: "Write it with your own AI", onSaved: recheck }));
426
- card.append(business);
427
-
428
- const priorities = fileStep(
429
- "priorities",
430
- "Rank org/priorities.md",
431
- "What matters this month, at most three things in order, and what is out of scope. Every " +
432
- "daily run reads it; without it each staff member picks its own direction from its charter.",
427
+ fileSteps.set("business", business.setDone);
428
+ list.append(business.card);
429
+
430
+ const priorities = todo(++n, "Set this month's priorities", !left.includes("priorities"));
431
+ priorities.hint("Up to three, in order. Staff pick work that serves them.");
432
+ priorities.body.append(
433
+ prioritiesForm({
434
+ path: opsName() + "/org/priorities.md",
435
+ onSaved: () => (priorities.setDone(true), recheck()),
436
+ }),
433
437
  );
434
- priorities.append(prioritiesEditor());
435
- card.append(priorities);
436
- return card;
438
+ fileSteps.set("priorities", priorities.setDone);
439
+ list.append(priorities.card);
440
+
441
+ const hire = todo(++n, "Hire your first staff member", staffCount > 0);
442
+ hire.hint("Pick a role. The Staff screen then lists each step to set them up.");
443
+ const hireBtn = el("button", { className: "btn primary", textContent: "Hire someone" });
444
+ hireBtn.onclick = () => {
445
+ // Before the org has loaded, this screen is the whole app, so the Staff screen needs a reload.
446
+ if (App.data) go({ view: "staff" });
447
+ else location.assign("/#/-/staff") || location.reload();
448
+ };
449
+ hire.body.append(el("div", { className: "row" }, [hireBtn]));
450
+ list.append(hire.card);
451
+
452
+ const cred = todo(++n, "Add your agent credential", false);
453
+ cred.hint(staffCount ? "Staff use it to run. You only add it once." : "Do this after your first hire.");
454
+ cred.body.append(credentialPanel({ bare: true, onStatus: (ok) => cred.setDone(ok) }));
455
+ list.append(cred.card);
456
+
457
+ const access = todo(++n, "Let staff repos use the shared workflow", false);
458
+ access.body.append(accessStep({ onStatus: (ok) => access.setDone(ok) }));
459
+ list.append(access.card);
460
+
461
+ return list;
437
462
  }
438
463
 
439
464
  /**
@@ -442,18 +467,6 @@ function afterCreate(n) {
442
467
  * Read from the status rather than from the click that saved it, so a file written in an
443
468
  * editor, or by a coding agent, shows as done here too.
444
469
  */
445
- function fileStep(id, title, why) {
446
- const box = el("div", { className: "manual" });
447
- const tag = el("span", { className: "meta" });
448
- const mark = (done) => {
449
- tag.textContent = done ? "Written." : "Still the stub it shipped as.";
450
- box.classList[done ? "add" : "remove"]("done");
451
- };
452
- mark(!(S.tenant.left ?? []).includes(id));
453
- fileSteps.set(id, mark);
454
- box.append(el("div", {}, [el("b", { textContent: title }), tag]), el("p", { textContent: why }));
455
- return box;
456
- }
457
470
 
458
471
  /**
459
472
  * org/priorities.md, edited in place.
@@ -463,57 +476,11 @@ function fileStep(id, title, why) {
463
476
  * quicker to type than to explain to a model. So the file opens as it is on disk, stub and
464
477
  * all, and saving it is the same commit-and-push as every other editor here.
465
478
  */
466
- function prioritiesEditor() {
467
- const box = el("div", { style: "margin-top:9px" });
468
- const path = opsName() + "/org/priorities.md";
469
- const ta = el("textarea", { className: "pastebox" });
470
- ta.rows = 12;
471
- const save = el("button", { className: "btn primary", textContent: "Save and commit" });
472
- const out = el("div");
473
- box.append(ta, el("div", { className: "row", style: "margin-top:9px" }, [save]), out);
474
-
475
- let before = "";
476
- save.disabled = true;
477
- // Not getFile: an absent file answers 404 with a message, and that is not what to edit.
478
- fetch(fileUrl(path), { cache: "no-store" })
479
- .then((r) => (r.ok ? r.text() : ""))
480
- .then((text) => {
481
- before = text;
482
- ta.value = text;
483
- grow(ta);
484
- save.disabled = false;
485
- })
486
- .catch((err) => out.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) })));
487
- ta.addEventListener("input", () => grow(ta));
488
479
 
489
- save.onclick = async () => {
490
- if (ta.value.trim() === before.trim()) {
491
- out.replaceChildren(el("p", { className: "sub", textContent: "Nothing changed yet." }));
492
- return;
493
- }
494
- save.disabled = true;
495
- save.textContent = "Saving…";
496
- try {
497
- const r = await saveFile(path, ta.value, "portal: write org/priorities.md");
498
- before = ta.value;
499
- out.replaceChildren(
500
- el("p", {
501
- className: r.pushed ? "sub" : "err",
502
- textContent: r.pushed
503
- ? "Committed and pushed. Every daily run reads it from the next one."
504
- : "Committed, but the push failed: " + (r.note ?? ""),
505
- }),
506
- );
507
- recheck();
508
- } catch (err) {
509
- out.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
510
- } finally {
511
- save.disabled = false;
512
- save.textContent = "Save and commit";
513
- }
514
- };
515
- return box;
516
- }
480
+
481
+
482
+
483
+
517
484
 
518
485
  /** The ops repo's directory name, which is what every workspace-relative path starts with. */
519
486
  function opsName() {
@@ -527,9 +494,8 @@ function opsName() {
527
494
  *
528
495
  * Skipped, every workflow fails with "workflow not found", which reads like a typo in a path.
529
496
  */
530
- function accessStep() {
531
- const box = el("div", { className: "manual" });
532
- box.append(el("b", { textContent: "Let every repo in the org call the ops repo's workflow" }));
497
+ function accessStep(opts = {}) {
498
+ const box = el("div");
533
499
  const out = el("div");
534
500
  box.append(out);
535
501
  const say = (text, cls) => el("p", { className: cls ?? "sub", textContent: text });
@@ -539,8 +505,7 @@ function accessStep() {
539
505
  out.replaceChildren(
540
506
  say(
541
507
  (why ? why + " " : "") +
542
- "Settings → Actions → General → Access on roster-ops. Skip it and every workflow fails " +
543
- "with “workflow not found”.",
508
+ "Roster tried to set this when it created the org, and GitHub didn't allow it.",
544
509
  ),
545
510
  el("div", { className: "row" }, [go]),
546
511
  );
@@ -549,7 +514,8 @@ function accessStep() {
549
514
  try {
550
515
  const r = await setAccess();
551
516
  if (r.ok) {
552
- out.replaceChildren(say("Set. Every repo in the org can call roster-ops."));
517
+ out.replaceChildren(say("Done."));
518
+ opts.onStatus?.(true);
553
519
  return;
554
520
  }
555
521
  out.replaceChildren(
@@ -567,7 +533,8 @@ function accessStep() {
567
533
  out.replaceChildren(say("Checking…"));
568
534
  getAccess()
569
535
  .then((r) => {
570
- if (r.ok) out.replaceChildren(say("Done. Every repo in the org can call roster-ops."));
536
+ opts.onStatus?.(Boolean(r.ok));
537
+ if (r.ok) out.replaceChildren(say("Done."));
571
538
  else offer(r.level ? "It is set to “" + r.level + "”." : "");
572
539
  })
573
540
  .catch(() => offer(""));