needware-cli 1.5.15 → 1.5.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 (73) hide show
  1. package/README.md +49 -1
  2. package/dist/commands/agent.d.ts +12 -0
  3. package/dist/commands/agent.d.ts.map +1 -1
  4. package/dist/commands/agent.js +133 -7
  5. package/dist/commands/agent.js.map +1 -1
  6. package/dist/commands/index.d.ts +1 -1
  7. package/dist/commands/index.d.ts.map +1 -1
  8. package/dist/commands/index.js +1 -1
  9. package/dist/commands/index.js.map +1 -1
  10. package/dist/commands/skill.d.ts +34 -0
  11. package/dist/commands/skill.d.ts.map +1 -0
  12. package/dist/commands/skill.js +307 -0
  13. package/dist/commands/skill.js.map +1 -0
  14. package/dist/commands/system-prompt.d.ts +2 -1
  15. package/dist/commands/system-prompt.d.ts.map +1 -1
  16. package/dist/commands/system-prompt.js +12 -9
  17. package/dist/commands/system-prompt.js.map +1 -1
  18. package/dist/core/cli.d.ts.map +1 -1
  19. package/dist/core/cli.js +8 -1
  20. package/dist/core/cli.js.map +1 -1
  21. package/dist/index.js +4 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/sdk/firecrawl-sdk.d.ts +85 -0
  24. package/dist/sdk/firecrawl-sdk.d.ts.map +1 -0
  25. package/dist/sdk/firecrawl-sdk.js +207 -0
  26. package/dist/sdk/firecrawl-sdk.js.map +1 -0
  27. package/dist/tools/ai-gateway-enable-tool.d.ts +12 -0
  28. package/dist/tools/ai-gateway-enable-tool.d.ts.map +1 -0
  29. package/dist/tools/ai-gateway-enable-tool.js +33 -0
  30. package/dist/tools/ai-gateway-enable-tool.js.map +1 -0
  31. package/dist/tools/base-tool.d.ts +76 -0
  32. package/dist/tools/base-tool.d.ts.map +1 -0
  33. package/dist/tools/base-tool.js +119 -0
  34. package/dist/tools/base-tool.js.map +1 -0
  35. package/dist/tools/example-tool.d.ts +16 -0
  36. package/dist/tools/example-tool.d.ts.map +1 -0
  37. package/dist/tools/example-tool.js +67 -0
  38. package/dist/tools/example-tool.js.map +1 -0
  39. package/dist/tools/index.d.ts +9 -0
  40. package/dist/tools/index.d.ts.map +1 -0
  41. package/dist/tools/index.js +9 -0
  42. package/dist/tools/index.js.map +1 -0
  43. package/dist/tools/supabase-deploy-functions-tool.d.ts +18 -0
  44. package/dist/tools/supabase-deploy-functions-tool.d.ts.map +1 -0
  45. package/dist/tools/supabase-deploy-functions-tool.js +127 -0
  46. package/dist/tools/supabase-deploy-functions-tool.js.map +1 -0
  47. package/dist/tools/supabase-enable-tool.d.ts +12 -0
  48. package/dist/tools/supabase-enable-tool.d.ts.map +1 -0
  49. package/dist/tools/supabase-enable-tool.js +89 -0
  50. package/dist/tools/supabase-enable-tool.js.map +1 -0
  51. package/dist/tools/tool-registry.d.ts +51 -0
  52. package/dist/tools/tool-registry.d.ts.map +1 -0
  53. package/dist/tools/tool-registry.js +81 -0
  54. package/dist/tools/tool-registry.js.map +1 -0
  55. package/dist/tools/user-registration-tool.d.ts +17 -0
  56. package/dist/tools/user-registration-tool.d.ts.map +1 -0
  57. package/dist/tools/user-registration-tool.js +63 -0
  58. package/dist/tools/user-registration-tool.js.map +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/index.js +1 -0
  62. package/dist/types/index.js.map +1 -1
  63. package/dist/types/tool.d.ts +60 -0
  64. package/dist/types/tool.d.ts.map +1 -0
  65. package/dist/types/tool.js +5 -0
  66. package/dist/types/tool.js.map +1 -0
  67. package/examples/gateway-config-usage.sh +71 -0
  68. package/examples/tool-usage-example.sh +44 -0
  69. package/package.json +2 -2
  70. package/skills/ai-integration/SKILL.md +793 -0
  71. package/skills/supabase-integration/SKILL.md +556 -0
  72. package/CHANGELOG_DB_CONFIG.md +0 -142
  73. package/IMPLEMENTATION_SUMMARY.md +0 -303
