feat: 添加完整的单元测试套件

- 新增 vitest 测试框架配置
- 添加 54 个测试文件,共 951 个测试用例
- 覆盖核心模块:
  - Agent: executor, registry, config-loader, permission-merger
  - Context: manager, compaction, prune, token-counter
  - Permission: manager, bash/file/git/web checkers, wildcard
  - Session: manager, storage
  - Tools: filesystem (12个), git (10个), web, shell, todo, task
  - LSP: client, server, language
  - Utils: config, diff
  - UI: terminal
This commit is contained in:
2025-12-11 14:45:24 +08:00
parent f4df6483a6
commit 729fb2d42a
58 changed files with 14320 additions and 3 deletions
+17
View File
@@ -0,0 +1,17 @@
/**
* Vitest 测试环境设置
*/
import { beforeAll, afterAll, vi } from 'vitest';
// Mock console.warn/error 避免测试输出干扰
beforeAll(() => {
vi.spyOn(console, 'warn').mockImplementation(() => {});
});
afterAll(() => {
vi.restoreAllMocks();
});
// 设置测试环境变量
process.env.NODE_ENV = 'test';