tencil 0.3.0 → 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 loadAgentSdk } from "./server-B7qPM-xo.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",
@@ -92,8 +151,23 @@ function serviceNames(port = DEFAULT_PORT) {
92
151
  task: own ? `Tencil ${port}` : "Tencil"
93
152
  };
94
153
  }
95
- function launchdPlist(command, logPath) {
154
+ /**
155
+ * What the daemon needs from the shell that installed it. launchd and systemd
156
+ * start it with a bare PATH (`/usr/bin:/bin`), where nvm's npm and npx, which
157
+ * it runs to pair and to install the Claude Agent SDK, can't be found; and a
158
+ * custom XDG_CONFIG_HOME must reach it, or it reads another data folder than
159
+ * the CLI. npx's and npm's own folders (anything in node_modules) are left out of PATH.
160
+ */
161
+ function serviceEnvironment(command, env = process.env) {
162
+ const separator = process.platform === "win32" ? ";" : ":";
163
+ const entries = [dirname(command.node), ...(env.PATH ?? "").split(separator)].filter((entry) => entry && !/[\\/](?:_npx|node_modules)[\\/]/.test(entry));
164
+ const environment = { PATH: [...new Set(entries)].join(separator) };
165
+ if (env.XDG_CONFIG_HOME) environment.XDG_CONFIG_HOME = env.XDG_CONFIG_HOME;
166
+ return environment;
167
+ }
168
+ function launchdPlist(command, logPath, environment = {}) {
96
169
  const args = [command.node, ...daemonArgs(command)].map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n");
170
+ const variables = Object.entries(environment).map(([key, value]) => ` <key>${escapeXml(key)}</key>\n <string>${escapeXml(value)}</string>`).join("\n");
97
171
  return `<?xml version="1.0" encoding="UTF-8"?>
98
172
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
99
173
  <plist version="1.0">
@@ -104,6 +178,10 @@ function launchdPlist(command, logPath) {
104
178
  <array>
105
179
  ${args}
106
180
  </array>
181
+ <key>EnvironmentVariables</key>
182
+ <dict>
183
+ ${variables}
184
+ </dict>
107
185
  <key>RunAtLoad</key>
108
186
  <true/>
109
187
  <key>KeepAlive</key>
@@ -116,12 +194,12 @@ ${args}
116
194
  </plist>
117
195
  `;
118
196
  }
119
- function systemdUnit(command) {
197
+ function systemdUnit(command, environment = {}) {
120
198
  return `[Unit]
121
199
  Description=Tencil daemon
122
200
 
123
201
  [Service]
124
- ExecStart=${[command.node, ...daemonArgs(command)].map((arg) => `"${arg}"`).join(" ")}
202
+ ${Object.entries(environment).map(([key, value]) => `Environment="${key}=${value}"\n`).join("")}ExecStart=${[command.node, ...daemonArgs(command)].map((arg) => `"${arg}"`).join(" ")}
125
203
  Restart=on-failure
126
204
 
127
205
  [Install]
@@ -184,7 +262,7 @@ async function installService(command, dataDir) {
184
262
  ]);
185
263
  await stopDaemon(command.port);
186
264
  mkdirSync(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
187
- writeFileSync(plist, launchdPlist(command, logPath));
265
+ writeFileSync(plist, launchdPlist(command, logPath, serviceEnvironment(command)));
188
266
  execFileSync("launchctl", [
189
267
  "bootstrap",
190
268
  launchdDomain(),
@@ -201,7 +279,7 @@ async function installService(command, dataDir) {
201
279
  ]);
202
280
  await stopDaemon(command.port);
203
281
  mkdirSync(join(homedir(), ".config", "systemd", "user"), { recursive: true });
204
- writeFileSync(unit, systemdUnit(command));
282
+ writeFileSync(unit, systemdUnit(command, serviceEnvironment(command)));
205
283
  execFileSync("systemctl", ["--user", "daemon-reload"]);
206
284
  execFileSync("systemctl", [
207
285
  "--user",
@@ -351,6 +429,7 @@ function runtimeInstallArgs(dataDir, spec, port = DEFAULT_PORT) {
351
429
  */
352
430
  async function enableAutostart(command, dataDir, from) {
353
431
  const running = await probeDaemon(command.port);
432
+ if (running && isNewerThanThis(running.version)) throw new NewerDaemonError(running.version);
354
433
  const args = command.args?.length ? command.args : running?.flags ?? [];
355
434
  let cli = command.cli;
356
435
  if (isPackageInstall(cli)) {
@@ -362,7 +441,8 @@ async function enableAutostart(command, dataDir, from) {
362
441
  "ignore",
363
442
  "pipe"
364
443
  ],
365
- shell: process.platform === "win32"
444
+ shell: process.platform === "win32",
445
+ env: withoutNpmEnv()
366
446
  });
367
447
  if (result.status !== 0) throw new Error(`Couldn't install Tencil for the login service (npm ${result.status ?? "failed"}): ${result.stderr?.trim() ?? ""}`);
368
448
  cli = runtimeCli(dataDir, command.port);
@@ -381,13 +461,19 @@ async function enableAutostart(command, dataDir, from) {
381
461
  */
382
462
  async function ensureDaemon(command, dataDir) {
383
463
  if (!isServiceInstalled(command.port)) {
384
- const { status } = await startInBackground(command, dataDir);
464
+ const { status, newer } = await startInBackground(command, dataDir);
385
465
  return {
386
466
  status,
387
- autostart: false
467
+ autostart: false,
468
+ newer
388
469
  };
389
470
  }
390
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
+ };
391
477
  const flags = command.args?.length ? command.args : running?.flags ?? [];
392
478
  if (running && running.version === VERSION && sameFlags(running.flags, flags)) return {
393
479
  status: "running",
@@ -455,7 +541,7 @@ async function pairWithLocalT3(t3Url, log) {
455
541
  if (await store.get(baseUrl)) return log(` ${pc.green("✓")} Paired with T3 Code.`);
456
542
  const code = await createLocalPairingCode(baseUrl).catch(() => void 0);
457
543
  if (!code) {
458
- log(` ${pc.yellow("!")} T3 Code isn't running, so pairing is skipped. Tencil pairs on its own once it is.`);
544
+ log(await fetch(new URL("/.well-known/t3/environment", baseUrl), { signal: AbortSignal.timeout(3e3) }).then((response) => response.ok, () => false) ? ` ${pc.yellow("!")} Couldn't pair with T3 Code automatically. Press Pair in the overlay, or run ${pc.cyan("npx tencil connect")} with a pairing link from T3 Code.` : ` ${pc.yellow("!")} T3 Code isn't running, so pairing is skipped. Tencil pairs on its own once it is.`);
459
545
  return;
460
546
  }
461
547
  try {
@@ -848,7 +934,7 @@ async function runInit(options) {
848
934
  if (options.daemon) {
849
935
  const result = await ensureDaemon(options.daemon, defaultDataDir());
850
936
  autostart = result.autostart;
851
- 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}.`);
852
938
  }
853
939
  if (!options.skipPair) await prepareProvider(await chooseProvider({
854
940
  yes: options.yes,
@@ -874,7 +960,8 @@ function uninstall(options, name, log) {
874
960
  spawnSync(command, args, {
875
961
  cwd: options.root,
876
962
  stdio: "inherit",
877
- shell: process.platform === "win32"
963
+ shell: process.platform === "win32",
964
+ env: withoutNpmEnv()
878
965
  });
879
966
  }
880
967
  function install(options, log) {
@@ -883,7 +970,8 @@ function install(options, log) {
883
970
  if (spawnSync(command, args, {
884
971
  cwd: options.root,
885
972
  stdio: "inherit",
886
- shell: process.platform === "win32"
973
+ shell: process.platform === "win32",
974
+ env: withoutNpmEnv()
887
975
  }).status !== 0) log(` ${pc.yellow("!")} Install failed; run it yourself: ${command} ${args.join(" ")}\n`);
888
976
  }
889
977
  function describe(framework) {
@@ -980,15 +1068,6 @@ async function connect(input, t3Url) {
980
1068
  console.log(`\n ${pc.green("✓")} Paired with T3 Code at ${target.baseUrl} ${pc.dim(`(valid until ${new Date(credential.expiresAt).toLocaleDateString()})`)}\n`);
981
1069
  }
982
1070
  //#endregion
983
- //#region src/cli/format.ts
984
- function time() {
985
- return (/* @__PURE__ */ new Date()).toLocaleTimeString([], {
986
- hour: "2-digit",
987
- minute: "2-digit",
988
- second: "2-digit"
989
- });
990
- }
991
- //#endregion
992
1071
  //#region src/cli/options.ts
993
1072
  const RUNTIME_MODES = [
994
1073
  "approval-required",
@@ -1073,20 +1152,31 @@ async function runDaemon(values, port, provider, t3Url, runtimeMode) {
1073
1152
  async function setup(command, options = {}) {
1074
1153
  const log = (message) => console.log(message);
1075
1154
  log(`\n ${pc.bold("Tencil")} setup ${pc.dim(`v${VERSION}`)}\n`);
1076
- const provider = await chooseProvider({
1155
+ const notice = updateNotice();
1156
+ await prepareProvider(await chooseProvider({
1077
1157
  ...options,
1078
1158
  log
1079
- });
1159
+ }), options.t3Url, log);
1080
1160
  await setUpMachine(command, options, log);
1081
- await prepareProvider(provider, options.t3Url, log);
1082
- log(`
1083
- Next, in each project: ${pc.cyan("npx tencil")}
1084
- Then start its dev server and press ${pc.bold("C")} on the page.
1085
- `);
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`;
1086
1171
  }
1087
1172
  /** Ask about starting at login (yes by default), then start the daemon that way. */
1088
1173
  async function setUpMachine(command, options, log) {
1089
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
+ }
1090
1180
  if (options.yes || !process.stdin.isTTY ? true : await confirm("Start Tencil automatically when you log in?")) {
1091
1181
  log(pc.dim(" Setting up the login service…"));
1092
1182
  try {
@@ -1118,17 +1208,18 @@ async function confirm(question) {
1118
1208
  async function quickstart(command, options) {
1119
1209
  const log = (message) => console.log(message);
1120
1210
  log(`\n ${pc.bold("Tencil")} ${pc.dim(`v${VERSION}`)}\n`);
1121
- const provider = await chooseProvider({
1211
+ const notice = updateNotice();
1212
+ await prepareProvider(await chooseProvider({
1122
1213
  ...options,
1123
1214
  log
1124
- });
1215
+ }), options.t3Url, log);
1125
1216
  if (!await probeDaemon(command.port) && !isServiceInstalled(command.port)) await setUpMachine(command, options, log);
1126
1217
  else {
1127
1218
  const result = await ensureDaemon(command, defaultDataDir());
1128
1219
  const verb = result.status === "running" ? "is running" : result.status;
1129
- 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)") : ""}`);
1130
1221
  }
1131
- await prepareProvider(provider, options.t3Url, log);
1222
+ await printUpdateNotice(notice, log);
1132
1223
  const framework = await detectFramework(options.root);
1133
1224
  if (framework.kind !== "unknown" || existsSync(join(options.root, "package.json"))) {
1134
1225
  const apps = framework.kind === "unknown" ? await findApps(options.root) : [];
@@ -1171,7 +1262,12 @@ async function service(action, command, from) {
1171
1262
  //#endregion
1172
1263
  //#region src/cli/commands/start.ts
1173
1264
  async function start(command) {
1265
+ const notice = updateNotice();
1174
1266
  const result = await ensureDaemon(command, defaultDataDir());
1267
+ if (result.newer) {
1268
+ console.log(`\n${newerDaemonLine(result.newer, command.port)}\n`);
1269
+ return;
1270
+ }
1175
1271
  const verb = result.status === "running" ? "is running" : result.status;
1176
1272
  console.log(`
1177
1273
  ${pc.green("●")} ${pc.bold("Tencil")} ${verb} ${pc.dim(`(v${VERSION}, port ${command.port})`)}
@@ -1179,6 +1275,7 @@ async function start(command) {
1179
1275
  Open a project's dev server and press ${pc.bold("C")} on the page. Projects need the
1180
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")}`)}`}
1181
1277
  `);
1278
+ await printUpdateNotice(notice, console.log);
1182
1279
  }
1183
1280
  //#endregion
1184
1281
  //#region src/cli/commands/status.ts
@@ -1311,7 +1408,8 @@ async function main() {
1311
1408
  case "setup": return setup(daemonCommand, {
1312
1409
  yes: values.yes,
1313
1410
  from: values.from,
1314
- t3Url
1411
+ t3Url,
1412
+ root: resolve(values.root ?? process.cwd())
1315
1413
  });
1316
1414
  case "stop":
1317
1415
  if (isServiceInstalled(port)) {
package/dist/index.d.mts CHANGED
@@ -53,11 +53,11 @@ type ImageAttachment = z.infer<typeof ImageAttachment>;
53
53
  * - `error`: last turn or the thread itself failed
54
54
  */
55
55
  declare const ThreadStatus: z.ZodEnum<{
56
- error: "error";
57
56
  starting: "starting";
58
57
  working: "working";
59
58
  waiting: "waiting";
60
59
  idle: "idle";
60
+ error: "error";
61
61
  }>;
62
62
  type ThreadStatus = z.infer<typeof ThreadStatus>;
63
63
  declare const MessageRole: z.ZodEnum<{
@@ -109,11 +109,11 @@ declare const Thread: z.ZodObject<{
109
109
  selection: z.ZodOptional<z.ZodString>;
110
110
  }, z.core.$strip>>;
111
111
  status: z.ZodEnum<{
112
- error: "error";
113
112
  starting: "starting";
114
113
  working: "working";
115
114
  waiting: "waiting";
116
115
  idle: "idle";
116
+ error: "error";
117
117
  }>;
118
118
  statusDetail: z.ZodOptional<z.ZodString>;
119
119
  resolved: z.ZodDefault<z.ZodBoolean>;
@@ -142,10 +142,10 @@ declare const ProviderThreadSummary: z.ZodObject<{
142
142
  id: z.ZodString;
143
143
  title: z.ZodString;
144
144
  status: z.ZodEnum<{
145
- error: "error";
146
145
  working: "working";
147
146
  waiting: "waiting";
148
147
  idle: "idle";
148
+ error: "error";
149
149
  }>;
150
150
  updatedAt: z.ZodString;
151
151
  url: z.ZodOptional<z.ZodString>;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as stripContext, S as renderPrompt, b as projectRoot, d as projectStorePath, l as ThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, x as Bridge, y as ProjectResolver } from "./server-B7qPM-xo.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 };
@@ -903,7 +903,8 @@ async function installAgentSdk(installDir) {
903
903
  ], {
904
904
  cwd: installDir,
905
905
  shell: process.platform === "win32",
906
- timeout: 6e5
906
+ timeout: 6e5,
907
+ env: Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith("npm_")))
907
908
  });
908
909
  } catch (error) {
909
910
  const stderr = error.stderr?.trim();
@@ -1487,6 +1488,15 @@ async function exchangePairingCredential(target, clientLabel = "Tencil") {
1487
1488
  * the server's own version (mismatched CLIs may migrate the database).
1488
1489
  * Returns undefined when the server isn't local or the CLI fails.
1489
1490
  */
1491
+ /**
1492
+ * The environment minus the lowercase `npm_*` variables an outer npm or npx
1493
+ * passes down: under `npx --package <spec> tencil`, `npm_config_package` makes
1494
+ * a nested `npx t3` run that package instead. Variables the user set
1495
+ * (`NPM_CONFIG_REGISTRY`) are uppercase and stay.
1496
+ */
1497
+ function withoutNpmEnv(env = process.env) {
1498
+ return Object.fromEntries(Object.entries(env).filter(([key]) => !key.startsWith("npm_")));
1499
+ }
1490
1500
  async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME ?? join(homedir(), ".t3")) {
1491
1501
  const { hostname } = new URL(baseUrl);
1492
1502
  if (![
@@ -1509,7 +1519,8 @@ async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME
1509
1519
  const installed = join(baseDir, "runtime", "versions", serverVersion, "t3");
1510
1520
  const result = existsSync(installed) ? spawnSync(installed, args, {
1511
1521
  encoding: "utf8",
1512
- timeout: 3e4
1522
+ timeout: 3e4,
1523
+ env: withoutNpmEnv()
1513
1524
  }) : spawnSync(process.platform === "win32" ? "npx.cmd" : "npx", [
1514
1525
  "-y",
1515
1526
  `t3@${serverVersion}`,
@@ -1517,7 +1528,8 @@ async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME
1517
1528
  ], {
1518
1529
  encoding: "utf8",
1519
1530
  timeout: 12e4,
1520
- shell: process.platform === "win32"
1531
+ shell: process.platform === "win32",
1532
+ env: withoutNpmEnv()
1521
1533
  });
1522
1534
  return `${result.stdout ?? ""}\n${result.stderr ?? ""}`.match(/^Token:\s*(\S+)/m)?.[1];
1523
1535
  }
@@ -1533,8 +1545,8 @@ async function requestWebSocketTicket(baseUrl, token, timeoutMs = 8e3) {
1533
1545
  return ticket;
1534
1546
  }
1535
1547
  var UnauthorizedError = class extends Error {
1536
- constructor() {
1537
- super("T3 Code rejected the stored token. Run `tencil connect` to pair again.");
1548
+ constructor(message = "T3 Code rejected the stored token. Run `tencil connect` to pair again.") {
1549
+ super(message);
1538
1550
  this.name = "UnauthorizedError";
1539
1551
  }
1540
1552
  };
@@ -2236,6 +2248,7 @@ var T3CodeProvider = class {
2236
2248
  state: "unauthorized",
2237
2249
  detail: "Couldn't pair automatically. Run `npx tencil connect` with a pairing link from T3 Code."
2238
2250
  });
2251
+ this.#scheduleReconnect();
2239
2252
  return;
2240
2253
  }
2241
2254
  try {
@@ -2250,6 +2263,7 @@ var T3CodeProvider = class {
2250
2263
  state: "unauthorized",
2251
2264
  detail: errorMessage(error)
2252
2265
  });
2266
+ this.#scheduleReconnect();
2253
2267
  return;
2254
2268
  }
2255
2269
  clearTimeout(this.#retryTimer);
@@ -2429,7 +2443,7 @@ var T3CodeProvider = class {
2429
2443
  const environment = await this.#fetchJson("/.well-known/t3/environment", void 0, `T3 Code isn't running at ${this.#baseUrl}. Open T3 Code and Tencil connects on its own.`);
2430
2444
  const protocol = environment.orchestrationProtocolVersion === 2 ? v2 : v1;
2431
2445
  const token = this.#options.token ?? (await this.#credentials.get(this.#baseUrl))?.token;
2432
- if (!token) throw new UnauthorizedError();
2446
+ if (!token) throw new UnauthorizedError("Not paired with T3 Code yet. Press Pair, or run `npx tencil connect`.");
2433
2447
  const ticket = await requestWebSocketTicket(this.#baseUrl, token, this.#timeouts.httpMs);
2434
2448
  const wsUrl = new URL("/ws", this.#baseUrl);
2435
2449
  wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
@@ -2594,7 +2608,7 @@ function errorMessage(error) {
2594
2608
  }
2595
2609
  //#endregion
2596
2610
  //#region src/version.ts
2597
- const VERSION = "0.3.0";
2611
+ const VERSION = "0.3.2";
2598
2612
  //#endregion
2599
2613
  //#region src/daemon/thread-store.ts
2600
2614
  const StoreFile = z.object({
@@ -3188,4 +3202,4 @@ function resolveOverlayPath() {
3188
3202
  return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
3189
3203
  }
3190
3204
  //#endregion
3191
- export { stripContext as C, renderPrompt as S, parsePairingInput as _, detectAgents as a, projectRoot as b, savedProvider as c, projectStorePath as d, VERSION as f, exchangePairingCredential as g, createLocalPairingCode as h, PROVIDERS as i, ThreadStore as l, DEFAULT_T3_URL as m, probeDaemon as n, providerLabel as o, CredentialStore as p, startDaemon as r, saveProvider as s, DEFAULT_PORT as t, defaultDataDir as u, loadAgentSdk as v, Bridge as x, ProjectResolver as y };
3205
+ export { renderPrompt as C, Bridge as S, parsePairingInput as _, detectAgents as a, ProjectResolver as b, savedProvider as c, projectStorePath as d, VERSION as f, exchangePairingCredential as g, createLocalPairingCode as h, PROVIDERS as i, ThreadStore as l, DEFAULT_T3_URL as m, probeDaemon as n, providerLabel as o, CredentialStore as p, startDaemon as r, saveProvider as s, DEFAULT_PORT as t, defaultDataDir as u, withoutNpmEnv as v, stripContext as w, projectRoot as x, loadAgentSdk as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencil",
3
- "version": "0.3.0",
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",
@@ -86,11 +86,11 @@
86
86
  "react": "^19.3.0",
87
87
  "tsdown": "^0.23.0",
88
88
  "@tencil/overlay": "0.0.0",
89
- "@tencil/testing": "0.0.0",
90
- "@tencil/provider-t3code": "0.0.0",
91
- "@tencil/tsconfig": "0.0.0",
89
+ "@tencil/protocol": "0.0.0",
92
90
  "@tencil/provider-claude-code": "0.0.0",
93
- "@tencil/protocol": "0.0.0"
91
+ "@tencil/provider-t3code": "0.0.0",
92
+ "@tencil/testing": "0.0.0",
93
+ "@tencil/tsconfig": "0.0.0"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "tsdown && node scripts/copy-overlay.mjs",