@insitue/claude-plugin 0.3.1 → 0.3.3

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.
@@ -21,7 +21,11 @@ not need to ask the user to run any extra commands.
21
21
  to click Send in the InSitue panel"). Otherwise just say
22
22
  "Connected. Pick something in the browser when you're ready."
23
23
  2. Enter the loop: call `mcp__insitue__next_pick`. It long-polls
24
- (~5 min default). When it returns with `status: "ok"`:
24
+ (~25s default short on purpose so the chat stays responsive
25
+ to other questions the user might type while you wait). When
26
+ it returns with `status: "timeout"`, **call it again immediately
27
+ without announcing it** — the timeout is just a heartbeat, not
28
+ news. When it returns with `status: "ok"`:
25
29
  - **Always echo the prompt back first.** Before any action,
26
30
  diff, or follow-up question, lead with:
27
31
 
@@ -54,7 +58,13 @@ not need to ask the user to run any extra commands.
54
58
  - Loop back to `next_pick`.
55
59
  3. If `next_pick` returns `status: "timeout"`, the user simply
56
60
  hasn't picked anything yet. Stay quiet and call `next_pick`
57
- again.
61
+ again. **Do not narrate the loop** — no "still waiting…", no
62
+ "polling again…". The user sees `[insitue] 📥 pick received`
63
+ on stderr the moment their pick lands; that's the
64
+ confirmation, not your narration. If the user types another
65
+ question while you're between calls, answer it first (since
66
+ the chat is responsive), then resume the loop with
67
+ `next_pick`.
58
68
  4. If a pick comes back with `target` starting with
59
69
  `[insitue]` (e.g. "companion disconnected"), tell the user
60
70
  what happened in one sentence and call `next_pick` again —
@@ -10,7 +10,7 @@ import { dirname, join, resolve } from "path";
10
10
  import WebSocket from "ws";
11
11
  import { z } from "zod";
12
12
  var MAX_BUFFERED_PICKS = 32;
13
- var NEXT_PICK_DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
13
+ var NEXT_PICK_DEFAULT_TIMEOUT_MS = 25 * 1e3;
14
14
  var NEXT_PICK_MAX_TIMEOUT_MS = 30 * 60 * 1e3;
15
15
  function findSession(start = process.cwd()) {
16
16
  let dir = resolve(start);
@@ -54,7 +54,8 @@ function summariseBundle(raw) {
54
54
  selector: t?.selector ?? null,
55
55
  userNote: raw.bundle.userNote ?? null,
56
56
  url: raw.bundle.runtime?.url ?? null,
57
- componentStack
57
+ componentStack,
58
+ ...t?.cmsSource ? { cmsSource: t.cmsSource } : {}
58
59
  };
59
60
  }
60
61
  var PickBuffer = class {
@@ -239,8 +240,15 @@ function connectToCompanion(session2) {
239
240
  }
240
241
  if (tag === "broadcast-capture") {
241
242
  try {
242
- buffer.push(
243
- summariseBundle(m)
243
+ const summary = summariseBundle(
244
+ m
245
+ );
246
+ buffer.push(summary);
247
+ const note = summary.userNote ? summary.userNote.length > 60 ? `${summary.userNote.slice(0, 57)}\u2026` : summary.userNote : "(no description)";
248
+ const where = summary.source ? `${summary.source.file}:${summary.source.line}` : summary.target;
249
+ process.stderr.write(
250
+ `[insitue] \u{1F4E5} pick received \u2014 "${note}" @ ${where}
251
+ `
244
252
  );
245
253
  } catch (err) {
246
254
  process.stderr.write(
@@ -265,7 +273,11 @@ if (!session) {
265
273
  process.stderr.write(
266
274
  "[insitue-mcp] no companion available \u2014 `next_pick` will time out.\n"
267
275
  );
268
- } else {
276
+ }
277
+ var attached = false;
278
+ function ensureSubscriberAttached() {
279
+ if (attached || !session) return;
280
+ attached = true;
269
281
  connectToCompanion(session);
270
282
  }
271
283
  var server = new McpServer({
@@ -283,6 +295,7 @@ server.registerTool(
283
295
  }
284
296
  },
285
297
  async ({ timeout_ms }) => {
298
+ ensureSubscriberAttached();
286
299
  const ms = timeout_ms ?? NEXT_PICK_DEFAULT_TIMEOUT_MS;
287
300
  const pick = await buffer.next(ms);
288
301
  if (!pick) {
@@ -311,6 +324,7 @@ server.registerTool(
311
324
  }
312
325
  },
313
326
  async ({ limit }) => {
327
+ ensureSubscriberAttached();
314
328
  const picks = buffer.recent(limit ?? 10);
315
329
  return {
316
330
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insitue/claude-plugin",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Drive a Claude Code session from the InSitue browser overlay — pick an element in your app, claude reads the file and proposes the edit.",
5
5
  "license": "MIT",
6
6
  "type": "module",