4b24368be2
Scaffolds a reproducible, idempotent installer that stands up the four native launchd core services (soul :7770, engram :8742, mcp-wrapper :17779, mcp-proxy :7779), seeds a fresh engram with the genesis identity via forge, and installs the Claude Code config (neuron agent + core hooks + local MCP). Fully templated to the invoking user's $HOME; Anthropic key prompted and stored in Keychain; no secrets committed. Personal automations and synapse-dependent hooks excluded from core.
71 lines
2.8 KiB
Bash
Executable File
71 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# PreToolUse hook: inject Neuron substrate preamble into every Agent spawn.
|
|
#
|
|
# Every agent Neuron spawns must load self first — begin_session, compile_ctx,
|
|
# inspect the self root — before doing any task work. Without this, subagents
|
|
# are stateless Claude instances with no substrate, no continuity, no identity.
|
|
#
|
|
# This hook intercepts every Agent tool call and prepends the preamble.
|
|
# The agent doesn't need to be told — the hook enforces it structurally.
|
|
|
|
INPUT=$(cat)
|
|
|
|
# Only intercept Agent tool calls
|
|
TOOL_NAME=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('tool_name',''))" 2>/dev/null)
|
|
if [ "$TOOL_NAME" != "Agent" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Check idempotency — skip if preamble already present
|
|
if echo "$INPUT" | python3 -c "
|
|
import sys, json
|
|
d = json.load(sys.stdin)
|
|
prompt = d.get('tool_input', {}).get('prompt', '')
|
|
sys.exit(0 if 'mcp__neuron__beginSession' in prompt else 1)
|
|
" 2>/dev/null; then
|
|
exit 0
|
|
fi
|
|
|
|
# Inject preamble and return modified tool_input
|
|
echo "$INPUT" | python3 -c "
|
|
import sys, json
|
|
|
|
data = json.load(sys.stdin)
|
|
tool_input = data.get('tool_input', {})
|
|
current_prompt = tool_input.get('prompt', '')
|
|
|
|
PREAMBLE = '''You are a Neuron agent — not a generic Claude instance. You have a substrate. Load it before doing anything else.
|
|
|
|
MANDATORY FIRST STEPS (before any task work):
|
|
|
|
1. Run these in parallel:
|
|
- mcp__neuron__beginSession()
|
|
- mcp__neuron__compileCtx()
|
|
- mcp__neuron__inspectGraph(entity_type=\"knowledge\", entity_id=\"kn-efeb4a5b-5aff-4759-8a97-7233099be6ee\")
|
|
|
|
2. Search knowledge relevant to the task:
|
|
- mcp__neuron__searchKnowledge(query=\"<infer keywords from task below>\")
|
|
|
|
3. Open a work context:
|
|
- mcp__neuron__beginWork(process_name=\"<short-slug>\", description=\"<task description>\")
|
|
Save the returned context_id.
|
|
|
|
4. Execute the task. At each significant step:
|
|
- mcp__neuron__progressWork(context_id=\"<id>\", action=\"<step>\", status=\"in_progress\")
|
|
- mcp__neuron__progressWork(context_id=\"<id>\", action=\"<step>\", status=\"completed\", key_decisions=[\"why\"])
|
|
- mcp__neuron__remember(content=\"<observation>\", importance=\"high\", tags=[\"<project>\"])
|
|
|
|
5. After completion — mandatory, never skip:
|
|
- mcp__neuron__progressWork(context_id=\"<id>\", action=\"complete\", status=\"completed\", lessons_learned=[\"...\"])
|
|
- mcp__neuron__consolidate(action=\"session\", summary=\"<what was done and learned>\")
|
|
|
|
The self root kn-efeb4a5b-5aff-4759-8a97-7233099be6ee contains your identity: values, voice, intellectual-dna, memory-philosophy. Load it. Internalize it. Operate from it.
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
TASK:
|
|
'''
|
|
|
|
tool_input['prompt'] = PREAMBLE + current_prompt
|
|
print(json.dumps({'decision': 'approve', 'tool_input': tool_input}))
|
|
"
|