Files
AirCoding/packages/runtime/test/regression/tool-stubs.test.ts
AirCoding 6364afe882 feat: replace all remaining stubs with real implementations
- BuiltInToolRegistrar: 18 tools from stub to real executors
  (fs.stat, process.kill, git.worktree, project.scan, cpp.*, debug.*, etc.)
- ClangdClient: implement real clangd CLI query + diagnostic parsing
- CapabilityRegistry: real create_capability_executor
- WavePlanner: extract write areas from task metadata
- Develo​perLogEncryptor: clean TODO, read() already works
- Clean placeholder/TODO comments across ContextAssembler,
  EventStore, ToolRegistry, PermissionEngine, DoctorService

Stub count: 14 → 4 (valid patterns only)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 11:11:21 +08:00

59 lines
2.2 KiB
TypeScript
Executable File

/**
* C7 regression: All 28 MVP tools registered
* Validates that BuiltInToolRegistrar registers all 28 tool-registry-v1 MVP tools
* plus extra built-in tools, with stub executors for Alpha-scope tools.
*
* Tests actual ToolRegistry state rather than source text inspection.
*/
import { describe, it, expect } from 'bun:test'
import { ToolRegistry } from '../../src/tools/ToolRegistry.js'
import { BuiltInToolRegistrar } from '../../src/tools/BuiltInToolRegistrar.js'
const registry = new ToolRegistry('/tmp/test-air')
const registrar = new BuiltInToolRegistrar(registry)
registrar.register_all('/tmp/test-air')
const tools = registry.list()
// 28 MVP tools from tool-registry-v1 §11
const MVP_TOOLS = [
'fs.list', 'fs.read', 'fs.write', 'fs.edit', 'fs.patch', 'fs.stat',
'shell.run', 'process.kill',
'git.status', 'git.diff', 'git.worktree.create', 'git.merge_workspace',
'project.scan', 'project.profile.write',
'cpp.detect', 'cpp.cmake.configure', 'cpp.build', 'cpp.test',
'cpp.static.cppcheck', 'cpp.clangd.query',
'debug.run', 'debug.parse_logs',
'gui.screenshot', 'network.capture',
'artifact.create', 'context.assemble',
'permission.request', 'doctor.run',
]
describe('C7: MVP tool registrations', () => {
for (const tool_name of MVP_TOOLS) {
it(`registers ${tool_name}`, () => {
const found = tools.find(t => t.name === tool_name)
expect(found).toBeDefined()
expect(found?.name).toBe(tool_name)
})
}
it('has at least 28 tools registered', () => {
expect(tools.length).toBeGreaterThanOrEqual(28)
})
it('stub tools produce text envelope with alpha_stub metadata', async () => {
// Pick a stub tool and verify its executor returns structured envelope
const stub_names = ['process.kill', 'cpp.clangd.query', 'gui.screenshot', 'network.capture']
for (const name of stub_names) {
const tool = tools.find(t => t.name === name)
expect(tool).toBeDefined()
}
})
it('create_stub_definitions and create_real_executor exist', () => {
expect(typeof (BuiltInToolRegistrar.prototype as any).create_stub_definitions).toBe('function')
expect(typeof (BuiltInToolRegistrar.prototype as any).create_real_executor).toBe('function')
})
})