@nanocollective/roster 0.1.0-beta.1 → 0.1.0-beta.11

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 (37) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +150 -45
  3. package/dist/worker/assets/assets/css/base.css +17 -2
  4. package/dist/worker/assets/assets/css/home.css +42 -29
  5. package/dist/worker/assets/assets/css/layout.css +6 -0
  6. package/dist/worker/assets/assets/js/api.js +30 -0
  7. package/dist/worker/assets/assets/js/app.js +37 -2
  8. package/dist/worker/assets/assets/js/homesort.js +4 -21
  9. package/dist/worker/assets/assets/js/views/home.js +115 -79
  10. package/dist/worker/index.js +795 -85
  11. package/docs/architecture.md +22 -3
  12. package/docs/commands.md +29 -8
  13. package/docs/concepts.md +1 -1
  14. package/docs/developing.md +1 -1
  15. package/docs/getting-started.md +5 -2
  16. package/docs/hosting.md +25 -0
  17. package/docs/memory.md +2 -1
  18. package/docs/portal.md +4 -3
  19. package/docs/security.md +13 -0
  20. package/docs/session-workflow.md +10 -6
  21. package/docs/staff-yaml.md +5 -2
  22. package/package.json +1 -1
  23. package/templates/brain/CHARTER.md +2 -2
  24. package/templates/brain/STATE.md +16 -0
  25. package/templates/brain/memory/INDEX.md +1 -1
  26. package/templates/ops/.github/workflows/session.yaml +14 -1
  27. package/templates/ops/org/voice.md +2 -2
  28. package/templates/ops/prompts/daily.md +27 -18
  29. package/templates/ops/prompts/mention.md +6 -2
  30. package/templates/ops/status-week.mjs +169 -0
  31. package/templates/portal/css/base.css +17 -2
  32. package/templates/portal/css/home.css +42 -29
  33. package/templates/portal/css/layout.css +6 -0
  34. package/templates/portal/js/api.js +30 -0
  35. package/templates/portal/js/app.js +37 -2
  36. package/templates/portal/js/homesort.js +4 -21
  37. package/templates/portal/js/views/home.js +115 -79
