@nanocollective/roster 0.1.0-alpha.4 → 0.1.0-alpha.41

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 (97) hide show
  1. package/README.md +70 -84
  2. package/dist/cli.js +4562 -2744
  3. package/docs/README.md +9 -6
  4. package/docs/agents.md +24 -20
  5. package/docs/architecture.md +13 -5
  6. package/docs/charters/analyst.md +65 -0
  7. package/docs/charters/cmo.md +69 -0
  8. package/docs/charters/community.md +63 -0
  9. package/docs/charters/cto.md +71 -0
  10. package/docs/charters/designer.md +65 -0
  11. package/docs/charters/devops.md +65 -0
  12. package/docs/charters/pm.md +70 -0
  13. package/docs/charters/qa.md +65 -0
  14. package/docs/charters/support.md +60 -0
  15. package/docs/charters/writer.md +63 -0
  16. package/docs/commands.md +90 -5
  17. package/docs/concepts.md +48 -14
  18. package/docs/cost.md +36 -1
  19. package/docs/developing.md +16 -21
  20. package/docs/doctor-codes.md +8 -2
  21. package/docs/export.md +2 -0
  22. package/docs/extending.md +2 -2
  23. package/docs/getting-started.md +126 -77
  24. package/docs/images/brain.jpg +0 -0
  25. package/docs/images/org.jpg +0 -0
  26. package/docs/images/prompt.jpg +0 -0
  27. package/docs/images/setup-org.jpg +0 -0
  28. package/docs/images/setup-plan.jpg +0 -0
  29. package/docs/images/staff.jpg +0 -0
  30. package/docs/manual-steps.md +94 -123
  31. package/docs/memory.md +21 -3
  32. package/docs/org-yaml.md +39 -2
  33. package/docs/portal.md +119 -44
  34. package/docs/prompts.md +31 -4
  35. package/docs/security.md +37 -5
  36. package/docs/session-workflow.md +49 -17
  37. package/docs/staff-yaml.md +14 -2
  38. package/docs/troubleshooting.md +8 -8
  39. package/docs/upgrading.md +9 -3
  40. package/docs/writing-a-charter.md +28 -0
  41. package/package.json +18 -20
  42. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +6 -0
  43. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +6 -0
  44. package/templates/brain/CHARTER.md +3 -3
  45. package/templates/brain/README.md +1 -0
  46. package/templates/brain/log/decisions.md +3 -0
  47. package/templates/brain/strategy/ideas.md +7 -0
  48. package/templates/briefs/priorities.md +46 -0
  49. package/templates/ops/.github/workflows/session.yaml +108 -14
  50. package/templates/ops/agents.mjs +7 -3
  51. package/templates/ops/compose.mjs +16 -3
  52. package/templates/ops/inflight.mjs +157 -0
  53. package/templates/ops/org/operating.md +21 -1
  54. package/templates/ops/org/voice.md +9 -0
  55. package/templates/ops/prompts/_inflight.md +14 -0
  56. package/templates/ops/prompts/_paths.md +2 -1
  57. package/templates/ops/prompts/daily.md +16 -7
  58. package/templates/ops/prompts/mention.md +2 -0
  59. package/templates/ops/run-record.mjs +144 -0
  60. package/templates/portal/css/base.css +146 -73
  61. package/templates/portal/css/brain.css +23 -20
  62. package/templates/portal/css/diff.css +10 -9
  63. package/templates/portal/css/graph.css +12 -7
  64. package/templates/portal/css/health.css +13 -11
  65. package/templates/portal/css/inbox.css +57 -25
  66. package/templates/portal/css/layout.css +96 -41
  67. package/templates/portal/css/markdown.css +36 -14
  68. package/templates/portal/css/runs.css +13 -0
  69. package/templates/portal/css/setup.css +116 -34
  70. package/templates/portal/index.html +18 -2
  71. package/templates/portal/js/api.js +41 -4
  72. package/templates/portal/js/app.js +132 -9
  73. package/templates/portal/js/dialog.js +82 -0
  74. package/templates/portal/js/icons.js +37 -0
  75. package/templates/portal/js/inflight.js +18 -0
  76. package/templates/portal/js/md.js +5 -2
  77. package/templates/portal/js/mdedit.js +84 -0
  78. package/templates/portal/js/readiness.js +35 -0
  79. package/templates/portal/js/refresh.js +2 -1
  80. package/templates/portal/js/state.js +17 -4
  81. package/templates/portal/js/views/app.js +24 -7
  82. package/templates/portal/js/views/checklist.js +10 -4
  83. package/templates/portal/js/views/credential.js +84 -0
  84. package/templates/portal/js/views/graph.js +1 -1
  85. package/templates/portal/js/views/health.js +17 -4
  86. package/templates/portal/js/views/hire.js +583 -0
  87. package/templates/portal/js/views/inbox.js +264 -84
  88. package/templates/portal/js/views/org.js +46 -106
  89. package/templates/portal/js/views/orgedit.js +234 -0
  90. package/templates/portal/js/views/paste.js +87 -21
  91. package/templates/portal/js/views/prompt.js +11 -4
  92. package/templates/portal/js/views/repos.js +20 -15
  93. package/templates/portal/js/views/runonce.js +94 -0
  94. package/templates/portal/js/views/runs.js +170 -0
  95. package/templates/portal/js/views/setup.js +257 -75
  96. package/templates/portal/js/views/staff.js +158 -243
  97. package/templates/portal/js/views/todo.js +62 -0
