worktrust 0.10.1 → 0.10.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.
package/config-edits.mjs CHANGED
@@ -71,14 +71,17 @@ export function takeOut(lines, path, mine) {
71
71
  /**
72
72
  * ONLY THE HOUSE'S OWN DOOR (0.6.16, audit L5; the same rule as log-session.mjs and count-behaviour.mjs): an MCP address is
73
73
  * WorkTrust's when its path is /api/mcp and its host is worktrust.io or a subdomain over https, the host WORKTRUST_MCP_URL
74
- * names, or this computer. `/api/mcp` alone is every hosted MCP server's conventional path, so another product's entry is
74
+ * names, or WorkTrust's own port on this computer. `/api/mcp` alone is every hosted MCP server's conventional path, so another product's entry is
75
75
  * never adopted as the coupling, and never taken out with it.
76
76
  */
77
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
78
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
79
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
77
80
  export const isWorkTrustDoor = (url) => {
78
81
  try {
79
82
  const parsed = new URL(String(url));
80
83
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
81
84
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
82
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
85
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
83
86
  } catch { return false; }
84
87
  };
@@ -17,6 +17,7 @@
17
17
  * node count-behaviour.mjs --url https://app.worktrust.io/api/mcp --token wt_...
18
18
  * node count-behaviour.mjs --dry-run --exclude client-x --exclude secret
19
19
  * node count-behaviour.mjs --dry-run --claude-export ~/Downloads/claude-export (a claude.ai data export beside the transcripts)
20
+ * node count-behaviour.mjs --dry-run --chatgpt-export ~/Downloads/chatgpt-export (a ChatGPT data export, the same way)
20
21
  *
21
22
  * CONFIDENTIAL PROJECTS stay out BEFORE anything is counted: `--exclude <text>` (repeatable)
22
23
  * skips every project directory whose name contains that text, and `.worktrust-counter.json`
@@ -433,6 +434,15 @@ for (let i = 0; i < args.length; i += 1) if (args[i] === "--exclude" && args[i +
433
434
  */
434
435
  const EXPORTS = [];
435
436
  for (let i = 0; i < args.length; i += 1) if (args[i] === "--claude-export" && args[i + 1]) EXPORTS.push(args[i + 1]);
437
+ /**
438
+ * A CHATGPT DATA EXPORT (Settings → Data controls → Export data; docs/OPEN.md §0p step 2), the same way:
439
+ * `--chatgpt-export <folder or conversations.json>`, repeatable. A conversation is a tree (`mapping`, a node per
440
+ * message with its parent); only the branch that ends at `current_node` is read, so an answer regenerated or a message
441
+ * edited is counted once, as the person kept it. The person's own messages are the turns, `create_time` (epoch
442
+ * seconds) the clock, `model_slug` the model. No tokens: the export carries none, and none are estimated from text.
443
+ */
444
+ const CHATGPT_EXPORTS = [];
445
+ for (let i = 0; i < args.length; i += 1) if (args[i] === "--chatgpt-export" && args[i + 1]) CHATGPT_EXPORTS.push(args[i + 1]);
436
446
  try {
437
447
  const config = JSON.parse(readFileSync(join(homedir(), ".worktrust-counter.json"), "utf8"));
438
448
  for (const entry of Array.isArray(config.exclude) ? config.exclude : []) EXCLUDE.push(String(entry).toLowerCase());
@@ -485,12 +495,15 @@ if (flag("classify")) {
485
495
  * fetched a script to run from its origin. A door is WorkTrust's when its host is worktrust.io or a
486
496
  * subdomain, or a local one named by WORKTRUST_MCP_URL; nothing else is a coupling.
487
497
  */
498
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
499
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
500
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
488
501
  const isWorkTrustDoor = (url) => {
489
502
  try {
490
503
  const parsed = new URL(String(url));
491
504
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
492
505
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
493
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
506
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
494
507
  } catch { return false; }
495
508
  };
496
509
  function fromClientConfig() {
@@ -625,6 +638,44 @@ function* claudeExportSessions() {
625
638
  }
626
639
  }
627
640
  }
641
+ let chatgptConversations = 0;
642
+ /** The kept branch of one ChatGPT conversation, oldest first: from `current_node` up through the parents. */
643
+ function chatgptBranch(conversation) {
644
+ const mapping = conversation?.mapping && typeof conversation.mapping === "object" ? conversation.mapping : {};
645
+ const branch = [];
646
+ const seen = new Set();
647
+ for (let id = conversation?.current_node; id && mapping[id] && !seen.has(id); id = mapping[id].parent) { seen.add(id); branch.push(mapping[id]); }
648
+ return branch.reverse();
649
+ }
650
+ function* chatgptExportSessions() {
651
+ for (const given of CHATGPT_EXPORTS) {
652
+ let path = given.replace(/^~(?=\/|$)/, homedir());
653
+ try { if (statSync(path).isDirectory()) path = join(path, "conversations.json"); } catch { throw Error(`chatgpt export not found: ${given}`); }
654
+ let conversations; try { conversations = JSON.parse(readFileSync(path, "utf8")); } catch { throw Error(`chatgpt export unreadable: ${path}`); }
655
+ if (!Array.isArray(conversations)) throw Error("chatgpt export must contain an array of conversations");
656
+ for (const conversation of conversations) {
657
+ const title = String(conversation?.title ?? "");
658
+ if (excluded(title)) { skippedConversations.push(title.slice(0, 40)); continue; }
659
+ const lines = [];
660
+ for (const node of chatgptBranch(conversation)) {
661
+ const m = node?.message;
662
+ const role = m?.author?.role;
663
+ // The person and the model only: system prompts, tools and what the app hides are neither.
664
+ if ((role !== "user" && role !== "assistant") || m?.metadata?.is_visually_hidden_from_conversation) continue;
665
+ const parts = Array.isArray(m?.content?.parts) ? m.content.parts.filter((part) => typeof part === "string") : [];
666
+ const text = parts.join("\n");
667
+ if (text.length === 0) continue;
668
+ const seconds = Number(m?.create_time ?? conversation?.create_time);
669
+ const at = Number.isFinite(seconds) && seconds > 0 ? new Date(seconds * 1000).toISOString() : null;
670
+ const model = typeof m?.metadata?.model_slug === "string" ? m.metadata.model_slug : undefined;
671
+ lines.push({ type: role === "user" ? "user" : "assistant", timestamp: at, message: { ...(role === "assistant" && model ? { model } : {}), content: [{ type: "text", text }] } });
672
+ }
673
+ if (lines.length === 0) continue;
674
+ chatgptConversations += 1;
675
+ yield { key: `chatgpt:${conversation?.conversation_id ?? conversation?.id ?? title}`, projectDir: "chatgpt", basename: "chatgpt", lines };
676
+ }
677
+ }
678
+ }
628
679
  /**
629
680
  * THE READERS FOR CODEX AND ANTIGRAVITY live in transcript-readers.mjs beside this file (2026-10-04;
630
681
  * the session hook imports the same file). Run alone, without it, the counter reads Claude Code,
@@ -709,7 +760,7 @@ function* sessions() {
709
760
  // A rollout is a transcript on this machine, so --only-transcripts keeps it.
710
761
  yield* codexSessions();
711
762
  yield* antigravitySessions();
712
- if (!flag("only-transcripts")) { yield* claudeExportSessions(); yield* copilotSessions(); }
763
+ if (!flag("only-transcripts")) { yield* claudeExportSessions(); yield* chatgptExportSessions(); yield* copilotSessions(); }
713
764
  }
714
765
 
715
766
  /**
@@ -843,7 +894,7 @@ const seenLines = new Set(); // v0.10: line identities already counted (a uuid o
843
894
  // scan; complete session boundaries preserve signals that depend on earlier turns.
844
895
  const manifest = [];
845
896
  for(const session of sessions())manifest.push(sessionDigest(session));
846
- exportConversations = 0; copilotSessionCount = 0; codexRolloutCount = 0; antigravityCount = 0; skippedDirs.length = 0; countedDirs.length = 0; skippedConversations.length = 0;
897
+ exportConversations = 0; chatgptConversations = 0; copilotSessionCount = 0; codexRolloutCount = 0; antigravityCount = 0; skippedDirs.length = 0; countedDirs.length = 0; skippedConversations.length = 0;
847
898
  const checkpoint = flag("no-checkpoint") || flag("stretch-signals") || LABEL_OUT ? null : checkpointStore(
848
899
  value("checkpoint") ?? join(homedir(), ".worktrust", "counter-checkpoint.json"),
849
900
  fingerprint({code:readFileSync(new URL(import.meta.url)),version:ANALYZER_VERSION,months:MONTHS_BACK,thisMonth,exclude:EXCLUDE,leaveOut:LEAVE_OUT,exports:EXPORTS}),manifest);
@@ -1226,6 +1277,7 @@ if (!codexLines) console.log(" codex and antigravity: not read (transcript-reade
1226
1277
  if (antigravityCount > 0) console.log(` antigravity conversations read: ${antigravityCount} (~/.gemini/antigravity*, this machine; clocks and the person's turns, no tokens recorded)`);
1227
1278
  if (codexRolloutCount > 0) console.log(` codex rollouts read: ${codexRolloutCount} (~/.codex/sessions, this machine; tokens once per response, the person's turns only)`);
1228
1279
  if (EXPORTS.length > 0) console.log(` claude.ai export: ${exportConversations} conversation(s) counted${skippedConversations.length ? ` · excluded, never read: ${skippedConversations.length}` : ""}`);
1280
+ if (CHATGPT_EXPORTS.length > 0) console.log(` ChatGPT export: ${chatgptConversations} conversation(s) counted (the kept branch of each; no tokens, the export carries none)`);
1229
1281
  if (skippedDirs.length > 0) console.log(` excluded, never read: ${skippedDirs.join(", ")}`);
1230
1282
  for (const month of months) {
1231
1283
  const bucket = byMonth.get(month);
package/log-session.mjs CHANGED
@@ -212,12 +212,15 @@ const floorOf = (state, key) => { const at = typeof state?.[key] === "string" ?
212
212
  * fetched a script to run from its origin. A door is WorkTrust's when its host is worktrust.io or a
213
213
  * subdomain, or a local one named by WORKTRUST_MCP_URL; nothing else is a coupling.
214
214
  */
215
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
216
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
217
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
215
218
  const isWorkTrustDoor = (url) => {
216
219
  try {
217
220
  const parsed = new URL(String(url));
218
221
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
219
222
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
220
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
223
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
221
224
  } catch { return false; }
222
225
  };
223
226
  /** The coupling: given, or the one Claude Code already holds — the same read the counter does. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
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/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.1";
76
+ const CLI_VERSION = "0.10.3";
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");