taskplane 0.23.9 → 0.23.11

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.
@@ -14,8 +14,21 @@ import { fileURLToPath } from "node:url";
14
14
  import { dirname, join } from "node:path";
15
15
 
16
16
  const __dirname = dirname(fileURLToPath(import.meta.url));
17
- // TP-115: Disable jiti filesystem cache to prevent stale compiled code
18
- // after npm update. Without this, jiti serves old cached .mjs even when
19
- // the .ts source files have been updated by a new package version.
20
- const jiti = createJiti(import.meta.url, { cache: false });
17
+
18
+ // TP-115: Purge jiti cache for taskplane modules before loading.
19
+ // Pi's main process caches compiled .ts .mjs at $TEMP/jiti/.
20
+ // The engine-worker fork must compile fresh from current source files,
21
+ // not use stale cached versions from Pi's startup.
22
+ import { readdirSync, unlinkSync } from "node:fs";
23
+ import { tmpdir } from "node:os";
24
+ try {
25
+ const cacheDir = join(tmpdir(), "jiti");
26
+ for (const f of readdirSync(cacheDir)) {
27
+ if (f.startsWith("taskplane-") && f.endsWith(".mjs")) {
28
+ try { unlinkSync(join(cacheDir, f)); } catch {}
29
+ }
30
+ }
31
+ } catch { /* cache dir may not exist */ }
32
+
33
+ const jiti = createJiti(import.meta.url);
21
34
  await jiti.import(join(__dirname, "engine-worker.ts"));
@@ -2267,9 +2267,8 @@ export async function executeOrchBatch(
2267
2267
  const snap = JSON.parse(readFileSync(join(lanesDir, f), "utf-8"));
2268
2268
  const w = snap.worker || {};
2269
2269
  const r = snap.reviewer || {};
2270
- // Key by session name (match lane record) for per-task lookup
2271
- const laneRec = batchState.lanes.find((l: { laneNumber: number }) => l.laneNumber === snap.laneNumber);
2272
- const key = laneRec?.tmuxSessionName || `lane-${snap.laneNumber}`;
2270
+ // Key by lane number for reliable per-task lookup (TP-115)
2271
+ const key = `lane-${snap.laneNumber}`;
2273
2272
  laneTokens.set(key, {
2274
2273
  input: (w.inputTokens || 0) + (r.inputTokens || 0),
2275
2274
  output: (w.outputTokens || 0) + (r.outputTokens || 0),
@@ -2282,6 +2281,7 @@ export async function executeOrchBatch(
2282
2281
  }
2283
2282
  } catch { /* runtime dir may not exist */ }
2284
2283
 
2284
+
2285
2285
  // Legacy fallback: lane-state-*.json sidecars (only if V2 found nothing)
2286
2286
  if (laneTokens.size === 0) {
2287
2287
  try {
@@ -2320,9 +2320,9 @@ export async function executeOrchBatch(
2320
2320
  const durationMs = (to.startTime && to.endTime) ? (to.endTime - to.startTime) : 0;
2321
2321
 
2322
2322
  // Get tokens for this lane (cumulative — shared across tasks in same lane)
2323
- // TP-115: V2 sessionName includes role suffix (-worker/-reviewer) but
2324
- // laneTokens is keyed by tmuxSessionName (no suffix). Try both.
2325
- const tokens = laneTokens.get(to.sessionName)
2323
+ // TP-115: Try lane number key first (V2), then sessionName variants (legacy).
2324
+ const tokens = laneTokens.get(`lane-${lane}`)
2325
+ || laneTokens.get(to.sessionName)
2326
2326
  || laneTokens.get(to.sessionName?.replace(/-(?:worker|reviewer)$/, ""))
2327
2327
  || { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, costUsd: 0 };
2328
2328
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskplane",
3
- "version": "0.23.9",
3
+ "version": "0.23.11",
4
4
  "description": "AI agent orchestration for pi — parallel task execution with checkpoint discipline",
5
5
  "keywords": [
6
6
  "pi-package",