@leonidstern/labit 0.6.3-main.6 → 0.6.3-main.8

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,8 @@ Versions follow [semver](https://semver.org). Before 1.0, a minor version can ch
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ - `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`.
8
+ - 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
9
  - 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
10
 
9
11
  ## 0.6.2 · 2026-11-17
package/README.md CHANGED
@@ -30,6 +30,7 @@ It finds your running dev server (Astro, Next, Vite…) or serves plain HTML, an
30
30
  ```sh
31
31
  npx @leonidstern/labit wait # ends with your next comment
32
32
  npx @leonidstern/labit reply <id> "Done: …" # answers on the pin
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
- - `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.
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.
@@ -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 });
@@ -13,7 +13,7 @@ function waitSeconds(opts, isTTY = false) {
13
13
  return { seconds: Math.min(asked, FOREGROUND_CAP), capped: asked > FOREGROUND_CAP };
14
14
  }
15
15
  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"];
16
+ var VALUED = ["--port", "--name", "--page", "--pages", "--timeout", "--dir", "--proxy", "--model", "--suggest-rule", "--at"];
17
17
  function parseArgs(argv) {
18
18
  const opts = {};
19
19
  const pos = [];
@@ -42,6 +42,9 @@ import fs from "node:fs";
42
42
  import os from "node:os";
43
43
  import path from "node:path";
44
44
  var REGISTRY = path.join(process.env.LABIT_HOME || path.join(os.homedir(), ".labit"), "servers");
45
+ var keyFor = (rel) => "/" + rel.replace(/\.html?$/i, "").split(path.sep).map(
46
+ (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("")
47
+ ).join("/");
45
48
  var runningLabs = () => (fs.existsSync(REGISTRY) ? fs.readdirSync(REGISTRY) : []).filter((n) => n.endsWith(".json")).flatMap((n) => {
46
49
  const file = path.join(REGISTRY, n);
47
50
  try {
@@ -61,5 +64,6 @@ export {
61
64
  WRITE_SHORT,
62
65
  parseArgs,
63
66
  REGISTRY,
67
+ keyFor,
64
68
  runningLabs
65
69
  };
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  FOREGROUND_CAP,
3
+ keyFor,
3
4
  listenPages,
4
5
  runningLabs,
5
6
  waitSeconds
6
- } from "./chunk-XZUZQFBJ.mjs";
7
+ } from "./chunk-AVHHABII.mjs";
7
8
  import {
8
9
  WAIT_SAID,
9
10
  findLab,
@@ -140,7 +141,7 @@ ${links.map((l) => `${l.title || l.url} ${l.url}`).join("\n")}`);
140
141
  console.log(out);
141
142
  process.exit(0);
142
143
  }
143
- if (["wait", "reply", "resolve", "invite", "zoom"].includes(pos[0])) {
144
+ if (["wait", "reply", "resolve", "pin", "invite"].includes(pos[0])) {
144
145
  const [cmd, ref, ...words] = pos;
145
146
  const lab = findLab(opts.dir || ".") || die(`No lab server for this folder. Start one: run ${CMD} in the project.`);
146
147
  const { dir, server } = lab;
@@ -172,6 +173,59 @@ That wait was held to ${FOREGROUND_CAP} seconds. Run it in the background (your
172
173
  );
173
174
  process.exit(out.status < 300 || out.status === 409 || out.status === 410 ? 0 : 1);
174
175
  }
176
+ if (cmd === "pin") {
177
+ const selector = (ref || "").trim();
178
+ if (!selector) die(`Say where: ${CMD} pin <selector> "text" [--page /path] [--at x,y], e.g. ${CMD} pin "#pricing h2" "1. \u2026"`);
179
+ if (!words.length) die(`Pin text is missing: ${CMD} pin ${selector} "what you'd change, or your question"`);
180
+ let x = 0.5;
181
+ let y = 0.5;
182
+ if (opts.at !== void 0) {
183
+ const m = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*$/.exec(String(opts.at));
184
+ 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.");
185
+ [x, y] = [Number(m[1]), Number(m[2])];
186
+ }
187
+ const page = await pinPage(opts.page);
188
+ const who = process.env.LAB_AGENT_NAME || session.agent;
189
+ const name = `${who}${session.name !== session.agent ? ` \xB7 ${session.name}` : ""}`;
190
+ const out = await call("/_lab/api/comments", { page, name, text: words.join(" "), anchor: { kind: "element", selector, x, y } });
191
+ if (out.status >= 300) die(`Could not pin: ${out.text}`);
192
+ const { comment } = JSON.parse(out.text);
193
+ console.log(`Pinned ${comment.id} on ${page} at ${selector}.`);
194
+ process.exit(0);
195
+ }
196
+ async function pinPage(asked) {
197
+ const got = await call("/_lab/pages", {});
198
+ const pages = got.status < 300 ? JSON.parse(got.text).pages || [] : [];
199
+ const proxied = got.status < 300 && Boolean(JSON.parse(got.text).proxy);
200
+ const list = () => pages.map((p) => p.path).join(", ") || "none yet";
201
+ if (asked === void 0 || asked === true) {
202
+ if (pages.length === 1 && !proxied) return pages[0].path;
203
+ die(`Which page? Add --page /path. This lab's pages: ${list()}.`);
204
+ }
205
+ let want2 = String(asked).trim();
206
+ try {
207
+ if (/^https?:\/\//.test(want2)) want2 = new URL(want2).pathname;
208
+ } catch {
209
+ }
210
+ try {
211
+ want2 = decodeURIComponent(want2);
212
+ } catch {
213
+ }
214
+ const bare = want2.replace(/^\/+|\/+$/g, "");
215
+ const pathOf = (u) => {
216
+ try {
217
+ return decodeURIComponent(new URL(u).pathname).replace(/^\/+|\/+$/g, "");
218
+ } catch {
219
+ return null;
220
+ }
221
+ };
222
+ const key = keyFor((bare.replace(/\.html?$/i, "") || "index").split("/").join(path.sep));
223
+ if (proxied) return key;
224
+ const asIndex = keyFor(`${bare}/index`.split("/").join(path.sep));
225
+ const hit2 = pages.find((p) => [want2, "/" + bare, key, asIndex].includes(p.path) || p.file && p.file === bare || pathOf(p.url) === bare);
226
+ if (hit2) return hit2.path;
227
+ die(`No page ${want2} in this lab. Its pages: ${list()}.`);
228
+ }
175
229
  const data = {};
176
230
  const store = path.join(dir, ".lab/comments");
177
231
  if (!fs.existsSync(store)) Object.assign(data, JSON.parse(fs.readFileSync(path.join(dir, ".lab/comments.json"), "utf8")));
@@ -195,23 +249,6 @@ That wait was held to ${FOREGROUND_CAP} seconds. Run it in the background (your
195
249
  hit = hits[0];
196
250
  }
197
251
  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
252
  if (cmd === "reply") {
216
253
  if (!words.length) die(`Reply text is missing: ${CMD} reply <id> "what you did"`);
217
254
  const who = process.env.LAB_AGENT_NAME || session.agent;
package/dist/local.mjs CHANGED
@@ -2,9 +2,10 @@
2
2
  import {
3
3
  REGISTRY,
4
4
  WRITE_SHORT,
5
+ keyFor,
5
6
  parseArgs,
6
7
  runningLabs
7
- } from "./chunk-XZUZQFBJ.mjs";
8
+ } from "./chunk-AVHHABII.mjs";
8
9
  import {
9
10
  AGENTS,
10
11
  agentKind,
@@ -203,91 +204,6 @@ How the person wants answers, for the rest of this session (sent once, and again
203
204
  ${rules.map((r) => `- ${r.text}`).join("\n")}` : "";
204
205
  }
205
206
 
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
207
  // local.mjs
292
208
  var SELF_DIR = path3.dirname(fileURLToPath(import.meta.url));
293
209
  var REPO = path3.basename(SELF_DIR) === "dist" ? path3.dirname(SELF_DIR) : SELF_DIR;
@@ -316,7 +232,7 @@ Run it as npx @leonidstern/labit \u2026, or node local.mjs \u2026 from a clone.
316
232
  labit add <url> [--name "title"] \xB7 labit remove <url>
317
233
  Save a cloud lab page (https://<lab domain>/<page>) for this folder, in .lab/links.json.
318
234
  labit mcp
319
- Optional: an MCP server (stdin/stdout) for agents with MCP: tools comments, reply and wait, for this folder's lab.
235
+ Optional: an MCP server (stdin/stdout) for agents with MCP: tools comments, reply, pin and wait, for this folder's lab.
320
236
  Claude Code: claude mcp add labit -- npx @leonidstern/labit@latest mcp
321
237
  Codex: codex mcp add labit -- npx @leonidstern/labit@latest mcp
322
238
  labit preview [folder]
@@ -338,8 +254,9 @@ For the agent, from the project (any folder under it):
338
254
  labit reply <id> "what you did" [--resolve] [--wait] [--page /path]
339
255
  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
256
  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.
257
+ labit pin <selector> "text" [--page /path] [--at x,y]
258
+ Leave your own pin on a spot: for suggestions and questions about the page, one pin per point, numbered, instead
259
+ of a list in a reply. --at: where on the element, as shares of it (default 0.5,0.5, its middle). Prints the pin's id.
343
260
 
344
261
  Files in .lab/ inside the folder: comments.md (every open comment as text), comments/ (the store, one file per
345
262
  page), archive/ (done threads with nothing new in 30 days), server.json (port, key, session; owner-only), seen.
@@ -355,8 +272,8 @@ var die = (msg) => {
355
272
  };
356
273
  if (unknownFlags.length) die(`Unknown option ${unknownFlags[0]}. See: ${CMD} --help`);
357
274
  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");
275
+ var COMMANDS = ["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "pin", "invite", "mcp", "settings"];
276
+ var { loadSettings, changedShortcuts, savePersonal, saveFlag } = await import("./settings-T6OQSQH4.mjs");
360
277
  var { FLAGS, flagsOn } = await import("./flags-PGKWZHJC.mjs");
361
278
  var SETTINGS = loadSettings(HERE, {
362
279
  port: opts.port !== void 0 && opts.port !== true ? Number(opts.port) : void 0,
@@ -381,7 +298,7 @@ if (fromFile("model") && SET.model) process.env.LAB_MODEL = SET.model;
381
298
  for (const p of SETTINGS.problems) console.error(`[labit] ${p}`);
382
299
  if (pos[0] === "settings") {
383
300
  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);
301
+ 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
302
  const home = (f) => f.replace(os2.homedir(), "~");
386
303
  const src = (f) => f.split(" + ").map((x) => x === SETTINGS.files.project ? "labit.json" : x === SETTINGS.files.personal ? "your settings" : x).join(" + ");
387
304
  console.log(`Project: ${SETTINGS.files.project ? home(SETTINGS.files.project) : `no labit.json in ${home(HERE)} or above`}
@@ -393,12 +310,12 @@ Yours: ${home(SETTINGS.files.personal)}${fs3.existsSync(SETTINGS.files.persona
393
310
  A flag or variable wins over labit.json, which wins over your file. See docs/settings.md.`);
394
311
  process.exit(SETTINGS.problems.length ? 1 : 0);
395
312
  }
396
- if (["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "invite", "zoom"].includes(pos[0])) {
397
- const { runCommand } = await import("./commands-LAQNMF2X.mjs");
313
+ if (["preview", "add", "remove", "list", "pages", "wait", "reply", "resolve", "pin", "invite"].includes(pos[0])) {
314
+ const { runCommand } = await import("./commands-OHKRNEW2.mjs");
398
315
  await runCommand({ pos, opts, HERE, CMD, ME, die });
399
316
  }
400
317
  if (pos[0] === "mcp") {
401
- const { runMcp } = await import("./mcp-4UPGXLZR.mjs");
318
+ const { runMcp } = await import("./mcp-PALQPXC6.mjs");
402
319
  await runMcp({ HERE, ME, CMD, VERSION, WRITE_SHORT, AGENTS, agentKind, agentNow });
403
320
  }
404
321
  if (pos[0] && !fs3.existsSync(pos[0])) die(`No folder ${pos[0]}. Run ${CMD} in your project, or name a folder (see --help)`);
@@ -411,7 +328,7 @@ var alreadyRunning = (() => {
411
328
  return false;
412
329
  }
413
330
  })();
414
- if (!alreadyRunning && !opts.new && !["wait", "reply", "resolve", "zoom"].includes(pos[0])) {
331
+ if (!alreadyRunning && !opts.new && !["wait", "reply", "resolve", "pin"].includes(pos[0])) {
415
332
  const home = runningLabs().find((lab) => ROOT.startsWith(lab.root + path3.sep));
416
333
  if (home) {
417
334
  const url = `http://localhost:${home.port}/${path3.relative(home.root, ROOT).split(path3.sep).map(encodeURIComponent).join("/")}/`;
@@ -579,9 +496,6 @@ function archiveOld(now = Date.now()) {
579
496
  return changed;
580
497
  }
581
498
  for (const p of archiveOld()) savePage(p);
582
- var keyFor = (rel) => "/" + rel.replace(/\.html?$/i, "").split(path3.sep).map(
583
- (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("")
584
- ).join("/");
585
499
  var fileIndex = null;
586
500
  var fileMemo = /* @__PURE__ */ new Map();
587
501
  var fileMemoAt = Date.now();
@@ -593,7 +507,6 @@ var fileFor = (page) => {
593
507
  if (!fileMemo.has(page)) fileMemo.set(page, findFile(page));
594
508
  return fileMemo.get(page);
595
509
  };
596
- var ZOOM_SKILL = SET.zoom.skill || path3.join(REPO, "skills/labit/zoom.md");
597
510
  var findFile = (page) => {
598
511
  if (!fileIndex) {
599
512
  fileIndex = /* @__PURE__ */ new Map();
@@ -1104,8 +1017,7 @@ ${f.c.parent || f.c.id}`));
1104
1017
 
1105
1018
  ${blocks.join("\n\n")}` : "") + `
1106
1019
 
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) ? `
1020
+ 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
1021
  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
1022
  ${WRITE_SHORT}` + rulesOnce();
1111
1023
  const handed = [...sent].map((k) => k.split("\n"));
@@ -1439,29 +1351,6 @@ var handler = async (req, res) => {
1439
1351
  res.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
1440
1352
  return res.end(JSON.stringify({ ids }));
1441
1353
  }
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
1354
  if (pathname === "/_lab/api/comments") {
1466
1355
  const agent = isAgent(req);
1467
1356
  const listPage = req.method === "GET" && [...url.searchParams.keys()].join() === "page" ? url.searchParams.get("page") : "";
@@ -1493,12 +1382,6 @@ var handler = async (req, res) => {
1493
1382
  const oneThing = asks.length === 1 && !listy(asks[0].text);
1494
1383
  if (oneThing && !root.resolved && root.anchor?.kind !== "page") h.set(stored.parent, JSON.stringify({ ...root, resolved: true, resolvedBy: "agent" }));
1495
1384
  }
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
1385
  if (!agent) announce(key.slice("lab:comments:".length), stored);
1503
1386
  }
1504
1387
  const changed = (() => {
@@ -65,6 +65,24 @@ async function runMcp({ HERE, ME, CMD, VERSION, WRITE_SHORT, AGENTS, agentKind,
65
65
  },
66
66
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
67
67
  },
68
+ {
69
+ name: "pin",
70
+ title: "Leave your own pin",
71
+ description: `Leave your own pin on a spot of a page in the local lab: for suggestions and questions about the page, one pin per point, numbered, instead of a list in a reply. Returns the pin's id. ${WRITE_SHORT}`,
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: {
75
+ selector: { type: "string", description: 'CSS selector of the element, e.g. "#pricing h2"' },
76
+ text: { type: "string", description: 'The suggestion or question, e.g. "1. The price is easy to miss: make it bigger?"' },
77
+ page: { type: "string", description: "The page: its path (/pricing), file (pricing.html) or address. Default: the lab's only page" },
78
+ at: { type: "string", description: 'Where on the element, x,y as shares of it (default "0.5,0.5", its middle)' },
79
+ dir: { type: "string", description: "The project folder, if the server started somewhere else (default: the client's root or the folder it started in)" }
80
+ },
81
+ required: ["selector", "text"],
82
+ additionalProperties: false
83
+ },
84
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
85
+ },
68
86
  {
69
87
  name: "wait",
70
88
  title: "Wait for the next pin",
@@ -119,6 +137,13 @@ async function runMcp({ HERE, ME, CMD, VERSION, WRITE_SHORT, AGENTS, agentKind,
119
137
  const r = await run(["reply", a.id, a.text, ...a.resolve ? ["--resolve"] : []], 3e4, project(a));
120
138
  return text(r.text, !r.ok);
121
139
  }
140
+ if (name === "pin") {
141
+ for (const k of ["selector", "text"])
142
+ if (typeof a[k] !== "string" || !a[k].trim()) return text(`\`${k}\` is required: ${k === "selector" ? "the CSS selector of the element" : "your suggestion or question"}.`, true);
143
+ for (const k of ["page", "at", "dir"]) if (a[k] !== void 0 && typeof a[k] !== "string") return text(`\`${k}\` must be a string.`, true);
144
+ const r = await run(["pin", ...a.page ? ["--page", a.page] : [], ...a.at ? ["--at", a.at] : [], "--", a.selector, a.text], 3e4, project(a));
145
+ return text(r.text, !r.ok);
146
+ }
122
147
  if (a.seconds !== void 0 && (typeof a.seconds !== "number" || !Number.isFinite(a.seconds))) return text("`seconds` must be a number.", true);
123
148
  if (a.dir !== void 0 && typeof a.dir !== "string") return text("`dir` must be a folder path.", true);
124
149
  if (a.model !== void 0 && typeof a.model !== "string") return text("`model` must be a name, e.g. Sonnet 5.5.", true);
@@ -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.6",
3
+ "version": "0.6.3-main.8",
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": {