@leonidstern/labit 0.6.0 → 0.6.1
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +44 -0
- package/README.md +20 -127
- package/api/lab-comments.mjs +8 -1
- package/dist/chunk-T4IF6ZJQ.mjs +106 -0
- package/dist/commands-BPVIWBCF.mjs +255 -0
- package/dist/devserver-KCLPMBNL.mjs +56 -0
- package/dist/local.mjs +1487 -0
- package/dist/mcp-BKU67CST.mjs +192 -0
- package/dist/proxy-FLFZV6EI.mjs +74 -0
- package/package.json +8 -6
- package/public/_lab/comments.js +30 -3592
- package/public/_lab/favicon.svg +1 -0
- package/public/_lab/lab.css +12 -0
- package/skills/labit/SKILL.md +7 -3
- package/skills/labit/zoom.md +29 -0
- package/lib/dev.mjs +0 -128
- package/lib/devserver.mjs +0 -58
- package/lib/mcp.mjs +0 -207
- package/lib/proxy.mjs +0 -73
- package/local.mjs +0 -1552
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,50 @@ Versions follow [semver](https://semver.org). Before 1.0, a minor version can ch
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.6.1 · 2026-11-16
|
|
8
|
+
|
|
9
|
+
- iPhones: a new comment no longer sometimes sits behind the keyboard's bar. When Safari (or Chrome) slid the page up for the keyboard instead of scrolling it, the widget counted that slide twice and saw no keyboard at all; it now measures the slide where WebKit measures boxes, from the screen's top.
|
|
10
|
+
- The page list: newest first, each page with its open comments and when it last changed, a summary line under the folder's name, and a filter once there are more than 8 pages (`/` to focus it).
|
|
11
|
+
- A flat drag no longer draws a green hairline across the page. Marking an area by dragging sideways (or straight down) made a rectangle with no height, which read as a line through everything rather than as something being marked. The outline now keeps a least size of 12 px each way while you drag — the size the saved area was already grown to.
|
|
12
|
+
- The bar: hover, pressed and "its menu is open" (⋯) use the first grey step after white, not the second, which read as a dirty block on the white bar; menu rows the same. The mode switch's "off" pin (3, cursor) is the pin of 1 now (white, the pins' thin edge, bold letters) with the word in grey; it had a thicker, darker ring.
|
|
13
|
+
- Zoom in the widget: 3 zooms in, 3 again zooms out (the pointer moves to 4; on phones a tap on the switch steps comment → go → in → out). A zoom is placed at once like a go, its pin shows arrows in or out, Command-Z takes it back, and the page scrolls to the block when it lands.
|
|
14
|
+
- A `#id` in a message links to that block on the page.
|
|
15
|
+
- Zoom, the lab side (plain HTML pages): a comment with `zoom: in` or `zoom: out` asks the agent for one block, a deeper look or the bigger picture, not a change. The agent hands it over with `labit zoom <id> <file>`; the lab places it next to the section the comment is in (a deeper look after, a bigger picture above) and names it; the agent's reply closes the zoom. Rules for agents: `skills/labit/zoom.md`. The widget's keys come next.
|
|
16
|
+
- Phones: the mark on the chat button sits on the word's baseline, 6 px from it (it hung 3 px low and 9 px away), and every sheet's grab handle is a pill with round ends.
|
|
17
|
+
- The widget ships minified again, its stylesheet too: 218 → 138 KB, 58.2 → 43.9 KB gzipped, 50.2 → 39.3 KB brotli. Minifying was built on 15 Nov and lost when that work moved onto main (#41). `npm run build` runs `scripts/build-widget.mjs` (esbuild's API through npx, still no dependencies), which also minifies `styles.css` as it goes in. The readable source stays `src/`.
|
|
18
|
+
- A tap on the "talking to" pill no longer copies the agent's resume command: it only says who listens.
|
|
19
|
+
- The page says which model the agent runs on: "talking to Claude · Sonnet 5.5 (project)". The agent says it with `wait --model "Sonnet 5.5"` (or the MCP `wait` tool's `model`); without it, LAB_MODEL or ANTHROPIC_MODEL when set, an id like claude-sonnet-5-5 read as "Sonnet 5.5". The skill now asks agents to pass it.
|
|
20
|
+
- Go for guests: with go on and no name saved yet (a guest's first pin), the hold opens a small card that asks only your name, with "go" already in it; send and it's a go pin. It used to open the full comment box, and nothing sent until you typed a comment too. Once the name is saved, a go hold sends straight away as before. On phones a hold now pins after 0.4 s (was 0.5 s): at 0.5 s it raced iOS's own long press, which sometimes selected text instead.
|
|
21
|
+
- Your name is remembered for this computer, not for one lab. The browser keeps it per origin and every lab takes its own port, so naming yourself in one lab left you a stranger in the next. Now the lab keeps the name you give in `~/.config/labit/me.json` (`XDG_CONFIG_HOME` is honoured) and hands it to the widget, so the next lab starts out knowing you. Phones too: `labit invite [name]` bakes a name into the one-time link — the one you give, or yours — and the device that opens it starts out named.
|
|
22
|
+
- On a phone, a tap on the send arrow sends on the first try. The arrow keeps the cursor in the box by preventing the default on pointerdown, and a prevented pointerdown can swallow the click that follows — the tap then only moved focus, the box went back to its one line, and it took a second tap to send. A touch now sends from the touch itself, and the click that may follow it is ignored.
|
|
23
|
+
- A comment you sent no longer comes back in the box. The kept draft was let go after the send, and posting redraws the box, so the new one read the words straight back in. It is let go before the send now, and handed back only if the send fails.
|
|
24
|
+
- New in the ⋯ menu: **pin over controls**. The page's own links and buttons keep their clicks, so a demo still works while comments are on — with this on they do not, and a click there places a comment, as option-click always has. Remembered per browser.
|
|
25
|
+
- While you are writing a comment, the page's own pointer is back. The crosshair (and the drawn pin that follows the mouse) said a click would drop another comment, mid-sentence, which is never what you meant. It returns the moment the box is empty again.
|
|
26
|
+
- While there are words in a box that you have not sent, the dev server's reload waits. Behind a dev server the lab now puts a small holder at the top of every page: it keeps a reload message until the last box is empty again (sent or cleared), then hands it on, so the page is never more than one comment behind and you never lose your place mid-sentence.
|
|
27
|
+
- A comment you are part-way through writing survives the page reloading under you. A dev server rebuilding the page (or a crash, or a tab closed by mistake) used to take the words with it. Now what is typed is kept as you type — per page, per thread — and comes back with it: a reply reopens its thread, and an unsent new comment comes back with its pin, on the spot you put it. It is dropped the moment it is sent.
|
|
28
|
+
- labit has a mark (our pin as a head, two slabs as ears) and uses it: the bar's listening pill shows it instead of a dot (dark with a blink now and then while an agent listens, green with twitching ears while one works, grey and still when nobody listens; same pill size), and on phones it sits on the chat button. The lab's own screens (page list, not found, the one-time-link screen) open with it. A page with no tab icon of its own gets labit's in a local lab. The README carries it beside the name.
|
|
29
|
+
- A pin whose element is gone now waits beside the content (in the gutter left of what it sat in), not 10 px from the window's left edge. On a wide window with a centred column those pins were hundreds of px from the page and read as lost. Phones and full-width pages are unchanged.
|
|
30
|
+
- Computers: a click on the page's own controls is the page's, and the pin pointer steps aside over them: links and buttons as before, and now anything the page gives a hand pointer (a card, a demo you tap to play). Option-click still pins there.
|
|
31
|
+
- Pause motion (⋯ menu, P): everything that moves on the page stops where it is, so you can pin a moment of an animation; again to play on.
|
|
32
|
+
- Phones move more like native sheets (checked frame by frame in the iOS 27 simulator):
|
|
33
|
+
- Closing a sheet with the keyboard up takes the keyboard with it at once; the keyboard used to stay alone for 0.6 s after the sheet was gone.
|
|
34
|
+
- After you send, the sheet slides off with the keyboard; it used to ride the keyboard halfway down and vanish mid-screen.
|
|
35
|
+
- The dimmed page fades with the sheet's position, as it slides and while a finger drags it; it used to be gone while most of the sheet was still up.
|
|
36
|
+
- The first sheet after the page loads slides in; it used to show up already open.
|
|
37
|
+
- A new pin low on the page scrolls up above the sheet, so you see what you're commenting on.
|
|
38
|
+
- A pin's state change (Claude on it, done, a reply) eases in, and the ring fades in and out; they used to be cuts.
|
|
39
|
+
- Tapping "your name" no longer drops the sheet behind the keyboard, and Safari no longer offers "AutoFill Contact" there.
|
|
40
|
+
- The bar's buttons no longer stay grey after a tap.
|
|
41
|
+
- Pins keep their look but take a 44 pt tap: a finger near one opens it (they were 22 pt to hit).
|
|
42
|
+
- Sheets float as cards, as iOS 27's do: inset from the screen's edges, round at every corner, the page behind not dimmed. A tapped sheet grows out of what you tapped and shrinks back into it (after a send, into the new pin); a swipe still slides it down.
|
|
43
|
+
- The new comment card moves up with the keyboard instead of jumping there.
|
|
44
|
+
- From the motion lab (Leo's picks): after a send the card flies into the new pin, which pops in (B2), the keyboard waiting until it lands; the send arrow turns dark with a tiny pop when you start typing (A5); Claude's ring draws its arc in (C2).
|
|
45
|
+
|
|
46
|
+
- The widget is split into TypeScript modules in `src/widget/`: `composer` (the message box), `messages`, `list`, `chat`, `thread`, `sheets` (phone sheets, back gesture, keyboard fit) and `live` (live page updates), beside `anchoring` and `styles`. Its shared state is one object, so the parts can share it. Same behaviour; `src/comments.js` keeps setup, loading, drawing and the events (2,688 → 1,428 lines).
|
|
47
|
+
|
|
48
|
+
- The server is moving to TypeScript: all of `lib/` is TypeScript now (`dev`, `devserver`, `mcp`, `proxy`), and `local.mjs` hands its command line (`args`), agent detection (`agents`), the running-labs list (`labs`) and the commands that answer and exit (`commands`: preview, add, list, pages, wait, reply, resolve, invite) to their own files; it keeps the server. Node runs the `.ts` source directly while working on labit; npm gets a built copy, `dist/` (made by `npm run build:cli` before every pack), so the package stays plain JavaScript with no dependencies, now 109 kB instead of 120 kB.
|
|
49
|
+
- A phone on a `--wifi` lab now needs a one-time link (`labit invite`): one use, ten minutes, after which that browser keeps a signed cookie for a day. Being on the same wifi is no longer enough, so finding the port on a public network shows a gate and nothing else. The pages still travel unencrypted over the wifi.
|
|
50
|
+
|
|
7
51
|
## 0.6.0 · 2026-11-16
|
|
8
52
|
|
|
9
53
|
- New npm name: `@leonidstern/labit` (`npx @leonidstern/labit`; npm turned down the plain name `labit` as too close to `lab` and `lit`). The `labit` and `labfb` commands both work once installed. The GitHub repo is now leonidstern/labit (old links redirect).
|
package/README.md
CHANGED
|
@@ -1,154 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
<h1><picture><source media="(prefers-color-scheme: dark)" srcset="docs/labit-mark-dark.svg"><img src="docs/labit-mark-light.svg" alt="" width="34" height="34" align="top"></picture> labit</h1>
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@leonidstern/labit) [](https://github.com/leonidstern/labit/actions/workflows/test.yml) [](LICENSE)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Pin comments on pages, and your agent reads them as plain text. Use it on a live domain where anyone with the link can comment, or on your own computer, where your agent (Claude, Codex, Cursor…) answers on the pins while it works.
|
|
8
|
-
|
|
9
|
-
**Small, no dependencies, runs in any folder.** labit uses only Node 22+ itself: no packages to install, about 120 kB on npm, 15 files. Run `npx @leonidstern/labit` in any project or folder: nothing goes into your project's dependencies or code, and it works with any stack, from plain HTML to Astro, Next or Vite.
|
|
5
|
+
**Review is the new build.** Pin comments on your pages. Your coding agent reads them, changes the code, and answers on the pin.
|
|
10
6
|
|
|
11
7
|

|
|
12
8
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
**Cloud lab**: pages on a domain, for people you share links with
|
|
16
|
-
- **No account:** anyone with the link clicks anywhere, types a name and comments.
|
|
17
|
-
- **One link for your agent:** "copy link" gives plain text with every open comment. Paste it into any agent and it goes to the file.
|
|
18
|
-
- **Knows what's under the pin:** the quoted words, the element, the image file and pixel, the code line, the video second; on a dev build, the component and the file and line that wrote it. No screenshots needed.
|
|
19
|
-
- **One domain, many repos:** the lab domain only proxies `/<name>/*` to each member's own repo and Vercel project.
|
|
20
|
-
- **Admin links per person:** let someone resolve and delete on their pages only. Nothing to set up per person.
|
|
21
|
-
|
|
22
|
-
**Local lab**: pages on your computer, for you and Claude
|
|
23
|
-
- **No deploy:** run `npx @leonidstern/labit@latest` in your project. It finds your running Astro, Next or Vite dev server and puts comments on top, or serves plain HTML files.
|
|
24
|
-
- **Your agent answers on the pin:** it hears each comment as you post it, edits the file, the page reloads, and the reply shows on the pin.
|
|
25
|
-
- **Shows who is listening:** the label says whether Claude is listening or working. Close the page and Claude waits quietly: your first comment when you're back wakes it, and it stops after an hour.
|
|
26
|
-
- **Phone too:** `--wifi` lets a phone at home join. Comments stay in `.lab/`, one store per project.
|
|
9
|
+
## Start
|
|
27
10
|
|
|
28
|
-
|
|
11
|
+
In your project:
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Paste this into your agent. It is the whole setup.
|
|
33
|
-
|
|
34
|
-
```text
|
|
35
|
-
Set up labit (https://github.com/leonidstern/labit) for me on Vercel.
|
|
36
|
-
|
|
37
|
-
0. First check whether I already have a lab (a Vercel project with LAB_HOST set, or a site that loads /_lab/comments.js). If I do, stop and tell me: add sites to that one instead.
|
|
38
|
-
1. Fork the repo and import it into Vercel: framework preset "Other", no build command.
|
|
39
|
-
2. Add Upstash Redis from the Vercel Marketplace (free tier). It sets KV_REST_API_URL and KV_REST_API_TOKEN.
|
|
40
|
-
3. Set env vars: LAB_HOST=<lab domain, e.g. lab.example.com> and LAB_COMMENTS_ADMIN_TOKEN=<output of `openssl rand -hex 24`>. Tell me the token. Redeploy so the variables apply.
|
|
41
|
-
4. Add <lab domain> to the Vercel project and tell me the DNS record to create.
|
|
42
|
-
5. For each site that should get comments (slug = a short name, e.g. anna):
|
|
43
|
-
- serve it under the base path /<slug> (Astro `base`, Next `basePath`, Vite `base`) from its own Vercel project; every page answers 200, no redirects
|
|
44
|
-
- add two rewrites to labit's vercel.json:
|
|
45
|
-
{ "source": "/<slug>", "destination": "https://<their-project>.vercel.app/<slug>" },
|
|
46
|
-
{ "source": "/<slug>/:path*", "destination": "https://<their-project>.vercel.app/<slug>/:path*" }
|
|
47
|
-
- add this to the site's shared layout, before </body>:
|
|
48
|
-
<script src="https://<lab domain>/_lab/comments.js" defer></script>
|
|
49
|
-
- put pages at /<slug>/<project>/<secret>/<page>, where <secret> is 10 random characters per project; mark them noindex and link to them from nowhere
|
|
50
|
-
- deploy it with prebuilt deploys: add "ship": "npx --yes vercel build --prod --yes && npx --yes vercel deploy --prebuilt --prod --yes"
|
|
51
|
-
to its package.json scripts and "git": { "deploymentEnabled": false } to its vercel.json, so `npm run ship` builds on my computer
|
|
52
|
-
and is live in seconds, and a push only keeps the history (link it once: `npx vercel link`)
|
|
53
|
-
6. Once I confirm the DNS works: POST a test comment with curl to https://<lab domain>/_lab/api/comments
|
|
54
|
-
({"page":"/_lab/demo","name":"setup","text":"test"}, content-type application/json) and check that
|
|
55
|
-
https://<lab domain>/_lab/agent/_lab/demo shows it as text. Then delete it with header x-lab-admin: <token>.
|
|
13
|
+
```sh
|
|
14
|
+
npx @leonidstern/labit@latest
|
|
56
15
|
```
|
|
57
16
|
|
|
58
|
-
|
|
59
|
-
- **Read:** `https://<lab domain>/_lab/agent/<page path>` returns every open comment as plain text. Paste it into your agent.
|
|
60
|
-
- **Resolve or delete:** open any page once with `#lab-admin=<token>`.
|
|
61
|
-
- **Deploys:** each site ships with `npm run ship` (built on your computer, uploaded with `vercel deploy --prebuilt`, live in about 6 s for a small Astro site); pushes don't deploy. Ship what you commit.
|
|
62
|
-
- **Admins:** ask your agent "make a lab admin link for anna on /anna". With your token it gets a link that lets anna resolve and delete comments on `/anna` pages only. One browser can hold links for several labs. Nothing to set up per person (how: top of `api/lab-comments.mjs`).
|
|
17
|
+
It finds your running dev server (Astro, Next, Vite…) or serves plain HTML, and opens the page with comments on top. Click to comment, drag to mark an area. `M` hides the comments.
|
|
63
18
|
|
|
64
|
-
##
|
|
19
|
+
## Let your agent answer
|
|
65
20
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```text
|
|
69
|
-
Start labit (https://github.com/leonidstern/labit) on this project and listen to my comments.
|
|
70
|
-
|
|
71
|
-
1. Run `npx @leonidstern/labit@latest` here in the background. It finds this project's dev server, or serves plain HTML files.
|
|
72
|
-
If it says the dev server isn't running, start it the way this project does, then run it again. Never stop other servers.
|
|
73
|
-
2. Run `npx @leonidstern/labit wait` in the background, with --name set to this project's name. It ends with my next comment.
|
|
74
|
-
3. For each comment, change what it asks, then answer on the pin: `npx @leonidstern/labit reply <id> "Done: …"`, with the id
|
|
75
|
-
that wait printed. Add --resolve when it's fully done; if you need something from me, ask in the reply instead.
|
|
76
|
-
4. Run wait again right away. Stop when wait says the page was closed.
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Using it often? Install the plugin once, then just say **"start labit"** in any project. With the plugin, **"use lab"** also makes Claude show new pages in labit instead of an Artifact:
|
|
21
|
+
**Claude Code:** install the plugin once, then say **"start labit"** in any project.
|
|
80
22
|
|
|
81
23
|
```text
|
|
82
24
|
/plugin marketplace add leonidstern/labit
|
|
83
25
|
/plugin install labit@leonidstern
|
|
84
26
|
```
|
|
85
27
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- **Dev server (Astro, Next, Vite…):** start it as usual. labit finds the one running from this project, even with other projects' servers running, and puts comments on top. `--proxy 4321` picks a port yourself.
|
|
89
|
-
- **Plain HTML files:** served as they are. Pages somewhere else: `npx @leonidstern/labit@latest dist`.
|
|
90
|
-
|
|
91
|
-
- **Comment:** press `m` (or hold Option) and click. Drag to mark an area.
|
|
92
|
-
- **One lab per project:** `npx @leonidstern/labit list` shows the labs running on your computer. Starting one in a folder that a running lab already serves opens that lab instead (`--new` starts a separate one anyway).
|
|
93
|
-
- **This project's pages:** `npx @leonidstern/labit pages` writes `.lab/lab-pages.md`, the project's lab pages as links with open comment counts (`--all` for every lab on your computer). `npx @leonidstern/labit add <url>` adds a cloud lab page to the project's list. Claude sends it to you, so in the desktop app it sits under Outputs.
|
|
94
|
-
- **Which model listens:** the session you start decides it. Start it with `claude --model sonnet`, or `/model` in a running session.
|
|
95
|
-
- **MCP (optional):** `npx @leonidstern/labit@latest mcp` is an MCP server with three tools, `comments`, `reply` and `wait`, for the lab in the folder the agent runs in (`comments` also reads a cloud lab page by its address). In Claude Code, once for all your projects: `claude mcp add -s user labit -- npx @leonidstern/labit@latest mcp`. The `wait` command stays the quickest way to hear a pin as it's posted.
|
|
96
|
-
- **Options:** `--wifi` lets a phone at home join. `npx @leonidstern/labit preview` opens it in the Claude desktop app's preview pane. `--help` has the rest.
|
|
97
|
-
- **Files:** comments stay in `.lab/` in the project. Delete it to start over. Add `.lab/` to `.gitignore`.
|
|
98
|
-
|
|
99
|
-
## Other agents
|
|
100
|
-
|
|
101
|
-
labit works with any agent that can use a terminal or MCP. Comments are plain text, the local loop is a few shell commands, and the skill is in the shared Agent Skills format.
|
|
102
|
-
|
|
103
|
-
- **The plugin (skill + MCP server):**
|
|
104
|
-
- Codex: `codex plugin marketplace add leonidstern/labit`, then `codex plugin add labit@leonidstern`.
|
|
105
|
-
- Cursor: add the repo as a plugin (Dashboard → Plugins & MCPs → Import from Repo), or copy it to `~/.cursor/plugins/local/labit`.
|
|
106
|
-
- Copilot CLI: `copilot plugin marketplace add leonidstern/labit` (it reads the Claude plugin files).
|
|
107
|
-
- Others with Agent Plugins: `plugin.json` and `mcp.json` at the repo root.
|
|
108
|
-
- **Just the skill:** `npx skills add leonidstern/labit` puts it where your agent reads skills (`.agents/skills/` for most). Then "start labit" works as in Claude. To point every session at it, add to your `AGENTS.md`:
|
|
109
|
-
```md
|
|
110
|
-
Pin comments on pages: labit. Say "start labit" to listen; see .agents/skills/labit/SKILL.md.
|
|
111
|
-
```
|
|
112
|
-
- **Cloud lab:** give the agent the `/_lab/agent/<page path>` link. It's plain text with every open comment.
|
|
113
|
-
- **Local lab:** paste the prompt from [Local lab](#local-lab), or use the skill. labit tells the agent apart by itself: the page says "talking to Codex", and replies are signed "Codex".
|
|
114
|
-
- **Agents that aren't woken when a background command ends** (Codex, Antigravity): run `wait --timeout 50` in the foreground, in a loop. The MCP `wait` returns after 50 seconds by default for the same reason (Codex and Cursor stop tool calls at 60).
|
|
115
|
-
|
|
116
|
-
| Agent | Known by | MCP | Back to the session |
|
|
117
|
-
|---|---|---|---|
|
|
118
|
-
| Claude Code | `CLAUDECODE` | `claude mcp add labit -- npx @leonidstern/labit@latest mcp` | link, or `claude --resume` |
|
|
119
|
-
| Codex | `CODEX_THREAD_ID` | `codex mcp add labit -- npx @leonidstern/labit@latest mcp` | `codex resume <id>` (tap the label to copy) |
|
|
120
|
-
| Cursor | `CURSOR_AGENT` | its MCP settings | |
|
|
121
|
-
| Amp | `AMP_CURRENT_THREAD_ID` | its MCP settings | thread link |
|
|
122
|
-
| opencode | `OPENCODE_CLIENT` | its MCP settings | |
|
|
123
|
-
| Antigravity | `ANTIGRAVITY_AGENT` | its MCP settings | |
|
|
124
|
-
| Copilot CLI | set `LAB_AGENT=copilot` | its MCP settings | |
|
|
125
|
-
|
|
126
|
-
- **Choose:** `LAB_AGENT=<name>` overrides who is listening (any name), and `LAB_AGENT_NAME` signs replies.
|
|
127
|
-
- **Codex's sandbox:** if `wait` or `reply` can't reach the lab, labit says so. Use the MCP tools, or allow it: `-c sandbox_workspace_write.network_access=true`.
|
|
28
|
+
**Any other agent:** tell it to run these in your project.
|
|
128
29
|
|
|
129
30
|
```sh
|
|
130
|
-
npx @leonidstern/labit
|
|
131
|
-
npx @leonidstern/labit reply <id> "Done: …"
|
|
31
|
+
npx @leonidstern/labit wait # ends with your next comment
|
|
32
|
+
npx @leonidstern/labit reply <id> "Done: …" # answers on the pin
|
|
132
33
|
```
|
|
133
34
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
## Updating
|
|
137
|
-
|
|
138
|
-
- **The command:** start labit with `npx @leonidstern/labit@latest` and npx fetches the newest version (plain `npx @leonidstern/labit` may reuse an older copy it keeps). When a newer one is out, labit says so as it starts; it checks npm at most once a day. `LABIT_NO_UPDATE_CHECK=1` turns that off.
|
|
139
|
-
- **The Claude Code plugin:** `claude plugin marketplace update leonidstern`, then `claude plugin update labit@leonidstern`.
|
|
140
|
-
- **The MCP server:** added with `@latest` (as above), it starts the newest version each time.
|
|
141
|
-
- **Your cloud lab:** sync your fork of labit with this repo on GitHub ("Sync fork") and redeploy; every site on the lab gets the new widget from the lab domain.
|
|
142
|
-
|
|
143
|
-
## Both
|
|
144
|
-
|
|
145
|
-

|
|
35
|
+
Or as an MCP server: `npx @leonidstern/labit@latest mcp`.
|
|
146
36
|
|
|
147
|
-
|
|
148
|
-
- **Theme:** set `--lab-accent`, `--lab-bg`, `--lab-fg`, `--lab-radius` or `--lab-font` on `[data-lab-comments]`.
|
|
37
|
+
## Good to know
|
|
149
38
|
|
|
150
|
-
|
|
39
|
+
- `--wifi` lets your phone comment too. Each device opens a one-time link from `npx @leonidstern/labit invite`, so being on the same wifi isn't enough. The pages still travel in the clear over the wifi.
|
|
40
|
+
- You name yourself once. The name is kept for this computer in `~/.config/labit/me.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.
|
|
41
|
+
- Comments stay in `.lab/` in your project. Add it to `.gitignore`.
|
|
42
|
+
- `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.
|
|
43
|
+
- No dependencies, Node 22+. `--help` lists everything else.
|
|
151
44
|
|
|
152
|
-
|
|
45
|
+
Shared labs on a domain (comments from people you send a link to) come later.
|
|
153
46
|
|
|
154
47
|
MIT · made by [leonidstern](https://github.com/LeonidStern) · [OOZE](https://ooze.design)
|
package/api/lab-comments.mjs
CHANGED
|
@@ -160,6 +160,9 @@ 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.
|
|
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,
|
|
163
166
|
};
|
|
164
167
|
if (a.quote && typeof a.quote === 'object') {
|
|
165
168
|
const exact = clean(a.quote.exact, 300); // selected words can run long; a click quotes one word
|
|
@@ -287,6 +290,8 @@ function asText(path, comments, host) {
|
|
|
287
290
|
if (a.chosen) lines.push(`chosen option: ${a.chosen}`);
|
|
288
291
|
if (a.cssText) lines.push(`text added by CSS: ${a.cssText} (search the CSS for it)`);
|
|
289
292
|
if (a.section) lines.push(`section: "${a.section}"`);
|
|
293
|
+
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)');
|
|
290
295
|
if (a.zw) {
|
|
291
296
|
lines.push(`type: area comment, ${a.docW}×${a.docH} px on screen`);
|
|
292
297
|
lines.push(`area on element: ${pct(a.x)}–${pct(a.x + a.zw)} across, ${pct(a.y)}–${pct(a.y + a.zh)} down`);
|
|
@@ -359,7 +364,9 @@ export async function POST(request) {
|
|
|
359
364
|
if (!current) return json({ error: 'not found' }, 404);
|
|
360
365
|
const thread = JSON.parse(current);
|
|
361
366
|
if (thread.parent || !body.anchor || typeof body.anchor !== 'object') return json({ error: 'bad move' }, 400);
|
|
362
|
-
const
|
|
367
|
+
const anchor = cleanAnchor(body.anchor);
|
|
368
|
+
if (thread.anchor?.zoom && !anchor.zoom) anchor.zoom = thread.anchor.zoom; // a moved zoom stays a zoom, whatever the widget sent
|
|
369
|
+
const comment = { ...thread, anchor, movedAt: new Date().toISOString() };
|
|
363
370
|
await run('HSET', key, id, JSON.stringify(comment));
|
|
364
371
|
return json({ comment });
|
|
365
372
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// lib/args.ts
|
|
2
|
+
function listenPages(opts, forWait = false) {
|
|
3
|
+
const raw = opts.pages || (forWait ? opts.page : "");
|
|
4
|
+
if (!raw) return null;
|
|
5
|
+
return String(raw).split(",").map((p) => "/" + p.trim().replace(/^\/+/, "").replace(/\.html?$/i, "")).filter((p) => p !== "/");
|
|
6
|
+
}
|
|
7
|
+
var SWITCHES = ["--wifi", "--no-open", "--resolve", "--wait", "--new", "--all", "--fast", "--no-fast"];
|
|
8
|
+
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.";
|
|
9
|
+
var VALUED = ["--port", "--name", "--page", "--pages", "--timeout", "--dir", "--proxy", "--model"];
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const opts = {};
|
|
12
|
+
const pos = [];
|
|
13
|
+
const unknownFlags = [];
|
|
14
|
+
for (let i = 0; i < argv.length; i++) {
|
|
15
|
+
const a = argv[i];
|
|
16
|
+
if (a === "--") {
|
|
17
|
+
pos.push(...argv.slice(i + 1));
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
if (a === "--help" || a === "-h") opts.help = true;
|
|
21
|
+
else if (a === "--version" || a === "-v") opts.version = true;
|
|
22
|
+
else if (SWITCHES.includes(a)) opts[a.slice(2)] = true;
|
|
23
|
+
else if (a.startsWith("--") && !VALUED.includes(a)) unknownFlags.push(a);
|
|
24
|
+
else if (VALUED.includes(a)) {
|
|
25
|
+
const v = argv[i + 1];
|
|
26
|
+
if (v === void 0 || v.startsWith("-")) opts[a.slice(2)] = true;
|
|
27
|
+
else opts[a.slice(2)] = argv[++i];
|
|
28
|
+
} else pos.push(a);
|
|
29
|
+
}
|
|
30
|
+
return { opts, pos, unknownFlags };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// lib/agents.ts
|
|
34
|
+
var AGENTS = {
|
|
35
|
+
amp: { name: "Amp", env: ["AMP_CURRENT_THREAD_ID"] },
|
|
36
|
+
codex: { name: "Codex", env: ["CODEX_THREAD_ID", "CODEX_SANDBOX", "CODEX_SANDBOX_NETWORK_DISABLED"] },
|
|
37
|
+
cursor: { name: "Cursor", env: ["CURSOR_AGENT"] },
|
|
38
|
+
antigravity: { name: "Antigravity", env: ["ANTIGRAVITY_AGENT"] },
|
|
39
|
+
gemini: { name: "Gemini", env: ["GEMINI_CLI"] },
|
|
40
|
+
opencode: { name: "opencode", env: ["OPENCODE_CLIENT", "OPENCODE"] },
|
|
41
|
+
copilot: { name: "Copilot", env: [] },
|
|
42
|
+
claude: { name: "Claude", env: ["CLAUDECODE", "CLAUDE_CODE_SESSION_ID"] }
|
|
43
|
+
};
|
|
44
|
+
var agentKind = (word = "") => {
|
|
45
|
+
const w = String(word).toLowerCase();
|
|
46
|
+
if (/\bagy\b/.test(w)) return "antigravity";
|
|
47
|
+
return Object.keys(AGENTS).find((k) => w.includes(k)) || "";
|
|
48
|
+
};
|
|
49
|
+
function agentNow(env = process.env) {
|
|
50
|
+
const own = (env.LAB_AGENT || "").trim().slice(0, 30);
|
|
51
|
+
if (own) return { kind: agentKind(own), name: AGENTS[agentKind(own)]?.name || own };
|
|
52
|
+
const kind = Object.keys(AGENTS).find((k) => AGENTS[k].env.some((v) => env[v])) || agentKind(env.AGENT) || agentKind(env.AI_AGENT);
|
|
53
|
+
return kind ? { kind, name: AGENTS[kind].name } : { kind: "", name: "Claude" };
|
|
54
|
+
}
|
|
55
|
+
var modelName = (m = "") => {
|
|
56
|
+
const w = String(m).trim().replace(/\[.*\]$/, "");
|
|
57
|
+
const id = /^(?:claude-)?(opus|sonnet|haiku|fable)-(\d+)(?:-(\d{1,2}))?(?:-\d{8})?$/i.exec(w);
|
|
58
|
+
if (id) return `${id[1][0].toUpperCase()}${id[1].slice(1).toLowerCase()} ${id[2]}${id[3] ? `.${id[3]}` : ""}`;
|
|
59
|
+
return /^(opus|sonnet|haiku|fable)$/i.test(w) ? w[0].toUpperCase() + w.slice(1).toLowerCase() : w.replace(/\s+/g, " ").slice(0, 30);
|
|
60
|
+
};
|
|
61
|
+
function mySession(asked, model) {
|
|
62
|
+
const agent = agentNow();
|
|
63
|
+
const env = process.env;
|
|
64
|
+
const remote = agent.kind === "claude" || !agent.kind ? env.CLAUDE_CODE_REMOTE_SESSION_ID || "" : "";
|
|
65
|
+
const id = { claude: env.CLAUDE_CODE_SESSION_ID, codex: env.CODEX_THREAD_ID, amp: env.AMP_CURRENT_THREAD_ID }[agent.kind || "claude"] || "";
|
|
66
|
+
const name = asked || env.LAB_SESSION_NAME || (id ? `session ${id.slice(0, 8)}` : agent.name);
|
|
67
|
+
const safe = /^[\w-]+$/.test(id);
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
name: name.replace(/\s+/g, " ").slice(0, 40),
|
|
71
|
+
agent: agent.name,
|
|
72
|
+
model: modelName(model || env.LAB_MODEL || env.ANTHROPIC_MODEL),
|
|
73
|
+
kind: agent.kind,
|
|
74
|
+
url: remote ? `https://claude.ai/code/${remote.replace(/^cse_/, "session_")}` : agent.kind === "amp" && safe ? `https://ampcode.com/threads/${id}` : "",
|
|
75
|
+
resume: !safe || remote ? "" : { claude: `claude --resume ${id}`, codex: `codex resume ${id}`, amp: `amp threads continue ${id}` }[agent.kind || "claude"] || ""
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// lib/labs.ts
|
|
80
|
+
import fs from "node:fs";
|
|
81
|
+
import os from "node:os";
|
|
82
|
+
import path from "node:path";
|
|
83
|
+
var REGISTRY = path.join(process.env.LABIT_HOME || process.env.LABFB_HOME || path.join(os.homedir(), ".labit"), "servers");
|
|
84
|
+
var runningLabs = () => (fs.existsSync(REGISTRY) ? fs.readdirSync(REGISTRY) : []).filter((n) => n.endsWith(".json")).flatMap((n) => {
|
|
85
|
+
const file = path.join(REGISTRY, n);
|
|
86
|
+
try {
|
|
87
|
+
const lab = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
88
|
+
process.kill(lab.pid, 0);
|
|
89
|
+
return [lab];
|
|
90
|
+
} catch {
|
|
91
|
+
fs.rmSync(file, { force: true });
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}).sort((a, b) => a.root.localeCompare(b.root));
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
listenPages,
|
|
98
|
+
WRITE_SHORT,
|
|
99
|
+
parseArgs,
|
|
100
|
+
AGENTS,
|
|
101
|
+
agentKind,
|
|
102
|
+
agentNow,
|
|
103
|
+
mySession,
|
|
104
|
+
REGISTRY,
|
|
105
|
+
runningLabs
|
|
106
|
+
};
|