@@ -55,40 +55,18 @@ export function viewHome(m) {
55
55
  const page = el("div", { className: "home" });
56
56
  page.append(askBox(staff));
57
57
 
58
- if (h.reports.length) {
58
+ const reporters = staff.filter((x) => x.brain && x.statusIssue);
59
+ if (reporters.length) {
59
60
  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);
61
+ page.append(el("div", { className: "card homereports" }, reporters.map((s) => reportRow(s, h.reports))));
87
62
  }
88
63
 
89
64
  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." }));
65
+ /* One list rather than a card each: five boxes with a green button apiece read as a wall, and
66
+ nothing in it said which to do first. The top row's action is the one in green. */
67
+ if (h.needs.length) {
68
+ page.append(el("div", { className: "card homelist" }, h.needs.map((e, i) => needRow(e, i === 0))));
69
+ } else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
92
70
 
93
71
  if (h.unread.length) {
94
72
  page.append(section("Unread", h.unread.length));
@@ -113,6 +91,61 @@ export function viewHome(m) {
113
91
  m.append(page);
114
92
  }
115
93
 
94
+ /* ------------------------------- reports -------------------------------- */
95
+
96
+ /**
97
+ * One staff member's report: the body of their status issue, which every run rewrites, with a
98
+ * button that asks them to bring it up to date now. It is markdown they wrote, with links to the
99
+ * work it names. The whole row opens the issue; a link inside it goes where it points.
100
+ */
101
+ function reportRow(s, reports) {
102
+ const r = reports.find((x) => x.staff.handle === s.handle);
103
+ const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
104
+ const note = el("span", { className: "meta" });
105
+ const ask = el("button", { className: "ghbtn", textContent: "Ask for a report" });
106
+ ask.onclick = async () => {
107
+ ask.disabled = true;
108
+ note.className = "meta";
109
+ note.textContent = "Asking…";
110
+ try {
111
+ await post({
112
+ action: "comment",
113
+ repo: s.brain,
114
+ number: s.statusIssue,
115
+ body: `${s.mention ?? "@" + s.handle} Report, please.`,
116
+ });
117
+ ask.remove();
118
+ note.textContent = `Asked. ${s.name} updates it in a few minutes.`;
119
+ refreshSoon();
120
+ } catch (e) {
121
+ note.textContent = String(e.message || e);
122
+ note.className = "meta err";
123
+ ask.disabled = false;
124
+ }
125
+ };
126
+
127
+ const row = el("div", { className: "homereport homeclick", tabIndex: 0, role: "button" }, [
128
+ el("div", { className: "homereportwho" }, [
129
+ el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
130
+ el("span", { className: "meta", textContent: r ? "Updated " + ago(r.at) : "No report yet" }),
131
+ el("div", { className: "homereportask" }, [ask, note]),
132
+ ]),
133
+ r
134
+ ? el("div", { className: "md homereportbody", innerHTML: mdlite(r.body, { repo: s.brain }) })
135
+ : el("div"),
136
+ ]);
137
+ row.onclick = (ev) => {
138
+ if (!ev.target.closest("a, button")) openThread(item);
139
+ };
140
+ row.onkeydown = (ev) => {
141
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
142
+ ev.preventDefault();
143
+ openThread(item);
144
+ }
145
+ };
146
+ return row;
147
+ }
148
+
116
149
  /* ------------------------------- asking -------------------------------- */
117
150
 
118
151
  function askBox(staff) {
@@ -165,57 +198,59 @@ function titleOf(said) {
165
198
 
166
199
  /* ------------------------------ needs you ------------------------------- */
167
200
 
168
- function needCard(e) {
201
+ function needRow(e, first) {
169
202
  const { item, kind } = e;
170
- /* The whole card opens the thread; the one quick action on it does not. Answering in words
203
+ /* The whole row opens the thread; the one quick action on it does not. Answering in words
171
204
  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" : ""),
205
+ const row = el("div", {
206
+ className: "homeneed" + (item.unread ? " unread" : ""),
174
207
  tabIndex: 0,
175
208
  role: "button",
176
209
  });
177
- card.onclick = (ev) => {
210
+ row.onclick = (ev) => {
178
211
  if (!ev.target.closest("button, a, textarea")) openThread(item);
179
212
  };
180
- card.onkeydown = (ev) => {
181
- if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
213
+ row.onkeydown = (ev) => {
214
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
182
215
  ev.preventDefault();
183
216
  openThread(item);
184
217
  }
185
218
  };
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
219
 
220
+ /* What kind of thing it is sits in the line under the title, so every title starts in the
221
+ same place; a chip in front of it pushed each one along by its own width. */
222
+ const meta = el("div", { className: "meta" }, [
223
+ el("span", { className: "homekind " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
224
+ document.createTextNode(" · " + whereOf(e) + " · " + ago(item.createdAt)),
225
+ ]);
226
+ const about = el("div", { className: "homeabout" }, [openLink(item), meta]);
196
227
  if (kind === "decision" && item.due) about.append(dueLine(item.due));
197
228
  if (kind === "merge") about.append(checksLine(item));
198
229
 
199
230
  // The note comes first so that what happened sits just left of the button that did it.
200
231
  const note = el("span", { className: "meta" });
201
232
  const actions = el("div", { className: "row homeacts" }, [note]);
233
+ row.append(el("span", { className: "homedot", ariaHidden: "true" }), about, actions);
202
234
 
203
235
  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)));
236
+ actions.append(button("Reply", first, () => openThread(item)));
237
+ if (item.due) {
238
+ actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
239
+ }
206
240
  } else if (kind === "review") {
207
- actions.append(button("Approve", true, () => say(e, "Approved.", note, actions)));
241
+ actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
208
242
  } else if (kind === "chore") {
209
- actions.append(button("Done", true, () => done(e, note, actions)));
243
+ actions.append(button("Done", first, () => done(e, note, actions)));
210
244
  } 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 () => {
245
+ /* Merge is offered only when pressing it can work. A conflict, failing checks or checks
246
+ still running are in the line under the title instead; a grey button that cannot be
247
+ pressed looked like one that could. */
248
+ const blocked =
249
+ item.checks === "failing" || item.checks === "pending" || item.mergeable === "CONFLICTING";
250
+ const merge = () => button("Merge", first, () => merge_(e, note, actions));
251
+ if (item.reviewDecision === "REVIEW_REQUIRED") {
252
+ // Approve is the person's review, given on purpose; Merge waits for it.
253
+ const approve = button("Approve", first, async () => {
219
254
  approve.disabled = true;
220
255
  note.className = "meta";
221
256
  note.textContent = "Approving…";
@@ -224,8 +259,7 @@ function needCard(e) {
224
259
  item.reviewDecision = "APPROVED";
225
260
  note.textContent = "Approved.";
226
261
  approve.remove();
227
- merge.className = "ghbtn primary";
228
- merge.disabled = blocked || item.checks === "pending";
262
+ if (!blocked) actions.append(merge());
229
263
  } catch (err) {
230
264
  note.textContent = String(err.message || err);
231
265
  note.className = "meta err";
@@ -233,11 +267,9 @@ function needCard(e) {
233
267
  }
234
268
  });
235
269
  actions.append(approve);
236
- }
237
- actions.append(merge);
270
+ } else if (!blocked) actions.append(merge());
238
271
  }
239
- card.append(actions);
240
- return card;
272
+ return row;
241
273
  }
242
274
 
243
275
  function dueLine(due) {
@@ -250,20 +282,20 @@ function dueLine(due) {
250
282
  });
251
283
  }
252
284
 
285
+ /** Where a pull request stands, with only the parts that stop a merge in amber. */
253
286
  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,
287
+ const parts = [];
288
+ if (item.checks === "passing") parts.push(["Checks pass", false]);
289
+ if (item.checks === "failing") parts.push(["Checks fail", true]);
290
+ if (item.checks === "pending") parts.push(["Checks are running", false]);
291
+ if (item.mergeable === "CONFLICTING") parts.push(["Conflicts with its base", true]);
292
+ if (item.reviewDecision === "REVIEW_REQUIRED") parts.push(["Needs your approval", false]);
293
+ const line = el("p", { className: "homedue" });
294
+ parts.forEach(([text, bad], i) => {
295
+ if (i) line.append(document.createTextNode(" · "));
296
+ line.append(el("span", { className: bad ? "bad" : "", textContent: text }));
266
297
  });
298
+ return line;
267
299
  }
