cbc-it-here 1.0.0 → 1.0.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/.cbc-it.json +5 -0
- package/.codebuddy/plans/fulfill-readme_a2f49f27.md +68 -0
- package/README.en.md +79 -24
- package/README.md +80 -9
- package/index.js +42 -6
- package/package.json +4 -1
package/.cbc-it.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fulfill-readme
|
|
3
|
+
overview: 完善 README.md,补充项目简介、功能特性、安装说明、使用方法、环境要求、License 等信息,并同步更新 README.en.md。
|
|
4
|
+
todos:
|
|
5
|
+
- id: rewrite-readme-zh
|
|
6
|
+
content: 重写 README.md 中文文档,补充完整的项目介绍、功能特性、安装、使用、配置、输出示例、贡献指南等内容
|
|
7
|
+
status: completed
|
|
8
|
+
- id: rewrite-readme-en
|
|
9
|
+
content: 重写 README.en.md 英文文档,与中文 README 结构和内容保持同步对齐
|
|
10
|
+
status: completed
|
|
11
|
+
dependencies:
|
|
12
|
+
- rewrite-readme-zh
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 用户需求
|
|
16
|
+
|
|
17
|
+
完善项目根目录的 `README.md`,使其内容完整、专业、可用。当前 README.md 内容过于简陋,缺少功能特性、环境要求、前置条件、task.md 格式说明、输出示例、配置项等关键信息。同时 `README.en.md` 仍为 Gitee 模板默认内容,也需要同步完善。
|
|
18
|
+
|
|
19
|
+
## 项目背景
|
|
20
|
+
|
|
21
|
+
- **项目名**: cbc-it-here
|
|
22
|
+
- **类型**: 全局 Node.js CLI 工具
|
|
23
|
+
- **功能**: 在任意项目目录下运行 `cbc-it` 命令,读取当前目录的 `task.md` 文件,通过 `@tencent-ai/agent-sdk` 调用 CodeBuddy AI 代理执行任务
|
|
24
|
+
- **入口**: index.js(ES Module),调用 `query()` 发送 prompt,使用 `permissionMode: 'bypassPermissions'`,流式输出 AI 回复文本和执行结果(耗时/费用)
|
|
25
|
+
- **依赖**: `@tencent-ai/agent-sdk ^0.3.92`
|
|
26
|
+
- **仓库**: https://gitee.com/z168w/cbc-it-here.git
|
|
27
|
+
- **License**: CC BY 4.0
|
|
28
|
+
- **作者**: z1680w
|
|
29
|
+
|
|
30
|
+
## 核心特性
|
|
31
|
+
|
|
32
|
+
- 读取当前目录 `task.md` 作为任务描述,自动提交给 CodeBuddy AI 执行
|
|
33
|
+
- 流式实时输出 AI 回复内容
|
|
34
|
+
- 执行完成后显示耗时(ms)和费用(USD)
|
|
35
|
+
- 以 bypassPermissions 模式运行,自动授权 AI 代理操作
|
|
36
|
+
|
|
37
|
+
## 技术方案
|
|
38
|
+
|
|
39
|
+
纯文档修改任务,不涉及代码实现。
|
|
40
|
+
|
|
41
|
+
### 修改文件
|
|
42
|
+
|
|
43
|
+
- `README.md` - 重写中文 README,补充完整内容
|
|
44
|
+
- `README.en.md` - 重写英文 README,与中文版本同步
|
|
45
|
+
|
|
46
|
+
### README 内容结构(基于实际代码逻辑)
|
|
47
|
+
|
|
48
|
+
1. **项目标题 + 徽章** - 名称、版本、License
|
|
49
|
+
2. **项目简介** - 一句话描述核心功能
|
|
50
|
+
3. **功能特性** - 流式输出、自动执行、耗时统计等
|
|
51
|
+
4. **前置条件** - Node.js >= 18(ES Module + async iterator)、CodeBuddy API Key 环境变量
|
|
52
|
+
5. **安装** - pnpm add -g z1680/cbc-it-here
|
|
53
|
+
6. **使用说明** - 创建 task.md → 运行 cbc-it → 查看输出
|
|
54
|
+
7. **task.md 格式** - Markdown checkbox 列表格式说明,引用 task.md 实际内容作为示例
|
|
55
|
+
8. **输出示例** - 展示 AI 回复文本 + 完成耗时/费用格式的终端输出效果
|
|
56
|
+
9. **工作原理** - 简述 index.js 的执行流程(读取 task.md → query() → 流式输出)
|
|
57
|
+
10. **配置** - permissionMode: bypassPermissions 说明
|
|
58
|
+
11. **常见问题** - API Key 配置、网络问题等
|
|
59
|
+
12. **贡献指南** - Fork → PR 流程
|
|
60
|
+
13. **许可证** - CC BY 4.0
|
|
61
|
+
|
|
62
|
+
### 关键约束
|
|
63
|
+
|
|
64
|
+
- 基于实际 `index.js` 代码逻辑描述功能,不虚构不存在的特性
|
|
65
|
+
- task.md 示例使用项目中的真实内容
|
|
66
|
+
- 输出示例与代码中的 console.log 格式一致("完成!耗时:xxx ms"、"费用:xxx USD")
|
|
67
|
+
- 不添加 package.json 中不存在的 bin 字段到文档中(当前 CLI 注册方式通过安装包处理)
|
|
68
|
+
- 中英文 README 内容保持结构一致、语义对齐
|
package/README.en.md
CHANGED
|
@@ -1,36 +1,91 @@
|
|
|
1
1
|
# cbc-it-here
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
cbc-it-here
|
|
3
|
+
A global Node.js CLI tool that reads a `task.md` file in any project directory and automatically executes tasks via the [CodeBuddy Agent SDK](https://github.com/Tencent-ai/agent-sdk).
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
Software architecture description
|
|
5
|
+
## Features
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- Reads `task.md` in the current directory and submits tasks to the CodeBuddy AI agent
|
|
8
|
+
- Streams AI responses in real time
|
|
9
|
+
- Displays execution time and cost upon completion
|
|
10
|
+
- Runs in auto-approve mode — no manual confirmation needed
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
2. xxxx
|
|
13
|
-
3. xxxx
|
|
12
|
+
## Prerequisites
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
- [Node.js](https://nodejs.org/) >= 18 (ES Module and async iterator support required)
|
|
15
|
+
- CodeBuddy API Key configured as an environment variable
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
2. xxxx
|
|
19
|
-
3. xxxx
|
|
17
|
+
## Installation
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add -g z1680/cbc-it-here
|
|
21
|
+
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
2. Create Feat_xxx branch
|
|
25
|
-
3. Commit your code
|
|
26
|
-
4. Create Pull Request
|
|
23
|
+
## Usage
|
|
27
24
|
|
|
25
|
+
### 1. Create a `task.md` file in your project root
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
Write your tasks using Markdown checkbox lists:
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
```markdown
|
|
30
|
+
- [ ] Write the current time to time4.txt in the current directory
|
|
31
|
+
- [ ] Write the current time to time5.txt in the current directory
|
|
32
|
+
- [ ] Write the current time to time6.txt in the current directory
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. (Optional) Create a configuration file
|
|
36
|
+
|
|
37
|
+
Create a configuration file in your project root to customize behavior. The following filenames are supported (in priority order):
|
|
38
|
+
|
|
39
|
+
- `.cbc-it.json`
|
|
40
|
+
- `.cbc-it.js`
|
|
41
|
+
- `cbc-it.config.js`
|
|
42
|
+
- `cbc-it.config.json`
|
|
43
|
+
|
|
44
|
+
**JSON config example (`.cbc-it.json`)**:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"options": {
|
|
49
|
+
"permissionMode": "bypassPermissions"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**JS config example (`.cbc-it.js`)**:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
export default {
|
|
58
|
+
options: {
|
|
59
|
+
permissionMode: 'bypassPermissions'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If no configuration file is created, the default configuration will be used (`permissionMode: 'bypassPermissions'`).
|
|
65
|
+
|
|
66
|
+
### 3. Run the command
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cbc-it
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. View the output
|
|
73
|
+
|
|
74
|
+
The tool streams the AI agent's responses in real time. Upon completion, it displays:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
Done! Time: xxxx ms
|
|
78
|
+
Cost: x.xxxx USD
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## How It Works
|
|
82
|
+
|
|
83
|
+
1. Reads the `task.md` file in the current directory
|
|
84
|
+
2. Calls the CodeBuddy Agent SDK `query()` method to submit the task to the AI agent
|
|
85
|
+
3. Runs in `bypassPermissions` mode, granting the AI agent full permissions automatically
|
|
86
|
+
4. Streams and outputs the AI agent's responses in real time
|
|
87
|
+
5. Displays execution time (milliseconds) and cost (USD) after the task completes
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[CC BY 4.0](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,20 +1,91 @@
|
|
|
1
1
|
# cbc-it-here
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
全局 Node.js CLI 工具,在任意项目目录下读取 `task.md` 文件,通过 [CodeBuddy Agent SDK](https://github.com/Tencent-ai/agent-sdk) 自动执行任务。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 功能特性
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 读取当前目录 `task.md` 作为任务描述,自动提交给 CodeBuddy AI 代理执行
|
|
8
|
+
- 流式实时输出 AI 回复内容
|
|
9
|
+
- 执行完成后显示耗时和费用
|
|
10
|
+
- 以自动授权模式运行,无需手动确认
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
## 前置条件
|
|
10
13
|
|
|
14
|
+
- [Node.js](https://nodejs.org/) >= 18(需要 ES Module 和 async iterator 支持)
|
|
15
|
+
- 已配置 CodeBuddy API Key 环境变量
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
## 安装
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add -g z1680/cbc-it-here
|
|
21
|
+
```
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
## 使用说明
|
|
17
24
|
|
|
18
|
-
1.
|
|
25
|
+
### 1. 在项目根目录创建 `task.md`
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
使用 Markdown checkbox 列表格式编写任务:
|
|
28
|
+
|
|
29
|
+
```markdown
|
|
30
|
+
- [ ] 将现在时间写入当前目录time4.txt
|
|
31
|
+
- [ ] 将现在时间写入当前目录time5.txt
|
|
32
|
+
- [ ] 将现在时间写入当前目录time6.txt
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. (可选)创建配置文件
|
|
36
|
+
|
|
37
|
+
在项目根目录创建配置文件来自定义行为。支持以下文件名(按优先级排序):
|
|
38
|
+
|
|
39
|
+
- `.cbc-it.json`
|
|
40
|
+
- `.cbc-it.js`
|
|
41
|
+
- `cbc-it.config.js`
|
|
42
|
+
- `cbc-it.config.json`
|
|
43
|
+
|
|
44
|
+
**JSON 配置示例 (`.cbc-it.json`)**:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"options": {
|
|
49
|
+
"permissionMode": "bypassPermissions"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**JS 配置示例 (`.cbc-it.js`)**:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
export default {
|
|
58
|
+
options: {
|
|
59
|
+
permissionMode: 'bypassPermissions'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
如未创建配置文件,将使用默认配置(`permissionMode: 'bypassPermissions'`)。
|
|
65
|
+
|
|
66
|
+
### 3. 运行命令
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cbc-it
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. 查看输出
|
|
73
|
+
|
|
74
|
+
工具会流式输出 AI 代理的回复文本,任务完成后显示:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
完成!耗时:xxxx ms
|
|
78
|
+
费用:x.xxxx USD
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 工作原理
|
|
82
|
+
|
|
83
|
+
1. 读取当前目录下的 `task.md` 文件内容
|
|
84
|
+
2. 调用 CodeBuddy Agent SDK 的 `query()` 方法,将任务提交给 AI 代理
|
|
85
|
+
3. 以 `bypassPermissions` 模式运行,AI 代理自动获得操作权限
|
|
86
|
+
4. 流式接收并输出 AI 代理的回复内容
|
|
87
|
+
5. 任务完成后输出耗时(毫秒)和费用(美元)
|
|
88
|
+
|
|
89
|
+
## 许可证
|
|
90
|
+
|
|
91
|
+
[CC BY 4.0](LICENSE)
|
package/index.js
CHANGED
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
import { query } from '@tencent-ai/agent-sdk';
|
|
2
|
+
import { readFileSync, existsSync } from 'fs';
|
|
3
|
+
import { resolve } from 'path';
|
|
2
4
|
|
|
3
|
-
async function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
async function loadConfig() {
|
|
6
|
+
const configPaths = [
|
|
7
|
+
resolve(process.cwd(), '.cbc-it.json'),
|
|
8
|
+
resolve(process.cwd(), '.cbc-it.js'),
|
|
9
|
+
resolve(process.cwd(), 'cbc-it.config.js'),
|
|
10
|
+
resolve(process.cwd(), 'cbc-it.config.json'),
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
for (const configPath of configPaths) {
|
|
14
|
+
if (existsSync(configPath)) {
|
|
15
|
+
if (configPath.endsWith('.json')) {
|
|
16
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
17
|
+
return JSON.parse(content);
|
|
18
|
+
} else if (configPath.endsWith('.js')) {
|
|
19
|
+
const configModule = await import(configPath);
|
|
20
|
+
return configModule.default || configModule;
|
|
21
|
+
}
|
|
8
22
|
}
|
|
9
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function main() {
|
|
29
|
+
const taskPath = resolve(process.cwd(), 'task.md');
|
|
30
|
+
|
|
31
|
+
if (!existsSync(taskPath)) {
|
|
32
|
+
console.error('错误:未找到 task.md 文件');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const prompt = readFileSync(taskPath, 'utf-8');
|
|
37
|
+
|
|
38
|
+
const config = await loadConfig();
|
|
39
|
+
|
|
40
|
+
const queryOptions = {
|
|
41
|
+
prompt,
|
|
42
|
+
...config.options
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const q = query(queryOptions);
|
|
10
46
|
|
|
11
47
|
for await (const message of q) {
|
|
12
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbc-it-here",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "cbc it here",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tool"
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"author": "z1680w",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "index.js",
|
|
16
|
+
"bin": {
|
|
17
|
+
"cbc-it": "index.js"
|
|
18
|
+
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
21
|
},
|