@@ -5,19 +5,114 @@
5
5
  * is rather than as it was left. Setup cannot be finished in one sitting, so it must survive
6
6
  * being abandoned halfway. */
7
7
 
8
- import { checkOrg, createTenant, getSetup, joinOrg, planTenant } from "../api.js";
8
+ import {
9
+ checkOrg,
10
+ createTenant,
11
+ getAccess,
12
+ getOrg,
13
+ getSetup,
14
+ joinOrg,
15
+ planTenant,
16
+ setAccess,
17
+ } from "../api.js";
9
18
  import { $, el, esc, toClipboard } from "../dom.js";
19
+ import { go } from "../router.js";
20
+ import { S as App } from "../state.js";
21
+ import { checkAll, notReady, sentence } from "../readiness.js";
10
22
  import { checklist } from "./checklist.js";
23
+ import { businessForm, prioritiesForm } from "./orgedit.js";
24
+ import { credentialPanel } from "./credential.js";
11
25
  import { repoPicker } from "./repos.js";
12
- import { paste } from "./paste.js";
26
+ import { todo } from "./todo.js";
13
27
 
14
28
  let S = null; // /api/setup/status, refreshed after anything that changes the world
15
29
 
30
+ /* Where the doctor checklist is drawn on this screen, so a save can re-run it. Left stale, it
31
+ went on saying business.stub after business.md had been saved, until "Check again". */
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 };
39
+
40
+ /* Each "what is left" step that is a file, by id, so a save can mark it done in place rather
41
+ than repainting the page and throwing away the diff somebody is still reading. */
42
+ const fileSteps = new Map();
43
+
16
44
  export async function viewSetup(main) {
17
45
  S = await getSetup();
18
46
  render(main);
19
47
  }
20
48
 
