feat(extensions/pi): keybindings symlink + settings template + AWS/pi probes
Round out the pi bring-up story so a fresh machine can reach a working pi+mempalace install with just `git clone && ./install.sh`: - extensions/pi/keybindings.json: generic mosh/tmux newline fix (shift+enter, ctrl+j, alt+j). Safe on any machine — not region/account-specific. Symlinked into ~/.pi/agent/. - extensions/pi/settings.example.json: template for `settings.json` so pi can start without --provider/--model. NOT symlinked — pi rewrites settings.json at runtime (lastChangelogVersion bumps), which would dirty the repo. Installer prints the cp + edit hint. - install.sh: new install_pi_keybindings + uninstall mirror; new check_pi_settings probe (warns if settings.json missing); new check_aws_env probe (warns if AWS_PROFILE/AWS_REGION unset and settings.json selects amazon-bedrock). All new steps gated on pi being installed (~/.pi/agent/extensions/ exists). - extensions/pi/README.md: documents keybindings rationale, settings bootstrap, and the recommended ~/.config/pi/.env + ~/.oh-my-zsh/custom/pi-env.zsh env layout (paired with the myconfigs commit 884e329 that split AWS vars out of ~/.config/opencode/.env). Verified on tor-ms22: full install → uninstall → reinstall cycle, new shell loads AWS_PROFILE/AWS_REGION from the new pi-env.zsh hook. Works on macOS and Linux (plain ln -s, POSIX bash).
This commit is contained in:
+106
@@ -21,6 +21,14 @@ 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"
|
||||
|
||||
# pi keybindings (generic mosh/tmux newline fix — safe on any machine)
|
||||
PI_KEYS_SRC="${SCRIPT_DIR}/extensions/pi/keybindings.json"
|
||||
PI_KEYS_DEST="${HOME}/.pi/agent/keybindings.json"
|
||||
|
||||
# pi settings template (NOT symlinked — pi rewrites this file at runtime)
|
||||
PI_SETTINGS_EXAMPLE="${SCRIPT_DIR}/extensions/pi/settings.example.json"
|
||||
PI_SETTINGS_DEST="${HOME}/.pi/agent/settings.json"
|
||||
|
||||
# ── args ─────────────────────────────────────────────
|
||||
ACTION="install"
|
||||
ASSUME_YES="no"
|
||||
@@ -45,6 +53,13 @@ What install does:
|
||||
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.
|
||||
- If pi exists, symlinks extensions/pi/keybindings.json into
|
||||
~/.pi/agent/keybindings.json (generic mosh/tmux newline fix).
|
||||
- If pi exists, warns if ~/.pi/agent/settings.json is missing and points
|
||||
at extensions/pi/settings.example.json as a template (NOT symlinked —
|
||||
pi rewrites this file at runtime).
|
||||
- Warns if AWS_PROFILE / AWS_REGION are unset (only relevant to users
|
||||
whose pi settings.json selects amazon-bedrock as defaultProvider).
|
||||
- Drops a .skill-source marker in the skill dir so sibling tooling
|
||||
(deploy-skills.sh, agents-sync.zsh) knows the dir is externally owned
|
||||
|
||||
@@ -52,6 +67,7 @@ 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 pi keybindings symlink if it points into this repo
|
||||
- Removes the .skill-source marker and empty skill dir
|
||||
EOF
|
||||
exit 0 ;;
|
||||
@@ -257,6 +273,80 @@ install_pi_extension() {
|
||||
printf ' at startup only).\n'
|
||||
}
|
||||
|
||||
install_pi_keybindings() {
|
||||
# Generic mosh/tmux newline fix. Non-destructive: if a real
|
||||
# keybindings.json exists we back it up rather than clobber.
|
||||
[[ -d "$PI_EXT_DEST_DIR" ]] || return 0 # no pi → no keybindings
|
||||
|
||||
note "Linking pi keybindings → $PI_KEYS_DEST"
|
||||
if [[ -e "$PI_KEYS_DEST" || -L "$PI_KEYS_DEST" ]]; then
|
||||
if link_if_into_repo "$PI_KEYS_DEST"; then
|
||||
ok "pi keybindings already linked"
|
||||
return 0
|
||||
fi
|
||||
local backup="${PI_KEYS_DEST}.bak.$(date +%Y%m%d-%H%M%S)"
|
||||
mv "$PI_KEYS_DEST" "$backup"
|
||||
warn "Existing $PI_KEYS_DEST backed up to $backup"
|
||||
fi
|
||||
ln -s "$PI_KEYS_SRC" "$PI_KEYS_DEST"
|
||||
ok "Linked keybindings.json → $PI_KEYS_SRC"
|
||||
}
|
||||
|
||||
# ── Verify ~/.pi/agent/settings.json exists ──────────────────────────
|
||||
# If pi is installed but settings.json is missing, `pi` refuses to start
|
||||
# without `--provider ... --model ...` on every invocation. The toolkit
|
||||
# ships extensions/pi/settings.example.json as a template with a working
|
||||
# Bedrock (eu-west-1) stanza — copy + edit for your region/account.
|
||||
#
|
||||
# NOT symlinked: pi rewrites settings.json at runtime (lastChangelogVersion
|
||||
# bumps on upgrade), which would dirty the repo and cause merge noise.
|
||||
# Template-only install is the right trade-off.
|
||||
check_pi_settings() {
|
||||
[[ -d "$PI_EXT_DEST_DIR" ]] || return 0 # no pi → nothing to check
|
||||
|
||||
if [[ -f "$PI_SETTINGS_DEST" ]]; then
|
||||
ok "pi settings.json present at $PI_SETTINGS_DEST"
|
||||
return 0
|
||||
fi
|
||||
|
||||
warn "pi settings.json NOT found at $PI_SETTINGS_DEST"
|
||||
printf ' Without it, pi must be invoked with --provider/--model on every run.\n'
|
||||
printf ' Bootstrap from the shipped template:\n'
|
||||
printf ' cp %q %q\n' "$PI_SETTINGS_EXAMPLE" "$PI_SETTINGS_DEST"
|
||||
printf ' $EDITOR %q # adjust region prefix + model IDs\n' "$PI_SETTINGS_DEST"
|
||||
printf ' See extensions/pi/README.md for the eu./us./anthropic: prefix rules.\n'
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── Verify AWS env vars are present for Bedrock-backed pi ────────────
|
||||
# Only meaningful if pi's settings.json selects amazon-bedrock. We do a
|
||||
# best-effort grep rather than parsing JSON — false positives are cheap
|
||||
# (one extra probe) and the check is gated on pi being installed at all.
|
||||
check_aws_env() {
|
||||
[[ -d "$PI_EXT_DEST_DIR" ]] || return 0 # no pi → nothing to check
|
||||
|
||||
# Only warn if settings.json selects amazon-bedrock. If pi uses a
|
||||
# non-Bedrock provider (bare anthropic, openai, ...) AWS creds are
|
||||
# irrelevant and this probe would be noise.
|
||||
if [[ -f "$PI_SETTINGS_DEST" ]] \
|
||||
&& ! grep -q '"amazon-bedrock"' "$PI_SETTINGS_DEST" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -n "${AWS_PROFILE:-}" && -n "${AWS_REGION:-}" ]]; then
|
||||
ok "AWS env present (AWS_PROFILE=$AWS_PROFILE, AWS_REGION=$AWS_REGION)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
warn "AWS_PROFILE and/or AWS_REGION not set in this shell"
|
||||
printf ' pi with defaultProvider=amazon-bedrock needs both to invoke Bedrock.\n'
|
||||
printf ' Recommended layout (matches the tor-ms22 dotfiles pattern):\n'
|
||||
printf ' ~/.config/pi/.env # AWS_PROFILE=..., AWS_REGION=...\n'
|
||||
printf ' ~/.oh-my-zsh/custom/pi-env.zsh # set -a; source ~/.config/pi/.env; set +a\n'
|
||||
printf ' See extensions/pi/README.md#environment-setup for the template.\n'
|
||||
return 0
|
||||
}
|
||||
|
||||
do_install() {
|
||||
echo
|
||||
echo "mempalace-toolkit installer"
|
||||
@@ -267,6 +357,7 @@ do_install() {
|
||||
echo " Symlink SKILL.md into $SKILL_DEST"
|
||||
if [[ -d "$PI_EXT_DEST_DIR" ]]; then
|
||||
echo " Symlink extensions/pi/mempalace.ts into $PI_EXT_DEST"
|
||||
echo " Symlink extensions/pi/keybindings.json into $PI_KEYS_DEST"
|
||||
fi
|
||||
echo
|
||||
confirm || { echo "Aborted."; exit 0; }
|
||||
@@ -277,12 +368,18 @@ do_install() {
|
||||
echo
|
||||
install_pi_extension
|
||||
echo
|
||||
install_pi_keybindings
|
||||
echo
|
||||
check_path
|
||||
echo
|
||||
check_wake_up_protocol
|
||||
echo
|
||||
check_opencode_mcp
|
||||
echo
|
||||
check_pi_settings
|
||||
echo
|
||||
check_aws_env
|
||||
echo
|
||||
ok "Done."
|
||||
echo
|
||||
echo "Next: ./bin/mempalace-session --dry-run"
|
||||
@@ -330,6 +427,15 @@ do_uninstall() {
|
||||
ok "No pi extension symlink to remove"
|
||||
fi
|
||||
|
||||
echo
|
||||
note "Removing pi keybindings symlink"
|
||||
if link_if_into_repo "$PI_KEYS_DEST"; then
|
||||
rm "$PI_KEYS_DEST"
|
||||
ok "Removed pi keybindings symlink"
|
||||
else
|
||||
ok "No pi keybindings 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"
|
||||
|
||||
Reference in New Issue
Block a user