blade-code 0.0.9 → 0.0.11

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.
package/README.en.md CHANGED
@@ -21,7 +21,7 @@ English | [简体中文](README.md)
21
21
  <tr>
22
22
  <td width="50%" valign="top">
23
23
  <h3>🤖 Intelligent Conversations</h3>
24
- <p>Natural language interactions powered by LLMs with context understanding and multi-turn dialogues</p>
24
+ <p>Natural language interactions powered by LLMs with context understanding and multi-turn dialogues. Simply run <code>blade "task"</code> to launch the UI and auto-send your first message.</p>
25
25
  </td>
26
26
  <td width="50%" valign="top">
27
27
  <h3>🛠️ Rich Toolset</h3>
@@ -92,6 +92,8 @@ blade
92
92
  blade --print "Hello, introduce yourself"
93
93
  ```
94
94
 
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.
96
+
95
97
  ---
96
98
 
97
99
  ## 🔐 Configure API Keys
@@ -110,20 +112,29 @@ export VOLCENGINE_API_KEY="your-volcengine-api-key"
110
112
  export BLADE_BASE_URL="https://ark.cn-beijing.volces.com/api/v3"
111
113
  ```
112
114
 
113
- ### Method 2: Command Line Arguments
115
+ ### Method 2: First-Run Setup Wizard (Recommended Experience)
116
+
117
+ ```bash
118
+ blade
119
+ # If no API key is configured, an interactive wizard will guide you through Provider, Base URL, API Key, and model setup.
120
+ ```
121
+
122
+ ### Method 3: Command Line Arguments
114
123
 
115
124
  ```bash
116
- blade --print "Hello" # Uses configured API key
125
+ blade --api-key your-api-key --base-url https://api.example.com "Hello"
117
126
  ```
118
127
 
119
- ### Method 3: Configuration File
128
+ ### Method 4: Configuration File
120
129
 
121
130
  ```bash
122
- # Copy example config
123
- cp config.env.example .env
131
+ # User-level configuration
132
+ mkdir -p ~/.blade
133
+ nano ~/.blade/config.json
124
134
 
125
- # Edit .env file with your credentials
126
- nano .env
135
+ # Project-level configuration
136
+ mkdir -p .blade
137
+ nano .blade/config.json
127
138
  ```
128
139
 
129
140
  ### Get API Keys
@@ -141,25 +152,30 @@ nano .env
141
152
  # Interactive mode (default)
142
153
  blade
143
154
 
144
- # Direct message (with --print for non-interactive)
145
- blade --print "What is artificial intelligence?"
155
+ # Direct message (automatically sent once the UI is ready)
156
+ blade "What is artificial intelligence?"
146
157
 
147
158
  # Code generation
148
- blade --print "Write a debounce function in JavaScript"
159
+ blade "Write a debounce function in JavaScript"
160
+
161
+ # Non-interactive quick answer
162
+ blade --print "Summarize the repo in one sentence"
149
163
  ```
150
164
 
165
+ > Any message passed as `blade "..."` is automatically injected and executed once the interactive UI finishes initializing—no extra keystrokes required.
166
+
151
167
  ### Smart Tool Invocation
152
168
 
153
169
  Blade Code automatically selects appropriate tools based on your needs:
154
170
 
155
171
  ```bash
156
172
  # File operations
157
- blade --print "List all TypeScript files in the current directory"
173
+ blade "List all TypeScript files in the current directory"
158
174
 
159
175
  # Git operations
160
- blade --print "Show the last 5 commit logs"
176
+ blade "Show the last 5 commit logs"
161
177
 
162
- # Code review
178
+ # Code review (non-interactive example)
163
179
  blade --print "Review code quality in src/utils directory"
164
180
  ```
165
181
 
@@ -167,7 +183,7 @@ blade --print "Review code quality in src/utils directory"
167
183
 
168
184
  ```bash
169
185
  # Create or use named session
170
- blade --sessionId "project-alpha" "Start new project"
186
+ blade --session-id "project-alpha" "Start new project"
171
187
 
172
188
  # Continue recent session
173
189
  blade --continue
