ai-worktool 1.0.11 → 1.0.12

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 CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.0.11 (2025-08-03)
1
+ ## 1.0.12 (2025-08-03)
2
2
 
3
3
 
4
4
  ### Bug Fixes
@@ -146,6 +146,7 @@
146
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
147
  * **test/demo:** 添加用户成绩 API 路由 ([6f838c7](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6f838c7fda9924b1e5a7556d0a429427a652b985))
148
148
  * **test:** 添加 demo ([403c8fe](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/403c8fe37d39a21936561e743087d6b25ab6ad56))
149
+ * **testAgent:** 添加onReady回调并移动覆盖率显示逻辑 ([746dfa3](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/746dfa39da2c010bf61e916a669b4fc77bc4661c))
149
150
  * **toolbox:** 新增测试结果解析和错误查找工具 ([129decd](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/129decd2ada2db843b08d1383680a2675ef7b003))
150
151
  * **toolbox:** 优化函数文档生成和行号处理 ([9a16317](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9a163177914a2d175665697e1b5c9754488f7d62))
151
152
  * **toolbox:** 重构并增强项目配置检测功能 ([6cc4e33](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/6cc4e33a58c7ebb622d27bc643c1e65d1e8af577))
package/dist/program.js CHANGED
@@ -8,9 +8,13 @@ const commander_1 = require("commander");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const testAgent_1 = require("./testAgent");
10
10
  const tools_1 = require("./tools");
11
+ const view_1 = require("./view");
11
12
  // import { showCoverageView } from './view';
12
13
  const program = new commander_1.Command();
13
14
  program.name('testAgent').description('吃豆豆:单测智能体').version('1.0.1');
15
+ // 屏蔽调试日志
16
+ const logHandler = console.log;
17
+ console.log = () => { };
14
18
  program
15
19
  .command('start [projectRoot]')
16
20
  .description('启动单测智能体,根据源代码文件开始补全单测代码,直到覆盖率100%')
@@ -21,10 +25,22 @@ program
21
25
  .option('-c, --coverageDir <string>', '覆盖率报告文件夹', 'coverage')
22
26
  .option('--autoCommit <boolean>', '覆盖率报告文件夹', (txt) => txt === 'true', true)
23
27
  .option('--fullCoverageEnd <boolean>', '是否在达到100%覆盖率后结束', (txt) => txt === 'true', true)
24
- .action((projectRoot, options) => (0, testAgent_1.startTestAgent)({
25
- ...options,
26
- projectRoot: projectRoot || options.projectRoot
27
- }));
28
+ .action(async (projectRoot, options) => {
29
+ let projectConfig;
30
+ (0, testAgent_1.startTestAgent)({
31
+ ...options,
32
+ projectRoot: projectRoot || options.projectRoot,
33
+ onReady: async (project) => {
34
+ projectConfig = project;
35
+ },
36
+ onMessage: async (message) => {
37
+ logHandler(message);
38
+ if (message.includes('当前代码总覆盖率')) {
39
+ await (0, view_1.loadAndDisplayCoverage)(path_1.default.join(projectConfig.projectRoot, projectConfig.coverageDir, view_1.COVERAGE_FILE_PATH), 0);
40
+ }
41
+ }
42
+ });
43
+ });
28
44
  program
29
45
  .command('showCoverage [projectRoot]')
30
46
  .description('监控代码覆盖率报告')
package/dist/testAgent.js CHANGED
@@ -7,7 +7,6 @@ exports.startTestAgent = startTestAgent;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const agents_1 = require("./agents");
9
9
  const tools_1 = require("./tools");
10
- const view_1 = require("./view");
11
10
  async function startTestAgent(options) {
12
11
  const ctrl = options.controller;
13
12
  const log = options.onMessage || console.log;
@@ -23,6 +22,7 @@ async function startTestAgent(options) {
23
22
  await (0, tools_1.initProject)(options.projectRoot, projectConfig.packageManager);
24
23
  }
25
24
  await (0, tools_1.setupTestEnvironment)(projectConfig.projectRoot, projectConfig.packageManager, projectConfig.languages[0], projectConfig.testFramework);
25
+ await options.onReady?.(projectConfig);
26
26
  let toolCalls = null;
27
27
  let lastTestResult = null;
28
28
  let lastFailedTest = null;
@@ -103,7 +103,6 @@ async function startTestAgent(options) {
103
103
  break;
104
104
  }
105
105
  log(`当前代码总覆盖率为${parseFloat(total[options.checkPct || 'branches'].pct.toString()) || 0}%`);
106
- await (0, view_1.loadAndDisplayCoverage)(path_1.default.join(projectConfig.projectRoot, projectConfig.coverageDir, view_1.COVERAGE_FILE_PATH), 0);
107
106
  const finished = total[options.checkPct || 'branches'].pct >= 100;
108
107
  if (!finished) {
109
108
  for (const filePath of Object.keys(files)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-worktool",
3
3
  "displayName": "吃豆豆:单测智能体",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "description": "单元测试智能体,帮你开发单元测试用例代码直到100%单测覆盖通过。",
6
6
  "author": "jianguoke.cn",
7
7
  "license": "MIT",