49
+ /**
50
+ * The same steps once a tenant exists, as their own screen in the portal.
51
+ *
52
+ * Setup used to be reachable only before there was a tenant, so the reload that followed
53
+ * creating one landed on an empty Inbox with the repo picker, the credential and both files
54
+ * gone. The sidebar offers this while anything is unfinished, and an org nobody has been hired
55
+ * into opens on it.
56
+ */
57
+ export async function viewGettingStarted(main) {
58
+ main.append(el("h1", { textContent: "Getting started" }));
59
+ const sub = el("p", { className: "sub", textContent: "Reading what is left…" });
60
+ main.append(sub);
61
+ S = await getSetup();
62
+ // Somebody may have clicked elsewhere while GitHub was answering.
63
+ if (App.view !== "setup") return;
64
+ await checkAll();
65
+ if (App.view !== "setup") return;
66
+ sub.textContent = "Work through these in order.";
67
+ const list = afterCreate();
68
+
69
+ // Somebody hired but not ready to run is the most important thing left, so it comes first.
70
+ for (const s of notReady().reverse()) {
71
+ const t = todo("!", "Finish setting up " + s.name, false);
72
+ t.hint("Still to do: " + sentence(App.readiness?.[s.handle] ?? []) + ".");
73
+ const cont = el("button", { className: "btn primary", textContent: "Continue" });
74
+ cont.onclick = () => {
75
+ App.staffOpen = { handle: s.handle, name: s.name, dir: s.dir };
76
+ go({ view: "staff" });
77
+ };
78
+ t.body.append(el("div", { className: "row" }, [cont]));
79
+ list.prepend(t.card);
80
+ }
81
+ main.append(list);
82
+
83
+ const health = step("!", "Other problems", false);
84
+ healthHost = el("div", { style: "margin-top:12px" });
85
+ health.append(healthHost);
86
+ main.append(health);
87
+ healthStep = health;
88
+ checklist(healthHost, { ...HEALTH, onEmpty: () => health.remove() });
89
+ }
90
+
91
+ /** Whether the sidebar offers Getting started: while anything is left, or while it is open. */
92
+ export function paintSetupNav() {
93
+ const nav = $("#setupnav");
94
+ if (!nav) return;
95
+ nav.hidden = !App.data?.unfinished?.length && !notReady().length && App.view !== "setup";
96
+ }
97
+
98
+ /* After a save: the checklist and the step list are both derived from disk, so both are asked
99
+ again rather than updated by hand. The sidebar's list comes from /api/org, which is the one
100
+ the portal already reads. */
101
+ async function recheck() {
102
+ if (healthHost) checklist(healthHost, { ...HEALTH, onEmpty: () => healthStep?.remove() });
103
+ try {
104
+ S = await getSetup();
105
+ for (const [id, mark] of fileSteps) mark(!(S.tenant.left ?? []).includes(id));
106
+ } catch {
107
+ // The saved file is saved either way; a stale tick is not worth an error on top of it.
108
+ }
109
+ if (App.data) {
110
+ const fresh = await getOrg().catch(() => null);
111
+ if (fresh?.unfinished) App.data.unfinished = fresh.unfinished;
112
+ paintSetupNav();
113
+ }
114
+ }
115
+
21
116
  function render(main) {
22
117
  /* The sidebar is written by boot() before any of this is known. Once a tenant has been
23
118
  adopted, leaving it on "no org yet" contradicts the card directly below it. */
@@ -30,8 +125,7 @@ function render(main) {
30
125
  el("p", {
31
126
  className: "sub",
32
127
  textContent:
33
- "Four things here, then two that GitHub insists a human does. Nothing is created until " +
34
- "you have read the plan.",
128
+ "Choose an organisation and a coding agent. Nothing is created until you press Create it.",
35
129
  }),
36
130
  );
37
131
 
@@ -41,7 +135,11 @@ function render(main) {
41
135
 
42
136
  /* Drawn whenever a tenant exists, not only in the seconds after creating one. Setup takes
43
137
  days: the repo picker and the two manual steps have to still be here tomorrow. */
44
- if (S.tenant.found) main.append(afterCreate());
138
+ if (S.tenant.found) {
139
+ const rest = step(3, "Finish setting up", false);
140
+ rest.append(afterCreate());
141
+ main.append(rest);
142
+ }
45
143
  }
46
144
 
47
145
  /* ---------------------------------- 1 · gh ---------------------------------- */
@@ -57,8 +155,7 @@ function stepGh() {
57
155
  el("p", {
58
156
  className: "sub",
59
157
  textContent:
60
- "roster does everything through your own gh, so it holds no token of its own. Run this " +
61
- "in a terminal, then reload:",
158
+ "Run this in a terminal, then reload:",
62
159
  }),
63
160
  el("pre", { className: "cmd", textContent: "gh auth login" }),
64
161
  );
@@ -78,12 +175,10 @@ function stepOrg(main) {
78
175
  }),
79
176
  el("p", {
80
177
  className: "sub",
81
- textContent: "Reload the page to leave setup and use the portal.",
178
+ textContent:
179
+ "Finish the steps below. They stay under Getting started in the sidebar until they're done.",
82
180
  }),
