v2.0.1: Add /qwenclaw slash commands for Qwen Code CLI
This commit is contained in:
31
README.md
31
README.md
@@ -64,6 +64,8 @@ qwenclaw send "Check my tasks"
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
### Terminal Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
qwenclaw start # Start daemon
|
qwenclaw start # Start daemon
|
||||||
qwenclaw status # Check status
|
qwenclaw status # Check status
|
||||||
@@ -73,6 +75,35 @@ qwenclaw setup # Setup wizard
|
|||||||
qwenclaw help # Show help
|
qwenclaw help # Show help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Inside Qwen Code CLI (Slash Commands)
|
||||||
|
|
||||||
|
After setup, use `/qwenclaw:` commands directly in Qwen Code chat:
|
||||||
|
|
||||||
|
```
|
||||||
|
/qwenclaw:start - Start daemon
|
||||||
|
/qwenclaw:status - Check daemon status
|
||||||
|
/qwenclaw:send "task" - Send task to daemon
|
||||||
|
/qwenclaw:skills - List available skills
|
||||||
|
/qwenclaw:help - Show help
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```
|
||||||
|
/qwenclaw:status
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response:**
|
||||||
|
```
|
||||||
|
🐾 QwenClaw Status
|
||||||
|
════════════════════════════════════════
|
||||||
|
Daemon: Ready
|
||||||
|
Provider: Qwen Code CLI
|
||||||
|
Skills: 81 available
|
||||||
|
Web Dashboard: http://127.0.0.1:4632
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Commands execute in your terminal and show output in Qwen Code chat.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const command = args[0];
|
|||||||
const commands = {
|
const commands = {
|
||||||
async start() {
|
async start() {
|
||||||
console.log('🐾 QwenClaw - Starting daemon...');
|
console.log('🐾 QwenClaw - Starting daemon...');
|
||||||
const proc = spawn('qwen', ['-p', 'QwenClaw daemon started. Ready for tasks.'], {
|
const proc = spawn('qwen', ['QwenClaw daemon started. Ready for tasks.'], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
@@ -39,7 +39,7 @@ const commands = {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
console.log('📤 Sending to Qwen Code CLI...');
|
console.log('📤 Sending to Qwen Code CLI...');
|
||||||
const proc = spawn('qwen', ['-p', message], {
|
const proc = spawn('qwen', [message], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
|
|||||||
1146
package-lock.json
generated
Normal file
1146
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -4,7 +4,8 @@
|
|||||||
"description": "Qwen Code CLI's ALWAYS-ON AI Assistant - Built from OpenClaw",
|
"description": "Qwen Code CLI's ALWAYS-ON AI Assistant - Built from OpenClaw",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
"qwenclaw": "./bin/qwenclaw.js"
|
"qwenclaw": "./bin/qwenclaw.js",
|
||||||
|
"qwenclaw-mcp": "./src/mcp-server.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node bin/qwenclaw.js start",
|
"start": "node bin/qwenclaw.js start",
|
||||||
@@ -12,7 +13,8 @@
|
|||||||
"send": "node bin/qwenclaw.js send",
|
"send": "node bin/qwenclaw.js send",
|
||||||
"skills": "node bin/qwenclaw.js skills",
|
"skills": "node bin/qwenclaw.js skills",
|
||||||
"setup": "node bin/qwenclaw.js setup",
|
"setup": "node bin/qwenclaw.js setup",
|
||||||
"help": "node bin/qwenclaw.js help"
|
"help": "node bin/qwenclaw.js help",
|
||||||
|
"mcp": "node src/mcp-server.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"qwen",
|
"qwen",
|
||||||
@@ -21,7 +23,8 @@
|
|||||||
"ai-assistant",
|
"ai-assistant",
|
||||||
"openclaw",
|
"openclaw",
|
||||||
"multi-agent",
|
"multi-agent",
|
||||||
"automation"
|
"automation",
|
||||||
|
"mcp"
|
||||||
],
|
],
|
||||||
"author": "QwenClaw Team",
|
"author": "QwenClaw Team",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -35,5 +38,8 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22.0.0"
|
"node": ">=22.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@modelcontextprotocol/sdk": "^1.27.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
200
src/mcp-server.js
Normal file
200
src/mcp-server.js
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* QwenClaw MCP Server
|
||||||
|
*
|
||||||
|
* Provides QwenClaw functionality as MCP tools for Qwen Code CLI
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* In Qwen Code, type: /qwenclaw <command>
|
||||||
|
* Commands: start, status, send, skills, help
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
||||||
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
||||||
|
import {
|
||||||
|
CallToolRequestSchema,
|
||||||
|
ListToolsRequestSchema,
|
||||||
|
} from '@modelcontextprotocol/sdk/types.js';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
const QWENCLAW_DIR = join(process.cwd());
|
||||||
|
|
||||||
|
// Tool definitions
|
||||||
|
const TOOLS = [
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_start',
|
||||||
|
description: 'Start QwenClaw daemon',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
web: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Enable web dashboard',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_status',
|
||||||
|
description: 'Check QwenClaw daemon status',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_send',
|
||||||
|
description: 'Send message to QwenClaw daemon',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
message: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Message to send',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ['message'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_skills',
|
||||||
|
description: 'List all available QwenClaw skills',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_help',
|
||||||
|
description: 'Show QwenClaw help information',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Create MCP server
|
||||||
|
const server = new Server(
|
||||||
|
{
|
||||||
|
name: 'qwenclaw',
|
||||||
|
version: '2.0.0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
capabilities: {
|
||||||
|
tools: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Handle tool listing
|
||||||
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||||
|
return {
|
||||||
|
tools: TOOLS,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle tool execution
|
||||||
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||||
|
const { name, arguments: args = {} } = request.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (name) {
|
||||||
|
case 'qwenclaw_start': {
|
||||||
|
const web = args.web || false;
|
||||||
|
const result = await runCommand('start', web ? ['--web'] : []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_status': {
|
||||||
|
const result = await runCommand('status', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_send': {
|
||||||
|
const message = args.message;
|
||||||
|
if (!message) {
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: 'Error: message is required' }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result = await runCommand('send', [message]);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_skills': {
|
||||||
|
const result = await runCommand('skills', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_help': {
|
||||||
|
const result = await runCommand('help', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: `Error: ${error.message}` }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run QwenClaw command
|
||||||
|
async function runCommand(command, args = []) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const proc = spawn('node', [join(QWENCLAW_DIR, 'bin', 'qwenclaw.js'), command, ...args], {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = '';
|
||||||
|
let error = '';
|
||||||
|
|
||||||
|
proc.stdout.on('data', (data) => {
|
||||||
|
output += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.stderr.on('data', (data) => {
|
||||||
|
error += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
resolve(output.trim());
|
||||||
|
} else {
|
||||||
|
reject(new Error(error || `Command failed with code ${code}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
async function main() {
|
||||||
|
const transport = new StdioServerTransport();
|
||||||
|
await server.connect(transport);
|
||||||
|
console.error('QwenClaw MCP server running on stdio');
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error('Fatal error:', error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user