blade-code 0.0.17 → 0.0.19

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 (4) hide show
  1. package/README.en.md +54 -440
  2. package/README.md +53 -480
  3. package/dist/blade.js +186 -181
  4. package/package.json +1 -1
package/README.en.md CHANGED
@@ -17,294 +17,88 @@ English | [简体中文](README.md)
17
17
 
18
18
  ## ✨ Key Features
19
19
 
20
- <table>
21
- <tr>
22
- <td width="50%" valign="top">
23
- <h3>🤖 Intelligent Conversations</h3>
24
- <p>Natural language interactions powered by LLMs with context understanding and multi-turn dialogues. Simply run <code>blade</code> to launch the interactive UI.</p>
25
- </td>
26
- <td width="50%" valign="top">
27
- <h3>🛠️ Rich Toolset</h3>
28
- <p>Built-in tools for file operations, Git management, network requests, code analysis, and more</p>
29
- </td>
30
- </tr>
31
- <tr>
32
- <td width="50%" valign="top">
33
- <h3>🔗 MCP Protocol</h3>
34
- <p>Model Context Protocol support for seamless external resource and tool integration</p>
35
- </td>
36
- <td width="50%" valign="top">
37
- <h3>🎨 Modern UI</h3>
38
- <p>Beautiful terminal interface powered by Ink with smooth interactions</p>
39
- </td>
40
- </tr>
41
- <tr>
42
- <td width="50%" valign="top">
43
- <h3>💾 Session Management</h3>
44
- <p>Multi-session support with conversation continuation and recovery</p>
45
- </td>
46
- <td width="50%" valign="top">
47
- <h3>🔒 Secure & Controllable</h3>
48
- <p>Permission management, tool whitelisting, and operation confirmation</p>
49
- </td>
50
- </tr>
51
- </table>
20
+ - 🤖 **Intelligent Conversations** - LLM-powered with context understanding and multi-turn dialogues
21
+ - 🛠️ **Rich Toolset** - 18+ built-in tools: file operations, code search, shell execution, Git, and more
22
+ - 🔗 **MCP Protocol** - Model Context Protocol support for seamless external tool integration
23
+ - 🎨 **Modern UI** - React + Ink based terminal UI with Markdown rendering and syntax highlighting
24
+ - 💾 **Session Management** - Multi-session, continuation, recovery, and forking support
25
+ - 🔒 **Secure & Controllable** - Three-tier permission system (allow/ask/deny), tool whitelisting
52
26
 
53
27
  ---
54
28
 
55
29
  ## 🚀 Quick Start
56
30
 
57
- ### Try Without Installation
58
-
59
- Experience Blade Code instantly without installation:
31
+ ### Try Without Installation
60
32
 
61
33
  ```bash
62
- # Interactive mode
63
34
  npx blade-code
64
-
65
- # Quick Q&A (non-interactive)
66
35
  npx blade-code --print "Explain what TypeScript is"
67
-
68
- # Code generation (non-interactive)
69
- npx blade-code --print "Write a quicksort algorithm in Python"
70
36
  ```
71
37
 
72
- ### 📦 Global Installation (Recommended)
38
+ ### Global Installation
73
39
 
74
40
  ```bash
75
- # Using npm
76
41
  npm install -g blade-code
77
-
78
- # Using pnpm
42
+ # or
79
43
  pnpm add -g blade-code
80
-
81
- # Using yarn
82
- yarn global add blade-code
83
44
  ```
84
45
 
85
- After installation, use the `blade` command:
46
+ ### Basic Usage
86
47
 
87
48
  ```bash
88
- # Interactive mode (default)
89
- blade
90
-
91
- # Quick Q&A (non-interactive)
92
- blade --print "Hello, introduce yourself"
49
+ blade # Interactive mode
50
+ blade "Help me analyze this project" # Enter with initial message
51
+ blade --print "Write a quicksort" # Print mode (for piping)
52
+ blade --continue # Continue last conversation
93
53
  ```
94
54
 
95
- > On the first run, if no API key is detected, Blade will automatically open an interactive setup wizard in your terminal to collect Provider, Base URL, API Key, and model information before continuing.
55
+ > On first run, if no API key is configured, a setup wizard will appear automatically.
96
56
 
97
57
  ---
98
58
 
