fix: tsc 0 errors + depcruise 0 violations + all GA blockers closed

Changes (37 files, +1159/-587):
- tsconfig: moduleResolution bundler + paths alias for bun:sqlite
- bun-sqlite.ts: type shim replacing stale declare module .d.ts
- All 7 tool files: ToolDefinition alignment (version, output_schema,
  ToolPermissionSpec read_paths/write_paths, ToolCall.call_id)
- 2 adapters: ProviderAdapter implements + ProviderCapabilityMatrix shape
  (provider_kind, enabled, quality_tier, cost_tier, conversion)
- PathClassifier: 9 categories aligned (credential_store, project_air_*)
- CommandRiskAnalyzer: remove unused imports
- Recovery: Database field + scanOrphanReferences FK-off 8 invariants
- Scheduler: rebuild_from_db from session DB tasks
- ProjectionStore: 20+ event types, subscribe, rebuild from repos
- MigrationRunner: constructor accepts optional db_path
- e2e.ts: replaced hardcoded  with 14 real test/check gates
- wiring.ts: eventIngestor.ingest (durable path, INV-2)
- init.ts: ToolRegistry+PermissionEngine path (INV-3)
- TUI: local ProjectionClient (INV-4)
- MainAgent: classify_via_llm with real ProviderManager invocation
- WorkerMessage: kind/session_id/agent_id/correlation_id (contracts §10)
- WorkerProcess exit code 4 = parent_cancelled

Validation gates:
- tsc --noEmit: 0 errors
- depcruise: 0 violations (28 modules)
- tests: 169/169 pass

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-04 11:43:19 +08:00
parent 223ff1bc7c
commit ea7cf427dd
37 changed files with 1182 additions and 610 deletions

View File