@@ -176,7 +192,7 @@ blade --continue
176
192
  blade --resume <conversation-id>
177
193
 
178
194
  # Fork session (create new session from existing)
179
- blade --resume <id> --forkSession
195
+ blade --resume <id> --fork-session
180
196
  ```
181
197
 
182
198
  ### Print Mode
@@ -188,23 +204,23 @@ Perfect for piping and scripting:
188
204
  blade --print "Generate a README template" > README.md
189
205
 
190
206
  # Specify output format
191
- blade --print --outputFormat json "Get project info"
207
+ blade --print --output-format json "Get project info"
192
208
 
193
209
  # Stream JSON output
194
- blade --print --outputFormat stream-json "Analyze code"
210
+ blade --print --output-format stream-json "Analyze code"
195
211
  ```
196
212
 
197
213
  ### Input/Output Options
198
214
 
199
215
  ```bash
200
216
  # Read from stdin (stream JSON format)
201
- cat input.json | blade --inputFormat stream-json --print
217
+ cat input.json | blade --input-format stream-json --print
202
218
 
203
219
  # Include partial message chunks
204
- blade --print --includePartialMessages "Generate long text"
220
+ blade --print --include-partial-messages "Generate long text"
205
221
 
206
222
  # Replay user messages
207
- blade --replayUserMessages < input.txt
223
+ blade --replay-user-messages < input.txt
208
224
  ```
209
225
 
210
226
  ---
@@ -220,10 +236,10 @@ Model Context Protocol allows integration of external tools and resources:
220
236
  blade mcp
221
237
 
222
238
  # Load MCP config from JSON file
223
- blade --mcpConfig config.json "Use external tools"
239
+ blade --mcp-config config.json "Use external tools"
224
240
 
225
241
  # Strict mode (only use specified MCP config)
226
- blade --mcpConfig config.json --strictMcpConfig "Query"
242
+ blade --mcp-config config.json --strict-mcp-config "Query"
227
243
  ```
228
244
 
229
245
  ### Configuration Management
@@ -249,10 +265,13 @@ blade setup-token
249
265
  blade --model qwen-max --print "Complex question"
250
266
 
251
267
  # Set fallback model
252
- blade --fallbackModel qwen-turbo --print "Question"
268
+ blade --fallback-model qwen-turbo --print "Question"
253
269
 
254
270
  # Custom system prompt
255
- blade --appendSystemPrompt "You are a senior architect" --print "Design microservices architecture"
271
+ blade --append-system-prompt "You are a senior architect" --print "Design microservices architecture"
272
+
273
+ # Replace default system prompt entirely
274
+ blade --system-prompt "You are a TypeScript expert" --print "Explain decorators"
256
275
 
257
276
  # Custom agent config
258
277
  blade --agents '{"reviewer": {"model": "qwen-max"}}' --print "Review code"
@@ -260,22 +279,22 @@ blade --agents '{"reviewer": {"model": "qwen-max"}}' --print "Review code"
260
279
 
261
280
  ### Security & Permissions
262
281
 
263
- ```bash
264
- # Skip permission checks (dangerous)
265
- blade --dangerouslySkipPermissions --print "Execute command"
282
+ Blade ships with a three-tier permission system (`allow` / `ask` / `deny`). You can fine-tune runtime behavior with CLI flags:
266
283
 
284
+ ```bash
267
285
  # Allow specific tools only
268
- blade --allowedTools "read,write" --print "Handle files"
286
+ blade --allowed-tools "read,write" --print "Handle files"
269
287
 
270
288
  # Disallow specific tools
271
- blade --disallowedTools "bash,execute" --print "Safe operations"
289
+ blade --disallowed-tools "bash,execute" --print "Safe operations"
272
290
 
273
291
  # Permission modes
274
- blade --permissionMode plan --print "Plan task" # Plan only, no execution
275
- blade --permissionMode acceptEdits --print "Modify code" # Auto-accept edits
292
+ blade --permission-mode plan --print "Plan task" # Plan only, no execution
293
+ blade --permission-mode autoEdit --print "Modify code" # Auto-approve edits
294
+ blade --yolo --print "Run high-trust operations" # Approve every tool call
276
295
 
277
296
  # Add allowed directories
278
- blade --addDir /path/to/dir --print "Access directory"
297
+ blade --add-dir /path/to/dir --print "Access directory"
279
298
  ```
