@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
@@ -1,14 +1,18 @@
1
- /* Home: what needs you, who is working, what you asked for, and what was closed today.
1
+ /* Home: who is working, what needs you, how each staff member is getting on, what you asked
2
+ * for, and what was closed today.
2
3
  *
3
4
  * Built from the inbox list and /api/live, sorted by homesort.js, which is where the rule that
4
5
  * every open item has exactly one place lives. Clicking an item opens its thread in a side
5
6
  * sheet, the same thread view Trackers has, with the reply box in it. */
6
7
 
7
8
  import { getLive, post } from "../api.js";
8
- import { sheet } from "../dialog.js";
9
+ import { askText, sheet } from "../dialog.js";
9
10
  import { ago, el, skeleton } from "../dom.js";
10
- import { daysUntil, sortHome } from "../homesort.js";
11
+ import { daysUntil, isFor, sortHome } from "../homesort.js";
11
12
  import { mdlite } from "../md.js";
13
+ import { checkAll, notReady, ORG_STEPS, stepCommand } from "../readiness.js";
14
+ import { commandLine } from "./notready.js";
15
+ import { parseReport } from "../report.js";
12
16
  import { icon, iconHTML, staffIcon } from "../icons.js";
13
17
  import { ensureInbox, stampCounts } from "../refresh.js";
14
18
  import { go, render } from "../router.js";
@@ -53,56 +57,44 @@ export function viewHome(m) {
53
57
  stampCounts();
54
58
 
55
59
  const page = el("div", { className: "home" });
56
- page.append(askBox(staff));
57
-
58
- if (h.reports.length) {
59
- page.append(section("Latest reports"));
60
- const box = el("div", { className: "card homereports" });
61
- for (const r of h.reports) {
62
- /* The report is markdown the staff member wrote, with links to the work it names. The
63
- whole report opens their status issue, where it was posted; a link inside it goes
64
- where it points. */
65
- const row = el("div", { className: "homereport homeclick", tabIndex: 0, role: "button" }, [
66
- el("div", { className: "homereportwho" }, [
67
- el("span", { className: "homewho2" }, [icon(staffIcon(r.staff), "ic"), el("b", { textContent: r.staff.name })]),
68
- el("span", { className: "meta", textContent: ago(r.at) }),
69
- ]),
70
- el("div", {
71
- className: "md homereportbody",
72
- innerHTML: mdlite(r.lines.join("\n\n"), { repo: r.staff.brain }),
73
- }),
74
- ]);
75
- row.onclick = (ev) => {
76
- if (!ev.target.closest("a, button")) openThread(r.item);
77
- };
78
- row.onkeydown = (ev) => {
79
- if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
80
- ev.preventDefault();
81
- openThread(r.item);
82
- }
83
- };
84
- box.append(row);
85
- }
86
- page.append(box);
87
- }
88
-
89
- page.append(section("Needs you", h.needs.length));
90
- if (h.needs.length) for (const e of h.needs) page.append(needCard(e));
91
- else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
60
+ page.append(team(staff));
61
+ const unset = setupLeft(staff);
62
+ if (unset) page.append(unset);
63
+
64
+ /* With more than one person, each sees what is on them, plus anything on nobody in
65
+ particular. Everyone's is one click away, so nothing is hidden for good. */
66
+ const me = meHuman();
67
+ const split = Boolean(me) && humansOf().length > 1;
68
+ const mine = split ? h.needs.filter((e) => isFor(e, me.github)) : h.needs;
69
+ const shown = split && needsScope === "all" ? h.needs : mine;
70
+ const needsHead = section("Needs you", shown.length);
71
+ if (split && mine.length !== h.needs.length) needsHead.append(scopeToggle(mine.length, h.needs.length));
72
+ page.append(needsHead);
73
+ /* One list rather than a card each: five boxes with a green button apiece read as a wall, and
74
+ nothing in it said which to do first. The top row's action is the one in green. */
75
+ if (shown.length) {
76
+ page.append(
77
+ el("div", { className: "card homelist" }, shown.map((e, i) => needRow(e, i === 0, split ? me : null))),
78
+ );
79
+ } else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
92
80
 
81
+ // What is waiting on you, or was asked by you, comes before how the staff say it is going.
93
82
  if (h.unread.length) {
94
83
  page.append(section("Unread", h.unread.length));
95
84
  page.append(listBox(h.unread.map(unreadRow)));
96
85
  }
97
86
 
