Repository navigation
Run declared plugin cleanup before removal - #11470
antongisli wants to merge 1 commit into
Conversation
Automated AI review
Outcome: Some plugins without an uninstall hook now need Some plugins without a hook are refused
Suggested change: after refusing unparseable JSON, exit 0 unless Reproducer: hookless plugin refused (fails at cba9e5d)Reproducer: removal now refuses a hookless plugin whose manifest has no entryPoints object Test file in the style of #!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
require_command jq
test_dir=$(mktemp -d)
trap 'rm -rf -- "$test_dir"' EXIT
mkdir -p "$test_dir/stubs"
cat >"$test_dir/stubs/omarchy-shell" <<'STUB'
#!/bin/bash
[[ $2 == "listPlugins" ]] && echo '[]'
exit 0
STUB
chmod +x "$test_dir/stubs/omarchy-shell"
# A leftover folder whose manifest the shell never accepted (no entryPoints
# object), so it declares no uninstall entry point.
plugin="$test_dir/home/.config/omarchy/plugins/acme.legacy"
mkdir -p "$plugin/.git"
printf '{"id":"acme.legacy"}\n' >"$plugin/manifest.json"
output=$(HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/stubs:$ROOT/bin:$PATH" \
"$ROOT/bin/omarchy-plugin-remove" acme.legacy --yes 2>&1) ||
fail "a plugin without an uninstall entry point is removed as before" "$output"
[[ ! -e $plugin ]] || fail "the plugin folder is removed"
pass "a plugin without an uninstall entry point is removed as before"Output at the PR head (cba9e5d), Output at the merge base (31bd80d), exit 0: Output at the head with the suggested helper change (check for The same refusal makes open PR #13743's On quattro plus #13743 alone the same file passes all 9 checks. Related open PRs
DetailsVerified (at cba9e5d, synthetic HOME, stubbed
Optional notes:
Reproducer: untested `..` guard (passes at cba9e5d, fails on the mutant)Reproducer: the This is a test-strength note, not a behaviour bug: at the PR head the guard works. The PR's traversal cases ( Mutation used (one line in -[[ $entry != /* && $entry != *..* && $entry != */ && $entry != *//* ]] || fail "uninstall entry point must be a safe relative path"
+[[ $entry != /* && $entry != */ && $entry != *//* ]] || fail "uninstall entry point must be a safe relative path"With that mutation, the PR's A case whose escape target exists catches it (save as #!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
require_command jq
test_dir=$(mktemp -d)
trap 'rm -rf -- "$test_dir"' EXIT
mkdir -p "$test_dir/stubs"
cat >"$test_dir/stubs/omarchy-shell" <<'STUB'
#!/bin/bash
[[ $2 == "listPlugins" ]] && echo '[]'
exit 0
STUB
chmod +x "$test_dir/stubs/omarchy-shell"
# The escape target exists and is executable, so only the '..' guard can
# reject it.
home="$test_dir/home"
plugins="$home/.config/omarchy/plugins"
plugin="$plugins/acme.test"
mkdir -p "$plugin"
touch "$plugin/Widget.qml" "$home/external-setup"
printf '#!/bin/bash\nrm -- "$HOME/external-setup"\n' >"$plugins/outside"
chmod +x "$plugins/outside"
printf '%s\n' '{"schemaVersion":1,"id":"acme.test","name":"Test","version":"1","kinds":["bar-widget"],"entryPoints":{"barWidget":"Widget.qml","uninstall":"../outside"}}' >"$plugin/manifest.json"
output=$(HOME="$home" OMARCHY_PATH="$ROOT" PATH="$test_dir/stubs:$ROOT/bin:$PATH" \
"$ROOT/bin/omarchy-plugin-remove" acme.test --yes 2>&1) &&
fail "an existing parent-directory hook path is rejected" "$output"
[[ -f $home/external-setup && -f $plugin/manifest.json ]] ||
fail "an escaping hook never runs"
pass "an existing parent-directory hook path is rejected"At the PR head, exit 0: With the mutation above, exit 1 (the outside script ran and the plugin was removed): Review informationTest scope: Source and sandbox tests with stubbed shell IPC, at cba9e5d; no live desktop. AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Nice addition — validated uninstall entry points, |
Why
Plugins can create local state outside their checkout after the user enables and sets them up: user services, agent registrations, credentials and private runtime caches. Today
omarchy plugin removeonly unloads/removes the checkout, so removal from the menu or an agent can leave that setup behind even when the plugin provides its own complete uninstall UI.Proposed contract
entryPoints.uninstallnames a repository-local executable. Add/update validate it but never run it.--yesexplicitly approves cleanup and is the only argument passed through to the hook.OMARCHY_PLUGIN_REMOVAL_IDandOMARCHY_PLUGIN_DIRlet a plugin share an implementation with its own uninstall UI without recursively removing itself.--skip-cleanupis an explicit recovery/untrusted-code escape hatch and warns about leftovers. Symlinked checkouts are unlinked without executing a hook.The shared path validator rejects absolute/traversing paths, control characters, non-string values, missing/non-executable files and symlink components. Removal revalidates the approved entry point before execution. No install, update, disable or shell-reload hooks are added, and Omarchy never elevates the hook itself.
The documentation asks plugin authors to make cleanup idempotent, preserve shared tools and access keys by default, disclose cloud-resource/billing boundaries, and return nonzero on cancellation. These are author responsibilities, not a new sandbox or a guarantee enforced by the host.
Tests
./test/allon Linux in an isolated home with no graphical session: 231/237 shell test files passed. The six failures reproduce on unmodified base31bd80daa4613ffdee995ac27467fce5a2990806:ascii-test,branding-about-animation-test, three suites requiring a siblingomarchy-pkgscheckout (config,snapper,unowned-system-paths), andlocate-testafter the agent-scanner tests create.pycfiles underbin/. The focused removal/validation suites were rerun after the final disable-result check.No running desktop, installed Omarchy files or real cloud resources were changed by these tests. This PR proposes the host API; downstream plugins must opt in, and existing Omarchy releases do not gain cleanup behavior until it ships.