Skip to content

Releases: cortexkit/opencode-magic-context

v0.7.4

06 Apr 17:06

Choose a tag to compare

Bug Fixes

  • Web mode commands/ctx-status and other /ctx-* commands now work in opencode web mode. Fixed a bug where undefined OPENCODE_CLIENT was treated as TUI mode, which removed server-side command registration and broke notifications for web users. (Fixes #1)

v0.7.3

05 Apr 22:19

Choose a tag to compare

Bug Fixes

  • Fixed /ctx-status dialog crash on newer @opentui/solid — nested <text> elements inside <text> are no longer allowed by the TUI renderer. Split the title into sibling elements inside a <box> container.

v0.7.1

05 Apr 15:38

Choose a tag to compare

Bug Fixes

  • Dreamer re-enqueue loop — Dreamer's own memory mutations (consolidate, verify, improve, archive) set updated_at on modified memories, which made the next scheduler check think there was new user activity and re-enqueue the project. This caused 4+ dream runs per night instead of 1. Fixed with a 12-hour cooldown: findProjectsNeedingDream now skips projects whose last_dream_at is less than 12 hours old.

v0.7.0

05 Apr 14:34

Choose a tag to compare

What's New

Experimental: Key File Pinning

Dreamer analyzes which files each session's agent reads most frequently (full reads only, not partial ranges) and pins core orientation files into the system prompt as a <key-files> block. Files are read fresh from disk on each cache-busting pass so edits are always reflected.

Enable with:

"experimental": {
  "pin_key_files": {
    "enabled": true,
    "token_budget": 10000,
    "min_reads": 4
  }
}

Requires dreamer to be enabled. The dreamer uses LLM evaluation to distinguish true orientation files from task-specific reads, with a heuristic fallback when the LLM is unavailable.

Security

  • Path traversal guard with realpathSync() symlink resolution on key-file injection
  • XML content and attribute escaping using shared utilities
  • LLM output filtered against candidate allow-set to prevent hallucinated file pinning
  • PRAGMA busy_timeout=5000 on OpenCode DB readonly connections

Improvements

  • ctx_note dismiss hint: single footer line instead of per-note boilerplate
  • Token estimation standardized to ÷3.5 ratio across all plugin and TUI estimation sites
  • setKeyFiles ensures session_meta row exists before UPDATE
  • Compressor same-turn injection refresh after compression
  • clearInjectionCache added at all data-change points
  • knapsackFitFiles renamed to greedyFitFiles (accurate naming)
  • ctx_note update action for editing smart note content and conditions

v0.6.2

05 Apr 09:31

Choose a tag to compare

v0.6.2

Fixes

  • FTS full reindex on message removaldeleteIndexedMessage now clears all FTS rows and the tracker to avoid ordinal skipping when messages are added after a removal
  • Memory cache invalidation on all mutation pathsinvalidateAllMemoryBlockCaches now runs after update, merge, and archive actions (was only write/delete)
  • Stale anchor clearing — sticky turn reminders and note nudges with missing anchors are now cleared on cache-busting passes instead of re-anchored to unrelated messages
  • Dashboard tray includes permanent memories — "Run Dreamer" tray action now queries both active and permanent memories for project identity
  • Dashboard notes tab count — includes both session notes and smart notes in the tab count
  • NaN guard on context percentage — division by zero protection when context limit is 0
  • Compaction marker state preserved on removal failure — partial failures no longer orphan OpenCode DB rows
  • Migration v1 row count verification — INSERT count checked before DROP TABLE

v0.6.1

04 Apr 23:32

Choose a tag to compare

Bug Fixes

  • Heuristic tool dedup restoredextractToolInfo was reading tool names from state.tool instead of part.tool, so the DEDUP_SAFE_TOOLS deduplication path (mcp_grep, mcp_read, etc.) never fired in production. Fixed to match real OpenCode tool part shape.
  • Dashboard config pathresolve_project_config_path now checks both <project>/magic-context.jsonc and <project>/.opencode/magic-context.jsonc, so dashboard edits target the correct active config.
  • Message bus atomicityconsumeMessages SELECT+UPDATE now wrapped in a SQLite transaction, preventing duplicate message consumption when TUI and server poll concurrently.
  • "action" message type — added to the MessageType union with proper typing, removing the as never type bypass in the TUI action consumer.
  • Dashboard foreign keys — added PRAGMA foreign_keys=ON to the dashboard's writable DB connection so ON DELETE CASCADE works correctly (fixes orphaned memory_embeddings on memory delete).
  • Dashboard toggle defaults — dreamer, sidekick, and inject_docs toggles now default to false matching the schema, instead of showing enabled when the config is unset.
  • Session cleanupclearSession now deletes user_memory_candidates for the session, preventing orphaned candidate data from accumulating after session deletion.
  • Memory count accuracygetMemoryCountsByStatus no longer double-counts merged memories as both merged and archived.

443 tests passing.

v0.6.0

04 Apr 21:46

Choose a tag to compare

What's New

🧪 New Experimental Features

Compaction Markers — after historian compresses older messages, Magic Context injects a boundary into OpenCode's message table. OpenCode's filterCompacted stops at the boundary, so the transform processes only the live tail instead of the full session history. Dramatically reduces per-turn overhead on long sessions. Enable with experimental.compaction_markers: true.

User Memories — historian extracts behavioral observations about the user alongside its normal compartment output (communication style, expertise level, review focus, working patterns). Recurring observations are promoted by the dreamer to stable user memories that appear in all sessions via <user-profile> in the system prompt. Enable with experimental.user_memories.enabled: true (requires dreamer).

Features

  • Unified notessession_notes and smart_notes merged into a single notes table with unified ID space. ctx_note gains update action for editing existing notes. ctx_note read supports filter param (all, pending, ready, dismissed).
  • Plugin message bus — SQLite-backed plugin_messages table for TUI ↔ server communication. TUI toasts, confirmation dialogs, and action triggers now flow through the bus instead of brittle ignored-message hacks.
  • Doctor CLIbunx @cortexkit/opencode-magic-context doctor auto-fixes plugin registration, TUI config, compaction/DCP/OMO conflicts, and reports missing config.
  • /ctx-recomp confirmation — TUI shows a native confirmation dialog; Desktop uses a double-tap safety gate. Both show compartment count and cost warning before proceeding.
  • TUI action consumer — server polls for TUI-initiated actions so TUI dialogs can trigger server-side operations without slash command round-trips.
  • Version display/ctx-status dialog and TUI sidebar now show the installed version.
  • Comment-preserving config edits — all JSONC config writes (setup, doctor, conflict fixer) now use comment-json to preserve user comments.
  • Nested experimental configexperimental_compaction_markersexperimental.compaction_markers and new experimental.user_memories under a clean namespace.
  • JSON Schemaassets/magic-context.schema.json for editor autocomplete and validation, auto-regenerated on release.
  • Auto tui.json setup — server plugin auto-adds TUI entry on startup with a one-time notification.
  • Startup conflict detection — warns about compaction/DCP/OMO conflicts via toast (TUI) or notification (Desktop).
  • ctx_search boundary filter — message history results now exclude ordinals still in the live unsummarized tail.
  • ctx_note update — edit content and/or surface_condition of existing notes.
  • message.removed cleanup — tags, FTS index, note/nudge anchors, stripped-placeholder state all cleaned when messages are reverted.
  • Historian TC summaries — tool-only assistant turns now emit compact TC: lines so historian sees what happened during tool-heavy work.
  • Session token breakdown — dashboard shows proportional bar for System/Compartments/Facts/Memories/Conversation tokens.

Bug Fixes

  • Cache-bust fix — decoupled injection cache from scheduler execute decision. <session-history> is no longer re-rendered from scratch on every turn above the execute threshold; the injection cache is only invalidated when compartments/facts/memories actually change.
  • Memory sort tiebreakertrimMemoriesToBudget now uses id as tiebreaker for deterministic cache-stable ordering.
  • Anchor re-anchoring — sticky turn reminders, assistant nudges, and note nudges now re-anchor to the latest visible message on cache-busting passes when the original anchor falls behind the compaction boundary.
  • Migration safety — migration v1 (unified notes) verifies row counts before dropping source tables.
  • Compaction marker state — preserved on removal failure so the next update can retry instead of orphaning DB rows.
  • Projected reasoning bytes — historian trigger projection now counts reasoningByteSize on tool tags for accurate reclaim estimates.
  • History-budget mathexecute_threshold_percentage resolution now uses live model key in all code paths.
  • Heuristic cleanup on execute — no longer gated on hasPendingUserOps when ctx_reduce_enabled: false.
  • New session scheduler — sessions with lastResponseTime=0 and context=0% return "defer" instead of running pointless execute passes.
  • Dashboard first-message labeling — correctly identifies the true first message of a session, not the oldest in the display window.
  • TUI src/shared packagingsrc/shared now included in npm files so TUI imports resolve from published packages.

Internal

  • Versioned migration framework (schema_migrations table) for safe multi-version schema upgrades
  • plugin_messages table for cross-process communication
  • user_memory_candidates and user_memories tables
  • 443 tests passing

v0.5.2

03 Apr 16:34

Choose a tag to compare

v0.5.2

New Features

  • TUI Sidebar — Live context breakdown bar in OpenCode's terminal UI showing token usage split across System Prompt, Compartments, Facts, Memories, and Conversation. Includes historian status, memory counts, dreamer last run, and pending queue count. Updates after every message.
  • TUI Commands/ctx-status, /ctx-flush, and /ctx-aug work directly in TUI mode via dialogs and toasts.
  • Doctor CLIbunx @cortexkit/opencode-magic-context doctor auto-detects and fixes configuration issues: verifies plugin registration, checks for conflicts (compaction, DCP, OMO hooks), ensures TUI sidebar is configured, and adds the plugin entry to opencode.json if missing.
  • Startup Conflict Detection — On startup, the plugin checks for compaction/DCP/OMO conflicts and warns the active session with a fix suggestion.
  • Auto tui.json Setup — Server plugin automatically adds the TUI plugin entry to tui.json on startup and notifies the user to restart.
  • JSON Schema — Published magic-context.schema.json for editor autocomplete and validation. Setup wizard adds $schema automatically.

Improvements

  • ctx_search message filter — Message history results now exclude messages still in the live context (not yet compartmentalized), reducing noise from content the agent can already see.
  • Comment-preserving config edits — CLI config writes (setup, doctor) now use comment-json to preserve user comments through read-modify-write cycles.
  • Nudge anchor reset — Rolling nudge positions properly reset after queue execution so they don't drift to unreachable token counts.
  • Status dialog/ctx-status in TUI shows full categorized progress bar with per-model config resolution for thresholds and TTL.

Bug Fixes

  • Fixed enabled schema default from false to true (zero-config installs no longer silently disabled the plugin).
  • Fixed protected_tags config range from 1-20 to 1-100.
  • Fixed TUI crash when installed from npm — conflict-fixer.ts no longer imports comment-json (npm dep unavailable in TUI's raw-source runtime).
  • Fixed doctor issue counting and config filename display.

Documentation

  • README: Added TUI Sidebar section, Startup Conflict Detection section, JSON Schema tip, dream_runs and compression_depth storage tables.
  • CONFIGURATION.md: Added JSON Schema and Doctor sections, fixed enabled default and protected_tags range.
Sidebar New Status Dialog
image image

v0.4.2

01 Apr 22:28

Choose a tag to compare

Bug Fixes

  • enabled now defaults to true — installing the plugin activates it without requiring "enabled": true in magic-context.jsonc. Previously defaulted to false, which meant users who installed the plugin without a config file got no functionality. The config-parse failure fallback correctly stays enabled: false.

SORRY!

v0.4.1

01 Apr 21:27

Choose a tag to compare

What's New

Proactive Memory Embedding

Memories are now embedded immediately after ctx_memory write (fire-and-forget) and swept periodically on the dream timer. The first ctx_search after dreamer runs no longer pays bulk embedding latency. The lazy search-time fallback remains as a safety net.

Smarter Compressor Selection

The compressor no longer always picks the oldest compartments for compression. A new weighted scoring system (0.7 × age + 0.3 × inverse compression depth) prevents the earliest compartments from being re-compressed indefinitely while untouched middle history exists. Per-message compression depth is tracked in a new compression_depth table and incremented after each successful pass.

Depth-Aware U: Line Handling

The compressor prompt now adapts based on how many times the selected compartments have been compressed:

  • Avg depth < 2: Preserve all U: lines exactly as-is — compression targets prose only
  • Avg depth 2–3: Condense each U: line to its core intent in one sentence
  • Avg depth 3+: Fold U: intent into narrative prose — no separate U: lines

This preserves user voice in recent history while allowing graceful degradation in ultra-long sessions.

Bug Fixes

  • History budget formula: Was contextLimit × historyBudgetPercentage, now correctly contextLimit × executeThreshold × historyBudgetPercentage as originally designed. With execute_threshold=40% and history_budget=15%, the budget was 150k (wrong) instead of the correct 60k.