83
181
  );
84
- const rows = el("div", { style: "margin-top:12px" });
85
- card.append(rows);
86
- checklist(rows, {});
87
182
  return card;
88
183
  }
89
184
 
@@ -113,8 +208,7 @@ function stepOrg(main) {
113
208
  orgWrap.append(
114
209
  el("small", {
115
210
  textContent:
116
- "Repos are created here. GitHub has no API for creating an organisation, so make one on " +
117
- "github.com first if you need to.",
211
+ "Don't have one? Create it on github.com first.",
118
212
  }),
119
213
  );
120
214
  form.append(orgWrap);
@@ -157,8 +251,8 @@ function stepOrg(main) {
157
251
  });
158
252
  other.input.addEventListener("change", look);
159
253
 
160
- const name = field("name", "What the business is called", "", "Shown to the agents. Defaults to the org.");
161
- const human = field("human", "Your GitHub login", S.gh.login ?? "", "The person the agents answer to.");
254
+ const name = field("name", "What the business is called", "", "Defaults to the organisation name.");
255
+ const human = field("human", "Your GitHub login", S.gh.login ?? "", "The person the staff report to.");
162
256
 
163
257
  card.append(form);
164
258
  const agentHead = el("h3", { textContent: "Which coding agent runs a session" });
@@ -171,7 +265,7 @@ function stepOrg(main) {
171
265
  const opt = el("label", { className: "choice" });
172
266
  const radio = el("input", { name: "agent", value: a.id, checked: i === 0 });
173
267
  radio.setAttribute("type", "radio");
174
- opt.append(radio, el("b", { textContent: a.label }), el("small", { textContent: a.note }));
268
+ opt.append(radio, el("b", { textContent: a.label }));
175
269
  opt.append(el("code", { textContent: a.tokenEnv }));
176
270
  agents.append(opt);
177
271
  });
