tencil 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -12,20 +12,25 @@ Think Vercel Comments, except the reviewer on the other side is an agent.
12
12
 
13
13
  ```
14
14
  your dev site (any origin on localhost) your machine
15
- ┌────────────────────────────────────┐ ws ┌─────────────────────┐ ws/rpc ┌───────────┐
16
- │ overlay (Preact, shadow DOM) │ ──────▶ │ tencil daemon │ ─────────▶ │ T3 Code │
17
- │ • picker, pins, threads, inbox │ ◀────── │ • holds credentials│ ◀───────── │ (threads) │
18
- │ • React source via owner stacks │ │ • provider adapters│ └───────────┘
19
- └────────────────────────────────────┘ │ • pin store │
20
- └─────────────────────┘
15
+ ┌────────────────────────────────────┐ ws ┌─────────────────────┐ ws/rpc ┌─────────────┐
16
+ │ overlay (Preact, shadow DOM) │ ──────▶ │ tencil daemon │ ─────────▶ │ T3 Code │
17
+ │ • picker, pins, threads, inbox │ ◀────── │ • holds credentials│ ◀───────── │ (threads) │
18
+ │ • React source via owner stacks │ │ • provider adapters│ └─────────────┘
19
+ └────────────────────────────────────┘ │ • pin store │ Agent SDK ┌─────────────┐
20
+ │ │ ──────────▶ │ Claude Code │
21
+ └─────────────────────┘ │ (sessions) │
22
+ └─────────────┘
21
23
  ```
22
24
 
23
- T3 Code is the orchestrator: every pin is a real T3 Code thread in the project
24
- that matches your dev site's folder, so you can continue any conversation there.
25
+ Tencil works with two agents. With **T3 Code**, every pin is a real T3 Code thread
26
+ in the project that matches your dev site's folder, so you can continue any
27
+ conversation there. With **Claude Code**, the daemon runs Claude Code itself and
28
+ every pin is a Claude Code session you can resume in a terminal.
25
29
 
26
30
  ## Quick start
27
31
 