280
299
 
281
300
  ### IDE Integration
@@ -292,7 +311,7 @@ blade --ide
292
311
  blade --settings settings.json
293
312
 
294
313
  # Specify config sources
295
- blade --settingSources "global,user,local"
314
+ blade --setting-sources "global,user,local"
296
315
  ```
297
316
 
298
317
  ---
@@ -324,40 +343,41 @@ blade --settingSources "global,user,local"
324
343
  | Option | Short | Description |
325
344
  |--------|-------|-------------|
326
345
  | `--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 |
346
+ | `--output-format <format>` | | Output format: text/json/stream-json (with --print only) |
347
+ | `--include-partial-messages` | | Include partial message chunks |
329
348
 
330
349
  ### Input Options
331
350
 
332
351
  | Option | Description |
333
352
  |--------|-------------|
334
- | `--inputFormat <format>` | Input format: text/stream-json |
335
- | `--replayUserMessages` | Re-emit user messages from stdin |
353
+ | `--input-format <format>` | Input format: text/stream-json |
354
+ | `--replay-user-messages` | Re-emit user messages from stdin |
336
355
 
337
356
  ### Security Options
338
357
 
339
358
  | Option | Description |
340
359
  |--------|-------------|
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 |
360
+ | `--allowed-tools <tools>` | Allowed tools list (comma or space separated) |
361
+ | `--disallowed-tools <tools>` | Disallowed tools list (comma or space separated) |
362
+ | `--permission-mode <mode>` | Permission mode: default/autoEdit/yolo/plan |
363
+ | `--yolo` | Shortcut for `--permission-mode yolo` |
364
+ | `--add-dir <dirs>` | Additional directories for tool access |
346
365
 
347
366
  ### MCP Options
348
367
 
349
368
  | Option | Description |
350
369
  |--------|-------------|
351
- | `--mcpConfig <files>` | Load MCP servers from JSON files or strings |
352
- | `--strictMcpConfig` | Only use servers from --mcpConfig |
370
+ | `--mcp-config <files>` | Load MCP servers from JSON files or strings |
371
+ | `--strict-mcp-config` | Only use servers from --mcp-config |
353
372
 
354
373
  ### AI Options
355
374
 
356
375
  | Option | Description |
357
376
  |--------|-------------|
358
- | `--appendSystemPrompt <text>` | Append system prompt to default |
377
+ | `--append-system-prompt <text>` | Append system prompt to default |
378
+ | `--system-prompt <text>` | Replace default system prompt |
359
379
  | `--model <name>` | Model for current session |
360
- | `--fallbackModel <name>` | Enable automatic fallback to specified model |
380
+ | `--fallback-model <name>` | Enable automatic fallback to specified model |
361
381
  | `--agents <json>` | Custom agent configuration JSON |
362
382
 
363
383
  ### Session Options
@@ -366,15 +386,15 @@ blade --settingSources "global,user,local"
366
386
  |--------|-------|-------------|
367
387
  | `--continue` | `-c` | Continue recent session |
368
388
  | `--resume <id>` | `-r` | Resume specific session |
369
- | `--forkSession` | | Create new session ID when resuming |
370
- | `--sessionId <id>` | | Use specific session ID |
389
+ | `--fork-session` | | Create new session ID when resuming |
390
+ | `--session-id <id>` | | Use specific session ID |
371
391
 
372
392
  ### Configuration Options
373
393
 
374
394
  | Option | Description |
375
395
  |--------|-------------|
376
396
  | `--settings <path>` | Settings JSON file path or JSON string |
377
- | `--settingSources <sources>` | Setting sources to load (comma separated) |
397
+ | `--setting-sources <sources>` | Setting sources to load (comma separated) |
378
398
 
379
399
  ### Integration Options
380
400
 
package/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
  <tr>
