aboutsummaryrefslogtreecommitdiffstats
path: root/pi-ext/dev.sh
blob: efd17570d7ab829b48c5890227b362eb0e95b2a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
# dev.sh - run pi with ONLY this repo's extensions (isolated from the global set).
#
# -ne / --no-extensions disables auto-discovery of ~/.pi/agent/extensions and
# project-local .pi/extensions, so the stable global set keeps running other
# sessions untouched. Each *.ts here is then loaded explicitly via -e.
#
# Any extra args are passed through to pi, e.g:  ./dev.sh --mode rpc
set -euo pipefail

cd "$(dirname "$0")"

# Extensions to skip loading in dev too (experimental / broken / opt-in).
EXCLUDE=" sixel-images.ts "

args=(-ne)
shopt -s nullglob
for f in *.ts; do
  case "$EXCLUDE" in *" $f "*) continue ;; esac
  args+=(-e "./$f")
done
shopt -u nullglob

if [ "${#args[@]}" -eq 1 ]; then
  echo "dev.sh: no *.ts extensions found in $(pwd)" >&2
  exit 1
fi

# -ne disables package discovery too, so globally-installed pi packages
# (pi-subagents, pi-goal, pi-autoresearch, ...) wouldn't load their tools. Re-add
# each package's extension entry via -e so they work alongside our dev copies.
# Their skills/prompts still load (separate -ns/-np gates, which we don't pass).
# Skip some with e.g. PI_DEV_SKIP_PACKAGES="pi-goal,pi-autoresearch".
if command -v node >/dev/null 2>&1; then
  while IFS= read -r extpath; do
    [ -n "$extpath" ] && args+=(-e "$extpath")
  done < <(node "$(dirname "$0")/scripts/resolve-package-extensions.mjs" 2>/dev/null || true)
fi

exec pi "${args[@]}" "$@"