blade-code 0.0.5 → 0.0.7

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 +531 -0
  2. package/README.md +387 -255
  3. package/dist/blade.js +168 -169
  4. package/package.json +9 -3
package/README.en.md ADDED
@@ -0,0 +1,531 @@
1
+ <div align="center">
2
+
3
+ # đŸ—Ąī¸ Blade Code
4
+
5
+ **Next-Generation AI-Powered Coding Assistant**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/blade-code.svg?style=flat-square)](https://www.npmjs.com/package/blade-code)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
9
+ [![Node.js Version](https://img.shields.io/node/v/blade-code.svg?style=flat-square)](https://nodejs.org/)
10
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md)
11
+
12
+ English | [įŽ€äŊ“中文](README.md)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## ✨ Key Features
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</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>
52
+
53
+ ---
54
+
55
+ ## 🚀 Quick Start
56
+
57
+ ### ⚡ Try Without Installation
58
+
59
+ Experience Blade Code instantly without installation:
60
+
61
+ ```bash
62
+ # Interactive mode
63
+ npx blade-code
64
+
65
+ # Quick Q&A (non-interactive)
66
+ 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
+ ```
71
+
72
+ ### đŸ“Ļ Global Installation (Recommended)
73
+
74
+ ```bash
75
+ # Using npm
76
+ npm install -g blade-code
77
+
78
+ # Using pnpm
79
+ pnpm add -g blade-code
80
+
81
+ # Using yarn
82
+ yarn global add blade-code
83
+ ```
84
+
85
+ After installation, use the `blade` command:
86
+
87
+ ```bash
88
+ # Interactive mode (default)
89
+ blade
90
+
91
+ # Quick Q&A (non-interactive)
92
+ blade --print "Hello, introduce yourself"
93
+ ```
94
+
95
+ ---
96
+
97
+ ## 🔐 Configure API Keys
98
+
99
+ Blade Code supports multiple LLM providers. You need to configure the appropriate API key:
100
+
101
+ ### Method 1: Environment Variables (Recommended)
102
+
103
+ ```bash
104
+ # Qwen (Alibaba Cloud)
105
+ export QWEN_API_KEY="your-qwen-api-key"
106
+ export BLADE_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
107
+
108
+ # VolcEngine
109
+ export VOLCENGINE_API_KEY="your-volcengine-api-key"
110
+ export BLADE_BASE_URL="https://ark.cn-beijing.volces.com/api/v3"
111
+ ```
112
+
113
+ ### Method 2: Command Line Arguments
114
+
115
+ ```bash
116
+ blade --print "Hello" # Uses configured API key
117
+ ```
118
+
119
+ ### Method 3: Configuration File
120
+
121
+ ```bash
122
+ # Copy example config
123
+ cp config.env.example .env
124
+
125
+ # Edit .env file with your credentials
126
+ nano .env
127
+ ```
128
+
129
+ ### Get API Keys
130
+
131
+ - **Qwen**: [DashScope Console](https://dashscope.console.aliyun.com/apiKey)
132
+ - **VolcEngine**: [Volcano Ark Console](https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey)
133
+
134
+ ---
135
+
136
+ ## đŸ’Ŧ Usage Examples
137
+
138
+ ### Basic Conversations
139
+
140
+ ```bash
141
+ # Interactive mode (default)
142
+ blade
143
+
144
+ # Direct message (with --print for non-interactive)
145
+ blade --print "What is artificial intelligence?"
146
+
147
+ # Code generation
148
+ blade --print "Write a debounce function in JavaScript"
149
+ ```
150
+
151
+ ### Smart Tool Invocation
152
+
153
+ Blade Code automatically selects appropriate tools based on your needs:
154
+
155
+ ```bash
156
+ # File operations
157
+ blade --print "List all TypeScript files in the current directory"
158
+
159
+ # Git operations
160
+ blade --print "Show the last 5 commit logs"
161
+
162
+ # Code review
163
+ blade --print "Review code quality in src/utils directory"
164
+ ```
165
+
166
+ ### Session Management
167
+
168
+ ```bash
169
+ # Create or use named session
170
+ blade --sessionId "project-alpha" "Start new project"
171
+
172
+ # Continue recent session
173
+ blade --continue
174
+
175
+ # Resume specific conversation
176
+ blade --resume <conversation-id>
177
+
178
+ # Fork session (create new session from existing)
179
+ blade --resume <id> --forkSession
180
+ ```
181
+
182
+ ### Print Mode
183
+
184
+ Perfect for piping and scripting:
185
+
186
+ ```bash
187
+ # Print mode (non-interactive, direct output)
188
+ blade --print "Generate a README template" > README.md
189
+
190
+ # Specify output format
191
+ blade --print --outputFormat json "Get project info"
192
+
193
+ # Stream JSON output
194
+ blade --print --outputFormat stream-json "Analyze code"
195
+ ```
196
+
197
+ ### Input/Output Options
198
+
199
+ ```bash
200
+ # Read from stdin (stream JSON format)
201
+ cat input.json | blade --inputFormat stream-json --print
202
+
203
+ # Include partial message chunks
204
+ blade --print --includePartialMessages "Generate long text"
205
+
206
+ # Replay user messages
207
+ blade --replayUserMessages < input.txt
208
+ ```
209
+
210
+ ---
211
+
212
+ ## 🔧 Advanced Features
213
+
214
+ ### MCP Server Integration
215
+
216
+ Model Context Protocol allows integration of external tools and resources:
217
+
218
+ ```bash
219
+ # Configure and manage MCP servers
220
+ blade mcp
221
+
222
+ # Load MCP config from JSON file
223
+ blade --mcpConfig config.json "Use external tools"
224
+
225
+ # Strict mode (only use specified MCP config)
226
+ blade --mcpConfig config.json --strictMcpConfig "Query"
227
+ ```
228
+
229
+ ### Configuration Management
230
+
231
+ ```bash
232
+ # Configuration management
233
+ blade config
234
+
235
+ # System health check
236
+ blade doctor
237
+
238
+ # Check for updates
239
+ blade update
240
+
241
+ # Set up authentication token
242
+ blade setup-token
243
+ ```
244
+
245
+ ### AI Model Options
246
+
247
+ ```bash
248
+ # Specify model
249
+ blade --model qwen-max --print "Complex question"
250
+
251
+ # Set fallback model
252
+ blade --fallbackModel qwen-turbo --print "Question"
253
+
254
+ # Custom system prompt
255
+ blade --appendSystemPrompt "You are a senior architect" --print "Design microservices architecture"
256
+
257
+ # Custom agent config
258
+ blade --agents '{"reviewer": {"model": "qwen-max"}}' --print "Review code"
259
+ ```
260
+
261
+ ### Security & Permissions
262
+
263
+ ```bash
264
+ # Skip permission checks (dangerous)
265
+ blade --dangerouslySkipPermissions --print "Execute command"
266
+
267
+ # Allow specific tools only
268
+ blade --allowedTools "read,write" --print "Handle files"
269
+
270
+ # Disallow specific tools
271
+ blade --disallowedTools "bash,execute" --print "Safe operations"
272
+
273
+ # Permission modes
274
+ blade --permissionMode plan --print "Plan task" # Plan only, no execution
275
+ blade --permissionMode acceptEdits --print "Modify code" # Auto-accept edits
276
+
277
+ # Add allowed directories
278
+ blade --addDir /path/to/dir --print "Access directory"
279
+ ```
280
+
281
+ ### IDE Integration
282
+
283
+ ```bash
284
+ # Auto-connect to IDE on startup
285
+ blade --ide
286
+ ```
287
+
288
+ ### Configuration Files
289
+
290
+ ```bash
291
+ # Use settings file
292
+ blade --settings settings.json
293
+
294
+ # Specify config sources
295
+ blade --settingSources "global,user,local"
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 📚 Command Reference
301
+
302
+ ### Main Commands
303
+
304
+ | Command | Description | Example |
305
+ |---------|-------------|---------|
306
+ | `blade [message..]` | Send message or launch interactive mode (default) | `blade "Hello"` |
307
+ | `blade config` | Configuration management | `blade config` |
308
+ | `blade mcp` | Configure and manage MCP servers | `blade mcp` |
309
+ | `blade doctor` | System health check | `blade doctor` |
310
+ | `blade update` | Check and install updates | `blade update` |
311
+ | `blade install [target]` | Install specific version (stable/latest/version) | `blade install latest` |
312
+ | `blade setup-token` | Set up authentication token | `blade setup-token` |
313
+ | `blade completion` | Generate shell completion script | `blade completion` |
314
+
315
+ ### Debug Options
316
+
317
+ | Option | Short | Description |
318
+ |--------|-------|-------------|
319
+ | `--debug [category]` | `-d` | Enable debug mode with optional category filtering |
320
+ | `--verbose` | | Enable verbose output mode |
321
+
322
+ ### Output Options
323
+
324
+ | Option | Short | Description |
325
+ |--------|-------|-------------|
326
+ | `--print` | `-p` | Print response and exit (for piping) |
327
+ | `--outputFormat <format>` | | Output format: text/json/stream-json (with --print only) |
328
+ | `--includePartialMessages` | | Include partial message chunks |
329
+
330
+ ### Input Options
331
+
332
+ | Option | Description |
333
+ |--------|-------------|
334
+ | `--inputFormat <format>` | Input format: text/stream-json |
335
+ | `--replayUserMessages` | Re-emit user messages from stdin |
336
+
337
+ ### Security Options
338
+
339
+ | Option | Description |
340
+ |--------|-------------|
341
+ | `--dangerouslySkipPermissions` | Skip all permission checks (dangerous) |
342
+ | `--allowedTools <tools>` | Allowed tools list (comma or space separated) |
343
+ | `--disallowedTools <tools>` | Disallowed tools list (comma or space separated) |
344
+ | `--permissionMode <mode>` | Permission mode: acceptEdits/bypassPermissions/default/plan |
345
+ | `--addDir <dirs>` | Additional directories for tool access |
346
+
347
+ ### MCP Options
348
+
349
+ | Option | Description |
350
+ |--------|-------------|
351
+ | `--mcpConfig <files>` | Load MCP servers from JSON files or strings |
352
+ | `--strictMcpConfig` | Only use servers from --mcpConfig |
353
+
354
+ ### AI Options
355
+
356
+ | Option | Description |
357
+ |--------|-------------|
358
+ | `--appendSystemPrompt <text>` | Append system prompt to default |
359
+ | `--model <name>` | Model for current session |
360
+ | `--fallbackModel <name>` | Enable automatic fallback to specified model |
361
+ | `--agents <json>` | Custom agent configuration JSON |
362
+
363
+ ### Session Options
364
+
365
+ | Option | Short | Description |
366
+ |--------|-------|-------------|
367
+ | `--continue` | `-c` | Continue recent session |
368
+ | `--resume <id>` | `-r` | Resume specific session |
369
+ | `--forkSession` | | Create new session ID when resuming |
370
+ | `--sessionId <id>` | | Use specific session ID |
371
+
372
+ ### Configuration Options
373
+
374
+ | Option | Description |
375
+ |--------|-------------|
376
+ | `--settings <path>` | Settings JSON file path or JSON string |
377
+ | `--settingSources <sources>` | Setting sources to load (comma separated) |
378
+
379
+ ### Integration Options
380
+
381
+ | Option | Description |
382
+ |--------|-------------|
383
+ | `--ide` | Auto-connect to IDE on startup |
384
+
385
+ ### Other Options
386
+
387
+ | Option | Short | Description |
388
+ |--------|-------|-------------|
389
+ | `--help` | `-h` | Show help |
390
+ | `--version` | `-V` | Show version number |
391
+
392
+ ---
393
+
394
+ ## đŸ—ī¸ Technical Architecture
395
+
396
+ Blade Code features a modern flat architecture design:
397
+
398
+ ```
399
+ src/
400
+ ├── agent/ # Agent core logic
401
+ ├── cli/ # CLI config and middleware
402
+ ├── commands/ # Command handlers
403
+ ├── config/ # Configuration management
404
+ ├── tools/ # Tool system
405
+ ├── ui/ # UI components (Ink-based)
406
+ ├── services/ # Shared services
407
+ └── utils/ # Utility functions
408
+ ```
409
+
410
+ ### Core Features
411
+
412
+ - 🚀 **Lightning Fast**: Built with Bun for exceptional performance
413
+ - đŸ“Ļ **Single File Deploy**: Build output ~1MB only
414
+ - 🎨 **React for CLI**: Modern UI powered by Ink
415
+ - 🔧 **TypeScript**: Full type support
416
+ - ✅ **Comprehensive Testing**: Unit, integration, and E2E test coverage
417
+
418
+ ---
419
+
420
+ ## 🔨 Development Guide
421
+
422
+ ### Requirements
423
+
424
+ - Node.js >= 16.0.0
425
+ - pnpm (recommended) or npm
426
+
427
+ ### Clone Project
428
+
429
+ ```bash
430
+ git clone https://github.com/echoVic/blade-code.git
431
+ cd blade-code
432
+ pnpm install
433
+ ```
434
+
435
+ ### Development Commands
436
+
437
+ ```bash
438
+ # Development mode (hot reload)
439
+ pnpm dev
440
+
441
+ # Build
442
+ pnpm build
443
+
444
+ # Run tests
445
+ pnpm test
446
+
447
+ # Test coverage
448
+ pnpm test:coverage
449
+
450
+ # Code linting
451
+ pnpm check:fix
452
+
453
+ # Type checking
454
+ pnpm type-check
455
+ ```
456
+
457
+ ### Project Structure
458
+
459
+ ```
460
+ blade-code/
461
+ ├── src/ # Source code
462
+ ├── tests/ # Test files
463
+ ├── dist/ # Build output
464
+ ├── scripts/ # Build scripts
465
+ └── docs/ # Documentation
466
+ ```
467
+
468
+ ---
469
+
470
+ ## 🤝 Contributing
471
+
472
+ We welcome all forms of contributions!
473
+
474
+ - 🐛 [Report Bug](https://github.com/echoVic/blade-code/issues/new?template=bug_report.md)
475
+ - 💡 [Feature Request](https://github.com/echoVic/blade-code/issues/new?template=feature_request.md)
476
+ - 📖 [Improve Documentation](https://github.com/echoVic/blade-code/pulls)
477
+ - 🔧 [Submit Code](CONTRIBUTING.md)
478
+
479
+ ### Contribution Process
480
+
481
+ 1. Fork this repository
482
+ 2. Create feature branch (`git checkout -b feature/AmazingFeature`)
483
+ 3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
484
+ 4. Push to branch (`git push origin feature/AmazingFeature`)
485
+ 5. Open Pull Request
486
+
487
+ See [Contributing Guide](CONTRIBUTING.md) for details.
488
+
489
+ ---
490
+
491
+ ## 📄 License
492
+
493
+ This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details.
494
+
495
+ ---
496
+
497
+ ## 🙏 Acknowledgments
498
+
499
+ Blade Code is built upon these excellent open-source projects:
500
+
501
+ - [Ink](https://github.com/vadimdemedes/ink) - React for CLI
502
+ - [OpenAI](https://github.com/openai/openai-node) - OpenAI API client
503
+ - [Biome](https://github.com/biomejs/biome) - Code formatting and linting
504
+ - [Vitest](https://github.com/vitest-dev/vitest) - Testing framework
505
+ - [Bun](https://github.com/oven-sh/bun) - Fast build tool
506
+
507
+ ---
508
+
509
+ ## 📞 Contact
510
+
511
+ - **Author**: echoVic
512
+ - **Homepage**: [https://github.com/echoVic/blade-code](https://github.com/echoVic/blade-code)
513
+ - **Issue Tracker**: [GitHub Issues](https://github.com/echoVic/blade-code/issues)
514
+
515
+ ---
516
+
517
+ ## 🌟 Star History
518
+
519
+ If Blade Code helps you, please give us a â­ī¸ Star!
520
+
521
+ [![Star History Chart](https://api.star-history.com/svg?repos=echoVic/blade-code&type=Date)](https://star-history.com/#echoVic/blade-code&Date)
522
+
523
+ ---
524
+
525
+ <div align="center">
526
+
527
+ **đŸ—Ąī¸ Blade Code - Make AI Your Command Line Companion!**
528
+
529
+ Made with â¤ī¸ by [echoVic](https://github.com/echoVic)
530
+
531
+ </div>