22
22
  <td width="50%" valign="top">
23
23
  <h3>🤖 智能对话</h3>
24
- <p>基于大语言模型的自然语言交互,支持上下文理解和多轮对话</p>
24
+ <p>基于大语言模型的自然语言交互,支持上下文理解和多轮对话,直接运行 <code>blade "任务"</code> 即可自动进入界面并发送首条消息</p>
25
25
  </td>
26
26
  <td width="50%" valign="top">
27
27
  <h3>🛠️ 丰富工具</h3>
@@ -101,6 +101,8 @@ blade
101
101
  blade --print "你好,介绍一下自己"
102
102
  ```
103
103
 
104
+ > 首次运行若未检测到 API 密钥,会自动弹出终端设置向导,按提示填写 Provider / Base URL / API Key / 模型后即可继续使用。
105
+
104
106
  ---
105
107
 
106
108
  ## 🔐 配置 API 密钥
@@ -119,20 +121,31 @@ export VOLCENGINE_API_KEY="your-volcengine-api-key"
119
121
  export BLADE_BASE_URL="https://ark.cn-beijing.volces.com/api/v3"
120
122
  ```
121
123
 
122
- ### 方式二:命令行参数
124
+ ### 方式二:首启设置向导(推荐体验)
123
125
 
124
126
  ```bash
125
- blade --api-key your-api-key --base-url https://api.example.com "你好"
127
+ blade
128
+ # 若未配置 API Key,将自动引导完成 Provider、Base URL、API Key、模型的填写
126
129
  ```
127
130
 
128
- ### 方式三:配置文件
131
+ ### 方式三:命令行参数
129
132
 
130
133
  ```bash
131
- # 复制示例配置文件
132
- cp config.env.example .env
134
+ blade --api-key your-api-key --base-url https://api.example.com "你好"
135
+ ```
133
136
 
134
- # 编辑 .env 文件,填入您的配置
135
- nano .env
137
+ ### 方式四:配置文件
138
+
139
+ ```bash
140
+ # 用户级配置
141
+ mkdir -p ~/.blade
142
+ nano ~/.blade/config.json
143
+
144
+ # 项目级配置(提交到仓库)
145
+ mkdir -p .blade
146
+ nano .blade/config.json
147
+ # 或者为当前机器准备不提交的设置
148
+ nano .blade/settings.local.json
136
149
  ```
137
150
 
138
151
  ### 获取 API 密钥
@@ -150,7 +163,7 @@ nano .env
150
163
  # 交互式模式(默认)
151
164
  blade
152
165
 
153
- # 直接发送消息
166
+ # 直接发送消息(会在 UI 初始化后自动输入并执行)
154
167
  blade "什么是人工智能?"
155
168
 
156
169
  # 代码生成
@@ -176,7 +189,7 @@ blade "审查 src/utils 目录的代码质量"
176
189
 
177
190
  ```bash
178
191
  # 创建或使用命名会话
179
- blade --sessionId "project-alpha" "开始新项目"
192
+ blade --session-id "project-alpha" "开始新项目"
180
193
 
181
194
  # 继续最近的会话
182
195
  blade --continue
@@ -185,7 +198,7 @@ blade --continue
185
198
  blade --resume <conversation-id>
186
199
 
187
200
  # Fork 会话(从现有会话创建新会话)
188
- blade --resume <id> --forkSession
201
+ blade --resume <id> --fork-session
189
202
  ```
190
203
 
191
204
  ### 打印模式
@@ -197,23 +210,23 @@ blade --resume <id> --forkSession
197
210
  blade --print "生成一个 README 模板" > README.md
198
211
 
199
212
  # 指定输出格式
200
- blade --print --outputFormat json "获取项目信息"
213
+ blade --print --output-format json "获取项目信息"
201
214
 
202
215
  # 流式 JSON 输出
203
- blade --print --outputFormat stream-json "分析代码"
216
+ blade --print --output-format stream-json "分析代码"
204
217
  ```
205
218
 
206
219
  ### 输入/输出选项
207
220
 
208
221
  ```bash
209
222
  # 从标准输入读取(流式 JSON 格式)
