[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-92282":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":12,"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":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":14,"starSnapshotCount":14,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},92282,"compact-plus","u-ichi\u002Fcompact-plus","u-ichi","Claude Code plugin: preserve and restore working state around \u002Fcompact",null,"Shell",139,1,106,0,29,43.8,"MIT License",false,"main",[],"2026-07-22 04:02:05","# compact-plus\n\n[Japanese README](.\u002FREADME.ja.md) | [Architecture](.\u002Fdocs\u002Farchitecture.md)\n\nA transparent Claude Code plugin that raises `\u002Fcompact` session continuity (state capture, recovery guidance, and skill recall) above Codex CLI parity. It does not replace Claude Code's compaction algorithm — it augments compaction through the documented hook surface.\n\n## What It Does\n\n- Backs up the transcript before compaction and writes a 10-section state file with an LLM\n- Injects the state file, plan file, and original-source reminder after compaction through `additionalContext`\n- Recovers the list of skills invoked earlier in the session — a mechanism not present in the Codex CLI baseline\n- When context usage crosses a configured threshold (default 60%), the next user prompt receives a suggestion to run `\u002Fcompact`\n- Alongside that reminder, the plugin injects a three-line recitation (Active Plan, Current Phase, and the most recent Session Decision from the state file) into `additionalContext`, so the agent keeps its bearings during the last few turns before compaction actually runs. This does not change the compaction algorithm itself; it is a focus aid that reduces late-session drift between warn and the real `\u002Fcompact`\n- Provides the `\u002Fcompact-plus` skill for manual state capture\n\n## Usage\n\nAfter installation, just run `\u002Fcompact` as usual. **No additional action is required** — the flow is fully transparent.\n\n- Both manual `\u002Fcompact` and auto-compaction trigger the same hook path\n- Before compaction: the PreCompact hook automatically backs up the transcript and generates the 10-section state file\n- After compaction: recovery guidance is automatically injected into `additionalContext` through the UserPromptSubmit hook on the next user prompt\n- The agent does not need to call any specific skill or perform any preparation\n\nOptional enhancements:\n\n- Pass an instruction such as `\u002Fcompact keep the security-related decisions` to send priority guidance to the state-generation LLM\n- Invoke `\u002Fcompact-plus` manually right before compaction if you want to leave richer recovery notes; this switches to the fallback path where the agent writes the structured state itself\n\n## Requirements\n\n- Claude Code v2.x or later\n- An LLM backend through `claude -p` or `codex exec`\n- The default configuration uses `claude -p --model claude-sonnet-5 --effort medium` as the primary backend and `codex exec --model gpt-5.3-codex-spark` as the fallback backend\n- The Codex Spark fallback assumes ChatGPT Pro access. You can switch the fallback to models such as `gpt-5.4` or `gpt-5.5`\n\n## Installation\n\nAdd the local marketplace, then install the plugin.\n\n```bash\nclaude plugin marketplace add \u002Fpath\u002Fto\u002Fcompact-plus --scope user\nclaude plugin install compact-plus@compact-plus-local\n```\n\n## Configuration\n\nFollowing the Claude Code plugin model, write environment variables under the `env` block in `~\u002F.claude\u002Fsettings.json`. For temporary per-session overrides, shell `export` also works.\n\n### Backend Overrides\n\nTwo environment variables replace the primary and fallback commands as whole shell commands.\n\n| env var | Meaning |\n|---|---|\n| `COMPACT_PLUS_PRIMARY_BACKEND` | Complete shell command for the primary backend. Set to an empty string (`\"\"`) to skip the primary backend |\n| `COMPACT_PLUS_FALLBACK_BACKEND` | Complete shell command for the fallback backend. Set to an empty string to skip the fallback backend |\n\nEnvironment variables available inside those commands:\n\n- `$SYSTEM_PROMPT`: the LLM system prompt from `prompts\u002Fstate-summary.md`\n- `$SESSION_ID`: Claude Code session id\n- `$TRANSCRIPT_PATH`: transcript JSONL path\n- `$MAX_OUTPUT_TOKENS`: LLM output cap\n\nDefault values are embedded in `hooks\u002Fprecompact-state-summary.sh`.\n\nExample `~\u002F.claude\u002Fsettings.json` override for a lower-cost Haiku backend:\n\n```json\n{\n  \"env\": {\n    \"COMPACT_PLUS_PRIMARY_BACKEND\": \"claude -p --model claude-haiku-4-5-20251001 --effort low --permission-mode dontAsk --output-format text --no-session-persistence --system-prompt \\\"$SYSTEM_PROMPT\\\"\"\n  }\n}\n```\n\nExample replacing the primary backend with Codex Spark (requires ChatGPT Pro; served through Cerebras for higher throughput):\n\n```json\n{\n  \"env\": {\n    \"COMPACT_PLUS_PRIMARY_BACKEND\": \"tmp=$(mktemp \\\"${TMPDIR:-\u002Ftmp}\u002Fcompact-plus-codex.XXXXXX\\\"); { printf \\\"%s\\\\n\\\\n\\\" \\\"$SYSTEM_PROMPT\\\"; cat; } | codex exec --model gpt-5.3-codex-spark --sandbox read-only --skip-git-repo-check --dangerously-bypass-hook-trust --ignore-user-config --ephemeral --output-last-message \\\"$tmp\\\" - >\u002Fdev\u002Fnull && cat \\\"$tmp\\\"; status=$?; rm -f \\\"$tmp\\\"; exit \\\"$status\\\"\"\n  }\n}\n```\n\nCodex output can prepend a CLI preamble to stdout, so `--output-last-message \"$tmp\"` is used to capture only the final message. This mirrors the default fallback implementation.\n\nExample disabling the fallback:\n\n```json\n{\n  \"env\": {\n    \"COMPACT_PLUS_FALLBACK_BACKEND\": \"\"\n  }\n}\n```\n\n### Transcript, Squash, and Two-Pass Tuning\n\n| env var | default | Meaning |\n|---|---|---|\n| `COMPACT_PLUS_TRANSCRIPT_MODE` | `incremental` | Transcript selection mode: `incremental`, `head-tail`, or `tail` |\n| `COMPACT_PLUS_TRANSCRIPT_HEAD_TURNS` | `5` | Number of turns to keep from the head side |\n| `COMPACT_PLUS_TRANSCRIPT_TAIL_TURNS` | `25` | Number of turns to keep from the tail side |\n| `COMPACT_PLUS_TRANSCRIPT_HEAD_KB` | `10` | Head-side byte cap in KB |\n| `COMPACT_PLUS_TRANSCRIPT_TAIL_KB` | `40` | Tail-side byte cap in KB |\n| `COMPACT_PLUS_INCREMENTAL_REFRESH` | `10` | Full rebuild every N runs. Set `0` to disable |\n| `COMPACT_PLUS_MAX_OUTPUT_TOKENS` | `4096` | LLM output cap for backends that read it |\n| `COMPACT_PLUS_SQUASH_ENABLED` | `1` | Enables or disables tool result squash |\n| `COMPACT_PLUS_SQUASH_READ_LINES` | `100` | Replaces Read tool output above N lines with `[Read: N lines from path]` |\n| `COMPACT_PLUS_SQUASH_BASH_CHARS` | `500` | Replaces Bash output above N characters with `[Bash: exit code, N chars output]` |\n| `COMPACT_PLUS_TWO_PASS` | `1` | Enables or disables two-pass self-critique |\n\n### Warn Threshold\n\nSet `COMPACT_WARN_THRESHOLD` (default `60`) in the `settings.json` `env` block to change when the statusline emits a warn marker. This setting belongs to the base repository `home\u002Fhooks\u002Fclaude\u002Fstatusline.sh`, not to the compact-plus plugin itself.\n\n### `\u002Fcompact` Arguments\n\nWhen you pass natural-language instructions, such as `\u002Fcompact keep the important design decisions`, compact-plus forwards those instructions to the state-generation LLM as priority guidance.\n\n## Runtime Flow\n\n1. **PreCompact hook**\n   - `precompact-transcript-backup.sh` copies the transcript JSONL to `~\u002F.claude\u002Fbackups\u002Ftranscripts\u002F`\n   - `precompact-state-summary.sh` applies semantic chunking and tool output squash to the transcript, then calls the primary or fallback backend and writes the 10-section state file\n2. **PostCompact hook**\n   - `compaction-recovery.sh` writes a recovery marker and resets the warning cooldown\n3. **UserPromptSubmit hook**\n   - `userpromptsubmit-compaction-recovery.sh` consumes the recovery marker and injects state file and plan file references, plus a factual note that memory, rule, and skill mentions in the compact summary are summaries and that the original files remain authoritative\n   - If the state file has `## Skills Invoked`, the hook also injects guidance for rereading the relevant skills\n   - `userpromptsubmit-compact-plus-reminder.sh` consumes warn markers and injects a lightweight notification plus a three-line state recitation when available\n4. **SessionStart hook**\n   - `sessionstart-export-session-id.sh` writes `export CLAUDE_CODE_SESSION_ID=\u003Cid>` to `$CLAUDE_ENV_FILE` so the `\u002Fcompact-plus` skill can obtain the session id through the bundled `scripts\u002Fget-session-id.sh` wrapper without depending on any file outside the plugin\n5. **Manual fallback (`\u002Fcompact-plus` skill)**\n   - The agent follows the `SKILL.md` 10-section procedure and writes the state file manually\n\n## State File Sections\n\nState files start with `# Compact Prep State` and use the same 10-section order in both the manual skill and LLM-generated output.\n\n1. `## Active Plan`\n2. `## Current Phase`\n3. `## TaskList Summary`\n4. `## Session Decisions`\n5. `## Constraints and Blockers`\n6. `## Worker Topology`\n7. `## Skills Invoked`\n8. `## Editing Files`\n9. `## Failed Attempts`\n10. `## Recovery Notes`\n\n## Marker Files\n\n| path | writer | reader | Purpose |\n|---|---|---|---|\n| `${TMPDIR}\u002Fclaude-compact-state\u002F\u003Csession_id>.md` | `precompact-state-summary.sh` \u002F `\u002Fcompact-plus` skill | recovery hook \u002F agent | Pre-compaction state |\n| `${TMPDIR}\u002Fclaude-compact-state-offset\u002F\u003Csession_id>` | `precompact-state-summary.sh` | `precompact-state-summary.sh` | Incremental byte offset |\n| `${TMPDIR}\u002Fclaude-compact-state-counter\u002F\u003Csession_id>` | `precompact-state-summary.sh` | `precompact-state-summary.sh` | Refresh cycle counter |\n| `${TMPDIR}\u002Fclaude-compacted\u002F\u003Csession_id>` | `compaction-recovery.sh` | `userpromptsubmit-compaction-recovery.sh` | PostCompact marker |\n| `${TMPDIR}\u002Fclaude-compact-warn\u002F\u003Csession_id>` | base repo `statusline.sh` | `userpromptsubmit-compact-plus-reminder.sh` | Threshold warning |\n| `${TMPDIR}\u002Fclaude-compact-warned\u002F\u003Csession_id>` | `userpromptsubmit-compact-plus-reminder.sh` | statusline \u002F recovery hook | Notification cooldown |\n| `${TMPDIR}\u002Fclaude-active-plan\u002F\u003Csession_id>` | plan-management hook | recovery hook | Active plan path |\n\n## Architecture\n\nSee [docs\u002Farchitecture.md](.\u002Fdocs\u002Farchitecture.md) for the design overview, Claude Code and Codex CLI compaction comparison, hook boundaries, marker ownership, and source references.\n\n## Development Checks\n\n```bash\npython3 -m json.tool .claude-plugin\u002Fplugin.json >\u002Fdev\u002Fnull\npython3 -m json.tool .claude-plugin\u002Fmarketplace.json >\u002Fdev\u002Fnull\npython3 -m json.tool hooks\u002Fhooks.json >\u002Fdev\u002Fnull\nbash -n hooks\u002F*.sh\n```\n","compact-plus 是一个为 Claude Code 设计的轻量级插件，用于增强对话会话的上下文压缩（\u002Fcompact）过程中的状态连续性。它通过预压缩时自动生成 10 节段结构化状态文件、自动注入恢复指引与技能调用历史，并在临近压缩阈值时提供主动提示与三行上下文锚点（Active Plan \u002F Current Phase \u002F 最近决策），显著降低会话后期的语义漂移。插件不修改原始压缩算法，仅通过 Claude Code 官方 Hook 接口透明增强，支持自动与手动（\u002Fcompact-plus）两种状态捕获模式。适用于需长期多轮协作、任务分阶段推进、或依赖历史决策连贯性的复杂编码辅助场景。",2,"2026-07-08 04:29:57","CREATED_QUERY"]