deictic 0.4.0 → 0.6.0

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 (69) hide show
  1. package/API.md +19 -8
  2. package/dist/cli.js +34 -28
  3. package/dist/cli.js.map +1 -1
  4. package/dist/shared/board.js +8 -19
  5. package/dist/shared/board.js.map +1 -1
  6. package/dist/shared/clean.js +105 -0
  7. package/dist/shared/clean.js.map +1 -0
  8. package/dist/shared/endpoints.js +35 -9
  9. package/dist/shared/endpoints.js.map +1 -1
  10. package/dist/shared/find.js +3 -2
  11. package/dist/shared/find.js.map +1 -1
  12. package/dist/shared/frame.js +4 -18
  13. package/dist/shared/frame.js.map +1 -1
  14. package/dist/shared/index.d.ts +8 -4
  15. package/dist/shared/index.d.ts.map +1 -1
  16. package/dist/shared/index7.d.ts +2 -0
  17. package/dist/shared/index7.d.ts.map +1 -1
  18. package/dist/shared/init.js +17 -24
  19. package/dist/shared/init.js.map +1 -1
  20. package/dist/shared/local.js +2 -1
  21. package/dist/shared/local.js.map +1 -1
  22. package/dist/shared/packages.js +9 -2
  23. package/dist/shared/packages.js.map +1 -1
  24. package/dist/shared/recording.js +4 -27
  25. package/dist/shared/recording.js.map +1 -1
  26. package/dist/shared/src.js.map +1 -1
  27. package/dist/shared/task.js +43 -10
  28. package/dist/shared/task.js.map +1 -1
  29. package/dist/shared/tasks.js +109 -115
  30. package/dist/shared/tasks.js.map +1 -1
  31. package/dist/shared/transcribe.js +1 -128
  32. package/dist/shared/transcribe2.js +119 -0
  33. package/dist/shared/transcribe2.js.map +1 -0
  34. package/dist/shared/vb.js +2 -3
  35. package/dist/shared/vb.js.map +1 -1
  36. package/dist/shared/voice2.js +4 -17
  37. package/dist/shared/voice2.js.map +1 -1
  38. package/dist/shared/watch.js +56 -39
  39. package/dist/shared/watch.js.map +1 -1
  40. package/dist/tailwind/index.js +6 -2
  41. package/dist/tailwind/index.js.map +1 -1
  42. package/dist/tasks/client.d.ts.map +1 -1
  43. package/dist/tasks/client.js +4 -5
  44. package/dist/tasks/client.js.map +1 -1
  45. package/dist/tasks/index.js +1 -1
  46. package/package.json +2 -1
  47. package/skills/deictic/SKILL.md +5 -3
  48. package/skills/deictic/references/tasks.md +6 -5
  49. package/src/cli/board.ts +7 -13
  50. package/src/cli/clean.ts +104 -0
  51. package/src/cli/find.ts +3 -1
  52. package/src/cli/frame.ts +3 -13
  53. package/src/cli/init.ts +16 -20
  54. package/src/cli/recording.ts +15 -21
  55. package/src/cli/task.ts +49 -10
  56. package/src/cli/transcribe.ts +13 -16
  57. package/src/cli/vb.ts +0 -2
  58. package/src/cli/voice.ts +3 -12
  59. package/src/cli/watch.ts +58 -29
  60. package/src/cli.ts +130 -31
  61. package/src/index.ts +8 -4
  62. package/src/plugins/tailwind/index.ts +6 -2
  63. package/src/plugins/tasks/client.ts +4 -5
  64. package/src/plugins/tasks/index.ts +113 -124
  65. package/src/plugins/tasks/local.ts +2 -1
  66. package/src/tools/endpoints.ts +18 -7
  67. package/src/tools/packages.ts +3 -0
  68. package/src/tools/source.ts +25 -5
  69. package/dist/shared/transcribe.js.map +0 -1
@@ -1,31 +1,29 @@
1
1
  import { existsSync, mkdirSync, readFileSync } from "node:fs";
2
2
  import { dirname, join, resolve } from "node:path";
3
- import { d as read, g as vbJson, l as fail, o as deicticDirs, s as download, t as ME, u as parseArgs } from "./board.js";
3
+ import { h as vbJson, o as deicticDirs, s as download, t as ME, u as read } from "./board.js";
4
4
  // src/cli/task.ts
5
5
  /**
6
6
  * `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the
7
7
  * page, what's attached with the command to look at each, the replies, and the other open tasks about the same page.
8
8
  */
9
- const usage = "task <id> [--out dir] a task briefly; --out downloads what is attached";
10
9
  /** An actor by the profile its ID ends in (`…+claude`), or the ID of one that writes as itself. */
11
10
  const nameOf = (actor) => actor.includes("+") ? actor.slice(actor.lastIndexOf("+") + 1) : actor;
