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
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// A task, briefly: what was asked, where (and whether that place has moved in the source since), the page,
|
|
3
|
-
// what's attached with the command to look at each, the replies, and the other open tasks about the same page.
|
|
4
|
-
// Usage: task.mjs <id> [--out dir]
|
|
5
|
-
// --out downloads the attachments there.
|
|
6
|
-
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
7
|
-
import { dirname, join, resolve } from 'node:path';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
|
|
10
|
-
import { deicticDirs, fail, parseArgs, vb } from './lib.mjs';
|
|
11
|
-
|
|
12
|
-
const vbScript = join(dirname(fileURLToPath(import.meta.url)), 'vb.mjs');
|
|
13
|
-
|
|
14
|
-
const { options, rest } = parseArgs(process.argv.slice(2));
|
|
15
|
-
if (rest[0] === undefined) fail('Name a task: task.mjs 68');
|
|
16
|
-
const { message: root, replies } = vb(['read', rest[0].replace(/^#/, '')], { json: true });
|
|
17
|
-
const [asked = '', where = ''] = root.text.split(/\n---\n/);
|
|
18
|
-
const at = root.labels['deictic.at'];
|
|
19
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
|
|
21
|
-
console.log(`#${root.id} ${root.task?.state ?? 'not a task'}, by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);
|
|
22
|
-
console.log(`\nAsked:\n${asked.trim()}\n`);
|
|
23
|
-
// The part inside the element that was pointed at, where nothing marked it: what the person means.
|
|
24
|
-
const pointed = where.match(/\nPointed at, inside it: `([^`]*)`\n`{3,}\w*\n([\s\S]*?)\n`{3,}/);
|
|
25
|
-
// Where, from the labels: the place, the page, and the viewport to look at it in.
|
|
26
|
-
const facts = [
|
|
27
|
-
['deictic.project', (v) => `Project ${v}`],
|
|
28
|
-
['deictic.at', (v) => `${v} <${root.labels['deictic.tag'] ?? '?'}>`],
|
|
29
|
-
['deictic.url', (v) => v],
|
|
30
|
-
['deictic.viewport', (v) => `Viewport ${v}`],
|
|
31
|
-
['deictic.count', (v) => (v === '1' ? undefined : `${v} elements on the page come from that line`)],
|
|
32
|
-
['deictic.position', (v) => `In the screenshot at x,y ${v}, ${root.labels['deictic.size'] ?? '?'} (CSS pixels from its top left)`],
|
|
33
|
-
];
|
|
34
|
-
for (const [key, say] of facts) {
|
|
35
|
-
const line = root.labels[key] === undefined ? undefined : say(root.labels[key]);
|
|
36
|
-
if (line !== undefined) console.log(line);
|
|
37
|
-
}
|
|
38
|
-
// What no label holds: what's attached and drawn on it.
|
|
39
|
-
const told = (pointed ? where.slice(0, pointed.index) : where).trim();
|
|
40
|
-
if (told !== '') console.log(told);
|
|
41
|
-
if (pointed) console.log(`\nPointed at, inside it: ${pointed[1]}\n ${pointed[2]}`);
|
|
42
|
-
|
|
43
|
-
// The place as the task saw it, against the file now: the element's opening tag may have moved or changed.
|
|
44
|
-
if (at !== undefined) {
|
|
45
|
-
const [file, line] = [at.replace(/:\d+:\d+$/, ''), Number(at.split(':').at(-2))];
|
|
46
|
-
// Marks are from the dev server's root: here, above, or a folder with a .deictic/ of its own.
|
|
47
|
-
const roots = [process.cwd(), ...deicticDirs().map(dirname)];
|
|
48
|
-
const path = roots.map((r) => resolve(r, file)).find((p) => existsSync(p));
|
|
49
|
-
if (path === undefined) {
|
|
50
|
-
console.log(`\n${file} isn't under ${roots.join(' or ')}: find the dev server's root.`);
|
|
51
|
-
} else {
|
|
52
|
-
const lines = readFileSync(path, 'utf8').split('\n');
|
|
53
|
-
// The tag's first line may follow other code on its line: `const App = () => <h1>`.
|
|
54
|
-
const first = root.labels['deictic.line'];
|
|
55
|
-
const now = lines[line - 1]?.trim();
|
|
56
|
-
if (first === undefined || now?.includes(first.slice(0, 40))) {
|
|
57
|
-
console.log(`\nFile: ${path}:${line}, as the task saw it.`);
|
|
58
|
-
} else {
|
|
59
|
-
const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));
|
|
60
|
-
console.log(
|
|
61
|
-
moved >= 0
|
|
62
|
-
? `\nFile: moved to ${path}:${moved + 1} (the task says line ${line}).`
|
|
63
|
-
: `\nFile: ${path}:${line} no longer reads as the task saw it; it was:\n ${first}`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (root.attachments.length > 0) console.log('\nAttached:');
|
|
70
|
-
const out = options.out?.[0] && resolve(options.out[0]);
|
|
71
|
-
if (out) mkdirSync(out, { recursive: true });
|
|
72
|
-
for (const a of root.attachments) {
|
|
73
|
-
const kb = `${Math.round(a.size / 1024)} KB`;
|
|
74
|
-
if (out) vb(['download', a.id, join(out, a.name)]);
|
|
75
|
-
const saved = out ? ` → ${join(out, a.name)}` : '';
|
|
76
|
-
if (a.name.startsWith('recording-')) {
|
|
77
|
-
console.log(` ${a.name} (${kb})${saved}`);
|
|
78
|
-
console.log(` timeline: node ${join(here, 'recording.mjs')} ${root.id}`);
|
|
79
|
-
console.log(` frames: node ${join(here, 'frame.mjs')} ${root.id}`);
|
|
80
|
-
} else if (a.name.startsWith('voice-')) {
|
|
81
|
-
console.log(` ${a.name} (${kb}), a voice clip${saved}`);
|
|
82
|
-
console.log(` speech: node ${join(here, 'voice.mjs')} ${root.id}`);
|
|
83
|
-
} else if (a.name === 'element.html') {
|
|
84
|
-
console.log(
|
|
85
|
-
` ${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved || `: node ${vbScript} download ${a.id} ${a.name}`}`,
|
|
86
|
-
);
|
|
87
|
-
} else {
|
|
88
|
-
// To a file's path: the CLI writes what it's given, and refuses a folder.
|
|
89
|
-
console.log(` ${a.name} (${a.type}, ${kb})${saved || `: node ${vbScript} download ${a.id} ${a.name}`}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (replies.length > 0) console.log('\nReplies:');
|
|
93
|
-
for (const r of replies) console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);
|
|
94
|
-
|
|
95
|
-
// The other open tasks about the same page, of the same project: left a minute apart, they're often one change.
|
|
96
|
-
const page = root.labels['deictic.page'];
|
|
97
|
-
if (page !== undefined) {
|
|
98
|
-
const project = root.labels['deictic.project'];
|
|
99
|
-
const labels = [`deictic.page=${page}`, ...(project === undefined ? [] : [`deictic.project=${project}`])];
|
|
100
|
-
const { tasks } = vb(['tasks', root.channel, ...labels.flatMap((l) => ['--label', l])], { json: true });
|
|
101
|
-
const others = tasks.map((t) => t.message).filter((m) => m.id !== root.id);
|
|
102
|
-
if (others.length > 0) {
|
|
103
|
-
const count = `${others.length} other open task${others.length === 1 ? '' : 's'}`;
|
|
104
|
-
console.log(`\n${count} on ${page}: read them before you start, they may be one change.`);
|
|
105
|
-
for (const m of others) {
|
|
106
|
-
const title = m.text
|
|
107
|
-
.split(/\n---\n/)[0]
|
|
108
|
-
.split('\n')[0]
|
|
109
|
-
.slice(0, 100);
|
|
110
|
-
console.log(` #${m.id} ${m.task?.state ?? ''}, ${m.labels['deictic.at'] ?? '?'}: ${title}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// What was said in voice clips, with when: Whisper on this machine, through transformers.js. For a recording, the
|
|
3
|
-
// times are the recording's, to line up with its timeline. Nothing leaves the machine once the model is downloaded.
|
|
4
|
-
//
|
|
5
|
-
// Usage: transcribe.mjs <task | replay URL | recording ID | file | clip ID> [--model base] [--language en] [--json]
|
|
6
|
-
// transcribe.mjs --setup [--model base] installs it: ask the person first
|
|
7
|
-
//
|
|
8
|
-
// Setup puts @huggingface/transformers and the model in ~/.cache/deictic/transcribe (DEICTIC_CACHE moves it),
|
|
9
|
-
// outside the project. Models: tiny (~40 MB), base (~77 MB, the default), small (~250 MB), large-v3-turbo
|
|
10
|
-
// (~800 MB), or any ONNX Whisper on Hugging Face by its ID. Needs ffmpeg on the PATH.
|
|
11
|
-
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
13
|
-
import { createRequire } from 'node:module';
|
|
14
|
-
import { homedir } from 'node:os';
|
|
15
|
-
import { join } from 'node:path';
|
|
16
|
-
import { pathToFileURL } from 'node:url';
|
|
17
|
-
|
|
18
|
-
import { clock, fail, ffmpeg, parseArgs, voiceClips } from './lib.mjs';
|
|
19
|
-
|
|
20
|
-
// Pinned, so a setup installs what the script was written against; move it on deliberately.
|
|
21
|
-
const TRANSFORMERS = '@huggingface/transformers@4.3.2';
|
|
22
|
-
const MODELS = { tiny: 'whisper-tiny', base: 'whisper-base', small: 'whisper-small', 'large-v3-turbo': 'whisper-large-v3-turbo' };
|
|
23
|
-
|
|
24
|
-
const { options, rest } = parseArgs(process.argv.slice(2), ['setup', 'json']);
|
|
25
|
-
const size = options.model?.[0] ?? 'base';
|
|
26
|
-
const model = size.includes('/')
|
|
27
|
-
? size
|
|
28
|
-
: `onnx-community/${MODELS[size] ?? fail(`--model is one of ${Object.keys(MODELS).join(', ')}, or a model ID`)}`;
|
|
29
|
-
const dir = join(process.env.DEICTIC_CACHE ?? join(homedir(), '.cache', 'deictic'), 'transcribe');
|
|
30
|
-
const models = join(dir, 'models');
|
|
31
|
-
const installed = existsSync(join(dir, 'node_modules', '@huggingface', 'transformers', 'package.json'));
|
|
32
|
-
const downloaded = existsSync(join(models, ...model.split('/')));
|
|
33
|
-
|
|
34
|
-
if (options.setup) {
|
|
35
|
-
mkdirSync(dir, { recursive: true });
|
|
36
|
-
if (!existsSync(join(dir, 'package.json'))) writeFileSync(join(dir, 'package.json'), '{ "private": true }\n');
|
|
37
|
-
if (!installed) {
|
|
38
|
-
console.log(`Installing ${TRANSFORMERS} in ${dir}…`);
|
|
39
|
-
const windows = process.platform === 'win32';
|
|
40
|
-
const args = ['install', '--prefix', dir, '--no-audit', '--no-fund', '--save-exact', TRANSFORMERS];
|
|
41
|
-
const run = spawnSync(windows ? `npm ${args.map((a) => `"${a}"`).join(' ')}` : 'npm', windows ? [] : args, {
|
|
42
|
-
stdio: 'inherit',
|
|
43
|
-
shell: windows,
|
|
44
|
-
});
|
|
45
|
-
if (run.status !== 0) fail(`npm install failed (${run.error?.message ?? `exit ${run.status}`}).`);
|
|
46
|
-
}
|
|
47
|
-
} else if (!installed || !downloaded) {
|
|
48
|
-
fail(
|
|
49
|
-
`Local transcription isn't set up${installed ? ` with the ${size} model` : ''}. Ask the person first: it downloads ` +
|
|
50
|
-
`${installed ? '' : `${TRANSFORMERS} (with ONNX Runtime, ~470 MB) and `}Whisper ${size} into ${dir}, outside ` +
|
|
51
|
-
`the project; after that, audio is transcribed on this machine. On yes: node ${process.argv[1]} --setup` +
|
|
52
|
-
(size === 'base' ? '' : ` --model ${size}`),
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const transformers = await import(pathToFileURL(createRequire(join(dir, 'package.json')).resolve('@huggingface/transformers')).href);
|
|
57
|
-
transformers.env.cacheDir = models;
|
|
58
|
-
// Only setup downloads; a transcription uses what's here.
|
|
59
|
-
transformers.env.allowRemoteModels = Boolean(options.setup);
|
|
60
|
-
if (options.setup) console.log(`Downloading ${model} (quantized) into ${models}…`);
|
|
61
|
-
const asr = await transformers.pipeline('automatic-speech-recognition', model, { dtype: 'q8' });
|
|
62
|
-
if (options.setup) {
|
|
63
|
-
console.log(`Ready: node ${process.argv[1]} <task>${size === 'base' ? '' : ` --model ${size}`}`);
|
|
64
|
-
if (rest[0] === undefined) process.exit(0);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const results = [];
|
|
68
|
-
for (const c of await voiceClips(rest[0])) {
|
|
69
|
-
// Whisper takes 16 kHz mono samples; ffmpeg decodes the clip (webm, ogg or mp4) to them.
|
|
70
|
-
const raw = ffmpeg(['-loglevel', 'error', '-i', c.file, '-f', 'f32le', '-ac', '1', '-ar', '16000', '-'], 'buffer').stdout;
|
|
71
|
-
const audio = new Float32Array(raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength - (raw.byteLength % 4)));
|
|
72
|
-
const out = await asr(audio, {
|
|
73
|
-
return_timestamps: true,
|
|
74
|
-
chunk_length_s: 30,
|
|
75
|
-
stride_length_s: 5,
|
|
76
|
-
...(options.language ? { language: options.language[0] } : {}),
|
|
77
|
-
});
|
|
78
|
-
const said = (out.chunks ?? [{ timestamp: [0, audio.length / 16000], text: out.text }]).map(({ timestamp: [from, to], text }) => ({
|
|
79
|
-
from: c.at + from * 1000,
|
|
80
|
-
to: c.at + (to ?? audio.length / 16000) * 1000,
|
|
81
|
-
text: text.trim(),
|
|
82
|
-
}));
|
|
83
|
-
results.push({ ...c, text: out.text.trim(), said });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (options.json) {
|
|
87
|
-
console.log(JSON.stringify(results, null, 2));
|
|
88
|
-
} else {
|
|
89
|
-
for (const r of results) {
|
|
90
|
-
console.log(`clip ${r.id} (${r.recording ? `in recording ${r.recording}, from ${clock(r.at)}` : 'a voice note'}):`);
|
|
91
|
-
for (const s of r.said) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} ${s.text}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// The board's CLI as the other scripts run it: the project's own `@vercel/board`, which needn't be on the PATH,
|
|
3
|
-
// on the board the dev server uses (`BOARD_URL`, or with none, the one `.deictic/board.json` names).
|
|
4
|
-
// Usage: vb.mjs <anything vb takes>, as in: vb.mjs whoami · vb.mjs tasks claim 68 --lease 30m
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
|
|
7
|
-
import { fail, vbCommand } from './lib.mjs';
|
|
8
|
-
|
|
9
|
-
const [command, argv, options] = vbCommand(process.argv.slice(2));
|
|
10
|
-
const run = spawnSync(command, argv, { ...options, stdio: 'inherit' });
|
|
11
|
-
if (run.error) fail(`vb: ${run.error.message}. Install @vercel/board in the project, or put vb on the PATH.`);
|
|
12
|
-
process.exit(run.status ?? 1);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// When something was said: the stretches of speech in voice clips, found by ffmpeg's silence detection. For a
|
|
3
|
-
// recording, in the recording's time, to line up with its timeline; for a task, each voice note on it too.
|
|
4
|
-
// Usage: voice.mjs <task | replay URL | recording ID | file | clip ID> [--noise -35] [--gap 0.4] [--wav dir] [--json]
|
|
5
|
-
// --wav writes each clip as 16 kHz mono WAV, what speech-to-text tools take. Needs ffmpeg on the PATH.
|
|
6
|
-
import { mkdirSync } from 'node:fs';
|
|
7
|
-
import { join, resolve } from 'node:path';
|
|
8
|
-
|
|
9
|
-
import { clock, ffmpeg, parseArgs, voiceClips } from './lib.mjs';
|
|
10
|
-
|
|
11
|
-
const { options, rest } = parseArgs(process.argv.slice(2), ['json']);
|
|
12
|
-
const noise = Number(options.noise?.[0] ?? -35);
|
|
13
|
-
const gap = Number(options.gap?.[0] ?? 0.4);
|
|
14
|
-
const clips = await voiceClips(rest[0]);
|
|
15
|
-
|
|
16
|
-
const results = [];
|
|
17
|
-
for (const c of clips) {
|
|
18
|
-
// ffmpeg reports silence; speech is what's between. MediaRecorder's webm has no duration, so it's measured.
|
|
19
|
-
const run = ffmpeg(['-i', c.file, '-af', `silencedetect=noise=${noise}dB:d=${gap}`, '-f', 'null', '-']);
|
|
20
|
-
const log = run.stderr;
|
|
21
|
-
const starts = [...log.matchAll(/silence_start: (-?[\d.]+)/g)].map((m) => Number(m[1]) * 1000);
|
|
22
|
-
const ends = [...log.matchAll(/silence_end: (-?[\d.]+)/g)].map((m) => Number(m[1]) * 1000);
|
|
23
|
-
const times = [...log.matchAll(/time=(\d+):(\d+):([\d.]+)/g)].at(-1);
|
|
24
|
-
const length = times ? (Number(times[1]) * 3600 + Number(times[2]) * 60 + Number(times[3])) * 1000 : Math.max(0, ...ends);
|
|
25
|
-
const speech = [];
|
|
26
|
-
let from = 0;
|
|
27
|
-
for (let i = 0; i < starts.length; i++) {
|
|
28
|
-
if (starts[i] - from > 150) speech.push([from, starts[i]]);
|
|
29
|
-
from = ends[i] ?? length;
|
|
30
|
-
}
|
|
31
|
-
if (length - from > 150) speech.push([from, length]);
|
|
32
|
-
if (options.wav) {
|
|
33
|
-
const dir = resolve(options.wav[0]);
|
|
34
|
-
mkdirSync(dir, { recursive: true });
|
|
35
|
-
ffmpeg(['-y', '-loglevel', 'error', '-i', c.file, '-ar', '16000', '-ac', '1', '-sample_fmt', 's16', join(dir, `${c.id}.wav`)]);
|
|
36
|
-
}
|
|
37
|
-
results.push({ ...c, length, speech: speech.map(([a, b]) => ({ from: c.at + a, to: c.at + b })) });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (options.json) {
|
|
41
|
-
console.log(JSON.stringify(results, null, 2));
|
|
42
|
-
} else {
|
|
43
|
-
for (const r of results) {
|
|
44
|
-
const where = r.recording ? `in recording ${r.recording}, from ${clock(r.at)}` : 'a voice note';
|
|
45
|
-
console.log(`clip ${r.id} (${where}), ${clock(r.length)} long: ${r.file}`);
|
|
46
|
-
if (r.speech.length === 0) console.log(' no speech found: try a lower --noise, like -45');
|
|
47
|
-
for (const s of r.speech) console.log(` ${clock(s.from).padStart(6)} – ${clock(s.to).padStart(6)} speech`);
|
|
48
|
-
if (options.wav) console.log(` wav: ${join(resolve(options.wav[0]), `${r.id}.wav`)}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Watches the board for deictic's tasks and prints one line per thing to act on: the tasks ready now as it
|
|
3
|
-
// starts, then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's
|
|
4
|
-
// monitor (each line an event). It says so if the board goes away, and ends by itself once nothing has happened
|
|
5
|
-
// on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.
|
|
6
|
-
// With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits.
|
|
7
|
-
// It ends, too, when the process that started it does: nobody reads its lines then.
|
|
8
|
-
// While it runs the project's Task tab shows who watches (`watching`, in lib.mjs). Replies the watcher wrote
|
|
9
|
-
// itself are left out where it has a name of its own (BOARD_PROFILE): with none it writes as the person.
|
|
10
|
-
// Usage: watch.mjs [channel, default deictic] [--idle 20m] [--once] [--label k=v ...]
|
|
11
|
-
// Exits 0 after `--once`'s event, 2 when idle, 1 when the board went away.
|
|
12
|
-
import { spawn } from 'node:child_process';
|
|
13
|
-
import { createInterface } from 'node:readline';
|
|
14
|
-
|
|
15
|
-
import { boardUrl, duration, parseArgs, vb, vbCommand, watching, whoami } from './lib.mjs';
|
|
16
|
-
|
|
17
|
-
const { options, rest } = parseArgs(process.argv.slice(2), ['once']);
|
|
18
|
-
const channel = rest[0] ?? 'deictic';
|
|
19
|
-
const labels = (options.label ?? []).flatMap((l) => ['--label', l]);
|
|
20
|
-
const idle = options.idle?.[0] ?? '20m';
|
|
21
|
-
const say = (line) => console.log(line.replace(/\s+/g, ' ').trim());
|
|
22
|
-
const first = (text) => (text.split('\n---')[0] ?? '').trim().slice(0, 160);
|
|
23
|
-
|
|
24
|
-
const ready = vb(['tasks', channel, '--state', 'ready', ...labels]).trim();
|
|
25
|
-
const me = whoami();
|
|
26
|
-
const unseen = watching(channel, me.profile ?? me.name ?? me.handle ?? me.actor);
|
|
27
|
-
let tail;
|
|
28
|
-
const end = (code) => {
|
|
29
|
-
unseen();
|
|
30
|
-
tail?.removeAllListeners('exit');
|
|
31
|
-
tail?.kill();
|
|
32
|
-
process.exit(code);
|
|
33
|
-
};
|
|
34
|
-
// Stopped by its monitor, where the system says so: the page isn't left thinking someone watches.
|
|
35
|
-
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => end(0));
|
|
36
|
-
|
|
37
|
-
// Whoever started the watch reads its lines. With that gone (a session that ended and left the watch behind) no
|
|
38
|
-
// one does, and the page mustn't go on saying an agent watches. A dead parent shows as another parent's ID, except
|
|
39
|
-
// on Windows, where the ID stays and the system is asked whether it's still a process.
|
|
40
|
-
const parent = process.ppid;
|
|
41
|
-
const orphaned = () => {
|
|
42
|
-
if (process.ppid !== parent) return true;
|
|
43
|
-
try {
|
|
44
|
-
process.kill(parent, 0);
|
|
45
|
-
return false;
|
|
46
|
-
} catch (e) {
|
|
47
|
-
return e.code === 'ESRCH';
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
setInterval(() => orphaned() && end(0), 5000);
|
|
51
|
-
|
|
52
|
-
say(`watching ${channel} on ${boardUrl() ?? "the team's board"} as ${me.handle ?? me.actor}`);
|
|
53
|
-
// With no profile, the person's replies and the watcher's own are one actor's: none can be left out.
|
|
54
|
-
if (!me.profile) {
|
|
55
|
-
say(
|
|
56
|
-
`you write as ${me.handle ?? me.actor}, the person's own identity: set BOARD_PROFILE=<your name> (claude, codex) for every vb command, this watch too, and start it again`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
const waiting = (ready ? ready.split('\n') : []).filter((line) => /^#\d+/.test(line));
|
|
60
|
-
for (const line of waiting) say(`ready: ${line}`);
|
|
61
|
-
if (options.once && waiting.length > 0) end(0);
|
|
62
|
-
|
|
63
|
-
/** One thing to act on: all `--once` waits for. */
|
|
64
|
-
const event = (line) => {
|
|
65
|
-
say(line);
|
|
66
|
-
if (options.once) end(0);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Anything on the channel puts the end off, the watcher's own claims and replies too: it's being worked.
|
|
70
|
-
let quiet;
|
|
71
|
-
const heard = () => {
|
|
72
|
-
clearTimeout(quiet);
|
|
73
|
-
quiet = setTimeout(() => {
|
|
74
|
-
say(
|
|
75
|
-
`idle: nothing on ${channel} in ${idle}, so the watch is over. Don't start it again by yourself: tell the person in a line that you've stopped watching, and watch again when they ask. Only if you're working a task now, start it once more when that's done.`,
|
|
76
|
-
);
|
|
77
|
-
end(2);
|
|
78
|
-
}, duration(idle));
|
|
79
|
-
};
|
|
80
|
-
heard();
|
|
81
|
-
|
|
82
|
-
// What the board says about each thread: its root's first line and where, to name it when a task is made.
|
|
83
|
-
const roots = new Map();
|
|
84
|
-
const [command, argv, spawnOptions] = vbCommand(['tail', channel, ...labels, '--json']);
|
|
85
|
-
tail = spawn(command, argv, { ...spawnOptions, stdio: ['ignore', 'pipe', 'inherit'] });
|
|
86
|
-
createInterface({ input: tail.stdout }).on('line', (line) => {
|
|
87
|
-
let e;
|
|
88
|
-
try {
|
|
89
|
-
e = JSON.parse(line);
|
|
90
|
-
} catch {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
heard();
|
|
94
|
-
const p = e.payload ?? {};
|
|
95
|
-
if (e.type === 'message.posted' && p.re === null) {
|
|
96
|
-
const at = p.labels?.['deictic.at'];
|
|
97
|
-
roots.set(
|
|
98
|
-
p.thread,
|
|
99
|
-
`"${first(p.text ?? '')}"${at ? ` at ${at}` : ''}${p.labels?.['deictic.page'] ? ` on ${p.labels['deictic.page']}` : ''}${p.labels?.['deictic.project'] ? ` in ${p.labels['deictic.project']}` : ''}`,
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
if (e.type === 'task.created') event(`new task #${p.id}: ${roots.get(p.thread) ?? ''}. Read it: vb read ${p.id}`);
|
|
103
|
-
|
|
104
|
-
if (e.type === 'message.posted' && p.re !== null && p.re !== undefined) {
|
|
105
|
-
if (me.profile && p.by?.actor === me.actor) return;
|
|
106
|
-
const by = e.message?.author?.handle ?? p.by?.actor ?? 'someone';
|
|
107
|
-
event(`reply on #${p.re} by ${by}: ${first(p.text ?? '')}`);
|
|
108
|
-
}
|
|
109
|
-
if (e.type === 'task.canceled') event(`task #${p.id} canceled: ${p.reason ?? ''}. Stop work on it.`);
|
|
110
|
-
});
|
|
111
|
-
tail.on('exit', (code) => {
|
|
112
|
-
say(`watch ended (vb tail exited ${code}): start it again`);
|
|
113
|
-
unseen();
|
|
114
|
-
process.exit(1);
|
|
115
|
-
});
|