Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d57a2e1
feat: Implement comprehensive hook system with Claude Code compatibility
vladislavdonchev Nov 8, 2025
d444708
Implement Claude-compatible timestamps for todoWrite tool and enhance…
vladislavdonchev Nov 9, 2025
51de0eb
Add Claude-compatible timestamp fields to todoWrite tool and enhance …
vladislavdonchev Nov 9, 2025
211772a
feat: Update documentation for hook compatibility and create general …
vladislavdonchev Nov 9, 2025
0b2d730
Fix TypeScript errors and improve code quality across multiple modules
vladislavdonchev Nov 10, 2025
17d071f
fix: ts errors
vladislavdonchev Nov 10, 2025
3793def
Merge remote-tracking branch 'origin' into feat/hooks
vladislavdonchev Nov 10, 2025
572f05b
Fix linting errors in HookManager files and clean up test files
vladislavdonchev Nov 13, 2025
0d32430
fix: resolve build errors and update hook documentation
vladislavdonchev Nov 13, 2025
38fbdd8
fix: implement missing functionality from unused parameters
vladislavdonchev Nov 13, 2025
a4a793d
feat: Implement comprehensive hook system with tests
vladislavdonchev Nov 15, 2025
fd50c10
feat: add --append-system-prompt option for system prompt customization
vladislavdonchev Nov 16, 2025
d5267f7
feat: Add Claude-compatible stream-json output format
vladislavdonchev Nov 16, 2025
77d49e3
Merge branch 'main-qwen' into feat/hooks
vladislavdonchev Nov 16, 2025
8993666
Add documentation for missing features and remove incorrect --system-…
vladislavdonchev Nov 16, 2025
1099a40
chore: added missing docs
vladislavdonchev Nov 16, 2025
cc26738
feat: option to remove registered aliases
vladislavdonchev Nov 18, 2025
6f9012e
Merge remote-tracking branch 'independent-ai-labs/main-qwen' into fea…
vladislavdonchev Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ gha-creds-*.json

# Log files
patch_output.log

# Map files (build artifacts)
*.map
*.js.map