98
- page.append(section("Working now"));
99
- page.append(working(staff));
100
-
101
87
  if (h.requests.length) {
102
88
  page.append(section("Your requests", h.requests.length));
103
89
  page.append(listBox(h.requests.map(requestRow)));
104
90
  }
105
91
 
92
+ const reporters = staff.filter((x) => x.brain && x.statusIssue);
93
+ if (reporters.length) {
94
+ page.append(section("Progress"));
95
+ page.append(el("div", { className: "card homereports" }, reporters.map((s) => reportRow(s, h.reports))));
96
+ }
97
+
106
98
  if (h.closedToday.length) {
107
99
  page.append(section("Closed today", h.closedToday.length));
108
100
  page.append(listBox(h.closedToday.map(closedRow)));
@@ -113,48 +105,178 @@ export function viewHome(m) {
113
105
  m.append(page);
114
106
  }
115
107
 
116
- /* ------------------------------- asking -------------------------------- */
108
+ /* ------------------------------- reports -------------------------------- */
117
109
 
118
- function askBox(staff) {
119
- const who = el("select", { className: "homewho", ariaLabel: "Who to ask" });
120
- for (const s of staff.filter((x) => x.brain)) {
121
- who.append(el("option", { value: s.handle, textContent: s.name }));
122
- }
123
- const text = el("textarea", {
124
- className: "homeask",
125
- rows: 2,
126
- placeholder: "Ask a staff member to do something",
127
- });
128
- const send = el("button", { className: "ghbtn primary", textContent: "Send" });
110
+ /** Whose reports are open in full. Kept here, since Home repaints on every poll. */
111
+ const openReports = new Set();
112
+
113
+ const STATUS_TONE = { "on track": "ok", "needs you": "warm", stuck: "hot", blocked: "hot" };
114
+
115
+ /**
116
+ * One staff member's report, as a row: who, their status, and when it was written; then the
117
+ * one line on how it is going and what is next. What got done, and the rest of the report,
118
+ * open under it. Their status issue is rewritten by every run, so this is always the latest.
119
+ */
120
+ function reportRow(s, reports) {
121
+ /* Before a first run the status issue holds the scaffold hire wrote, which read as a report
122
+ from 36 minutes ago. And asking for one wakes somebody who cannot run yet. */
123
+ const left = S.readiness?.[s.handle] ?? [];
124
+ const neverRan = left.includes("run once");
125
+ const unready = left.some((x) => x !== "run once");
126
+ const r = neverRan ? null : reports.find((x) => x.staff.handle === s.handle);
127
+ const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
129
128
  const note = el("span", { className: "meta" });
130
- send.onclick = async () => {
131
- const s = staff.find((x) => x.handle === who.value);
132
- const said = text.value.trim();
133
- if (!s || !said) return;
134
- send.disabled = true;
135
- note.textContent = "Sending…";
129
+ const ask = el("button", { className: "ghbtn sm", textContent: "Ask for an update" });
130
+ ask.onclick = async () => {
131
+ ask.disabled = true;
132
+ note.className = "meta";
133
+ note.textContent = "Asking…";
136
134
  try {
137
135
  await post({
138
- action: "create",
136
+ action: "comment",
139
137
  repo: s.brain,
140
- title: titleOf(said),
141
- body: `${s.mention ?? "@" + s.handle} ${said}`,
138
+ number: s.statusIssue,
139
+ body: `${s.mention ?? "@" + s.handle} Report, please.`,
142
140
  });
143
- text.value = "";
144
- note.textContent = `Sent. ${s.name} starts in about a minute.`;
141
+ ask.remove();
142
+ note.textContent = `Asked. ${s.name} updates it in a few minutes.`;
145
143
  refreshSoon();
146
144
  } catch (e) {
147
145
  note.textContent = String(e.message || e);
148
146
  note.className = "meta err";
149
- } finally {
150
- send.disabled = false;
147
+ ask.disabled = false;
151
148
  }
152
149
  };
153
- return el("div", { className: "card homeaskcard" }, [
154
- el("div", { className: "row" }, [who]),
155
- text,
156
- el("div", { className: "row" }, [send, note]),
150
+
151
+ const full = openReports.has(s.handle);
152
+ const row = el("div", { className: "homereport" + (full ? " full" : "") });
153
+ const issue = el("button", { className: "homereportissue", textContent: "#" + item.number });
154
+ issue.onclick = () => openThread(item);
155
+ const p = r ? parseReport(r.body) : null;
156
+ const needs = p?.sections.needs?.length ?? 0;
157
+
158
+ const head = el("div", { className: "homereporthead" }, [
159
+ el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
157
160
  ]);
161
+ if (p?.status) {
162
+ head.append(
163
+ el("span", {
164
+ className: "chip homereportstatus " + (STATUS_TONE[p.status] ?? ""),
165
+ textContent: cap(p.status) + (needs ? ` · ${needs}` : ""),
166
+ title: needs ? `Waiting on a person: ${needs} thing${needs === 1 ? "" : "s"}` : "",
167
+ }),
168
+ );
169
+ }
170
+ head.append(
171
+ el("span", { className: "meta homereportwhen" }, [
172
+ document.createTextNode(
173
+ (r ? "Updated " + ago(r.at) : neverRan ? "No report yet: the first comes with their first run" : "No report yet") +
174
+ " · ",
175
+ ),
176
+ issue,
177
+ ]),
178
+ );
179
+ const acts = el("span", { className: "homereportacts" }, [note]);
180
+ if (r) {
181
+ const more = el("button", { className: "ghbtn sm", textContent: full ? "Show less" : "Full report" });
182
+ more.onclick = () => {
183
+ if (openReports.has(s.handle)) openReports.delete(s.handle);
184
+ else openReports.add(s.handle);
185
+ repaintInPlace();
186
+ };
187
+ acts.append(more);
188
+ }
189
+ if (!unready) acts.append(ask);
190
+ head.append(acts);
191
+ row.append(head);
192
+
193
+ if (!p) return row;
194
+ if (p.headline) {
195
+ row.append(el("div", { className: "md homereportline", innerHTML: mdlite(p.headline, { repo: s.brain }) }));
196
+ }
197
+ const next = p.sections.next?.[0];
198
+ if (next && !full) {
199
+ row.append(
200
+ el("div", { className: "homereportnext" }, [
201
+ el("b", { textContent: "Next" }),
202
+ el("span", { className: "md", innerHTML: mdlite(next, { repo: s.brain }) }),
203
+ ]),
204
+ );
205
+ }
206
+ if (full) {
207
+ const cols = [
208
+ ["done", "Done"],
209
+ ["next", "Next"],
210
+ ["needs", "Waiting on a person"],
211
+ ].filter(([k]) => p.sections[k]?.length);
212
+ if (cols.length) {
213
+ row.append(
214
+ el(
215
+ "div",
216
+ { className: "homereportcols" },
217
+ cols.map(([k, label]) => bullets(label, p.sections[k], s.brain, 99)),
218
+ ),
219
+ );
220
+ } else {
221
+ // A report in the old shape has no sections, so the whole of it stands in.
222
+ row.append(el("div", { className: "md homereportbody", innerHTML: mdlite(r.body, { repo: s.brain }) }));
223
+ }
224
+ }
225
+ return row;
226
+ }
227
+
228
+ /** A short list under a label, with how many more there are once it runs past `max`. */
229
+ function bullets(label, items, repo, max) {
230
+ const list = el(
231
+ "ul",
232
+ {},
233
+ items.slice(0, max).map((x) => el("li", { className: "md", innerHTML: mdlite(x, { repo }) })),
234
+ );
235
+ const box = el("div", { className: "homereportcol" }, [el("h3", { textContent: label }), list]);
236
+ if (items.length > max) box.append(el("p", { className: "meta", textContent: `and ${items.length - max} more` }));
237
+ return box;
238
+ }
239
+
240
+ /* ------------------------------- asking -------------------------------- */
241
+
242
+ /** What each staff member is being asked, kept if the dialog is closed before sending. */
243
+ const askDrafts = {};
244
+ /** When each was last asked, so their card can say so until they pick it up. */
245
+ const askedAt = {};
246
+
247
+ /**
248
+ * Asking one staff member to do something: their card's button opens this, already addressed
249
+ * to them. It becomes a new issue on their tracker that mentions them, which starts a run.
250
+ */
251
+ async function askStaff(s, error = "") {
252
+ const said = await askText({
253
+ title: `Ask ${s.name}`,
254
+ hint: error,
255
+ value: askDrafts[s.handle] ?? "",
256
+ placeholder: "What do you need? For example: write a post about the new pricing page.",
257
+ confirm: "Send",
258
+ decorate: (ta) => {
259
+ ta.addEventListener("input", () => {
260
+ askDrafts[s.handle] = ta.value;
261
+ });
262
+ },
263
+ });
264
+ if (!said) return;
265
+ try {
266
+ await post({
267
+ action: "create",
268
+ repo: s.brain,
269
+ title: titleOf(said),
270
+ body: `${s.mention ?? "@" + s.handle} ${said}`,
271
+ });
272
+ delete askDrafts[s.handle];
273
+ askedAt[s.handle] = Date.now();
274
+ repaintInPlace();
275
+ refreshSoon();
276
+ } catch (e) {
277
+ askDrafts[s.handle] = said;
278
+ await askStaff(s, String(e.message || e));
279
+ }
158
280
  }
159
281
 
160
282
  /** The first line, short enough to be an issue title. */
@@ -165,57 +287,107 @@ function titleOf(said) {
165
287
 
166
288
  /* ------------------------------ needs you ------------------------------- */
167
289
 
168
- function needCard(e) {
290
+ /** "mine" or "all": whose asks Needs you lists, when there is more than one person. */
291
+ let needsScope = readScope();
292
+
293
+ function readScope() {
294
+ try {
295
+ return localStorage.getItem("roster.needsScope") === "all" ? "all" : "mine";
296
+ } catch {
297
+ return "mine";
298
+ }
299
+ }
300
+
301
+ /** The signed-in person, when they are one of the org's humans. */
302
+ function meHuman() {
303
+ const login = String(S.me ?? "").toLowerCase();
304
+ return login ? (humansOf().find((h) => String(h.github ?? "").toLowerCase() === login) ?? null) : null;
305
+ }
306
+
307
+ function scopeToggle(mine, all) {
308
+ const bar = el("span", { className: "homescope", role: "group", ariaLabel: "Whose to show" });
309
+ for (const [value, label] of [
310
+ ["mine", `Yours ${mine}`],
311
+ ["all", `Everyone's ${all}`],
312
+ ]) {
313
+ const b = el("button", { className: needsScope === value ? "on" : "", textContent: label });
314
+ b.setAttribute("aria-pressed", String(needsScope === value));
315
+ b.onclick = () => {
316
+ needsScope = value;
317
+ try {
318
+ localStorage.setItem("roster.needsScope", value);
319
+ } catch {
320
+ /* a private window: it is only remembered for this visit */
321
+ }
322
+ repaintInPlace();
323
+ };
324
+ bar.append(b);
325
+ }
326
+ return bar;
327
+ }
328
+
329
+ /** "For Ben", on an ask that is on somebody else. */
330
+ function forWhom(e, me) {
331
+ if (!me || !e.for?.length || e.for.some((g) => g.toLowerCase() === me.github.toLowerCase())) return "";
332
+ const names = e.for.map((g) => humansOf().find((h) => h.github === g)?.name ?? g);
333
+ return "For " + names.join(" and ");
334
+ }
335
+
336
+ function needRow(e, first, me = null) {
169
337
  const { item, kind } = e;
170
- /* The whole card opens the thread; the one quick action on it does not. Answering in words
338
+ /* The whole row opens the thread; the one quick action on it does not. Answering in words
171
339
  happens in the thread, where what was asked is in front of you. */
172
- const card = el("div", {
173
- className: "card homecard" + (item.unread ? " unread" : ""),
340
+ const row = el("div", {
341
+ className: "homeneed" + (item.unread ? " unread" : ""),
174
342
  tabIndex: 0,
175
343
  role: "button",
176
344
  });
177
- card.onclick = (ev) => {
345
+ row.onclick = (ev) => {
178
346
  if (!ev.target.closest("button, a, textarea")) openThread(item);
179
347
  };
180
- card.onkeydown = (ev) => {
181
- if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
348
+ row.onkeydown = (ev) => {
349
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
182
350
  ev.preventDefault();
183
351
  openThread(item);
184
352
  }
185
353
  };
186
- // What it is on the left, what you can do about it on the right.
187
- const about = el("div", { className: "homeabout" }, [
188
- el("div", { className: "homehead" }, [
189
- el("span", { className: "chip " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
190
- openLink(item),
191
- ]),
192
- el("div", { className: "meta", textContent: whereOf(e) + " · " + ago(item.createdAt) }),
193
- ]);
194
- card.append(about);
195
354
 
355
+ /* What kind of thing it is sits in the line under the title, so every title starts in the
356
+ same place; a chip in front of it pushed each one along by its own width. */
357
+ const other = forWhom(e, me);
358
+ const meta = el("div", { className: "meta" }, [
359
+ el("span", { className: "homekind " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
360
+ ...(other ? [document.createTextNode(" · "), el("span", { className: "homefor", textContent: other })] : []),
361
+ document.createTextNode(" · " + whereOf(e) + " · " + ago(item.createdAt)),
362
+ ]);
363
+ const about = el("div", { className: "homeabout" }, [openLink(item), meta]);
196
364
  if (kind === "decision" && item.due) about.append(dueLine(item.due));
197
365
  if (kind === "merge") about.append(checksLine(item));
198
366
 
199
367
  // The note comes first so that what happened sits just left of the button that did it.
200
368
  const note = el("span", { className: "meta" });
201
369
  const actions = el("div", { className: "row homeacts" }, [note]);
370
+ row.append(el("span", { className: "homedot", ariaHidden: "true" }), about, actions);
202
371
 
203
372
  if (kind === "decision" || kind === "ask") {
204
- actions.append(button("Reply", true, () => openThread(item)));
205
- if (item.due) actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
373
+ actions.append(button("Reply", first, () => openThread(item)));
374
+ if (item.due) {
375
+ actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
376
+ }
206
377
  } else if (kind === "review") {
207
- actions.append(button("Approve", true, () => say(e, "Approved.", note, actions)));
378
+ actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
208
379
  } else if (kind === "chore") {
209
- actions.append(button("Done", true, () => done(e, note, actions)));
380
+ actions.append(button("Done", first, () => done(e, note, actions)));
210
381
  } else if (kind === "merge") {
211
- const blocked = item.checks === "failing" || item.mergeable === "CONFLICTING";
212
- const needsReview = item.reviewDecision === "REVIEW_REQUIRED";
213
- const merge = button("Merge", !needsReview, () => merge_(e, note, actions));
214
- merge.disabled = blocked || item.checks === "pending" || needsReview;
215
- /* The branch rules want an approving review. Approve is the person's review, given on
216
- purpose; Merge waits for it rather than approving on their behalf. */
217
- if (needsReview) {
218
- const approve = button("Approve", true, async () => {
382
+ /* Merge is offered only when pressing it can work. A conflict, failing checks or checks
383
+ still running are in the line under the title instead; a grey button that cannot be
384
+ pressed looked like one that could. */
385
+ const blocked =
386
+ item.checks === "failing" || item.checks === "pending" || item.mergeable === "CONFLICTING";
387
+ const merge = () => button("Merge", first, () => merge_(e, note, actions));
388
+ if (item.reviewDecision === "REVIEW_REQUIRED") {
389
+ // Approve is the person's review, given on purpose; Merge waits for it.
390
+ const approve = button("Approve", first, async () => {
219
391
  approve.disabled = true;
220
392
  note.className = "meta";
221
393
  note.textContent = "Approving…";
@@ -224,8 +396,7 @@ function needCard(e) {
224
396
  item.reviewDecision = "APPROVED";
225
397
  note.textContent = "Approved.";
226
398
  approve.remove();
227
- merge.className = "ghbtn primary";
228
- merge.disabled = blocked || item.checks === "pending";
399
+ if (!blocked) actions.append(merge());
229
400
  } catch (err) {
230
401
  note.textContent = String(err.message || err);
231
402
  note.className = "meta err";
@@ -233,11 +404,9 @@ function needCard(e) {
233
404
  }
234
405
  });
235
406
  actions.append(approve);
236
- }
237
- actions.append(merge);
407
+ } else if (!blocked) actions.append(merge());
238
408
  }
239
- card.append(actions);
240
- return card;
409
+ return row;
241
410
  }
242
411
 
243
412
  function dueLine(due) {
@@ -250,20 +419,20 @@ function dueLine(due) {
250
419
  });
251
420
  }
252
421
 
422
+ /** Where a pull request stands, with only the parts that stop a merge in amber. */
253
423
  function checksLine(item) {
254
- const words = {
255
- passing: "Checks pass.",
256
- failing: "Checks fail.",
257
- pending: "Checks are running.",
258
- none: "No checks.",
259
- };
260
- const conflict =
261
- (item.mergeable === "CONFLICTING" ? " Conflicts with its base." : "") +
262
- (item.reviewDecision === "REVIEW_REQUIRED" ? " Needs your approval to merge." : "");
263
- return el("p", {
264
- className: "homedue" + (item.checks === "failing" || conflict ? " late" : ""),
265
- textContent: (words[item.checks] ?? "") + conflict,
424
+ const parts = [];
425
+ if (item.checks === "passing") parts.push(["Checks pass", false]);
426
+ if (item.checks === "failing") parts.push(["Checks fail", true]);
427
+ if (item.checks === "pending") parts.push(["Checks are running", false]);
428
+ if (item.mergeable === "CONFLICTING") parts.push(["Conflicts with its base", true]);
429
+ if (item.reviewDecision === "REVIEW_REQUIRED") parts.push(["Needs your approval", false]);
430
+ const line = el("p", { className: "homedue" });
431
+ parts.forEach(([text, bad], i) => {
432
+ if (i) line.append(document.createTextNode(" · "));
433
+ line.append(el("span", { className: bad ? "bad" : "", textContent: text }));
266
434
  });
435
+ return line;
267
436
  }
268
437
 
269
438
  async function say(e, text, note, actions) {
@@ -289,7 +458,7 @@ async function act(note, actions, payload, ok) {
289
458
  await post(payload);
290
459
  note.textContent = ok;
291
460
  // Done is done: the card goes now, rather than when GitHub next answers.
292
- const card = actions.closest?.(".homecard, .homeline");
461
+ const card = actions.closest?.(".homeneed, .homeline");
293
462
  if (card) {
294
463
  card.classList.add("gone");
295
464
  setTimeout(() => card.remove(), 220);
@@ -302,75 +471,181 @@ async function act(note, actions, payload, ok) {
302
471
  }
303
472
  }
304
473
 
305
- /* ------------------------------ working now ----------------------------- */
474
+ /* ---------------------------------- team ---------------------------------- */
306
475
 
307
- /** What a run was, in a few words: "daily run", "answering #12", "a peer's ask #4". */
476
+ /* One colour per staff member, in hire order, so two orbs side by side are told apart. */
477
+ const HUES = ["#30d158", "#0a84ff", "#bf5af2", "#ff375f", "#ff9f0a", "#64d2ff", "#ffd60a"];
478
+
479
+ /** What a run is doing, as a person would say it. */
308
480
  function whatRun(r) {
309
- if (r.trigger === "mention") return r.issue ? `answering #${r.issue}` : "answering a mention";
310
- if (r.trigger === "peer") return r.issue ? `a peer's ask #${r.issue}` : "a peer's ask";
481
+ const on = r.issue ? titleOn(r) : "";
482
+ if (r.trigger === "mention") return r.issue ? `Answering #${r.issue}${on}` : "Answering a message";
483
+ if (r.trigger === "peer") return r.issue ? `Helping a colleague with #${r.issue}${on}` : "Helping a colleague";
484
+ if (r.trigger === "routine") return r.routine ? `Running the ${r.routine} routine` : "Running a routine";
311
485
  return (
312
- { daily: "daily run", manual: "run started by hand", "follow-on": "follow-on run" }[r.trigger] ??
313
- "run"
486
+ {
487
+ daily: "Doing their daily work",
488
+ manual: "Doing the work you started",
489
+ "follow-on": "Carrying on from their last session",
490
+ }[r.trigger] ?? "Working"
314
491
  );
315
492
  }
316
493
 
317
- function working(staff) {
318
- const box = el("div", { className: "card homeworking" });
319
- if (!S.live) {
320
- box.append(el("p", { className: "homerunwhat", textContent: "Asking GitHub…" }));
321
- return box;
322
- }
323
- for (const s of staff) {
324
- const l = (S.live.staff ?? []).find((x) => x.handle === s.handle);
494
+ /** ": the issue's title", when the inbox has it. */
495
+ function titleOn(r) {
496
+ const s = (S.data?.staff ?? []).find((x) => x.handle === r.handle);
497
+ const it = (S.inbox?.items ?? []).find((i) => i.number === r.issue && (!s || i.repo === s.brain));
498
+ return it?.title ? `: ${it.title}` : "";
499
+ }
500
+
501
+ /**
502
+ * Who is working, as a row of orbs. A lit, moving orb is somebody at work; a still, dim one is
503
+ * somebody free. Under it, in words, what they are doing or when they last finished. Pressing
504
+ * an orb that is answering something opens that thread.
505
+ */
506
+ function team(staff) {
507
+ const box = el("div", { className: "hometeam" });
508
+ const live = S.live?.staff ?? [];
509
+ staff.forEach((s, i) => {
510
+ const l = live.find((x) => x.handle === s.handle);
325
511
  const runs = l && !l.error ? (l.running ?? []) : [];
326
- const busy = runs.length > 0;
512
+ const queued = runs.length > 0 && runs.every((r) => r.status === "queued");
513
+ const busy = runs.length > 0 && !queued;
327
514
  const last = l?.finished?.[0];
328
-
329
- const what = el("div", { className: "homerunwhat" });
330
- let log = null;
331
- if (!l || l.error) {
332
- what.append(el("span", { className: "err", textContent: l?.error ?? "Could not read their runs." }));
333
- } else if (busy) {
334
- for (const r of runs) {
335
- what.append(el("div", { textContent: `${cap(whatRun(r))} · ${minutes(r.createdAt)} so far` }));
336
- }
337
- log = runs[0].url;
515
+ const failed = !runs.length && last && last.conclusion === "failure";
516
+ const state = !S.live ? "wait" : busy ? "busy" : queued ? "queued" : failed ? "failed" : "idle";
517
+
518
+ let word = "Free";
519
+ let line = "Not working right now";
520
+ if (!S.live) {
521
+ word = "…";
522
+ line = "Checking…";
523
+ } else if (!l || l.error) {
524
+ word = "Unknown";
525
+ line = "Could not check on them";
526
+ } else if (busy || queued) {
527
+ const r = { ...runs[0], handle: s.handle };
528
+ word = busy ? "Working" : "Waiting to start";
529
+ line = busy
530
+ ? `${whatRun(r)} · ${minutes(r.createdAt)} so far`
531
+ : `${whatRun(r)} · queued ${minutes(r.createdAt)} ago`;
532
+ } else if (failed) {
533
+ word = "Free";
534
+ line = `Their last session stopped with a problem, ${ago(last.updatedAt)}`;
338
535
  } else if (last) {
339
- what.append(
340
- el("div", { textContent: `${cap(whatRun(last))}, ${outcome(last)} ${ago(last.updatedAt)}` }),
341
- );
342
- log = last.url;
343
- } else {
344
- what.append(el("div", { textContent: "No runs in the last few hours." }));
536
+ line = `Last finished ${ago(last.updatedAt)}`;
345
537
  }
346
- if (l && !l.error && l.automatic) {
347
- what.append(
348
- el("div", {
349
- className: "homerunsub",
350
- textContent: `${l.automatic} of ${l.limit} runs today that nobody asked for`,
351
- }),
352
- );
538
+ /* Somebody who cannot run yet looked exactly like somebody free. A run in progress, the
539
+ first one included, still says what it is doing. */
540
+ const left = S.readiness?.[s.handle] ?? [];
541
+ const unready = left.length > 0 && !busy && !queued;
542
+ if (unready) {
543
+ // The card is narrow; the steps themselves are in the panel under it.
544
+ word = "Not set up yet";
545
+ line = left.length === 1 ? "One step left: " + left[0] : `${left.length} steps left, below`;
546
+ }
547
+ // A run takes about a minute to start, and until then the card would say nothing happened.
548
+ if (!busy && !queued && Date.now() - (askedAt[s.handle] ?? 0) < 120_000) {
549
+ line = "Sent. Starts in about a minute";
353
550
  }
354
551
 
355
- const state = el("span", {
356
- className: "chip homestate " + (busy ? "ok" : ""),
357
- textContent: busy ? (runs[0].status === "queued" ? "Queued" : "Working") : "Idle",
552
+ const issue = (busy || queued) && runs[0].issue && s.brain ? runs[0].issue : null;
553
+ const card = el("div", {
554
+ className: "orbcard " + state + (issue ? " homeclick" : ""),
555
+ ...(issue ? { tabIndex: 0, role: "button", title: `Open #${issue}` } : {}),
358
556
  });
359
- const actions = el("div", { className: "homerunlog" });
360
- if (log) {
361
- actions.append(
362
- el("a", { className: "ghbtn", href: log, target: "_blank", rel: "noopener", textContent: "Log" }),
557
+ card.style?.setProperty?.("--hue", HUES[i % HUES.length]);
558
+ const orb = el("div", { className: "orb", ariaHidden: "true" }, [
559
+ el("span", { className: "orbglow" }),
560
+ el("span", { className: "orbbody" }, [el("span", { className: "orbswirl" })]),
561
+ el("span", { className: "orbicon" }, [icon(staffIcon(s), "ic")]),
562
+ ]);
563
+ card.append(
564
+ orb,
565
+ el("b", { className: "orbname", textContent: s.name }),
566
+ el("span", { className: "orbstate", textContent: word }),
567
+ el("span", { className: "orbline", textContent: line }),
568
+ );
569
+ const log = runs[0]?.url ?? last?.url;
570
+ if (log && state !== "idle") {
571
+ card.append(
572
+ el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
363
573
  );
364
574
  }
575
+ // Asking wakes them, which proves nothing until the rest is done. A first run is fine.
576
+ if (s.brain && !(unready && left.some((x) => x !== "run once"))) {
577
+ const ask = el("button", { className: "ghbtn orbask", textContent: "Ask a question" });
578
+ ask.onclick = () => askStaff(s);
579
+ card.append(el("span", { className: "orbgap" }), ask);
580
+ }
581
+ if (issue) {
582
+ const open = () => openThread({ repo: s.brain, number: issue, kind: "issue" });
583
+ card.onclick = (ev) => {
584
+ if (!ev.target.closest("a, button")) open();
585
+ };
586
+ card.onkeydown = (ev) => {
587
+ if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
588
+ ev.preventDefault();
589
+ open();
590
+ }
591
+ };
592
+ }
593
+ box.append(card);
594
+ });
595
+ return box;
596
+ }
365
597
 
366
- box.append(
367
- el("div", { className: "homerun" + (busy ? " busy" : "") }, [
368
- el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
369
- state,
370
- what,
371
- actions,
372
- ]),
373
- );
598
+ /* ------------------------------- setup left ----------------------------- */
599
+
600
+ let readinessAsked = false;
601
+
602
+ /**
603
+ * What is left of setting up, at the top of Home. Home said a staff member who could not run
604
+ * was "Free" with a button to ask them something, and nothing on it said setup was unfinished.
605
+ * Hosted, the steps are commands, since that is the only place they can be done.
606
+ */
607
+ function setupLeft(staff) {
608
+ if (staff.some((s) => !S.readiness?.[s.handle]) && !readinessAsked) {
609
+ readinessAsked = true;
610
+ checkAll(() => {
611
+ readinessAsked = false;
612
+ if (S.view === "home") render();
613
+ });
614
+ }
615
+ const steps = [];
616
+ for (const id of S.data?.unfinished ?? []) if (ORG_STEPS[id]) steps.push(ORG_STEPS[id]);
617
+ for (const s of notReady()) {
618
+ for (const what of S.readiness[s.handle]) {
619
+ steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle)]);
620
+ }
621
+ }
622
+ if (!steps.length) return null;
623
+
624
+ const box = el("div", { className: "card homesetup" });
625
+ box.append(
626
+ el("b", { textContent: "Setup is not finished" }),
627
+ el("p", {
628
+ className: "sub",
629
+ textContent: S.hosted
630
+ ? "Nobody runs until these are done. They need your own machine: run each in your workspace, in order."
631
+ : "Nobody runs until these are done.",
632
+ }),
633
+ );
634
+ const seen = new Set();
635
+ const list = el("ol", { className: "homesetupsteps" });
636
+ for (const [what, cmd] of steps) {
637
+ // The credential is the org's, so two staff members missing it is one step.
638
+ if (cmd && seen.has(cmd)) continue;
639
+ seen.add(cmd);
640
+ const row = el("li", {}, [el("span", { textContent: cap(what) })]);
641
+ if (S.hosted && cmd) row.append(commandLine(cmd));
642
+ list.append(row);
643
+ }
644
+ box.append(list);
645
+ if (!S.hosted) {
646
+ const cont = el("button", { className: "btn primary", textContent: "Continue setting up" });
647
+ cont.onclick = () => go({ view: "setup" });
648
+ box.append(el("div", { className: "row" }, [cont]));
374
649
  }
375
650
  return box;
376
651
  }
@@ -423,7 +698,7 @@ function poll() {
423
698
 
424
699
  /* ------------------------------ your requests ---------------------------- */
425
700
 
426
- /** A card of rows, laid out like Working now. */
701
+ /** A card of rows. */
427
702
  function listBox(rows) {
428
703
  return el("div", { className: "card homeworking" }, rows);
429
704
  }
@@ -437,10 +712,14 @@ function listRow(e, { chip, tone = "", sub, action = null }) {
437
712
  "div",
438
713
  { className: "homeline homeclick" + (e.item.unread ? " unread" : ""), tabIndex: 0, role: "button" },
439
714
  [
440
- el("span", { className: "chip homestate " + tone, textContent: chip }),
715
+ // The same row as Needs you: an unread dot, the title, and what it is in the line under it.
716
+ el("span", { className: "homedot", ariaHidden: "true" }),
441
717
  el("div", { className: "homerunwhat" }, [
442
718
  el("div", { className: "homerowtitle", textContent: e.item.title }),
443
- el("div", { className: "homerunsub", textContent: `${whereOf(e)} · ${sub}` }),
719
+ el("div", { className: "homerunsub" }, [
720
+ el("span", { className: "homekind " + tone, textContent: chip }),
721
+ document.createTextNode(` · ${whereOf(e)} · ${sub}`),
722
+ ]),
444
723
  ]),
445
724
  el("div", { className: "homerunlog" }, action ? [action] : []),
446
725
  ],