@nanocollective/roster 0.1.0-alpha.9 → 0.1.0-beta.1
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 +5 -0
- package/dist/cli.js +4067 -1950
- package/dist/worker/assets/assets/css/base.css +312 -0
- package/dist/worker/assets/assets/css/brain.css +116 -0
- package/dist/worker/assets/assets/css/diff.css +33 -0
- package/dist/worker/assets/assets/css/graph.css +39 -0
- package/dist/worker/assets/assets/css/health.css +75 -0
- package/dist/worker/assets/assets/css/home.css +101 -0
- package/dist/worker/assets/assets/css/inbox.css +199 -0
- package/dist/worker/assets/assets/css/layout.css +175 -0
- package/dist/worker/assets/assets/css/markdown.css +96 -0
- package/dist/worker/assets/assets/css/runs.css +13 -0
- package/dist/worker/assets/assets/css/search.css +48 -0
- package/dist/worker/assets/assets/css/setup.css +194 -0
- package/dist/worker/assets/assets/js/api.js +161 -0
- package/dist/worker/assets/assets/js/app.js +465 -0
- package/dist/worker/assets/assets/js/dialog.js +196 -0
- package/dist/worker/assets/assets/js/dom.js +131 -0
- package/dist/worker/assets/assets/js/homesort.js +174 -0
- package/dist/worker/assets/assets/js/icons.js +142 -0
- package/dist/worker/assets/assets/js/inflight.js +18 -0
- package/dist/worker/assets/assets/js/lightbox.js +273 -0
- package/dist/worker/assets/assets/js/md.js +406 -0
- package/dist/worker/assets/assets/js/mdedit.js +84 -0
- package/dist/worker/assets/assets/js/mention.js +264 -0
- package/dist/worker/assets/assets/js/readiness.js +70 -0
- package/dist/worker/assets/assets/js/refresh.js +197 -0
- package/dist/worker/assets/assets/js/router.js +20 -0
- package/dist/worker/assets/assets/js/search.js +366 -0
- package/dist/worker/assets/assets/js/state.js +213 -0
- package/dist/worker/assets/assets/js/textdiff.js +96 -0
- package/dist/worker/assets/assets/js/views/app.js +145 -0
- package/dist/worker/assets/assets/js/views/brain.js +260 -0
- package/dist/worker/assets/assets/js/views/changed.js +157 -0
- package/dist/worker/assets/assets/js/views/checklist.js +115 -0
- package/dist/worker/assets/assets/js/views/credential.js +84 -0
- package/dist/worker/assets/assets/js/views/docs.js +174 -0
- package/dist/worker/assets/assets/js/views/files.js +139 -0
- package/dist/worker/assets/assets/js/views/graph.js +436 -0
- package/dist/worker/assets/assets/js/views/health.js +304 -0
- package/dist/worker/assets/assets/js/views/hire.js +593 -0
- package/dist/worker/assets/assets/js/views/home.js +585 -0
- package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
- package/dist/worker/assets/assets/js/views/memory.js +150 -0
- package/dist/worker/assets/assets/js/views/org.js +195 -0
- package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
- package/dist/worker/assets/assets/js/views/paste.js +216 -0
- package/dist/worker/assets/assets/js/views/prompt.js +457 -0
- package/dist/worker/assets/assets/js/views/repos.js +97 -0
- package/dist/worker/assets/assets/js/views/runonce.js +94 -0
- package/dist/worker/assets/assets/js/views/runs.js +182 -0
- package/dist/worker/assets/assets/js/views/setup.js +557 -0
- package/dist/worker/assets/assets/js/views/staff.js +291 -0
- package/dist/worker/assets/assets/js/views/todo.js +62 -0
- package/dist/worker/assets/assets/js/yaml.js +134 -0
- package/dist/worker/assets/docs-images/brain.jpg +0 -0
- package/dist/worker/assets/docs-images/home.jpg +0 -0
- package/dist/worker/assets/docs-images/org.jpg +0 -0
- package/dist/worker/assets/docs-images/prompt.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
- package/dist/worker/assets/docs-images/staff.jpg +0 -0
- package/dist/worker/assets/index.html +82 -0
- package/dist/worker/index.js +4430 -0
- package/docs/README.md +2 -2
- package/docs/architecture.md +1 -1
- package/docs/charters/analyst.md +65 -0
- package/docs/charters/community.md +63 -0
- package/docs/charters/designer.md +65 -0
- package/docs/charters/devops.md +65 -0
- package/docs/charters/pm.md +70 -0
- package/docs/charters/qa.md +65 -0
- package/docs/charters/writer.md +63 -0
- package/docs/commands.md +9 -3
- package/docs/concepts.md +33 -20
- package/docs/cost.md +3 -3
- package/docs/developing.md +27 -9
- package/docs/doctor-codes.md +3 -1
- package/docs/export.md +2 -0
- package/docs/getting-started.md +44 -27
- package/docs/hosting.md +89 -43
- package/docs/images/brain.jpg +0 -0
- package/docs/images/home.jpg +0 -0
- package/docs/images/org.jpg +0 -0
- package/docs/images/prompt.jpg +0 -0
- package/docs/images/staff.jpg +0 -0
- package/docs/manual-steps.md +3 -2
- package/docs/org-yaml.md +3 -0
- package/docs/portal.md +143 -45
- package/docs/prompts.md +6 -0
- package/docs/security.md +57 -11
- package/docs/session-workflow.md +14 -0
- package/docs/staff-yaml.md +17 -1
- package/docs/upgrading.md +3 -3
- package/docs/writing-a-charter.md +19 -6
- package/package.json +4 -3
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
- package/templates/brain/staff.yaml +4 -1
- package/templates/briefs/amend.md +4 -3
- package/templates/briefs/priorities.md +46 -0
- package/templates/ops/.github/workflows/session.yaml +137 -3
- package/templates/ops/compose.mjs +35 -8
- package/templates/ops/org/operating.md +29 -10
- package/templates/ops/prompts/daily.md +23 -4
- package/templates/ops/prompts/mention.md +19 -0
- package/templates/ops/run-record.mjs +5 -3
- package/templates/portal/css/base.css +34 -0
- package/templates/portal/css/health.css +14 -1
- package/templates/portal/css/home.css +101 -0
- package/templates/portal/css/inbox.css +21 -4
- package/templates/portal/css/layout.css +29 -3
- package/templates/portal/css/markdown.css +19 -0
- package/templates/portal/css/search.css +48 -0
- package/templates/portal/css/setup.css +79 -4
- package/templates/portal/index.html +15 -9
- package/templates/portal/js/api.js +30 -4
- package/templates/portal/js/app.js +90 -7
- package/templates/portal/js/dialog.js +36 -0
- package/templates/portal/js/homesort.js +174 -0
- package/templates/portal/js/icons.js +41 -0
- package/templates/portal/js/inflight.js +18 -0
- package/templates/portal/js/md.js +5 -2
- package/templates/portal/js/mdedit.js +84 -0
- package/templates/portal/js/readiness.js +70 -0
- package/templates/portal/js/refresh.js +10 -2
- package/templates/portal/js/search.js +366 -0
- package/templates/portal/js/state.js +11 -5
- package/templates/portal/js/views/app.js +1 -2
- package/templates/portal/js/views/brain.js +1 -1
- package/templates/portal/js/views/checklist.js +19 -4
- package/templates/portal/js/views/credential.js +42 -51
- package/templates/portal/js/views/health.js +11 -6
- package/templates/portal/js/views/hire.js +593 -0
- package/templates/portal/js/views/home.js +585 -0
- package/templates/portal/js/views/inbox.js +237 -68
- package/templates/portal/js/views/org.js +31 -111
- package/templates/portal/js/views/orgedit.js +240 -0
- package/templates/portal/js/views/paste.js +111 -66
- package/templates/portal/js/views/prompt.js +94 -40
- package/templates/portal/js/views/repos.js +10 -10
- package/templates/portal/js/views/runs.js +21 -4
- package/templates/portal/js/views/setup.js +130 -163
- package/templates/portal/js/views/staff.js +181 -301
- package/templates/portal/js/views/todo.js +62 -0
|
@@ -1,50 +1,166 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* The Staff screen: a card per staff member, retiring, and the way in to hiring.
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Plan then apply, the same as every roster command that changes something: you see every
|
|
8
|
-
* file, every label and every existing staff member it would edit, and nothing happens until
|
|
9
|
-
* you say so.
|
|
3
|
+
* Hiring itself is in hire.js. Retiring runs the CLI's own `buildRetirePlan` and
|
|
4
|
+
* `applyRetirePlan` on the server, plan then apply: you see what it stops and what it keeps,
|
|
5
|
+
* and nothing happens until you say so.
|
|
10
6
|
*/
|
|
11
7
|
|
|
12
8
|
import { post } from "../api.js";
|
|
13
|
-
import { askYes } from "../dialog.js";
|
|
9
|
+
import { askYes, sheet } from "../dialog.js";
|
|
10
|
+
import { pending } from "../inflight.js";
|
|
14
11
|
import { ago, el, esc } from "../dom.js";
|
|
15
|
-
import {
|
|
12
|
+
import { sentence, staffProgress, whatsLeft } from "../readiness.js";
|
|
16
13
|
import { refreshAll } from "../refresh.js";
|
|
17
14
|
import { S } from "../state.js";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
import { hireFlow, line, rolePicker } from "./hire.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Resolves once nothing is loading and `node` has stopped changing for a moment, or after a few
|
|
19
|
+
* seconds regardless. Quiet alone was not enough: while GitHub was still answering, nothing
|
|
20
|
+
* changed, and the half-built list was shown.
|
|
21
|
+
*/
|
|
22
|
+
function settled(node, quiet = 250, most = 6000) {
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
if (typeof MutationObserver !== "function") return resolve();
|
|
25
|
+
let lastChange = Date.now();
|
|
26
|
+
const obs = new MutationObserver(() => {
|
|
27
|
+
lastChange = Date.now();
|
|
28
|
+
});
|
|
29
|
+
obs.observe(node, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
30
|
+
const started = Date.now();
|
|
31
|
+
const tick = setInterval(() => {
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
if ((pending() === 0 && now - lastChange >= quiet) || now - started >= most) {
|
|
34
|
+
clearInterval(tick);
|
|
35
|
+
obs.disconnect();
|
|
36
|
+
resolve();
|
|
37
|
+
}
|
|
38
|
+
}, 50);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* The open dialog, if any. It lives on <body>, so it outlives a repaint of this screen, and a
|
|
43
|
+
background refresh leaves whatever was typed into it alone. */
|
|
44
|
+
let current = null;
|
|
23
45
|
|
|
24
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @param {{open?: string, result?: object}} [o] `open` keeps one staff member's steps on
|
|
48
|
+
* screen across a repaint, which is how a finished hire lands on step 2.
|
|
49
|
+
*/
|
|
50
|
+
export function viewStaff(m, o = {}) {
|
|
25
51
|
m.append(el("h1", { textContent: "Staff" }));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
const empty = !S.data.staff.length;
|
|
53
|
+
if (empty) m.append(el("p", { className: "sub", textContent: "No staff yet. Pick a role to hire your first." }));
|
|
54
|
+
|
|
55
|
+
const pane = el("div", { className: "hirepane" });
|
|
56
|
+
|
|
57
|
+
/* Tasks open in a dialog. Where there is no dialog element (the test shim) they draw into
|
|
58
|
+
the pane instead, which is how this screen always drew them. */
|
|
59
|
+
function present(node) {
|
|
60
|
+
const spin = el("div", { className: "sheetloading" }, [el("span", { className: "spinner" })]);
|
|
61
|
+
if (current?.isOpen()) current.set(spin);
|
|
62
|
+
else {
|
|
63
|
+
current = sheet({
|
|
64
|
+
node: spin,
|
|
65
|
+
onClose: () => {
|
|
66
|
+
current = null;
|
|
67
|
+
S.staffOpen = null;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
if (!current) {
|
|
71
|
+
pane.replaceChildren(node);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/* The list is built from half a dozen answers arriving one by one, and showing each as it
|
|
76
|
+
landed meant the dialog reflowed four times. It is shown once it has stopped changing. */
|
|
77
|
+
const mine = current;
|
|
78
|
+
settled(node).then(() => {
|
|
79
|
+
if (mine.isOpen() && current === mine) mine.set(node);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function dismiss() {
|
|
83
|
+
if (current) current.close();
|
|
84
|
+
else pane.replaceChildren();
|
|
85
|
+
S.staffOpen = null;
|
|
86
|
+
if (empty) pick();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// With nobody hired the roles are the page. After that they are a dialog behind Hire someone.
|
|
90
|
+
function pick() {
|
|
91
|
+
if (empty) {
|
|
92
|
+
pane.replaceChildren(rolePicker({ onPick: (role) => open(role) }));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
96
|
+
cancel.onclick = dismiss;
|
|
97
|
+
present(
|
|
98
|
+
el("div", {}, [
|
|
99
|
+
el("h2", { className: "sheettitle", textContent: "Pick a role" }),
|
|
100
|
+
rolePicker({ onPick: (role) => open(role) }),
|
|
101
|
+
el("div", { className: "row", style: "margin-top:14px" }, [cancel]),
|
|
102
|
+
]),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
35
105
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
106
|
+
/* One staff member's steps, hired or not yet. A hire repaints the whole screen, so the new
|
|
107
|
+
card is in the list and the steps reopen on the same person. */
|
|
108
|
+
function open(role, result) {
|
|
109
|
+
// Remembered, so a refresh after a trip to GitHub (creating the App) reopens it.
|
|
110
|
+
S.staffOpen = role;
|
|
111
|
+
present(
|
|
112
|
+
hireFlow({
|
|
113
|
+
role,
|
|
114
|
+
result,
|
|
115
|
+
onHired: (handle, r) => {
|
|
116
|
+
m.replaceChildren();
|
|
117
|
+
viewStaff(m, { open: handle, result: r });
|
|
118
|
+
},
|
|
119
|
+
onClose: dismiss,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
39
123
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
124
|
+
if (!empty) {
|
|
125
|
+
const list = el("div", { className: "grid", style: "margin-bottom:18px" });
|
|
126
|
+
for (const s of S.data.staff) list.append(card(s));
|
|
127
|
+
// In the grid, where the next person would go, rather than a button under it.
|
|
128
|
+
if (!S.hosted) {
|
|
129
|
+
const hire = el("button", { className: "hirecard", textContent: "Hire someone" });
|
|
130
|
+
hire.onclick = pick;
|
|
131
|
+
list.append(hire);
|
|
132
|
+
}
|
|
133
|
+
m.append(list);
|
|
134
|
+
// Hiring creates repos and Apps and writes secrets, which is done from your own machine.
|
|
135
|
+
if (S.hosted) {
|
|
136
|
+
m.append(
|
|
137
|
+
el("p", {
|
|
138
|
+
className: "sub",
|
|
139
|
+
textContent: "Hire, retire and finish setting up in roster portal on your machine.",
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
44
144
|
m.append(pane);
|
|
45
145
|
|
|
146
|
+
const opened = o.open && S.data.staff.find((s) => s.handle === o.open);
|
|
147
|
+
const kept = !opened && S.staffOpen;
|
|
148
|
+
const keptStaff = kept && S.data.staff.find((s) => s.handle === kept.handle);
|
|
149
|
+
if (empty) pick();
|
|
150
|
+
if (opened) open(roleOf(opened), o.result);
|
|
151
|
+
// An open dialog is still open; only the inline fallback has to be drawn again.
|
|
152
|
+
else if (kept && !current?.isOpen()) open(keptStaff ? roleOf(keptStaff) : kept);
|
|
153
|
+
|
|
46
154
|
/* --------------------------- one staff member --------------------------- */
|
|
47
155
|
|
|
156
|
+
/** " · works with Chief Marketing Officer". The labels and wiring behind it are roster's. */
|
|
157
|
+
function worksWith(s) {
|
|
158
|
+
const names = (s.peers ?? [])
|
|
159
|
+
.map((p) => S.data.staff.find((x) => x.handle === p.handle)?.name ?? p.handle)
|
|
160
|
+
.filter(Boolean);
|
|
161
|
+
return names.length ? " · works with " + esc(names.join(", ")) : "";
|
|
162
|
+
}
|
|
163
|
+
|
|
48
164
|
function card(s) {
|
|
49
165
|
const d = el("div", { className: "kv staffcard" });
|
|
50
166
|
const rig = s.rig ?? {};
|
|
@@ -53,198 +169,43 @@ export function viewStaff(m) {
|
|
|
53
169
|
'<div class="v">' + esc(s.name) +
|
|
54
170
|
"<small>" + esc(s.brain ?? s.dir) + " · " + s.facts.length + " facts · " +
|
|
55
171
|
(rig.lastCommit ? "last commit " + esc(ago(rig.lastCommit.date)) : "no commits") +
|
|
172
|
+
worksWith(s) +
|
|
56
173
|
"</small></div>";
|
|
57
174
|
|
|
58
175
|
const status = el("span", { className: "meta" });
|
|
59
176
|
const go = el("button", { className: "ghbtn", textContent: "Retire" });
|
|
60
|
-
go.onclick = () =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
it refers to already inside it and somewhere to put the answer. */
|
|
65
|
-
const write = el("button", { className: "ghbtn", textContent: "Write the charter" });
|
|
66
|
-
write.onclick = () => {
|
|
67
|
-
pane.replaceChildren(
|
|
68
|
-
el("div", { className: "card" }, [
|
|
69
|
-
paste({
|
|
70
|
-
kind: "charter",
|
|
71
|
-
staff: s.handle,
|
|
72
|
-
title: "Write " + s.name + "'s charter with your own AI",
|
|
73
|
-
onSaved: () => refreshAll(false),
|
|
74
|
-
}),
|
|
75
|
-
]),
|
|
76
|
-
);
|
|
77
|
-
pane.scrollIntoView?.({ behavior: "smooth", block: "start" });
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/* The step `hire` has always had to hand back: there is no API that creates a GitHub App,
|
|
81
|
-
so it is a browser hand-off either way. It may as well be this browser. */
|
|
82
|
-
const app = el("button", { className: "ghbtn", textContent: "GitHub App" });
|
|
83
|
-
app.onclick = () => {
|
|
84
|
-
pane.replaceChildren(
|
|
85
|
-
el("div", { className: "card" }, [
|
|
86
|
-
el("h3", { textContent: s.name + "'s identity" }),
|
|
87
|
-
appPanel({ staff: s.handle, name: s.name, scope: "private" }),
|
|
88
|
-
appPanel({ staff: s.handle, name: s.name, scope: "public" }),
|
|
89
|
-
]),
|
|
90
|
-
);
|
|
91
|
-
pane.scrollIntoView?.({ behavior: "smooth", block: "start" });
|
|
177
|
+
go.onclick = () => {
|
|
178
|
+
const host = el("div");
|
|
179
|
+
present(host);
|
|
180
|
+
retireForm(host, s, status);
|
|
92
181
|
};
|
|
93
182
|
|
|
94
|
-
/*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
183
|
+
/* Every setup step (the App, the charter, the credential, a run) is in the one list, so the
|
|
184
|
+
card has one way in. It says Finish setting up until setup looks finished: the charter
|
|
185
|
+
from disk at once, and the App's secrets and a first run from GitHub when it answers. */
|
|
186
|
+
const finish = el("button", { className: "ghbtn", textContent: "Set up" });
|
|
187
|
+
finish.onclick = () => open(roleOf(s));
|
|
188
|
+
const warn = el("p", { className: "warnline", hidden: true });
|
|
189
|
+
whatsLeft(s).then((left) => {
|
|
190
|
+
if (!left.length) return;
|
|
191
|
+
finish.textContent = "Finish setting up";
|
|
192
|
+
finish.className = "ghbtn primary";
|
|
193
|
+
d.classList.add("notready");
|
|
194
|
+
warn.hidden = false;
|
|
195
|
+
const p = staffProgress(s.handle);
|
|
196
|
+
warn.textContent =
|
|
197
|
+
"Not ready to run. " + (p ? `${p.done} of ${p.total} done. ` : "") +
|
|
198
|
+
"Still to do: " + sentence(left) + ".";
|
|
199
|
+
});
|
|
200
|
+
d.append(warn);
|
|
201
|
+
|
|
202
|
+
// Both create or delete things only your own machine can: Apps, secrets, repos.
|
|
203
|
+
if (!S.hosted) {
|
|
204
|
+
d.append(
|
|
205
|
+
el("div", { className: "row", style: "margin-top:10px" }, [finish, go, status]),
|
|
108
206
|
);
|
|
109
|
-
pane.scrollIntoView?.({ behavior: "smooth", block: "start" });
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
d.append(
|
|
113
|
-
el("div", { className: "row", style: "margin-top:10px" }, [write, app, cred, run, go, status]),
|
|
114
|
-
);
|
|
115
|
-
return d;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* ------------------------------- hiring -------------------------------- */
|
|
119
|
-
|
|
120
|
-
function hireForm(host) {
|
|
121
|
-
/* App names are copied from whoever is already here. The first hire has nobody to copy
|
|
122
|
-
from, and the CLI asks for --app and --public-app at that point; these are those two. */
|
|
123
|
-
const first = !S.data.staff.length;
|
|
124
|
-
const box = el("div", { className: "card" });
|
|
125
|
-
box.append(
|
|
126
|
-
el("h3", { textContent: "Hire someone" }),
|
|
127
|
-
el("p", {
|
|
128
|
-
className: "sub",
|
|
129
|
-
style: "margin-bottom:14px",
|
|
130
|
-
textContent: first
|
|
131
|
-
? "Only the handle is required. This is the first hire, so there is nobody to copy " +
|
|
132
|
-
"App names from: name them here, and later hires follow the pattern."
|
|
133
|
-
: "Only the handle is required. Everything else is copied from whoever is already " +
|
|
134
|
-
"here, because app slugs carry a house naming scheme and the public identity is " +
|
|
135
|
-
"genuinely shared.",
|
|
136
|
-
}),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const handle = field("handle", "cfo", "lowercase, digits and dashes");
|
|
140
|
-
const name = field("name", "Chief Financial Officer", "defaults to the handle, uppercased");
|
|
141
|
-
const dir = field("dir", "finance", "directory and repo name; defaults to the handle");
|
|
142
|
-
const schedule = scheduleField();
|
|
143
|
-
const fields = [handle, name, dir, schedule];
|
|
144
|
-
const apps = [];
|
|
145
|
-
if (first) {
|
|
146
|
-
const org = S.data.org;
|
|
147
|
-
apps.push(
|
|
148
|
-
["app", field("app", org + "-cfo", "this staff member's GitHub App. Names are unique across GitHub, so prefix it")],
|
|
149
|
-
["publicApp", field("public app", org + "-robot", "the shared identity for public product repos. Optional when they are all private")],
|
|
150
|
-
);
|
|
151
|
-
fields.push(...apps.map(([, f]) => f));
|
|
152
|
-
}
|
|
153
|
-
for (const f of fields) box.append(f.row);
|
|
154
|
-
|
|
155
|
-
const status = el("span", { className: "meta" });
|
|
156
|
-
const plan = el("button", { className: "ghbtn primary", textContent: "Show the plan" });
|
|
157
|
-
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
158
|
-
cancel.onclick = () => host.replaceChildren();
|
|
159
|
-
box.append(el("div", { className: "row", style: "margin-top:12px" }, [plan, cancel, status]));
|
|
160
|
-
|
|
161
|
-
const out = el("div");
|
|
162
|
-
box.append(out);
|
|
163
|
-
host.replaceChildren(box);
|
|
164
|
-
handle.input.focus();
|
|
165
|
-
|
|
166
|
-
plan.onclick = async () => {
|
|
167
|
-
if (!handle.input.value.trim()) {
|
|
168
|
-
handle.input.focus();
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
status.textContent = "planning…";
|
|
172
|
-
status.className = "meta";
|
|
173
|
-
out.replaceChildren();
|
|
174
|
-
const params = new URLSearchParams({ handle: handle.input.value.trim() });
|
|
175
|
-
for (const [key, f] of [["name", name], ["dir", dir], ["schedule", schedule], ...apps]) {
|
|
176
|
-
const value = (f.value ? f.value() : f.input.value).trim();
|
|
177
|
-
if (value) params.set(key, value);
|
|
178
|
-
}
|
|
179
|
-
try {
|
|
180
|
-
const data = await (await fetch("/api/staff/plan?" + params, { cache: "no-store" })).json();
|
|
181
|
-
if (data.error) throw new Error(data.error);
|
|
182
|
-
status.textContent = "";
|
|
183
|
-
out.replaceChildren(hirePlan(data.plan, params));
|
|
184
|
-
} catch (e) {
|
|
185
|
-
status.textContent = e.message;
|
|
186
|
-
status.className = "meta err";
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function hirePlan(plan, params) {
|
|
192
|
-
const box = el("div", { className: "plan" });
|
|
193
|
-
box.append(el("div", { className: "planhead", textContent: "This would create" }));
|
|
194
|
-
|
|
195
|
-
const s = plan.staff;
|
|
196
|
-
box.append(
|
|
197
|
-
line("ok", s.brain + ", private"),
|
|
198
|
-
line("ok", plan.files.length + " files, including three caller workflows"),
|
|
199
|
-
line("ok", plan.labels.length + " labels: " + plan.labels.join(", ")),
|
|
200
|
-
line("ok", "a pinned status issue"),
|
|
201
|
-
line("ok", "runs at " + s.schedule + ", on " + s.model),
|
|
202
|
-
);
|
|
203
|
-
for (const p of plan.peers) {
|
|
204
|
-
box.append(line("ok", p.brain + " gains a " + p.label + " label"));
|
|
205
207
|
}
|
|
206
|
-
|
|
207
|
-
somebody else's repo, and a plan that hid them would be the silent kind. */
|
|
208
|
-
box.append(el("div", { className: "planhead", textContent: "Commits and pushes, as you" }));
|
|
209
|
-
for (const c of plan.commits ?? []) box.append(line("ok", c.repo + ": " + c.file + ", " + c.why));
|
|
210
|
-
|
|
211
|
-
const cred = s.agentSecret ?? "the agent credential";
|
|
212
|
-
box.append(
|
|
213
|
-
plan.orgSecret?.visibility === "selected"
|
|
214
|
-
? line("ok", s.brain + " is added to the repos that can read the org secret " + cred)
|
|
215
|
-
: plan.orgSecret
|
|
216
|
-
? line("ok", "the org secret " + cred + " already reaches " + plan.orgSecret.visibility + " repos")
|
|
217
|
-
: line("warn", "no org secret " + cred + " yet: store it once with Agent credential, after this"),
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
box.append(el("div", { className: "planhead", textContent: "Then, on the new card" }));
|
|
221
|
-
box.append(
|
|
222
|
-
line(
|
|
223
|
-
"todo",
|
|
224
|
-
"GitHub App, or roster app " + s.handle + " --apply: creates it, sets its secrets, and " +
|
|
225
|
-
"opens the install page with the repos already ticked",
|
|
226
|
-
),
|
|
227
|
-
line("todo", "Write the charter"),
|
|
228
|
-
line("todo", "Run once now, or roster run " + s.handle + " --apply: the run that proves the wiring"),
|
|
229
|
-
);
|
|
230
|
-
for (const w of plan.warnings ?? []) box.append(line("warn", S.data.staff.length ? w : portalWords(w)));
|
|
231
|
-
|
|
232
|
-
const status = el("span", { className: "meta" });
|
|
233
|
-
const go = el("button", { className: "ghbtn primary", textContent: "Hire " + s.handle });
|
|
234
|
-
go.onclick = () =>
|
|
235
|
-
apply(
|
|
236
|
-
{
|
|
237
|
-
action: "hire",
|
|
238
|
-
handle: s.handle,
|
|
239
|
-
flags: Object.fromEntries(params),
|
|
240
|
-
},
|
|
241
|
-
{ title: "Create " + s.brain + " and wire it up?", hint: "This creates a repository on GitHub.", confirm: "Hire " + s.handle },
|
|
242
|
-
go,
|
|
243
|
-
status,
|
|
244
|
-
box,
|
|
245
|
-
);
|
|
246
|
-
box.append(el("div", { className: "row", style: "margin-top:14px" }, [go, status]));
|
|
247
|
-
return box;
|
|
208
|
+
return d;
|
|
248
209
|
}
|
|
249
210
|
|
|
250
211
|
/* ------------------------------- retiring ------------------------------- */
|
|
@@ -289,7 +250,7 @@ export function viewStaff(m) {
|
|
|
289
250
|
const status = el("span", { className: "meta" });
|
|
290
251
|
const go = el("button", { className: "ghbtn", textContent: "Retire " + plan.handle });
|
|
291
252
|
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
292
|
-
cancel.onclick =
|
|
253
|
+
cancel.onclick = dismiss;
|
|
293
254
|
go.onclick = () =>
|
|
294
255
|
apply(
|
|
295
256
|
{ action: "retire", handle: plan.handle },
|
|
@@ -324,88 +285,7 @@ export function viewStaff(m) {
|
|
|
324
285
|
}
|
|
325
286
|
}
|
|
326
287
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return warning
|
|
331
|
-
.replace(/pass --public-app\b/, "fill in public app above")
|
|
332
|
-
.replace(/pass --app\b/, "fill in app above");
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function field(label, placeholder, hint) {
|
|
336
|
-
const input = el("input", { type: "search", placeholder, value: "", style: "width:100%" });
|
|
337
|
-
input.dataset.field = label;
|
|
338
|
-
const row = el("div", { className: "ffield" });
|
|
339
|
-
row.append(
|
|
340
|
-
el("label", { textContent: label }),
|
|
341
|
-
input,
|
|
342
|
-
el("small", { textContent: hint }),
|
|
343
|
-
);
|
|
344
|
-
return { row, input };
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* When the daily run happens, as a time and a set of days rather than as cron.
|
|
349
|
-
*
|
|
350
|
-
* The value on the wire is still a cron expression, because that is what goes in the workflow
|
|
351
|
-
* and what `roster hire` takes. But nobody hiring their first staff member knows that
|
|
352
|
-
* `0 9 * * 1-5` is nine in the morning on weekdays, and a field that demands it is a field
|
|
353
|
-
* that gets a wrong answer or an empty one.
|
|
354
|
-
*
|
|
355
|
-
* UTC, said out loud, with the local equivalent beside it: GitHub schedules in UTC, and an
|
|
356
|
-
* agent that starts an hour off twice a year is worse than one you had to think about once.
|
|
357
|
-
*/
|
|
358
|
-
function scheduleField() {
|
|
359
|
-
const time = el("input", { type: "time", value: "", step: "60", style: "width:130px" });
|
|
360
|
-
const days = el("select");
|
|
361
|
-
days.append(
|
|
362
|
-
el("option", { value: "1-5", textContent: "Weekdays" }),
|
|
363
|
-
el("option", { value: "*", textContent: "Every day" }),
|
|
364
|
-
el("option", { value: "1", textContent: "Mondays" }),
|
|
365
|
-
el("option", { value: "1,3,5", textContent: "Mon, Wed, Fri" }),
|
|
366
|
-
);
|
|
367
|
-
// Said rather than relying on "the first option is selected", which is true of a rendered
|
|
368
|
-
// <select> and not of one that has only been built.
|
|
369
|
-
days.value = "1-5";
|
|
370
|
-
|
|
371
|
-
const said = el("small");
|
|
372
|
-
const value = () => {
|
|
373
|
-
if (!time.value) return "";
|
|
374
|
-
const [h, m] = time.value.split(":");
|
|
375
|
-
return `${Number(m)} ${Number(h)} * * ${days.value}`;
|
|
376
|
-
};
|
|
377
|
-
const say = () => {
|
|
378
|
-
const cron = value();
|
|
379
|
-
said.textContent = cron
|
|
380
|
-
? cronText(cron) + local(time.value)
|
|
381
|
-
: "Leave it empty for a slot clear of everyone else.";
|
|
382
|
-
};
|
|
383
|
-
time.oninput = say;
|
|
384
|
-
days.onchange = say;
|
|
385
|
-
say();
|
|
386
|
-
|
|
387
|
-
const row = el("div", { className: "ffield" });
|
|
388
|
-
row.append(
|
|
389
|
-
el("label", { textContent: "schedule" }),
|
|
390
|
-
el("div", { className: "row" }, [time, days, el("span", { className: "meta", textContent: "UTC" })]),
|
|
391
|
-
said,
|
|
392
|
-
);
|
|
393
|
-
return { row, input: time, value };
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/** What that UTC time is where the person reading it is, when the two differ. */
|
|
397
|
-
function local(hhmm) {
|
|
398
|
-
if (!hhmm) return "";
|
|
399
|
-
const [h, m] = hhmm.split(":").map(Number);
|
|
400
|
-
const at = new Date(Date.UTC(2026, 0, 5, h, m));
|
|
401
|
-
const here = at.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
|
|
402
|
-
return here === hhmm ? "" : " · " + here + " where you are";
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
const MARK = { ok: "check", stop: "closed", keep: "issue-open", todo: "dash", warn: "label" };
|
|
406
|
-
|
|
407
|
-
function line(kind, text) {
|
|
408
|
-
const d = el("div", { className: "planline " + kind });
|
|
409
|
-
d.append(icon(MARK[kind] ?? "dot", "ic"), el("span", { textContent: text }));
|
|
410
|
-
return d;
|
|
288
|
+
/** The flow's view of somebody already hired. */
|
|
289
|
+
function roleOf(s) {
|
|
290
|
+
return { handle: s.handle, name: s.name, dir: s.dir };
|
|
411
291
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* The numbered step card shared by Getting started and the hiring flow on the Staff screen. */
|
|
2
|
+
|
|
3
|
+
import { el } from "../dom.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One numbered thing to do. Done ones fold to a single ticked line, and Change opens them again,
|
|
7
|
+
* so the list shows what is left without hiding what was done.
|
|
8
|
+
*
|
|
9
|
+
* `setLocked(reason)` greys a step that cannot start yet and says why in the pill; `null`
|
|
10
|
+
* unlocks it. A locked step shows no body, because a form you cannot use yet is a trap.
|
|
11
|
+
*/
|
|
12
|
+
export function todo(n, title, done) {
|
|
13
|
+
const card = el("section", { className: "todo" });
|
|
14
|
+
const num = el("span", { className: "todon" });
|
|
15
|
+
const pill = el("span", { className: "todopill" });
|
|
16
|
+
const change = el("button", { className: "ghbtn todochange", textContent: "Change" });
|
|
17
|
+
const head = el("div", { className: "todohead" }, [num, el("h3", { textContent: title }), pill, change]);
|
|
18
|
+
const hintEl = el("p", { className: "sub todohint" });
|
|
19
|
+
const body = el("div", { className: "todobody" });
|
|
20
|
+
card.append(head, hintEl, body);
|
|
21
|
+
let open = false;
|
|
22
|
+
let locked = null;
|
|
23
|
+
let isDone = done;
|
|
24
|
+
const paint = () => {
|
|
25
|
+
card.classList.toggle("done", isDone && !locked);
|
|
26
|
+
card.classList.toggle("locked", Boolean(locked));
|
|
27
|
+
num.textContent = isDone && !locked ? "✓" : String(n);
|
|
28
|
+
pill.textContent = locked ?? (isDone ? "Done" : "To do");
|
|
29
|
+
change.hidden = !isDone || Boolean(locked);
|
|
30
|
+
const shown = !locked && (!isDone || open);
|
|
31
|
+
body.hidden = !shown;
|
|
32
|
+
hintEl.hidden = !shown || !hintEl.textContent;
|
|
33
|
+
};
|
|
34
|
+
const setDone = (d) => {
|
|
35
|
+
isDone = Boolean(d);
|
|
36
|
+
paint();
|
|
37
|
+
};
|
|
38
|
+
change.onclick = () => {
|
|
39
|
+
open = !open;
|
|
40
|
+
change.textContent = open ? "Close" : "Change";
|
|
41
|
+
paint();
|
|
42
|
+
};
|
|
43
|
+
paint();
|
|
44
|
+
return {
|
|
45
|
+
card,
|
|
46
|
+
body,
|
|
47
|
+
setDone,
|
|
48
|
+
isDone: () => isDone,
|
|
49
|
+
setLocked: (reason) => {
|
|
50
|
+
locked = reason || null;
|
|
51
|
+
paint();
|
|
52
|
+
},
|
|
53
|
+
renumber: (m) => {
|
|
54
|
+
n = m;
|
|
55
|
+
paint();
|
|
56
|
+
},
|
|
57
|
+
hint: (text) => {
|
|
58
|
+
hintEl.textContent = text;
|
|
59
|
+
paint();
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|