@cortexkit/opencode-magic-context 0.11.1 → 0.13.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/README.md +3 -1
- package/dist/agents/historian.d.ts +1 -0
- package/dist/agents/historian.d.ts.map +1 -1
- package/dist/agents/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli.js +362 -83
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +117 -2
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/config/variable.d.ts +46 -0
- package/dist/config/variable.d.ts.map +1 -0
- package/dist/features/magic-context/compartment-storage.d.ts +27 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/compression-depth-storage.d.ts +7 -0
- package/dist/features/magic-context/compression-depth-storage.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-probe.d.ts +69 -0
- package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -0
- package/dist/features/magic-context/scheduler.d.ts +5 -1
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman.d.ts +35 -0
- package/dist/hooks/magic-context/caveman.d.ts.map +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts +29 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts +8 -3
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +46 -0
- package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +10 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts +29 -0
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +9 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +5 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +31 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +39 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +4 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +13 -4
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +11 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +13 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +7 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +2 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/temporal-awareness.d.ts +73 -0
- package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +10 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +18 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2562 -1086
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/shared/model-requirements.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +11 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/model-requirements.ts +3 -1
- package/src/shared/models-dev-cache.ts +11 -1
- package/src/shared/rpc-types.ts +11 -0
- package/src/tui/data/context-db.ts +1 -0
|
@@ -1,12 +1,17 @@
|
|
|
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
|
-
export declare const COMPRESSOR_AGENT_SYSTEM_PROMPT = "You compress older compartments from a long AI coding session
|
|
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- If one broad effort contains multiple completed sub-pivots with distinct outcomes, prefer multiple smaller compartments over one umbrella compartment with many U: lines.\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- Every displayed raw message ordinal in the input MUST appear in exactly one compartment. Gaps between compartments are invalid. When a displayed block is pure tool noise (e.g. a long \"TC: ...\" run with no narrative text), do NOT skip it \u2014 extend the preceding compartment's `end` to absorb the range, or include it inside the current compartment if the block falls within an ongoing work unit. Never create a dedicated compartment just to cover a tool-only run.\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\n# Construction order (MANDATORY)\n\nFor each compartment, build in this exact order:\n\n1. Write the narrative summary first \u2014 what was done, why, and the outcome. This is 1\u20134 sentences covering the work unit completely.\n2. Re-read your narrative. Ask: does the summary already convey all important decisions and constraints from this work unit?\n3. If yes, the compartment is DONE with zero U: lines. Move on.\n4. If no, identify the specific signal the narrative cannot capture. Add U: lines ONLY for those signals.\n5. Before writing each U: line, run the CROSS-COMPARTMENT CHECK (see below).\n\nZero U: lines in a compartment is normal and expected. Most compartments should have 0\u20132 U: lines. Compartments with 3\u20135 are rare and must be justified by genuinely distinct durable signals.\n\n# DROP rules (check these first \u2014 if any match, drop without exception)\n\n- Questions in ANY form: \"should I X?\", \"what about Y?\", \"do you think Z?\", \"isn't it better to A?\", \"why don't we B?\", \"any ideas?\" \u2014 the resolved answer belongs in narrative only. If it feels important to keep the question, you are wrong: keep the answer in narrative.\n- Agreements and acknowledgments: \"yes\", \"okay\", \"sure\", \"thanks\", \"go ahead\", \"looks good\", \"perfect\", \"I agree\", \"sounds good\", \"great\".\n- Pure pacing and sequencing: \"let's start\", \"continue\", \"let's do all\", \"now we can X\", \"let's commit\", \"first do A then B\", \"before that\", \"in the meantime\".\n- Tactical observations: \"I just noticed X\", \"we recently did Y\", \"I'm seeing Z right now\", \"this seems wrong\".\n- Debugging status: \"context is at 78%\", \"I'm restarting\", \"the last build failed\".\n- Dogfooding/restart loops: \"I restarted, can you check?\", \"okay we should have updated versions now\", \"let me try again\".\n- Pasted error output or logs as U: line \u2014 capture the underlying problem in narrative, not the raw paste.\n- Examples and illustrations: \"mine was when an agent wants to see X\" \u2014 convert the underlying intent into a directive or drop.\n- Hype with embedded directive: ALL-CAPS pleas, \"PLEASE PLEASE PLEASE just do X\" \u2014 extract only the underlying directive into narrative; drop the hype.\n- Social signals, banter, emoji-only, enthusiasm.\n- Deferred ideas: \"for later\", \"we can do X later\", \"another idea for the future\".\n- Mid-process status: \"running Y\", \"checking Z\".\n- Superseded drafts once a later message gives the final decision.\n- Standing workflow rules (\"always run lint before push\") \u2014 these belong in WORKFLOW_RULES facts, not U: lines.\n\n# Wording rule (default: verbatim)\n\nBy default, U: lines use the user's actual wording. The user's exact phrasing often carries negotiation context, emphasis, or technical specificity that paraphrase loses.\n\nParaphrase ONLY in these cases:\n- **Strip agreement prefixes**: \"Yes X\", \"Okay X\", \"Sure X\" \u2192 keep only the substantive part of X, in the user's original wording.\n- **Split compound directives**: If one message contains two distinct durable directives, split into two U: lines \u2014 each preserving the user's wording for its part.\n- **Drop conversational noise, keep core**: If a message wraps a directive in exploratory phrasing (\"so I was thinking, maybe... but actually...\"), drop the exploration and keep the core directive in the user's remaining words. Don't invent new phrasing.\n\nNEVER:\n- Rewrite a clear user directive into a formal constraint statement. (\"We need tool count at ~8\" stays as-is; do NOT convert to \"Tool count must be capped at 8.\")\n- Synthesize a directive from multiple messages into one canonical statement. If the signal needs synthesis, it belongs in narrative, not a U: line.\n- Add technical specificity the user didn't state (file paths, function names, constant names). Canonical technical specificity belongs in narrative or facts, not in U: lines attributed to the user.\n\nGood example:\n Original user message: \"Yes let's do this. But we need to also make sure that we limit by message count as some sessions have quite a lot of messages.\"\n Correct U: line: \"We need to also make sure that we limit by message count as some sessions have quite a lot of messages.\"\n (Stripped agreement prefix; kept the user's actual wording.)\n\nBad example (do not do this):\n Incorrect U: line: \"Cap session history retrieval at a maximum message count to prevent memory issues on large sessions.\"\n (Rewrote the user directive into formal language and invented specificity.)\n\n# KEEP rules (U: line survives only if ALL pass)\n\n1. DURABLE: The signal matters after the immediate turn.\n2. SPECIFIC: Concrete goal, hard constraint, design decision, rejection, rationale, threshold, source-of-truth correction, or future-work directive.\n3. OUTCOME-BACKED: This compartment's narrative clearly states what was done, decided, or changed because of the message.\n4. NON-REDUNDANT: Not captured by another U: line (see CROSS-COMPARTMENT CHECK), by a fact, or by the narrative.\n5. IRREPLACEABLE: The user's wording adds signal that narrative paraphrase cannot preserve. If the same information could appear as narrative without losing meaning, it should.\n\nCategories of KEEP:\n- Hard gates, thresholds, config defaults, percentages, byte sizes with concrete values.\n- Accepted designs and explicit decisions.\n- Rejections and negative constraints: \"X is wrong because Y\", \"we should NOT do Z\".\n- Source-of-truth corrections: \"follow the code, not the README\".\n- Implementation pivots stated in future tense: \"instead of X let's do Y\", \"switch to Z\".\n- Durable rationale that explains WHY an approach was chosen.\n- Specific feature requirements stated as durable goals.\n\n# PIVOT vs OBSERVATION test\n\nA pivot is FUTURE-TENSE and changes the plan: \"instead of X, let's do Y\", \"switch this to Z\", \"actually, let's not do A\".\nAn observation is PAST-TENSE or PRESENT-TENSE and reports state: \"we recently did X\", \"I just noticed Y\", \"this is broken right now\".\nObservations may frame narrative context but are NOT pivots and NOT durable. Drop them as U: lines.\n\n# CROSS-COMPARTMENT CHECK (forward-looking)\n\nBefore writing ANY U: line in the current compartment:\n1. Scan U: lines you have ALREADY written in previous compartments in this response.\n2. If any prior U: line expresses the same intent, decision, constraint, or rationale \u2014 even in different words \u2014 do NOT write the new U: line.\n3. Let the narrative in the current compartment carry the signal instead.\n\nThis is a forward operation: you only need to check what you already wrote, not revisit past compartments.\n\nExamples of same-intent pairs to collapse:\n- \"X shouldn't cause cache bust\" + \"X must not bust cache by itself\" \u2192 keep only the first, in its original compartment.\n- \"Let's use monorepo\" + \"Yes, monorepo is the right call\" \u2192 keep only the first.\n- \"Add logging\" + \"We need logs here too\" \u2192 keep only the first.\n\nNever keep two U: lines for the same underlying directive across compartments.\n\n# Budget\n\n- HARD LIMIT: 3\u20135 U: lines per compartment. 0\u20132 is typical.\n- If you have more than 5 candidate U: lines in one compartment, that is a signal to split into two compartments at a natural pivot, not to stuff more.\n- Every U: line must be immediately followed by 1\u20133 sentences describing the outcome, decision, or effect. Never stack two U: lines without intervening outcome text.\n\n# Example: CORRECT preservation (narrative-first, verbatim U: line)\n\n<compartment start=\"50\" end=\"120\" title=\"Built the auth layer\">\nImplemented JWT auth with hard 60-minute exp claim and refresh-token rotation. Chose Bearer tokens over cookies after finding cookie-based auth broke the SPA flow. Added session_expiry config (read-only at runtime). Commits: a3f891, b22c4e.\nU: We need session expiry capped at 1 hour, no exceptions\nHardcoded the 60-minute cap at the JWT-issuer layer so runtime overrides cannot extend it.\n</compartment>\n\nNotice: only one U: line, kept verbatim from the user's actual message. The cookie-to-Bearer pivot is narrative because paraphrase captures the signal fully.\n\n# Example: OVER-PRESERVATION (avoid)\n\n<compartment start=\"200\" end=\"350\" title=\"Refactored data layer\">\nU: Okay let's start on the data layer\nU: What about transactions?\nU: Yes that approach looks good\nU: Actually wait, maybe we need write-ahead logging\nU: I just noticed the previous commit broke a test\nU: Let's commit and ship it\nRefactored data layer with WAL mode and connection pooling.\n</compartment>\n\nProblems: pacing, question, agreement, observation, pacing again. Only one message carries signal, and even that is narrative-capturable.\n\n# CORRECT version of the above\n\n<compartment start=\"200\" end=\"350\" title=\"Refactored data layer\">\nRefactored data layer to use WAL mode plus connection pooling. Chose WAL over plain connections for concurrent read performance under sustained write load.\n</compartment>\n\nZero U: lines. The pivot to WAL is clear in narrative.\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
|
+
export declare const COMPRESSOR_AGENT_SYSTEM_PROMPT = "You compress older compartments from a long AI coding session by merging adjacent compartments and rewriting their content at a target density.\n\nYour two jobs:\n1. Merge N input compartments into M output compartments (M < N). Typical M = ceil(N/2).\n2. Rewrite each merged compartment's content at the density level specified per-request.\n\nUniversal rules (all density levels):\n- Merged compartments must collectively cover the same start-to-end range as the input.\n- Use the EXACT start/end ordinals from the input compartments for every output compartment boundary.\n- Do not invent new ordinal boundaries that don't exist in the input.\n- Output compartments must be ordered and non-overlapping.\n- Preserve commit hashes (7-40 hex chars), file paths, config keys, URLs, and `backtick-fenced` code verbatim \u2014 never modify, abbreviate, or drop them.\n- Preserve lines starting with \"U: \" verbatim when they remain in output. Do not paraphrase user directives.\n- Do not add new information or invent details.\n- Do not re-emit any compartment unchanged \u2014 if the content doesn't need rewriting at the target density, still merge it with neighbors.\n\nDensity levels (specified per-request):\n\nLevel 1 \u2014 MERGE ONLY:\n Preserve all narrative prose and all U: lines. Only remove genuine duplicate sentences spanning merged compartments (same fact said twice becomes one).\n\nLevel 2 \u2014 LITE TIGHTEN:\n Merge + drop filler words (\"just\", \"really\", \"basically\", \"essentially\") and hedging (\"I think\", \"probably\", \"perhaps\"). Keep full grammar, keep U: lines verbatim.\n\nLevel 3 \u2014 FULL CONDENSE:\n Single paragraph per output compartment. Drop articles (\"the\", \"a\", \"an\") and weak auxiliaries (\"was\", \"were\"). Fragments acceptable. Keep only the IRREPLACEABLE U: lines (unique-signal quotes). Drop U: lines whose intent is already in narrative.\n\nLevel 4 \u2014 ULTRA TELEGRAPH:\n Telegraphic fragments. Symbol connectives: \"\u2192\" for \"then/causes\", \"+\" for \"and\", \"//\" for \"because\", \"|\" for \"or\". Pattern: [thing] [action] [reason]. [next]. Keep U: lines only if their exact phrasing is truly irreplaceable (rare).\n\nOutput valid XML only in this shape:\n<output>\n<compartments>\n<compartment start=\"FIRST\" end=\"LAST\" title=\"short title\">Compressed content.</compartment>\n</compartments>\n</output>";
|
|
3
|
+
export declare const HISTORIAN_EDITOR_SYSTEM_PROMPT = "You are an editor refining a historian draft. The draft was produced by a first-pass historian and may contain noise \u2014 low-signal U: lines, redundant quotes across compartments, and weak preservation decisions.\n\nYour job is to clean the draft without changing its structure:\n\n1. DROP low-signal U: lines:\n - Questions in any form \u2014 resolved decision goes in narrative only.\n - Pacing/agreement: \"let's go\", \"yes\", \"okay\", \"sounds good\", \"I agree\".\n - Pasted error output, debugging status, mid-process observations.\n - Tactical micro-direction: \"now look at X\", \"first check Y\".\n\n2. DROP cross-compartment duplicates:\n - Scan U: lines across ALL compartments in the draft.\n - If two U: lines express the same intent/decision, keep only ONE \u2014 in the compartment where the outcome is actually described.\n\n3. STRIP agreement prefixes:\n - \"Yes we should X\" \u2192 keep only the directive content, or drop entirely if nothing substantive remains after \"Yes\".\n\n4. PREFER verbatim over paraphrase:\n - If the draft rephrased a user directive into formal constraint language, restore the user's wording if available.\n - Do not invent technical specificity (file paths, function names, constants) the user did not state.\n\n5. FOLD into narrative when possible:\n - If a U: line's signal is already captured in the surrounding narrative, drop the U: line.\n - Narrative should not need the U: line to be understood.\n\n6. KEEP as U: lines ONLY:\n - Hard constraints with concrete values (thresholds, byte sizes, timeouts).\n - Explicit rejections (\"X is wrong because Y\", \"NOT Z\").\n - Implementation pivots in future-tense (\"instead of A, do B\").\n - Source-of-truth corrections.\n\nDo NOT change:\n- Compartment titles, ranges, or ordering.\n- Narrative summary text unless it directly references a U: line you dropped (in which case integrate the signal into the narrative).\n- Facts \u2014 leave the facts section untouched.\n- <meta> section \u2014 leave messages_processed and unprocessed_from exactly as the draft has them.\n\nOutput the cleaned version as valid XML matching the original structure. Preserve all XML tags, compartment ranges, meta, and facts.";
|
|
4
|
+
export declare function buildHistorianEditorPrompt(draft: string): string;
|
|
3
5
|
export declare const USER_OBSERVATIONS_APPENDIX = "\n\nUser observation rules (EXPERIMENTAL):\n- After outputting compartments and facts, also output a <user_observations> section.\n- User observations capture UNIVERSAL behavioral patterns about the human user \u2014 not project-specific or technical.\n- Good observations: communication preferences, review focus areas, expertise level, decision-making patterns, frustration triggers, working style.\n- Bad observations (DO NOT emit): project-specific preferences, framework choices, coding language preferences, one-off moods, task-local frustration.\n- Each observation must be a single concise sentence in present tense.\n- Only emit observations you have strong evidence for from the conversation. Do not speculate.\n- Emit 0-5 observations per run. Zero is fine if nothing stands out.\n- The output shape inside <output> gains an additional section:\n<user_observations>\n* User prefers terse communication and dislikes verbose explanations.\n* User is technically deep \u2014 understands cache invalidation, SQLite internals, and prompt engineering.\n</user_observations>\nIf no observations, omit the <user_observations> section entirely.";
|
|
6
|
+
/** Build the per-request prompt for a compressor run.
|
|
7
|
+
* `outputDepth` selects the density level (1-4). Depth 5 is handled by
|
|
8
|
+
* the runner short-circuit and never invokes this builder. */
|
|
4
9
|
export declare function buildCompressorPrompt(compartments: Array<{
|
|
5
10
|
startMessage: number;
|
|
6
11
|
endMessage: number;
|
|
7
12
|
title: string;
|
|
8
13
|
content: string;
|
|
9
|
-
}>, currentTokens: number, targetTokens: number,
|
|
14
|
+
}>, currentTokens: number, targetTokens: number, outputDepth: number, outputCount?: number): string;
|
|
10
15
|
export declare function buildCompartmentAgentPrompt(existingState: string, inputSource: string, options?: {
|
|
11
16
|
userMemoriesEnabled?: boolean;
|
|
12
17
|
}): string;
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"compartment-prompt.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,+BAA+B,4xgBAgNyE,CAAC;AAEtH,eAAO,MAAM,8BAA8B,u1EAmCjC,CAAC;AAEX,eAAO,MAAM,8BAA8B,ysEAqC0F,CAAC;AAEtI,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED,eAAO,MAAM,0BAA0B,+nCAe4B,CAAC;AAEpE;;+DAE+D;AAC/D,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,EACpB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACrB,MAAM,CAkDR;AAED,wBAAgB,2BAA2B,CACvC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5C,MAAM,CAsBR"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { Compartment } from "../../features/magic-context/compartment-storage";
|
|
2
3
|
import type { PluginContext } from "../../plugin/types";
|
|
3
4
|
export interface CompressorDeps {
|
|
4
5
|
client: PluginContext["client"];
|
|
@@ -7,10 +8,55 @@ export interface CompressorDeps {
|
|
|
7
8
|
directory: string;
|
|
8
9
|
historyBudgetTokens: number;
|
|
9
10
|
historianTimeoutMs?: number;
|
|
11
|
+
/** Floor = ceil(lastEndMessage / minCompartmentRatio). Default 1000. */
|
|
12
|
+
minCompartmentRatio?: number;
|
|
13
|
+
/** Maximum depth any compartment range can be compressed to. Default 5. */
|
|
14
|
+
maxMergeDepth?: number;
|
|
15
|
+
/** Cap on compartments sent to the LLM in one pass. Default 15. */
|
|
16
|
+
maxCompartmentsPerPass?: number;
|
|
17
|
+
/** Newest compartments always excluded from compression. Default 10. */
|
|
18
|
+
graceCompartments?: number;
|
|
19
|
+
}
|
|
20
|
+
interface ScoredCompartment {
|
|
21
|
+
compartment: Compartment;
|
|
22
|
+
index: number;
|
|
23
|
+
tokenEstimate: number;
|
|
24
|
+
averageDepth: number;
|
|
25
|
+
score: number;
|
|
10
26
|
}
|
|
11
27
|
/**
|
|
12
28
|
* Check if the compartment block exceeds the history budget and run a compression pass if needed.
|
|
13
29
|
* Returns true if compression ran successfully, false otherwise.
|
|
14
30
|
*/
|
|
15
31
|
export declare function runCompressionPassIfNeeded(deps: CompressorDeps): Promise<boolean>;
|
|
32
|
+
interface SelectionConstraints {
|
|
33
|
+
/** Max compartments to pick per pass (LLM batch cap). */
|
|
34
|
+
maxPickable: number;
|
|
35
|
+
/** Max compression depth a compartment range can reach. */
|
|
36
|
+
maxMergeDepth: number;
|
|
37
|
+
/** Number of newest compartments always excluded (grace period). */
|
|
38
|
+
graceCompartments: number;
|
|
39
|
+
/** compartments.length - floor; we can't reduce below this without violating floor. */
|
|
40
|
+
floorHeadroom: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Find the oldest contiguous band of compartments that share the same rounded depth.
|
|
44
|
+
*
|
|
45
|
+
* Strategy: scan oldest→newest (low index first). Skip compartments at max depth,
|
|
46
|
+
* and skip the newest `graceCompartments` (grace period). Within the remaining
|
|
47
|
+
* scope, find the oldest run of 2+ consecutive compartments with the SAME rounded
|
|
48
|
+
* averageDepth. This keeps per-pass work uniform (same LLM prompt tier for all
|
|
49
|
+
* inputs) and naturally progresses: depth 0 bands get compressed first, producing
|
|
50
|
+
* depth 1 bands, which compress next, etc.
|
|
51
|
+
*
|
|
52
|
+
* Constraints:
|
|
53
|
+
* - Skip compartments with averageDepth >= maxMergeDepth (already maxed out).
|
|
54
|
+
* - Skip the newest graceCompartments (never compress fresh work).
|
|
55
|
+
* - Cap picks at maxPickable to avoid huge LLM inputs.
|
|
56
|
+
* - Cap picks at floorHeadroom to avoid violating min-compartment floor. Each
|
|
57
|
+
* merge reduces count by (input - output), so limiting picks to floorHeadroom
|
|
58
|
+
* guarantees we can't fall below floor even in the worst case (output = 1).
|
|
59
|
+
*/
|
|
60
|
+
export declare function findOldestContiguousSameDepthBand(scored: ScoredCompartment[], constraints: SelectionConstraints): ScoredCompartment[];
|
|
61
|
+
export {};
|
|
16
62
|
//# sourceMappingURL=compartment-runner-compressor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-compressor.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-compressor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compartment-runner-compressor.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-compressor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAQpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAaxD,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAaD,UAAU,iBAAiB;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAqKvF;AAoCD,UAAU,oBAAoB;IAC1B,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uFAAuF;IACvF,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iCAAiC,CAC7C,MAAM,EAAE,iBAAiB,EAAE,EAC3B,WAAW,EAAE,oBAAoB,GAClC,iBAAiB,EAAE,CA6CrB"}
|
|
@@ -12,6 +12,12 @@ export declare function runValidatedHistorianPass(args: {
|
|
|
12
12
|
ordinal: number;
|
|
13
13
|
messageId: string;
|
|
14
14
|
}>;
|
|
15
|
+
/** Tool-only ordinal ranges — passed through to validator so gaps
|
|
16
|
+
* inside these ranges heal regardless of size. */
|
|
17
|
+
toolOnlyRanges?: ReadonlyArray<{
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
}>;
|
|
15
21
|
};
|
|
16
22
|
priorCompartments: StoredCompartmentRange[];
|
|
17
23
|
sequenceOffset: number;
|
|
@@ -19,5 +25,9 @@ export declare function runValidatedHistorianPass(args: {
|
|
|
19
25
|
timeoutMs?: number;
|
|
20
26
|
fallbackModelId?: string;
|
|
21
27
|
callbacks?: HistorianProgressCallbacks;
|
|
28
|
+
/** When true, run a second editor pass after successful historian output
|
|
29
|
+
* to clean low-signal U: lines and cross-compartment duplicates. If editor
|
|
30
|
+
* validation fails, falls back to the draft (first-pass) result. */
|
|
31
|
+
twoPass?: boolean;
|
|
22
32
|
}): Promise<ValidatedHistorianPassResult>;
|
|
23
33
|
//# sourceMappingURL=compartment-runner-historian.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-historian.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-historian.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"compartment-runner-historian.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-historian.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD,OAAO,KAAK,EACR,0BAA0B,EAE1B,sBAAsB,EACtB,4BAA4B,EAC/B,MAAM,4BAA4B,CAAC;AAiBpC,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IAClD,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QACH,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACrD;2DACmD;QACnD,cAAc,CAAC,EAAE,aAAa,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClE,CAAC;IACF,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC;;yEAEqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAkFxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAoBxE,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAoBxE,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+NpF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Compartment } from "../../features/magic-context/compartment-storage";
|
|
2
|
+
import type { CompartmentRunnerDeps } from "./compartment-runner-types";
|
|
3
|
+
export interface PartialRecompRange {
|
|
4
|
+
/** Inclusive raw message ordinal to start rebuilding from. */
|
|
5
|
+
start: number;
|
|
6
|
+
/** Inclusive raw message ordinal to stop rebuilding at. */
|
|
7
|
+
end: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SnappedPartialRange {
|
|
10
|
+
/** Snapped start = first enclosing compartment's startMessage. */
|
|
11
|
+
snapStart: number;
|
|
12
|
+
/** Snapped end = last enclosing compartment's endMessage. */
|
|
13
|
+
snapEnd: number;
|
|
14
|
+
priorCompartments: Compartment[];
|
|
15
|
+
rangeCompartments: Compartment[];
|
|
16
|
+
tailCompartments: Compartment[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Preview-only snap computation. Shown in the first-tap confirmation warning so
|
|
20
|
+
* the user sees which compartments will be replaced before executing.
|
|
21
|
+
*
|
|
22
|
+
* Returns an error string when the requested range cannot be snapped (e.g. no
|
|
23
|
+
* compartments exist yet, or the range is entirely after the last compartment).
|
|
24
|
+
*/
|
|
25
|
+
export declare function snapRangeToCompartments(compartments: Compartment[], range: PartialRecompRange): SnappedPartialRange | {
|
|
26
|
+
error: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function executePartialRecompInternal(deps: CompartmentRunnerDeps, range: PartialRecompRange): Promise<string>;
|
|
29
|
+
//# sourceMappingURL=compartment-runner-partial-recomp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compartment-runner-partial-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-partial-recomp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EAEd,MAAM,kDAAkD,CAAC;AAqB1D,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAU9F,MAAM,WAAW,kBAAkB;IAC/B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAChC,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,YAAY,EAAE,WAAW,EAAE,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA2CzC;AAcD,wBAAsB,4BAA4B,CAC9C,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAkWjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-recomp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compartment-runner-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-recomp.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAc9F,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2T/F"}
|
|
@@ -20,6 +20,15 @@ export interface CompartmentRunnerDeps {
|
|
|
20
20
|
experimentalCompactionMarkers?: boolean;
|
|
21
21
|
/** When true, extract user behavior observations from historian output */
|
|
22
22
|
experimentalUserMemories?: boolean;
|
|
23
|
+
/** When true, inject wall-clock dates on compartments in <session-history>. */
|
|
24
|
+
experimentalTemporalAwareness?: boolean;
|
|
25
|
+
/** When true, run an editor pass after successful historian output to clean
|
|
26
|
+
* low-signal U: lines and cross-compartment duplicates. */
|
|
27
|
+
historianTwoPass?: boolean;
|
|
28
|
+
/** Compressor floor ratio: floor = ceil(lastEndMessage / minCompartmentRatio). */
|
|
29
|
+
compressorMinCompartmentRatio?: number;
|
|
30
|
+
/** Compressor max merge depth (1-5). Compartments at or above this depth are skipped. */
|
|
31
|
+
compressorMaxMergeDepth?: number;
|
|
23
32
|
}
|
|
24
33
|
export interface CandidateCompartment {
|
|
25
34
|
sequence: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-types.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,kBAAkB,CAAC;IACjD,gFAAgF;IAChF,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,0EAA0E;IAC1E,wBAAwB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"compartment-runner-types.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,kBAAkB,CAAC;IACjD,gFAAgF;IAChF,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,0EAA0E;IAC1E,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;gEAC4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,yFAAyF;IACzF,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,4BAA4B,GAClC;IACI,EAAE,EAAE,IAAI,CAAC;IACT,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD"}
|
|
@@ -6,6 +6,11 @@ export declare function validateHistorianOutput(text: string, _sessionId: string
|
|
|
6
6
|
ordinal: number;
|
|
7
7
|
messageId: string;
|
|
8
8
|
}>;
|
|
9
|
+
/** Optional — when provided, gaps inside these ranges heal at any size. */
|
|
10
|
+
toolOnlyRanges?: ReadonlyArray<{
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}>;
|
|
9
14
|
}, _priorCompartments: StoredCompartmentRange[], sequenceOffset: number): ValidatedHistorianPassResult;
|
|
10
15
|
export declare function buildHistorianRepairPrompt(originalPrompt: string, previousOutput: string, validationError: string): string;
|
|
11
16
|
export declare function validateStoredCompartments(compartments: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-validation.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,sBAAsB,EACtB,4BAA4B,EAC/B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"compartment-runner-validation.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,sBAAsB,EACtB,4BAA4B,EAC/B,MAAM,4BAA4B,CAAC;AAmDpC,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,2EAA2E;IAC3E,cAAc,CAAC,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClE,EACD,kBAAkB,EAAE,sBAAsB,EAAE,EAC5C,cAAc,EAAE,MAAM,GACvB,4BAA4B,CAyC9B;AAED,wBAAgB,0BAA0B,CACtC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACxB,MAAM,CAaR;AAED,wBAAgB,0BAA0B,CACtC,YAAY,EAAE,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAClE,MAAM,GAAG,IAAI,CAoBf;AAgDD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrC,GAAG,MAAM,GAAG,IAAI,CAkBhB;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhF"}
|
|
@@ -1,6 +1,36 @@
|
|
|
1
|
+
import { type PartialRecompRange } from "./compartment-runner-partial-recomp";
|
|
1
2
|
import type { CompartmentRunnerDeps } from "./compartment-runner-types";
|
|
2
3
|
export declare function getActiveCompartmentRun(sessionId: string): Promise<void> | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Register a compartment-state-mutating promise with the active-runs map.
|
|
6
|
+
*
|
|
7
|
+
* Use this to serialize background compressor runs against historian/recomp
|
|
8
|
+
* runs: both read-modify-write compartment rows, and while SQLite serializes
|
|
9
|
+
* individual statements it does NOT serialize multi-step update cycles. If a
|
|
10
|
+
* historian starts while a background compressor is still running, either
|
|
11
|
+
* side's final write can overwrite the other's work.
|
|
12
|
+
*
|
|
13
|
+
* The registered promise is cleared from activeRuns on settle so later passes
|
|
14
|
+
* can start a new run. If a run is already registered for the session, the
|
|
15
|
+
* caller is expected to have checked getActiveCompartmentRun() first and
|
|
16
|
+
* bailed — this function will overwrite silently if called anyway, which is
|
|
17
|
+
* the desired behavior for the retry path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerActiveCompartmentRun(sessionId: string, promise: Promise<void>): void;
|
|
3
20
|
export declare function startCompartmentAgent(deps: CompartmentRunnerDeps): void;
|
|
4
|
-
export
|
|
21
|
+
export interface ExecuteContextRecompOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Optional partial range (inclusive raw message ordinals). When provided,
|
|
24
|
+
* runs partial recomp — snaps to enclosing compartment boundaries and
|
|
25
|
+
* rebuilds only the matching compartments, preserving prior/tail
|
|
26
|
+
* compartments and all session facts.
|
|
27
|
+
*
|
|
28
|
+
* When omitted, runs full recomp from message 1 to the protected tail,
|
|
29
|
+
* replacing all compartments and facts.
|
|
30
|
+
*/
|
|
31
|
+
range?: PartialRecompRange;
|
|
32
|
+
}
|
|
33
|
+
export declare function executeContextRecomp(deps: CompartmentRunnerDeps, options?: ExecuteContextRecompOptions): Promise<string>;
|
|
5
34
|
export { runCompartmentAgent } from "./compartment-runner-incremental";
|
|
35
|
+
export type { PartialRecompRange } from "./compartment-runner-partial-recomp";
|
|
6
36
|
//# sourceMappingURL=compartment-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compartment-runner.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,kBAAkB,EAC1B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAIxE,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAEpF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAS5F;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CA0BvE;AAED,MAAM,WAAW,2BAA2B;IACxC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CACtC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,GAAE,2BAAgC,GAC1C,OAAO,CAAC,MAAM,CAAC,CAsBjB;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -22,6 +22,10 @@ export interface EventHandlerDeps {
|
|
|
22
22
|
default: number;
|
|
23
23
|
[modelKey: string]: number;
|
|
24
24
|
};
|
|
25
|
+
execute_threshold_tokens?: {
|
|
26
|
+
default?: number;
|
|
27
|
+
[modelKey: string]: number | undefined;
|
|
28
|
+
};
|
|
25
29
|
cache_ttl: CacheTtlConfig;
|
|
26
30
|
commit_cluster_trigger?: {
|
|
27
31
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAqBvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAmBvE,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKhF,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD,UAAU,iBAAiB;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB;AAOD,MAAM,WAAW,gBAAgB;IAC7B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,iBAAiB,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IAC9D,eAAe,EAAE,mBAAmB,CAAC;IACrC,yB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,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAkTzF"}
|
|
@@ -5,7 +5,45 @@ type ExecuteThresholdConfig = number | {
|
|
|
5
5
|
default: number;
|
|
6
6
|
[modelKey: string]: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type ExecuteThresholdTokensConfig = {
|
|
9
|
+
default?: number;
|
|
10
|
+
[modelKey: string]: number | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
export interface ExecuteThresholdOptions {
|
|
13
|
+
/** Optional tokens-based threshold config. When matched for the given modelKey,
|
|
14
|
+
* overrides the percentage-based threshold. */
|
|
15
|
+
tokensConfig?: ExecuteThresholdTokensConfig;
|
|
16
|
+
/** Required when `tokensConfig` is provided — used to convert tokens → percentage
|
|
17
|
+
* and to clamp values above 80% × context_limit. */
|
|
18
|
+
contextLimit?: number;
|
|
19
|
+
/** Session ID for warn logs when clamping. If absent, warns to global log. */
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
}
|
|
22
|
+
export type ExecuteThresholdMode = "percentage" | "tokens";
|
|
23
|
+
export interface ExecuteThresholdDetail {
|
|
24
|
+
/** Effective execute threshold as a percentage (0–80). Downstream math keys off this. */
|
|
25
|
+
percentage: number;
|
|
26
|
+
/** Which source was authoritative: tokens config (when matched + valid context) or percentage. */
|
|
27
|
+
mode: ExecuteThresholdMode;
|
|
28
|
+
/** When mode is "tokens", the absolute token value after clamping (≤ 80% × contextLimit). */
|
|
29
|
+
absoluteTokens?: number;
|
|
30
|
+
/** The config key that matched, if any (for display/debugging). `"default"` when default fallback. */
|
|
31
|
+
matchedKey?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Single source of truth for execute-threshold resolution. Returns the effective
|
|
35
|
+
* percentage plus which config source was authoritative. Callers that only need
|
|
36
|
+
* the percentage can use `resolveExecuteThreshold` (thin wrapper below); callers
|
|
37
|
+
* that surface the mode to users (`/ctx-status`, TUI, RPC) must use this directly
|
|
38
|
+
* to avoid the "progressive lookup drift" bug where two call sites disagree on
|
|
39
|
+
* whether tokens mode is active.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveExecuteThresholdDetail(config: ExecuteThresholdConfig, modelKey: string | undefined, fallback: number, options?: ExecuteThresholdOptions): ExecuteThresholdDetail;
|
|
42
|
+
/**
|
|
43
|
+
* Backward-compatible wrapper around `resolveExecuteThresholdDetail`.
|
|
44
|
+
* Use the detail version when you also need the mode or absolute token value.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveExecuteThreshold(config: ExecuteThresholdConfig, modelKey: string | undefined, fallback: number, options?: ExecuteThresholdOptions): number;
|
|
9
47
|
export declare function resolveModelKey(providerID: string | undefined, modelID: string | undefined): string | undefined;
|
|
10
48
|
export declare function resolveSessionId(properties: {
|
|
11
49
|
info?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-resolvers.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-resolvers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-resolvers.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-resolvers.ts"],"names":[],"mappings":"AAMA,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD,wBAAgB,mBAAmB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAiBR;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAiB9F;AAED,KAAK,sBAAsB,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AACvF,KAAK,4BAA4B,GAC3B;IAA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AG,SAAS,CAmBpB"}
|
|
@@ -5,5 +5,8 @@ export declare function executeStatus(db: Database, sessionId: string, protected
|
|
|
5
5
|
}, liveModelKey?: string, historyBudgetPercentage?: number, commitClusterTrigger?: {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
min_clusters: number;
|
|
8
|
-
}
|
|
8
|
+
}, executeThresholdTokens?: {
|
|
9
|
+
default?: number;
|
|
10
|
+
[modelKey: string]: number | undefined;
|
|
11
|
+
}, contextLimit?: number): string;
|
|
9
12
|
//# sourceMappingURL=execute-status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-status.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/execute-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-status.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/execute-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAyC3C,wBAAgB,aAAa,CACzB,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,mBAAmB,GAAE,MAAsC,EAC3D,gCAAgC,GAC1B,MAAM,GACN;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAyC,EAC5F,YAAY,CAAC,EAAE,MAAM,EACrB,uBAAuB,CAAC,EAAE,MAAM,EAChC,oBAAoB,CAAC,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EACjE,sBAAsB,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,EACrF,YAAY,CAAC,EAAE,MAAM,GACtB,MAAM,CA8JR"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { AgentOverrideConfigSchema } from "../../config/schema/agent-overrides";
|
|
3
|
-
import { type DreamerConfig, type SidekickConfig } from "../../config/schema/magic-context";
|
|
1
|
+
import { type DreamerConfig, type HistorianConfig, type SidekickConfig } from "../../config/schema/magic-context";
|
|
4
2
|
import type { createCompactionHandler } from "../../features/magic-context/compaction";
|
|
5
3
|
import type { Scheduler } from "../../features/magic-context/scheduler";
|
|
6
4
|
import type { Tagger } from "../../features/magic-context/tagger";
|
|
@@ -27,8 +25,12 @@ export interface MagicContextDeps {
|
|
|
27
25
|
default: number;
|
|
28
26
|
[modelKey: string]: number;
|
|
29
27
|
};
|
|
28
|
+
execute_threshold_tokens?: {
|
|
29
|
+
default?: number;
|
|
30
|
+
[modelKey: string]: number | undefined;
|
|
31
|
+
};
|
|
30
32
|
cache_ttl: string | Record<string, string>;
|
|
31
|
-
historian?:
|
|
33
|
+
historian?: HistorianConfig;
|
|
32
34
|
history_budget_percentage?: number;
|
|
33
35
|
historian_timeout_ms?: number;
|
|
34
36
|
memory?: {
|
|
@@ -42,6 +44,12 @@ export interface MagicContextDeps {
|
|
|
42
44
|
min_clusters: number;
|
|
43
45
|
};
|
|
44
46
|
compaction_markers?: boolean;
|
|
47
|
+
compressor?: {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
min_compartment_ratio: number;
|
|
50
|
+
max_merge_depth: number;
|
|
51
|
+
cooldown_ms: number;
|
|
52
|
+
};
|
|
45
53
|
experimental?: {
|
|
46
54
|
user_memories?: {
|
|
47
55
|
enabled: boolean;
|
|
@@ -52,6 +60,7 @@ export interface MagicContextDeps {
|
|
|
52
60
|
token_budget: number;
|
|
53
61
|
min_reads: number;
|
|
54
62
|
};
|
|
63
|
+
temporal_awareness?: boolean;
|
|
55
64
|
};
|
|
56
65
|
};
|
|
57
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/hook.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAOvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAMxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAaxD,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAUnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,yBAAyB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,iBAAiB,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IAC9D,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,MAAM,EAAE;QACJ,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,yBAAyB,CAAC,EAAE,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,CAAC;KACL,CAAC;CACL;AAqCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB;;;;;iBAlDvC,CAAC;;;;;;;;;;;;iBAzBwB,CAAC;eAC5C,CAAC;aAAe,CAAC;;mBAoaQ;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;;;SAa7E"}
|
|
@@ -18,6 +18,6 @@ export interface CompartmentInjectionResult {
|
|
|
18
18
|
skippedVisibleMessages: number;
|
|
19
19
|
}
|
|
20
20
|
export declare function renderMemoryBlock(memories: Memory[]): string | null;
|
|
21
|
-
export declare function prepareCompartmentInjection(db: Database, sessionId: string, messages: MessageLike[], isCacheBusting: boolean, projectPath?: string, injectionBudgetTokens?: number): PreparedCompartmentInjection | null;
|
|
21
|
+
export declare function prepareCompartmentInjection(db: Database, sessionId: string, messages: MessageLike[], isCacheBusting: boolean, projectPath?: string, injectionBudgetTokens?: number, temporalAwareness?: boolean): PreparedCompartmentInjection | null;
|
|
22
22
|
export declare function renderCompartmentInjection(sessionId: string, messages: MessageLike[], prepared: PreparedCompartmentInjection): CompartmentInjectionResult;
|
|
23
23
|
//# sourceMappingURL=inject-compartments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-compartments.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/inject-compartments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"inject-compartments.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/inject-compartments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAU3C,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,2CAA2C,CAAC;AAIxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC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AC;AA+BzD,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yBAAyB,EAAE,MAAM,CAAC;IAClC,4BAA4B,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvF,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C,IAIO,WAAW,MAAM,EACjB,cAAc,YAAY,EAC1B,IAAI,eAAe,EACnB,QAAQ,OAAO,aAAa,EAC5B,gBAAgB,QAAQ,EAAE,EAC1B,wBAAwB,MAAM,EAC9B,uBAAuB,WAAW,KACnC,YAAY,GAAG,IAAI,CAyIzB;AAyED,wBAAgB,0BAA0B,CACtC,EAAE,EAAE,eAAe,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,GACnC,MAAM,CA2BR"}
|
|
@@ -15,6 +15,17 @@ export interface SessionChunk {
|
|
|
15
15
|
lines: SessionChunkLine[];
|
|
16
16
|
/** Number of distinct commit clusters — assistant blocks with commits separated by meaningful user turns */
|
|
17
17
|
commitClusterCount: number;
|
|
18
|
+
/**
|
|
19
|
+
* Contiguous ranges of raw message ordinals whose visible chunk content was
|
|
20
|
+
* tool-only (TC: lines, no narrative text). Historian frequently skips such
|
|
21
|
+
* ranges entirely — that's safe, so validation absorbs gaps that fall fully
|
|
22
|
+
* within these ranges regardless of size. Gaps outside these ranges still
|
|
23
|
+
* fail validation and trigger a repair retry.
|
|
24
|
+
*/
|
|
25
|
+
toolOnlyRanges: Array<{
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
}>;
|
|
18
29
|
}
|
|
19
30
|
export declare function withRawSessionMessageCache<T>(fn: () => T): T;
|
|
20
31
|
export declare function readRawSessionMessages(sessionId: string): RawMessage[];
|
|
@@ -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,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;
|
|
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;IAC3B;;;;;;OAMG;IACH,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD;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,CAWtE;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,MAAU,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC5B,YAAY,CA+Ld;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9F"}
|
|
@@ -2,4 +2,17 @@ import { Database } from "bun:sqlite";
|
|
|
2
2
|
export declare function withReadOnlySessionDb<T>(fn: (db: Database) => T): T;
|
|
3
3
|
export declare function closeReadOnlySessionDb(): void;
|
|
4
4
|
export declare function getRawSessionMessageCountFromDb(db: Database, sessionId: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve `time_created` (ms since epoch) for a set of OpenCode message IDs.
|
|
7
|
+
* Returns a Map keyed by message ID. Missing IDs are simply omitted.
|
|
8
|
+
*
|
|
9
|
+
* Used by temporal-awareness to map compartment start/end message IDs to
|
|
10
|
+
* wall-clock dates for the `start="YYYY-MM-DD"` / `end="YYYY-MM-DD"` attrs
|
|
11
|
+
* on the `<compartment>` elements in `<session-history>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMessageTimesFromOpenCodeDb(sessionId: string, messageIds: readonly string[]): Map<string, number>;
|
|
14
|
+
export declare function findLastAssistantModelFromOpenCodeDb(sessionId: string): {
|
|
15
|
+
providerID: string;
|
|
16
|
+
modelID: string;
|
|
17
|
+
} | null;
|
|
5
18
|
//# sourceMappingURL=read-session-db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-session-db.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAyCtC,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,CAAC,GAAG,CAAC,CAEnE;AAGD,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAYvF"}
|
|
1
|
+
{"version":3,"file":"read-session-db.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAyCtC,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,CAAC,GAAG,CAAC,CAEnE;AAGD,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAYvF;AAoBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CACzC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,SAAS,MAAM,EAAE,GAC9B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAyBrB;AAED,wBAAgB,oCAAoC,CAChD,SAAS,EAAE,MAAM,GAClB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAyBhD"}
|
|
@@ -9,6 +9,13 @@ export interface ChunkBlock {
|
|
|
9
9
|
parts: string[];
|
|
10
10
|
meta: SessionChunkLine[];
|
|
11
11
|
commitHashes: string[];
|
|
12
|
+
/**
|
|
13
|
+
* True when every part in this block came from tool-call summaries only
|
|
14
|
+
* (no textual narrative from the user or assistant). Historian often skips
|
|
15
|
+
* such blocks — that's safe as long as we know the skipped range is
|
|
16
|
+
* tool-only, so we mark the block here and let validation absorb the gap.
|
|
17
|
+
*/
|
|
18
|
+
isToolOnly: boolean;
|
|
12
19
|
}
|
|
13
20
|
export declare function hasMeaningfulUserText(parts: unknown[]): boolean;
|
|
14
21
|
export declare function extractTexts(parts: unknown[]): string[];
|