@nanocollective/roster 0.1.0-beta.3 → 0.1.0-beta.31

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 (147) hide show
  1. package/README.md +8 -0
  2. package/dist/agents-POITEZRI.js +232 -0
  3. package/dist/chunk-FF2WBNNW.js +370 -0
  4. package/dist/chunk-GDAJPOHK.js +562 -0
  5. package/dist/cli.js +3391 -1239
  6. package/dist/compose-5DBEHSEV.js +17 -0
  7. package/dist/connectors-5E5ZMGZV.js +23 -0
  8. package/dist/worker/assets/assets/css/astryx.css +948 -0
  9. package/dist/worker/assets/assets/css/base.css +51 -110
  10. package/dist/worker/assets/assets/css/brain.css +28 -2
  11. package/dist/worker/assets/assets/css/connectors.css +58 -0
  12. package/dist/worker/assets/assets/css/graph.css +9 -12
  13. package/dist/worker/assets/assets/css/health.css +4 -7
  14. package/dist/worker/assets/assets/css/home.css +155 -60
  15. package/dist/worker/assets/assets/css/inbox.css +11 -0
  16. package/dist/worker/assets/assets/css/layout.css +18 -22
  17. package/dist/worker/assets/assets/css/markdown.css +22 -1
  18. package/dist/worker/assets/assets/css/routines.css +43 -0
  19. package/dist/worker/assets/assets/css/runs.css +5 -3
  20. package/dist/worker/assets/assets/css/search.css +3 -6
  21. package/dist/worker/assets/assets/css/setup.css +8 -15
  22. package/dist/worker/assets/assets/js/api.js +3 -0
  23. package/dist/worker/assets/assets/js/app.js +28 -1
  24. package/dist/worker/assets/assets/js/astryx-ui.js +34 -0
  25. package/dist/worker/assets/assets/js/dom.js +1 -1
  26. package/dist/worker/assets/assets/js/homesort.js +66 -20
  27. package/dist/worker/assets/assets/js/icons.js +6 -0
  28. package/dist/worker/assets/assets/js/md.js +7 -2
  29. package/dist/worker/assets/assets/js/mention.js +2 -1
  30. package/dist/worker/assets/assets/js/readiness.js +36 -0
  31. package/dist/worker/assets/assets/js/refcard.js +216 -0
  32. package/dist/worker/assets/assets/js/refresh.js +8 -2
  33. package/dist/worker/assets/assets/js/report.js +51 -0
  34. package/dist/worker/assets/assets/js/select.js +362 -0
  35. package/dist/worker/assets/assets/js/state.js +14 -1
  36. package/dist/worker/assets/assets/js/views/connectors.js +428 -0
  37. package/dist/worker/assets/assets/js/views/graph.js +67 -28
  38. package/dist/worker/assets/assets/js/views/health.js +11 -5
  39. package/dist/worker/assets/assets/js/views/home.js +453 -174
  40. package/dist/worker/assets/assets/js/views/inbox.js +82 -17
  41. package/dist/worker/assets/assets/js/views/notready.js +60 -0
  42. package/dist/worker/assets/assets/js/views/org.js +16 -1
  43. package/dist/worker/assets/assets/js/views/people.js +109 -0
  44. package/dist/worker/assets/assets/js/views/routines.js +395 -0
  45. package/dist/worker/assets/assets/js/views/runonce.js +5 -0
  46. package/dist/worker/assets/assets/js/views/runs.js +14 -2
  47. package/dist/worker/assets/assets/js/views/staff.js +18 -3
  48. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  49. package/dist/worker/assets/docs-images/home.jpg +0 -0
  50. package/dist/worker/assets/docs-images/org.jpg +0 -0
  51. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  52. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  53. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  54. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  55. package/dist/worker/assets/index.html +19 -3
  56. package/dist/worker/index.js +4478 -1098
  57. package/docs/README.md +2 -0
  58. package/docs/architecture.md +23 -4
  59. package/docs/commands.md +111 -9
  60. package/docs/concepts.md +2 -1
  61. package/docs/connectors.md +169 -0
  62. package/docs/cost.md +1 -1
  63. package/docs/developing.md +3 -3
  64. package/docs/doctor-codes.md +8 -2
  65. package/docs/export.md +4 -3
  66. package/docs/extending.md +1 -1
  67. package/docs/getting-started.md +20 -3
  68. package/docs/hosting.md +67 -3
  69. package/docs/images/brain.jpg +0 -0
  70. package/docs/images/home.jpg +0 -0
  71. package/docs/images/org.jpg +0 -0
  72. package/docs/images/prompt.jpg +0 -0
  73. package/docs/images/setup-org.jpg +0 -0
  74. package/docs/images/setup-plan.jpg +0 -0
  75. package/docs/images/staff.jpg +0 -0
  76. package/docs/memory.md +3 -2
  77. package/docs/org-yaml.md +58 -5
  78. package/docs/portal.md +52 -11
  79. package/docs/prompts.md +3 -2
  80. package/docs/routines.md +65 -0
  81. package/docs/security.md +37 -4
  82. package/docs/session-workflow.md +31 -8
  83. package/docs/staff-yaml.md +7 -3
  84. package/docs/troubleshooting.md +1 -1
  85. package/docs/upgrading.md +1 -1
  86. package/docs/writing-a-charter.md +1 -1
  87. package/package.json +8 -1
  88. package/templates/brain/.gitattributes +3 -0
  89. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +24 -15
  90. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +12 -10
  91. package/templates/brain/CHARTER.md +2 -2
  92. package/templates/brain/STATE.md +16 -0
  93. package/templates/brain/memory/INDEX.md +1 -1
  94. package/templates/brain/staff.yaml +3 -0
  95. package/templates/ops/.gitattributes +3 -0
  96. package/templates/ops/.github/workflows/session.yaml +92 -13
  97. package/templates/ops/agents.mjs +38 -11
  98. package/templates/ops/compose.mjs +60 -2
  99. package/templates/ops/connectors.mjs +722 -0
  100. package/templates/ops/org/operating.md +10 -0
  101. package/templates/ops/org/voice.md +21 -3
  102. package/templates/ops/prompts/_identity.md +20 -0
  103. package/templates/ops/prompts/daily.md +70 -19
  104. package/templates/ops/prompts/mention.md +7 -2
  105. package/templates/ops/status-week.mjs +169 -0
  106. package/templates/portal/css/astryx.css +948 -0
  107. package/templates/portal/css/base.css +51 -110
  108. package/templates/portal/css/brain.css +28 -2
  109. package/templates/portal/css/connectors.css +58 -0
  110. package/templates/portal/css/graph.css +9 -12
  111. package/templates/portal/css/health.css +4 -7
  112. package/templates/portal/css/home.css +155 -60
  113. package/templates/portal/css/inbox.css +11 -0
  114. package/templates/portal/css/layout.css +18 -22
  115. package/templates/portal/css/markdown.css +22 -1
  116. package/templates/portal/css/routines.css +43 -0
  117. package/templates/portal/css/runs.css +5 -3
  118. package/templates/portal/css/search.css +3 -6
  119. package/templates/portal/css/setup.css +8 -15
  120. package/templates/portal/index.html +19 -3
  121. package/templates/portal/js/api.js +3 -0
  122. package/templates/portal/js/app.js +28 -1
  123. package/templates/portal/js/astryx-ui.js +34 -0
  124. package/templates/portal/js/dom.js +1 -1
  125. package/templates/portal/js/homesort.js +66 -20
  126. package/templates/portal/js/icons.js +6 -0
  127. package/templates/portal/js/md.js +7 -2
  128. package/templates/portal/js/mention.js +2 -1
  129. package/templates/portal/js/readiness.js +36 -0
  130. package/templates/portal/js/refcard.js +216 -0
  131. package/templates/portal/js/refresh.js +8 -2
  132. package/templates/portal/js/report.js +51 -0
  133. package/templates/portal/js/select.js +362 -0
  134. package/templates/portal/js/state.js +14 -1
  135. package/templates/portal/js/views/connectors.js +428 -0
  136. package/templates/portal/js/views/graph.js +67 -28
  137. package/templates/portal/js/views/health.js +11 -5
  138. package/templates/portal/js/views/home.js +453 -174
  139. package/templates/portal/js/views/inbox.js +82 -17
  140. package/templates/portal/js/views/notready.js +60 -0
  141. package/templates/portal/js/views/org.js +16 -1
  142. package/templates/portal/js/views/people.js +109 -0
  143. package/templates/portal/js/views/routines.js +395 -0
  144. package/templates/portal/js/views/runonce.js +5 -0
  145. package/templates/portal/js/views/runs.js +14 -2
  146. package/templates/portal/js/views/staff.js +18 -3
  147. package/templates/skill/SKILL.md +115 -0
