@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.
Files changed (151) hide show
  1. package/README.md +6 -0
  2. package/dist/cli.js +4189 -1971
  3. package/dist/worker/assets/assets/css/base.css +327 -0
  4. package/dist/worker/assets/assets/css/brain.css +116 -0
  5. package/dist/worker/assets/assets/css/diff.css +33 -0
  6. package/dist/worker/assets/assets/css/graph.css +39 -0
  7. package/dist/worker/assets/assets/css/health.css +75 -0
  8. package/dist/worker/assets/assets/css/home.css +114 -0
  9. package/dist/worker/assets/assets/css/inbox.css +199 -0
  10. package/dist/worker/assets/assets/css/layout.css +181 -0
  11. package/dist/worker/assets/assets/css/markdown.css +96 -0
  12. package/dist/worker/assets/assets/css/runs.css +13 -0
  13. package/dist/worker/assets/assets/css/search.css +48 -0
  14. package/dist/worker/assets/assets/css/setup.css +194 -0
  15. package/dist/worker/assets/assets/js/api.js +191 -0
  16. package/dist/worker/assets/assets/js/app.js +500 -0
  17. package/dist/worker/assets/assets/js/dialog.js +196 -0
  18. package/dist/worker/assets/assets/js/dom.js +131 -0
  19. package/dist/worker/assets/assets/js/homesort.js +174 -0
  20. package/dist/worker/assets/assets/js/icons.js +142 -0
  21. package/dist/worker/assets/assets/js/inflight.js +18 -0
  22. package/dist/worker/assets/assets/js/lightbox.js +273 -0
  23. package/dist/worker/assets/assets/js/md.js +406 -0
  24. package/dist/worker/assets/assets/js/mdedit.js +84 -0
  25. package/dist/worker/assets/assets/js/mention.js +264 -0
  26. package/dist/worker/assets/assets/js/readiness.js +70 -0
  27. package/dist/worker/assets/assets/js/refresh.js +197 -0
  28. package/dist/worker/assets/assets/js/router.js +20 -0
  29. package/dist/worker/assets/assets/js/search.js +366 -0
  30. package/dist/worker/assets/assets/js/state.js +213 -0
  31. package/dist/worker/assets/assets/js/textdiff.js +96 -0
  32. package/dist/worker/assets/assets/js/views/app.js +145 -0
  33. package/dist/worker/assets/assets/js/views/brain.js +260 -0
  34. package/dist/worker/assets/assets/js/views/changed.js +157 -0
  35. package/dist/worker/assets/assets/js/views/checklist.js +115 -0
  36. package/dist/worker/assets/assets/js/views/credential.js +84 -0
  37. package/dist/worker/assets/assets/js/views/docs.js +174 -0
  38. package/dist/worker/assets/assets/js/views/files.js +139 -0
  39. package/dist/worker/assets/assets/js/views/graph.js +436 -0
  40. package/dist/worker/assets/assets/js/views/health.js +304 -0
  41. package/dist/worker/assets/assets/js/views/hire.js +593 -0
  42. package/dist/worker/assets/assets/js/views/home.js +621 -0
  43. package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
  44. package/dist/worker/assets/assets/js/views/memory.js +150 -0
  45. package/dist/worker/assets/assets/js/views/org.js +195 -0
  46. package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
  47. package/dist/worker/assets/assets/js/views/paste.js +216 -0
  48. package/dist/worker/assets/assets/js/views/prompt.js +457 -0
  49. package/dist/worker/assets/assets/js/views/repos.js +97 -0
  50. package/dist/worker/assets/assets/js/views/runonce.js +94 -0
  51. package/dist/worker/assets/assets/js/views/runs.js +182 -0
  52. package/dist/worker/assets/assets/js/views/setup.js +557 -0
  53. package/dist/worker/assets/assets/js/views/staff.js +291 -0
  54. package/dist/worker/assets/assets/js/views/todo.js +62 -0
  55. package/dist/worker/assets/assets/js/yaml.js +134 -0
  56. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  57. package/dist/worker/assets/docs-images/home.jpg +0 -0
  58. package/dist/worker/assets/docs-images/org.jpg +0 -0
  59. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  60. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  61. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  62. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  63. package/dist/worker/assets/index.html +82 -0
  64. package/dist/worker/index.js +5143 -0
  65. package/docs/README.md +2 -2
  66. package/docs/architecture.md +23 -4
  67. package/docs/charters/analyst.md +65 -0
  68. package/docs/charters/community.md +63 -0
  69. package/docs/charters/designer.md +65 -0
  70. package/docs/charters/devops.md +65 -0
  71. package/docs/charters/pm.md +70 -0
  72. package/docs/charters/qa.md +65 -0
  73. package/docs/charters/writer.md +63 -0
  74. package/docs/commands.md +36 -9
  75. package/docs/concepts.md +34 -21
  76. package/docs/cost.md +3 -3
  77. package/docs/developing.md +28 -10
  78. package/docs/doctor-codes.md +3 -1
  79. package/docs/export.md +2 -0
  80. package/docs/getting-started.md +49 -29
  81. package/docs/hosting.md +114 -43
  82. package/docs/images/brain.jpg +0 -0
  83. package/docs/images/home.jpg +0 -0
  84. package/docs/images/org.jpg +0 -0
  85. package/docs/images/prompt.jpg +0 -0
  86. package/docs/images/staff.jpg +0 -0
  87. package/docs/manual-steps.md +3 -2
  88. package/docs/memory.md +2 -1
  89. package/docs/org-yaml.md +3 -0
  90. package/docs/portal.md +144 -45
  91. package/docs/prompts.md +6 -0
  92. package/docs/security.md +70 -11
  93. package/docs/session-workflow.md +24 -6
  94. package/docs/staff-yaml.md +21 -2
  95. package/docs/upgrading.md +3 -3
  96. package/docs/writing-a-charter.md +19 -6
  97. package/package.json +4 -3
  98. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
  99. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
  100. package/templates/brain/CHARTER.md +2 -2
  101. package/templates/brain/STATE.md +16 -0
  102. package/templates/brain/memory/INDEX.md +1 -1
  103. package/templates/brain/staff.yaml +4 -1
  104. package/templates/briefs/amend.md +4 -3
  105. package/templates/briefs/priorities.md +46 -0
  106. package/templates/ops/.github/workflows/session.yaml +150 -3
  107. package/templates/ops/compose.mjs +35 -8
  108. package/templates/ops/org/operating.md +29 -10
  109. package/templates/ops/org/voice.md +2 -1
  110. package/templates/ops/prompts/daily.md +51 -14
  111. package/templates/ops/prompts/mention.md +24 -2
  112. package/templates/ops/run-record.mjs +5 -3
  113. package/templates/ops/status-week.mjs +169 -0
  114. package/templates/portal/css/base.css +49 -0
  115. package/templates/portal/css/health.css +14 -1
  116. package/templates/portal/css/home.css +114 -0
  117. package/templates/portal/css/inbox.css +21 -4
  118. package/templates/portal/css/layout.css +35 -3
  119. package/templates/portal/css/markdown.css +19 -0
  120. package/templates/portal/css/search.css +48 -0
  121. package/templates/portal/css/setup.css +79 -4
  122. package/templates/portal/index.html +15 -9
  123. package/templates/portal/js/api.js +60 -4
  124. package/templates/portal/js/app.js +125 -7
  125. package/templates/portal/js/dialog.js +36 -0
  126. package/templates/portal/js/homesort.js +174 -0
  127. package/templates/portal/js/icons.js +41 -0
  128. package/templates/portal/js/inflight.js +18 -0
  129. package/templates/portal/js/md.js +5 -2
  130. package/templates/portal/js/mdedit.js +84 -0
  131. package/templates/portal/js/readiness.js +70 -0
  132. package/templates/portal/js/refresh.js +10 -2
  133. package/templates/portal/js/search.js +366 -0
  134. package/templates/portal/js/state.js +11 -5
  135. package/templates/portal/js/views/app.js +1 -2
  136. package/templates/portal/js/views/brain.js +1 -1
  137. package/templates/portal/js/views/checklist.js +19 -4
  138. package/templates/portal/js/views/credential.js +42 -51
  139. package/templates/portal/js/views/health.js +11 -6
  140. package/templates/portal/js/views/hire.js +593 -0
  141. package/templates/portal/js/views/home.js +621 -0
  142. package/templates/portal/js/views/inbox.js +237 -68
  143. package/templates/portal/js/views/org.js +31 -111
  144. package/templates/portal/js/views/orgedit.js +240 -0
  145. package/templates/portal/js/views/paste.js +111 -66
  146. package/templates/portal/js/views/prompt.js +94 -40
  147. package/templates/portal/js/views/repos.js +10 -10
  148. package/templates/portal/js/views/runs.js +21 -4
  149. package/templates/portal/js/views/setup.js +130 -163
  150. package/templates/portal/js/views/staff.js +181 -301
  151. package/templates/portal/js/views/todo.js +62 -0
