Skip to content

refactor(hooks): dedup INDEPENDENT_MODES into caveman-config#206

Open
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d:refactor/independent-modes-dedup
Open

refactor(hooks): dedup INDEPENDENT_MODES into caveman-config#206
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d:refactor/independent-modes-dedup

Conversation

@d123d
Copy link
Copy Markdown

@d123d d123d commented Apr 17, 2026

Problem

`const INDEPENDENT_MODES = new Set(['commit', 'review', 'compress'])` is defined identically in two places:

  • `hooks/caveman-activate.js:40`
  • `hooks/caveman-mode-tracker.js:81`

Adding a new independent mode (or removing one) requires editing both files; one will inevitably drift.

Fix

Export `INDEPENDENT_MODES` from `hooks/caveman-config.js` alongside the existing `VALID_MODES` export. Import where needed.

Diff summary

```
hooks/caveman-activate.js | 6 +-----
hooks/caveman-config.js | 7 ++++++-
hooks/caveman-mode-tracker.js | 3 +--
3 files changed, 8 insertions(+), 8 deletions(-)
```

Verify

```
node --check hooks/caveman-config.js
node --check hooks/caveman-activate.js
node --check hooks/caveman-mode-tracker.js
node -e "const {INDEPENDENT_MODES}=require('./hooks/caveman-config'); console.log([...INDEPENDENT_MODES]);"

→ [ 'commit', 'review', 'compress' ]

```

All pass. No behavior change.

Before: 'commit', 'review', 'compress' set defined identically in
both caveman-activate.js:40 and caveman-mode-tracker.js:81. Adding a
new independent mode requires editing two files; one will drift.

After: export INDEPENDENT_MODES from caveman-config.js (alongside
VALID_MODES), import where needed.

No behavior change. Node --check passes on all three files.
Import smoke test confirms the set round-trips through require().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant