repowise-dev / repowise-dev/repowise

[Bug] hook rewrite uninstall leaves distill.commands.enabled set and skips AGENTS.md when Codex is gone

Open Beginner friendly
#2,471 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Python
Stars
6.7k
Forks
711
Avg merge
1d 13h
Merged PRs (30d)
439

Description

Summary

repowise hook rewrite uninstall says it removes the rewrite hooks and the AGENTS.md awareness section. It leaves the repo-level flag that install set, and it skips the AGENTS.md removal entirely when Codex is no longer installed.

packages/cli/src/repowise/cli/commands/hook_cmd.py:349-371:

def rewrite_uninstall(path: str | None, workspace: bool, no_workspace: bool) -> None:
    """Remove the rewrite hooks and the AGENTS.md awareness section."""
    ...
    removed = ClaudeCodeAdapter().uninstall_rewrite_hook()
    ...
    codex = CodexAdapter()
    if codex.detect():
        codex_removed = codex.uninstall_rewrite_hook()
        ...
        for repo_path in _target_repo_paths(target):
            if remove_agents_md_distill_section(repo_path):
                ...

Two things follow from that shape.

The AGENTS.md removal is inside the Codex branch. Install is not. rewrite_install's own docstring says so at hook_cmd.py:288:

the AGENTS.md awareness section installs regardless, because it [...]

So a user who installed while ~/.codex existed, then removed Codex, cannot remove the section through this command. codex.detect() is false, the loop never runs, and nothing is printed about it.

distill.commands.enabled is never cleared. rewrite_install sets it, at hook_cmd.py:273 and :278:

save_distill_commands_enabled(abs_path, enabled=True)

rewrite_uninstall has no matching call. Grepping the file for save_distill_commands_enabled finds the two writes in install and none in uninstall.

Consequence

For the AGENTS.md half: the managed block stays in a tracked file the user owns, with no command that removes it and no message saying it was skipped. Hand-editing is the only route left.

For the config half: .repowise/config.yaml keeps distill.commands.enabled: true after the user has uninstalled the thing it was set for. Any later path that installs the rewrite hook without re-asking, init among them, then resumes rewriting on a flag the user believes they turned off. The flag outliving the feature is what makes this more than cosmetic.

Done looks like

The AGENTS.md removal runs on the same condition install ran on, which is unconditionally, and reports when it found nothing rather than when it was skipped. remove_agents_md_distill_section already returns a bool for that.

distill.commands.enabled is set back to False on uninstall, and the workspace branch does it for each repo the install branch wrote it to.

Worth checking in the same pass: whether the Codex rewrite hook removal itself should be gated on codex.detect(). A user who removed Codex still has whatever repowise wrote into ~/.codex/hooks.json, and detection keys on the directory existing.

The pattern this belongs to

Two other uninstall paths leave something their install wrote: #2469 (repowise uninstall omits .git/hooks/post-commit from its inventory) and #2470 (the Claude Code target leaves an env pin and two permission rules in settings.json while reporting the file clean). Same question in each case: what did install write that uninstall does not account for?

Scope note

Verified by reading rewrite_install and rewrite_uninstall in full and grepping the file for save_distill_commands_enabled. I did not run either command, and I did not check what _target_repo_paths returns for a workspace whose members were added after install.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/cli/src/repowise/cli/commands/hook_cmd.py, reading rewrite_install and rewrite_uninstall around the cited lines. Check the Codex detection branch, the unconditional AGENTS.md removal path, and each workspace target returned by _target_repo_paths. Done means uninstall removes the AGENTS.md section, resets distill.commands.enabled for every installed target, and reports when no section was found.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.