feat(extensions): version-control pi mempalace extension + install.sh symlink

The pi coding-agent extension at ~/.pi/agent/extensions/mempalace.ts was
living only on tor-ms22, including hand-edited fixes (Type.Unsafe
schema-passthrough for MCP tool parameters). One disk wipe away from
losing it, and no way to reproduce the install on a new machine.

- extensions/pi/mempalace.ts: canonical copy (matches tor-ms22 byte-for-byte)
- extensions/pi/README.md: what it does, the schema-passthrough gotcha,
  debugging knobs
- install.sh: new install_pi_extension step — gated on ~/.pi/agent/extensions/
  existing, backs up any real file in the way, idempotent re-runs, mirror
  block in uninstall. Works on macOS and Linux (plain ln -s, readlink -f).
- README.md: mention extensions/pi/ in the repo-contents list and in the
  Setup section

Verified on tor-ms22: install (backs up existing real file) → uninstall
(removes symlink) → reinstall (clean symlink). Re-runs are no-ops.
This commit is contained in:
2026-05-05 13:42:47 +02:00
parent 6352373a1f
commit ef1d022fbc
4 changed files with 429 additions and 1 deletions
+52
View File
@@ -16,6 +16,11 @@ SKILL_SRC="${SCRIPT_DIR}/SKILL.md"
SKILL_DEST_DIR="${HOME}/.agents/skills/opencode-mempalace-bridge"
SKILL_DEST="${SKILL_DEST_DIR}/SKILL.md"
# pi coding-agent extension (optional — only linked if pi is installed)
PI_EXT_SRC="${SCRIPT_DIR}/extensions/pi/mempalace.ts"
PI_EXT_DEST_DIR="${HOME}/.pi/agent/extensions"
PI_EXT_DEST="${PI_EXT_DEST_DIR}/mempalace.ts"
# ── args ─────────────────────────────────────────────
ACTION="install"
ASSUME_YES="no"
@@ -38,12 +43,15 @@ 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)
- If pi (~/.pi/agent/extensions/) exists, symlinks extensions/pi/mempalace.ts
into ~/.pi/agent/extensions/mempalace.ts (pi bridge). Skipped otherwise.
- 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 pi extension symlink if it points into this repo
- Removes the .skill-source marker and empty skill dir
EOF
exit 0 ;;
@@ -219,6 +227,36 @@ check_opencode_mcp() {
return 0
}
install_pi_extension() {
# The pi coding-agent extension is optional: link it only if pi is
# already installed on this machine (its ~/.pi/agent/extensions/
# directory exists). Otherwise silently skip — mempalace-toolkit is
# useful on opencode-only boxes too.
if [[ ! -d "$PI_EXT_DEST_DIR" ]]; then
note "pi not detected at $PI_EXT_DEST_DIR — skipping pi extension"
printf ' (install pi first if you want the pi↔mempalace bridge:\n'
printf ' https://github.com/mariozechner/pi-coding-agent)\n'
return 0
fi
note "Linking pi extension into $PI_EXT_DEST_DIR"
if [[ -e "$PI_EXT_DEST" || -L "$PI_EXT_DEST" ]]; then
if link_if_into_repo "$PI_EXT_DEST"; then
ok "pi extension already linked"
return 0
fi
# Non-symlink (or foreign symlink) in the way — back it up rather
# than clobber. User may have local edits they want to preserve.
local backup="${PI_EXT_DEST}.bak.$(date +%Y%m%d-%H%M%S)"
mv "$PI_EXT_DEST" "$backup"
warn "Existing $PI_EXT_DEST backed up to $backup"
fi
ln -s "$PI_EXT_SRC" "$PI_EXT_DEST"
ok "Linked mempalace.ts → $PI_EXT_SRC"
printf ' Restart pi to load the extension (it reads ~/.pi/agent/extensions/\n'
printf ' at startup only).\n'
}
do_install() {
echo
echo "mempalace-toolkit installer"
@@ -227,6 +265,9 @@ do_install() {
echo "==> Installation plan:"
echo " Symlink executables in bin/ into $BIN_DEST"
echo " Symlink SKILL.md into $SKILL_DEST"
if [[ -d "$PI_EXT_DEST_DIR" ]]; then
echo " Symlink extensions/pi/mempalace.ts into $PI_EXT_DEST"
fi
echo
confirm || { echo "Aborted."; exit 0; }
echo
@@ -234,6 +275,8 @@ do_install() {
echo
install_skill
echo
install_pi_extension
echo
check_path
echo
check_wake_up_protocol
@@ -278,6 +321,15 @@ do_uninstall() {
ok "No skill symlink to remove"
fi
echo
note "Removing pi extension symlink"
if link_if_into_repo "$PI_EXT_DEST"; then
rm "$PI_EXT_DEST"
ok "Removed pi extension symlink"
else
ok "No pi extension 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"