@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.
- package/README.md +1 -0
- package/dist/cli.js +150 -45
- package/dist/worker/assets/assets/css/base.css +17 -2
- package/dist/worker/assets/assets/css/home.css +42 -29
- package/dist/worker/assets/assets/css/layout.css +6 -0
- package/dist/worker/assets/assets/js/api.js +30 -0
- package/dist/worker/assets/assets/js/app.js +37 -2
- package/dist/worker/assets/assets/js/homesort.js +4 -21
- package/dist/worker/assets/assets/js/views/home.js +115 -79
- package/dist/worker/index.js +795 -85
- package/docs/architecture.md +22 -3
- package/docs/commands.md +29 -8
- package/docs/concepts.md +1 -1
- package/docs/developing.md +1 -1
- package/docs/getting-started.md +5 -2
- package/docs/hosting.md +25 -0
- package/docs/memory.md +2 -1
- package/docs/portal.md +4 -3
- package/docs/security.md +13 -0
- package/docs/session-workflow.md +10 -6
- package/docs/staff-yaml.md +5 -2
- package/package.json +1 -1
- package/templates/brain/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- package/templates/ops/.github/workflows/session.yaml +14 -1
- package/templates/ops/org/voice.md +2 -2
- package/templates/ops/prompts/daily.md +27 -18
- package/templates/ops/prompts/mention.md +6 -2
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/base.css +17 -2
- package/templates/portal/css/home.css +42 -29
- package/templates/portal/css/layout.css +6 -0
- package/templates/portal/js/api.js +30 -0
- package/templates/portal/js/app.js +37 -2
- package/templates/portal/js/homesort.js +4 -21
- package/templates/portal/js/views/home.js +115 -79
|
@@ -20,17 +20,6 @@ const CHORE_WORDS = ["setup", "submit", "data", "blocked"];
|
|
|
20
20
|
|
|
21
21
|
const lower = (s) => String(s ?? "").toLowerCase();
|
|
22
22
|
|
|
23
|
-
/** How old a run report can be and still be this morning's. */
|
|
24
|
-
const REPORT_HOURS = 20;
|
|
25
|
-
|
|
26
|
-
/** A run report as lines, without the @mention it opens with. */
|
|
27
|
-
function reportLines(body) {
|
|
28
|
-
return String(body ?? "")
|
|
29
|
-
.split("\n")
|
|
30
|
-
.map((l) => l.replace(/^\s*(@[\w-]+\s*)+/, "").replace(/^[-*]\s+/, "").trim())
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.slice(0, 5);
|
|
33
|
-
}
|
|
34
23
|
|
|
35
24
|
/**
|
|
36
25
|
* @param items the inbox list: open and recently closed issues and pull requests
|
|
@@ -76,16 +65,10 @@ export function sortHome(items, staff, humans, live = [], now = new Date()) {
|
|
|
76
65
|
continue;
|
|
77
66
|
}
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
owner
|
|
83
|
-
item.number === owner.statusIssue &&
|
|
84
|
-
c &&
|
|
85
|
-
!people.has(lower(c.author)) &&
|
|
86
|
-
now - new Date(c.createdAt) < REPORT_HOURS * 3_600_000
|
|
87
|
-
) {
|
|
88
|
-
out.reports.push({ staff: owner, item, at: c.createdAt, lines: reportLines(c.body) });
|
|
68
|
+
/* The report: the body of a staff member's status issue, which every run rewrites. Not its
|
|
69
|
+
comments, which used to be the reports and grew into a thread nobody wanted to scroll. */
|
|
70
|
+
if (owner && item.number === owner.statusIssue && String(item.body ?? "").trim()) {
|
|
71
|
+
out.reports.push({ staff: owner, item, at: item.updatedAt, body: String(item.body).trim() });
|
|
89
72
|
}
|
|
90
73
|
|
|
91
74
|
const place = placeOf(item, owner, people, markers);
|
|
@@ -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
|
-
|
|
58
|
+
const reporters = staff.filter((x) => x.brain && x.statusIssue);
|
|
59
|
+
if (reporters.length) {
|
|
59
60
|
page.append(section("Latest reports"));
|
|
60
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
|
201
|
+
function needRow(e, first) {
|
|
169
202
|
const { item, kind } = e;
|
|
170
|
-
/* The whole
|
|
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
|
|
173
|
-
className: "
|
|
205
|
+
const row = el("div", {
|
|
206
|
+
className: "homeneed" + (item.unread ? " unread" : ""),
|
|
174
207
|
tabIndex: 0,
|
|
175
208
|
role: "button",
|
|
176
209
|
});
|
|
177
|
-
|
|
210
|
+
row.onclick = (ev) => {
|
|
178
211
|
if (!ev.target.closest("button, a, textarea")) openThread(item);
|
|
179
212
|
};
|
|
180
|
-
|
|
181
|
-
if (ev.target ===
|
|
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",
|
|
205
|
-
if (item.due)
|
|
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",
|
|
241
|
+
actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
|
|
208
242
|
} else if (kind === "chore") {
|
|
209
|
-
actions.append(button("Done",
|
|
243
|
+
actions.append(button("Done", first, () => done(e, note, actions)));
|
|
210
244
|
} else if (kind === "merge") {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (
|
|
218
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
(
|
|
263
|
-
|
|
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?.(".
|
|
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
|
-
|
|
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"
|
|
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
|
],
|