Repository navigation
fix(setup): remove emptied skill directories on uninstall - #2182
Conversation
Uninstall removes only the managed skill files so user files survive, but it left every emptied reverse-engineer-anything directory and its references/ subdirectory behind. After the ownership manifest is removed, remove the managed directories deepest first with a non-recursive rmdir, which keeps any directory that still holds user files. Fixes #2159 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f25cc49a39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } catch { | ||
| // A directory that still holds user files, or is already gone, stays as is. |
There was a problem hiding this comment.
Report errors removing empty skill directories
When rmdir fails for a reason other than a non-empty or missing directory (for example, the skill root can permit deleting managed files from references/ while its parent permissions deny deleting that now-empty directory), this catches the error and removeManagedSkill still reports success, so runUninstall returns complete with the owned empty directory left behind. Classify only the expected non-destructive errors as retained; surface permission and I/O failures as cleanup failures.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a25aaa8. Only ENOTEMPTY/EEXIST (user files remain), ENOENT (already gone) and ENOTDIR (replaced by a non-directory) are kept silently. Any other rmdir failure now fails the skill item with Managed skill directory could not be removed: <path>., so runUninstall returns failed. New test reports an emptied skill directory that cannot be removed makes the parent skills directory read-only (0555) and asserts the failed item; it fails without this commit.
Only a directory that still holds user files, is already absent, or is no longer a directory is kept silently. Any other rmdir failure, such as a parent that denies deletion, now fails the skill item with the directory path instead of reporting the skill as removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Since a011485, uninstall removes only the files in
MANAGED_SKILL_FILES, so user files in a skill directory survive. Nothing removes the managed directories once they are empty. Afterrea uninstall, every skill destination (~/.agents/skills, Claude Code, Antigravity, Hermes) therefore kept an emptyreverse-engineer-anything/directory with an emptyreferences/inside, while the summary reported the skill asremoved.Once the ownership manifest itself has been removed, uninstall now removes the managed directories deepest first (
references/, then the skill root). It uses a non-recursivermdirthrough a new optionalUninstallFileSystem.removeEmptyDirectory.rmdircannot delete content, so a directory that still holds user files (or was replaced by a symlink) is left exactly as it was. No item status or message changes. Injected test file systems without the new method keep the previous behavior.Fixes #2159
Before / after (isolated HOME, setup for Claude Code, Hermes and Antigravity, then uninstall)
Validation
removes emptied skill directories and keeps ones with user files(tests/boundary/filesystem/clientLifecycle.test.ts). It fails on main and passes with this change; all 49 tests in the file pass.npm run lintpasses.npm test: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on cleanorigin/mainon this host: Hopper not installed, Command Line Tools only (ibtool),hdiutil, and inspector target-location cases.#2154 also edits
src/application/Uninstall.ts, but in the configuration-reading path; the two changes do not overlap.🤖 Generated with Claude Code