← Back to Leaderboard
Mcortexkit

cortexkit/magic-context

Coding-agent extensions for cache-aware compaction and persistent project memory

Engineering Health (Methodology)
A+ · 90/100
Maintenance Activity
● Updated today
Latest Release
v0.49.104
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption15/25
Release Cadence20/20
License Clarity20/20
CLI
Total Stars
★ 2,588
24h Growth
+6
7d Growth
+24
Forks
153

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

cortexkit/magic-context Star History (2026-03-25 - 2026-12-04) ALL-TIME STAR HISTORY (2026-03 – 2026-12) +2.6k in 254d · avg +10/day 2.7k 1.4k 0 2026-03-25: ★ 12026-04-11: ★ 1292026-05-02: ★ 4552026-05-23: ★ 6622026-06-13: ★ 8692026-07-04: ★ 1,1392026-07-25: ★ 1,4172026-08-15: ★ 1,6852026-09-05: ★ 1,9782026-09-26: ★ 2,1572026-10-17: ★ 2,3142026-11-02: ★ 2,4392026-11-18: ★ 2,5282026-12-04: ★ 2,588 ★ 2.6k 2026-03 2026-07 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & 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.

Host adapters: OpenCode 1.x and 2.x use different plugin APIs over one core; Pi and Oh My Pi reuse that core.
Prompt-cache preservation: ctx_reduce queues removals for cache-safe points; deterministic decay controls how much detail older summaries contribute.
Shared project memory: OpenCode and Pi pool memories and embeddings in the same database, and ctx_memory provides explicit writes and deletes.
Retrieval: ctx_search spans memories, conversations, indexed Git commits, notes, and primers; ctx_expand recovers original transcript text.
Model routing: Historian and dreamer settings are per host, and Oh My Pi falls back to Pi settings only when its own block is absent.
Release v0.49.96: Long messages are ranked by the matching passage, and doctor flags a known SQLite fault in a host runtime.
Best For

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.

Skip If

Work is mostly short and independent, the host's native compaction is sufficient, or project policy prohibits persistent transcripts or background model calls.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releases · Newer release v0.49.104 (2026-12-03) shipped after this reviewMethodology

Quick Start & Installation

CLI
npx @cortexkit/magic-context@latest setup

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/cortexkit/magic-context.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

cortexkit/magic-context Star History on RepoForAI

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?

No. It is installed as a host extension: OpenCode 1.x and 2.x use separate adapters over a shared TypeScript core, while Pi and Oh My Pi use a package that imports that core. The Rust 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?

There is no fixed GPU or VRAM requirement in the available specifications. The default embedding model is local 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?

Yes. MIT permits commercial use and self-hosting, subject to retaining the required copyright and license notices. That license does not govern model-provider terms or make it permissible to send proprietary transcripts to a hosted model. For sensitive projects, verify the effective model configuration and access to the shared memory store before rollout.

When is this preferable to the host's built-in compaction?

Keep native compaction if you mainly need short, independent sessions and want fewer moving parts. Choose Magic Context if you need background summarization, deliberate timing of prompt reductions, and recall of project decisions or older transcripts. Disable the host's own compaction when using Magic Context so the two mechanisms do not compete.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining cortexkit/magic-context? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature cortexkit/magic-context on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

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

Saved in your browser · Export Markdown RFC tables or jump into /vs compare