Replace placeholder files with originals from system

Found and copied original files from ~/.claude installation:

- hooks/ - Original Qwen and Ralph hook scripts with full functionality
- commands/ - Original command definitions (brainstorm, write-plan, execute-plan)
- bin/ralphloop - Original 223-line Python wrapper (6,290 bytes)
- scripts/sync-agents.sh - Original sync script with GitHub/Gitea backup
- templates/ - Original config templates from working installation
- plugins/ - Original comprehensive plugin README

Files sourced from:
- ~/.claude/skills/skills/hooks/
- ~/.claude/skills/skills/commands/
- ~/.claude/skills/skills/templates/
- /home/uroma/obsidian-web-interface/bin/ralphloop
- ~/.claude/agents/sync-agents.sh

These are the production files from the working Claude Code
installation, replacing the placeholder files I created earlier.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-23 18:23:28 +00:00
Unverified
parent 62bec9d554
commit 932529d37f
21 changed files with 1439 additions and 898 deletions

88
hooks/QWEN-HOOK-README.md Normal file
View File

@@ -0,0 +1,88 @@
# Qwen Consultation Hook for Claude Code
Allows Claude Code to consult with the local Qwen installation (`/usr/local/bin/qwen`) for assistance with tasks.
## Files Created
- `/home/uroma/.claude/hooks/qwen-consult.sh` - Main hook script
- `/home/uroma/.claude/hooks/hooks.json` - Updated with Qwen hook
- `/home/uroma/.claude/hooks.json` - Updated with Qwen hook
## Configuration
The hook behavior is controlled via environment variables:
| Variable | Default | Description |
|----------|---------|-------------|
| `QWEN_CONSULT_MODE` | `off` | When to consult Qwen: `off`, `delegate`, or `always` |
| `QWEN_MODEL` | (default) | Optional: specify Qwen model to use |
| `QWEN_MAX_ITERATIONS` | `30` | Max iterations for Qwen execution |
## Usage Modes
### 1. Off Mode (Default)
```bash
export QWEN_CONSULT_MODE=off
```
Qwen is never consulted. Hook is disabled.
### 2. Delegate Mode
```bash
export QWEN_CONSULT_MODE=delegate
```
Qwen is consulted when you use keywords like:
- "consult qwen"
- "ask qwen"
- "delegate to qwen"
- "get a second opinion"
- "alternative approach"
### 3. Always Mode
```bash
export QWEN_CONSULT_MODE=always
```
Qwen is consulted for every request.
## Examples
### Enable delegate mode in current session
```bash
export QWEN_CONSULT_MODE=delegate
```
### Use with a specific model
```bash
export QWEN_CONSULT_MODE=delegate
export QWEN_MODEL=qwen2.5-coder-32b-instruct
```
### Make permanent (add to ~/.bashrc)
```bash
echo 'export QWEN_CONSULT_MODE=delegate' >> ~/.bashrc
```
## Monitoring Qwen
When Qwen is triggered, it runs in the background. You can monitor it:
```bash
# View Qwen output in real-time
tail -f ~/.claude/qwen-output.log
# Check if Qwen is running
ps aux | grep qwen
# Stop Qwen manually
kill $(cat ~/.claude/qwen.lock)
```
## Hook Event
This hook triggers on `UserPromptSubmit` - every time you submit a prompt to Claude Code.
## State Files
- `~/.claude/qwen-consult.md` - Current consultation state
- `~/.claude/qwen-output.log` - Qwen execution output
- `~/.claude/qwen.lock` - PID file for running Qwen process
- `~/.claude/qwen-consult.log` - Consultation trigger log

View File

@@ -1,14 +1,21 @@
#!/bin/bash
# Qwen Consultation Wrapper Hook
# Trigger: user-prompt
# Wrapper for Qwen consultation functionality
# Simple Qwen Consultation Script
# Usage: consult-qwen.sh "your question here"
# This hook integrates with the brainstorming skill
# to provide multi-AI consultation capabilities
set -euo pipefail
QWEN_MAX_ITERATIONS="${QWEN_MAX_ITERATIONS:-3}"
QUESTION="${1:-}"
# Delegate to the brainstorming skill when appropriate
# The actual consultation logic is in the skill
if [[ -z "$QUESTION" ]]; then
echo "Usage: $0 \"your question\""
exit 1
fi
exit 0
echo "=== Consulting Qwen ==="
echo "Question: $QUESTION"
echo ""
echo "Qwen's Response:"
echo "---"
# Run Qwen with the question
echo "$QUESTION" | timeout 30 qwen -p - 2>&1

