P0-P8: Full V1.0.0 Alpha implementation + audit reports
Implements 123 tasks across 9 phases (T-001..T-809) totaling 146 source files. Monorepo (P0): - 7-package Bun + Turborepo + TypeScript monorepo - dependency-cruiser enforcing 7 forbidden edges + 5 deep-import rules Contracts (P0): - 16 type files (ids/error/event/runtime/ipc/task/worker-result/tool/artifact/evidence/project/provider/permission/ui/capability/platform) Storage & Events (P1): - DatabaseManager + MigrationRunner (19 tables, 22 indexes, 5 schema_meta seeds) - 16 repositories (Repository<T,I,U> pattern, INV-1 status columns via EventStore.project only) - EventSchemaRegistry (54 durable + 7 ephemeral), EventStore, EventBus, EventIngestor - Project/Session/Artifact/Evidence stores + 8-step Recovery Tools & Permission (P2): - PathClassifier (8 categories), CommandRiskAnalyzer (10 categories), SecretRedactor - PermissionEngine 6-layer evaluation (capability→profile→task_scope→risk→credential→user_prompt) - ToolRegistry with 20+ tools across fs/shell/git/project/artifact/context/permission/doctor - CapabilityManifestValidator + CapabilityRegistry LLM & Context (P3): - ModelConfigLoader, CapabilityMatrix, AnthropicCanonicalConverter - AnthropicAdapter + OpenAICompatibleAdapter - ProviderManager facade - PromptLayerLoader (L0/L1/L3/L5), CompactionPolicy, ContextAssembler Worker IPC & Scheduler (P4): - WorkerProtocol (NDJSON), WorkerProcess (exit codes 0-5), WorkerManager (spawn/handshake) - WorkerRuntime (INV-3: IPC only, no direct fs/shell/SQLite) - 5 worker roles (Executor/Reviewer/Debugger/Compactor/ExperienceMiner) - TaskGraph, WavePlanner, RetryPlanner, AgentMonitor, WorkspaceManager - Scheduler (state machine), 8-step Recovery C++ Toolchain (P5): - DiagnosticParser, CppProjectDetector, CMakeConfigurator, CppBuilder - CppTestRunner, CppcheckRunner, ClangdClient - CppToolRegistrar + capability manifest Projection & TUI (P6): - ProjectionStore (hydrate/apply/snapshot/subscribe) - TuiApp + 8 components (Session/Task/Agent/Tool/Diff/Evidence/Permission/Blocker/Hud) - ProjectionClient in-process ref Agents & Knowledge (P7): - MainAgent, ArchitectureDesigner - DebugKnowledgeStore + LearnedMemoryStore (single-writer, outbox model) - Role integration wiring CLI & Doctor & Release (P8): - Logger + DeveloperLogEncryptor (AES-256-GCM) - DoctorService (self_bootstrap first) - RuntimeApp + ServiceRegistry - 11 CLI commands: run/init/doctor/provider/resume/compact/history/session/restore/e2e/release - CliEntrypoint + air<TODO> Audit (in AirPlan/docs/): - Deepseek开发阶段审计.md (97 findings) - Opus开发阶段审计.md (140+ findings, 18 P0 blockers) - MiniMaxM3开发阶段审计.md (18 P0 blockers, focuses on executability) - AirPlan/TODO.md (technical debt + 42 TODOs by phase) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
233
packages/llm/src/CapabilityMatrix.ts
Executable file
233
packages/llm/src/CapabilityMatrix.ts
Executable file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* CapabilityMatrixRegistry - Provider capability matrix lookup
|
||||
*
|
||||
* Implements DD §12.2.
|
||||
* Holds ProviderCapabilityMatrix rows.
|
||||
*
|
||||
* @module packages/llm/src/CapabilityMatrix
|
||||
*/
|
||||
|
||||
export interface ProviderCapability {
|
||||
provider: string
|
||||
model: string
|
||||
max_tokens_output?: number
|
||||
max_tokens_input?: number
|
||||
supports_thinking?: boolean
|
||||
supports_vision?: boolean
|
||||
supports_tools?: boolean
|
||||
supports_streaming?: boolean
|
||||
supports_json_mode?: boolean
|
||||
supports_temperature?: boolean
|
||||
supports_top_p?: boolean
|
||||
}
|
||||
|
||||
export interface ProviderCapabilityMatrix {
|
||||
provider: string
|
||||
model_pattern: string
|
||||
capabilities: Omit<ProviderCapability, 'provider' | 'model'>
|
||||
}
|
||||
|
||||
// Capability matrix - would be loaded from provider-capability-matrix-v1.md
|
||||
const CAPABILITY_MATRIX: ProviderCapabilityMatrix[] = [
|
||||
{
|
||||
provider: 'anthropic',
|
||||
model_pattern: '^claude-opus-4-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 200000,
|
||||
max_tokens_input: 200000,
|
||||
supports_thinking: true,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'anthropic',
|
||||
model_pattern: '^claude-sonnet-4-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 200000,
|
||||
max_tokens_input: 200000,
|
||||
supports_thinking: true,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'anthropic',
|
||||
model_pattern: '^claude-haiku-4-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 200000,
|
||||
max_tokens_input: 200000,
|
||||
supports_thinking: false,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'openai',
|
||||
model_pattern: '^gpt-5-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 128000,
|
||||
max_tokens_input: 128000,
|
||||
supports_thinking: true,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'openai',
|
||||
model_pattern: '^gpt-4[ot]-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 128000,
|
||||
max_tokens_input: 128000,
|
||||
supports_thinking: false,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'openai-compatible',
|
||||
model_pattern: '.*',
|
||||
capabilities: {
|
||||
// Defaults for compatible providers - actual capability varies
|
||||
max_tokens_output: 4096,
|
||||
max_tokens_input: 128000,
|
||||
supports_thinking: false,
|
||||
supports_vision: false,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'glm',
|
||||
model_pattern: '^glm-5-.*',
|
||||
capabilities: {
|
||||
max_tokens_output: 128000,
|
||||
max_tokens_input: 128000,
|
||||
supports_thinking: true,
|
||||
supports_vision: true,
|
||||
supports_tools: true,
|
||||
supports_streaming: true,
|
||||
supports_json_mode: true,
|
||||
supports_temperature: true,
|
||||
supports_top_p: true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
export class CapabilityMatrixRegistry {
|
||||
private matrix: ProviderCapabilityMatrix[]
|
||||
|
||||
constructor(matrix?: ProviderCapabilityMatrix[]) {
|
||||
this.matrix = matrix || CAPABILITY_MATRIX
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up capabilities for a specific provider/model.
|
||||
*/
|
||||
lookup(provider: string, model: string): ProviderCapability | undefined {
|
||||
// Find matching entry
|
||||
for (const entry of this.matrix) {
|
||||
if (entry.provider !== provider) continue
|
||||
|
||||
const regex = new RegExp(entry.model_pattern)
|
||||
if (regex.test(model)) {
|
||||
return {
|
||||
provider,
|
||||
model,
|
||||
...entry.capabilities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* List all models for a provider.
|
||||
*/
|
||||
list_models(provider: string): string[] {
|
||||
const models: string[] = []
|
||||
|
||||
for (const entry of this.matrix) {
|
||||
if (entry.provider === provider) {
|
||||
// Extract example model name from pattern
|
||||
const example = entry.model_pattern.replace(/^\^|\$.*$/g, '')
|
||||
models.push(example || entry.model_pattern)
|
||||
}
|
||||
}
|
||||
|
||||
return models
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a provider/model supports a specific capability.
|
||||
*/
|
||||
supports(provider: string, model: string, capability: keyof Omit<ProviderCapability, 'provider' | 'model'>): boolean {
|
||||
const caps = this.lookup(provider, model)
|
||||
if (!caps) return false
|
||||
|
||||
return caps[capability] === true
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the best model for a set of requirements.
|
||||
*/
|
||||
find_best(
|
||||
provider: string,
|
||||
requirements: {
|
||||
min_output_tokens?: number
|
||||
supports_thinking?: boolean
|
||||
supports_tools?: boolean
|
||||
}
|
||||
): string | undefined {
|
||||
const entries = this.matrix.filter(e => e.provider === provider)
|
||||
|
||||
for (const entry of entries) {
|
||||
const caps = entry.capabilities
|
||||
|
||||
if (requirements.min_output_tokens && (!caps.max_tokens_output || caps.max_tokens_output < requirements.min_output_tokens)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (requirements.supports_thinking && !caps.supports_thinking) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (requirements.supports_tools && !caps.supports_tools) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Return first matching model pattern
|
||||
return entry.model_pattern.replace(/[\^$]/g, '')
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function createCapabilityMatrixRegistry(): CapabilityMatrixRegistry {
|
||||
return new CapabilityMatrixRegistry()
|
||||
}
|
||||
Reference in New Issue
Block a user