# Qwen documentation
QWEN.md
scripts/log/
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ For detailed setup instructions, see [Authorization](#authorization).

- **Code Understanding & Editing** - Query and edit large codebases beyond traditional context window limits
- **Workflow Automation** - Automate operational tasks like handling pull requests and complex rebases
- **Extensible Hook System** - Execute custom scripts at key points in the application lifecycle (compatible with Claude Code hooks) for advanced automation, monitoring, and security checks
- **Enhanced Parser** - Adapted parser specifically optimized for Qwen-Coder models
- **Vision Model Support** - Automatically detect images in your input and seamlessly switch to vision-capable models for multimodal analysis

Expand Down Expand Up @@ -174,6 +175,56 @@ To completely disable vision model support, add to your `.qwen/settings.json`:

> πŸ’‘ **Tip**: In YOLO mode (`--yolo`), vision switching happens automatically without prompts when images are detected.

### Advanced Features

#### Claude Compatibility Mode

Qwen Code includes a Claude-compatible adapter that allows you to use Claude-style commands and arguments:

```bash
# Install the Claude-compatible alias
npm run create-alias # Select option 2 for qwen-alt

# Use Claude-style commands
qwen-alt --append-system-prompt "Focus on security and performance" "Optimize this code"

# Claude-compatible streaming output
qwen-alt -p "Explain this function" --output-format stream-json
```

The `qwen-alt` alias supports most Claude Code CLI arguments and workflows.

#### System Prompt Customization

You can append custom instructions to the default system prompt to guide the AI behavior:

```bash
# Append a system instruction to guide the AI
qwen --append-system-prompt "Always respond with detailed explanations" "Explain this codebase"

# Use with print mode for headless operations
qwen -p "Analyze this file" --append-system-prompt "Focus on potential bugs and security issues"
```

#### Streaming JSON Output

For programmatic use cases, Qwen Code supports streaming JSON output compatible with Claude's format:

```bash
# Stream output as newline-delimited JSON objects
qwen -p "Generate code" --output-format stream-json

# Process streaming output with jq
qwen -p "List items" --output-format stream-json | jq -c 'select(.type == "content_block_delta") | .text'

# Use for automation and integration
qwen -p "Write documentation" --output-format stream-json | while read line; do
echo "Processing: $line"
done
```

The `stream-json` format outputs events like `content_block_delta`, `message_start`, `message_stop`, and `tool_call` as they occur, enabling real-time processing of responses.

### Authorization

Choose your preferred authentication method based on your needs:
Expand Down Expand Up @@ -318,6 +369,42 @@ qwen
> Find and remove all console.log statements
```

### πŸͺ Hook System for Advanced Automation

For more advanced automation, Qwen Code features a powerful hook system that allows you to execute custom scripts at key lifecycle events:

- **Security checks**: Run validation scripts before file operations
- **Monitoring**: Track and log all tool usage
- **Automation**: Trigger external tools or CI/CD processes
- **Claude compatibility**: Use existing Claude Code hooks seamlessly

Configure hooks in your `.qwen/settings.json`:

```json
{
"hooks": {
"enabled": true,
"timeoutMs": 10000,
"hooks": [
{
"type": "tool.before",
"scriptPath": "./hooks/security-check.js",
"enabled": true,
"priority": 10
}
],
"claudeHooks": [
{
"event": "PreToolUse",
"matcher": ["Write", "Edit"],
"command": "./hooks/security.js",
"timeout": 30
}
]
}
}
```

### πŸ› Debugging & Analysis

```bash
Expand Down
42 changes: 42 additions & 0 deletions config/claude-adapter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"argumentMappings": {
"--print": ["-p"],
"--allowed-tools": ["--allowed-tools"],
"--permission-mode": ["--approval-mode"],
"--model": ["-m"],
"--session-id": ["--session-id"],
"--settings": ["--settings"],
"--allowedTools": ["--allowed-tools"],
"--disallowedTools": ["--exclude-tools"],
"--include-partial-messages": ["--all-files"],
"--debug": ["--debug"],
"--verbose": ["--debug"],
"--yolo": ["--approval-mode", "yolo"],
"--allow-dangerously-skip-permissions": ["--dangerously-skip-permissions"],
"--dangerously-skip-permissions": ["--dangerously-skip-permissions"],
"--include-directories": ["--include-directories"],
"--continue": ["--continue"],
"--resume": ["--resume"],
"--output-format": ["--output-format"],
"--input-format": ["--input-format"],
"--mcp-config": ["--mcp-config"],
"--append-system-prompt": ["--append-system-prompt"],
"--replay-user-messages": ["--replay-user-messages"],
"--fork-session": ["--fork-session"],
"--fallback-model": ["--fallback-model"],
"--add-dir": ["--add-dir"]
},
"toolNameMappings": {
"Write": "write_file",
"Edit": "replace",
"Bash": "run_shell_command",
"Read": "read_file",
"Grep": "grep",
"Glob": "glob",
"Ls": "ls",
"WebSearch": "web_search",
"WebFetch": "web_fetch",
"TodoWrite": "todo_write",
"NotebookEdit": "edit_notebook"
}
}
15 changes: 15 additions & 0 deletions config/hook-event-mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hookEventMappings": {
"PreToolUse": "tool.before",
"PostToolUse": "tool.after",
"Stop": "session.end",
"SubagentStop": "session.end",
"Notification": "session.notification",
"UserPromptSubmit": "input.received",
"PreCompact": "before.compact",
"SessionStart": "session.start",
"SessionEnd": "session.end",
"AppStartup": "app.startup",
"AppShutdown": "app.shutdown"
}
}
86 changes: 86 additions & 0 deletions config/tool-input-format-mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"toolInputFormatMappings": {
"Write": {
"claudeFieldMapping": {
"file_path": "file_path",
"content": "content"
},
"requiredFields": ["file_path", "content"],
"claudeFormat": {
"file_path": "string",
"content": "string"
}
},
"Edit": {
"claudeFieldMapping": {
"file_path": "file_path",
"old_string": "old_string",
"new_string": "new_string"
},
"requiredFields": ["file_path", "old_string", "new_string"],
"claudeFormat": {
"file_path": "string",
"old_string": "string",
"new_string": "string"
}
},
"Bash": {
"claudeFieldMapping": {
"command": "command",
"description": "description"
},
"requiredFields": ["command"],
"claudeFormat": {
"command": "string",
"description": "string"
}
},
"TodoWrite": {
"claudeFieldMapping": {
"todos": "todos"
},
"requiredFields": ["todos"],
"claudeFormat": {
"todos": "array"
}
},
"Read": {
"claudeFieldMapping": {
"file_path": "file_path"
},
"requiredFields": ["file_path"],
"claudeFormat": {
"file_path": "string"
}
},
"Grep": {
"claudeFieldMapping": {
"pattern": "pattern",
"path": "path"
},
"requiredFields": ["pattern"],
"claudeFormat": {
"pattern": "string",
"path": "string"
}
},
"Glob": {
"claudeFieldMapping": {
"pattern": "pattern"
},
"requiredFields": ["pattern"],
"claudeFormat": {
"pattern": "string"
}
},
"Ls": {
"claudeFieldMapping": {
"path": "path"
},
"requiredFields": ["path"],
"claudeFormat": {
"path": "string"
}
}
}
}
13 changes: 13 additions & 0 deletions config/tool-name-mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Write": "write_file",
"Edit": "replace",
"Bash": "run_shell_command",
"TodoWrite": "todo_write",
"NotebookEdit": "edit_notebook",
"Read": "read_file",
"Grep": "grep",
"Glob": "glob",
"Ls": "ls",
"WebSearch": "web_search",
"WebFetch": "web_fetch"
}
Loading