deictic 0.5.0 → 0.7.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.
- package/API.md +150 -37
- package/README.md +4 -3
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.d.ts.map +1 -1
- package/dist/annotations/client.js +161 -176
- package/dist/annotations/client.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -11
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1007 -192
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/recommended/index.d.ts +2 -2
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +82 -153
- package/dist/recordings/client.js.map +1 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/shared/annotations.js +3 -4
- package/dist/shared/annotations.js.map +1 -1
- package/dist/shared/board.js +1 -1
- package/dist/shared/client.js +45 -2
- package/dist/shared/client.js.map +1 -1
- package/dist/shared/component.js +62 -0
- package/dist/shared/component.js.map +1 -0
- package/dist/shared/dom.js +79 -0
- package/dist/shared/dom.js.map +1 -0
- package/dist/shared/drawer.js +217 -0
- package/dist/shared/drawer.js.map +1 -0
- package/dist/shared/endpoints.js +34 -8
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +2 -1
- package/dist/shared/find.js.map +1 -1
- package/dist/shared/index.d.ts +124 -11
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +9 -19
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +105 -26
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +1 -1
- package/dist/shared/init.js +12 -10
- package/dist/shared/init.js.map +1 -1
- package/dist/shared/integration.d.ts +1 -1
- package/dist/shared/packages.js +1 -1
- package/dist/shared/recording.js +31 -3
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +72 -21
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +330 -166
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/vb.js +1 -1
- package/dist/shared/voice2.js +6 -4
- package/dist/shared/voice2.js.map +1 -1
- package/dist/shared/watch.js +14 -14
- package/dist/shared/watch.js.map +1 -1
- package/dist/tailwind/index.js +6 -2
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tasks/client.d.ts +2 -2
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +1829 -742
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +154 -57
- package/dist/voice/client.js.map +1 -1
- package/package.json +1 -1
- package/skills/deictic/SKILL.md +22 -28
- package/src/cli/find.ts +3 -1
- package/src/cli/init.ts +13 -11
- package/src/cli/recording.ts +34 -3
- package/src/cli/task.ts +94 -23
- package/src/cli/voice.ts +9 -4
- package/src/cli/watch.ts +14 -13
- package/src/client/away.ts +3 -1
- package/src/client/component.ts +98 -0
- package/src/client/dom.ts +70 -0
- package/src/client/drawer.ts +258 -0
- package/src/client/index.ts +220 -128
- package/src/client/lightbox.ts +8 -8
- package/src/client/lighting.ts +279 -0
- package/src/client/style.ts +263 -44
- package/src/client/tools.ts +279 -0
- package/src/client/tooltip.ts +25 -5
- package/src/client/tray.ts +48 -0
- package/src/index.ts +121 -10
- package/src/plugins/annotations/client.ts +103 -129
- package/src/plugins/annotations/draw.ts +68 -72
- package/src/plugins/annotations/index.ts +12 -19
- package/src/plugins/recordings/client.ts +89 -167
- package/src/plugins/screenshots/client.ts +53 -2
- package/src/plugins/tailwind/index.ts +6 -2
- package/src/plugins/tasks/client.ts +219 -749
- package/src/plugins/tasks/composer.ts +797 -0
- package/src/plugins/tasks/drawer.ts +516 -0
- package/src/plugins/tasks/index.ts +459 -192
- package/src/plugins/tasks/pins.ts +275 -0
- package/src/plugins/tasks/store.ts +132 -0
- package/src/plugins/voice/client.ts +96 -5
- package/src/tools/endpoints.ts +18 -7
- package/src/tools/source.ts +25 -5
- package/skills/deictic/references/recordings.md +0 -13
- package/skills/deictic/references/tasks.md +0 -21
- package/skills/deictic/references/watch.md +0 -17
package/dist/shared/tasks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","names":[],"sources":["../../src/plugins/tasks/index.ts"],"sourcesContent":["/**\n * `deictic/tasks`: open its tab on an element to add a task about it to a Vercel Board\n * (`@vercel/board`). The task says what to change, in the words typed, and where: the element's file,\n * line and tag, the page and the project, all as labels beside the short facts (viewport, how many, where\n * it is in the shot), and after the words what a label can't hold: the chain of source it rendered through, from\n * its own line out to the files that use its component. Its HTML as it rendered is a file attached, `element.html`, for whoever\n * 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\n * from there; deictic only adds them.\n *\n * Adding one is a change like any other: undo cancels the task, while no one has claimed it, and redo\n * adds it again, as a new task. Each task carries `deictic.at=<file:line:column>` and `deictic.file`, so\n * the panel lists the ones about the element clicked, and after them the rest of its file's. One whose\n * place is no longer the element's is still its own where the tag and the line it saw (`deictic.line`) are\n * the element's, and that line is in the file once: the element has moved, as lines above it changed.\n */\nimport { readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport type { Board } from '@vercel/board';\n\nimport { definePlugin, Refusal, type ServerContext, type Shortcut, type Source, type Target } from '#src/index.ts';\n// For `use('screenshots')`'s type: the plugin may not be loaded, and nothing of it runs here.\nimport type { Recordings } from '#src/plugins/recordings/index.ts';\nimport type { Box } from '#src/plugins/screenshots/index.ts';\nimport type { Clips } from '#src/plugins/voice/index.ts';\n\nimport { type LocalBoard, localBoard } from './local.ts';\nimport { watchersOf } from './watchers.ts';\n\nexport { local, type LocalBoard, type LocalOptions } from './local.ts';\n\n/** What the plugin uses of a board: `board()` from `@vercel/board` is one. */\nexport type TaskBoard = Pick<Board, 'tasks' | 'thread' | 'discovery' | 'upload' | 'edit' | 'actors'>;\n\nexport interface TasksOptions {\n /**\n * The board, as `@vercel/board`'s `board()` answers it. By default the one `BOARD_URL` names, and with none,\n * one of the project's own on this machine: `vb serve`, started with the dev server and stopped with it, at\n * `http://127.0.0.1:4100/api/board` (or the port `.deictic/board.json` says, where that one's taken), its log\n * in `.deictic/board`. For your team's board, through `vercel login`, pass `board()`. `local()`, from here, is\n * that board of the project's own whatever `BOARD_URL` says, with its port, its folder and the rest as options.\n */\n board?: TaskBoard | LocalBoard;\n /** The channel tasks go to: `deictic` by default. */\n channel?: string;\n /**\n * The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several\n * projects share: by default the `name` in the root's `package.json`, and no label where it has none.\n */\n project?: string;\n /** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */\n labels?: Record<string, string>;\n /**\n * Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links\n * that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine\n * (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages\n * deictic can't know.\n */\n link?: (channel: string, task?: string) => string | undefined;\n /**\n * Whether a task has the element's HTML as it rendered attached, as `element.html`, masked as a screenshot is\n * (the screenshots plugin's masking, where it's loaded): what was on the page, for whoever can't open it as the\n * person did. True by default: the Task tab has a box for it, ticked, to untick for a task that should go\n * without. `false` takes the box away, where a page shows what the board shouldn't hold.\n */\n html?: boolean;\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n}\n\nexport interface Task {\n id: string;\n /** The first line of what was typed. */\n title: string;\n /** What was typed, whole: what an edit changes. */\n text: string;\n state: string;\n /** Who holds its claim, by name (`claude`), while it's claimed. A board keeps no one for a task's end. */\n by?: string;\n /** Whether it can still be edited or deleted: no one has claimed it. */\n open: boolean;\n /** Its page on the board, when there's one to link to. */\n link?: string;\n /**\n * Where it was added, where that isn't the element's place: for one of `tasks`, where the element was before\n * it moved; for one of `elsewhere`, the element it's about.\n */\n at?: Place;\n}\n\n/** A place in the element's file: a line and a column, from 1, and the tag there as the task saw it. */\nexport interface Place {\n line: number;\n column: number;\n tag: string;\n}\n\nexport interface Model {\n channel: string;\n /** The channel's page, when there's one to link to. */\n link?: string;\n /** Tasks about this element, oldest first, canceled ones left out: also those added before it moved. */\n tasks: Task[];\n /** Tasks about the file's other elements, by line, canceled ones left out: each with its `at`. */\n elsewhere: Task[];\n /**\n * Who watches the channel, by name (`claude`): the agents whose watch (`deictic watch`) is running in\n * this project, as a board can't say, and those holding a claim on one of the channel's tasks, which it can.\n * Empty where none is and the board is this machine's own;\n * left out where none is and the board is another, which an agent may watch from elsewhere.\n */\n watching?: string[];\n}\n\n/**\n * What the Task tab asks for: a new task (an `Op`), other words for one it lists (`edit` is its ID), or\n * that one deleted (`remove` is its ID), which cancels it on the board.\n */\nexport type Change = Op | { edit: string; text: string } | { remove: string };\n\n/** A new task: what the page knows and the source doesn't. */\nexport interface Op {\n text: string;\n /** The page's URL. */\n page: string;\n viewport: { width: number; height: number };\n /**\n * What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a\n * shadow root's): its path from the element, and its HTML, cut short.\n */\n pointed?: { path: string; html: string };\n /** How many elements on the page come from the same place in the source. */\n count: number;\n /**\n * The source it rendered through, after its own place, nearest first: where the one before it is used. With\n * React in development, the components that wrote it, `Field (src/Field.tsx:20)` or a name alone; without, the\n * files around it, each a `file:line`. A shared component's line says nothing of which use of it this is, and\n * these do.\n */\n chain?: string[];\n /** The element's HTML as it rendered, to attach: cut short, and masked where the screenshots plugin is loaded. */\n html?: string;\n /**\n * Shots the screenshots plugin took of it, to attach, where that plugin is loaded: each with where the\n * element is in it, whether it's `outlined` there (dashes drawn around it, in the PNG), and the marks drawn\n * on it in the panel, where there are any.\n */\n screenshots?: { id: string; box: Box; outlined?: boolean; marks?: Marks }[];\n /**\n * Recordings the recordings plugin made, to attach, where that plugin is loaded: how long each ran,\n * where it plays back, and the voice plugin's clips of the mic in it, attached too.\n */\n recordings?: { id: string; duration: number; replay: string; voice?: string[] }[];\n /** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */\n voice?: { id: string; duration: number }[];\n /** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */\n annotations?: Marks;\n}\n\n/**\n * A task the Task tab just added, as the page hears of it: the `detail` of a `deictic:task` event on `window`, for a\n * page that shows its own tasks (deictic's playground lists them as a board does).\n */\nexport interface TaskAdded {\n id: string;\n /** The first line of what was typed. */\n title: string;\n state: string;\n channel: string;\n /** The element: its file, line and column, and its tag. */\n target: Target;\n /** The page's URL. */\n page: string;\n /** How many of each were attached; `marks` counts those drawn on shots and on the page. */\n attached: { screenshots: number; recordings: number; voice: number; marks: number };\n}\n\n/** Marks, as a task tells of them: how many, and what the notes among them say. */\nexport interface Marks {\n count: number;\n notes: string[];\n}\n\nexport interface Added {\n channel: string;\n id: string;\n text: string;\n labels: Record<string, string>;\n /** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */\n attachments?: string[];\n}\n\n/** A task's words changed: its message's whole text before and after. */\nexport interface Edited {\n kind: 'edited';\n id: string;\n before: string;\n after: string;\n}\n\n/**\n * A task deleted in the panel: canceled on the board, for good, as a board has it. So it's kept whole, and\n * an undo adds it again, as a new task whose ID the record then has.\n */\nexport interface Removed extends Added {\n kind: 'removed';\n}\n\n/** What the history keeps of a change: a task added has no `kind`, as it had none before there were others. */\nexport type Kept = Added | Edited | Removed;\n\nconst AT = 'deictic.at';\nconst FILE = 'deictic.file';\n/** What parts what was typed from the rest of a task's text. */\nconst REST = '\\n---\\n';\nconst OPEN = new Set(['waiting', 'ready', 'blocked']);\n\nexport function tasks(options: TasksOptions = {}) {\n const channel = options.channel ?? 'deictic';\n let team: Promise<TaskBoard> | undefined;\n let root: string | undefined;\n const own = options.board !== undefined && 'local' in options.board ? options.board.local : undefined;\n const found = async (): Promise<TaskBoard> => {\n if (options.board !== undefined && !('local' in options.board)) return options.board;\n // Loaded when first used, so a project that doesn't add this plugin needn't install the SDK.\n const { board } = await import('@vercel/board');\n if (own === undefined && process.env.BOARD_URL !== undefined) return board();\n\n const base = root ?? process.cwd();\n const { url, fresh, dir } = await localBoard(base, own);\n if (fresh) {\n const kept = relative(base, dir).replaceAll('\\\\', '/');\n console.log(`deictic/tasks: tasks go to a board on this machine, ${url.replace(/\\/api\\/board$/, '/')} (kept in ${kept})`);\n }\n // `board()` takes a URL from the environment only, as it's called: so it's set for the call, and what the\n // environment said is left as it was.\n const before = process.env.BOARD_URL;\n process.env.BOARD_URL = url;\n try {\n return board();\n } finally {\n if (before === undefined) delete process.env.BOARD_URL;\n else process.env.BOARD_URL = before;\n }\n };\n // Asked again after a failure: a board that didn't start may the next time.\n const boardOf = () =>\n (team ??= found().catch((e: unknown) => {\n team = undefined;\n throw e;\n }));\n let link: Promise<string | undefined> | undefined;\n // Asked once, unless asking failed: no link is no reason to keep the panel from showing the tasks.\n const linkOf = () =>\n (link ??= (\n options.link\n ? Promise.resolve(options.link(channel))\n : boardOf().then((b) => (own?.inspect === false ? undefined : localPage(b, channel)))\n ).catch(() => {\n link = undefined;\n return undefined;\n }));\n /** A task's page: what `link` says, or its thread on the channel's own page on this machine. */\n const taskLink = (page: string | undefined, id: string) =>\n options.link ? options.link(channel, id) : page === undefined ? undefined : `${page}?thread=${encodeURIComponent(id)}`;\n /**\n * One of this channel's tasks about an element, while it's still open: the page names it by ID, so\n * nothing else on the board is its to change, nor a task someone has taken up.\n */\n const openTask = async (team: TaskBoard, id: string, verb: string) => {\n const { message } = await team.thread(id);\n if (message.channel !== channel || message.labels[AT] === undefined)\n throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);\n\n const { task } = message;\n if (task !== undefined && !OPEN.has(task.state)) {\n throw new Refusal(\n `task ${id} is ${task.state}${task.claim ? ` by ${task.claim.actor}` : ''} now: ${verb} it on the board if you still mean to`,\n );\n }\n return message;\n };\n /** Cancels an open task of ours, and answers it as it was. */\n const cancel = async (id: string, reason: string) => {\n const team = await boardOf();\n const message = await openTask(team, id, 'cancel');\n await team.tasks.cancel(id, reason);\n return message;\n };\n /** Puts a task's text from one to the other, unless it reads as neither any more. */\n const rewrite = async (id: string, from: string, to: string) => {\n const team = await boardOf();\n const message = await openTask(team, id, 'edit');\n if (message.text === to) return;\n if (message.text !== from) throw new Refusal(`task ${id} has been edited since: change it on the board`);\n await team.edit(id, to, { revision: message.revision });\n };\n const create = async (record: Omit<Added, 'id'>): Promise<Added> => {\n const { task } = await (\n await boardOf()\n ).tasks.create(record.channel, {\n text: record.text,\n labels: record.labels,\n ...(record.attachments === undefined ? {} : { attachments: record.attachments }),\n });\n return { ...record, id: task.id };\n };\n\n // Kept from `setup`, to `use` another plugin when an op asks for it.\n let context: ServerContext | undefined;\n let project = options.project;\n /** The screenshots, recordings and the element's HTML to attach, uploaded to the board, or nothing when there are none. */\n const attach = async (op: Op): Promise<string[] | undefined> => {\n // All read first, so one no longer kept uploads none.\n const files = [\n ...(op.screenshots ?? []).map(({ id }) => {\n const shot = context?.use('screenshots')?.read(id);\n if (shot === undefined) throw new Refusal(`screenshot ${id} isn't kept any more: take it again`);\n return shot;\n }),\n ...(op.recordings ?? []).map(({ id }) => {\n const recording: ReturnType<Recordings['read']> = context?.use('recordings')?.read(id);\n if (recording === undefined) throw new Refusal(`recording ${id} isn't kept any more: record it again`);\n return recording;\n }),\n ...[...(op.recordings ?? []).flatMap((r) => r.voice ?? []), ...(op.voice ?? []).map((v) => v.id)].map((id) => {\n const clip: ReturnType<Clips['read']> = context?.use('voice')?.read(id);\n if (clip === undefined) throw new Refusal(`voice clip ${id} isn't kept any more: record it again`);\n return clip;\n }),\n // Last, and a file, not the task's words: it's there to look into, and most tasks are done without it.\n ...(typeof op.html !== 'string' || op.html === ''\n ? []\n : [{ data: new TextEncoder().encode(op.html.slice(0, HTML)), name: 'element.html', type: 'text/html' }]),\n ];\n if (files.length === 0) return undefined;\n const team = await boardOf();\n return Promise.all(files.map(async (file) => (await team.upload(file)).id));\n };\n\n return definePlugin<Model, Change, Kept>({\n name: 'tasks',\n client: 'deictic/tasks/client',\n packages: ['@vercel/board'],\n // Only where it's turned off: the page half sends the HTML unless told not to.\n ...(options.html === false ? { clientOptions: { html: false } } : {}),\n shortcut: options.shortcut,\n setup: (given) => {\n context = given;\n root = given.root;\n project ??= nameOf(given.root);\n // Started with the dev server, not at the first task, so whoever works the tasks can watch from the start.\n // Not waited for: a failure is the first request's to tell.\n void boardOf().catch(() => {});\n },\n read: (source, target) =>\n asked(async () => {\n const team = await boardOf();\n const labelled = (label: Record<string, string>) => team.tasks.list({ channel, label, state: 'all' });\n // By place too: a task added before there was a `deictic.file` has none, and is still its element's.\n const [here, inFile, page, held] = await Promise.all([\n labelled({ [AT]: atOf(target) }),\n labelled({ [FILE]: clip(target.loc.file, LABEL) }),\n linkOf(),\n team.tasks.list({ channel, state: 'claimed' }),\n ]);\n const listed = new Set(inFile.tasks.map(({ message }) => message.id));\n const line = lineOf(source);\n // A line the file has twice says nothing of which element a task was about.\n const once = source.code.split(line).length === 2;\n const tasks: Task[] = [];\n const elsewhere: (Task & { at: Place })[] = [];\n const about = [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks];\n // Who has each, and who holds any claim on the channel: asked of the board at once.\n const actorOf = ({ task }: (typeof about)[number]['message']) => task?.claim?.actor;\n const claims = held.tasks.flatMap(({ message }) => message.task?.claim ?? []);\n const actors = await actorsOf(team, [...about.flatMap(({ message }) => actorOf(message) ?? []), ...claims.map((c) => c.actor)]);\n for (const { message } of about) {\n const state = message.task?.state ?? 'ready';\n if (state === 'canceled') continue;\n const by = actors.get(actorOf(message) ?? '')?.name;\n const text = message.text.split(REST, 1)[0]!;\n const to = taskLink(page, message.id);\n const task = {\n id: message.id,\n title: text.split('\\n', 1)[0]!,\n text,\n state,\n ...(by === undefined ? {} : { by }),\n open: OPEN.has(state),\n ...(to === undefined ? {} : { link: to }),\n };\n const at = placeIn(message.labels);\n if (at === undefined || message.labels[AT] === atOf(target)) tasks.push(task);\n else if (once && at.tag === target.tag && message.labels['deictic.line'] === clip(line, LABEL)) tasks.push({ ...task, at });\n else elsewhere.push({ ...task, at });\n }\n // An agent at work on a task is here too, though its watch may be over until the task is (`deictic watch --once`).\n const working = agentsOf(actors, claims);\n const watching = [...new Set([...watchersOf(root ?? process.cwd(), channel), ...working])].sort();\n // A board of this machine's own is watched from here or not at all.\n const ours = own !== undefined || (options.board === undefined && process.env.BOARD_URL === undefined);\n return {\n channel,\n ...(page === undefined ? {} : { link: page }),\n ...(watching.length > 0 || ours ? { watching } : {}),\n tasks,\n // The board's order (oldest first) among those of one place.\n elsewhere: elsewhere.sort((a, b) => (a.at.line === b.at.line ? a.at.column - b.at.column : a.at.line - b.at.line)),\n };\n }),\n apply: (source, target, op) => {\n if ('remove' in op) {\n return asked(async () => {\n const message = await cancel(op.remove, 'deleted in deictic');\n // The board's own labels (`board.task`) are its to set on the task an undo adds.\n const labels = Object.fromEntries(Object.entries(message.labels).filter(([key]) => !key.startsWith('board.')));\n const attachments = message.attachments.map((a) => a.id);\n const kept = { channel, id: op.remove, text: message.text, labels, ...(attachments.length === 0 ? {} : { attachments }) };\n return { done: { kind: 'removed' as const, ...kept } };\n });\n }\n // A new task may go without words where something attached says it; a task's words are never changed to none.\n if (op.text.trim() === '' && ('edit' in op || shown(op) === undefined)) throw new Refusal('say what should change first');\n if ('edit' in op) {\n return asked(async () => {\n const before = (await openTask(await boardOf(), op.edit, 'edit')).text;\n // What follows the words (what's attached, what was pointed at) stays as it was.\n const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : '';\n const after = clip(op.text.trim(), 10_000 - rest.length) + rest;\n await rewrite(op.edit, before, after);\n return { done: { kind: 'edited' as const, id: op.edit, before, after } };\n });\n }\n const labels = {\n ...options.labels,\n ...(project === undefined ? {} : { 'deictic.project': clip(project, LABEL) }),\n ...labelsOf(source, target, op),\n };\n return asked(async () => {\n const attachments = await attach(op);\n return {\n done: await create({ channel, text: textOf(op, target), labels, ...(attachments === undefined ? {} : { attachments }) }),\n };\n });\n },\n undo: (record) =>\n asked(async () => {\n if (!('kind' in record)) {\n await cancel(record.id, 'undone in deictic');\n return undefined;\n }\n if (record.kind === 'edited') {\n await rewrite(record.id, record.after, record.before);\n return undefined;\n }\n const { kind, id: _, ...task } = record;\n return { kind, ...(await create(task)) };\n }),\n redo: (record) =>\n asked(async () => {\n if (!('kind' in record)) {\n const { id: _, ...added } = record;\n return create(added);\n }\n if (record.kind === 'edited') {\n await rewrite(record.id, record.before, record.after);\n return record;\n }\n await cancel(record.id, 'deleted in deictic');\n return record;\n }),\n describe: (op, before) => {\n const named = (id: string) => `task \"${clip(before.tasks.find((t) => t.id === id)?.title ?? `#${id}`, 60)}\"`;\n if ('remove' in op) return `delete ${named(op.remove)}`;\n if ('edit' in op) return `edit ${named(op.edit)}`;\n return `task \"${clip(wordsOf(op).split('\\n', 1)[0]!, 60)}\"`;\n },\n });\n}\n\n/**\n * The channel's page on a board `vb serve` runs on this machine, which serves its pages beside its API:\n * `/api/board` there, `/c/<channel>` beside it. Nothing for any other board.\n */\nasync function localPage(team: TaskBoard, channel: string): Promise<string | undefined> {\n const url = new URL((await team.discovery()).url);\n if (!['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname) || !url.pathname.endsWith('/api/board')) return undefined;\n return `${url.origin}${url.pathname.slice(0, -'/api/board'.length)}/c/${channel.split('/').map(encodeURIComponent).join('/')}`;\n}\n\nconst plural = (count: number, word: string) => `${count} ${word}${count === 1 ? '' : 's'}`;\nconst said = (notes: string[]) => (notes.length === 0 ? '' : `; the notes say: ${notes.map((n) => JSON.stringify(n)).join(', ')}`);\n\n/** What was marked on the page: how many marks, and what the notes say. */\nfunction annotated({ count, notes }: Marks, shots: number, recordings: number): string {\n const where = [\n ...(shots === 0 ? [] : [shots === 1 ? 'the screenshot' : 'the screenshots']),\n ...(recordings === 0 ? [] : [recordings === 1 ? 'the recording' : 'the recordings']),\n ];\n const drawn = where.length === 0 ? '' : `, drawn in ${where.join(' and ')}`;\n return `${plural(count, 'mark')} on the page${drawn}${said(notes)}`;\n}\n\n/** How long each recording ran, and where it plays back, while the dev server keeps it. */\nfunction recordingsOf(recordings: NonNullable<Op['recordings']>): string[] {\n return recordings.map(({ duration, replay, voice }, i) => {\n const name = recordings.length === 1 ? 'A recording' : `Recording ${i + 1}`;\n const spoken = voice === undefined || voice.length === 0 ? '' : `, with the voice (${voice.map((id) => `voice-${id}`).join(', ')})`;\n return `${name}, ${clock(duration)} long, attached as rrweb events${spoken}; it replays at ${replay}`;\n });\n}\n\n/** How long each voice note runs, and the attachment it's in. */\nfunction voicesOf(voice: NonNullable<Op['voice']>): string[] {\n return voice.map(({ id, duration }, i) => {\n const name = voice.length === 1 ? 'A voice note' : `Voice note ${i + 1}`;\n return `${name}, ${clock(duration)} long, attached as voice-${id}`;\n });\n}\n\nconst clock = (ms: number) => {\n const s = Math.round(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;\n};\n\n/**\n * What's drawn on each shot (the element's outline, the person's marks), and with several, where the element is\n * in each. One shot's place is the `deictic.position` and `deictic.size` labels, so a shot with nothing drawn\n * on it has no line.\n */\nfunction shotsOf(shots: NonNullable<Op['screenshots']>): string[] {\n const [only] = shots;\n if (shots.length === 1 && only !== undefined) {\n const { marks, outlined } = only;\n const has = [\n ...(outlined === true ? ['the element outlined in dashes'] : []),\n ...(marks === undefined || marks.count === 0 ? [] : [`${plural(marks.count, 'mark')} drawn on it${said(marks.notes)}`]),\n ];\n return has.length === 0 ? [] : [`The screenshot has ${has.join(' and ')}`];\n }\n return shots.map(({ box, marks, outlined }, i) => {\n const drawn = marks === undefined || marks.count === 0 ? '' : `, with ${plural(marks.count, 'mark')} drawn on it${said(marks.notes)}`;\n const [x, y, width, height] = boxOf(box);\n return `In screenshot ${i + 1} at x ${x}, y ${y}, ${width}×${height}${outlined === true ? ', outlined in dashes' : ''}${drawn}`;\n });\n}\n\n/**\n * `Source: src/ui/label.tsx:6 ← Field (src/Field.tsx:20) ← Panel`: from the element's line out, as the page said\n * it: the components that use it, where the page knows them, or the files around it.\n */\nfunction chainOf({ loc }: Target, chain: NonNullable<Op['chain']>): string[] {\n const places = chain.slice(0, CHAIN).map((place) => clip(String(place), LABEL));\n return places.length === 0 ? [] : [`Source: ${[`${loc.file}:${loc.line}`, ...places].join(' ← ')}`];\n}\n\n/** How many places a chain names after the element's own: the first few say which use of a component it is. */\nconst CHAIN = 3;\n\n/** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */\nconst boxOf = ({ x, y, width, height }: Box) => [x, y, width, height].map(Math.round);\n\n/** What `element.html` holds of an element at most, in characters: a table's rows, not a whole page. */\nconst HTML = 100_000;\n\n/** A label's value: a board holds 256 characters. */\nconst LABEL = 256;\n\n/** The project's name: the `name` in the root's `package.json`, or nothing where it has none. */\nfunction nameOf(root: string): string | undefined {\n try {\n const { name } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as { name?: unknown };\n return typeof name === 'string' && name !== '' ? name : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The facts about the element, as labels: short values a script reads without parsing the text, and a watch\n * filters by. `deictic.line` is the opening tag's first line as the task saw it, to tell later that it moved.\n * `deictic.url` is the page's whole URL, where a label holds it: `textOf` says a longer one.\n */\nfunction labelsOf({ code, element }: Source, target: Target, op: Op): Record<string, string> {\n const [shot] = op.screenshots ?? [];\n return {\n [AT]: atOf(target),\n [FILE]: clip(target.loc.file, LABEL),\n 'deictic.tag': target.tag,\n 'deictic.line': clip(lineOf({ code, element }), LABEL),\n 'deictic.page': clip(new URL(op.page).pathname, LABEL),\n ...(op.page.length <= LABEL ? { 'deictic.url': op.page } : {}),\n 'deictic.viewport': `${op.viewport.width}x${op.viewport.height}`,\n 'deictic.count': String(op.count),\n ...(op.screenshots?.length === 1 && shot !== undefined ? placeOf(shot.box) : {}),\n };\n}\n\n/** Where the element is in the one shot, from its top left, and how big: `87,387` and `138x32`, as the viewport is written. */\nfunction placeOf(box: Box): Record<string, string> {\n const [x, y, width, height] = boxOf(box);\n return { 'deictic.position': `${x},${y}`, 'deictic.size': `${width}x${height}` };\n}\n\n/**\n * The actors these IDs name, by ID. An actor's ID isn't read for its name (each board writes them its own way), so\n * the board is asked who they are, and only when there's one to ask about.\n */\nasync function actorsOf(team: TaskBoard, ids: string[]): Promise<Map<string, Awaited<ReturnType<TaskBoard['actors']>>[number]>> {\n const asked = [...new Set(ids)];\n if (asked.length === 0) return new Map();\n // By ID, which a board from 0.54 answers without listing everyone; an older one lists them all, and the rest go unread.\n return new Map((await team.actors({ id: asked })).map((actor) => [actor.id, actor]));\n}\n\n/**\n * The agents holding these claims, by name, while their leases run. A person holding one is left out: they needn't\n * be told they're there. (Whatever else holds one works tasks: an agent, a workflow.)\n */\nfunction agentsOf(actors: Awaited<ReturnType<typeof actorsOf>>, claims: { actor: string; until: string }[]): string[] {\n return claims\n .filter((claim) => Date.parse(claim.until) > Date.now())\n .flatMap((claim) => actors.get(claim.actor) ?? [])\n .filter((actor) => actor.kind !== 'person')\n .map((actor) => actor.name);\n}\n\nconst atOf = ({ loc }: Target) => `${loc.file}:${loc.line}:${loc.column}`;\n\n/** The opening tag's first line, as written. */\nconst lineOf = ({ code, element }: Pick<Source, 'code' | 'element'>) => code.slice(element.start, element.end).split('\\n', 1)[0]!.trim();\n\n/** Where a task says its element is, from its labels. */\nfunction placeIn(labels: Record<string, string>): Place | undefined {\n const [, line, column] = /:(\\d+):(\\d+)$/.exec(labels[AT] ?? '') ?? [];\n if (line === undefined || column === undefined) return undefined;\n return { line: Number(line), column: Number(column), tag: labels['deictic.tag'] ?? '' };\n}\n\n/**\n * The task's text: what was typed, and after a `---` only what no label holds: what's attached and drawn, the\n * source it rendered through, what was pointed at inside it, and a URL too long for a label.\n * A board holds 10,000 characters.\n */\nfunction textOf(op: Op, target: Target): string {\n const more = [\n ...(op.page.length <= LABEL ? [] : [op.page]),\n ...shotsOf(op.screenshots ?? []),\n ...recordingsOf(op.recordings ?? []),\n ...voicesOf(op.voice ?? []),\n ...(op.annotations === undefined ? [] : [annotated(op.annotations, op.screenshots?.length ?? 0, op.recordings?.length ?? 0)]),\n ...chainOf(target, op.chain ?? []),\n ...(op.pointed === undefined ? [] : [`Pointed at, inside it: \\`${op.pointed.path}\\``, fence(op.pointed.html, 'html')]),\n ];\n const tail = more.length === 0 ? '' : REST + more.join('\\n');\n return clip(wordsOf(op), 10_000 - tail.length) + tail;\n}\n\n/** The task's words: what was typed, or where nothing was, a line that sends the reader to what's attached. */\nconst wordsOf = (op: Op) => (op.text.trim() === '' ? (shown(op) ?? '') : op.text.trim());\n\n/** `See the recording and the voice note`: what stands for the words of a task sent with none, where something is attached. */\nfunction shown(op: Op): string | undefined {\n const named = (count: number | undefined, word: string) =>\n count === undefined || count === 0 ? [] : [`the ${word}${count === 1 ? '' : 's'}`];\n const attached = [\n ...named(op.screenshots?.length, 'screenshot'),\n ...named(op.recordings?.length, 'recording'),\n ...named(op.voice?.length, 'voice note'),\n ];\n return attached.length === 0 ? undefined : `See ${new Intl.ListFormat('en', { type: 'conjunction' }).format(attached)}`;\n}\n\nconst fence = (text: string, lang: string) => `\\`\\`\\`\\`${lang}\\n${clip(text, 1500)}\\n\\`\\`\\`\\``;\n\nconst clip = (text: string, max: number) => (text.length <= max ? text : `${text.slice(0, max - 1)}…`);\n\n/** The board's answer, or a `Refusal` saying what to do when there's no board to ask or it said no. */\nasync function asked<T>(ask: () => Promise<T>): Promise<T> {\n try {\n return await ask();\n } catch (e) {\n if (e instanceof Refusal) throw e;\n const { code, message, hint } = e as { code?: unknown; message?: string; hint?: string };\n if (typeof code === 'string') throw new Refusal(`the board says: ${message}${hint === undefined ? '' : ` (${hint})`}`, { cause: e });\n throw new Refusal(\n `can't reach the board (${message ?? String(e)}): restart the dev server, which starts its own, or check the BOARD_URL or \\`board\\` it was given`,\n { cause: e },\n );\n }\n}\n\nex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AS,OAA2B,SACxC,UAAU,KAAA,KAAa,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,OAAO,UAAU,IAAI,KAAK,KAAK;CACnF,MAAM,WAAW;EACf,GAAG,MAAM,GAAG,aAAa,QAAQ,YAAY;EAC7C,GAAG,MAAM,GAAG,YAAY,QAAQ,WAAW;EAC3C,GAAG,MAAM,GAAG,OAAO,QAAQ,YAAY;CACzC;CACA,OAAO,SAAS,WAAW,IAAI,KAAA,IAAY,OAAO,IAAI,KAAK,WAAW,MAAM,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,OAAO,QAAQ;AACtH;AAEA,MAAM,SAAS,MAAc,SAAiB,WAAW,KAAK,IAAI,KAAK,MAAM,IAAI,EAAE;AAEnF,MAAM,QAAQ,MAAc,QAAiB,KAAK,UAAU,MAAM,OAAO,GAAG,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE;;AAGnG,eAAe,MAAS,KAAmC;CACzD,IAAI;EACF,OAAO,MAAM,IAAI;CACnB,SAAS,GAAG;EACV,IAAI,aAAa,SAAS,MAAM;EAChC,MAAM,EAAE,MAAM,SAAS,SAAS;EAChC,IAAI,OAAO,SAAS,UAAU,MAAM,IAAI,QAAQ,mBAAmB,UAAU,SAAS,KAAA,IAAY,KAAK,KAAK,KAAK,MAAM,EAAE,OAAO,EAAE,CAAC;EACnI,MAAM,IAAI,QACR,0BAA0B,WAAW,OAAO,CAAC,EAAE,oGAC/C,EAAE,OAAO,EAAE,CACb;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"tasks.js","names":[],"sources":["../../src/plugins/tasks/index.ts"],"sourcesContent":["/**\n * `deictic/tasks`: open its tab on an element to add a task about it to a Vercel Board\n * (`@vercel/board`). The task says what to change, in the words typed, and where: the element's file,\n * line and tag, the page and the project, all as labels beside the short facts (viewport, how many, where\n * 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\n * 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\n * from there; deictic only adds them.\n *\n * Adding one is a change like any other: undo cancels the task, while no one has claimed it, and redo\n * adds it again, as a new task. Each task carries `deictic.at=<file:line:column>` and `deictic.file`, so\n * the panel lists the ones about the element clicked, and after them the rest of its file's. One whose\n * place is no longer the element's is still its own where the tag and the line it saw (`deictic.line`) are\n * the element's, and that line is in the file once: the element has moved, as lines above it changed.\n */\nimport { readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport type { Board } from '@vercel/board';\n\nimport { definePlugin, type Point, Refusal, type ServerContext, type Shortcut, type Source, type Target } from '#src/index.ts';\n// For `use('screenshots')`'s type: the plugin may not be loaded, and nothing of it runs here.\nimport type { Recordings } from '#src/plugins/recordings/index.ts';\nimport type { Box } from '#src/plugins/screenshots/index.ts';\nimport type { Clips } from '#src/plugins/voice/index.ts';\n\nimport { type LocalBoard, localBoard } from './local.ts';\nimport { watchersOf } from './watchers.ts';\n\nexport { local, type LocalBoard, type LocalOptions } from './local.ts';\n\n/** What the plugin uses of a board: `board()` from `@vercel/board` is one. */\nexport type TaskBoard = Pick<Board, 'tasks' | 'thread' | 'threads' | 'reply' | 'discovery' | 'upload' | 'download' | 'edit' | 'actors'>;\n\nexport interface TasksOptions {\n /**\n * The board, as `@vercel/board`'s `board()` answers it. By default the one `BOARD_URL` names, and with none,\n * one of the project's own on this machine: `vb serve`, started with the dev server and stopped with it, at\n * `http://127.0.0.1:4100/api/board` (or the port `.deictic/board.json` says, where that one's taken), its log\n * in `.deictic/board`. For your team's board, through `vercel login`, pass `board()`. `local()`, from here, is\n * that board of the project's own whatever `BOARD_URL` says, with its port, its folder and the rest as options.\n */\n board?: TaskBoard | LocalBoard;\n /** The channel tasks go to: `deictic` by default. */\n channel?: string;\n /**\n * The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several\n * projects share: by default the `name` in the root's `package.json`, and no label where it has none.\n */\n project?: string;\n /** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */\n labels?: Record<string, string>;\n /**\n * Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links\n * that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine\n * (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages\n * deictic can't know.\n */\n link?: (channel: string, task?: string) => string | undefined;\n /**\n * Whether a task has the element's HTML as it rendered attached, as `element.html`, masked as a screenshot is\n * (the screenshots plugin's masking, where it's loaded): what was on the page, for whoever can't open it as the\n * person did. True by default: the Task tab has a box for it, ticked, to untick for a task that should go\n * without. `false` takes the box away, where a page shows what the board shouldn't hold.\n */\n html?: boolean;\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n}\n\nexport interface Task {\n id: string;\n /** The first line of what was typed. */\n title: string;\n /** What was typed, whole: what an edit changes. */\n text: string;\n state: string;\n /** Who holds its claim, by name (`claude`), while it's claimed. A board keeps no one for a task's end. */\n by?: string;\n /** Whether it can still be edited or deleted: no one has claimed it. */\n open: boolean;\n /** Its page on the board, when there's one to link to. */\n link?: string;\n /** What was attached to it but not kept by the time it was sent, so it went without: `a screenshot`. */\n dropped?: string;\n /** The spot in the element it's about, where it's about one: CSS pixels from the element's top left. */\n point?: Point;\n /**\n * Where it was added, where that isn't the element's place: where the element was before it moved.\n */\n at?: Place;\n}\n\n/** A place in the element's file: a line and a column, from 1, and the tag there as the task saw it. */\nexport interface Place {\n line: number;\n column: number;\n tag: string;\n}\n\n/** A task as the drawer lists it: with its place, where it has one, and how its thread stands. */\nexport interface Listed extends Task {\n /** `file:line:column`, as the element's mark: none for a task about the page. */\n place?: string;\n /** The tag there, as the task saw it. */\n tag?: string;\n /** The page it was added on, as its path: `/pricing`. */\n page?: string;\n /** How many replies its thread has, and the newest's ID: what the page tells the unread by. */\n replies: number;\n last?: string;\n /** What the board says of where it stands: why it's blocked, what it came to, why it failed. */\n said?: string;\n}\n\n/** A task with a place, as its mark has it: what the page pins to the element there. */\nexport type Placed = Listed & { place: string };\n\n/** A file attached to a task or to a reply in its thread, as the board keeps it. */\nexport interface Attached {\n /** The board's ID for it. */\n id: string;\n name: string;\n /** Its MIME type: `image/png`, `audio/webm`, `application/json` for a recording, `text/html` for an element's HTML. */\n type: string;\n /** In bytes. */\n size: number;\n /**\n * Where the page gets it: by default the plugin's `file/<task>/<id>` route, which serves an image or a sound as it\n * is and anything else as text. A `standalone` server answers its own.\n */\n url?: string;\n /** Where a recording plays back, as the message says. */\n replay?: string;\n}\n\n/** A message in a task's thread, oldest first. */\nexport interface Reply {\n id: string;\n /** Who wrote it, by name. */\n by: string;\n /** `person`, or what else wrote it: an agent's `profile`, a deployment, a workflow. */\n kind: string;\n text: string;\n /** When, as an ISO date. */\n at: string;\n /** What it has attached. */\n files: Attached[];\n}\n\n/** A task with its thread, as the drawer opens it. */\nexport interface Thread {\n task: Listed;\n /** What the task has attached: its shots, recordings, voice notes and elements' HTML. */\n files: Attached[];\n replies: Reply[];\n}\n\n/**\n * A reply, as the drawer's composer sends it to the `reply/<id>` route: its words, and what's attached, as a task\n * attaches it. A reply with nothing typed says what's attached instead.\n */\nexport type Answer = Pick<Op, 'text' | 'screenshots' | 'recordings' | 'voice' | 'annotations'>;\n\nexport interface Model {\n channel: string;\n /** The channel's page, when there's one to link to. */\n link?: string;\n /** Tasks about this element, oldest first, canceled ones left out: also those added before it moved. */\n tasks: Task[];\n /**\n * Who watches the channel, by name (`claude`): the agents whose watch (`deictic watch`) is running in\n * this project, as a board can't say, and those holding a claim on one of the channel's tasks, which it can.\n * Empty where none is and the board is this machine's own;\n * left out where none is and the board is another, which an agent may watch from elsewhere.\n */\n watching?: string[];\n}\n\n/** A new task: what the page knows and the source doesn't. */\nexport interface Op {\n text: string;\n /** The page's URL. */\n page: string;\n viewport: { width: number; height: number };\n /**\n * The spot it's about, where it was added on one (the tool panel's task tool) and not on the element as a whole:\n * CSS pixels from the element's top left, and outside its box where the element is only the nearest to the spot.\n */\n point?: Point;\n /**\n * What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a\n * shadow root's): its path from the element, and its HTML, cut short.\n */\n pointed?: { path: string; html: string };\n /** How many elements on the page come from the same place in the source. */\n count: number;\n /**\n * The other elements it's about, after the one it's sent on, in the order they were attached: each one's place,\n * its tag, and its HTML as it rendered, where that's attached.\n */\n also?: { at: string; tag: string; html?: string }[];\n /**\n * No element is attached: it's about the page, and the element it's sent on is only where the popup was. It has\n * no place then, so no element's tab lists it and nothing pins it.\n */\n detached?: boolean;\n /**\n * The source it rendered through, after its own place, nearest first: where the one before it is used. With\n * React in development, the components that wrote it, `Field (src/Field.tsx:20)` or a name alone; without, the\n * files around it, each a `file:line`. A shared component's line says nothing of which use of it this is, and\n * these do.\n */\n chain?: string[];\n /** The element's HTML as it rendered, to attach: cut short, and masked where the screenshots plugin is loaded. */\n html?: string;\n /**\n * Shots the screenshots plugin took, to attach, where that plugin is loaded: each with where the element is in\n * it (`box`, for one taken of the element; one taken of the window from the tool panel has none), whether\n * it's `outlined` there (dashes drawn around it, or around the spot, in the PNG), and the marks drawn on it in\n * the Task tab, where there are any.\n */\n screenshots?: { id: string; box?: Box; outlined?: boolean; marks?: Marks }[];\n /**\n * Recordings the recordings plugin made, to attach, where that plugin is loaded: how long each ran,\n * where it plays back, and the voice plugin's clips of the mic in it, attached too.\n */\n recordings?: { id: string; duration: number; replay: string; voice?: string[] }[];\n /** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */\n voice?: { id: string; duration: number }[];\n /** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */\n annotations?: Marks;\n}\n\n/**\n * A task the Task tab just added, as the page hears of it: the `detail` of a `deictic:task` event on `window`, for a\n * page that shows its own tasks (deictic's playground lists them as a board does).\n */\nexport interface TaskAdded {\n id: string;\n /** The first line of what was typed. */\n title: string;\n state: string;\n channel: string;\n /** The element: its file, line and column, and its tag. */\n target: Target;\n /** The page's URL. */\n page: string;\n /** How many of each were attached; `marks` counts those drawn on shots and on the page. */\n attached: { screenshots: number; recordings: number; voice: number; marks: number };\n /**\n * Where each attached shot is, as it was sent (outlined, or as it was drawn on), for the page to show: the\n * screenshots plugin's `shot` route, or what a `standalone` server answered.\n */\n screenshots: string[];\n}\n\n/** Marks, as a task tells of them: how many, and what the notes among them say. */\nexport interface Marks {\n count: number;\n notes: string[];\n}\n\nexport interface Added {\n channel: string;\n id: string;\n text: string;\n labels: Record<string, string>;\n /** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */\n attachments?: string[];\n}\n\n/** A task's words changed in the tab, as an earlier version let it: its message's whole text before and after. */\nexport interface Edited {\n kind: 'edited';\n id: string;\n before: string;\n after: string;\n}\n\n/**\n * A task deleted in the tab, as an earlier version let it: canceled on the board, for good, as a board has it. So\n * it's kept whole, and an undo adds it again, as a new task whose ID the record then has.\n */\nexport interface Removed extends Added {\n kind: 'removed';\n}\n\n/**\n * What the history keeps of a change: a task added has no `kind`, as it had none before there were others. The others\n * are no longer made (a task is changed in the drawer, by the plugin's routes), and still undone where a history has them.\n */\nexport type Kept = Added | Edited | Removed;\n\n/** A task as a board lists it: its root message. */\ntype Message = Awaited<ReturnType<TaskBoard['thread']>>['message'];\n/** A task's thread at a glance, as a board lists tasks. */\ntype Summary = Awaited<ReturnType<TaskBoard['tasks']['list']>>['tasks'][number];\n/** How many of the latest finished tasks the drawer lists: what an agent said as it ended one is there to read. */\nconst OVER = 10;\n\n/** How many tasks a page is asked about at most: past that it has more pins than anyone reads. */\nconst PINNED = 500;\nconst AT = 'deictic.at';\nconst FILE = 'deictic.file';\n/** `x,y`: the spot in the element a task is about, in CSS pixels from the element's top left. */\nconst POINT = 'deictic.point';\n/** What parts what was typed from the rest of a task's text. */\nconst REST = '\\n---\\n';\n/** A file for the board, as the plugins that keep them read it. */\ntype Upload = { data: Uint8Array<ArrayBuffer>; name: string; type: string };\nconst OPEN = new Set(['waiting', 'ready', 'blocked']);\n\nexport function tasks(options: TasksOptions = {}) {\n const channel = options.channel ?? 'deictic';\n let team: Promise<TaskBoard> | undefined;\n let root: string | undefined;\n const own = options.board !== undefined && 'local' in options.board ? options.board.local : undefined;\n const found = async (): Promise<TaskBoard> => {\n if (options.board !== undefined && !('local' in options.board)) return options.board;\n // Loaded when first used, so a project that doesn't add this plugin needn't install the SDK.\n const { board } = await import('@vercel/board');\n if (own === undefined && process.env.BOARD_URL !== undefined) return board();\n\n const base = root ?? process.cwd();\n const { url, fresh, dir } = await localBoard(base, own);\n if (fresh) {\n const kept = relative(base, dir).replaceAll('\\\\', '/');\n console.log(`deictic/tasks: tasks go to a board on this machine, ${url.replace(/\\/api\\/board$/, '/')} (kept in ${kept})`);\n }\n // `board()` takes a URL from the environment only, as it's called: so it's set for the call, and what the\n // environment said is left as it was.\n const before = process.env.BOARD_URL;\n process.env.BOARD_URL = url;\n try {\n return board();\n } finally {\n if (before === undefined) delete process.env.BOARD_URL;\n else process.env.BOARD_URL = before;\n }\n };\n // Asked again after a failure: a board that didn't start may the next time.\n const boardOf = () =>\n (team ??= found().catch((e: unknown) => {\n team = undefined;\n throw e;\n }));\n let link: Promise<string | undefined> | undefined;\n // Asked once, unless asking failed: no link is no reason to keep the panel from showing the tasks.\n const linkOf = () =>\n (link ??= (\n options.link\n ? Promise.resolve(options.link(channel))\n : boardOf().then((b) => (own?.inspect === false ? undefined : localPage(b, channel)))\n ).catch(() => {\n link = undefined;\n return undefined;\n }));\n /** A task's page: what `link` says, or its thread on the channel's own page on this machine. */\n const taskLink = (page: string | undefined, id: string) =>\n options.link ? options.link(channel, id) : page === undefined ? undefined : `${page}?thread=${encodeURIComponent(id)}`;\n /**\n * One of this channel's tasks about an element, while it's still open: the page names it by ID, so\n * nothing else on the board is its to change, nor a task someone has taken up.\n */\n /** One of deictic's: it has a place, or the page it's about where no element was attached. */\n const ours = (message: Message) => message.labels[AT] !== undefined || message.labels['deictic.page'] !== undefined;\n const openTask = async (team: TaskBoard, id: string, verb: string) => {\n const { message } = await team.thread(id);\n if (message.channel !== channel || !ours(message))\n throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);\n\n const { task } = message;\n if (task !== undefined && !OPEN.has(task.state)) {\n throw new Refusal(\n `task ${id} is ${task.state}${task.claim ? ` by ${task.claim.actor}` : ''} now: ${verb} it on the board if you still mean to`,\n );\n }\n return message;\n };\n /** Cancels an open task of ours, and answers it as it was. */\n const cancel = async (id: string, reason: string) => {\n const team = await boardOf();\n const message = await openTask(team, id, 'cancel');\n await team.tasks.cancel(id, reason);\n return message;\n };\n /** Puts a task's text from one to the other, unless it reads as neither any more. */\n const rewrite = async (id: string, from: string, to: string) => {\n const team = await boardOf();\n const message = await openTask(team, id, 'edit');\n if (message.text === to) return;\n if (message.text !== from) throw new Refusal(`task ${id} has been edited since: change it on the board`);\n await team.edit(id, to, { revision: message.revision });\n };\n const create = async (record: Omit<Added, 'id'>): Promise<Added> => {\n const { task } = await (\n await boardOf()\n ).tasks.create(record.channel, {\n text: record.text,\n labels: record.labels,\n ...(record.attachments === undefined ? {} : { attachments: record.attachments }),\n });\n return { ...record, id: task.id };\n };\n\n /** A board's task as the panel lists it: its words, its state, who has it, and its page there. */\n const taskOf = (message: Message, actors: Awaited<ReturnType<typeof actorsOf>>, page: string | undefined): Task => {\n const state = message.task?.state ?? 'ready';\n const by = actors.get(message.task?.claim?.actor ?? '')?.name;\n const text = message.text.split(REST, 1)[0]!;\n const to = taskLink(page, message.id);\n const missing = Object.entries(message.labels).flatMap(([key, value]) => (/^deictic\\.dropped\\.\\d+$/.test(key) ? [value] : []));\n const dropped = missing.length === 0 ? undefined : listOf(missing);\n const [, x, y] = /^(-?\\d+),(-?\\d+)$/.exec(message.labels[POINT] ?? '') ?? [];\n const point = x === undefined || y === undefined ? undefined : { x: Number(x), y: Number(y) };\n return {\n id: message.id,\n title: text.split('\\n', 1)[0]!,\n text,\n state,\n ...(by === undefined ? {} : { by }),\n open: OPEN.has(state),\n ...(to === undefined ? {} : { link: to }),\n ...(dropped === undefined ? {} : { dropped }),\n ...(point === undefined ? {} : { point }),\n };\n };\n const listedOf = (\n { message, replies, last }: Summary,\n actors: Awaited<ReturnType<typeof actorsOf>>,\n page: string | undefined,\n ): Listed => {\n const { task, labels } = message;\n const said = task?.blocked?.reason ?? task?.result ?? task?.reason ?? undefined;\n return {\n ...taskOf(message, actors, page),\n ...(labels[AT] === undefined ? {} : { place: labels[AT] }),\n ...(labels['deictic.tag'] === undefined ? {} : { tag: labels['deictic.tag'] }),\n ...(labels['deictic.page'] === undefined ? {} : { page: labels['deictic.page'] }),\n replies,\n ...(last === null ? {} : { last: last.id }),\n ...(said === undefined || said === '' ? {} : { said: clip(said, 2000) }),\n };\n };\n /**\n * The channel's tasks, for the page: those still to do, oldest first, a page of the board's at a time and no more\n * than `PINNED`, then the `OVER` that last ended, the latest first.\n */\n const listed = async (): Promise<Listed[]> => {\n const team = await boardOf();\n const open: Summary[] = [];\n for (let after: string | undefined; open.length < PINNED;) {\n const { tasks, cursor } = await team.tasks.list({ channel, ...(after === undefined ? {} : { after }) });\n open.push(...tasks);\n if (tasks.length === 0 || cursor === after) break;\n after = cursor;\n }\n // By their latest activity, which is how a board answers threads: the newest of each end, then of both.\n const ended = await Promise.all(\n ['completed', 'failed'].map((state) => team.threads({ channel, label: { 'board.task': state }, limit: OVER })),\n );\n const when = ({ message, last }: Summary) => (last ?? message).createdAt;\n const over = ended\n .flatMap(({ threads }) => threads)\n .sort((a, b) => when(b).localeCompare(when(a)))\n .slice(0, OVER);\n const about = [...open, ...over].filter(({ message }) => ours(message));\n const [actors, page] = await Promise.all([\n actorsOf(\n team,\n about.flatMap(({ message }) => message.task?.claim?.actor ?? []),\n ),\n linkOf(),\n ]);\n return about.map((summary) => listedOf(summary, actors, page));\n };\n const replyOf = (message: Message): Reply => ({\n id: message.id,\n by: message.author?.name ?? message.by.actor,\n kind: message.author?.kind ?? 'unknown',\n text: message.text,\n at: message.createdAt,\n files: filesOf(message),\n });\n /** A task of ours with its thread, the newest replies a board answers at once. */\n const threadOf = async (id: string): Promise<Thread> => {\n const team = await boardOf();\n const { message, replies } = await team.thread(id);\n if (message.channel !== channel || !ours(message))\n throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);\n const said = replies.filter((reply) => !reply.deleted);\n const [actors, page] = await Promise.all([actorsOf(team, message.task?.claim ? [message.task.claim.actor] : []), linkOf()]);\n return {\n task: listedOf({ message, replies: said.length, last: said.at(-1) ?? null }, actors, page),\n files: filesOf(message),\n replies: said.map(replyOf),\n };\n };\n /** The task a route's request names, as its last segment, and what it sent. */\n const named = async (req: Request) => {\n const id = decodeURIComponent(new URL(req.url).pathname.split('/').at(-1) ?? '');\n const sent: unknown = req.method === 'POST' ? await req.json().catch(() => ({})) : {};\n const body = (typeof sent === 'object' && sent !== null ? sent : {}) as Partial<Answer>;\n return { id, text: typeof body.text === 'string' ? body.text : '', body };\n };\n /**\n * A file of a task's, `file/<task>/<file>`: one attached to the task or to a reply in its thread, and to nothing\n * else on the board. An image or a sound is served as it is; anything else as its text, escaped, in a page of the\n * lightbox's dark colours, so an element's HTML is read there, never run, on the dev server's origin.\n */\n const fileOf = async (req: Request): Promise<Response> => {\n const [task = '', file = ''] = (new URL(req.url).pathname.split('/file/')[1] ?? '').split('/').map(decodeURIComponent);\n const team = await boardOf();\n const { message, replies } = await team.thread(task);\n if (message.channel !== channel || !ours(message))\n throw new Refusal(`#${task} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);\n const found = [message, ...replies].flatMap((m) => m.attachments).find((a) => a.id === file);\n if (found === undefined) throw new Refusal(`task ${task} has no file ${file}: reload the page for what it has`);\n const res = await team.download(found.id);\n const media = /^(image|audio|video)\\//.test(found.type);\n const body = media ? res.body : textPage(found.name, await res.text());\n return new Response(body, {\n headers: {\n 'content-type': media ? found.type : 'text/html; charset=utf-8',\n 'content-disposition': `inline; filename=\"${found.name.replaceAll('\"', '')}\"`,\n 'x-content-type-options': 'nosniff',\n // Its own style and nothing else: no script, no request anywhere.\n 'content-security-policy': \"sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src 'self' blob:; media-src 'self' blob:\",\n // A board's file never changes under its ID.\n 'cache-control': 'private, max-age=86400, immutable',\n },\n });\n };\n\n // Kept from `setup`, to `use` another plugin when an op asks for it. // Kept from `setup`, to `use` another plugin when an op asks for it.\n let context: ServerContext | undefined;\n let project = options.project;\n /**\n * The op with only the screenshots, recordings and voice clips still kept, their files, and what's left out: a file\n * goes once newer ones pass its plugin's `keep`, or `deictic clean` takes it, and that's no reason to lose the task.\n */\n const keptOf = <T extends Attaching>(op: T) => {\n const clipOf = (id: string): ReturnType<Clips['read']> => context?.use('voice')?.read(id);\n // In the op's order, each kind's: the Nth PNG is `deictic.screenshot.N`'s, the Nth recording `deictic.recording.N`'s.\n const files: Upload[] = [];\n const dropped: Kind[] = [];\n const take = (file: Upload | undefined, missing: Kind) => {\n if (file === undefined) dropped.push(missing);\n else files.push(file);\n return file !== undefined;\n };\n const screenshots = (op.screenshots ?? []).filter(({ id }) => take(context?.use('screenshots')?.read(id), 'screenshot'));\n const recordings = (op.recordings ?? []).flatMap((recording) => {\n const found: ReturnType<Recordings['read']> = context?.use('recordings')?.read(recording.id);\n if (!take(found, 'recording')) return [];\n if (recording.voice === undefined) return [recording];\n const clipped = (id: string) => take(clipOf(id), 'voice clip');\n return [{ ...recording, voice: recording.voice.filter(clipped) }];\n });\n const voice = (op.voice ?? []).filter(({ id }) => take(clipOf(id), 'voice note'));\n // Last, and files, not the task's words: there to look into, and most tasks are done without them. What was\n // pointed at is in the element's HTML, and a file of its own only where that isn't attached.\n const html = typeof op.html === 'string' && op.html !== '' ? op.html : undefined;\n if (html !== undefined) files.push({ data: new TextEncoder().encode(html.slice(0, HTML)), name: 'element.html', type: 'text/html' });\n else if (op.pointed !== undefined)\n files.push({ data: new TextEncoder().encode(op.pointed.html.slice(0, HTML)), name: 'pointed.html', type: 'text/html' });\n // The others': the Nth element's is `element.N.html`, the first being the one it's sent on.\n for (const [i, other] of (op.also ?? []).entries()) {\n if (typeof other.html !== 'string' || other.html === '') continue;\n files.push({ data: new TextEncoder().encode(other.html.slice(0, HTML)), name: `element.${i + 2}.html`, type: 'text/html' });\n }\n const kept: T = {\n ...op,\n ...(op.screenshots === undefined ? {} : { screenshots }),\n ...(op.recordings === undefined ? {} : { recordings }),\n ...(op.voice === undefined ? {} : { voice }),\n };\n return { op: kept, files, dropped };\n };\n /** The files uploaded to the board, or nothing when there are none. */\n const upload = async (files: Upload[]): Promise<string[] | undefined> => {\n if (files.length === 0) return undefined;\n const team = await boardOf();\n return Promise.all(files.map(async (file) => (await team.upload(file)).id));\n };\n\n return definePlugin<Model, Op, Kept>({\n name: 'tasks',\n client: 'deictic/tasks/client',\n packages: ['@vercel/board'],\n // Only where it's turned off: the page half sends the HTML unless told not to.\n ...(options.html === false ? { clientOptions: { html: false } } : {}),\n shortcut: options.shortcut,\n setup: (given) => {\n context = given;\n root = given.root;\n project ??= nameOf(given.root);\n // Started with the dev server, not at the first task, so whoever works the tasks can watch from the start.\n // Not waited for: a failure is the first request's to tell.\n void boardOf().catch(() => {});\n },\n routes: {\n // The channel's tasks, for the page: the drawer lists them, and those with a place are pinned where their\n // elements are.\n page: async () => {\n const [tasks, link] = await Promise.all([asked(listed), linkOf()]);\n return Response.json({ channel, ...(link === undefined ? {} : { link }), tasks });\n },\n // A task and its thread, `thread/<id>`: what the drawer opens.\n thread: async (req) => Response.json(await asked(async () => threadOf((await named(req)).id))),\n // What the drawer does to a task: a reply in its thread, other words for it, or its end, which cancels it\n // on the board. Each answers the thread as it is after.\n // What a task has attached, or a reply in its thread, for the drawer to show.\n file: (req) => asked(() => fileOf(req)),\n reply: (req) =>\n asked(async () => {\n const { id, text, body } = await named(req);\n const answer: Answer = {\n text,\n ...(Array.isArray(body.screenshots) ? { screenshots: body.screenshots } : {}),\n ...(Array.isArray(body.recordings) ? { recordings: body.recordings } : {}),\n ...(Array.isArray(body.voice) ? { voice: body.voice } : {}),\n ...(body.annotations === undefined ? {} : { annotations: body.annotations }),\n };\n if (wordsOf(answer) === '') throw new Refusal('say something first');\n await threadOf(id);\n const { op: kept, files, dropped } = keptOf(answer);\n const verb = dropped.length === 1 ? \"isn't\" : \"aren't\";\n if (wordsOf(kept) === '') throw new Refusal(`${listOf(dropped)} ${verb} kept any more: attach again, or say something`);\n // What the files don't say, as a task has it: where each recording replays, the notes drawn.\n const labels = attachedLabels(kept, dropped);\n const attachments = await upload(files);\n await (\n await boardOf()\n ).reply(id, {\n text: clip(wordsOf(kept), 10_000),\n ...(Object.keys(labels).length === 0 ? {} : { labels }),\n ...(attachments === undefined ? {} : { attachments }),\n });\n return Response.json(await threadOf(id));\n }),\n edit: (req) =>\n asked(async () => {\n const { id, text } = await named(req);\n // A task's words are never changed to none.\n if (text.trim() === '') throw new Refusal('say what should change first');\n const before = (await openTask(await boardOf(), id, 'edit')).text;\n // What follows the words in a task added before they were labels (what's attached, what was pointed at) stays.\n const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : '';\n await rewrite(id, before, clip(text.trim(), 10_000 - rest.length) + rest);\n return Response.json(await threadOf(id));\n }),\n remove: (req) =>\n asked(async () => {\n const { id } = await named(req);\n await cancel(id, 'deleted in deictic');\n return Response.json({});\n }),\n },\n read: (source, target) =>\n asked(async () => {\n const team = await boardOf();\n const labelled = (label: Record<string, string>) => team.tasks.list({ channel, label, state: 'all' });\n // By place too: a task added before there was a `deictic.file` has none, and is still its element's.\n const [here, inFile, page, held] = await Promise.all([\n labelled({ [AT]: atOf(target) }),\n labelled({ [FILE]: clip(target.loc.file, LABEL) }),\n linkOf(),\n team.tasks.list({ channel, state: 'claimed' }),\n ]);\n const listed = new Set(inFile.tasks.map(({ message }) => message.id));\n // Nothing to tell a moved task by where the file has no such element.\n const line = source instanceof Refusal ? undefined : onceIn(source);\n const tasks: Task[] = [];\n const about = [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks];\n // Who has each, and who holds any claim on the channel: asked of the board at once.\n const actorOf = ({ task }: (typeof about)[number]['message']) => task?.claim?.actor;\n const claims = held.tasks.flatMap(({ message }) => message.task?.claim ?? []);\n const actors = await actorsOf(team, [...about.flatMap(({ message }) => actorOf(message) ?? []), ...claims.map((c) => c.actor)]);\n for (const { message } of about) {\n if (message.task?.state === 'canceled') continue;\n const task = taskOf(message, actors, page);\n const at = placeIn(message.labels);\n if (at === undefined || message.labels[AT] === atOf(target)) tasks.push(task);\n else if (line !== undefined && at.tag === target.tag && message.labels['deictic.line'] === line) tasks.push({ ...task, at });\n }\n // An agent at work on a task is here too, though its watch may be over until the task is (`deictic watch --once`).\n const working = agentsOf(actors, claims);\n const watching = [...new Set([...watchersOf(root ?? process.cwd(), channel), ...working])].sort();\n // A board of this machine's own is watched from here or not at all.\n const ours = own !== undefined || (options.board === undefined && process.env.BOARD_URL === undefined);\n return {\n channel,\n ...(page === undefined ? {} : { link: page }),\n ...(watching.length > 0 || ours ? { watching } : {}),\n tasks,\n };\n }),\n apply: (source, target, op) => {\n // A task may go without words where something attached says it.\n if (op.text.trim() === '' && shown(op) === undefined) throw new Refusal('say what should change first');\n const { op: kept, files, dropped } = keptOf(op);\n const verb = dropped.length === 1 ? \"isn't\" : \"aren't\";\n if (wordsOf(kept) === '') throw new Refusal(`${listOf(dropped)} ${verb} kept any more: attach again, or say what should change`);\n const labels = {\n ...options.labels,\n ...(project === undefined ? {} : { 'deictic.project': clip(project, LABEL) }),\n ...labelsOf(source, target, kept),\n ...attachedLabels(kept, dropped),\n };\n return asked(async () => {\n const attachments = await upload(files);\n const text = clip(wordsOf(kept), 10_000);\n return { done: await create({ channel, text, labels, ...(attachments === undefined ? {} : { attachments }) }) };\n });\n },\n undo: (record) =>\n asked(async () => {\n if (!('kind' in record)) {\n await cancel(record.id, 'undone in deictic');\n return undefined;\n }\n if (record.kind === 'edited') {\n await rewrite(record.id, record.after, record.before);\n return undefined;\n }\n const { kind, id: _, ...task } = record;\n return { kind, ...(await create(task)) };\n }),\n redo: (record) =>\n asked(async () => {\n if (!('kind' in record)) {\n const { id: _, ...added } = record;\n return create(added);\n }\n if (record.kind === 'edited') {\n await rewrite(record.id, record.before, record.after);\n return record;\n }\n await cancel(record.id, 'deleted in deictic');\n return record;\n }),\n describe: (op) => `task \"${clip(wordsOf(op).split('\\n', 1)[0]!, 60)}\"`,\n });\n}\n\n/**\n * The channel's page on a board `vb serve` runs on this machine, which serves its pages beside its API:\n * `/api/board` there, `/c/<channel>` beside it. Nothing for any other board.\n */\nasync function localPage(team: TaskBoard, channel: string): Promise<string | undefined> {\n const url = new URL((await team.discovery()).url);\n if (!['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname) || !url.pathname.endsWith('/api/board')) return undefined;\n return `${url.origin}${url.pathname.slice(0, -'/api/board'.length)}/c/${channel.split('/').map(encodeURIComponent).join('/')}`;\n}\n\n/**\n * A file's text as a page to read it in: escaped, so nothing in it runs or loads, in the lightbox's colours, as the\n * browser's own text page is black on nothing and the lightbox is dark under it.\n */\nfunction textPage(name: string, text: string): string {\n const escape = (raw: string) => raw.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');\n const style =\n ':root{color-scheme:dark}body{margin:0;padding:16px;font:12px/1.5 ui-monospace,monospace;color:#e4e4e7;background:#18181b;white-space:pre-wrap;overflow-wrap:anywhere}';\n return `<!doctype html><meta charset=\"utf-8\"><title>${escape(name)}</title><style>${style}</style><body>${escape(text)}`;\n}\n\n/** What may be left out of a task as no longer kept, as `deictic.dropped.N` names it. */\ntype Kind = 'screenshot' | 'recording' | 'voice clip' | 'voice note';\n\n/** What a task or a reply attaches: files, and what the labels say of them. */\ntype Attaching = Partial<Pick<Op, 'screenshots' | 'recordings' | 'voice' | 'annotations' | 'html' | 'pointed' | 'also'>>;\n\n/**\n * A message's files, as the drawer shows them: each recording with where it replays, which its\n * `deictic.recording.N.replay` label says, the Nth being the Nth recording attached.\n */\nfunction filesOf({ attachments, labels }: Message): Attached[] {\n const recordings = attachments.filter((a) => a.name.startsWith('recording-'));\n return attachments.map(({ id, name, type, size }) => {\n const n = recordings.findIndex((r) => r.id === id);\n const replay = n === -1 ? undefined : labels[`deictic.recording.${n + 1}.replay`];\n return { id, name, type, size, ...(replay === undefined ? {} : { replay }) };\n });\n}\n\n/**\n * What the attached files don't say, as labels numbered from 1, so each value is short and none is read out of the\n * text. `deictic.screenshot.N` is the Nth PNG attached: its `.position` and `.size` where the element is in it (CSS\n * pixels from its top left), for one taken of the element, `.note.M` a note drawn on it. `deictic.recording.N.replay` is where the Nth recording\n * plays back; `deictic.note.M` a note drawn on the page; `deictic.dropped.N` what wasn't kept any more;\n * `deictic.pointed` the path to what was pointed at inside the element. A note past a label is cut.\n */\nfunction attachedLabels(op: Attaching, dropped: Kind[]): Record<string, string> {\n const labels: Record<string, string> = {};\n // A board takes no control characters in a label: a note's lines go on one.\n const set = (key: string, value: string) => {\n labels[`deictic.${key}`] = clip(value.replace(/\\p{Cc}+/gu, ' '), LABEL);\n };\n for (const [i, { box, marks }] of (op.screenshots ?? []).entries()) {\n const n = `screenshot.${i + 1}`;\n for (const [j, note] of (marks?.notes ?? []).entries()) set(`${n}.note.${j + 1}`, note);\n // One of the window, from the tool panel, says nothing of the element: it may not be in it.\n if (box === undefined) continue;\n const [x, y, width, height] = boxOf(box);\n set(`${n}.position`, `${x},${y}`);\n set(`${n}.size`, `${width}x${height}`);\n }\n for (const [j, note] of (op.annotations?.notes ?? []).entries()) set(`note.${j + 1}`, note);\n for (const [i, { at, tag }] of (op.also ?? []).entries()) set(`also.${i + 1}`, `${at} <${tag}>`);\n // Not cut: half a URL leads nowhere.\n for (const [i, { replay }] of (op.recordings ?? []).entries()) if (replay.length <= LABEL) set(`recording.${i + 1}.replay`, replay);\n for (const [i, kind] of dropped.entries()) set(`dropped.${i + 1}`, kind);\n if (op.pointed !== undefined) set('pointed', op.pointed.path);\n return labels;\n}\n\n/**\n * `deictic.source`, `Field (src/Field.tsx:20) ← Panel`: what the element rendered through, out from its own place\n * (`deictic.at`), as the page said it: the components that use it, where the page knows them, or the files around\n * it. As many as a label holds, the farthest left out first.\n */\nfunction sourceOf(chain: NonNullable<Op['chain']>): Record<string, string> {\n let places = chain.slice(0, CHAIN).map(String);\n while (places.length > 1 && places.join(THROUGH).length > LABEL) places = places.slice(0, -1);\n return places.length === 0 ? {} : { 'deictic.source': clip(places.join(THROUGH), LABEL) };\n}\n\nconst THROUGH = ' ← ';\n\n/** How many places a chain names after the element's own: the first few say which use of a component it is. */\nconst CHAIN = 3;\n\n/** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */\nconst boxOf = ({ x, y, width, height }: Box) => [x, y, width, height].map(Math.round);\n\n/** What `element.html` holds of an element at most, in characters: a table's rows, not a whole page. */\nconst HTML = 100_000;\n\n/** A label's value: a board holds 256 characters. */\nconst LABEL = 256;\n\n/** The project's name: the `name` in the root's `package.json`, or nothing where it has none. */\nfunction nameOf(root: string): string | undefined {\n try {\n const { name } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as { name?: unknown };\n return typeof name === 'string' && name !== '' ? name : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The facts about the element, as labels: short values a script reads without parsing the text, and a watch\n * filters by. `deictic.line` is the opening tag's first line as the task saw it, to tell later that it moved.\n * `deictic.url` is the page's whole URL, where a label holds it; `deictic.page` is its path.\n */\nfunction labelsOf(source: Source | Refusal, target: Target, op: Op): Record<string, string> {\n const page = {\n 'deictic.page': clip(new URL(op.page).pathname, LABEL),\n ...(op.page.length <= LABEL ? { 'deictic.url': op.page } : {}),\n 'deictic.viewport': `${op.viewport.width}x${op.viewport.height}`,\n };\n // With no element attached it's the page's alone: nothing of the one the popup happened to be on.\n if (op.detached === true) return page;\n return {\n [AT]: atOf(target),\n [FILE]: clip(target.loc.file, LABEL),\n 'deictic.tag': target.tag,\n // Not where the file has no such element: the task is the page's, and goes without.\n ...(source instanceof Refusal ? {} : { 'deictic.line': clip(lineOf(source), LABEL) }),\n ...page,\n 'deictic.count': String(op.count),\n ...(op.point === undefined ? {} : { [POINT]: `${Math.round(op.point.x)},${Math.round(op.point.y)}` }),\n ...sourceOf(op.chain ?? []),\n };\n}\n\n/**\n * The actors these IDs name, by ID. An actor's ID isn't read for its name (each board writes them its own way), so\n * the board is asked who they are, and only when there's one to ask about.\n */\nasync function actorsOf(team: TaskBoard, ids: string[]): Promise<Map<string, Awaited<ReturnType<TaskBoard['actors']>>[number]>> {\n const asked = [...new Set(ids)];\n if (asked.length === 0) return new Map();\n // By ID, which a board from 0.54 answers without listing everyone; an older one lists them all, and the rest go unread.\n return new Map((await team.actors({ id: asked })).map((actor) => [actor.id, actor]));\n}\n\n/**\n * The agents holding these claims, by name, while their leases run. A person holding one is left out: they needn't\n * be told they're there. (Whatever else holds one works tasks: an agent, a workflow.)\n */\nfunction agentsOf(actors: Awaited<ReturnType<typeof actorsOf>>, claims: { actor: string; until: string }[]): string[] {\n return claims\n .filter((claim) => Date.parse(claim.until) > Date.now())\n .flatMap((claim) => actors.get(claim.actor) ?? [])\n .filter((actor) => actor.kind !== 'person')\n .map((actor) => actor.name);\n}\n\nconst atOf = ({ loc }: Target) => `${loc.file}:${loc.line}:${loc.column}`;\n\n/** The opening tag's first line, as written. */\nconst lineOf = ({ code, element }: Pick<Source, 'code' | 'element'>) => code.slice(element.start, element.end).split('\\n', 1)[0]!.trim();\n\n/** 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. */\nfunction onceIn(source: Source): string | undefined {\n const line = lineOf(source);\n return source.code.split(line).length === 2 ? clip(line, LABEL) : undefined;\n}\n\n/** Where a task says its element is, from its labels. */\nfunction placeIn(labels: Record<string, string>): Place | undefined {\n const [, line, column] = /:(\\d+):(\\d+)$/.exec(labels[AT] ?? '') ?? [];\n if (line === undefined || column === undefined) return undefined;\n return { line: Number(line), column: Number(column), tag: labels['deictic.tag'] ?? '' };\n}\n\n/** The task's words: what was typed, or where nothing was, a line that sends the reader to what's attached. */\nconst wordsOf = (op: Attaching & Pick<Op, 'text'>) => (op.text.trim() === '' ? (shown(op) ?? '') : op.text.trim());\n\n/** `See the recording and the voice note`: what stands for the words of a task sent with none, where something is attached. */\nfunction shown(op: Attaching): string | undefined {\n const named = (count: number | undefined, word: string) =>\n count === undefined || count === 0 ? [] : [`the ${word}${count === 1 ? '' : 's'}`];\n const attached = [\n ...named(op.screenshots?.length, 'screenshot'),\n ...named(op.recordings?.length, 'recording'),\n ...named(op.voice?.length, 'voice note'),\n ];\n return attached.length === 0 ? undefined : `See ${conjunction(attached)}`;\n}\n\n/** `a screenshot and 2 voice notes`, of `deictic.dropped.N`'s values. */\nfunction listOf(kinds: string[]): string {\n return conjunction(\n [...Map.groupBy(kinds, (kind) => kind)].map(([kind, all]) => (all.length === 1 ? `a ${kind}` : `${all.length} ${kind}s`)),\n );\n}\n\nconst conjunction = (things: string[]) => new Intl.ListFormat('en', { type: 'conjunction' }).format(things);\n\nconst clip = (text: string, max: number) => (text.length <= max ? text : `${text.slice(0, max - 1)}…`);\n\n/** The board's answer, or a `Refusal` saying what to do when there's no board to ask or it said no. */\nasync function asked<T>(ask: () => Promise<T>): Promise<T> {\n try {\n return await ask();\n } catch (e) {\n if (e instanceof Refusal) throw e;\n const { code, message, hint } = e as { code?: unknown; message?: string; hint?: string };\n if (typeof code === 'string') throw new Refusal(`the board says: ${message}${hint === undefined ? '' : ` (${hint})`}`, { cause: e });\n throw new Refusal(\n `can't reach the board (${message ?? String(e)}): restart the dev server, which starts its own, or check the BOARD_URL or \\`board\\` it was given`,\n { cause: e },\n );\n }\n}\n\nexport default tasks;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0SA,MAAM,OAAO;;AAGb,MAAM,SAAS;AACf,MAAM,KAAK;AACX,MAAM,OAAO;;AAEb,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAGb,MAAM,uBAAO,IAAI,IAAI;CAAC;CAAW;CAAS;AAAS,CAAC;AAEpD,SAAgB,MAAM,UAAwB,CAAC,GAAG;CAChD,MAAM,UAAU,QAAQ,W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;CACnB,SAAS,GAAG;EACV,IAAI,aAAa,SAAS,MAAM;EAChC,MAAM,EAAE,MAAM,SAAS,SAAS;EAChC,IAAI,OAAO,SAAS,UAAU,MAAM,IAAI,QAAQ,mBAAmB,UAAU,SAAS,KAAA,IAAY,KAAK,KAAK,KAAK,MAAM,EAAE,OAAO,EAAE,CAAC;EACnI,MAAM,IAAI,QACR,0BAA0B,WAAW,OAAO,CAAC,EAAE,oGAC/C,EAAE,OAAO,EAAE,CACb;CACF;AACF"}
|
package/dist/shared/vb.js
CHANGED
package/dist/shared/voice2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdirSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { a as clock } from "./board.js";
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { a as clock, t as ME } from "./board.js";
|
|
4
4
|
import { i as voiceClips, t as ffmpeg } from "./find.js";
|
|
5
5
|
// src/cli/voice.ts
|
|
6
6
|
/**
|
|
@@ -66,11 +66,13 @@ async function run(ref, values) {
|
|
|
66
66
|
}
|
|
67
67
|
for (const r of results) {
|
|
68
68
|
const where = r.recording === void 0 ? "a voice note" : `in recording ${r.recording}, from ${clock(r.at)}`;
|
|
69
|
-
console.log(`clip ${r.id} (${where}), ${clock(r.length)} long: ${r.file}`);
|
|
69
|
+
console.log(`clip ${r.id} (${where}), ${clock(r.length)} long: ${relative(process.cwd(), r.file)}`);
|
|
70
70
|
if (r.speech.length === 0) console.log(" no speech found: try a lower --noise, like -45");
|
|
71
71
|
for (const s of r.speech) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} speech`);
|
|
72
|
-
if (wav !== void 0) console.log(` wav: ${join(wav, `${r.id}.wav`)}`);
|
|
72
|
+
if (wav !== void 0) console.log(` wav: ${relative(process.cwd(), join(wav, `${r.id}.wav`))}`);
|
|
73
73
|
}
|
|
74
|
+
if (!results.some((r) => r.recording !== void 0 && r.speech.length > 0)) return;
|
|
75
|
+
console.log(`\nWhat was on screen as they spoke is what they mean: ${ME} frame ${ref} --at <seconds>. The words: ${ME} transcribe ${ref}.`);
|
|
74
76
|
}
|
|
75
77
|
export { run };
|
|
76
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice2.js","names":[],"sources":["../../src/cli/voice.ts"],"sourcesContent":["/**\n * `deictic voice`: when something was said: the stretches of speech in voice clips, found by ffmpeg's silence\n * detection. For a recording, in the recording's time, to line up with its timeline; for a task, each voice note on\n * it too. `--wav` writes each clip as 16 kHz mono WAV, what speech-to-text tools take.\n */\nimport { mkdirSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\n\nimport { clock } from './board.ts';\nimport { ffmpeg, voiceClips } from './find.ts';\n\nexport async function run(ref: string, values: { noise: string; gap: string; wav?: string; json?: boolean }): Promise<void> {\n const noise = Number(values.noise);\n const gap = Number(values.gap);\n const wav = values.wav === undefined ? undefined : resolve(values.wav);\n\n const results = [];\n for (const c of await voiceClips(ref)) {\n // ffmpeg reports silence; speech is what's between. MediaRecorder's webm has no duration, so it's measured.\n const log = ffmpeg(['-i', c.file, '-af', `silencedetect=noise=${noise}dB:d=${gap}`, '-f', 'null', '-']).log;\n const starts = [...log.matchAll(/silence_start: (-?[\\d.]+)/g)].map((m) => Number(m[1]) * 1000);\n const ends = [...log.matchAll(/silence_end: (-?[\\d.]+)/g)].map((m) => Number(m[1]) * 1000);\n const times = [...log.matchAll(/time=(\\d+):(\\d+):([\\d.]+)/g)].at(-1);\n const length = times ? (Number(times[1]) * 3600 + Number(times[2]) * 60 + Number(times[3])) * 1000 : Math.max(0, ...ends);\n const speech: [number, number][] = [];\n let from = 0;\n for (const [i, start] of starts.entries()) {\n if (start - from > 150) speech.push([from, start]);\n from = ends[i] ?? length;\n }\n if (length - from > 150) speech.push([from, length]);\n if (wav !== undefined) {\n mkdirSync(wav, { recursive: true });\n ffmpeg(['-y', '-loglevel', 'error', '-i', c.file, '-ar', '16000', '-ac', '1', '-sample_fmt', 's16', join(wav, `${c.id}.wav`)]);\n }\n results.push({ ...c, length, speech: speech.map(([a, b]) => ({ from: c.at + a, to: c.at + b })) });\n }\n\n if (values.json) {\n console.log(JSON.stringify(results, null, 2));\n return;\n }\n for (const r of results) {\n const where = r.recording === undefined ? 'a voice note' : `in recording ${r.recording}, from ${clock(r.at)}`;\n console.log(`clip ${r.id} (${where}), ${clock(r.length)} long: ${r.file}`);\n if (r.speech.length === 0) console.log(' no speech found: try a lower --noise, like -45');\n for (const s of r.speech) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} speech`);\n if (wav !== undefined) console.log(` wav: ${join(wav, `${r.id}.wav`)}`);\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,eAAsB,IAAI,KAAa,QAAqF;CAC1H,MAAM,QAAQ,OAAO,OAAO,KAAK;CACjC,MAAM,MAAM,OAAO,OAAO,GAAG;CAC7B,MAAM,MAAM,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,QAAQ,OAAO,GAAG;CAErE,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,KAAK,MAAM,WAAW,GAAG,GAAG;EAErC,MAAM,MAAM,OAAO;GAAC;GAAM,EAAE;GAAM;GAAO,uBAAuB,MAAM,OAAO;GAAO;GAAM;GAAQ;EAAG,CAAC,CAAC,CAAC;EACxG,MAAM,SAAS,CAAC,GAAG,IAAI,SAAS,4BAA4B,CAAC,CAAC,CAAC,KAAK,MAAM,OAAO,EAAE,EAAE,IAAI,GAAI;EAC7F,MAAM,OAAO,CAAC,GAAG,IAAI,SAAS,0BAA0B,CAAC,CAAC,CAAC,KAAK,MAAM,OAAO,EAAE,EAAE,IAAI,GAAI;EACzF,MAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,4BAA4B,CAAC,CAAC,CAAC,GAAG,EAAE;EACnE,MAAM,SAAS,SAAS,OAAO,MAAM,EAAE,IAAI,OAAO,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE,KAAK,MAAO,KAAK,IAAI,GAAG,GAAG,IAAI;EACxH,MAAM,SAA6B,CAAC;EACpC,IAAI,OAAO;EACX,KAAK,MAAM,CAAC,GAAG,UAAU,OAAO,QAAQ,GAAG;GACzC,IAAI,QAAQ,OAAO,KAAK,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;GACjD,OAAO,KAAK,MAAM;EACpB;EACA,IAAI,SAAS,OAAO,KAAK,OAAO,KAAK,CAAC,MAAM,MAAM,CAAC;EACnD,IAAI,QAAQ,KAAA,GAAW;GACrB,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;GAClC,OAAO;IAAC;IAAM;IAAa;IAAS;IAAM,EAAE;IAAM;IAAO;IAAS;IAAO;IAAK;IAAe;IAAO,KAAK,KAAK,GAAG,EAAE,GAAG,KAAK;GAAC,CAAC;EAC/H;EACA,QAAQ,KAAK;GAAE,GAAG;GAAG;GAAQ,QAAQ,OAAO,KAAK,CAAC,GAAG,QAAQ;IAAE,MAAM,EAAE,KAAK;IAAG,IAAI,EAAE,KAAK;GAAE,EAAE;EAAE,CAAC;CACnG;CAEA,IAAI,OAAO,MAAM;EACf,QAAQ,IAAI,KAAK,UAAU,SAAS,MAAM,CAAC,CAAC;EAC5C;CACF;CACA,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,QAAQ,EAAE,cAAc,KAAA,IAAY,iBAAiB,gBAAgB,EAAE,UAAU,SAAS,MAAM,EAAE,EAAE;EAC1G,QAAQ,IAAI,QAAQ,EAAE,GAAG,IAAI,MAAM,KAAK,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"voice2.js","names":[],"sources":["../../src/cli/voice.ts"],"sourcesContent":["/**\n * `deictic voice`: when something was said: the stretches of speech in voice clips, found by ffmpeg's silence\n * detection. For a recording, in the recording's time, to line up with its timeline; for a task, each voice note on\n * it too. `--wav` writes each clip as 16 kHz mono WAV, what speech-to-text tools take.\n */\nimport { mkdirSync } from 'node:fs';\nimport { join, relative, resolve } from 'node:path';\n\nimport { clock, ME } from './board.ts';\nimport { ffmpeg, voiceClips } from './find.ts';\n\nexport async function run(ref: string, values: { noise: string; gap: string; wav?: string; json?: boolean }): Promise<void> {\n const noise = Number(values.noise);\n const gap = Number(values.gap);\n const wav = values.wav === undefined ? undefined : resolve(values.wav);\n\n const results = [];\n for (const c of await voiceClips(ref)) {\n // ffmpeg reports silence; speech is what's between. MediaRecorder's webm has no duration, so it's measured.\n const log = ffmpeg(['-i', c.file, '-af', `silencedetect=noise=${noise}dB:d=${gap}`, '-f', 'null', '-']).log;\n const starts = [...log.matchAll(/silence_start: (-?[\\d.]+)/g)].map((m) => Number(m[1]) * 1000);\n const ends = [...log.matchAll(/silence_end: (-?[\\d.]+)/g)].map((m) => Number(m[1]) * 1000);\n const times = [...log.matchAll(/time=(\\d+):(\\d+):([\\d.]+)/g)].at(-1);\n const length = times ? (Number(times[1]) * 3600 + Number(times[2]) * 60 + Number(times[3])) * 1000 : Math.max(0, ...ends);\n const speech: [number, number][] = [];\n let from = 0;\n for (const [i, start] of starts.entries()) {\n if (start - from > 150) speech.push([from, start]);\n from = ends[i] ?? length;\n }\n if (length - from > 150) speech.push([from, length]);\n if (wav !== undefined) {\n mkdirSync(wav, { recursive: true });\n ffmpeg(['-y', '-loglevel', 'error', '-i', c.file, '-ar', '16000', '-ac', '1', '-sample_fmt', 's16', join(wav, `${c.id}.wav`)]);\n }\n results.push({ ...c, length, speech: speech.map(([a, b]) => ({ from: c.at + a, to: c.at + b })) });\n }\n\n if (values.json) {\n console.log(JSON.stringify(results, null, 2));\n return;\n }\n for (const r of results) {\n const where = r.recording === undefined ? 'a voice note' : `in recording ${r.recording}, from ${clock(r.at)}`;\n console.log(`clip ${r.id} (${where}), ${clock(r.length)} long: ${relative(process.cwd(), r.file)}`);\n if (r.speech.length === 0) console.log(' no speech found: try a lower --noise, like -45');\n for (const s of r.speech) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} speech`);\n if (wav !== undefined) console.log(` wav: ${relative(process.cwd(), join(wav, `${r.id}.wav`))}`);\n }\n // Speech in a recording points at the page: \"this one\" is what was on screen as it was said.\n if (!results.some((r) => r.recording !== undefined && r.speech.length > 0)) return;\n console.log(\n `\\nWhat was on screen as they spoke is what they mean: ${ME} frame ${ref} --at <seconds>. The words: ${ME} transcribe ${ref}.`,\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,eAAsB,IAAI,KAAa,QAAqF;CAC1H,MAAM,QAAQ,OAAO,OAAO,KAAK;CACjC,MAAM,MAAM,OAAO,OAAO,GAAG;CAC7B,MAAM,MAAM,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,QAAQ,OAAO,GAAG;CAErE,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,KAAK,MAAM,WAAW,GAAG,GAAG;EAErC,MAAM,MAAM,OAAO;GAAC;GAAM,EAAE;GAAM;GAAO,uBAAuB,MAAM,OAAO;GAAO;GAAM;GAAQ;EAAG,CAAC,CAAC,CAAC;EACxG,MAAM,SAAS,CAAC,GAAG,IAAI,SAAS,4BAA4B,CAAC,CAAC,CAAC,KAAK,MAAM,OAAO,EAAE,EAAE,IAAI,GAAI;EAC7F,MAAM,OAAO,CAAC,GAAG,IAAI,SAAS,0BAA0B,CAAC,CAAC,CAAC,KAAK,MAAM,OAAO,EAAE,EAAE,IAAI,GAAI;EACzF,MAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,4BAA4B,CAAC,CAAC,CAAC,GAAG,EAAE;EACnE,MAAM,SAAS,SAAS,OAAO,MAAM,EAAE,IAAI,OAAO,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE,KAAK,MAAO,KAAK,IAAI,GAAG,GAAG,IAAI;EACxH,MAAM,SAA6B,CAAC;EACpC,IAAI,OAAO;EACX,KAAK,MAAM,CAAC,GAAG,UAAU,OAAO,QAAQ,GAAG;GACzC,IAAI,QAAQ,OAAO,KAAK,O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,MAAM,MAAM,EAAE,cAAc,KAAA,KAAa,EAAE,OAAO,SAAS,CAAC,GAAG;CAC5E,QAAQ,IACN,yDAAyD,GAAG,SAAS,IAAI,8BAA8B,GAAG,cAAc,IAAI,EAC9H;AACF"}
|
package/dist/shared/watch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "node:child_process";
|
|
2
2
|
import { createInterface } from "node:readline";
|
|
3
3
|
import { t as watcherAt } from "./watchers.js";
|
|
4
|
-
import { c as duration, f as
|
|
4
|
+
import { c as duration, f as vbCommand, h as whoami, i as boardUrl, m as vbJson, n as answers, o as deicticDirs, r as boardIn, t as ME } from "./board.js";
|
|
5
5
|
// src/cli/watch.ts
|
|
6
6
|
/**
|
|
7
7
|
* `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,
|
|
@@ -75,6 +75,13 @@ function run(channel, values) {
|
|
|
75
75
|
const idle = duration(values.idle);
|
|
76
76
|
const say = (line) => console.log(line.replace(/\s+/g, " ").trim());
|
|
77
77
|
const first = (text) => (text.split("\n---")[0] ?? "").trim().slice(0, 160);
|
|
78
|
+
const about = (text, labels) => {
|
|
79
|
+
const label = (key) => labels?.[key];
|
|
80
|
+
const at = label("deictic.at");
|
|
81
|
+
const page = label("deictic.page");
|
|
82
|
+
const project = label("deictic.project");
|
|
83
|
+
return `"${first(text)}"${at ? ` at ${at}` : ""}${page ? ` on ${page}` : ""}${project ? ` in ${project}` : ""}`;
|
|
84
|
+
};
|
|
78
85
|
const made = () => {
|
|
79
86
|
const [command, argv, options] = vbCommand([
|
|
80
87
|
"channels",
|
|
@@ -90,13 +97,13 @@ function run(channel, values) {
|
|
|
90
97
|
"--limit",
|
|
91
98
|
"1"
|
|
92
99
|
]).cursor;
|
|
93
|
-
const ready =
|
|
100
|
+
const ready = vbJson([
|
|
94
101
|
"tasks",
|
|
95
102
|
channel,
|
|
96
103
|
"--state",
|
|
97
104
|
"ready",
|
|
98
105
|
...labels
|
|
99
|
-
]).
|
|
106
|
+
]).tasks.map((t) => t.message);
|
|
100
107
|
const me = whoami();
|
|
101
108
|
const url = boardUrl();
|
|
102
109
|
const dirs = deicticDirs();
|
|
@@ -120,10 +127,9 @@ function run(channel, values) {
|
|
|
120
127
|
setInterval(() => orphaned() && end(0), 5e3);
|
|
121
128
|
say(`watching ${channel} on ${url ?? "the team's board"} as ${me.handle ?? me.actor}`);
|
|
122
129
|
if (me.profile === null) say(`you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`);
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
if (values.once && waiting.length > 0) end(0);
|
|
130
|
+
const told = new Set(ready.map((m) => String(m.id)));
|
|
131
|
+
for (const m of ready) say(`ready: #${m.id} ${about(m.text, m.labels)}. Read it: ${ME} task ${m.id}`);
|
|
132
|
+
if (values.once && ready.length > 0) end(0);
|
|
127
133
|
/** One thing to act on: all `--once` waits for. */
|
|
128
134
|
const event = (line) => {
|
|
129
135
|
say(line);
|
|
@@ -149,13 +155,7 @@ function run(channel, values) {
|
|
|
149
155
|
if (e.cursor !== void 0) cursor = e.cursor;
|
|
150
156
|
heard();
|
|
151
157
|
const p = e.payload ?? {};
|
|
152
|
-
|
|
153
|
-
if (e.type === "message.posted" && p.re === null && p.thread !== void 0) {
|
|
154
|
-
const at = label("deictic.at");
|
|
155
|
-
const page = label("deictic.page");
|
|
156
|
-
const project = label("deictic.project");
|
|
157
|
-
roots.set(p.thread, `"${first(p.text ?? "")}"${at ? ` at ${at}` : ""}${page ? ` on ${page}` : ""}${project ? ` in ${project}` : ""}`);
|
|
158
|
-
}
|
|
158
|
+
if (e.type === "message.posted" && p.re === null && p.thread !== void 0) roots.set(p.thread, about(p.text ?? "", p.labels));
|
|
159
159
|
if (e.type === "task.created" && !told.has(String(p.id))) event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ""}. Read it: ${ME} task ${p.id}`);
|
|
160
160
|
if (e.type === "message.posted" && p.re !== null && p.re !== void 0) {
|
|
161
161
|
if (me.profile !== null && p.by?.actor === me.actor) return;
|
package/dist/shared/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","names":[],"sources":["../../src/cli/watch.ts"],"sourcesContent":["/**\n * `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,\n * then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's monitor (each\n * line an event). A board that goes away (the dev server restarted, and its board with it, maybe on another port) is\n * waited for and followed again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has\n * happened on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.\n * With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits. It ends,\n * too, when the process that started it does: nobody reads its lines then.\n *\n * While it runs the project's Task tab shows who watches (`watcherAt`). Replies the watcher wrote itself are left out\n * where it has a name of its own (BOARD_PROFILE): with none it writes as the person. Exits 0 after `--once`'s event,\n * 2 when idle, 1 when the board went away.\n */\nimport { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport { createInterface } from 'node:readline';\n\nimport { watcherAt } from '#src/plugins/tasks/watchers.ts';\n\nimport { answers, boardIn, boardUrl, deicticDirs, duration, ME, vb, vbCommand, vbJson, whoami } from './board.ts';\n\n/** What `vb tail --json` prints, one per line. */\ninterface Tailed {\n type: string;\n cursor?: string;\n payload?: {\n id?: number;\n thread?: number;\n re?: number | null;\n text?: string;\n reason?: string;\n labels?: Record<string, string>;\n by?: { actor: string };\n };\n message?: { author?: { handle?: string } };\n}\n\n/** How long a board that went away is waited for: a dev server's restart takes a few seconds. */\nconst BACK = 60_000;\n/** A tail that ends sooner than this after it's started again isn't started a third time: the board isn't the trouble. */\nconst SOON = 10_000;\n\n/** Each process's parent, by ID, asked of the system once: empty where it can't say. */\nfunction parents(): Map<number, number> {\n const run =\n process.platform === 'win32'\n ? spawnSync(\n 'powershell',\n ['-NoProfile', '-Command', 'Get-CimInstance Win32_Process | % { \"$($_.ProcessId) $($_.ParentProcessId)\" }'],\n {\n encoding: 'utf8',\n },\n )\n : spawnSync('ps', ['-A', '-o', 'pid=', '-o', 'ppid='], { encoding: 'utf8' });\n const map = new Map<number, number>();\n for (const line of (run.stdout ?? '').split('\\n')) {\n const [pid, ppid] = line.trim().split(/\\s+/).map(Number);\n if (pid !== undefined && ppid !== undefined && Number.isInteger(pid) && Number.isInteger(ppid)) map.set(pid, ppid);\n }\n return map;\n}\n\n/**\n * The processes above this one's parent, the nearest `count` of them. A runner (`npx`, `pnpm exec`, and on Windows the\n * shell and the bin's `.cmd` shim it runs) sits between the watch and the shell that ran it, and outlives that shell.\n */\nfunction ancestors(count: number): number[] {\n const of = parents();\n const out: number[] = [];\n for (let pid = of.get(process.ppid); pid !== undefined && pid > 1 && out.length < count && !out.includes(pid); pid = of.get(pid))\n out.push(pid);\n return out;\n}\n\n/** Whether a process is gone. On Windows a dead parent's ID stays a child's `ppid`, so the system is asked. */\nfunction gone(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return false;\n } catch (e) {\n return (e as { code?: string }).code === 'ESRCH';\n }\n}\n\n/** What `vb` said as it failed: its JSON's `message`, or its last line. */\nfunction reasonOf(said: string): string | undefined {\n const last = said.trim().split('\\n').at(-1)?.trim();\n if (last === undefined || last === '') return undefined;\n try {\n const { message } = JSON.parse(last) as { message?: unknown };\n return typeof message === 'string' ? message : last;\n } catch {\n return last;\n }\n}\n\nexport function run(channel: string, values: { idle: string; once?: boolean; label?: string[] }): void {\n const labels = (values.label ?? []).flatMap((l) => ['--label', l]);\n const idle = duration(values.idle);\n const say = (line: string) => console.log(line.replace(/\\s+/g, ' ').trim());\n const first = (text: string) => (text.split('\\n---')[0] ?? '').trim().slice(0, 160);\n\n // A board nothing has posted to yet has no channel, and won't list or follow one it hasn't: made here, as the first\n // task would make it. One that's there stays as it is; where the board won't let this make one, `vb tasks` says so.\n const made = () => {\n const [command, argv, options] = vbCommand(['channels', 'create', channel]);\n spawnSync(command, argv, options);\n };\n made();\n // Where the channel is now, taken before what's ready is: followed from here, nothing posted between is missed, and\n // a tail started again after the board went away follows on from what this one heard, never from a list taken earlier.\n let cursor = vbJson<{ cursor: string }>(['read', channel, '--limit', '1']).cursor;\n const ready = vb(['tasks', channel, '--state', 'ready', ...labels]).trim();\n const me = whoami();\n // In the `.deictic/` whose board this is, or in each one near here where the board is the environment's.\n const url = boardUrl();\n const dirs = deicticDirs();\n const own = dirs.filter((dir) => boardIn(dir) === url);\n const unseen = watcherAt(own.length > 0 ? own : dirs, me.profile ?? me.name ?? me.handle ?? me.actor, channel);\n let tail: ChildProcess | undefined;\n const end = (code: number) => {\n unseen();\n tail?.removeAllListeners('exit');\n tail?.kill();\n process.exit(code);\n };\n // Stopped by its monitor, where the system says so: the page isn't left thinking someone watches.\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) process.on(signal, () => end(0));\n\n // Whoever started the watch reads its lines. With that gone (a session that ended and left the watch behind) no one\n // does, and the page mustn't go on saying an agent watches. Run through a runner, the shell is a few processes up,\n // so those are watched too: any gone, and the watch ends. A dead parent shows as another parent's ID, except on\n // Windows, where the system is asked whether it's still a process.\n const parent = process.ppid;\n const above = ancestors(3);\n const orphaned = () => process.ppid !== parent || gone(parent) || above.some(gone);\n setInterval(() => orphaned() && end(0), 5000);\n\n say(`watching ${channel} on ${url ?? \"the team's board\"} as ${me.handle ?? me.actor}`);\n // With no profile (an agent `profileOf` doesn't know), the person's replies and the watcher's own are one actor's:\n // none can be left out.\n if (me.profile === null) {\n say(\n `you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`,\n );\n }\n const waiting = (ready ? ready.split('\\n') : []).filter((line) => /^#\\d+/.test(line));\n // The tasks said, by ID: one made after the cursor above and listed as ready is said once.\n const told = new Set(waiting.map((line) => /^#(\\d+)/.exec(line)?.[1]));\n for (const line of waiting) say(`ready: ${line}`);\n if (values.once && waiting.length > 0) end(0);\n\n /** One thing to act on: all `--once` waits for. */\n const event = (line: string) => {\n say(line);\n if (values.once) end(0);\n };\n\n // Anything on the channel puts the end off, the watcher's own claims and replies too: it's being worked.\n let quiet: ReturnType<typeof setTimeout> | undefined;\n const heard = () => {\n clearTimeout(quiet);\n quiet = setTimeout(() => {\n say(\n `idle: nothing on ${channel} in ${values.idle}, so the watch is over. Don't start it again by yourself: tell the person in a line that you've stopped watching, and watch again when they ask. Only if you're working a task now, start it once more when that's done.`,\n );\n end(2);\n }, idle);\n };\n heard();\n\n // What the board says about each thread: its root's first line and where, to name it when a task is made.\n const roots = new Map<number, string>();\n const heardOf = (line: string) => {\n let e: Tailed;\n try {\n e = JSON.parse(line) as Tailed;\n } catch {\n return;\n }\n // The last event heard, which a tail started again follows from: nothing left while the board was away is missed.\n if (e.cursor !== undefined) cursor = e.cursor;\n heard();\n const p = e.payload ?? {};\n const label = (key: string) => p.labels?.[key];\n if (e.type === 'message.posted' && p.re === null && p.thread !== undefined) {\n const at = label('deictic.at');\n const page = label('deictic.page');\n const project = label('deictic.project');\n roots.set(p.thread, `\"${first(p.text ?? '')}\"${at ? ` at ${at}` : ''}${page ? ` on ${page}` : ''}${project ? ` in ${project}` : ''}`);\n }\n if (e.type === 'task.created' && !told.has(String(p.id)))\n event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ''}. Read it: ${ME} task ${p.id}`);\n if (e.type === 'message.posted' && p.re !== null && p.re !== undefined) {\n if (me.profile !== null && p.by?.actor === me.actor) return;\n const by = e.message?.author?.handle ?? p.by?.actor ?? 'someone';\n event(`reply on #${p.re} by ${by}: ${first(p.text ?? '')}`);\n }\n if (e.type === 'task.canceled')\n event(`task #${p.id} canceled: ${p.reason ?? ''}. Stop work on it, and put back what you changed for it.`);\n };\n\n const over = (why: string) => {\n say(`watch ended (${why}): start it again`);\n end(1);\n };\n\n /** Follows the channel from `cursor`, and again when the board comes back after going away. */\n const follow = (again: boolean) => {\n const started = Date.now();\n const [command, argv, options] = vbCommand(['tail', channel, ...labels, '--after', cursor, '--json']);\n const child = spawn(command, argv, { env: options.env, shell: options.shell, stdio: ['ignore', 'pipe', 'pipe'] });\n tail = child;\n createInterface({ input: child.stdout }).on('line', heardOf);\n // What it said as it ended goes in the watch's own line: a board started again refuses the old token, as expected,\n // and the CLI's raw error isn't something for an agent to act on.\n let said = '';\n child.stderr.on('data', (chunk: Buffer) => (said += chunk.toString()));\n // A dev server started again may start its board on another port: the tail would go on asking the old one for\n // ever, so it's ended once the project's `.deictic/board.json` names another, and followed there.\n const at = boardUrl();\n let moved: string | undefined;\n const elsewhere = setInterval(() => {\n const now = boardUrl();\n if (now === at || now === undefined) return;\n moved = now;\n child.kill();\n }, 3000);\n child.on('exit', (code) => {\n clearInterval(elsewhere);\n const reason = reasonOf(said);\n const why = moved === undefined ? `vb tail exited ${code}${reason === undefined ? '' : `: ${reason}`}` : `started again on ${moved}`;\n if (again && moved === undefined && Date.now() - started < SOON) return over(why);\n say(`the board went away (${why}): waiting for it to come back`);\n const until = Date.now() + BACK;\n const tried = () => {\n // Asked anew each time: a board started again may be at another URL, and the CLI gets itself a new token for it.\n if (answers()) {\n say(`the board is back on ${boardUrl() ?? \"the team's board\"}: watching ${channel} again`);\n // A board started anew (its folder cleaned) has no channel again.\n made();\n return follow(true);\n }\n if (Date.now() > until) return over(why);\n setTimeout(tried, 2000);\n };\n setTimeout(tried, 2000);\n });\n };\n follow(false);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAM,OAAO;;AAEb,MAAM,OAAO;;AAGb,SAAS,UAA+B;CACtC,MAAM,MACJ,QAAQ,aAAa,UACjB,UACE,cACA;EAAC;EAAc;EAAY;CAA+E,GAC1G,EACE,UAAU,OACZ,CACF,IACA,UAAU,MAAM;EAAC;EAAM;EAAM;EAAQ;EAAM;CAAO,GAAG,EAAE,UAAU,O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MAAM,KAAK;EACb,GAAG,GAAI;EACP,MAAM,GAAG,SAAS,SAAS;GACzB,cAAc,SAAS;GACvB,MAAM,SAAS,SAAS,IAAI;GAC5B,MAAM,MAAM,UAAU,KAAA,IAAY,kBAAkB,OAAO,WAAW,KAAA,IAAY,KAAK,KAAK,aAAa,oBAAoB;GAC7H,IAAI,SAAS,UAAU,KAAA,KAAa,KAAK,IAAI,IAAI,UAAU,MAAM,OAAO,KAAK,GAAG;GAChF,IAAI,wBAAwB,IAAI,+BAA+B;GAC/D,MAAM,QAAQ,KAAK,IAAI,IAAI;GAC3B,MAAM,cAAc;IAElB,IAAI,QAAQ,GAAG;KACb,IAAI,wBAAwB,SAAS,KAAK,mBAAmB,aAAa,QAAQ,OAAO;KAEzF,KAAK;KACL,OAAO,OAAO,IAAI;IACpB;IACA,IAAI,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,GAAG;IACvC,WAAW,OAAO,GAAI;GACxB;GACA,WAAW,OAAO,GAAI;EACxB,CAAC;CACH;CACA,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"watch.js","names":[],"sources":["../../src/cli/watch.ts"],"sourcesContent":["/**\n * `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,\n * then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's monitor (each\n * line an event). A board that goes away (the dev server restarted, and its board with it, maybe on another port) is\n * waited for and followed again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has\n * happened on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.\n * With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits. It ends,\n * too, when the process that started it does: nobody reads its lines then.\n *\n * While it runs the project's Task tab shows who watches (`watcherAt`). Replies the watcher wrote itself are left out\n * where it has a name of its own (BOARD_PROFILE): with none it writes as the person. Exits 0 after `--once`'s event,\n * 2 when idle, 1 when the board went away.\n */\nimport { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport { createInterface } from 'node:readline';\n\nimport { watcherAt } from '#src/plugins/tasks/watchers.ts';\n\nimport { answers, boardIn, boardUrl, deicticDirs, duration, ME, type Message, vbCommand, vbJson, whoami } from './board.ts';\n\n/** What `vb tail --json` prints, one per line. */\ninterface Tailed {\n type: string;\n cursor?: string;\n payload?: {\n id?: number;\n thread?: number;\n re?: number | null;\n text?: string;\n reason?: string;\n labels?: Record<string, string>;\n by?: { actor: string };\n };\n message?: { author?: { handle?: string } };\n}\n\n/** How long a board that went away is waited for: a dev server's restart takes a few seconds. */\nconst BACK = 60_000;\n/** A tail that ends sooner than this after it's started again isn't started a third time: the board isn't the trouble. */\nconst SOON = 10_000;\n\n/** Each process's parent, by ID, asked of the system once: empty where it can't say. */\nfunction parents(): Map<number, number> {\n const run =\n process.platform === 'win32'\n ? spawnSync(\n 'powershell',\n ['-NoProfile', '-Command', 'Get-CimInstance Win32_Process | % { \"$($_.ProcessId) $($_.ParentProcessId)\" }'],\n {\n encoding: 'utf8',\n },\n )\n : spawnSync('ps', ['-A', '-o', 'pid=', '-o', 'ppid='], { encoding: 'utf8' });\n const map = new Map<number, number>();\n for (const line of (run.stdout ?? '').split('\\n')) {\n const [pid, ppid] = line.trim().split(/\\s+/).map(Number);\n if (pid !== undefined && ppid !== undefined && Number.isInteger(pid) && Number.isInteger(ppid)) map.set(pid, ppid);\n }\n return map;\n}\n\n/**\n * The processes above this one's parent, the nearest `count` of them. A runner (`npx`, `pnpm exec`, and on Windows the\n * shell and the bin's `.cmd` shim it runs) sits between the watch and the shell that ran it, and outlives that shell.\n */\nfunction ancestors(count: number): number[] {\n const of = parents();\n const out: number[] = [];\n for (let pid = of.get(process.ppid); pid !== undefined && pid > 1 && out.length < count && !out.includes(pid); pid = of.get(pid))\n out.push(pid);\n return out;\n}\n\n/** Whether a process is gone. On Windows a dead parent's ID stays a child's `ppid`, so the system is asked. */\nfunction gone(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return false;\n } catch (e) {\n return (e as { code?: string }).code === 'ESRCH';\n }\n}\n\n/** What `vb` said as it failed: its JSON's `message`, or its last line. */\nfunction reasonOf(said: string): string | undefined {\n const last = said.trim().split('\\n').at(-1)?.trim();\n if (last === undefined || last === '') return undefined;\n try {\n const { message } = JSON.parse(last) as { message?: unknown };\n return typeof message === 'string' ? message : last;\n } catch {\n return last;\n }\n}\n\nexport function run(channel: string, values: { idle: string; once?: boolean; label?: string[] }): void {\n const labels = (values.label ?? []).flatMap((l) => ['--label', l]);\n const idle = duration(values.idle);\n const say = (line: string) => console.log(line.replace(/\\s+/g, ' ').trim());\n const first = (text: string) => (text.split('\\n---')[0] ?? '').trim().slice(0, 160);\n // A task in a line: its words and where, not its labels, which `task` reads out.\n const about = (text: string, labels: Record<string, string> | undefined) => {\n const label = (key: string) => labels?.[key];\n const at = label('deictic.at');\n const page = label('deictic.page');\n const project = label('deictic.project');\n return `\"${first(text)}\"${at ? ` at ${at}` : ''}${page ? ` on ${page}` : ''}${project ? ` in ${project}` : ''}`;\n };\n\n // A board nothing has posted to yet has no channel, and won't list or follow one it hasn't: made here, as the first\n // task would make it. One that's there stays as it is; where the board won't let this make one, `vb tasks` says so.\n const made = () => {\n const [command, argv, options] = vbCommand(['channels', 'create', channel]);\n spawnSync(command, argv, options);\n };\n made();\n // Where the channel is now, taken before what's ready is: followed from here, nothing posted between is missed, and\n // a tail started again after the board went away follows on from what this one heard, never from a list taken earlier.\n let cursor = vbJson<{ cursor: string }>(['read', channel, '--limit', '1']).cursor;\n const ready = vbJson<{ tasks: { message: Message }[] }>(['tasks', channel, '--state', 'ready', ...labels]).tasks.map((t) => t.message);\n const me = whoami();\n // In the `.deictic/` whose board this is, or in each one near here where the board is the environment's.\n const url = boardUrl();\n const dirs = deicticDirs();\n const own = dirs.filter((dir) => boardIn(dir) === url);\n const unseen = watcherAt(own.length > 0 ? own : dirs, me.profile ?? me.name ?? me.handle ?? me.actor, channel);\n let tail: ChildProcess | undefined;\n const end = (code: number) => {\n unseen();\n tail?.removeAllListeners('exit');\n tail?.kill();\n process.exit(code);\n };\n // Stopped by its monitor, where the system says so: the page isn't left thinking someone watches.\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) process.on(signal, () => end(0));\n\n // Whoever started the watch reads its lines. With that gone (a session that ended and left the watch behind) no one\n // does, and the page mustn't go on saying an agent watches. Run through a runner, the shell is a few processes up,\n // so those are watched too: any gone, and the watch ends. A dead parent shows as another parent's ID, except on\n // Windows, where the system is asked whether it's still a process.\n const parent = process.ppid;\n const above = ancestors(3);\n const orphaned = () => process.ppid !== parent || gone(parent) || above.some(gone);\n setInterval(() => orphaned() && end(0), 5000);\n\n say(`watching ${channel} on ${url ?? \"the team's board\"} as ${me.handle ?? me.actor}`);\n // With no profile (an agent `profileOf` doesn't know), the person's replies and the watcher's own are one actor's:\n // none can be left out.\n if (me.profile === null) {\n say(\n `you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`,\n );\n }\n // The tasks said, by ID: one made after the cursor above and listed as ready is said once.\n const told = new Set(ready.map((m) => String(m.id)));\n for (const m of ready) say(`ready: #${m.id} ${about(m.text, m.labels)}. Read it: ${ME} task ${m.id}`);\n if (values.once && ready.length > 0) end(0);\n\n /** One thing to act on: all `--once` waits for. */\n const event = (line: string) => {\n say(line);\n if (values.once) end(0);\n };\n\n // Anything on the channel puts the end off, the watcher's own claims and replies too: it's being worked.\n let quiet: ReturnType<typeof setTimeout> | undefined;\n const heard = () => {\n clearTimeout(quiet);\n quiet = setTimeout(() => {\n say(\n `idle: nothing on ${channel} in ${values.idle}, so the watch is over. Don't start it again by yourself: tell the person in a line that you've stopped watching, and watch again when they ask. Only if you're working a task now, start it once more when that's done.`,\n );\n end(2);\n }, idle);\n };\n heard();\n\n // What the board says about each thread: its root's first line and where, to name it when a task is made.\n const roots = new Map<number, string>();\n const heardOf = (line: string) => {\n let e: Tailed;\n try {\n e = JSON.parse(line) as Tailed;\n } catch {\n return;\n }\n // The last event heard, which a tail started again follows from: nothing left while the board was away is missed.\n if (e.cursor !== undefined) cursor = e.cursor;\n heard();\n const p = e.payload ?? {};\n if (e.type === 'message.posted' && p.re === null && p.thread !== undefined) roots.set(p.thread, about(p.text ?? '', p.labels));\n if (e.type === 'task.created' && !told.has(String(p.id)))\n event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ''}. Read it: ${ME} task ${p.id}`);\n if (e.type === 'message.posted' && p.re !== null && p.re !== undefined) {\n if (me.profile !== null && p.by?.actor === me.actor) return;\n const by = e.message?.author?.handle ?? p.by?.actor ?? 'someone';\n event(`reply on #${p.re} by ${by}: ${first(p.text ?? '')}`);\n }\n if (e.type === 'task.canceled')\n event(`task #${p.id} canceled: ${p.reason ?? ''}. Stop work on it, and put back what you changed for it.`);\n };\n\n const over = (why: string) => {\n say(`watch ended (${why}): start it again`);\n end(1);\n };\n\n /** Follows the channel from `cursor`, and again when the board comes back after going away. */\n const follow = (again: boolean) => {\n const started = Date.now();\n const [command, argv, options] = vbCommand(['tail', channel, ...labels, '--after', cursor, '--json']);\n const child = spawn(command, argv, { env: options.env, shell: options.shell, stdio: ['ignore', 'pipe', 'pipe'] });\n tail = child;\n createInterface({ input: child.stdout }).on('line', heardOf);\n // What it said as it ended goes in the watch's own line: a board started again refuses the old token, as expected,\n // and the CLI's raw error isn't something for an agent to act on.\n let said = '';\n child.stderr.on('data', (chunk: Buffer) => (said += chunk.toString()));\n // A dev server started again may start its board on another port: the tail would go on asking the old one for\n // ever, so it's ended once the project's `.deictic/board.json` names another, and followed there.\n const at = boardUrl();\n let moved: string | undefined;\n const elsewhere = setInterval(() => {\n const now = boardUrl();\n if (now === at || now === undefined) return;\n moved = now;\n child.kill();\n }, 3000);\n child.on('exit', (code) => {\n clearInterval(elsewhere);\n const reason = reasonOf(said);\n const why = moved === undefined ? `vb tail exited ${code}${reason === undefined ? '' : `: ${reason}`}` : `started again on ${moved}`;\n if (again && moved === undefined && Date.now() - started < SOON) return over(why);\n say(`the board went away (${why}): waiting for it to come back`);\n const until = Date.now() + BACK;\n const tried = () => {\n // Asked anew each time: a board started again may be at another URL, and the CLI gets itself a new token for it.\n if (answers()) {\n say(`the board is back on ${boardUrl() ?? \"the team's board\"}: watching ${channel} again`);\n // A board started anew (its folder cleaned) has no channel again.\n made();\n return follow(true);\n }\n if (Date.now() > until) return over(why);\n setTimeout(tried, 2000);\n };\n setTimeout(tried, 2000);\n });\n };\n follow(false);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAM,OAAO;;AAEb,MAAM,OAAO;;AAGb,SAAS,UAA+B;CACtC,MAAM,MACJ,QAAQ,aAAa,UACjB,UACE,cACA;EAAC;EAAc;EAAY;CAA+E,GAC1G,EACE,UAAU,OACZ,CACF,IACA,UAAU,MAAM;EAAC;EAAM;EAAM;EAAQ;EAAM;CAAO,GAAG,EAAE,UAAU,OAAO,CAAC;CAC/E,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,IAAI,UAAU,GAAA,CAAI,MAAM,IAAI,GAAG;EACjD,MAAM,CAAC,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,MAAM;EACvD,IAAI,QAAQ,KAAA,KAAa,SAAS,KAAA,KAAa,OAAO,UAAU,GAAG,KAAK,OAAO,UAAU,IAAI,GAAG,IAAI,IAAI,KAAK,IAAI;CACnH;CACA,OAAO;AACT;;;;;AAMA,SAAS,UAAU,OAAyB;CAC1C,MAAM,KAAK,QAAQ;CACnB,MAAM,MAAgB,CAAC;CACvB,KAAK,IAAI,MAAM,GAAG,IAAI,QAAQ,IAAI,GAAG,QAAQ,KAAA,KAAa,MAAM,KAAK,IAAI,SAAS,SAAS,CAAC,IAAI,SAAS,GAAG,GAAG,MAAM,GAAG,IAAI,GAAG,GAC7H,IAAI,KAAK,GAAG;CACd,OAAO;AACT;;AAGA,SAAS,KAAK,KAAsB;CAClC,IAAI;E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;CACA,OAAO,KAAK;AACd"}
|
package/dist/tailwind/index.js
CHANGED
|
@@ -367,7 +367,9 @@ function tailwind(options = {}) {
|
|
|
367
367
|
},
|
|
368
368
|
css: async (request, context) => Response.json({ css: (await catalog(context))?.css(await asked(request)) ?? "" })
|
|
369
369
|
},
|
|
370
|
-
read(
|
|
370
|
+
read(source) {
|
|
371
|
+
if (source instanceof Refusal) throw source;
|
|
372
|
+
const { code, element, program } = source;
|
|
371
373
|
const spot = spotOf(element, code, helpers);
|
|
372
374
|
if (spot.kind === "fixed") return {
|
|
373
375
|
editable: false,
|
|
@@ -384,7 +386,9 @@ function tailwind(options = {}) {
|
|
|
384
386
|
...others === void 0 ? {} : { others }
|
|
385
387
|
};
|
|
386
388
|
},
|
|
387
|
-
apply(
|
|
389
|
+
apply(source, _target, { classes, at }) {
|
|
390
|
+
if (source instanceof Refusal) throw source;
|
|
391
|
+
const { file, code, element, program } = source;
|
|
388
392
|
const list = classes.trim().split(/\s+/).filter(Boolean).join(" ");
|
|
389
393
|
const spot = spotOf(element, code, helpers);
|
|
390
394
|
if (spot.kind === "fixed") throw new Refusal("this class list is built at runtime: edit it in the editor");
|