mirror of
https://github.com/earendil-works/pi.git
synced 2026-09-28 14:13:13 +08:00
A presentation draws tool calls and colours; it executes nothing and validates nothing. Both cost it typebox anyway, which is 17 MB of module graph: 682 ESM modules whose narrowest entry re-exports ~300 of them, so there is no cherry-picking and both doors had to close before any process stopped paying. ToolExecutionComponent no longer looks up createAllToolDefinitions by tool name; callers pass what to render, and its parameter type now says so. Each built-in tool's presentation moves to core/tools/renderers/<tool>.ts, leaving the schema and execute path behind; bash and powershell share createShellRenderers(prompt). Tool definitions keep their exact public shape and spread the renderers in. withBuiltInRenderers() preserves the old fallback, where an extension override without renderers still draws like the built-in - that behaviour used to live inside the component, and two tests caught its absence. theme.ts keeps palettes; the typebox schema and its error formatting move to theme-json.ts, installed through setThemeJsonValidator. Built-in themes were never validated, so only processes that load user-authored themes need it. pi installs it during startup, before the first theme loads, and the invalid-theme message is unchanged. Measured with mini, running built output: the presentation drops from 87 MB and 99 files to 72 MB and 88 files, with typebox absent from its graph, while still rendering tool output through the real built-in renderers. Also: packages/server's vitest aliases were prefix matches, so a subpath import resolved onto index.ts/utils/uuid and failed five suites; they are exact now with explicit subpath rules. And mini-test.sh spawns mini the way pi-test.sh spawns pi, with --fresh/--stop for the detached session server.
47 lines
1.5 KiB
Bash
Executable File
47 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
MINI_SRC="$SCRIPT_DIR/packages/coding-agent/src/experimental/mini/main.ts"
|
|
MINI_DIST="$SCRIPT_DIR/packages/coding-agent/dist/experimental/mini/main.js"
|
|
|
|
# The session server is spawned detached and outlives the TUI, so it keeps running whatever code it
|
|
# started with. Restart it after changing anything under mini/, or the protocol will not match.
|
|
stop_server() {
|
|
pkill -f "mini/server/entry" 2>/dev/null || true
|
|
rm -f "${PI_AGENT_DIR:-$HOME/.pi/agent}/experimental/mini.sock"
|
|
}
|
|
|
|
USE_DIST=false
|
|
ARGS=()
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--dist) USE_DIST=true ;;
|
|
--fresh) stop_server ;;
|
|
--stop) stop_server; echo "Stopped the mini session server."; exit 0 ;;
|
|
--help)
|
|
cat <<'USAGE'
|
|
Usage: ./mini-test.sh [--dist] [--fresh] [--stop] [mini args...]
|
|
|
|
--dist run built output with plain node instead of tsx on sources
|
|
--fresh stop the detached session server first, so it picks up your changes
|
|
--stop stop the detached session server and exit
|
|
|
|
Mini args are passed through, for example:
|
|
./mini-test.sh --continue
|
|
USAGE
|
|
exit 0 ;;
|
|
*) ARGS+=("$arg") ;;
|
|
esac
|
|
done
|
|
|
|
if [[ "$USE_DIST" == "true" ]]; then
|
|
if [[ ! -f "$MINI_DIST" ]]; then
|
|
echo "No build found. Run: npm run build -w @earendil-works/pi-coding-agent" >&2
|
|
exit 1
|
|
fi
|
|
exec node "$MINI_DIST" ${ARGS[@]+"${ARGS[@]}"}
|
|
fi
|
|
|
|
exec "$SCRIPT_DIR/node_modules/.bin/tsx" --tsconfig "$SCRIPT_DIR/tsconfig.json" "$MINI_SRC" ${ARGS[@]+"${ARGS[@]}"}
|