@nanocollective/roster 0.1.0-beta.16 → 0.1.0-beta.19

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 (45) hide show
  1. package/dist/{agents-NMGVORU3.js → agents-Q2DSTLOQ.js} +1 -1
  2. package/dist/{chunk-E3EVPK4I.js → chunk-JH3LQ34C.js} +16 -1
  3. package/dist/{chunk-QCKEGMXD.js → chunk-UEZPQ5PV.js} +2 -2
  4. package/dist/cli.js +210 -16
  5. package/dist/{compose-56JIIIHA.js → compose-H43W3QI5.js} +3 -1
  6. package/dist/{connectors-ZVEPXSAR.js → connectors-U5VT5W2I.js} +1 -1
  7. package/dist/worker/assets/assets/css/base.css +4 -0
  8. package/dist/worker/assets/assets/css/brain.css +20 -0
  9. package/dist/worker/assets/assets/css/home.css +102 -34
  10. package/dist/worker/assets/assets/css/inbox.css +11 -0
  11. package/dist/worker/assets/assets/js/app.js +1 -0
  12. package/dist/worker/assets/assets/js/homesort.js +24 -0
  13. package/dist/worker/assets/assets/js/md.js +7 -2
  14. package/dist/worker/assets/assets/js/refresh.js +4 -2
  15. package/dist/worker/assets/assets/js/report.js +51 -0
  16. package/dist/worker/assets/assets/js/state.js +2 -0
  17. package/dist/worker/assets/assets/js/views/home.js +274 -119
  18. package/dist/worker/assets/assets/js/views/inbox.js +52 -11
  19. package/dist/worker/assets/assets/js/views/org.js +2 -0
  20. package/dist/worker/assets/assets/js/views/people.js +103 -0
  21. package/dist/worker/index.js +201 -15
  22. package/docs/doctor-codes.md +2 -0
  23. package/docs/export.md +2 -1
  24. package/docs/org-yaml.md +25 -4
  25. package/package.json +1 -1
  26. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +4 -4
  27. package/templates/ops/compose.mjs +20 -0
  28. package/templates/ops/org/operating.md +10 -0
  29. package/templates/ops/org/voice.md +19 -1
  30. package/templates/ops/prompts/daily.md +27 -6
  31. package/templates/ops/prompts/mention.md +3 -2
  32. package/templates/portal/css/base.css +4 -0
  33. package/templates/portal/css/brain.css +20 -0
  34. package/templates/portal/css/home.css +102 -34
  35. package/templates/portal/css/inbox.css +11 -0
  36. package/templates/portal/js/app.js +1 -0
  37. package/templates/portal/js/homesort.js +24 -0
  38. package/templates/portal/js/md.js +7 -2
  39. package/templates/portal/js/refresh.js +4 -2
  40. package/templates/portal/js/report.js +51 -0
  41. package/templates/portal/js/state.js +2 -0
  42. package/templates/portal/js/views/home.js +274 -119
  43. package/templates/portal/js/views/inbox.js +52 -11
  44. package/templates/portal/js/views/org.js +2 -0
  45. package/templates/portal/js/views/people.js +103 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  parseYaml
4
- } from "./chunk-E3EVPK4I.js";
4
+ } from "./chunk-JH3LQ34C.js";
5
5
 
6
6
  // templates/ops/agents.mjs
7
7
  import { readFileSync } from "fs";
@@ -2,7 +2,7 @@
2
2
  import * as nodeFs from "fs";
3
3
  import { join, dirname, resolve } from "path";
4
4
  import { fileURLToPath } from "url";
5
- var { connectorsOf } = await import("./connectors-ZVEPXSAR.js").catch(() => ({ connectorsOf: () => [] }));
5
+ var { connectorsOf } = await import("./connectors-U5VT5W2I.js").catch(() => ({ connectorsOf: () => [] }));
6
6
  function parseYaml(text, file = "<yaml>") {
7
7
  const lines = [];
8
8
  text.split("\n").forEach((raw, i) => {
@@ -200,11 +200,23 @@ function readHumans(org) {
200
200
  name: name || github,
201
201
  marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
202
202
  role: entry.role ?? void 0,
203
+ ...handlesOf(entry.handles).length ? { handles: handlesOf(entry.handles) } : {},
203
204
  ...entry.view_only === true ? { viewOnly: true } : {}
204
205
  });
205
206
  }
206
207
  return out;
207
208
  }
