needware-cli 1.2.8 → 1.2.9
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/EXAMPLES.md +241 -0
- package/README.md +70 -5
- package/dist/commands/agent.d.ts +4 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +105 -6
- package/dist/commands/agent.js.map +1 -1
- package/dist/core/cli.js +1 -1
- package/dist/core/cli.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/prompt.d.ts +30 -0
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/types/prompt.js +5 -0
- package/dist/types/prompt.js.map +1 -0
- package/dist/utils/prompt-parser.d.ts +22 -0
- package/dist/utils/prompt-parser.d.ts.map +1 -0
- package/dist/utils/prompt-parser.js +148 -0
- package/dist/utils/prompt-parser.js.map +1 -0
- package/examples/sdk-message-example.json +10 -0
- package/install.sh +528 -0
- package/package.json +1 -1
- package/AGENT_COMMAND_SUMMARY.md +0 -364
- package/CHANGELOG.md +0 -172
- package/FEATURE_INTERACTIVE_MODE.md +0 -304
- package/INTERACTIVE_EXAMPLE.md +0 -306
- package/PROJECT_SUMMARY.md +0 -435
- package/QUICK_START.md +0 -216
- package/SETUP.md +0 -315
package/AGENT_COMMAND_SUMMARY.md
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
# Agent 命令实现总结
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
本次开发将 Next.js API 路由中的 Claude Agent SDK 集成代码封装成了 CLI 命令,使得可以通过命令行直接运行 AI Agent 任务。
|
|
6
|
-
|
|
7
|
-
## 实现内容
|
|
8
|
-
|
|
9
|
-
### 1. 核心文件
|
|
10
|
-
|
|
11
|
-
#### 新增文件
|
|
12
|
-
|
|
13
|
-
| 文件路径 | 说明 |
|
|
14
|
-
|---------|------|
|
|
15
|
-
| `src/commands/agent.ts` | Agent 命令实现(主要逻辑) |
|
|
16
|
-
| `docs/AGENT_COMMAND.md` | Agent 命令详细使用文档 |
|
|
17
|
-
| `docs/AGENT_QUICKSTART.md` | Agent 命令快速入门指南 |
|
|
18
|
-
| `AGENT_COMMAND_SUMMARY.md` | 本文档,变更总结 |
|
|
19
|
-
|
|
20
|
-
#### 修改文件
|
|
21
|
-
|
|
22
|
-
| 文件路径 | 修改内容 |
|
|
23
|
-
|---------|---------|
|
|
24
|
-
| `src/commands/index.ts` | 导出 `AgentCommand` 类 |
|
|
25
|
-
| `src/index.ts` | 导入并注册 `AgentCommand` |
|
|
26
|
-
| `src/core/cli.ts` | 为 agent 命令添加参数和选项支持 |
|
|
27
|
-
| `README.md` | 添加 agent 命令使用说明 |
|
|
28
|
-
|
|
29
|
-
### 2. 编译输出
|
|
30
|
-
|
|
31
|
-
编译后生成以下文件:
|
|
32
|
-
- `dist/commands/agent.js` - 编译后的 JavaScript 代码
|
|
33
|
-
- `dist/commands/agent.d.ts` - TypeScript 类型定义
|
|
34
|
-
- `dist/commands/agent.js.map` - Source Map
|
|
35
|
-
- `dist/commands/agent.d.ts.map` - 类型定义 Source Map
|
|
36
|
-
|
|
37
|
-
## 功能特性
|
|
38
|
-
|
|
39
|
-
### 1. 命令参数
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
needware-cli agent <prompt> [options]
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
- **必需参数**:
|
|
46
|
-
- `<prompt>`: AI 任务提示词
|
|
47
|
-
|
|
48
|
-
- **可选选项**:
|
|
49
|
-
- `--working-dir <path>`: 指定工作目录(默认:当前目录)
|
|
50
|
-
- `--additional-dirs <paths>`: 指定额外目录(逗号分隔)
|
|
51
|
-
- `-V, --verbose`: 详细输出模式
|
|
52
|
-
- `-q, --quiet`: 静默模式
|
|
53
|
-
|
|
54
|
-
### 2. 环境变量
|
|
55
|
-
|
|
56
|
-
- `ANTHROPIC_API_KEY`: **必需** - Anthropic API 密钥
|
|
57
|
-
- `ANTHROPIC_BASE_URL`: 可选 - 自定义 API 端点
|
|
58
|
-
|
|
59
|
-
### 3. 核心功能
|
|
60
|
-
|
|
61
|
-
1. **工作目录管理**
|
|
62
|
-
- 默认使用当前工作目录
|
|
63
|
-
- 支持通过 `--working-dir` 参数指定
|
|
64
|
-
- 自动解析为绝对路径
|
|
65
|
-
|
|
66
|
-
2. **提示词增强**
|
|
67
|
-
- 自动在用户提示词前添加工作目录上下文
|
|
68
|
-
- 确保 Agent 在正确的目录中操作
|
|
69
|
-
|
|
70
|
-
3. **流式输出**
|
|
71
|
-
- 实时显示 Agent 的执行过程
|
|
72
|
-
- 支持多种消息类型:
|
|
73
|
-
- `text`: 文本消息
|
|
74
|
-
- `tool_use`: 工具使用信息
|
|
75
|
-
- `tool_result`: 工具执行结果
|
|
76
|
-
- `thinking`: 思考过程
|
|
77
|
-
- `error`: 错误信息
|
|
78
|
-
|
|
79
|
-
4. **系统提示词**
|
|
80
|
-
- 内置针对 React + Vite + TypeScript + Tailwind CSS 的系统提示
|
|
81
|
-
- 包含最佳实践和开发规范
|
|
82
|
-
- 支持中英文交互
|
|
83
|
-
|
|
84
|
-
5. **错误处理**
|
|
85
|
-
- API Key 验证
|
|
86
|
-
- 工作目录验证
|
|
87
|
-
- 友好的错误提示
|
|
88
|
-
|
|
89
|
-
## 技术实现
|
|
90
|
-
|
|
91
|
-
### 1. 代码结构
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
export class AgentCommand extends Command {
|
|
95
|
-
readonly name = 'agent';
|
|
96
|
-
readonly description = 'Execute AI agent tasks using Claude Agent SDK';
|
|
97
|
-
readonly aliases = ['ag'];
|
|
98
|
-
|
|
99
|
-
async execute(options: CommandOptions): Promise<CommandResult> {
|
|
100
|
-
// 参数解析和验证
|
|
101
|
-
// 环境变量获取
|
|
102
|
-
// 工作目录处理
|
|
103
|
-
// Agent 查询执行
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private async runAgent(): Promise<CommandResult> {
|
|
107
|
-
// 提示词增强
|
|
108
|
-
// SDK 配置
|
|
109
|
-
// 流式输出处理
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private handleAgentMessage(message: any): void {
|
|
113
|
-
// 消息类型处理
|
|
114
|
-
// 格式化输出
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private getSystemPrompt(): string {
|
|
118
|
-
// 返回系统提示词
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 2. 与 CLI 框架集成
|
|
124
|
-
|
|
125
|
-
在 `src/core/cli.ts` 中为 agent 命令特殊处理:
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
if (command.name === 'agent') {
|
|
129
|
-
commandInstance
|
|
130
|
-
.argument('<prompt>', 'The task prompt for the AI agent')
|
|
131
|
-
.option('--working-dir <path>', 'Specify the working directory')
|
|
132
|
-
.option('--additional-dirs <paths>', 'Specify additional directories (comma-separated)');
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### 3. SDK 配置
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
query({
|
|
140
|
-
prompt: enhancedPrompt,
|
|
141
|
-
options: {
|
|
142
|
-
systemPrompt: this.getSystemPrompt(),
|
|
143
|
-
settingSources: ['project'],
|
|
144
|
-
model: 'claude-sonnet-4-5',
|
|
145
|
-
maxTurns: 30,
|
|
146
|
-
permissionMode: 'bypassPermissions',
|
|
147
|
-
cwd: resolvedWorkingDir,
|
|
148
|
-
additionalDirectories,
|
|
149
|
-
env: {
|
|
150
|
-
ANTHROPIC_API_KEY: apiKey,
|
|
151
|
-
ANTHROPIC_BASE_URL: baseUrl,
|
|
152
|
-
PATH: process.env.PATH,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
})
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## 使用示例
|
|
159
|
-
|
|
160
|
-
### 基本使用
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
# 配置 API Key
|
|
164
|
-
export ANTHROPIC_API_KEY="your_key"
|
|
165
|
-
|
|
166
|
-
# 在当前目录执行任务
|
|
167
|
-
needware-cli agent "创建一个待办事项应用"
|
|
168
|
-
|
|
169
|
-
# 指定工作目录
|
|
170
|
-
needware-cli agent "修复样式问题" --working-dir ./my-project
|
|
171
|
-
|
|
172
|
-
# 指定额外目录
|
|
173
|
-
needware-cli agent "重构代码" --additional-dirs ./shared,./utils
|
|
174
|
-
|
|
175
|
-
# 详细输出
|
|
176
|
-
needware-cli agent "优化性能" -V
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### 实际场景
|
|
180
|
-
|
|
181
|
-
1. **代码生成**
|
|
182
|
-
```bash
|
|
183
|
-
needware-cli agent "创建一个用户注册表单组件"
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
2. **代码审查**
|
|
187
|
-
```bash
|
|
188
|
-
needware-cli agent "审查这个项目的代码质量"
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
3. **Bug 修复**
|
|
192
|
-
```bash
|
|
193
|
-
needware-cli agent "修复登录表单验证问题"
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
4. **重构**
|
|
197
|
-
```bash
|
|
198
|
-
needware-cli agent "重构 utils 目录,使用 TypeScript"
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## 测试验证
|
|
202
|
-
|
|
203
|
-
### 编译测试
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
npm run build
|
|
207
|
-
# ✓ 编译成功,无错误
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### 命令测试
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
node bin/cli.js agent --help
|
|
214
|
-
# ✓ 正确显示帮助信息
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### 输出示例
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
🤖 启动 Claude Agent...
|
|
221
|
-
|
|
222
|
-
工作目录: /Users/user/project
|
|
223
|
-
提示词: 创建应用
|
|
224
|
-
|
|
225
|
-
✓ Agent 已启动
|
|
226
|
-
|
|
227
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
228
|
-
|
|
229
|
-
💭 思考中...
|
|
230
|
-
🔧 使用工具: write_file
|
|
231
|
-
✓ 工具执行成功
|
|
232
|
-
|
|
233
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
234
|
-
|
|
235
|
-
✓ Agent 执行完成
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## 文档
|
|
239
|
-
|
|
240
|
-
### 用户文档
|
|
241
|
-
|
|
242
|
-
1. **README.md**
|
|
243
|
-
- 添加 Agent 命令基本说明
|
|
244
|
-
- 更新命令列表
|
|
245
|
-
- 添加环境变量说明
|
|
246
|
-
|
|
247
|
-
2. **docs/AGENT_COMMAND.md**
|
|
248
|
-
- 完整的使用指南
|
|
249
|
-
- 参数说明
|
|
250
|
-
- 示例集合
|
|
251
|
-
- 故障排除
|
|
252
|
-
- 最佳实践
|
|
253
|
-
|
|
254
|
-
3. **docs/AGENT_QUICKSTART.md**
|
|
255
|
-
- 5 分钟快速入门
|
|
256
|
-
- 常见场景示例
|
|
257
|
-
- 问题解决
|
|
258
|
-
|
|
259
|
-
## 与原始代码的对比
|
|
260
|
-
|
|
261
|
-
### 原始代码(Next.js API 路由)
|
|
262
|
-
|
|
263
|
-
```typescript
|
|
264
|
-
// 通过 HTTP POST 接收请求
|
|
265
|
-
export async function POST(request: NextRequest) {
|
|
266
|
-
const { prompt, workingDirectory, additionalDirectories } = await request.json();
|
|
267
|
-
|
|
268
|
-
// 流式返回 SSE 格式数据
|
|
269
|
-
return new Response(stream.readable, {
|
|
270
|
-
headers: {
|
|
271
|
-
'Content-Type': 'text/event-stream',
|
|
272
|
-
...
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### 新实现(CLI 命令)
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
// 通过命令行参数接收
|
|
282
|
-
needware-cli agent <prompt> --working-dir <path>
|
|
283
|
-
|
|
284
|
-
// 直接输出到终端
|
|
285
|
-
console.log(chalk.green('✓ 工具执行成功'));
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### 主要差异
|
|
289
|
-
|
|
290
|
-
| 方面 | 原始代码 | CLI 命令 |
|
|
291
|
-
|------|---------|---------|
|
|
292
|
-
| 输入方式 | HTTP POST JSON | 命令行参数 |
|
|
293
|
-
| 输出格式 | SSE (Server-Sent Events) | 终端彩色输出 |
|
|
294
|
-
| 运行环境 | Next.js 服务器 | Node.js CLI |
|
|
295
|
-
| 交互方式 | 网页/API 客户端 | 命令行终端 |
|
|
296
|
-
| 工作目录 | 通过 POST body 传递 | 通过 CLI 选项传递 |
|
|
297
|
-
|
|
298
|
-
## 技术栈
|
|
299
|
-
|
|
300
|
-
- **TypeScript**: 类型安全的代码实现
|
|
301
|
-
- **Commander.js**: CLI 参数解析
|
|
302
|
-
- **Chalk**: 终端彩色输出
|
|
303
|
-
- **Ora**: 加载动画
|
|
304
|
-
- **@anthropic-ai/claude-agent-sdk**: AI Agent 核心功能
|
|
305
|
-
|
|
306
|
-
## 后续优化建议
|
|
307
|
-
|
|
308
|
-
### 1. 功能增强
|
|
309
|
-
|
|
310
|
-
- [ ] 添加配置文件支持(保存常用的工作目录和选项)
|
|
311
|
-
- [ ] 支持交互式提示词输入
|
|
312
|
-
- [ ] 添加历史记录功能
|
|
313
|
-
- [ ] 支持保存/加载会话
|
|
314
|
-
|
|
315
|
-
### 2. 用户体验
|
|
316
|
-
|
|
317
|
-
- [ ] 添加进度条显示
|
|
318
|
-
- [ ] 优化消息格式化输出
|
|
319
|
-
- [ ] 添加彩色语法高亮(代码输出)
|
|
320
|
-
- [ ] 支持 Markdown 渲染
|
|
321
|
-
|
|
322
|
-
### 3. 安全性
|
|
323
|
-
|
|
324
|
-
- [ ] 添加工作目录白名单
|
|
325
|
-
- [ ] 实现权限确认机制
|
|
326
|
-
- [ ] 添加操作审计日志
|
|
327
|
-
|
|
328
|
-
### 4. 测试
|
|
329
|
-
|
|
330
|
-
- [ ] 添加单元测试
|
|
331
|
-
- [ ] 添加集成测试
|
|
332
|
-
- [ ] 添加 E2E 测试
|
|
333
|
-
|
|
334
|
-
### 5. 文档
|
|
335
|
-
|
|
336
|
-
- [ ] 添加视频教程
|
|
337
|
-
- [ ] 更多使用示例
|
|
338
|
-
- [ ] FAQ 文档
|
|
339
|
-
|
|
340
|
-
## 总结
|
|
341
|
-
|
|
342
|
-
本次开发成功将 Next.js API 路由中的 Claude Agent SDK 集成逻辑封装为 CLI 命令,实现了以下目标:
|
|
343
|
-
|
|
344
|
-
✅ **功能完整**: 保留了原始代码的所有核心功能
|
|
345
|
-
✅ **易于使用**: 简洁的命令行界面,清晰的参数说明
|
|
346
|
-
✅ **文档完善**: 提供了详细的使用文档和快速入门指南
|
|
347
|
-
✅ **代码质量**: 通过 TypeScript 类型检查和 ESLint 验证
|
|
348
|
-
✅ **可扩展性**: 遵循项目架构,易于后续功能扩展
|
|
349
|
-
|
|
350
|
-
用户现在可以通过简单的命令行操作,在任何项目目录中使用 AI Agent 执行智能任务!
|
|
351
|
-
|
|
352
|
-
## 相关链接
|
|
353
|
-
|
|
354
|
-
- [Agent 命令详细文档](docs/AGENT_COMMAND.md)
|
|
355
|
-
- [快速入门指南](docs/AGENT_QUICKSTART.md)
|
|
356
|
-
- [项目架构文档](ARCHITECTURE.md)
|
|
357
|
-
- [主 README](README.md)
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
**开发完成时间**: 2025-10-16
|
|
362
|
-
**版本**: 1.0.0
|
|
363
|
-
**状态**: ✅ 已完成并测试通过
|
|
364
|
-
|
package/CHANGELOG.md
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.0.8] - 2025-10-19
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
- 🐛 **容器临时目录修复** - 修改 TMPDIR 环境变量为 `/app`,解决容器环境下临时文件权限问题
|
|
12
|
-
|
|
13
|
-
## [1.0.0] - 2025-10-16
|
|
14
|
-
|
|
15
|
-
### Added
|
|
16
|
-
|
|
17
|
-
#### Core Features
|
|
18
|
-
- ✅ CLI 主类实现 - 命令行程序核心框架
|
|
19
|
-
- ✅ 命令基类 - 统一的命令接口和生命周期管理
|
|
20
|
-
- ✅ 日志系统 - 多级日志和文件持久化支持
|
|
21
|
-
- ✅ 配置管理 - 支持多层配置(默认、用户、环境变量)
|
|
22
|
-
|
|
23
|
-
#### Commands
|
|
24
|
-
- ✅ `init` 命令 - 交互式初始化项目配置
|
|
25
|
-
- ✅ `config` 命令 - 配置管理(查看/设置/重置)
|
|
26
|
-
- ✅ `example` 命令 - SDK 调用示例
|
|
27
|
-
|
|
28
|
-
#### SDK Integration
|
|
29
|
-
- ✅ SDK 基类 - 统一的 SDK 接口规范
|
|
30
|
-
- ✅ SDK 管理器 - 集中管理和初始化 SDK
|
|
31
|
-
- ✅ Example SDK - 示例 SDK 实现
|
|
32
|
-
|
|
33
|
-
#### Utilities
|
|
34
|
-
- ✅ 文件工具 - 文件读写和路径处理
|
|
35
|
-
- ✅ 验证工具 - 输入验证和格式检查
|
|
36
|
-
- ✅ 配置工具 - 配置文件读写和合并
|
|
37
|
-
|
|
38
|
-
#### Development Tools
|
|
39
|
-
- ✅ TypeScript 支持 - 完整的类型定义
|
|
40
|
-
- ✅ ESLint 配置 - 代码质量检查
|
|
41
|
-
- ✅ Prettier 配置 - 代码格式化
|
|
42
|
-
- ✅ Jest 测试框架 - 单元测试支持
|
|
43
|
-
|
|
44
|
-
#### Documentation
|
|
45
|
-
- ✅ 架构文档 - 详细的系统设计说明
|
|
46
|
-
- ✅ README - 使用说明和快速开始
|
|
47
|
-
- ✅ 配置示例 - 默认配置文件
|
|
48
|
-
|
|
49
|
-
### Features
|
|
50
|
-
|
|
51
|
-
- 🎨 彩色终端输出
|
|
52
|
-
- 🔄 交互式命令行提示
|
|
53
|
-
- 📝 结构化日志记录
|
|
54
|
-
- ⚙️ 灵活的配置系统
|
|
55
|
-
- 🔌 可扩展的 SDK 架构
|
|
56
|
-
- ✅ 完善的错误处理
|
|
57
|
-
- 🚀 模块化设计
|
|
58
|
-
|
|
59
|
-
### Technical
|
|
60
|
-
|
|
61
|
-
- Node.js >= 18.0.0 支持
|
|
62
|
-
- TypeScript 5.x
|
|
63
|
-
- Commander.js 用于命令行解析
|
|
64
|
-
- Inquirer.js 用于交互式提示
|
|
65
|
-
- Chalk 用于彩色输出
|
|
66
|
-
- Ora 用于加载动画
|
|
67
|
-
- Axios 用于 HTTP 请求
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## [1.0.5] - 2025-10-19
|
|
72
|
-
|
|
73
|
-
### Added
|
|
74
|
-
- ✅ **工作目录验证** - 添加 `validateWorkingDirectory()` 函数,在启动 agent 前验证目录是否存在和可访问
|
|
75
|
-
- 📊 **详细错误信息** - agent 执行失败时显示完整的错误堆栈、错误代码和 stdout/stderr 输出
|
|
76
|
-
- 💡 **解决方案提示** - 提供针对常见错误的解决方案建议
|
|
77
|
-
|
|
78
|
-
### Improved
|
|
79
|
-
- 🎯 **用户体验** - 更友好的错误提示,帮助用户快速定位和解决问题
|
|
80
|
-
- 🔍 **错误诊断** - 增强错误处理,捕获并显示更多上下文信息
|
|
81
|
-
|
|
82
|
-
### Technical
|
|
83
|
-
- 🛠️ **导入 fs 模块** - 用于文件系统操作和权限检查
|
|
84
|
-
- 🔒 **权限检查** - 使用 `fs.accessSync()` 验证目录的读写权限
|
|
85
|
-
- 📝 **错误对象扩展** - 检查并显示错误对象的 code、stderr、stdout 等属性
|
|
86
|
-
|
|
87
|
-
## [1.0.4] - 2025-10-19
|
|
88
|
-
|
|
89
|
-
### Fixed
|
|
90
|
-
- 🐛 **CLI 参数解析修复** - 修复命令行参数(--api-key, --base-url)无法正确传递的问题
|
|
91
|
-
- ✅ **Commander.js 集成** - 正确使用 `commandObject.opts()` 提取命令选项,而不是直接使用 Command 对象
|
|
92
|
-
|
|
93
|
-
## [1.0.3] - 2025-10-19
|
|
94
|
-
|
|
95
|
-
### Fixed
|
|
96
|
-
- 🐛 **Agent 命令错误修复** - 修复当未提供 API Key 时的 `Cannot read properties of undefined (reading 'substring')` 错误
|
|
97
|
-
- ✅ **参数验证** - 添加 API Key 和 Base URL 的存在性检查
|
|
98
|
-
- 💬 **错误提示** - 当缺少 API Key 时显示友好的警告信息
|
|
99
|
-
|
|
100
|
-
## [Unreleased]
|
|
101
|
-
|
|
102
|
-
### Added
|
|
103
|
-
|
|
104
|
-
#### Agent Command - Interactive Mode
|
|
105
|
-
- 🔄 **多轮对话支持** - 支持交互式对话模式,可持续与 AI 进行多轮交互
|
|
106
|
-
- 💬 **上下文记忆** - AI 记住对话历史,提供更连贯的回答
|
|
107
|
-
- 🎯 **灵活启动** - 支持带初始提示或直接启动交互模式
|
|
108
|
-
- 📝 **会话管理** - 每个交互会话拥有独立的 session ID
|
|
109
|
-
- 🚪 **优雅退出** - 输入 `exit` 或 `quit` 随时退出对话
|
|
110
|
-
- ⚙️ **扩展配置** - 支持更多轮次(100轮),适应复杂任务
|
|
111
|
-
|
|
112
|
-
**使用方式:**
|
|
113
|
-
```bash
|
|
114
|
-
# 直接进入交互模式
|
|
115
|
-
needware-cli agent --interactive
|
|
116
|
-
needware-cli agent -i
|
|
117
|
-
|
|
118
|
-
# 带初始提示启动
|
|
119
|
-
needware-cli agent -i "创建一个待办事项应用"
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**文档:**
|
|
123
|
-
- [交互式模式详细文档](docs/INTERACTIVE_MODE.md)
|
|
124
|
-
- [使用示例](INTERACTIVE_EXAMPLE.md)
|
|
125
|
-
|
|
126
|
-
### Changed
|
|
127
|
-
- 📋 **Agent 命令参数** - `prompt` 参数改为可选,交互模式下不再必需
|
|
128
|
-
- 🔧 **CLI 配置** - 添加 `-i, --interactive` 选项支持
|
|
129
|
-
- 📖 **帮助文档** - 更新帮助信息,包含交互模式说明
|
|
130
|
-
|
|
131
|
-
### Technical
|
|
132
|
-
- 🛠️ **AsyncGenerator 实现** - 使用异步生成器实现消息流
|
|
133
|
-
- 🔗 **SDK 类型增强** - 引入 `SDKUserMessage` 类型支持
|
|
134
|
-
- 💾 **会话 ID 生成** - 使用 `crypto.randomUUID()` 生成唯一会话标识
|
|
135
|
-
|
|
136
|
-
### Planned
|
|
137
|
-
|
|
138
|
-
#### Short-term (1-3 months)
|
|
139
|
-
- [ ] 更多内置命令
|
|
140
|
-
- [ ] 完善测试覆盖
|
|
141
|
-
- [ ] 性能优化
|
|
142
|
-
- [ ] 更多 SDK 集成示例
|
|
143
|
-
|
|
144
|
-
#### Mid-term (3-6 months)
|
|
145
|
-
- [ ] 插件系统
|
|
146
|
-
- [ ] 多语言支持(i18n)
|
|
147
|
-
- [ ] 自动更新机制
|
|
148
|
-
- [ ] 配置迁移工具
|
|
149
|
-
|
|
150
|
-
#### Long-term (6-12 months)
|
|
151
|
-
- [ ] 可视化界面
|
|
152
|
-
- [ ] 云端集成
|
|
153
|
-
- [ ] 社区插件市场
|
|
154
|
-
- [ ] 企业级功能
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## Version History
|
|
159
|
-
|
|
160
|
-
### [1.0.0] - 2025-10-16
|
|
161
|
-
- Initial release
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
**Legend:**
|
|
166
|
-
- `Added` for new features
|
|
167
|
-
- `Changed` for changes in existing functionality
|
|
168
|
-
- `Deprecated` for soon-to-be removed features
|
|
169
|
-
- `Removed` for now removed features
|
|
170
|
-
- `Fixed` for any bug fixes
|
|
171
|
-
- `Security` in case of vulnerabilities
|
|
172
|
-
|