Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bin/omarchy-plugin-clone
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ Copies a built-in plugin into ~/.config/omarchy/plugins/<username>.<id>/ so you
can edit it freely. The clone keeps all of the source plugin's files and kinds
and uses "My <name>" 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.<username>.<id> instead. --edit
opens the clone in \$EDITOR afterwards.

USAGE
}
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions test/shell.d/plugin-clone-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"