feat: Complete sync of all Claude Code CLI upgrades
- Add all 21 commands (clawd, ralph, prometheus*, dexto*) - Add all hooks (intelligent-router, clawd-*, prometheus-wrapper, unified-integration-v2) - Add skills (ralph, prometheus master) - Add MCP servers (registry.json, manager.sh) - Add plugins directory with marketplaces - Add health-check.sh and aliases.sh scripts - Complete repository synchronization with local ~/.claude/ Total changes: 100+ new files added All integrations now fully backed up in repository 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
0
hooks/QWEN-HOOK-README.md
Normal file → Executable file
0
hooks/QWEN-HOOK-README.md
Normal file → Executable file
10
hooks/clawd-auto-trigger.sh
Executable file
10
hooks/clawd-auto-trigger.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
PROMPT=$(cat)
|
||||
COMPLEXITY_INDICATORS=("build.*from scratch" "implement.*complete" "autonomous" "end to end" "full.*feature")
|
||||
for indicator in "${COMPLEXITY_INDICATORS[@]}"; do
|
||||
if echo "$PROMPT" | grep -qiE "$indicator"; then
|
||||
echo "💡 Tip: This task looks complex. Consider using /clawd for autonomous execution."
|
||||
break
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
5
hooks/clawd-session-start.sh
Executable file
5
hooks/clawd-session-start.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
curl -s -X POST "http://127.0.0.1:8766/hooks/session-start" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"timestamp":"' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '"}' > /dev/null 2>&1 || true
|
||||
exit 0
|
||||
6
hooks/clawd-task-complete.sh
Executable file
6
hooks/clawd-task-complete.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
HOOK_INPUT=$(cat)
|
||||
curl -s -X POST "http://127.0.0.1:8766/hooks/task-complete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$HOOK_INPUT" > /dev/null 2>&1 || true
|
||||
exit 0
|
||||
135
hooks/clawd-wrapper.sh
Executable file
135
hooks/clawd-wrapper.sh
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
# Clawd Hook Wrapper - Executes clawd via the hook system
|
||||
# This avoids direct binary calls and uses the gateway properly
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CLAWD_DIR="${HOME}/.claude/clawd"
|
||||
GATEWAY_PID_FILE="${CLAWD_DIR}/gateway.pid"
|
||||
LOG_DIR="${CLAWD_DIR}/logs"
|
||||
|
||||
# Ensure log directory exists
|
||||
mkdir -p "${LOG_DIR}"
|
||||
|
||||
log() {
|
||||
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] [clawd-wrapper] $*" | tee -a "${LOG_DIR}/wrapper.log"
|
||||
}
|
||||
|
||||
# Check if gateway is running
|
||||
check_gateway() {
|
||||
if [[ -f "$GATEWAY_PID_FILE" ]]; then
|
||||
local pid
|
||||
pid=$(cat "$GATEWAY_PID_FILE" 2>/dev/null || echo "")
|
||||
if [[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if Python gateway is running
|
||||
if pgrep -f "uvicorn.*clawd.*main" > /dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if clawdbot-gateway is running
|
||||
if pgrep -f "clawdbot-gateway" > /dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Start the Python gateway if not running
|
||||
ensure_gateway() {
|
||||
if check_gateway; then
|
||||
log "Gateway already running"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "Starting Clawd gateway..."
|
||||
cd "${CLAWD_DIR}/gateway"
|
||||
|
||||
# Activate venv and start
|
||||
source venv/bin/activate
|
||||
nohup python -m uvicorn main:app --host 127.0.0.1 --port 8766 > "${LOG_DIR}/gateway.log" 2>&1 &
|
||||
|
||||
local pid=$!
|
||||
echo "$pid" > "$GATEWAY_PID_FILE"
|
||||
sleep 2
|
||||
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
log "Gateway started (PID: ${pid})"
|
||||
return 0
|
||||
else
|
||||
log "ERROR: Failed to start gateway"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute task via clawd using the agent command
|
||||
execute_clawd() {
|
||||
local task="$1"
|
||||
local agent="${2:-main}"
|
||||
local thinking="${3:-medium}"
|
||||
|
||||
log "Executing task via clawd: ${task}"
|
||||
|
||||
# Use clawdbot agent command with --local flag
|
||||
if command -v clawdbot >/dev/null 2>&1; then
|
||||
clawdbot agent --local --agent "$agent" --message "$task" --thinking "$thinking" 2>&1
|
||||
elif [[ -x "${HOME}/.local/bin/clawdbot" ]]; then
|
||||
"${HOME}/.local/bin/clawdbot" agent --local --agent "$agent" --message "$task" --thinking "$thinking" 2>&1
|
||||
else
|
||||
log "ERROR: clawdbot not found"
|
||||
echo "Error: clawdbot not found. Please install clawdbot first." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main entry point
|
||||
main() {
|
||||
local task=""
|
||||
local agent="main"
|
||||
local thinking="medium"
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--agent|-a)
|
||||
agent="$2"
|
||||
shift 2
|
||||
;;
|
||||
--thinking)
|
||||
thinking="$2"
|
||||
shift 2
|
||||
;;
|
||||
--task)
|
||||
task="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
task="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If no task, read from stdin
|
||||
if [[ -z "$task" ]]; then
|
||||
if [[ -t 0 ]]; then
|
||||
echo "Usage: $0 [--agent <id>] [--thinking <level>] --task <task>" >&2
|
||||
exit 1
|
||||
else
|
||||
task=$(cat)
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Task: ${task}, Agent: ${agent}, Thinking: ${thinking}"
|
||||
|
||||
# Ensure gateway is running
|
||||
ensure_gateway
|
||||
|
||||
# Execute the task
|
||||
execute_clawd "$task" "$agent" "$thinking"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
15
hooks/hooks.json
Normal file
15
hooks/hooks.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"matcher": "startup|resume|clear|compact",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "bash ~/.claude/hooks/session-start-superpowers.sh"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
88
hooks/prometheus-wrapper.sh
Executable file
88
hooks/prometheus-wrapper.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
# Prometheus Wrapper - All modes and agents
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PROMETHEUS_DIR="${HOME}/.claude/prometheus"
|
||||
VENV_DIR="${PROMETHEUS_DIR}/venv"
|
||||
LOG_DIR="${PROMETHEUS_DIR}/logs"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
log_prometheus() {
|
||||
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] [prometheus] $*" | tee -a "${LOG_DIR}/wrapper.log"
|
||||
}
|
||||
|
||||
check_installed() {
|
||||
if [[ ! -d "$VENV_DIR" ]]; then
|
||||
echo "Prometheus not installed. Run: bash ${PROMETHEUS_DIR}/install.sh"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
execute_prometheus() {
|
||||
local task="$1"
|
||||
local mode="${2:-auto}"
|
||||
local repo="${3:-.}"
|
||||
|
||||
log_prometheus "Mode: $mode, Repo: $repo"
|
||||
log_prometheus "Task: $task"
|
||||
|
||||
if ! check_installed; then
|
||||
echo "ERROR: Prometheus not installed. Run install script first." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
source "${VENV_DIR}/bin/activate"
|
||||
cd "$repo"
|
||||
|
||||
# Simulate Prometheus execution (would call actual Python code)
|
||||
case "$mode" in
|
||||
classify|bug|feature|context|edit|test)
|
||||
log_prometheus "Running in $mode mode"
|
||||
echo "Prometheus [$mode mode]: Analyzing task..."
|
||||
echo "Task: $task"
|
||||
echo ""
|
||||
echo "Note: Full Prometheus execution requires:"
|
||||
echo " 1. Run: bash ~/.claude/prometheus/install.sh"
|
||||
echo " 2. Configure: API keys and Neo4j (optional)"
|
||||
echo " 3. Dependencies: LangGraph, Docker, Neo4j"
|
||||
;;
|
||||
*)
|
||||
log_prometheus "Running in auto mode"
|
||||
echo "Prometheus [auto]: Detecting task type..."
|
||||
echo "Task: $task"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
local task=""
|
||||
local mode="auto"
|
||||
local repo="."
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--classify|--bug|--feature|--context|--edit|--test)
|
||||
mode="${1#--}"
|
||||
shift
|
||||
;;
|
||||
--repo|-r)
|
||||
repo="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
task="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -z "$task" ]] && task=$(cat)
|
||||
[[ -z "$task" ]] && echo "Usage: $0 [--classify|--bug|--feature|--context|--edit|--test] [--repo <path>] <task>" && exit 1
|
||||
|
||||
execute_prometheus "$task" "$mode" "$repo"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
144
hooks/unified-integration-v2.sh
Executable file
144
hooks/unified-integration-v2.sh
Executable file
@@ -0,0 +1,144 @@
|
||||
#!/bin/bash
|
||||
# Claude Code Enhanced Integration Hook v2
|
||||
# Integrates ALL 5 frameworks: Chippery, OpenAgentsControl, AGIAgent, Agno, OS-Copilot
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CLAUDE_DIR="${HOME}/.claude"
|
||||
UPGRADE_DIR="${CLAUDE_DIR}/claude-code-upgrade"
|
||||
LOG_DIR="${UPGRADE_DIR}/logs"
|
||||
STATE_FILE="${UPGRADE_DIR}/state.json"
|
||||
|
||||
SERVER_ENABLED="${SERVER_ENABLED:-true}"
|
||||
SERVER_HOST="${SERVER_HOST:-127.0.0.1}"
|
||||
SERVER_PORT="${SERVER_PORT:-8765}"
|
||||
SERVER_PID_FILE="${UPGRADE_DIR}/server.pid"
|
||||
SERVER_LOG="${LOG_DIR}/server.log"
|
||||
|
||||
mkdir -p "${UPGRADE_DIR}" "${LOG_DIR}"
|
||||
|
||||
log() {
|
||||
local level="$1"
|
||||
shift
|
||||
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] [${level}] $*" | tee -a "${LOG_DIR}/integration.log"
|
||||
}
|
||||
|
||||
save_state() {
|
||||
echo '{"timestamp":"'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"}' > "${STATE_FILE}"
|
||||
}
|
||||
|
||||
server_running() {
|
||||
if [[ -f "$SERVER_PID_FILE" ]]; then
|
||||
local pid
|
||||
pid=$(cat "$SERVER_PID_FILE" 2>/dev/null || echo "")
|
||||
[[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
start_server() {
|
||||
if [[ "$SERVER_ENABLED" != "true" ]]; then
|
||||
log INFO "FastAPI server disabled"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if server_running; then
|
||||
log INFO "FastAPI server already running"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log INFO "Starting FastAPI Control Plane server..."
|
||||
|
||||
cd "${CLAUDE_DIR}/server"
|
||||
nohup python3 -m uvicorn main:app --host "$SERVER_HOST" --port "$SERVER_PORT" --reload >> "$SERVER_LOG" 2>&1 &
|
||||
|
||||
local server_pid=$!
|
||||
echo "$server_pid" > "$SERVER_PID_FILE"
|
||||
sleep 3
|
||||
|
||||
if server_running; then
|
||||
log INFO "FastAPI server started (PID: ${server_pid})"
|
||||
echo "🌐 Control Plane: http://${SERVER_HOST}:${SERVER_PORT}/ui" >&2
|
||||
else
|
||||
log ERROR "Failed to start FastAPI server"
|
||||
return 1
|
||||
fi
|
||||
|
||||
save_state
|
||||
}
|
||||
|
||||
stop_server() {
|
||||
if ! server_running; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local pid
|
||||
pid=$(cat "$SERVER_PID_FILE")
|
||||
log INFO "Stopping FastAPI server (PID: ${pid})..."
|
||||
kill "$pid" 2>/dev/null || true
|
||||
rm -f "$SERVER_PID_FILE"
|
||||
save_state
|
||||
}
|
||||
|
||||
show_status() {
|
||||
log INFO "=== Claude Code Enhanced Integration Status ==="
|
||||
echo ""
|
||||
echo "🔧 Components:"
|
||||
echo " ✓ Codebase Indexer (Chippery)"
|
||||
echo " ✓ Plan Executor (OpenAgentsControl)"
|
||||
echo " ✓ MCP Client (AGIAgent/Agno)"
|
||||
echo " ✓ Multi-Agent Orchestrator (Agno)"
|
||||
echo " ✓ Self-Learner (OS-Copilot)"
|
||||
echo " ✓ Document Generator (AGIAgent)"
|
||||
echo " ✓ Context Manager (OpenAgentsControl)"
|
||||
echo ""
|
||||
|
||||
if server_running; then
|
||||
local pid
|
||||
pid=$(cat "$SERVER_PID_FILE")
|
||||
echo "🌐 FastAPI Control Plane: RUNNING (PID: ${pid})"
|
||||
echo " URL: http://${SERVER_HOST}:${SERVER_PORT}/ui"
|
||||
echo ""
|
||||
else
|
||||
echo "🌐 FastAPI Control Plane: STOPPED"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "📁 Logs: ${LOG_DIR}/"
|
||||
}
|
||||
|
||||
main() {
|
||||
local hook_input=""
|
||||
if [[ -t 0 ]]; then
|
||||
hook_input="${1:-}"
|
||||
else
|
||||
hook_input=$(cat)
|
||||
fi
|
||||
|
||||
local command="${hook_input:-status}"
|
||||
|
||||
case "$command" in
|
||||
start)
|
||||
log INFO "Starting Claude Code Enhanced Integration..."
|
||||
start_server
|
||||
log INFO "Integration complete"
|
||||
;;
|
||||
stop)
|
||||
log INFO "Stopping Claude Code Enhanced Integration..."
|
||||
stop_server
|
||||
;;
|
||||
restart)
|
||||
stop_server
|
||||
sleep 2
|
||||
start_server
|
||||
;;
|
||||
status|*)
|
||||
show_status
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
393
hooks/unified-integration.sh
Executable file
393
hooks/unified-integration.sh
Executable file
@@ -0,0 +1,393 @@
|
||||
#!/bin/bash
|
||||
# Claude Code Unified Integration Hook
|
||||
# Auto-triggers Ralph Orchestrator, ARC Protocol, and manages claude-mem
|
||||
# ALWAYS-ON MODE - Ralph runs continuously and orchestrates all tasks
|
||||
#
|
||||
# Architecture:
|
||||
# Claude Code (User) -> Hook -> Ralph Orchestrator (ALWAYS-ON)
|
||||
# |
|
||||
# +-> ARC Protocol Workers (parallel execution)
|
||||
# +-> claude-mem (persistent memory)
|
||||
# +-> Multiple AI Backends (Claude, Gemini, etc.)
|
||||
#
|
||||
# Environment Variables:
|
||||
# RALPH_MODE - "always" (default), "agents", "off"
|
||||
# RALPH_BACKEND - "claude" (default), "kiro", "gemini", "opencode"
|
||||
# RALPH_PRESET - "claude-code" (default), "feature", "tdd-red-green", etc.
|
||||
# ARC_ENABLED - "true" (default) to enable ARC Protocol workers
|
||||
# CLAUDE_MEM_ENABLED - "true" (default) to enable claude-mem memory
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURATION
|
||||
# ============================================================================
|
||||
|
||||
CLAUDE_DIR="${HOME}/.claude"
|
||||
RALPH_DIR="${CLAUDE_DIR}/ralph-integration"
|
||||
ARC_DIR="${RALPH_DIR}/arc"
|
||||
LOG_DIR="${RALPH_DIR}/logs"
|
||||
|
||||
# Ralph State Files
|
||||
RALPH_LOCK_FILE="${RALPH_DIR}/ralph.lock"
|
||||
RALPH_PID_FILE="${RALPH_DIR}/ralph.pid"
|
||||
RALPH_LOG_FILE="${LOG_DIR}/ralph.log"
|
||||
RALPH_CONFIG="${RALPH_DIR}/ralph.yml"
|
||||
|
||||
# ARC State Files
|
||||
ARC_LOCK_FILE="${RALPH_DIR}/arc.lock"
|
||||
ARC_PID_FILE="${RALPH_DIR}/arc.pid"
|
||||
ARC_LOG_FILE="${LOG_DIR}/arc.log"
|
||||
ARC_CONFIG="${ARC_DIR}/.arc/STATE.md"
|
||||
|
||||
# Integration Log
|
||||
INTEGRATION_LOG="${LOG_DIR}/integration.log"
|
||||
|
||||
# Default Settings (override via environment variables)
|
||||
RALPH_MODE="${RALPH_MODE:-always}"
|
||||
RALPH_BACKEND="${RALPH_BACKEND:-claude}"
|
||||
RALPH_PRESET="${RALPH_PRESET:-claude-code}"
|
||||
ARC_ENABLED="${ARC_ENABLED:-true}"
|
||||
CLAUDE_MEM_ENABLED="${CLAUDE_MEM_ENABLED:-true}"
|
||||
|
||||
# Maximum Ralph iterations
|
||||
RALPH_MAX_ITERATIONS="${RALPH_MAX_ITERATIONS:-100}"
|
||||
|
||||
# Create directories
|
||||
mkdir -p "${RALPH_DIR}" "${LOG_DIR}" "${ARC_DIR}"
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
local level="$1"
|
||||
shift
|
||||
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] [${level}] $*" | tee -a "${INTEGRATION_LOG}"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# INPUT PROCESSING
|
||||
# ============================================================================
|
||||
|
||||
# Read hook input from stdin
|
||||
HOOK_INPUT=$(cat)
|
||||
USER_PROMPT=$(echo "$HOOK_INPUT" | jq -r '.prompt // empty' 2>/dev/null || echo "")
|
||||
|
||||
# Fallback: if no JSON input, use first argument
|
||||
if [[ -z "$USER_PROMPT" && $# -gt 0 ]]; then
|
||||
USER_PROMPT="$1"
|
||||
fi
|
||||
|
||||
log INFO "Unified integration triggered"
|
||||
log INFO "Mode: ${RALPH_MODE}"
|
||||
log INFO "Prompt: ${USER_PROMPT:0:100}..."
|
||||
|
||||
# ============================================================================
|
||||
# RALPH ORCHESTRATOR INTEGRATION
|
||||
# ============================================================================
|
||||
|
||||
start_ralph() {
|
||||
local prompt="$1"
|
||||
|
||||
# Check if Ralph is already running
|
||||
if [[ -f "$RALPH_LOCK_FILE" ]]; then
|
||||
local lock_pid
|
||||
lock_pid=$(cat "$RALPH_LOCK_FILE" 2>/dev/null || echo "")
|
||||
if [[ -n "$lock_pid" ]] && kill -0 "$lock_pid" 2>/dev/null; then
|
||||
log INFO "Ralph already running (PID: ${lock_pid})"
|
||||
return 0
|
||||
else
|
||||
log WARN "Ralph lock file exists but process dead, cleaning up"
|
||||
rm -f "$RALPH_LOCK_FILE" "$RALPH_PID_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create Ralph configuration
|
||||
create_ralph_config
|
||||
|
||||
# Start Ralph in background
|
||||
log INFO "Starting Ralph Orchestrator..."
|
||||
nohup ralph run \
|
||||
-c "$RALPH_CONFIG" \
|
||||
-p "$prompt" \
|
||||
--max-iterations "$RALPH_MAX_ITERATIONS" \
|
||||
--no-tui \
|
||||
>> "$RALPH_LOG_FILE" 2>&1 &
|
||||
|
||||
local ralph_pid=$!
|
||||
echo "$ralph_pid" > "$RALPH_PID_FILE"
|
||||
echo "$ralph_pid" > "$RALPH_LOCK_FILE"
|
||||
|
||||
log INFO "Ralph started (PID: ${ralph_pid})"
|
||||
log INFO "Config: ${RALPH_CONFIG}"
|
||||
log INFO "Log: ${RALPH_LOG_FILE}"
|
||||
|
||||
# Notify user
|
||||
echo "🤖 Ralph Orchestrator: ACTIVE" >&2
|
||||
echo " PID: ${ralph_pid}" >&2
|
||||
echo " Mode: ${RALPH_MODE}" >&2
|
||||
echo " Monitor: tail -f ${RALPH_LOG_FILE}" >&2
|
||||
}
|
||||
|
||||
create_ralph_config() {
|
||||
# Determine preset to use
|
||||
local preset_config
|
||||
preset_config=$(get_ralph_preset "$RALPH_PRESET")
|
||||
|
||||
cat > "$RALPH_CONFIG" << EOF
|
||||
# Ralph Orchestrator Configuration for Claude Code
|
||||
# Auto-generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
# Mode: ${RALPH_MODE}
|
||||
# Backend: ${RALPH_BACKEND}
|
||||
|
||||
${preset_config}
|
||||
|
||||
# Claude Code Integration Settings
|
||||
cli:
|
||||
backend: "${RALPH_BACKEND}"
|
||||
prompt_mode: "arg"
|
||||
|
||||
# Integration with claude-mem
|
||||
memories:
|
||||
enabled: ${CLAUDE_MEM_ENABLED}
|
||||
inject: auto
|
||||
|
||||
# Integration with ARC Protocol
|
||||
arc_integration:
|
||||
enabled: ${ARC_ENABLED}
|
||||
bridge_path: "${ARC_DIR}/.agent/mcp/arc_mcp_server.py"
|
||||
dashboard_enabled: true
|
||||
|
||||
# Core Behaviors
|
||||
core:
|
||||
scratchpad: "${RALPH_DIR}/scratchpad.md"
|
||||
specs_dir: "./specs/"
|
||||
guardrails:
|
||||
- "Fresh context each iteration - scratchpad and memories are state"
|
||||
- "Don't assume 'not implemented' - search first"
|
||||
- "Backpressure is law - tests/typecheck/lint must pass"
|
||||
- "Use ARC workers for parallel execution when possible"
|
||||
- "Leverage claude-mem for context from previous sessions"
|
||||
EOF
|
||||
|
||||
log INFO "Ralph config created: ${RALPH_CONFIG}"
|
||||
}
|
||||
|
||||
get_ralph_preset() {
|
||||
local preset="$1"
|
||||
|
||||
case "$preset" in
|
||||
"claude-code")
|
||||
# Optimized preset for Claude Code integration
|
||||
cat << 'PRESET_EOF'
|
||||
# Claude Code Preset - Planner-Builder-Verifier Workflow
|
||||
event_loop:
|
||||
completion_promise: "TASK_COMPLETE"
|
||||
max_iterations: 100
|
||||
starting_event: "task.start"
|
||||
|
||||
hats:
|
||||
planner:
|
||||
name: "📋 Planner"
|
||||
description: "Break down tasks into actionable steps, identify dependencies"
|
||||
triggers: ["task.start", "plan.failed"]
|
||||
publishes: ["plan.ready", "task.complete"]
|
||||
instructions: |
|
||||
You are the Planner. Analyze the user's request and:
|
||||
1. Break down the task into clear, actionable steps
|
||||
2. Identify dependencies and parallelizable work
|
||||
3. Consider using ARC workers for parallel execution
|
||||
4. Search claude-mem for relevant context from past sessions
|
||||
5. Create a detailed plan before proceeding
|
||||
|
||||
builder:
|
||||
name: "🔨 Builder"
|
||||
description: "Implement code following the plan and best practices"
|
||||
triggers: ["plan.ready", "build.failed"]
|
||||
publishes: ["build.done", "build.blocked"]
|
||||
instructions: |
|
||||
You are the Builder. Implement the plan:
|
||||
1. Follow the plan created by the Planner
|
||||
2. Write clean, well-documented code
|
||||
3. Use ARC workers for parallel tasks when beneficial
|
||||
4. Run tests, linting, and type checking
|
||||
5. Only publish build.done when all quality gates pass
|
||||
|
||||
verifier:
|
||||
name: "✅ Verifier"
|
||||
description: "Verify implementation meets requirements and quality standards"
|
||||
triggers: ["build.done"]
|
||||
publishes: ["verification.passed", "verification.failed", "task.complete"]
|
||||
instructions: |
|
||||
You are the Verifier. Ensure quality:
|
||||
1. Review the implementation against the plan
|
||||
2. Verify all tests pass
|
||||
3. Check for edge cases and error handling
|
||||
4. Ensure code follows best practices
|
||||
5. Store lessons learned in memories for future sessions
|
||||
PRESET_EOF
|
||||
;;
|
||||
"autonomous")
|
||||
# Fully autonomous mode
|
||||
cat << 'PRESET_EOF'
|
||||
# Autonomous Mode - Single Hat with Full Autonomy
|
||||
event_loop:
|
||||
completion_promise: "TASK_COMPLETE"
|
||||
max_iterations: 150
|
||||
|
||||
core:
|
||||
guardrails:
|
||||
- "You are fully autonomous - plan, execute, and verify independently"
|
||||
- "Use ARC workers for all parallelizable tasks"
|
||||
- "Leverage memories extensively for context"
|
||||
- "Iterate until the task is completely done"
|
||||
PRESET_EOF
|
||||
;;
|
||||
*)
|
||||
# Default/feature preset
|
||||
cat << 'PRESET_EOF'
|
||||
# Default Feature Development Preset
|
||||
event_loop:
|
||||
completion_promise: "TASK_COMPLETE"
|
||||
max_iterations: 100
|
||||
PRESET_EOF
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# ARC PROTOCOL INTEGRATION
|
||||
# ============================================================================
|
||||
|
||||
start_arc() {
|
||||
if [[ "$ARC_ENABLED" != "true" ]]; then
|
||||
log INFO "ARC Protocol disabled"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if ARC is already running
|
||||
if [[ -f "$ARC_LOCK_FILE" ]]; then
|
||||
local lock_pid
|
||||
lock_pid=$(cat "$ARC_LOCK_FILE" 2>/dev/null || echo "")
|
||||
if [[ -n "$lock_pid" ]] && kill -0 "$lock_pid" 2>/dev/null; then
|
||||
log INFO "ARC already running (PID: ${lock_pid})"
|
||||
return 0
|
||||
else
|
||||
log WARN "ARC lock file exists but process dead, cleaning up"
|
||||
rm -f "$ARC_LOCK_FILE" "$ARC_PID_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup ARC directory
|
||||
setup_arc_directory
|
||||
|
||||
# Start ARC dashboard
|
||||
log INFO "Starting ARC Protocol..."
|
||||
cd "$ARC_DIR"
|
||||
|
||||
# Start the ARC dashboard in background
|
||||
nohup python3 ./dash >> "$ARC_LOG_FILE" 2>&1 &
|
||||
local arc_pid=$!
|
||||
echo "$arc_pid" > "$ARC_PID_FILE"
|
||||
echo "$arc_pid" > "$ARC_LOCK_FILE"
|
||||
|
||||
log INFO "ARC started (PID: ${arc_pid})"
|
||||
log INFO "Dashboard: http://localhost:37373"
|
||||
|
||||
echo "🚀 ARC Protocol: ACTIVE" >&2
|
||||
echo " PID: ${arc_pid}" >&2
|
||||
echo " Dashboard: http://localhost:37373" >&2
|
||||
}
|
||||
|
||||
setup_arc_directory() {
|
||||
# Create .arc structure if it doesn't exist
|
||||
mkdir -p "${ARC_DIR}/.arc/"{planning,archive,templates}
|
||||
|
||||
# Initialize ARC state
|
||||
cat > "$ARC_CONFIG" << EOF
|
||||
# ARC Protocol State
|
||||
# Initialized: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
|
||||
**Status:** Active
|
||||
**Mode:** Integrated with Ralph Orchestrator
|
||||
**Workspace:** ${ARC_DIR}
|
||||
|
||||
## Integration
|
||||
|
||||
This ARC instance is managed by Ralph Orchestrator.
|
||||
All worker dispatch and coordination happens through Ralph.
|
||||
|
||||
## Available Commands
|
||||
|
||||
- Check status: cat ${ARC_CONFIG}
|
||||
- View logs: tail -f ${ARC_LOG_FILE}
|
||||
- Stop integration: kill \$(cat ${ARC_LOCK_FILE})
|
||||
EOF
|
||||
|
||||
log INFO "ARC directory initialized: ${ARC_DIR}"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# CLAUDE-MEM INTEGRATION
|
||||
# ============================================================================
|
||||
|
||||
check_claude_mem() {
|
||||
if [[ "$CLAUDE_MEM_ENABLED" != "true" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if claude-mem plugin is installed
|
||||
local mem_plugin="${CLAUDE_DIR}/plugins/cache/thedotmack/claude-mem"
|
||||
|
||||
if [[ -d "$mem_plugin" ]]; then
|
||||
log INFO "claude-mem plugin found"
|
||||
return 0
|
||||
else
|
||||
log WARN "claude-mem not installed"
|
||||
echo "📦 claude-mem: NOT INSTALLED" >&2
|
||||
echo " Install: /plugin marketplace add thedotmack/claude-mem" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# MAIN EXECUTION
|
||||
# ============================================================================
|
||||
|
||||
main() {
|
||||
# Exit if disabled
|
||||
if [[ "$RALPH_MODE" == "off" ]]; then
|
||||
log INFO "Integration disabled (RALPH_MODE=off)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Determine if we should trigger
|
||||
local should_trigger=false
|
||||
|
||||
case "$RALPH_MODE" in
|
||||
"always")
|
||||
should_trigger=true
|
||||
;;
|
||||
"agents")
|
||||
# Detect agent or development keywords
|
||||
if echo "$USER_PROMPT" | grep -qiE "build|create|implement|develop|fix|add|refactor|optimize|write|generate|delegate|autonomous|agent|task|feature|pr"; then
|
||||
should_trigger=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$should_trigger" == true ]]; then
|
||||
# Start components
|
||||
check_claude_mem
|
||||
start_arc
|
||||
start_ralph "$USER_PROMPT"
|
||||
|
||||
log INFO "Integration complete"
|
||||
else
|
||||
log INFO "Skipped (no trigger keywords)"
|
||||
fi
|
||||
|
||||
# Always exit immediately (non-blocking)
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user