@leonidstern/labit 0.6.3-main.4 → 0.6.3-main.7

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 CHANGED
@@ -4,6 +4,7 @@ Versions follow [semver](https://semver.org). Before 1.0, a minor version can ch
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ - 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.
7
8
  - 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
9
 
9
10
  ## 0.6.2 · 2026-11-17
package/README.md CHANGED
@@ -45,7 +45,7 @@ Everything merged to main, before it is released: `npx @leonidstern/labit@next`.
45
45
  - 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
46
  - 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
47
  - Comments stay in `.lab/` in your project. Add it to `.gitignore`.
48
- - `3` is zoom, on plain HTML pages: a comment that asks your agent for a deeper look into what it's on (3 once) or the bigger picture around it (3 again). `1` comment, `2` go, `4` pointer.
48
+ - `1` comment, `2` go (every click approves what it's on), `3` pointer (clicks are the page's own).
49
49
  - No dependencies, Node 22+. `--help` lists everything else.
50
50
 
51
51
  Shared labs on a domain (comments from people you send a link to) come later.
@@ -160,9 +160,8 @@ function cleanAnchor(a) {
160
160
  time: sec(a.time),
161
161
  duration: sec(a.duration),
162
162
  context: clean(a.context, MAX.context) || undefined, // older widget versions
163
- // Zoom (lib/zoom.ts): the nearest element with an id around the spot, and on a zoom its direction.
163
+ // The nearest element with an id around the spot.
164
164
  block: /^[A-Za-z][\w:.-]{0,119}$/.test(a.block || '') ? a.block : undefined,
165
- zoom: a.zoom === 'in' || a.zoom === 'out' ? a.zoom : undefined,
166
165
  };
167
166
  if (a.quote && typeof a.quote === 'object') {
168
167
  const exact = clean(a.quote.exact, 300); // selected words can run long; a click quotes one word
@@ -291,7 +290,6 @@ function asText(path, comments, host) {
291
290
  if (a.cssText) lines.push(`text added by CSS: ${a.cssText} (search the CSS for it)`);
292
291
  if (a.section) lines.push(`section: "${a.section}"`);
293
292
  if (a.block) lines.push(`block: ${a.block}`);
294
- if (a.zoom) lines.push(a.zoom === 'out' ? 'zoom: out, the bigger picture (not a change request: write one block that shows the bigger picture this block sits in; see the zoom skill)' : 'zoom: in, dive deeper (not a change request: write one block that goes deeper into this block; see the zoom skill)');
295
293
  if (a.zw) {
296
294
  lines.push(`type: area comment, ${a.docW}×${a.docH} px on screen`);
297
295
  lines.push(`area on element: ${pct(a.x)}–${pct(a.x + a.zw)} across, ${pct(a.y)}–${pct(a.y + a.zh)} down`);
@@ -368,7 +366,6 @@ export async function POST(request) {
368
366
  const thread = JSON.parse(current);
369
367
  if (thread.parent || !body.anchor || typeof body.anchor !== 'object') return json({ error: 'bad move' }, 400);
370
368
  const anchor = cleanAnchor(body.anchor);
371
- if (thread.anchor?.zoom && !anchor.zoom) anchor.zoom = thread.anchor.zoom; // a moved zoom stays a zoom, whatever the widget sent
372
369
  const comment = { ...thread, anchor, movedAt: new Date().toISOString() };
373
370
  await run('HSET', key, id, JSON.stringify(comment));
374
371
  return json({ comment });
@@ -140,7 +140,7 @@ ${links.map((l) => `${l.title || l.url} ${l.url}`).join("\n")}`);
140
140
  console.log(out);
141
141
  process.exit(0);
142
142
  }
143
- if (["wait", "reply", "resolve", "invite", "zoom"].includes(pos[0])) {
143
+ if (["wait", "reply", "resolve", "invite"].includes(pos[0])) {
144
144
  const [cmd, ref, ...words] = pos;
145
145
  const lab = findLab(opts.dir || ".") || die(`No lab server for this folder. Start one: run ${CMD} in the project.`);
146
146
  const { dir, server } = lab;
@@ -195,23 +195,6 @@ That wait was held to ${FOREGROUND_CAP} seconds. Run it in the background (your
195
195
  hit = hits[0];
196
196
  }
197
197
  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
198
  if (cmd === "reply") {
216
199
  if (!words.length) die(`Reply text is missing: ${CMD} reply <id> "what you did"`);
217
200
  const who = process.env.LAB_AGENT_NAME || session.agent;
package/dist/local.mjs CHANGED
@@ -203,91 +203,6 @@ How the person wants answers, for the rest of this session (sent once, and again
203
203
  ${rules.map((r) => `- ${r.text}`).join("\n")}` : "";
204
204
  }
205
205
 
206
- // lib/zoom.ts
207
- var dirOf = (zoom) => zoom === "in" || zoom === "out" ? zoom : null;
208
- var zoomName = (dir) => dir === "out" ? "bigger picture" : "deeper look";
209
- var reEsc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
210
- var VOID = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i;
211
- function elementAt(html, m) {
212
- const tag = m[1];
213
- const start = m.index;
214
- if (VOID.test(tag) || m[0].endsWith("/>")) return { tag, open: m[0], start, end: start + m[0].length, outer: m[0] };
215
- const re = new RegExp(`<(/?)${reEsc(tag)}\\b[^>]*>`, "gi");
216
- re.lastIndex = start + m[0].length;
217
- let depth = 1;
218
- let k;
219
- while (k = re.exec(html)) {
220
- if (k[0].endsWith("/>")) continue;
221
- depth += k[1] ? -1 : 1;
222
- if (!depth) return { tag, open: m[0], start, end: re.lastIndex, outer: html.slice(start, re.lastIndex) };
223
- }
224
- return null;
225
- }
226
- var TAG = "<([a-zA-Z][a-zA-Z0-9-]*)\\b[^>]*";
227
- function blockById(html, id) {
228
- const m = new RegExp(`${TAG}\\bid="${reEsc(id)}"[^>]*>`).exec(html);
229
- return m ? elementAt(html, m) : null;
230
- }
231
- function topLevel(html) {
232
- const re = /<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*>/g;
233
- const out = [];
234
- let m;
235
- while (m = re.exec(html)) {
236
- const e = elementAt(html, m);
237
- if (!e) throw new ZoomError(`a <${m[1]}> in what you sent is not closed`);
238
- out.push(e);
239
- re.lastIndex = e.end;
240
- }
241
- return out;
242
- }
243
- var ZoomError = class extends Error {
244
- };
245
- var MARKS = /\s(?:id|data-zoom|data-zoom-of)="[^"]*"/g;
246
- function partOf(html, block) {
247
- const sec = /<section\b[^>]*>/gi;
248
- let q;
249
- while ((q = sec.exec(html)) && q.index <= block.start) {
250
- const e = elementAt(html, Object.assign(q, { 1: "section" }));
251
- if (e && e.start <= block.start && e.end >= block.end) return e;
252
- if (e) sec.lastIndex = e.end;
253
- }
254
- const m = /<(main)\b[^>]*>/i.exec(html) || /<(body)\b[^>]*>/i.exec(html);
255
- const box = m ? elementAt(html, m) : null;
256
- if (!box || block.start < box.start || block.end > box.end) return block;
257
- const re = /<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*>/g;
258
- re.lastIndex = box.start + box.open.length;
259
- let k;
260
- while ((k = re.exec(html)) && k.index < box.end) {
261
- const e = elementAt(html, k);
262
- if (!e) break;
263
- if (e.start <= block.start && e.end >= block.end) return e;
264
- re.lastIndex = e.end;
265
- }
266
- return block;
267
- }
268
- function place(p) {
269
- const block = blockById(p.html, p.block);
270
- if (!block) throw new ZoomError(`no block with id "${p.block}" on the page`);
271
- const els = topLevel(p.made);
272
- if (els.length !== 1) throw new ZoomError(`send one element (a <section> with everything inside it), you sent ${els.length}`);
273
- const el = els[0];
274
- const base = `${p.block}-${p.dir === "out" ? "bigger" : "deeper"}`;
275
- let id = base;
276
- for (let n = 2; blockById(p.html, id); n++) id = `${base}-${n}`;
277
- const open = el.open.replace(MARKS, "").replace(new RegExp(`^<${reEsc(el.tag)}`), `<${el.tag} id="${id}" data-zoom="${p.dir}" data-zoom-of="${p.block}"`);
278
- const placed = el.outer.replace(el.open, open).trim();
279
- const part = partOf(p.html, block);
280
- let end = part.end;
281
- for (; ; ) {
282
- const m = /^\s*<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-zoom="in"[^>]*>/.exec(p.html.slice(end));
283
- const next = m && elementAt(p.html, Object.assign(m, { index: end + m[0].indexOf("<") }));
284
- if (!next) break;
285
- end = next.end;
286
- }
287
- const html = p.dir === "in" ? p.html.slice(0, end) + "\n" + placed + p.html.slice(end) : p.html.slice(0, part.start) + placed + "\n" + p.html.slice(part.start);
288
- return { html, id };
289
- }
290
-
291
206
  // local.mjs
292
207
  var SELF_DIR = path3.dirname(fileURLToPath(import.meta.url));
293
208
  var REPO = path3.basename(SELF_DIR) === "dist" ? path3.dirname(SELF_DIR) : SELF_DIR;
@@ -338,8 +253,6 @@ For the agent, from the project (any folder under it):
338
253
  labit reply <id> "what you did" [--resolve] [--wait] [--page /path]
339
254
  Answer on the pin. Use the id that wait printed (the number on the card works too, but shifts after a delete). --resolve closes the thread; --wait listens again right after.
340
255
  labit resolve <id> [--page /path]
341
- labit zoom <id> <file>
342
- Answer a zoom: <file> holds one element, the deeper look or the bigger picture. The lab places it on the page.
343
256
 
344
257
  Files in .lab/ inside the folder: comments.md (every open comment as text), comments/ (the store, one file per
345
258
  page), archive/ (done threads with nothing new in 30 days), server.json (port, key, session; owner-only), seen.
@@ -355,8 +268,8 @@ var die = (msg) => {
355
268
  };
356
269
  if (unknownFlags.length) die(`Unknown option ${unknownFlags[0]}. See: ${CMD} --help`);
357
270
  var HERE = fs3.realpathSync(path3.resolve(opts.dir || "."));
358
- var COMMANDS = ["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "invite", "zoom", "mcp", "settings"];
359
- var { loadSettings, changedShortcuts, savePersonal, saveFlag } = await import("./settings-XLFKONNN.mjs");
271
+ var COMMANDS = ["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "invite", "mcp", "settings"];
272
+ var { loadSettings, changedShortcuts, savePersonal, saveFlag } = await import("./settings-T6OQSQH4.mjs");
360
273
  var { FLAGS, flagsOn } = await import("./flags-PGKWZHJC.mjs");
361
274
  var SETTINGS = loadSettings(HERE, {
362
275
  port: opts.port !== void 0 && opts.port !== true ? Number(opts.port) : void 0,
@@ -381,7 +294,7 @@ if (fromFile("model") && SET.model) process.env.LAB_MODEL = SET.model;
381
294
  for (const p of SETTINGS.problems) console.error(`[labit] ${p}`);
382
295
  if (pos[0] === "settings") {
383
296
  const changed = changedShortcuts(SET.shortcuts);
384
- const show = (k, v) => k === "shortcuts" ? Object.keys(changed).length ? Object.entries(changed).map(([a, key]) => `${a} ${key}`).join(", ") : "the defaults" : k === "zoom" ? v.skill || "the built-in skill" : k === "flags" ? flagsOn(v).join(", ") || "none on" : String(v === "" ? "(none)" : v);
297
+ const show = (k, v) => k === "shortcuts" ? Object.keys(changed).length ? Object.entries(changed).map(([a, key]) => `${a} ${key}`).join(", ") : "the defaults" : k === "flags" ? flagsOn(v).join(", ") || "none on" : String(v === "" ? "(none)" : v);
385
298
  const home = (f) => f.replace(os2.homedir(), "~");
386
299
  const src = (f) => f.split(" + ").map((x) => x === SETTINGS.files.project ? "labit.json" : x === SETTINGS.files.personal ? "your settings" : x).join(" + ");
387
300
  console.log(`Project: ${SETTINGS.files.project ? home(SETTINGS.files.project) : `no labit.json in ${home(HERE)} or above`}
@@ -393,8 +306,8 @@ Yours: ${home(SETTINGS.files.personal)}${fs3.existsSync(SETTINGS.files.persona
393
306
  A flag or variable wins over labit.json, which wins over your file. See docs/settings.md.`);
394
307
  process.exit(SETTINGS.problems.length ? 1 : 0);
395
308
  }
396
- if (["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "invite", "zoom"].includes(pos[0])) {
397
- const { runCommand } = await import("./commands-LAQNMF2X.mjs");
309
+ if (["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "invite"].includes(pos[0])) {
310
+ const { runCommand } = await import("./commands-2VQ6P2IH.mjs");
398
311
  await runCommand({ pos, opts, HERE, CMD, ME, die });
399
312
  }
400
313
  if (pos[0] === "mcp") {
@@ -411,7 +324,7 @@ var alreadyRunning = (() => {
411
324
  return false;
412
325
  }
413
326
  })();
414
- if (!alreadyRunning && !opts.new && !["wait", "reply", "resolve", "zoom"].includes(pos[0])) {
327
+ if (!alreadyRunning && !opts.new && !["wait", "reply", "resolve"].includes(pos[0])) {
415
328
  const home = runningLabs().find((lab) => ROOT.startsWith(lab.root + path3.sep));
416
329
  if (home) {
417
330
  const url = `http://localhost:${home.port}/${path3.relative(home.root, ROOT).split(path3.sep).map(encodeURIComponent).join("/")}/`;
@@ -593,7 +506,6 @@ var fileFor = (page) => {
593
506
  if (!fileMemo.has(page)) fileMemo.set(page, findFile(page));
594
507
  return fileMemo.get(page);
595
508
  };
596
- var ZOOM_SKILL = SET.zoom.skill || path3.join(REPO, "skills/labit/zoom.md");
597
509
  var findFile = (page) => {
598
510
  if (!fileIndex) {
599
511
  fileIndex = /* @__PURE__ */ new Map();
@@ -1104,8 +1016,7 @@ ${f.c.parent || f.c.id}`));
1104
1016
 
1105
1017
  ${blocks.join("\n\n")}` : "") + `
1106
1018
 
1107
- Answer each: ${CMD} reply <id> "what you did" [--resolve] (run in ${ROOT}); add --wait to the last one to listen again in the same command.` + (/\nzoom: (in|out)\b/.test(blocks.join("\n")) ? `
1108
- A pin that says "zoom": read ${ZOOM_SKILL} first. Write one block to a file, then ${CMD} zoom <id> <file>, then reply.` : "") + (given.some((f) => f.c.parent) ? `
1019
+ Answer each: ${CMD} reply <id> "what you did" [--resolve] (run in ${ROOT}); add --wait to the last one to listen again in the same command.` + (given.some((f) => f.c.parent) ? `
1109
1020
  A reply about how you answered rather than the work (too long, unclear, didn't show or link it, the same misread twice): answer it and add --suggest-rule "<one short rule>"; they keep it with a tap. Not for the work itself or a one-off correction.` : "") + `
1110
1021
  ${WRITE_SHORT}` + rulesOnce();
1111
1022
  const handed = [...sent].map((k) => k.split("\n"));
@@ -1439,29 +1350,6 @@ var handler = async (req, res) => {
1439
1350
  res.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
1440
1351
  return res.end(JSON.stringify({ ids }));
1441
1352
  }
1442
- if (pathname === "/_lab/api/zoom" && req.method === "POST") {
1443
- if (!isAgent(req)) return res.writeHead(403).end();
1444
- const b = JSON.parse(await new Response(req).text() || "{}");
1445
- const fail = (status, error) => res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify({ error }));
1446
- const page = String(b.page || "");
1447
- const c = commentsOf(page).find((x) => x.id === b.id && !x.parent);
1448
- const dir = dirOf(c?.anchor?.zoom);
1449
- if (!c || !dir) return fail(404, "that pin is not a zoom");
1450
- if (c.zoomed) return fail(409, `the ${zoomName(dir)} for this pin is already on the page: #${c.zoomed}`);
1451
- if (!c.anchor.block) return fail(409, `the spot is in no element with an id: put the ${zoomName(dir)} on the page yourself, next to the spot`);
1452
- const rel = !PROXY && fileFor(page);
1453
- if (!rel || !/\.html?$/i.test(rel)) return fail(409, `this page is not a plain HTML file the lab can write: put the ${zoomName(dir)} on the page yourself`);
1454
- try {
1455
- const out = place({ html: fs3.readFileSync(path3.join(ROOT, rel), "utf8"), block: c.anchor.block, dir, made: String(b.html || "") });
1456
- fs3.writeFileSync(path3.join(ROOT, rel), out.html);
1457
- setComment(page, c.id, { zoomed: out.id });
1458
- res.writeHead(200, { "content-type": "application/json" });
1459
- return res.end(JSON.stringify({ id: out.id, dir, file: rel }));
1460
- } catch (e) {
1461
- if (e instanceof ZoomError) return fail(422, e.message);
1462
- throw e;
1463
- }
1464
- }
1465
1353
  if (pathname === "/_lab/api/comments") {
1466
1354
  const agent = isAgent(req);
1467
1355
  const listPage = req.method === "GET" && [...url.searchParams.keys()].join() === "page" ? url.searchParams.get("page") : "";
@@ -1493,12 +1381,6 @@ var handler = async (req, res) => {
1493
1381
  const oneThing = asks.length === 1 && !listy(asks[0].text);
1494
1382
  if (oneThing && !root.resolved && root.anchor?.kind !== "page") h.set(stored.parent, JSON.stringify({ ...root, resolved: true, resolvedBy: "agent" }));
1495
1383
  }
1496
- if (agent && stored.parent && h.has(stored.parent)) {
1497
- const root = JSON.parse(h.get(stored.parent));
1498
- const more = [...h.values()].map((v) => JSON.parse(v)).some((x) => x.parent === root.id && x.id !== stored.id && !x.session);
1499
- const placed = root.anchor?.zoom && root.zoomed && !root.resolved && !more;
1500
- if (placed) h.set(stored.parent, JSON.stringify({ ...root, resolved: true, resolvedBy: "agent" }));
1501
- }
1502
1384
  if (!agent) announce(key.slice("lab:comments:".length), stored);
1503
1385
  }
1504
1386
  const changed = (() => {
@@ -7,7 +7,7 @@ import {
7
7
  import fs from "node:fs";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
10
- var SHORTCUTS = { toggle: "m", comment: "1", go: "2", zoom: "3", pointer: "4", chat: "c", next: "w", pause: "p", done: "d", reply: "r", resolve: "e" };
10
+ var SHORTCUTS = { toggle: "m", comment: "1", go: "2", pointer: "3", chat: "c", next: "w", pause: "p", done: "d", reply: "r", resolve: "e" };
11
11
  var SPEC = {
12
12
  port: { type: "number", def: 4400, min: 1 },
13
13
  proxy: { type: "string", def: "", only: "project" },
@@ -22,7 +22,6 @@ var SPEC = {
22
22
  name: { type: "string", def: "", only: "personal" },
23
23
  model: { type: "string", def: "", only: "personal" },
24
24
  shortcuts: { type: "shortcuts", def: SHORTCUTS },
25
- zoom: { type: "zoom", def: { skill: "" }, only: "project" },
26
25
  // What is being tried here (lib/flags.ts). Off unless a file or the ⋯ menu turns one on.
27
26
  flags: { type: "flags", def: flagDefaults() }
28
27
  };
@@ -75,12 +74,6 @@ var check = (key, v, file, problems) => {
75
74
  }
76
75
  return out;
77
76
  }
78
- if (s.type === "zoom") {
79
- if (!v || typeof v !== "object" || typeof v.skill !== "string") return bad('must be { "skill": "<path to a .md file>" }');
80
- const skill = path.resolve(path.dirname(file), v.skill);
81
- if (!fs.existsSync(skill)) return bad(`.skill: no file ${skill}`);
82
- return { skill };
83
- }
84
77
  if (typeof v !== s.type) return bad(`must be a ${s.type}`);
85
78
  if (s.type === "number" && (!Number.isFinite(v) || v < (s.min ?? -Infinity))) return bad(`must be a number of at least ${s.min}`);
86
79
  if (s.type === "string" && key === "folder") return path.resolve(path.dirname(file), v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonidstern/labit",
3
- "version": "0.6.3-main.4",
3
+ "version": "0.6.3-main.7",
4
4
  "description": "Pin comments on pages, read by your agent as plain text. Local mode: comment on pages on your computer and Claude answers on the pins.",
5
5
  "type": "module",
6
6
  "bin": {