taskplane 0.17.0 → 0.18.0

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.
@@ -462,8 +462,11 @@ function loadTelemetryData(batchState) {
462
462
  ? (usage.cost.total || 0)
463
463
  : (typeof usage.cost === "number" ? usage.cost : 0);
464
464
  }
465
- const totalTokens = usage.totalTokens
465
+ // Include cacheRead: totalTokens from pi excludes cache reads,
466
+ // but cached tokens still consume context window capacity.
467
+ const rawTotal = usage.totalTokens
466
468
  || ((usage.input || 0) + (usage.output || 0));
469
+ const totalTokens = rawTotal + (usage.cacheRead || 0);
467
470
  if (totalTokens > acc.latestTotalTokens) {
468
471
  acc.latestTotalTokens = totalTokens;
469
472
  }
@@ -1204,7 +1204,10 @@ function spawnAgent(opts: {
1204
1204
  // Use totalTokens (cumulative) — works across providers.
1205
1205
  // Anthropic reports small `input` per-turn but growing `totalTokens`.
1206
1206
  // OpenAI reports growing `input` but also growing `totalTokens`.
1207
- const tokens = (usage as any).totalTokens || ((usage as any).input + (usage as any).output) || 0;
1207
+ // Include cacheRead: pi's totalTokens excludes cache reads,
1208
+ // but cached tokens still consume context window capacity.
1209
+ const rawTokens = (usage as any).totalTokens || ((usage as any).input + (usage as any).output) || 0;
1210
+ const tokens = rawTokens + ((usage as any).cacheRead || 0);
1208
1211
  if (tokens > 0) {
1209
1212
  const pct = (tokens / opts.contextWindow) * 100;
1210
1213
  opts.onContextPct?.(pct);
@@ -1380,9 +1383,13 @@ function tailSidecarJsonl(filePath: string, tailState: SidecarTailState): Sideca
1380
1383
  ? (usage.cost.total || 0)
1381
1384
  : (typeof usage.cost === "number" ? usage.cost : 0);
1382
1385
  }
1383
- // totalTokens is cumulative (grows each turn) — use latest value
1384
- const totalTokens = usage.totalTokens
1386
+ // totalTokens is cumulative (grows each turn) — use latest value.
1387
+ // Include cacheRead tokens: pi's totalTokens and the
1388
+ // input+output fallback both exclude cache reads, but cached
1389
+ // tokens still consume context window capacity.
1390
+ const rawTotal = usage.totalTokens
1385
1391
  || ((usage.input || 0) + (usage.output || 0));
1392
+ const totalTokens = rawTotal + (usage.cacheRead || 0);
1386
1393
  if (totalTokens > delta.latestTotalTokens) {
1387
1394
  delta.latestTotalTokens = totalTokens;
1388
1395
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskplane",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "AI agent orchestration for pi — parallel task execution with checkpoint discipline",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -19,6 +19,7 @@ name: task-worker
19
19
  - Review protocol (inline reviews via review_step tool when available)
20
20
  - Review response handling
21
21
  - Test execution strategy (targeted tests during steps, full suite at gate)
22
+ - File reading strategy (grep-first for large files, context budget awareness)
22
23
 
23
24
  Add project-specific rules below. Common examples:
24
25
  - Preferred package manager (pnpm, yarn, bun)
@@ -265,4 +265,41 @@ checkpoints protect against regressions even when intermediate steps use targete
265
265
  2. The merge agent (before merging to the orchestrator branch)
266
266
  3. CI (before merging to main)
267
267
 
268
+ ## File Reading Strategy (Context Budget)
269
+
270
+ Your context window is finite. Reading large files whole wastes budget and risks
271
+ triggering the context-pressure safety net (85% → wrap-up, 95% → kill).
272
+ Use targeted reads instead:
273
+
274
+ ### Pattern: grep-first, read-with-offset
275
+
276
+ 1. **Locate** the relevant section with `grep` or `find`:
277
+ ```
278
+ grep -n "function buildPrompt" extensions/task-runner.ts
279
+ ```
280
+ 2. **Read** just that region with `offset` and `limit`:
281
+ ```
282
+ read extensions/task-runner.ts (offset: 1773, limit: 50)
283
+ ```
284
+ 3. **Edit** surgically with exact `oldText → newText`
285
+
286
+ ### When to read a full file
287
+
288
+ - Files under ~500 lines — read the whole thing, it's fine
289
+ - Config files, test files, templates — usually small enough to read fully
290
+ - New files you're creating — read after writing to verify
291
+
292
+ ### When NOT to read a full file
293
+
294
+ - Source files over ~1000 lines — grep first, read the relevant region
295
+ - Generated files, lock files, large data files — almost never need full reads
296
+ - Files you've already read this session — re-read only the changed region
297
+
298
+ ### Getting a file outline
299
+
300
+ To understand a large file's structure without reading it all:
301
+ ```bash
302
+ grep -n "^function\|^export\|^class\|^interface\|^const.*=" file.ts | head -50
303
+ ```
304
+
268
305