View File

@@ -1,11 +1,72 @@
#!/bin/bash
# Demo Qwen Integration Hook
# Trigger: user-prompt
# Demonstrates Qwen AI consultation capabilities
# Demo script showing how to use Qwen consultation hook
# This is a demo hook showing how to integrate
# Qwen AI for consultation and multi-AI brainstorming
set -euo pipefail
# The actual implementation is in the multi-ai-brainstorm skill
echo "====================================="
echo " Qwen Consultation Hook Demo"
echo "====================================="
echo ""
exit 0
# Step 1: Show current mode
echo "1. Current QWEN_CONSULT_MODE: ${QWEN_CONSULT_MODE:-off (default)}"
echo ""
# Step 2: Enable delegate mode
echo "2. Enabling delegate mode..."
export QWEN_CONSULT_MODE=delegate
echo " QWEN_CONSULT_MODE is now: $QWEN_CONSULT_MODE"
echo ""
# Step 3: Trigger consultation with delegate keyword
echo "3. Triggering Qwen consultation..."
echo " Prompt: 'please consult qwen for advice on bash scripting best practices'"
echo ""
# Clear previous log
> ~/.claude/qwen-output.log
# Trigger the hook
echo '{"prompt": "please consult qwen for advice on bash scripting best practices"}' | \
/home/uroma/.claude/hooks/qwen-consult.sh 2>&1
# Wait a moment for Qwen to start
sleep 2
# Step 4: Show Qwen is running
echo "4. Checking if Qwen is running..."
if [[ -f ~/.claude/qwen.lock ]]; then
PID=$(cat ~/.claude/qwen.lock)
if kill -0 "$PID" 2>/dev/null; then
echo " ✓ Qwen is running (PID: $PID)"
else
echo " ✗ Qwen process not found"
fi
else
echo " ✗ Qwen lock file not found"
fi
echo ""
# Step 5: Wait for output and show it
echo "5. Waiting for Qwen's response (10 seconds)..."
sleep 10
echo ""
echo "====================================="
echo " Qwen's Response:"
echo "====================================="
tail -n +4 ~/.claude/qwen-output.log
echo ""
echo "====================================="
echo " Monitoring Commands:"
echo "====================================="
echo "View output in real-time:"
echo " tail -f ~/.claude/qwen-output.log"
echo ""
echo "Check if Qwen is running:"
echo " ps aux | grep qwen"
echo ""
echo "Stop Qwen:"
echo " kill \$(cat ~/.claude/qwen.lock)"
echo ""

View File

