@nanocollective/roster 0.1.0-alpha.9 → 0.1.0-beta.10
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 +6 -0
- package/dist/cli.js +4189 -1971
- package/dist/worker/assets/assets/css/base.css +327 -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 +114 -0
- package/dist/worker/assets/assets/css/inbox.css +199 -0
- package/dist/worker/assets/assets/css/layout.css +181 -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 +191 -0
- package/dist/worker/assets/assets/js/app.js +500 -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 +621 -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 +5143 -0
- package/docs/README.md +2 -2
- package/docs/architecture.md +23 -4
- 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 +36 -9
- package/docs/concepts.md +34 -21
- package/docs/cost.md +3 -3
- package/docs/developing.md +28 -10
- package/docs/doctor-codes.md +3 -1
- package/docs/export.md +2 -0
- package/docs/getting-started.md +49 -29
- package/docs/hosting.md +114 -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/memory.md +2 -1
- package/docs/org-yaml.md +3 -0
- package/docs/portal.md +144 -45
- package/docs/prompts.md +6 -0
- package/docs/security.md +70 -11
- package/docs/session-workflow.md +24 -6
- package/docs/staff-yaml.md +21 -2
- 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/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- 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 +150 -3
- package/templates/ops/compose.mjs +35 -8
- package/templates/ops/org/operating.md +29 -10
- package/templates/ops/org/voice.md +2 -1
- package/templates/ops/prompts/daily.md +51 -14
- package/templates/ops/prompts/mention.md +24 -2
- package/templates/ops/run-record.mjs +5 -3
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/base.css +49 -0
- package/templates/portal/css/health.css +14 -1
- package/templates/portal/css/home.css +114 -0
- package/templates/portal/css/inbox.css +21 -4
- package/templates/portal/css/layout.css +35 -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 +60 -4
- package/templates/portal/js/app.js +125 -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 +621 -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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Whether each staff member can actually run yet.
|
|
2
|
+
*
|
|
3
|
+
* A hire that had its App created but not installed, and no credential, looked finished: the
|
|
4
|
+
* card said so and Getting started went away. This is the one answer every screen asks. */
|
|
5
|
+
|
|
6
|
+
import { getStaffProgress } from "./api.js";
|
|
7
|
+
import { S } from "./state.js";
|
|
8
|
+
|
|
9
|
+
/** What is left for one staff member, as short instructions. Empty when they are ready. */
|
|
10
|
+
export async function whatsLeft(s, fresh = false) {
|
|
11
|
+
const left = [];
|
|
12
|
+
if (s.rig?.charterStub) left.push("write the charter");
|
|
13
|
+
const p = await getStaffProgress(s.handle, fresh).catch(() => ({}));
|
|
14
|
+
if (p.installed === false) left.push(p.app ? "install the GitHub App" : "create the GitHub App");
|
|
15
|
+
if (p.credential === false) left.push("add the agent credential");
|
|
16
|
+
if (p.ran === false) left.push("run once");
|
|
17
|
+
S.readiness = { ...(S.readiness ?? {}), [s.handle]: left };
|
|
18
|
+
return left;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Every staff member's, then `then` once all have answered. */
|
|
22
|
+
export function checkAll(then) {
|
|
23
|
+
return Promise.all((S.data?.staff ?? []).map((s) => whatsLeft(s))).then(() => then?.());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The staff with anything left, from what has been checked so far. */
|
|
27
|
+
export function notReady() {
|
|
28
|
+
return (S.data?.staff ?? []).filter((s) => (S.readiness?.[s.handle] ?? []).length);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** "install the GitHub App, add the agent credential and run once" */
|
|
32
|
+
export function sentence(left) {
|
|
33
|
+
if (left.length < 2) return left.join("");
|
|
34
|
+
return left.slice(0, -1).join(", ") + " and " + left.at(-1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Per staff member: hire, the GitHub App, the charter, the agent credential, a first run. */
|
|
38
|
+
const STAFF_STEPS = 5;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Setup as a count, from the same answers as everything above: the org's three steps (create
|
|
42
|
+
* it, business.md, priorities.md), then five per staff member. With nobody hired, the first
|
|
43
|
+
* hire's five are counted as still to do.
|
|
44
|
+
*
|
|
45
|
+
* Null until every staff member's readiness has answered. A count that starts high and drops
|
|
46
|
+
* when GitHub replies reads as steps coming undone.
|
|
47
|
+
*/
|
|
48
|
+
export function progress(
|
|
49
|
+
unfinished = S.data?.unfinished ?? [],
|
|
50
|
+
staff = S.data?.staff ?? [],
|
|
51
|
+
readiness = S.readiness ?? {},
|
|
52
|
+
) {
|
|
53
|
+
const orgSteps = 3;
|
|
54
|
+
let done = orgSteps - unfinished.filter((id) => id !== "hire").length;
|
|
55
|
+
let total = orgSteps;
|
|
56
|
+
if (!staff.length) return { done, total: total + STAFF_STEPS };
|
|
57
|
+
for (const s of staff) {
|
|
58
|
+
const left = readiness[s.handle];
|
|
59
|
+
if (!left) return null;
|
|
60
|
+
total += STAFF_STEPS;
|
|
61
|
+
done += STAFF_STEPS - left.length;
|
|
62
|
+
}
|
|
63
|
+
return { done, total };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** One staff member's own count, or null before their readiness is known. */
|
|
67
|
+
export function staffProgress(handle, readiness = S.readiness ?? {}) {
|
|
68
|
+
const left = readiness[handle];
|
|
69
|
+
return left ? { done: STAFF_STEPS - left.length, total: STAFF_STEPS } : null;
|
|
70
|
+
}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import { getInbox, getOrg, getSync } from "./api.js";
|
|
11
11
|
import { $, ago, el, esc } from "./dom.js";
|
|
12
12
|
import { render } from "./router.js";
|
|
13
|
-
import {
|
|
13
|
+
import { sortHome } from "./homesort.js";
|
|
14
|
+
import { humansOf, openCount, S, unreadCount } from "./state.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* The inbox, fetched at most once at a time.
|
|
@@ -53,8 +54,9 @@ export function ensureInbox(force) {
|
|
|
53
54
|
export function stampCounts() {
|
|
54
55
|
const waiting = !S.inbox;
|
|
55
56
|
for (const [sel, n] of [
|
|
57
|
+
["#homecount", needsCount],
|
|
56
58
|
["#inboxcount", openCount],
|
|
57
|
-
["#
|
|
59
|
+
["#unreadcount", unreadCount],
|
|
58
60
|
]) {
|
|
59
61
|
const slot = document.querySelector(sel);
|
|
60
62
|
if (!slot) continue;
|
|
@@ -70,6 +72,12 @@ export function stampCounts() {
|
|
|
70
72
|
* which in practice meant "after you visit the Inbox". A sidebar that says nothing until you
|
|
71
73
|
* look at it is not a sidebar.
|
|
72
74
|
*/
|
|
75
|
+
/** What Home's "Needs you" holds, for the sidebar. */
|
|
76
|
+
function needsCount() {
|
|
77
|
+
if (!S.inbox || !S.data) return 0;
|
|
78
|
+
return sortHome(S.inbox.items ?? [], S.data.staff, humansOf(), S.live?.staff ?? []).needs.length;
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
export function countInBackground() {
|
|
74
82
|
stampCounts();
|
|
75
83
|
return ensureInbox(false)
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/* Search everything: ⌘K, or the search field in the sidebar.
|
|
2
|
+
*
|
|
3
|
+
* One dialog over the whole portal: issues and pull requests, staff, every fact and file in
|
|
4
|
+
* every brain, the org files, the docs, runs, and the screens themselves. All of it except the
|
|
5
|
+
* docs is already in the page, so it is searched here as you type; the docs are searched on the
|
|
6
|
+
* server, which reads every page rather than only titles.
|
|
7
|
+
*
|
|
8
|
+
* `index()` and `rank()` are plain functions over plain data, so what is found, and in which
|
|
9
|
+
* order, can be tested without a page. */
|
|
10
|
+
|
|
11
|
+
import { getOrgLayer, getRuns, searchDocs } from "./api.js";
|
|
12
|
+
import { ago, el } from "./dom.js";
|
|
13
|
+
import { icon, staffIcon } from "./icons.js";
|
|
14
|
+
import { ensureInbox } from "./refresh.js";
|
|
15
|
+
import { go } from "./router.js";
|
|
16
|
+
import { S } from "./state.js";
|
|
17
|
+
import { openThread } from "./views/home.js";
|
|
18
|
+
|
|
19
|
+
/** The groups, in the order they are shown. */
|
|
20
|
+
const GROUPS = ["Screens", "Staff", "Issues", "Pull requests", "Memory", "Files", "Org", "Runs", "Docs"];
|
|
21
|
+
/** How many of each a query shows; an empty query shows only screens and staff. */
|
|
22
|
+
const PER_GROUP = 5;
|
|
23
|
+
|
|
24
|
+
const SCREENS = [
|
|
25
|
+
["home", "Home", "What needs you, and who is working"],
|
|
26
|
+
["inbox", "Trackers", "Every open issue on each tracker"],
|
|
27
|
+
["runs", "Runs", "What ran, and what it cost"],
|
|
28
|
+
["org", "Org", "The files every staff member reads"],
|
|
29
|
+
["staff", "Staff", "Hire, set up, retire"],
|
|
30
|
+
["docs", "Docs", "How roster works"],
|
|
31
|
+
];
|
|
32
|
+
const STAFF_SCREENS = [
|
|
33
|
+
["brain", "Brain"],
|
|
34
|
+
["prompt", "Prompt"],
|
|
35
|
+
["graph", "Graph"],
|
|
36
|
+
["changed", "What changed"],
|
|
37
|
+
["health", "Health"],
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Every searchable thing, as `{ group, title, sub, text, icon, open }`. `text` is what is
|
|
42
|
+
* matched beyond the title; `open` is what choosing it does.
|
|
43
|
+
*/
|
|
44
|
+
export function index(state) {
|
|
45
|
+
const out = [];
|
|
46
|
+
const staff = state.data?.staff ?? [];
|
|
47
|
+
|
|
48
|
+
for (const [view, title, sub] of SCREENS) {
|
|
49
|
+
out.push({ group: "Screens", title, sub, text: view, icon: "square", open: () => go({ view }) });
|
|
50
|
+
}
|
|
51
|
+
for (const s of staff) {
|
|
52
|
+
for (const [view, label] of STAFF_SCREENS) {
|
|
53
|
+
out.push({
|
|
54
|
+
group: "Screens",
|
|
55
|
+
title: `${s.name} · ${label}`,
|
|
56
|
+
sub: s.handle,
|
|
57
|
+
text: `${s.handle} ${label}`,
|
|
58
|
+
icon: staffIcon(s),
|
|
59
|
+
open: () => go({ view, staffHandle: s.handle }),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
for (const s of staff) {
|
|
65
|
+
out.push({
|
|
66
|
+
group: "Staff",
|
|
67
|
+
title: s.name,
|
|
68
|
+
sub: [s.handle, s.brain].filter(Boolean).join(" · "),
|
|
69
|
+
text: `${s.handle} ${s.brain ?? ""} ${s.mention ?? ""}`,
|
|
70
|
+
icon: staffIcon(s),
|
|
71
|
+
open: () => go({ view: "brain", staffHandle: s.handle, openFile: "mem:*", fileQuery: "" }),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
for (const f of s.facts ?? []) {
|
|
75
|
+
out.push({
|
|
76
|
+
group: "Memory",
|
|
77
|
+
title: f.statement,
|
|
78
|
+
sub: `${s.name} · ${f.section} · ${f.slug}`,
|
|
79
|
+
text: `${f.slug} ${f.consequence ?? ""} ${f.section}`,
|
|
80
|
+
icon: "lightbulb",
|
|
81
|
+
open: () =>
|
|
82
|
+
go({ view: "brain", staffHandle: s.handle, openFile: "fact:" + f.slug, fileQuery: "" }),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
for (const surface of s.surfaces ?? []) {
|
|
87
|
+
for (const file of surface.files ?? []) {
|
|
88
|
+
const note = /(^|\/)notes\//.test(file.path);
|
|
89
|
+
out.push({
|
|
90
|
+
group: note ? "Memory" : "Files",
|
|
91
|
+
title: file.path.split("/").pop(),
|
|
92
|
+
sub: `${s.name} · ${file.path}`,
|
|
93
|
+
text: file.path,
|
|
94
|
+
icon: "file",
|
|
95
|
+
open: () => go({ view: "brain", staffHandle: s.handle, openFile: file.path, fileQuery: "" }),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const brains = new Map(staff.filter((s) => s.brain).map((s) => [s.brain, s]));
|
|
102
|
+
for (const item of state.inbox?.items ?? []) {
|
|
103
|
+
const owner = brains.get(item.repo);
|
|
104
|
+
const repo = item.repo.split("/")[1] ?? item.repo;
|
|
105
|
+
const where = owner ? owner.name : repo;
|
|
106
|
+
const open = item.state === "OPEN";
|
|
107
|
+
out.push({
|
|
108
|
+
group: item.kind === "pr" ? "Pull requests" : "Issues",
|
|
109
|
+
title: item.title,
|
|
110
|
+
sub: `${where} · #${item.number} · ${open ? "open" : item.state.toLowerCase()} · ${ago(item.updatedAt)}`,
|
|
111
|
+
text: `#${item.number} ${repo}#${item.number} ${(item.labels ?? []).join(" ")} ${item.author}`,
|
|
112
|
+
icon: item.kind === "pr" ? (item.state === "MERGED" ? "merged" : "review") : open ? "issue-open" : "issue-closed",
|
|
113
|
+
// Open work first among equal matches: it is usually what is being looked for.
|
|
114
|
+
weight: open ? 1 : 0,
|
|
115
|
+
open: () => openThread(item),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
for (const f of state.orgFiles ?? []) {
|
|
120
|
+
out.push({
|
|
121
|
+
group: "Org",
|
|
122
|
+
title: f.path.split("/").pop(),
|
|
123
|
+
sub: f.path,
|
|
124
|
+
text: f.path,
|
|
125
|
+
icon: "file",
|
|
126
|
+
open: () => go({ view: "org", orgOpen: f.path }),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (const s of state.runs?.staff ?? []) {
|
|
131
|
+
for (const r of s.runs ?? []) {
|
|
132
|
+
const word = r.record?.outcome ?? r.conclusion ?? r.status;
|
|
133
|
+
out.push({
|
|
134
|
+
group: "Runs",
|
|
135
|
+
title: `${s.name} · ${r.kind} run · ${word}`,
|
|
136
|
+
sub: `${ago(r.createdAt)} · opens the log on GitHub`,
|
|
137
|
+
text: `${s.handle} ${r.kind} ${word} ${r.id}`,
|
|
138
|
+
icon: "play",
|
|
139
|
+
open: () => window.open(r.url, "_blank", "noopener"),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The best matches for a query, grouped. Every word has to appear somewhere; a match in the
|
|
149
|
+
* title outranks one elsewhere, and the start of the title outranks the middle of it.
|
|
150
|
+
*/
|
|
151
|
+
export function rank(entries, query) {
|
|
152
|
+
const words = String(query ?? "").toLowerCase().split(/\s+/).filter(Boolean);
|
|
153
|
+
const groups = new Map(GROUPS.map((g) => [g, []]));
|
|
154
|
+
if (!words.length) {
|
|
155
|
+
for (const e of entries) {
|
|
156
|
+
if (e.group === "Screens" || e.group === "Staff") groups.get(e.group).push({ e, score: 0 });
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
for (const e of entries) {
|
|
160
|
+
const title = e.title.toLowerCase();
|
|
161
|
+
const all = `${title} ${String(e.sub ?? "").toLowerCase()} ${String(e.text ?? "").toLowerCase()}`;
|
|
162
|
+
if (!words.every((w) => all.includes(w))) continue;
|
|
163
|
+
let score = e.weight ?? 0;
|
|
164
|
+
for (const w of words) {
|
|
165
|
+
if (title.startsWith(w)) score += 6;
|
|
166
|
+
else if (new RegExp(`\\b${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`).test(title)) score += 4;
|
|
167
|
+
else if (title.includes(w)) score += 2;
|
|
168
|
+
}
|
|
169
|
+
groups.get(e.group)?.push({ e, score });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const out = [];
|
|
173
|
+
for (const [group, list] of groups) {
|
|
174
|
+
if (!list.length) continue;
|
|
175
|
+
list.sort((a, b) => b.score - a.score);
|
|
176
|
+
const shown = list.slice(0, words.length ? PER_GROUP : 40);
|
|
177
|
+
out.push({ group, entries: shown.map((x) => x.e), more: list.length - shown.length });
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* --------------------------------- the dialog --------------------------------- */
|
|
183
|
+
|
|
184
|
+
let current = null;
|
|
185
|
+
|
|
186
|
+
/** Open the search dialog, or focus it when it is already open. */
|
|
187
|
+
export function openSearch() {
|
|
188
|
+
if (current) {
|
|
189
|
+
current.input.focus();
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const box = document.createElement("dialog");
|
|
193
|
+
if (typeof box.showModal !== "function") return;
|
|
194
|
+
box.className = "palette";
|
|
195
|
+
|
|
196
|
+
const input = el("input", {
|
|
197
|
+
type: "search",
|
|
198
|
+
className: "palinput",
|
|
199
|
+
placeholder: "Search issues, pull requests, memory, files, runs and docs",
|
|
200
|
+
autocomplete: "off",
|
|
201
|
+
spellcheck: false,
|
|
202
|
+
});
|
|
203
|
+
const results = el("div", { className: "palresults", role: "listbox" });
|
|
204
|
+
const foot = el("div", { className: "palfoot" }, [
|
|
205
|
+
el("span", { innerHTML: "<kbd>↑</kbd><kbd>↓</kbd> move" }),
|
|
206
|
+
el("span", { innerHTML: "<kbd>↵</kbd> open" }),
|
|
207
|
+
el("span", { innerHTML: "<kbd>esc</kbd> close" }),
|
|
208
|
+
]);
|
|
209
|
+
box.append(el("div", { className: "palhead" }, [icon("search", "ic"), input]), results, foot);
|
|
210
|
+
document.body.append(box);
|
|
211
|
+
box.showModal();
|
|
212
|
+
input.focus();
|
|
213
|
+
|
|
214
|
+
let entries = index(S);
|
|
215
|
+
let flat = [];
|
|
216
|
+
let at = 0;
|
|
217
|
+
let docs = [];
|
|
218
|
+
let docsFor = "";
|
|
219
|
+
let docTimer = null;
|
|
220
|
+
|
|
221
|
+
const close = () => {
|
|
222
|
+
if (!current) return;
|
|
223
|
+
current = null;
|
|
224
|
+
clearTimeout(docTimer);
|
|
225
|
+
box.close();
|
|
226
|
+
box.remove();
|
|
227
|
+
};
|
|
228
|
+
current = { input, close };
|
|
229
|
+
box.addEventListener("close", () => {
|
|
230
|
+
current = null;
|
|
231
|
+
box.remove();
|
|
232
|
+
});
|
|
233
|
+
box.addEventListener("click", (e) => {
|
|
234
|
+
if (e.target === box) close();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const choose = (e) => {
|
|
238
|
+
close();
|
|
239
|
+
e.open();
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const paint = () => {
|
|
243
|
+
const q = input.value.trim();
|
|
244
|
+
const grouped = rank(entries, q);
|
|
245
|
+
if (q && docsFor === q && docs.length) {
|
|
246
|
+
grouped.push({
|
|
247
|
+
group: "Docs",
|
|
248
|
+
entries: docs.slice(0, PER_GROUP).map((h) => ({
|
|
249
|
+
title: h.title,
|
|
250
|
+
sub: h.matches?.[0]?.text ?? h.file,
|
|
251
|
+
icon: "book-open",
|
|
252
|
+
open: () => go({ view: "docs", openDoc: h.file, docQuery: q }),
|
|
253
|
+
})),
|
|
254
|
+
more: Math.max(0, docs.length - PER_GROUP),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
flat = grouped.flatMap((g) => g.entries);
|
|
258
|
+
at = Math.min(at, Math.max(0, flat.length - 1));
|
|
259
|
+
results.replaceChildren();
|
|
260
|
+
if (!flat.length) {
|
|
261
|
+
results.append(el("p", { className: "palempty", textContent: q ? "Nothing matches “" + q + "”." : "" }));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
let i = 0;
|
|
265
|
+
for (const g of grouped) {
|
|
266
|
+
results.append(
|
|
267
|
+
el("div", { className: "palgroup", textContent: g.group + (g.more ? ` · ${g.more} more` : "") }),
|
|
268
|
+
);
|
|
269
|
+
for (const e of g.entries) {
|
|
270
|
+
const n = i++;
|
|
271
|
+
const row = el("button", { className: "palrow", role: "option" }, [
|
|
272
|
+
icon(e.icon ?? "file", "ic"),
|
|
273
|
+
el("span", { className: "paltext" }, [
|
|
274
|
+
el("span", { className: "paltitle", innerHTML: highlight(e.title, q) }),
|
|
275
|
+
el("span", { className: "palsub", textContent: e.sub ?? "" }),
|
|
276
|
+
]),
|
|
277
|
+
]);
|
|
278
|
+
row.setAttribute("aria-selected", String(n === at));
|
|
279
|
+
row.onmouseenter = () => {
|
|
280
|
+
at = n;
|
|
281
|
+
mark();
|
|
282
|
+
};
|
|
283
|
+
row.onclick = () => choose(e);
|
|
284
|
+
results.append(row);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
mark();
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const mark = () => {
|
|
291
|
+
const rows = results.querySelectorAll(".palrow");
|
|
292
|
+
rows.forEach((r, n) => r.setAttribute("aria-selected", String(n === at)));
|
|
293
|
+
rows[at]?.scrollIntoView({ block: "nearest" });
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
input.addEventListener("input", () => {
|
|
297
|
+
at = 0;
|
|
298
|
+
paint();
|
|
299
|
+
const q = input.value.trim();
|
|
300
|
+
clearTimeout(docTimer);
|
|
301
|
+
if (q.length < 2) return;
|
|
302
|
+
docTimer = setTimeout(() => {
|
|
303
|
+
searchDocs(q)
|
|
304
|
+
.then((r) => {
|
|
305
|
+
docs = r.hits ?? [];
|
|
306
|
+
docsFor = q;
|
|
307
|
+
if (current && input.value.trim() === q) paint();
|
|
308
|
+
})
|
|
309
|
+
.catch(() => {});
|
|
310
|
+
}, 150);
|
|
311
|
+
});
|
|
312
|
+
input.addEventListener("keydown", (e) => {
|
|
313
|
+
if (e.key === "ArrowDown") {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
at = Math.min(at + 1, flat.length - 1);
|
|
316
|
+
mark();
|
|
317
|
+
} else if (e.key === "ArrowUp") {
|
|
318
|
+
e.preventDefault();
|
|
319
|
+
at = Math.max(at - 1, 0);
|
|
320
|
+
mark();
|
|
321
|
+
} else if (e.key === "Enter") {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
if (flat[at]) choose(flat[at]);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
paint();
|
|
328
|
+
|
|
329
|
+
/* What is not in the page yet is fetched once and folded in as it lands: the issues, the org
|
|
330
|
+
files and the runs. The dialog is usable straight away with whatever is already here. */
|
|
331
|
+
const refill = () => {
|
|
332
|
+
if (!current) return;
|
|
333
|
+
entries = index(S);
|
|
334
|
+
paint();
|
|
335
|
+
};
|
|
336
|
+
if (!S.inbox) ensureInbox(false).then(refill).catch(() => {});
|
|
337
|
+
if (!S.orgFiles) {
|
|
338
|
+
getOrgLayer()
|
|
339
|
+
.then((r) => {
|
|
340
|
+
S.orgFiles = r.files ?? [];
|
|
341
|
+
refill();
|
|
342
|
+
})
|
|
343
|
+
.catch(() => {});
|
|
344
|
+
}
|
|
345
|
+
if (!S.runs) {
|
|
346
|
+
getRuns(false)
|
|
347
|
+
.then((r) => {
|
|
348
|
+
S.runs = r;
|
|
349
|
+
refill();
|
|
350
|
+
})
|
|
351
|
+
.catch(() => {});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** The title with each query word marked, escaped first. */
|
|
356
|
+
function highlight(title, q) {
|
|
357
|
+
let html = String(title ?? "")
|
|
358
|
+
.replace(/&/g, "&")
|
|
359
|
+
.replace(/</g, "<")
|
|
360
|
+
.replace(/>/g, ">");
|
|
361
|
+
for (const w of String(q ?? "").toLowerCase().split(/\s+/).filter((x) => x.length > 1)) {
|
|
362
|
+
const re = new RegExp(`(${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "ig");
|
|
363
|
+
html = html.replace(re, "<mark>$1</mark>");
|
|
364
|
+
}
|
|
365
|
+
return html;
|
|
366
|
+
}
|
|
@@ -22,7 +22,7 @@ export const VIEWS = [
|
|
|
22
22
|
export const VIEW_ALIAS = { memory: "brain" };
|
|
23
23
|
|
|
24
24
|
/** Screens that belong to the org rather than to one staff member. */
|
|
25
|
-
export const ORG_WIDE = new Set(["setup", "inbox", "prs", "runs", "org", "staff", "docs"]);
|
|
25
|
+
export const ORG_WIDE = new Set(["setup", "home", "inbox", "prs", "runs", "org", "staff", "docs"]);
|
|
26
26
|
|
|
27
27
|
/** The two screens that read the inbox, and so share its filters and its `?t=` thread. */
|
|
28
28
|
const INBOXY = new Set(["inbox", "prs"]);
|
|
@@ -30,17 +30,23 @@ const INBOXY = new Set(["inbox", "prs"]);
|
|
|
30
30
|
export const S = {
|
|
31
31
|
/** The org export from /api/org. Everything the brain screens read comes off this. */
|
|
32
32
|
data: null,
|
|
33
|
+
/** `{login}` on a hosted portal, null on your own machine. Hosted has no setup, hire or doctor. */
|
|
34
|
+
hosted: null,
|
|
33
35
|
docs: null,
|
|
34
36
|
inbox: null,
|
|
35
37
|
/** /api/runs. Kept once read: it is minutes of downloads on a cold cache. */
|
|
36
38
|
runs: null,
|
|
37
39
|
sync: null,
|
|
38
40
|
loadedAt: null,
|
|
41
|
+
/** The role whose hire list is open on the Staff screen, kept across a refresh. */
|
|
42
|
+
staffOpen: null,
|
|
43
|
+
/** Per staff member, what is left before they can run. See readiness.js. */
|
|
44
|
+
readiness: null,
|
|
39
45
|
|
|
40
46
|
staffHandle: null,
|
|
41
47
|
/* What is waiting on you, not whose brain you read last. The org-wide screens are where a
|
|
42
48
|
session starts, which is also why the Staff list below them opens folded. */
|
|
43
|
-
view: "
|
|
49
|
+
view: "home",
|
|
44
50
|
/** The inbox filter box. Brain and "what changed" keep their own, below. */
|
|
45
51
|
query: "",
|
|
46
52
|
|
|
@@ -82,9 +88,9 @@ export const S = {
|
|
|
82
88
|
export const openCount = () =>
|
|
83
89
|
(S.inbox?.items ?? []).filter((i) => i.state === "OPEN" && i.kind !== "pr").length;
|
|
84
90
|
|
|
85
|
-
/**
|
|
86
|
-
export const
|
|
87
|
-
(S.inbox?.items ?? []).filter((i) => i.state === "OPEN" && i.kind
|
|
91
|
+
/** Issues with activity you have not read, from GitHub's notifications. */
|
|
92
|
+
export const unreadCount = () =>
|
|
93
|
+
(S.inbox?.items ?? []).filter((i) => i.unread && i.state === "OPEN" && i.kind !== "pr").length;
|
|
88
94
|
|
|
89
95
|
export const staff = () => S.data.staff.find((s) => s.handle === S.staffHandle) ?? S.data.staff[0];
|
|
90
96
|
|
|
@@ -27,8 +27,7 @@ export function appPanel(opts) {
|
|
|
27
27
|
}),
|
|
28
28
|
el("p", {
|
|
29
29
|
textContent:
|
|
30
|
-
"A tab opens
|
|
31
|
-
"into the repo's secrets. The key is held in memory and never written to disk.",
|
|
30
|
+
"A GitHub tab opens. Confirm there, then come back here to install it.",
|
|
32
31
|
}),
|
|
33
32
|
);
|
|
34
33
|
|
|
@@ -150,7 +150,7 @@ export function viewBrain(m) {
|
|
|
150
150
|
const fileHits = plain.filter((f) => !q || f.path.toLowerCase().includes(q));
|
|
151
151
|
|
|
152
152
|
/* ---- memory ---- */
|
|
153
|
-
const mem = group("
|
|
153
|
+
const mem = group("What they know", s.facts.length + " facts");
|
|
154
154
|
if (q) {
|
|
155
155
|
for (const f of hits.slice(0, 200)) mem.append(row("fact:" + f.slug, f.slug, "", "tmem"));
|
|
156
156
|
if (!hits.length) {
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
import { getDoctor, getFix } from "../api.js";
|
|
8
8
|
import { el, toClipboard } from "../dom.js";
|
|
9
|
+
import { S } from "../state.js";
|
|
9
10
|
|
|
10
11
|
const LEVEL_ORDER = { fail: 0, warn: 1, ok: 2 };
|
|
11
12
|
|
|
12
13
|
/**
|
|
14
|
+
* @param opts.skip finding ids the caller already shows as a step of its own, so they are not
|
|
15
|
+
* reported twice. With `opts.hideWhenClean`, a list left empty draws nothing at all.
|
|
13
16
|
* @param opts.shell when Health draws this, the section it lives in: `{actions, say}`. The
|
|
14
17
|
* setup screen passes nothing and gets the layout it has always had. Its own screen is a
|
|
15
18
|
* wizard, where a chunky button and a paragraph under it are right; on Health it is one
|
|
@@ -19,6 +22,14 @@ export async function checklist(host, opts = {}) {
|
|
|
19
22
|
const inSection = Boolean(opts.shell);
|
|
20
23
|
const btnClass = inSection ? "ghbtn" : "btn";
|
|
21
24
|
const noteClass = inSection ? "hnote" : "sub";
|
|
25
|
+
/* Doctor reads the checkout and the org's secrets, so it runs where the checkout is. */
|
|
26
|
+
if (S.hosted) {
|
|
27
|
+
opts.shell?.say("on your machine");
|
|
28
|
+
host.replaceChildren(
|
|
29
|
+
el("p", { className: noteClass, textContent: "Run roster doctor in your workspace." }),
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
22
33
|
host.replaceChildren(el("p", { className: noteClass, textContent: "Checking…" }));
|
|
23
34
|
|
|
24
35
|
let report;
|
|
@@ -32,9 +43,14 @@ export async function checklist(host, opts = {}) {
|
|
|
32
43
|
const findings = (report.findings ?? []).slice().sort(
|
|
33
44
|
(a, b) => (LEVEL_ORDER[a.level] ?? 3) - (LEVEL_ORDER[b.level] ?? 3),
|
|
34
45
|
);
|
|
35
|
-
const
|
|
46
|
+
const skip = new Set(opts.skip ?? []);
|
|
47
|
+
const bad = findings.filter((f) => f.level !== "ok" && !skip.has(f.id));
|
|
36
48
|
|
|
37
49
|
host.replaceChildren();
|
|
50
|
+
if (!bad.length && opts.hideWhenClean) {
|
|
51
|
+
opts.onEmpty?.();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
38
54
|
opts.shell?.say(bad.length ? String(bad.length) : "clean");
|
|
39
55
|
host.append(
|
|
40
56
|
el("p", {
|
|
@@ -83,7 +99,7 @@ export async function checklist(host, opts = {}) {
|
|
|
83
99
|
const again = el("button", { className: btnClass, textContent: "Check again" });
|
|
84
100
|
again.onclick = () => checklist(host, opts);
|
|
85
101
|
|
|
86
|
-
const feet = opts.shell?.actions ?? host;
|
|
102
|
+
const feet = opts.shell?.actions ?? host.appendChild(el("div", { className: "row" }));
|
|
87
103
|
if (opts.shell) feet.replaceChildren();
|
|
88
104
|
feet.append(copy, again, note);
|
|
89
105
|
if (bad.length) {
|
|
@@ -92,8 +108,7 @@ export async function checklist(host, opts = {}) {
|
|
|
92
108
|
className: noteClass,
|
|
93
109
|
style: "flex-basis:100%",
|
|
94
110
|
textContent:
|
|
95
|
-
"Paste
|
|
96
|
-
"check again. The ids above should be gone.",
|
|
111
|
+
"Paste them into your coding agent, then check again.",
|
|
97
112
|
}),
|
|
98
113
|
);
|
|
99
114
|
}
|