feat(install): --with-bridges flag emits bridges into $PWD

- Copy _bridges/ into ~/.claude/agents/_bridges/ so new-agent
  skill Phase 8 can invoke the renderer from the user fleet dir
- Add --with-bridges flag: after agents/hooks/skills install,
  invoke _bridges/emit.sh "$PWD" to render 11 bridge files
- Guard: if $PWD is the KeiSeiKit source repo itself (detected
  via ./install.sh + ./_bridges), warn and skip — avoid
  polluting the kit's own working tree
- --help prints usage block; flag parser loop supports future
  --activate-hooks coexistence without refactor
This commit is contained in:
Parfii-bot 2026-04-21 14:45:02 +08:00
parent a01ddae588
commit 3fca2427c1

View file

@ -1,6 +1,14 @@
#!/usr/bin/env bash
# KeiSeiKit — Constructor-Pattern Agent Kit installer
# Idempotent: safe to re-run. Never overwrites settings.json or existing user manifests.
#
# Usage:
# ./install.sh # install agents + hooks + skills + bridges/
# ./install.sh --with-bridges # also render cross-tool bridges into $PWD
# (AGENTS.md, .cursorrules, .cursor/rules/main.mdc,
# .github/copilot-instructions.md, Windsurf, Junie,
# Continue, Gemini, Aider, Replit — 11 files total)
# Skipped if $PWD is the KeiSeiKit repo itself.
set -euo pipefail
@ -10,6 +18,17 @@ AGENTS_DIR="$HOME_DIR/.claude/agents"
HOOKS_DIR="$HOME_DIR/.claude/hooks"
SKILLS_DIR="$HOME_DIR/.claude/skills"
WITH_BRIDGES=0
for arg in "$@"; do
case "$arg" in
--with-bridges) WITH_BRIDGES=1 ;;
--help|-h)
sed -n '3,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
exit 0
;;
esac
done
say() { printf '\033[1;36m[install]\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[warn]\033[0m %s\n' "$*"; }
err() { printf '\033[1;31m[error]\033[0m %s\n' "$*" >&2; }
@ -82,6 +101,17 @@ say "copying shared blocks -> $AGENTS_DIR/_blocks/"
backup_dir "$AGENTS_DIR/_blocks"
cp -f "$KIT_DIR/_blocks/"*.md "$AGENTS_DIR/_blocks/"
# --- copy bridges (overwrite; templates are SSoT from kit) -----------------
if [[ -d "$KIT_DIR/_bridges" ]]; then
say "copying bridge templates -> $AGENTS_DIR/_bridges/"
mkdir -p "$AGENTS_DIR/_bridges"
backup_dir "$AGENTS_DIR/_bridges"
cp -f "$KIT_DIR/_bridges/"*.tmpl "$AGENTS_DIR/_bridges/"
cp -f "$KIT_DIR/_bridges/README.md" "$AGENTS_DIR/_bridges/"
cp -f "$KIT_DIR/_bridges/emit.sh" "$AGENTS_DIR/_bridges/emit.sh"
chmod +x "$AGENTS_DIR/_bridges/emit.sh"
fi
# --- copy generic manifests, DO NOT overwrite user's existing manifests -----
say "copying generic manifests -> $AGENTS_DIR/_manifests/ (skip if exists)"
copied=0; skipped=0
@ -145,6 +175,16 @@ fi
say "generating agent .md files (--in-place)"
AGENT_ROOT="$AGENTS_DIR" "$AGENTS_DIR/_assembler/target/release/assemble" --in-place
# --- optional: render cross-tool bridges into $PWD -------------------------
if [[ "$WITH_BRIDGES" == "1" ]]; then
if [[ -f "./install.sh" && -d "./_bridges" ]]; then
warn "not generating bridges — you are in the KeiSeiKit repo, not a project directory"
else
say "rendering cross-tool bridges into $PWD"
"$KIT_DIR/_bridges/emit.sh" "$PWD"
fi
fi
# --- done -----------------------------------------------------------------
echo
say "install complete"