210
- cat input.json | blade --inputFormat stream-json --print
223
+ cat input.json | blade --input-format stream-json --print
211
224
 
212
225
  # 包含部分消息块
213
- blade --print --includePartialMessages "长文本生成"
226
+ blade --print --include-partial-messages "长文本生成"
214
227
 
215
228
  # 重新发送用户消息
216
- blade --replayUserMessages < input.txt
229
+ blade --replay-user-messages < input.txt
217
230
  ```
218
231
 
219
232
  ---
@@ -229,10 +242,10 @@ Model Context Protocol 允许集成外部工具和资源:
229
242
  blade mcp
230
243
 
231
244
  # 从 JSON 文件加载 MCP 配置
232
- blade --mcpConfig config.json "使用外部工具"
245
+ blade --mcp-config config.json "使用外部工具"
233
246
 
234
247
  # 仅使用指定的 MCP 配置(严格模式)
235
- blade --mcpConfig config.json --strictMcpConfig "查询"
248
+ blade --mcp-config config.json --strict-mcp-config "查询"
236
249
  ```
237
250
 
238
251
  ### 配置管理
@@ -258,10 +271,13 @@ blade setup-token
258
271
  blade --model qwen-max "复杂的问题"
259
272
 
260
273
  # 设置回退模型
261
- blade --fallbackModel qwen-turbo "问题"
274
+ blade --fallback-model qwen-turbo "问题"
262
275
 
263
276
  # 自定义系统提示
264
- blade --appendSystemPrompt "你是一位资深架构师" "设计微服务架构"
277
+ blade --append-system-prompt "你是一位资深架构师" "设计微服务架构"
278
+
279
+ # 完全替换默认系统提示
280
+ blade --system-prompt "你是一位 TypeScript 专家" "解释装饰器"
265
281
 
266
282
  # 自定义 Agent 配置
267
283
  blade --agents '{"reviewer": {"model": "qwen-max"}}' "审查代码"
@@ -272,21 +288,19 @@ blade --agents '{"reviewer": {"model": "qwen-max"}}' "审查代码"
272
288
  Blade 提供强大的三级权限控制系统(allow/ask/deny):
273
289
 
274
290
  ```bash
275
- # 跳过权限检查(危险)
276
- blade --dangerouslySkipPermissions "执行命令"
277
-
278
291
  # 仅允许特定工具
279
- blade --allowedTools "read,write" "处理文件"
292
+ blade --allowed-tools "read,write" "处理文件"
280
293
 
281
294
  # 禁止特定工具
282
- blade --disallowedTools "bash,execute" "安全操作"
295
+ blade --disallowed-tools "bash,execute" "安全操作"
283
296
 
284
297
  # 权限模式
285
- blade --permissionMode plan "规划任务" # 仅规划不执行
286
- blade --permissionMode acceptEdits "修改代码" # 自动接受编辑
298
+ blade --permission-mode plan "规划任务" # 仅规划不执行
299
+ blade --permission-mode autoEdit "修改代码" # 自动接受编辑
300
+ blade --yolo "任意工具自动批准" # 开启 YOLO 模式
287
301
 
288
302
  # 添加允许访问的目录
289
- blade --addDir /path/to/dir "访问目录"
303
+ blade --add-dir /path/to/dir "访问目录"
290
304
  ```
291
305
 
292
306
  **权限配置示例** (`.blade/settings.json`):
@@ -327,7 +341,7 @@ blade --ide
327
341
  blade --settings settings.json
328
342
 
329
343
  # 指定配置源
