worktrust 0.10.3 → 0.10.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
5
5
  "type": "module",
6
6
  "bin": {
package/setup-mcp.mjs CHANGED
@@ -68,7 +68,16 @@ const masked = BRIDGE ? "kept in ~/.worktrust/key.json, not in these files" : `$
68
68
  const stdio = { command: NODE, args: [BRIDGE ?? "", "mcp"] };
69
69
  const home = homedir();
70
70
  /** Whether Claude Code's own command is on this machine: asked of the shell, never guessed from a file. */
71
- const onPath = (command) => spawnSync(platform() === "win32" ? "where" : "which", [command], { encoding: "utf8", shell: platform() === "win32" }).status === 0;
71
+ /**
72
+ * A COMMAND, RUN THE SAME WAY ON EVERY SYSTEM (0.10.4). On Windows `claude`, `openclaw` and `where` are .cmd shims that
73
+ * need a shell, and Node 24 warns (DEP0190) when arguments ride beside `shell: true` unescaped. So on Windows the line is
74
+ * built here, each argument quoted for cmd.exe, and handed over whole; elsewhere no shell is used at all.
75
+ */
76
+ const quoteForCmd = (arg) => (/^[\w@%+=:,./\\-]+$/.test(arg) ? arg : `"${String(arg).replace(/"/g, '\\"')}"`);
77
+ const runCommand = (command, args, options = {}) => (platform() === "win32"
78
+ ? spawnSync([command, ...args].map(quoteForCmd).join(" "), { encoding: "utf8", ...options, shell: true })
79
+ : spawnSync(command, args, { encoding: "utf8", ...options }));
80
+ const onPath = (command) => runCommand(platform() === "win32" ? "where" : "which", [command]).status === 0;
72
81
  const claudeOnPath = () => onPath("claude");
73
82
  const VIBE_DIR = process.env.VIBE_HOME?.trim() || join(home, ".vibe");
74
83
  const GROK_DIR = process.env.GROK_HOME?.trim() || join(home, ".grok");