28
- You need the [T3 Code](https://github.com/pingdotgg/t3code) desktop app running.
32
+ You need [T3 Code](https://github.com/pingdotgg/t3code) (the desktop app, running) or
33
+ [Claude Code](https://docs.claude.com/en/docs/claude-code) (installed and logged in).
29
34
 
30
35
  ```sh
31
36
  cd your-app
@@ -33,7 +38,7 @@ npx tencil
33
38
  ```
34
39
 
35
40
  The first time, this sets up your machine: it asks whether Tencil should start
36
- when you log in (yes by default) and pairs with T3 Code. Then it adds Tencil to
41
+ when you log in (yes by default), picks your agent and, for T3 Code, pairs with it. Then it adds Tencil to
37
42
  the project in the current folder. In other projects it only does the second part.
38
43
  Start your dev server as usual and press <kbd>C</kbd> on the page.
39
44
 
@@ -51,9 +56,9 @@ When a page connects, the daemon works out which project it belongs to:
51
56
 
52
57
  1. **the dev server's folder**, found from the port the page is served on;
53
58
  2. if that fails (Docker, remote dev), the overlay asks **"Which project is this
54
- page?"** with your T3 Code projects and remembers the answer.
59
+ page?"** and remembers the answer.
55
60
 
56
- Each project gets its own T3 Code connection and pins, all served by the one daemon.
61
+ Each project gets its own agent connection and pins, all served by the one daemon.
57
62
 
58
63
  ### What `init` adds
59
64
 
@@ -119,10 +124,11 @@ is running when the daemon stops is lost; the pin turns red and you can follow u
119
124
  | Cancel | <kbd>Esc</kbd> |
120
125
  | Follow up | Open a pin and reply; the same agent thread continues |
121
126
  | Continue an existing thread | In the composer, switch **→ New thread** to any thread in the project; the element becomes its next message |
122
- | Open any project thread | Inbox → **T3 Code** tab; the thread docks on the right so you can read, reply and stop while using the page |
127
+ | Open any project thread | Inbox → the agent's tab (**T3 Code** or **Claude Code**); the thread docks on the right so you can read, reply and stop while using the page |
123
128
  | Stop the agent | **Stop** while a pin is working |
124
129
  | All pins | Inbox button, filter by page or show resolved |
125
130
  | Continue in T3 Code | External-link icon on a pin |
131
+ | Continue in Claude Code | `claude --resume <id>` in the project's folder |
126
132
 
127
133
  Pins show their state: spinning while the agent works, blue when done, amber when
128
134
  the agent waits for approval, red on errors, grey once resolved.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as withoutNpmEnv, y as loadAgentSdk } from "./server-PYBcw-eR.mjs";
2
+ import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as withoutNpmEnv, y as loadAgentSdk } from "./server-Bxj8yTb3.mjs";
3
3
  import { execFileSync, spawn, spawnSync } from "node:child_process";
4
4
  import { cpSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { readFile, readdir, writeFile } from "node:fs/promises";
@@ -9,6 +9,24 @@ import { fileURLToPath } from "node:url";
9
9
  import { homedir } from "node:os";
10
10
  import pc from "picocolors";
11
11
  import { createInterface } from "node:readline/promises";
12
+ //#region src/cli/format.ts
13
+ function time() {
14
+ return (/* @__PURE__ */ new Date()).toLocaleTimeString([], {
15
+ hour: "2-digit",
16
+ minute: "2-digit",
17
+ second: "2-digit"
18
+ });
19
+ }
20
+ /** When an older Tencil (a stale npx cache) finds a newer daemon running, it leaves it alone. */
21
+ function newerDaemonLine(newer, port) {
22
+ return ` ${pc.yellow("!")} Tencil ${newer} is already running on port ${port}. This is ${VERSION}, which is older, so it's left alone: use ${pc.cyan("npx tencil@latest")}.`;
23
+ }
24
+ /** Print the update notice, if the registry answered in time. */
25
+ async function printUpdateNotice(notice, log) {
26
+ const text = await notice;
27
+ if (text) log(` ${pc.cyan("↑")} ${text}\n`);
28
+ }
29
+ //#endregion
12
30
  //#region src/service/daemon-command.ts
13
31
  function daemonArgs(command) {
14
32
  return [
@@ -20,6 +38,42 @@ function daemonArgs(command) {
20
38
  ];
21
39
  }
22
40
  //#endregion
41
+ //#region src/service/versions.ts
42
+ /** Compare dotted versions by number (pre-release tags ignored): below 0, 0 or above 0. */
43
+ function compareVersions(a, b) {
44
+ const parts = (version) => version.split("-")[0]?.split(".").map(Number) ?? [];
45
+ const [left, right] = [parts(a), parts(b)];
46
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
47
+ const difference = (left[i] ?? 0) - (right[i] ?? 0);
48
+ if (difference) return difference;
49
+ }
50
+ return 0;
51
+ }
52
+ /**
53
+ * npx reuses what it cached for `npx tencil`, so an older Tencil can run after
54
+ * a newer one was set up. It must never replace that newer daemon.
55
+ */
56
+ function isNewerThanThis(version) {
57
+ return version !== void 0 && compareVersions(version, VERSION) > 0;
58
+ }
59
+ var NewerDaemonError = class extends Error {
60
+ constructor(running) {
61
+ super(`Tencil ${running} is already running and this is ${VERSION}, which is older. Run \`npx tencil@latest\` instead.`);
62
+ this.name = "NewerDaemonError";
63
+ }
64
+ };
65
+ /** The newest published Tencil, or undefined when the registry doesn't answer quickly. */
66
+ async function latestVersion() {
67
+ const response = await fetch("https://registry.npmjs.org/tencil/latest", { signal: AbortSignal.timeout(1500) }).catch(() => void 0);
68
+ if (!response?.ok) return void 0;
69
+ return (await response.json().catch(() => void 0))?.version;
70
+ }
71
+ /** A one-line nudge when a newer Tencil is published. */
72
+ async function updateNotice() {
73
+ const latest = await latestVersion();
74
+ return latest && isNewerThanThis(latest) ? `Tencil ${latest} is out (this is ${VERSION}): npx tencil@latest` : void 0;
75
+ }
76
+ //#endregion
23
77
  //#region src/service/background.ts
24
78
  /**
25
79
  * Start the daemon in the background unless it already runs. A daemon from an
@@ -29,6 +83,11 @@ function daemonArgs(command) {
29
83
  */
30
84
  async function startInBackground(command, dataDir) {
31
85
  const running = await probeDaemon(command.port);
86
+ if (running && isNewerThanThis(running.version)) return {
87
+ status: "running",
88
+ pid: running.pid,
89
+ newer: running.version
90
+ };
32
91
  const flags = command.args?.length ? command.args : running?.flags ?? [];
33
92
  if (running && running.version === VERSION && sameFlags(running.flags, flags)) return {
34
93
  status: "running",
@@ -370,6 +429,7 @@ function runtimeInstallArgs(dataDir, spec, port = DEFAULT_PORT) {
370
429
  */
371
430
  async function enableAutostart(command, dataDir, from) {
372
431
  const running = await probeDaemon(command.port);
432
+ if (running && isNewerThanThis(running.version)) throw new NewerDaemonError(running.version);
373
433
  const args = command.args?.length ? command.args : running?.flags ?? [];
374
434
  let cli = command.cli;
375
435
  if (isPackageInstall(cli)) {
@@ -401,13 +461,19 @@ async function enableAutostart(command, dataDir, from) {
401
461
  */
402
462
  async function ensureDaemon(command, dataDir) {
403
463
  if (!isServiceInstalled(command.port)) {
404
- const { status } = await startInBackground(command, dataDir);
464
+ const { status, newer } = await startInBackground(command, dataDir);
405
465
  return {
406
466
  status,
407
- autostart: false
467
+ autostart: false,
468
+ newer
408
469
  };
409
470
  }
410
471
  const running = await probeDaemon(command.port);
472
+ if (running && isNewerThanThis(running.version)) return {
473
+ status: "running",
474
+ autostart: true,
475
+ newer: running.version
476
+ };
411
477
  const flags = command.args?.length ? command.args : running?.flags ?? [];
412
478
  if (running && running.version === VERSION && sameFlags(running.flags, flags)) return {
413
479
  status: "running",
@@ -868,7 +934,7 @@ async function runInit(options) {
868
934
  if (options.daemon) {
869
935
  const result = await ensureDaemon(options.daemon, defaultDataDir());
870
936
  autostart = result.autostart;
871
- log(` ${pc.green("✓")} Tencil ${result.status === "running" ? "is running" : result.status} on port ${options.daemon.port}.`);
937
+ log(result.newer ? newerDaemonLine(result.newer, options.daemon.port) : ` ${pc.green("✓")} Tencil ${result.status === "running" ? "is running" : result.status} on port ${options.daemon.port}.`);
872
938
  }
873
939
  if (!options.skipPair) await prepareProvider(await chooseProvider({
874
940
  yes: options.yes,
@@ -1002,15 +1068,6 @@ async function connect(input, t3Url) {
1002
1068
  console.log(`\n ${pc.green("✓")} Paired with T3 Code at ${target.baseUrl} ${pc.dim(`(valid until ${new Date(credential.expiresAt).toLocaleDateString()})`)}\n`);
1003
1069
  }
1004
1070
  //#endregion
1005
- //#region src/cli/format.ts
1006
- function time() {
1007
- return (/* @__PURE__ */ new Date()).toLocaleTimeString([], {
1008
- hour: "2-digit",
1009
- minute: "2-digit",
1010
- second: "2-digit"
1011
- });
1012
- }
1013
- //#endregion
1014
1071
  //#region src/cli/options.ts
1015
1072
  const RUNTIME_MODES = [
1016
1073
  "approval-required",
@@ -1095,19 +1152,31 @@ async function runDaemon(values, port, provider, t3Url, runtimeMode) {
1095
1152
  async function setup(command, options = {}) {
1096
1153
  const log = (message) => console.log(message);
1097
1154
  log(`\n ${pc.bold("Tencil")} setup ${pc.dim(`v${VERSION}`)}\n`);
1155
+ const notice = updateNotice();
1098
1156
  await prepareProvider(await chooseProvider({
1099
1157
  ...options,
1100
1158
  log
1101
1159
  }), options.t3Url, log);
1102
1160
  await setUpMachine(command, options, log);
1103
- log(`
1104
- Next, in each project: ${pc.cyan("npx tencil")}
1105
- Then start its dev server and press ${pc.bold("C")} on the page.
1106
- `);
1161
+ log(await nextSteps(options.root));
1162
+ await printUpdateNotice(notice, log);
1163
+ }
1164
+ /** What to do next, for the folder setup ran in. */
1165
+ async function nextSteps(root) {
1166
+ const plan = root && existsSync(join(root, "package.json")) ? await planInit(root).catch(() => void 0) : void 0;
1167
+ const name = pc.bold(basename(root ?? ""));
1168
+ const devServer = `start its dev server and press ${pc.bold("C")} on the page.`;
1169
+ if (plan && plan.framework.kind !== "unknown") return plan.edits.length === 0 && plan.manual.length === 0 ? `\n ${pc.green("✓")} ${name} already loads Tencil: ${devServer}\n To add Tencil to another project, run ${pc.cyan("npx tencil")} in its folder.\n` : `\n Next, add Tencil to ${name}: ${pc.cyan("npx tencil")}\n Then ${devServer}\n`;
1170
+ return `\n Next, in each project: ${pc.cyan("npx tencil")}\n Then ${devServer}\n`;
1107
1171
  }
1108
1172
  /** Ask about starting at login (yes by default), then start the daemon that way. */
1109
1173
  async function setUpMachine(command, options, log) {
1110
1174
  const dataDir = defaultDataDir();
1175
+ const running = await probeDaemon(command.port);
1176
+ if (running && isNewerThanThis(running.version)) {
1177
+ log(newerDaemonLine(running.version, command.port));
1178
+ return;
1179
+ }
1111
1180
  if (options.yes || !process.stdin.isTTY ? true : await confirm("Start Tencil automatically when you log in?")) {
1112
1181
  log(pc.dim(" Setting up the login service…"));
1113
1182
  try {
@@ -1139,6 +1208,7 @@ async function confirm(question) {
1139
1208
  async function quickstart(command, options) {
1140
1209
  const log = (message) => console.log(message);
1141
1210
  log(`\n ${pc.bold("Tencil")} ${pc.dim(`v${VERSION}`)}\n`);
1211
+ const notice = updateNotice();
1142
1212
  await prepareProvider(await chooseProvider({
1143
1213
  ...options,
1144
1214
  log
@@ -1147,8 +1217,9 @@ async function quickstart(command, options) {
1147
1217
  else {
1148
1218
  const result = await ensureDaemon(command, defaultDataDir());
1149
1219
  const verb = result.status === "running" ? "is running" : result.status;
1150
- log(` ${pc.green("✓")} Tencil ${verb} on port ${command.port}${result.autostart ? pc.dim(" (starts at login)") : ""}`);
1220
+ log(result.newer ? newerDaemonLine(result.newer, command.port) : ` ${pc.green("✓")} Tencil ${verb} on port ${command.port}${result.autostart ? pc.dim(" (starts at login)") : ""}`);
1151
1221
  }
1222
+ await printUpdateNotice(notice, log);
1152
1223
  const framework = await detectFramework(options.root);
1153
1224
  if (framework.kind !== "unknown" || existsSync(join(options.root, "package.json"))) {
1154
1225
  const apps = framework.kind === "unknown" ? await findApps(options.root) : [];
@@ -1191,7 +1262,12 @@ async function service(action, command, from) {
1191
1262
  //#endregion
1192
1263
  //#region src/cli/commands/start.ts
1193
1264
  async function start(command) {
1265
+ const notice = updateNotice();
1194
1266
  const result = await ensureDaemon(command, defaultDataDir());
1267
+ if (result.newer) {
1268
+ console.log(`\n${newerDaemonLine(result.newer, command.port)}\n`);
1269
+ return;
1270
+ }
1195
1271
  const verb = result.status === "running" ? "is running" : result.status;
1196
1272
  console.log(`
1197
1273
  ${pc.green("●")} ${pc.bold("Tencil")} ${verb} ${pc.dim(`(v${VERSION}, port ${command.port})`)}
@@ -1199,6 +1275,7 @@ async function start(command) {
1199
1275
  Open a project's dev server and press ${pc.bold("C")} on the page. Projects need the
1200
1276
  overlay loaded once: run ${pc.cyan("npx tencil")} in the project.${result.autostart ? "" : `\n ${pc.dim(`Start it automatically at login: ${pc.cyan("npx tencil setup")}`)}`}
1201
1277
  `);
1278
+ await printUpdateNotice(notice, console.log);
1202
1279
  }
1203
1280
  //#endregion
1204
1281
  //#region src/cli/commands/status.ts
@@ -1331,7 +1408,8 @@ async function main() {
1331
1408
  case "setup": return setup(daemonCommand, {
1332
1409
  yes: values.yes,
1333
1410
  from: values.from,
1334
- t3Url
1411
+ t3Url,
1412
+ root: resolve(values.root ?? process.cwd())
1335
1413
  });
1336
1414
  case "stop":
1337
1415
  if (isServiceInstalled(port)) {
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as ThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-PYBcw-eR.mjs";
1
+ import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as ThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-Bxj8yTb3.mjs";
2
2
  export { Bridge, DEFAULT_PORT, ProjectResolver, ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
@@ -2608,7 +2608,7 @@ function errorMessage(error) {
2608
2608
  }
2609
2609
  //#endregion
2610
2610
  //#region src/version.ts
2611
- const VERSION = "0.3.1";
2611
+ const VERSION = "0.3.2";
2612
2612
  //#endregion
2613
2613
  //#region src/daemon/thread-store.ts
2614
2614
  const StoreFile = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencil",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Point at any element of your running app and tell your coding agent what to fix.",
5
5
  "license": "MIT",
6
6
  "author": "Pixel Perfect Agency",
@@ -85,11 +85,11 @@
85
85
  "@types/ws": "^8.18.2",
86
86
  "react": "^19.3.0",
87
87
  "tsdown": "^0.23.0",
88
+ "@tencil/overlay": "0.0.0",
88
89
  "@tencil/protocol": "0.0.0",
89
90
  "@tencil/provider-claude-code": "0.0.0",
90
91
  "@tencil/provider-t3code": "0.0.0",
91
92
  "@tencil/testing": "0.0.0",
92
- "@tencil/overlay": "0.0.0",
93
93
  "@tencil/tsconfig": "0.0.0"
94
94
  },
95
95
  "scripts": {