install.sh: drop .skill-source marker in deployed skill dir

The skill directory at ~/.agents/skills/opencode-mempalace-bridge/ is a
real dir containing a single SKILL.md symlink back into this repo — the
'colocated skill' pattern. Sibling reconcilers (skillset's
deploy-skills.sh, cli_utils's agents-sync.zsh) already handle external
dirs correctly via their existing 'leave real dirs alone' policies, but
a machine-readable marker makes ownership explicit:

  # skill-source: mempalace-toolkit
  # repo: <absolute path>
  # url: ssh://git@gitea.jordbo.se:2222/joakimp/mempalace-toolkit.git

The marker is the convention for any external repo that wants to ship a
colocated skill. The name is generic (.skill-source, not
.managed-by-mempalace-toolkit) so a second colocated skill from a
different repo can reuse the same file name; the first line identifies
the owner.

--uninstall now also removes the marker (only if it still says
mempalace-toolkit) and the now-empty skill dir.

AGENTS.md + README.md describe the pattern and point at sibling docs in
cli_utils/AGENTS-SYNC.md and skillset/README.md that mirror the
convention.
This commit is contained in:
Joakim Persson
2026-04-30 05:57:54 +00:00
parent 3554f56bcc
commit e49d9285c4
3 changed files with 55 additions and 0 deletions
+35
View File
@@ -38,10 +38,13 @@ What install does:
- Symlinks SKILL.md into ~/.agents/skills/opencode-mempalace-bridge/SKILL.md
(auto-discovered by opencode; run agents-sync from cli_utils to also
reach Claude Code and Kiro)
- Drops a .skill-source marker in the skill dir so sibling tooling
(deploy-skills.sh, agents-sync.zsh) knows the dir is externally owned
What uninstall does:
- Removes symlinks in ~/.local/bin/ that point into this repo
- Removes the skill symlink if it points into this repo
- Removes the .skill-source marker and empty skill dir
EOF
exit 0 ;;
*) echo "Unknown flag: $1" >&2; exit 2 ;;
@@ -98,6 +101,26 @@ install_bin() {
install_skill() {
note "Linking companion agent skill"
mkdir -p "$SKILL_DEST_DIR"
# Drop a marker file so sibling tooling (deploy-skills.sh, agents-sync.zsh,
# and any future reconciler) can tell at a glance that this skill directory
# is owned by an external repo and shouldn't be clobbered. The convention
# is two lines: "# skill-source: <repo-name>" + "# url: <clone-url>".
# Any colocated skill from any repo can adopt the same convention.
local marker="$SKILL_DEST_DIR/.skill-source"
if [[ ! -e "$marker" ]]; then
cat > "$marker" <<EOF
# skill-source: mempalace-toolkit
# repo: $SCRIPT_DIR
# url: ssh://git@gitea.jordbo.se:2222/joakimp/mempalace-toolkit.git
# This skill directory is managed by an external repo's install.sh.
# deploy-skills.sh (skillset) and agents-sync.zsh (cli_utils) leave
# directories containing this marker alone. Do not move SKILL.md out
# of this directory without also updating the owning repo.
EOF
ok "Wrote $marker"
fi
if [[ -e "$SKILL_DEST" || -L "$SKILL_DEST" ]]; then
if link_if_into_repo "$SKILL_DEST"; then
ok "Skill already linked"
@@ -174,6 +197,18 @@ do_uninstall() {
ok "No skill symlink to remove"
fi
# Remove the marker and the now-empty skill directory, but only if
# the marker was written by us and the directory has nothing else in it.
local marker="$SKILL_DEST_DIR/.skill-source"
if [[ -f "$marker" ]] && grep -q '^# skill-source: mempalace-toolkit$' "$marker" 2>/dev/null; then
rm "$marker"
ok "Removed $marker"
fi
if [[ -d "$SKILL_DEST_DIR" ]] && [[ -z "$(ls -A "$SKILL_DEST_DIR" 2>/dev/null)" ]]; then
rmdir "$SKILL_DEST_DIR"
ok "Removed empty $SKILL_DEST_DIR"
fi
echo
ok "Done."
}