worktrust 0.10.2 → 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/count-behaviour.mjs +51 -2
- package/package.json +1 -1
- package/worktrust.mjs +1 -1
package/count-behaviour.mjs
CHANGED
|
@@ -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());
|
|
@@ -628,6 +638,44 @@ function* claudeExportSessions() {
|
|
|
628
638
|
}
|
|
629
639
|
}
|
|
630
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
|
+
}
|
|
631
679
|
/**
|
|
632
680
|
* THE READERS FOR CODEX AND ANTIGRAVITY live in transcript-readers.mjs beside this file (2026-10-04;
|
|
633
681
|
* the session hook imports the same file). Run alone, without it, the counter reads Claude Code,
|
|
@@ -712,7 +760,7 @@ function* sessions() {
|
|
|
712
760
|
// A rollout is a transcript on this machine, so --only-transcripts keeps it.
|
|
713
761
|
yield* codexSessions();
|
|
714
762
|
yield* antigravitySessions();
|
|
715
|
-
if (!flag("only-transcripts")) { yield* claudeExportSessions(); yield* copilotSessions(); }
|
|
763
|
+
if (!flag("only-transcripts")) { yield* claudeExportSessions(); yield* chatgptExportSessions(); yield* copilotSessions(); }
|
|
716
764
|
}
|
|
717
765
|
|
|
718
766
|
/**
|
|
@@ -846,7 +894,7 @@ const seenLines = new Set(); // v0.10: line identities already counted (a uuid o
|
|
|
846
894
|
// scan; complete session boundaries preserve signals that depend on earlier turns.
|
|
847
895
|
const manifest = [];
|
|
848
896
|
for(const session of sessions())manifest.push(sessionDigest(session));
|
|
849
|
-
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;
|
|
850
898
|
const checkpoint = flag("no-checkpoint") || flag("stretch-signals") || LABEL_OUT ? null : checkpointStore(
|
|
851
899
|
value("checkpoint") ?? join(homedir(), ".worktrust", "counter-checkpoint.json"),
|
|
852
900
|
fingerprint({code:readFileSync(new URL(import.meta.url)),version:ANALYZER_VERSION,months:MONTHS_BACK,thisMonth,exclude:EXCLUDE,leaveOut:LEAVE_OUT,exports:EXPORTS}),manifest);
|
|
@@ -1229,6 +1277,7 @@ if (!codexLines) console.log(" codex and antigravity: not read (transcript-reade
|
|
|
1229
1277
|
if (antigravityCount > 0) console.log(` antigravity conversations read: ${antigravityCount} (~/.gemini/antigravity*, this machine; clocks and the person's turns, no tokens recorded)`);
|
|
1230
1278
|
if (codexRolloutCount > 0) console.log(` codex rollouts read: ${codexRolloutCount} (~/.codex/sessions, this machine; tokens once per response, the person's turns only)`);
|
|
1231
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)`);
|
|
1232
1281
|
if (skippedDirs.length > 0) console.log(` excluded, never read: ${skippedDirs.join(", ")}`);
|
|
1233
1282
|
for (const month of months) {
|
|
1234
1283
|
const bucket = byMonth.get(month);
|
package/package.json
CHANGED
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.
|
|
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");
|