Skip to content

refactor: remove deprecated aliases (#59) + unify install_state interface (#58)#70

Open
Cannon07 wants to merge 2 commits into
mainfrom
refactor/install-state-and-drop-aliases
Open

refactor: remove deprecated aliases (#59) + unify install_state interface (#58)#70
Cannon07 wants to merge 2 commits into
mainfrom
refactor/install-state-and-drop-aliases

Conversation

@Cannon07
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 commented May 22, 2026

Summary

Three cleanups to the plugin's backend layer, landing together since they all touch the same modules.

#59 — Remove deprecated ClaudePreview* aliases

  • Delete the deprecated_alias helper and its five invocations (ClaudePreviewInstallHooks, …UninstallHooks, …CloseDiff, …Status, …ToggleVisibleOnly). They have been warning on every call since the rename to :CodePreview*.
  • Drop the two migration-warning lines from README.md.

#58 — Unify installer install_state interface

  • Add M.install_state() -> { state = "installed"|"missing", warnings = string[]? } to each of claudecode, opencode, copilot, codex. The ad-hoc detection logic that previously lived inline in init.lua's status() for claudecode/opencode now lives in the backend modules where it belongs.
  • For codex, compose the existing is_installed() + feature_flag_state() checks into the unified shape: an explicitly-disabled hooks flag becomes a warning string on an otherwise-installed result.
  • Rewrite status() as a loop over a BACKENDS registry. Rendered output matches the prior format — warnings render as installed 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 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). Confirmed against the current Codex hooks docs.

  • backends/codex.lua: feature_flag_state() collapses to two states (enabled | disabled), defaults to enabled, 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-preview reports the new default-enabled semantics and warns only on explicit disable.
  • README.md: 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.

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 just installed — the absence of warnings conveys the same information. Easy to restore via an optional info field if you'd like it back.

Test plan

  • ./tests/run_lua.sh — 110 / 110 pass (includes new tests/plugin/install_state_spec.lua locking the return-shape contract across all four backends).
  • ./tests/run.sh — 65 / 65 pass (codex shell tests rewritten for the new default-enabled semantics).
  • Manually invoked :CodePreviewStatus headlessly in the plugin cwd; output format unchanged from pre-PR.
  • Reviewer to sanity-check :CodePreviewStatus and :checkhealth code-preview in a real project — especially the codex degraded path (user has [features] hooks = false set explicitly).

🤖 Generated with Claude Code

Cannon07 and others added 2 commits May 22, 2026 21:06
…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>
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