@brainervirus/workit-core 8.5.2 → 8.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-core",
3
- "version": "8.5.2",
3
+ "version": "8.6.0",
4
4
  "private": false,
5
5
  "description": "Workit shared core — task, policy, evidence, review, decision, worker, and writer state for agentic coding workflows",
6
6
  "keywords": [
@@ -291,11 +291,11 @@ export const turnContextText = (input: HookInput, descriptor: HostDescriptor): s
291
291
  }
292
292
  };
293
293
 
294
- // Change-only per-turn context. A hook-process host (Claude Code, Codex)
295
- // keeps each injected additionalContext in the transcript, so the task
296
- // context is resent only when it changed since the last injection for the
297
- // session. Each hook is a fresh process: the last digest lives in the
298
- // workspace store (`hooks/turn-<session hash>.json`). Every cache failure
294
+ // Change-only per-turn context. Claude Code, Codex and Pi keep each injected
295
+ // context in the transcript, so the task context is resent only when it
296
+ // changed since the last injection for the session. Each hook is a fresh
297
+ // process (and a Pi session can resume in another one): the last digest
298
+ // lives in the workspace store (`hooks/turn-<session hash>.json`). Every cache failure
299
299
  // answers "changed", so context is resent rather than lost.
300
300
 
301
301
  const TURN_TTL_MS = 7 * 24 * 60 * 60 * 1000;
@@ -376,13 +376,17 @@ export const changedTurnContext = (input: HookInput, text: string | null): strin
376
376
  * A session start already injects the task context (inside the contract), so
377
377
  * the per-turn digest is seeded with what the next prompt would carry: the
378
378
  * first turn after a start, resume or compaction does not resend it. A
379
- * session without task context clears its digest instead.
379
+ * session without task context clears its digest instead. An in-process
380
+ * host that renders its own per-turn `text` seeds with it.
380
381
  */
381
- export const seedTurnContext = (input: HookInput, descriptor: HostDescriptor): void => {
382
+ export const seedTurnContext = (
383
+ input: HookInput,
384
+ descriptor: HostDescriptor,
385
+ text: string | null = turnContextText(input, descriptor),
386
+ ): void => {
382
387
  const file = turnMarker(input);
383
388
  if (!file) return;
384
389
  pruneTurnDigests(path.dirname(file), Date.now());
385
- const text = turnContextText(input, descriptor);
386
390
  if (text) writeTurnDigest(file, digestOf(text));
387
391
  else clearTurnDigest(file);
388
392
  };
@@ -58,9 +58,8 @@ export const CLAUDE_CODE_DESCRIPTOR: HostDescriptor = {
58
58
  perTurn: "native",
59
59
  afterCompact: "native",
60
60
  task: "session-bound",
61
- // The plugin's src/hook.ts dedups per-turn context itself (its own cache)
62
- // until it moves onto the core's on-change resend.
63
- turnResend: "every-turn",
61
+ // Each additionalContext stays in the transcript: resend only on change.
62
+ turnResend: "on-change",
64
63
  },
65
64
  subagents: {
66
65
  identity: "native",
@@ -24,12 +24,12 @@ export const PI_DESCRIPTOR: HostDescriptor = {
24
24
  shellPolicy: { deny: "native", channel: "block", failClosed: false },
25
25
  context: {
26
26
  sessionStart: "native",
27
- // before_agent_start runs every turn, but the extension injects the task
28
- // context once per session and again after compaction, never on change.
29
- perTurn: "partial",
27
+ // before_agent_start runs every turn; its message stays in the session,
28
+ // so the extension resends the task context only when it changed.
29
+ perTurn: "native",
30
30
  afterCompact: "native",
31
31
  task: "session-bound",
32
- turnResend: "per-session",
32
+ turnResend: "on-change",
33
33
  },
34
34
  subagents: {
35
35
  identity: "none",
@@ -9,7 +9,9 @@ export {
9
9
  type Support,
10
10
  } from "./descriptor";
11
11
  export {
12
+ changedTurnContext,
12
13
  currentTaskEntry,
14
+ seedTurnContext,
13
15
  sessionCompactContext,
14
16
  sessionContextText,
15
17
  turnContextText,