ai-worktool 1.0.7
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/CHANGELOG.md +169 -0
- package/LICENSE.txt +1 -0
- package/README.md +67 -0
- package/dist/agents/chanjet.js +377 -0
- package/dist/agents/index.js +73 -0
- package/dist/agents/jianguoke.js +182 -0
- package/dist/agents/prompt.js +41 -0
- package/dist/agents/toolCall.js +135 -0
- package/dist/cli.js +9 -0
- package/dist/loging.js +110 -0
- package/dist/program.js +35 -0
- package/dist/testAgent.js +142 -0
- package/dist/tools/file.js +543 -0
- package/dist/tools/git.js +204 -0
- package/dist/tools/index.js +71 -0
- package/dist/tools/interface.js +3 -0
- package/dist/tools/javascript.js +180 -0
- package/dist/tools/jest.js +482 -0
- package/dist/tools/mocha.js +107 -0
- package/dist/tools/package.js +376 -0
- package/dist/tools/project.js +541 -0
- package/dist/tools/typescript.js +242 -0
- package/dist/tools/vitest.js +115 -0
- package/dist/user.js +472 -0
- package/dist/view.js +216 -0
- package/package.json +289 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
## 1.0.7 (2025-08-03)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* 报错没有终止 ([540b460](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/540b460f6e2438c87533ffc10be7a2a914442c01))
|
7
|
+
* 参数 ([d94249c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d94249c443d20ee82560d26298d7590ce6c38d43))
|
8
|
+
* 测试修改 ([458c0d5](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/458c0d5c56f693c0e97d9d853865748eb14d4a8c))
|
9
|
+
* 插件label简化 ([33c6ebb](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/33c6ebb1c870ff1552f5b265a655036d37b0b968))
|
10
|
+
* 插入行调整为前插 ([f73a507](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f73a5076844b92ee30e3cf33cfcbe959213dd893))
|
11
|
+
* 插入行判断有误 ([4f72932](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4f72932c684160594edbc55d847fbd9f2180613a))
|
12
|
+
* 查找不存在需要明确给出错误 ([897c511](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/897c5110c59a8771ed6ef94cfae6612d14906727))
|
13
|
+
* 单测 ([4db1b8b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4db1b8bf1856fa81393fe7881a37c840720c8ee3))
|
14
|
+
* 单测 ([1fecaf4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1fecaf497a478deadac24252f7c30a0e9830233e))
|
15
|
+
* 单测提示 ([fee4ab3](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/fee4ab356fe0d1e3affbebf771ee469f1cadc9d1))
|
16
|
+
* 单测hook测试 ([7bb12a2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/7bb12a2b569cf1504af969fdb2f18c269cce781e))
|
17
|
+
* 第一轮AI单测自动修复通过后代码 ([a34cba6](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/a34cba677658ae26c743878a75c9df1af6a11ee1))
|
18
|
+
* 调试没有生成sourcemap ([d5803c5](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d5803c5c35c425d7c742fd3466bf39db3acf035e))
|
19
|
+
* 调整参数去掉注释 ([01489c9](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/01489c9a78439add7426514903a3065ff7eba297))
|
20
|
+
* 更新 startAgent 调用参数,确保正确传递选项并修复单测代码增加覆盖率的测试用例 ([ac95797](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ac95797e160d9a06085e780460bd30f8f7c43230))
|
21
|
+
* 更新 startTestAgent 命令选项的参数类型,确保正确解析平台和文件夹参数 ([3830f81](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/3830f81252ffdc454b9e5bbd55b95c6022ce2f56))
|
22
|
+
* 更新单测代码修复任务的日志输出,确保信息准确反映补全状态 ([84aad45](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/84aad4565ed471eb67b01b67851f50fc6eedb964))
|
23
|
+
* 更新单测和覆盖率提示信息 ([482ba95](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/482ba95bc40d9332e88bcd36d038e5ebb6fc2e8f))
|
24
|
+
* 更新单测和覆盖率提示信息 ([2929916](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/292991668f458051eb555a3381d7321daa47f0b0))
|
25
|
+
* 更新单测修复和覆盖率提示信息 ([dcdbb37](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/dcdbb3762d8de969dc4e18b105b1d0e6439749df))
|
26
|
+
* 更新单测智能体测试用例 ([ff9d9da](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ff9d9dae81640f11f043d2883a7a791adfddceb8))
|
27
|
+
* 更新单测智能体测试用例信息 ([846764d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/846764d7ea68b35d5ef52b818e978ca6a62c7eb7))
|
28
|
+
* 更新单测智能体日志和逻辑 ([0588749](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/05887491410c85281b47d30987b223c28335c991))
|
29
|
+
* 更新单测智能体提示和逻辑 ([84ff629](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/84ff629a66c9ef18124a3a3e127387c3090f02eb))
|
30
|
+
* 更新描述和标签,修复拼写错误,添加文件忽略规则 ([7cfa7cc](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/7cfa7cc149e807dad8cc1bbf6f8ca61231c9b93f))
|
31
|
+
* 更新命令中的网页链接后缀为.html ([ec236f3](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ec236f3cb00bde70f44f10f77f7333681a1fa202))
|
32
|
+
* 更新日志和单测智能体逻辑 ([37ac1ba](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/37ac1ba95cc8fbb33478495a8cd0d5ef749a9812))
|
33
|
+
* 更新chanjet.ts API配置 ([8e26b4a](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8e26b4aa900c88b814f3f25535d83d4f97a63b02))
|
34
|
+
* 更新chanjet.ts函数处理逻辑 ([0e0b081](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/0e0b081da5dc2dd7ef9b2c3f65b1e1ab8f22a5d5))
|
35
|
+
* 更新chanjet.ts文件配置 ([6e05327](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6e053276453d54ad86b1f821b89f5de166ec52ea))
|
36
|
+
* 兼容没有生成报错 ([4db842c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4db842ce26ab43ab25f12f99258abbf956182f92))
|
37
|
+
* 监控 ([d3b2040](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d3b2040377e3668b3d382b7bc2e8c78563ef80ca))
|
38
|
+
* 简化配置 ([27c9f03](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/27c9f03d7c2e42ea061dafdd9fa932a303c355d5))
|
39
|
+
* 默认false ([9f6a31c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9f6a31c255156ce3c4f563e793e85712980598fa))
|
40
|
+
* 内部不带行号 ([fe77af7](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/fe77af72a1dd1bd86d7cb6e973ea1f3b857fe325))
|
41
|
+
* 去掉断言 ([287bfb6](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/287bfb6f1e5205656f212f5cec095b4de6816898))
|
42
|
+
* 去掉偏移计算 ([5a2f44d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5a2f44d0bfaf8ced6d35672ccfe46a5ed0f3d73d))
|
43
|
+
* 日志格式化修改 ([d64f213](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d64f2138927eb573d2e0b299ca48ab1015200f90))
|
44
|
+
* 删除测试文件 ([dfc2b95](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/dfc2b95c8231be0b9cb0e600a871e6c0b03ab30d))
|
45
|
+
* 始终用LF格式 ([829cb0e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/829cb0e3b594af6376f60c1aa500e09fbbb922e6))
|
46
|
+
* 提示词测试 ([5e720cd](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5e720cdc0f27ca2148df0cda32d03e4122a32966))
|
47
|
+
* 微调 ([926fbe2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/926fbe20dadabe7358ddf72e5bf656e70582f66a))
|
48
|
+
* 文件加载错误 ([f1eca0e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f1eca0ed38bdb7137245da53e33773c610a36b5c))
|
49
|
+
* 修复 invokeTool 函数返回值,确保在执行失败时返回默认消息 ([91db39d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/91db39d03a780b3fc11a6649a0a7e44818e97712))
|
50
|
+
* 修复测试问题 ([149d1c8](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/149d1c882d62376fb7c9d6364be00bd10b5bc312))
|
51
|
+
* 修复单测代码修复任务的期望输出,确保正确验证日志信息 ([ebf3de9](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ebf3de9f16627091de196d6fc8cccfa1321cf489))
|
52
|
+
* 修复类型 ([8665237](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8665237a54c0e34c0e182c4c7594e1169ffe88ee))
|
53
|
+
* 修改安装包 ([1022cc2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1022cc23472d4e015dc3e8a5e88c19e8b3f3a580))
|
54
|
+
* 修改并删除部分代码文件 ([2da0ab1](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/2da0ab1d5d2aea8d0f446e34eb6e675c990e008e))
|
55
|
+
* 修改参数 ([46fa55a](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/46fa55af91bda18478ed63b4413b4e86f06a2455))
|
56
|
+
* 修改错误参数描述 ([992b5f8](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/992b5f8624c73945876bcf097b2e5e22c23320d0))
|
57
|
+
* 修改单测智能体描述 ([d4e5f28](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d4e5f28ee5d9e510abad4ef99c40a789ee768760))
|
58
|
+
* 修改发布配置 ([ceb1f55](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ceb1f555a3fec76829a005b1535f1d8745ffe259))
|
59
|
+
* 修改设置和用户API单测 ([815f49e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/815f49e5e1ad5cb3723b7ac8a751923fee809ed7))
|
60
|
+
* 修改提示词 ([9ebe2df](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9ebe2df287413e5a0895e0bab13260adaa8676d7))
|
61
|
+
* 修改用例 ([94933ec](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/94933ecfb7647975901b1e59781cb132fc05c57f))
|
62
|
+
* 修改正则提取 ([f9193b2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f9193b2e1c343b9590b0ffe6174d20a90172380c))
|
63
|
+
* 修改智能体 ([6d71ccf](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6d71ccf11a8f5b1b3c3f5ab196ce6a6c31216094))
|
64
|
+
* 修改root ([0397cce](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/0397ccedc273f37878016c3e34b5155a7b1fe52e))
|
65
|
+
* 增加参数 ([5d095fd](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5d095fdc275da830fd9991dc826de1f02e8f7d4c))
|
66
|
+
* 增加用例 ([60769f4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/60769f43bb8144706ad6de197ee13d81a8591977))
|
67
|
+
* 增加log ([ee98adb](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ee98adb70d0b345695ce48251c9cfc5e5e4f1e6a))
|
68
|
+
* 重构增加actions ([8bf72e0](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8bf72e012299787295a5b7a64d766a5a814e0b8b))
|
69
|
+
* 自测问题 ([09e15a3](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/09e15a3c3cd97a747e45612c8b3a257c0f61dee8))
|
70
|
+
* **agent:** 修复工具调用信息格式化时的根目录问题 ([03b160a](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/03b160ab260199f9050c5a036ca94936db1695ba))
|
71
|
+
* **agent:** 修复difuyun晚于用户消息发送时的逻辑错误 ([9ba5b98](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9ba5b98c3d7ffa3f00dc269cd809d92414d37dce))
|
72
|
+
* **agent:** 优化单测执行失败的处理逻辑 ([1a2186c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1a2186c65f4a83c1a978cb431197dbe34be3644f))
|
73
|
+
* **app:** 修正 settings 路由的挂载路径 ([2a2890b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/2a2890be96b824f885dbd19e58f82ec3f1933a4b))
|
74
|
+
* **coverage:** 修复代码覆盖率实时更新的问题 ([14bd1f4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/14bd1f4eb4cc774547b55672422ace574fdec192))
|
75
|
+
* ESM 文件导入 ([1e3b68b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1e3b68bf951c13fdfb0ef4fbe4e82d97f9a6c688))
|
76
|
+
* **file:** 修复插入操作行号验证逻辑 ([4202d7c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4202d7c6524d21f200a8dced1a5e4bcba63787dd))
|
77
|
+
* JEST无法输出colors ([3a1bd24](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/3a1bd24ba0b9b6d78dc9cdb5958f3262d08d9ded))
|
78
|
+
* **login:** 更新登录地址 ([36ba18d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/36ba18db3f2acb42f4964de2e93a6a093909bec2))
|
79
|
+
* **login:** 更新客户端 ID ([bfeac59](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/bfeac590f8bae37c1a123c8356dd600ed9add4ad))
|
80
|
+
* **webview:** 新增文件无法观察问题 ([8f18813](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8f188134861f5e151d2bcd0e7a1dda5d6a1e0268))
|
81
|
+
* writeFile内部可以覆盖 ([ea4ee44](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ea4ee442e7f3ec5cdfef5cf9142c8036772aaa11))
|
82
|
+
|
83
|
+
|
84
|
+
### Features
|
85
|
+
|
86
|
+
* ** agents/dify :** 实现控制台输出自动换行功能 ([a599463](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/a59946390c40b5ac3702f34949dd4bddf8ba8990))
|
87
|
+
* 格式化LF格式 ([69e1cf4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/69e1cf4871f18ac6157f0d7939ce143926c7d0c3))
|
88
|
+
* 更新 API 配置,增强工具函数,添加类型定义和测试用例 ([d2fc033](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d2fc0333757c0df92c16eadd5f66736ef85e810a))
|
89
|
+
* 更新 README、logo 和版本号 ([738d988](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/738d98852b8b4d3e8a28c9ccf4ee49a9efc51749))
|
90
|
+
* 更新 searchFilesByExtension 函数以支持 includeIgnoreFiles 参数,并添加 fixErrorPrompt 工具及其配置 ([f582d65](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f582d65c625bbfcc64ec8246439b07006b0b3e1c))
|
91
|
+
* 更新 searchFilesByExtension 和 searchFilesByText 函数的参数类型,支持以逗号分割的扩展名字符串 ([2ec7a9c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/2ec7a9c587503c4475c76d9c1d5fb6947576b9c9))
|
92
|
+
* 更新 startAgent 函数以支持额外的变量参数,并在相关调用中传递这些变量 ([ab9e8fc](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ab9e8fcdf65c617ff3f064f7d2a88fc714963464))
|
93
|
+
* 更新 startTestAgent 命令以支持异步测试代码生成,增强工具函数的异步处理能力 ([8402f28](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8402f28b27ab9bf42162d5f711eed3e12aba34b5))
|
94
|
+
* 更新测试代理工作流程 ([9e9a764](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9e9a76429b24c851cc1b5298c61a2e79b86f3dcf))
|
95
|
+
* 更新工具函数的描述和参数,确保 llm_description 和 human_description 正确显示 ([8ce399e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8ce399ef0aca31d1d080673862560365d7e3ae91))
|
96
|
+
* 更新工具集功能及配置 ([0a05ac9](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/0a05ac9da264c582e2c4b418bda7e219dfe1ec4b))
|
97
|
+
* 更新工具集功能及修改配置 ([d9f8630](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d9f86307b2b4838713c688223f65f2d13adc0334))
|
98
|
+
* 更新工具配置及代码逻辑 ([849b27f](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/849b27feb6bcccab83a1552f5e893846c9faef5b))
|
99
|
+
* 更新文件操作工具函数 ([c3c788c](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/c3c788c41220a33d1a5b13569740c2d129590a6c))
|
100
|
+
* 更新文件扩展名参数描述,支持以管道符分隔的扩展名字符串 ([f972285](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f97228509b5aca4dc52f8d1f78d58afa1341df0a))
|
101
|
+
* 更新项目描述和webview标题 ([5a1df60](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5a1df60b37bc597708dceacfee4683c3a50706b7))
|
102
|
+
* 更新项目描述及功能 ([7b89185](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/7b89185dafacf95e69d2950312466381ae975372))
|
103
|
+
* 更新AI工具集单测及覆盖率处理 ([38ff6fc](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/38ff6fcd078776523b8bf4eb9b46e2cda19b4993))
|
104
|
+
* 更新dify.ts API配置和逻辑 ([7234585](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/723458597a9f8f31786ffefdad51ac2ad84e7a93))
|
105
|
+
* 更新dify.ts API配置和逻辑 ([a2cb02b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/a2cb02bf9bad29627e4c7a03c66024db60bd100f))
|
106
|
+
* 更新webview面板功能 ([5f03e56](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5f03e56afe0c021cb7c07cbb5d1808f6f6778094))
|
107
|
+
* 切换平台并更新 API 基础 URL ([1607801](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1607801b0d6eb3f5283106e12522b0c9c683ac3e))
|
108
|
+
* 添加 fixErrorPrompt 函数以处理单测执行失败的错误信息,并更新 startTestAgent 以在测试失败时调用修复逻辑 ([00a9b9b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/00a9b9b27166ae30013e14aea7faded0f6a3e034))
|
109
|
+
* 添加创建Jest配置文件工具 ([0afffec](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/0afffec6163ea4ff762b299bcbe602fe82b4944a))
|
110
|
+
* 添加创建tsconfig.json工具 ([644f364](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/644f364ca1e991f8a8b96385a2df701e5019f497))
|
111
|
+
* 添加订单和用量命令 ([df518c2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/df518c2c623722f6adbee2882e55e95fd23af760))
|
112
|
+
* 添加多个工具函数,更新现有工具的参数和描述,增强代码处理能力 ([322c3ad](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/322c3ad511b57683a73f1a8531af2a4def78abbd))
|
113
|
+
* 添加脚本添加和测试功能 ([604c90f](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/604c90f47b6a435ecf9f30e782d363e48615d061))
|
114
|
+
* 添加Jest配置创建工具 ([f159c37](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f159c37029e1592acb1d6df36e2d874e5b7b5df9))
|
115
|
+
* 完善单测用例生成工具 ([1f3fded](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1f3fded5b17b5d566185a89d6f6e696e8b508119))
|
116
|
+
* 项目初始化 ([e9833ff](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/e9833ff0fb1db6b21454ca3803a218f3cc3395a9))
|
117
|
+
* 新的UI ([6d60117](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6d601179db95779d5eb2d9fddf2eb2a08e8f5691))
|
118
|
+
* 优化测试代理工作流程 ([d8b7a82](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d8b7a82d3b8191e4093c5066ff8b795563d4651c))
|
119
|
+
* 优化测试流程及覆盖率处理 ([5bebd71](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5bebd712e0eff1f94f5af4f05c1e06319bcd0113))
|
120
|
+
* 优化单测执行及覆盖率处理 ([e5474c5](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/e5474c552a4ea0365127270380a94a64bc40314f))
|
121
|
+
* 优化单测智能体处理逻辑 ([14f2e34](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/14f2e34120475995c175ad10119deb981548c532))
|
122
|
+
* 优化主题样式并添加动态主题切换支持 ([e3acb36](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/e3acb36ca3920ee1150975327fc6a81bee161766))
|
123
|
+
* 增加登录 ([4c247b4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4c247b41cefc76de1ad0cc820339797cbe4d9ed6))
|
124
|
+
* 增加视图 ([bfbf3d4](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/bfbf3d46887ff84cd8b4834e52e71c9181029294))
|
125
|
+
* 增加行号 ([8b6a8c9](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8b6a8c9315573e2e577fe6615de54826f51d7f4f))
|
126
|
+
* 增加vscode插件配置 ([0e28f3b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/0e28f3b03aa18a13149e0c48bcf34a830d7ce126))
|
127
|
+
* 增加webview视图功能 ([7a5c413](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/7a5c413aad3a99cb20d0f9cff65d14d2a485d254))
|
128
|
+
* 支持多扩展名文件搜索 ([b4afeef](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/b4afeef92a844e86f0831423fa5eb09a904e2feb))
|
129
|
+
* 支持更多测试框架及优化 ([158d4b2](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/158d4b2a7b8d6bc1ea3deac9b6c73b274bcb04d2))
|
130
|
+
* add startFixAgent and startTestAgent commands for bug fixing and test generation ([83f2567](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/83f2567292d068cbd419ed2b690af1d27c294c08))
|
131
|
+
* **agent:** 添加单测覆盖率100%时自动结束功能 ([ff6e1cc](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ff6e1cc41bba63893757aab5f27b712ee5bf4c2f))
|
132
|
+
* **agent:** 为消息事件添加任务ID ([bfc4244](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/bfc42445e95cc7d927aab8ed13ea040d8d107b7a))
|
133
|
+
* **agent:** 优化 TestAgent 启停逻辑和 UI 显示 ([91ce307](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/91ce307e5317023107f392052fb4607aa21e8081))
|
134
|
+
* **agent:** 优化代码文件显示逻辑 ([e21ca68](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/e21ca680db772694254a98ac76518b74f6e7b726))
|
135
|
+
* **agent:** 增加测试代码生成功能 ([34fa137](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/34fa137c12e745182796023e9ae2896292059d2a))
|
136
|
+
* **agent:** 增加对话模式功能 ([cc53353](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/cc5335364f13ca39d9e92e7600c9c79587071591))
|
137
|
+
* **agent:** 增加工具调用回调并优化测试流程 ([1cae77e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1cae77e7bf05c3f72771d29568034eaecfea3c8e))
|
138
|
+
* **ai-worktool:** 重构 Webview 交互逻辑 ([d118dec](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/d118dec14d3ca3644f41a34db4a5b028987df2db))
|
139
|
+
* **configuration:** 增加包管理器、测试框架和编程语言选择配置项 ([ec3cceb](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ec3cceba695485010c5c710894ea2e49f57737f8))
|
140
|
+
* **dify-plugin:** 新增重命名文件或目录的功能 ([9bb6961](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9bb69613a28aba6859f72b14b2aa1a586ac9ca70))
|
141
|
+
* **extension:** 重构 Webview 并添加覆盖率报告功能 ([fd8a62b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/fd8a62b79aff4c03af8b56779d607f01d65c175a))
|
142
|
+
* **jianguoke:** 优化工具调用信息格式化及消息 ID 生成 ([1b240e7](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/1b240e7fbcabb2112789c116b7f483308c184fce))
|
143
|
+
* **log:** 增加日志容器拖动调整功能 ([cfdaf9d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/cfdaf9d7bec56687a2d49ca92785463dc6713a77))
|
144
|
+
* **plugin:** 更新插件版本和功能描述 ([f3773d6](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f3773d675fcb274080339cd0274a1a7aff8415a9))
|
145
|
+
* **project:** 优化项目类型检测逻辑 ([9bc024d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9bc024deeed239c05c9cab810f9f12a6a3306aab))
|
146
|
+
* Refactor CLI and program structure, update commands for testing and fixing code ([8dcbb19](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/8dcbb191fc8a95a40e07647de337452935926b10))
|
147
|
+
* **test/demo:** 添加用户成绩 API 路由 ([6f838c7](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6f838c7fda9924b1e5a7556d0a429427a652b985))
|
148
|
+
* **test:** 添加 demo ([403c8fe](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/403c8fe37d39a21936561e743087d6b25ab6ad56))
|
149
|
+
* **toolbox:** 新增测试结果解析和错误查找工具 ([129decd](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/129decd2ada2db843b08d1383680a2675ef7b003))
|
150
|
+
* **toolbox:** 优化函数文档生成和行号处理 ([9a16317](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9a163177914a2d175665697e1b5c9754488f7d62))
|
151
|
+
* **toolbox:** 重构并增强项目配置检测功能 ([6cc4e33](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6cc4e33a58c7ebb622d27bc643c1e65d1e8af577))
|
152
|
+
* **tools:** 为简咕客插件生成 zod 工具 ([42dfcd9](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/42dfcd9eb337603ecb0c5fa381ad89784345c9dc))
|
153
|
+
* **tools:** 优化工具插件支持连续多行操作并添加新功能 ([734ca52](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/734ca5287785d84be0f8fc98b074476a3cc643f2))
|
154
|
+
* **user:** 实现登录取消功能并优化登录流程 ([50d124e](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/50d124e720c778e537488ca436855af21dcbcdeb))
|
155
|
+
* **user:** 为认证回调页面添加立即关闭按钮 ([4328b48](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/4328b48e06002fa9d70427b21992f1022ffa73a0))
|
156
|
+
* **views:** 优化代码覆盖率显示 ([ef98b11](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/ef98b115e57650483fae65ddec5ded085839ddd0))
|
157
|
+
|
158
|
+
|
159
|
+
### Performance Improvements
|
160
|
+
|
161
|
+
* **webview:** 优化工作空间添加流程和覆盖率更新逻辑 ([085ff65](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/085ff6510c8d1d54444210069ce7fe7cc4af11e6))
|
162
|
+
|
163
|
+
|
164
|
+
### Reverts
|
165
|
+
|
166
|
+
* Revert "refactor(startTestAgent): 优化错误处理和代码结构" ([566f8a0](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/566f8a0f2c6dc1afc759504871af4e84218aacb0))
|
167
|
+
|
168
|
+
|
169
|
+
|
package/LICENSE.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
NO LICENSE
|
package/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# 🎮 吃豆豆:单测智能体
|
2
|
+
|
3
|
+
<p align="center">
|
4
|
+
<img src="resources/logo_white.png" alt="吃豆豆logo" width="120" height="120">
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p align="center">
|
8
|
+
<strong>自动生成高质量单元测试,让代码覆盖率轻松达到100% 🚀</strong>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p align="center">
|
12
|
+
<em>你负责编写源代码,我负责编写测试代码,解放双手,专注核心业务逻辑开发 💻</em>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
## 目录
|
18
|
+
- [🎮 吃豆豆:单测智能体](#-吃豆豆单测智能体)
|
19
|
+
- [目录](#目录)
|
20
|
+
- [🌟 特性亮点](#-特性亮点)
|
21
|
+
- [🚀 核心功能](#-核心功能)
|
22
|
+
- [💎 核心价值](#-核心价值)
|
23
|
+
- [📝 使用指南](#-使用指南)
|
24
|
+
- [🔧 适用范围](#-适用范围)
|
25
|
+
- [🚀 开始使用](#-开始使用)
|
26
|
+
- [💬 联系我们](#-联系我们)
|
27
|
+
|
28
|
+
## 🌟 特性亮点
|
29
|
+
- 🔍 **智能代码分析**:深入理解代码结构和逻辑关系
|
30
|
+
- 📝 **精准测试生成**:针对不同代码场景生成最佳测试策略
|
31
|
+
- 🔄 **持续优化**:根据测试结果不断完善测试用例
|
32
|
+
- 💡 **AI驱动**:利用先进的大语言模型提升测试质量
|
33
|
+
|
34
|
+
## 🚀 核心功能
|
35
|
+
- 🤖 **自动化测试生成**:自动识别未覆盖代码,生成完整测试用例,直到100%代码覆盖通过
|
36
|
+
- 🛠️ **智能错误修复**:检测并修复单元测试中的语法错误、逻辑错误及断言失败
|
37
|
+
- 📊 **覆盖率可视化**:实时展示行/语句/函数/分支覆盖率,通过颜色编码直观呈现测试状态
|
38
|
+
- 🔄 **全流程自动化**:从环境初始化、依赖安装到持续测试优化,全程无需人工干预
|
39
|
+
|
40
|
+
## 💎 核心价值
|
41
|
+
- ⚡ **提升开发效率**:再也**不用手写**单测代码,专注核心业务逻辑开发
|
42
|
+
- 🛡️ **保障代码质量**:确保测试覆盖率达标,降低线上bug风险
|
43
|
+
- 🧩 **简化测试流程**:无需深入掌握测试框架细节,一键启动全自动化测试流程
|
44
|
+
- 👁️ **可视化反馈**:通过直观的覆盖率报表和进度展示,让测试状态一目了然
|
45
|
+
|
46
|
+
## 📝 使用指南
|
47
|
+
1. 📂 打开项目文件夹
|
48
|
+
2. ▶️ 启动吃豆豆智能体
|
49
|
+
3. 📈 查看实时测试进度和覆盖率报告
|
50
|
+
4. 🧠 智能体自动编写代码
|
51
|
+
|
52
|
+
## 🔧 适用范围
|
53
|
+
- 🔌 支持多种调用方式:VSCode插件、CLI命令
|
54
|
+
- 💻 支持多种编程语言:TypeScript、JavaScript等
|
55
|
+
- 🧪 支持主流测试框架:Jest、Vitest等
|
56
|
+
|
57
|
+
---
|
58
|
+
|
59
|
+
## 🚀 开始使用
|
60
|
+
准备好提升你的开发效率了吗?立即安装吃豆豆单测智能体,让测试工作变得轻松简单!
|
61
|
+
|
62
|
+
## 💬 联系我们
|
63
|
+
如有任何问题或建议,可以给我发邮件 9160294@qq.com。
|
64
|
+
|
65
|
+
<p align="center">
|
66
|
+
<strong>© 2025 吃豆豆单测智能体 - 让单元测试自动化、智能化</strong>
|
67
|
+
</p>
|
@@ -0,0 +1,377 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.startAgent = exports.stopAgent = exports.setConversationId = exports.addMessage = void 0;
|
37
|
+
const tools = __importStar(require("../tools"));
|
38
|
+
const os = __importStar(require("os"));
|
39
|
+
const toolCall_1 = require("./toolCall");
|
40
|
+
// API配置 - 方便修改和更新
|
41
|
+
const API_CONFIG = {
|
42
|
+
// 聊天API地址
|
43
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
44
|
+
CHAT_ENDPOINT: 'https://inte-oneai.chanjet.com.cn/assistant/v1/chat',
|
45
|
+
// 函数调用结果上报地址前缀
|
46
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
47
|
+
FUNCTION_RESULT_ENDPOINT_PREFIX: 'https://inte-oneai.chanjet.com.cn/assistant/v1/function_call/update_result/',
|
48
|
+
// 认证信息
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
50
|
+
AUTH_TOKEN: 'Bearer DF#app-35EgnCA8VOlHFaRkR39pXvOw',
|
51
|
+
// 函数调用结果上报API密钥
|
52
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
53
|
+
API_KEY: 'your_api_key',
|
54
|
+
// 请求配置
|
55
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
56
|
+
REQUEST_CONFIG: {
|
57
|
+
channel: 'VSCode插件',
|
58
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
59
|
+
user_id: os.userInfo().username,
|
60
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
61
|
+
tenant_id: 'none'
|
62
|
+
}
|
63
|
+
};
|
64
|
+
let conversationId = ''; // 会话ID
|
65
|
+
// 添加日志
|
66
|
+
const addLog = (text, type = '') => {
|
67
|
+
console.log(text);
|
68
|
+
};
|
69
|
+
let lateLines = 0;
|
70
|
+
function wrapText(text, width = process.stdout.columns) {
|
71
|
+
// 按现有换行符分割文本
|
72
|
+
const paragraphs = text.split('\n');
|
73
|
+
let totalLines = 0;
|
74
|
+
let wrappedText = '';
|
75
|
+
paragraphs.forEach((paragraph, index) => {
|
76
|
+
let currentLine = '';
|
77
|
+
let currentLineWidth = 0;
|
78
|
+
let paragraphLines = 1; // 每个段落至少有一行
|
79
|
+
for (let i = 0; i < paragraph.length; i++) {
|
80
|
+
const char = paragraph[i];
|
81
|
+
const charWidth = getCharWidth(char);
|
82
|
+
if (currentLineWidth + charWidth > width) {
|
83
|
+
currentLine += '\n';
|
84
|
+
currentLine += char;
|
85
|
+
currentLineWidth = charWidth;
|
86
|
+
paragraphLines++;
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
currentLine += char;
|
90
|
+
currentLineWidth += charWidth;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
// 添加处理后的段落(最后一个段落不添加额外换行)
|
94
|
+
wrappedText += currentLine + (index < paragraphs.length - 1 ? '\n' : '');
|
95
|
+
totalLines += paragraphLines;
|
96
|
+
});
|
97
|
+
return {
|
98
|
+
wrappedText,
|
99
|
+
lines: totalLines
|
100
|
+
};
|
101
|
+
}
|
102
|
+
function getCharWidth(char) {
|
103
|
+
const code = char.codePointAt(0) ?? 0;
|
104
|
+
// 全角字符范围判断
|
105
|
+
return (code >= 0x1100 && code <= 0x11ff) || // Hangul Jamo
|
106
|
+
(code >= 0x2e80 && code <= 0xa4cf) || // CJK ... Yi
|
107
|
+
(code >= 0xac00 && code <= 0xd7af) || // Hangul Syllables
|
108
|
+
(code >= 0xf900 && code <= 0xfaff) || // CJK Compatibility Ideographs
|
109
|
+
(code >= 0xfe30 && code <= 0xfe4f) || // CJK Compatibility Forms
|
110
|
+
(code >= 0xff00 && code <= 0xffef) // Halfwidth and Fullwidth Forms
|
111
|
+
? 2
|
112
|
+
: 1;
|
113
|
+
}
|
114
|
+
const addMessage = (text, type = 'bot') => {
|
115
|
+
if (!process.stdout.moveCursor) {
|
116
|
+
console.log(text);
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
const { lines } = wrapText(text);
|
120
|
+
process.stdout.moveCursor(0, -lateLines);
|
121
|
+
process.stdout.write(text + '\n');
|
122
|
+
lateLines = lines;
|
123
|
+
};
|
124
|
+
exports.addMessage = addMessage;
|
125
|
+
const setConversationId = (id) => {
|
126
|
+
conversationId = id;
|
127
|
+
};
|
128
|
+
exports.setConversationId = setConversationId;
|
129
|
+
const invokeTool = async (toolName, params) => {
|
130
|
+
let data = null;
|
131
|
+
try {
|
132
|
+
const tool = tools[toolName];
|
133
|
+
if (!tool) {
|
134
|
+
throw new Error(`Tool ${toolName} not found`);
|
135
|
+
}
|
136
|
+
data = await tool.apply(null, params);
|
137
|
+
}
|
138
|
+
catch (err) {
|
139
|
+
data = err.message || '执行失败';
|
140
|
+
}
|
141
|
+
return data || '执行完成';
|
142
|
+
};
|
143
|
+
// 处理事件消息
|
144
|
+
const handleEventMessage = (contentObj) => {
|
145
|
+
switch (contentObj.type) {
|
146
|
+
case 'workflow_started':
|
147
|
+
addLog('工作流开始', 'workflow');
|
148
|
+
break;
|
149
|
+
case 'workflow_finished':
|
150
|
+
addLog('工作流结束', 'workflow');
|
151
|
+
break;
|
152
|
+
case 'node_started':
|
153
|
+
const startNodeInfo = contentObj.text || {};
|
154
|
+
addLog(`节点开始: ${startNodeInfo.title || ''} (${startNodeInfo.node_type || '未知类型'})`, 'node');
|
155
|
+
break;
|
156
|
+
case 'node_finished':
|
157
|
+
const finishNodeInfo = contentObj.text || {};
|
158
|
+
addLog(`节点结束: ${finishNodeInfo.title || ''} (${finishNodeInfo.node_type || '未知类型'})`, 'node');
|
159
|
+
break;
|
160
|
+
case 'message_end':
|
161
|
+
addLog('消息结束', 'workflow');
|
162
|
+
break;
|
163
|
+
default:
|
164
|
+
addLog(`事件: ${contentObj.type}`, 'workflow');
|
165
|
+
}
|
166
|
+
};
|
167
|
+
const reportFunctionResult = async (taskId, result) => {
|
168
|
+
addLog(`上报函数调用结果: ${taskId} ${result.success ? 'success' : 'failed'} ${typeof result.data === 'string' ? result.data : JSON.stringify(result.data, null, 2)}`);
|
169
|
+
try {
|
170
|
+
const response = await fetch(API_CONFIG.FUNCTION_RESULT_ENDPOINT_PREFIX + taskId, {
|
171
|
+
method: 'POST',
|
172
|
+
headers: {
|
173
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
174
|
+
'Content-Type': 'application/json'
|
175
|
+
},
|
176
|
+
body: JSON.stringify({
|
177
|
+
result
|
178
|
+
})
|
179
|
+
});
|
180
|
+
// if (response.ok) {
|
181
|
+
// addLog('函数调用结果上报成功');
|
182
|
+
// } else {
|
183
|
+
// addLog(`函数调用结果上报失败: ${response.status}`);
|
184
|
+
// }
|
185
|
+
}
|
186
|
+
catch (error) {
|
187
|
+
console.error('上报函数调用结果错误:', error);
|
188
|
+
addLog(`上报函数调用结果错误: ${error.message}`, 'error');
|
189
|
+
}
|
190
|
+
};
|
191
|
+
const stopAgent = async (taskId) => {
|
192
|
+
try {
|
193
|
+
await fetch(`${API_CONFIG.CHAT_ENDPOINT}/${taskId}/stop`, {
|
194
|
+
method: 'POST',
|
195
|
+
headers: {
|
196
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
197
|
+
Authorization: API_CONFIG.AUTH_TOKEN,
|
198
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
199
|
+
'Content-Type': 'application/json'
|
200
|
+
},
|
201
|
+
body: JSON.stringify(API_CONFIG.REQUEST_CONFIG)
|
202
|
+
});
|
203
|
+
}
|
204
|
+
catch (err) {
|
205
|
+
console.log(err);
|
206
|
+
}
|
207
|
+
};
|
208
|
+
exports.stopAgent = stopAgent;
|
209
|
+
// 获取机器人响应
|
210
|
+
const startAgent = async (name, userMessage, vars, withConversation, ctrl, onMessage, onToolCall) => {
|
211
|
+
if (withConversation !== true) {
|
212
|
+
(0, exports.setConversationId)(''); // 每次重来
|
213
|
+
}
|
214
|
+
// console.log('conversationId:', conversationId);
|
215
|
+
const requestData = {
|
216
|
+
...API_CONFIG.REQUEST_CONFIG,
|
217
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
218
|
+
conversation_id: conversationId,
|
219
|
+
variables: {
|
220
|
+
agent: name,
|
221
|
+
...vars,
|
222
|
+
testFilePatterns: vars?.testFilePatterns?.join(','),
|
223
|
+
languages: vars?.languages?.join(',')
|
224
|
+
},
|
225
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
226
|
+
completion_option: {
|
227
|
+
stream: true,
|
228
|
+
append: false
|
229
|
+
},
|
230
|
+
messages: [
|
231
|
+
{
|
232
|
+
role: 'user',
|
233
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
234
|
+
content_type: 'text',
|
235
|
+
content: JSON.stringify({ type: 'text', text: userMessage }),
|
236
|
+
attachments: []
|
237
|
+
}
|
238
|
+
]
|
239
|
+
};
|
240
|
+
console.log(userMessage);
|
241
|
+
let response;
|
242
|
+
try {
|
243
|
+
response = await fetch(API_CONFIG.CHAT_ENDPOINT, {
|
244
|
+
method: 'POST',
|
245
|
+
signal: ctrl?.signal,
|
246
|
+
headers: {
|
247
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
248
|
+
Authorization: API_CONFIG.AUTH_TOKEN,
|
249
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
250
|
+
'Content-Type': 'application/json'
|
251
|
+
},
|
252
|
+
body: JSON.stringify(requestData)
|
253
|
+
});
|
254
|
+
}
|
255
|
+
catch (err) {
|
256
|
+
throw new Error('大模型调用失败,' + err.message);
|
257
|
+
}
|
258
|
+
if (!response.ok) {
|
259
|
+
throw new Error(`HTTP错误! 状态码: ${response.status}`);
|
260
|
+
}
|
261
|
+
const reader = response.body.getReader();
|
262
|
+
const decoder = new TextDecoder();
|
263
|
+
let botResponse = '';
|
264
|
+
let botId = Date.now();
|
265
|
+
const clearMessage = () => {
|
266
|
+
if (botResponse) {
|
267
|
+
addLog(botResponse, 'bot');
|
268
|
+
botResponse = '';
|
269
|
+
}
|
270
|
+
lateLines = 0;
|
271
|
+
botId = Date.now();
|
272
|
+
};
|
273
|
+
// 处理函数调用
|
274
|
+
const handleFunctionCall = async (contentObj) => {
|
275
|
+
if (contentObj.type !== 'function_call') {
|
276
|
+
return;
|
277
|
+
}
|
278
|
+
try {
|
279
|
+
const functionCallData = JSON.parse(contentObj.text);
|
280
|
+
if (!functionCallData) {
|
281
|
+
return;
|
282
|
+
}
|
283
|
+
const { function_name: functionName, params, task_id: taskId } = functionCallData;
|
284
|
+
// console.log(JSON.stringify(params))
|
285
|
+
addLog(`函数调用: ${functionName}(\n${params
|
286
|
+
.map((it) => (typeof it === 'string' ? it.replace(/\\n/g, '\n') : JSON.stringify(it, null, 2)))
|
287
|
+
.join(',\n')})`, 'function');
|
288
|
+
await onMessage?.((0, toolCall_1.formatToolCallInfo)(functionCallData, vars.projectRoot), taskId);
|
289
|
+
let result = null;
|
290
|
+
try {
|
291
|
+
const ret = await invokeTool(functionName, params);
|
292
|
+
result = { success: true, data: ret };
|
293
|
+
await onToolCall?.({
|
294
|
+
functionName,
|
295
|
+
params,
|
296
|
+
result
|
297
|
+
});
|
298
|
+
}
|
299
|
+
catch (e) {
|
300
|
+
addLog(`函数调用失败: ${functionName}`, 'error');
|
301
|
+
result = { success: false, message: e instanceof Error ? e.message : '未知错误' };
|
302
|
+
await onToolCall?.({
|
303
|
+
functionName,
|
304
|
+
params,
|
305
|
+
result
|
306
|
+
});
|
307
|
+
}
|
308
|
+
await reportFunctionResult(taskId, result);
|
309
|
+
await onMessage?.((0, toolCall_1.formatToolCallInfo)(functionCallData, vars.projectRoot, result), taskId);
|
310
|
+
}
|
311
|
+
catch (error) {
|
312
|
+
console.error('函数调用错误:', error);
|
313
|
+
addLog(`函数调用错误: ${error instanceof Error ? error.message : '未知错误'}`, 'error');
|
314
|
+
}
|
315
|
+
};
|
316
|
+
let taskId = '';
|
317
|
+
while (true) {
|
318
|
+
const { value, done } = await reader.read();
|
319
|
+
if (done) {
|
320
|
+
break;
|
321
|
+
}
|
322
|
+
const chunk = decoder.decode(value, { stream: true });
|
323
|
+
const sseChunks = chunk.split('\n\n').filter((line) => line.trim().startsWith('data: '));
|
324
|
+
for (const sseChunk of sseChunks) {
|
325
|
+
const jsonStr = sseChunk.substring(6);
|
326
|
+
const data = JSON.parse(jsonStr);
|
327
|
+
if (!data?.answer?.length) {
|
328
|
+
continue;
|
329
|
+
}
|
330
|
+
if (data.conversation_id && !conversationId) {
|
331
|
+
(0, exports.setConversationId)(data.conversation_id);
|
332
|
+
// addLog(`会话ID: ${data.conversation_id}`);
|
333
|
+
}
|
334
|
+
for (const item of data.answer) {
|
335
|
+
if (!item.message) {
|
336
|
+
continue;
|
337
|
+
}
|
338
|
+
const { role, content_type: contentType, content } = item.message;
|
339
|
+
if (role !== 'assistant') {
|
340
|
+
continue;
|
341
|
+
}
|
342
|
+
const contentObj = JSON.parse(content);
|
343
|
+
if (!contentObj) {
|
344
|
+
continue;
|
345
|
+
}
|
346
|
+
switch (contentType) {
|
347
|
+
case 'event':
|
348
|
+
clearMessage();
|
349
|
+
handleEventMessage(contentObj);
|
350
|
+
if (contentObj.type === 'workflow_started') {
|
351
|
+
taskId = contentObj.task_id;
|
352
|
+
}
|
353
|
+
break;
|
354
|
+
case 'text':
|
355
|
+
if (contentObj.type === 'text' && contentObj.text) {
|
356
|
+
botResponse += contentObj.text;
|
357
|
+
await onMessage?.(botResponse, name + botId);
|
358
|
+
// addMessage(botResponse, 'bot');
|
359
|
+
}
|
360
|
+
break;
|
361
|
+
case 'function_call':
|
362
|
+
clearMessage();
|
363
|
+
await handleFunctionCall(contentObj);
|
364
|
+
break;
|
365
|
+
default:
|
366
|
+
clearMessage();
|
367
|
+
addLog(`未知的内容类型: ${contentType}`);
|
368
|
+
}
|
369
|
+
}
|
370
|
+
}
|
371
|
+
}
|
372
|
+
if (ctrl?.signal.aborted && taskId) {
|
373
|
+
await (0, exports.stopAgent)(taskId);
|
374
|
+
}
|
375
|
+
};
|
376
|
+
exports.startAgent = startAgent;
|
377
|
+
//# sourceMappingURL=chanjet.js.map
|