# 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
