erosolar-cli 1.7.284 → 1.7.285
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/README.md +148 -24
- package/dist/alpha-zero/agentWrapper.d.ts +84 -0
- package/dist/alpha-zero/agentWrapper.d.ts.map +1 -0
- package/dist/alpha-zero/agentWrapper.js +171 -0
- package/dist/alpha-zero/agentWrapper.js.map +1 -0
- package/dist/alpha-zero/codeEvaluator.d.ts +25 -0
- package/dist/alpha-zero/codeEvaluator.d.ts.map +1 -0
- package/dist/alpha-zero/codeEvaluator.js +273 -0
- package/dist/alpha-zero/codeEvaluator.js.map +1 -0
- package/dist/alpha-zero/competitiveRunner.d.ts +66 -0
- package/dist/alpha-zero/competitiveRunner.d.ts.map +1 -0
- package/dist/alpha-zero/competitiveRunner.js +224 -0
- package/dist/alpha-zero/competitiveRunner.js.map +1 -0
- package/dist/alpha-zero/index.d.ts +67 -0
- package/dist/alpha-zero/index.d.ts.map +1 -0
- package/dist/alpha-zero/index.js +99 -0
- package/dist/alpha-zero/index.js.map +1 -0
- package/dist/alpha-zero/introspection.d.ts +128 -0
- package/dist/alpha-zero/introspection.d.ts.map +1 -0
- package/dist/alpha-zero/introspection.js +300 -0
- package/dist/alpha-zero/introspection.js.map +1 -0
- package/dist/alpha-zero/metricsTracker.d.ts +71 -0
- package/dist/alpha-zero/metricsTracker.d.ts.map +1 -0
- package/dist/{core → alpha-zero}/metricsTracker.js +5 -2
- package/dist/alpha-zero/metricsTracker.js.map +1 -0
- package/dist/alpha-zero/security/core.d.ts +125 -0
- package/dist/alpha-zero/security/core.d.ts.map +1 -0
- package/dist/alpha-zero/security/core.js +271 -0
- package/dist/alpha-zero/security/core.js.map +1 -0
- package/dist/alpha-zero/security/google.d.ts +125 -0
- package/dist/alpha-zero/security/google.d.ts.map +1 -0
- package/dist/alpha-zero/security/google.js +311 -0
- package/dist/alpha-zero/security/google.js.map +1 -0
- package/dist/alpha-zero/security/googleLoader.d.ts +17 -0
- package/dist/alpha-zero/security/googleLoader.d.ts.map +1 -0
- package/dist/alpha-zero/security/googleLoader.js +41 -0
- package/dist/alpha-zero/security/googleLoader.js.map +1 -0
- package/dist/alpha-zero/security/index.d.ts +29 -0
- package/dist/alpha-zero/security/index.d.ts.map +1 -0
- package/dist/alpha-zero/security/index.js +32 -0
- package/dist/alpha-zero/security/index.js.map +1 -0
- package/dist/alpha-zero/security/simulation.d.ts +124 -0
- package/dist/alpha-zero/security/simulation.d.ts.map +1 -0
- package/dist/alpha-zero/security/simulation.js +277 -0
- package/dist/alpha-zero/security/simulation.js.map +1 -0
- package/dist/alpha-zero/selfModification.d.ts +109 -0
- package/dist/alpha-zero/selfModification.d.ts.map +1 -0
- package/dist/alpha-zero/selfModification.js +233 -0
- package/dist/alpha-zero/selfModification.js.map +1 -0
- package/dist/alpha-zero/types.d.ts +170 -0
- package/dist/alpha-zero/types.d.ts.map +1 -0
- package/dist/alpha-zero/types.js +31 -0
- package/dist/alpha-zero/types.js.map +1 -0
- package/dist/bin/erosolar.js +0 -1
- package/dist/bin/erosolar.js.map +1 -1
- package/dist/capabilities/agentSpawningCapability.d.ts.map +1 -1
- package/dist/capabilities/agentSpawningCapability.js +31 -56
- package/dist/capabilities/agentSpawningCapability.js.map +1 -1
- package/dist/capabilities/securityTestingCapability.d.ts +13 -0
- package/dist/capabilities/securityTestingCapability.d.ts.map +1 -0
- package/dist/capabilities/securityTestingCapability.js +25 -0
- package/dist/capabilities/securityTestingCapability.js.map +1 -0
- package/dist/contracts/agent-schemas.json +15 -0
- package/dist/contracts/tools.schema.json +9 -0
- package/dist/core/agent.d.ts +2 -2
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js.map +1 -1
- package/dist/core/aiFlowOptimizer.d.ts +26 -0
- package/dist/core/aiFlowOptimizer.d.ts.map +1 -0
- package/dist/core/aiFlowOptimizer.js +31 -0
- package/dist/core/aiFlowOptimizer.js.map +1 -0
- package/dist/core/aiOptimizationEngine.d.ts +158 -0
- package/dist/core/aiOptimizationEngine.d.ts.map +1 -0
- package/dist/core/aiOptimizationEngine.js +428 -0
- package/dist/core/aiOptimizationEngine.js.map +1 -0
- package/dist/core/aiOptimizationIntegration.d.ts +93 -0
- package/dist/core/aiOptimizationIntegration.d.ts.map +1 -0
- package/dist/core/aiOptimizationIntegration.js +250 -0
- package/dist/core/aiOptimizationIntegration.js.map +1 -0
- package/dist/core/customCommands.d.ts +0 -1
- package/dist/core/customCommands.d.ts.map +1 -1
- package/dist/core/customCommands.js +0 -3
- package/dist/core/customCommands.js.map +1 -1
- package/dist/core/enhancedErrorRecovery.d.ts +100 -0
- package/dist/core/enhancedErrorRecovery.d.ts.map +1 -0
- package/dist/core/enhancedErrorRecovery.js +345 -0
- package/dist/core/enhancedErrorRecovery.js.map +1 -0
- package/dist/core/hooksSystem.d.ts +65 -0
- package/dist/core/hooksSystem.d.ts.map +1 -0
- package/dist/core/hooksSystem.js +273 -0
- package/dist/core/hooksSystem.js.map +1 -0
- package/dist/core/memorySystem.d.ts +48 -0
- package/dist/core/memorySystem.d.ts.map +1 -0
- package/dist/core/memorySystem.js +271 -0
- package/dist/core/memorySystem.js.map +1 -0
- package/dist/core/toolPreconditions.d.ts.map +1 -1
- package/dist/core/toolPreconditions.js +14 -0
- package/dist/core/toolPreconditions.js.map +1 -1
- package/dist/core/toolRuntime.d.ts +1 -22
- package/dist/core/toolRuntime.d.ts.map +1 -1
- package/dist/core/toolRuntime.js +5 -0
- package/dist/core/toolRuntime.js.map +1 -1
- package/dist/core/toolValidation.d.ts.map +1 -1
- package/dist/core/toolValidation.js +3 -14
- package/dist/core/toolValidation.js.map +1 -1
- package/dist/core/unified/errors.d.ts +189 -0
- package/dist/core/unified/errors.d.ts.map +1 -0
- package/dist/core/unified/errors.js +497 -0
- package/dist/core/unified/errors.js.map +1 -0
- package/dist/core/unified/index.d.ts +19 -0
- package/dist/core/unified/index.d.ts.map +1 -0
- package/dist/core/unified/index.js +68 -0
- package/dist/core/unified/index.js.map +1 -0
- package/dist/core/unified/schema.d.ts +101 -0
- package/dist/core/unified/schema.d.ts.map +1 -0
- package/dist/core/unified/schema.js +350 -0
- package/dist/core/unified/schema.js.map +1 -0
- package/dist/core/unified/toolRuntime.d.ts +179 -0
- package/dist/core/unified/toolRuntime.d.ts.map +1 -0
- package/dist/core/unified/toolRuntime.js +517 -0
- package/dist/core/unified/toolRuntime.js.map +1 -0
- package/dist/core/unified/tools.d.ts +127 -0
- package/dist/core/unified/tools.d.ts.map +1 -0
- package/dist/core/unified/tools.js +1333 -0
- package/dist/core/unified/tools.js.map +1 -0
- package/dist/core/unified/types.d.ts +352 -0
- package/dist/core/unified/types.d.ts.map +1 -0
- package/dist/core/unified/types.js +12 -0
- package/dist/core/unified/types.js.map +1 -0
- package/dist/core/unified/version.d.ts +209 -0
- package/dist/core/unified/version.d.ts.map +1 -0
- package/dist/core/unified/version.js +454 -0
- package/dist/core/unified/version.js.map +1 -0
- package/dist/core/validationRunner.d.ts +3 -1
- package/dist/core/validationRunner.d.ts.map +1 -1
- package/dist/core/validationRunner.js.map +1 -1
- package/dist/headless/headlessApp.d.ts.map +1 -1
- package/dist/headless/headlessApp.js +0 -21
- package/dist/headless/headlessApp.js.map +1 -1
- package/dist/mcp/sseClient.d.ts.map +1 -1
- package/dist/mcp/sseClient.js +18 -9
- package/dist/mcp/sseClient.js.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.d.ts +6 -0
- package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.js +10 -4
- package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +2 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/plugins/tools/security/securityPlugin.d.ts +3 -0
- package/dist/plugins/tools/security/securityPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/security/securityPlugin.js +12 -0
- package/dist/plugins/tools/security/securityPlugin.js.map +1 -0
- package/dist/runtime/agentSession.d.ts +2 -2
- package/dist/runtime/agentSession.d.ts.map +1 -1
- package/dist/runtime/agentSession.js +2 -2
- package/dist/runtime/agentSession.js.map +1 -1
- package/dist/security/active-stack-security.d.ts +112 -0
- package/dist/security/active-stack-security.d.ts.map +1 -0
- package/dist/security/active-stack-security.js +296 -0
- package/dist/security/active-stack-security.js.map +1 -0
- package/dist/security/advanced-persistence-research.d.ts +92 -0
- package/dist/security/advanced-persistence-research.d.ts.map +1 -0
- package/dist/security/advanced-persistence-research.js +195 -0
- package/dist/security/advanced-persistence-research.js.map +1 -0
- package/dist/security/advanced-targeting.d.ts +119 -0
- package/dist/security/advanced-targeting.d.ts.map +1 -0
- package/dist/security/advanced-targeting.js +233 -0
- package/dist/security/advanced-targeting.js.map +1 -0
- package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
- package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
- package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
- package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
- package/dist/security/authorization/securityAuthorization.d.ts +88 -0
- package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
- package/dist/security/authorization/securityAuthorization.js +172 -0
- package/dist/security/authorization/securityAuthorization.js.map +1 -0
- package/dist/security/comprehensive-targeting.d.ts +85 -0
- package/dist/security/comprehensive-targeting.d.ts.map +1 -0
- package/dist/security/comprehensive-targeting.js +438 -0
- package/dist/security/comprehensive-targeting.js.map +1 -0
- package/dist/security/global-security-integration.d.ts +91 -0
- package/dist/security/global-security-integration.d.ts.map +1 -0
- package/dist/security/global-security-integration.js +218 -0
- package/dist/security/global-security-integration.js.map +1 -0
- package/dist/security/index.d.ts +38 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +47 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/persistence-analyzer.d.ts +56 -0
- package/dist/security/persistence-analyzer.d.ts.map +1 -0
- package/dist/security/persistence-analyzer.js +187 -0
- package/dist/security/persistence-analyzer.js.map +1 -0
- package/dist/security/persistence-cli.d.ts +36 -0
- package/dist/security/persistence-cli.d.ts.map +1 -0
- package/dist/security/persistence-cli.js +160 -0
- package/dist/security/persistence-cli.js.map +1 -0
- package/dist/security/persistence-research.d.ts +92 -0
- package/dist/security/persistence-research.d.ts.map +1 -0
- package/dist/security/persistence-research.js +364 -0
- package/dist/security/persistence-research.js.map +1 -0
- package/dist/security/research/persistenceResearch.d.ts +97 -0
- package/dist/security/research/persistenceResearch.d.ts.map +1 -0
- package/dist/security/research/persistenceResearch.js +282 -0
- package/dist/security/research/persistenceResearch.js.map +1 -0
- package/dist/security/security-integration.d.ts +74 -0
- package/dist/security/security-integration.d.ts.map +1 -0
- package/dist/security/security-integration.js +137 -0
- package/dist/security/security-integration.js.map +1 -0
- package/dist/security/security-testing-framework.d.ts +112 -0
- package/dist/security/security-testing-framework.d.ts.map +1 -0
- package/dist/security/security-testing-framework.js +364 -0
- package/dist/security/security-testing-framework.js.map +1 -0
- package/dist/security/simulation/attackSimulation.d.ts +93 -0
- package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
- package/dist/security/simulation/attackSimulation.js +341 -0
- package/dist/security/simulation/attackSimulation.js.map +1 -0
- package/dist/security/strategic-operations.d.ts +100 -0
- package/dist/security/strategic-operations.d.ts.map +1 -0
- package/dist/security/strategic-operations.js +276 -0
- package/dist/security/strategic-operations.js.map +1 -0
- package/dist/security/tool-security-wrapper.d.ts +58 -0
- package/dist/security/tool-security-wrapper.d.ts.map +1 -0
- package/dist/security/tool-security-wrapper.js +156 -0
- package/dist/security/tool-security-wrapper.js.map +1 -0
- package/dist/shell/claudeCodeStreamHandler.d.ts +145 -0
- package/dist/shell/claudeCodeStreamHandler.d.ts.map +1 -0
- package/dist/shell/claudeCodeStreamHandler.js +322 -0
- package/dist/shell/claudeCodeStreamHandler.js.map +1 -0
- package/dist/shell/inputQueueManager.d.ts +144 -0
- package/dist/shell/inputQueueManager.d.ts.map +1 -0
- package/dist/shell/inputQueueManager.js +290 -0
- package/dist/shell/inputQueueManager.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +7 -22
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +159 -226
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/metricsTracker.d.ts +60 -0
- package/dist/shell/metricsTracker.d.ts.map +1 -0
- package/dist/shell/metricsTracker.js +119 -0
- package/dist/shell/metricsTracker.js.map +1 -0
- package/dist/shell/shellApp.d.ts +0 -2
- package/dist/shell/shellApp.d.ts.map +1 -1
- package/dist/shell/shellApp.js +9 -40
- package/dist/shell/shellApp.js.map +1 -1
- package/dist/shell/streamingOutputManager.d.ts +115 -0
- package/dist/shell/streamingOutputManager.d.ts.map +1 -0
- package/dist/shell/streamingOutputManager.js +225 -0
- package/dist/shell/streamingOutputManager.js.map +1 -0
- package/dist/shell/systemPrompt.d.ts.map +1 -1
- package/dist/shell/systemPrompt.js +4 -1
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/shell/terminalInput.d.ts +186 -78
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +927 -496
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +35 -28
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +50 -26
- package/dist/shell/terminalInputAdapter.js.map +1 -1
- package/dist/subagents/taskRunner.d.ts +1 -7
- package/dist/subagents/taskRunner.d.ts.map +1 -1
- package/dist/subagents/taskRunner.js +47 -180
- package/dist/subagents/taskRunner.js.map +1 -1
- package/dist/tools/securityTools.d.ts +22 -0
- package/dist/tools/securityTools.d.ts.map +1 -0
- package/dist/tools/securityTools.js +448 -0
- package/dist/tools/securityTools.js.map +1 -0
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +12 -13
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +44 -23
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +286 -139
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/persistentPrompt.d.ts +50 -0
- package/dist/ui/persistentPrompt.d.ts.map +1 -0
- package/dist/ui/persistentPrompt.js +92 -0
- package/dist/ui/persistentPrompt.js.map +1 -0
- package/dist/ui/terminalUISchema.d.ts +195 -0
- package/dist/ui/terminalUISchema.d.ts.map +1 -0
- package/dist/ui/terminalUISchema.js +113 -0
- package/dist/ui/terminalUISchema.js.map +1 -0
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +8 -6
- package/dist/ui/theme.js.map +1 -1
- package/dist/ui/toolDisplay.d.ts +158 -0
- package/dist/ui/toolDisplay.d.ts.map +1 -1
- package/dist/ui/toolDisplay.js +348 -0
- package/dist/ui/toolDisplay.js.map +1 -1
- package/dist/ui/unified/layout.d.ts +0 -1
- package/dist/ui/unified/layout.d.ts.map +1 -1
- package/dist/ui/unified/layout.js +25 -15
- package/dist/ui/unified/layout.js.map +1 -1
- package/package.json +1 -1
- package/scripts/deploy-security-capabilities.js +178 -0
- package/dist/core/hooks.d.ts +0 -113
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js +0 -267
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/metricsTracker.d.ts +0 -122
- package/dist/core/metricsTracker.d.ts.map +0 -1
- package/dist/core/metricsTracker.js.map +0 -1
- package/dist/core/securityAssessment.d.ts +0 -91
- package/dist/core/securityAssessment.d.ts.map +0 -1
- package/dist/core/securityAssessment.js +0 -580
- package/dist/core/securityAssessment.js.map +0 -1
- package/dist/core/verification.d.ts +0 -137
- package/dist/core/verification.d.ts.map +0 -1
- package/dist/core/verification.js +0 -323
- package/dist/core/verification.js.map +0 -1
- package/dist/subagents/agentConfig.d.ts +0 -27
- package/dist/subagents/agentConfig.d.ts.map +0 -1
- package/dist/subagents/agentConfig.js +0 -89
- package/dist/subagents/agentConfig.js.map +0 -1
- package/dist/subagents/agentRegistry.d.ts +0 -33
- package/dist/subagents/agentRegistry.d.ts.map +0 -1
- package/dist/subagents/agentRegistry.js +0 -162
- package/dist/subagents/agentRegistry.js.map +0 -1
- package/dist/utils/frontmatter.d.ts +0 -10
- package/dist/utils/frontmatter.d.ts.map +0 -1
- package/dist/utils/frontmatter.js +0 -78
- package/dist/utils/frontmatter.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight AI flow optimizer stub.
|
|
3
|
+
*/
|
|
4
|
+
export interface AIFlowMetrics {
|
|
5
|
+
latencyMs: number;
|
|
6
|
+
toolCalls: number;
|
|
7
|
+
tokenUsage?: number;
|
|
8
|
+
parallelExecution?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface OptimizedFlow {
|
|
11
|
+
originalMetrics: AIFlowMetrics;
|
|
12
|
+
optimizedMetrics: AIFlowMetrics;
|
|
13
|
+
suggestions: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface OptimizationInsights {
|
|
16
|
+
patterns: string[];
|
|
17
|
+
averageLatency?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class AIFlowOptimizer {
|
|
20
|
+
constructor(_options?: {
|
|
21
|
+
workingDir?: string;
|
|
22
|
+
});
|
|
23
|
+
analyzeFlow(flowData: any): OptimizedFlow;
|
|
24
|
+
getOptimizationInsights(): OptimizationInsights;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=aiFlowOptimizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiFlowOptimizer.d.ts","sourceRoot":"","sources":["../../src/core/aiFlowOptimizer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,aAAa,CAAC;IAC/B,gBAAgB,EAAE,aAAa,CAAC;IAChC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,eAAe;gBAEd,QAAQ,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO;IAElD,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,aAAa;IAoBzC,uBAAuB,IAAI,oBAAoB;CAMhD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight AI flow optimizer stub.
|
|
3
|
+
*/
|
|
4
|
+
export class AIFlowOptimizer {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
constructor(_options = {}) { }
|
|
7
|
+
analyzeFlow(flowData) {
|
|
8
|
+
const baseline = {
|
|
9
|
+
latencyMs: Number(flowData?.latencyMs ?? 1000),
|
|
10
|
+
toolCalls: Number(flowData?.toolCalls ?? 1),
|
|
11
|
+
tokenUsage: Number(flowData?.tokenUsage ?? 0),
|
|
12
|
+
parallelExecution: Boolean(flowData?.parallelExecution ?? false),
|
|
13
|
+
};
|
|
14
|
+
const optimized = {
|
|
15
|
+
...baseline,
|
|
16
|
+
latencyMs: Math.max(100, Math.round(baseline.latencyMs * 0.9)),
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
originalMetrics: baseline,
|
|
20
|
+
optimizedMetrics: optimized,
|
|
21
|
+
suggestions: ['Enable parallel execution where safe', 'Trim redundant tool calls'],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getOptimizationInsights() {
|
|
25
|
+
return {
|
|
26
|
+
patterns: ['stub-optimization-pattern'],
|
|
27
|
+
averageLatency: undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=aiFlowOptimizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiFlowOptimizer.js","sourceRoot":"","sources":["../../src/core/aiFlowOptimizer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,MAAM,OAAO,eAAe;IAC1B,6DAA6D;IAC7D,YAAY,WAAoC,EAAE,IAAG,CAAC;IAEtD,WAAW,CAAC,QAAa;QACvB,MAAM,QAAQ,GAAkB;YAC9B,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAC;YAC9C,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,IAAI,CAAC,CAAC;YAC3C,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,IAAI,CAAC,CAAC;YAC7C,iBAAiB,EAAE,OAAO,CAAC,QAAQ,EAAE,iBAAiB,IAAI,KAAK,CAAC;SACjE,CAAC;QAEF,MAAM,SAAS,GAAkB;YAC/B,GAAG,QAAQ;YACX,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;SAC/D,CAAC;QAEF,OAAO;YACL,eAAe,EAAE,QAAQ;YACzB,gBAAgB,EAAE,SAAS;YAC3B,WAAW,EAAE,CAAC,sCAAsC,EAAE,2BAA2B,CAAC;SACnF,CAAC;IACJ,CAAC;IAED,uBAAuB;QACrB,OAAO;YACL,QAAQ,EAAE,CAAC,2BAA2B,CAAC;YACvC,cAAc,EAAE,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Optimization Engine - Advanced Decision Making and Error Recovery
|
|
3
|
+
*
|
|
4
|
+
* Provides intelligent problem-solving with:
|
|
5
|
+
* - Optimal solution path analysis
|
|
6
|
+
* - Multi-strategy decision making
|
|
7
|
+
* - Intelligent error recovery
|
|
8
|
+
* - Performance optimization
|
|
9
|
+
* - Context-aware reasoning
|
|
10
|
+
*
|
|
11
|
+
* @license MIT
|
|
12
|
+
* @author Bo Shang
|
|
13
|
+
*/
|
|
14
|
+
export declare enum ProblemComplexity {
|
|
15
|
+
TRIVIAL = "trivial",// Single-step, deterministic solution
|
|
16
|
+
SIMPLE = "simple",// 2-3 steps, clear path
|
|
17
|
+
MODERATE = "moderate",// Multiple steps, some uncertainty
|
|
18
|
+
COMPLEX = "complex",// Complex dependencies, multiple approaches
|
|
19
|
+
VERY_COMPLEX = "very_complex"
|
|
20
|
+
}
|
|
21
|
+
export declare enum SolutionStrategy {
|
|
22
|
+
DIRECT = "direct",// Straightforward implementation
|
|
23
|
+
INCREMENTAL = "incremental",// Step-by-step with validation
|
|
24
|
+
DEFENSIVE = "defensive",// Conservative with fallbacks
|
|
25
|
+
OPTIMISTIC = "optimistic",// Aggressive with rollback
|
|
26
|
+
ADAPTIVE = "adaptive",// Dynamic strategy selection
|
|
27
|
+
EXPLORATORY = "exploratory"
|
|
28
|
+
}
|
|
29
|
+
export interface ProblemAnalysis {
|
|
30
|
+
complexity: ProblemComplexity;
|
|
31
|
+
riskLevel: 'low' | 'medium' | 'high';
|
|
32
|
+
dependencies: string[];
|
|
33
|
+
constraints: string[];
|
|
34
|
+
successCriteria: string[];
|
|
35
|
+
failurePoints: string[];
|
|
36
|
+
optimalStrategy: SolutionStrategy;
|
|
37
|
+
alternativeStrategies: SolutionStrategy[];
|
|
38
|
+
estimatedSteps: number;
|
|
39
|
+
confidence: number;
|
|
40
|
+
}
|
|
41
|
+
export interface SolutionPath {
|
|
42
|
+
strategy: SolutionStrategy;
|
|
43
|
+
steps: SolutionStep[];
|
|
44
|
+
validationPoints: ValidationPoint[];
|
|
45
|
+
rollbackPlan: RollbackStep[];
|
|
46
|
+
estimatedTime: number;
|
|
47
|
+
successProbability: number;
|
|
48
|
+
}
|
|
49
|
+
export interface SolutionStep {
|
|
50
|
+
id: string;
|
|
51
|
+
action: string;
|
|
52
|
+
tool?: string;
|
|
53
|
+
parameters?: Record<string, unknown>;
|
|
54
|
+
validation?: string;
|
|
55
|
+
fallback?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ValidationPoint {
|
|
58
|
+
stepId: string;
|
|
59
|
+
validationType: 'tool_output' | 'file_content' | 'test_result' | 'user_confirmation';
|
|
60
|
+
expectedPattern?: string;
|
|
61
|
+
failureAction: 'retry' | 'fallback' | 'abort';
|
|
62
|
+
}
|
|
63
|
+
export interface RollbackStep {
|
|
64
|
+
stepId: string;
|
|
65
|
+
action: string;
|
|
66
|
+
tool?: string;
|
|
67
|
+
parameters?: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
export interface ErrorRecoveryStrategy {
|
|
70
|
+
errorType: string;
|
|
71
|
+
errorPattern: RegExp;
|
|
72
|
+
recoveryActions: RecoveryAction[];
|
|
73
|
+
priority: 'immediate' | 'high' | 'medium' | 'low';
|
|
74
|
+
autoRecoverable: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface RecoveryAction {
|
|
77
|
+
action: string;
|
|
78
|
+
tool?: string;
|
|
79
|
+
parameters?: Record<string, unknown>;
|
|
80
|
+
validation?: string;
|
|
81
|
+
successProbability: number;
|
|
82
|
+
}
|
|
83
|
+
export declare class AIOptimizationEngine {
|
|
84
|
+
private readonly workingDir;
|
|
85
|
+
private readonly performanceThresholds;
|
|
86
|
+
constructor(options?: {
|
|
87
|
+
workingDir?: string;
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Analyze problem and determine optimal solution strategy
|
|
91
|
+
*/
|
|
92
|
+
analyzeProblem(problemDescription: string, context?: {
|
|
93
|
+
filesRead?: string[];
|
|
94
|
+
toolsUsed?: string[];
|
|
95
|
+
errorsEncountered?: string[];
|
|
96
|
+
complexityHints?: string[];
|
|
97
|
+
}): ProblemAnalysis;
|
|
98
|
+
/**
|
|
99
|
+
* Generate optimal solution path with validation and rollback
|
|
100
|
+
*/
|
|
101
|
+
generateSolutionPath(analysis: ProblemAnalysis, context: {
|
|
102
|
+
availableTools: string[];
|
|
103
|
+
currentState: Record<string, unknown>;
|
|
104
|
+
userPreferences?: {
|
|
105
|
+
riskTolerance: 'low' | 'medium' | 'high';
|
|
106
|
+
validationPreference: 'minimal' | 'balanced' | 'thorough';
|
|
107
|
+
};
|
|
108
|
+
}): SolutionPath;
|
|
109
|
+
/**
|
|
110
|
+
* Intelligent error recovery with multiple strategies
|
|
111
|
+
*/
|
|
112
|
+
recoverFromError(error: string, context: {
|
|
113
|
+
currentStep: SolutionStep;
|
|
114
|
+
analysis: ProblemAnalysis;
|
|
115
|
+
attemptedSolutions: string[];
|
|
116
|
+
availableTools: string[];
|
|
117
|
+
}): RecoveryAction[];
|
|
118
|
+
/**
|
|
119
|
+
* Optimize AI flow for efficiency and effectiveness
|
|
120
|
+
*/
|
|
121
|
+
optimizeAIFlow(currentFlow: {
|
|
122
|
+
toolCalls: Array<{
|
|
123
|
+
tool: string;
|
|
124
|
+
parameters: Record<string, unknown>;
|
|
125
|
+
}>;
|
|
126
|
+
contextUsage: {
|
|
127
|
+
filesRead: number;
|
|
128
|
+
searches: number;
|
|
129
|
+
edits: number;
|
|
130
|
+
};
|
|
131
|
+
validationRounds: number;
|
|
132
|
+
}): {
|
|
133
|
+
optimizedFlow: Array<{
|
|
134
|
+
tool: string;
|
|
135
|
+
parameters: Record<string, unknown>;
|
|
136
|
+
}>;
|
|
137
|
+
efficiencyGains: number;
|
|
138
|
+
recommendations: string[];
|
|
139
|
+
};
|
|
140
|
+
private assessComplexity;
|
|
141
|
+
private assessRisk;
|
|
142
|
+
private extractDependencies;
|
|
143
|
+
private extractConstraints;
|
|
144
|
+
private extractSuccessCriteria;
|
|
145
|
+
private identifyFailurePoints;
|
|
146
|
+
private selectOptimalStrategy;
|
|
147
|
+
private getAlternativeStrategies;
|
|
148
|
+
private estimateSteps;
|
|
149
|
+
private calculateConfidence;
|
|
150
|
+
private generateSteps;
|
|
151
|
+
private getErrorRecoveryStrategies;
|
|
152
|
+
private isStrategyApplicable;
|
|
153
|
+
private detectSequentialReads;
|
|
154
|
+
private mergeSequentialReads;
|
|
155
|
+
private calculateContextEfficiency;
|
|
156
|
+
private calculateEfficiencyGains;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=aiOptimizationEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiOptimizationEngine.d.ts","sourceRoot":"","sources":["../../src/core/aiOptimizationEngine.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Optimization Engine - Advanced Decision Making and Error Recovery
|
|
3
|
+
*
|
|
4
|
+
* Provides intelligent problem-solving with:
|
|
5
|
+
* - Optimal solution path analysis
|
|
6
|
+
* - Multi-strategy decision making
|
|
7
|
+
* - Intelligent error recovery
|
|
8
|
+
* - Performance optimization
|
|
9
|
+
* - Context-aware reasoning
|
|
10
|
+
*
|
|
11
|
+
* @license MIT
|
|
12
|
+
* @author Bo Shang
|
|
13
|
+
*/
|
|
14
|
+
export var ProblemComplexity;
|
|
15
|
+
(function (ProblemComplexity) {
|
|
16
|
+
ProblemComplexity["TRIVIAL"] = "trivial";
|
|
17
|
+
ProblemComplexity["SIMPLE"] = "simple";
|
|
18
|
+
ProblemComplexity["MODERATE"] = "moderate";
|
|
19
|
+
ProblemComplexity["COMPLEX"] = "complex";
|
|
20
|
+
ProblemComplexity["VERY_COMPLEX"] = "very_complex"; // High uncertainty, multiple failure points
|
|
21
|
+
})(ProblemComplexity || (ProblemComplexity = {}));
|
|
22
|
+
export var SolutionStrategy;
|
|
23
|
+
(function (SolutionStrategy) {
|
|
24
|
+
SolutionStrategy["DIRECT"] = "direct";
|
|
25
|
+
SolutionStrategy["INCREMENTAL"] = "incremental";
|
|
26
|
+
SolutionStrategy["DEFENSIVE"] = "defensive";
|
|
27
|
+
SolutionStrategy["OPTIMISTIC"] = "optimistic";
|
|
28
|
+
SolutionStrategy["ADAPTIVE"] = "adaptive";
|
|
29
|
+
SolutionStrategy["EXPLORATORY"] = "exploratory"; // Test multiple approaches
|
|
30
|
+
})(SolutionStrategy || (SolutionStrategy = {}));
|
|
31
|
+
export class AIOptimizationEngine {
|
|
32
|
+
workingDir;
|
|
33
|
+
performanceThresholds = {
|
|
34
|
+
maxSequentialReads: 3,
|
|
35
|
+
maxValidationRounds: 2,
|
|
36
|
+
maxRetryAttempts: 3,
|
|
37
|
+
contextEfficiencyThreshold: 0.7 // 70% context utilization
|
|
38
|
+
};
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
this.workingDir = options.workingDir ?? process.cwd();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Analyze problem and determine optimal solution strategy
|
|
44
|
+
*/
|
|
45
|
+
analyzeProblem(problemDescription, context = {}) {
|
|
46
|
+
const complexity = this.assessComplexity(problemDescription, context);
|
|
47
|
+
const riskLevel = this.assessRisk(problemDescription, context);
|
|
48
|
+
const dependencies = this.extractDependencies(problemDescription, context);
|
|
49
|
+
const constraints = this.extractConstraints(problemDescription);
|
|
50
|
+
const successCriteria = this.extractSuccessCriteria(problemDescription);
|
|
51
|
+
const failurePoints = this.identifyFailurePoints(problemDescription, context);
|
|
52
|
+
const optimalStrategy = this.selectOptimalStrategy(complexity, riskLevel, context);
|
|
53
|
+
const alternativeStrategies = this.getAlternativeStrategies(optimalStrategy, complexity);
|
|
54
|
+
const estimatedSteps = this.estimateSteps(complexity, problemDescription);
|
|
55
|
+
const confidence = this.calculateConfidence(complexity, context);
|
|
56
|
+
return {
|
|
57
|
+
complexity,
|
|
58
|
+
riskLevel,
|
|
59
|
+
dependencies,
|
|
60
|
+
constraints,
|
|
61
|
+
successCriteria,
|
|
62
|
+
failurePoints,
|
|
63
|
+
optimalStrategy,
|
|
64
|
+
alternativeStrategies,
|
|
65
|
+
estimatedSteps,
|
|
66
|
+
confidence
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate optimal solution path with validation and rollback
|
|
71
|
+
*/
|
|
72
|
+
generateSolutionPath(analysis, context) {
|
|
73
|
+
const strategy = analysis.optimalStrategy;
|
|
74
|
+
const steps = this.generateSteps(analysis, context);
|
|
75
|
+
const validationPoints = this.generateValidationPoints(steps, context);
|
|
76
|
+
const rollbackPlan = this.generateRollbackPlan(steps, analysis);
|
|
77
|
+
const estimatedTime = this.estimateTime(steps, analysis);
|
|
78
|
+
const successProbability = this.calculateSuccessProbability(analysis, context);
|
|
79
|
+
return {
|
|
80
|
+
strategy,
|
|
81
|
+
steps,
|
|
82
|
+
validationPoints,
|
|
83
|
+
rollbackPlan,
|
|
84
|
+
estimatedTime,
|
|
85
|
+
successProbability
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Intelligent error recovery with multiple strategies
|
|
90
|
+
*/
|
|
91
|
+
recoverFromError(error, context) {
|
|
92
|
+
const recoveryStrategies = this.getErrorRecoveryStrategies(error);
|
|
93
|
+
const applicableStrategies = recoveryStrategies.filter(strategy => this.isStrategyApplicable(strategy, context));
|
|
94
|
+
// Sort by priority and success probability
|
|
95
|
+
return applicableStrategies
|
|
96
|
+
.flatMap(strategy => strategy.recoveryActions)
|
|
97
|
+
.sort((a, b) => b.successProbability - a.successProbability)
|
|
98
|
+
.slice(0, 3); // Return top 3 recovery actions
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Optimize AI flow for efficiency and effectiveness
|
|
102
|
+
*/
|
|
103
|
+
optimizeAIFlow(currentFlow) {
|
|
104
|
+
const recommendations = [];
|
|
105
|
+
const optimizedFlow = [...currentFlow.toolCalls];
|
|
106
|
+
// Optimize sequential reads
|
|
107
|
+
const sequentialReads = this.detectSequentialReads(currentFlow.toolCalls);
|
|
108
|
+
if (sequentialReads.length > this.performanceThresholds.maxSequentialReads) {
|
|
109
|
+
recommendations.push(`Merge ${sequentialReads.length} sequential read operations into parallel reads`);
|
|
110
|
+
optimizedFlow.splice(0, optimizedFlow.length, ...this.mergeSequentialReads(optimizedFlow));
|
|
111
|
+
}
|
|
112
|
+
// Optimize validation timing
|
|
113
|
+
if (currentFlow.validationRounds > this.performanceThresholds.maxValidationRounds) {
|
|
114
|
+
recommendations.push(`Reduce validation rounds from ${currentFlow.validationRounds} to 1 (deferred validation)`);
|
|
115
|
+
}
|
|
116
|
+
// Optimize context usage
|
|
117
|
+
const contextEfficiency = this.calculateContextEfficiency(currentFlow.contextUsage);
|
|
118
|
+
if (contextEfficiency < this.performanceThresholds.contextEfficiencyThreshold) {
|
|
119
|
+
recommendations.push(`Improve context efficiency (current: ${(contextEfficiency * 100).toFixed(1)}%, target: ${(this.performanceThresholds.contextEfficiencyThreshold * 100).toFixed(1)}%)`);
|
|
120
|
+
}
|
|
121
|
+
const efficiencyGains = this.calculateEfficiencyGains(currentFlow, optimizedFlow);
|
|
122
|
+
return {
|
|
123
|
+
optimizedFlow,
|
|
124
|
+
efficiencyGains,
|
|
125
|
+
recommendations
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Private implementation methods
|
|
129
|
+
assessComplexity(description, context) {
|
|
130
|
+
const complexityIndicators = {
|
|
131
|
+
trivial: ['typo', 'format', 'rename', 'simple'],
|
|
132
|
+
simple: ['update', 'modify', 'add', 'remove'],
|
|
133
|
+
moderate: ['refactor', 'implement', 'create', 'integration'],
|
|
134
|
+
complex: ['architecture', 'redesign', 'migration', 'complex'],
|
|
135
|
+
very_complex: ['rewrite', 'overhaul', 'fundamental', 'strategic']
|
|
136
|
+
};
|
|
137
|
+
const lowerDesc = description.toLowerCase();
|
|
138
|
+
for (const [level, indicators] of Object.entries(complexityIndicators)) {
|
|
139
|
+
if (indicators.some(indicator => lowerDesc.includes(indicator))) {
|
|
140
|
+
return level;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Fallback based on context
|
|
144
|
+
if (context.errorsEncountered && context.errorsEncountered.length > 2) {
|
|
145
|
+
return ProblemComplexity.COMPLEX;
|
|
146
|
+
}
|
|
147
|
+
if (context.filesRead && context.filesRead.length > 5) {
|
|
148
|
+
return ProblemComplexity.MODERATE;
|
|
149
|
+
}
|
|
150
|
+
return ProblemComplexity.SIMPLE;
|
|
151
|
+
}
|
|
152
|
+
assessRisk(description, context) {
|
|
153
|
+
const highRiskTerms = ['delete', 'drop', 'remove', 'overwrite', 'force', 'irreversible'];
|
|
154
|
+
const mediumRiskTerms = ['modify', 'update', 'change', 'edit', 'refactor'];
|
|
155
|
+
const lowerDesc = description.toLowerCase();
|
|
156
|
+
if (highRiskTerms.some(term => lowerDesc.includes(term))) {
|
|
157
|
+
return 'high';
|
|
158
|
+
}
|
|
159
|
+
if (mediumRiskTerms.some(term => lowerDesc.includes(term))) {
|
|
160
|
+
return 'medium';
|
|
161
|
+
}
|
|
162
|
+
return 'low';
|
|
163
|
+
}
|
|
164
|
+
extractDependencies(description, context) {
|
|
165
|
+
const dependencies = [];
|
|
166
|
+
// Extract file dependencies from description
|
|
167
|
+
const filePattern = /[\w\/.-]+\.(ts|js|tsx|jsx|json|md|txt)/gi;
|
|
168
|
+
const fileMatches = description.match(filePattern) || [];
|
|
169
|
+
dependencies.push(...fileMatches);
|
|
170
|
+
// Add context dependencies
|
|
171
|
+
if (context.filesRead) {
|
|
172
|
+
dependencies.push(...context.filesRead);
|
|
173
|
+
}
|
|
174
|
+
return [...new Set(dependencies)]; // Remove duplicates
|
|
175
|
+
}
|
|
176
|
+
extractConstraints(description) {
|
|
177
|
+
const constraints = [];
|
|
178
|
+
const constraintPatterns = [
|
|
179
|
+
/(?:must|should|need to|required to)\s+([^.!?]+)/gi,
|
|
180
|
+
/(?:cannot|should not|must not)\s+([^.!?]+)/gi,
|
|
181
|
+
/(?:constraint|limit|restriction)[^.!?]*/gi
|
|
182
|
+
];
|
|
183
|
+
for (const pattern of constraintPatterns) {
|
|
184
|
+
const matches = description.match(pattern) || [];
|
|
185
|
+
constraints.push(...matches);
|
|
186
|
+
}
|
|
187
|
+
return constraints;
|
|
188
|
+
}
|
|
189
|
+
extractSuccessCriteria(description) {
|
|
190
|
+
const criteria = [];
|
|
191
|
+
const successPatterns = [
|
|
192
|
+
/(?:should|must)\s+(?:work|function|compile|pass|succeed)/gi,
|
|
193
|
+
/(?:expected|desired)\s+([^.!?]+)/gi,
|
|
194
|
+
/(?:goal|objective)\s+is\s+([^.!?]+)/gi
|
|
195
|
+
];
|
|
196
|
+
for (const pattern of successPatterns) {
|
|
197
|
+
const matches = description.match(pattern) || [];
|
|
198
|
+
criteria.push(...matches);
|
|
199
|
+
}
|
|
200
|
+
return criteria.length > 0 ? criteria : ['Complete implementation successfully'];
|
|
201
|
+
}
|
|
202
|
+
identifyFailurePoints(description, context) {
|
|
203
|
+
const failurePoints = [];
|
|
204
|
+
// Common failure points
|
|
205
|
+
const commonFailures = [
|
|
206
|
+
'TypeScript compilation errors',
|
|
207
|
+
'Test failures',
|
|
208
|
+
'Missing dependencies',
|
|
209
|
+
'File not found errors',
|
|
210
|
+
'Permission issues'
|
|
211
|
+
];
|
|
212
|
+
// Add context-specific failure points
|
|
213
|
+
if (context.errorsEncountered) {
|
|
214
|
+
failurePoints.push(...context.errorsEncountered);
|
|
215
|
+
}
|
|
216
|
+
// Add based on complexity
|
|
217
|
+
const complexity = this.assessComplexity(description, context);
|
|
218
|
+
if (complexity >= ProblemComplexity.COMPLEX) {
|
|
219
|
+
failurePoints.push('Complex integration issues');
|
|
220
|
+
failurePoints.push('Architecture conflicts');
|
|
221
|
+
}
|
|
222
|
+
return [...new Set([...commonFailures, ...failurePoints])];
|
|
223
|
+
}
|
|
224
|
+
selectOptimalStrategy(complexity, riskLevel, context) {
|
|
225
|
+
// Strategy selection matrix
|
|
226
|
+
const strategyMatrix = {
|
|
227
|
+
[ProblemComplexity.TRIVIAL]: {
|
|
228
|
+
low: SolutionStrategy.DIRECT,
|
|
229
|
+
medium: SolutionStrategy.DIRECT,
|
|
230
|
+
high: SolutionStrategy.DEFENSIVE
|
|
231
|
+
},
|
|
232
|
+
[ProblemComplexity.SIMPLE]: {
|
|
233
|
+
low: SolutionStrategy.DIRECT,
|
|
234
|
+
medium: SolutionStrategy.INCREMENTAL,
|
|
235
|
+
high: SolutionStrategy.DEFENSIVE
|
|
236
|
+
},
|
|
237
|
+
[ProblemComplexity.MODERATE]: {
|
|
238
|
+
low: SolutionStrategy.INCREMENTAL,
|
|
239
|
+
medium: SolutionStrategy.ADAPTIVE,
|
|
240
|
+
high: SolutionStrategy.DEFENSIVE
|
|
241
|
+
},
|
|
242
|
+
[ProblemComplexity.COMPLEX]: {
|
|
243
|
+
low: SolutionStrategy.ADAPTIVE,
|
|
244
|
+
medium: SolutionStrategy.EXPLORATORY,
|
|
245
|
+
high: SolutionStrategy.DEFENSIVE
|
|
246
|
+
},
|
|
247
|
+
[ProblemComplexity.VERY_COMPLEX]: {
|
|
248
|
+
low: SolutionStrategy.EXPLORATORY,
|
|
249
|
+
medium: SolutionStrategy.EXPLORATORY,
|
|
250
|
+
high: SolutionStrategy.DEFENSIVE
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
return strategyMatrix[complexity][riskLevel];
|
|
254
|
+
}
|
|
255
|
+
getAlternativeStrategies(optimal, complexity) {
|
|
256
|
+
const allStrategies = Object.values(SolutionStrategy);
|
|
257
|
+
return allStrategies.filter(strategy => strategy !== optimal).slice(0, 2);
|
|
258
|
+
}
|
|
259
|
+
estimateSteps(complexity, description) {
|
|
260
|
+
const baseSteps = {
|
|
261
|
+
[ProblemComplexity.TRIVIAL]: 1,
|
|
262
|
+
[ProblemComplexity.SIMPLE]: 2,
|
|
263
|
+
[ProblemComplexity.MODERATE]: 4,
|
|
264
|
+
[ProblemComplexity.COMPLEX]: 8,
|
|
265
|
+
[ProblemComplexity.VERY_COMPLEX]: 15
|
|
266
|
+
};
|
|
267
|
+
// Adjust based on description length (proxy for complexity)
|
|
268
|
+
const lengthFactor = Math.min(description.length / 100, 2); // Cap at 2x
|
|
269
|
+
return Math.ceil(baseSteps[complexity] * lengthFactor);
|
|
270
|
+
}
|
|
271
|
+
calculateConfidence(complexity, context) {
|
|
272
|
+
let confidence = 1.0;
|
|
273
|
+
// Reduce confidence based on complexity
|
|
274
|
+
const complexityPenalty = {
|
|
275
|
+
[ProblemComplexity.TRIVIAL]: 0.0,
|
|
276
|
+
[ProblemComplexity.SIMPLE]: 0.1,
|
|
277
|
+
[ProblemComplexity.MODERATE]: 0.3,
|
|
278
|
+
[ProblemComplexity.COMPLEX]: 0.5,
|
|
279
|
+
[ProblemComplexity.VERY_COMPLEX]: 0.7
|
|
280
|
+
};
|
|
281
|
+
confidence -= complexityPenalty[complexity];
|
|
282
|
+
// Reduce confidence based on previous errors
|
|
283
|
+
if (context.errorsEncountered && context.errorsEncountered.length > 0) {
|
|
284
|
+
confidence -= 0.2 * Math.min(context.errorsEncountered.length, 3);
|
|
285
|
+
}
|
|
286
|
+
return Math.max(0.1, confidence); // Minimum 10% confidence
|
|
287
|
+
}
|
|
288
|
+
generateSteps(n, analysis, n, context, n) {
|
|
289
|
+
n;
|
|
290
|
+
const steps = [];
|
|
291
|
+
n;
|
|
292
|
+
n; // Generic steps based on strategy\n switch (analysis.optimalStrategy) {\n case SolutionStrategy.DIRECT:\n steps.push({\n id: 'direct_implementation',\n action: 'Implement solution directly',\n tool: 'Edit',\n validation: 'Verify implementation matches requirements'\n });\n break;\n \n case SolutionStrategy.INCREMENTAL:\n steps.push(\n {\n id: 'analysis',\n action: 'Analyze current state and requirements',\n tool: 'read_files',\n validation: 'Understand the problem context'\n },\n {\n id: 'plan',\n action: 'Create implementation plan',\n validation: 'Plan covers all requirements'\n },\n {\n id: 'implement',\n action: 'Implement solution incrementally',\n tool: 'Edit',\n validation: 'Each step passes validation'\n }\n );\n break;\n \n case SolutionStrategy.DEFENSIVE:\n steps.push(\n {\n id: 'backup',\n action: 'Create backup of current state',\n tool: 'execute_bash',\n parameters: { command: 'git status' },\n validation: 'Backup created successfully'\n },\n {\n id: 'validate_current',\n action: 'Validate current state',\n tool: 'validate_all_changes',\n validation: 'Current state is stable'\n },\n {\n id: 'implement_carefully',\n action: 'Implement with validation at each step',\n tool: 'Edit',\n validation: 'Each edit passes validation'\n }\n );\n break;\n }\n\n return steps;\n }\n\n private generateValidationPoints(\n steps: SolutionStep[],\n context: any\n ): ValidationPoint[] {\n const validationPoints: ValidationPoint[] = [];\n\n for (const step of steps) {\n if (step.validation) {\n validationPoints.push({\n stepId: step.id,\n validationType: 'tool_output',\n failureAction: 'retry',\n expectedPattern: step.validation\n });\n }\n }\n\n return validationPoints;\n }\n\n private generateRollbackPlan(\n steps: SolutionStep[],\n analysis: ProblemAnalysis\n ): RollbackStep[] {\n const rollbackSteps: RollbackStep[] = [];\n\n // Add git-based rollback for defensive strategies\n if (analysis.optimalStrategy === SolutionStrategy.DEFENSIVE) {\n rollbackSteps.push({\n stepId: 'git_rollback',\n action: 'Revert all changes using git',\n tool: 'execute_bash',\n parameters: { command: 'git reset --hard HEAD' }\n });\n }\n\n return rollbackSteps;\n }\n\n private estimateTime(steps: SolutionStep[], analysis: ProblemAnalysis): number {\n const baseTimePerStep = 30; // seconds\n const complexityMultiplier: Record<ProblemComplexity, number> = {\n [ProblemComplexity.TRIVIAL]: 0.5,\n [ProblemComplexity.SIMPLE]: 1,\n [ProblemComplexity.MODERATE]: 2,\n [ProblemComplexity.COMPLEX]: 4,\n [ProblemComplexity.VERY_COMPLEX]: 8\n };\n\n return Math.ceil(steps.length * baseTimePerStep * complexityMultiplier[analysis.complexity]);\n }\n\n private calculateSuccessProbability(\n analysis: ProblemAnalysis,\n context: any\n ): number {
|
|
293
|
+
let probability = analysis.confidence;
|
|
294
|
+
// Adjust based on available tools
|
|
295
|
+
if (context.availableTools && context.availableTools.length > 10) {
|
|
296
|
+
probability += 0.1;
|
|
297
|
+
}
|
|
298
|
+
// Adjust based on user preferences
|
|
299
|
+
if (context.userPreferences?.validationPreference === 'thorough') {
|
|
300
|
+
probability += 0.1;
|
|
301
|
+
}
|
|
302
|
+
return Math.min(0.95, probability); // Cap at 95%
|
|
303
|
+
}
|
|
304
|
+
getErrorRecoveryStrategies(error) {
|
|
305
|
+
const strategies = [
|
|
306
|
+
{
|
|
307
|
+
errorType: 'TypeScript Compilation Error',
|
|
308
|
+
errorPattern: /TS\d+:.*error/,
|
|
309
|
+
recoveryActions: [
|
|
310
|
+
{
|
|
311
|
+
action: 'Run TypeScript type checking to get detailed errors',
|
|
312
|
+
tool: 'validate_typescript',
|
|
313
|
+
successProbability: 0.9
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
action: 'Fix TypeScript errors using suggested fixes',
|
|
317
|
+
tool: 'suggest_fixes',
|
|
318
|
+
successProbability: 0.7
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
priority: 'high',
|
|
322
|
+
autoRecoverable: true
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
errorType: 'Test Failure',
|
|
326
|
+
errorPattern: /FAIL\s+.*test/i,
|
|
327
|
+
recoveryActions: [
|
|
328
|
+
{
|
|
329
|
+
action: 'Run tests to get detailed failure information',
|
|
330
|
+
tool: 'run_tests',
|
|
331
|
+
successProbability: 0.8
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
action: 'Analyze test failures and fix implementation',
|
|
335
|
+
tool: 'analyze_code_structure',
|
|
336
|
+
successProbability: 0.6
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
priority: 'high',
|
|
340
|
+
autoRecoverable: false
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
errorType: 'File Not Found',
|
|
344
|
+
errorPattern: /(?:file not found|cannot find|ENOENT)/i,
|
|
345
|
+
recoveryActions: [
|
|
346
|
+
{
|
|
347
|
+
action: 'Search for similar files',
|
|
348
|
+
tool: 'search_files',
|
|
349
|
+
successProbability: 0.5
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
action: 'List files in directory to understand structure',
|
|
353
|
+
tool: 'list_files',
|
|
354
|
+
successProbability: 0.8
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
priority: 'medium',
|
|
358
|
+
autoRecoverable: true
|
|
359
|
+
}
|
|
360
|
+
];
|
|
361
|
+
return strategies.filter(strategy => strategy.errorPattern.test(error));
|
|
362
|
+
}
|
|
363
|
+
isStrategyApplicable(strategy, context) {
|
|
364
|
+
// Check if required tools are available
|
|
365
|
+
const requiredTools = strategy.recoveryActions
|
|
366
|
+
.map(action => action.tool)
|
|
367
|
+
.filter(Boolean);
|
|
368
|
+
return requiredTools.every(tool => context.availableTools?.includes(tool));
|
|
369
|
+
}
|
|
370
|
+
detectSequentialReads(toolCalls) {
|
|
371
|
+
const sequentialReadIndices = [];
|
|
372
|
+
let currentSequence = [];
|
|
373
|
+
for (let i = 0; i < toolCalls.length; i++) {
|
|
374
|
+
const call = toolCalls[i];
|
|
375
|
+
if (call.tool.includes('read') || call.tool.includes('search')) {
|
|
376
|
+
currentSequence.push(i);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
if (currentSequence.length > 1) {
|
|
380
|
+
sequentialReadIndices.push(...currentSequence);
|
|
381
|
+
}
|
|
382
|
+
currentSequence = [];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (currentSequence.length > 1) {
|
|
386
|
+
sequentialReadIndices.push(...currentSequence);
|
|
387
|
+
}
|
|
388
|
+
return sequentialReadIndices;
|
|
389
|
+
}
|
|
390
|
+
mergeSequentialReads(toolCalls) {
|
|
391
|
+
const optimizedCalls = [...toolCalls];
|
|
392
|
+
const sequentialIndices = this.detectSequentialReads(toolCalls);
|
|
393
|
+
// Remove sequential reads and replace with parallel reads
|
|
394
|
+
for (let i = sequentialIndices.length - 1; i >= 0; i--) {
|
|
395
|
+
const index = sequentialIndices[i];
|
|
396
|
+
optimizedCalls.splice(index, 1);
|
|
397
|
+
}
|
|
398
|
+
// Add parallel read at the beginning of sequences
|
|
399
|
+
if (sequentialIndices.length > 0) {
|
|
400
|
+
const firstIndex = Math.min(...sequentialIndices);
|
|
401
|
+
const readFiles = sequentialIndices.map(idx => toolCalls[idx].parameters?.path).filter(Boolean);
|
|
402
|
+
if (readFiles.length > 0) {
|
|
403
|
+
optimizedCalls.splice(firstIndex, 0, {
|
|
404
|
+
tool: 'read_files',
|
|
405
|
+
parameters: { paths: readFiles }
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return optimizedCalls;
|
|
410
|
+
}
|
|
411
|
+
calculateContextEfficiency(contextUsage) {
|
|
412
|
+
const totalOperations = contextUsage.filesRead + contextUsage.searches + contextUsage.edits;
|
|
413
|
+
if (totalOperations === 0)
|
|
414
|
+
return 1.0;
|
|
415
|
+
// Efficiency formula: higher ratio of productive operations (edits) to exploratory operations
|
|
416
|
+
const productiveRatio = contextUsage.edits / totalOperations;
|
|
417
|
+
const searchEfficiency = 1 - (contextUsage.searches / (contextUsage.filesRead + 1));
|
|
418
|
+
return (productiveRatio + searchEfficiency) / 2;
|
|
419
|
+
}
|
|
420
|
+
calculateEfficiencyGains(currentFlow, optimizedFlow) {
|
|
421
|
+
const currentOps = currentFlow.toolCalls.length;
|
|
422
|
+
const optimizedOps = optimizedFlow.length;
|
|
423
|
+
if (currentOps === 0)
|
|
424
|
+
return 0;
|
|
425
|
+
return ((currentOps - optimizedOps) / currentOps) * 100;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=aiOptimizationEngine.js.map
|