268
300
 
269
301
  async function say(e, text, note, actions) {
@@ -289,7 +321,7 @@ async function act(note, actions, payload, ok) {
289
321
  await post(payload);
290
322
  note.textContent = ok;
291
323
  // Done is done: the card goes now, rather than when GitHub next answers.
292
- const card = actions.closest?.(".homecard, .homeline");
324
+ const card = actions.closest?.(".homeneed, .homeline");
293
325
  if (card) {
294
326
  card.classList.add("gone");
295
327
  setTimeout(() => card.remove(), 220);
@@ -437,10 +469,14 @@ function listRow(e, { chip, tone = "", sub, action = null }) {
437
469
  "div",
438
470
  { className: "homeline homeclick" + (e.item.unread ? " unread" : ""), tabIndex: 0, role: "button" },
439
471
  [
440
- el("span", { className: "chip homestate " + tone, textContent: chip }),
472
+ // The same row as Needs you: an unread dot, the title, and what it is in the line under it.
473
+ el("span", { className: "homedot", ariaHidden: "true" }),
441
474
  el("div", { className: "homerunwhat" }, [
442
475
  el("div", { className: "homerowtitle", textContent: e.item.title }),
443
- el("div", { className: "homerunsub", textContent: `${whereOf(e)} · ${sub}` }),
476
+ el("div", { className: "homerunsub" }, [
477
+ el("span", { className: "homekind " + tone, textContent: chip }),
478
+ document.createTextNode(` · ${whereOf(e)} · ${sub}`),
479
+ ]),
444
480
  ]),
445
481
  el("div", { className: "homerunlog" }, action ? [action] : []),
446
482
  ],