cortexkit/magic-context
Coding-agent extensions for cache-aware compaction and persistent project memory
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Magic Context is a host-integrated extension, not a standalone MCP service. OpenCode 1.x and 2.x adapt their different plugin APIs to the same TypeScript core in packages/plugin; packages/pi-plugin imports that core for Pi and Oh My Pi. The Rust ck-mc module runs the context transform and historian inside the subc daemon for sessions hosted in a runner rather than a plugin host. The source workspace declares Bun >=1.4.0 and includes a Cargo workspace.
The historian converts older conversation into chronological, importance-scored summaries and extracts durable facts into project memory in the same pass. The prompt transform renders older summaries at progressively lower detail using deterministic rules. Reductions requested through ctx_reduce are queued and applied at cache-safe points rather than immediately rewriting the prompt prefix. OpenCode and Pi share a database for memories and embeddings.
Key Capabilities & Differentiators
Active project memories and compacted history are injected each turn. ctx_search queries project memory, raw conversations, indexed Git commits, notes, and primers with semantic retrieval and a full-text fallback; ctx_expand restores exact transcript text when a summary is insufficient. ctx_memory explicitly writes or deletes categorized facts. Embeddings default to local Xenova/all-MiniLM-L6-v2; disabling them leaves keyword retrieval and context management in place.
The optional dreamer runs maintenance in ephemeral child sessions: it can map memories to source files, verify and deduplicate them, refresh primers, and update ARCHITECTURE.md and STRUCTURE.md. /ctx-dream triggers a run on demand. Historian and dreamer model settings are host-specific. If Oh My Pi has no setting block for either component, it uses that component's Pi block; an explicit OMP block takes precedence even if it omits a model.
Trade-offs & Limitations
Compared with built-in compaction, Magic Context gives teams more control over when the prompt changes and what remains retrievable across turns and sessions. In return, it takes over a host responsibility: leaving native compaction enabled can cause double compression and interfere with deferred reductions. The model window is still finite, summaries can omit details, and the value of preserving the prefix depends on the provider's cache behavior. Validate cache reuse and recovery from raw history on representative sessions before switching a team over.
A smaller historian can keep auxiliary inference separate from the primary coding model, but local inference competes for workstation resources while hosted inference adds cost and may send project text outside the machine. The optional dreamer adds ongoing maintenance work and can update project documentation, so decide whether that belongs in your workflow before enabling it. MIT permits commercial use, but it does not resolve provider data-handling terms or determine who should have access to persisted history.
Hardware & Deployment Guide
Run npx @cortexkit/magic-context@latest setup to detect and configure installed hosts, or target one via --harness opencode, --harness pi, or --harness omp. Pi requires >=0.74.0 and Oh My Pi >=17.1.7. Restart the host after setup. For manual OpenCode setup, register @cortexkit/opencode-magic-context, disable both compaction.auto and compaction.prune, and set historian.opencode.model in magic-context.jsonc. Project config at .cortexkit/magic-context.jsonc overlays user config under ~/.config/cortexkit/ unless the user config location has been redirected.
Historian and dreamer models can run locally or use hosted inference; actual resources depend on model choice and concurrent background work. Docker appears in the test scripts, not as a requirement for normal host installation. v0.49.95 extended search and expansion to messages removed from the live prompt. v0.49.96 fixed OpenCode 2 behavior after /compact and in the session list, improved long-message ranking, and added a doctor warning for a known host SQLite fault.
ctx_reduce queues removals for cache-safe points; deterministic decay controls how much detail older summaries contribute.ctx_memory provides explicit writes and deletes.ctx_search spans memories, conversations, indexed Git commits, notes, and primers; ctx_expand recovers original transcript text.doctor flags a known SQLite fault in a host runtime.Teams running long-lived OpenCode, Pi, or Oh My Pi sessions that want to preserve prompt-cache reuse and recover past decisions without reloading entire transcripts.
Work is mostly short and independent, the host's native compaction is sufficient, or project policy prohibits persistent transcripts or background model calls.
Quick Start & Installation
npx @cortexkit/magic-context@latest setupAI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/cortexkit/magic-context.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about magic-context
Does Magic Context run as a standalone MCP server?
ck-mc module handles context transforms and historian work for runner-hosted sessions. The setup CLI configures the integration; it is not the session runtime.Do I need a GPU, and what overhead should I plan for?
Xenova/all-MiniLM-L6-v2; turning embeddings off retains full-text search and context management. For local historian or dreamer models, size for the model and inference workload. For hosted models, budget for auxiliary requests as well as the primary coding agent.Can we use it commercially or run models on our own infrastructure?
When is this preferable to the host's built-in compaction?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy