@cortexkit/opencode-magic-context 0.3.2 → 0.3.4

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.
Files changed (27) hide show
  1. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  2. package/dist/features/magic-context/dreamer/queue.d.ts.map +1 -1
  3. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -1
  4. package/dist/features/magic-context/dreamer/scheduler.d.ts +1 -1
  5. package/dist/features/magic-context/dreamer/scheduler.d.ts.map +1 -1
  6. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  7. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -0
  8. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  9. package/dist/features/magic-context/types.d.ts +1 -0
  10. package/dist/features/magic-context/types.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -1
  12. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  14. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/read-session-formatting.d.ts +3 -0
  17. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
  21. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/transform.d.ts +1 -0
  23. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  24. package/dist/index.js +143 -24
  25. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  26. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  27. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GACR,UAAU,GACV,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,eAAe,CAAC;AAoLtB;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOlF;AAED,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,EACvB,cAAc,UAAQ,GACvB,MAAM,CAUR"}
1
+ {"version":3,"file":"magic-context-prompt.d.ts","sourceRoot":"","sources":["../../src/agents/magic-context-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GACR,UAAU,GACV,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,eAAe,CAAC;AA4LtB;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOlF;AAED,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,aAAa,EAAE,MAAM,EACrB,gBAAgB,UAAO,EACvB,cAAc,UAAQ,GACvB,MAAM,CAUR"}
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI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ClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;CACP;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACjC,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,6FAA6F;IAC7F,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,cAAc,CAAC,CAkO1B;AAwLD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC1C,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAuDjC"}
@@ -10,7 +10,7 @@ export declare function parseScheduleWindow(schedule: string): {
10
10
  } | null;
11
11
  /** Check if the current time is inside the schedule window. Handles overnight windows (e.g. 23:00-05:00). */
12
12
  export declare function isInScheduleWindow(schedule: string, now?: Date): boolean;
13
- /** Find projects that have memory updates since their per-project last dream time. */
13
+ /** Find projects that have memory updates or pending smart notes since their per-project last dream time. */
14
14
  export declare function findProjectsNeedingDream(db: Database): string[];
15
15
  /**
16
16
  * Check schedule and enqueue eligible projects.
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,GACjB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBrD;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAYpF;AAED,sFAAsF;AACtF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,EAAE,CA4B/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwB9E"}
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,GACjB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBrD;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAYpF;AAED,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,EAAE,CAyC/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwB9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAwPrD;AA6BD,wBAAgB,YAAY,IAAI,QAAQ,CAqCvC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAyPrD;AA6BD,wBAAgB,YAAY,IAAI,QAAQ,CAqCvC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -14,6 +14,7 @@ export interface SessionMetaRow {
14
14
  times_execute_threshold_reached: number;
15
15
  compartment_in_progress: number;
16
16
  system_prompt_hash: string | number;
17
+ system_prompt_tokens: number;
17
18
  cleared_reasoning_through_tag: number;
18
19
  }
19
20
  export declare const META_COLUMNS: Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"storage-meta-shared.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-meta-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+BAA+B,EAAE,MAAM,CAAC;IACxC,uBAAuB,EAAE,MAAM,CAAC;IAGhC,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,6BAA6B,EAAE,MAAM,CAAC;CACzC;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAc/C,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAmD,CAAC;AAElF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAmBpE;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAiBpE;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAoB9D"}
1
+ {"version":3,"file":"storage-meta-shared.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-meta-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+BAA+B,EAAE,MAAM,CAAC;IACxC,uBAAuB,EAAE,MAAM,CAAC;IAGhC,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6BAA6B,EAAE,MAAM,CAAC;CACzC;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAe/C,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAmD,CAAC;AAElF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAoBpE;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAkBpE;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAqB9D"}
@@ -28,6 +28,7 @@ export interface SessionMeta {
28
28
  timesExecuteThresholdReached: number;
29
29
  compartmentInProgress: boolean;
30
30
  systemPromptHash: string;
31
+ systemPromptTokens: number;
31
32
  clearedReasoningThroughTag: number;
32
33
  }
33
34
  export type SchedulerDecision = "execute" | "defer";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC;IAC7D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,4BAA4B,EAAE,MAAM,CAAC;IACrC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,0BAA0B,EAAE,MAAM,CAAC;CACtC;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;A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iB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACvB"}
@@ -1,4 +1,4 @@
1
- export declare const COMPARTMENT_AGENT_SYSTEM_PROMPT = "You condense long AI coding sessions into two outputs:\n\n1. compartments: completed logical work units\n2. facts: persistent cross-cutting information for future work\n\nCompartment rules:\n- A compartment is one contiguous completed work unit: investigation, fix, refactor, docs update, feature, or decision.\n- Start a new compartment only when the work clearly pivots to a different objective.\n- Do not create compartments for magic-context commands or tool-only noise.\n- If the input ends mid-topic, leave it out and report its first message index in <unprocessed_from>.\n- All compartment start/end ordinals and <unprocessed_from> must use the absolute raw message numbers shown in the input. Never renumber relative to this chunk.\n- Only emit NEW compartments for the new messages. Do not re-emit existing compartments from the existing state.\n- Write comprehensive, detailed compartments. Include file paths, function names, commit hashes, config keys, and values when they matter.\n- Do not list every changed file. Do not narrate tool calls. Do not preserve dead-end exploration beyond a brief clause when needed.\n\nUser message preservation:\n- Include high-signal user messages verbatim inside compartments, prefixed with U:.\n- A high-signal user message states a goal, constraint, design decision, direction, preference, or rationale.\n- Drop trivial messages: yes, continue, I agree, thanks, looks good, go ahead, and similar low-signal steering.\n- Drop large pasted text unless it contains durable rules or requirements; summarize its gist instead.\n- Place U: lines at the point in the summary where the user's direction changed the work.\n- Limit to 3-5 U: lines per compartment \u2014 keep only the most important ones.\n\nCompartment example:\n<compartment start=\"50\" end=\"120\" title=\"Built the LSP stack\">\nU: We need inline diagnostics on every edit, not just on-demand\nImplemented in-process LSP client with per-server reader threads and crossbeam-channel delivery. Added inline edit diagnostics to write, edit, and apply_patch. commits: a3f891, b22c4e\nU: Ship this as 0.2.0\nUpdated docs and publish automation, released v0.2.0.\n</compartment>\n\nFact rules:\n- Facts are editable state, not append-only notes. Rewrite, normalize, deduplicate, or drop existing facts whenever needed.\n- Before emitting any fact, check all existing facts in the same category for semantic duplicates. If two facts describe the same decision, constraint, or default with different wording, merge them into one canonical statement. Never emit two facts that could be answered by the same question.\n- When project memories are provided as read-only reference, drop any session fact that is already covered by a project memory. Project memories are the canonical cross-session source; session facts must not duplicate them.\n- Facts must be durable and actionable after the conversation ends.\n- A fact is either a stable invariant/default or a reusable operating rule. If it mainly explains what happened, it belongs in a compartment, not a fact.\n- Facts belong only in these categories when relevant: WORKFLOW_RULES, ARCHITECTURE_DECISIONS, CONSTRAINTS, CONFIG_DEFAULTS, KNOWN_ISSUES, ENVIRONMENT, NAMING, USER_PREFERENCES, USER_DIRECTIVES.\n- Keep only high-signal facts. Omit greetings, acknowledgements, temporary status, one-off sequencing, branch-local tactics, and task-local cleanup notes.\n- When a user message carries durable goals, constraints, preferences, or decision rationale, add a USER_DIRECTIVES fact when future agents should follow it after the session is compacted.\n- Do not turn task-local details into facts.\n- Do not keep stale facts. Rewrite or drop them even if the new input only implies they are obsolete.\n- Keep existing ARCHITECTURE_DECISIONS and CONSTRAINTS facts when they are still valid and uncontradicted; rewrite them into canonical form instead of dropping them.\n- Facts must be present tense and operational. Do not use chronology or provenance wording such as: initially, currently, remained, previously, later, then, was implemented, we changed, used to.\n- One fact bullet must contain exactly one rule/default/constraint/preference. If a candidate fact mixes history with guidance, keep the guidance and drop the history.\n- Durability test: a future agent should still act correctly on the fact next session, after merge/restart, without rereading the conversation.\n- Category guide:\n - WORKFLOW_RULES: standing repeatable process only. Prefer Do/When form: When <condition>, <action>. Do not store one-off branch strategy or task-specific sequencing unless it is standing policy.\n - ARCHITECTURE_DECISIONS: stable design choice. Use: <component> uses <choice> because <reason>.\n - CONSTRAINTS: hard must/must-not rule or invariant. Use: <thing> must/must not <action> because <reason>.\n - CONFIG_DEFAULTS: stable default only. Use: <key>=<value>.\n - KNOWN_ISSUES: unresolved recurring problem only. Do not store solved-issue stories.\n - ENVIRONMENT: stable setup fact that affects future work.\n - NAMING: canonical term choice. Use: Use <term>; avoid <term>.\n - USER_PREFERENCES: durable user preference. Prefer Do/When form.\n - USER_DIRECTIVES: durable user-stated goal, constraint, preference, or rationale. Keep the user's wording when it carries meaning, but narrow it to 1-3 sentences and remove filler.\n- Fact dedup examples:\n - These are DUPLICATES (merge into one): \"Plugin config uses layered JSONC files\" and \"AFT plugin config uses layered JSONC files at ~/.config/opencode/aft.jsonc and <project>/.opencode/aft.jsonc, with project values deep-merging over user values.\" \u2192 keep the longer, more specific version only.\n - These are NOT duplicates (keep both): \"AFT uses 1-based line numbers\" and \"AFT converts to LSP 0-based UTF-16 at the protocol boundary\" \u2192 different aspects of the same system.\n- Fact rewrite examples:\n - Bad ARCHITECTURE_DECISIONS: The new tool-heavy `ctx_reduce` reminder was initially implemented as a hidden instruction appended to the latest user message in `transform`.\n - Good ARCHITECTURE_DECISIONS: `ctx_reduce` turn reminders are injected into the latest user message in `transform`.\n - Bad WORKFLOW_RULES: Current local workflow remained feat -> integrate -> build for code changes.\n - Good WORKFLOW_RULES (only if this is standing policy): For magic-context changes, commit on `feat/magic-context`, cherry-pick to `integrate/athena-magic-context`, run `bun run build` on integrate, then return to `feat/magic-context`.\n\nInput notes:\n- [N] or [N-M] is a stable raw OpenCode message range.\n- U: means user.\n- A: means assistant.\n- commits: ... on an assistant block lists commit hashes mentioned in that work unit; keep the relevant ones in the compartment summary when they matter.\n- Tool-only noise is already stripped before you see the input.\n\nOutput valid XML only in this shape:\n<output>\n<compartments>\n<compartment start=\"FIRST\" end=\"LAST\" title=\"short title\">\nU: Verbatim high-signal user message\nSummary text describing what was done and why.\nU: Another high-signal user message if applicable\nMore summary text.\n</compartment>\n</compartments>\n<facts>\n<WORKFLOW_RULES>\n* Fact text\n</WORKFLOW_RULES>\n</facts>\n<meta>\n<messages_processed>FIRST-LAST</messages_processed>\n<unprocessed_from>INDEX</unprocessed_from>\n</meta>\n</output>\n\nOmit empty fact categories. Compartments must be ordered, contiguous for the ranges they cover, and non-overlapping.";
1
+ export declare const COMPARTMENT_AGENT_SYSTEM_PROMPT = "You condense long AI coding sessions into two outputs:\n\n1. compartments: completed logical work units\n2. facts: persistent cross-cutting information for future work\n\nCompartment rules:\n- A compartment is one contiguous completed work unit: investigation, fix, refactor, docs update, feature, or decision.\n- Start a new compartment only when the work clearly pivots to a different objective.\n- Do not create compartments for magic-context commands or tool-only noise.\n- If the input ends mid-topic, leave it out and report its first message index in <unprocessed_from>.\n- All compartment start/end ordinals and <unprocessed_from> must use the absolute raw message numbers shown in the input. Never renumber relative to this chunk.\n- Only emit NEW compartments for the new messages. Do not re-emit existing compartments from the existing state.\n- Write comprehensive, detailed compartments. Include file paths, function names, commit hashes, config keys, and values when they matter.\n- Do not list every changed file. Do not narrate tool calls. Do not preserve dead-end exploration beyond a brief clause when needed.\n\nUser message preservation:\n- Include high-signal user messages verbatim inside compartments, prefixed with U:.\n- A high-signal user message states a goal, constraint, design decision, direction, preference, or rationale.\n- Drop trivial messages: yes, continue, I agree, thanks, looks good, go ahead, and similar low-signal steering.\n- Drop large pasted text unless it contains durable rules or requirements; summarize its gist instead.\n- Place U: lines at the point in the summary where the user's direction changed the work.\n- Limit to 3-5 U: lines per compartment \u2014 keep only the most important ones.\n\nCompartment example:\n<compartment start=\"50\" end=\"120\" title=\"Built the LSP stack\">\nU: We need inline diagnostics on every edit, not just on-demand\nImplemented in-process LSP client with per-server reader threads and crossbeam-channel delivery. Added inline edit diagnostics to write, edit, and apply_patch. commits: a3f891, b22c4e\nU: Ship this as 0.2.0\nUpdated docs and publish automation, released v0.2.0.\n</compartment>\n\nFact rules:\n- Facts are editable state, not append-only notes. Rewrite, normalize, deduplicate, or drop existing facts whenever needed.\n- Before emitting any fact, check all existing facts in the same category for semantic duplicates. If two facts describe the same decision, constraint, or default with different wording, merge them into one canonical statement. Never emit two facts that could be answered by the same question.\n- When project memories are provided as read-only reference, drop any session fact that is already covered by a project memory. Project memories are the canonical cross-session source; session facts must not duplicate them.\n- Facts must be durable and actionable after the conversation ends.\n- A fact is either a stable invariant/default or a reusable operating rule. If it mainly explains what happened, it belongs in a compartment, not a fact.\n- Facts belong only in these categories when relevant: WORKFLOW_RULES, ARCHITECTURE_DECISIONS, CONSTRAINTS, CONFIG_DEFAULTS, KNOWN_ISSUES, ENVIRONMENT, NAMING, USER_PREFERENCES, USER_DIRECTIVES.\n- Keep only high-signal facts. Omit greetings, acknowledgements, temporary status, one-off sequencing, branch-local tactics, and task-local cleanup notes.\n- When a user message carries durable goals, constraints, preferences, or decision rationale, add a USER_DIRECTIVES fact when future agents should follow it after the session is compacted.\n- Do not turn task-local details into facts.\n- Do not keep stale facts. Rewrite or drop them even if the new input only implies they are obsolete.\n- Keep existing ARCHITECTURE_DECISIONS and CONSTRAINTS facts when they are still valid and uncontradicted; rewrite them into canonical form instead of dropping them.\n- Facts must be present tense and operational. Do not use chronology or provenance wording such as: initially, currently, remained, previously, later, then, was implemented, we changed, used to.\n- One fact bullet must contain exactly one rule/default/constraint/preference. If a candidate fact mixes history with guidance, keep the guidance and drop the history.\n- Durability test: a future agent should still act correctly on the fact next session, after merge/restart, without rereading the conversation.\n- Category guide:\n - WORKFLOW_RULES: standing repeatable process only. Prefer Do/When form: When <condition>, <action>. Do not store one-off branch strategy or task-specific sequencing unless it is standing policy.\n - ARCHITECTURE_DECISIONS: stable design choice. Use: <component> uses <choice> because <reason>.\n - CONSTRAINTS: hard must/must-not rule or invariant. Use: <thing> must/must not <action> because <reason>.\n - CONFIG_DEFAULTS: stable default only. Use: <key>=<value>.\n - KNOWN_ISSUES: unresolved recurring problem only. Do not store solved-issue stories.\n - ENVIRONMENT: stable setup fact that affects future work.\n - NAMING: canonical term choice. Use: Use <term>; avoid <term>.\n - USER_PREFERENCES: durable user preference. Prefer Do/When form.\n - USER_DIRECTIVES: durable user-stated goal, constraint, preference, or rationale. Keep the user's wording when it carries meaning, but narrow it to 1-3 sentences and remove filler.\n- Fact dedup examples:\n - These are DUPLICATES (merge into one): \"Plugin config uses layered JSONC files\" and \"AFT plugin config uses layered JSONC files at ~/.config/opencode/aft.jsonc and <project>/.opencode/aft.jsonc, with project values deep-merging over user values.\" \u2192 keep the longer, more specific version only.\n - These are NOT duplicates (keep both): \"AFT uses 1-based line numbers\" and \"AFT converts to LSP 0-based UTF-16 at the protocol boundary\" \u2192 different aspects of the same system.\n- Fact rewrite examples:\n - Bad ARCHITECTURE_DECISIONS: The new tool-heavy `ctx_reduce` reminder was initially implemented as a hidden instruction appended to the latest user message in `transform`.\n - Good ARCHITECTURE_DECISIONS: `ctx_reduce` turn reminders are injected into the latest user message in `transform`.\n - Bad WORKFLOW_RULES: Current local workflow remained feat -> integrate -> build for code changes.\n - Good WORKFLOW_RULES (only if this is standing policy): For magic-context changes, commit on `feat/magic-context`, cherry-pick to `integrate/athena-magic-context`, run `bun run build` on integrate, then return to `feat/magic-context`.\n\nInput notes:\n- [N] or [N-M] is a stable raw OpenCode message range.\n- U: means user.\n- A: means assistant.\n- TC: means tool call \u2014 a compact summary of what the agent did (e.g., \"TC: Fix lint errors\", \"TC: read(src/index.ts)\", \"TC: grep(ctx_memory)\"). TC lines appear when there is no text describing the action. Use them to understand what happened between text blocks, but do not copy them verbatim into compartments \u2014 incorporate their meaning into the narrative.\n- commits: ... on an assistant block lists commit hashes mentioned in that work unit; keep the relevant ones in the compartment summary when they matter.\n\nOutput valid XML only in this shape:\n<output>\n<compartments>\n<compartment start=\"FIRST\" end=\"LAST\" title=\"short title\">\nU: Verbatim high-signal user message\nSummary text describing what was done and why.\nU: Another high-signal user message if applicable\nMore summary text.\n</compartment>\n</compartments>\n<facts>\n<WORKFLOW_RULES>\n* Fact text\n</WORKFLOW_RULES>\n</facts>\n<meta>\n<messages_processed>FIRST-LAST</messages_processed>\n<unprocessed_from>INDEX</unprocessed_from>\n</meta>\n</output>\n\nOmit empty fact categories. Compartments must be ordered, contiguous for the ranges they cover, and non-overlapping.";
2
2
  export declare const COMPRESSOR_AGENT_SYSTEM_PROMPT = "You compress older compartments from a long AI coding session to fit within a token budget.\n\nYou receive a set of compartments that are over budget. Your job is to merge and shorten them so the total output is approximately the target token count.\n\nRules:\n- You have full authority over which compartments to merge and which to keep separate.\n- Merged compartments must cover the same start-to-end range as the originals they replace.\n- Drop verbatim U: (user message) lines from merged compartments. Instead, summarize the user's key intent in the prose: \"User directed X. Implemented Y.\"\n- Keep summaries outcome-focused. Mention file paths, function names, commit hashes, and config keys only when they matter conceptually.\n- You may merge 2-5 adjacent compartments into one broader compartment when they share a theme or phase of work.\n- You may keep a compartment separate but shorten its summary.\n- Do not add new information. Do not invent details not present in the input.\n- Compartments must remain ordered and non-overlapping.\n- Preserve the start and end ordinals exactly from the original compartments.\n\nOutput valid XML only in this shape:\n<output>\n<compartments>\n<compartment start=\"FIRST\" end=\"LAST\" title=\"short title\">Compressed summary text.</compartment>\n</compartments>\n</output>";
3
3
  export declare function buildCompressorPrompt(compartments: Array<{
4
4
  startMessage: number;
@@ -1 +1 @@
1
- {"version":3,"file":"compartment-prompt.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,+BAA+B,o4OA6FyE,CAAC;AAEtH,eAAO,MAAM,8BAA8B,ozCAoBjC,CAAC;AAEX,wBAAgB,qBAAqB,CACjC,YAAY,EAAE,KAAK,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,EACF,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACrB,MAAM,CAgBR;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAiB9F"}
1
+ {"version":3,"file":"compartment-prompt.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,+BAA+B,4rPA6FyE,CAAC;AAEtH,eAAO,MAAM,8BAA8B,ozCAoBjC,CAAC;AAEX,wBAAgB,qBAAqB,CACjC,YAAY,EAAE,KAAK,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,EACF,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACrB,MAAM,CAgBR;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAiB9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"heuristic-cleanup.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/heuristic-cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAM5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAe7D,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,EAC3C,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,EAClF,aAAa,CAAC,EAAE,QAAQ,EAAE,GAC3B;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAmHhF"}
1
+ {"version":3,"file":"heuristic-cleanup.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/heuristic-cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAA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CAAC;QAE9C,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,CAAC,EAAE;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,uBAAuB,EAAE,MAAM,CAAC;SACnC,CAAC;QACF,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;KAC3B,CAAC;CACL;AAqCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB;;;;;iBAxDpC,CAAC;;;;;;;;;;;;iBANtB,CAAA;eACA,CAAF;;mBAmR2B;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;;;SAa7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAGA,OAAO,EAUH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,oBAAoB,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIhF,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,4GAA4G;IAC5G,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAa5D;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAatE;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBjG;AAID,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAStE;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,MAAU,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC5B,YAAY,CAsHd;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9F"}
1
+ {"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAGA,OAAO,EAWH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,oBAAoB,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIhF,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,4GAA4G;IAC5G,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAa5D;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAatE;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBjG;AAID,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAStE;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,MAAU,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC5B,YAAY,CAmJd;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9F"}
@@ -12,6 +12,9 @@ export interface ChunkBlock {
12
12
  }
13
13
  export declare function hasMeaningfulUserText(parts: unknown[]): boolean;
14
14
  export declare function extractTexts(parts: unknown[]): string[];
15
+ /** Extract compact tool-call summaries from message parts.
16
+ * Returns lines like "TC: Fix lint errors" or "TC: read(src/index.ts)". */
17
+ export declare function extractToolCallSummaries(parts: unknown[]): string[];
15
18
  export declare function estimateTokens(text: string): number;
16
19
  export declare function normalizeText(text: string): string;
17
20
  export declare function compactRole(role: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"read-session-formatting.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-formatting.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAMD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAiB/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQrD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAW1D;AAED,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAmB1C;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAS9E"}
1
+ {"version":3,"file":"read-session-formatting.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-formatting.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,I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MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,EAAE,CAAC;CACpB;AAoCD,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAgC1F"}
1
+ {"version":3,"file":"read-session-raw.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,EAAE,CAAC;CACpB;AA4CD,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAiC1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAkC9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,6FAA6F;IAC7F,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,GAAG,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CA6HjF"}
1
+ {"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAkC9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,6FAA6F;IAC7F,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,GAAG,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAsIjF"}
@@ -47,6 +47,7 @@ interface RunPostTransformPhaseArgs {
47
47
  watermark: number;
48
48
  forceMaterializationPercentage: number;
49
49
  hasRecentReduceCall: boolean;
50
+ projectPath?: string;
50
51
  }
51
52
  export declare function runPostTransformPhase(args: RunPostTransformPhaseArgs): void;
52
53
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"transform-postprocess-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-postprocess-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,eAAe,EAKpB,aAAa,EAIhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,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GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,mBAAmB,CAAC;IACrC,MAAM,EAAE,CACJ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EACzD,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,OAAO,aAAa,EAC5B,aAAa,CAAC,EAAE,QAAQ,EAAE,EAC1B,qBAAqB,CAAC,EAAE,MAAM,EAC9B,oBAAoB,CAAC,EAAE,WAAW,KACjC,YAAY,GAAG,IAAI,CAAC;IACzB,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,4BAA4B,EAAE,OAAO,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B,EAAE,MAAM,CAAC;IACvC,mBAAmB,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CA+Y3E"}
1
+ {"version":3,"file":"transform-postprocess-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-postprocess-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,eAAe,EAKpB,aAAa,EAIhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAOhF,OAAO,EACH,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAa7C,OAAO,EAEH,KAAK,W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AAS,EAAE,MAAM,EACjB,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EACzD,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,OAAO,aAAa,EAC5B,aAAa,CAAC,EAAE,QAAQ,EAAE,EAC1B,qBAAqB,CAAC,EAAE,MAAM,EAC9B,oBAAoB,CAAC,EAAE,WAAW,KACjC,YAAY,GAAG,IAAI,CAAC;IACzB,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,4BAA4B,EAAE,OAAO,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B,EAAE,MAAM,CAAC;IACvC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAoZ3E"}
@@ -33,6 +33,7 @@ export interface TransformDeps {
33
33
  historianTimeoutMs?: number;
34
34
  getNotificationParams?: (sessionId: string) => import("./send-session-notification").NotificationParams;
35
35
  getModelKey?: (sessionId: string) => string | undefined;
36
+ projectPath?: string;
36
37
  }