12
- function run(args) {
13
- const { values, positionals } = parseArgs(args, { out: { type: "string" } });
14
- if (positionals[0] === void 0) fail(`Name a task: ${ME} task 68`);
15
- const { message: root, replies } = read(positionals[0]);
11
+ function run(id, values) {
12
+ const { message: root, replies } = read(id);
16
13
  const [asked = "", where = ""] = root.text.split(/\n---\n/);
17
14
  const label = (key) => root.labels[key];
18
15
  const at = label("deictic.at");
19
16
  console.log(`#${root.id} ${root.task?.state ?? "not a task"}, asked by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);
20
17
  const claim = root.task?.claim;
21
18
  if (claim) console.log(`Claimed by ${nameOf(claim.actor)} until ${claim.until}`);
22
- if (root.task?.result !== void 0) console.log(`Result: ${root.task.result}`);
23
- if (root.task?.reason !== void 0) console.log(`Reason: ${root.task.reason}`);
19
+ if (root.task?.result != null) console.log(`Result: ${root.task.result}`);
20
+ if (root.task?.reason != null) console.log(`Reason: ${root.task.reason}`);
24
21
  console.log(`\nAsked:\n${asked.trim()}\n`);
25
22
  const pointed = /\nPointed at, inside it: `([^`]*)`\n`{3,}\w*\n([\s\S]*?)\n`{3,}/.exec(where);
26
23
  const facts = [
27
24
  ["deictic.project", (v) => `Project ${v}`],
28
25
  ["deictic.at", (v) => `${v} <${label("deictic.tag") ?? "?"}>`],
26
+ ["deictic.source", (v) => `Source: ${at?.replace(/:\d+$/, "") ?? "?"} ← ${v}`],
29
27
  ["deictic.url", (v) => v],
30
28
  ["deictic.viewport", (v) => `Viewport ${v}`],
31
29
  ["deictic.count", (v) => v === "1" ? void 0 : `${v} elements on the page come from that line`],
@@ -36,15 +34,50 @@ function run(args) {
36
34
  const line = value === void 0 ? void 0 : say(value);
37
35
  if (line !== void 0) console.log(line);
38
36
  }
37
+ for (const line of drawn(root)) console.log(line);
39
38
  const told = (pointed ? where.slice(0, pointed.index) : where).trim();
40
39
  if (told !== "") console.log(told);
41
40
  if (pointed) console.log(`\nPointed at, inside it: ${pointed[1]}\n ${pointed[2]}`);
41
+ const path = label("deictic.pointed");
42
+ if (path !== void 0) {
43
+ const file = root.attachments.some((a) => a.name === "pointed.html") ? "pointed.html" : "element.html";
44
+ console.log(`\nPointed at, inside it: ${path} (its HTML is in ${file})`);
45
+ }
42
46
  if (at !== void 0) placeOf(at, label("deictic.line"));
43
47
  attachments(root, values.out === void 0 ? void 0 : resolve(values.out));
44
48
  if (replies.length > 0) console.log("\nReplies:");
45
49
  for (const r of replies) console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);
46
50
  others(root);
47
51
  }
52
+ /**
53
+ * What the attached files don't say, from the numbered labels: where the element is in each shot and the notes on it, the
54
+ * notes drawn on the page, where each recording replays, and what wasn't kept any more.
55
+ */
56
+ function drawn({ labels, attachments }) {
57
+ const numbered = (prefix) => {
58
+ const out = [];
59
+ for (let n = 1; labels[`${prefix}.${n}`] !== void 0; n++) out.push(labels[`${prefix}.${n}`]);
60
+ return out;
61
+ };
62
+ const notes = (prefix) => numbered(`${prefix}.note`).map((note) => JSON.stringify(note));
63
+ const lines = [];
64
+ for (const [i, { name }] of attachments.filter((a) => a.type === "image/png").entries()) {
65
+ const shot = `deictic.screenshot.${i + 1}`;
66
+ const position = labels[`${shot}.position`];
67
+ if (position === void 0) continue;
68
+ const said = notes(shot);
69
+ lines.push(`${name}: the element at x,y ${position}, ${labels[`${shot}.size`] ?? "?"} (CSS pixels from its top left)${said.length === 0 ? "" : `; notes drawn on it: ${said.join(", ")}`}`);
70
+ }
71
+ const onPage = notes("deictic");
72
+ if (onPage.length > 0) lines.push(`Notes drawn on the page: ${onPage.join(", ")}`);
73
+ for (const [i, { name }] of attachments.filter((a) => a.name.startsWith("recording-")).entries()) {
74
+ const replay = labels[`deictic.recording.${i + 1}.replay`];
75
+ if (replay !== void 0) lines.push(`${name} replays at ${replay}`);
76
+ }
77
+ const dropped = numbered("deictic.dropped");
78
+ if (dropped.length > 0) lines.push(`Not attached, as it wasn't kept any more: ${dropped.join(", ")}`);
79
+ return lines;
80
+ }
48
81
  /** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */
49
82
  function placeOf(at, first) {
50
83
  const file = at.replace(/:\d+:\d+$/, "");
@@ -72,7 +105,7 @@ function attachments(root, out) {
72
105
  const kb = `${Math.round(a.size / 1024)} KB`;
73
106
  if (out !== void 0) download(a, join(out, a.name));
74
107
  const saved = out === void 0 ? "" : ` → ${join(out, a.name)}`;
75
- const get = saved || `: npx deictic vb download ${a.id} ${a.name}`;
108
+ const get = saved || `: ${ME} vb download ${a.id} ${a.name}`;
76
109
  if (a.name.startsWith("recording-")) {
77
110
  console.log(` ${a.name} (${kb})${saved}`);
78
111
  console.log(` timeline: ${ME} recording ${root.id}`);
@@ -103,6 +136,6 @@ function others(root) {
103
136
  console.log(` #${m.id} ${m.task?.state ?? ""}, ${m.labels["deictic.at"] ?? "?"}: ${title}`);
104
137
  }
105
138
  }
106
- export { run, usage };
139
+ export { run };
107
140
 
108
141
  //# sourceMappingURL=task.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"task.js","names":[],"sources":["../../src/cli/task.ts"],"sourcesContent":["/**\n * `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the\n * page, what's attached with the command to look at each, the replies, and the other open tasks about the same page.\n */\nimport { existsSync, mkdirSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\nimport { deicticDirs, download, fail, ME, type Message, parseArgs, read, vbJson } from './board.ts';\n\nexport const usage = 'task <id> [--out dir] a task briefly; --out downloads what is attached';\n\n/** An actor by the profile its ID ends in (`…+claude`), or the ID of one that writes as itself. */\nconst nameOf = (actor: string) => (actor.includes('+') ? actor.slice(actor.lastIndexOf('+') + 1) : actor);\n\nexport function run(args: string[]): void {\n const { values, positionals } = parseArgs(args, { out: { type: 'string' } });\n if (positionals[0] === undefined) fail(`Name a task: ${ME} task 68`);\n const { message: root, replies } = read(positionals[0]);\n const [asked = '', where = ''] = root.text.split(/\\n---\\n/);\n const label = (key: string) => root.labels[key];\n const at = label('deictic.at');\n\n // Who asked, said as that: the line's state is beside it, and a board's record names no one for a task's end.\n console.log(`#${root.id} ${root.task?.state ?? 'not a task'}, asked by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);\n const claim = root.task?.claim;\n if (claim) console.log(`Claimed by ${nameOf(claim.actor)} until ${claim.until}`);\n if (root.task?.result !== undefined) console.log(`Result: ${root.task.result}`);\n if (root.task?.reason !== undefined) console.log(`Reason: ${root.task.reason}`);\n console.log(`\\nAsked:\\n${asked.trim()}\\n`);\n // The part inside the element that was pointed at, where nothing marked it: what the person means.\n const pointed = /\\nPointed at, inside it: `([^`]*)`\\n`{3,}\\w*\\n([\\s\\S]*?)\\n`{3,}/.exec(where);\n // Where, from the labels: the place, the page, and the viewport to look at it in.\n const facts: [string, (v: string) => string | undefined][] = [\n ['deictic.project', (v) => `Project ${v}`],\n ['deictic.at', (v) => `${v} <${label('deictic.tag') ?? '?'}>`],\n ['deictic.url', (v) => v],\n ['deictic.viewport', (v) => `Viewport ${v}`],\n ['deictic.count', (v) => (v === '1' ? undefined : `${v} elements on the page come from that line`)],\n ['deictic.position', (v) => `In the screenshot at x,y ${v}, ${label('deictic.size') ?? '?'} (CSS pixels from its top left)`],\n ];\n for (const [key, say] of facts) {\n const value = label(key);\n const line = value === undefined ? undefined : say(value);\n if (line !== undefined) console.log(line);\n }\n // What no label holds: what's attached and drawn on it.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(told);\n if (pointed) console.log(`\\nPointed at, inside it: ${pointed[1]}\\n ${pointed[2]}`);\n\n if (at !== undefined) placeOf(at, label('deictic.line'));\n attachments(root, values.out === undefined ? undefined : resolve(values.out));\n\n if (replies.length > 0) console.log('\\nReplies:');\n for (const r of replies) console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);\n others(root);\n}\n\n/** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */\nfunction placeOf(at: string, first: string | undefined): void {\n const file = at.replace(/:\\d+:\\d+$/, '');\n const line = Number(at.split(':').at(-2));\n // Marks are from the dev server's root: here, above, or a folder with a .deictic/ of its own.\n const roots = [process.cwd(), ...deicticDirs().map(dirname)];\n const path = roots.map((r) => resolve(r, file)).find((p) => existsSync(p));\n if (path === undefined) {\n console.log(`\\n${file} isn't under ${roots.join(' or ')}: find the dev server's root.`);\n return;\n }\n const lines = readFileSync(path, 'utf8').split('\\n');\n // The tag's first line may follow other code on its line: `const App = () => <h1>`.\n const now = lines[line - 1]?.trim();\n if (first === undefined || now?.includes(first.slice(0, 40))) {\n console.log(`\\nFile: ${path}:${line}, as the task saw it.`);\n return;\n }\n const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));\n console.log(\n moved >= 0\n ? `\\nFile: moved to ${path}:${moved + 1} (the task says line ${line}).`\n : `\\nFile: ${path}:${line} no longer reads as the task saw it; it was:\\n ${first}`,\n );\n}\n\n/** What's attached, with the command to look at each, downloaded to `out` where it's given. */\nfunction attachments(root: Message, out: string | undefined): void {\n if (root.attachments.length > 0) console.log('\\nAttached:');\n if (out !== undefined) mkdirSync(out, { recursive: true });\n for (const a of root.attachments) {\n const kb = `${Math.round(a.size / 1024)} KB`;\n if (out !== undefined) download(a, join(out, a.name));\n const saved = out === undefined ? '' : ` → ${join(out, a.name)}`;\n // To a file's path: the CLI writes what it's given, and refuses a folder.\n const get = saved || `: ${ME} vb download ${a.id} ${a.name}`;\n if (a.name.startsWith('recording-')) {\n console.log(` ${a.name} (${kb})${saved}`);\n console.log(` timeline: ${ME} recording ${root.id}`);\n console.log(` frames: ${ME} frame ${root.id}`);\n } else if (a.name.startsWith('voice-')) {\n console.log(` ${a.name} (${kb}), a voice clip${saved}`);\n console.log(` speech: ${ME} voice ${root.id}`);\n } else if (a.name === 'element.html') {\n console.log(` ${a.name} (${kb}), the element's HTML as it rendered, if you need it${get}`);\n } else {\n console.log(` ${a.name} (${a.type}, ${kb})${get}`);\n }\n }\n}\n\n/** The other open tasks about the same page, of the same project: left a minute apart, they're often one change. */\nfunction others(root: Message): void {\n const page = root.labels['deictic.page'];\n if (page === undefined) return;\n const project = root.labels['deictic.project'];\n const labels = [`deictic.page=${page}`, ...(project === undefined ? [] : [`deictic.project=${project}`])];\n const { tasks } = vbJson<{ tasks: { message: Message }[] }>(['tasks', root.channel, ...labels.flatMap((l) => ['--label', l])]);\n const rest = tasks.map((t) => t.message).filter((m) => m.id !== root.id);\n if (rest.length === 0) return;\n console.log(\n `\\n${rest.length} other open task${rest.length === 1 ? '' : 's'} on ${page}: read them before you start, they may be one change.`,\n );\n for (const m of rest) {\n const title = (m.text.split(/\\n---\\n/)[0] ?? '').split('\\n')[0]?.slice(0, 100);\n console.log(` #${m.id} ${m.task?.state ?? ''}, ${m.labels['deictic.at'] ?? '?'}: ${title}`);\n }\n}\n"],"mappings":";;;;;;;;AASA,MAAa,QAAQ;;AAGrB,MAAM,UAAU,UAAmB,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI;AAEnG,SAAgB,IAAI,MAAsB;CACxC,MAAM,EAAE,QAAQ,gBAAgB,UAAU,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,EAAE,CAAC;CAC3E,IAAI,YAAY,OAAO,KAAA,GAAW,KAAK,gBAAgB,GAAG,SAAS;CACnE,MAAM,EAAE,SAAS,MAAM,YAAY,KAAK,YAAY,EAAE;CACtD,MAAM,CAAC,QAAQ,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,SAAS;CAC1D,MAAM,SAAS,QAAgB,KAAK,OAAO;CAC3C,MAAM,KAAK,MAAM,YAAY;CAG7B,QAAQ,IAAI,IAAI,KAAK,GAAG,GAAG,KAAK,MAAM,SAAS,aAAa,aAAa,KAAK,QAAQ,UAAU,KAAK,GAAG,MAAM,IAAI,KAAK,WAAW;CAClI,MAAM,QAAQ,KAAK,MAAM;CACzB,IAAI,OAAO,QAAQ,IAAI,cAAc,OAAO,MAAM,KAAK,EAAE,SAAS,MAAM,OAAO;CAC/E,IAAI,KAAK,MAAM,WAAW,KAAA,GAA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IACN,KAAK,KAAK,OAAO,kBAAkB,KAAK,WAAW,IAAI,KAAK,IAAI,MAAM,KAAK,sDAC7E;CACA,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,SAAS,EAAE,KAAK,MAAM,SAAS,CAAC,CAAC,MAAM,GAAA,CAAI,MAAM,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG;EAC7E,QAAQ,IAAI,MAAM,EAAE,GAAG,GAAG,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,iBAAiB,IAAI,IAAI,OAAO;CAC7F;AACF"}
1
+ {"version":3,"file":"task.js","names":[],"sources":["../../src/cli/task.ts"],"sourcesContent":["/**\n * `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the\n * page, what's attached with the command to look at each, the replies, and the other open tasks about the same page.\n */\nimport { existsSync, mkdirSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\nimport { deicticDirs, download, ME, type Message, read, vbJson } from './board.ts';\n\n/** An actor by the profile its ID ends in (`…+claude`), or the ID of one that writes as itself. */\nconst nameOf = (actor: string) => (actor.includes('+') ? actor.slice(actor.lastIndexOf('+') + 1) : actor);\n\nexport function run(id: string, values: { out?: string }): void {\n const { message: root, replies } = read(id);\n const [asked = '', where = ''] = root.text.split(/\\n---\\n/);\n const label = (key: string) => root.labels[key];\n const at = label('deictic.at');\n\n // Who asked, said as that: the line's state is beside it, and a board's record names no one for a task's end.\n console.log(`#${root.id} ${root.task?.state ?? 'not a task'}, asked by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);\n const claim = root.task?.claim;\n if (claim) console.log(`Claimed by ${nameOf(claim.actor)} until ${claim.until}`);\n // A task not over yet has them, as null.\n if (root.task?.result != null) console.log(`Result: ${root.task.result}`);\n if (root.task?.reason != null) console.log(`Reason: ${root.task.reason}`);\n console.log(`\\nAsked:\\n${asked.trim()}\\n`);\n // The part inside the element that was pointed at, where nothing marked it: what the person means.\n const pointed = /\\nPointed at, inside it: `([^`]*)`\\n`{3,}\\w*\\n([\\s\\S]*?)\\n`{3,}/.exec(where);\n // Where, from the labels: the place, the page, and the viewport to look at it in.\n const facts: [string, (v: string) => string | undefined][] = [\n ['deictic.project', (v) => `Project ${v}`],\n ['deictic.at', (v) => `${v} <${label('deictic.tag') ?? '?'}>`],\n // From its own line out: before the label, tasks said it in their text, which is printed below as it is.\n ['deictic.source', (v) => `Source: ${at?.replace(/:\\d+$/, '') ?? '?'} ← ${v}`],\n ['deictic.url', (v) => v],\n ['deictic.viewport', (v) => `Viewport ${v}`],\n ['deictic.count', (v) => (v === '1' ? undefined : `${v} elements on the page come from that line`)],\n // A task added before shots were numbered had its one shot's place here.\n ['deictic.position', (v) => `In the screenshot at x,y ${v}, ${label('deictic.size') ?? '?'} (CSS pixels from its top left)`],\n ];\n for (const [key, say] of facts) {\n const value = label(key);\n const line = value === undefined ? undefined : say(value);\n if (line !== undefined) console.log(line);\n }\n for (const line of drawn(root)) console.log(line);\n // A task added before these were labels says them after its words.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(told);\n if (pointed) console.log(`\\nPointed at, inside it: ${pointed[1]}\\n ${pointed[2]}`);\n const path = label('deictic.pointed');\n if (path !== undefined) {\n const file = root.attachments.some((a) => a.name === 'pointed.html') ? 'pointed.html' : 'element.html';\n console.log(`\\nPointed at, inside it: ${path} (its HTML is in ${file})`);\n }\n\n if (at !== undefined) placeOf(at, label('deictic.line'));\n attachments(root, values.out === undefined ? undefined : resolve(values.out));\n\n if (replies.length > 0) console.log('\\nReplies:');\n for (const r of replies) console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);\n others(root);\n}\n\n/**\n * What the attached files don't say, from the numbered labels: where the element is in each shot and the notes on it, the\n * notes drawn on the page, where each recording replays, and what wasn't kept any more.\n */\nfunction drawn({ labels, attachments }: Message): string[] {\n const numbered = (prefix: string) => {\n const out: string[] = [];\n for (let n = 1; labels[`${prefix}.${n}`] !== undefined; n++) out.push(labels[`${prefix}.${n}`]!);\n return out;\n };\n const notes = (prefix: string) => numbered(`${prefix}.note`).map((note) => JSON.stringify(note));\n const lines: string[] = [];\n // `deictic.screenshot.N` is the Nth PNG attached, `deictic.recording.N` the Nth recording.\n for (const [i, { name }] of attachments.filter((a) => a.type === 'image/png').entries()) {\n const shot = `deictic.screenshot.${i + 1}`;\n const position = labels[`${shot}.position`];\n if (position === undefined) continue;\n const said = notes(shot);\n lines.push(\n `${name}: the element at x,y ${position}, ${labels[`${shot}.size`] ?? '?'} (CSS pixels from its top left)${said.length === 0 ? '' : `; notes drawn on it: ${said.join(', ')}`}`,\n );\n }\n const onPage = notes('deictic');\n if (onPage.length > 0) lines.push(`Notes drawn on the page: ${onPage.join(', ')}`);\n for (const [i, { name }] of attachments.filter((a) => a.name.startsWith('recording-')).entries()) {\n const replay = labels[`deictic.recording.${i + 1}.replay`];\n if (replay !== undefined) lines.push(`${name} replays at ${replay}`);\n }\n const dropped = numbered('deictic.dropped');\n if (dropped.length > 0) lines.push(`Not attached, as it wasn't kept any more: ${dropped.join(', ')}`);\n return lines;\n}\n\n/** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */\nfunction placeOf(at: string, first: string | undefined): void {\n const file = at.replace(/:\\d+:\\d+$/, '');\n const line = Number(at.split(':').at(-2));\n // Marks are from the dev server's root: here, above, or a folder with a .deictic/ of its own.\n const roots = [process.cwd(), ...deicticDirs().map(dirname)];\n const path = roots.map((r) => resolve(r, file)).find((p) => existsSync(p));\n if (path === undefined) {\n console.log(`\\n${file} isn't under ${roots.join(' or ')}: find the dev server's root.`);\n return;\n }\n const lines = readFileSync(path, 'utf8').split('\\n');\n // The tag's first line may follow other code on its line: `const App = () => <h1>`.\n const now = lines[line - 1]?.trim();\n if (first === undefined || now?.includes(first.slice(0, 40))) {\n console.log(`\\nFile: ${path}:${line}, as the task saw it.`);\n return;\n }\n const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));\n console.log(\n moved >= 0\n ? `\\nFile: moved to ${path}:${moved + 1} (the task says line ${line}).`\n : `\\nFile: ${path}:${line} no longer reads as the task saw it; it was:\\n ${first}`,\n );\n}\n\n/** What's attached, with the command to look at each, downloaded to `out` where it's given. */\nfunction attachments(root: Message, out: string | undefined): void {\n if (root.attachments.length > 0) console.log('\\nAttached:');\n if (out !== undefined) mkdirSync(out, { recursive: true });\n for (const a of root.attachments) {\n const kb = `${Math.round(a.size / 1024)} KB`;\n if (out !== undefined) download(a, join(out, a.name));\n const saved = out === undefined ? '' : ` → ${join(out, a.name)}`;\n // To a file's path: the CLI writes what it's given, and refuses a folder.\n const get = saved || `: ${ME} vb download ${a.id} ${a.name}`;\n if (a.name.startsWith('recording-')) {\n console.log(` ${a.name} (${kb})${saved}`);\n console.log(` timeline: ${ME} recording ${root.id}`);\n console.log(` frames: ${ME} frame ${root.id}`);\n } else if (a.name.startsWith('voice-')) {\n console.log(` ${a.name} (${kb}), a voice clip${saved}`);\n console.log(` speech: ${ME} voice ${root.id}`);\n } else if (a.name === 'element.html') {\n console.log(` ${a.name} (${kb}), the element's HTML as it rendered, if you need it${get}`);\n } else {\n console.log(` ${a.name} (${a.type}, ${kb})${get}`);\n }\n }\n}\n\n/** The other open tasks about the same page, of the same project: left a minute apart, they're often one change. */\nfunction others(root: Message): void {\n const page = root.labels['deictic.page'];\n if (page === undefined) return;\n const project = root.labels['deictic.project'];\n const labels = [`deictic.page=${page}`, ...(project === undefined ? [] : [`deictic.project=${project}`])];\n const { tasks } = vbJson<{ tasks: { message: Message }[] }>(['tasks', root.channel, ...labels.flatMap((l) => ['--label', l])]);\n const rest = tasks.map((t) => t.message).filter((m) => m.id !== root.id);\n if (rest.length === 0) return;\n console.log(\n `\\n${rest.length} other open task${rest.length === 1 ? '' : 's'} on ${page}: read them before you start, they may be one change.`,\n );\n for (const m of rest) {\n const title = (m.text.split(/\\n---\\n/)[0] ?? '').split('\\n')[0]?.slice(0, 100);\n console.log(` #${m.id} ${m.task?.state ?? ''}, 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I,MAAM,EAAE,GAAG,GAAG,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,iBAAiB,IAAI,IAAI,OAAO;CAC7F;AACF"}
@@ -1,15 +1,14 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join, relative } from "node:path";
3
3
  import { r as definePlugin, t as Refusal } from "./src.js";
4
- import { n as localBoard } from "./local.js";
4
+ import { r as localBoard } from "./local.js";
5
5
  import { n as watchersOf } from "./watchers.js";
6
6
  // src/plugins/tasks/index.ts
7
7
  /**
8
8
  * `deictic/tasks`: open its tab on an element to add a task about it to a Vercel Board
9
9
  * (`@vercel/board`). The task says what to change, in the words typed, and where: the element's file,
10
10
  * line and tag, the page and the project, all as labels beside the short facts (viewport, how many, where
11
- * it is in the shot), and after the words what a label can't hold: the chain of source it rendered through, from
12
- * its own line out to the files that use its component. Its HTML as it rendered is a file attached, `element.html`, for whoever
11
+ * it is in the shot) and the chain of source it rendered through, out to the files that use its component. Its HTML as it rendered is a file attached, `element.html`, for whoever
13
12
  * wants more than the task says: a task stays short. Whatever works the board's tasks (a person, or an agent of theirs claiming them) takes it
14
13
  * from there; deictic only adds them.
15
14
  *
@@ -101,30 +100,55 @@ function tasks(options = {}) {
101
100
  };
102
101
  let context;
103
102
  let project = options.project;
104
- /** The screenshots, recordings and the element's HTML to attach, uploaded to the board, or nothing when there are none. */
105
- const attach = async (op) => {
106
- const files = [
107
- ...(op.screenshots ?? []).map(({ id }) => {
108
- const shot = context?.use("screenshots")?.read(id);
109
- if (shot === void 0) throw new Refusal(`screenshot ${id} isn't kept any more: take it again`);
110
- return shot;
111
- }),
112
- ...(op.recordings ?? []).map(({ id }) => {
113
- const recording = context?.use("recordings")?.read(id);
114
- if (recording === void 0) throw new Refusal(`recording ${id} isn't kept any more: record it again`);
115
- return recording;
116
- }),
117
- ...[...(op.recordings ?? []).flatMap((r) => r.voice ?? []), ...(op.voice ?? []).map((v) => v.id)].map((id) => {
118
- const clip = context?.use("voice")?.read(id);
119
- if (clip === void 0) throw new Refusal(`voice clip ${id} isn't kept any more: record it again`);
120
- return clip;
121
- }),
122
- ...typeof op.html !== "string" || op.html === "" ? [] : [{
123
- data: new TextEncoder().encode(op.html.slice(0, HTML)),
124
- name: "element.html",
125
- type: "text/html"
126
- }]
127
- ];
103
+ /**
104
+ * The op with only the screenshots, recordings and voice clips still kept, their files, and what's left out: a file
105
+ * goes once newer ones pass its plugin's `keep`, or `deictic clean` takes it, and that's no reason to lose the task.
106
+ */
107
+ const keptOf = (op) => {
108
+ const clipOf = (id) => context?.use("voice")?.read(id);
109
+ const files = [];
110
+ const dropped = [];
111
+ const take = (file, missing) => {
112
+ if (file === void 0) dropped.push(missing);
113
+ else files.push(file);
114
+ return file !== void 0;
115
+ };
116
+ const screenshots = (op.screenshots ?? []).filter(({ id }) => take(context?.use("screenshots")?.read(id), "screenshot"));
117
+ const recordings = (op.recordings ?? []).flatMap((recording) => {
118
+ const found = context?.use("recordings")?.read(recording.id);
119
+ if (!take(found, "recording")) return [];
120
+ if (recording.voice === void 0) return [recording];
121
+ const clipped = (id) => take(clipOf(id), "voice clip");
122
+ return [{
123
+ ...recording,
124
+ voice: recording.voice.filter(clipped)
125
+ }];
126
+ });
127
+ const voice = (op.voice ?? []).filter(({ id }) => take(clipOf(id), "voice note"));
128
+ const html = typeof op.html === "string" && op.html !== "" ? op.html : void 0;
129
+ if (html !== void 0) files.push({
130
+ data: new TextEncoder().encode(html.slice(0, HTML)),
131
+ name: "element.html",
132
+ type: "text/html"
133
+ });
134
+ else if (op.pointed !== void 0) files.push({
135
+ data: new TextEncoder().encode(op.pointed.html.slice(0, HTML)),
136
+ name: "pointed.html",
137
+ type: "text/html"
138
+ });
139
+ return {
140
+ op: {
141
+ ...op,
142
+ ...op.screenshots === void 0 ? {} : { screenshots },
143
+ ...op.recordings === void 0 ? {} : { recordings },
144
+ ...op.voice === void 0 ? {} : { voice }
145
+ },
146
+ files,
147
+ dropped
148
+ };
149
+ };
150
+ /** The files uploaded to the board, or nothing when there are none. */
151
+ const upload = async (files) => {
128
152
  if (files.length === 0) return void 0;
129
153
  const team = await boardOf();
130
154
  return Promise.all(files.map(async (file) => (await team.upload(file)).id));
@@ -158,8 +182,7 @@ function tasks(options = {}) {
158
182
  })
159
183
  ]);
160
184
  const listed = new Set(inFile.tasks.map(({ message }) => message.id));
161
- const line = lineOf(source);
162
- const once = source.code.split(line).length === 2;
185
+ const line = source instanceof Refusal ? void 0 : onceIn(source);
163
186
  const tasks = [];
164
187
  const elsewhere = [];
165
188
  const about = [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks];
@@ -172,6 +195,8 @@ function tasks(options = {}) {
172
195
  const by = actors.get(actorOf(message) ?? "")?.name;
173
196
  const text = message.text.split(REST, 1)[0];
174
197
  const to = taskLink(page, message.id);
198
+ const missing = Object.entries(message.labels).flatMap(([key, value]) => /^deictic\.dropped\.\d+$/.test(key) ? [value] : []);
199
+ const dropped = missing.length === 0 ? void 0 : listOf(missing);
175
200
  const task = {
176
201
  id: message.id,
177
202
  title: text.split("\n", 1)[0],
@@ -179,11 +204,12 @@ function tasks(options = {}) {
179
204
  state,
180
205
  ...by === void 0 ? {} : { by },
181
206
  open: OPEN.has(state),
182
- ...to === void 0 ? {} : { link: to }
207
+ ...to === void 0 ? {} : { link: to },
208
+ ...dropped === void 0 ? {} : { dropped }
183
209
  };
184
210
  const at = placeIn(message.labels);
185
211
  if (at === void 0 || message.labels[AT] === atOf(target)) tasks.push(task);
186
- else if (once && at.tag === target.tag && message.labels["deictic.line"] === clip(line, LABEL)) tasks.push({
212
+ else if (line !== void 0 && at.tag === target.tag && message.labels["deictic.line"] === line) tasks.push({
187
213
  ...task,
188
214
  at
189
215
  });
@@ -230,16 +256,21 @@ function tasks(options = {}) {
230
256
  after
231
257
  } };
232
258
  });
259
+ const { op: kept, files, dropped } = keptOf(op);
260
+ const verb = dropped.length === 1 ? "isn't" : "aren't";
261
+ if (wordsOf(kept) === "") throw new Refusal(`${listOf(dropped)} ${verb} kept any more: attach again, or say what should change`);
233
262
  const labels = {
234
263
  ...options.labels,
235
264
  ...project === void 0 ? {} : { "deictic.project": clip(project, LABEL) },
236
- ...labelsOf(source, target, op)
265
+ ...labelsOf(source, target, kept),
266
+ ...attachedLabels(kept, dropped)
237
267
  };
238
268
  return asked(async () => {
239
- const attachments = await attach(op);
269
+ const attachments = await upload(files);
270
+ const text = clip(wordsOf(kept), 1e4);
240
271
  return { done: await create({
241
272
  channel,
242
- text: textOf(op, target),
273
+ text,
243
274
  labels,
244
275
  ...attachments === void 0 ? {} : { attachments }
245
276
  }) };
@@ -293,58 +324,42 @@ async function localPage(team, channel) {
293
324
  ].includes(url.hostname) || !url.pathname.endsWith("/api/board")) return void 0;
294
325
  return `${url.origin}${url.pathname.slice(0, -10)}/c/${channel.split("/").map(encodeURIComponent).join("/")}`;
295
326
  }
296
- const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
297
- const said = (notes) => notes.length === 0 ? "" : `; the notes say: ${notes.map((n) => JSON.stringify(n)).join(", ")}`;
298
- /** What was marked on the page: how many marks, and what the notes say. */
299
- function annotated({ count, notes }, shots, recordings) {
300
- const where = [...shots === 0 ? [] : [shots === 1 ? "the screenshot" : "the screenshots"], ...recordings === 0 ? [] : [recordings === 1 ? "the recording" : "the recordings"]];
301
- const drawn = where.length === 0 ? "" : `, drawn in ${where.join(" and ")}`;
302
- return `${plural(count, "mark")} on the page${drawn}${said(notes)}`;
303
- }
304
- /** How long each recording ran, and where it plays back, while the dev server keeps it. */
305
- function recordingsOf(recordings) {
306
- return recordings.map(({ duration, replay, voice }, i) => {
307
- const name = recordings.length === 1 ? "A recording" : `Recording ${i + 1}`;
308
- const spoken = voice === void 0 || voice.length === 0 ? "" : `, with the voice (${voice.map((id) => `voice-${id}`).join(", ")})`;
309
- return `${name}, ${clock(duration)} long, attached as rrweb events${spoken}; it replays at ${replay}`;
310
- });
311
- }
312
- /** How long each voice note runs, and the attachment it's in. */
313
- function voicesOf(voice) {
314
- return voice.map(({ id, duration }, i) => {
315
- return `${voice.length === 1 ? "A voice note" : `Voice note ${i + 1}`}, ${clock(duration)} long, attached as voice-${id}`;
316
- });
317
- }
318
- const clock = (ms) => {
319
- const s = Math.round(ms / 1e3);
320
- return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
321
- };
322
327
  /**
323
- * What's drawn on each shot (the element's outline, the person's marks), and with several, where the element is
324
- * in each. One shot's place is the `deictic.position` and `deictic.size` labels, so a shot with nothing drawn
325
- * on it has no line.
328
+ * What the attached files don't say, as labels numbered from 1, so each value is short and none is read out of the
329
+ * text. `deictic.screenshot.N` is the Nth PNG attached: its `.position` and `.size` where the element is in it (CSS
330
+ * pixels from its top left), `.note.M` a note drawn on it. `deictic.recording.N.replay` is where the Nth recording
331
+ * plays back; `deictic.note.M` a note drawn on the page; `deictic.dropped.N` what wasn't kept any more;
332
+ * `deictic.pointed` the path to what was pointed at inside the element. A note past a label is cut.
326
333
  */
327
- function shotsOf(shots) {
328
- const [only] = shots;
329
- if (shots.length === 1 && only !== void 0) {
330
- const { marks, outlined } = only;
331
- const has = [...outlined === true ? ["the element outlined in dashes"] : [], ...marks === void 0 || marks.count === 0 ? [] : [`${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`]];
332
- return has.length === 0 ? [] : [`The screenshot has ${has.join(" and ")}`];
333
- }
334
- return shots.map(({ box, marks, outlined }, i) => {
335
- const drawn = marks === void 0 || marks.count === 0 ? "" : `, with ${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`;
334
+ function attachedLabels(op, dropped) {
335
+ const labels = {};
336
+ const set = (key, value) => {
337
+ labels[`deictic.${key}`] = clip(value.replace(/\p{Cc}+/gu, " "), LABEL);
338
+ };
339
+ for (const [i, { box, marks }] of (op.screenshots ?? []).entries()) {
340
+ const n = `screenshot.${i + 1}`;
336
341
  const [x, y, width, height] = boxOf(box);
337
- return `In screenshot ${i + 1} at x ${x}, y ${y}, ${width}×${height}${outlined === true ? ", outlined in dashes" : ""}${drawn}`;
338
- });
342
+ set(`${n}.position`, `${x},${y}`);
343
+ set(`${n}.size`, `${width}x${height}`);
344
+ for (const [j, note] of (marks?.notes ?? []).entries()) set(`${n}.note.${j + 1}`, note);
345
+ }
346
+ for (const [j, note] of (op.annotations?.notes ?? []).entries()) set(`note.${j + 1}`, note);
347
+ for (const [i, { replay }] of (op.recordings ?? []).entries()) if (replay.length <= LABEL) set(`recording.${i + 1}.replay`, replay);
348
+ for (const [i, kind] of dropped.entries()) set(`dropped.${i + 1}`, kind);
349
+ if (op.pointed !== void 0) set("pointed", op.pointed.path);
350
+ return labels;
339
351
  }
340
352
  /**
341
- * `Source: src/ui/label.tsx:6 ← Field (src/Field.tsx:20) ← Panel`: from the element's line out, as the page said
342
- * it: the components that use it, where the page knows them, or the files around it.
353
+ * `deictic.source`, `Field (src/Field.tsx:20) ← Panel`: what the element rendered through, out from its own place
354
+ * (`deictic.at`), as the page said it: the components that use it, where the page knows them, or the files around
355
+ * it. As many as a label holds, the farthest left out first.
343
356
  */
344
- function chainOf({ loc }, chain) {
345
- const places = chain.slice(0, CHAIN).map((place) => clip(String(place), LABEL));
346
- return places.length === 0 ? [] : [`Source: ${[`${loc.file}:${loc.line}`, ...places].join(" ← ")}`];
357
+ function sourceOf(chain) {
358
+ let places = chain.slice(0, CHAIN).map(String);
359
+ while (places.length > 1 && places.join(THROUGH).length > LABEL) places = places.slice(0, -1);
360
+ return places.length === 0 ? {} : { "deictic.source": clip(places.join(THROUGH), LABEL) };
347
361
  }
362
+ const THROUGH = " ← ";
348
363
  /** How many places a chain names after the element's own: the first few say which use of a component it is. */
349
364
  const CHAIN = 3;
350
365
  /** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */
@@ -370,31 +385,19 @@ function nameOf(root) {
370
385
  /**
371
386
  * The facts about the element, as labels: short values a script reads without parsing the text, and a watch
372
387
  * filters by. `deictic.line` is the opening tag's first line as the task saw it, to tell later that it moved.
373
- * `deictic.url` is the page's whole URL, where a label holds it: `textOf` says a longer one.
388
+ * `deictic.url` is the page's whole URL, where a label holds it; `deictic.page` is its path.
374
389
  */
375
- function labelsOf({ code, element }, target, op) {
376
- const [shot] = op.screenshots ?? [];
390
+ function labelsOf(source, target, op) {
377
391
  return {
378
392
  [AT]: atOf(target),
379
393
  [FILE]: clip(target.loc.file, LABEL),
380
394
  "deictic.tag": target.tag,
381
- "deictic.line": clip(lineOf({
382
- code,
383
- element
384
- }), LABEL),
395
+ ...source instanceof Refusal ? {} : { "deictic.line": clip(lineOf(source), LABEL) },
385
396
  "deictic.page": clip(new URL(op.page).pathname, LABEL),
386
397
  ...op.page.length <= LABEL ? { "deictic.url": op.page } : {},
387
398
  "deictic.viewport": `${op.viewport.width}x${op.viewport.height}`,
388
399
  "deictic.count": String(op.count),
389
- ...op.screenshots?.length === 1 && shot !== void 0 ? placeOf(shot.box) : {}
390
- };
391
- }
392
- /** Where the element is in the one shot, from its top left, and how big: `87,387` and `138x32`, as the viewport is written. */
393
- function placeOf(box) {
394
- const [x, y, width, height] = boxOf(box);
395
- return {
396
- "deictic.position": `${x},${y}`,
397
- "deictic.size": `${width}x${height}`
400
+ ...sourceOf(op.chain ?? [])
398
401
  };
399
402
  }
400
403
  /**
@@ -416,6 +419,11 @@ function agentsOf(actors, claims) {
416
419
  const atOf = ({ loc }) => `${loc.file}:${loc.line}:${loc.column}`;
417
420
  /** The opening tag's first line, as written. */
418
421
  const lineOf = ({ code, element }) => code.slice(element.start, element.end).split("\n", 1)[0].trim();
422
+ /** The element's line as a label has it, where the file has it once: a line it has twice says nothing of which element a task was about. */
423
+ function onceIn(source) {
424
+ const line = lineOf(source);
425
+ return source.code.split(line).length === 2 ? clip(line, LABEL) : void 0;
426
+ }
419
427
  /** Where a task says its element is, from its labels. */
420
428
  function placeIn(labels) {
421
429
  const [, line, column] = /:(\d+):(\d+)$/.exec(labels[AT] ?? "") ?? [];
@@ -426,24 +434,6 @@ function placeIn(labels) {
426
434
  tag: labels["deictic.tag"] ?? ""
427
435
  };
428
436
  }
429
- /**
430
- * The task's text: what was typed, and after a `---` only what no label holds: what's attached and drawn, the
431
- * source it rendered through, what was pointed at inside it, and a URL too long for a label.
432
- * A board holds 10,000 characters.
433
- */
434
- function textOf(op, target) {
435
- const more = [
436
- ...op.page.length <= LABEL ? [] : [op.page],
437
- ...shotsOf(op.screenshots ?? []),
438
- ...recordingsOf(op.recordings ?? []),
439
- ...voicesOf(op.voice ?? []),
440
- ...op.annotations === void 0 ? [] : [annotated(op.annotations, op.screenshots?.length ?? 0, op.recordings?.length ?? 0)],
441
- ...chainOf(target, op.chain ?? []),
442
- ...op.pointed === void 0 ? [] : [`Pointed at, inside it: \`${op.pointed.path}\``, fence(op.pointed.html, "html")]
443
- ];
444
- const tail = more.length === 0 ? "" : REST + more.join("\n");
445
- return clip(wordsOf(op), 1e4 - tail.length) + tail;
446
- }
447
437
  /** The task's words: what was typed, or where nothing was, a line that sends the reader to what's attached. */
448
438
  const wordsOf = (op) => op.text.trim() === "" ? shown(op) ?? "" : op.text.trim();
449
439
  /** `See the recording and the voice note`: what stands for the words of a task sent with none, where something is attached. */
@@ -454,9 +444,13 @@ function shown(op) {
454
444
  ...named(op.recordings?.length, "recording"),
455
445
  ...named(op.voice?.length, "voice note")
456
446
  ];
457
- return attached.length === 0 ? void 0 : `See ${new Intl.ListFormat("en", { type: "conjunction" }).format(attached)}`;
447
+ return attached.length === 0 ? void 0 : `See ${conjunction(attached)}`;
448
+ }
449
+ /** `a screenshot and 2 voice notes`, of `deictic.dropped.N`'s values. */
450
+ function listOf(kinds) {
451
+ return conjunction([...Map.groupBy(kinds, (kind) => kind)].map(([kind, all]) => all.length === 1 ? `a ${kind}` : `${all.length} ${kind}s`));
458
452
  }
459
- const fence = (text, lang) => `\`\`\`\`${lang}\n${clip(text, 1500)}\n\`\`\`\``;
453
+ const conjunction = (things) => new Intl.ListFormat("en", { type: "conjunction" }).format(things);
460
454
  const clip = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1)}…`;
461
455
  /** The board's answer, or a `Refusal` saying what to do when there's no board to ask or it said no. */
462
456
  async function asked(ask) {