330
- blade --settingSources "global,user,local"
344
+ blade --setting-sources "global,user,local"
331
345
  ```
332
346
 
333
347
  ---
@@ -359,40 +373,41 @@ blade --settingSources "global,user,local"
359
373
  | 选项 | 简写 | 说明 |
360
374
  |------|------|------|
361
375
  | `--print` | `-p` | 打印响应并退出(适合管道) |
362
- | `--outputFormat <format>` | | 输出格式:text/json/stream-json(仅与 --print 配合) |
363
- | `--includePartialMessages` | | 包含部分消息块 |
376
+ | `--output-format <format>` | | 输出格式:text/json/stream-json(仅与 --print 配合) |
377
+ | `--include-partial-messages` | | 包含部分消息块 |
364
378
 
365
379
  ### 输入选项
366
380
 
367
381
  | 选项 | 说明 |
368
382
  |------|------|
369
- | `--inputFormat <format>` | 输入格式:text/stream-json |
370
- | `--replayUserMessages` | 重新发送来自 stdin 的用户消息 |
383
+ | `--input-format <format>` | 输入格式:text/stream-json |
384
+ | `--replay-user-messages` | 重新发送来自 stdin 的用户消息 |
371
385
 
372
386
  ### 安全选项
373
387
 
374
388
  | 选项 | 说明 |
375
389
  |------|------|
376
- | `--dangerouslySkipPermissions` | 跳过所有权限检查(危险) |
377
- | `--allowedTools <tools>` | 允许的工具列表(逗号或空格分隔) |
378
- | `--disallowedTools <tools>` | 禁止的工具列表(逗号或空格分隔) |
379
- | `--permissionMode <mode>` | 权限模式:acceptEdits/bypassPermissions/default/plan |
380
- | `--addDir <dirs>` | 允许工具访问的额外目录 |
390
+ | `--allowed-tools <tools>` | 允许的工具列表(逗号或空格分隔) |
391
+ | `--disallowed-tools <tools>` | 禁止的工具列表(逗号或空格分隔) |
392
+ | `--permission-mode <mode>` | 权限模式:default/autoEdit/yolo/plan |
393
+ | `--yolo` | YOLO 模式快捷开关(等同于 `--permission-mode yolo`) |
394
+ | `--add-dir <dirs>` | 允许工具访问的额外目录 |
381
395
 
382
396
  ### MCP 选项
383
397
 
384
398
  | 选项 | 说明 |
385
399
  |------|------|
386
- | `--mcpConfig <files>` | 从 JSON 文件或字符串加载 MCP 服务器 |
387
- | `--strictMcpConfig` | 仅使用 --mcpConfig 指定的服务器 |
400
+ | `--mcp-config <files>` | 从 JSON 文件或字符串加载 MCP 服务器 |
401
+ | `--strict-mcp-config` | 仅使用 --mcp-config 指定的服务器 |
388
402
 
389
403
  ### AI 选项
390
404
 
391
405
  | 选项 | 说明 |
392
406
  |------|------|
393
- | `--appendSystemPrompt <text>` | 追加系统提示到默认提示 |
407
+ | `--append-system-prompt <text>` | 追加系统提示到默认提示 |
408
+ | `--system-prompt <text>` | 完全替换默认系统提示 |
394
409
  | `--model <name>` | 当前会话使用的模型 |
395
- | `--fallbackModel <name>` | 启用自动回退到指定模型 |
410
+ | `--fallback-model <name>` | 启用自动回退到指定模型 |
396
411
  | `--agents <json>` | 自定义 Agent 的 JSON 对象 |
397
412
 
398
413
  ### 会话选项
@@ -401,15 +416,15 @@ blade --settingSources "global,user,local"
401
416
  |------|------|------|
402
417
  | `--continue` | `-c` | 继续最近的会话 |
403
418
  | `--resume <id>` | `-r` | 恢复指定会话 |
404
- | `--forkSession` | | 恢复会话时创建新会话 ID |
405
- | `--sessionId <id>` | | 使用特定会话 ID |
419
+ | `--fork-session` | | 恢复会话时创建新会话 ID |
420
+ | `--session-id <id>` | | 使用特定会话 ID |
406
421
 
407
422
  ### 配置选项
408
423
 
409
424
  | 选项 | 说明 |
410
425
  |------|------|
411
426
  | `--settings <path>` | | 设置 JSON 文件路径或 JSON 字符串 |
412
- | `--settingSources <sources>` | | 要加载的设置源(逗号分隔) |
427
+ | `--setting-sources <sources>` | | 要加载的设置源(逗号分隔) |
413
428
 
414
429
  ### 集成选项
415
430