99
- ## 🔐 Configure API Keys
59
+ ## 🔐 Configuration
100
60
 
101
- Blade Code supports multiple LLM providers. You need to configure the appropriate API key:
102
-
103
- ### Method 1: Configuration File (Recommended)
61
+ ### Config File
104
62
 
105
63
  ```bash
106
- # Create user-level configuration file
107
64
  mkdir -p ~/.blade
108
65
  cat > ~/.blade/config.json << 'EOF'
109
66
  {
110
67
  "provider": "openai-compatible",
111
68
  "apiKey": "your-api-key",
112
- "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
113
- "model": "qwen-max"
69
+ "baseUrl": "https://api.openai.com/v1",
70
+ "model": "gpt-4"
114
71
  }
115
72
  EOF
116
-
117
- # Or use environment variable interpolation in config file
118
- cat > ~/.blade/config.json << 'EOF'
119
- {
120
- "apiKey": "${BLADE_API_KEY}",
121
- "baseUrl": "${BLADE_BASE_URL:-https://apis.iflow.cn/v1}"
122
- }
123
- EOF
124
- ```
125
-
126
- ### Method 2: First-Run Setup Wizard (Recommended Experience)
127
-
128
- ```bash
129
- blade
130
- # If no API key is configured, an interactive wizard will guide you through Provider, Base URL, API Key, and model setup.
131
- ```
132
-
133
- ### Method 3: Config Command
134
-
135
- ```bash
136
- # Use config command to manage configuration
137
- blade config
138
73
  ```
139
74
 
75
+ Supports environment variable interpolation: `"apiKey": "${BLADE_API_KEY}"`
140
76
 
141
77
  ### Get API Keys
142
78
 