@@ -179,8 +273,7 @@ function stepOrg(main) {
179
273
  const agentNote = el("p", {
180
274
  className: "sub",
181
275
  textContent:
182
- "Anything else works too: a runner is an install command, a run command and the name of " +
183
- "the secret holding its credential. Write those three into org.yaml afterwards.",
276
+ "Using a different agent? Pick any of these, then set it in org.yaml afterwards.",
184
277
  });
185
278
  card.append(agentNote);
186
279
 
@@ -256,23 +349,20 @@ function stepOrg(main) {
256
349
  out.replaceChildren(el("p", { className: "sub", textContent: "Working…" }));
257
350
  try {
258
351
  const result = await planTenant(p);
259
- out.replaceChildren();
260
- out.append(
261
- el("p", {
262
- textContent: `${result.files.length} files in ${result.dir}, and one private repo, ${p.org}/roster-ops.`,
263
- }),
264
- );
265
- const list = el("div", { className: "filelist" });
266
- for (const f of result.files) list.append(el("code", { textContent: "+ " + f }));
267
- out.append(list);
268
- out.append(
269
- el("p", {
270
- className: "sub",
271
- textContent:
272
- "org/business.md arrives as questions, not prose. Answering it is the next step and " +
273
- "it is the one that decides whether any of this is worth running.",
274
- }),
275
- );
352
+ const steps = el("ol", { className: "plansteps" }, [
353
+ el("li", { textContent: `Create a private repo, ${p.org}/roster-ops, to hold the org's shared settings.` }),
354
+ el("li", { textContent: `Put a copy of it in ${result.dir}.` }),
355
+ el("li", { textContent: `Let the other repos in ${p.org} run its workflow.` }),
356
+ ]);
357
+ const files = el("details", { className: "planfiles" }, [
358
+ el("summary", { textContent: `The ${result.files.length} files it writes` }),
359
+ el("div", { className: "filelist" }, result.files.map((f) => el("code", { textContent: f }))),
360
+ ]);
361
+ const next = el("p", {
362
+ className: "sub",
363
+ textContent: "After that: describe the business, set this month's priorities, and hire your first staff member.",
364
+ });
365
+ out.replaceChildren(el("p", { textContent: "Create it will:" }), steps, files, next);
276
366
  go.hidden = false;
277
367
  } catch (err) {
278
368
  out.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
@@ -303,53 +393,145 @@ function stepOrg(main) {
303
393
  /* ------------------------- 5 · the two GitHub insists on ------------------------- */
304
394
 
305
395
  function afterCreate() {
306
- const card = step(3, "What is left", false);
307
- card.append(
308
- el("p", {
309
- textContent:
310
- "None of these can be done for you, and the first fails in a way that wastes an " +
311
- "afternoon if you skip it.",
312
- }),
313
- );
314
-
315
- const one = el("div", { className: "manual" });
316
- one.append(
317
- el("b", { textContent: "Let the ops repo's workflow be called" }),
318
- el("p", {
319
- textContent:
320
- "Settings → Actions → General → Access → “Accessible from repositories in the " +
321
- "organisation”, on roster-ops.",
322
- }),
323
- el("small", {
324
- textContent:
325
- "Skip it and every workflow fails with “workflow not found”, which reads like a typo in " +
326
- "a path and is not one. It is an org permission on a repo, so it is yours to click.",
327
- }),
328
- );
329
- if (S.tenant.org) {
330
- const url = `https://github.com/${S.tenant.org}/roster-ops/settings/actions`;
331
- one.append(el("a", { className: "btn", href: url, target: "_blank", textContent: "Open that page" }));
332
- }
333
- card.append(one);
396
+ fileSteps.clear();
397
+ const list = el("div", { className: "todos" });
398
+ const left = S.tenant.left ?? [];
399
+ const staffCount = App.data?.staff?.length ?? 0;
400
+ let n = 0;
334
401
 
335
402
  if (S.tenant.org) {
336
- card.append(repoPicker({ org: S.tenant.org, known: S.tenant.repos ?? [] }));
403
+ const repos = todo(++n, "Choose the repos your staff work on", (S.tenant.products ?? []).length > 0);
404
+ repos.hint("Pick at least one. Staff open pull requests there, and you review them.");
405
+ repos.body.append(
406
+ repoPicker({ org: S.tenant.org, known: S.tenant.repos ?? [], bare: true, onAdded: () => repos.setDone(true) }),
407
+ );
408
+ list.append(repos.card);
337
409
  }
338
410
 
339
- const two = el("div", { className: "manual" });
340
- two.append(
341
- el("b", { textContent: "Answer org/business.md" }),
342
- el("p", {
343
- textContent:
344
- "It ships as questions. It is composed into the top of every prompt, every run, and an " +
345
- "agent that cannot answer them writes work that is plausible and generic.",
411
+ const business = todo(++n, "Describe the business", !left.includes("business"));
412
+ business.hint("A few short answers. Every staff member reads them before they start work.");
413
+ business.body.append(
414
+ businessForm({
415
+ path: opsName() + "/org/business.md",
416
+ name: App.data?.name ?? S.tenant.name ?? S.tenant.org,
417
+ onSaved: () => (business.setDone(true), recheck()),
346
418
  }),
347
419
  );
348
- card.append(two);
420
+ fileSteps.set("business", business.setDone);
421
+ list.append(business.card);
422
+
423
+ const priorities = todo(++n, "Set this month's priorities", !left.includes("priorities"));
424
+ priorities.hint("Up to three, in order. Staff pick work that serves them.");
425
+ priorities.body.append(
426
+ prioritiesForm({
427
+ path: opsName() + "/org/priorities.md",
428
+ onSaved: () => (priorities.setDone(true), recheck()),
429
+ }),
430
+ );
431
+ fileSteps.set("priorities", priorities.setDone);
432
+ list.append(priorities.card);
433
+
434
+ const hire = todo(++n, "Hire your first staff member", staffCount > 0);
435
+ hire.hint("Pick a role. The Staff screen then lists each step to set them up.");
436
+ const hireBtn = el("button", { className: "btn primary", textContent: "Hire someone" });
437
+ hireBtn.onclick = () => {
438
+ // Before the org has loaded, this screen is the whole app, so the Staff screen needs a reload.
439
+ if (App.data) go({ view: "staff" });
440
+ else location.assign("/#/-/staff") || location.reload();
441
+ };
442
+ hire.body.append(el("div", { className: "row" }, [hireBtn]));
443
+ list.append(hire.card);
349
444
 
350
- // The copy-a-prompt loop, which is the whole answer to "how do I write this file".
351
- card.append(paste({ kind: "discover", title: "Write it with your own AI" }));
352
- return card;
445
+ const cred = todo(++n, "Add your agent credential", false);
446
+ cred.hint(staffCount ? "Staff use it to run. You only add it once." : "Do this after your first hire.");
447
+ cred.body.append(credentialPanel({ bare: true, onStatus: (ok) => cred.setDone(ok) }));
448
+ list.append(cred.card);
449
+
450
+ const access = todo(++n, "Let staff repos use the shared workflow", false);
451
+ access.body.append(accessStep({ onStatus: (ok) => access.setDone(ok) }));
452
+ list.append(access.card);
453
+
454
+ return list;
455
+ }
456
+
457
+ /**
458
+ * One of the files only a person can write, with whether it is written yet.
459
+ *
460
+ * Read from the status rather than from the click that saved it, so a file written in an
461
+ * editor, or by a coding agent, shows as done here too.
462
+ */
463
+
464
+ /**
465
+ * org/priorities.md, edited in place.
466
+ *
467
+ * There is no brief for it, and it does not want one: business.md needs an interview because
468
+ * nobody can write it off the top of their head, while a ranked list of three things is
469
+ * quicker to type than to explain to a model. So the file opens as it is on disk, stub and
470
+ * all, and saving it is the same commit-and-push as every other editor here.
471
+ */
472
+
473
+
474
+
475
+
476
+
477
+
478
+ /** The ops repo's directory name, which is what every workspace-relative path starts with. */
479
+ function opsName() {
480
+ return App.data?.opsName ?? String(S.tenant.opsDir ?? "roster-ops").split("/").pop();
481
+ }
482
+
483
+ /**
484
+ * The ops repo's Actions access. Read on arrival, so a page reloaded after it was set says it
485
+ * is done without anybody pressing anything; the button asks the server to set it, and a
486
+ * refusal comes back with GitHub's reason and the page to click instead.
487
+ *
488
+ * Skipped, every workflow fails with "workflow not found", which reads like a typo in a path.
489
+ */
490
+ function accessStep(opts = {}) {
491
+ const box = el("div");
492
+ const out = el("div");
493
+ box.append(out);
494
+ const say = (text, cls) => el("p", { className: cls ?? "sub", textContent: text });
495
+
496
+ const offer = (why) => {
497
+ const go = el("button", { className: "btn primary", textContent: "Set it for me" });
498
+ out.replaceChildren(
499
+ say(
500
+ (why ? why + " " : "") +
501
+ "Roster tried to set this when it created the org, and GitHub didn't allow it.",
502
+ ),
503
+ el("div", { className: "row" }, [go]),
504
+ );
505
+ go.onclick = async () => {
506
+ go.disabled = true;
507
+ try {
508
+ const r = await setAccess();
509
+ if (r.ok) {
510
+ out.replaceChildren(say("Done."));
511
+ opts.onStatus?.(true);
512
+ return;
513
+ }
514
+ out.replaceChildren(
515
+ say("GitHub refused: " + r.error + ".", "err"),
516
+ el("a", { className: "btn", href: r.link, target: "_blank", textContent: "Set it by hand" }),
517
+ say("Access → “Accessible from repositories in the organisation”."),
518
+ );
519
+ } catch (err) {
520
+ out.replaceChildren(say(String(err.message || err), "err"));
521
+ go.disabled = false;
522
+ }
523
+ };
524
+ };
525
+
526
+ out.replaceChildren(say("Checking…"));
527
+ getAccess()
528
+ .then((r) => {
529
+ opts.onStatus?.(Boolean(r.ok));
530
+ if (r.ok) out.replaceChildren(say("Done."));
531
+ else offer(r.level ? "It is set to “" + r.level + "”." : "");
532
+ })
533
+ .catch(() => offer(""));
534
+ return box;
353
535
  }
354
536
 
355
537
  /* ---------------------------------- furniture ---------------------------------- */