refactor: remove deprecated aliases (#59) + unify install_state interface (#58)#70
Open
Cannon07 wants to merge 2 commits into
Open
refactor: remove deprecated aliases (#59) + unify install_state interface (#58)#70Cannon07 wants to merge 2 commits into
Cannon07 wants to merge 2 commits into
Conversation
…face (#58) #59 — Drop the five :ClaudePreview* command aliases and the deprecated_alias helper that produced them. They have been warning on every invocation since the rename to :CodePreview*; the README's migration notes are removed alongside. #58 — Replace the four ad-hoc backend detection patterns with a single install_state() interface on each backend module: M.install_state() -> { state = "installed" | "missing", warnings = string[]? } The claudecode and opencode detection logic that previously lived inline in init.lua's status() now lives in the respective backend modules. Codex composes its existing is_installed() + feature_flag_state() checks into the unified shape: a missing/disabled codex_hooks flag becomes a warning string on an otherwise-installed result. status() is rewritten as a loop over a BACKENDS registry; rendered output matches the prior format (warnings render as "installed BUT <warning>", same shape as the old codex degraded line). A new tests/plugin/install_state_spec.lua locks the return-shape contract across all four backends in a fresh project. The codex degraded path stays covered end-to-end by tests/backends/codex/test_install.sh. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Modern Codex enables hooks by default under [features] and has renamed the canonical key from `codex_hooks` to `hooks` (the old name remains a deprecated alias). The only failure mode now is the user *explicitly* opting out with `hooks = false` (or `codex_hooks = false`). - feature_flag_state() collapses to two states (enabled | disabled). No-config-file or no-opinion now resolves to enabled, matching Codex's own default. Project-local config wins over global. Both the canonical `hooks` key and the legacy `codex_hooks` alias are accepted on both sides (true and false). - install() no longer nags when the flag is unset — it only warns on an explicit `hooks = false` / `codex_hooks = false`. - install_state() drops the "missing flag" warning; the only warning surface is an explicit disable. - :checkhealth code-preview reports the new default-enabled semantics. - README updates: install instructions no longer ask the user to set `codex_hooks = true`; architecture note and troubleshooting reflect the new default-enabled + explicit-opt-out model. - tests/backends/codex/test_install.sh rewritten to exercise the new semantics: default-enabled, both keys (canonical + legacy) for both true and false, project-local precedence over global. Confirmed against the current Codex docs (developers.openai.com/codex/hooks). Co-Authored-By: Claude Opus 4.7 <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.
Summary
Three cleanups to the plugin's backend layer, landing together since they all touch the same modules.
#59 — Remove deprecated
ClaudePreview*aliasesdeprecated_aliashelper and its five invocations (ClaudePreviewInstallHooks,…UninstallHooks,…CloseDiff,…Status,…ToggleVisibleOnly). They have been warning on every call since the rename to:CodePreview*.README.md.#58 — Unify installer
install_stateinterfaceM.install_state() -> { state = "installed"|"missing", warnings = string[]? }to each ofclaudecode,opencode,copilot,codex. The ad-hoc detection logic that previously lived inline ininit.lua'sstatus()for claudecode/opencode now lives in the backend modules where it belongs.is_installed()+feature_flag_state()checks into the unified shape: an explicitly-disabled hooks flag becomes a warning string on an otherwise-installed result.status()as a loop over aBACKENDSregistry. Rendered output matches the prior format — warnings render asinstalled BUT <warning>, mirroring how the codex degraded line already looked.Codex hooks feature flag — track current Codex behaviour
Modern Codex enables hooks by default under
[features], and the canonical key has been renamed fromcodex_hookstohooks(the old name remains a deprecated alias). The only failure mode now is the user explicitly opting out withhooks = false(orcodex_hooks = false). Confirmed against the current Codex hooks docs.backends/codex.lua:feature_flag_state()collapses to two states (enabled|disabled), defaults toenabled, accepts both keys for both true/false, project-local config wins over global.install()no longer nags when the flag is unset — it warns only on an explicit opt-out.install_state()likewise only warns on explicit disable.health.lua::checkhealth code-previewreports the new default-enabled semantics and warns only on explicit disable.README.md: install instructions no longer ask the user to setcodex_hooks = true; architecture note and troubleshooting reflect the new default-enabled + explicit-opt-out model.tests/backends/codex/test_install.sh: rewritten to exercise the new semantics — default-enabled, both keys (canonical + legacy) for both true and false, project-local precedence over global.One small caveat on the unified status format: the prior codex-healthy line said
installed (codex_hooks=true). The new schema ({state, warnings?}) has no field for positive confirmations, so that affirmation is now justinstalled— the absence of warnings conveys the same information. Easy to restore via an optionalinfofield if you'd like it back.Test plan
./tests/run_lua.sh— 110 / 110 pass (includes newtests/plugin/install_state_spec.lualocking the return-shape contract across all four backends)../tests/run.sh— 65 / 65 pass (codex shell tests rewritten for the new default-enabled semantics).:CodePreviewStatusheadlessly in the plugin cwd; output format unchanged from pre-PR.:CodePreviewStatusand:checkhealth code-previewin a real project — especially the codex degraded path (user has[features] hooks = falseset explicitly).🤖 Generated with Claude Code