209
+ function handlesOf(v) {
210
+ const list = Array.isArray(v) ? v : v ? String(v).split(",") : [];
211
+ return list.map((x) => String(x ?? "").trim()).filter(Boolean);
212
+ }
213
+ function handlesList(humans) {
214
+ if (humans.length < 2 || !humans.some((h) => h.handles?.length)) return "";
215
+ return humans.map((h) => {
216
+ const who = `- **${h.name}**${h.github ? ` (@${h.github}, label \`${h.marker}\`)` : ""}`;
217
+ return h.handles?.length ? `${who}: ${h.handles.join(", ")}` : `${who}: anything else`;
218
+ }).join("\n");
219
+ }
208
220
  function humanSentence(humans) {
209
221
  const parts = humans.map((h) => h.github ? `${h.name} (@${h.github})` : h.name);
210
222
  if (parts.length < 2) return parts[0] ?? "";
@@ -287,6 +299,8 @@ function compose({
287
299
  human_list: humanSentence(humans),
288
300
  inflight,
289
301
  humans_extra: humanSentence(humans.slice(1)),
302
+ // Who looks after what, when an org has said. Empty for one person, and the rule goes.
303
+ humans_handles: handlesList(humans),
290
304
  // Who can read along and cannot rule. Empty, and the paragraph gone, when nobody is.
291
305
  humans_viewing: humanSentence(everyone.filter((h) => h.viewOnly)),
292
306
  // The services this staff member may use, as a list for the prompt. Empty, and the section
@@ -333,6 +347,7 @@ export {
333
347
  parseYaml,
334
348
  render,
335
349
  readHumans,
350
+ handlesList,
336
351
  humanSentence,
337
352
  compose
338
353
  };
@@ -490,8 +490,8 @@ async function main(argv) {
490
490
  const brainsDir = at("--brains") ?? ".";
491
491
  const handle = at("--staff");
492
492
  const dir = resolve(at("--out") ?? join(process.env.RUNNER_TEMP ?? ".", "roster-connectors"));
493
- const { parseYaml } = await import("./compose-56JIIIHA.js");
494
- const { resolveAgent, permissionOf } = await import("./agents-NMGVORU3.js");
493
+ const { parseYaml } = await import("./compose-H43W3QI5.js");
494
+ const { resolveAgent, permissionOf } = await import("./agents-Q2DSTLOQ.js");
495
495
  const org = parseYaml(readFileSync(join(opsDir, "org.yaml"), "utf8"), "org.yaml");
496
496
  const entry = (org.staff ?? []).find((s) => s.handle === handle);
497
497
  if (!entry) throw new Error(`no staff member "${handle}" in org.yaml`);
package/dist/cli.js CHANGED
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  compose,
4
4
  parseYaml
5
- } from "./chunk-E3EVPK4I.js";
5
+ } from "./chunk-JH3LQ34C.js";
6
6
  import {
7
7
  CATALOGUE,
8
8
  declared,
9
9
  secretName,
10
10
  withConnectors
11
- } from "./chunk-QCKEGMXD.js";
11
+ } from "./chunk-UEZPQ5PV.js";
12
12
 
13
13
  // src/commands/app.ts
14
14
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
@@ -1117,14 +1117,14 @@ function searchDocs(query2, snippets = 3) {
1117
1117
  return out.sort((a, b) => b.score - a.score);
1118
1118
  }
1119
1119
  function snippet(line, terms, width = 150) {
1120
- const clean = line.replace(/^#+\s*/, "").replace(/^[-*|]\s*/, "");
1121
- if (clean.length <= width) return clean;
1120
+ const clean2 = line.replace(/^#+\s*/, "").replace(/^[-*|]\s*/, "");
1121
+ if (clean2.length <= width) return clean2;
1122
1122
  const at = Math.min(
1123
- ...terms.map((t) => clean.toLowerCase().indexOf(t)).filter((n) => n >= 0),
1124
- clean.length
1123
+ ...terms.map((t) => clean2.toLowerCase().indexOf(t)).filter((n) => n >= 0),
1124
+ clean2.length
1125
1125
  );
1126
1126
  const from = Math.max(0, at - 40);
1127
- return (from ? "\u2026" : "") + clean.slice(from, from + width).trim() + "\u2026";
1127
+ return (from ? "\u2026" : "") + clean2.slice(from, from + width).trim() + "\u2026";
1128
1128
  }
1129
1129
  function titleOf(path) {
1130
1130
  const first = readFileSync2(path, "utf8").split("\n").find((l) => l.startsWith("# "));
@@ -1226,11 +1226,16 @@ function readHumans(org) {
1226
1226
  name: name || github,
1227
1227
  marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
1228
1228
  role: entry.role === void 0 || entry.role === null ? void 0 : String(entry.role),
1229
+ ...handlesOf(entry.handles).length ? { handles: handlesOf(entry.handles) } : {},
1229
1230
  ...entry.view_only === true ? { viewOnly: true } : {}
1230
1231
  });
1231
1232
  }
1232
1233
  return out;
1233
1234
  }
1235
+ function handlesOf(v) {
1236
+ const list2 = Array.isArray(v) ? v : v ? String(v).split(",") : [];
1237
+ return list2.map((x) => String(x ?? "").trim()).filter(Boolean);
1238
+ }
1234
1239
  function staffHumans(org) {
1235
1240
  return readHumans(org).filter((h) => !h.viewOnly);
1236
1241
  }
@@ -1247,6 +1252,87 @@ function humanLogins(org) {
1247
1252
  function defaultMarker(name) {
1248
1253
  return String(name).trim().split(/[\s-]+/)[0].toLowerCase().replace(/[^a-z0-9]/g, "") || "human";
1249
1254
  }
1255
+ var clean = (v) => String(v ?? "").replace(/[,{}[\]#"'\n\r]/g, " ").replace(/\s+/g, " ").trim();
1256
+ var LOGIN_RE = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;
1257
+ function tidyPeople(input) {
1258
+ const people = [];
1259
+ for (const p of input) {
1260
+ const github = clean(p.github).replace(/^@/, "");
1261
+ const name = clean(p.name) || github;
1262
+ if (!github && !name) continue;
1263
+ if (!LOGIN_RE.test(github))
1264
+ return { people, error: `"${github || name}" is not a GitHub login` };
1265
+ if (people.some((h) => h.github.toLowerCase() === github.toLowerCase())) {
1266
+ return { people, error: `@${github} is in the list twice` };
1267
+ }
1268
+ const marker = (clean(p.marker) || defaultMarker(name || github)).toLowerCase().replace(/[^a-z0-9-]/g, "");
1269
+ if (people.some((h) => h.marker === marker)) {
1270
+ return {
1271
+ people,
1272
+ error: `two people would share the label "${marker}"; give one a different label`
1273
+ };
1274
+ }
1275
+ const handles = (Array.isArray(p.handles) ? p.handles : String(p.handles ?? "").split(",")).map(clean).filter(Boolean);
1276
+ people.push({
1277
+ github,
1278
+ name,
1279
+ marker,
1280
+ ...clean(p.role) ? { role: clean(p.role) } : {},
1281
+ ...handles.length ? { handles } : {},
1282
+ ...p.view_only === true ? { viewOnly: true } : {}
1283
+ });
1284
+ }
1285
+ if (!people.some((h) => !h.viewOnly)) {
1286
+ return {
1287
+ people,
1288
+ error: "someone has to be able to wake the staff: one person cannot be read-only"
1289
+ };
1290
+ }
1291
+ return { people };
1292
+ }
1293
+ function writeHumans(text2, people) {
1294
+ const lines = text2.split("\n");
1295
+ const block = [
1296
+ "humans:",
1297
+ ...people.map((h) => {
1298
+ const parts = [`name: ${h.name}`, `github: ${h.github}`, `marker: ${h.marker}`];
1299
+ if (h.role) parts.push(`role: ${h.role}`);
1300
+ if (h.handles?.length) parts.push(`handles: [${h.handles.join(", ")}]`);
1301
+ if (h.viewOnly) parts.push("view_only: true");
1302
+ return ` - { ${parts.join(", ")} }`;
1303
+ })
1304
+ ];
1305
+ const out = [];
1306
+ let at = -1;
1307
+ for (let i = 0; i < lines.length; i++) {
1308
+ if (/^humans?:/.test(lines[i])) {
1309
+ if (at < 0) at = out.length;
1310
+ while (i + 1 < lines.length) {
1311
+ const next = lines[i + 1];
1312
+ const more = /^\s+\S/.test(next) || /^\s*$/.test(next) && nextIsIndented(lines, i + 1);
1313
+ if (!more) break;
1314
+ i++;
1315
+ }
1316
+ continue;
1317
+ }
1318
+ out.push(lines[i]);
1319
+ }
1320
+ if (at < 0) {
1321
+ const name = out.findIndex((l) => /^name:/.test(l));
1322
+ at = name >= 0 ? name + 1 : out.length;
1323
+ out.splice(at, 0, "");
1324
+ at++;
1325
+ }
1326
+ out.splice(at, 0, ...block);
1327
+ return out.join("\n");
1328
+ }
1329
+ function nextIsIndented(lines, from) {
1330
+ for (let j = from; j < lines.length; j++) {
1331
+ if (/^\s*$/.test(lines[j])) continue;
1332
+ return /^\s+\S/.test(lines[j]);
1333
+ }
1334
+ return false;
1335
+ }
1250
1336
 
1251
1337
  // src/lib/prompt.ts
1252
1338
  import { execFileSync } from "child_process";
@@ -2680,7 +2766,9 @@ function buildPlan(ws, org, handle, opts, parseYaml3) {
2680
2766
  }));
2681
2767
  const labels = [
2682
2768
  .../* @__PURE__ */ new Set([
2769
+ // Every person's label, not only the first's: staff send each ask to whoever's area it is.
2683
2770
  orgSpec2.humanMarker,
2771
+ ...humans.map((h) => h.marker).filter(Boolean),
2684
2772
  handle,
2685
2773
  ...ASK_KINDS,
2686
2774
  "keep-open",
@@ -5346,7 +5434,8 @@ async function checkStaff(ws, org, entry, composer, online) {
5346
5434
  if (online && manifest.brain) {
5347
5435
  const logins = humanLogins(org);
5348
5436
  const keys = declared2(org).filter((c) => c.staff.includes(entry.handle) && !c.problem && c.auth === "key").map((c) => ({ name: c.name, secrets: c.secrets.map((x) => x.name) }));
5349
- out.push(...await checkStaffOnline(scope, manifest, callers, logins, keys));
5437
+ const markers = staffHumans(org).map((h) => h.marker).filter(Boolean);
5438
+ out.push(...await checkStaffOnline(scope, manifest, callers, logins, keys, markers));
5350
5439
  }
5351
5440
  return out;
5352
5441
  }
@@ -5473,7 +5562,7 @@ async function checkReviewGates(ws, org, composer) {
5473
5562
  const readings = await Promise.all([...repos].map((r) => readGate(r, [...apps])));
5474
5563
  return readings.map((r) => ({ scope: "workspace", id: "review-gate", ...judgeGate(r) }));
5475
5564
  }
5476
- async function checkStaffOnline(scope, manifest, callers, humans = [], connectors = []) {
5565
+ async function checkStaffOnline(scope, manifest, callers, humans = [], connectors = [], markers = []) {
5477
5566
  const out = [];
5478
5567
  const repo = manifest.brain;
5479
5568
  const needed = /* @__PURE__ */ new Set();
@@ -5583,8 +5672,11 @@ async function checkStaffOnline(scope, manifest, callers, humans = [], connector
5583
5672
  } : { scope, level: "ok", id: "labels", title: "every declared label exists" }
5584
5673
  );
5585
5674
  out.push(ownedLabels(scope, repo, have));
5675
+ out.push(personLabels(scope, repo, have, markers));
5586
5676
  }
5587
5677
  if (open2.ok) out.push(...unkindedAsks(scope, repo, open2.data, humans));
5678
+ const variable = await api(`repos/${repo}/actions/variables/ROSTER_HUMANS`);
5679
+ if (variable.ok) out.push(humansVariable(scope, repo, variable.data.value, humans));
5588
5680
  const peers = (manifest.peers ?? []).filter((p) => p.label && p.brain);
5589
5681
  const peerLabels = await Promise.all(
5590
5682
  peers.map(
@@ -5910,6 +6002,32 @@ function ownedLabels(scope, repo, have) {
5910
6002
  fix: gone.map((l) => `gh label create ${l} --repo ${repo} --force`).join("\n")
5911
6003
  } : { scope, level: "ok", id: "owned-labels", title: "roster's own labels exist" };
5912
6004
  }
6005
+ function humansVariable(scope, repo, value, humans) {
6006
+ let set = [];
6007
+ try {
6008
+ set = JSON.parse(value).map((x) => String(x).toLowerCase());
6009
+ } catch {
6010
+ }
6011
+ const want = humans.map((h) => h.toLowerCase());
6012
+ const same = set.length === want.length && want.every((h) => set.includes(h));
6013
+ return same ? { scope, level: "ok", id: "humans-variable", title: "ROSTER_HUMANS matches org.yaml" } : {
6014
+ scope,
6015
+ level: "fail",
6016
+ id: "humans-variable",
6017
+ title: `ROSTER_HUMANS on ${repo} is ${value}, but org.yaml says ${JSON.stringify(humans)}`,
6018
+ fix: `gh variable set ROSTER_HUMANS --repo ${repo} --body '${JSON.stringify(humans)}'`
6019
+ };
6020
+ }
6021
+ function personLabels(scope, repo, have, markers) {
6022
+ const gone = [...new Set(markers)].filter((l) => !have.has(l));
6023
+ return gone.length ? {
6024
+ scope,
6025
+ level: "warn",
6026
+ id: "person-labels",
6027
+ title: `a person's label is missing from ${repo}: ${gone.join(", ")}`,
6028
+ fix: gone.map((l) => `gh label create ${l} --repo ${repo} --force`).join("\n")
6029
+ } : { scope, level: "ok", id: "person-labels", title: "every person's label exists" };
6030
+ }
5913
6031
  function unkindedAsks(scope, repo, issues, humans) {
5914
6032
  const on = new Set(humans.map((h) => h.toLowerCase()));
5915
6033
  const bad2 = issues.filter(
@@ -6035,6 +6153,7 @@ function buildExport(ws, org, parseYaml3, opts = {}) {
6035
6153
  opsName: ws.opsName,
6036
6154
  human: humans[0] ?? org.human ?? {},
6037
6155
  humans,
6156
+ people: readHumans(org),
6038
6157
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
6039
6158
  staff
6040
6159
  };
@@ -7404,7 +7523,7 @@ var REACTIONS = `
7404
7523
  `;
7405
7524
  var TIMELINE_COMMON = `
7406
7525
  __typename
7407
- ... on IssueComment { author { login } createdAt body url ${REACTIONS} }
7526
+ ... on IssueComment { author { login } createdAt body bodyHTML url ${REACTIONS} }
7408
7527
  ... on CrossReferencedEvent {
7409
7528
  actor { login } createdAt
7410
7529
  source {
@@ -7436,7 +7555,7 @@ var TIMELINE_COMMON = `
7436
7555
  `;
7437
7556
  var TIMELINE_PR = `
7438
7557
  ... on MergedEvent { actor { login } createdAt commit { oid url } }
7439
- ... on PullRequestReview { author { login } createdAt state body url }
7558
+ ... on PullRequestReview { author { login } createdAt state body bodyHTML url }
7440
7559
  ... on ReadyForReviewEvent { actor { login } createdAt }
7441
7560
  ... on ReviewRequestedEvent {
7442
7561
  actor { login } createdAt
@@ -7487,7 +7606,7 @@ query($owner:String!, $name:String!, $number:Int!) {
7487
7606
  issueOrPullRequest(number:$number) {
7488
7607
  __typename
7489
7608
  ... on Issue {
7490
- number title body url state createdAt updatedAt ${ROW_EXTRAS}
7609
+ number title body bodyHTML url state createdAt updatedAt ${ROW_EXTRAS}
7491
7610
  author { login }
7492
7611
  ${REACTIONS}
7493
7612
  labels(first:12) { nodes { name } }
@@ -7495,7 +7614,7 @@ query($owner:String!, $name:String!, $number:Int!) {
7495
7614
  timelineItems(last:100, itemTypes:${ISSUE_TYPES}) { nodes { ${TIMELINE_COMMON} } }
7496
7615
  }
7497
7616
  ... on PullRequest {
7498
- number title body url state createdAt updatedAt isDraft mergeable reviewDecision ${ROW_EXTRAS}
7617
+ number title body bodyHTML url state createdAt updatedAt isDraft mergeable reviewDecision ${ROW_EXTRAS}
7499
7618
  author { login }
7500
7619
  ${REACTIONS}
7501
7620
  labels(first:12) { nodes { name } }
@@ -7564,7 +7683,7 @@ function shape(n, repo, role, kind) {
7564
7683
  // The list carries the body only to find a decision's default; a row never shows it, and
7565
7684
  // a thread that is opened is read whole on its own. A status issue's body is the exception:
7566
7685
  // it is the staff member's report, and Home shows it.
7567
- body: n.timelineItems || isStatus(n) ? n.body ?? "" : "",
7686
+ body: n.timelineItems || isStatus(n) ? signed(n.body ?? "", n.bodyHTML) : "",
7568
7687
  ...extras(n),
7569
7688
  labels: (n.labels?.nodes ?? []).map((l) => l.name),
7570
7689
  assignees: (n.assignees?.nodes ?? []).map((a) => a.login),
@@ -7604,6 +7723,21 @@ function dueOf(body2) {
7604
7723
  const action = m[2].replace(/[*_"“”]+/g, "").replace(/\.\s*$/, "").trim();
7605
7724
  return { date: m[1], action };
7606
7725
  }
7726
+ var ASSET_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
7727
+ var ASSET_LINK = /https:\/\/github\.com\/(?:user-attachments\/assets|[\w.-]+\/[\w.-]+\/assets\/\d+)\/([0-9a-f-]{36})/g;
7728
+ function signed(body2, html) {
7729
+ if (!html || !body2.includes("github.com/")) return body2;
7730
+ const found = /* @__PURE__ */ new Map();
7731
+ for (const m of html.matchAll(
7732
+ /src="(https:\/\/private-user-images\.githubusercontent\.com\/[^"]+)"/g
7733
+ )) {
7734
+ const src = m[1].replace(/&amp;/g, "&");
7735
+ const id = ASSET_ID.exec(src)?.[0];
7736
+ if (id && !found.has(id)) found.set(id, src);
7737
+ }
7738
+ if (!found.size) return body2;
7739
+ return body2.replace(ASSET_LINK, (link, id) => found.get(id) ?? link);
7740
+ }
7607
7741
  function reactions(n) {
7608
7742
  return (n.reactionGroups ?? []).filter((g) => (g.reactors?.totalCount ?? 0) > 0).map((g) => ({
7609
7743
  content: g.content,
@@ -7620,7 +7754,7 @@ function event(e) {
7620
7754
  type: "comment",
7621
7755
  actor: who,
7622
7756
  createdAt: at,
7623
- body: e.body ?? "",
7757
+ body: signed(e.body ?? "", e.bodyHTML),
7624
7758
  url: e.url,
7625
7759
  reactions: reactions(e)
7626
7760
  };
@@ -7680,7 +7814,7 @@ function event(e) {
7680
7814
  actor: who,
7681
7815
  createdAt: at,
7682
7816
  state: e.state,
7683
- body: e.body ?? "",
7817
+ body: signed(e.body ?? "", e.bodyHTML),
7684
7818
  url: e.url
7685
7819
  };
7686
7820
  case "ReadyForReviewEvent":
@@ -8566,7 +8700,16 @@ var DOCS = /* @__PURE__ */ new Set(["/api/docs", "/api/docsearch", "/api/doc", "
8566
8700
  function isPortalRoute(path) {
8567
8701
  return Object.hasOwn(ROUTES, path);
8568
8702
  }
8703
+ var localLogin = null;
8569
8704
  var ROUTES = {
8705
+ /* A hosted portal answers this before it gets here. On your own machine it is whoever your
8706
+ `gh` is signed in as, so Home can show you what is yours. */
8707
+ "/api/session": async ({ actor }) => {
8708
+ localLogin ??= actor.gh.graphql("query { viewer { login } }").then((r) => r.ok ? r.data?.viewer?.login ?? "" : "").catch(() => "");
8709
+ const login = await localLogin;
8710
+ if (!login) localLogin = null;
8711
+ return json({ login, hosted: false });
8712
+ },
8570
8713
  /* The docs ship with the framework, so they are served from there rather than the tenant. */
8571
8714
  "/api/docs": async () => json(docPages()),
8572
8715
  "/api/docsearch": async ({ url }) => json({ hits: searchDocs(url.searchParams.get("q") ?? "") }),
@@ -8837,6 +8980,57 @@ var ROUTES = {
8837
8980
  await commitFile(portal, actor.gh, dir, rest.join("/"), payload.text, message2, base2)
8838
8981
  );
8839
8982
  },
8983
+ /* Who the staff answer to, from the Org screen. One commit to org.yaml, then each person's
8984
+ label on every tracker (an ask is sent by labelling it for someone, and GitHub refuses a
8985
+ label that does not exist) and the ROSTER_HUMANS variable the mention callers gate on, so
8986
+ somebody added here can wake a staff member straight away rather than after an upgrade. */
8987
+ "/api/people": async (c) => {
8988
+ const { req, portal, actor } = c;
8989
+ if (!actor.canWrite) return refuse();
8990
+ const { org, brains } = await ready(c, { force: true });
8991
+ if (isViewOnly(org, actor.id))
8992
+ return json({ error: "Read-only people cannot change this." }, 403);
8993
+ const payload = await body(req);
8994
+ const { people, error } = tidyPeople(Array.isArray(payload.people) ? payload.people : []);
8995
+ if (error) return json({ error }, 400);
8996
+ const text2 = portal.snapshots.get(`${portal.org}/${portal.opsName}`)?.files.get("org.yaml")?.text;
8997
+ if (text2 === void 0) return json({ error: "could not read org.yaml" }, 502);
8998
+ const next = writeHumans(text2, people);
8999
+ const wrong = validateOrgYaml(next, parseYaml2);
9000
+ if (wrong) return json({ error: wrong }, 400);
9001
+ const saved = await commitFile(
9002
+ portal,
9003
+ actor.gh,
9004
+ portal.opsName,
9005
+ "org.yaml",
9006
+ next,
9007
+ "portal: who the staff answer to",
9008
+ payload.base
9009
+ );
9010
+ const warnings = [];
9011
+ const logins = JSON.stringify(people.filter((h) => !h.viewOnly).map((h) => h.github));
9012
+ await Promise.all(
9013
+ brains.map(async (dir) => {
9014
+ const repo = `${portal.org}/${dir}`;
9015
+ for (const h of people) {
9016
+ const made = await actor.gh.request("POST", `repos/${repo}/labels`, {
9017
+ body: { name: h.marker, color: "1d76db", description: `An ask for ${h.name}` }
9018
+ });
9019
+ if (!made.ok && made.status !== 422)
9020
+ warnings.push(`label "${h.marker}" on ${dir}: ${made.error}`);
9021
+ }
9022
+ const v = { name: "ROSTER_HUMANS", value: logins };
9023
+ let set = await actor.gh.request("PATCH", `repos/${repo}/actions/variables/ROSTER_HUMANS`, {
9024
+ body: v
9025
+ });
9026
+ if (!set.ok && set.status === 404) {
9027
+ set = await actor.gh.request("POST", `repos/${repo}/actions/variables`, { body: v });
9028
+ }
9029
+ if (!set.ok) warnings.push(`who can wake ${dir}: ${set.error}`);
9030
+ })
9031
+ );
9032
+ return json({ ...saved, warnings });
9033
+ },
8840
9034
  /* Connectors: what is offered, what this org has, and whether each one's keys are stored. */
8841
9035
  "/api/connectors": async (c) => {
8842
9036
  const { portal, actor } = c;
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  compose,
4
+ handlesList,
4
5
  humanSentence,
5
6
  parseYaml,
6
7
  readHumans,
7
8
  render
8
- } from "./chunk-E3EVPK4I.js";
9
+ } from "./chunk-JH3LQ34C.js";
9
10
  export {
10
11
  compose,
12
+ handlesList,
11
13
  humanSentence,
12
14
  parseYaml,
13
15
  readHumans,
@@ -9,7 +9,7 @@ import {
9
9
  serverFor,
10
10
  wiringFor,
11
11
  withConnectors
12
- } from "./chunk-QCKEGMXD.js";
12
+ } from "./chunk-UEZPQ5PV.js";
13
13
  export {
14
14
  CATALOGUE,
15
15
  connectorsOf,
@@ -133,6 +133,10 @@ button.ghbtn:hover{background:color-mix(in srgb,var(--surface-2) 88%,var(--ink)
133
133
  .ghbtn.primary{background:var(--accent);border-color:transparent;color:var(--accent-ink);font-weight:600}
134
134
  .ghbtn.primary:hover{background:var(--accent);color:var(--accent-ink);opacity:.88}
135
135
  .ghbtn:disabled{opacity:.45;cursor:default}
136
+ /* Something that ends a thing: light red, so it is never mistaken for the way forward. */
137
+ .ghbtn.danger{color:var(--err);background:color-mix(in srgb,var(--err) 10%,transparent);
138
+ border-color:color-mix(in srgb,var(--err) 28%,transparent)}
139
+ button.ghbtn.danger:hover{color:var(--err);background:color-mix(in srgb,var(--err) 17%,transparent)}
136
140
  .iconbtn{background:var(--surface-2);border:1px solid transparent;color:var(--ink-dim);
137
141
  border-radius:8px;width:34px;height:34px;cursor:pointer;font-size:15px;line-height:1;
138
142
  transition:background .15s var(--ease),color .15s var(--ease)}
@@ -114,3 +114,23 @@
114
114
  .effect{border:1px solid color-mix(in srgb,var(--accent) 35%,transparent);
115
115
  background:color-mix(in srgb,var(--accent) 7%,transparent);
116
116
  border-radius:var(--r);padding:11px 13px;margin-bottom:14px}
117
+
118
+ /* People on the Org screen: one row per person, edited in place. */
119
+ .peoplecard{margin-bottom:18px;display:flex;flex-direction:column;gap:12px}
120
+ .peoplecard h2{margin:0;font:600 15px var(--sans);color:var(--ink);text-transform:none;letter-spacing:-.01em}
121
+ .peoplelist{display:flex;flex-direction:column;gap:8px}
122
+ .peoplerow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1.6fr) 72px auto;
123
+ gap:8px;align-items:center}
124
+ .peoplerow input[type=text]{width:100%;box-sizing:border-box;font:13px var(--sans);color:var(--ink);
125
+ background:var(--surface-2);border:1px solid transparent;border-radius:8px;padding:7px 9px}
126
+ .peoplerow input[type=text]:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
127
+ .peoplehead span{font:600 11.5px var(--sans);color:var(--ink-dim)}
128
+ .peopleonly{display:flex;justify-content:center}
129
+ .peoplerow .ghbtn{min-height:30px;padding:3px 12px;font-size:12.5px}
130
+ @media (max-width:720px){
131
+ .peoplehead{display:none}
132
+ .peoplerow{grid-template-columns:1fr 1fr;padding-bottom:10px;border-bottom:1px solid var(--line)}
133
+ .peoplerow > :nth-child(3){grid-column:1 / -1}
134
+ .peopleonly::after{content:"Read only";font:12.5px var(--sans);color:var(--ink-dim);margin-left:6px}
135
+ .peopleonly{justify-content:flex-start;align-items:center}
136
+ }