@drakulavich/cogload 0.14.0 → 0.14.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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/package.json +4 -5
- package/src/lib/metrics/analyze.ts +15 -1
- package/src/lib/transcripts/cache.io.ts +8 -3
- package/src/lib/transcripts/parse.ts +10 -4
- package/src/lib/types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project are documented here. The format follows
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.14.2] - 2026-10-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Messages from your other Claude Code sessions count as agent reports
|
|
12
|
+
again. Since Claude Code 2.1.280 they had dropped out of the index and the
|
|
13
|
+
card. (#226)
|
|
14
|
+
|
|
15
|
+
## [0.14.1] - 2026-10-17
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Compact summaries, plugin messages, `!` and slash-command output and
|
|
19
|
+
monitor events no longer count as typed prompts, so they cannot extend the
|
|
20
|
+
streak or start a rest. (#221)
|
|
21
|
+
- A session moved to the background no longer counts its copied history a
|
|
22
|
+
second time. (#222)
|
|
23
|
+
|
|
8
24
|
## [0.14.0] - 2026-10-10
|
|
9
25
|
|
|
10
26
|
### Removed
|
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ It also makes you rest. After 40 minutes of work without a ten-minute gap, or in
|
|
|
102
102
|
|
|
103
103
|
## Privacy
|
|
104
104
|
|
|
105
|
-
cogload reads `~/.claude/projects` on your machine and sends nothing anywhere. It keeps, writes and prints no message text, prompt length, file path or session title: what survives from a transcript is timestamps, session ids, event kinds and token counts. The plugin
|
|
105
|
+
cogload reads `~/.claude/projects` on your machine and sends nothing anywhere. It keeps, writes and prints no message text, prompt length, file path or session title: what survives from a transcript is timestamps, session ids, event kinds and token counts. The plugin writes one piece of text to disk, the reason you give for a skip, and holds a prompt it delays in memory until the rest is over. [The reference](docs/reference.md#privacy) lists every file cogload and the plugin write, and [PRIVACY.md](PRIVACY.md) is the privacy policy.
|
|
106
106
|
|
|
107
107
|
## More
|
|
108
108
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakulavich/cogload",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Keep your head cold. A thermometer for your Claude Code days: every hour scored 0 to 100 from the transcripts already on your disk. Nothing leaves your machine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Anton Yakutovich",
|
|
@@ -16,15 +16,14 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "bun run src/cli/index.ts",
|
|
18
18
|
"stats": "bun scripts/signal-stats.ts",
|
|
19
|
-
"test": "TZ=UTC bun test ./tests",
|
|
20
|
-
"typecheck": "
|
|
19
|
+
"test": "TZ=UTC bun test --randomize ./tests",
|
|
20
|
+
"typecheck": "bun --check && bun scripts/typecheck-plugin.ts",
|
|
21
21
|
"lint": "biome ci && knip --include files,exports,types",
|
|
22
22
|
"check": "bun run typecheck && bun run lint && bun run test"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@biomejs/biome": "2.5.14",
|
|
26
26
|
"@types/bun": "^1.4.0",
|
|
27
|
-
"knip": "^6.38.0"
|
|
28
|
-
"typescript": "^7.0.2"
|
|
27
|
+
"knip": "^6.38.0"
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -13,5 +13,19 @@ export function analyze(transcripts: Transcript[], w: Window): Day[] {
|
|
|
13
13
|
|
|
14
14
|
// Events already parsed, concatenated in path order as `analyze` does.
|
|
15
15
|
export function analyzeEvents(events: Event[], w: Window): Day[] {
|
|
16
|
-
return derive(events, w);
|
|
16
|
+
return derive(dropCopies(events), w);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// A background session copies its history under a new session id, times kept
|
|
20
|
+
// to the millisecond (#222); the original never carries `bg`.
|
|
21
|
+
function dropCopies(events: Event[]): Event[] {
|
|
22
|
+
const copies = new Map<number, Event[]>();
|
|
23
|
+
for (const e of events) if (e.bg) copies.set(e.ts, [...(copies.get(e.ts) ?? []), e]);
|
|
24
|
+
if (copies.size === 0) return events;
|
|
25
|
+
const dropped = new Set<Event>();
|
|
26
|
+
for (const e of events) {
|
|
27
|
+
if (e.bg) continue;
|
|
28
|
+
for (const c of copies.get(e.ts) ?? []) if (c.kind === e.kind && c.sessionId !== e.sessionId) dropped.add(c);
|
|
29
|
+
}
|
|
30
|
+
return events.filter((e) => !dropped.has(e));
|
|
17
31
|
}
|
|
@@ -41,6 +41,7 @@ function encode(events: Event[]): Uint8Array {
|
|
|
41
41
|
const rows = events.map((e) => {
|
|
42
42
|
let i = index.get(e.sessionId);
|
|
43
43
|
if (i === undefined) { i = sessions.length; index.set(e.sessionId, i); sessions.push(e.sessionId); }
|
|
44
|
+
if (e.bg) return [e.ts, e.kind, i, e.tokens ?? null, 1];
|
|
44
45
|
return e.tokens === undefined ? [e.ts, e.kind, i] : [e.ts, e.kind, i, e.tokens];
|
|
45
46
|
});
|
|
46
47
|
return new TextEncoder().encode(JSON.stringify({ sessions, events: rows }));
|
|
@@ -54,11 +55,15 @@ function decode(blob: Uint8Array): Event[] | null {
|
|
|
54
55
|
if (!Array.isArray(sessions) || !sessions.every((s) => typeof s === "string") || !Array.isArray(events)) return null;
|
|
55
56
|
const out: Event[] = [];
|
|
56
57
|
for (const r of events) {
|
|
57
|
-
if (!Array.isArray(r) || r.length < 3 || r.length >
|
|
58
|
-
const [ts, kind, i, tokens] = r as unknown[];
|
|
58
|
+
if (!Array.isArray(r) || r.length < 3 || r.length > 5) return null;
|
|
59
|
+
const [ts, kind, i, tokens, bg] = r as unknown[];
|
|
59
60
|
if (typeof ts !== "number" || typeof kind !== "string" || !Object.hasOwn(KINDS, kind) || typeof i !== "number" || sessions[i] === undefined) return null;
|
|
60
61
|
const e: Event = { ts, sessionId: sessions[i] as string, kind: kind as EventKind };
|
|
61
|
-
if (r.length ===
|
|
62
|
+
if (r.length === 5) {
|
|
63
|
+
if (bg !== 1) return null;
|
|
64
|
+
e.bg = true;
|
|
65
|
+
}
|
|
66
|
+
if (r.length === 4 || (r.length === 5 && tokens !== null)) {
|
|
62
67
|
if (kind !== "output" || typeof tokens !== "number") return null;
|
|
63
68
|
e.tokens = tokens;
|
|
64
69
|
}
|
|
@@ -13,7 +13,10 @@ const AGENT_MARKERS = [
|
|
|
13
13
|
"<cross-session-message",
|
|
14
14
|
"<task-notification>",
|
|
15
15
|
"[Cross-session",
|
|
16
|
+
"<ci-monitor-event>",
|
|
16
17
|
];
|
|
18
|
+
// Echoes of a command the human typed: the command itself is the prompt.
|
|
19
|
+
const OUTPUT_MARKERS = ["<bash-stdout>", "<local-command-stdout>"];
|
|
17
20
|
|
|
18
21
|
type Rec = Record<string, unknown>;
|
|
19
22
|
const isObj = (v: unknown): v is Rec => typeof v === "object" && v !== null;
|
|
@@ -91,6 +94,7 @@ export function parseTranscript(text: string, cutoffMs = -Infinity): Event[] {
|
|
|
91
94
|
const ts = Date.parse(str(rec.timestamp) ?? "");
|
|
92
95
|
if (Number.isNaN(ts)) continue;
|
|
93
96
|
lastTs = ts;
|
|
97
|
+
const first = events.length;
|
|
94
98
|
events.push({ ts, sessionId, kind: "activity" });
|
|
95
99
|
for (; pendingModeChanges > 0; pendingModeChanges--) events.push({ ts, sessionId, kind: "mode_change" });
|
|
96
100
|
|
|
@@ -105,10 +109,11 @@ export function parseTranscript(text: string, cutoffMs = -Infinity): Event[] {
|
|
|
105
109
|
if (toolUseId !== null && askedIds.has(toolUseId)) events.push({ ts, sessionId, kind: "answer" });
|
|
106
110
|
}
|
|
107
111
|
const head = firstText(content);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
// Claude Code 2.1.280+ marks a message from another session `isMeta` (#226).
|
|
113
|
+
const peer = isObj(rec.origin) && rec.origin.kind === "peer";
|
|
114
|
+
if (head?.startsWith(INTERRUPT_PREFIX)) events.push({ ts, sessionId, kind: "interrupt" });
|
|
115
|
+
else if (head !== null && (rec.isMeta !== true || peer) && rec.isCompactSummary !== true && !OUTPUT_MARKERS.some((marker) => head.startsWith(marker))) {
|
|
116
|
+
if (peer || rec.promptSource === "system" || AGENT_MARKERS.some((marker) => head.startsWith(marker))) events.push({ ts, sessionId, kind: "report" });
|
|
112
117
|
else events.push({ ts, sessionId, kind: "prompt" });
|
|
113
118
|
}
|
|
114
119
|
} else {
|
|
@@ -133,6 +138,7 @@ export function parseTranscript(text: string, cutoffMs = -Infinity): Event[] {
|
|
|
133
138
|
events.push({ ts, sessionId, kind: "output", tokens });
|
|
134
139
|
}
|
|
135
140
|
}
|
|
141
|
+
if (rec.sessionKind === "bg") for (let i = first; i < events.length; i++) if (events[i]!.kind !== "mode_change") events[i]!.bg = true;
|
|
136
142
|
}
|
|
137
143
|
return events;
|
|
138
144
|
}
|
package/src/lib/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type EventKind = "prompt" | "report" | "output" | "interrupt" | "reject" | "answer" | "question" | "plan_review" | "mode_change" | "activity";
|
|
2
|
-
export type Event = { ts: number; sessionId: string; kind: EventKind; tokens?: number };
|
|
2
|
+
export type Event = { ts: number; sessionId: string; kind: EventKind; tokens?: number; bg?: true };
|
|
3
3
|
export type Transcript = { path: string; text: string };
|
|
4
4
|
// to = "YYYY-MM-DD" local. `streakFrom` reads further back than the 3 h look-back,
|
|
5
5
|
// for `presence` only: the live streak is traced to its first action, up to it.
|