@putao520/aiw 0.5.32 → 0.5.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +165 -257
  2. package/index.js +23 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,352 +1,260 @@
1
- # AIW - AI Workflow Orchestration Tool
1
+ # AIW - AI CLI & MCP Unified Gateway
2
2
 
3
3
  <div align="center">
4
4
 
5
- ![Version](https://img.shields.io/badge/version-0.5.26-blue?style=flat-square)
5
+ ![Version](https://img.shields.io/badge/version-0.5.35-blue?style=flat-square)
6
6
  ![Rust](https://img.shields.io/badge/Rust-1.70+-orange?style=flat-square&logo=rust)
7
7
  ![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)
8
8
  ![MCP](https://img.shields.io/badge/MCP-Supported-purple?style=flat-square)
9
9
 
10
- **Universal AI CLI Management Platform with Intelligent MCP Routing & Transparent Parameter Forwarding**
10
+ **Unified Router & Proxy for AI CLI Tools and MCP Servers**
11
11
 
12
12
  </div>
13
13
 
14
- AIW is an intelligent platform for managing AI CLI tools (Claude, Codex, Gemini) with MCP routing, process tracking, provider management, and transparent parameter forwarding.
14
+ ## What is AIW?
15
15
 
16
- ## 🎯 Core Features
16
+ AIW is a **unified gateway** that acts as:
17
17
 
18
- ### 1. AI CLI Management
19
- - **Process Tree Tracking**: Monitor AI CLI processes and their children
20
- - **Provider Management**: Switch between AI providers (OpenAI, Anthropic, Google, etc.)
21
- - **Transparent Parameter Forwarding**: Seamlessly pass all CLI parameters while using provider management
22
- - **Capability Detection**: Auto-detect installed AI CLI tools
23
- - **Wait Mode**: Block until AI CLI tasks complete
18
+ | Layer | Role | What it does |
19
+ |-------|------|--------------|
20
+ | **AI CLI Proxy** | Router + Proxy | Route requests to claude/codex/gemini with provider switching, role injection, and transparent parameter forwarding |
21
+ | **MCP Proxy** | Router + Proxy | Route tool calls to multiple MCP servers with intelligent selection, plugin marketplace, and hot-reload |
22
+
23
+ ```
24
+ ┌─────────────────────────────────────────────────────────────┐
25
+ │ AIW Gateway │
26
+ ├─────────────────────────────────────────────────────────────┤
27
+ │ │
28
+ │ ┌─────────────────────┐ ┌─────────────────────────────┐ │
29
+ │ │ AI CLI Router │ │ MCP Router │ │
30
+ │ │ │ │ │ │
31
+ │ │ aiw claude ... ───┼───►│ Claude CLI │ │
32
+ │ │ aiw codex ... ───┼───►│ Codex CLI │ │
33
+ │ │ aiw gemini ... ───┼───►│ Gemini CLI │ │
34
+ │ │ │ │ │ │
35
+ │ │ + Provider Switch │ │ aiw mcp serve ────────────►│ │
36
+ │ │ + Role Injection │ │ ├─► filesystem server │ │
37
+ │ │ + Param Forwarding │ │ ├─► git server │ │
38
+ │ │ + CWD Control │ │ ├─► database server │ │
39
+ │ │ │ │ └─► ... (plugin market) │ │
40
+ │ └─────────────────────┘ └─────────────────────────────┘ │
41
+ │ │
42
+ └─────────────────────────────────────────────────────────────┘
43
+ ```
44
+
45
+ ## Installation
24
46
 
25
47
  ```bash
26
- # Basic usage with provider management
27
- aiw claude "explain this code" # Use default provider
28
- aiw claude -p openrouter "explain this code" # Use OpenRouter provider
29
- aiw claude -p glm "explain this code" # Use custom GLM provider
48
+ # Install from NPM
49
+ npm install -g @putao520/aiw
30
50
 
31
- # 🆕 Transparent Parameter Forwarding (v0.5.23+)
32
- aiw claude -p glm --model sonnet --debug api "explain this code"
33
- aiw claude -p glm --print --output-format json "get structured response"
34
- aiw codex -p glm --temperature 0.7 --max-tokens 1000 "generate text"
51
+ # Verify installation
52
+ aiw --version
53
+ ```
35
54
 
36
- # Interactive mode with parameter forwarding
37
- aiw claude -p glm --model sonnet --debug api # Interactive session with custom parameters
38
- aiw claude -p glm --print --allowed-tools Bash,Edit # Interactive with tool restrictions
55
+ ## AI CLI Router & Proxy
39
56
 
40
- # Wait for all AI CLI tasks to complete
41
- aiw wait
57
+ ### Basic Usage
42
58
 
43
- # Manage providers (TUI interface)
44
- aiw provider
59
+ ```bash
60
+ # Route to specific AI CLI
61
+ aiw claude "explain this code"
62
+ aiw codex "write tests"
63
+ aiw gemini "translate to Chinese"
64
+
65
+ # Route to multiple AI CLIs
66
+ aiw all "review this code" # All available CLIs
67
+ aiw "claude|gemini" "compare approaches" # Specific CLIs
45
68
  ```
46
69
 
47
- ### 5. Update
48
- - **AIW Self-Update**: Update AIW itself to latest version from NPM
49
- - **AI CLI Tools Update**: Update all installed AI CLI tools (claude, codex, gemini)
50
- - **Combined Update**: Update both AIW and AI CLI tools in one command
70
+ ### Provider Switching (-p)
51
71
 
52
72
  ```bash
53
- # Update both AIW and all AI CLI tools
54
- aiw update
73
+ # Switch API provider without changing AI CLI
74
+ aiw claude -p openrouter "explain this"
75
+ aiw claude -p glm "explain this"
76
+ aiw claude -p anthropic "explain this"
77
+
78
+ # Provider config: ~/.aiw/providers.json
79
+ ```
80
+
81
+ ### Role Injection (-r)
82
+
83
+ ```bash
84
+ # Inject role prompt before task
85
+ aiw claude -r common "write a function"
86
+ aiw claude -r security "review this code"
87
+ aiw claude -r debugger "fix this bug"
88
+
89
+ # 22 built-in roles + custom roles in ~/.aiw/role/*.md
90
+ aiw roles list
91
+ ```
92
+
93
+ ### Working Directory (-C)
94
+
95
+ ```bash
96
+ # Start AI CLI in specific directory
97
+ aiw claude -C /path/to/project "implement feature"
98
+ aiw claude -r common -C ~/myproject "fix the bug"
99
+ ```
100
+
101
+ ### Transparent Parameter Forwarding
55
102
 
56
- # Command will:
57
- # 1. Check and update AIW to latest version
58
- # 2. Check and update all installed AI CLI tools
59
- # 3. Show detailed results for both updates
103
+ ```bash
104
+ # All unknown flags forwarded to AI CLI
105
+ aiw claude -p glm --model sonnet --debug api "explain this"
106
+ aiw claude -r security --print --output-format json "review"
107
+
108
+ # Order: aiw flags (-r, -p, -C) → AI CLI flags → prompt
60
109
  ```
61
110
 
62
- ### 2. Intelligent MCP Routing ⭐
63
- Route user requests to the best MCP tool with 98% token reduction.
111
+ ### Combined Example
64
112
 
65
- **How it works:**
66
- - **LLM ReAct Mode**: Uses LLM reasoning to analyze requests
67
- - **Vector Search Mode**: Semantic similarity fallback
68
- - **Dynamic Registration**: Registers tools on-demand (98% token savings)
69
- - **JavaScript Orchestration**: Auto-generates workflows for complex tasks
113
+ ```bash
114
+ # Full example with all options
115
+ aiw claude -r common -p glm -C ~/project --model sonnet "implement REQ-001"
116
+ # ^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
117
+ # role provider cwd forwarded prompt
118
+ ```
119
+
120
+ ## MCP Router & Proxy
121
+
122
+ ### Start MCP Server
70
123
 
71
- **Usage:**
72
124
  ```bash
73
- # Start MCP server
74
- aiw mcp
125
+ # Start AIW as MCP server
126
+ aiw mcp serve
75
127
 
76
128
  # Configure in Claude Code (~/.claude/settings.json)
77
129
  {
78
130
  "mcpServers": {
79
131
  "aiw": {
80
132
  "command": "aiw",
81
- "args": ["mcp"]
133
+ "args": ["mcp", "serve"]
82
134
  }
83
135
  }
84
136
  }
85
-
86
- # Available MCP tools:
87
- # - intelligent_route: Auto-route to best tool
88
- # - get_method_schema: Get tool schemas
89
- # - execute_tool: Execute tools with negotiation
90
137
  ```
91
138
 
92
- ### 3. MCP Server Management
93
- Manage external MCP servers with hot-reload support.
139
+ ### MCP Server Management
94
140
 
95
141
  ```bash
96
- # Add MCP server
97
- aiw mcp add filesystem npx --description "File operations" \
98
- -- -y @modelcontextprotocol/server-filesystem /home/user
99
-
100
- # List servers
142
+ # List configured MCP servers
101
143
  aiw mcp list
102
144
 
103
- # Enable/disable servers
104
- aiw mcp enable brave-search
105
- aiw mcp disable filesystem
145
+ # Add MCP server
146
+ aiw mcp add filesystem npx -- -y @modelcontextprotocol/server-filesystem $HOME
147
+
148
+ # Enable/disable servers (hot-reload)
149
+ aiw mcp enable filesystem
150
+ aiw mcp disable git
106
151
 
107
- # Hot-reload: Changes apply instantly without restart
152
+ # Edit config directly
153
+ aiw mcp edit
108
154
  ```
109
155
 
110
- ### 4. MCP Registry CLI
111
- Search and install MCP servers from multiple registries with multi-source aggregation.
112
-
113
- **Supported Registries:**
114
- - **Official MCP Registry** (registry.modelcontextprotocol.io)
115
- - **Smithery** (registry.smithery.ai)
156
+ ### MCP Registry (Search & Install)
116
157
 
117
158
  ```bash
118
- # Interactive browse all MCP servers (with fuzzy search)
159
+ # Browse all available MCP servers (interactive TUI)
119
160
  aiw mcp browse
120
161
 
121
- # Search MCP servers across all registries
122
- aiw mcp search "filesystem"
123
- aiw mcp search "git" --source official # Search specific registry
162
+ # Search across registries (Official + Smithery)
163
+ aiw mcp search "git"
164
+ aiw mcp search "database" --source official
124
165
 
125
- # Get detailed server information
166
+ # Get server info
126
167
  aiw mcp info @anthropic/filesystem
127
168
 
128
- # Install MCP server with interactive setup
169
+ # Install server
129
170
  aiw mcp install @anthropic/filesystem
130
-
131
- # Install with environment variables
132
171
  aiw mcp install @anthropic/filesystem --env API_KEY=xxx
133
-
134
- # Update registry cache
135
- aiw mcp update
136
172
  ```
137
173
 
138
- **Features:**
139
- - **Interactive Browse**: Fuzzy search through all servers with ↑↓ navigation
140
- - **Multi-source Aggregation**: Search across Official Registry + Smithery in parallel
141
- - **Deduplication**: Same server from multiple sources shown once with best match
142
- - **Interactive Install**: Configure environment variables during installation
143
- - **Source Tracking**: Track where each server was installed from
144
-
145
- ### 5. Plugin Marketplace ⭐
146
- Browse and install plugins from Claude Code-compatible plugin marketplaces.
147
-
148
- **Default Marketplaces:**
149
- - **Claude Code Official** (anthropics/claude-plugins-official)
150
- - **AIW Official** (putao520/aiw-plugins)
174
+ ### Plugin Marketplace
151
175
 
152
176
  ```bash
153
- # Browse MCP plugins interactively
177
+ # Browse MCP plugins (interactive TUI)
154
178
  aiw plugin browse
155
179
 
156
180
  # Search plugins
157
- aiw plugin search "git"
158
- aiw plugin search "playwright" --market claude-code-official
159
-
160
- # View plugin details
161
- aiw plugin info playwright@claude-code-official
181
+ aiw plugin search "playwright"
162
182
 
163
- # Install plugin (interactive setup)
183
+ # Install plugin
164
184
  aiw plugin install playwright@claude-code-official
165
185
 
166
- # Install with environment variables
167
- aiw plugin install serena@claude-code-official --env MY_VAR=value
168
-
169
- # List installed plugins
186
+ # List/manage installed plugins
170
187
  aiw plugin list
171
-
172
- # Enable/disable plugins
173
188
  aiw plugin enable playwright
174
189
  aiw plugin disable serena
175
-
176
- # Remove plugin
177
190
  aiw plugin remove playwright
178
- ```
179
191
 
180
- **Marketplace Management:**
181
- ```bash
182
- # List marketplaces
192
+ # Manage marketplace sources
183
193
  aiw plugin marketplace list
184
-
185
- # Add custom marketplace
186
- aiw plugin marketplace add my-market https://github.com/user/marketplace
187
-
188
- # Remove marketplace
189
- aiw plugin marketplace remove my-market
190
-
191
- # Update marketplace indexes
192
- aiw plugin marketplace update
194
+ aiw plugin marketplace add my-market https://github.com/user/plugins
193
195
  ```
194
196
 
195
- **Configuration Files:**
196
- - `~/.aiw/settings.json`: Marketplace sources and plugin states
197
- - `~/.aiw/plugins.json`: Installed plugin records
198
- - `~/.aiw/mcp.json`: Extracted MCP server configurations
199
-
200
- **Features:**
201
- - **MCP-Only Filtering**: Only shows plugins with MCP servers (mcpServers field)
202
- - **Claude Code Compatible**: Uses same plugin format as Claude Code
203
- - **JSON Configuration**: Modern JSON format (automatic YAML migration)
204
- - **Interactive Setup**: Configure environment variables during installation
205
- - **Hot-Reload**: Changes apply instantly without restart
206
- - **Transport Type Support**: Supports stdio transport (local executables). HTTP/SSE transports coming soon.
207
-
208
- **Environment Variables:**
209
- Plugins can use environment variable placeholders in their MCP configuration:
210
- ```json
211
- {
212
- "env": {
213
- "API_KEY": "${API_KEY}",
214
- "GITHUB_TOKEN": "${GITHUB_TOKEN}"
215
- }
216
- }
217
- ```
218
- During installation, AIW will prompt for values or you can provide them via `--env` flag. Placeholders are preserved in the config and expanded at runtime.
219
-
220
- ## 🔄 Transparent Parameter Forwarding (v0.5.23+)
221
-
222
- AIW now supports transparent parameter forwarding, allowing you to use **all** AI CLI features while maintaining provider management capabilities.
223
-
224
- ### How It Works
225
-
226
- ```bash
227
- # Parameter parsing logic:
228
- aiw <ai_type> -p <provider> <cli_params...> <prompt>
229
- # ^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
230
- # AIW args AIW args Forward to AI CLI
231
- ```
232
-
233
- ### Rules
234
-
235
- - **AIW Consumes**: `-r` / `--role` for role injection, `-p` / `--provider` for provider selection
236
- - **Transparent Forwarding**: All other `-` prefixed parameters are passed directly to the AI CLI
237
- - **Parameter Order**: AIW flags (-r, -p) must come **before** other CLI parameters
238
- - **Full Compatibility**: Maintain complete access to all AI CLI features
239
-
240
- ### Examples
241
-
242
- #### Task Mode
243
- ```bash
244
- # Model selection with debugging
245
- aiw claude -p glm --model sonnet --debug api "explain this code"
246
-
247
- # Structured output
248
- aiw claude -p glm --print --output-format json "summarize the file"
249
-
250
- # Tool restrictions
251
- aiw claude -p glm --allowed-tools Bash,Edit "modify this file"
252
-
253
- # Multiple parameters
254
- aiw claude -p glm --model sonnet --max-budget-usd 5 --dangerously-skip-permissions "help me debug"
255
- ```
256
-
257
- #### Interactive Mode
258
- ```bash
259
- # Interactive session with custom model and debugging
260
- aiw claude -p glm --model sonnet --debug api
261
-
262
- # Interactive with output formatting
263
- aiw claude -p glm --print --output-format stream-json
264
-
265
- # Interactive with specific tools
266
- aiw claude -p glm --tools "Bash,Edit,Read" --no-session-persistence
267
-
268
- # Multi-AI with same provider
269
- aiw "claude|codex" -p glm --temperature 0.7 "compare approaches"
270
- ```
197
+ ## Task Monitoring
271
198
 
272
- #### Provider-Specific Examples
273
199
  ```bash
274
- # Claude with structured output
275
- aiw claude -p glm --json-schema '{"type":"object","properties":{"summary":{"type":"string"}}}' "summarize this"
200
+ # Show task status
201
+ aiw status
276
202
 
277
- # Codex with custom settings
278
- aiw codex -p glm --temperature 0.3 --max-tokens 500 "write python function"
203
+ # Wait for all AI CLI tasks to complete
204
+ aiw wait
279
205
 
280
- # Gemini with approval mode
281
- aiw gemini -p glm --approval-mode yolo "translate this text"
206
+ # Wait for specific process
207
+ aiw pwait <PID>
282
208
  ```
283
209
 
284
- ### Benefits
285
-
286
- ✅ **Full CLI Access**: Use all AI CLI parameters without limitations
287
- ✅ **Provider Flexibility**: Switch providers without changing commands
288
- ✅ **Process Tracking**: Maintain AIW's monitoring and task management
289
- ✅ **Environment Injection**: Automatic provider configuration injection
290
- ✅ **Zero Learning Curve**: Works exactly like native AI CLI with provider prefix
291
-
292
- ---
210
+ ## Update
293
211
 
294
- ## 🚀 Quick Start
295
-
296
- ### Installation
297
212
  ```bash
298
- # Install from NPM
299
- npm install -g @putao520/aiw
300
-
301
- # Or use npx directly
302
- npx @putao520/aiw --help
303
- ```
304
-
305
- ### Initial Setup
306
- ```bash
307
- # Verify installation
308
- aiw --version
309
-
310
- # Check available AI CLI tools
311
- aiw status
312
-
313
- # Configure MCP servers
314
- aiw mcp add filesystem npx -- -y @modelcontextprotocol/server-filesystem $HOME
213
+ # Update AIW and all AI CLI tools
214
+ aiw update
315
215
  ```
316
216
 
317
- ## 📖 Documentation
217
+ ## Configuration Files
318
218
 
319
- - **[MCP Usage Guide](./docs/MCP_GUIDE.md)** - Detailed MCP configuration and usage
320
- - **[GitHub Repository](https://github.com/putao520/agentic-warden)** - Full source code and issues
219
+ | File | Purpose |
220
+ |------|---------|
221
+ | `~/.aiw/providers.json` | AI provider configurations |
222
+ | `~/.aiw/mcp.json` | MCP server configurations |
223
+ | `~/.aiw/role/*.md` | Custom role prompts |
224
+ | `~/.aiw/settings.json` | Plugin marketplace settings |
225
+ | `~/.aiw/plugins.json` | Installed plugin records |
321
226
 
322
- ## 🛠️ Configuration
227
+ ## Quick Reference
323
228
 
324
- ### Environment Variables
325
229
  ```bash
326
- # AI CLI Configuration
327
- export CLI_TYPE=claude # claude, codex, or gemini
328
- export CLI_PROVIDER=llmlite # Any provider from provider.json
329
-
330
- # MCP Server Configuration
331
- export MCP_CONFIG_PATH=~/.aiw/mcp.json
230
+ # AI CLI routing
231
+ aiw <cli> [-r role] [-p provider] [-C cwd] [cli-args...] "prompt"
232
+
233
+ # MCP commands
234
+ aiw mcp serve # Start MCP server
235
+ aiw mcp list|add|remove # Manage servers
236
+ aiw mcp browse|search # Registry
237
+ aiw mcp install|info # Install servers
238
+
239
+ # Plugin commands
240
+ aiw plugin browse|search # Discover plugins
241
+ aiw plugin install|remove # Manage plugins
242
+ aiw plugin list|enable|disable
243
+
244
+ # Other commands
245
+ aiw status # Task status
246
+ aiw wait # Wait for tasks
247
+ aiw update # Update tools
248
+ aiw roles list # List roles
249
+ aiw help <command> # Detailed help
332
250
  ```
333
251
 
334
- ### Configuration Files
335
- - **MCP Servers**: `~/.aiw/mcp.json` (standard `mcpServers` schema compatible with Claude Code)
336
- - Claude Code users: Add to `~/.claude/settings.json` under the "mcpServers" section
337
- - **Providers**: `~/.aiw/providers.json`
338
-
339
- ## 🙏 Acknowledgments
340
-
341
- - **Claude Code**: Anthropic's official CLI for Claude
342
- - **Anthropic Code Execution**: Inspired by [Code Execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp)
343
-
344
- ## 📜 License
252
+ ## License
345
253
 
346
254
  MIT License - see [LICENSE](LICENSE) file for details.
347
255
 
348
256
  ---
349
257
 
350
- **AIW** - Universal AI CLI Management Platform with MCP Routing v0.5.26
258
+ **AIW** - Unified Gateway for AI CLI & MCP | v0.5.35
351
259
 
352
- For full documentation and source code, visit: [https://github.com/putao520/agentic-warden](https://github.com/putao520/agentic-warden)
260
+ [GitHub](https://github.com/putao520/agentic-warden) | [NPM](https://www.npmjs.com/package/@putao520/aiw)
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawnSync } = require('child_process');
3
+ const { spawn } = require('child_process');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
6
  const fs = require('fs');
@@ -48,9 +48,28 @@ if (!fs.existsSync(binaryPath)) {
48
48
  process.exit(1);
49
49
  }
50
50
 
51
- // Execute binary and pass all arguments
52
- const result = spawnSync(binaryPath, process.argv.slice(2), {
51
+ // Execute binary with real-time stdio passthrough
52
+ const child = spawn(binaryPath, process.argv.slice(2), {
53
53
  stdio: 'inherit',
54
+ // Ensure signals are passed through
55
+ detached: false,
54
56
  });
55
57
 
56
- process.exit(result.status || 0);
58
+ // Forward signals to child process
59
+ ['SIGINT', 'SIGTERM', 'SIGHUP'].forEach((signal) => {
60
+ process.on(signal, () => {
61
+ if (!child.killed) {
62
+ child.kill(signal);
63
+ }
64
+ });
65
+ });
66
+
67
+ // Exit with child's exit code
68
+ child.on('close', (code) => {
69
+ process.exit(code || 0);
70
+ });
71
+
72
+ child.on('error', (err) => {
73
+ console.error(`Failed to start aiw: ${err.message}`);
74
+ process.exit(1);
75
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putao520/aiw",
3
- "version": "0.5.32",
3
+ "version": "0.5.36",
4
4
  "description": "Universal AI CLI management platform with intelligent MCP routing, process tracking, and configuration synchronization",
5
5
  "keywords": [
6
6
  "ai",