From 755903b349a0f188d18e64da5c26f0c565750ae2 Mon Sep 17 00:00:00 2001 From: 686f6c61 Date: Tue, 18 Aug 2026 10:36:14 +0200 Subject: [PATCH] Keep plugin clones out of the reserved omarchy.* namespace A unix user named omarchy produced ids like omarchy.clock. PluginRegistry rejects those, but discovery still matches the built-in, so clone reported success and the copy was never loaded. Prefix reserved ids with user. so they stay outside omarchy.*. --- bin/omarchy-plugin-clone | 10 +++++++++- test/shell.d/plugin-clone-test.sh | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/bin/omarchy-plugin-clone b/bin/omarchy-plugin-clone index 59ca16172ed4..5045c7c1e334 100755 --- a/bin/omarchy-plugin-clone +++ b/bin/omarchy-plugin-clone @@ -87,7 +87,9 @@ Copies a built-in plugin into ~/.config/omarchy/plugins/./ so you can edit it freely. The clone keeps all of the source plugin's files and kinds and uses "My " as its display name, then replaces the built-in with the clone. The username prefix keeps the id yours, so a shared clone does not -collide with anyone else's. --edit opens the clone in \$EDITOR afterwards. +collide with anyone else's. If that id would start with omarchy., the reserved +first-party namespace, it is stored as user.. instead. --edit +opens the clone in \$EDITOR afterwards. USAGE } @@ -129,6 +131,12 @@ source_info=$(omarchy-plugin-catalog | jq -r --arg id "$source_id" ' IFS=$'\t' read -r source_dir source_manifest source_name <<<"$source_info" new_id="${USER:-$(id -un)}.${source_id#omarchy.}" +# PluginRegistry and omarchy-plugin-validate reserve omarchy.* for built-ins. +# A unix user named omarchy would otherwise clone to omarchy.clock: the CLI +# matches the built-in, reports success, and the copy is never loaded. +if [[ $new_id == omarchy.* ]]; then + new_id="user.$new_id" +fi display_name="My $source_name" target_dir="$PLUGINS_DIR/$new_id" [[ ! -e $target_dir && ! -L $target_dir ]] || fail "$target_dir already exists" diff --git a/test/shell.d/plugin-clone-test.sh b/test/shell.d/plugin-clone-test.sh index 2c9c815525ec..6e1a2679a6c3 100755 --- a/test/shell.d/plugin-clone-test.sh +++ b/test/shell.d/plugin-clone-test.sh @@ -191,3 +191,23 @@ fi [[ ! -e $TMPDIR/home/.config/omarchy/plugins/tester.osd ]] || fail "failed clone discovery leaves a partial clone behind" pass "clone removes a partial clone when switching fails" + +# USER=omarchy produces omarchy.clock, which PluginRegistry rejects as reserved +# while discovery still matches the built-in and the CLI reports success. +omarchy_user_calls="$TMPDIR/calls-omarchy" +HOME="$TMPDIR/home" USER=omarchy OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \ + FAKE_CALLS="$omarchy_user_calls" OMARCHY_TEST_ROOT="$ROOT" \ + omarchy-plugin-clone omarchy.clock >/dev/null +omarchy_clock="$TMPDIR/home/.config/omarchy/plugins/user.omarchy.clock" +[[ ! -e $TMPDIR/home/.config/omarchy/plugins/omarchy.clock ]] || + fail "clone for user omarchy lands in the reserved omarchy.* path" +[[ -f $omarchy_clock/manifest.json ]] || + fail "clone for user omarchy did not write user.omarchy.clock" +jq -e ' + .id == "user.omarchy.clock" and + .omarchy.clonedFrom == "omarchy.clock" +' "$omarchy_clock/manifest.json" >/dev/null || + fail "clone for user omarchy kept a reserved manifest id" +grep -qx 'omarchy-plugin-enable user.omarchy.clock' "$omarchy_user_calls" || + fail "clone does not enable the reserved-safe id" +pass "clone keeps USER=omarchy out of the reserved omarchy.* namespace"