143
79
  - **Qwen**: [DashScope Console](https://dashscope.console.aliyun.com/apiKey)
144
80
  - **VolcEngine**: [Volcano Ark Console](https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey)
81
+ - **OpenAI**: [OpenAI Platform](https://platform.openai.com/api-keys)
145
82
 
146
83
  ---
147
84
 
148
85
  ## 💬 Usage Examples
149
86
 
150
- ### Basic Conversations
151
-
152
- ```bash
153
- # Interactive mode (default)
154
- blade
155
-
156
- # Non-interactive quick answer (print mode)
157
- blade --print "What is artificial intelligence?"
158
-
159
- # Code generation (print mode)
160
- blade --print "Write a debounce function in JavaScript"
161
- ```
162
-
163
- ### Smart Tool Invocation
164
-
165
- Blade Code automatically selects appropriate tools based on your needs:
166
-
167
- ```bash
168
- # File operations (print mode)
169
- blade --print "List all TypeScript files in the current directory"
170
-
171
- # Git operations (print mode)
172
- blade --print "Show the last 5 commit logs"
173
-
174
- # Code review (print mode)
175
- blade --print "Review code quality in src/utils directory"
176
- ```
177
-
178
- ### Session Management
179
-
180
- ```bash
181
- # Create or use named session (print mode)
182
- blade --session-id "project-alpha" --print "Start new project"
183
-
184
- # Continue recent session
185
- blade --continue
186
-
187
- # Resume specific conversation
188
- blade --resume <conversation-id>
189
-
190
- # Fork session (create new session from existing)
191
- blade --resume <id> --fork-session
192
- ```
193
-
194
- ### Print Mode
195
-
196
- Perfect for piping and scripting:
197
-
198
87
  ```bash
199
- # Print mode (non-interactive, direct output)
200
- blade --print "Generate a README template" > README.md
88
+ # Smart tool invocation
89
+ blade "List all TypeScript files"
90
+ blade "Find code containing TODO"
91
+ blade "Review code in src/utils"
201
92
 
202
- # Specify output format
203
- blade --print --output-format json "Get project info"
93
+ # Session management
94
+ blade --session-id "my-project" "Start new project"
95
+ blade --resume <id> # Resume session
96
+ blade --resume <id> --fork-session # Fork session
204
97
 
205
- # Stream JSON output
206
- blade --print --output-format stream-json "Analyze code"
207
- ```
208
-
209
- ### Input/Output Options
210
-
211
- ```bash
212
- # Read from stdin (stream JSON format)
213
- cat input.json | blade --input-format stream-json --print
214
-
215
- # Include partial message chunks
216
- blade --print --include-partial-messages "Generate long text"
217
-
218
- # Replay user messages
219
- blade --replay-user-messages < input.txt
220
- ```
221
-
222
- ---
223
-
224
- ## 🔧 Advanced Features
225
-
226
- ### MCP Server Integration
227
-
228
- Model Context Protocol allows integration of external tools and resources:
229
-
230
- ```bash
231
- # Configure and manage MCP servers
232
- blade mcp
233
-
234
- # Load MCP config from JSON file
235
- blade --mcp-config config.json "Use external tools"
236
-
237
- # Strict mode (only use specified MCP config)
238
- blade --mcp-config config.json --strict-mcp-config "Query"
239
- ```
240
-
241
- ### Configuration Management
242
-
243
- ```bash
244
- # Configuration management
245
- blade config
246
-
247
- # System health check
248
- blade doctor
249
-
250
- # Check for updates
251
- blade update
252
- ```
253
-
254
- ### AI Model Options
255
-
256
- ```bash
257
- # Specify model
258
- blade --model qwen-max --print "Complex question"
259
-
260
- # Set fallback model
261
- blade --fallback-model qwen-turbo --print "Question"
262
-
263
- # Custom system prompt
264
- blade --append-system-prompt "You are a senior architect" --print "Design microservices architecture"
265
-
266
- # Replace default system prompt entirely
267
- blade --system-prompt "You are a TypeScript expert" --print "Explain decorators"
268
-
269
- # Custom agent config
270
- blade --agents '{"reviewer": {"model": "qwen-max"}}' --print "Review code"
271
- ```
272
-
273
- ### Security & Permissions
274
-
275
- Blade ships with a three-tier permission system (`allow` / `ask` / `deny`). You can fine-tune runtime behavior with CLI flags:
276
-
277
- ```bash
278
- # Allow specific tools only
279
- blade --allowed-tools "read,write" --print "Handle files"
280
-
281
- # Disallow specific tools
282
- blade --disallowed-tools "bash,execute" --print "Safe operations"
283
-
284
- # Permission modes
285
- blade --permission-mode plan --print "Plan task" # Plan only, no execution
286
- blade --permission-mode autoEdit --print "Modify code" # Auto-approve edits
287
- blade --yolo --print "Run high-trust operations" # Approve every tool call
288
-
289
- # Add allowed directories
290
- blade --add-dir /path/to/dir --print "Access directory"
291
- ```
292
-
293
- ### IDE Integration
294
-
295
- ```bash
296
- # Auto-connect to IDE on startup
297
- blade --ide
298
- ```
299
-
300
- ### Configuration Files
301
-
302
- ```bash
303
- # Use settings file
304
- blade --settings settings.json
305
-
306
- # Specify config sources
307
- blade --setting-sources "global,user,local"
98
+ # Security control
99
+ blade --allowed-tools "Read,Grep" "Read-only operations"
100
+ blade --permission-mode plan "Plan only, no execution"
101
+ blade --yolo "Auto-approve all operations"
308
102
  ```
309
103
 
310
104
  ---
@@ -313,229 +107,49 @@ blade --setting-sources "global,user,local"
313
107
 
314
108
  ### Main Commands
315
109
 
316
- | Command | Description | Example |
317
- |---------|-------------|---------|
318
- | `blade` | Start interactive AI assistant (default) | `blade` |
319
- | `blade config` | Configuration management | `blade config` |
320
- | `blade mcp` | Configure and manage MCP servers | `blade mcp` |
321
- | `blade doctor` | System health check | `blade doctor` |
322
- | `blade update` | Check and install updates | `blade update` |
323
- | `blade install [target]` | Install specific version (stable/latest/version) | `blade install latest` |
324
-
325
- ### Debug Options
326
-
327
- | Option | Short | Description |
328
- |--------|-------|-------------|
329
- | `--debug [category]` | `-d` | Enable debug mode with optional category filtering |
110
+ | Command | Description |
111
+ |---------|-------------|
112
+ | `blade` | Start interactive assistant |
113
+ | `blade config` | Configuration management |
114
+ | `blade mcp` | MCP server management |
115
+ | `blade doctor` | System health check |
116
+ | `blade update` | Check for updates |
330
117
 
331
- ### Output Options
332
-
333
- | Option | Short | Description |
334
- |--------|-------|-------------|
335
- | `--print` | `-p` | Print response and exit (for piping) |
336
- | `--output-format <format>` | | Output format: text/json/stream-json (with --print only) |
337
- | `--include-partial-messages` | | Include partial message chunks |
338
-
339
- ### Input Options
340
-
341
- | Option | Description |
342
- |--------|-------------|
343
- | `--input-format <format>` | Input format: text/stream-json |
344
- | `--replay-user-messages` | Re-emit user messages from stdin |
345
-
346
- ### Security Options
347
-
348
- | Option | Description |
349
- |--------|-------------|
350
- | `--allowed-tools <tools>` | Allowed tools list (comma or space separated) |
351
- | `--disallowed-tools <tools>` | Disallowed tools list (comma or space separated) |
352
- | `--permission-mode <mode>` | Permission mode: default/autoEdit/yolo/plan |
353
- | `--yolo` | Shortcut for `--permission-mode yolo` |
354
- | `--add-dir <dirs>` | Additional directories for tool access |
355
-
356
- ### MCP Options
357
-
358
- | Option | Description |
359
- |--------|-------------|
360
- | `--mcp-config <files>` | Load MCP servers from JSON files or strings |
361
- | `--strict-mcp-config` | Only use servers from --mcp-config |
362
-
363
- ### AI Options
364
-
365
- | Option | Description |
366
- |--------|-------------|
367
- | `--append-system-prompt <text>` | Append system prompt to default |
368
- | `--system-prompt <text>` | Replace default system prompt |
369
- | `--model <name>` | Model for current session |
370
- | `--fallback-model <name>` | Enable automatic fallback to specified model |
371
- | `--agents <json>` | Custom agent configuration JSON |
372
-
373
- ### Session Options
118
+ ### Common Options
374
119
 
375
120
  | Option | Short | Description |
376
121
  |--------|-------|-------------|
122
+ | `--print` | `-p` | Print response and exit |
377
123
  | `--continue` | `-c` | Continue recent session |
378
124
  | `--resume <id>` | `-r` | Resume specific session |
379
- | `--fork-session` | | Create new session ID when resuming |
380
- | `--session-id <id>` | | Use specific session ID |
381
-
382
- ### Configuration Options
383
-
384
- | Option | Description |
385
- |--------|-------------|
386
- | `--settings <path>` | Settings JSON file path or JSON string |
387
- | `--setting-sources <sources>` | Setting sources to load (comma separated) |
388
-
389
- ### Integration Options
125
+ | `--model <name>` | | Specify model |
126
+ | `--yolo` | | Auto-approve all operations |
390
127
 
391
- | Option | Description |
392
- |--------|-------------|
393
- | `--ide` | Auto-connect to IDE on startup |
128
+ ### Slash Commands
394
129
 
395
- ### Other Options
396
-
397
- | Option | Short | Description |
398
- |--------|-------|-------------|
399
- | `--help` | `-h` | Show help |
400
- | `--version` | `-V` | Show version number |
130
+ Use in interactive mode: `/init` `/help` `/clear` `/compact` `/agents` `/permissions` `/mcp` `/resume` `/config` `/theme` `/model`
401
131
 
402
132
  ---
403
133
 
404
- ## 🏗️ Technical Architecture
405
-
406
- Blade Code features a modern flat architecture design:
407
-
408
- ```
409
- src/
410
- ├── agent/ # Agent core logic
411
- ├── cli/ # CLI config and middleware
412
- ├── commands/ # Command handlers
413
- ├── config/ # Configuration management
414
- ├── tools/ # Tool system
415
- ├── ui/ # UI components (Ink-based)
416
- ├── services/ # Shared services
417
- └── utils/ # Utility functions
418
- ```
419
-
420
- ### Core Features
134
+ ## 📖 Documentation
421
135
 
422
- - 🚀 **Lightning Fast**: Built with Bun for exceptional performance
423
- - 📦 **Single File Deploy**: Build output ~1MB only
424
- - 🎨 **React for CLI**: Modern UI powered by Ink
425
- - 🔧 **TypeScript**: Full type support
426
- - ✅ **Comprehensive Testing**: Unit, integration, and E2E test coverage
136
+ - **[User Docs](docs/public/README.md)** - Installation, configuration, usage guides
137
+ - **[Developer Docs](docs/development/README.md)** - Architecture, implementation details
138
+ - **[Contributing Guide](CONTRIBUTING.md)** - Open source contribution
427
139
 
428
140
  ---
429
141
 
430
- ## 🔨 Development Guide
431
-
432
- ### Requirements
433
-
434
- - Node.js >= 16.0.0
435
- - pnpm (recommended) or npm
142
+ ## 🤝 Contributing
436
143
 
437
- ### Clone Project
144
+ Contributions welcome! See [Contributing Guide](CONTRIBUTING.md).
438
145
 
439
146
  ```bash
440
147
  git clone https://github.com/echoVic/blade-code.git
441
- cd blade-code
442
- pnpm install
148
+ cd blade-code && pnpm install && pnpm dev
443
149
  ```
444
150
 
445
- ### Development Commands
446
-
447
- ```bash
448
- # Development mode (hot reload)
449
- pnpm dev
450
-
451
- # Build
452
- pnpm build
453
-
454
- # Run tests
455
- pnpm test
456
-
457
- # Test coverage
458
- pnpm test:coverage
459
-
460
- # Code linting
461
- pnpm check:fix
462
-
463
- # Type checking
464
- pnpm type-check
465
- ```
466
-
467
- ### Project Structure
468
-
469
- ```
470
- blade-code/
471
- ├── src/ # Source code
472
- ├── tests/ # Test files
473
- ├── dist/ # Build output
474
- ├── scripts/ # Build scripts
475
- └── docs/ # Documentation
476
- ```
477
-
478
- ---
479
-
480
- ## 🤝 Contributing
481
-
482
- We welcome all forms of contributions!
483
-
484
- - 🐛 [Report Bug](https://github.com/echoVic/blade-code/issues/new?template=bug_report.md)
485
- - 💡 [Feature Request](https://github.com/echoVic/blade-code/issues/new?template=feature_request.md)
486
- - 📖 [Improve Documentation](https://github.com/echoVic/blade-code/pulls)
487
- - 🔧 [Submit Code](CONTRIBUTING.md)
488
-
489
- ### Contribution Process
490
-
491
- 1. Fork this repository
492
- 2. Create feature branch (`git checkout -b feature/AmazingFeature`)
493
- 3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
494
- 4. Push to branch (`git push origin feature/AmazingFeature`)
495
- 5. Open Pull Request
496
-
497
- See [Contributing Guide](CONTRIBUTING.md) for details.
498
-
499
151
  ---
500
152
 
501
153
  ## 📄 License
502
154
 
503
- This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details.
504
-
505
- ---
506
-
507
- ## 🙏 Acknowledgments
508
-
509
- Blade Code is built upon these excellent open-source projects:
510
-
511
- - [Ink](https://github.com/vadimdemedes/ink) - React for CLI
512
- - [OpenAI](https://github.com/openai/openai-node) - OpenAI API client
513
- - [Biome](https://github.com/biomejs/biome) - Code formatting and linting
514
- - [Vitest](https://github.com/vitest-dev/vitest) - Testing framework
515
- - [Bun](https://github.com/oven-sh/bun) - Fast build tool
516
-
517
- ---
518
-
519
- ## 📞 Contact
520
-
521
- - **Author**: echoVic
522
- - **Homepage**: [https://github.com/echoVic/blade-code](https://github.com/echoVic/blade-code)
523
- - **Issue Tracker**: [GitHub Issues](https://github.com/echoVic/blade-code/issues)
524
-
525
- ---
526
-
527
- ## 🌟 Star History
528
-
529
- If Blade Code helps you, please give us a ⭐️ Star!
530
-
531
- [![Star History Chart](https://api.star-history.com/svg?repos=echoVic/blade-code&type=Date)](https://star-history.com/#echoVic/blade-code&Date)
532
-
533
- ---
534
-
535
- <div align="center">
536
-
537
- **🗡️ Blade Code - Make AI Your Command Line Companion!**
538
-
539
- Made with ❤️ by [echoVic](https://github.com/echoVic)
540
-
541
- </div>
155
+ [MIT](LICENSE) - Made with ❤️ by [echoVic](https://github.com/echoVic)