Repository navigation
fix: stop forcing autocompact to 50% and stop reconcile overwriting user hooks - #31
Open
1aifanatic wants to merge 1 commit into
Open
1aifanatic wants to merge 1 commit into
1aifanatic wants to merge 1 commit into
Conversation
…ser hooks Setup wrote CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 to settings.json and the shell rc file without asking, and reconcileAll() (run daily from the status line) re-added it whenever the user removed it. On a 1M-context model that compacts at ~500K tokens instead of Claude Code's default. The same reconcile replaced the whole UserPromptSubmit/PostToolUse/ PreCompact arrays and statusLine, silently deleting user hooks on those events, including user hooks sharing a matcher group with DietCode's. - Only write CLAUDE_AUTOCOMPACT_PCT_OVERRIDE (settings.json and shell rc) when SCALEDOWN_COMPACT_THRESHOLD is explicitly set; reconcile never touches it. - Add applyClaudeHooks(), shared by setup and reconcile: strip only DietCode's own hook commands, keep user hooks (even in shared groups), append DietCode's entry, and keep a user-configured statusLine. - Uninstall uses the same per-command filter, so it no longer drops user hooks that share a group with DietCode's. - The "compaction imminent" hint defaults to 95% when no threshold is set. Closes scaledown-team#29 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #29
Problem
dietcode setupsilently wroteCLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50to~/.claude/settings.jsonand the shell rc file.reconcileAll()runs daily from the status line, and it put the key back whenever the user deleted it. On a 1M-context model that means compaction at ~500K tokens rather than Claude Code's default.reconcileClaude()(and setup'swriteHooks()) assigned whole new arrays tohooks.UserPromptSubmit,hooks.PostToolUse,hooks.PreCompactandstatusLine. Any user hook on those events was silently deleted, including one placed in the same matcher group as DietCode's (the reporter's setup).Changes
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE(settings.json and shell rc) only whenSCALEDOWN_COMPACT_THRESHOLDis explicitly set, and prints a line when it does. Reconcile never touches the key.applyClaudeHooks()insrc/reconcile.ts, used by both setup and reconcile:statusLineand installs DietCode's only when none exists or the existing one is already DietCode's.dietcode/scaledownand one of the hook scripts, or when it exactly matches the command being installed. The second case covers checkouts whose path doesn't name the package.isOurHookEntry, which matched any group mentioning "dietcode", is removed.compaction imminentprogress hint defaults to 95% when no threshold is configured, instead of warning at 50% when nothing happens there.dietcodehelp text are updated.Not changed (needs a maintainer decision)
Existing installs keep the
"50"that older versions wrote. Reconcile can't tell it apart from a value the user chose, so this PR leaves it in place rather than guess. The README uninstall section now explains where that line comes from. If you'd rather migrate (e.g. remove"50"when_dietcodeVersion≤ 0.5.0 and the env var is unset), I can add that.Tests
New
src/reconcile.test.ts(10 tests):The test mocks
os.homedir(), because jest's ESM sandbox doesn't propagateprocess.env.HOMEto it (see note below).hooks/user-prompt-submit.test.ts,hooks/post-tool-use.test.ts,src/niah.test.ts: 57 passed.🤖 Generated with Claude Code