tencil 0.6.0 → 0.7.0

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/dist/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as TencilCloudOptions } from "./cloud-CIAGUsk2.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-jOobzTY9.mjs";
2
2
  //#region src/integrations/react.d.ts
3
3
  /**
4
4
  * Loads the Tencil overlay in development from the daemon on the machine
@@ -28,6 +28,39 @@ const Rect = z.object({
28
28
  width: z.number(),
29
29
  height: z.number()
30
30
  });
31
+ /** CSS pixels per side, in CSS order: top, right, bottom, left. */
32
+ const Sides = z.tuple([
33
+ z.number(),
34
+ z.number(),
35
+ z.number(),
36
+ z.number()
37
+ ]);
38
+ /** The element's computed box model. */
39
+ const BoxModel = z.object({
40
+ margin: Sides,
41
+ padding: Sides,
42
+ border: Sides,
43
+ /** Only on flex and grid containers with a gap. */
44
+ gap: z.object({
45
+ row: z.number(),
46
+ column: z.number()
47
+ }).optional()
48
+ });
49
+ /**
50
+ * Distances measured from the element to another one (Alt in the overlay):
51
+ * the space on each side of the element, up to the other element's nearest edge.
52
+ */
53
+ const Spacing = z.object({
54
+ /** Label of the other element (component · tag). */
55
+ to: z.string(),
56
+ selector: z.string().optional(),
57
+ /** The other element is the picked one's parent. */
58
+ parent: z.boolean().optional(),
59
+ top: z.number().optional(),
60
+ right: z.number().optional(),
61
+ bottom: z.number().optional(),
62
+ left: z.number().optional()
63
+ });
31
64
  /**
32
65
  * Everything the overlay knows about the picked element. Captured once when
33
66
  * the pin is placed and forwarded to the agent as context.
@@ -47,7 +80,9 @@ const ElementContext = z.object({
47
80
  dpr: z.number()
48
81
  }),
49
82
  /** Selected text inside the element at pin time, if any. */
50
- selection: z.string().optional()
83
+ selection: z.string().optional(),
84
+ box: BoxModel.optional(),
85
+ spacing: Spacing.optional()
51
86
  });
52
87
  /** Where a pin sits: the element plus the click offset inside it (0..1). */
