[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-92334":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":17,"hasPages":17,"topics":19,"createdAt":9,"pushedAt":9,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":14,"starSnapshotCount":14,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},92334,"magic-compact","aerovato\u002Fmagic-compact","aerovato","Lossless context compression plugin for Claude Code & OpenCode.",null,"TypeScript",97,7,1,0,39,43.61,false,"main",[],"2026-07-22 04:02:05","# Magic Compact\n\nEnglish | [中文](.\u002FREADME.zh-CN.md)\n\nLossless context compression for OpenCode and Claude Code.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\".github\u002Fassets\u002Fpreview.png\" alt=\"Magic Compact Preview\" \u002F>\n\u003C\u002Fp>\n\n## Why\n\nOpenCode and Claude Code's built-in compaction replaces an entire conversation with one summary blob. The user messages, the assistant's reasoning, tool calls, design decisions, and workflow are all flattened into a generic template (Goal, Progress, Key Decisions...). The agent wakes up with amnesia, forced to reconstruct its working state from an abstraction that captured a fraction of what mattered.\n\nMagic Compact takes a different approach: preserve the conversation skeleton, condense each old assistant turn into its own summary, prune bulky tool I\u002FO, and keep everything retrievable. The agent retains its memory of what it did, why, and what comes next.\n\n## How\n\nInstead of collapsing an entire session into a single generic summary, Magic Compact replaces old assistant turns with high-fidelity summaries while leaving user messages and tool calls in place.\n\nThe assistant's thought process, decisions, and actions remain in context along with all your commands while unnecessary bloat is stripped away. Long tool calls are aggressively pruned but can be retrieved via a custom `read_omitted_content` tool.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\".github\u002Fassets\u002Fvisualization.png\" alt=\"Compaction Comparison\" \u002F>\n\u003C\u002Fp>\n\n## Features\n\n- Lossless context compression — Fully preserve working memory instead of flattening history into one recap.\n- Zero compaction overhead — Compaction happens once on your command rather than during the agentic loop. Maximum token savings, minimal cache invalidations.\n- Preserved user messages — Exact requirements and guidance remain visible to the agent, verbatim.\n- Smart tool call pruning — Bulky completed tool I\u002FO is replaced with omission notices, with original content cached and retrievable on demand via `read_omitted_content`.\n- Recompactable — Run `\u002Fmagic-compact` again later to compact new turns while preserving prior summaries.\n\n## Installation\n\nMagic Compact works flawlessly on Claude Code, but OpenCode will have more features + first class support as OpenCode exposes more functionality to plugins.\n\n### Claude Code\n\nInstall from this repository's first-party plugin marketplace:\n\n```shell\n\u002Fplugin marketplace add aerovato\u002Fmagic-compact\n\u002Fplugin install claude-magic-compact@magic-compact\n```\n\nAfter installation, run `\u002Freload-plugins` if Claude Code is already open.\n\n### OpenCode\n\nInstall from the CLI:\n\n```bash\nopencode plugin magic-compact --global\n\n# If you are encountering \"No versions available:\nNPM_CONFIG_MIN_RELEASE_AGE=0 opencode plugin magic-compact --global\n```\n\nThis installs the package and adds it to your global OpenCode config.\n\n## Usage\n\n### `\u002Fmagic-compact`\n\nTo compact, run `\u002Fmagic-compact [N]` with an optional argument indicating how many turns to preserve.\n\n- `N` is the number of recent assistant turns to preserve as-is. Default: `0` (summarize everything).\n- A backup session is created before the current conversation is compacted. If compaction fails, you will return to the backup.\n\nExamples:\n\n- `\u002Fmagic-compact` — summarize all old assistant turns.\n- `\u002Fmagic-compact 3` — keep the 3 most recent assistant turns, summarize the rest.\n\n### `\u002Fmagic-stats` (OpenCode Exclusive)\n\nRun `\u002Fmagic-stats` to show cumulative token savings for the current conversation: tokens pruned, cached tokens saved, estimated money saved, among other statistics.\n\n### The Omitted Content Tool\n\nMagic Compact registers a `read_omitted_content` tool that the agent can call to retrieve any tool input or output that was pruned during compaction.\n\nEach omission notice in the conversation includes a Content ID (e.g. `omitted-001`). The agent uses that ID to fetch the original content when it needs stale information that cannot be reproduced via a new tool call.\n\n### Claude Code\n\nClaude Code does not expose as much capability to plugins vs OpenCode. Therefore, certain differences are present when using Magic Compact for Claude Code:\n\n- Magic Compact will create a compacted destintaion sesion instead of compacting in place.\n  - Claude Code does not allow us to modify the current session's message transcript\n- After compaction, Claude Code will tell you to run `\u002Fresume \u003Cnew-session-id>` to enter the compacted session\n  - Simply copy and paste that command and run it\n- `\u002Fmagic-stats` is not implemented for Claude Code\n\n## Pruning Rules\n\nPruning applies only to summarized turns.\n\nKept:\n\n- User messages (verbatim)\n- Per-turn summaries\n- Tool calls (structure preserved)\n- Selected high-value synthetic messages (shell wrappers, background task results, working-directory change reminders)\n\nRemoved or condensed:\n\n- Assistant reasoning, text, and step markers — replaced by the per-turn summary\n- Most synthetic\u002Finjected messages (file expansions, plan reminders, prior compaction notices, etc.)\n- Bulky completed tool I\u002FO — replaced with an omission notice pointing to the cache\n\n### Tool I\u002FO Rules\n\nCompleted tool outputs over 128 words or 1024 characters are omitted by default. A few tools have special handling.\n\n#### OpenCode\n\n- `read` — output always omitted (stale file contents are reloadable)\n- `write` \u002F `edit` \u002F `apply_patch` — large file content omitted\n- `bash` — commands over 1024 characters are truncated\n- `task` — output omitted above a higher threshold (512 words \u002F 4096 characters)\n- `question` — input and output preserved\n- `todowrite` \u002F `skill` — output discarded without caching (redundant or reloadable)\n\n#### Claude Code\n\n- `Read` \u002F `NotebookEdit` — output always omitted (file text, notebook JSON, images, PDFs are reloadable)\n- `Bash.command` — commands over 512 characters truncated; full command cached with an omission ID\n- `Agent` \u002F `TaskOutput` — output omitted above a higher threshold (512 words \u002F 4096 characters)\n- `AskUserQuestion` — input and output preserved (captures explicit user decisions)\n- `Skill` — output discarded without caching (reloadable by re-invoking the skill)\n\nPending, running, and errored tool calls are always preserved as-is.\n\n## Vs DCP Plugin (OpenCode)\n\nOpenCode-DCP is a runtime context management system that rewrites messages when requested by the model. Magic Compact takes a different approach.\n\nMagic Compact Offers:\n\n- Simplicity — One command, zero configuration.\n- Lossless quality — Turn-by-turn flow stays intact. All user commands are preserved. All past tool calls are preserved.\n- Maximum token savings — The entire conversation is summarized with one request. Long tool calls are aggressively pruned.\n- No cache churn — Compaction happens once and is cache friendly, whereas DCP may invalidate entire conversations multiple times within one request.\n- Zero assistant overhead — No prompt injections asking the assistant to compact. Your assistant stay focused on its task.\n\nIf you want model-driven compaction with increased cache invalidations and token burn, consider using DCP instead.\n\n## Vs Magic Context (OpenCode)\n\nMagic Context is a much broader runtime context-management system: it runs background historian and dreamer processes, maintains project memory, and injects recalled memories and history back into the prompt on an ongoing basis. That makes it powerful, but also much heavier in tokens and cache churn.\n\nMagic Compact Offers:\n\n- Efficiency — One explicit compaction command, no background summarization loop, no always-on memory RAG, and no recurring prompt injections.\n- Lower token burn — Context reduction happens once on demand instead of continuously consuming tokens across every turn.\n- Fewer cache invalidations — The session is rewritten once, then stays stable, instead of repeatedly re-rendering volatile background state.\n- Lossless conversation shape — User messages stay verbatim, tool structure is preserved, and summarized assistant turns remain retrievable.\n- Focused compaction — The plugin does one job: compress the conversation without turning the runtime into a memory subsystem.\n\nIf you want a lightweight, user-driven compaction tool with minimal ongoing overhead, Magic Compact is the better fit. If you want a full long-term memory system with background maintenance, Magic Context is the heavier alternative.\n\n## Development\n\nSee [`docs\u002FDevelopment.md`](.\u002Fdocs\u002FDevelopment.md) for setup and maintenance commands.\n","Magic Compact 是一款面向 Claude Code 和 OpenCode 的无损上下文压缩插件，用于智能保留长对话中的关键信息。它通过为每个历史助手回复生成高保真摘要、原样保留用户消息与工具调用结构、智能裁剪冗余工具 I\u002FO（支持按需恢复）来实现上下文精简，避免传统单摘要压缩导致的记忆丢失。插件采用按需触发式压缩，零运行时开销，支持多次递进压缩。适用于需要长期多轮协作、复杂推理链追踪及工具密集型开发任务的 AI 编程场景。",2,"2026-07-08 04:30:09","CREATED_QUERY"]