deictic 0.3.0 → 0.4.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 +31 -19
- package/README.md +6 -26
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.js +1 -1
- package/dist/annotations/index.d.ts +2 -101
- package/dist/annotations/index.js +1 -22
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +1 -10
- package/dist/logs/client.d.ts +1 -1
- package/dist/logs/client.js +1 -1
- package/dist/logs/index.d.ts +2 -18
- package/dist/logs/index.js +1 -21
- package/dist/network/client.d.ts +1 -1
- package/dist/network/client.js +1 -1
- package/dist/network/index.d.ts +1 -1
- package/dist/network/index.js +1 -37
- package/dist/recommended/index.d.ts +7 -7
- package/dist/recommended/index.js +1 -26
- package/dist/recordings/client.d.ts +1 -1
- package/dist/recordings/client.js +1 -1
- package/dist/recordings/index.d.ts +1 -1
- package/dist/screenshots/client.d.ts +1 -1
- package/dist/screenshots/client.js +1 -108
- package/dist/screenshots/dom.d.ts +1 -1
- package/dist/screenshots/dom.js +1 -1
- package/dist/screenshots/index.d.ts +1 -1
- package/dist/screenshots/index.js +1 -98
- package/dist/screenshots/rrweb.d.ts +2 -1
- package/dist/screenshots/rrweb.d.ts.map +1 -1
- package/dist/screenshots/rrweb.js +6 -2
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/shared/annotations.js +22 -0
- package/dist/shared/annotations.js.map +1 -0
- package/dist/shared/board.js +190 -0
- package/dist/shared/board.js.map +1 -0
- package/dist/shared/client.js +108 -0
- package/dist/{screenshots → shared}/client.js.map +1 -1
- package/dist/shared/endpoints.js +4 -1
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +156 -0
- package/dist/shared/find.js.map +1 -0
- package/dist/shared/frame.js +75 -0
- package/dist/shared/frame.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +85 -84
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index3.d.ts +83 -89
- package/dist/shared/index3.d.ts.map +1 -1
- package/dist/shared/index4.d.ts +98 -50
- package/dist/shared/index4.d.ts.map +1 -1
- package/dist/shared/index5.d.ts +13 -215
- package/dist/shared/index5.d.ts.map +1 -1
- package/dist/shared/index6.d.ts +55 -61
- package/dist/shared/index6.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +224 -0
- package/dist/shared/index7.d.ts.map +1 -0
- package/dist/shared/index8.d.ts +52 -0
- package/dist/shared/index8.d.ts.map +1 -0
- package/dist/shared/index9.d.ts +70 -0
- package/dist/shared/index9.d.ts.map +1 -0
- package/dist/shared/init.js +472 -0
- package/dist/shared/init.js.map +1 -0
- package/dist/shared/local.js +165 -0
- package/dist/shared/local.js.map +1 -0
- package/dist/shared/logs.js +22 -0
- package/dist/shared/logs.js.map +1 -0
- package/dist/shared/network.js +39 -0
- package/dist/shared/network.js.map +1 -0
- package/dist/shared/packages.js +125 -0
- package/dist/shared/packages.js.map +1 -0
- package/dist/shared/playwright.js +36 -9
- package/dist/shared/playwright.js.map +1 -1
- package/dist/shared/recommended.js +26 -0
- package/dist/shared/recommended.js.map +1 -0
- package/dist/shared/recording.js +316 -0
- package/dist/shared/recording.js.map +1 -0
- package/dist/shared/recordings.js +2 -1
- package/dist/shared/recordings.js.map +1 -1
- package/dist/shared/screenshots.js +108 -0
- package/dist/shared/screenshots.js.map +1 -0
- package/dist/shared/src.js +10 -0
- package/dist/shared/src.js.map +1 -0
- package/dist/shared/task.js +108 -0
- package/dist/shared/task.js.map +1 -0
- package/dist/shared/tasks.js +33 -191
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/transcribe.js +128 -0
- package/dist/shared/transcribe.js.map +1 -0
- package/dist/shared/vb.js +13 -0
- package/dist/shared/vb.js.map +1 -0
- package/dist/shared/vite.d.ts +16 -0
- package/dist/shared/vite.d.ts.map +1 -0
- package/dist/shared/vite.js +61 -0
- package/dist/shared/vite.js.map +1 -0
- package/dist/shared/voice.js +84 -0
- package/dist/{voice/index.js.map → shared/voice.js.map} +1 -1
- package/dist/shared/voice2.js +90 -0
- package/dist/shared/voice2.js.map +1 -0
- package/dist/shared/watch.js +209 -0
- package/dist/shared/watch.js.map +1 -0
- package/dist/shared/watchers.js +62 -0
- package/dist/shared/watchers.js.map +1 -0
- package/dist/tailwind/client.d.ts +1 -1
- package/dist/tailwind/client.js +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +1 -1
- package/dist/tasks/client.d.ts +1 -1
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +45 -8
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +3 -1
- package/dist/vite.d.ts +2 -15
- package/dist/vite.js +2 -60
- package/dist/voice/client.d.ts +1 -1
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +2 -52
- package/dist/voice/index.js +1 -84
- package/package.json +6 -9
- package/skills/deictic/SKILL.md +27 -42
- package/skills/deictic/references/recordings.md +9 -108
- package/skills/deictic/references/tasks.md +21 -107
- package/skills/deictic/references/watch.md +13 -66
- package/src/cli/board.ts +204 -0
- package/src/cli/bun.ts +133 -0
- package/src/cli/edit.ts +56 -0
- package/src/cli/find.ts +147 -0
- package/src/cli/frame.ts +90 -0
- package/src/cli/init.ts +388 -0
- package/src/cli/recording.ts +383 -0
- package/src/cli/task.ts +126 -0
- package/src/cli/transcribe.ts +129 -0
- package/src/cli/vb.ts +11 -0
- package/src/cli/voice.ts +59 -0
- package/src/cli/watch.ts +221 -0
- package/src/cli.ts +37 -0
- package/src/index.ts +5 -0
- package/src/plugins/logs/index.ts +1 -0
- package/src/plugins/network/index.ts +1 -0
- package/src/plugins/recordings/index.ts +1 -0
- package/src/plugins/screenshots/client.ts +3 -2
- package/src/plugins/screenshots/index.ts +10 -3
- package/src/plugins/screenshots/playwright.ts +34 -7
- package/src/plugins/screenshots/rrweb.ts +5 -1
- package/src/plugins/tasks/client.ts +62 -7
- package/src/plugins/tasks/index.ts +41 -20
- package/src/plugins/tasks/local.ts +19 -6
- package/src/plugins/tasks/watchers.ts +41 -6
- package/src/tools/endpoints.ts +3 -0
- package/src/tools/packages.ts +107 -0
- package/dist/annotations/index.d.ts.map +0 -1
- package/dist/annotations/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logs/index.d.ts.map +0 -1
- package/dist/logs/index.js.map +0 -1
- package/dist/network/index.js.map +0 -1
- package/dist/recommended/index.js.map +0 -1
- package/dist/screenshots/index.js.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/vite.js.map +0 -1
- package/dist/voice/index.d.ts.map +0 -1
- package/skills/deictic/references/install.md +0 -103
- package/skills/deictic/scripts/frame.mjs +0 -62
- package/skills/deictic/scripts/lib.mjs +0 -277
- package/skills/deictic/scripts/recording.mjs +0 -266
- package/skills/deictic/scripts/task.mjs +0 -113
- package/skills/deictic/scripts/transcribe.mjs +0 -93
- package/skills/deictic/scripts/vb.mjs +0 -12
- package/skills/deictic/scripts/voice.mjs +0 -50
- package/skills/deictic/scripts/watch.mjs +0 -115
package/dist/shared/tasks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","names":[],"sources":["../../src/plugins/tasks/local.ts","../../src/plugins/tasks/watchers.ts","../../src/plugins/tasks/index.ts"],"sourcesContent":["/**\n * The board tasks go to when nothing names one: `vb serve`, `@vercel/board`'s own, started with the dev server\n * and stopped with it, its log in `.deictic/board`. So Alt-click adds a task with nothing else to run, and\n * whoever works the tasks reaches the same board at the URL `.deictic/board.json` holds.\n */\nimport { type ChildProcess, spawn } from 'node:child_process';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { createServer } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\n\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** `vb serve`'s own default, so `http://127.0.0.1:4100/api/board` is the board wherever it's free. */\nconst PORT = 4100;\n/** How long a board may take to answer after it's started, or to be gone after it's stopped. */\nconst PATIENCE = 20_000;\n\nexport interface LocalOptions {\n /**\n * The port it listens on, on 127.0.0.1. By default 4100, or a free one where that's taken. One named here is\n * the only one tried: taken, the board doesn't start.\n */\n port?: number;\n /** Where its log is kept, from the project's root: `.deictic/board` by default. */\n dir?: string;\n /** `false` for no pages of the board's own (its inspector): the panel then links its tasks nowhere. */\n inspect?: boolean;\n /** More arguments for `vb serve`, as it takes them: `['--tailscale', 'box.tailnet.ts.net']`. */\n args?: string[];\n}\n\n/** What `local()` answers, for the tasks plugin's `board` option. */\nexport interface LocalBoard {\n local: LocalOptions;\n}\n\n/**\n * The project's own board on this machine, as the tasks plugin's `board`: what it uses anyway with no\n * `BOARD_URL`, here whatever the environment says, and with options.\n */\nexport const local = (options: LocalOptions = {}): LocalBoard => ({ local: options });\n\n/** What `.deictic/board.json` holds: the board the dev server started, for whoever works its tasks. */\nexport interface Running {\n url: string;\n pid: number;\n /** The options it was started with, as one string to compare: other ones need another board. */\n as: string;\n}\n\nexport interface Local {\n url: string;\n /** Whether this call started it, rather than found it running. */\n fresh: boolean;\n /** Where its log is. */\n dir: string;\n /** Stops the board, where this call started it: one found running is left to what started it. */\n stop: () => void;\n}\n\n/**\n * The project's own board, started unless it's running: a dev server that restarts in its process (Vite, when\n * its config changes) asks again, and so does a second dev server of the same project, and two boards mustn't\n * write one log. One running with other options is stopped first, for the same reason.\n */\nexport async function localBoard(root: string, options: LocalOptions = {}): Promise<Local> {\n const file = keptIn(root, 'board.json');\n const dir = options.dir === undefined ? keptIn(root, 'board') : resolve(root, options.dir);\n const flags = [...(options.inspect === false ? ['--no-inspect'] : []), ...(options.args ?? [])];\n const as = JSON.stringify([options.port ?? null, dir, flags]);\n\n const running = read(file);\n if (running !== undefined && alive(running.pid) && (await answers(running.url))) {\n if (running.as === as) return { url: running.url, fresh: false, dir, stop: () => {} };\n process.kill(running.pid);\n await gone(running.url);\n }\n\n const port = options.port ?? (await free(PORT));\n const url = `http://127.0.0.1:${port}/api/board`;\n const child = spawn(process.execPath, [cli(), 'serve', '--port', String(port), '--no-open', '--dir', dir, ...flags], {\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n let said = '';\n child.stderr.on('data', (chunk: Buffer) => (said += chunk.toString()));\n const stop = () => void child.kill();\n process.once('exit', stop);\n\n try {\n await started(child, url);\n } catch (e) {\n stop();\n const fix = options.port === undefined ? 'set BOARD_URL to a board of your own' : `is port ${port} taken? name another, or none`;\n throw new Error(`the board didn't start (${said.trim() || (e as Error).message}): ${fix}`, { cause: e });\n }\n writeFileSync(file, `${JSON.stringify({ url, pid: child.pid, as }, null, 2)}\\n`);\n // The board ends with this process, and mustn't be what keeps it from ending.\n child.unref();\n (child.stderr as { unref?: () => void }).unref?.();\n return { url, fresh: true, dir, stop };\n}\n\n/** `vb`'s script in the project's `@vercel/board`, run with this process's own runtime: no shim, no shell. */\nfunction cli(): string {\n return join(dirname(createRequire(import.meta.url).resolve('@vercel/board/package.json')), 'dist', 'cli.mjs');\n}\n\nfunction read(file: string): Running | undefined {\n try {\n const { url, pid, as } = JSON.parse(readFileSync(file, 'utf8')) as Partial<Running>;\n return typeof url === 'string' && typeof pid === 'number' ? { url, pid, as: as ?? '' } : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction alive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Whether a board answers there: its discovery, which names its own URL. */\nasync function answers(url: string): Promise<boolean> {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(2000) });\n return res.ok && ((await res.json()) as { url?: unknown }).url === url;\n } catch {\n return false;\n }\n}\n\n/** `wanted` where nothing listens on it (another project's board may), or else a port the system picks. */\nasync function free(wanted: number): Promise<number> {\n const listen = (port: number) =>\n new Promise<number>((done, failed) => {\n const server = createServer();\n server.once('error', failed);\n server.listen(port, '127.0.0.1', () => {\n const { port: got } = server.address() as { port: number };\n server.close(() => done(got));\n });\n });\n return listen(wanted).catch(() => listen(0));\n}\n\nconst nap = () => new Promise((wake) => setTimeout(wake, 100));\n\n/** Waits for the board to answer, or for its process to end without having. */\nasync function started(child: ChildProcess, url: string): Promise<void> {\n let ended: string | undefined;\n child.once('error', (e) => (ended = e.message));\n child.once('exit', (code) => (ended ??= `exit ${code}`));\n for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) {\n if (ended !== undefined) throw new Error(ended);\n if (await answers(url)) return;\n }\n throw new Error(`no answer at ${url} after ${PATIENCE / 1000}s`);\n}\n\n/** Waits for a stopped board to let go of its port and its log. */\nasync function gone(url: string): Promise<void> {\n for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) if (!(await answers(url))) return;\n\n throw new Error(`the board at ${url} is still running: stop it, then restart the dev server`);\n}\n","/**\n * Who watches the channel for tasks. A board can't say (it knows who claimed a task, not who's listening), so a\n * watch says it itself: the skill's `watch.mjs` keeps a file under `.deictic/watchers` while it runs, written\n * again every 20 seconds, and the Task tab shows the names, so a person knows whether a task they add is taken up.\n * (An agent holding a claim is one more, which the board does say: `agentsOf`, in `index.ts`.)\n */\nimport { readdirSync, readFileSync, rmSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** How old a watch's last word may be: three of its beats, as one killed says nothing more. */\nconst FRESH = 60_000;\n\n/** The names watching `channel` from this project now, each once, in order. */\nexport function watchersOf(root: string, channel: string, now = Date.now()): string[] {\n const dir = keptIn(root, 'watchers');\n let files: string[];\n try {\n files = readdirSync(dir);\n } catch {\n return [];\n }\n const names = new Set<string>();\n for (const file of files) {\n const path = join(dir, file);\n try {\n const { name, channel: of, at } = JSON.parse(readFileSync(path, 'utf8')) as { name?: unknown; channel?: unknown; at?: unknown };\n if (typeof at !== 'number' || now - at > FRESH) rmSync(path, { force: true });\n else if (of === channel && typeof name === 'string') names.add(name);\n } catch {\n // Half written: whole by the next read.\n }\n }\n return [...names].sort();\n}\n","/**\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 /** 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 (the skill's `watch.mjs`) 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, each a `file:line`: where the file\n * before it is used. A shared component's line says nothing of which use of it this is, and 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 // 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 for (const { message } of [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks]) {\n const state = message.task?.state ?? 'ready';\n if (state === 'canceled') continue;\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 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 (`watch.mjs --once`).\n const working = await agentsOf(\n team,\n held.tasks.flatMap(({ message }) => message.task?.claim ?? []),\n );\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/** `Source: src/ui/label.tsx:6 ← src/Field.tsx:20 ← src/Panel.tsx:880`: from the element's line out, as the page said it. */\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 = 5;\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 agents holding these claims, by name, while their leases run. An actor's ID isn't read for it (each board\n * writes them its own way), so the board is asked who they are, and only when a claim is held. A person holding\n * one is left out: they needn't be told they're there. (Whatever else holds one works tasks: an agent, a workflow.)\n */\nasync function agentsOf(team: TaskBoard, claims: { actor: string; until: string }[]): Promise<string[]> {\n const holders = new Set(claims.filter((claim) => Date.parse(claim.until) > Date.now()).map((claim) => claim.actor));\n if (holders.size === 0) return [];\n // By ID, which a board from 0.54 answers without listing everyone; an older one lists them all, so they're picked out here too.\n return (await team.actors({ id: [...holders] }))\n .filter((actor) => holders.has(actor.id) && 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\nexport default tasks;\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,OAAO;;AAEb,MAAM,WAAW;;;;;AAyBjB,MAAa,SAAS,UAAwB,CAAC,OAAmB,EAAE,OAAO,QAAQ;;;;;;AAyBnF,eAAsB,WAAW,MAAc,UAAwB,CAAC,GAAmB;CACzF,MAAM,OAAO,OAAO,MAAM,YAAY;CACtC,MAAM,MAAM,QAAQ,QAAQ,KAAA,IAAY,OAAO,MAAM,OAAO,IAAI,QAAQ,MAAM,QAAQ,GAAG;CACzF,MAAM,QAAQ,CAAC,GAAI,QAAQ,YAAY,QAAQ,CAAC,cAAc,IAAI,CAAC,GAAI,GAAI,QAAQ,QAAQ,CAAC,CAAE;CAC9F,MAAM,KAAK,KAAK,UAAU;EAAC,QAAQ,QAAQ;EAAM;EAAK;CAAK,CAAC;CAE5D,MAAM,UAAU,KAAK,IAAI;CACzB,IAAI,YAAY,KAAA,KAAa,MAAM,QAAQ,GAAG,KAAM,MAAM,QAAQ,QAAQ,GAAG,GAAI;EAC/E,IAAI,QAAQ,OAAO,IAAI,OAAO;GAAE,KAAK,QAAQ;GAAK,OAAO;GAAO;GAAK,YA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cesContent":["/**\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\nexport default tasks;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmNA,MAAM,KAAK;AACX,MAAM,OAAO;;AAEb,MAAM,OAAO;AACb,MAAM,uBAAO,IAAI,IAAI;CAAC;CAAW;CAAS;AAAS,CAAC;AAEpD,SAAgB,MAAM,UAAwB,CAAC,GAAG;CAChD,MAAM,UAAU,QAAQ,WAAW;CACnC,IAAI;CACJ,IAAI;CACJ,MAAM,MAAM,QAAQ,UAA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I,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"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { a as clock, l as fail, t as ME, u as parseArgs } from "./board.js";
|
|
8
|
+
import { i as voiceClips, t as ffmpeg } from "./find.js";
|
|
9
|
+
// src/cli/transcribe.ts
|
|
10
|
+
/**
|
|
11
|
+
* `deictic transcribe`: what was said in voice clips, with when: Whisper on this machine, through transformers.js.
|
|
12
|
+
* For a recording, the times are the recording's, to line up with its timeline. Nothing leaves the machine once the
|
|
13
|
+
* model is downloaded.
|
|
14
|
+
*
|
|
15
|
+
* `--setup` puts @huggingface/transformers and the model in ~/.cache/deictic/transcribe (DEICTIC_CACHE moves it),
|
|
16
|
+
* outside the project; an agent asks the person first. Models: tiny (~40 MB), base (~77 MB, the default), small
|
|
17
|
+
* (~250 MB), large-v3-turbo (~800 MB), or any ONNX Whisper on Hugging Face by its ID. Needs ffmpeg on the PATH.
|
|
18
|
+
*/
|
|
19
|
+
const usage = `transcribe <task | replay URL | recording ID | file | clip ID> [--model base] [--language en] [--json] what was said
|
|
20
|
+
transcribe --setup [--model base] installs it, outside the project: ask the person first`;
|
|
21
|
+
const TRANSFORMERS = "@huggingface/transformers@4.3.2";
|
|
22
|
+
const MODELS = {
|
|
23
|
+
tiny: "whisper-tiny",
|
|
24
|
+
base: "whisper-base",
|
|
25
|
+
small: "whisper-small",
|
|
26
|
+
"large-v3-turbo": "whisper-large-v3-turbo"
|
|
27
|
+
};
|
|
28
|
+
async function run(args) {
|
|
29
|
+
const { values, positionals } = parseArgs(args, {
|
|
30
|
+
setup: { type: "boolean" },
|
|
31
|
+
json: { type: "boolean" },
|
|
32
|
+
model: {
|
|
33
|
+
type: "string",
|
|
34
|
+
default: "base"
|
|
35
|
+
},
|
|
36
|
+
language: { type: "string" }
|
|
37
|
+
});
|
|
38
|
+
const size = values.model;
|
|
39
|
+
const named = MODELS[size];
|
|
40
|
+
if (!size.includes("/") && named === void 0) fail(`--model is one of ${Object.keys(MODELS).join(", ")}, or a model ID`);
|
|
41
|
+
const model = named === void 0 ? size : `onnx-community/${named}`;
|
|
42
|
+
const dir = join(process.env.DEICTIC_CACHE ?? join(homedir(), ".cache", "deictic"), "transcribe");
|
|
43
|
+
const models = join(dir, "models");
|
|
44
|
+
const installed = existsSync(join(dir, "node_modules", "@huggingface", "transformers", "package.json"));
|
|
45
|
+
const downloaded = existsSync(join(models, ...model.split("/")));
|
|
46
|
+
const again = `${ME} transcribe`;
|
|
47
|
+
const sized = size === "base" ? "" : ` --model ${size}`;
|
|
48
|
+
if (values.setup) {
|
|
49
|
+
mkdirSync(dir, { recursive: true });
|
|
50
|
+
if (!existsSync(join(dir, "package.json"))) writeFileSync(join(dir, "package.json"), "{ \"private\": true }\n");
|
|
51
|
+
if (!installed) {
|
|
52
|
+
console.log(`Installing ${TRANSFORMERS} in ${dir}…`);
|
|
53
|
+
const windows = process.platform === "win32";
|
|
54
|
+
const npm = [
|
|
55
|
+
"install",
|
|
56
|
+
"--prefix",
|
|
57
|
+
dir,
|
|
58
|
+
"--no-audit",
|
|
59
|
+
"--no-fund",
|
|
60
|
+
"--save-exact",
|
|
61
|
+
TRANSFORMERS
|
|
62
|
+
];
|
|
63
|
+
const run = spawnSync(windows ? `npm ${npm.map((a) => `"${a}"`).join(" ")}` : "npm", windows ? [] : npm, {
|
|
64
|
+
stdio: "inherit",
|
|
65
|
+
shell: windows
|
|
66
|
+
});
|
|
67
|
+
if (run.status !== 0) fail(`npm install failed (${run.error?.message ?? `exit ${run.status}`}).`);
|
|
68
|
+
}
|
|
69
|
+
} else if (!installed || !downloaded) fail(`Local transcription isn't set up${installed ? ` with the ${size} model` : ""}. Ask the person first: it downloads ${installed ? "" : `${TRANSFORMERS} (with ONNX Runtime, ~470 MB) and `}Whisper ${size} into ${dir}, outside the project; after that, audio is transcribed on this machine. On yes: ${again} --setup${sized} (--model small hears better, ~250 MB more). On no, don't ask again this session: work from ${ME} voice's times.`);
|
|
70
|
+
const entry = createRequire(join(dir, "package.json")).resolve("@huggingface/transformers");
|
|
71
|
+
const transformers = await import(pathToFileURL(entry).href);
|
|
72
|
+
transformers.env.cacheDir = models;
|
|
73
|
+
transformers.env.allowRemoteModels = values.setup === true;
|
|
74
|
+
if (values.setup) console.log(`Downloading ${model} (quantized) into ${models}…`);
|
|
75
|
+
const asr = await transformers.pipeline("automatic-speech-recognition", model, { dtype: "q8" });
|
|
76
|
+
if (values.setup) {
|
|
77
|
+
console.log(`Ready: ${again} <task>${sized}`);
|
|
78
|
+
if (positionals[0] === void 0) return;
|
|
79
|
+
}
|
|
80
|
+
const results = [];
|
|
81
|
+
for (const c of await voiceClips(positionals[0])) {
|
|
82
|
+
const raw = ffmpeg([
|
|
83
|
+
"-loglevel",
|
|
84
|
+
"error",
|
|
85
|
+
"-i",
|
|
86
|
+
c.file,
|
|
87
|
+
"-f",
|
|
88
|
+
"f32le",
|
|
89
|
+
"-ac",
|
|
90
|
+
"1",
|
|
91
|
+
"-ar",
|
|
92
|
+
"16000",
|
|
93
|
+
"-"
|
|
94
|
+
]).stdout;
|
|
95
|
+
const audio = new Float32Array(raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength - raw.byteLength % 4));
|
|
96
|
+
const seconds = audio.length / 16e3;
|
|
97
|
+
const out = await asr(audio, {
|
|
98
|
+
return_timestamps: true,
|
|
99
|
+
chunk_length_s: 30,
|
|
100
|
+
stride_length_s: 5,
|
|
101
|
+
...values.language === void 0 ? {} : { language: values.language }
|
|
102
|
+
});
|
|
103
|
+
const said = (out.chunks ?? [{
|
|
104
|
+
timestamp: [0, seconds],
|
|
105
|
+
text: out.text
|
|
106
|
+
}]).map(({ timestamp: [from, to], text }) => ({
|
|
107
|
+
from: c.at + from * 1e3,
|
|
108
|
+
to: c.at + (to ?? seconds) * 1e3,
|
|
109
|
+
text: text.trim()
|
|
110
|
+
}));
|
|
111
|
+
results.push({
|
|
112
|
+
...c,
|
|
113
|
+
text: out.text.trim(),
|
|
114
|
+
said
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (values.json) {
|
|
118
|
+
console.log(JSON.stringify(results, null, 2));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
for (const r of results) {
|
|
122
|
+
console.log(`clip ${r.id} (${r.recording === void 0 ? "a voice note" : `in recording ${r.recording}, from ${clock(r.at)}`}):`);
|
|
123
|
+
for (const s of r.said) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} ${s.text}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export { run, usage };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=transcribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcribe.js","names":[],"sources":["../../src/cli/transcribe.ts"],"sourcesContent":["/**\n * `deictic transcribe`: what was said in voice clips, with when: Whisper on this machine, through transformers.js.\n * For a recording, the times are the recording's, to line up with its timeline. Nothing leaves the machine once the\n * model is downloaded.\n *\n * `--setup` puts @huggingface/transformers and the model in ~/.cache/deictic/transcribe (DEICTIC_CACHE moves it),\n * outside the project; an agent asks the person first. Models: tiny (~40 MB), base (~77 MB, the default), small\n * (~250 MB), large-v3-turbo (~800 MB), or any ONNX Whisper on Hugging Face by its ID. Needs ffmpeg on the PATH.\n */\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { clock, fail, ME, parseArgs } from './board.ts';\nimport { ffmpeg, voiceClips } from './find.ts';\n\nexport const usage = `transcribe <task | replay URL | recording ID | file | clip ID> [--model base] [--language en] [--json] what was said\n transcribe --setup [--model base] installs it, outside the project: ask the person first`;\n\n// Pinned, so a setup installs what this was written against; move it on deliberately.\nconst TRANSFORMERS = '@huggingface/transformers@4.3.2';\nconst MODELS: Record<string, string> = {\n tiny: 'whisper-tiny',\n base: 'whisper-base',\n small: 'whisper-small',\n 'large-v3-turbo': 'whisper-large-v3-turbo',\n};\n\n/** What of transformers.js this uses: its type isn't the project's, as it's installed outside it. */\ninterface Transformers {\n env: { cacheDir: string; allowRemoteModels: boolean };\n pipeline(\n task: 'automatic-speech-recognition',\n model: string,\n options: { dtype: string },\n ): Promise<\n (\n audio: Float32Array,\n options: Record<string, unknown>,\n ) => Promise<{ text: string; chunks?: { timestamp: [number, number | null]; text: string }[] }>\n >;\n}\n\nexport async function run(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs(args, {\n setup: { type: 'boolean' },\n json: { type: 'boolean' },\n model: { type: 'string', default: 'base' },\n language: { type: 'string' },\n });\n const size = values.model;\n const named = MODELS[size];\n if (!size.includes('/') && named === undefined) fail(`--model is one of ${Object.keys(MODELS).join(', ')}, or a model ID`);\n const model = named === undefined ? size : `onnx-community/${named}`;\n const dir = join(process.env.DEICTIC_CACHE ?? join(homedir(), '.cache', 'deictic'), 'transcribe');\n const models = join(dir, 'models');\n const installed = existsSync(join(dir, 'node_modules', '@huggingface', 'transformers', 'package.json'));\n const downloaded = existsSync(join(models, ...model.split('/')));\n const again = `${ME} transcribe`;\n const sized = size === 'base' ? '' : ` --model ${size}`;\n\n if (values.setup) {\n mkdirSync(dir, { recursive: true });\n if (!existsSync(join(dir, 'package.json'))) writeFileSync(join(dir, 'package.json'), '{ \"private\": true }\\n');\n if (!installed) {\n console.log(`Installing ${TRANSFORMERS} in ${dir}…`);\n const windows = process.platform === 'win32';\n const npm = ['install', '--prefix', dir, '--no-audit', '--no-fund', '--save-exact', TRANSFORMERS];\n const run = spawnSync(windows ? `npm ${npm.map((a) => `\"${a}\"`).join(' ')}` : 'npm', windows ? [] : npm, {\n stdio: 'inherit',\n shell: windows,\n });\n if (run.status !== 0) fail(`npm install failed (${run.error?.message ?? `exit ${run.status}`}).`);\n }\n } else if (!installed || !downloaded) {\n fail(\n `Local transcription isn't set up${installed ? ` with the ${size} model` : ''}. Ask the person first: it downloads ` +\n `${installed ? '' : `${TRANSFORMERS} (with ONNX Runtime, ~470 MB) and `}Whisper ${size} into ${dir}, outside ` +\n `the project; after that, audio is transcribed on this machine. On yes: ${again} --setup${sized} (--model small ` +\n `hears better, ~250 MB more). On no, don't ask again this session: work from ${ME} voice's times.`,\n );\n }\n\n const entry = createRequire(join(dir, 'package.json')).resolve('@huggingface/transformers');\n const transformers = (await import(pathToFileURL(entry).href)) as Transformers;\n transformers.env.cacheDir = models;\n // Only setup downloads; a transcription uses what's here.\n transformers.env.allowRemoteModels = values.setup === true;\n if (values.setup) console.log(`Downloading ${model} (quantized) into ${models}…`);\n const asr = await transformers.pipeline('automatic-speech-recognition', model, { dtype: 'q8' });\n if (values.setup) {\n console.log(`Ready: ${again} <task>${sized}`);\n if (positionals[0] === undefined) return;\n }\n\n const results = [];\n for (const c of await voiceClips(positionals[0])) {\n // Whisper takes 16 kHz mono samples; ffmpeg decodes the clip (webm, ogg or mp4) to them.\n const raw = ffmpeg(['-loglevel', 'error', '-i', c.file, '-f', 'f32le', '-ac', '1', '-ar', '16000', '-']).stdout;\n const audio = new Float32Array(raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength - (raw.byteLength % 4)));\n const seconds = audio.length / 16000;\n const out = await asr(audio, {\n return_timestamps: true,\n chunk_length_s: 30,\n stride_length_s: 5,\n ...(values.language === undefined ? {} : { language: values.language }),\n });\n const said = (out.chunks ?? [{ timestamp: [0, seconds] as [number, number], text: out.text }]).map(\n ({ timestamp: [from, to], text }) => ({\n from: c.at + from * 1000,\n to: c.at + (to ?? seconds) * 1000,\n text: text.trim(),\n }),\n );\n results.push({ ...c, text: out.text.trim(), said });\n }\n\n if (values.json) {\n console.log(JSON.stringify(results, null, 2));\n return;\n }\n for (const r of results) {\n console.log(`clip ${r.id} (${r.recording === undefined ? 'a voice note' : `in recording ${r.recording}, from ${clock(r.at)}`}):`);\n for (const s of r.said) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} ${s.text}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,QAAQ;;AAIrB,MAAM,eAAe;AACrB,MAAM,SAAiC;CACrC,MAAM;CACN,MAAM;CACN,OAAO;CACP,kBAAkB;AACpB;AAiBA,eAAsB,IAAI,MAA+B;CACvD,MAAM,EAAE,QAAQ,gBAAgB,UAAU,MAAM;EAC9C,OAAO,EAAE,MAAM,UAAU;EACzB,MAAM,EAAE,MAAM,UAAU;EACxB,OAAO;GAAE,MAAM;GAAU,SAAS;EAAO;EACzC,UAAU,EAAE,MAAM,SAAS;CAC7B,CAAC;CACD,MAAM,OAAO,OAAO;CACpB,MAAM,QAAQ,OA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GACpB,IAAI,EAAE,MAAM,MAAM,WAAW;GAC7B,MAAM,KAAK,KAAK;EAClB,EACF;EACA,QAAQ,KAAK;GAAE,GAAG;GAAG,MAAM,IAAI,KAAK,KAAK;GAAG;EAAK,CAAC;CACpD;CAEA,IAAI,OAAO,MAAM;EACf,QAAQ,IAAI,KAAK,UAAU,SAAS,MAAM,CAAC,CAAC;EAC5C;CACF;CACA,KAAK,MAAM,KAAK,SAAS;EACvB,QAAQ,IAAI,QAAQ,EAAE,GAAG,IAAI,EAAE,cAAc,KAAA,IAAY,iBAAiB,gBAAgB,EAAE,UAAU,SAAS,MAAM,EAAE,EAAE,IAAI,GAAG;EAChI,KAAK,MAAM,KAAK,EAAE,MAAM,QAAQ,IAAI,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM;CAC9G;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { h as vbHere } from "./board.js";
|
|
2
|
+
// src/cli/vb.ts
|
|
3
|
+
/**
|
|
4
|
+
* `deictic vb`: the board's CLI as the other commands run it, the project's own `@vercel/board`, which needn't be on
|
|
5
|
+
* the PATH, on the board the dev server uses (`BOARD_URL`, or with none, the one `.deictic/board.json` names).
|
|
6
|
+
*/
|
|
7
|
+
const usage = "vb <anything vb takes> the board on the dev server: vb whoami, vb tasks claim 68 --lease 30m";
|
|
8
|
+
function run(args) {
|
|
9
|
+
process.exit(vbHere(args));
|
|
10
|
+
}
|
|
11
|
+
export { run, usage };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=vb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vb.js","names":[],"sources":["../../src/cli/vb.ts"],"sourcesContent":["/**\n * `deictic vb`: the board's CLI as the other commands run it, the project's own `@vercel/board`, which needn't be on\n * the PATH, on the board the dev server uses (`BOARD_URL`, or with none, the one `.deictic/board.json` names).\n */\nimport { vbHere } from './board.ts';\n\nexport const usage = 'vb <anything vb takes> the board on the dev server: vb whoami, vb tasks claim 68 --lease 30m';\n\nexport function run(args: string[]): void {\n process.exit(vbHere(args));\n}\n"],"mappings":";;;;;;AAMA,MAAa,QAAQ;AAErB,SAAgB,IAAI,MAAsB;CACxC,QAAQ,KAAK,OAAO,IAAI,CAAC;AAC3B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { t as DeicticOptions } from "./integration.js";
|
|
3
|
+
interface ViteOptions extends DeicticOptions {
|
|
4
|
+
/**
|
|
5
|
+
* deictic in a build too, for a page that shows it with no dev server behind it (a deployed demo): a module of
|
|
6
|
+
* the page's, from the root, whose default export answers the overlay's requests there (a `Standalone`, from
|
|
7
|
+
* `deictic`). The build's elements are marked and the overlay is in its bundle. The dev server answers as ever.
|
|
8
|
+
* Without it, the default, nothing of deictic is in a build.
|
|
9
|
+
*/
|
|
10
|
+
standalone?: string;
|
|
11
|
+
}
|
|
12
|
+
/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */
|
|
13
|
+
declare const CLIENT = "virtual:deictic/client";
|
|
14
|
+
declare function deictic(options?: ViteOptions): Plugin;
|
|
15
|
+
export { ViteOptions as n, deictic as r, CLIENT as t };
|
|
16
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../../src/vite.ts"],"mappings":";;UAmBiB,oBAAoB;;;;;;;EAOnC;;;cAIW;iBAGG,QAAQ,UAAS,cAAmB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { n as nodeMiddleware, r as redirect, t as endpoints } from "./endpoints.js";
|
|
3
|
+
import { a as markAstro, i as mark, n as clientModule, o as prepare } from "./integration.js";
|
|
4
|
+
// src/vite.ts
|
|
5
|
+
/**
|
|
6
|
+
* `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build, unless `standalone` asks for it.
|
|
7
|
+
*
|
|
8
|
+
* Its transform runs `pre`, so each JSX module's host elements are marked with their place in the
|
|
9
|
+
* source as written (`tools/locate.ts`). In the browser each marked module also imports the client
|
|
10
|
+
* module, which starts the overlay with every plugin's panel: imports run first and only once, so no
|
|
11
|
+
* line moves and frameworks that render their own HTML get it too. The endpoints are middleware on
|
|
12
|
+
* Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever
|
|
13
|
+
* Vite already launches. A write reaches the page through Vite's usual update for the file.
|
|
14
|
+
*/
|
|
15
|
+
/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */
|
|
16
|
+
const CLIENT = "virtual:deictic/client";
|
|
17
|
+
const CLIENT_ID = "\0deictic/client";
|
|
18
|
+
function deictic(options = {}) {
|
|
19
|
+
const { plugins, shortcut } = prepare(options);
|
|
20
|
+
let root = "";
|
|
21
|
+
let base = "/";
|
|
22
|
+
let building = false;
|
|
23
|
+
return {
|
|
24
|
+
name: "deictic",
|
|
25
|
+
enforce: "pre",
|
|
26
|
+
apply: (_, { command }) => command === "serve" || options.standalone !== void 0,
|
|
27
|
+
config: () => ({ optimizeDeps: { exclude: ["deictic"] } }),
|
|
28
|
+
configResolved(config) {
|
|
29
|
+
root = config.root;
|
|
30
|
+
base = config.base;
|
|
31
|
+
building = config.command === "build";
|
|
32
|
+
},
|
|
33
|
+
configureServer(server) {
|
|
34
|
+
const handle = endpoints({
|
|
35
|
+
root,
|
|
36
|
+
plugins,
|
|
37
|
+
base,
|
|
38
|
+
open: (path, { line, column }) => redirect(`${base}__open-in-editor?${new URLSearchParams({ file: `${path}:${line}:${column}` })}`)
|
|
39
|
+
});
|
|
40
|
+
server.middlewares.use(nodeMiddleware(handle));
|
|
41
|
+
},
|
|
42
|
+
resolveId: (id) => id === "virtual:deictic/client" ? CLIENT_ID : void 0,
|
|
43
|
+
load(id) {
|
|
44
|
+
if (id !== CLIENT_ID) return void 0;
|
|
45
|
+
const server = building && options.standalone !== void 0 ? resolve(root, options.standalone).replaceAll("\\", "/") : void 0;
|
|
46
|
+
return clientModule(plugins, base, shortcut, server);
|
|
47
|
+
},
|
|
48
|
+
transform: {
|
|
49
|
+
order: "pre",
|
|
50
|
+
handler(code, id) {
|
|
51
|
+
const [path = ""] = id.split("?");
|
|
52
|
+
if (path.endsWith(".astro")) return id === path ? markAstro(code, path, root) : void 0;
|
|
53
|
+
const browser = this.environment.config.consumer === "client";
|
|
54
|
+
return mark(code, path, root, browser ? `\nimport ${JSON.stringify(CLIENT)};\n` : "");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { deictic as n, CLIENT as t };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../src/vite.ts"],"sourcesContent":["/**\n * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build, unless `standalone` asks for it.\n *\n * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the\n * source as written (`tools/locate.ts`). In the browser each marked module also imports the client\n * module, which starts the overlay with every plugin's panel: imports run first and only once, so no\n * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on\n * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever\n * Vite already launches. A write reaches the page through Vite's usual update for the file.\n */\nimport { resolve } from 'node:path';\n\nimport type { Plugin } from 'vite';\n\nimport { endpoints, nodeMiddleware, redirect } from './tools/endpoints.ts';\nimport { clientModule, type DeicticOptions, mark, markAstro, prepare } from './tools/integration.ts';\n\nexport { clientModule, type DeicticOptions };\n\nexport interface ViteOptions extends DeicticOptions {\n /**\n * deictic in a build too, for a page that shows it with no dev server behind it (a deployed demo): a module of\n * the page's, from the root, whose default export answers the overlay's requests there (a `Standalone`, from\n * `deictic`). The build's elements are marked and the overlay is in its bundle. The dev server answers as ever.\n * Without it, the default, nothing of deictic is in a build.\n */\n standalone?: string;\n}\n\n/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */\nexport const CLIENT = 'virtual:deictic/client';\nconst CLIENT_ID = '\\0deictic/client';\n\nexport function deictic(options: ViteOptions = {}): Plugin {\n const { plugins, shortcut } = prepare(options);\n let root = '';\n let base = '/';\n let building = false;\n return {\n name: 'deictic',\n enforce: 'pre',\n apply: (_, { command }) => command === 'serve' || options.standalone !== undefined,\n // The client is the app's to bundle as it changes, not a dependency to prebundle once.\n config: () => ({ optimizeDeps: { exclude: ['deictic'] } }),\n configResolved(config) {\n root = config.root;\n base = config.base;\n building = config.command === 'build';\n },\n configureServer(server) {\n const handle = endpoints({\n root,\n plugins,\n base,\n open: (path, { line, column }) => redirect(`${base}__open-in-editor?${new URLSearchParams({ file: `${path}:${line}:${column}` })}`),\n });\n server.middlewares.use(nodeMiddleware(handle));\n },\n resolveId: (id) => (id === CLIENT ? CLIENT_ID : undefined),\n load(id) {\n if (id !== CLIENT_ID) return undefined;\n // Only a build's page asks the module: the dev server is there to answer.\n const server = building && options.standalone !== undefined ? resolve(root, options.standalone).replaceAll('\\\\', '/') : undefined;\n return clientModule(plugins, base, shortcut, server);\n },\n transform: {\n // First of all, not only first of the `pre` plugins: the React Compiler (`react({ compiler: true })`) is\n // `pre` too and compiles the JSX away, so after it there'd be no element to mark, wherever deictic is listed.\n order: 'pre',\n handler(code, id) {\n const [path = ''] = id.split('?');\n // An `.astro` component itself, not the styles and scripts Astro loads from it by a query.\n if (path.endsWith('.astro')) return id === path ? markAstro(code, path, root) : undefined;\n const browser = this.environment.config.consumer === 'client';\n return mark(code, path, root, browser ? `\\nimport ${JSON.stringify(CLIENT)};\\n` : '');\n },\n },\n };\n}\n\nexport default deictic;\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAa,SAAS;AACtB,MAAM,YAAY;AAElB,SAAgB,QAAQ,UAAuB,CAAC,GAAW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import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { r as definePlugin } from "./src.js";
|
|
4
|
+
import { t as keptIn } from "./kept.js";
|
|
5
|
+
// src/plugins/voice/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* `deictic/voice`: records the mic, for other plugins to attach (tasks does) or play along with
|
|
8
|
+
* something (a recording does). No tab of its own. The page half asks for the mic the first time, records
|
|
9
|
+
* with `MediaRecorder` and sends each take as it's spoken, its start to the `add` route and the rest to
|
|
10
|
+
* `more/<id>`, so one a page load cuts short is kept up to there; the server half keeps the latest `keep`
|
|
11
|
+
* clips under `.deictic/voice` and serves them at `clip/<id>`.
|
|
12
|
+
*/
|
|
13
|
+
const ID = /^[a-z0-9]+-[a-z0-9]+$/;
|
|
14
|
+
/** What one clip may weigh: minutes of speech in Opus are well under a MB. */
|
|
15
|
+
const MAX = 26214400;
|
|
16
|
+
/** The audio a browser's `MediaRecorder` makes, by the extension it's kept under. */
|
|
17
|
+
const TYPES = {
|
|
18
|
+
webm: "audio/webm",
|
|
19
|
+
ogg: "audio/ogg",
|
|
20
|
+
mp4: "audio/mp4"
|
|
21
|
+
};
|
|
22
|
+
function voice(options = {}) {
|
|
23
|
+
const keep = options.keep ?? 50;
|
|
24
|
+
let dir = "";
|
|
25
|
+
let taken = 0;
|
|
26
|
+
const fileOf = (id) => ID.test(id) && existsSync(dir) ? readdirSync(dir).find((f) => f.startsWith(`${id}.`)) : void 0;
|
|
27
|
+
const read = (id) => {
|
|
28
|
+
const file = fileOf(id);
|
|
29
|
+
if (file === void 0) return void 0;
|
|
30
|
+
const ext = file.slice(id.length + 1);
|
|
31
|
+
return {
|
|
32
|
+
data: new Uint8Array(readFileSync(join(dir, file))),
|
|
33
|
+
name: `voice-${file}`,
|
|
34
|
+
type: TYPES[ext] ?? "application/octet-stream"
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const keepClip = (data, ext) => {
|
|
38
|
+
const id = `${Date.now().toString(36).padStart(9, "0")}${(taken++ % 1296).toString(36).padStart(2, "0")}-${crypto.randomUUID().slice(0, 8)}`;
|
|
39
|
+
mkdirSync(dir, { recursive: true });
|
|
40
|
+
writeFileSync(join(dir, `${id}.${ext}`), data);
|
|
41
|
+
const kept = readdirSync(dir).toSorted();
|
|
42
|
+
for (const old of kept.slice(0, Math.max(0, kept.length - keep))) rmSync(join(dir, old));
|
|
43
|
+
return id;
|
|
44
|
+
};
|
|
45
|
+
return definePlugin({
|
|
46
|
+
name: "voice",
|
|
47
|
+
client: "deictic/voice/client",
|
|
48
|
+
setup: ({ root }) => {
|
|
49
|
+
dir = options.dir === void 0 ? keptIn(root, "voice") : resolve(root, options.dir);
|
|
50
|
+
return { read };
|
|
51
|
+
},
|
|
52
|
+
routes: {
|
|
53
|
+
add: async (req) => {
|
|
54
|
+
const type = (req.headers.get("content-type") ?? "").split(";")[0].trim();
|
|
55
|
+
const ext = Object.keys(TYPES).find((e) => TYPES[e] === type);
|
|
56
|
+
if (ext === void 0) return Response.json({ problem: `send the clip as ${Object.values(TYPES).join(", ")}` }, { status: 415 });
|
|
57
|
+
const body = new Uint8Array(await req.arrayBuffer());
|
|
58
|
+
if (body.byteLength === 0) return Response.json({ problem: "the clip is empty: speak for a moment longer" }, { status: 400 });
|
|
59
|
+
if (body.byteLength > MAX) return Response.json({ problem: `a clip may weigh ${MAX / 1024 / 1024} MB at most` }, { status: 413 });
|
|
60
|
+
return Response.json({ id: keepClip(body, ext) });
|
|
61
|
+
},
|
|
62
|
+
more: async (req) => {
|
|
63
|
+
const id = new URL(req.url).pathname.split("/").at(-1) ?? "";
|
|
64
|
+
const file = fileOf(id);
|
|
65
|
+
if (file === void 0) return Response.json({ problem: `clip ${id} isn't kept any more: record it again` }, { status: 404 });
|
|
66
|
+
const body = new Uint8Array(await req.arrayBuffer());
|
|
67
|
+
if (statSync(join(dir, file)).size + body.byteLength > MAX) return Response.json({ problem: `a clip may weigh ${MAX / 1024 / 1024} MB at most` }, { status: 413 });
|
|
68
|
+
appendFileSync(join(dir, file), body);
|
|
69
|
+
return Response.json({ id });
|
|
70
|
+
},
|
|
71
|
+
clip: (req) => {
|
|
72
|
+
const found = read(new URL(req.url).pathname.split("/").at(-1) ?? "");
|
|
73
|
+
if (found === void 0) return new Response("no such clip, or not kept any more", { status: 404 });
|
|
74
|
+
return new Response(found.data, { headers: {
|
|
75
|
+
"content-type": found.type,
|
|
76
|
+
"cache-control": "no-store"
|
|
77
|
+
} });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export { voice as t };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=voice.js.map
|