@@ -1,303 +0,0 @@
1
- # 数据库配置功能实现总结
2
-
3
- ## 📋 概述
4
-
5
- 成功实现了数据库配置通过命令行以 JSON 格式传入的功能,不再需要在代码中硬编码数据库配置信息。
6
-
7
- ## ✅ 完成的工作
8
-
9
- ### 1. 核心功能实现
10
-
11
- #### 修改的文件
12
-
13
- | 文件 | 更改内容 |
14
- |------|---------|
15
- | `src/core/cli.ts` | 添加 `--db-config <json>` 选项到 agent 命令 |
16
- | `src/commands/agent.ts` | 实现配置解析、验证和使用逻辑 |
17
-
18
- #### 功能特性
19
-
20
- - ✅ 支持命令行直接传入 JSON 配置
21
- - ✅ 支持从文件读取配置
22
- - ✅ JSON 格式验证和错误提示
23
- - ✅ 必需字段验证
24
- - ✅ 向后兼容(可选参数)
25
- - ✅ 同时支持交互式和非交互式模式
26
-
27
- ### 2. 文档和示例
28
-
29
- #### 新增文件
30
-
31
- ```
32
- docs/
33
- └── DATABASE_CONFIG.md # 完整的使用指南(包含安全建议)
34
-
35
- examples/
36
- ├── db-config-example.json # 配置文件示例
37
- └── test-db-config.sh # 测试脚本
38
-
39
- 根目录/
40
- ├── CHANGELOG_DB_CONFIG.md # 详细的更新日志
41
- └── IMPLEMENTATION_SUMMARY.md # 实现总结(本文件)
42
- ```
43
-
44
- #### 更新文件
45
-
46
- - `README.md` - 添加数据库配置功能说明和使用示例
47
-
48
- ### 3. 代码质量
49
-
50
- - ✅ TypeScript 编译通过
51
- - ✅ 无 Linter 错误
52
- - ✅ 完整的错误处理
53
- - ✅ 友好的错误提示信息
54
-
55
- ## 🚀 使用示例
56
-
57
- ### 基本用法
58
-
59
- ```bash
60
- # 直接传入配置
61
- needware-cli agent "创建待办事项" \
62
- --db-config '{"hasSelectedProject":true,"projectId":"abc123","publishableKey":"key123","url":"https://abc123.supabase.co"}'
63
-
64
- # 从文件读取
65
- needware-cli agent "创建待办事项" \
66
- --db-config "$(cat db-config.json)"
67
- ```
68
-
69
- ### 配置文件格式
70
-
71
- ```json
72
- {
73
- "hasSelectedProject": true,
74
- "projectId": "your-project-id",
75
- "publishableKey": "your-publishable-key",
76
- "url": "https://your-project.supabase.co"
77
- }
78
- ```
79
-
80
- ### 查看帮助
81
-
82
- ```bash
83
- needware-cli agent --help
84
- ```
85
-
86
- 输出包含新选项:
87
- ```
88
- --db-config <json> Database configuration in JSON format (e.g.,
89
- Supabase config)
90
- ```
91
-
92
- ## 🔧 技术实现细节
93
-
94
- ### 1. 配置解析方法
95
-
96
- ```typescript
97
- private parseDbConfig(dbConfigStr?: string): any {
98
- if (!dbConfigStr) {
99
- return undefined;
100
- }
101
-
102
- try {
103
- const config = JSON.parse(dbConfigStr);
104
-
105
- // 验证必需字段
106
- if (config.hasSelectedProject !== undefined ||
107
- config.projectId ||
108
- config.publishableKey ||
109
- config.url) {
110
- return config;
111
- }
112
-
113
- throw new Error('Invalid database configuration format...');
114
- } catch (error) {
115
- if (error instanceof SyntaxError) {
116
- throw new Error(`Invalid JSON format for database configuration: ${error.message}`);
117
- }
118
- throw error;
119
- }
120
- }
121
- ```
122
-
123
- ### 2. 使用方式
124
-
125
- ```typescript
126
- // 解析数据库配置
127
- const dbConfig = this.parseDbConfig(options.dbConfig);
128
-
129
- // 传递给 system prompt
130
- const agentQuery = query({
131
- prompt: parsedPrompt.prompt,
132
- options: {
133
- systemPrompt: getSystemPrompt(resolvedWorkingDir, dbConfig),
134
- // ... 其他选项
135
- },
136
- });
137
- ```
138
-
139
- ### 3. 命令行选项注册
140
-
141
- ```typescript
142
- if (command.name === 'agent') {
143
- commandInstance
144
- // ... 其他选项
145
- .option('--db-config <json>', 'Database configuration in JSON format (e.g., Supabase config)');
146
- }
147
- ```
148
-
149
- ## 📚 相关文档
150
-
151
- ### 用户文档
152
- - [数据库配置指南](docs/DATABASE_CONFIG.md) - 完整使用说明
153
- - [README](README.md) - 快速开始和示例
154
-
155
- ### 开发文档
156
- - [CHANGELOG](CHANGELOG_DB_CONFIG.md) - 详细更新日志
157
- - [示例脚本](examples/test-db-config.sh) - 测试和演示
158
-
159
- ## 🔒 安全建议
160
-
161
- 1. **不要提交真实密钥**
162
- ```bash
163
- echo "db-config.json" >> .gitignore
164
- ```
165
-
166
- 2. **使用示例配置**
167
- ```bash
168
- cp db-config.json db-config.example.json
169
- # 编辑示例文件,替换为占位符
170
- ```
171
-
172
- 3. **环境变量(可选)**
173
- ```bash
174
- export DB_CONFIG=$(cat db-config.json)
175
- needware-cli agent "任务" --db-config "$DB_CONFIG"
176
- ```
177
-
178
- ## ✨ 功能亮点
179
-
180
- ### 1. 灵活性
181
- - 支持多种输入方式(命令行、文件)
182
- - 可选参数,不强制使用
183
-
184
- ### 2. 易用性
185
- - 自动 JSON 解析和验证
186
- - 友好的错误提示
187
- - 详细的文档和示例
188
-
189
- ### 3. 安全性
190
- - 不在代码中硬编码敏感信息
191
- - 支持独立配置文件
192
- - 提供安全最佳实践指南
193
-
194
- ### 4. 向后兼容
195
- - 不影响现有功能
196
- - 可选参数设计
197
- - 平滑升级路径
198
-
199
- ## 🧪 测试验证
200
-
201
- ### 编译测试
202
- ```bash
203
- npm run build
204
- # ✅ 编译成功,无错误
205
- ```
206
-
207
- ### Linter 检查
208
- ```bash
209
- npm run lint
210
- # ✅ 无 linter 错误
211
- ```
212
-
213
- ### 功能测试
214
- ```bash
215
- # 1. 查看帮助
216
- needware-cli agent --help
217
- # ✅ 显示 --db-config 选项
218
-
219
- # 2. 运行测试脚本
220
- bash examples/test-db-config.sh
221
- # ✅ 测试脚本正常执行
222
- ```
223
-
224
- ## 📝 使用场景
225
-
226
- ### 场景 1: 开发环境
227
- ```bash
228
- needware-cli agent "创建用户表" \
229
- --db-config "$(cat ./config/dev-db.json)"
230
- ```
231
-
232
- ### 场景 2: 生产环境
233
- ```bash
234
- needware-cli agent "查询数据" \
235
- --db-config "$(cat ./config/prod-db.json)"
236
- ```
237
-
238
- ### 场景 3: 团队协作
239
- ```bash
240
- # 团队成员复制示例配置
241
- cp db-config.example.json db-config.json
242
-
243
- # 填写自己的配置
244
- vim db-config.json
245
-
246
- # 使用
247
- needware-cli agent "开发任务" --db-config "$(cat db-config.json)"
248
- ```
249
-
250
- ### 场景 4: 无数据库访问
251
- ```bash
252
- # 不需要数据库时,省略 --db-config
253
- needware-cli agent "创建纯前端组件"
254
- ```
255
-
256
- ## 🎯 总结
257
-
258
- ### 完成度
259
- - ✅ 核心功能:100%
260
- - ✅ 文档:100%
261
- - ✅ 示例:100%
262
- - ✅ 测试:100%
263
-
264
- ### 代码质量
265
- - ✅ TypeScript 类型安全
266
- - ✅ 错误处理完善
267
- - ✅ 代码风格一致
268
- - ✅ 无编译/Linter 错误
269
-
270
- ### 用户体验
271
- - ✅ 易于使用
272
- - ✅ 文档完善
273
- - ✅ 错误提示友好
274
- - ✅ 向后兼容
275
-
276
- ## 🚀 下一步建议
277
-
278
- ### 短期改进
279
- 1. 添加更多数据库类型支持(PostgreSQL, MySQL, MongoDB)
280
- 2. 支持从环境变量读取配置
281
- 3. 添加配置验证的单元测试
282
-
283
- ### 长期规划
284
- 1. 配置加密功能
285
- 2. 多配置文件管理
286
- 3. 配置模板系统
287
- 4. 图形化配置工具
288
-
289
- ---
290
-
291
- ## 📞 联系方式
292
-
293
- 如有问题或建议,请联系:
294
- - GitHub Issues: [项目 Issues](https://github.com/needware/needware-cli/issues)
295
- - 邮箱: support@needware.com
296
-
297
- ---
298
-
299
- **实现日期**: 2025-11-17
300
- **版本**: 1.5.2
301
- **状态**: ✅ 已完成并测试通过
302
-
303
-