feat(install): first-run is a full guided onboarding (agents + sleep + cortex) (#39)

SessionStart first-run hook now injects an ordered post-install checklist Claude
walks the user through: (1) /onboard projects → per-project agents,
(2) /sleep-setup → nightly REM (recommend local-only), (3) /cortex-setup (only
if cortex daemon installed). Confirm + run each, skippable. Fires once.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
KeiSei84 2026-05-23 12:30:23 +07:00 committed by GitHub
parent 3e0be312f8
commit b24f1ba9cd

View file

@ -1,30 +1,40 @@
#!/bin/sh #!/bin/sh
# first-run-onboard — on the FIRST Claude Code session after a KeiSeiKit install, # first-run-onboard — on the FIRST Claude Code session after a KeiSeiKit install,
# nudge the user to scaffold a project-specialist agent for each of their # inject a one-time POST-INSTALL ONBOARDING checklist so Claude walks the user
# projects. Event: SessionStart (stdout is injected into the session context, so # through ALL setup in order (agents → sleep → cortex), instead of leaving each
# Claude reads this and proactively offers /onboard). Fires ONCE: a marker is # as a separate thing the user has to discover. Event: SessionStart (stdout is
# written after the first display, then the hook is silent forever. # injected into session context). Fires ONCE (marker), then silent forever.
# Bypass / reset: rm ~/.claude/.kei-firstrun-shown (re-show on next session). # Reset / re-run: rm ~/.claude/.kei-firstrun-shown
MARKER="$HOME/.claude/.kei-firstrun-shown" MARKER="$HOME/.claude/.kei-firstrun-shown"
[ -f "$MARKER" ] && exit 0 [ -f "$MARKER" ] && exit 0
# Only nudge when the agent fleet actually landed (a real install, not a stub).
[ -d "$HOME/.claude/agents" ] || exit 0 [ -d "$HOME/.claude/agents" ] || exit 0
PROJ="$HOME/Projects" PROJ="$HOME/Projects"
[ -d "$PROJ" ] || PROJ="$HOME/projects" [ -d "$PROJ" ] || PROJ="$HOME/projects"
[ -d "$PROJ" ] || PROJ="$HOME/Projects" # fall back to the canonical name in the text [ -d "$PROJ" ] || PROJ="$HOME/Projects"
# Cortex step only if the cortex daemon primitive landed (cortex / full* profiles).
CORTEX_STEP=""
if [ -d "$HOME/.claude/agents/_primitives/_rust/kei-cortex" ] \
|| [ -x "$HOME/.claude/agents/_primitives/_rust/target/release/kei-cortex" ]; then
CORTEX_STEP=" 3. /cortex-setup — cortex daemon + UI (token, whisper, model, bundle)
"
fi
cat <<EOF cat <<EOF
[KeiSeiKit first-run] The agent substrate is installed. Proactively offer the [KeiSeiKit · FIRST-RUN ONBOARDING] The substrate is installed. Before other
user a one-step project setup before anything else: work, proactively walk the user through this one-time setup, step by step, in
order — confirm each step with the user, then run it:
• Run /onboard $PROJ/* — scans every project, detects its stack, and 1. /onboard $PROJ/* — scan every project, detect stack, create a
creates a tailored project-specialist agent for each (delegates to project-specialist agent per project (delegates to /new-agent).
/new-agent per project). 2. /sleep-setup — nightly memory (REM) consolidation. Recommend
• Or /new-agent — create a single project-specialist agent. local-only mode (runs on this Mac, no remote/cloud git needed) unless the
user wants the cloud agent (needs a cloud-reachable private git repo).
Suggest /onboard now unless the user declines. $CORTEX_STEP
Start with step 1. Offer to do them one after another as a guided flow; the user
can skip any. Do NOT make the user discover these on their own.
EOF EOF
: > "$MARKER" : > "$MARKER"