@@ -9,8 +9,9 @@
9
9
  * changing a byte of the composed text, and nothing said so before.
10
10
  */
11
11
 
12
+ import { highlighted } from "../mdedit.js";
12
13
  import { getFile, post } from "../api.js";
13
- import { askText, askYes } from "../dialog.js";
14
+ import { askYes, sheet } from "../dialog.js";
14
15
  import { el, esc, grow, kb, toClipboard } from "../dom.js";
15
16
  import { icon } from "../icons.js";
16
17
  import { mdlite } from "../md.js";
@@ -18,6 +19,7 @@ import { render } from "../router.js";
18
19
  import { S, staff, writeHash } from "../state.js";
19
20
  import { diffStat, unifiedDiff } from "../textdiff.js";
20
21
  import { renderDiff } from "./changed.js";
22
+ import { showPasteResult } from "./paste.js";
21
23
 
22
24
  const KINDS = [
23
25
  ["daily", "Daily", "the scheduled run"],
@@ -25,48 +27,98 @@ const KINDS = [
25
27
  ];
26
28
 
27
29
  /**
28
- * Build the paste-ready brief on the server, where compose.mjs lives, and copy it.
30
+ * Fix a prompt with your own AI, in a side sheet: what is wrong, what you want changed, the
31
+ * prompt as it is today, a brief to copy, and a box for the reply. The reply is parsed into
32
+ * whole files and shown as diffs; nothing is saved until you press Save on one.
29
33
  *
30
- * A finding pre-fills the box rather than skipping it: what it wrote is a starting point, and
31
- * "and keep it in operating.md" is exactly the sort of thing you want to add.
32
- *
33
- * Exported because the findings themselves live on Health now, and the fix for one of them is
34
- * the same brief whichever screen you asked from.
34
+ * @param {{handle: string, name?: string, kind: string, want?: string, title?: string,
35
+ * detail?: string}} o
36
+ * @returns {{box: object | null, body: HTMLElement, want: HTMLTextAreaElement}} what it built,
37
+ * so a caller (or a test, where there is no <dialog>) can see it.
35
38
  */
36
- export async function copyAmendBrief(handle, kind, want, btn, note) {
37
- const label = btn.textContent;
38
- const asked = await askText({
39
- title: "What do you want changed?",
40
- hint:
41
- "This goes at the top of a brief carrying the whole prompt and every file it is " +
42
- "made of. Say it the way you would say it to a person.",
43
- value: want,
39
+ export function amendSheet(o) {
40
+ const body = el("div", { className: "amend" });
41
+ const x = el("button", { className: "iconbtn", title: "Close (Esc)", ariaLabel: "Close" });
42
+ x.append(icon("close"));
43
+ body.append(el("div", { className: "sidebar-x" }, [x]));
44
+
45
+ body.append(el("h3", { className: "sheettitle", textContent: o.title ?? "Change what they are told" }));
46
+ if (o.detail) body.append(el("p", { className: "sub", textContent: o.detail }));
47
+
48
+ const want = el("textarea", {
49
+ className: "pastebox",
50
+ rows: 3,
51
+ value: o.want ?? "",
44
52
  placeholder: "stop opening decision issues for anything reversible",
45
- confirm: "Copy the brief",
46
53
  });
47
- if (!asked) return;
48
- btn.disabled = true;
49
- btn.textContent = "building…";
50
- try {
51
- const url =
52
- "/api/amend?staff=" + encodeURIComponent(handle) +
53
- "&kind=" + encodeURIComponent(kind) +
54
- "&want=" + encodeURIComponent(asked);
55
- const text = await (await fetch(url, { cache: "no-store" })).text();
56
- btn.disabled = false;
57
- toClipboard(text, btn, label);
58
- if (note) {
59
- note.textContent = "paste it into whatever agent you use";
60
- note.className = "meta";
54
+ body.append(el("label", { className: "amendlabel", textContent: "1. What you want changed" }), want);
55
+
56
+ const copy = el("button", { className: "btn primary", textContent: "Copy the prompt" });
57
+ const copied = el("span", { className: "meta" });
58
+ copy.onclick = async () => {
59
+ copy.disabled = true;
60
+ try {
61
+ const url =
62
+ "/api/amend?staff=" + encodeURIComponent(o.handle) +
63
+ "&kind=" + encodeURIComponent(o.kind) +
64
+ "&want=" + encodeURIComponent(want.value);
65
+ const text = await (await fetch(url, { cache: "no-store" })).text();
66
+ await toClipboard(text, copy, "Copy the prompt");
67
+ copied.textContent = "Paste it into Claude, ChatGPT or any other AI.";
68
+ copied.className = "meta";
69
+ } catch (e) {
70
+ copied.textContent = String(e.message || e);
71
+ copied.className = "meta err";
72
+ } finally {
73
+ copy.disabled = false;
61
74
  }
62
- } catch (e) {
63
- btn.disabled = false;
64
- btn.textContent = label;
65
- if (note) {
66
- note.textContent = e.message;
67
- note.className = "meta err";
75
+ };
76
+ body.append(
77
+ el("label", { className: "amendlabel", textContent: "2. Copy the prompt into your AI" }),
78
+ el("div", { className: "row" }, [copy, copied]),
79
+ );
80
+
81
+ // The prompt this is about, to read before deciding what to ask for.
82
+ const today = el("details", { className: "amendtoday" });
83
+ const summary = el("summary", { textContent: "The " + o.kind + " prompt as it is today" });
84
+ const text = el("pre", { className: "briefpreview", textContent: "Composing…" });
85
+ today.append(summary, text);
86
+ body.append(today);
87
+ fetch("/api/prompt?staff=" + encodeURIComponent(o.handle) + "&kind=" + encodeURIComponent(o.kind), { cache: "no-store" })
88
+ .then((r) => r.json())
89
+ .then((v) => {
90
+ if (v.error) throw new Error(v.error);
91
+ const words = String(v.composed ?? "").split(/\s+/).filter(Boolean).length;
92
+ summary.textContent = "The " + o.kind + " prompt as it is today · " + words.toLocaleString() + " words";
93
+ text.textContent = v.composed ?? "";
94
+ })
95
+ .catch((e) => {
96
+ text.textContent = String(e.message || e);
97
+ });
98
+
99
+ const answer = el("textarea", { className: "pastebox", rows: 8, placeholder: "Paste its whole reply here." });
100
+ const check = el("button", { className: "btn", textContent: "Check the answer" });
101
+ const result = el("div", { className: "pasteresult" });
102
+ check.onclick = async () => {
103
+ if (!answer.value.trim()) return;
104
+ result.replaceChildren(el("p", { className: "sub", textContent: "Reading…" }));
105
+ try {
106
+ const data = await post({ staff: o.handle, kind: o.kind, answer: answer.value }, "/api/amend/check");
107
+ showPasteResult(result, data, answer.value, () => {});
108
+ } catch (e) {
109
+ result.replaceChildren(el("p", { className: "err", textContent: String(e.message || e) }));
68
110
  }
69
- }
111
+ };
112
+ body.append(
113
+ el("label", { className: "amendlabel", textContent: "3. Paste its reply" }),
114
+ answer,
115
+ el("div", { className: "row" }, [check]),
116
+ result,
117
+ );
118
+
119
+ const box = sheet({ node: body, side: true });
120
+ if (box) x.onclick = () => box.close();
121
+ return { box, body, want };
70
122
  }
71
123
 
72
124
  export function viewPrompt(m) {
@@ -90,7 +142,7 @@ export function viewPrompt(m) {
90
142
  };
91
143
  /* The point of the screen: you can see the prompt, and you can get help changing it
92
144
  without first working out which of eight files to open. */
93
- const help = el("button", { className: "ghbtn primary", textContent: "Copy a brief for changing this" });
145
+ const help = el("button", { className: "ghbtn primary", textContent: "Change this with your AI" });
94
146
  help.onclick = () => copyAmend("");
95
147
  const copy = el("button", { className: "ghbtn", textContent: "Copy the prompt" });
96
148
  copy.onclick = () => {
@@ -99,7 +151,7 @@ export function viewPrompt(m) {
99
151
  const note = el("span", { className: "meta" });
100
152
  m.append(el("div", { className: "row", style: "margin-bottom:16px" }, [kind, help, copy, note]));
101
153
 
102
- const copyAmend = (want, btn) => copyAmendBrief(s.handle, S.promptKind, want, btn ?? help, note);
154
+ const copyAmend = (want) => amendSheet({ handle: s.handle, name: s.name, kind: S.promptKind, want });
103
155
 
104
156
  const split = el("div", { className: "split" });
105
157
  const tree = el("div", { className: "tree" });
@@ -351,8 +403,10 @@ export function viewPrompt(m) {
351
403
  );
352
404
 
353
405
  const ta = el("textarea", { value: text, className: "editor" });
354
- viewer.append(ta);
406
+ const hl = highlighted(ta, "md");
407
+ viewer.append(hl);
355
408
  grow(ta);
409
+ hl.repaint();
356
410
  ta.addEventListener("input", () => grow(ta));
357
411
 
358
412
  const status = el("span", { className: "meta" });
@@ -13,16 +13,16 @@ import { el } from "../dom.js";
13
13
  * org.yaml already lists is read off disk, which is how the Org screen uses it long after setup.
14
14
  */
15
15
  export function repoPicker(opts) {
16
- const box = el("div", { className: "manual" });
17
- box.append(
18
- el("b", { textContent: "Which repos the staff work in" }),
19
- el("p", {
20
- textContent:
21
- "Repos marked as products are the ones staff contribute to without owning. A new hire " +
22
- "picks them up automatically; somebody already hired keeps the works_in list in their " +
23
- "own staff.yaml.",
24
- }),
25
- );
16
+ const box = el("div", { className: opts.bare ? "" : "manual" });
17
+ if (!opts.bare) {
18
+ box.append(
19
+ el("b", { textContent: "Which repos the staff work in" }),
20
+ el("p", {
21
+ textContent:
22
+ "Add the repos your staff should work on. New hires get access to them automatically.",
23
+ }),
24
+ );
25
+ }
26
26
 
27
27
  const out = el("div", { style: "margin-top:9px" });
28
28
  box.append(out);
@@ -18,7 +18,7 @@ export function viewRuns(m) {
18
18
  className: "sub",
19
19
  textContent:
20
20
  "What each staff member ran in the last 30 days, how it ended, and what it cost where " +
21
- "the agent said. Read from GitHub through your own gh.",
21
+ "the agent said.",
22
22
  }),
23
23
  );
24
24
 
@@ -29,6 +29,11 @@ export function viewRuns(m) {
29
29
  return;
30
30
  }
31
31
  paint(m, S.runs);
32
+ /* Kept for the session, it could be days old: a tab opened during a rate limit went on
33
+ showing a two-week-old list. Anything older than a few minutes is asked for again. */
34
+ // Only a read with a time on it can be old, and only one re-read is asked for at a time.
35
+ const at = S.runs.fetchedAt ? new Date(S.runs.fetchedAt).getTime() : 0;
36
+ if (at && Date.now() - at > 5 * 60_000 && !asking) load(true);
32
37
  }
33
38
 
34
39
  let asking = false;
@@ -57,9 +62,7 @@ function paint(m, data) {
57
62
  if (!data.online) {
58
63
  const box = el("div", { className: "notice" });
59
64
  box.innerHTML =
60
- "<b>Runs live on GitHub, and it could not be reached.</b><br>" +
61
- esc(data.error ?? "gh is unavailable") +
62
- "<br>Everything else in the portal reads from disk and still works.";
65
+ "<b>GitHub could not be reached.</b><br>" + esc(data.error ?? "No answer from GitHub.");
63
66
  m.append(box, el("div", { className: "row hacts" }, [again]));
64
67
  return;
65
68
  }
@@ -72,6 +75,20 @@ function paint(m, data) {
72
75
  g.append(tile("Runs", String(data.spend?.runs ?? 0), "skipped mentions are not counted"));
73
76
  m.append(g);
74
77
 
78
+ /* The table shows at once with the costs already known; the rest are read from GitHub in the
79
+ background, and the screen asks again until they are all in. */
80
+ if (data.pending) {
81
+ m.append(
82
+ el("p", {
83
+ className: "hnote",
84
+ textContent: "Reading the cost of " + data.pending + " run" + (data.pending === 1 ? "" : "s") + " from GitHub…",
85
+ }),
86
+ );
87
+ setTimeout(() => {
88
+ if (S.view === "runs") load(true);
89
+ }, 3000);
90
+ }
91
+
75
92
  for (const s of data.staff ?? []) m.append(...staffSection(s));
76
93
 
77
94
  m.append(