@@ -6,6 +6,7 @@ import { ago, el, esc, markCurrent, skeleton } from "../dom.js";
6
6
  import { icon, iconHTML, staffIcon } from "../icons.js";
7
7
  import { mdlite } from "../md.js";
8
8
  import { attachMentions } from "../mention.js";
9
+ import { canRun } from "../readiness.js";
9
10
  import { ensureInbox, refreshAll, stampCounts } from "../refresh.js";
10
11
  import { humanLabel, humansOf, isHuman, S, writeHash } from "../state.js";
11
12
  import { renderDiff } from "./changed.js";
@@ -26,7 +27,7 @@ const LABEL_TONE = {
26
27
  * which coloured exactly one org's and left every other org's looking like an ordinary tag.
27
28
  * It comes off org.yaml now, so it is right wherever this runs.
28
29
  */
29
- function tone(label) {
30
+ export function tone(label) {
30
31
  if (LABEL_TONE[label]) return LABEL_TONE[label];
31
32
  const name = String(label).toLowerCase();
32
33
  return humansOf().some(
@@ -93,8 +94,11 @@ export function belongsTo(item, s) {
93
94
  }
94
95
 
95
96
  /* Threads read so far, by repo#number, kept for the session. Each is reused while its
96
- updatedAt matches the list's, so a thread is fetched again only when it has changed. */
97
+ updatedAt matches the list's, so a thread is fetched again only when it has changed, or once
98
+ the signed links to its images (good for five minutes) are about to run out. */
97
99
  const THREADS = new Map();
100
+ const THREAD_AT = new Map();
101
+ const THREAD_FRESH = 4 * 60_000;
98
102
 
99
103
  export const viewInbox = (m) => inboxScreen(m, {});
100
104
 
@@ -125,7 +129,13 @@ export function threadInto(host, ref) {
125
129
  THREADS.delete(item.repo + "#" + item.number);
126
130
  item.partial = true;
127
131
  }
128
- host.append(inboxScreen(el("div"), { prs: ref.kind === "pr", only: ref }));
132
+ /* A #175 in a report is as likely to be closed, or in a repo nobody watches, as it is to be
133
+ in the inbox. It is read on its own and kept beside the inbox rather than added to it,
134
+ where it would turn up as a row on Trackers. */
135
+ const stray = item
136
+ ? null
137
+ : { repo: ref.repo, number: ref.number, kind: ref.kind ?? "issue", labels: [], partial: true };
138
+ host.append(inboxScreen(el("div"), { prs: ref.kind === "pr", only: ref, stray }));
129
139
  }
130
140
 
131
141
  function inboxScreen(m, opts) {
@@ -333,7 +343,13 @@ function inboxScreen(m, opts) {
333
343
  String(b.updatedAt).localeCompare(String(a.updatedAt)),
334
344
  );
335
345
  if (!items.length) {
336
- list.append(el("p", { className: "empty", textContent: "Nothing matches." }));
346
+ // With nobody hired there is nothing to match yet, and that is setup, not a filter.
347
+ list.append(
348
+ el("p", {
349
+ className: "empty",
350
+ textContent: S.data.staff.length ? "Nothing matches." : "Nothing here yet: nobody is hired. Home says what setup has left.",
351
+ }),
352
+ );
337
353
  return;
338
354
  }
339
355
 
@@ -385,11 +401,14 @@ function inboxScreen(m, opts) {
385
401
  }
386
402
  }
387
403
 
404
+ function find(ref) {
405
+ const same = (i) => i.repo === ref.repo && i.number === ref.number;
406
+ return (S.inbox?.items ?? []).find(same) ?? (opts.stray && same(opts.stray) ? opts.stray : null);
407
+ }
408
+
388
409
  /* Everything is already loaded, so opening a thread is a render, not a request. */
389
410
  function openThread(ref) {
390
- const item = (S.inbox?.items ?? []).find(
391
- (i) => i.repo === ref.repo && i.number === ref.number,
392
- );
411
+ const item = find(ref);
393
412
  if (!item) {
394
413
  viewer.replaceChildren(
395
414
  el("p", { className: "empty", textContent: "That one is no longer open. Refresh." }),
@@ -414,7 +433,7 @@ function inboxScreen(m, opts) {
414
433
  const key = item.repo + "#" + item.number;
415
434
  const kept = THREADS.get(key);
416
435
  const keep = { role: item.role, unread: item.unread };
417
- if (kept && kept.updatedAt === item.updatedAt) {
436
+ if (kept && kept.updatedAt === item.updatedAt && Date.now() - (THREAD_AT.get(key) ?? 0) < THREAD_FRESH) {
418
437
  Object.assign(item, kept, keep, { partial: false });
419
438
  } else {
420
439
  viewer.dataset.want = key;
@@ -423,6 +442,7 @@ function inboxScreen(m, opts) {
423
442
  .then((fresh) => {
424
443
  if (!fresh || fresh.error) throw new Error(fresh?.error ?? "could not read it");
425
444
  THREADS.set(key, fresh);
445
+ THREAD_AT.set(key, Date.now());
426
446
  Object.assign(item, fresh, keep, { partial: false });
427
447
  })
428
448
  .catch((e) => {
@@ -481,7 +501,22 @@ function inboxScreen(m, opts) {
481
501
  just happened. The title and the actions are in the header, so nothing you need is
482
502
  further down than the first screenful. */
483
503
  const from = pane.children.length;
484
- for (const node of timeline(item, openThread)) pane.append(node);
504
+ const nodes = timeline(item, openThread);
505
+ /* The newest message is what you came for, so it is marked and everything between it and
506
+ the opening post folds behind one button. What happened after it (closed, relabelled)
507
+ stays in view above it, and the opening post stays at the bottom, since it says what
508
+ was asked in the first place. */
509
+ const latest = nodes.findIndex((n) => n.classList?.contains("cmt"));
510
+ if (latest >= 0) {
511
+ nodes[latest].classList.add("latest");
512
+ nodes[latest].querySelector?.(".cwhen")?.before?.(el("span", { className: "pill clatest", textContent: "Latest" }));
513
+ const older = nodes.slice(latest + 1);
514
+ const said = older.filter((n) => n.classList?.contains("cmt")).length;
515
+ if (said) {
516
+ nodes.splice(latest + 1, older.length, earlier(older, said));
517
+ }
518
+ }
519
+ for (const node of nodes) pane.append(node);
485
520
  pane.append(
486
521
  comment({
487
522
  author: item.author, when: item.createdAt, body: item.body, first: true,
@@ -724,9 +759,11 @@ function inboxScreen(m, opts) {
724
759
  };
725
760
  buttons.push(reply);
726
761
 
762
+ /* Closing, in words a person uses: "close" read as shutting the panel. Light red and over
763
+ by Open in GitHub, away from Reply, so it is not pressed on the way to answering. */
727
764
  const closeBtn = el("button", {
728
- className: "ghbtn",
729
- textContent: item.state === "OPEN" ? "Close" : "Reopen",
765
+ className: "ghbtn" + (item.state === "OPEN" ? " danger" : ""),
766
+ textContent: item.state === "OPEN" ? "Mark as completed" : "Reopen",
730
767
  });
731
768
  closeBtn.onclick = async () => {
732
769
  const closing = item.state === "OPEN";
@@ -735,9 +772,9 @@ function inboxScreen(m, opts) {
735
772
  // Closing is the one thing here that is awkward to undo from a phone later, so it asks
736
773
  // — and since it is asking anyway, it takes a parting comment.
737
774
  body = await compose({
738
- title: "Close " + item.repo + " #" + item.number + "?",
739
- hint: "Anything you write here is posted as a comment first. Leave it empty to just close.",
740
- confirm: "Close it",
775
+ title: "Are you sure you want to mark #" + item.number + " as completed?",
776
+ hint: "This closes it. Anything you write here is posted as a comment first.",
777
+ confirm: "Mark as completed",
741
778
  allowEmpty: true,
742
779
  });
743
780
  if (body === null) return;
@@ -767,9 +804,8 @@ function inboxScreen(m, opts) {
767
804
  openThread({ repo: item.repo, number: item.number, kind: item.kind });
768
805
  } catch (e) { failed(e); }
769
806
  };
770
- buttons.push(closeBtn);
771
-
772
807
  const row = el("div", { className: "row tacts" }, buttons);
808
+ buttons.push(closeBtn);
773
809
 
774
810
  /* Merging cannot be undone with another click, so it asks first and names what it is about
775
811
  to merge. It does not ask *how*: squash, merge commit or rebase is a question about git
@@ -824,9 +860,11 @@ function inboxScreen(m, opts) {
824
860
  row.append(status);
825
861
  // Last, and pushed to the far end: it is the way out of this screen rather than one of the
826
862
  // things you do on it. Same shape as the rest, so the row reads as one set of controls.
863
+ closeBtn.classList.add("out");
827
864
  row.append(
865
+ closeBtn,
828
866
  el("a", {
829
- className: "ghbtn out",
867
+ className: "ghbtn",
830
868
  href: item.url,
831
869
  target: "_blank",
832
870
  rel: "noopener",
@@ -847,8 +885,11 @@ function inboxScreen(m, opts) {
847
885
  if (at >= 0) {
848
886
  const old = S.inbox.items[at];
849
887
  THREADS.set(item.repo + "#" + item.number, fresh);
888
+ THREAD_AT.set(item.repo + "#" + item.number, Date.now());
850
889
  // A single thread does not know which part of the org it is in, or whether it is unread.
851
890
  S.inbox.items[at] = { ...old, ...fresh, role: old.role, unread: old.unread, partial: false };
891
+ } else if (opts.stray && find(item) === opts.stray) {
892
+ Object.assign(opts.stray, fresh, { partial: false });
852
893
  }
853
894
  }
854
895
  } catch {
@@ -1058,6 +1099,24 @@ function timeline(item, openThread) {
1058
1099
  return out;
1059
1100
  }
1060
1101
 
1102
+ /** Older messages in a thread, behind one button that shows them all. */
1103
+ function earlier(nodes, said) {
1104
+ const box = el("div", { className: "tearlier" });
1105
+ const btn = el("button", {
1106
+ className: "tearlierbtn",
1107
+ textContent: "Show " + said + " earlier message" + (said === 1 ? "" : "s"),
1108
+ });
1109
+ btn.setAttribute("aria-expanded", "false");
1110
+ const body = el("div", {}, nodes);
1111
+ body.hidden = true;
1112
+ btn.onclick = () => {
1113
+ body.hidden = false;
1114
+ btn.remove();
1115
+ };
1116
+ box.append(btn, body);
1117
+ return box;
1118
+ }
1119
+
1061
1120
  function folded(events, item, openThread) {
1062
1121
  const box = el("div");
1063
1122
  const btn = el("button", { className: "tevmore" });
@@ -1339,6 +1398,12 @@ function newIssueForm(viewer) {
1339
1398
  return;
1340
1399
  }
1341
1400
  create.disabled = false;
1401
+ // The issue is worth filing either way; it waits. What it must not do is promise a reply.
1402
+ if (!canRun(s.handle)) {
1403
+ forWhom.textContent =
1404
+ "Goes to " + s.brain + ". " + s.name + " is not set up yet, so nothing will wake them: it waits for their first run.";
1405
+ return;
1406
+ }
1342
1407
  forWhom.textContent =
1343
1408
  "Goes to " + s.brain + ". " +
1344
1409
  (String(body.value ?? "").includes(mentionOf(s))
@@ -0,0 +1,60 @@
1
+ /* What a screen says about a staff member who cannot run yet.
2
+ *
3
+ * Every screen with a button that wakes somebody (Run now, Run once now, a new issue, a
4
+ * mention) used to offer it to a staff member with no App or no credential, and the run it
5
+ * started failed where nobody was looking. One note, the same everywhere: what is left, and on
6
+ * a hosted portal the command for each step, since setting up is only done on your machine. */
7
+
8
+ import { el, toClipboard } from "../dom.js";
9
+ import { canRun, ROSTER, sentence, stepCommand, whatsLeft } from "../readiness.js";
10
+ import { go } from "../router.js";
11
+ import { S } from "../state.js";
12
+
13
+ /** One roster command, with a Copy button. */
14
+ export function commandLine(cmd) {
15
+ const text = `${ROSTER} ${cmd}`;
16
+ const copy = el("button", { className: "ghbtn", textContent: "Copy" });
17
+ copy.onclick = () => toClipboard(text, copy, "Copy");
18
+ return el("div", { className: "connline" }, [el("code", { textContent: text }), copy]);
19
+ }
20
+
21
+ /** The note, or null when they can run (or it is not known yet). */
22
+ export function notReadyNote(s) {
23
+ if (canRun(s.handle)) return null;
24
+ const left = S.readiness[s.handle];
25
+ const box = el("div", { className: "warnline notready" }, [
26
+ el("span", {
27
+ textContent: `${s.name} is not set up yet, so nothing will start them. Still to do: ${sentence(left)}.`,
28
+ }),
29
+ ]);
30
+ if (!S.hosted) {
31
+ // On your machine the steps are a click away, on Staff.
32
+ const finish = el("button", { className: "ghbtn primary", textContent: "Finish setting up" });
33
+ finish.onclick = () => {
34
+ S.staffOpen = { handle: s.handle, name: s.name, dir: s.dir };
35
+ go({ view: "staff" });
36
+ };
37
+ box.append(el("div", { className: "row" }, [finish]));
38
+ } else {
39
+ const seen = new Set();
40
+ for (const what of left) {
41
+ const cmd = stepCommand(what, s.handle);
42
+ if (!cmd || seen.has(cmd)) continue;
43
+ seen.add(cmd);
44
+ box.append(commandLine(cmd));
45
+ }
46
+ }
47
+ return box;
48
+ }
49
+
50
+ /**
51
+ * A slot filled once their readiness is known: at once when it is, or when GitHub answers.
52
+ * Landing straight on a screen used to find nothing known yet and nothing that asked.
53
+ */
54
+ export function whenKnown(s, fill) {
55
+ const slot = el("div", { className: "readyslot" });
56
+ const paint = () => slot.replaceChildren(...[fill()].flat().filter(Boolean));
57
+ if (S.readiness?.[s.handle]) paint();
58
+ else whatsLeft(s).then(paint, paint);
59
+ return slot;
60
+ }
@@ -20,6 +20,7 @@ import { mdlite } from "../md.js";
20
20
  import { humansOf, S, writeHash } from "../state.js";
21
21
  import { yamlPre } from "../yaml.js";
22
22
  import { businessForm, fileModes, prioritiesForm } from "./orgedit.js";
23
+ import { peopleCard } from "./people.js";
23
24
  import { repoPicker } from "./repos.js";
24
25
 
25
26
  /* What the files roster itself ships are for, in one line each. A filename says nothing about
@@ -72,6 +73,7 @@ export function viewOrg(m) {
72
73
  kv("Staff", String(org.staff.length), org.staff.map((s) => s.handle).join(", ")),
73
74
  );
74
75
  m.append(facts);
76
+ m.append(peopleCard());
75
77
 
76
78
  /* Marking a product repo after setup. The picker only lived on the setup screen, so a repo
77
79
  created later meant typing `role: product` into org.yaml by hand. Folded, because it asks
@@ -100,13 +102,23 @@ export function viewOrg(m) {
100
102
  .then(({ files }) => {
101
103
  S.orgFiles = files ?? [];
102
104
  paintTree();
103
- const first = S.orgFiles[0]?.path;
105
+ // A file still the questions it shipped with is the thing to do here, so it opens first.
106
+ const first = unwritten().find((p) => S.orgFiles.some((f) => f.path === p)) ?? S.orgFiles[0]?.path;
104
107
  open(S.orgFiles.some((f) => f.path === S.orgOpen) ? S.orgOpen : first);
105
108
  })
106
109
  .catch((e) => {
107
110
  tree.replaceChildren(el("p", { className: "empty err", textContent: e.message }));
108
111
  });
109
112
 
113
+ /** The org files setup is still waiting on, by path. */
114
+ function unwritten() {
115
+ const ids = S.data.unfinished ?? [];
116
+ return [
117
+ ids.includes("business") && "org/business.md",
118
+ ids.includes("priorities") && "org/priorities.md",
119
+ ].filter(Boolean);
120
+ }
121
+
110
122
  function why(file) {
111
123
  return KNOWN[file.path] ?? file.title ?? "";
112
124
  }
@@ -130,6 +142,9 @@ export function viewOrg(m) {
130
142
  el("span", { className: "lname", textContent: f.path.replace(/^(org|prompts)\//, "") }),
131
143
  el("span", { className: "lrepo", textContent: why(f) }),
132
144
  );
145
+ if (unwritten().includes(f.path)) {
146
+ t.append(el("span", { className: "chip warm", textContent: "Not written yet" }));
147
+ }
133
148
  b.append(t);
134
149
  b.onclick = () => open(f.path);
135
150
  group.append(b);
@@ -0,0 +1,109 @@
1
+ /* People: who the staff answer to, and what each of them looks after. On the Org screen.
2
+ *
3
+ * Saving writes the humans list in org.yaml, and the server then puts each person's label on
4
+ * every tracker and tells the mention callers who may wake a staff member, so somebody added
5
+ * here can send work straight away. */
6
+
7
+ import { post } from "../api.js";
8
+ import { el } from "../dom.js";
9
+ import { icon } from "../icons.js";
10
+ import { refreshAll } from "../refresh.js";
11
+ import { S } from "../state.js";
12
+
13
+ export function peopleCard() {
14
+ const start = (S.data?.people?.length ? S.data.people : (S.data?.humans ?? [])).map((h) => ({
15
+ name: h.name ?? "",
16
+ github: h.github ?? "",
17
+ marker: h.marker ?? "",
18
+ role: h.role ?? "",
19
+ handles: (h.handles ?? []).join(", "),
20
+ view_only: Boolean(h.viewOnly),
21
+ }));
22
+ const rows = start.map((p) => ({ ...p }));
23
+
24
+ const list = el("div", { className: "peoplelist" });
25
+ const note = el("span", { className: "meta" });
26
+ const save = el("button", { className: "ghbtn primary", textContent: "Save" });
27
+ const add = el("button", { className: "ghbtn", textContent: "Add a person" });
28
+
29
+ const changed = () => JSON.stringify(rows) !== JSON.stringify(start);
30
+ const stamp = () => {
31
+ save.disabled = !changed();
32
+ };
33
+
34
+ function paint() {
35
+ list.replaceChildren(
36
+ el("div", { className: "peoplerow peoplehead", ariaHidden: "true" }, [
37
+ el("span", { textContent: "Name" }),
38
+ el("span", { textContent: "GitHub login" }),
39
+ el("span", { textContent: "Looks after" }),
40
+ el("span", { className: "peopleonlyhead", textContent: "Read only" }),
41
+ el("span"),
42
+ ]),
43
+ ...rows.map((p, i) => row(p, i)),
44
+ );
45
+ stamp();
46
+ }
47
+
48
+ function row(p, i) {
49
+ const input = (key, placeholder, label) => {
50
+ const box = el("input", { type: "text", value: p[key], placeholder, ariaLabel: label });
51
+ box.oninput = () => {
52
+ p[key] = box.value;
53
+ stamp();
54
+ };
55
+ return box;
56
+ };
57
+ const only = el("input", { type: "checkbox", checked: p.view_only, ariaLabel: "Read only" });
58
+ only.onchange = () => {
59
+ p.view_only = only.checked;
60
+ stamp();
61
+ };
62
+ // Quiet on purpose: one per row, and a column of red buttons outshouts the list it edits.
63
+ const remove = el("button", {
64
+ className: "iconbtn peopleremove",
65
+ title: "Remove",
66
+ ariaLabel: `Remove ${p.name || "this person"}`,
67
+ }, [icon("trash", "ic")]);
68
+ remove.onclick = () => {
69
+ rows.splice(i, 1);
70
+ paint();
71
+ };
72
+ return el("div", { className: "peoplerow" }, [
73
+ input("name", "Name", "Name"),
74
+ input("github", "login", "GitHub login"),
75
+ input("handles", "e.g. marketing, content", "Looks after"),
76
+ el("label", { className: "peopleonly" }, [only]),
77
+ remove,
78
+ ]);
79
+ }
80
+
81
+ add.onclick = () => {
82
+ rows.push({ name: "", github: "", marker: "", role: "", handles: "", view_only: false });
83
+ paint();
84
+ list.querySelector(".peoplerow:last-child input")?.focus();
85
+ };
86
+
87
+ save.onclick = async () => {
88
+ save.disabled = true;
89
+ note.className = "meta";
90
+ note.textContent = "Saving…";
91
+ try {
92
+ const r = await post({ people: rows.filter((p) => p.github.trim() || p.name.trim()) }, "/api/people");
93
+ note.textContent = r.warnings?.length ? "Saved, but: " + r.warnings.join("; ") : "Saved.";
94
+ if (r.warnings?.length) note.className = "meta warn";
95
+ await refreshAll(false);
96
+ } catch (e) {
97
+ note.textContent = String(e.message || e);
98
+ note.className = "meta err";
99
+ stamp();
100
+ }
101
+ };
102
+
103
+ paint();
104
+ return el("div", { className: "card peoplecard" }, [
105
+ el("h2", { textContent: "People" }),
106
+ list,
107
+ el("div", { className: "row" }, [add, save, note]),
108
+ ]);
109
+ }