Compare commits

...

3 commits

Author SHA1 Message Date
d34a375da7 feat(install): first-run is a full guided onboarding (agents + sleep + cortex)
Some checks are pending
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / preflight (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / vps-smoke (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:frustration-matrix,kei-frustration-loop,kei-skill-importer,kei-projects-index,kei-projects-watcher,kei-gdrive-import,kei-leak-matrix,kei-skills,kei-gateway,kei-cron-scheduler,kei-export-trajectories,kei-backend-daytona,kei-d… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-compute-baremetal,kei-compute-vultr,kei-compute-linode,kei-compute-digitalocean,kei-svc-systemd,kei-llm-bridge-mlx name:hosted-sleep-compute]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-diff,kei-scheduler,kei-watch,kei-prune,kei-discover,kei-brain-view,kei-hibernate,kei-ledger-sign,kei-fork name:wave13-15]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-git-gitea,kei-git-forgejo,kei-git-gitlab,kei-git-bitbucket,kei-memory-sled,kei-memory-redis,kei-memory-postgres,kei-memory-sqlite,kei-auth-google,kei-auth-apple,kei-auth-magiclink,kei-auth-webauthn,kei-notify-slack,kei-n… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-ledger,kei-migrate,kei-changelog,kei-memory,kei-store,kei-conflict-scan,kei-refactor-engine,kei-graph-check,kei-shared,kei-dna-index,kei-pet name:core]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-machine-probe,kei-llm-ollama,kei-llm-llamacpp,kei-llm-mlx,kei-llm-router,kei-model name:llm-stack]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-router,kei-sage,kei-task,kei-chat-store,kei-crossdomain,kei-search-core,kei-content-store,kei-social-store,kei-curator,kei-auth,kei-artifact name:mcp-lbm]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:keisei,kei-forge,kei-runtime,kei-runtime-core,kei-atom-discovery,kei-agent-runtime,kei-capability,kei-provision,kei-entity-store,kei-pipe,kei-cache,kei-spawn,kei-replay name:atom-substrate]) (push) Blocked by required conditions
Sleep/cortex setup were left as separate things the user had to discover. Make
the SessionStart first-run hook a single ordered post-install checklist that
Claude walks the user through: (1) /onboard projects → per-project agents,
(2) /sleep-setup → nightly REM (recommend local-only, no remote git needed),
(3) /cortex-setup (only if the cortex daemon primitive is installed). Confirm +
run each, skippable. Fires once (marker), then silent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 21:27:01 +08:00
582b51155f feat(install): first-run nudge to /onboard projects after bundle install
After install the user got no guidance to set up project agents — the summary
only mentioned /new-agent (single), never /onboard (scan all projects → create
a specialist per project). The installer is bash and can't launch a skill, so:

- New SessionStart hook first-run-onboard.sh: on the FIRST Claude Code session
  after install, injects context nudging the user/Claude to run
  `/onboard ~/Projects/*` (scan stack + create per-project agent, delegates to
  /new-agent). Fires once (marker ~/.claude/.kei-firstrun-shown), then silent.
  Reset: rm the marker.
- settings-snippet.json: wire the hook under SessionStart (matcher "*").
- lib-summary.sh next-steps: lead with `/onboard ~/Projects/*`, then /new-agent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 19:05:00 +08:00
d89ddf0c74 fix(install): normalize null hook matcher → "" on merge (Claude Code /doctor)
Users with pre-kit hooks that have no `matcher` field end up with matcher:null,
which Claude Code /doctor rejects ("Expected string, but received null") and
skips the whole settings file. The jq merge preserved null as-is, so every
reinstall re-surfaced the error. Now map(.matcher //= "") before group_by →
null/absent collapses to "" (match-all), one group per matcher.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 16:53:27 +08:00
4 changed files with 63 additions and 2 deletions

41
hooks/first-run-onboard.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh
# first-run-onboard — on the FIRST Claude Code session after a KeiSeiKit install,
# inject a one-time POST-INSTALL ONBOARDING checklist so Claude walks the user
# through ALL setup in order (agents → sleep → cortex), instead of leaving each
# as a separate thing the user has to discover. Event: SessionStart (stdout is
# injected into session context). Fires ONCE (marker), then silent forever.
# Reset / re-run: rm ~/.claude/.kei-firstrun-shown
MARKER="$HOME/.claude/.kei-firstrun-shown"
[ -f "$MARKER" ] && exit 0
[ -d "$HOME/.claude/agents" ] || exit 0
PROJ="$HOME/Projects"
[ -d "$PROJ" ] || PROJ="$HOME/projects"
[ -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
[KeiSeiKit · FIRST-RUN ONBOARDING] The substrate is installed. Before other
work, proactively walk the user through this one-time setup, step by step, in
order — confirm each step with the user, then run it:
1. /onboard $PROJ/* — scan every project, detect stack, create a
project-specialist agent per project (delegates to /new-agent).
2. /sleep-setup — nightly memory (REM) consolidation. Recommend
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).
$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
: > "$MARKER"
exit 0

View file

@ -60,6 +60,10 @@ _jq_merge_hooks() {
| reduce ($add.hooks | keys[]) as $phase ($orig;
.hooks[$phase] = (
((.hooks[$phase] // []) + ($add.hooks[$phase] // []))
# Normalize null/absent matcher → "" (Claude Code /doctor rejects null;
# user's pre-kit hooks often have no matcher field). Before group_by so
# null + "" collapse into one group.
| map(.matcher //= "")
| group_by(.matcher)
| map(
.[0].matcher as $m

View file

@ -66,7 +66,9 @@ print_summary() {
$AGENTS_DIR/_assembler/target/release/assemble --validate
./install.sh --list # show installed primitives
To create a new project-specialist agent:
To set up agents for ALL your projects (scan stack + create one per project):
/onboard ~/Projects/*
Or create a single project-specialist agent:
/new-agent
==========================================================================
@ -93,7 +95,9 @@ EOF
$AGENTS_DIR/_assembler/target/release/assemble --validate
./install.sh --list # show installed primitives
To create a new project-specialist agent:
To set up agents for ALL your projects (scan stack + create one per project):
/onboard ~/Projects/*
Or create a single project-specialist agent:
/new-agent
==========================================================================

View file

@ -279,6 +279,18 @@
}
]
}
],
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/first-run-onboard.sh",
"statusMessage": "KeiSeiKit first-run onboard nudge..."
}
]
}
]
}
}