deictic 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +150 -37
- package/README.md +4 -3
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.d.ts.map +1 -1
- package/dist/annotations/client.js +161 -176
- package/dist/annotations/client.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -11
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1007 -192
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/recommended/index.d.ts +2 -2
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +82 -153
- package/dist/recordings/client.js.map +1 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/shared/annotations.js +3 -4
- package/dist/shared/annotations.js.map +1 -1
- package/dist/shared/board.js +1 -1
- package/dist/shared/client.js +45 -2
- package/dist/shared/client.js.map +1 -1
- package/dist/shared/component.js +62 -0
- package/dist/shared/component.js.map +1 -0
- package/dist/shared/dom.js +79 -0
- package/dist/shared/dom.js.map +1 -0
- package/dist/shared/drawer.js +217 -0
- package/dist/shared/drawer.js.map +1 -0
- package/dist/shared/endpoints.js +34 -8
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +2 -1
- package/dist/shared/find.js.map +1 -1
- package/dist/shared/index.d.ts +124 -11
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +9 -19
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +105 -26
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +1 -1
- package/dist/shared/init.js +12 -10
- package/dist/shared/init.js.map +1 -1
- package/dist/shared/integration.d.ts +1 -1
- package/dist/shared/packages.js +1 -1
- package/dist/shared/recording.js +31 -3
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +72 -21
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +330 -166
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/vb.js +1 -1
- package/dist/shared/voice2.js +6 -4
- package/dist/shared/voice2.js.map +1 -1
- package/dist/shared/watch.js +14 -14
- package/dist/shared/watch.js.map +1 -1
- package/dist/tailwind/index.js +6 -2
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tasks/client.d.ts +2 -2
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +1829 -742
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +154 -57
- package/dist/voice/client.js.map +1 -1
- package/package.json +1 -1
- package/skills/deictic/SKILL.md +22 -28
- package/src/cli/find.ts +3 -1
- package/src/cli/init.ts +13 -11
- package/src/cli/recording.ts +34 -3
- package/src/cli/task.ts +94 -23
- package/src/cli/voice.ts +9 -4
- package/src/cli/watch.ts +14 -13
- package/src/client/away.ts +3 -1
- package/src/client/component.ts +98 -0
- package/src/client/dom.ts +70 -0
- package/src/client/drawer.ts +258 -0
- package/src/client/index.ts +220 -128
- package/src/client/lightbox.ts +8 -8
- package/src/client/lighting.ts +279 -0
- package/src/client/style.ts +263 -44
- package/src/client/tools.ts +279 -0
- package/src/client/tooltip.ts +25 -5
- package/src/client/tray.ts +48 -0
- package/src/index.ts +121 -10
- package/src/plugins/annotations/client.ts +103 -129
- package/src/plugins/annotations/draw.ts +68 -72
- package/src/plugins/annotations/index.ts +12 -19
- package/src/plugins/recordings/client.ts +89 -167
- package/src/plugins/screenshots/client.ts +53 -2
- package/src/plugins/tailwind/index.ts +6 -2
- package/src/plugins/tasks/client.ts +219 -749
- package/src/plugins/tasks/composer.ts +797 -0
- package/src/plugins/tasks/drawer.ts +516 -0
- package/src/plugins/tasks/index.ts +459 -192
- package/src/plugins/tasks/pins.ts +275 -0
- package/src/plugins/tasks/store.ts +132 -0
- package/src/plugins/voice/client.ts +96 -5
- package/src/tools/endpoints.ts +18 -7
- package/src/tools/source.ts +25 -5
- package/skills/deictic/references/recordings.md +0 -13
- package/skills/deictic/references/tasks.md +0 -21
- package/skills/deictic/references/watch.md +0 -17
package/dist/voice/client.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { u as toolButton } from "../shared/dom.js";
|
|
2
|
+
import { n as playMark, r as trayed } from "../shared/drawer.js";
|
|
3
|
+
import { n as liveWaveform } from "../shared/waveform.js";
|
|
1
4
|
import { n as defineClientPlugin } from "../shared/src.js";
|
|
2
5
|
// src/plugins/voice/client.ts
|
|
3
6
|
/**
|
|
@@ -6,7 +9,24 @@ import { n as defineClientPlugin } from "../shared/src.js";
|
|
|
6
9
|
* the rest to `more/<id>`. So a take the page leaves in the middle of (a recording that goes on to another
|
|
7
10
|
* page) is kept up to there. `stop` sends the last of it and lets the mic go, so the browser's recording
|
|
8
11
|
* light goes out between takes.
|
|
12
|
+
*
|
|
13
|
+
* Its tool in the tool panel is the mic: on, it's a take, with its time and the mic's live waveform, so it's plain
|
|
14
|
+
* it hears; off again, the clip goes in the tray, for the next task. While a recording is going the mic is the
|
|
15
|
+
* recording's own, and this one is away.
|
|
9
16
|
*/
|
|
17
|
+
const STYLE = `
|
|
18
|
+
.voice-tool .time { font: 12px ui-monospace, monospace; }
|
|
19
|
+
.voice-tool .wave { width: 44px; height: 18px; }
|
|
20
|
+
.tool-panel.vertical .voice-tool .wave { width: 28px; }
|
|
21
|
+
.voice-tool .mic[aria-pressed='true'], .voice-tool .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }
|
|
22
|
+
/* The recordings plugin's own mic is in the panel while one is going (its \`.recorder.going\`): one mic at a time. */
|
|
23
|
+
.tool-panel:has(.recorder.going) :is(.voice-tool, .sep:has(+ .voice-tool)) { display: none; }
|
|
24
|
+
`;
|
|
25
|
+
const MIC = "<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>";
|
|
26
|
+
const clock = (ms) => {
|
|
27
|
+
const s = Math.floor(ms / 1e3);
|
|
28
|
+
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
29
|
+
};
|
|
10
30
|
/** What the browser can record, best first: Opus in WebM where it can (Chrome, Firefox), else MP4 (Safari). */
|
|
11
31
|
const TYPES = [
|
|
12
32
|
"audio/webm;codecs=opus",
|
|
@@ -18,69 +38,146 @@ const TYPES = [
|
|
|
18
38
|
const EVERY = 1e3;
|
|
19
39
|
var client_default = defineClientPlugin({
|
|
20
40
|
name: "voice",
|
|
21
|
-
setup: ({ base, request
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
setup: ({ base, request, tools, tray, drawer, lightbox }) => {
|
|
42
|
+
const start = async () => {
|
|
43
|
+
if (typeof MediaRecorder === "undefined" || navigator.mediaDevices?.getUserMedia === void 0) throw new Error("voice: this browser can't record the mic here: it needs a secure page (https or localhost)");
|
|
44
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true }).catch((e) => {
|
|
45
|
+
throw new Error(`voice: the mic isn't available: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
46
|
+
});
|
|
47
|
+
const mimeType = TYPES.find((t) => MediaRecorder.isTypeSupported(t));
|
|
48
|
+
const recorder = new MediaRecorder(stream, mimeType === void 0 ? {} : { mimeType });
|
|
49
|
+
const typeOf = () => (recorder.mimeType || mimeType || "audio/webm").split(";")[0];
|
|
50
|
+
let id;
|
|
51
|
+
let url;
|
|
52
|
+
let sent = Promise.resolve();
|
|
53
|
+
const send = (body, last = false) => {
|
|
54
|
+
sent = sent.then(async () => {
|
|
55
|
+
if (id === void 0 && body === void 0) throw new Error("voice: the clip is empty: speak for a moment longer");
|
|
56
|
+
const res = await request(id === void 0 ? "add" : `more/${id}${last ? "?last" : ""}`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: { "content-type": typeOf() },
|
|
59
|
+
...body ? { body } : {}
|
|
60
|
+
});
|
|
61
|
+
const answer = await res.json();
|
|
62
|
+
if (answer.id === void 0) throw new Error(`voice: ${answer.problem ?? res.statusText}`);
|
|
63
|
+
id = answer.id;
|
|
64
|
+
url = answer.url ?? url;
|
|
39
65
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
return sent;
|
|
67
|
+
};
|
|
68
|
+
recorder.addEventListener("dataavailable", (e) => {
|
|
69
|
+
if (e.data.size > 0) send(new Blob([e.data], { type: typeOf() })).catch(() => {});
|
|
70
|
+
});
|
|
71
|
+
const started = Date.now();
|
|
72
|
+
recorder.start(EVERY);
|
|
73
|
+
const release = () => {
|
|
74
|
+
for (const track of stream.getTracks()) track.stop();
|
|
75
|
+
};
|
|
76
|
+
const ended = () => new Promise((done) => {
|
|
77
|
+
if (recorder.state === "inactive") return done();
|
|
78
|
+
recorder.addEventListener("stop", () => done(), { once: true });
|
|
79
|
+
recorder.stop();
|
|
44
80
|
});
|
|
45
|
-
return
|
|
81
|
+
return {
|
|
82
|
+
started,
|
|
83
|
+
stream,
|
|
84
|
+
soFar: () => id === void 0 ? void 0 : {
|
|
85
|
+
id,
|
|
86
|
+
duration: Date.now() - started
|
|
87
|
+
},
|
|
88
|
+
cancel: () => {
|
|
89
|
+
ended().then(release);
|
|
90
|
+
},
|
|
91
|
+
stop: async () => {
|
|
92
|
+
await ended();
|
|
93
|
+
release();
|
|
94
|
+
const duration = Date.now() - started;
|
|
95
|
+
await send(void 0, true);
|
|
96
|
+
return {
|
|
97
|
+
id,
|
|
98
|
+
url: url ?? `${base}__deictic/plugins/voice/clip/${id}`,
|
|
99
|
+
duration,
|
|
100
|
+
type: typeOf()
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
46
104
|
};
|
|
47
|
-
|
|
48
|
-
|
|
105
|
+
const group = Object.assign(document.createElement("div"), { className: "tool-group voice-tool" });
|
|
106
|
+
const time = Object.assign(document.createElement("span"), {
|
|
107
|
+
className: "time",
|
|
108
|
+
hidden: true
|
|
49
109
|
});
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (const track of stream.getTracks()) track.stop();
|
|
54
|
-
};
|
|
55
|
-
const ended = () => new Promise((done) => {
|
|
56
|
-
if (recorder.state === "inactive") return done();
|
|
57
|
-
recorder.addEventListener("stop", () => done(), { once: true });
|
|
58
|
-
recorder.stop();
|
|
110
|
+
const wave = Object.assign(document.createElement("canvas"), {
|
|
111
|
+
className: "wave",
|
|
112
|
+
hidden: true
|
|
59
113
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
let take;
|
|
115
|
+
let busy = Promise.resolve();
|
|
116
|
+
const problem = (e) => {
|
|
117
|
+
mic.classList.add("problem");
|
|
118
|
+
mic.title = e instanceof Error ? e.message : String(e);
|
|
119
|
+
};
|
|
120
|
+
const on = async () => {
|
|
121
|
+
const mine = await start();
|
|
122
|
+
take = mine;
|
|
123
|
+
const unkeep = tools.keep();
|
|
124
|
+
const stopWave = liveWaveform(wave, mine.stream, {
|
|
125
|
+
played: "#ef4444",
|
|
126
|
+
rest: "#52525b"
|
|
127
|
+
});
|
|
128
|
+
const tick = () => time.textContent = clock(Date.now() - mine.started);
|
|
129
|
+
tick();
|
|
130
|
+
const ticking = setInterval(tick, 250);
|
|
131
|
+
time.hidden = wave.hidden = false;
|
|
132
|
+
mic.setAttribute("aria-pressed", "true");
|
|
133
|
+
mic.title = "Stop";
|
|
134
|
+
return async () => {
|
|
135
|
+
take = void 0;
|
|
136
|
+
clearInterval(ticking);
|
|
137
|
+
stopWave();
|
|
138
|
+
time.hidden = wave.hidden = true;
|
|
139
|
+
mic.setAttribute("aria-pressed", "false");
|
|
140
|
+
mic.title = "Voice";
|
|
141
|
+
unkeep();
|
|
142
|
+
const clip = await mine.stop();
|
|
143
|
+
tray.add("voice", clip.id, clip);
|
|
144
|
+
};
|
|
82
145
|
};
|
|
83
|
-
|
|
146
|
+
let off;
|
|
147
|
+
const mic = toolButton(MIC, "Voice", "K", () => {
|
|
148
|
+
busy = busy.then(async () => {
|
|
149
|
+
mic.classList.remove("problem");
|
|
150
|
+
try {
|
|
151
|
+
if (off === void 0) off = await on();
|
|
152
|
+
else {
|
|
153
|
+
const ending = off;
|
|
154
|
+
off = void 0;
|
|
155
|
+
await ending();
|
|
156
|
+
}
|
|
157
|
+
} catch (e) {
|
|
158
|
+
problem(e);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
mic.classList.add("mic");
|
|
163
|
+
mic.setAttribute("aria-pressed", "false");
|
|
164
|
+
group.append(Object.assign(document.createElement("style"), { textContent: STYLE }), mic, time, wave);
|
|
165
|
+
tools.add(group, { section: "capture" });
|
|
166
|
+
drawer.add(trayed({ tray }, "voice", "Voice notes", (item, i, all) => {
|
|
167
|
+
const { url, duration } = item.value;
|
|
168
|
+
const name = `${all.length === 1 ? "Voice" : `Voice ${i + 1}`} ${clock(duration)}`;
|
|
169
|
+
return {
|
|
170
|
+
label: [playMark(), name],
|
|
171
|
+
open: (from) => lightbox([{
|
|
172
|
+
kind: "audio",
|
|
173
|
+
url,
|
|
174
|
+
title: name
|
|
175
|
+
}], { from })
|
|
176
|
+
};
|
|
177
|
+
}));
|
|
178
|
+
addEventListener("pagehide", () => take?.cancel());
|
|
179
|
+
return { start };
|
|
180
|
+
}
|
|
84
181
|
});
|
|
85
182
|
export { client_default as default };
|
|
86
183
|
|
package/dist/voice/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/voice/client.ts"],"sourcesContent":["/**\n * The voice plugin's page half: `start()` asks for the mic (the browser asks the user the first time) and\n * records it with `MediaRecorder`, sending what's spoken each second: the take's start to the `add` route,\n * the rest to `more/<id>`. So a take the page leaves in the middle of (a recording that goes on to another\n * page) is kept up to there. `stop` sends the last of it and lets the mic go, so the browser's recording\n * light goes out between takes.\n */\nimport { defineClientPlugin } from '#src/index.ts';\n\nimport type { Clip, Voice } from './index.ts';\n\n/** What the browser can record, best first: Opus in WebM where it can (Chrome, Firefox), else MP4 (Safari). */\nconst TYPES = ['audio/webm;codecs=opus', 'audio/webm', 'audio/ogg;codecs=opus', 'audio/mp4'];\n/** How often what's spoken is sent, in milliseconds: what a page load can lose of a take. */\nconst EVERY = 1000;\n\nexport default defineClientPlugin<never, never, Voice>({\n name: 'voice',\n setup: ({ base, request }) => ({\n start: async () => {\n if (typeof MediaRecorder === 'undefined' || navigator.mediaDevices?.getUserMedia === undefined)\n throw new Error(\"voice: this browser can't record the mic here: it needs a secure page (https or localhost)\");\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true }).catch((e: unknown) => {\n throw new Error(`voice: the mic isn't available: ${e instanceof Error ? e.message : String(e)}`, { cause: e });\n });\n const mimeType = TYPES.find((t) => MediaRecorder.isTypeSupported(t));\n const recorder = new MediaRecorder(stream, mimeType === undefined ? {} : { mimeType });\n const typeOf = () => (recorder.mimeType || mimeType || 'audio/webm').split(';')[0]!;\n // The clip, once its start is kept, and where it is, where what keeps it says (a `standalone` build's does).\n let id: string | undefined;\n let url: string | undefined;\n // One request at a time, in the order spoken: the audio is its pieces end to end. The first problem ends the sending.\n let sent: Promise<void> = Promise.resolve();\n const send = (body: Blob | undefined, last = false) => {\n sent = sent.then(async () => {\n if (id === undefined && body === undefined) throw new Error('voice: the clip is empty: speak for a moment longer');\n const route = id === undefined ? 'add' : `more/${id}${last ? '?last' : ''}`;\n const res = await request(route, { method: 'POST', headers: { 'content-type': typeOf() }, ...(body ? { body } : {}) });\n const answer = (await res.json()) as { id?: string; url?: string; problem?: string };\n if (answer.id === undefined) throw new Error(`voice: ${answer.problem ?? res.statusText}`);\n id = answer.id;\n url = answer.url ?? url;\n });\n return sent;\n };\n recorder.addEventListener('dataavailable', (e) => {\n // Heard only at `stop`, with the rest: a problem here is that one's.\n if (e.data.size > 0) send(new Blob([e.data], { type: typeOf() })).catch(() => {});\n });\n const started = Date.now();\n recorder.start(EVERY);\n const release = () => {\n for (const track of stream.getTracks()) track.stop();\n };\n const ended = () =>\n new Promise<void>((done) => {\n if (recorder.state === 'inactive') return done();\n recorder.addEventListener('stop', () => done(), { once: true });\n recorder.stop();\n });\n\n return {\n started,\n stream,\n soFar: () => (id === undefined ? undefined : { id, duration: Date.now() - started }),\n cancel: () => {\n void ended().then(release);\n },\n stop: async (): Promise<Clip> => {\n await ended();\n release();\n const duration = Date.now() - started;\n // The last piece came as it stopped. This says it's over, to what names the clip's place only then.\n await send(undefined, true);\n return { id: id!, url: url ?? `${base}__deictic/plugins/voice/clip/${id}`, duration, type: typeOf() };\n },\n };\n },\n }),\n});\n"],"mappings":";;;;;;;;;;AAYA,MAAM,QAAQ;CAAC;CAA0B;CAAc;CAAyB;AAAW;;AAE3F,MAAM,QAAQ;AAEd,IAAA,iBAAe,mBAAwC;CACrD,MAAM;CACN,QAAQ,EAAE,MAAM,eAAe,EAC7B,OAAO,YAAY;EACjB,IAAI,OAAO,kBAAkB,eAAe,UAAU,cAAc,iBAAiB,KAAA,GACnF,MAAM,IAAI,MAAM,4FAA4F;EAC9G,MAAM,SAAS,MAAM,UAAU,aAAa,aAAa,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,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O,UAAU,GAAG,MAAM,KAAK;EACrD;EACA,MAAM,cACJ,IAAI,SAAe,SAAS;GAC1B,IAAI,SAAS,UAAU,YAAY,OAAO,KAAK;GAC/C,SAAS,iBAAiB,cAAc,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;GAC9D,SAAS,KAAK;EAChB,CAAC;EAEH,OAAO;GACL;GACA;GACA,aAAc,OAAO,KAAA,IAAY,KAAA,IAAY;IAAE;IAAI,UAAU,KAAK,IAAI,IAAI;GAAQ;GAClF,cAAc;IACP,MAAM,CAAC,CAAC,KAAK,OAAO;GAC3B;GACA,MAAM,YAA2B;IAC/B,MAAM,MAAM;IACZ,QAAQ;IACR,MAAM,WAAW,KAAK,IAAI,IAAI;IAE9B,MAAM,KAAK,KAAA,GAAW,IAAI;IAC1B,OAAO;KAAM;KAAK,KAAK,OAAO,GAAG,KAAK,+BAA+B;KAAM;KAAU,MAAM,OAAO;IAAE;GACtG;EACF;CACF,EACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/voice/client.ts"],"sourcesContent":["/**\n * The voice plugin's page half: `start()` asks for the mic (the browser asks the user the first time) and\n * records it with `MediaRecorder`, sending what's spoken each second: the take's start to the `add` route,\n * the rest to `more/<id>`. So a take the page leaves in the middle of (a recording that goes on to another\n * page) is kept up to there. `stop` sends the last of it and lets the mic go, so the browser's recording\n * light goes out between takes.\n *\n * Its tool in the tool panel is the mic: on, it's a take, with its time and the mic's live waveform, so it's plain\n * it hears; off again, the clip goes in the tray, for the next task. While a recording is going the mic is the\n * recording's own, and this one is away.\n */\nimport { toolButton } from '#src/client/dom.ts';\nimport { playMark, trayed } from '#src/client/drawer.ts';\nimport { liveWaveform } from '#src/client/waveform.ts';\nimport { defineClientPlugin } from '#src/index.ts';\n\nimport type { Clip, Take, Voice } from './index.ts';\n\nconst STYLE = `\n.voice-tool .time { font: 12px ui-monospace, monospace; }\n.voice-tool .wave { width: 44px; height: 18px; }\n.tool-panel.vertical .voice-tool .wave { width: 28px; }\n.voice-tool .mic[aria-pressed='true'], .voice-tool .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }\n/* The recordings plugin's own mic is in the panel while one is going (its \\`.recorder.going\\`): one mic at a time. */\n.tool-panel:has(.recorder.going) :is(.voice-tool, .sep:has(+ .voice-tool)) { display: none; }\n`;\nconst MIC = '<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>';\n\nconst clock = (ms: number) => {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;\n};\n\n/** What the browser can record, best first: Opus in WebM where it can (Chrome, Firefox), else MP4 (Safari). */\nconst TYPES = ['audio/webm;codecs=opus', 'audio/webm', 'audio/ogg;codecs=opus', 'audio/mp4'];\n/** How often what's spoken is sent, in milliseconds: what a page load can lose of a take. */\nconst EVERY = 1000;\n\nexport default defineClientPlugin<never, never, Voice>({\n name: 'voice',\n setup: ({ base, request, tools, tray, drawer, lightbox }) => {\n const start = async (): Promise<Take> => {\n if (typeof MediaRecorder === 'undefined' || navigator.mediaDevices?.getUserMedia === undefined)\n throw new Error(\"voice: this browser can't record the mic here: it needs a secure page (https or localhost)\");\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true }).catch((e: unknown) => {\n throw new Error(`voice: the mic isn't available: ${e instanceof Error ? e.message : String(e)}`, { cause: e });\n });\n const mimeType = TYPES.find((t) => MediaRecorder.isTypeSupported(t));\n const recorder = new MediaRecorder(stream, mimeType === undefined ? {} : { mimeType });\n const typeOf = () => (recorder.mimeType || mimeType || 'audio/webm').split(';')[0]!;\n // The clip, once its start is kept, and where it is, where what keeps it says (a `standalone` build's does).\n let id: string | undefined;\n let url: string | undefined;\n // One request at a time, in the order spoken: the audio is its pieces end to end. The first problem ends the sending.\n let sent: Promise<void> = Promise.resolve();\n const send = (body: Blob | undefined, last = false) => {\n sent = sent.then(async () => {\n if (id === undefined && body === undefined) throw new Error('voice: the clip is empty: speak for a moment longer');\n const route = id === undefined ? 'add' : `more/${id}${last ? '?last' : ''}`;\n const res = await request(route, { method: 'POST', headers: { 'content-type': typeOf() }, ...(body ? { body } : {}) });\n const answer = (await res.json()) as { id?: string; url?: string; problem?: string };\n if (answer.id === undefined) throw new Error(`voice: ${answer.problem ?? res.statusText}`);\n id = answer.id;\n url = answer.url ?? url;\n });\n return sent;\n };\n recorder.addEventListener('dataavailable', (e) => {\n // Heard only at `stop`, with the rest: a problem here is that one's.\n if (e.data.size > 0) send(new Blob([e.data], { type: typeOf() })).catch(() => {});\n });\n const started = Date.now();\n recorder.start(EVERY);\n const release = () => {\n for (const track of stream.getTracks()) track.stop();\n };\n const ended = () =>\n new Promise<void>((done) => {\n if (recorder.state === 'inactive') return done();\n recorder.addEventListener('stop', () => done(), { once: true });\n recorder.stop();\n });\n\n return {\n started,\n stream,\n soFar: () => (id === undefined ? undefined : { id, duration: Date.now() - started }),\n cancel: () => {\n void ended().then(release);\n },\n stop: async (): Promise<Clip> => {\n await ended();\n release();\n const duration = Date.now() - started;\n // The last piece came as it stopped. This says it's over, to what names the clip's place only then.\n await send(undefined, true);\n return { id: id!, url: url ?? `${base}__deictic/plugins/voice/clip/${id}`, duration, type: typeOf() };\n },\n };\n };\n\n const group = Object.assign(document.createElement('div'), { className: 'tool-group voice-tool' });\n const time = Object.assign(document.createElement('span'), { className: 'time', hidden: true });\n const wave = Object.assign(document.createElement('canvas'), { className: 'wave', hidden: true });\n let take: Take | undefined;\n // What the mic is doing (asking for it, keeping a take): the next press waits for it.\n let busy: Promise<void> = Promise.resolve();\n const problem = (e: unknown) => {\n mic.classList.add('problem');\n mic.title = e instanceof Error ? e.message : String(e);\n };\n const on = async () => {\n const mine = await start();\n take = mine;\n // The panel stays while the mic is on: its button is what turns it off.\n const unkeep = tools.keep();\n const stopWave = liveWaveform(wave, mine.stream, { played: '#ef4444', rest: '#52525b' });\n const tick = () => (time.textContent = clock(Date.now() - mine.started));\n tick();\n const ticking = setInterval(tick, 250);\n time.hidden = wave.hidden = false;\n mic.setAttribute('aria-pressed', 'true');\n mic.title = 'Stop';\n return async () => {\n take = undefined;\n clearInterval(ticking);\n stopWave();\n time.hidden = wave.hidden = true;\n mic.setAttribute('aria-pressed', 'false');\n mic.title = 'Voice';\n unkeep();\n const clip = await mine.stop();\n tray.add('voice', clip.id, clip);\n };\n };\n let off: (() => Promise<void>) | undefined;\n const mic = toolButton(MIC, 'Voice', 'K', () => {\n busy = busy.then(async () => {\n mic.classList.remove('problem');\n try {\n if (off === undefined) {\n off = await on();\n } else {\n const ending = off;\n off = undefined;\n await ending();\n }\n } catch (e) {\n problem(e);\n }\n });\n });\n mic.classList.add('mic');\n mic.setAttribute('aria-pressed', 'false');\n group.append(Object.assign(document.createElement('style'), { textContent: STYLE }), mic, time, wave);\n // Beside the other tools that capture the page: a shot, a recording, the mic.\n tools.add(group, { section: 'capture' });\n // In the drawer until a task takes them: each plays in the lightbox.\n drawer.add(\n trayed({ tray }, 'voice', 'Voice notes', (item, i, all) => {\n const { url, duration } = item.value as Clip;\n const name = `${all.length === 1 ? 'Voice' : `Voice ${i + 1}`} ${clock(duration)}`;\n return { label: [playMark(), name], open: (from) => lightbox([{ kind: 'audio', url, title: name }], { from }) };\n }),\n );\n // A take the page leaves in the middle of is kept as far as it's sent, and the mic let go.\n addEventListener('pagehide', () => take?.cancel());\n\n return { start };\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,QAAQ;;;;;;;;AAQd,MAAM,MAAM;AAEZ,MAAM,SAAS,OAAe;CAC5B,MAAM,IAAI,KAAK,MAAM,KAAK,GAAI;CAC9B,OAAO,GAAG,KAAK,MAAM,IAAI,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAChE;;AAGA,MAAM,QAAQ;CAAC;CAA0B;CAAc;CAAyB;AAAW;;AAE3F,MAAM,QAAQ;A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,IACL,OAAO,EAAE,KAAK,GAAG,SAAS,gBAAgB,MAAM,GAAG,QAAQ;GACzD,MAAM,EAAE,KAAK,aAAa,KAAK;GAC/B,MAAM,OAAO,GAAG,IAAI,WAAW,IAAI,UAAU,SAAS,IAAI,IAAI,GAAG,MAAM,QAAQ;GAC/E,OAAO;IAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IAAG,OAAO,SAAS,SAAS,CAAC;KAAE,MAAM;KAAS;KAAK,OAAO;IAAK,CAAC,GAAG,EAAE,KAAK,CAAC;GAAE;EAChH,CAAC,CACH;EAEA,iBAAiB,kBAAkB,MAAM,OAAO,CAAC;EAEjD,OAAO,EAAE,MAAM;CACjB;AACF,CAAC"}
|
package/package.json
CHANGED
package/skills/deictic/SKILL.md
CHANGED
|
@@ -6,35 +6,29 @@ description: Work the UI tasks people leave from their running app with deictic
|
|
|
6
6
|
# deictic
|
|
7
7
|
|
|
8
8
|
A person Alt-clicks an element in their dev server and leaves a task about it on a Vercel Board (channel `deictic`
|
|
9
|
-
unless
|
|
10
|
-
carry screenshots, recordings and voice.
|
|
9
|
+
unless `tasks({ channel })` says otherwise): the element's file, line and tag, maybe screenshots, recordings and voice.
|
|
11
10
|
|
|
12
|
-
Run everything in the project
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
you post is yours, by the agent your environment names (`claude`, `codex`), not the person's; where `watch` says it
|
|
16
|
-
can't tell, set `BOARD_PROFILE=<your name>` on each command.
|
|
17
|
-
|
|
18
|
-
Not set up yet (no `deictic` in `package.json`): ask the person, then `npx deictic init --no-skill`.
|
|
11
|
+
Run everything in the project as `npx deictic <command>` (`--help` for any), or with its own runner (`bunx deictic`,
|
|
12
|
+
`pnpm exec deictic`, `yarn deictic`). `vb` below is `npx deictic vb`, the board's CLI. What a command prints says
|
|
13
|
+
what to do next: do it. Not set up (no `deictic` in `package.json`): ask the person, then `npx deictic init --no-skill`.
|
|
19
14
|
|
|
20
15
|
## The loop
|
|
21
16
|
|
|
22
|
-
1. **Watch**: `npx deictic watch`,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
deictic brings it.
|
|
17
|
+
1. **Watch**: `npx deictic watch`, a line per task, reply or cancellation. Run it as a monitor (each line an event)
|
|
18
|
+
with the longest timeout, started again when it times out; else in the background with `--once`, started again
|
|
19
|
+
after each event; else `--once` in the foreground after each task, telling the person it holds the session.
|
|
20
|
+
Never sleep-poll or detach it (`nohup`, `&`).
|
|
21
|
+
2. **Claim and read**, one task at a time: `vb tasks claim 68 --lease 30m` (`vb tasks renew 68` for longer), then
|
|
22
|
+
`npx deictic task 68 --out <dir>`. Look at every screenshot, and read the other open tasks it lists: often one
|
|
23
|
+
change. The element is one place: they may mean its parent, a sibling, or every element its line renders.
|
|
24
|
+
3. **Work it**: change the source, then look at the page at the task's viewport. The page is theirs (host, account,
|
|
25
|
+
data): reach the same screen in the app as the project runs it, never use their session, and say what you
|
|
26
|
+
couldn't see.
|
|
27
|
+
4. **Complete**: `vb tasks complete 68 "<what changed, where>"`, say it in a line, and back to the watch.
|
|
28
|
+
|
|
29
|
+
Unsure what they mean: `vb reply 68 "<what you understood, and the question>"`, then `vb tasks block 68 "<why>"`; the
|
|
30
|
+
watch says `reply on` when they answer. Can't be done: `vb tasks fail 68 "<why, and what would make it possible>"`.
|
|
31
|
+
Never complete, fail or cancel a task you didn't claim.
|
|
32
|
+
|
|
33
|
+
What they attach (screenshots, recordings, voice) may hold personal data: never send it off the machine unless they
|
|
34
|
+
ask.
|
package/src/cli/find.ts
CHANGED
|
@@ -48,7 +48,9 @@ export async function loadRecording(ref: string | undefined, nth = 1): Promise<F
|
|
|
48
48
|
const file = files[nth - 1];
|
|
49
49
|
if (file === undefined) fail(`Task #${root.id} has ${files.length} recording(s), not a ${nth}th.`);
|
|
50
50
|
const id = file.name.slice('recording-'.length, -'.json'.length);
|
|
51
|
-
|
|
51
|
+
// Its `deictic.recording.N.replay` label, or in the text of a task added before that was a label.
|
|
52
|
+
const where = (text: string) => new RegExp(`https?://\\S+/replay/${id}`).exec(text)?.[0];
|
|
53
|
+
const replay = Object.values(root.labels).map(where).find(Boolean) ?? where(root.text);
|
|
52
54
|
return { kept: parsed(fetched(root, file.name)), id, replay, task: root };
|
|
53
55
|
}
|
|
54
56
|
if (/^https?:/.test(ref)) {
|
package/src/cli/init.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { installCommand, packageManager, readJson, runnerOf } from '#src/tools/p
|
|
|
18
18
|
|
|
19
19
|
import { fail } from './board.ts';
|
|
20
20
|
import { addToBunfig, addToServer, BY_HAND, MODULE, PLUGIN, serverOf } from './bun.ts';
|
|
21
|
-
import { addFirst, addImports
|
|
21
|
+
import { addFirst, addImports } from './edit.ts';
|
|
22
22
|
|
|
23
23
|
export type Bundler = 'next' | 'astro' | 'vite' | 'rspack' | 'webpack' | 'bun';
|
|
24
24
|
|
|
@@ -62,7 +62,7 @@ const SETUPS: Record<Exclude<Bundler, 'bun'>, Setup> = {
|
|
|
62
62
|
name: 'deictic',
|
|
63
63
|
list: 'plugins',
|
|
64
64
|
value: `deictic(${PLUGINS})`,
|
|
65
|
-
snippet: `export default defineConfig({ plugins: [
|
|
65
|
+
snippet: `export default defineConfig({ plugins: [deictic(${PLUGINS}), react()] });`,
|
|
66
66
|
},
|
|
67
67
|
rspack: {
|
|
68
68
|
files: extensions('rspack.config'),
|
|
@@ -177,7 +177,7 @@ function exportedOf(program: Program): { value: Expression; commonjs: boolean }
|
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* The config with deictic added, or nothing where it can't tell where: deictic's import beside the config's, and its
|
|
180
|
-
* plugin
|
|
180
|
+
* plugin first in the list (`plugins`, `integrations`), as its marks count lines and columns in the code it's given, or the config wrapped (Next's). Written in the config's quotes,
|
|
181
181
|
* semicolons and line endings.
|
|
182
182
|
*/
|
|
183
183
|
export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code: string): string | undefined {
|
|
@@ -186,7 +186,6 @@ export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code
|
|
|
186
186
|
if (errors.length > 0) return undefined;
|
|
187
187
|
const exported = exportedOf(program);
|
|
188
188
|
if (exported === undefined) return undefined;
|
|
189
|
-
const eol = eolOf(code);
|
|
190
189
|
const out = new MagicString(code);
|
|
191
190
|
|
|
192
191
|
if (setup.wrap) {
|
|
@@ -194,7 +193,7 @@ export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code
|
|
|
194
193
|
out.appendRight(exported.value.end, `, ${setup.value})`);
|
|
195
194
|
} else {
|
|
196
195
|
const object = objectOf(exported.value, program);
|
|
197
|
-
if (object === undefined || !addTo(out, code, object, setup.list!, setup.value
|
|
196
|
+
if (object === undefined || !addTo(out, code, object, setup.list!, setup.value)) return undefined;
|
|
198
197
|
}
|
|
199
198
|
|
|
200
199
|
const lines: [string, string][] = [
|
|
@@ -205,8 +204,12 @@ export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code
|
|
|
205
204
|
return out.toString();
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
/**
|
|
209
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Adds `value` first in the object's array `list`, or the list with it, as the object is laid out. False where `list`
|
|
209
|
+
* isn't an array. First, since a plugin before deictic's that changes a module (both `pre` under Vite) leaves the
|
|
210
|
+
* page's marks pointing at its code, not the file.
|
|
211
|
+
*/
|
|
212
|
+
function addTo(out: MagicString, code: string, object: ObjectExpression, list: string, value: string): boolean {
|
|
210
213
|
const property = object.properties.find(
|
|
211
214
|
(p) =>
|
|
212
215
|
p.type === 'Property' &&
|
|
@@ -218,13 +221,12 @@ function addTo(out: MagicString, code: string, object: ObjectExpression, list: s
|
|
|
218
221
|
let array = property.value;
|
|
219
222
|
while (array.type === 'TSAsExpression' || array.type === 'TSSatisfiesExpression') array = array.expression;
|
|
220
223
|
if (array.type !== 'ArrayExpression') return false;
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
224
|
+
const first = array.elements.find((e) => e !== null);
|
|
225
|
+
if (first == null) {
|
|
223
226
|
out.appendLeft(array.start + 1, value);
|
|
224
227
|
return true;
|
|
225
228
|
}
|
|
226
|
-
|
|
227
|
-
out.appendLeft(last.end, multiline ? `,${eol}${indentAt(code, last.start)}${value}` : `, ${value}`);
|
|
229
|
+
addFirst(out, code, array.start, first, value);
|
|
228
230
|
return true;
|
|
229
231
|
}
|
|
230
232
|
addFirst(out, code, object.start, object.properties[0], `${list}: [${value}]`);
|
package/src/cli/recording.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* clips, the page's console and its requests where the project records them, and the end. Or the part of it asked
|
|
5
5
|
* for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, and `--full` for all of each line.
|
|
6
6
|
*/
|
|
7
|
+
import { relative } from 'node:path';
|
|
8
|
+
|
|
7
9
|
import type { Shape } from '#src/plugins/annotations/index.ts';
|
|
8
10
|
|
|
9
11
|
import { clock, fail, ME } from './board.ts';
|
|
@@ -228,7 +230,9 @@ function timelineOf(events: Event[], voice: { id: string; at: number; duration:
|
|
|
228
230
|
const added = now.filter((a) => !before.has(key(a)));
|
|
229
231
|
const removed = marks.filter((a) => !after.has(key(a)));
|
|
230
232
|
if (added.length > 0 || removed.length > 0) {
|
|
231
|
-
|
|
233
|
+
// All of them cleared (a task added, the page left) is said as that: each was said as it was drawn.
|
|
234
|
+
const gone = now.length === 0 && removed.length > 1 ? [`− all ${removed.length} marks`] : removed.map((a) => `− ${shapeOf(a)}`);
|
|
235
|
+
const text = [...added.map((a) => `+ ${shapeOf(a)}`), ...gone].join('; ');
|
|
232
236
|
push(t, 'marks', text, { marks: now.map((a) => a.shape) });
|
|
233
237
|
}
|
|
234
238
|
marks = now;
|
|
@@ -295,6 +299,32 @@ function timelineOf(events: Event[], voice: { id: string; at: number; duration:
|
|
|
295
299
|
return timeline.sort((a, b) => a.t - b.t);
|
|
296
300
|
}
|
|
297
301
|
|
|
302
|
+
/**
|
|
303
|
+
* The page's own URLs as paths, in a line of text: `http://localhost:5180/src/App.tsx?t=1712:9:7` is `/src/App.tsx:9:7`,
|
|
304
|
+
* and a file Vite serves from outside its root (`/@fs/S:/…/dist/client.js`) is that file's path from here. The header
|
|
305
|
+
* says the origin once; `--json` keeps every URL whole.
|
|
306
|
+
*/
|
|
307
|
+
function shortener(page: string): (text: string) => string {
|
|
308
|
+
let origin: string;
|
|
309
|
+
try {
|
|
310
|
+
origin = new URL(page).origin;
|
|
311
|
+
} catch {
|
|
312
|
+
return (text) => text;
|
|
313
|
+
}
|
|
314
|
+
const quoted = origin.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
315
|
+
// A Windows path has a drive's colon in it, which a line and column also follow.
|
|
316
|
+
const fs = new RegExp(`${quoted}/@fs/([A-Za-z]:)?([^\\s?:)]+)`, 'g');
|
|
317
|
+
const own = new RegExp(`${quoted}(?=/)`, 'g');
|
|
318
|
+
return (text) =>
|
|
319
|
+
text
|
|
320
|
+
.replace(fs, (_, drive: string | undefined, rest: string) =>
|
|
321
|
+
relative(process.cwd(), drive ? `${drive}${rest}` : `/${rest}`).replaceAll('\\', '/'),
|
|
322
|
+
)
|
|
323
|
+
.replace(own, '')
|
|
324
|
+
// A bundler's cache-busting query, between a module's path and its line.
|
|
325
|
+
.replace(/(\.[cm]?[jt]sx?)\?[tv]=[\w.-]+/g, '$1');
|
|
326
|
+
}
|
|
327
|
+
|
|
298
328
|
export interface Options {
|
|
299
329
|
nth: string;
|
|
300
330
|
json?: boolean;
|
|
@@ -349,9 +379,10 @@ export async function run(named: string, values: Options): Promise<void> {
|
|
|
349
379
|
if (replay !== undefined) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);
|
|
350
380
|
if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);
|
|
351
381
|
console.log();
|
|
352
|
-
const
|
|
382
|
+
const short = shortener(kept.page);
|
|
383
|
+
const under = (line: string) => console.log(`${' '.repeat(22)}${short(line)}`);
|
|
353
384
|
for (const e of shown) {
|
|
354
|
-
console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${e.text}`);
|
|
385
|
+
console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);
|
|
355
386
|
// Where a warning or an error came from, its nearest few places: all of them, and every line's, with `--full`.
|
|
356
387
|
if (e.trace && (values.full === true || e.problem === true))
|
|
357
388
|
for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);
|