@unity-china/codely-cli 1.0.0-alpha.1
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/LICENSE +203 -0
- package/README.md +332 -0
- package/README.zh-CN.md +336 -0
- package/bundle/example-prompts/README.md +56 -0
- package/bundle/example-prompts/analyze.toml +47 -0
- package/bundle/example-prompts/explain-code.toml +200 -0
- package/bundle/example-prompts/git-commit.toml +48 -0
- package/bundle/gemini.js +7161 -0
- package/bundle/gemini.js.LEGAL.txt +374 -0
- package/bundle/policies/plan.toml +131 -0
- package/bundle/policies/read-only.toml +75 -0
- package/bundle/policies/write.toml +44 -0
- package/bundle/policies/yolo.toml +9 -0
- package/bundle/sandbox-macos-permissive-closed.sb +32 -0
- package/bundle/sandbox-macos-permissive-open.sb +25 -0
- package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
- package/bundle/sandbox-macos-restrictive-closed.sb +93 -0
- package/bundle/sandbox-macos-restrictive-open.sb +96 -0
- package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
- package/bundle/tiktoken_bg.wasm +0 -0
- package/bundle/web-ui/dist/public/app.css +2188 -0
- package/bundle/web-ui/dist/public/app.js +122 -0
- package/bundle/web-ui/dist/public/index.html +17 -0
- package/package.json +119 -0
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# Codely CLI
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@unity-china/codely-cli)
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](https://www.npmjs.com/package/@unity-china/codely-cli)
|
|
11
|
+
|
|
12
|
+
**面向开发者的 AI 驱动命令行工作流工具**
|
|
13
|
+
|
|
14
|
+
🌐 [官方网站](https://codely.tuanjie.cn/) • 📖 [使用手册](https://yousandi.feishu.cn/wiki/Sqmlw31sYiTm8qkh7s1cSlbenmb) • 🇺🇸 [English](./README.md)
|
|
15
|
+
|
|
16
|
+
[安装](#安装) • [快速开始](#快速开始) • [核心功能](#核心功能)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
## 核心功能
|
|
21
|
+
|
|
22
|
+
- **代码理解与编辑** - 查询和编辑超出传统上下文窗口限制的大型代码库
|
|
23
|
+
- **工作流自动化** - 自动化处理拉取请求和复杂变基等操作任务
|
|
24
|
+
- **AI 智能体系统** - 专业的智能代理,用于深度代码库分析和自动化任务
|
|
25
|
+
- **MCP 集成** - 通过模型上下文协议服务器扩展外部工具和服务能力
|
|
26
|
+
- **Unity 集成** - 与 Unity/团结引擎直接集成,支持游戏开发任务
|
|
27
|
+
- **截图分析** - 分析截图和图像以理解 UI/UX 并提取信息
|
|
28
|
+
- **沙箱环境** - 多种沙箱模式的安全执行环境
|
|
29
|
+
- **IDE 插件** - VS Code 扩展实现无缝集成
|
|
30
|
+
|
|
31
|
+
## 🤖 AI 智能体系统
|
|
32
|
+
|
|
33
|
+
Codely CLI 包含强大的智能体系统,提供专业的 AI 助手处理复杂的开发任务:
|
|
34
|
+
|
|
35
|
+
### 智能体使用
|
|
36
|
+
|
|
37
|
+
**交互模式**(智能体自动调用):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
codely
|
|
41
|
+
> 分析这个 React 项目的组件架构并识别性能瓶颈
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**非交互模式**支持不同的输出格式:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 标准文本输出
|
|
48
|
+
codely --prompt "分析 API 端点和安全措施"
|
|
49
|
+
|
|
50
|
+
# JSON 输出用于自动化
|
|
51
|
+
codely --output-format json --prompt "调查代码库结构" > analysis.json
|
|
52
|
+
|
|
53
|
+
# 流式 JSON 用于实时监控
|
|
54
|
+
codely --output-format stream-json --prompt "记录数据流" | jq '.type == "agent_think"'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 智能体管理
|
|
58
|
+
|
|
59
|
+
**列出可用的智能体:**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
/agents list
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**创建自定义智能体:**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# 项目级别智能体
|
|
69
|
+
/agents create security-auditor
|
|
70
|
+
|
|
71
|
+
# 全局智能体
|
|
72
|
+
/agents create my-helper --global
|
|
73
|
+
|
|
74
|
+
# 带自定义描述
|
|
75
|
+
/agents create api-analyzer "分析 API 端点和文档"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**智能体位置:**
|
|
79
|
+
|
|
80
|
+
- **项目智能体**:`.codely-cli/agents/`(与团队共享)
|
|
81
|
+
- **全局智能体**:`~/.codely-cli/agents/`(个人使用)
|
|
82
|
+
|
|
83
|
+
### 智能体输出示例
|
|
84
|
+
|
|
85
|
+
智能体提供结构化的完整结果:
|
|
86
|
+
|
|
87
|
+
**交互式进度:**
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
🚀 委派给 codebase_investigator 子智能体...
|
|
91
|
+
🔧 [1] 列出目录 - 扫描项目结构
|
|
92
|
+
✅ 列出目录完成 - 找到 45 个目录
|
|
93
|
+
🤖💭 正在分析 package.json 依赖...
|
|
94
|
+
🔧 [2] 读取文件 - package.json
|
|
95
|
+
✅ 读取文件完成 - 分析依赖中
|
|
96
|
+
📋 结果:
|
|
97
|
+
{
|
|
98
|
+
"SummaryOfFindings": "React 应用采用三层架构...",
|
|
99
|
+
"ExplorationTrace": ["分析项目结构", "检查路由"],
|
|
100
|
+
"RelevantLocations": ["src/components/App.tsx", "src/api/routes.ts"]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 安装
|
|
105
|
+
|
|
106
|
+
### 前置要求
|
|
107
|
+
|
|
108
|
+
确保已安装 [Node.js 20](https://nodejs.org/en/download) 或更高版本。
|
|
109
|
+
|
|
110
|
+
### 直接安装
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm i -g @unity-china/codely-cli
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 快速开始
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# 启动
|
|
120
|
+
codely
|
|
121
|
+
|
|
122
|
+
# 示例命令
|
|
123
|
+
> 解释这个代码库结构
|
|
124
|
+
> 帮我重构这个函数
|
|
125
|
+
> 为这个模块生成单元测试
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 会话管理
|
|
129
|
+
|
|
130
|
+
通过可配置的会话限制控制您的 token 使用量,以优化成本和性能。
|
|
131
|
+
|
|
132
|
+
#### 配置会话 Token 限制
|
|
133
|
+
|
|
134
|
+
在您的主目录中创建或编辑 `.codely-cli/settings.json`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"sessionTokenLimit": 32000
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### 会话命令
|
|
143
|
+
|
|
144
|
+
- **`/compress`** - 压缩对话历史以继续在 token 限制内使用
|
|
145
|
+
- **`/clear`** - 清除所有对话历史并重新开始
|
|
146
|
+
- **`/stats`** - 检查当前 token 使用情况和限制
|
|
147
|
+
|
|
148
|
+
> 📝 **注意**:会话 token 限制适用于单次对话,而非累计 API 调用。
|
|
149
|
+
|
|
150
|
+
## 使用示例
|
|
151
|
+
|
|
152
|
+
### 🔍 探索代码库
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
cd your-project/
|
|
156
|
+
codely
|
|
157
|
+
|
|
158
|
+
# 架构分析
|
|
159
|
+
> 描述这个系统架构的主要部分
|
|
160
|
+
> 关键依赖是什么,它们如何交互?
|
|
161
|
+
> 查找所有 API 端点及其认证方法
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 💻 代码开发
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# 重构
|
|
168
|
+
> 重构这个函数以提高可读性和性能
|
|
169
|
+
> 将这个类转换为使用依赖注入
|
|
170
|
+
> 将这个大模块拆分成更小、更专注的组件
|
|
171
|
+
|
|
172
|
+
# 代码生成
|
|
173
|
+
> 创建一个用户管理的 REST API 端点
|
|
174
|
+
> 为认证模块生成单元测试
|
|
175
|
+
> 为所有数据库操作添加错误处理
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 🔄 自动化工作流
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Git 自动化
|
|
182
|
+
> 分析过去 7 天的 git 提交,按功能分组
|
|
183
|
+
> 从最近的提交创建变更日志
|
|
184
|
+
> 查找所有 TODO 注释并创建 GitHub issues
|
|
185
|
+
|
|
186
|
+
# 文件操作
|
|
187
|
+
> 将此目录中的所有图像转换为 PNG 格式
|
|
188
|
+
> 将所有测试文件重命名为 *.test.ts 模式
|
|
189
|
+
> 查找并删除所有 console.log 语句
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 🐛 调试与分析
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# 性能分析
|
|
196
|
+
> 识别这个 React 组件中的性能瓶颈
|
|
197
|
+
> 在代码库中查找所有 N+1 查询问题
|
|
198
|
+
|
|
199
|
+
# 安全审计
|
|
200
|
+
> 检查潜在的 SQL 注入漏洞
|
|
201
|
+
> 查找所有硬编码的凭据或 API 密钥
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 常用任务
|
|
205
|
+
|
|
206
|
+
### 📚 理解新代码库
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
> 核心业务逻辑组件是什么?
|
|
210
|
+
> 有哪些安全机制?
|
|
211
|
+
> 数据如何在系统中流动?
|
|
212
|
+
> 使用了哪些主要设计模式?
|
|
213
|
+
> 为这个模块生成依赖关系图
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 🔨 代码重构与优化
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
> 这个模块的哪些部分可以优化?
|
|
220
|
+
> 帮我重构这个类以遵循 SOLID 原则
|
|
221
|
+
> 添加适当的错误处理和日志记录
|
|
222
|
+
> 将回调转换为 async/await 模式
|
|
223
|
+
> 为昂贵的操作实现缓存
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 📝 文档与测试
|
|
227
|
+
|
|
228
|
+
```text
|
|
229
|
+
> 为所有公共 API 生成全面的 JSDoc 注释
|
|
230
|
+
> 编写包含边界情况的单元测试
|
|
231
|
+
> 以 OpenAPI 格式创建 API 文档
|
|
232
|
+
> 添加解释复杂算法的内联注释
|
|
233
|
+
> 为这个模块生成 README
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 🚀 开发加速
|
|
237
|
+
|
|
238
|
+
```text
|
|
239
|
+
> 设置一个带认证的新 Express 服务器
|
|
240
|
+
> 创建一个带 TypeScript 和测试的 React 组件
|
|
241
|
+
> 实现一个速率限制中间件
|
|
242
|
+
> 为新架构添加数据库迁移
|
|
243
|
+
> 为这个项目配置 CI/CD 流水线
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 命令与快捷键
|
|
247
|
+
|
|
248
|
+
### 会话命令
|
|
249
|
+
|
|
250
|
+
- `/help` - 显示可用命令
|
|
251
|
+
- `/clear` - 清除对话历史
|
|
252
|
+
- `/compress` - 压缩历史以节省 tokens
|
|
253
|
+
- `/stats` - 显示当前会话信息
|
|
254
|
+
- `/exit` 或 `/quit` - 退出 Codely CLI
|
|
255
|
+
|
|
256
|
+
### MCP 命令
|
|
257
|
+
|
|
258
|
+
管理模型上下文协议(MCP)服务器以扩展 Codely 的外部工具和服务能力:
|
|
259
|
+
|
|
260
|
+
- `/mcp` - 列出已配置的 MCP 服务器及其可用工具
|
|
261
|
+
- `/mcp desc` - 显示服务器和工具的详细描述
|
|
262
|
+
- `/mcp schema` - 显示工具参数架构
|
|
263
|
+
- `/mcp auth <server-name>` - 对启用 OAuth 的 MCP 服务器进行身份验证
|
|
264
|
+
- `/mcp refresh` - 刷新 MCP 服务器和工具列表
|
|
265
|
+
|
|
266
|
+
管理 MCP 服务器配置的 CLI 命令:
|
|
267
|
+
|
|
268
|
+
#### `codely mcp add <name> <commandOrUrl> [args...]`
|
|
269
|
+
|
|
270
|
+
添加具有指定名称和连接详情的新 MCP 服务器。
|
|
271
|
+
|
|
272
|
+
**选项:**
|
|
273
|
+
|
|
274
|
+
- `--scope` (`-s`) - 配置范围(user 或 project)
|
|
275
|
+
- `--transport` (`-t`) - 传输类型(stdio、sse、http)
|
|
276
|
+
- `--env` (`-e`) - 为 stdio 传输设置环境变量(例如 `-e KEY=value`)
|
|
277
|
+
- `--header` (`-H`) - 为 SSE 和 HTTP 传输设置 HTTP 头(例如 `-H "X-Api-Key: abc123"`)
|
|
278
|
+
- `--timeout` - 连接超时时间(毫秒)
|
|
279
|
+
- `--trust` - 信任服务器(绕过所有工具调用确认提示)
|
|
280
|
+
- `--description` - 服务器描述
|
|
281
|
+
- `--include-tools` - 要包含的工具的逗号分隔列表
|
|
282
|
+
- `--exclude-tools` - 要排除的工具的逗号分隔列表
|
|
283
|
+
|
|
284
|
+
**传输类型:**
|
|
285
|
+
|
|
286
|
+
- `stdio`(默认)- 使用指定的命令和参数启动进程
|
|
287
|
+
- `sse` - 使用服务器发送事件协议连接到服务器
|
|
288
|
+
- `http` - 使用 HTTP 协议连接到服务器
|
|
289
|
+
|
|
290
|
+
**示例:**
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# 添加 stdio 服务器
|
|
294
|
+
codely mcp add my-server python /path/to/server.py --env API_KEY=abc123
|
|
295
|
+
|
|
296
|
+
# 添加 HTTP 服务器
|
|
297
|
+
codely mcp add my-http-server http://localhost:8000 --transport http --header "Authorization: Bearer token"
|
|
298
|
+
|
|
299
|
+
# 添加具有范围配置的服务器
|
|
300
|
+
codely mcp add my-server python /path/to/server.py --scope user
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### `codely mcp list`
|
|
304
|
+
|
|
305
|
+
列出所有已配置的 MCP 服务器及其连接状态。
|
|
306
|
+
|
|
307
|
+
#### `codely mcp remove <name>`
|
|
308
|
+
|
|
309
|
+
删除具有指定名称的 MCP 服务器。
|
|
310
|
+
|
|
311
|
+
**选项:**
|
|
312
|
+
|
|
313
|
+
- `--scope` (`-s`) - 配置范围(user 或 project)
|
|
314
|
+
|
|
315
|
+
### 键盘快捷键
|
|
316
|
+
|
|
317
|
+
- `Ctrl+C` - 取消当前操作
|
|
318
|
+
- `Ctrl+D` - 退出(在空行上)
|
|
319
|
+
- `上/下箭头` - 浏览命令历史
|
|
320
|
+
|
|
321
|
+
## 故障排除
|
|
322
|
+
|
|
323
|
+
如果您遇到问题,请检查错误消息并确保:
|
|
324
|
+
|
|
325
|
+
- Node.js 版本为 20 或更高
|
|
326
|
+
- 所有依赖项已正确安装
|
|
327
|
+
- API 密钥在设置中正确配置
|
|
328
|
+
|
|
329
|
+
如需更多帮助,请访问:
|
|
330
|
+
|
|
331
|
+
- 🌐 [官方网站](https://codely.tuanjie.cn/)
|
|
332
|
+
- 📖 [使用手册](https://yousandi.feishu.cn/wiki/Sqmlw31sYiTm8qkh7s1cSlbenmb)
|
|
333
|
+
|
|
334
|
+
## 许可证
|
|
335
|
+
|
|
336
|
+
[LICENSE](./LICENSE)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Example Prompts
|
|
2
|
+
|
|
3
|
+
This directory contains example prompts that can be used with the CLI. These prompts are bundled with the CLI package for easy access.
|
|
4
|
+
|
|
5
|
+
## Available Example Prompts
|
|
6
|
+
|
|
7
|
+
- `git-commit` - Review Git staged changes, generate commit message and commit
|
|
8
|
+
- `analyze` - Analyze an open/complex topic across a very large codebase
|
|
9
|
+
- `explain-code` - Analyze and explain code functionality in detail
|
|
10
|
+
|
|
11
|
+
## Using Example Prompts
|
|
12
|
+
|
|
13
|
+
### In Non-Interactive Mode
|
|
14
|
+
|
|
15
|
+
You can use these example prompts directly in non-interactive mode with the `--example-prompt` flag:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Run the git-commit example
|
|
19
|
+
codely --yolo --example-prompt git-commit
|
|
20
|
+
|
|
21
|
+
# List all available example prompts
|
|
22
|
+
codely --list-example-prompts
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### In Interactive Mode
|
|
26
|
+
|
|
27
|
+
In interactive mode, you can use the `/example-prompt` slash command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Start interactive mode
|
|
31
|
+
codely
|
|
32
|
+
|
|
33
|
+
# Then use the command:
|
|
34
|
+
/example-prompt git-commit
|
|
35
|
+
|
|
36
|
+
# Or for the explain-code prompt:
|
|
37
|
+
/example-prompt explain-code
|
|
38
|
+
|
|
39
|
+
# Or list available prompts:
|
|
40
|
+
/example-prompt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
This functionality allows you to:
|
|
46
|
+
|
|
47
|
+
- Execute pre-defined prompts without needing to type them out
|
|
48
|
+
- Create reusable prompt templates for common tasks
|
|
49
|
+
- Share standardized prompts across your team
|
|
50
|
+
- List all available prompts to see what's available
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
54
|
+
- The `--example-prompt` flag cannot be used together with `--prompt` or `--prompt-interactive`
|
|
55
|
+
- Example prompts must be TOML files with at least a `prompt` field
|
|
56
|
+
- The `description` field is optional but recommended for better documentation
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
description = "Analyze an open/complex topic across a very large codebase"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are an expert in Unity Game Engine and a large-repo explorer. Your task is to investigate an open/complex topic across a very large Unity/engine-adjacent codebase and produce evidence-backed findings with prioritized recommendations. Provide analysis only; do not modify any code or files.
|
|
4
|
+
|
|
5
|
+
Analysis Topic: {input}
|
|
6
|
+
|
|
7
|
+
Topic-driven goals:
|
|
8
|
+
1. **Topic Framing**: Restate the topic; define scope, assumptions, hypotheses, key questions, and success criteria.
|
|
9
|
+
2. **Relevance Mapping**: Identify likely subsystems, languages, directories, services, data models, build/CI pieces, and runtime contexts that relate to the topic.
|
|
10
|
+
3. **Investigation Plan**: Break work into steps using sequential_think and create a plan with job_create; prefer independent steps in parallel; set an IO/search budget per step.
|
|
11
|
+
4. **Evidence Gathering**: Use semantic search first, then narrow with exact matches; read only focused file ranges; capture citations with file paths and line numbers.
|
|
12
|
+
5. **Synthesis**: Connect evidence to findings; quantify impact and risk; propose concrete changes.
|
|
13
|
+
|
|
14
|
+
Search and tooling rules (MANDATORY):
|
|
15
|
+
- **MUST use sequential_think first** to define scope and create a plan with job_create before any search.
|
|
16
|
+
- **ALWAYS keep searches tightly scoped** to specific directories/files; avoid using project root "./" as the target.
|
|
17
|
+
- Prefer codebase_search for semantic discovery; use grep/glob only for exact symbols/strings within the scoped paths.
|
|
18
|
+
- Use read_file only for specific, bounded ranges; avoid opening entire large files unless necessary.
|
|
19
|
+
- Run independent searches/reads in parallel (limit 3–5 concurrent) to improve throughput.
|
|
20
|
+
- Respect .gitignore; skip vendor, build artifacts, logs, binaries, and large auto-generated files.
|
|
21
|
+
|
|
22
|
+
Operating constraints (MANDATORY):
|
|
23
|
+
- Analysis-only mode: Do not create/edit/delete files, refactor code, or apply patches.
|
|
24
|
+
- Do not run any state-changing commands; propose commands as suggestions without executing them.
|
|
25
|
+
- Avoid large code dumps or sweeping rewrites; use minimal illustrative snippets only when strictly necessary.
|
|
26
|
+
|
|
27
|
+
Output format (ADAPTIVE):
|
|
28
|
+
Always include:
|
|
29
|
+
- **Executive Summary (3–7 bullets)**: Key findings, impact, confidence.
|
|
30
|
+
- **Topic Framing**: Scope, assumptions, hypotheses, key questions, success criteria.
|
|
31
|
+
- **Findings & Evidence**: Evidence-backed observations with citations; note trade-offs and confidence.
|
|
32
|
+
- **Key Examples**: Code Fragments, Functions and Classes.
|
|
33
|
+
- **Appendix**: Citations with file paths and line ranges.
|
|
34
|
+
|
|
35
|
+
Citation requirements:
|
|
36
|
+
- When quoting code, include minimal necessary lines and show file path and line numbers.
|
|
37
|
+
- Keep snippets small; prefer targeted additional reads over large dumps.
|
|
38
|
+
|
|
39
|
+
Notes:
|
|
40
|
+
- If the topic is ambiguous, briefly state assumptions and proceed; do not stall.
|
|
41
|
+
- Optimize for breadth-first discovery first, then go deep where evidence indicates hotspots.
|
|
42
|
+
- Keep explanations concise but precise; avoid generic claims without evidence.
|
|
43
|
+
|
|
44
|
+
**CRITICAL**: You MUST NOT use Grep/Glob tool under project root "./". You MUST use sequential_thining to narrow down the search scope to folder.
|
|
45
|
+
|
|
46
|
+
Focus on providing constructive, actionable feedback suitable for large-scale codebases.
|
|
47
|
+
"""
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
description = "Analyze and explain code functionality in detail"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are an expert software engineer and code analyst. Your task is to analyze and explain the functionality of the provided code in detail. Provide a comprehensive analysis only; do not modify any code or files.
|
|
4
|
+
|
|
5
|
+
Code to analyze: {input}
|
|
6
|
+
|
|
7
|
+
Follow this systematic approach to explain the code:
|
|
8
|
+
|
|
9
|
+
1. **Code Context Analysis**
|
|
10
|
+
- Identify the programming language and framework
|
|
11
|
+
- Understand the broader context and purpose of the code
|
|
12
|
+
- Identify the file location and its role in the project
|
|
13
|
+
- Review related imports, dependencies, and configurations
|
|
14
|
+
|
|
15
|
+
2. **High-Level Overview**
|
|
16
|
+
- Provide a summary of what the code does
|
|
17
|
+
- Explain the main purpose and functionality
|
|
18
|
+
- Identify the problem the code is solving
|
|
19
|
+
- Describe how it fits into the larger system
|
|
20
|
+
|
|
21
|
+
3. **Code Structure Breakdown**
|
|
22
|
+
- Break down the code into logical sections
|
|
23
|
+
- Identify classes, functions, and methods
|
|
24
|
+
- Explain the overall architecture and design patterns
|
|
25
|
+
- Map out data flow and control flow
|
|
26
|
+
|
|
27
|
+
4. **Line-by-Line Analysis**
|
|
28
|
+
- Explain complex or non-obvious lines of code
|
|
29
|
+
- Describe variable declarations and their purposes
|
|
30
|
+
- Explain function calls and their parameters
|
|
31
|
+
- Clarify conditional logic and loops
|
|
32
|
+
|
|
33
|
+
5. **Algorithm and Logic Explanation**
|
|
34
|
+
- Describe the algorithm or approach being used
|
|
35
|
+
- Explain the logic behind complex calculations
|
|
36
|
+
- Break down nested conditions and loops
|
|
37
|
+
- Clarify recursive or asynchronous operations
|
|
38
|
+
|
|
39
|
+
6. **Data Structures and Types**
|
|
40
|
+
- Explain data types and structures being used
|
|
41
|
+
- Describe how data is transformed or processed
|
|
42
|
+
- Explain object relationships and hierarchies
|
|
43
|
+
- Clarify input and output formats
|
|
44
|
+
|
|
45
|
+
7. **Framework and Library Usage**
|
|
46
|
+
- Explain framework-specific patterns and conventions
|
|
47
|
+
- Describe library functions and their purposes
|
|
48
|
+
- Explain API calls and their expected responses
|
|
49
|
+
- Clarify configuration and setup code
|
|
50
|
+
|
|
51
|
+
8. **Error Handling and Edge Cases**
|
|
52
|
+
- Explain error handling mechanisms
|
|
53
|
+
- Describe exception handling and recovery
|
|
54
|
+
- Identify edge cases being handled
|
|
55
|
+
- Explain validation and defensive programming
|
|
56
|
+
|
|
57
|
+
9. **Performance Considerations**
|
|
58
|
+
- Identify performance-critical sections
|
|
59
|
+
- Explain optimization techniques being used
|
|
60
|
+
- Describe complexity and scalability implications
|
|
61
|
+
- Point out potential bottlenecks or inefficiencies
|
|
62
|
+
|
|
63
|
+
10. **Security Implications**
|
|
64
|
+
- Identify security-related code sections
|
|
65
|
+
- Explain authentication and authorization logic
|
|
66
|
+
- Describe input validation and sanitization
|
|
67
|
+
- Point out potential security vulnerabilities
|
|
68
|
+
|
|
69
|
+
11. **Testing and Debugging**
|
|
70
|
+
- Explain how the code can be tested
|
|
71
|
+
- Identify debugging points and logging
|
|
72
|
+
- Describe mock data or test scenarios
|
|
73
|
+
- Explain test helpers and utilities
|
|
74
|
+
|
|
75
|
+
12. **Dependencies and Integrations**
|
|
76
|
+
- Explain external service integrations
|
|
77
|
+
- Describe database operations and queries
|
|
78
|
+
- Explain API interactions and protocols
|
|
79
|
+
- Clarify third-party library usage
|
|
80
|
+
|
|
81
|
+
**Explanation Format Examples:**
|
|
82
|
+
|
|
83
|
+
**For Complex Algorithms:**
|
|
84
|
+
```
|
|
85
|
+
This function implements a depth-first search algorithm:
|
|
86
|
+
|
|
87
|
+
1. Line 1-3: Initialize a stack with the starting node and a visited set
|
|
88
|
+
2. Line 4-8: Main loop - continue until stack is empty
|
|
89
|
+
3. Line 9-11: Pop a node and check if it's the target
|
|
90
|
+
4. Line 12-15: Add unvisited neighbors to the stack
|
|
91
|
+
5. Line 16: Return null if target not found
|
|
92
|
+
|
|
93
|
+
Time Complexity: O(V + E) where V is vertices and E is edges
|
|
94
|
+
Space Complexity: O(V) for the visited set and stack
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**For API Integration Code:**
|
|
98
|
+
```
|
|
99
|
+
This code handles user authentication with a third-party service:
|
|
100
|
+
|
|
101
|
+
1. Extract credentials from request headers
|
|
102
|
+
2. Validate credential format and required fields
|
|
103
|
+
3. Make API call to authentication service
|
|
104
|
+
4. Handle response and extract user data
|
|
105
|
+
5. Create session token and set cookies
|
|
106
|
+
6. Return user profile or error response
|
|
107
|
+
|
|
108
|
+
Error Handling: Catches network errors, invalid credentials, and service unavailability
|
|
109
|
+
Security: Uses HTTPS, validates inputs, and sanitizes responses
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**For Database Operations:**
|
|
113
|
+
```
|
|
114
|
+
This function performs a complex database query with joins:
|
|
115
|
+
|
|
116
|
+
1. Build base query with primary table
|
|
117
|
+
2. Add LEFT JOIN for related user data
|
|
118
|
+
3. Apply WHERE conditions for filtering
|
|
119
|
+
4. Add ORDER BY for consistent sorting
|
|
120
|
+
5. Implement pagination with LIMIT/OFFSET
|
|
121
|
+
6. Execute query and handle potential errors
|
|
122
|
+
7. Transform raw results into domain objects
|
|
123
|
+
|
|
124
|
+
Performance Notes: Uses indexes on filtered columns, implements connection pooling
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
13. **Common Patterns and Idioms**
|
|
128
|
+
- Identify language-specific patterns and idioms
|
|
129
|
+
- Explain design patterns being implemented
|
|
130
|
+
- Describe architectural patterns in use
|
|
131
|
+
- Clarify naming conventions and code style
|
|
132
|
+
|
|
133
|
+
14. **Potential Improvements**
|
|
134
|
+
- Suggest code improvements and optimizations
|
|
135
|
+
- Identify possible refactoring opportunities
|
|
136
|
+
- Point out maintainability concerns
|
|
137
|
+
- Recommend best practices and standards
|
|
138
|
+
|
|
139
|
+
15. **Related Code and Context**
|
|
140
|
+
- Reference related functions and classes
|
|
141
|
+
- Explain how this code interacts with other components
|
|
142
|
+
- Describe the calling context and usage patterns
|
|
143
|
+
- Point to relevant documentation and resources
|
|
144
|
+
|
|
145
|
+
16. **Debugging and Troubleshooting**
|
|
146
|
+
- Explain how to debug issues in this code
|
|
147
|
+
- Identify common failure points
|
|
148
|
+
- Describe logging and monitoring approaches
|
|
149
|
+
- Suggest testing strategies
|
|
150
|
+
|
|
151
|
+
**Language-Specific Considerations:**
|
|
152
|
+
|
|
153
|
+
**JavaScript/TypeScript:**
|
|
154
|
+
- Explain async/await and Promise handling
|
|
155
|
+
- Describe closure and scope behavior
|
|
156
|
+
- Clarify this binding and arrow functions
|
|
157
|
+
- Explain event handling and callbacks
|
|
158
|
+
|
|
159
|
+
**Python:**
|
|
160
|
+
- Explain list comprehensions and generators
|
|
161
|
+
- Describe decorator usage and purpose
|
|
162
|
+
- Clarify context managers and with statements
|
|
163
|
+
- Explain class inheritance and method resolution
|
|
164
|
+
|
|
165
|
+
**Java:**
|
|
166
|
+
- Explain generics and type parameters
|
|
167
|
+
- Describe annotation usage and processing
|
|
168
|
+
- Clarify stream operations and lambda expressions
|
|
169
|
+
- Explain exception hierarchy and handling
|
|
170
|
+
|
|
171
|
+
**C#:**
|
|
172
|
+
- Explain LINQ queries and expressions
|
|
173
|
+
- Describe async/await and Task handling
|
|
174
|
+
- Clarify delegate and event usage
|
|
175
|
+
- Explain nullable reference types
|
|
176
|
+
|
|
177
|
+
**Go:**
|
|
178
|
+
- Explain goroutines and channel usage
|
|
179
|
+
- Describe interface implementation
|
|
180
|
+
- Clarify error handling patterns
|
|
181
|
+
- Explain package structure and imports
|
|
182
|
+
|
|
183
|
+
**Rust:**
|
|
184
|
+
- Explain ownership and borrowing
|
|
185
|
+
- Describe lifetime annotations
|
|
186
|
+
- Clarify pattern matching and Option/Result types
|
|
187
|
+
- Explain trait implementations
|
|
188
|
+
|
|
189
|
+
Remember to:
|
|
190
|
+
- Use clear, non-technical language when possible
|
|
191
|
+
- Provide examples and analogies for complex concepts
|
|
192
|
+
- Structure explanations logically from high-level to detailed
|
|
193
|
+
- Include visual diagrams or flowcharts when helpful
|
|
194
|
+
- Tailor the explanation level to the intended audience
|
|
195
|
+
|
|
196
|
+
Operating constraints (MANDATORY):
|
|
197
|
+
- Analysis-only mode: Do not create/edit/delete files, refactor code, or apply patches.
|
|
198
|
+
- Do not run any state-changing commands; propose commands as suggestions without executing them.
|
|
199
|
+
- Avoid large code dumps or sweeping rewrites; use minimal illustrative snippets only when strictly necessary.
|
|
200
|
+
"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
description = "Review Git staged changes, generate commit message and commit"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are a professional Git user assistant. Your task is to help users complete the following operations:
|
|
4
|
+
1. Review current Git staged changes
|
|
5
|
+
2. Generate appropriate commit messages based on the changes
|
|
6
|
+
3. Execute git commit command to commit the changes
|
|
7
|
+
|
|
8
|
+
Please follow these steps:
|
|
9
|
+
1. First run `git diff --cached` command to view the staged changes
|
|
10
|
+
2. Analyze these changes to understand the content and purpose of modifications
|
|
11
|
+
3. Generate a clear, concise and conventional commit message based on the changes
|
|
12
|
+
- Must use English and keep commit messages consistency
|
|
13
|
+
- Follow conventional commits specification (use prefixes like feat:, fix:, docs:, style:, refactor:, perf:, test:, chore:, etc.)
|
|
14
|
+
- Structure:
|
|
15
|
+
* First line: concise title with conventional commit prefix. Title length MUST be less than 50
|
|
16
|
+
* Second line: blank line (required)
|
|
17
|
+
* Body paragraph: a descriptive paragraph (within 200 words) explaining the target of the commit - what feature is being added or what problem is being fixed. This should provide context and motivation for the changes.
|
|
18
|
+
* Third line: blank line (required)
|
|
19
|
+
* Bullet points: use bullet points (with '-' prefix) to list main changes
|
|
20
|
+
* Each bullet point should be concise and focused on one specific change
|
|
21
|
+
* Group related changes together logically
|
|
22
|
+
* Keep each bullet point to one line when possible
|
|
23
|
+
- Example format:
|
|
24
|
+
```
|
|
25
|
+
feat: enhance compress command and update system prompt
|
|
26
|
+
|
|
27
|
+
This commit improves the compress command functionality to provide better user experience and feedback. The main goal is to enhance logging capabilities, display detailed compression statistics, and improve test coverage. Additionally, it updates the system prompt to reflect the rebranding of the agent to 'Codely CLI', ensuring consistency across the codebase.
|
|
28
|
+
|
|
29
|
+
- Improve compress command with better logging and user feedback
|
|
30
|
+
- Add detailed compression ratio information and summary display
|
|
31
|
+
- Enhance test coverage with console spies and assertions
|
|
32
|
+
- Update system prompt to rename agent to 'Codely CLI'
|
|
33
|
+
```
|
|
34
|
+
4. Show the generated commit message to the user
|
|
35
|
+
5. IMPORTANT: Execute the commit using `git commit -m "commit_message"` command
|
|
36
|
+
- Must use the ShellTool to execute the git commit command
|
|
37
|
+
- Always use the `-m` flag with the message in double quotes
|
|
38
|
+
- For multiline commit messages, MUST use multiple `-m` flags to specify each line
|
|
39
|
+
- Example: `git commit -m "feat: add feature" -m "This commit adds a new feature to improve..." -m "- Change A" -m "- Change B"`
|
|
40
|
+
- The system will automatically handle any additional metadata
|
|
41
|
+
- If precommit hook failed, we MUST stop commit. We SHOULD NOT fix them.
|
|
42
|
+
6. Report the commit result to the user or report errors and stop
|
|
43
|
+
|
|
44
|
+
Please note:
|
|
45
|
+
- If there are no staged changes, remind the user to first use `git add` to add changes to the staging area
|
|
46
|
+
- Keep interactions friendly and ensure the user understands each step of the operation
|
|
47
|
+
"""
|
|
48
|
+
|