codex-linux 1.0.0
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/.claude/settings.local.json +10 -0
- package/.eslintrc.json +27 -0
- package/.github/workflows/ci.yml +156 -0
- package/.huskyrc +7 -0
- package/.lintstagedrc +13 -0
- package/.prettierrc +12 -0
- package/CLAUDE.md +163 -0
- package/DESIGN_SUPERIOR.md +73 -0
- package/Dockerfile +64 -0
- package/INSTALLATION.md +152 -0
- package/LICENSE +21 -0
- package/README.md +245 -0
- package/assets/skills/code-review/instructions.md +102 -0
- package/assets/skills/code-review/skill.yaml +15 -0
- package/assets/skills/refactoring/instructions.md +149 -0
- package/assets/skills/refactoring/skill.yaml +15 -0
- package/assets/skills/testing/skill.yaml +15 -0
- package/commitlint.config.js +23 -0
- package/dist/main/DatabaseManager.js +763 -0
- package/dist/main/DatabaseManager.js.map +1 -0
- package/dist/main/SettingsManager.js +61 -0
- package/dist/main/SettingsManager.js.map +1 -0
- package/dist/main/agents/AgentOrchestrator.js +787 -0
- package/dist/main/agents/AgentOrchestrator.js.map +1 -0
- package/dist/main/agents/AgentSDK.js +219 -0
- package/dist/main/agents/AgentSDK.js.map +1 -0
- package/dist/main/agents/AgentTools.js +348 -0
- package/dist/main/agents/AgentTools.js.map +1 -0
- package/dist/main/agents/CodeIndex.js +233 -0
- package/dist/main/agents/CodeIndex.js.map +1 -0
- package/dist/main/agents/EmbeddingService.js +80 -0
- package/dist/main/agents/EmbeddingService.js.map +1 -0
- package/dist/main/agents/NativeToolCalling.js +206 -0
- package/dist/main/agents/NativeToolCalling.js.map +1 -0
- package/dist/main/api/APIServer.js +278 -0
- package/dist/main/api/APIServer.js.map +1 -0
- package/dist/main/api/RateLimiter.js +138 -0
- package/dist/main/api/RateLimiter.js.map +1 -0
- package/dist/main/api/WebSocketManager.js +300 -0
- package/dist/main/api/WebSocketManager.js.map +1 -0
- package/dist/main/assistant/ContextOptimizer.js +192 -0
- package/dist/main/assistant/ContextOptimizer.js.map +1 -0
- package/dist/main/assistant/PredictedOutputManager.js +172 -0
- package/dist/main/assistant/PredictedOutputManager.js.map +1 -0
- package/dist/main/assistant/PromptCacheManager.js +193 -0
- package/dist/main/assistant/PromptCacheManager.js.map +1 -0
- package/dist/main/assistant/PromptOptimizer.js +626 -0
- package/dist/main/assistant/PromptOptimizer.js.map +1 -0
- package/dist/main/assistant/SmartCodeAssistant.js +224 -0
- package/dist/main/assistant/SmartCodeAssistant.js.map +1 -0
- package/dist/main/auth/SessionManager.js +300 -0
- package/dist/main/auth/SessionManager.js.map +1 -0
- package/dist/main/automations/AdvancedWebhookSystem.js +212 -0
- package/dist/main/automations/AdvancedWebhookSystem.js.map +1 -0
- package/dist/main/automations/AutomationScheduler.js +269 -0
- package/dist/main/automations/AutomationScheduler.js.map +1 -0
- package/dist/main/automations/BatchProcessingSystem.js +159 -0
- package/dist/main/automations/BatchProcessingSystem.js.map +1 -0
- package/dist/main/automations/BrowserAutomationManager.js +195 -0
- package/dist/main/automations/BrowserAutomationManager.js.map +1 -0
- package/dist/main/automations/GitHubActionsManager.js +129 -0
- package/dist/main/automations/GitHubActionsManager.js.map +1 -0
- package/dist/main/automations/GitLabCIManager.js +122 -0
- package/dist/main/automations/GitLabCIManager.js.map +1 -0
- package/dist/main/automations/PriorityQueueManager.js +240 -0
- package/dist/main/automations/PriorityQueueManager.js.map +1 -0
- package/dist/main/background/BackgroundModeManager.js +117 -0
- package/dist/main/background/BackgroundModeManager.js.map +1 -0
- package/dist/main/backup/BackupManager.js +254 -0
- package/dist/main/backup/BackupManager.js.map +1 -0
- package/dist/main/backup/MigrationManager.js +114 -0
- package/dist/main/backup/MigrationManager.js.map +1 -0
- package/dist/main/commands/SlashCommandManager.js +399 -0
- package/dist/main/commands/SlashCommandManager.js.map +1 -0
- package/dist/main/config/ClaudeMdParser.js +519 -0
- package/dist/main/config/ClaudeMdParser.js.map +1 -0
- package/dist/main/config/CustomizationManager.js +381 -0
- package/dist/main/config/CustomizationManager.js.map +1 -0
- package/dist/main/config/LaunchConfigManager.js +211 -0
- package/dist/main/config/LaunchConfigManager.js.map +1 -0
- package/dist/main/config/SettingsManager.js +166 -0
- package/dist/main/config/SettingsManager.js.map +1 -0
- package/dist/main/connectors/ConnectorManager.js +151 -0
- package/dist/main/connectors/ConnectorManager.js.map +1 -0
- package/dist/main/connectors/DatabaseConnector.js +222 -0
- package/dist/main/connectors/DatabaseConnector.js.map +1 -0
- package/dist/main/cowork/CoworkManager.js +324 -0
- package/dist/main/cowork/CoworkManager.js.map +1 -0
- package/dist/main/evals/AgentEvalFramework.js +538 -0
- package/dist/main/evals/AgentEvalFramework.js.map +1 -0
- package/dist/main/evals/GraderManager.js +285 -0
- package/dist/main/evals/GraderManager.js.map +1 -0
- package/dist/main/git/GitWorktreeManager.js +214 -0
- package/dist/main/git/GitWorktreeManager.js.map +1 -0
- package/dist/main/github/GitHubPRMonitor.js +244 -0
- package/dist/main/github/GitHubPRMonitor.js.map +1 -0
- package/dist/main/ide/ContinueInManager.js +181 -0
- package/dist/main/ide/ContinueInManager.js.map +1 -0
- package/dist/main/ide/IDEIntegration.js +277 -0
- package/dist/main/ide/IDEIntegration.js.map +1 -0
- package/dist/main/integrations/LinearManager.js +252 -0
- package/dist/main/integrations/LinearManager.js.map +1 -0
- package/dist/main/integrations/SlackBotManager.js +247 -0
- package/dist/main/integrations/SlackBotManager.js.map +1 -0
- package/dist/main/lsp/LSPManager.js +394 -0
- package/dist/main/lsp/LSPManager.js.map +1 -0
- package/dist/main/main.js +1087 -0
- package/dist/main/main.js.map +1 -0
- package/dist/main/mcp/MCPConfigurationManager.js +281 -0
- package/dist/main/mcp/MCPConfigurationManager.js.map +1 -0
- package/dist/main/mcp/MCPManager.js +710 -0
- package/dist/main/mcp/MCPManager.js.map +1 -0
- package/dist/main/mcp/MCPRegistry.js +272 -0
- package/dist/main/mcp/MCPRegistry.js.map +1 -0
- package/dist/main/monitoring/ErrorRecoveryManager.js +268 -0
- package/dist/main/monitoring/ErrorRecoveryManager.js.map +1 -0
- package/dist/main/monitoring/ErrorTracker.js +57 -0
- package/dist/main/monitoring/ErrorTracker.js.map +1 -0
- package/dist/main/monitoring/MetricsCollector.js +155 -0
- package/dist/main/monitoring/MetricsCollector.js.map +1 -0
- package/dist/main/monitoring/TraceGradingSystem.js +148 -0
- package/dist/main/monitoring/TraceGradingSystem.js.map +1 -0
- package/dist/main/notifications/NotificationManager.js +67 -0
- package/dist/main/notifications/NotificationManager.js.map +1 -0
- package/dist/main/pair/AIPairProgramming.js +200 -0
- package/dist/main/pair/AIPairProgramming.js.map +1 -0
- package/dist/main/plugins/PluginManager.js +222 -0
- package/dist/main/plugins/PluginManager.js.map +1 -0
- package/dist/main/plugins/PluginMarketplace.js +237 -0
- package/dist/main/plugins/PluginMarketplace.js.map +1 -0
- package/dist/main/preload.js +189 -0
- package/dist/main/preload.js.map +1 -0
- package/dist/main/preview/PreviewSessionManager.js +170 -0
- package/dist/main/preview/PreviewSessionManager.js.map +1 -0
- package/dist/main/providers/AIProviderManager.js +327 -0
- package/dist/main/providers/AIProviderManager.js.map +1 -0
- package/dist/main/providers/FineTuningManager.js +276 -0
- package/dist/main/providers/FineTuningManager.js.map +1 -0
- package/dist/main/providers/FreeModelsProvider.js +1104 -0
- package/dist/main/providers/FreeModelsProvider.js.map +1 -0
- package/dist/main/realtime/RealtimeManager.js +116 -0
- package/dist/main/realtime/RealtimeManager.js.map +1 -0
- package/dist/main/remote/CloudEnvironmentManager.js +232 -0
- package/dist/main/remote/CloudEnvironmentManager.js.map +1 -0
- package/dist/main/remote/RemoteSessionManager.js +255 -0
- package/dist/main/remote/RemoteSessionManager.js.map +1 -0
- package/dist/main/search/DeepResearchManager.js +335 -0
- package/dist/main/search/DeepResearchManager.js.map +1 -0
- package/dist/main/search/WebSearchIntegration.js +147 -0
- package/dist/main/search/WebSearchIntegration.js.map +1 -0
- package/dist/main/security/AdminConsoleManager.js +223 -0
- package/dist/main/security/AdminConsoleManager.js.map +1 -0
- package/dist/main/security/AuditLogger.js +136 -0
- package/dist/main/security/AuditLogger.js.map +1 -0
- package/dist/main/security/PermissionManager.js +144 -0
- package/dist/main/security/PermissionManager.js.map +1 -0
- package/dist/main/security/SSOManager.js +173 -0
- package/dist/main/security/SSOManager.js.map +1 -0
- package/dist/main/security/SecurityManager.js +152 -0
- package/dist/main/security/SecurityManager.js.map +1 -0
- package/dist/main/skills/SkillsManager.js +223 -0
- package/dist/main/skills/SkillsManager.js.map +1 -0
- package/dist/main/ssh/SSHManager.js +65 -0
- package/dist/main/ssh/SSHManager.js.map +1 -0
- package/dist/main/streaming/StreamingManager.js +225 -0
- package/dist/main/streaming/StreamingManager.js.map +1 -0
- package/dist/main/sync/CloudSyncManager.js +422 -0
- package/dist/main/sync/CloudSyncManager.js.map +1 -0
- package/dist/main/types.js +28 -0
- package/dist/main/types.js.map +1 -0
- package/dist/main/verification/AutoVerifyManager.js +235 -0
- package/dist/main/verification/AutoVerifyManager.js.map +1 -0
- package/dist/main/vision/ComputerUseManager.js +376 -0
- package/dist/main/vision/ComputerUseManager.js.map +1 -0
- package/dist/main/vision/ImageVideoGenerationManager.js +401 -0
- package/dist/main/vision/ImageVideoGenerationManager.js.map +1 -0
- package/dist/main/vision/VisionManager.js +172 -0
- package/dist/main/vision/VisionManager.js.map +1 -0
- package/dist/renderer/assets/main-DJlZQBCA.js +304 -0
- package/dist/renderer/assets/main-N33ZXEr8.css +1 -0
- package/dist/renderer/index.html +21 -0
- package/dist/renderer/manifest.json +42 -0
- package/dist/renderer/sw.ts +109 -0
- package/dist/shared/types.js +35 -0
- package/dist/shared/types.js.map +1 -0
- package/docker-compose.yml +65 -0
- package/docs/API.md +307 -0
- package/docs/USER_GUIDE.md +476 -0
- package/examples/plugins/sample-plugin/package.json +41 -0
- package/examples/plugins/sample-plugin/src/index.ts +75 -0
- package/index.html +20 -0
- package/jest.config.js +39 -0
- package/package.json +180 -0
- package/packages/cli/package.json +29 -0
- package/packages/cli/src/commands/agents.ts +199 -0
- package/packages/cli/src/commands/tasks.ts +61 -0
- package/packages/cli/src/index.ts +91 -0
- package/packages/cli/src/utils/api.ts +45 -0
- package/packages/cli/src/utils/config.ts +61 -0
- package/packages/npm-installer/bin/codex-linux +126 -0
- package/packages/npm-installer/lib/download.js +273 -0
- package/packages/npm-installer/package.json +42 -0
- package/packages/vscode-extension/package.json +167 -0
- package/packages/vscode-extension/src/api.ts +68 -0
- package/packages/vscode-extension/src/extension.ts +161 -0
- package/packages/vscode-extension/src/panels/chatPanel.ts +265 -0
- package/packages/vscode-extension/src/panels/createAgentPanel.ts +227 -0
- package/packages/vscode-extension/src/providers/agentsProvider.ts +80 -0
- package/postcss.config.js +6 -0
- package/public/manifest.json +42 -0
- package/public/sw.ts +109 -0
- package/scripts/install-dev.sh +103 -0
- package/scripts/install.sh +275 -0
- package/src/main/DatabaseManager.ts +950 -0
- package/src/main/SettingsManager.ts +63 -0
- package/src/main/agents/AgentOrchestrator.ts +930 -0
- package/src/main/agents/AgentSDK.ts +269 -0
- package/src/main/agents/AgentTools.ts +380 -0
- package/src/main/agents/CodeIndex.ts +240 -0
- package/src/main/agents/EmbeddingService.ts +88 -0
- package/src/main/agents/NativeToolCalling.ts +245 -0
- package/src/main/api/APIServer.ts +316 -0
- package/src/main/api/RateLimiter.ts +165 -0
- package/src/main/api/WebSocketManager.ts +398 -0
- package/src/main/assistant/ContextOptimizer.ts +214 -0
- package/src/main/assistant/PredictedOutputManager.ts +265 -0
- package/src/main/assistant/PromptCacheManager.ts +280 -0
- package/src/main/assistant/PromptOptimizer.ts +746 -0
- package/src/main/assistant/SmartCodeAssistant.ts +234 -0
- package/src/main/auth/SessionManager.ts +415 -0
- package/src/main/automations/AdvancedWebhookSystem.ts +281 -0
- package/src/main/automations/AutomationScheduler.ts +272 -0
- package/src/main/automations/BatchProcessingSystem.ts +207 -0
- package/src/main/automations/BrowserAutomationManager.ts +203 -0
- package/src/main/automations/GitHubActionsManager.ts +151 -0
- package/src/main/automations/GitLabCIManager.ts +206 -0
- package/src/main/automations/PriorityQueueManager.ts +328 -0
- package/src/main/background/BackgroundModeManager.ts +130 -0
- package/src/main/backup/BackupManager.ts +287 -0
- package/src/main/backup/MigrationManager.ts +132 -0
- package/src/main/commands/SlashCommandManager.ts +407 -0
- package/src/main/config/ClaudeMdParser.ts +539 -0
- package/src/main/config/CustomizationManager.ts +493 -0
- package/src/main/config/LaunchConfigManager.ts +212 -0
- package/src/main/config/SettingsManager.ts +163 -0
- package/src/main/connectors/ConnectorManager.ts +175 -0
- package/src/main/connectors/DatabaseConnector.ts +212 -0
- package/src/main/cowork/CoworkManager.ts +431 -0
- package/src/main/evals/AgentEvalFramework.ts +665 -0
- package/src/main/evals/GraderManager.ts +417 -0
- package/src/main/git/GitWorktreeManager.ts +211 -0
- package/src/main/github/GitHubPRMonitor.ts +317 -0
- package/src/main/ide/ContinueInManager.ts +180 -0
- package/src/main/ide/IDEIntegration.ts +288 -0
- package/src/main/integrations/LinearManager.ts +327 -0
- package/src/main/integrations/SlackBotManager.ts +312 -0
- package/src/main/lsp/LSPManager.ts +445 -0
- package/src/main/main.ts +1221 -0
- package/src/main/mcp/MCPConfigurationManager.ts +281 -0
- package/src/main/mcp/MCPManager.ts +799 -0
- package/src/main/mcp/MCPRegistry.ts +273 -0
- package/src/main/monitoring/ErrorRecoveryManager.ts +359 -0
- package/src/main/monitoring/ErrorTracker.ts +60 -0
- package/src/main/monitoring/MetricsCollector.ts +196 -0
- package/src/main/monitoring/TraceGradingSystem.ts +196 -0
- package/src/main/notifications/NotificationManager.ts +96 -0
- package/src/main/pair/AIPairProgramming.ts +290 -0
- package/src/main/plugins/PluginManager.ts +266 -0
- package/src/main/plugins/PluginMarketplace.ts +318 -0
- package/src/main/preload.ts +215 -0
- package/src/main/preview/PreviewSessionManager.ts +186 -0
- package/src/main/providers/AIProviderManager.ts +394 -0
- package/src/main/providers/FineTuningManager.ts +390 -0
- package/src/main/providers/FreeModelsProvider.ts +1156 -0
- package/src/main/realtime/RealtimeManager.ts +147 -0
- package/src/main/remote/CloudEnvironmentManager.ts +253 -0
- package/src/main/remote/RemoteSessionManager.ts +323 -0
- package/src/main/search/DeepResearchManager.ts +458 -0
- package/src/main/search/WebSearchIntegration.ts +203 -0
- package/src/main/security/AdminConsoleManager.ts +244 -0
- package/src/main/security/AuditLogger.ts +143 -0
- package/src/main/security/PermissionManager.ts +184 -0
- package/src/main/security/SSOManager.ts +241 -0
- package/src/main/security/SecurityManager.ts +139 -0
- package/src/main/skills/SkillsManager.ts +218 -0
- package/src/main/ssh/SSHManager.ts +86 -0
- package/src/main/streaming/StreamingManager.ts +306 -0
- package/src/main/sync/CloudSyncManager.ts +532 -0
- package/src/main/verification/AutoVerifyManager.ts +285 -0
- package/src/main/vision/ComputerUseManager.ts +475 -0
- package/src/main/vision/ImageVideoGenerationManager.ts +526 -0
- package/src/main/vision/VisionManager.ts +186 -0
- package/src/renderer/App.tsx +314 -0
- package/src/renderer/components/AdvancedSettingsPanel.tsx +225 -0
- package/src/renderer/components/AgentPanel.tsx +760 -0
- package/src/renderer/components/AppPreview.tsx +220 -0
- package/src/renderer/components/AuditTrailPanel.tsx +148 -0
- package/src/renderer/components/AutomationPanel.tsx +220 -0
- package/src/renderer/components/ChatInterface.tsx +595 -0
- package/src/renderer/components/ChatTab.tsx +296 -0
- package/src/renderer/components/CodeEditor.tsx +257 -0
- package/src/renderer/components/CodeReviewPanel.tsx +256 -0
- package/src/renderer/components/CodeWorkspace.tsx +192 -0
- package/src/renderer/components/CodebaseDashboard.tsx +295 -0
- package/src/renderer/components/ComputerUsePanel.tsx +262 -0
- package/src/renderer/components/ConnectorsPanel.tsx +471 -0
- package/src/renderer/components/ContextMenu.tsx +155 -0
- package/src/renderer/components/ContextUsageDisplay.tsx +248 -0
- package/src/renderer/components/CoworkPanel.tsx +415 -0
- package/src/renderer/components/DiffViewer.tsx +452 -0
- package/src/renderer/components/ErrorBoundary.tsx +273 -0
- package/src/renderer/components/ExtendedThinkingToggle.tsx +244 -0
- package/src/renderer/components/FileAttachments.tsx +247 -0
- package/src/renderer/components/FileExplorer.tsx +242 -0
- package/src/renderer/components/FileExplorerPanel.tsx +302 -0
- package/src/renderer/components/GitPanel.tsx +154 -0
- package/src/renderer/components/Header.tsx +113 -0
- package/src/renderer/components/MCPPanel.tsx +326 -0
- package/src/renderer/components/MentionAutocomplete.tsx +239 -0
- package/src/renderer/components/PermissionPanel.tsx +159 -0
- package/src/renderer/components/PermissionSelector.tsx +203 -0
- package/src/renderer/components/PluginMarketplace.tsx +325 -0
- package/src/renderer/components/PromptOptimizerPanel.tsx +399 -0
- package/src/renderer/components/SearchPanel.tsx +173 -0
- package/src/renderer/components/SearchReplace.tsx +284 -0
- package/src/renderer/components/SessionSidebar.tsx +367 -0
- package/src/renderer/components/SettingsPanel.tsx +426 -0
- package/src/renderer/components/Sidebar.tsx +100 -0
- package/src/renderer/components/SkillsPanel.tsx +245 -0
- package/src/renderer/components/SplitPane.tsx +173 -0
- package/src/renderer/components/Terminal.tsx +190 -0
- package/src/renderer/components/VoiceCommand.tsx +129 -0
- package/src/renderer/components/WorktreePanel.tsx +163 -0
- package/src/renderer/components/ui/AriaComponents.tsx +193 -0
- package/src/renderer/components/ui/Button.tsx +68 -0
- package/src/renderer/components/ui/Card.tsx +102 -0
- package/src/renderer/components/ui/Input.tsx +44 -0
- package/src/renderer/components/ui/Skeleton.tsx +55 -0
- package/src/renderer/components/ui/VirtualList.tsx +196 -0
- package/src/renderer/i18n/I18nProvider.tsx +101 -0
- package/src/renderer/i18n/de.ts +161 -0
- package/src/renderer/i18n/en.ts +163 -0
- package/src/renderer/i18n/es.ts +161 -0
- package/src/renderer/i18n/fr.ts +161 -0
- package/src/renderer/i18n/index.ts +44 -0
- package/src/renderer/index.css +129 -0
- package/src/renderer/lib/accessibility.tsx +287 -0
- package/src/renderer/lib/hooks.ts +304 -0
- package/src/renderer/lib/utils.ts +6 -0
- package/src/renderer/main.tsx +25 -0
- package/src/renderer/styles/minimalist.css +539 -0
- package/src/renderer/sw.ts +180 -0
- package/src/renderer/types.d.ts +138 -0
- package/src/shared/types.ts +813 -0
- package/supabase/schema.sql +234 -0
- package/tailwind.config.js +78 -0
- package/tests/e2e/package.json +15 -0
- package/tests/e2e/playwright.config.ts +31 -0
- package/tests/e2e/specs/app.spec.ts +194 -0
- package/tests/setup.ts +99 -0
- package/tests/unit/AgentOrchestrator.test.ts +274 -0
- package/tests/unit/DatabaseManager.test.ts +262 -0
- package/tests/unit/GitWorktreeManager.test.ts +150 -0
- package/tests/unit/SecurityManager.test.ts +110 -0
- package/tsconfig.main.json +22 -0
- package/tsconfig.renderer.json +27 -0
- package/vite.config.ts +28 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import log from 'electron-log';
|
|
4
|
+
import { AgentOrchestrator } from '../agents/AgentOrchestrator';
|
|
5
|
+
import { AIProviderManager } from '../providers/AIProviderManager';
|
|
6
|
+
import { SmartCodeAssistant } from '../assistant/SmartCodeAssistant';
|
|
7
|
+
import { Agent, AgentMessage } from '../../shared/types';
|
|
8
|
+
|
|
9
|
+
interface PairSession {
|
|
10
|
+
id: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
status: 'active' | 'paused' | 'ended';
|
|
14
|
+
context: {
|
|
15
|
+
currentFile: string;
|
|
16
|
+
cursorPosition: { line: number; column: number };
|
|
17
|
+
selectedCode?: string;
|
|
18
|
+
openFiles: string[];
|
|
19
|
+
};
|
|
20
|
+
mode: 'collaborative' | 'teacher' | 'reviewer';
|
|
21
|
+
suggestions: Array<{
|
|
22
|
+
id: string;
|
|
23
|
+
type: 'completion' | 'fix' | 'refactor' | 'question';
|
|
24
|
+
content: string;
|
|
25
|
+
accepted: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AIPairProgramming extends EventEmitter {
|
|
30
|
+
private sessions: Map<string, PairSession> = new Map();
|
|
31
|
+
private agentOrchestrator: AgentOrchestrator;
|
|
32
|
+
private aiProviderManager: AIProviderManager;
|
|
33
|
+
private smartAssistant: SmartCodeAssistant;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
agentOrchestrator: AgentOrchestrator,
|
|
37
|
+
aiProviderManager: AIProviderManager
|
|
38
|
+
) {
|
|
39
|
+
super();
|
|
40
|
+
this.agentOrchestrator = agentOrchestrator;
|
|
41
|
+
this.aiProviderManager = aiProviderManager;
|
|
42
|
+
this.smartAssistant = new SmartCodeAssistant(aiProviderManager);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async startSession(
|
|
46
|
+
projectPath: string,
|
|
47
|
+
mode: PairSession['mode'] = 'collaborative',
|
|
48
|
+
userId: string
|
|
49
|
+
): Promise<PairSession> {
|
|
50
|
+
const sessionId = uuidv4();
|
|
51
|
+
|
|
52
|
+
// Create AI pair programmer agent
|
|
53
|
+
const agent = await this.agentOrchestrator.createAgent({
|
|
54
|
+
name: `Pair Programmer - ${mode}`,
|
|
55
|
+
projectPath,
|
|
56
|
+
providerId: 'openai',
|
|
57
|
+
model: 'gpt-4o',
|
|
58
|
+
skills: ['refactoring', 'testing', 'code-review'],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Configure agent based on mode
|
|
62
|
+
const systemPrompt = this.getSystemPromptForMode(mode);
|
|
63
|
+
await this.agentOrchestrator.sendMessage(agent.id, systemPrompt);
|
|
64
|
+
|
|
65
|
+
const session: PairSession = {
|
|
66
|
+
id: sessionId,
|
|
67
|
+
agentId: agent.id,
|
|
68
|
+
userId,
|
|
69
|
+
status: 'active',
|
|
70
|
+
context: {
|
|
71
|
+
currentFile: '',
|
|
72
|
+
cursorPosition: { line: 0, column: 0 },
|
|
73
|
+
openFiles: [],
|
|
74
|
+
},
|
|
75
|
+
mode,
|
|
76
|
+
suggestions: [],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
this.sessions.set(sessionId, session);
|
|
80
|
+
this.emit('session:started', session);
|
|
81
|
+
|
|
82
|
+
log.info(`AI Pair Programming session started: ${sessionId} (${mode})`);
|
|
83
|
+
return session;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private getSystemPromptForMode(mode: PairSession['mode']): string {
|
|
87
|
+
const prompts = {
|
|
88
|
+
collaborative: `You are a collaborative pair programmer. Work with the user as an equal partner:
|
|
89
|
+
- Suggest improvements and alternatives
|
|
90
|
+
- Ask clarifying questions
|
|
91
|
+
- Challenge assumptions constructively
|
|
92
|
+
- Share knowledge and explain your reasoning
|
|
93
|
+
- Help debug issues together`,
|
|
94
|
+
|
|
95
|
+
teacher: `You are a programming mentor. Help the user learn and improve:
|
|
96
|
+
- Explain concepts clearly
|
|
97
|
+
- Suggest best practices
|
|
98
|
+
- Provide learning resources
|
|
99
|
+
- Break down complex problems
|
|
100
|
+
- Encourage good habits`,
|
|
101
|
+
|
|
102
|
+
reviewer: `You are a code reviewer. Help improve code quality:
|
|
103
|
+
- Identify potential issues
|
|
104
|
+
- Suggest optimizations
|
|
105
|
+
- Check for security concerns
|
|
106
|
+
- Ensure test coverage
|
|
107
|
+
- Maintain consistency`,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return prompts[mode];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async updateContext(
|
|
114
|
+
sessionId: string,
|
|
115
|
+
context: Partial<PairSession['context']>
|
|
116
|
+
): Promise<void> {
|
|
117
|
+
const session = this.sessions.get(sessionId);
|
|
118
|
+
if (!session) return;
|
|
119
|
+
|
|
120
|
+
session.context = { ...session.context, ...context };
|
|
121
|
+
|
|
122
|
+
// Trigger proactive suggestions
|
|
123
|
+
if (context.selectedCode) {
|
|
124
|
+
await this.provideProactiveSuggestion(session);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private async provideProactiveSuggestion(session: PairSession): Promise<void> {
|
|
129
|
+
if (!session.context.selectedCode) return;
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const prompt = `The user has selected this code:
|
|
133
|
+
|
|
134
|
+
\`\`\`
|
|
135
|
+
${session.context.selectedCode}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
Current file: ${session.context.currentFile}
|
|
139
|
+
|
|
140
|
+
As a ${session.mode} pair programmer, provide a brief, helpful suggestion or insight. Keep it concise (1-2 sentences).`;
|
|
141
|
+
|
|
142
|
+
const provider = this.aiProviderManager.getActiveProviderInstance();
|
|
143
|
+
if (!provider) return;
|
|
144
|
+
|
|
145
|
+
const response = await provider.sendMessage('gpt-4o-mini', [
|
|
146
|
+
{ role: 'system', content: 'You are a helpful pair programmer.' },
|
|
147
|
+
{ role: 'user', content: prompt },
|
|
148
|
+
] as Array<{ role: string; content: string }>);
|
|
149
|
+
|
|
150
|
+
const suggestion = {
|
|
151
|
+
id: uuidv4(),
|
|
152
|
+
type: 'question' as const,
|
|
153
|
+
content: response.content,
|
|
154
|
+
accepted: false,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
session.suggestions.push(suggestion);
|
|
158
|
+
this.emit('suggestion:available', { sessionId: session.id, suggestion });
|
|
159
|
+
} catch (error) {
|
|
160
|
+
log.error('Failed to provide proactive suggestion:', error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async chat(sessionId: string, message: string): Promise<AgentMessage> {
|
|
165
|
+
const session = this.sessions.get(sessionId);
|
|
166
|
+
if (!session) throw new Error('Session not found');
|
|
167
|
+
|
|
168
|
+
// Enhance message with context
|
|
169
|
+
const enhancedMessage = this.enhanceMessageWithContext(message, session);
|
|
170
|
+
|
|
171
|
+
const response = await this.agentOrchestrator.sendMessage(
|
|
172
|
+
session.agentId,
|
|
173
|
+
enhancedMessage
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
this.emit('message:received', { sessionId, message: response });
|
|
177
|
+
return response;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private enhanceMessageWithContext(
|
|
181
|
+
message: string,
|
|
182
|
+
session: PairSession
|
|
183
|
+
): string {
|
|
184
|
+
let context = '';
|
|
185
|
+
|
|
186
|
+
if (session.context.currentFile) {
|
|
187
|
+
context += `\n\nCurrent file: ${session.context.currentFile}`;
|
|
188
|
+
context += `\nCursor position: Line ${session.context.cursorPosition.line}, Column ${session.context.cursorPosition.column}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (session.context.selectedCode) {
|
|
192
|
+
context += `\n\nSelected code:\n\`\`\`\n${session.context.selectedCode}\n\`\`\``;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return message + context;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async requestInlineCompletion(
|
|
199
|
+
sessionId: string,
|
|
200
|
+
filePath: string,
|
|
201
|
+
content: string,
|
|
202
|
+
position: { line: number; column: number }
|
|
203
|
+
): Promise<string | null> {
|
|
204
|
+
const session = this.sessions.get(sessionId);
|
|
205
|
+
if (!session) return null;
|
|
206
|
+
|
|
207
|
+
return this.smartAssistant.provideInlineCompletion(
|
|
208
|
+
filePath,
|
|
209
|
+
content,
|
|
210
|
+
position
|
|
211
|
+
).then(result => result?.text || null);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async suggestRefactoring(
|
|
215
|
+
sessionId: string,
|
|
216
|
+
code: string,
|
|
217
|
+
goal: string
|
|
218
|
+
): Promise<string> {
|
|
219
|
+
const session = this.sessions.get(sessionId);
|
|
220
|
+
if (!session) throw new Error('Session not found');
|
|
221
|
+
|
|
222
|
+
return this.smartAssistant.refactorSuggestion(
|
|
223
|
+
session.context.currentFile,
|
|
224
|
+
code,
|
|
225
|
+
goal
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async explainSelectedCode(sessionId: string): Promise<string> {
|
|
230
|
+
const session = this.sessions.get(sessionId);
|
|
231
|
+
if (!session) throw new Error('Session not found');
|
|
232
|
+
|
|
233
|
+
if (!session.context.selectedCode) {
|
|
234
|
+
return 'No code selected. Please select some code first.';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return this.smartAssistant.explainCode(
|
|
238
|
+
session.context.selectedCode,
|
|
239
|
+
'detailed'
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
acceptSuggestion(sessionId: string, suggestionId: string): void {
|
|
244
|
+
const session = this.sessions.get(sessionId);
|
|
245
|
+
if (!session) return;
|
|
246
|
+
|
|
247
|
+
const suggestion = session.suggestions.find(s => s.id === suggestionId);
|
|
248
|
+
if (suggestion) {
|
|
249
|
+
suggestion.accepted = true;
|
|
250
|
+
this.emit('suggestion:accepted', { sessionId, suggestionId });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async endSession(sessionId: string): Promise<void> {
|
|
255
|
+
const session = this.sessions.get(sessionId);
|
|
256
|
+
if (!session) return;
|
|
257
|
+
|
|
258
|
+
session.status = 'ended';
|
|
259
|
+
await this.agentOrchestrator.deleteAgent(session.agentId);
|
|
260
|
+
|
|
261
|
+
// Generate session summary
|
|
262
|
+
const summary = await this.generateSessionSummary(session);
|
|
263
|
+
|
|
264
|
+
this.sessions.delete(sessionId);
|
|
265
|
+
this.emit('session:ended', { sessionId, summary });
|
|
266
|
+
|
|
267
|
+
log.info(`AI Pair Programming session ended: ${sessionId}`);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private async generateSessionSummary(session: PairSession): Promise<string> {
|
|
271
|
+
const accepted = session.suggestions.filter(s => s.accepted).length;
|
|
272
|
+
const total = session.suggestions.length;
|
|
273
|
+
|
|
274
|
+
return `Session Summary:
|
|
275
|
+
- Mode: ${session.mode}
|
|
276
|
+
- Duration: Active
|
|
277
|
+
- Suggestions: ${accepted}/${total} accepted
|
|
278
|
+
- Files worked on: ${session.context.openFiles.join(', ') || 'None'}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
getSession(sessionId: string): PairSession | undefined {
|
|
282
|
+
return this.sessions.get(sessionId);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
getActiveSessions(): PairSession[] {
|
|
286
|
+
return Array.from(this.sessions.values()).filter(
|
|
287
|
+
s => s.status === 'active'
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
import log from 'electron-log';
|
|
5
|
+
|
|
6
|
+
export interface PluginManifest {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
description: string;
|
|
11
|
+
author: string;
|
|
12
|
+
main: string;
|
|
13
|
+
contributes?: {
|
|
14
|
+
commands?: Array<{
|
|
15
|
+
command: string;
|
|
16
|
+
title: string;
|
|
17
|
+
category?: string;
|
|
18
|
+
}>;
|
|
19
|
+
menus?: Record<string, Array<{
|
|
20
|
+
command: string;
|
|
21
|
+
when?: string;
|
|
22
|
+
group?: string;
|
|
23
|
+
}>>;
|
|
24
|
+
themes?: Array<{
|
|
25
|
+
label: string;
|
|
26
|
+
uiTheme: 'vs' | 'vs-dark' | 'hc-black';
|
|
27
|
+
path: string;
|
|
28
|
+
}>;
|
|
29
|
+
skills?: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
path: string;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
activationEvents?: string[];
|
|
36
|
+
engines?: {
|
|
37
|
+
codex?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PluginContext {
|
|
42
|
+
registerCommand: (command: string, callback: (...args: any[]) => any) => void;
|
|
43
|
+
registerMenu: (location: string, items: any[]) => void;
|
|
44
|
+
registerTheme: (theme: any) => void;
|
|
45
|
+
registerSkill: (skill: any) => void;
|
|
46
|
+
subscribe: (event: string, callback: (...args: any[]) => void) => void;
|
|
47
|
+
emit: (event: string, ...args: any[]) => void;
|
|
48
|
+
getConfig: (key: string) => any;
|
|
49
|
+
setConfig: (key: string, value: any) => void;
|
|
50
|
+
log: ReturnType<typeof log.scope>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface LoadedPlugin {
|
|
54
|
+
manifest: PluginManifest;
|
|
55
|
+
path: string;
|
|
56
|
+
instance: any;
|
|
57
|
+
isActive: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const PLUGIN_DIR = path.join(process.env.HOME || '~', '.config', 'codex', 'plugins');
|
|
61
|
+
|
|
62
|
+
export class PluginManager extends EventEmitter {
|
|
63
|
+
private plugins: Map<string, LoadedPlugin> = new Map();
|
|
64
|
+
private contexts: Map<string, PluginContext> = new Map();
|
|
65
|
+
|
|
66
|
+
async initialize(): Promise<void> {
|
|
67
|
+
await fs.mkdir(PLUGIN_DIR, { recursive: true });
|
|
68
|
+
await this.loadPlugins();
|
|
69
|
+
log.info(`Plugin manager initialized. Loaded ${this.plugins.size} plugins.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async loadPlugins(): Promise<void> {
|
|
73
|
+
try {
|
|
74
|
+
const entries = await fs.readdir(PLUGIN_DIR, { withFileTypes: true });
|
|
75
|
+
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
if (entry.isDirectory()) {
|
|
78
|
+
await this.loadPlugin(path.join(PLUGIN_DIR, entry.name));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
log.error('Failed to load plugins:', error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async loadPlugin(pluginPath: string): Promise<void> {
|
|
87
|
+
try {
|
|
88
|
+
const manifestPath = path.join(pluginPath, 'package.json');
|
|
89
|
+
const manifestContent = await fs.readFile(manifestPath, 'utf-8');
|
|
90
|
+
const manifest: PluginManifest = JSON.parse(manifestContent);
|
|
91
|
+
|
|
92
|
+
// Check compatibility
|
|
93
|
+
if (manifest.engines?.codex) {
|
|
94
|
+
const appVersion = '1.0.0'; // Get from package.json
|
|
95
|
+
if (!this.checkCompatibility(manifest.engines.codex, appVersion)) {
|
|
96
|
+
log.warn(`Plugin ${manifest.id} requires Codex ${manifest.engines.codex}, but running ${appVersion}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const plugin: LoadedPlugin = {
|
|
102
|
+
manifest,
|
|
103
|
+
path: pluginPath,
|
|
104
|
+
instance: null,
|
|
105
|
+
isActive: false,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
this.plugins.set(manifest.id, plugin);
|
|
109
|
+
log.info(`Loaded plugin: ${manifest.name} (${manifest.id})`);
|
|
110
|
+
|
|
111
|
+
// Auto-activate if no activation events specified
|
|
112
|
+
if (!manifest.activationEvents || manifest.activationEvents.includes('*')) {
|
|
113
|
+
await this.activatePlugin(manifest.id);
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
log.error(`Failed to load plugin from ${pluginPath}:`, error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async activatePlugin(pluginId: string): Promise<void> {
|
|
121
|
+
const plugin = this.plugins.get(pluginId);
|
|
122
|
+
if (!plugin || plugin.isActive) return;
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const mainPath = path.join(plugin.path, plugin.manifest.main);
|
|
126
|
+
const PluginClass = require(mainPath).default || require(mainPath);
|
|
127
|
+
|
|
128
|
+
const context = this.createContext(pluginId);
|
|
129
|
+
plugin.instance = new PluginClass(context);
|
|
130
|
+
|
|
131
|
+
if (typeof plugin.instance.activate === 'function') {
|
|
132
|
+
await plugin.instance.activate();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
plugin.isActive = true;
|
|
136
|
+
this.emit('plugin:activated', pluginId);
|
|
137
|
+
log.info(`Activated plugin: ${plugin.manifest.name}`);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
log.error(`Failed to activate plugin ${pluginId}:`, error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async deactivatePlugin(pluginId: string): Promise<void> {
|
|
144
|
+
const plugin = this.plugins.get(pluginId);
|
|
145
|
+
if (!plugin || !plugin.isActive) return;
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
if (typeof plugin.instance.deactivate === 'function') {
|
|
149
|
+
await plugin.instance.deactivate();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
plugin.instance = null;
|
|
153
|
+
plugin.isActive = false;
|
|
154
|
+
this.contexts.delete(pluginId);
|
|
155
|
+
|
|
156
|
+
this.emit('plugin:deactivated', pluginId);
|
|
157
|
+
log.info(`Deactivated plugin: ${plugin.manifest.name}`);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
log.error(`Failed to deactivate plugin ${pluginId}:`, error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async uninstallPlugin(pluginId: string): Promise<void> {
|
|
164
|
+
await this.deactivatePlugin(pluginId);
|
|
165
|
+
|
|
166
|
+
const plugin = this.plugins.get(pluginId);
|
|
167
|
+
if (plugin) {
|
|
168
|
+
try {
|
|
169
|
+
await fs.rmdir(plugin.path, { recursive: true });
|
|
170
|
+
this.plugins.delete(pluginId);
|
|
171
|
+
this.emit('plugin:uninstalled', pluginId);
|
|
172
|
+
log.info(`Uninstalled plugin: ${plugin.manifest.name}`);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
log.error(`Failed to uninstall plugin ${pluginId}:`, error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
getPlugins(): LoadedPlugin[] {
|
|
180
|
+
return Array.from(this.plugins.values());
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getActivePlugins(): LoadedPlugin[] {
|
|
184
|
+
return this.getPlugins().filter(p => p.isActive);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
getPlugin(pluginId: string): LoadedPlugin | undefined {
|
|
188
|
+
return this.plugins.get(pluginId);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
isPluginActive(pluginId: string): boolean {
|
|
192
|
+
return this.plugins.get(pluginId)?.isActive || false;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private createContext(pluginId: string): PluginContext {
|
|
196
|
+
const context: PluginContext = {
|
|
197
|
+
registerCommand: (command: string, callback: (...args: any[]) => any) => {
|
|
198
|
+
this.emit('command:registered', { pluginId, command, callback });
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
registerMenu: (location: string, items: any[]) => {
|
|
202
|
+
this.emit('menu:registered', { pluginId, location, items });
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
registerTheme: (theme: any) => {
|
|
206
|
+
this.emit('theme:registered', { pluginId, theme });
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
registerSkill: (skill: any) => {
|
|
210
|
+
this.emit('skill:registered', { pluginId, skill });
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
subscribe: (event: string, callback: (...args: any[]) => void) => {
|
|
214
|
+
this.on(event, callback);
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
emit: (event: string, ...args: any[]) => {
|
|
218
|
+
this.emit(event, ...args);
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
getConfig: (key: string) => {
|
|
222
|
+
// Get from plugin-specific config
|
|
223
|
+
return null;
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
setConfig: (key: string, value: any) => {
|
|
227
|
+
// Set in plugin-specific config
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
log: log.scope(pluginId),
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
this.contexts.set(pluginId, context);
|
|
234
|
+
return context;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private checkCompatibility(required: string, current: string): boolean {
|
|
238
|
+
// Simple semver check
|
|
239
|
+
const [reqMajor, reqMinor] = required.split('.').map(Number);
|
|
240
|
+
const [curMajor, curMinor] = current.split('.').map(Number);
|
|
241
|
+
|
|
242
|
+
return curMajor >= reqMajor && (curMajor > reqMajor || curMinor >= reqMinor);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Execute command from plugin
|
|
246
|
+
async executeCommand(command: string, ...args: any[]): Promise<any> {
|
|
247
|
+
this.emit('command:execute', { command, args });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Cleanup all plugins
|
|
251
|
+
async cleanup(): Promise<void> {
|
|
252
|
+
for (const [pluginId, context] of this.contexts) {
|
|
253
|
+
try {
|
|
254
|
+
const plugin = this.plugins.get(pluginId);
|
|
255
|
+
if (plugin && typeof (plugin as any).cleanup === 'function') {
|
|
256
|
+
await (plugin as any).cleanup();
|
|
257
|
+
}
|
|
258
|
+
} catch (error) {
|
|
259
|
+
log.error(`Failed to cleanup plugin ${pluginId}:`, error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
this.contexts.clear();
|
|
263
|
+
this.plugins.clear();
|
|
264
|
+
log.info('Plugin manager cleanup completed');
|
|
265
|
+
}
|
|
266
|
+
}
|