blue/hooks/session-start
Eric Garcia a5b142299d feat: context injection architecture via 12-expert alignment dialogue
RFC 0016 drafted from alignment dialogue achieving 95% convergence:
- Three-tier model: Identity (fixed) / Workflow (session) / Reference (on-demand)
- Manifest-driven injection via .blue/context.manifest.yaml
- URI addressing: blue://docs/, blue://context/, blue://state/
- Hooks push URIs, MCP resolves content
- Progressive visibility: blue context show

New ADRs ported from coherence-mcp:
- 0014: Alignment Dialogue Agents (renamed from 0006)
- 0015: Plausibility
- 0016: You Know Who You Are

Knowledge injection system:
- hooks/session-start for SessionStart injection
- knowledge/*.md files for global context
- Expert pools with domain-specific relevance tiers
- Updated /alignment-play skill with full scoring

Spikes completed:
- Context injection mechanisms (7 mechanisms designed)
- ADR porting inventory (17 Blue ADRs mapped)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 16:16:11 -05:00

49 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Blue SessionStart Hook
# Injects private knowledge into Claude's context via stdout
BLUE_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
KNOWLEDGE_DIR="$BLUE_ROOT/knowledge"
# Phase 1: Read from plaintext files
# Phase 2: Will read from encrypted SQLite via `blue knowledge get`
inject_file() {
local file="$1"
local tag="$2"
local name="$3"
if [ -f "$file" ]; then
if [ -n "$name" ]; then
echo "<$tag name=\"$name\">"
else
echo "<$tag>"
fi
cat "$file"
echo "</$tag>"
fi
}
# 1. Inject global knowledge (from blue repo)
for knowledge_file in "$KNOWLEDGE_DIR"/*.md; do
if [ -f "$knowledge_file" ]; then
name=$(basename "$knowledge_file" .md)
inject_file "$knowledge_file" "blue-knowledge" "$name"
fi
done
# 2. Inject project-specific workflow (from current project, if exists)
# This file is committed to git, so team can see it
inject_file ".blue/workflow.md" "blue-project-workflow" ""
# 3. Run the actual session-start command (registers session in DB)
"$BLUE_ROOT/target/release/blue" session-start "$@" 2>/dev/null
# Output session context
cat << 'EOF'
<system-reminder>
SessionStart:blue hook loaded. Blue MCP tools available.
Use `blue_status` to see current state, `blue_next` for recommendations.
</system-reminder>
EOF