@@ -214,7 +223,7 @@ for (const client of CLIENTS) {
214
223
  if (REMOVE ? !named : named && text.includes(JSON.stringify(BRIDGE ?? URL_).slice(1, -1)) && (BRIDGE === undefined || !text.includes(URL_))) { console.log(REMOVE ? ` – ${client.label}: does not name the door` : ` ✓ ${client.label}: already names the door (${client.file})`); if (!REMOVE) standing += 1; continue; }
215
224
  if (!WRITE) { console.log(` ${REMOVE ? "−" : "+"} ${client.label}: would run ${shown}`); continue; }
216
225
  if (!onPath("openclaw")) { console.log(` ! ${client.label}: the \`openclaw\` command is not on this machine's PATH; run ${shown}`); continue; }
217
- const run = spawnSync("openclaw", verb, { encoding: "utf8", shell: platform() === "win32" });
226
+ const run = runCommand("openclaw", verb);
218
227
  if (run.status === 0) { console.log(` ${REMOVE ? "−" : "+"} ${client.label}: ${REMOVE ? "removed" : "coupled"} through \`openclaw mcp ${REMOVE ? "unset" : "set"}\``); touched += 1; }
219
228
  else console.log(` ! ${client.label}: \`openclaw mcp\` refused (${(run.stderr || run.stdout || "").trim().split("\n")[0] || "no output"}); run it yourself: ${shown}`);
220
229
  continue;
@@ -232,11 +241,11 @@ for (const client of CLIENTS) {
232
241
  if (BRIDGE || REMOVE) for (const entry of direct.entries.filter((one) => !(REMOVE && one.name === NAME && one.scope === "user"))) {
233
242
  const verb = `claude mcp remove -s ${entry.scope} ${entry.name}`;
234
243
  if (!WRITE) { console.log(` ↻ ${client.label}: the direct entry "${entry.name}" (${entry.scope}) is replaced`); continue; }
235
- const out = claudeOnPath() ? spawnSync("claude", ["mcp", "remove", "-s", entry.scope, entry.name], { encoding: "utf8", shell: platform() === "win32", ...(entry.dir ? { cwd: entry.dir } : {}) }) : null;
244
+ const out = claudeOnPath() ? runCommand("claude", ["mcp", "remove", "-s", entry.scope, entry.name], entry.dir ? { cwd: entry.dir } : {}) : null;
236
245
  console.log(out?.status === 0 ? ` – ${client.label}: removed the direct entry "${entry.name}" (${entry.scope})` : ` ! ${client.label}: could not remove "${entry.name}"; run it yourself${entry.dir ? ` in ${entry.dir}` : ""}: ${verb}`);
237
246
  }
238
247
  if (WRITE && claudeOnPath()) {
239
- const run = spawnSync("claude", claudeArgs, { encoding: "utf8", shell: platform() === "win32" });
248
+ const run = runCommand("claude", claudeArgs);
240
249
  if (run.status === 0) { console.log(` + ${client.label}: ${REMOVE ? "removed" : "coupled"} through \`claude mcp ${REMOVE ? "remove" : "add"}\` (user scope)`); touched += 1; continue; }
241
250
  console.log(` ! ${client.label}: \`claude mcp\` refused (${(run.stderr || run.stdout || "").trim().split("\n")[0] || "no output"}); run it yourself: ${shown}`);
242
251
  continue;
package/worktrust.mjs CHANGED
@@ -73,7 +73,7 @@ const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALU
73
73
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
74
74
  const has = (name) => args.includes(`--${name}`);
75
75
  /** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
76
- const CLI_VERSION = "0.10.3";
76
+ const CLI_VERSION = "0.10.4";
77
77
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
78
78
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
79
79
  const HOME_DIR = join(homedir(), ".worktrust");
@@ -593,7 +593,8 @@ async function connect() {
593
593
 
594
594
  // The device key: made here, its private half kept with the key, its public half bound at WorkTrust.
595
595
  const device = direct ? null : generateKeyPairSync("ed25519");
596
- const apps = foundApps.map((line) => /^\s*[↻+✓] ([^:]+):/.exec(line)?.[1]).filter(Boolean).slice(0, 12);
596
+ // Claude Code is coupled through its own command, so its plan line reads "! … couple with": it is coupled all the same (0.10.4).
597
+ const apps = foundApps.map((line) => /^\s*(?:[↻+✓] ([^:]+):|! ([^:]+): couple with)/.exec(line)).map((match) => match?.[1] ?? match?.[2]).filter(Boolean).slice(0, 12);
597
598
  const extra = { apps, ...computerIds(), ...(device ? { device_key: device.publicKey.export({ format: "jwk" }).x } : {}) };
598
599
  const pairing = useDevice() ? await pairByCode(host, extra) : await pairByBrowser(host, extra);
599
600
  const { token } = pairing;
@@ -656,7 +657,7 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
656
657
  if (!has("history") && !(rebuild ? await ask("Rebuild the history (replaces this computer's earlier lines for these days)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { say(rebuild ? " Not sent. Rebuild later with: npx worktrust@latest history --rebuild" : " Not sent. Send them later with: npx worktrust@latest history"); return; }
657
658
  const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : [])], token, true, env);
658
659
  if (rebuild) say(sent.code === 0 ? " ✓ Rebuilt. This computer's earlier lines for those days were replaced; the record shows each replacement." : " Not all of it arrived. Run npx worktrust@latest history --rebuild again: a day already rebuilt is counted once.");
659
- else say(sent.code === 0 ? " ✓ Sent as history. It shows in WorkTrust as earlier work, never as verified hours." : " Not all of it arrived. Run npx worktrust@latest history again: a line already received is kept once.");
660
+ else say(sent.code === 0 ? " ✓ Sent as history. Measured sessions count toward your verified hours; a day WorkTrust already holds is kept once." : " Not all of it arrived. Run npx worktrust@latest history again: a line already received is kept once.");
660
661
  }
661
662
 
662
663
  /** The version stamped in the stable copy in ~/.worktrust, the CLI this computer ran before an update; null without one. */