53
88
  const Anchor = z.object({
@@ -152,7 +187,8 @@ const ClientMessage = z.discriminatedUnion("type", [
152
187
  z.object({
153
188
  type: z.literal("settings.update"),
154
189
  provider: z.string().min(1).optional(),
155
- batch: z.boolean().optional()
190
+ batch: z.boolean().optional(),
191
+ ruler: z.boolean().optional()
156
192
  }),
157
193
  z.object({
158
194
  type: z.literal("model.select"),
@@ -186,7 +222,9 @@ z.object({
186
222
  /** Model picked for the provider's new threads; unset means the provider's default. */
187
223
  model: z.string().optional(),
188
224
  /** New comments are queued and sent together. */
189
- batch: z.boolean()
225
+ batch: z.boolean(),
226
+ /** The toolbar offers the ruler: spacing while picking, distances with Alt. */
227
+ ruler: z.boolean()
190
228
  });
191
229
  //#endregion
192
230
  //#region ../protocol/src/thread.ts
@@ -388,8 +426,46 @@ function contextLines(pageUrl, context) {
388
426
  if (context.selection) lines.push(`- Selected text: "${page(truncate(oneLine(context.selection), 300))}"`);
389
427
  const { rect, viewport } = context;
390
428
  lines.push(`- Layout: ${Math.round(rect.width)}×${Math.round(rect.height)} at (${Math.round(rect.x)}, ${Math.round(rect.y)}) in a ${viewport.width}×${viewport.height} viewport @${viewport.dpr}x`);
429
+ const box = context.box && boxLine(context.box);
430
+ if (box) lines.push(`- Box: ${box}`);
431
+ if (context.spacing) lines.push(spacingLine(context.spacing));
391
432
  return lines;
392
433
  }
434
+ /** Computed spacing in CSS shorthand, px: `padding 12 16, margin 0 0 24, gap 8`. */
435
+ function boxLine(box) {
436
+ const parts = [];
437
+ for (const kind of [
438
+ "padding",
439
+ "margin",
440
+ "border"
441
+ ]) if (box[kind].some((value) => value !== 0)) parts.push(`${kind} ${shorthand(box[kind])}`);
442
+ if (box.gap) {
443
+ const { row, column } = box.gap;
444
+ parts.push(`gap ${row === column ? row : `${row} ${column}`}`);
445
+ }
446
+ return parts.length > 0 ? `${parts.join(", ")} (px)` : void 0;
447
+ }
448
+ function shorthand([top, right, bottom, left]) {
449
+ if (left !== right) return `${top} ${right} ${bottom} ${left}`;
450
+ if (top !== bottom) return `${top} ${right} ${bottom}`;
451
+ return top === right ? `${top}` : `${top} ${right}`;
452
+ }
453
+ const SIDE_WORDS = {
454
+ top: "above",
455
+ right: "right",
456
+ bottom: "below",
457
+ left: "left"
458
+ };
459
+ /** What the user measured with Alt: the space on each side of the element. */
460
+ function spacingLine(spacing) {
461
+ const sides = [
462
+ "top",
463
+ "right",
464
+ "bottom",
465
+ "left"
466
+ ].filter((side) => spacing[side] !== void 0).map((side) => `${spacing[side]}px ${SIDE_WORDS[side]}`);
467
+ return `- Measured spacing to ${`${spacing.parent ? "its parent " : ""}\`${page(truncate(spacing.to, 200))}\``}${spacing.selector ? ` (\`${page(truncate(spacing.selector, 500))}\`)` : ""}: ${sides.length > 0 ? sides.join(", ") : "none"}`;
468
+ }
393
469
  function stripContext(text) {
394
470
  const index = text.indexOf(CONTEXT_OPEN);
395
471
  return index === -1 ? text : text.slice(0, index).trimEnd();
@@ -527,6 +603,7 @@ var Bridge = class {
527
603
  const { providers } = this.#options;
528
604
  if (message.provider) await providers.setDefault(message.provider);
529
605
  if (message.batch !== void 0) await providers.setBatch(message.batch);
606
+ if (message.ruler !== void 0) await providers.setRuler(message.ruler);
530
607
  return;
531
608
  }
532
609
  case "provider.models": {
@@ -893,7 +970,8 @@ var Bridge = class {
893
970
  provider: providers.defaultId,
894
971
  providers: providers.choices,
895
972
  ...model ? { model } : {},
896
- batch: providers.batch
973
+ batch: providers.batch,
974
+ ruler: providers.ruler
897
975
  };
898
976
  }
899
977
  #require(threadId) {
@@ -995,6 +1073,8 @@ var ProjectProviders = class ProjectProviders {
995
1073
  #models = {};
996
1074
  /** On unless the project turns it off. */
997
1075
  #batch = true;
1076
+ /** On unless the project turns it off. */
1077
+ #ruler = true;
998
1078
  constructor(options) {
999
1079
  this.#options = options;
1000
1080
  this.choices = options.choices;
@@ -1025,6 +1105,7 @@ var ProjectProviders = class ProjectProviders {
1025
1105
  this.#chosen = saved.provider;
1026
1106
  this.#models = saved.models ?? {};
1027
1107
  this.#batch = saved.batch ?? true;
1108
+ this.#ruler = saved.ruler ?? true;
1028
1109
  }
1029
1110
  }
1030
1111
  get defaultId() {
@@ -1078,7 +1159,16 @@ var ProjectProviders = class ProjectProviders {
1078
1159
  await this.#save();
1079
1160
  for (const listener of this.#settingsListeners) listener();
1080
1161
  }
1081
- /** Fires when a picked model or batching changes. */
1162
+ get ruler() {
1163
+ return this.#ruler;
1164
+ }
1165
+ async setRuler(on) {
1166
+ if (on === this.#ruler) return;
1167
+ this.#ruler = on;
1168
+ await this.#save();
1169
+ for (const listener of this.#settingsListeners) listener();
1170
+ }
1171
+ /** Fires when a picked model, batching or the ruler changes. */
1082
1172
  onSettingsChange(listener) {
1083
1173
  this.#settingsListeners.add(listener);
1084
1174
  return () => this.#settingsListeners.delete(listener);
@@ -1095,7 +1185,8 @@ var ProjectProviders = class ProjectProviders {
1095
1185
  await this.#options.settings?.save({
1096
1186
  provider: this.#chosen,
1097
1187
  models: this.#models,
1098
- batch: this.#batch
1188
+ batch: this.#batch,
1189
+ ruler: this.#ruler
1099
1190
  });
1100
1191
  }
1101
1192
  };
@@ -2399,6 +2490,15 @@ async function persist(socket, threadId, messageId, attachments) {
2399
2490
  }))
2400
2491
  })).attachments;
2401
2492
  }
2493
+ /** Requests the user answers; T3 Code resolves `auth_refresh` and `dynamic_tool_call` itself. */
2494
+ const USER_REQUEST_KINDS = /* @__PURE__ */ new Set([
2495
+ "command",
2496
+ "file-read",
2497
+ "file-change",
2498
+ "mcp-elicitation",
2499
+ "permission",
2500
+ "user_input"
2501
+ ]);
2402
2502
  const ACTIVE_RUN_STATUSES = /* @__PURE__ */ new Set([
2403
2503
  "preparing",
2404
2504
  "starting",
@@ -2407,6 +2507,7 @@ const ACTIVE_RUN_STATUSES = /* @__PURE__ */ new Set([
2407
2507
  ]);
2408
2508
  var V2ThreadTracker = class {
2409
2509
  #runs = /* @__PURE__ */ new Map();
2510
+ #requests = /* @__PURE__ */ new Map();
2410
2511
  #messages = /* @__PURE__ */ new Map();
2411
2512
  #lastStatusKey = "";
2412
2513
  apply(raw) {
@@ -2415,6 +2516,7 @@ var V2ThreadTracker = class {
2415
2516
  let gone = false;
2416
2517
  if (item.kind === "snapshot") {
2417
2518
  for (const run of item.projection.runs ?? []) this.#runs.set(run.id, run);
2519
+ for (const request of item.projection.runtimeRequests ?? []) this.#requests.set(request.id, request);
2418
2520
  for (const message of item.projection.messages ?? []) this.#upsertMessage(message, changed);
2419
2521
  for (const turnItem of item.projection.turnItems ?? []) this.#upsertTurnItem(turnItem, changed);
2420
2522
  } else if (item.kind === "event") {
@@ -2422,6 +2524,9 @@ var V2ThreadTracker = class {
2422
2524
  if (type === "run.created" || type === "run.updated") {
2423
2525
  const run = payload;
2424
2526
  this.#runs.set(run.id, run);
2527
+ } else if (type === "runtime-request.updated") {
2528
+ const request = payload;
2529
+ this.#requests.set(request.id, request);
2425
2530
  } else if (type === "message.updated") this.#upsertMessage(payload, changed);
2426
2531
  else if (type === "turn-item.updated") this.#upsertTurnItem(payload, changed);
2427
2532
  else if (type === "thread.deleted") gone = true;
@@ -2443,11 +2548,8 @@ var V2ThreadTracker = class {
2443
2548
  case "preparing":
2444
2549
  case "queued":
2445
2550
  case "starting":
2446
- case "running": return { status: "working" };
2447
- case "waiting": return {
2448
- status: "waiting",
2449
- detail: "Waiting for approval in T3 Code"
2450
- };
2551
+ case "running":
2552
+ case "waiting": return this.#pendingRequest(latest) ?? { status: "working" };
2451
2553
  case "failed": return {
2452
2554
  status: "error",
2453
2555
  detail: "Run failed"
@@ -2468,6 +2570,20 @@ var V2ThreadTracker = class {
2468
2570
  }
2469
2571
  return active?.id;
2470
2572
  }
2573
+ /**
2574
+ * Approvals and questions don't change the run's status; they're runtime requests.
2575
+ * A stopped run can leave one pending, so only count those made during `run`.
2576
+ */
2577
+ #pendingRequest(run) {
2578
+ for (const request of this.#requests.values()) {
2579
+ if (request.status !== "pending" || !USER_REQUEST_KINDS.has(request.kind)) continue;
2580
+ if (run.requestedAt && request.createdAt && request.createdAt < run.requestedAt) continue;
2581
+ return {
2582
+ status: "waiting",
2583
+ detail: request.kind === "user_input" ? "Waiting for your answer in T3 Code" : "Waiting for approval in T3 Code"
2584
+ };
2585
+ }
2586
+ }
2471
2587
  #latestRun() {
2472
2588
  let latest;
2473
2589
  for (const run of this.#runs.values()) if (!latest || run.ordinal > latest.ordinal) latest = run;
@@ -3141,7 +3257,7 @@ function errorMessage(error) {
3141
3257
  }
3142
3258
  //#endregion
3143
3259
  //#region src/version.ts
3144
- const VERSION = "0.6.0";
3260
+ const VERSION = "0.7.0";
3145
3261
  //#endregion
3146
3262
  //#region src/daemon/thread-store.ts
3147
3263
  const StoreFile = z.object({
@@ -3313,13 +3429,15 @@ const SettingsFile = z.object({
3313
3429
  /** Model picked per provider for new threads; unset means the provider's default. */
3314
3430
  models: z.record(z.string(), z.string()).optional(),
3315
3431
  /** Queue new comments and send them together. */
3316
- batch: z.boolean().optional()
3432
+ batch: z.boolean().optional(),
3433
+ /** Offer the ruler in the overlay's toolbar. */
3434
+ ruler: z.boolean().optional()
3317
3435
  });
3318
3436
  /** A project's settings live next to its pins: `<slug>-<hash>.settings.json`. */
3319
3437
  function projectSettingsPath(projectRoot, dataDir = defaultDataDir()) {
3320
3438
  return projectStorePath(projectRoot, dataDir).replace(/\.json$/, ".settings.json");
3321
3439
  }
3322
- /** A project's overlay settings (provider, models, batching) in a JSON file. */
3440
+ /** A project's overlay settings (provider, models, batching, ruler) in a JSON file. */
3323
3441
  var FileProjectSettings = class {
3324
3442
  path;
3325
3443
  constructor(path) {
@@ -3337,7 +3455,8 @@ var FileProjectSettings = class {
3337
3455
  version: 1,
3338
3456
  provider: settings.provider,
3339
3457
  models: settings.models,
3340
- batch: settings.batch
3458
+ batch: settings.batch,
3459
+ ruler: settings.ruler
3341
3460
  }, null, 2)}\n`);
3342
3461
  await rename(temp, this.path);
3343
3462
  }
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as TencilCloudOptions } from "./cloud-CIAGUsk2.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-jOobzTY9.mjs";
2
2
  //#region src/integrations/vite.d.ts
3
3
  /** Structural subset of Vite's Plugin type, so `vite` stays an optional peer. */
4
4
  interface VitePlugin {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencil",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Point at any element of your running app and tell your coding agent what to fix.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pixel Perfect Agency",
@@ -93,13 +93,13 @@
93
93
  "@types/ws": "^8.18.2",
94
94
  "react": "^19.3.0",
95
95
  "tsdown": "^0.23.0",
96
+ "@tencildev/bridge": "0.3.0",
96
97
  "@tencildev/overlay": "0.0.0",
97
- "@tencildev/bridge": "0.2.0",
98
- "@tencildev/protocol": "0.2.0",
99
98
  "@tencildev/provider-claude-code": "0.0.0",
99
+ "@tencildev/protocol": "0.3.0",
100
100
  "@tencildev/provider-t3code": "0.0.0",
101
- "@tencildev/testing": "0.1.1",
102
- "@tencildev/tsconfig": "0.0.0"
101
+ "@tencildev/tsconfig": "0.0.0",
102
+ "@tencildev/testing": "0.1.2"
103
103
  },
104
104
  "scripts": {
105
105
  "build": "tsdown && node scripts/copy-overlay.mjs",