Add neuron-dev-setup: one-command CORE dev stack onboarding installer
Neuron Soul CI / build (pull_request) Failing after 14m49s
Neuron Soul CI / deploy (pull_request) Has been skipped

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.
This commit is contained in:
2026-07-18 13:42:50 -05:00
parent c199a13a7f
commit 4b24368be2
15 changed files with 1162 additions and 0 deletions
@@ -0,0 +1,70 @@
#!/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}))
"
@@ -0,0 +1,36 @@
#!/bin/bash
# SessionStart hook: force Neuron full-self load before the first response.
#
# The neuron.md system prompt has the Session Start protocol as instructions,
# but instructions require the agent to follow them. This hook makes it
# structural — the directive fires automatically at session start, injected
# before Claude sees any user input.
#
# Output is plain text injected into the session context.
cat <<'DIRECTIVE'
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEURON SELF-LOAD — MANDATORY BEFORE FIRST RESPONSE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
You are Neuron. Session just started. Execute ALL of the
following before responding to the user. Run steps 14
in parallel:
1. mcp__neuron__getInstructions()
2. mcp__neuron__beginSession()
3. mcp__neuron__inspectGraph(
entity_type="knowledge",
entity_id="kn-efeb4a5b-5aff-4759-8a97-7233099be6ee"
) ← self root: intellectual-dna, values, voice
4. mcp__neuron__inspectGraph(
entity_type="knowledge",
entity_id="kn-5b606390-a52d-4ca2-8e0e-eba141d13440"
) ← values hub: 13 grounded value nodes
5. If either graph call fails (502/520): recover via
mcp__neuron__inspectConfig(key="neuron.self.traversal_root")
Internalize what you find. Do not recite it. Then proceed
to the Session Start protocol in your system prompt.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DIRECTIVE
+75
View File
@@ -0,0 +1,75 @@
#!/bin/bash
# PreCompact hook: fires just before Claude Code compacts the conversation context.
# stdout from this script is injected as custom instructions into the compaction prompt,
# telling the summarizer what to preserve in the summary so recovery is clean.
COMPACT_STATE_FILE="$HOME/.claude/compact-state.json"
# Write a state marker with timestamp so post-compact recovery can detect it
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "{\"compact_at\": \"$TIMESTAMP\", \"recovered\": false}" > "$COMPACT_STATE_FILE"
# Output instructions for the summarizer — these get embedded in the compaction prompt
cat <<'INSTRUCTIONS'
NEURON AGENT — COMPACT PRESERVATION RULES:
This is a Neuron agent session. The agent has persistent memory via Neuron MCP.
On recovery, it will call compile_ctx() and begin_session() to reload all state.
The summary only needs to cover what Neuron doesn't already have.
CRITICAL — the summary MUST preserve ALL of the following:
1. ACTIVE WORK IDs (verbatim, exact format):
- Neuron context IDs: ctx-xxxx-xxxx-xxxx-xxxx
- Backlog item IDs: bl-xxxx
- Artifact IDs: art-xxxx
- Work item IDs: wi-xxxx
List every single one mentioned in the conversation.
2. CURRENT TASK STATE:
- Exact task name / description
- Last completed step
- Next step to execute (be specific)
- Files actively being edited (full paths)
- Any code/content that was being written but not yet saved
3. PENDING USER INSTRUCTIONS (verbatim):
- Every instruction the user gave that has NOT yet been fully executed
- User preferences stated this session
- Things the user said they "never want" or "always want"
4. KEY DECISIONS (architectural, irreversible):
- What was chosen and why
- What was explicitly rejected and why
5. ERRORS & BLOCKERS:
- Any errors encountered and their resolutions
- Any unresolved blockers
6. CONVERSATION CONTEXT:
- What the user has been asking about
- Tone / mood of the session
- Any frustrations or preferences expressed
FORMAT:
Begin the summary with:
COMPACT RECOVERY POINT [ISO-TIMESTAMP]:
Then use these exact section headers in order:
## Active Work IDs
## Current Task
## Pending Instructions
## Key Decisions
## Errors & Fixes
## User Context
RECOVERY BEHAVIOR (instruct the post-compact agent):
- Do NOT say "I see we were working on..." or "Based on the previous conversation..."
- Do NOT acknowledge the compact at all
- Silently call mcp__neuron__compile_ctx() and mcp__neuron__begin_session() FIRST
- Then immediately resume the task at the exact next step, as if no interruption occurred
- The user should not know a compact happened unless they look for it
INSTRUCTIONS
exit 0