37
38
  export declare function createTransform(deps: TransformDeps): (_input: Record<string, never>, output: {
38
39
  messages: unknown[];
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EACH,KAAK,eAAe,EAGpB,KAAK,aAAa,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQxD,OAAO,K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EAC7B,QAAQ;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,KAChC,OAAO,CAAC,IAAI,CAAC,CAmPnB"}
package/dist/index.js CHANGED
@@ -14879,8 +14879,8 @@ Input notes:
14879
14879
  - [N] or [N-M] is a stable raw OpenCode message range.
14880
14880
  - U: means user.
14881
14881
  - A: means assistant.
14882
+ - TC: means tool call \u2014 a compact summary of what the agent did (e.g., "TC: Fix lint errors", "TC: read(src/index.ts)", "TC: grep(ctx_memory)"). TC lines appear when there is no text describing the action. Use them to understand what happened between text blocks, but do not copy them verbatim into compartments \u2014 incorporate their meaning into the narrative.
14882
14883
  - commits: ... on an assistant block lists commit hashes mentioned in that work unit; keep the relevant ones in the compartment summary when they matter.
14883
- - Tool-only noise is already stripped before you see the input.
14884
14884
 
14885
14885
  Output valid XML only in this shape:
14886
14886
  <output>
@@ -15037,7 +15037,7 @@ function releaseLease(db, holderId) {
15037
15037
  function enqueueDream(db, projectIdentity, reason) {
15038
15038
  const now = Date.now();
15039
15039
  return db.transaction(() => {
15040
- const staleThresholdMs = 10 * 60 * 1000;
15040
+ const staleThresholdMs = 120 * 60 * 1000;
15041
15041
  db.run("DELETE FROM dream_queue WHERE project_path = ? AND started_at IS NOT NULL AND started_at < ?", [projectIdentity, now - staleThresholdMs]);
15042
15042
  const existing = db.query("SELECT id FROM dream_queue WHERE project_path = ?").get(projectIdentity);
15043
15043
  if (existing) {
@@ -15414,14 +15414,22 @@ Only include notes whose conditions you could definitively evaluate. Skip notes
15414
15414
  const output = extractLatestAssistantText(messages);
15415
15415
  if (!output)
15416
15416
  throw new Error("Smart note evaluation returned no output.");
15417
- const jsonMatch = output.match(/\[[\s\S]*?\]/);
15417
+ const jsonMatch = output.match(/\[[\s\S]*\]/);
15418
15418
  if (!jsonMatch) {
15419
15419
  log("[dreamer] smart notes: no JSON array found in output, skipping");
15420
15420
  for (const note of pendingNotes)
15421
15421
  markSmartNoteChecked(args.db, note.id);
15422
15422
  return;
15423
15423
  }
15424
- const evaluations = JSON.parse(jsonMatch[0]);
15424
+ let evaluations;
15425
+ try {
15426
+ evaluations = JSON.parse(jsonMatch[0]);
15427
+ } catch {
15428
+ log(`[dreamer] smart notes: failed to parse JSON from LLM output, marking all checked`);
15429
+ for (const note of pendingNotes)
15430
+ markSmartNoteChecked(args.db, note.id);
15431
+ return;
15432
+ }
15425
15433
  let surfaced = 0;
15426
15434
  let checked = 0;
15427
15435
  for (const evaluation of evaluations) {
@@ -15539,15 +15547,20 @@ function isInScheduleWindow(schedule, now = new Date) {
15539
15547
  return currentMinutes >= window.startMinutes || currentMinutes < window.endMinutes;
15540
15548
  }
15541
15549
  function findProjectsNeedingDream(db) {
15542
- const projectRows = db.query(`SELECT DISTINCT project_path FROM memories WHERE status = 'active' ORDER BY project_path`).all();
15550
+ const projectRows = db.query(`SELECT DISTINCT project_path FROM memories WHERE status = 'active'
15551
+ UNION
15552
+ SELECT DISTINCT project_path FROM smart_notes WHERE status = 'pending'
15553
+ ORDER BY project_path`).all();
15543
15554
  const projects = [];
15544
15555
  for (const row of projectRows) {
15545
15556
  const lastDreamAtStr = getDreamState(db, `last_dream_at:${row.project_path}`);
15546
15557
  const fallbackStr = !lastDreamAtStr ? getDreamState(db, "last_dream_at") : null;
15547
15558
  const lastDreamAt = Number(lastDreamAtStr ?? fallbackStr ?? "0") || 0;
15548
- const updated = db.query(`SELECT COUNT(*) as cnt FROM memories
15559
+ const updatedMemories = db.query(`SELECT COUNT(*) as cnt FROM memories
15549
15560
  WHERE project_path = ? AND status = 'active' AND updated_at > ?`).get(row.project_path, lastDreamAt);
15550
- if (updated && updated.cnt > 0) {
15561
+ const pendingSmartNotes = db.query(`SELECT COUNT(*) as cnt FROM smart_notes
15562
+ WHERE project_path = ? AND status = 'pending'`).get(row.project_path);
15563
+ if (updatedMemories && updatedMemories.cnt > 0 || pendingSmartNotes && pendingSmartNotes.cnt > 0) {
15551
15564
  projects.push(row.project_path);
15552
15565
  }
15553
15566
  }
@@ -15666,6 +15679,54 @@ function extractTexts(parts) {
15666
15679
  }
15667
15680
  return texts;
15668
15681
  }
15682
+ function extractToolCallSummaries(parts) {
15683
+ const summaries = [];
15684
+ for (const part of parts) {
15685
+ if (part === null || typeof part !== "object")
15686
+ continue;
15687
+ const p = part;
15688
+ if (p.type !== "tool" || typeof p.tool !== "string")
15689
+ continue;
15690
+ const state = p.state;
15691
+ if (!state || typeof state !== "object")
15692
+ continue;
15693
+ const input = state.input;
15694
+ const metadata = state.metadata;
15695
+ const description = input && typeof input.description === "string" && input.description || metadata && typeof metadata.description === "string" && metadata.description;
15696
+ if (description) {
15697
+ summaries.push(`TC: ${description}`);
15698
+ continue;
15699
+ }
15700
+ const toolName = p.tool;
15701
+ const keyArg = extractKeyArg(toolName, input);
15702
+ summaries.push(keyArg ? `TC: ${toolName}(${keyArg})` : `TC: ${toolName}`);
15703
+ }
15704
+ return summaries;
15705
+ }
15706
+ function extractKeyArg(_toolName, input) {
15707
+ if (!input)
15708
+ return null;
15709
+ if (typeof input.filePath === "string")
15710
+ return truncateArg(input.filePath);
15711
+ if (typeof input.path === "string")
15712
+ return truncateArg(input.path);
15713
+ if (typeof input.pattern === "string")
15714
+ return truncateArg(input.pattern);
15715
+ if (typeof input.query === "string")
15716
+ return truncateArg(input.query);
15717
+ if (typeof input.symbol === "string")
15718
+ return input.symbol;
15719
+ if (typeof input.module === "string")
15720
+ return input.module;
15721
+ if (typeof input.action === "string")
15722
+ return input.action;
15723
+ return null;
15724
+ }
15725
+ function truncateArg(value, maxLen = 60) {
15726
+ if (value.length <= maxLen)
15727
+ return value;
15728
+ return `${value.slice(0, maxLen)}\u2026`;
15729
+ }
15669
15730
  function estimateTokens(text) {
15670
15731
  return Math.ceil(text.length / 3.5);
15671
15732
  }
@@ -15737,14 +15798,22 @@ function isRawPartRow(row) {
15737
15798
  return typeof candidate.message_id === "string" && typeof candidate.data === "string";
15738
15799
  }
15739
15800
  function parseJsonRecord(value) {
15740
- const parsed = JSON.parse(value);
15741
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
15742
- throw new Error("Expected JSON object");
15801
+ try {
15802
+ const parsed = JSON.parse(value);
15803
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
15804
+ return null;
15805
+ }
15806
+ return parsed;
15807
+ } catch {
15808
+ return null;
15743
15809
  }
15744
- return parsed;
15745
15810
  }
15746
15811
  function parseJsonUnknown(value) {
15747
- return JSON.parse(value);
15812
+ try {
15813
+ return JSON.parse(value);
15814
+ } catch {
15815
+ return null;
15816
+ }
15748
15817
  }
15749
15818
  function readRawSessionMessagesFromDb(db, sessionId) {
15750
15819
  const messageRows = db.prepare("SELECT id, data FROM message WHERE session_id = ? ORDER BY time_created ASC, id ASC").all(sessionId).filter(isRawMessageRow);
@@ -15755,8 +15824,10 @@ function readRawSessionMessagesFromDb(db, sessionId) {
15755
15824
  list.push(parseJsonUnknown(part.data));
15756
15825
  partsByMessageId.set(part.message_id, list);
15757
15826
  }
15758
- return messageRows.map((row, index) => {
15827
+ return messageRows.flatMap((row, index) => {
15759
15828
  const info = parseJsonRecord(row.data);
15829
+ if (!info)
15830
+ return [];
15760
15831
  const role = typeof info.role === "string" ? info.role : "unknown";
15761
15832
  return {
15762
15833
  ordinal: index + 1,
@@ -15922,11 +15993,37 @@ function readSessionChunk(sessionId, tokenBudget, offset = 1, eligibleEndOrdinal
15922
15993
  continue;
15923
15994
  const meta3 = { ordinal: msg.ordinal, messageId: msg.id };
15924
15995
  if (msg.role === "user" && !hasMeaningfulUserText(msg.parts)) {
15925
- pendingNoiseMeta.push(meta3);
15996
+ const tcSummaries = extractToolCallSummaries(msg.parts);
15997
+ if (tcSummaries.length === 0) {
15998
+ pendingNoiseMeta.push(meta3);
15999
+ continue;
16000
+ }
16001
+ const tcText = tcSummaries.join(" / ");
16002
+ if (currentBlock && currentBlock.role === "A") {
16003
+ currentBlock.endOrdinal = msg.ordinal;
16004
+ currentBlock.parts.push(tcText);
16005
+ currentBlock.meta.push(...pendingNoiseMeta, meta3);
16006
+ pendingNoiseMeta = [];
16007
+ } else {
16008
+ if (!flushCurrentBlock())
16009
+ break;
16010
+ currentBlock = {
16011
+ role: "A",
16012
+ startOrdinal: pendingNoiseMeta[0]?.ordinal ?? msg.ordinal,
16013
+ endOrdinal: msg.ordinal,
16014
+ parts: [tcText],
16015
+ meta: [...pendingNoiseMeta, meta3],
16016
+ commitHashes: []
16017
+ };
16018
+ pendingNoiseMeta = [];
16019
+ }
15926
16020
  continue;
15927
16021
  }
15928
16022
  const role = compactRole(msg.role);
15929
- const compacted = compactTextForSummary(extractTexts(msg.parts).map((t) => msg.role === "user" ? cleanUserText(t) : t).map(normalizeText).filter((value) => value.length > 0).join(" / "), msg.role);
16023
+ const textParts = extractTexts(msg.parts).map((t) => msg.role === "user" ? cleanUserText(t) : t).map(normalizeText).filter((value) => value.length > 0);
16024
+ const toolSummaries = textParts.length === 0 ? extractToolCallSummaries(msg.parts) : [];
16025
+ const allParts = [...textParts, ...toolSummaries];
16026
+ const compacted = compactTextForSummary(allParts.join(" / "), msg.role);
15930
16027
  const text = compacted.text;
15931
16028
  if (!text) {
15932
16029
  pendingNoiseMeta.push(meta3);
@@ -16354,6 +16451,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
16354
16451
  ensureColumn(db, "session_meta", "memory_block_count", "INTEGER DEFAULT 0");
16355
16452
  ensureColumn(db, "dream_queue", "retry_count", "INTEGER DEFAULT 0");
16356
16453
  ensureColumn(db, "tags", "reasoning_byte_size", "INTEGER DEFAULT 0");
16454
+ ensureColumn(db, "session_meta", "system_prompt_tokens", "INTEGER DEFAULT 0");
16357
16455
  }
16358
16456
  function ensureColumn(db, table, column, definition) {
16359
16457
  if (!/^[a-z_]+$/.test(table) || !/^[a-z_]+$/.test(column) || !/^[A-Z0-9_'(),\s]+$/i.test(definition)) {
@@ -16429,6 +16527,7 @@ var META_COLUMNS = {
16429
16527
  timesExecuteThresholdReached: "times_execute_threshold_reached",
16430
16528
  compartmentInProgress: "compartment_in_progress",
16431
16529
  systemPromptHash: "system_prompt_hash",
16530
+ systemPromptTokens: "system_prompt_tokens",
16432
16531
  clearedReasoningThroughTag: "cleared_reasoning_through_tag"
16433
16532
  };
16434
16533
  var BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress"]);
@@ -16436,7 +16535,7 @@ function isSessionMetaRow(row) {
16436
16535
  if (row === null || typeof row !== "object")
16437
16536
  return false;
16438
16537
  const r = row;
16439
- return typeof r.session_id === "string" && typeof r.last_response_time === "number" && typeof r.cache_ttl === "string" && typeof r.counter === "number" && typeof r.last_nudge_tokens === "number" && typeof r.last_nudge_band === "string" && typeof r.last_transform_error === "string" && typeof r.is_subagent === "number" && typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && typeof r.times_execute_threshold_reached === "number" && typeof r.compartment_in_progress === "number" && (typeof r.system_prompt_hash === "string" || typeof r.system_prompt_hash === "number") && typeof r.cleared_reasoning_through_tag === "number";
16538
+ return typeof r.session_id === "string" && typeof r.last_response_time === "number" && typeof r.cache_ttl === "string" && typeof r.counter === "number" && typeof r.last_nudge_tokens === "number" && typeof r.last_nudge_band === "string" && typeof r.last_transform_error === "string" && typeof r.is_subagent === "number" && typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && typeof r.times_execute_threshold_reached === "number" && typeof r.compartment_in_progress === "number" && (typeof r.system_prompt_hash === "string" || typeof r.system_prompt_hash === "number") && typeof r.system_prompt_tokens === "number" && typeof r.cleared_reasoning_through_tag === "number";
16440
16539
  }
16441
16540
  function getDefaultSessionMeta(sessionId) {
16442
16541
  return {
@@ -16453,6 +16552,7 @@ function getDefaultSessionMeta(sessionId) {
16453
16552
  timesExecuteThresholdReached: 0,
16454
16553
  compartmentInProgress: false,
16455
16554
  systemPromptHash: "",
16555
+ systemPromptTokens: 0,
16456
16556
  clearedReasoningThroughTag: 0
16457
16557
  };
16458
16558
  }
@@ -16475,6 +16575,7 @@ function toSessionMeta(row) {
16475
16575
  timesExecuteThresholdReached: row.times_execute_threshold_reached,
16476
16576
  compartmentInProgress: row.compartment_in_progress === 1,
16477
16577
  systemPromptHash: String(row.system_prompt_hash),
16578
+ systemPromptTokens: row.system_prompt_tokens,
16478
16579
  clearedReasoningThroughTag: row.cleared_reasoning_through_tag
16479
16580
  };
16480
16581
  }
@@ -16643,7 +16744,7 @@ function removeStrippedPlaceholderId(db, sessionId, messageId) {
16643
16744
  }
16644
16745
  // src/features/magic-context/storage-meta-session.ts
16645
16746
  function getOrCreateSessionMeta(db, sessionId) {
16646
- const result = db.prepare("SELECT session_id, last_response_time, cache_ttl, counter, last_nudge_tokens, last_nudge_band, last_transform_error, is_subagent, last_context_percentage, last_input_tokens, times_execute_threshold_reached, compartment_in_progress, system_prompt_hash, cleared_reasoning_through_tag FROM session_meta WHERE session_id = ?").get(sessionId);
16747
+ const result = db.prepare("SELECT session_id, last_response_time, cache_ttl, counter, last_nudge_tokens, last_nudge_band, last_transform_error, is_subagent, last_context_percentage, last_input_tokens, times_execute_threshold_reached, compartment_in_progress, system_prompt_hash, system_prompt_tokens, cleared_reasoning_through_tag FROM session_meta WHERE session_id = ?").get(sessionId);
16647
16748
  if (isSessionMetaRow(result)) {
16648
16749
  return toSessionMeta(result);
16649
16750
  }
@@ -21598,7 +21699,9 @@ function applyHeuristicCleanup(sessionId, db, targets, messageTagNumbers, config
21598
21699
  for (let i = 0;i < group.length - 1; i++) {
21599
21700
  const tag = group[i];
21600
21701
  const target = targets.get(tag.tagNumber);
21601
- target?.drop?.();
21702
+ const dropResult = target?.drop?.() ?? "absent";
21703
+ if (dropResult === "incomplete")
21704
+ continue;
21602
21705
  updateTagStatus(db, sessionId, tag.tagNumber, "dropped");
21603
21706
  deduplicatedTools++;
21604
21707
  }
@@ -21877,7 +21980,7 @@ function runPostTransformPhase(args) {
21877
21980
  sessionLog(args.sessionId, `preserving sticky note nudge anchor to avoid cache bust: messageId=${stickyNoteNudge.messageId}`);
21878
21981
  }
21879
21982
  }
21880
- const deferredNoteText = peekNoteNudgeText(args.db, args.sessionId, args.currentTurnId);
21983
+ const deferredNoteText = peekNoteNudgeText(args.db, args.sessionId, args.currentTurnId, args.projectPath);
21881
21984
  if (deferredNoteText) {
21882
21985
  const noteInstruction = `
21883
21986
 
@@ -22074,7 +22177,8 @@ function createTransform(deps) {
22074
22177
  didMutateFromFlushedStatuses,
22075
22178
  watermark,
22076
22179
  forceMaterializationPercentage: FORCE_MATERIALIZE_PERCENTAGE,
22077
- hasRecentReduceCall
22180
+ hasRecentReduceCall,
22181
+ projectPath: deps.projectPath
22078
22182
  });
22079
22183
  const elapsed = (performance.now() - startTime).toFixed(1);
22080
22184
  sessionLog(sessionId, `transform completed in ${elapsed}ms (${messages.length} messages, ${targets.size} targets, watermark: ${watermark})`);
@@ -22237,6 +22341,10 @@ Use \`ctx_reduce\` to manage context size. It supports one operation:
22237
22341
  Syntax: "3-5", "1,2,9", or "1-5,8,12-15". Last ${protectedTags} tags are protected.
22238
22342
  Use \`ctx_note\` for deferred intentions \u2014 things to tackle later, not right now. NOT for task tracking (use todos). Notes survive context compression and you'll be reminded at natural work boundaries (after commits, historian runs, todo completion).
22239
22343
  Use \`ctx_memory\` to manage cross-session project memories. Write new memories or delete stale ones. Memories persist across sessions and are automatically injected into new sessions.
22344
+ **Save to memory proactively**: If you spent multiple turns finding something (a file path, a DB location, a config pattern, a workaround), save it with \`ctx_memory\` so future sessions don't repeat the search. Examples:
22345
+ - Found a project's source code path after searching \u2192 \`ctx_memory(action="write", category="ENVIRONMENT", content="OpenCode source is at ~/Work/OSS/opencode")\`
22346
+ - Discovered a non-obvious build/test command \u2192 \`ctx_memory(action="write", category="WORKFLOW_RULES", content="Always use scripts/release.sh for releases")\`
22347
+ - Learned a constraint the hard way \u2192 \`ctx_memory(action="write", category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale")\`
22240
22348
  Use \`ctx_search\` to search across project memories, session facts, and conversation history from one query.
22241
22349
  Use \`ctx_expand\` to decompress a compartment range to see the original conversation transcript. Use \`start\`/\`end\` from \`<compartment start=N end=M>\` attributes. Returns the compacted U:/A: transcript for that message range, capped at ~15K tokens.
22242
22350
  **Search before asking the user**: If you can't remember or don't know something that might have been discussed before or stored in project memory, use \`ctx_search\` before asking the user. Examples:
@@ -22253,6 +22361,10 @@ Before your turn finishes, consider using \`ctx_reduce\` to drop large tool outp
22253
22361
  var BASE_INTRO_NO_REDUCE = `Messages and tool outputs are tagged with \xA7N\xA7 identifiers (e.g., \xA71\xA7, \xA742\xA7).
22254
22362
  Use \`ctx_note\` for deferred intentions \u2014 things to tackle later, not right now. NOT for task tracking (use todos). Notes survive context compression and you'll be reminded at natural work boundaries (after commits, historian runs, todo completion).
22255
22363
  Use \`ctx_memory\` to manage cross-session project memories. Write new memories or delete stale ones. Memories persist across sessions and are automatically injected into new sessions.
22364
+ **Save to memory proactively**: If you spent multiple turns finding something (a file path, a DB location, a config pattern, a workaround), save it with \`ctx_memory\` so future sessions don't repeat the search. Examples:
22365
+ - Found a project's source code path after searching \u2192 \`ctx_memory(action="write", category="ENVIRONMENT", content="OpenCode source is at ~/Work/OSS/opencode")\`
22366
+ - Discovered a non-obvious build/test command \u2192 \`ctx_memory(action="write", category="WORKFLOW_RULES", content="Always use scripts/release.sh for releases")\`
22367
+ - Learned a constraint the hard way \u2192 \`ctx_memory(action="write", category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale")\`
22256
22368
  Use \`ctx_search\` to search across project memories, session facts, and conversation history from one query.
22257
22369
  Use \`ctx_expand\` to decompress a compartment range to see the original conversation transcript. Use \`start\`/\`end\` from \`<compartment start=N end=M>\` attributes. Returns the compacted U:/A: transcript for that message range, capped at ~15K tokens.
22258
22370
  **Search before asking the user**: If you can't remember or don't know something that might have been discussed before or stored in project memory, use \`ctx_search\` before asking the user. Examples:
@@ -22519,8 +22631,14 @@ function createSystemPromptHashHandler(deps) {
22519
22631
  } else if (previousHash === "" || previousHash === "0") {
22520
22632
  sessionLog(sessionId, `system prompt hash initialized: ${currentHash} (len=${systemContent.length})`);
22521
22633
  }
22634
+ const systemPromptTokens = Math.ceil(systemContent.length / 4);
22522
22635
  if (currentHash !== previousHash) {
22523
- updateSessionMeta(deps.db, sessionId, { systemPromptHash: currentHash });
22636
+ updateSessionMeta(deps.db, sessionId, {
22637
+ systemPromptHash: currentHash,
22638
+ systemPromptTokens
22639
+ });
22640
+ } else if (sessionMeta.systemPromptTokens === 0 && systemPromptTokens > 0) {
22641
+ updateSessionMeta(deps.db, sessionId, { systemPromptTokens });
22524
22642
  }
22525
22643
  };
22526
22644
  }
@@ -22604,7 +22722,8 @@ function createMagicContextHook(deps) {
22604
22722
  getModelKey: (sessionId) => {
22605
22723
  const model = liveModelBySession.get(sessionId);
22606
22724
  return resolveModelKey(model?.providerID, model?.modelID);
22607
- }
22725
+ },
22726
+ projectPath
22608
22727
  });
22609
22728
  const eventHandler = createEventHandler2({
22610
22729
  contextUsageMap,
@@ -22627,9 +22746,9 @@ function createMagicContextHook(deps) {
22627
22746
  if (now - lastScheduleCheckMs < DREAM_SCHEDULE_CHECK_INTERVAL_MS) {
22628
22747
  return;
22629
22748
  }
22630
- lastScheduleCheckMs = now;
22631
22749
  try {
22632
22750
  checkScheduleAndEnqueue(db, dreaming.schedule);
22751
+ lastScheduleCheckMs = now;
22633
22752
  } catch (error48) {
22634
22753
  log("[dreamer] scheduled enqueue check failed:", error48);
22635
22754
  return;
@@ -22951,7 +23070,7 @@ function createCtxMemoryTool(deps) {
22951
23070
  return tool2({
22952
23071
  description: CTX_MEMORY_DESCRIPTION,
22953
23072
  args: {
22954
- action: tool2.schema.enum(CTX_MEMORY_DREAMER_ACTIONS).describe("Action to perform on memories"),
23073
+ action: tool2.schema.enum(allowedActions).describe("Action to perform on memories"),
22955
23074
  content: tool2.schema.string().optional().describe("Memory content (required for write, update, merge)"),
22956
23075
  category: tool2.schema.string().optional().describe("Memory category (required for write, optional filter for list, optional override for merge)"),
22957
23076
  id: tool2.schema.number().optional().describe("Memory ID (required for delete, update, archive)"),
@@ -1 +1 @@
1
- {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C;;;;;;qBA2CA,CAAC;;;;;;;;;;;;qBARc,CAAN;mBAAiB,CAAC;;;;;0BAQm9T,CAAC;;;;;;EAD/+T"}
1
+ {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C;;;;;;qBA2CA,CAAC;;;;;;;;;;;;qBARc,CAAN;mBAAiB,CAAC;;;;;0BAQ4+T,CAAC;;;;;;EADxgU"}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAqBhE,OAAO,EAIH,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AAsajB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAqBhE,OAAO,EAIH,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AAoajB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",