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
|
@@ -75,6 +75,8 @@ export interface Task {
|
|
|
75
75
|
/** What was typed, whole: what an edit changes. */
|
|
76
76
|
text: string;
|
|
77
77
|
state: string;
|
|
78
|
+
/** Who holds its claim, by name (`claude`), while it's claimed. A board keeps no one for a task's end. */
|
|
79
|
+
by?: string;
|
|
78
80
|
/** Whether it can still be edited or deleted: no one has claimed it. */
|
|
79
81
|
open: boolean;
|
|
80
82
|
/** Its page on the board, when there's one to link to. */
|
|
@@ -102,7 +104,7 @@ export interface Model {
|
|
|
102
104
|
/** Tasks about the file's other elements, by line, canceled ones left out: each with its `at`. */
|
|
103
105
|
elsewhere: Task[];
|
|
104
106
|
/**
|
|
105
|
-
* Who watches the channel, by name (`claude`): the agents whose watch (
|
|
107
|
+
* Who watches the channel, by name (`claude`): the agents whose watch (`deictic watch`) is running in
|
|
106
108
|
* this project, as a board can't say, and those holding a claim on one of the channel's tasks, which it can.
|
|
107
109
|
* Empty where none is and the board is this machine's own;
|
|
108
110
|
* left out where none is and the board is another, which an agent may watch from elsewhere.
|
|
@@ -130,8 +132,10 @@ export interface Op {
|
|
|
130
132
|
/** How many elements on the page come from the same place in the source. */
|
|
131
133
|
count: number;
|
|
132
134
|
/**
|
|
133
|
-
* The source it rendered through, after its own place, nearest first
|
|
134
|
-
*
|
|
135
|
+
* The source it rendered through, after its own place, nearest first: where the one before it is used. With
|
|
136
|
+
* React in development, the components that wrote it, `Field (src/Field.tsx:20)` or a name alone; without, the
|
|
137
|
+
* files around it, each a `file:line`. A shared component's line says nothing of which use of it this is, and
|
|
138
|
+
* these do.
|
|
135
139
|
*/
|
|
136
140
|
chain?: string[];
|
|
137
141
|
/** The element's HTML as it rendered, to attach: cut short, and masked where the screenshots plugin is loaded. */
|
|
@@ -337,6 +341,7 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
337
341
|
return definePlugin<Model, Change, Kept>({
|
|
338
342
|
name: 'tasks',
|
|
339
343
|
client: 'deictic/tasks/client',
|
|
344
|
+
packages: ['@vercel/board'],
|
|
340
345
|
// Only where it's turned off: the page half sends the HTML unless told not to.
|
|
341
346
|
...(options.html === false ? { clientOptions: { html: false } } : {}),
|
|
342
347
|
shortcut: options.shortcut,
|
|
@@ -365,9 +370,15 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
365
370
|
const once = source.code.split(line).length === 2;
|
|
366
371
|
const tasks: Task[] = [];
|
|
367
372
|
const elsewhere: (Task & { at: Place })[] = [];
|
|
368
|
-
|
|
373
|
+
const about = [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks];
|
|
374
|
+
// Who has each, and who holds any claim on the channel: asked of the board at once.
|
|
375
|
+
const actorOf = ({ task }: (typeof about)[number]['message']) => task?.claim?.actor;
|
|
376
|
+
const claims = held.tasks.flatMap(({ message }) => message.task?.claim ?? []);
|
|
377
|
+
const actors = await actorsOf(team, [...about.flatMap(({ message }) => actorOf(message) ?? []), ...claims.map((c) => c.actor)]);
|
|
378
|
+
for (const { message } of about) {
|
|
369
379
|
const state = message.task?.state ?? 'ready';
|
|
370
380
|
if (state === 'canceled') continue;
|
|
381
|
+
const by = actors.get(actorOf(message) ?? '')?.name;
|
|
371
382
|
const text = message.text.split(REST, 1)[0]!;
|
|
372
383
|
const to = taskLink(page, message.id);
|
|
373
384
|
const task = {
|
|
@@ -375,6 +386,7 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
375
386
|
title: text.split('\n', 1)[0]!,
|
|
376
387
|
text,
|
|
377
388
|
state,
|
|
389
|
+
...(by === undefined ? {} : { by }),
|
|
378
390
|
open: OPEN.has(state),
|
|
379
391
|
...(to === undefined ? {} : { link: to }),
|
|
380
392
|
};
|
|
@@ -383,11 +395,8 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
383
395
|
else if (once && at.tag === target.tag && message.labels['deictic.line'] === clip(line, LABEL)) tasks.push({ ...task, at });
|
|
384
396
|
else elsewhere.push({ ...task, at });
|
|
385
397
|
}
|
|
386
|
-
// An agent at work on a task is here too, though its watch may be over until the task is (`watch
|
|
387
|
-
const working =
|
|
388
|
-
team,
|
|
389
|
-
held.tasks.flatMap(({ message }) => message.task?.claim ?? []),
|
|
390
|
-
);
|
|
398
|
+
// An agent at work on a task is here too, though its watch may be over until the task is (`deictic watch --once`).
|
|
399
|
+
const working = agentsOf(actors, claims);
|
|
391
400
|
const watching = [...new Set([...watchersOf(root ?? process.cwd(), channel), ...working])].sort();
|
|
392
401
|
// A board of this machine's own is watched from here or not at all.
|
|
393
402
|
const ours = own !== undefined || (options.board === undefined && process.env.BOARD_URL === undefined);
|
|
@@ -537,14 +546,17 @@ function shotsOf(shots: NonNullable<Op['screenshots']>): string[] {
|
|
|
537
546
|
});
|
|
538
547
|
}
|
|
539
548
|
|
|
540
|
-
/**
|
|
549
|
+
/**
|
|
550
|
+
* `Source: src/ui/label.tsx:6 ← Field (src/Field.tsx:20) ← Panel`: from the element's line out, as the page said
|
|
551
|
+
* it: the components that use it, where the page knows them, or the files around it.
|
|
552
|
+
*/
|
|
541
553
|
function chainOf({ loc }: Target, chain: NonNullable<Op['chain']>): string[] {
|
|
542
554
|
const places = chain.slice(0, CHAIN).map((place) => clip(String(place), LABEL));
|
|
543
555
|
return places.length === 0 ? [] : [`Source: ${[`${loc.file}:${loc.line}`, ...places].join(' ← ')}`];
|
|
544
556
|
}
|
|
545
557
|
|
|
546
558
|
/** How many places a chain names after the element's own: the first few say which use of a component it is. */
|
|
547
|
-
const CHAIN =
|
|
559
|
+
const CHAIN = 3;
|
|
548
560
|
|
|
549
561
|
/** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */
|
|
550
562
|
const boxOf = ({ x, y, width, height }: Box) => [x, y, width, height].map(Math.round);
|
|
@@ -592,16 +604,25 @@ function placeOf(box: Box): Record<string, string> {
|
|
|
592
604
|
}
|
|
593
605
|
|
|
594
606
|
/**
|
|
595
|
-
* The
|
|
596
|
-
*
|
|
597
|
-
|
|
607
|
+
* 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
|
|
608
|
+
* the board is asked who they are, and only when there's one to ask about.
|
|
609
|
+
*/
|
|
610
|
+
async function actorsOf(team: TaskBoard, ids: string[]): Promise<Map<string, Awaited<ReturnType<TaskBoard['actors']>>[number]>> {
|
|
611
|
+
const asked = [...new Set(ids)];
|
|
612
|
+
if (asked.length === 0) return new Map();
|
|
613
|
+
// By ID, which a board from 0.54 answers without listing everyone; an older one lists them all, and the rest go unread.
|
|
614
|
+
return new Map((await team.actors({ id: asked })).map((actor) => [actor.id, actor]));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* The agents holding these claims, by name, while their leases run. A person holding one is left out: they needn't
|
|
619
|
+
* be told they're there. (Whatever else holds one works tasks: an agent, a workflow.)
|
|
598
620
|
*/
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
.filter((actor) => holders.has(actor.id) && actor.kind !== 'person')
|
|
621
|
+
function agentsOf(actors: Awaited<ReturnType<typeof actorsOf>>, claims: { actor: string; until: string }[]): string[] {
|
|
622
|
+
return claims
|
|
623
|
+
.filter((claim) => Date.parse(claim.until) > Date.now())
|
|
624
|
+
.flatMap((claim) => actors.get(claim.actor) ?? [])
|
|
625
|
+
.filter((actor) => actor.kind !== 'person')
|
|
605
626
|
.map((actor) => actor.name);
|
|
606
627
|
}
|
|
607
628
|
|
|
@@ -70,7 +70,7 @@ export async function localBoard(root: string, options: LocalOptions = {}): Prom
|
|
|
70
70
|
const flags = [...(options.inspect === false ? ['--no-inspect'] : []), ...(options.args ?? [])];
|
|
71
71
|
const as = JSON.stringify([options.port ?? null, dir, flags]);
|
|
72
72
|
|
|
73
|
-
const running =
|
|
73
|
+
const running = runningAt(file);
|
|
74
74
|
if (running !== undefined && alive(running.pid) && (await answers(running.url))) {
|
|
75
75
|
if (running.as === as) return { url: running.url, fresh: false, dir, stop: () => {} };
|
|
76
76
|
process.kill(running.pid);
|
|
@@ -79,7 +79,9 @@ export async function localBoard(root: string, options: LocalOptions = {}): Prom
|
|
|
79
79
|
|
|
80
80
|
const port = options.port ?? (await free(PORT));
|
|
81
81
|
const url = `http://127.0.0.1:${port}/api/board`;
|
|
82
|
-
const
|
|
82
|
+
const script = vbScript();
|
|
83
|
+
if (script === undefined) throw new Error('@vercel/board is missing: add it to your devDependencies');
|
|
84
|
+
const child = spawn(process.execPath, [script, 'serve', '--port', String(port), '--no-open', '--dir', dir, ...flags], {
|
|
83
85
|
stdio: ['ignore', 'ignore', 'pipe'],
|
|
84
86
|
});
|
|
85
87
|
let said = '';
|
|
@@ -101,12 +103,23 @@ export async function localBoard(root: string, options: LocalOptions = {}): Prom
|
|
|
101
103
|
return { url, fresh: true, dir, stop };
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* `vb`'s script in the project's `@vercel/board`, by its `bin`, to run with this process's own runtime: no shim, no
|
|
108
|
+
* shell. Nothing where it isn't installed.
|
|
109
|
+
*/
|
|
110
|
+
export function vbScript(): string | undefined {
|
|
111
|
+
try {
|
|
112
|
+
const manifest = createRequire(import.meta.url).resolve('@vercel/board/package.json');
|
|
113
|
+
const { bin } = JSON.parse(readFileSync(manifest, 'utf8')) as { bin?: string | { vb?: string } };
|
|
114
|
+
const entry = typeof bin === 'string' ? bin : bin?.vb;
|
|
115
|
+
return entry === undefined ? undefined : join(dirname(manifest), entry);
|
|
116
|
+
} catch {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
|
|
109
|
-
|
|
121
|
+
/** What a `.deictic/board.json` says, where it says it. */
|
|
122
|
+
export function runningAt(file: string): Running | undefined {
|
|
110
123
|
try {
|
|
111
124
|
const { url, pid, as } = JSON.parse(readFileSync(file, 'utf8')) as Partial<Running>;
|
|
112
125
|
return typeof url === 'string' && typeof pid === 'number' ? { url, pid, as: as ?? '' } : undefined;
|
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Who watches the channel for tasks. A board can't say (it knows who claimed a task, not who's listening), so a
|
|
3
|
-
* watch says it itself:
|
|
4
|
-
* again every
|
|
3
|
+
* watch says it itself: `deictic watch` keeps a file under `.deictic/watchers` while it runs (`watcherAt`), written
|
|
4
|
+
* again every `BEAT`, and the Task tab shows the names, so a person knows whether a task they add is taken up.
|
|
5
5
|
* (An agent holding a claim is one more, which the board does say: `agentsOf`, in `index.ts`.)
|
|
6
6
|
*/
|
|
7
|
-
import { readdirSync, readFileSync, rmSync } from 'node:fs';
|
|
8
|
-
import { join } from 'node:path';
|
|
7
|
+
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
9
|
|
|
10
10
|
import { keptIn } from '#src/tools/kept.ts';
|
|
11
11
|
|
|
12
|
+
/** How often a watch says it's still there, and so how soon the page knows of one that was killed (three missed). */
|
|
13
|
+
export const BEAT = 20_000;
|
|
12
14
|
/** How old a watch's last word may be: three of its beats, as one killed says nothing more. */
|
|
13
|
-
const FRESH =
|
|
15
|
+
const FRESH = 3 * BEAT;
|
|
16
|
+
|
|
17
|
+
/** What a watch keeps in a `.deictic/watchers` while it runs: one file per process. */
|
|
18
|
+
export interface Watcher {
|
|
19
|
+
name: string;
|
|
20
|
+
channel: string;
|
|
21
|
+
pid: number;
|
|
22
|
+
at: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A watch's file in each of `dirs` (`.deictic/` folders), written now and again every `BEAT`. Answers what takes
|
|
27
|
+
* it back, as the watch ends.
|
|
28
|
+
*/
|
|
29
|
+
export function watcherAt(dirs: readonly string[], name: string, channel: string): () => void {
|
|
30
|
+
const files = dirs.map((dir) => join(dir, 'watchers', `${process.pid}.json`));
|
|
31
|
+
const beat = () => {
|
|
32
|
+
const watcher: Watcher = { name, channel, pid: process.pid, at: Date.now() };
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
try {
|
|
35
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
36
|
+
writeFileSync(file, `${JSON.stringify(watcher)}\n`);
|
|
37
|
+
} catch {
|
|
38
|
+
// A folder that can't be written to: the watch goes on, unseen.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
beat();
|
|
43
|
+
const timer = setInterval(beat, BEAT);
|
|
44
|
+
return () => {
|
|
45
|
+
clearInterval(timer);
|
|
46
|
+
for (const file of files) rmSync(file, { force: true });
|
|
47
|
+
};
|
|
48
|
+
}
|
|
14
49
|
|
|
15
50
|
/** The names watching `channel` from this project now, each once, in order. */
|
|
16
51
|
export function watchersOf(root: string, channel: string, now = Date.now()): string[] {
|
|
@@ -25,7 +60,7 @@ export function watchersOf(root: string, channel: string, now = Date.now()): str
|
|
|
25
60
|
for (const file of files) {
|
|
26
61
|
const path = join(dir, file);
|
|
27
62
|
try {
|
|
28
|
-
const { name, channel: of, at } = JSON.parse(readFileSync(path, 'utf8')) as
|
|
63
|
+
const { name, channel: of, at } = JSON.parse(readFileSync(path, 'utf8')) as Partial<Watcher>;
|
|
29
64
|
if (typeof at !== 'number' || now - at > FRESH) rmSync(path, { force: true });
|
|
30
65
|
else if (of === channel && typeof name === 'string') names.add(name);
|
|
31
66
|
} catch {
|
package/src/tools/endpoints.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
18
18
|
import { type Loc, Refusal, type ServerPlugin, type Target } from '#src/index.ts';
|
|
19
19
|
|
|
20
20
|
import { History, type Scope } from './history.ts';
|
|
21
|
+
import { missingMessage } from './packages.ts';
|
|
21
22
|
import { setUp } from './plugins.ts';
|
|
22
23
|
import { applyEdits, resolveFile, sourceAt } from './source.ts';
|
|
23
24
|
|
|
@@ -48,6 +49,8 @@ export function endpoints({ root, plugins, base = '/', open, history = new Histo
|
|
|
48
49
|
const prefix = `${base}__deictic/`;
|
|
49
50
|
// Started now, awaited by every request: a plugin's API is there before anything asks for it.
|
|
50
51
|
const ready = setUp(root, plugins);
|
|
52
|
+
const gone = missingMessage(root, plugins);
|
|
53
|
+
if (gone !== undefined) console.warn(gone);
|
|
51
54
|
|
|
52
55
|
const pluginOf = (name: string) => {
|
|
53
56
|
const plugin = byName.get(name);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The packages plugins import that the project installs itself (`ServerPlugin.packages`: deictic's optional peers,
|
|
3
|
+
* or a plugin's own), and how to install them with the project's package manager. A missing one is said as the dev
|
|
4
|
+
* server starts, with the command that installs it, not on the first shot or recording, where it would fail.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
import manifest from '#package.json' with { type: 'json' };
|
|
11
|
+
import type { ServerPlugin } from '#src/index.ts';
|
|
12
|
+
|
|
13
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
14
|
+
|
|
15
|
+
/** Each package manager's lockfiles, in the order they're looked for in a folder. */
|
|
16
|
+
const LOCKS: [string, PackageManager][] = [
|
|
17
|
+
['bun.lock', 'bun'],
|
|
18
|
+
['bun.lockb', 'bun'],
|
|
19
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
20
|
+
['yarn.lock', 'yarn'],
|
|
21
|
+
['package-lock.json', 'npm'],
|
|
22
|
+
];
|
|
23
|
+
const MANAGERS: PackageManager[] = ['npm', 'pnpm', 'yarn', 'bun'];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The project's package manager: its `packageManager` field, or the lockfile nearest the root (a workspace's is
|
|
27
|
+
* above it), or the one running this (`npm_config_user_agent`), or npm. The lockfile wins over what runs this,
|
|
28
|
+
* as `npx deictic init` runs under npm in a project of any manager's.
|
|
29
|
+
*/
|
|
30
|
+
export function packageManager(root: string, agent = process.env.npm_config_user_agent): PackageManager {
|
|
31
|
+
for (let dir = root; ; dir = dirname(dir)) {
|
|
32
|
+
const field = fieldOf(dir);
|
|
33
|
+
if (field !== undefined) return field;
|
|
34
|
+
const lock = LOCKS.find(([file]) => existsSync(join(dir, file)));
|
|
35
|
+
if (lock !== undefined) return lock[1];
|
|
36
|
+
if (dirname(dir) === dir) break;
|
|
37
|
+
}
|
|
38
|
+
const running = agent?.split('/')[0];
|
|
39
|
+
return MANAGERS.find((m) => m === running) ?? 'npm';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A package.json's `packageManager` (`pnpm@9.1.0`), by its manager's name. */
|
|
43
|
+
function fieldOf(dir: string): PackageManager | undefined {
|
|
44
|
+
const field = readJson(join(dir, 'package.json'))?.packageManager;
|
|
45
|
+
const name = typeof field === 'string' ? field.split('@')[0] : undefined;
|
|
46
|
+
return MANAGERS.find((m) => m === name);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function readJson(path: string): Record<string, unknown> | undefined {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>;
|
|
52
|
+
} catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A package as the install command names it: with deictic's range for it where it's one of deictic's peers (rrweb's
|
|
59
|
+
* packages must agree), or deictic's own version for deictic. Quoted, as `>` and `^` are a shell's.
|
|
60
|
+
*/
|
|
61
|
+
export function specOf(name: string): string {
|
|
62
|
+
const range = name === manifest.name ? `^${manifest.version}` : (manifest.peerDependencies as Record<string, string>)[name];
|
|
63
|
+
return range === undefined ? name : `"${name}@${range}"`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The command that adds `names` to the project's dev dependencies. A pnpm workspace's root takes them only with `-w`. */
|
|
67
|
+
export function installCommand(manager: PackageManager, names: readonly string[], root: string): string {
|
|
68
|
+
const add = {
|
|
69
|
+
npm: 'npm install -D',
|
|
70
|
+
pnpm: existsSync(join(root, 'pnpm-workspace.yaml')) ? 'pnpm add -D -w' : 'pnpm add -D',
|
|
71
|
+
yarn: 'yarn add -D',
|
|
72
|
+
bun: 'bun add -d',
|
|
73
|
+
}[manager];
|
|
74
|
+
return [add, ...names.map(specOf)].join(' ');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What runs a package's CLI without installing it, for the manager: `npx`, `bunx`. */
|
|
78
|
+
export const runnerOf = (manager: PackageManager) => ({ npm: 'npx', pnpm: 'pnpm dlx', yarn: 'npx', bun: 'bunx' })[manager];
|
|
79
|
+
|
|
80
|
+
/** Whether the project can import `name`: it's found from the root, as the bundler and deictic's own imports find it. */
|
|
81
|
+
export function installed(root: string, name: string): boolean {
|
|
82
|
+
try {
|
|
83
|
+
createRequire(join(root, 'package.json')).resolve(`${name}/package.json`);
|
|
84
|
+
return true;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
// There, but its `exports` don't name its package.json: only "not found" means it's missing.
|
|
87
|
+
return (e as { code?: string }).code !== 'MODULE_NOT_FOUND';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Each plugin with the packages it imports that the project hasn't installed, where it has any. */
|
|
92
|
+
export function missing(root: string, plugins: readonly ServerPlugin[]): { plugin: string; packages: string[] }[] {
|
|
93
|
+
return plugins.flatMap(({ name, packages = [] }) => {
|
|
94
|
+
const gone = packages.filter((p) => !installed(root, p));
|
|
95
|
+
return gone.length === 0 ? [] : [{ plugin: name, packages: gone }];
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** What to say as the dev server starts when plugins' packages are missing: which, and the command that installs them. */
|
|
100
|
+
export function missingMessage(root: string, plugins: readonly ServerPlugin[]): string | undefined {
|
|
101
|
+
const gone = missing(root, plugins);
|
|
102
|
+
if (gone.length === 0) return undefined;
|
|
103
|
+
const names = [...new Set(gone.flatMap((g) => g.packages))];
|
|
104
|
+
const which = gone.map((g) => g.plugin);
|
|
105
|
+
const who = which.length === 1 ? which[0] : `${which.slice(0, -1).join(', ')} and ${which.at(-1)}`;
|
|
106
|
+
return `deictic: install what ${who} ${which.length === 1 ? 'needs' : 'need'}: ${installCommand(packageManager(root), names, root)}`;
|
|
107
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/annotations/index.ts"],"mappings":";;;;;;;;;;;iBAYiB;EACf;EACA;;;iBAIe;EACf;EACA;EACA;EACA;;YAGU;EACL;IAAgB;EACjB;EAAe,MAAM;EAAO,IAAI;;EAChC;EAAa,QAAQ;;EACrB;EAAc,IAAI;EAAO;;iBAEd;EACf;EACA;EACA,OAAO;;EAEP;;;YAIU;EAAoB;EAAa,YAAY;;EAAiB;EAAgB;;EAAiB;;;iBAG1F;;EAEf,QAAQ;EACR,IAAI,OAAO,OAAO,iBAAiB;EACnC,OAAO;EACP;;EAEA,UAAU,WAAW,OAAO;;;;;EAK5B,IAAI,MAAM;;;;;;EAMV,KAAK,SAAS,SAAS,iBAAiB,cAAc;IAAY,SAAS;MAAgB,QAAQ;;EAEnG,QAAQ,SAAS,SAAS,gBAAgB,eAAe,QAAQ;;;;;;EAMjE;IAAW,SAAS;IAAa,OAAO;IAAS;;;;YAIvC,UAAU,KAAK;;iBAGV;EACf;EACA;EACA;;;YAIU;IACR,aAAa;;;iBAIA;;EAEf,WAAW;;EAEX;;wBAGc,YAAY,UAAS,uCAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/annotations/index.ts"],"sourcesContent":["/**\n * `deictic/annotations`: mark up the page itself. Its tab is annotate\n * mode over the page: boxes, arrows, a pen and notes, drawn where the page is, so they stay with\n * it as it scrolls. They're kept for the tab's session, per page, until cleared.\n *\n * They're data other plugins build on, through `use('annotations')` in the page: screenshots draw them\n * over the page (`svg(area)`), tasks repeat their notes, and a recording can keep each change as it\n * happens (`subscribe`). Nothing of it runs on the server.\n */\nimport { definePlugin, type Shortcut } from '#src/index.ts';\n\n/** A point in page coordinates: CSS pixels from the document's top left, so it stays put as the page scrolls. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** A rectangle: in page coordinates for a shape, in viewport coordinates for an area to draw. */\nexport interface Area {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport type Shape =\n | ({ kind: 'box' } & Area)\n | { kind: 'arrow'; from: Point; to: Point }\n | { kind: 'pen'; points: Point[] }\n | { kind: 'note'; at: Point; text: string };\n\nexport interface Annotation {\n id: string;\n color: string;\n shape: Shape;\n /** When it was made, as `Date.now()`. */\n at: number;\n}\n\n/** A change, as `subscribe` hears it: what a recording keeps, to show the marks as they were made. */\nexport type AnnotationEvent = { type: 'add'; annotation: Annotation } | { type: 'remove'; id: string } | { type: 'clear' };\n\n/** The page's half, for other plugins' page halves. */\nexport interface Annotations {\n /** Every annotation on this page, oldest first. */\n list(): Annotation[];\n add(shape: Shape, color?: string): Annotation;\n remove(id: string): void;\n clear(): void;\n /** Hears every change from now on; answers what stops it. */\n subscribe(listener: (event: AnnotationEvent) => void): () => void;\n /**\n * The annotations over a part of the viewport, in viewport CSS pixels, as an SVG that size: what a\n * screenshot of that area draws over it. Nothing when there are none.\n */\n svg(area: Area): string | undefined;\n /**\n * Opens a picture (a screenshot, most often) over everything, with the toolbar, to draw on: answers the\n * marks, in the picture's CSS pixels, on Save, and nothing on Cancel, Esc or `signal`. It starts from\n * `marks`, to edit them again. They're the picture's alone, not the page's.\n */\n edit(picture: Picture, marks?: readonly Annotation[], options?: { signal?: AbortSignal }): Promise<Annotation[] | undefined>;\n /** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */\n flatten(picture: Picture, marks: readonly Annotation[]): Promise<Blob>;\n /**\n * Annotate mode's tools, for another plugin's UI to show (a recording's toolbar): a pointer tool, picked\n * to start with, leaves the page usable; while a drawing tool is picked, the page is drawn on. What's\n * drawn is its own `marks`, not the page's: shown while it's open, kept by nothing, gone on `close`.\n */\n tools(): { element: HTMLElement; marks: MarkSet; close: () => void };\n}\n\n/** A set of marks on the page: the page's own, kept for the session, or a toolbar's, kept by nothing. */\nexport type MarkSet = Pick<Annotations, 'list' | 'add' | 'remove' | 'clear' | 'subscribe' | 'svg'>;\n\n/** An image to draw on: where it loads from (the page's origin, so a canvas may read it), and its size in CSS pixels, which marks on it are in. */\nexport interface Picture {\n url: string;\n width: number;\n height: number;\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n annotations: Annotations;\n }\n}\n\nexport interface AnnotationsOptions {\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n /** The colour marks are drawn in: a red that deictic's own green isn't. */\n color?: string;\n}\n\nexport function annotations(options: AnnotationsOptions = {}) {\n return definePlugin({\n name: 'annotations',\n client: 'deictic/annotations/client',\n shortcut: options.shortcut,\n clientOptions: { color: options.color ?? '#ef4444' },\n });\n}\n\nexport default annotations;\n"],"mappings":";;;;;;;;;;;AA+FA,SAAgB,YAAY,UAA8B,CAAC,GAAG;CAC5D,OAAO,aAAa;EAClB,MAAM;EACN,QAAQ;EACR,UAAU,QAAQ;EAClB,eAAe,EAAE,OAAO,QAAQ,SAAS,UAAU;CACrD,CAAC;AACH"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded. One the plugin\n * `needs` always is; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /** The model its panel shows for an element. Without it, the panel gets none. */\n read?(source: Source, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, or a change the plugin made itself. */\n apply?(source: Source, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would: after a recording, say. An\n * element rendered again since stands in for one no longer on the page. False when there's no such tab\n * or no such element any more. Not from `setup`, which runs before the popup can open.\n */\n open: (plugin: string, element: Element) => boolean;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /** Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows. */\n apply(op: Op): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AAwEA,MAAa,gBACX,WACyC;AAiH3C,MAAa,sBAAgD,WAAuE"}
|
package/dist/logs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/logs/index.ts"],"mappings":";;YAaY;iBAmBK;;;;;EAKf,SAAS;;;YAIC;IACR,MAAM;;;wBAIM,KAAK,UAAS,gCAAgB"}
|
package/dist/logs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/logs/index.ts"],"sourcesContent":["/**\n * `deictic/logs`: what the page logs while it's recorded, and the errors nothing caught, in the recording, each at\n * its moment. No tab, and nothing of its own: it hands the recordings plugin rrweb's console plugin\n * (`@rrweb/rrweb-plugin-console-record`, an optional peer), whose events are rrweb's (`rrweb/console@1`).\n *\n * A wrapped console names the wrapper, not the caller, as each line's source in the browser's tools. rrweb wraps it\n * as a recording starts and puts it back as it stops, so it's the page's own the rest of the time. Leave the plugin\n * out and it never is.\n */\nimport { definePlugin } from '#src/index.ts';\nimport type { Recorded } from '#src/plugins/recordings/index.ts';\n\n/** What of the console is kept: its methods, by name. */\nexport type Level =\n | 'assert'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\nexport interface LogsOptions {\n /**\n * The console's methods kept, `['warn', 'error']` for the least: every one that says something by default. Errors\n * nothing caught, and rejections nothing handled, come with `error`.\n */\n levels?: Level[];\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n logs: Recorded;\n }\n}\n\nexport function logs(options: LogsOptions = {}) {\n return definePlugin<never, never>({\n name: 'logs',\n client: 'deictic/logs/client',\n clientOptions: { levels: options.levels },\n });\n}\n\nexport default logs;\n"],"mappings":";;;;;;;;;;;AA8CA,SAAgB,KAAK,UAAuB,CAAC,GAAG;CAC9C,OAAO,aAA2B;EAChC,MAAM;EACN,QAAQ;EACR,eAAe,EAAE,QAAQ,QAAQ,OAAO;CAC1C,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/network/index.ts"],"sourcesContent":["/**\n * `deictic/network`: the requests the page makes while it's recorded, in the recording, each as it ends. No tab,\n * and nothing of its own: it hands the recordings plugin rrweb's network plugin\n * (`@rrweb/rrweb-plugin-network-record`, an optional peer), whose events are rrweb's (`rrweb/network@1`).\n *\n * By default a request is its URL, its status and its timing, which the browser reports of itself\n * (`PerformanceObserver`): nothing of the page's is wrapped, and no method is known. `headers` and `body` add those\n * and the method, for which rrweb wraps `fetch` and `XMLHttpRequest` while a recording is going, and only then.\n *\n * Everything kept is masked first (`mask.ts`): a secret in a URL's query, a header or a body's field is blanked by\n * its name, and deictic's own requests are left out.\n */\nimport { definePlugin } from '#src/index.ts';\nimport type { Recorded } from '#src/plugins/recordings/index.ts';\n\nexport { MASKED, maskBody, maskHeaders, maskRequest, maskUrl, sensitive } from './mask.ts';\n\nexport interface NetworkOptions {\n /**\n * What made the requests kept, as the browser names it (a resource's `initiatorType`): `['fetch',\n * 'xmlhttprequest']` by default, the page's own calls. `'img'`, `'script'`, `'css'` and the like add what it loads.\n */\n initiators?: string[];\n /** Keeps each request's and response's headers, the secret ones blanked (`Authorization`, `Cookie`, …): not by default. */\n headers?: boolean;\n /**\n * Keeps each request's and response's body, cut at 10,000 characters, secrets blanked by name where it's JSON or a\n * form's fields: not by default. `true` is JSON, text and forms; a list names the content types, by a part of each.\n */\n body?: boolean | string[];\n /** More names whose values are blanked, in a query, a header or a body: a part of the name, in any case (`['email']`). */\n mask?: string[];\n /** Requests left out whole: a part of the URL (`['/analytics', 'sentry.io']`). */\n ignore?: string[];\n}\n\n/** The options as the page half gets them. */\nexport interface Resolved {\n initiators: string[];\n headers: boolean;\n body: false | string[];\n mask: string[];\n ignore: string[];\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n network: Recorded;\n }\n}\n\n/** The bodies kept with `body: true`: what reads as text. */\nconst TEXT = ['application/json', '+json', 'text/', 'application/x-www-form-urlencoded', 'application/xml'];\n\nexport function network(options: NetworkOptions = {}) {\n return definePlugin<never, never>({\n name: 'network',\n client: 'deictic/network/client',\n clientOptions: {\n initiators: options.initiators ?? ['fetch', 'xmlhttprequest'],\n headers: options.headers ?? false,\n body: options.body === true ? TEXT : (options.body ?? false),\n mask: options.mask ?? [],\n ignore: options.ignore ?? [],\n } satisfies Resolved,\n });\n}\n\nexport default network;\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,MAAM,OAAO;CAAC;CAAoB;CAAS;CAAS;CAAqC;AAAiB;AAE1G,SAAgB,QAAQ,UAA0B,CAAC,GAAG;CACpD,OAAO,aAA2B;EAChC,MAAM;EACN,QAAQ;EACR,eAAe;GACb,YAAY,QAAQ,cAAc,CAAC,SAAS,gBAAgB;GAC5D,SAAS,QAAQ,WAAW;GAC5B,MAAM,QAAQ,SAAS,OAAO,OAAQ,QAAQ,QAAQ;GACtD,MAAM,QAAQ,QAAQ,CAAC;GACvB,QAAQ,QAAQ,UAAU,CAAC;EAC7B;CACF,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/recommended/index.ts"],"sourcesContent":["/**\n * `deictic/recommended`: the plugins for describing a change rather than making it. Alt-click an element, say what\n * should change, attach a screenshot to draw on, a screen recording or your voice, and it goes to a Vercel Board.\n * A recording has the page's console and its requests in it too.\n *\n * Only the server halves, as every factory is: each names its page half, which the integration imports. A plugin\n * outside the preset (Tailwind, your own) goes beside it: `plugins: [...recommended(), tailwind()]`.\n */\nimport type { ServerPlugin } from '#src/index.ts';\nimport { annotations, type AnnotationsOptions } from '#src/plugins/annotations/index.ts';\nimport { logs, type LogsOptions } from '#src/plugins/logs/index.ts';\nimport { network, type NetworkOptions } from '#src/plugins/network/index.ts';\nimport { recordings, type RecordingsOptions } from '#src/plugins/recordings/index.ts';\nimport { screenshots, type ScreenshotsOptions } from '#src/plugins/screenshots/index.ts';\nimport { tasks, type TasksOptions } from '#src/plugins/tasks/index.ts';\nimport { voice, type VoiceOptions } from '#src/plugins/voice/index.ts';\n\n/** Each plugin's options, by its name, or `false` to leave it out. */\nexport interface RecommendedOptions {\n tasks?: TasksOptions | false;\n screenshots?: ScreenshotsOptions | false;\n annotations?: AnnotationsOptions | false;\n recordings?: RecordingsOptions | false;\n voice?: VoiceOptions | false;\n /** The console's lines in a recording. */\n logs?: LogsOptions | false;\n /** The page's requests in a recording, masked. */\n network?: NetworkOptions | false;\n}\n\n/**\n * Tasks, screenshots, annotations, recordings and voice, in that order, the order of their tabs, then what a\n * recording has besides the page: logs and network.\n */\nexport function recommended(options: RecommendedOptions = {}): ServerPlugin[] {\n const plugins: ServerPlugin[] = [];\n if (options.tasks !== false) plugins.push(tasks(options.tasks));\n if (options.screenshots !== false) plugins.push(screenshots(options.screenshots));\n if (options.annotations !== false) plugins.push(annotations(options.annotations));\n if (options.recordings !== false) plugins.push(recordings(options.recordings));\n if (options.voice !== false) plugins.push(voice(options.voice));\n // Nothing without recordings to be in.\n if (options.recordings !== false && options.logs !== false) plugins.push(logs(options.logs));\n if (options.recordings !== false && options.network !== false) plugins.push(network(options.network));\n return plugins;\n}\n\nexport default recommended;\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,YAAY,UAA8B,CAAC,GAAmB;CAC5E,MAAM,UAA0B,CAAC;CACjC,IAAI,QAAQ,UAAU,OAAO,QAAQ,KAAK,MAAM,QAAQ,KAAK,CAAC;CAC9D,IAAI,QAAQ,gBAAgB,OAAO,QAAQ,KAAK,YAAY,QAAQ,WAAW,CAAC;CAChF,IAAI,QAAQ,gBAAgB,OAAO,QAAQ,KAAK,YAAY,QAAQ,WAAW,CAAC;CAChF,IAAI,QAAQ,eAAe,OAAO,QAAQ,KAAK,WAAW,QAAQ,UAAU,CAAC;CAC7E,IAAI,QAAQ,UAAU,OAAO,QAAQ,KAAK,MAAM,QAAQ,KAAK,CAAC;CAE9D,IAAI,QAAQ,eAAe,SAAS,QAAQ,SAAS,OAAO,QAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;CAC3F,IAAI,QAAQ,eAAe,SAAS,QAAQ,YAAY,OAAO,QAAQ,KAAK,QAAQ,QAAQ,OAAO,CAAC;CACpG,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/screenshots/index.ts"],"sourcesContent":["/**\n * `deictic/screenshots`: a plugin with no panel, for others to build on. In the page,\n * `use('screenshots').capture(element)` takes what the viewport shows (or the element alone), with\n * nothing of deictic's in it, and says where the element is; on the server, `use('screenshots').read(id)`\n * hands the PNG to another plugin, which the tasks plugin attaches to a task.\n *\n * How a shot is made is its renderer's: `rrweb()` by default, which snapshots the page's DOM and renders it\n * in a browser beside the dev server, so text lays out as the page's does; or `dom()`, which draws the page\n * in the page itself, for a target with no server to render on. A renderer is a page module and, where it\n * renders elsewhere, a `render` here (`Renderer`): another may take pixels from screen sharing or devtools.\n *\n * Shots are kept under `.deictic/screenshots`, the latest `keep` of them, so they outlive a\n * restart of the dev server and stay out of git.\n */\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\n\nimport { definePlugin } from '#src/index.ts';\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** A rectangle in CSS pixels, from the shot's top left. */\nexport interface Box {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** A shot as the page knows it: its ID, where the dev server serves its PNG, and where the element is in it. */\nexport interface Shot {\n id: string;\n url: string;\n /** The element, in the shot: nothing marks it there, as nothing of deictic's is drawn. */\n box: Box;\n /** The shot's size in CSS pixels; its PNG may have more, on a high-density screen. */\n size: { width: number; height: number };\n}\n\nexport interface CaptureOptions {\n /** `viewport`, what the page shows, by default; or `element`, the element alone. */\n area?: 'viewport' | 'element';\n}\n\n/** The page's half, for other plugins' page halves. */\nexport interface Capture {\n capture(element: Element, options?: CaptureOptions): Promise<Shot>;\n /** Keeps a PNG made of a shot (the same one with marks drawn over it, say) as a shot of its own. */\n upload(png: Blob, of: Pick<Shot, 'box' | 'size'>): Promise<Shot>;\n /** A copy of an element with what a shot hides hidden in it too: for a plugin that sends its HTML somewhere. */\n masked(element: Element): Element;\n}\n\n/** The server's half, for other plugins' server halves. */\nexport interface Screenshots {\n /** A shot's PNG, or nothing for one not kept (any more). */\n read(id: string): { data: Uint8Array<ArrayBuffer>; name: string; type: 'image/png' } | undefined;\n}\n\ndeclare module 'deictic' {\n interface ServerApis {\n screenshots: Screenshots;\n }\n interface ClientApis {\n screenshots: Capture;\n }\n}\n\n/**\n * What a shot hides, as rrweb names it and by its defaults, so one marking in the app hides the same\n * things from a screenshot as from an rrweb recording or snapshot.\n */\nexport interface Masking {\n /** Elements drawn as a blank box their size: `rr-block` by default. */\n blockClass?: string;\n blockSelector?: string;\n /** Elements whose text is drawn as `*`: `rr-mask` by default. */\n maskTextClass?: string;\n maskTextSelector?: string;\n /** Every field's value as `*`, not only passwords': false by default. */\n maskAllInputs?: boolean;\n}\n\n/** Masking with its defaults, as a renderer's page half gets it. */\nexport type ResolvedMasking = Required<Pick<Masking, 'blockClass' | 'maskTextClass' | 'maskAllInputs'>> & Masking;\n\n/**\n * How shots are made. `client` is the page module that captures, default-exporting `screenshotsClient(…)`\n * from `deictic/screenshots/client`. A page half that sends a PNG needs nothing here; one that sends\n * something else, as JSON (a DOM snapshot), needs `render` to make the PNG of it.\n */\nexport interface Renderer {\n client: string;\n /** What the page half gets, besides the masking. */\n clientOptions?: unknown;\n render?(input: unknown): Promise<Uint8Array>;\n}\n\n/** Where `rrweb()` finds a browser: any Chromium renders the snapshot as the page's own would. */\nexport interface BrowserOptions {\n /** A Chromium-based browser's executable. */\n executablePath?: string;\n /** An installed browser by Playwright's name: `chrome`, `msedge`. By default Playwright's own Chromium, then Chrome, then Edge. */\n channel?: string;\n}\n\n/** Draws the page in the page, from its DOM (`modern-screenshot`): no server needed, but text may lay out a little differently. */\nexport const dom = (): Renderer => ({ client: 'deictic/screenshots/dom' });\n\n/**\n * Snapshots the page's DOM in the page (`rrweb-snapshot`, masking as rrweb does) and renders it in a\n * browser beside the dev server (`playwright-core`), so text lays out as the page's does.\n */\nexport const rrweb = (options: BrowserOptions = {}): Renderer => ({\n client: 'deictic/screenshots/rrweb',\n // Loaded on the first shot, so a project rendering in the page needn't install Playwright.\n render: async (input) => (await import('./playwright.ts')).render(input, options),\n});\n\nexport interface ScreenshotsOptions extends Masking {\n /** How shots are made: `rrweb()` by default, or `dom()` where there's no server to render on. */\n renderer?: Renderer;\n /** How many shots to keep, the latest: 100 by default. */\n keep?: number;\n /** Where they're kept, from the project's root: `.deictic/screenshots` by default. */\n dir?: string;\n}\n\nconst ID = /^[a-z0-9]+-[a-z0-9]+$/;\n/** What one PNG, or one snapshot to render, may weigh: a viewport at twice its pixels is a few MB. */\nconst MAX = 20 * 1024 * 1024;\n\nexport function screenshots(options: ScreenshotsOptions = {}) {\n const renderer = options.renderer ?? rrweb();\n const keep = options.keep ?? 100;\n let dir = '';\n let taken = 0;\n const pathOf = (id: string) => join(dir, `${id}.png`);\n const read: Screenshots['read'] = (id) => {\n if (!ID.test(id) || !existsSync(pathOf(id))) return undefined;\n return { data: new Uint8Array(readFileSync(pathOf(id))), name: `${id}.png`, type: 'image/png' };\n };\n const keepShot = (data: Uint8Array) => {\n // Sorts by when it was taken, which is what pruning keeps by: the count orders two in one millisecond.\n const id = `${Date.now().toString(36).padStart(9, '0')}${(taken++ % 1296).toString(36).padStart(2, '0')}-${crypto.randomUUID().slice(0, 8)}`;\n mkdirSync(dir, { recursive: true });\n writeFileSync(pathOf(id), data);\n const kept = readdirSync(dir)\n .filter((f) => f.endsWith('.png'))\n .toSorted();\n for (const old of kept.slice(0, Math.max(0, kept.length - keep))) rmSync(join(dir, old));\n return id;\n };\n\n return definePlugin<never, never, never, Screenshots>({\n name: 'screenshots',\n client: renderer.client,\n clientOptions: {\n masking: {\n blockClass: options.blockClass ?? 'rr-block',\n blockSelector: options.blockSelector,\n maskTextClass: options.maskTextClass ?? 'rr-mask',\n maskTextSelector: options.maskTextSelector,\n maskAllInputs: options.maskAllInputs ?? false,\n } satisfies ResolvedMasking,\n renderer: renderer.clientOptions,\n },\n setup: ({ root }) => {\n dir = options.dir === undefined ? keptIn(root, 'screenshots') : resolve(root, options.dir);\n return { read };\n },\n routes: {\n // A PNG the page made, or what the renderer makes one of.\n add: async (req) => {\n const type = req.headers.get('content-type') ?? '';\n const body = new Uint8Array(await req.arrayBuffer());\n if (body.byteLength > MAX) return Response.json({ problem: `a shot may weigh ${MAX / 1024 / 1024} MB at most` }, { status: 413 });\n if (type === 'image/png') return Response.json({ id: keepShot(body) });\n if (renderer.render === undefined || !type.startsWith('application/json'))\n return Response.json({ problem: 'send the shot as image/png' }, { status: 415 });\n try {\n return Response.json({ id: keepShot(await renderer.render(JSON.parse(new TextDecoder().decode(body)))) });\n } catch (e) {\n return Response.json({ problem: e instanceof Error ? e.message : String(e) }, { status: 500 });\n }\n },\n // `shot/<id>`: the PNG, for a panel to show.\n shot: (req) => {\n const shot = read(new URL(req.url).pathname.split('/').at(-1) ?? '');\n if (shot === undefined) return new Response('no such shot, or not kept any more', { status: 404 });\n return new Response(shot.data, { headers: { 'content-type': shot.type, 'cache-control': 'no-store' } });\n },\n },\n });\n}\n\nexport default screenshots;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0GA,MAAa,aAAuB,EAAE,QAAQ,0BAA0B;;;;;AAMxE,MAAa,SAAS,UAA0B,CAAC,OAAiB;CAChE,QAAQ;CAER,QAAQ,OAAO,WAAW,MAAM,OAAO,2BAAA,CAAoB,OAAO,OAAO,OAAO;AAClF;AAWA,MAAM,KAAK;;AAEX,MAAM,MAAM;AAEZ,SAAgB,YAAY,UAA8B,CAAC,GAAG;CAC5D,MAAM,WAAW,QAAQ,YAAY,MAAM;CAC3C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI,MAAM;CACV,IAAI,QAAQ;CACZ,MAAM,UAAU,OAAe,KAAK,KAAK,GAAG,GAAG,KAAK;CACpD,MAAM,QAA6B,OAAO;EACxC,IAAI,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,WAAW,OAAO,EAAE,CAAC,GAAG,OAAO,KAAA;EACpD,OAAO;GAAE,MAAM,IAAI,WAAW,aAAa,OAAO,EAAE,CAAC,CAAC;GAAG,MAAM,GAAG,GAAG;GAAO,MAAM;EAAY;CAChG;CACA,MAAM,YAAY,SAAqB;EAErC,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,KAAK,UAAU,KAAA,CAAM,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;EACzI,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;EAClC,cAAc,OAAO,EAAE,GAAG,IAAI;EAC9B,MAAM,OAAO,YAAY,GAAG,CAAC,CAC1B,QAAQ,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,CACjC,SAAS;EACZ,KAAK,MAAM,OAAO,KAAK,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,OAAO,KAAK,KAAK,GAAG,CAAC;EACvF,OAAO;CACT;CAEA,OAAO,aAA+C;EACpD,MAAM;EACN,QAAQ,SAAS;EACjB,eAAe;GACb,SAAS;IACP,YAAY,QAAQ,cAAc;IAClC,eAAe,QAAQ;IACvB,eAAe,QAAQ,iBAAiB;IACxC,kBAAkB,QAAQ;IAC1B,eAAe,QAAQ,iBAAiB;GAC1C;GACA,UAAU,SAAS;EACrB;EACA,QAAQ,EAAE,WAAW;GACnB,MAAM,QAAQ,QAAQ,KAAA,IAAY,OAAO,MAAM,aAAa,IAAI,QAAQ,MAAM,QAAQ,GAAG;GACzF,OAAO,EAAE,KAAK;EAChB;EACA,QAAQ;GAEN,KAAK,OAAO,QAAQ;IAClB,MAAM,OAAO,IAAI,QAAQ,IAAI,cAAc,KAAK;IAChD,MAAM,OAAO,IAAI,WAAW,MAAM,IAAI,YAAY,CAAC;IACnD,IAAI,KAAK,aAAa,KAAK,OAAO,SAAS,KAAK,EAAE,SAAS,oBAAoB,MAAM,OAAO,KAAK,aAAa,GAAG,EAAE,QAAQ,IAAI,CAAC;IAChI,IAAI,SAAS,aAAa,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,IAAI,EAAE,CAAC;IACrE,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,KAAK,WAAW,kBAAkB,GACtE,OAAO,SAAS,KAAK,EAAE,SAAS,6BAA6B,GAAG,EAAE,QAAQ,IAAI,CAAC;IACjF,IAAI;KACF,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,MAAM,SAAS,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1G,SAAS,GAAG;KACV,OAAO,SAAS,KAAK,EAAE,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,IAAI,CAAC;IAC/F;GACF;GAEA,OAAO,QAAQ;IACb,MAAM,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE;IACnE,IAAI,SAAS,KAAA,GAAW,OAAO,IAAI,SAAS,sCAAsC,EAAE,QAAQ,IAAI,CAAC;IACjG,OAAO,IAAI,SAAS,KAAK,MAAM,EAAE,SAAS;KAAE,gBAAgB,KAAK;KAAM,iBAAiB;IAAW,EAAE,CAAC;GACxG;EACF;CACF,CAAC;AACH"}
|
package/dist/vite.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;iBAmBiB,oBAAoB;;;;;;;EAOnC;;;qBAIW;wBAGG,QAAQ,UAAS,cAAmB"}
|
package/dist/vite.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;CACzD,MAAM,EAAE,SAAS,aAAa,QAAQ,OAAO;CAC7C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,WAAW;CACf,OAAO;EACL,MAAM;EACN,SAAS;EACT,QAAQ,GAAG,EAAE,cAAc,YAAY,WAAW,QAAQ,eAAe,KAAA;EAEzE,eAAe,EAAE,cAAc,EAAE,SAAS,CAAC,SAAS,EAAE,EAAE;EACxD,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,WAAW,OAAO,YAAY;EAChC;EACA,gBAAgB,QAAQ;GACtB,MAAM,SAAS,UAAU;IACvB;IACA;IACA;IACA,OAAO,MAAM,EAAE,MAAM,aAAa,SAAS,GAAG,KAAK,mBAAmB,IAAI,gBAAgB,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG;GACpI,CAAC;GACD,OAAO,YAAY,IAAI,eAAe,MAAM,CAAC;EAC/C;EACA,YAAY,OAAQ,OAAA,2BAAgB,YAAY,KAAA;EAChD,KAAK,IAAI;GACP,IAAI,OAAO,WAAW,OAAO,KAAA;GAE7B,MAAM,SAAS,YAAY,QAAQ,eAAe,KAAA,IAAY,QAAQ,MAAM,QAAQ,UAAU,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI,KAAA;GACxH,OAAO,aAAa,SAAS,MAAM,UAAU,MAAM;EACrD;EACA,WAAW;GAGT,OAAO;GACP,QAAQ,MAAM,IAAI;IAChB,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM,GAAG;IAEhC,IAAI,KAAK,SAAS,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,MAAM,MAAM,IAAI,IAAI,KAAA;IAChF,MAAM,UAAU,KAAK,YAAY,OAAO,aAAa;IACrD,OAAO,KAAK,MAAM,MAAM,MAAM,UAAU,YAAY,KAAK,UAAU,MAAM,EAAE,OAAO,EAAE;GACtF;EACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/voice/index.ts"],"mappings":";iBAciB;EACf;EACA;EACA;EACA;;;iBAIe;;EAEf;;EAEA,QAAQ;;;;;EAKR,SAAS,KAAK;EACd,QAAQ,QAAQ;EAChB;;;iBAIe;;EAEf,SAAS,QAAQ;;;iBAIF;;EAEf,KAAK;IAAe,MAAM,WAAW;IAAc;IAAc;;;;YAIvD;IACR,OAAO;;YAEC;IACR,OAAO;;;iBAIM;;EAEf;;EAEA;;wBASc,MAAM,UAAS,iCAAiB,kCAAA"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# Setting deictic up
|
|
2
|
-
|
|
3
|
-
Only when the project doesn't have it yet, or the person asks. Check first: a `deictic` dependency and its plugin
|
|
4
|
-
in the bundler config. The package's `API.md` has the setup; each plugin's options are its factory's types.
|
|
5
|
-
|
|
6
|
-
## The package and the bundler
|
|
7
|
-
|
|
8
|
-
Install with the project's package manager (`npm install -D`, `bun add -d`, `pnpm add -D`, `yarn add -D`), the
|
|
9
|
-
plugins' dependencies with it (below), and add it to the bundler; each runs in the dev server only and takes the
|
|
10
|
-
same options:
|
|
11
|
-
|
|
12
|
-
| Bundler | Config |
|
|
13
|
-
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
-
| Vite (and frameworks on it) | `plugins: [deictic({ plugins })]`, `deictic` from `deictic/vite` |
|
|
15
|
-
| Next.js (`next dev`, either bundler) | `export default withDeictic(nextConfig, { plugins })`, from `deictic/next` |
|
|
16
|
-
| webpack 5, Rspack | `plugins: [new DeicticPlugin({ plugins })]`, from `deictic/webpack`; `launch-editor` to open files |
|
|
17
|
-
| Bun (`Bun.serve` with HTML imports) | `deictic/bun`: a plugin module named in `bunfig.toml`'s `[serve.static] plugins`, its `routes` spread into `Bun.serve` |
|
|
18
|
-
| Astro | `integrations: [deictic({ plugins })]`, from `deictic/astro`; `.astro` components are marked with Astro 7 or later |
|
|
19
|
-
|
|
20
|
-
React Native isn't supported. With no plugins deictic loads nothing; `.deictic/` (kept data) ignores itself in git.
|
|
21
|
-
|
|
22
|
-
## Which plugins: ask first
|
|
23
|
-
|
|
24
|
-
Before installing anything, ask the person in one message whether they want the recommended setup, and name the
|
|
25
|
-
other options so they can add or drop some:
|
|
26
|
-
|
|
27
|
-
> I'd set deictic up for tasks: Alt-click an element, describe the change, and attach a screenshot (which you can
|
|
28
|
-
> draw on), a screen recording, or your voice; it goes to a Vercel Board for me to work. That's the tasks,
|
|
29
|
-
> screenshots, annotations, recordings and voice plugins (a recording keeps the page's console and its requests too,
|
|
30
|
-
> secrets masked), plus `@vercel/board`, `rrweb`, `rrweb-player`, `rrweb-snapshot`, rrweb's console and network plugins
|
|
31
|
-
> and `playwright-core` as dev dependencies. Also available: Tailwind (edit an element's classes in place, no task
|
|
32
|
-
> needed), screenshots drawn in the page instead of a headless browser (`dom()`, for a page with no server to
|
|
33
|
-
> render on), a channel or labels for the tasks, and a shortcut other than Alt. Go with the recommended setup?
|
|
34
|
-
|
|
35
|
-
On yes, the recommended setup:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm install -D deictic @vercel/board rrweb rrweb-player rrweb-snapshot playwright-core \
|
|
39
|
-
@rrweb/rrweb-plugin-console-record @rrweb/rrweb-plugin-network-record
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { recommended } from 'deictic/recommended';
|
|
44
|
-
|
|
45
|
-
deictic({ plugins: recommended() });
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Screenshots render in a Chromium: Playwright's (`npx playwright install chromium`), else Chrome or Edge if installed.
|
|
49
|
-
|
|
50
|
-
To fit what they choose instead: a plugin's options go under its name, `false` leaves one out
|
|
51
|
-
(`recommended({ tasks: { channel: 'ui' }, voice: false })`), and one outside the preset goes beside it
|
|
52
|
-
(`[...recommended(), tailwind()]`, `tailwind` from `deictic/tailwind`). Every plugin:
|
|
53
|
-
|
|
54
|
-
| Plugin | What it adds | Install too |
|
|
55
|
-
| --------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
56
|
-
| `tasks()` | The Task tab; `{ channel, project, labels }` route and name them (`deictic` by default) | `@vercel/board` |
|
|
57
|
-
| `screenshots()` | A shot of the page attached to a task; `{ renderer: dom() }` in-page | `rrweb-snapshot`, `playwright-core` (`modern-screenshot` for `dom()`) |
|
|
58
|
-
| `annotations()` | Marks on the page, on shots (Annotate) and in recordings | |
|
|
59
|
-
| `recordings()` | Record beside Attach: a screen recording attached to a task | `rrweb`, `rrweb-player` (its replay) |
|
|
60
|
-
| `voice()` | The mic, in recordings and as voice notes in a task | |
|
|
61
|
-
| `logs()` | The console's lines and uncaught errors in a recording; `{ levels }` | `@rrweb/rrweb-plugin-console-record` |
|
|
62
|
-
| `network()` | The page's requests in a recording, masked; `{ headers, body, mask, ignore }` | `@rrweb/rrweb-plugin-network-record` |
|
|
63
|
-
| `tailwind()` | Edit an element's classes in place; `{ css: 'src/index.css' }` names the theme's sheet | |
|
|
64
|
-
|
|
65
|
-
`deictic({ shortcut })` changes Alt-click, or `false` for none. The plugins' order is the tabs' order: keep theirs.
|
|
66
|
-
|
|
67
|
-
A build has nothing of deictic. Only for a deployed demo with no dev server, `deictic/vite` takes
|
|
68
|
-
`standalone: 'src/standalone.ts'`: deictic is then in the build, and that module's default export (a `Standalone`,
|
|
69
|
-
from `deictic`: `(request: Request) => Response`) answers in the page what the dev server would under `/__deictic/`
|
|
70
|
-
(`read` → `{ model }`, `apply` → `{ model, change: { label } }`, `undo`, `redo`, `history`, each plugin's routes).
|
|
71
|
-
What keeps a shot (`add`), a voice clip (`add`, then `more/<id>`, the last with `?last`) or a recording (`begin`,
|
|
72
|
-
`part/<id>?seq=<n>`, then `end/<id>` or `discard/<id>`) may name the `url` it's kept at. For a recording that's a
|
|
73
|
-
replay page the build publishes: `replayPage({ player, source })` from `deictic/recordings` is its HTML.
|
|
74
|
-
|
|
75
|
-
## The board
|
|
76
|
-
|
|
77
|
-
Tasks go to a Vercel Board. With nothing set, the dev server starts one on this machine and stops it as it stops:
|
|
78
|
-
`http://127.0.0.1:4100/api/board` (another port where that one's taken), its log in `.deictic/board`. It prints the
|
|
79
|
-
URL as it starts and keeps it in `.deictic/board.json`:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
export BOARD_PROFILE=claude # your name: what you post is yours, not the person's
|
|
83
|
-
node <skill>/scripts/vb.mjs whoami # krtgo/claude, and the board's URL
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
`vb.mjs` is the project's own `vb` (in `node_modules/.bin`, so rarely on the PATH), and like the other scripts here
|
|
87
|
-
it reads that file when `BOARD_URL` isn't set. A `vb` you run yourself needs the variable:
|
|
88
|
-
`export BOARD_URL=$(node -p "require('./.deictic/board.json').url")`. The board is there only while the dev server
|
|
89
|
-
runs.
|
|
90
|
-
|
|
91
|
-
For another board, set `BOARD_URL` for the dev server and for `vb` alike. For the team's, through `vercel login`,
|
|
92
|
-
with no `BOARD_URL`: `tasks({ board: board() })` in the bundler config (`board` from `@vercel/board`), or
|
|
93
|
-
`recommended({ tasks: { board: board() } })`. `board: local({ port, dir, inspect, args })`, with `local` from
|
|
94
|
-
`deictic/tasks`, is the board on this machine with those options (its port, its folder from the root, `false` for
|
|
95
|
-
none of its pages, more of `vb serve`'s arguments), and whatever `BOARD_URL` says.
|
|
96
|
-
|
|
97
|
-
## This skill
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npx skills add gkurt/deictic # or ./node_modules/deictic, the installed package's; -a <agent> to pick agents, -g for global
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Then restart the agent if it only reads skills as it starts.
|