@@ -1,22 +1,163 @@
#!/bin/bash
# Qwen AI Consultation Hook
# Trigger: user-prompt
# Consults Qwen AI for additional perspectives
# Qwen Consult Hook - Integration with Qwen Code CLI
# Allows Claude Code to consult with local Qwen installation for tasks
#
# Modes (via QWEN_CONSULT_MODE environment variable):
# "always" - Consult Qwen for every request
# "delegate" - Only when explicitly asked to delegate/consult
# "off" - Disable Qwen consultation (default)
#
# Usage:
# Set QWEN_CONSULT_MODE environment variable to control behavior
# The hook runs Qwen in non-blocking mode and logs output
QWEN_MODE="${QWEN_CONSULT_MODE:-delegate}"
QWEN_MODEL="${QWEN_MODEL:-qwen-coder-plus}"
set -euo pipefail
# Only run in delegate or always mode
if [ "$QWEN_MODE" != "delegate" ] && [ "$QWEN_MODE" != "always" ]; then
# Configuration
CLAUDE_DIR="$HOME/.claude"
QWEN_STATE_FILE="$CLAUDE_DIR/qwen-consult.md"
QWEN_OUTPUT_LOG="$CLAUDE_DIR/qwen-output.log"
QWEN_LOCK_FILE="$CLAUDE_DIR/qwen.lock"
# 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
# Get Qwen mode (default: off - requires explicit opt-in)
QWEN_CONSULT_MODE="${QWEN_CONSULT_MODE:-off}"
QWEN_MODEL="${QWEN_MODEL:-}"
QWEN_MAX_ITERATIONS="${QWEN_MAX_ITERATIONS:-30}"
# Exit if consultation is disabled
if [[ "$QWEN_CONSULT_MODE" == "off" ]]; then
exit 0
fi
# Check if qwen CLI is available
if ! command -v qwen &> /dev/null; then
exit 0
# Check if Qwen is already running
if [[ -f "$QWEN_LOCK_FILE" ]]; then
LOCK_PID=$(cat "$QWEN_LOCK_FILE" 2>/dev/null || echo "")
if [[ -n "$LOCK_PID" ]] && kill -0 "$LOCK_PID" 2>/dev/null; then
exit 0
else
rm -f "$QWEN_LOCK_FILE"
fi
fi
# Run consultation (would be called by the skill, not here directly)
# This is a placeholder for the hook mechanism
# Keywords that trigger Qwen consultation (in delegate mode)
DELEGATE_KEYWORDS="consult|qwen|delegate|second opinion|alternative|get.*advice|ask.*qwen"
# Determine if we should consult Qwen
should_consult=false
case "$QWEN_CONSULT_MODE" in
"always")
should_consult=true
;;
"delegate")
if echo "$USER_PROMPT" | grep -iqE "$DELEGATE_KEYWORDS"; then
should_consult=true
fi
;;
esac
if [[ "$should_consult" == true ]]; then
# Create state directory
mkdir -p "$CLAUDE_DIR"
# Build Qwen command arguments
QWEN_ARGS=()
if [[ -n "$QWEN_MODEL" ]]; then
QWEN_ARGS+=(-m "$QWEN_MODEL")
fi
# Prepare prompt for Qwen with context
QWEN_PROMPT="You are Qwen, consulted by Claude Code for assistance. The user asks: $USER_PROMPT
Please provide your analysis, suggestions, or solution. Be concise and actionable."
# Create state file
cat > "$QWEN_STATE_FILE" << EOF
# Qwen Consult State
# Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
**User Request:**
$USER_PROMPT
**Mode:** $QWEN_CONSULT_MODE
**Model:** ${QWEN_MODEL:-default}
**Timestamp:** $(date -Iseconds)
## Context
This state file was generated by the Qwen consultation hook. Qwen Code CLI
is being consulted to provide additional insights on this request.
## Configuration
- Hook: UserPromptSubmit
- Trigger mode: $QWEN_CONSULT_MODE
- Log file: $QWEN_OUTPUT_LOG
## Usage
Qwen is running autonomously in the background. Monitor progress:
\`\`\`bash
# View Qwen output in real-time
tail -f ~/.claude/qwen-output.log
# Check if Qwen is still running
ps aux | grep qwen
# Stop Qwen manually
kill \$(cat ~/.claude/qwen.lock)
\`\`\`
EOF
# Check if Qwen is available
if command -v qwen &> /dev/null; then
# Create log file
touch "$QWEN_OUTPUT_LOG"
# Start Qwen in background
{
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] Qwen consultation started"
echo "Mode: $QWEN_CONSULT_MODE"
echo "Model: ${QWEN_MODEL:-default}"
echo "---"
} >> "$QWEN_OUTPUT_LOG"
# Run Qwen in background
if [[ ${#QWEN_ARGS[@]} -gt 0 ]]; then
nohup qwen "${QWEN_ARGS[@]}" -p "$QWEN_PROMPT" >> "$QWEN_OUTPUT_LOG" 2>&1 &
else
nohup qwen -p "$QWEN_PROMPT" >> "$QWEN_OUTPUT_LOG" 2>&1 &
fi
QWEN_PID=$!
echo "$QWEN_PID" > "$QWEN_LOCK_FILE"
# Log the consultation
{
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] Qwen consultation triggered"
echo " Mode: $QWEN_CONSULT_MODE"
echo " Model: ${QWEN_MODEL:-default}"
echo " PID: $QWEN_PID"
echo " Log: $QWEN_OUTPUT_LOG"
} >> "$CLAUDE_DIR/qwen-consult.log" 2>/dev/null || true
# Notify user
echo "🤖 Qwen consultation started (PID: $QWEN_PID)" >&2
echo " Monitor: tail -f ~/.claude/qwen-output.log" >&2
else
echo "⚠️ Qwen CLI not found at /usr/local/bin/qwen" >&2
fi
fi
# Exit immediately (non-blocking)
exit 0

View File

@@ -1,17 +1,193 @@
#!/bin/bash
# Ralph Auto-Trigger Hook
# Trigger: user-prompt
# Automatically triggers Ralph for complex tasks
# Ralph Auto-Trigger Hook - Enhanced with Background Task Spawning
# Automatically starts Ralph CLI in background when needed
#
# Modes (via RALPH_AUTO_MODE environment variable):
# "always" - Start Ralph for every request
# "agents" - Only for agent requests (default)
# "off" - Disable auto-trigger
#
# Background Execution:
# - Ralph runs as background process (non-blocking)
# - Claude Code continues immediately
# - Ralph output logged to: ~/.claude/ralph-output.log
# - Ralph PID tracked in: ~/.claude/ralph.pid
# Analyze task complexity and auto-trigger Ralph
# when RALPH_AUTO=true or task appears complex
set -euo pipefail
RALPH_AUTO="${RALPH_AUTO:-false}"
# Configuration
CLAUDE_DIR="$HOME/.claude"
RALPH_STATE_FILE="$CLAUDE_DIR/ralph-loop.local.md"
RALPH_PID_FILE="$CLAUDE_DIR/ralph.pid"
RALPH_LOG_FILE="$CLAUDE_DIR/ralph-output.log"
RALPH_LOCK_FILE="$CLAUDE_DIR/ralph.lock"
if [ "$RALPH_AUTO" = "true" ]; then
# Auto-delegate to Ralph for complex tasks
# The actual delegation logic is in the ralph skill
:
# 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
# Get Ralph mode (default: agents)
RALPH_AUTO_MODE="${RALPH_AUTO_MODE:-agents}"
RALPH_MAX_ITERATIONS="${RALPH_MAX_ITERATIONS:-50}"
# Exit if auto-trigger is disabled
if [[ "$RALPH_AUTO_MODE" == "off" ]]; then
exit 0
fi
# Check if Ralph is already running (via lock file)
if [[ -f "$RALPH_LOCK_FILE" ]]; then
# Check if process is still alive
LOCK_PID=$(cat "$RALPH_LOCK_FILE" 2>/dev/null || echo "")
if [[ -n "$LOCKPD" ]] && kill -0 "$LOCK_PID" 2>/dev/null; then
# Ralph is already running, don't start another instance
exit 0
else
# Lock file exists but process is dead, clean up
rm -f "$RALPH_LOCK_FILE" "$RALPH_PID_FILE"
fi
fi
# Agent detection list (lowercase for matching)
AGENTS=(
"ai-engineer" "backend-architect" "devops-automator" "frontend-developer"
"mobile-app-builder" "rapid-prototyper" "test-writer-fixer"
"tiktok-strategist" "growth-hacker" "content-creator" "instagram-curator"
"reddit-builder" "twitter-engager" "app-store-optimizer"
"brand-guardian" "ui-designer" "ux-researcher" "visual-storyteller"
"whimsy-injector" "ui-ux-pro-max"
"feedback-synthesizer" "sprint-prioritizer" "trend-researcher"
"experiment-tracker" "project-shipper" "studio-producer" "studio-coach"
"analytics-reporter" "finance-tracker" "infrastructure-maintainer"
"legal-compliance-checker" "support-responder"
"api-tester" "performance-benchmarker" "test-results-analyzer"
"tool-evaluator" "workflow-optimizer"
"joker" "agent-updater"
"explore" "plan" "general-purpose"
)
# Detect agent request (case-insensitive)
agent_detected=false
detected_agent=""
for agent in "${AGENTS[@]}"; do
if echo "$USER_PROMPT" | grep -iq "$agent"; then
agent_detected=true
detected_agent="$agent"
break
fi
done
# Determine if we should start Ralph
should_trigger=false
case "$RALPH_AUTO_MODE" in
"always")
# Trigger on all prompts
should_trigger=true
;;
"agents")
# Only trigger on agent requests OR development keywords
if [[ "$agent_detected" == true ]]; then
should_trigger=true
elif echo "$USER_PROMPT" | grep -qiE "build|create|implement|develop|fix|add|refactor|optimize|write|generate|delegate|autonomous"; then
should_trigger=true
detected_agent="general-development"
fi
;;
esac
if [[ "$should_trigger" == true ]]; then
# Create Ralph state file
mkdir -p "$CLAUDE_DIR"
cat > "$RALPH_STATE_FILE" << EOF
# Ralph Loop State - Auto-Triggered
# Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
**User Request:**
$USER_PROMPT
**Detected Agent:** $detected_agent
**Mode:** $RALPH_AUTO_MODE
**Max Iterations:** $RALPH_MAX_ITERATIONS
**Timestamp:** $(date -Iseconds)
## Context
This state file was automatically generated by the Ralph auto-trigger hook.
Ralph CLI will read this file and autonomously execute the request.
## Auto-Trigger Details
- Triggered by: Claude Code UserPromptSubmit hook
- Trigger mode: $RALPH_AUTO_MODE
- Background execution: Yes (non-blocking)
- Log file: $RALPH_LOG_FILE
## Usage
Ralph is running autonomously in the background. Monitor progress:
\`\`\`bash
# View Ralph output in real-time
tail -f ~/.claude/ralph-output.log
# Check if Ralph is still running
ps aux | grep ralph
# Stop Ralph manually
kill \$(cat ~/.claude/ralph.pid)
rm ~/.claude/ralph.lock
\`\`\`
EOF
# Spawn Ralph in background (NON-BLOCKING)
if command -v ralph &> /dev/null; then
# Create log file
touch "$RALPH_LOG_FILE"
# Start Ralph in background with nohup (survives terminal close)
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] Starting Ralph in background..." >> "$RALPH_LOG_FILE"
echo "Mode: $RALPH_AUTO_MODE" >> "$RALPH_LOG_FILE"
echo "Agent: $detected_agent" >> "$RALPH_LOG_FILE"
echo "Max iterations: $RALPH_MAX_ITERATIONS" >> "$RALPH_LOG_FILE"
echo "---" >> "$RALPH_LOG_FILE"
# Start Ralph in background
nohup ralph build "$RALPH_MAX_ITERATIONS" >> "$RALPH_LOG_FILE" 2>&1 &
RALPH_PID=$!
# Save PID for tracking
echo "$RALPH_PID" > "$RALPH_PID_FILE"
echo "$RALPH_PID" > "$RALPH_LOCK_FILE"
# Log the trigger
{
echo "[$(date -u +"%Y-%m-%d %H:%M:%S UTC")] Ralph auto-triggered"
echo " Mode: $RALPH_AUTO_MODE"
echo " Agent: $detected_agent"
echo " PID: $RALPH_PID"
echo " Log: $RALPH_LOG_FILE"
} >> "$CLAUDE_DIR/ralph-trigger.log" 2>/dev/null || true
# Notify user via stderr (visible in Claude Code)
echo "🔄 Ralph CLI auto-started in background" >&2
echo " PID: $RALPH_PID" >&2
echo " Agent: $detected_agent" >&2
echo " Monitor: tail -f ~/.claude/ralph-output.log" >&2
echo " Stop: kill \$(cat ~/.claude/ralph.pid)" >&2
else
# Ralph not installed, just create state file
echo "⚠️ Ralph CLI not installed. State file created for manual use." >&2
echo " Install: npm install -g @iannuttall/ralph" >&2
fi
fi
# Exit immediately (NON-BLOCKING - Claude Code continues)
exit 0

View File

@@ -1,14 +1,15 @@
#!/bin/bash
# Session Start Hook - Auto-inject superpowers context
# This hook runs on every session start/resume
# Trigger: session-start
#!/usr/bin/env bash
set -euo pipefail
# Check if AUTO_SUPERPOWERS is enabled
if [ "${AUTO_SUPERPOWERS:-false}" = "true" ]; then
# Inject superpowers context into the session
if [ -f "$HOME/.claude/skills/using-superpowers/skill.md" ]; then
cat "$HOME/.claude/skills/using-superpowers/skill.md"
fi
fi
# Read skill files and inject into session context
auto_superpowers_content=$(cat "${HOME}/.claude/skills/auto-superpowers/SKILL.md" 2>/dev/null || echo "Skill not found")
using_superpowers_content=$(cat "${HOME}/.claude/skills/using-superpowers/SKILL.md" 2>/dev/null || echo "Skill not found")
exit 0
# Output JSON with skills injected
cat <<EOF
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": "\n**AUTO-SUPERPOWERS IS ACTIVE**\n\n${auto_superpowers_content}\n\n**USING-SUPERPOWERS INSTRUCTION:**\n\n${using_superpowers_content}\n\n"
}
}