Skip to content

fix(setup): remove emptied skill directories on uninstall - #2182

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
fix/issue-2159
Oct 12, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
fix/issue-2159

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

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. After rea uninstall, every skill destination (~/.agents/skills, Claude Code, Antigravity, Hermes) therefore kept an empty reverse-engineer-anything/ directory with an empty references/ inside, while the summary reported the skill as removed.

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-recursive rmdir through a new optional UninstallFileSystem.removeEmptyDirectory. rmdir cannot 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)

before: ~/.claude/skills/reverse-engineer-anything/{references/}   (empty)  — same for every destination
after:  empty skill directories are gone; a directory containing a user notes.md keeps that file (only its emptied references/ is removed)

Validation

  • New boundary test 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 lint passes.
  • npm test: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on clean origin/main on 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

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T12:37:10.585336Z a25aaa8 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/application/Uninstall.ts Outdated
Comment on lines +649 to +650
} catch {
// A directory that still holds user files, or is already gone, stays as is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit d350357 into main Oct 12, 2026
30 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/issue-2159 branch October 12, 2026 13:54
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: setup Setup, packaging, upgrade, install, Doctor, and client registration labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] rea uninstall leaves empty reverse-engineer-anything skill directories behind

2 participants