@leonidstern/labit 0.6.3-main.1 → 0.6.3-main.11
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/CHANGELOG.md +12 -0
- package/README.md +3 -2
- package/dist/{chunk-XZUZQFBJ.mjs → chunk-B5QP5NGM.mjs} +12 -2
- package/dist/chunk-FRJUZ6AN.mjs +34 -0
- package/dist/{chunk-LNYMIFDQ.mjs → chunk-QTMKKULT.mjs} +1 -1
- package/dist/{commands-LAQNMF2X.mjs → commands-P7L2JAN6.mjs} +74 -23
- package/dist/lab-comments-IWYSOZ4X.mjs +401 -0
- package/dist/local.mjs +286 -259
- package/dist/{mcp-4UPGXLZR.mjs → mcp-6CQVLVZW.mjs} +33 -5
- package/dist/{settings-XLFKONNN.mjs → settings-T6OQSQH4.mjs} +1 -8
- package/package.json +1 -2
- package/public/_lab/comments.js +18 -18
- package/skills/labit/SKILL.md +4 -6
- package/api/lab-comments.mjs +0 -446
- package/skills/labit/zoom.md +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ Versions follow [semver](https://semver.org). Before 1.0, a minor version can ch
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
- With a dev server (`--proxy`), its reload waits while the chat, a thread, the list or a new comment is open, not only while words are typed, so an update no longer closes the chat under you. It comes in once you close it, as the lab's own reload already did.
|
|
8
|
+
- The ⋯ menu ends with which labit the lab runs (`labit 0.6.2`), and for a local edge build what it merged on top of main (`LABIT_EDGE`, e.g. `edge: main + #89 #91`), so labs on different builds can be told apart at a glance.
|
|
9
|
+
- `labit pin <selector> "text" [--page /path] [--at x,y]`: the agent leaves its own pin on a spot of the page, for suggestions and questions, one pin per point, numbered, instead of a list in a reply. It prints the pin's id; `--page` takes the page's path, file or address (default: the lab's only page), `--at` where on the element (default its middle). Also an MCP tool, `pin`.
|
|
10
|
+
- Zoom is out for now: no zoom pins, no `labit zoom`, no `zoom` setting, no zoom skill. The keys are 1 comment, 2 go, 3 pointer again (pointer was 4). Zoom pins saved earlier show as ordinary comments, and a `zoom` left in a `labit.json` or a `shortcuts.zoom` key is named when the lab starts and ignored. `#id` links in messages stay.
|
|
11
|
+
- Pins find their spot better after edits: own section first; text pins sit on their words (found anywhere on the page if the element is gone); gap pins stay between their blocks; made-up ids/classes ignored; a lost look-alike shows as moved; a pin found elsewhere saves its new path.
|
|
12
|
+
- `labit reply --done | --on-it | --question` sets the reply's intent; `--done` closes the thread ("Done…" text still works).
|
|
13
|
+
- Comments carry `v: 2`, older ones upgrade on load: `resolvedAt` (archive a month after it), one `suggest: { text, state }`, no `anchor` on replies, wait marks in `.lab/handed.json`.
|
|
14
|
+
- The agent has its own key in `.lab/server.json`; page scripts can't act as the agent. Older CLIs can't either.
|
|
15
|
+
- The 500 cap skips owner, agent and done threads. One lab per folder (`.lab/lock`). A new session gets whole threads.
|
|
16
|
+
- A page file renamed with `mv` keeps its comments. `wait` says how to answer once per session, then in one line.
|
|
17
|
+
- Shared API: a write can't undo a change made meanwhile; npm ships it in `dist/`, not `api/`.
|
|
18
|
+
|
|
7
19
|
- Releases publish themselves: a version bump merged to main goes to npm as `latest` (tagged `vX.Y.Z`), and every merge to main goes out as `next` (0.6.3-main.41…). `npx @leonidstern/labit@latest` is the newest release; `@next` is main as it is now, for whoever wants each merge in their labs. From GitHub Actions with npm trusted publishing, no token.
|
|
8
20
|
|
|
9
21
|
## 0.6.2 · 2026-11-17
|
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ It finds your running dev server (Astro, Next, Vite…) or serves plain HTML, an
|
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
npx @leonidstern/labit wait # ends with your next comment
|
|
32
|
-
npx @leonidstern/labit reply <id> "
|
|
32
|
+
npx @leonidstern/labit reply <id> --done "…" # answers on the pin and closes it
|
|
33
|
+
npx @leonidstern/labit pin <selector> "1. …" # its own pin on a spot: suggestions and questions, one per point, numbered
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
Or as an MCP server: `npx @leonidstern/labit@latest mcp`.
|
|
@@ -45,7 +46,7 @@ Everything merged to main, before it is released: `npx @leonidstern/labit@next`.
|
|
|
45
46
|
- You name yourself once. The name is kept for this computer in `~/.config/labit/settings.json`, so every later lab starts out knowing you — browsers keep it per port, labs don't. `labit invite [name]` carries a name to a phone the same way. `--page /path` makes the link open that page. Opening a used or old link again on a phone that's already in just takes you there, and a phone that keeps using the lab stays in.
|
|
46
47
|
- Settings (port, your dev server, keys, how long the lab waits…): `labit.json` in the project and `~/.config/labit/settings.json` for you. `labit settings` shows them all; [docs/settings.md](docs/settings.md) explains each.
|
|
47
48
|
- Comments stay in `.lab/` in your project. Add it to `.gitignore`.
|
|
48
|
-
- `
|
|
49
|
+
- `1` comment, `2` go (every click approves what it's on), `3` pointer (clicks are the page's own).
|
|
49
50
|
- No dependencies, Node 22+. `--help` lists everything else.
|
|
50
51
|
|
|
51
52
|
Shared labs on a domain (comments from people you send a link to) come later.
|
|
@@ -4,7 +4,12 @@ function listenPages(opts, forWait = false) {
|
|
|
4
4
|
if (!raw) return null;
|
|
5
5
|
return String(raw).split(",").map((p) => "/" + p.trim().replace(/^\/+/, "").replace(/\.html?$/i, "")).filter((p) => p !== "/");
|
|
6
6
|
}
|
|
7
|
-
var SWITCHES = ["--wifi", "--no-open", "--resolve", "--wait", "--new", "--all", "--bg", "--fast", "--no-fast"];
|
|
7
|
+
var SWITCHES = ["--wifi", "--no-open", "--resolve", "--wait", "--new", "--all", "--bg", "--fast", "--no-fast", "--done", "--on-it", "--question"];
|
|
8
|
+
function replyIntent(opts) {
|
|
9
|
+
const given = ["done", "on-it", "question"].filter((f) => opts[f]);
|
|
10
|
+
if (given.length > 1) return new Error(`Give one of --done, --on-it, --question, not ${given.map((f) => `--${f}`).join(" and ")}.`);
|
|
11
|
+
return given[0] === "on-it" ? "working" : given[0];
|
|
12
|
+
}
|
|
8
13
|
var FOREGROUND_CAP = 60;
|
|
9
14
|
var WAIT_DEFAULT = 1500;
|
|
10
15
|
function waitSeconds(opts, isTTY = false) {
|
|
@@ -13,7 +18,7 @@ function waitSeconds(opts, isTTY = false) {
|
|
|
13
18
|
return { seconds: Math.min(asked, FOREGROUND_CAP), capped: asked > FOREGROUND_CAP };
|
|
14
19
|
}
|
|
15
20
|
var WRITE_SHORT = "Write answers short: they're read in a small window, often on a phone. One point per line or two, a blank line between points, '- ' lines for lists.";
|
|
16
|
-
var VALUED = ["--port", "--name", "--page", "--pages", "--timeout", "--dir", "--proxy", "--model", "--suggest-rule"];
|
|
21
|
+
var VALUED = ["--port", "--name", "--page", "--pages", "--timeout", "--dir", "--proxy", "--model", "--suggest-rule", "--at"];
|
|
17
22
|
function parseArgs(argv) {
|
|
18
23
|
const opts = {};
|
|
19
24
|
const pos = [];
|
|
@@ -42,6 +47,9 @@ import fs from "node:fs";
|
|
|
42
47
|
import os from "node:os";
|
|
43
48
|
import path from "node:path";
|
|
44
49
|
var REGISTRY = path.join(process.env.LABIT_HOME || path.join(os.homedir(), ".labit"), "servers");
|
|
50
|
+
var keyFor = (rel) => "/" + rel.replace(/\.html?$/i, "").split(path.sep).map(
|
|
51
|
+
(seg) => [...Buffer.from(seg.toLowerCase())].map((b, i) => /[a-z0-9]/.test(String.fromCharCode(b)) || b === 45 && i ? String.fromCharCode(b) : `_${b.toString(16)}`).join("")
|
|
52
|
+
).join("/");
|
|
45
53
|
var runningLabs = () => (fs.existsSync(REGISTRY) ? fs.readdirSync(REGISTRY) : []).filter((n) => n.endsWith(".json")).flatMap((n) => {
|
|
46
54
|
const file = path.join(REGISTRY, n);
|
|
47
55
|
try {
|
|
@@ -56,10 +64,12 @@ var runningLabs = () => (fs.existsSync(REGISTRY) ? fs.readdirSync(REGISTRY) : []
|
|
|
56
64
|
|
|
57
65
|
export {
|
|
58
66
|
listenPages,
|
|
67
|
+
replyIntent,
|
|
59
68
|
FOREGROUND_CAP,
|
|
60
69
|
waitSeconds,
|
|
61
70
|
WRITE_SHORT,
|
|
62
71
|
parseArgs,
|
|
63
72
|
REGISTRY,
|
|
73
|
+
keyFor,
|
|
64
74
|
runningLabs
|
|
65
75
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// api/_schema.mjs
|
|
2
|
+
var VERSION = 2;
|
|
3
|
+
var INTENTS = ["done", "working", "question"];
|
|
4
|
+
var intentFromText = (text) => /^done\b/i.test(String(text ?? "").trim()) ? "done" : /^on it\b/i.test(String(text ?? "").trim()) ? "working" : void 0;
|
|
5
|
+
var slim = (s) => Object.fromEntries(Object.entries(s).filter(([k, v]) => v && k !== "url" && k !== "resume"));
|
|
6
|
+
function upgrade(record, handed) {
|
|
7
|
+
if (!record || typeof record !== "object" || (Number(record.v) || 0) >= VERSION) return record;
|
|
8
|
+
const c = { ...record, v: VERSION };
|
|
9
|
+
if (c.parent) {
|
|
10
|
+
if (c.resolved === false) delete c.resolved;
|
|
11
|
+
if (c.anchor === null) delete c.anchor;
|
|
12
|
+
if (c.session && !c.intent) {
|
|
13
|
+
const intent = intentFromText(c.text);
|
|
14
|
+
if (intent) c.intent = intent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const text = c.rule || c.suggest;
|
|
18
|
+
if (typeof text === "string") c.suggest = { text, ...c.rule ? { state: c.ruleUndone ? "undone" : "kept" } : c.suggestDone === "no" ? { state: "no" } : {} };
|
|
19
|
+
if (handed && c.deliveredAt) handed[c.id] = [c.deliveredAt, c.deliveredTo ?? null, ...c.remindedAt ? [c.remindedAt] : []];
|
|
20
|
+
for (const k of ["suggestDone", "rule", "ruleUndone", "deliveredAt", "deliveredTo", "remindedAt"]) delete c[k];
|
|
21
|
+
if (c.session) c.session = slim(c.session);
|
|
22
|
+
const a = c.anchor;
|
|
23
|
+
const word = a && !a.quote && /^(?:element|text|)$/.test(a.kind || "") && /^(…?)(.*?)\[([^\]]+)\](.*?)(…?)$/s.exec(a.text || "");
|
|
24
|
+
if (word && (word[1] || word[5])) c.anchor = { ...a, kind: "text", quote: { exact: word[3], prefix: word[2].slice(-40), suffix: word[4].slice(0, 40) } };
|
|
25
|
+
return c;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
VERSION,
|
|
30
|
+
INTENTS,
|
|
31
|
+
intentFromText,
|
|
32
|
+
slim,
|
|
33
|
+
upgrade
|
|
34
|
+
};
|
|
@@ -22,7 +22,7 @@ var labCall = (server, pathname, body, session, signal) => new Promise((resolve,
|
|
|
22
22
|
host: `localhost:${server.port}`,
|
|
23
23
|
"content-type": "application/json",
|
|
24
24
|
"content-length": Buffer.byteLength(data),
|
|
25
|
-
"x-lab-admin": server.token,
|
|
25
|
+
"x-lab-admin": server.agent || server.token,
|
|
26
26
|
"x-lab-agent": "1",
|
|
27
27
|
"x-lab-session": encodeURIComponent(JSON.stringify(session))
|
|
28
28
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FOREGROUND_CAP,
|
|
3
|
+
keyFor,
|
|
3
4
|
listenPages,
|
|
5
|
+
replyIntent,
|
|
4
6
|
runningLabs,
|
|
5
7
|
waitSeconds
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B5QP5NGM.mjs";
|
|
7
9
|
import {
|
|
8
10
|
WAIT_SAID,
|
|
9
11
|
findLab,
|
|
10
12
|
labCall
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QTMKKULT.mjs";
|
|
12
14
|
import {
|
|
13
15
|
mySession
|
|
14
16
|
} from "./chunk-X4RYDWNI.mjs";
|
|
@@ -46,11 +48,21 @@ ${JSON.stringify(entry(), null, 2)}`);
|
|
|
46
48
|
const forHere = (lab) => lab.root === HERE || lab.root.startsWith(HERE + path.sep) || HERE.startsWith(lab.root + path.sep);
|
|
47
49
|
const LINKS = path.join(HERE, ".lab", "links.json");
|
|
48
50
|
const savedLinks = () => {
|
|
51
|
+
let text;
|
|
49
52
|
try {
|
|
50
|
-
|
|
53
|
+
text = fs.readFileSync(LINKS, "utf8");
|
|
51
54
|
} catch {
|
|
52
55
|
return [];
|
|
53
56
|
}
|
|
57
|
+
try {
|
|
58
|
+
const list = JSON.parse(text);
|
|
59
|
+
if (Array.isArray(list)) return list;
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
const aside = `${LINKS}.broken-${Date.now()}`;
|
|
63
|
+
fs.renameSync(LINKS, aside);
|
|
64
|
+
console.error(`[lab] .lab/links.json was damaged; moved it to ${path.basename(aside)}`);
|
|
65
|
+
return [];
|
|
54
66
|
};
|
|
55
67
|
const cloudOpen = async (url) => {
|
|
56
68
|
try {
|
|
@@ -83,7 +95,8 @@ ${JSON.stringify(entry(), null, 2)}`);
|
|
|
83
95
|
list.push({ url: key, title });
|
|
84
96
|
}
|
|
85
97
|
fs.mkdirSync(path.dirname(LINKS), { recursive: true });
|
|
86
|
-
fs.writeFileSync(LINKS, JSON.stringify(list, null, 2) + "\n");
|
|
98
|
+
fs.writeFileSync(LINKS + ".tmp", JSON.stringify(list, null, 2) + "\n");
|
|
99
|
+
fs.renameSync(LINKS + ".tmp", LINKS);
|
|
87
100
|
console.log(pos[0] === "add" ? `Saved ${key}${title ? ` (${title})` : ""}. It shows in \`${CMD} pages\` and \`${CMD} list\`.` : `Removed ${key}.`);
|
|
88
101
|
process.exit(0);
|
|
89
102
|
}
|
|
@@ -140,7 +153,7 @@ ${links.map((l) => `${l.title || l.url} ${l.url}`).join("\n")}`);
|
|
|
140
153
|
console.log(out);
|
|
141
154
|
process.exit(0);
|
|
142
155
|
}
|
|
143
|
-
if (["wait", "reply", "resolve", "
|
|
156
|
+
if (["wait", "reply", "resolve", "pin", "invite"].includes(pos[0])) {
|
|
144
157
|
const [cmd, ref, ...words] = pos;
|
|
145
158
|
const lab = findLab(opts.dir || ".") || die(`No lab server for this folder. Start one: run ${CMD} in the project.`);
|
|
146
159
|
const { dir, server } = lab;
|
|
@@ -172,6 +185,59 @@ That wait was held to ${FOREGROUND_CAP} seconds. Run it in the background (your
|
|
|
172
185
|
);
|
|
173
186
|
process.exit(out.status < 300 || out.status === 409 || out.status === 410 ? 0 : 1);
|
|
174
187
|
}
|
|
188
|
+
if (cmd === "pin") {
|
|
189
|
+
const selector = (ref || "").trim();
|
|
190
|
+
if (!selector) die(`Say where: ${CMD} pin <selector> "text" [--page /path] [--at x,y], e.g. ${CMD} pin "#pricing h2" "1. \u2026"`);
|
|
191
|
+
if (!words.length) die(`Pin text is missing: ${CMD} pin ${selector} "what you'd change, or your question"`);
|
|
192
|
+
let x = 0.5;
|
|
193
|
+
let y = 0.5;
|
|
194
|
+
if (opts.at !== void 0) {
|
|
195
|
+
const m = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*$/.exec(String(opts.at));
|
|
196
|
+
if (!m || Number(m[1]) > 1 || Number(m[2]) > 1) die("--at takes x,y as shares of the element, each 0 to 1: --at 0.5,0.5 is its middle.");
|
|
197
|
+
[x, y] = [Number(m[1]), Number(m[2])];
|
|
198
|
+
}
|
|
199
|
+
const page = await pinPage(opts.page);
|
|
200
|
+
const who = process.env.LAB_AGENT_NAME || session.agent;
|
|
201
|
+
const name = `${who}${session.name !== session.agent ? ` \xB7 ${session.name}` : ""}`;
|
|
202
|
+
const out = await call("/_lab/api/comments", { page, name, text: words.join(" "), anchor: { kind: "element", selector, x, y } });
|
|
203
|
+
if (out.status >= 300) die(`Could not pin: ${out.text}`);
|
|
204
|
+
const { comment } = JSON.parse(out.text);
|
|
205
|
+
console.log(`Pinned ${comment.id} on ${page} at ${selector}.`);
|
|
206
|
+
process.exit(0);
|
|
207
|
+
}
|
|
208
|
+
async function pinPage(asked) {
|
|
209
|
+
const got = await call("/_lab/pages", {});
|
|
210
|
+
const pages = got.status < 300 ? JSON.parse(got.text).pages || [] : [];
|
|
211
|
+
const proxied = got.status < 300 && Boolean(JSON.parse(got.text).proxy);
|
|
212
|
+
const list = () => pages.map((p) => p.path).join(", ") || "none yet";
|
|
213
|
+
if (asked === void 0 || asked === true) {
|
|
214
|
+
if (pages.length === 1 && !proxied) return pages[0].path;
|
|
215
|
+
die(`Which page? Add --page /path. This lab's pages: ${list()}.`);
|
|
216
|
+
}
|
|
217
|
+
let want2 = String(asked).trim();
|
|
218
|
+
try {
|
|
219
|
+
if (/^https?:\/\//.test(want2)) want2 = new URL(want2).pathname;
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
want2 = decodeURIComponent(want2);
|
|
224
|
+
} catch {
|
|
225
|
+
}
|
|
226
|
+
const bare = want2.replace(/^\/+|\/+$/g, "");
|
|
227
|
+
const pathOf = (u) => {
|
|
228
|
+
try {
|
|
229
|
+
return decodeURIComponent(new URL(u).pathname).replace(/^\/+|\/+$/g, "");
|
|
230
|
+
} catch {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const key = keyFor((bare.replace(/\.html?$/i, "") || "index").split("/").join(path.sep));
|
|
235
|
+
if (proxied) return key;
|
|
236
|
+
const asIndex = keyFor(`${bare}/index`.split("/").join(path.sep));
|
|
237
|
+
const hit2 = pages.find((p) => [want2, "/" + bare, key, asIndex].includes(p.path) || p.file && p.file === bare || pathOf(p.url) === bare);
|
|
238
|
+
if (hit2) return hit2.path;
|
|
239
|
+
die(`No page ${want2} in this lab. Its pages: ${list()}.`);
|
|
240
|
+
}
|
|
175
241
|
const data = {};
|
|
176
242
|
const store = path.join(dir, ".lab/comments");
|
|
177
243
|
if (!fs.existsSync(store)) Object.assign(data, JSON.parse(fs.readFileSync(path.join(dir, ".lab/comments.json"), "utf8")));
|
|
@@ -195,28 +261,13 @@ That wait was held to ${FOREGROUND_CAP} seconds. Run it in the background (your
|
|
|
195
261
|
hit = hits[0];
|
|
196
262
|
}
|
|
197
263
|
if (!hit) die(`No open comment ${ref || ""}${want ? ` on ${want}` : ""}. See .lab/comments.md.`);
|
|
198
|
-
if (cmd === "zoom") {
|
|
199
|
-
const [file] = words;
|
|
200
|
-
if (!file) die(`Give the file with the block: ${CMD} zoom <id> <file>`);
|
|
201
|
-
if (!fs.existsSync(file)) die(`No file ${file}.`);
|
|
202
|
-
const out = await call("/_lab/api/zoom", { page: hit.page, id: hit.id, html: fs.readFileSync(file, "utf8") });
|
|
203
|
-
if (out.status >= 300) {
|
|
204
|
-
let why = out.text;
|
|
205
|
-
try {
|
|
206
|
-
why = JSON.parse(out.text).error || why;
|
|
207
|
-
} catch {
|
|
208
|
-
}
|
|
209
|
-
die(`Not placed: ${why || out.status}. Fix it and run it again.`);
|
|
210
|
-
}
|
|
211
|
-
const r = JSON.parse(out.text);
|
|
212
|
-
console.log(`Placed #${r.id} in ${r.file}. Now answer on the pin in one line, naming #${r.id} (it links to it): ${CMD} reply ${hit.id} "\u2026 #${r.id}"`);
|
|
213
|
-
process.exit(0);
|
|
214
|
-
}
|
|
215
264
|
if (cmd === "reply") {
|
|
216
265
|
if (!words.length) die(`Reply text is missing: ${CMD} reply <id> "what you did"`);
|
|
266
|
+
const intent = replyIntent(opts);
|
|
267
|
+
if (intent instanceof Error) die(intent.message);
|
|
217
268
|
const who = process.env.LAB_AGENT_NAME || session.agent;
|
|
218
269
|
const name = `${who}${session.name !== session.agent ? ` \xB7 ${session.name}` : ""}`;
|
|
219
|
-
const out = await call("/_lab/api/comments", { page: hit.page, parent: hit.id, ...hit.to ? { to: hit.to } : {}, name, text: words.join(" "), ...typeof opts["suggest-rule"] === "string" ? { suggest: opts["suggest-rule"] } : {} });
|
|
270
|
+
const out = await call("/_lab/api/comments", { page: hit.page, parent: hit.id, ...hit.to ? { to: hit.to } : {}, name, text: words.join(" "), ...typeof opts["suggest-rule"] === "string" ? { suggest: opts["suggest-rule"] } : {}, ...intent ? { intent } : {} });
|
|
220
271
|
if (out.status >= 300) die(`Could not reply: ${out.text}`);
|
|
221
272
|
}
|
|
222
273
|
if (cmd === "resolve" || opts.resolve) {
|