@@ -19,6 +19,8 @@ export const fs_read: ToolDefinition = {
name: 'fs.read',
category: 'filesystem',
description: 'Read file contents',
version: 1,
output_schema: { type: 'object', properties: {}, required: [] },
input_schema: {
type: 'object',
properties: {
@@ -29,7 +31,7 @@ export const fs_read: ToolDefinition = {
},
required: ['path']
},
permissions: { read: true, write: false, network: false },
permissions: { read_paths: { allow: ["*"] } },
streaming: false
}
@@ -37,6 +39,8 @@ export const fs_write: ToolDefinition = {
name: 'fs.write',
category: 'filesystem',
description: 'Write content to file',
version: 1,
output_schema: { type: 'object', properties: {}, required: [] },
input_schema: {
type: 'object',
properties: {
@@ -47,7 +51,7 @@ export const fs_write: ToolDefinition = {
},
required: ['path', 'content']
},
permissions: { read: false, write: true, network: false },
permissions: { write_paths: { allow: ["*"] } },
streaming: false
}
@@ -55,6 +59,8 @@ export const fs_edit: ToolDefinition = {
name: 'fs.edit',
category: 'filesystem',
description: 'Edit a file by replacing exact text',
version: 1,
output_schema: { type: 'object', properties: {}, required: [] },
input_schema: {
type: 'object',
properties: {
@@ -65,7 +71,7 @@ export const fs_edit: ToolDefinition = {
},
required: ['path', 'find', 'replace']
},
permissions: { read: true, write: true, network: false },
permissions: { read_paths: { allow: ["*"] }, write_paths: { allow: ["*"] } },
streaming: false
}
@@ -73,6 +79,8 @@ export const fs_patch: ToolDefinition = {
name: 'fs.patch',
category: 'filesystem',
description: 'Apply a unified diff patch to a file',
version: 1,
output_schema: { type: 'object', properties: {}, required: [] },
input_schema: {
type: 'object',
properties: {
@@ -82,7 +90,7 @@ export const fs_patch: ToolDefinition = {
},
required: ['path', 'patch']
},
permissions: { read: true, write: true, network: false },
permissions: { read_paths: { allow: ["*"] }, write_paths: { allow: ["*"] } },
streaming: false
}
@@ -90,6 +98,8 @@ export const fs_list: ToolDefinition = {
name: 'fs.list',
category: 'filesystem',
description: 'List directory contents',
version: 1,
output_schema: { type: 'object', properties: {}, required: [] },
input_schema: {
type: 'object',
properties: {
@@ -100,7 +110,7 @@ export const fs_list: ToolDefinition = {
},
required: ['path']
},
permissions: { read: true, write: false, network: false },
permissions: { read_paths: { allow: ["*"] } },
streaming: false
}
@@ -126,7 +136,7 @@ export function createFsExecutors(project_root: string) {
const full_path = resolve_path(path)
if (!existsSync(full_path)) {
return create_result(call.id, 'fs.read', 'error', { message: `File not found: ${path}` })
return create_result(call.call_id, 'fs.read', 'error', { message: `File not found: ${path}` })
}
try {
@@ -143,9 +153,9 @@ export function createFsExecutors(project_root: string) {
? content.toString('base64')
: content.toString('utf-8')
return create_result(call.id, 'fs.read', 'text', { content: output, size: content.length })
return create_result(call.call_id, 'fs.read', 'text', { content: output, size: content.length })
} catch (error) {
return create_result(call.id, 'fs.read', 'error', { message: error instanceof Error ? error.message : String(error) })
return create_result(call.call_id, 'fs.read', 'error', { message: error instanceof Error ? error.message : String(error) })
}
},
@@ -172,9 +182,9 @@ export function createFsExecutors(project_root: string) {
: Buffer.from(content, 'utf-8')
writeFileSync(full_path, data)
return create_result(call.id, 'fs.write', 'text', { message: `Written to ${path}`, size: data.length })
return create_result(call.call_id, 'fs.write', 'text', { message: `Written to ${path}`, size: data.length })
} catch (error) {
return create_result(call.id, 'fs.write', 'error', { message: error instanceof Error ? error.message : String(error) })
return create_result(call.call_id, 'fs.write', 'error', { message: error instanceof Error ? error.message : String(error) })
}
},
@@ -189,7 +199,7 @@ export function createFsExecutors(project_root: string) {
const full_path = resolve_path(path)
if (!existsSync(full_path)) {
return create_result(call.id, 'fs.edit', 'error', { message: `File not found: ${path}` })
return create_result(call.call_id, 'fs.edit', 'error', { message: `File not found: ${path}` })
}
try {
@@ -197,7 +207,7 @@ export function createFsExecutors(project_root: string) {
// Read-before-edit enforcement (DD §9.4)
if (!original.includes(find)) {
return create_result(call.id, 'fs.edit', 'error', { message: 'Exact text not found in file' })
return create_result(call.call_id, 'fs.edit', 'error', { message: 'Exact text not found in file' })
}
let edited: string
@@ -210,7 +220,7 @@ export function createFsExecutors(project_root: string) {
writeFileSync(full_path, edited, 'utf-8')
// Emit diff artifact (DD §9.4)
return create_result(call.id, 'fs.edit', 'text', {
return create_result(call.call_id, 'fs.edit', 'text', {
message: `Edited ${path}`,
changes: {
before: find,
@@ -219,7 +229,7 @@ export function createFsExecutors(project_root: string) {
}
})
} catch (error) {
return create_result(call.id, 'fs.edit', 'error', { message: error instanceof Error ? error.message : String(error) })
return create_result(call.call_id, 'fs.edit', 'error', { message: error instanceof Error ? error.message : String(error) })
}
},
@@ -233,7 +243,7 @@ export function createFsExecutors(project_root: string) {
const full_path = resolve_path(path)
if (!existsSync(full_path) && !create_if_missing) {
return create_result(call.id, 'fs.patch', 'error', { message: `File not found: ${path}` })
return create_result(call.call_id, 'fs.patch', 'error', { message: `File not found: ${path}` })
}
// Simplified patch application - in production use diff library
@@ -256,9 +266,9 @@ export function createFsExecutors(project_root: string) {
}
writeFileSync(full_path, result, 'utf-8')
return create_result(call.id, 'fs.patch', 'text', { message: `Patched ${path}` })
return create_result(call.call_id, 'fs.patch', 'text', { message: `Patched ${path}` })
} catch (error) {
return create_result(call.id, 'fs.patch', 'error', { message: error instanceof Error ? error.message : String(error) })
return create_result(call.call_id, 'fs.patch', 'error', { message: error instanceof Error ? error.message : String(error) })
}
},
@@ -273,14 +283,14 @@ export function createFsExecutors(project_root: string) {
const full_path = resolve_path(path)
if (!existsSync(full_path)) {
return create_result(call.id, 'fs.list', 'error', { message: `Directory not found: ${path}` })
return create_result(call.call_id, 'fs.list', 'error', { message: `Directory not found: ${path}` })
}
try {
const entries = list_directory(full_path, recursive, include_hidden, filter)
return create_result(call.id, 'fs.list', 'text', { entries, count: entries.length })
return create_result(call.call_id, 'fs.list', 'text', { entries, count: entries.length })
} catch (error) {
return create_result(call.id, 'fs.list', 'error', { message: error instanceof Error ? error.message : String(error) })
return create_result(call.call_id, 'fs.list', 'error', { message: error instanceof Error ? error.message : String(error) })
}
}
}
@@ -342,11 +352,5 @@ function create_result(
type: 'text' | 'error' | 'artifact',
content: Record<string, unknown>
): ToolResultEnvelope {
return {
call_id,
tool_name,
type,
content,
metadata: { timestamp: new Date().toISOString() as ISOTimeString }
}
return { status: type === "error" ? "error" : "ok", output: type === "error" ? undefined : content, error: type === "error" ? { error_id: call_id, kind: "tool_error", severity: "error", message: typeof content?.message === "string" ? content.message : "tool error", retryability: "not_retryable", semantic_signature: tool_name } : undefined, metadata: { timestamp: new Date().toISOString() as ISOTimeString, call_id, tool_name, type: type === "error" ? "error" : "ok" } }
}