agent-dag 1.15.4 → 1.15.6

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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>agent-dag</title>
7
7
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='84' font-size='84'%3E%E2%97%89%3C/text%3E%3C/svg%3E" />
8
- <script type="module" crossorigin src="/assets/index-BPyjn8Kd.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-LqGanb3A.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-Bwj0xSAo.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-dag",
3
- "version": "1.15.4",
3
+ "version": "1.15.6",
4
4
  "description": "Live DAG of Claude Code agents — watch parallel subagents fork, call tools, and return on one calm canvas.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -256,7 +256,21 @@ async function readContextFromTranscript(path) {
256
256
  let buf;
257
257
  try { buf = Buffer.alloc(s.size); await fh.read(buf, 0, s.size, 0); }
258
258
  finally { await fh.close(); }
259
- const text = buf.toString("utf8");
259
+ const fullText = buf.toString("utf8");
260
+ // CC `/clear` writes a user message `<command-name>/clear</command-name>`
261
+ // into the same transcript file and resets its in-memory context window
262
+ // to ~0, but the JSONL keeps growing — every usage block before the
263
+ // clear marker is stale (pre-reset) and reading the LAST one made the
264
+ // donut report ~100% even though CC's actual context was empty. Same
265
+ // applies to `/compact`: it writes a summary and starts a fresh context.
266
+ // Slice the transcript to the segment AFTER the most recent reset so
267
+ // counts/usage reflect what CC is actually carrying forward.
268
+ const resetRe = /<command-name>\s*\/(?:clear|compact)\s*<\/command-name>/g;
269
+ let lastResetIdx = -1;
270
+ for (const m of fullText.matchAll(resetRe)) {
271
+ lastResetIdx = (m.index ?? -1) + m[0].length;
272
+ }
273
+ const text = lastResetIdx >= 0 ? fullText.slice(lastResetIdx) : fullText;
260
274
  const breakdown = {
261
275
  msgsUser: 0,
262
276
  msgsAssistant: 0,
@@ -271,9 +285,9 @@ async function readContextFromTranscript(path) {
271
285
  breakdown.toolResults = (text.match(/"type"\s*:\s*"tool_result"/g) ?? []).length;
272
286
  breakdown.systemReminders = (text.match(/<system-reminder>/g) ?? []).length;
273
287
  // Current context size = input + cache_read + cache_create on the LAST
274
- // usage block. Each assistant message's usage describes the context
275
- // window for THAT call; summing across calls double-counts cached
276
- // prefixes and explodes past the real ceiling. Take the most recent.
288
+ // usage block in the post-reset slice. If the user just ran /clear and
289
+ // hasn't sent a new prompt yet, this stays 0 (no usage blocks yet) —
290
+ // matches what CC's own `/context` would report.
277
291
  const re = /"usage"\s*:\s*\{([^}]+)\}/g;
278
292
  const grab = (blob, key) => {
279
293
  const km = blob.match(new RegExp(`"${key}"\\s*:\\s*(\\d+)`));