erosolar-cli 1.5.2 → 1.5.4
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/config/security-deployment.json +54 -0
- package/dist/bin/adapters/node/index.js +33 -0
- package/dist/bin/adapters/types.js +1 -0
- package/dist/bin/alpha-zero/agentWrapper.js +165 -0
- package/dist/bin/alpha-zero/codeEvaluator.js +272 -0
- package/dist/bin/alpha-zero/competitiveRunner.js +219 -0
- package/dist/bin/alpha-zero/index.js +98 -0
- package/dist/bin/alpha-zero/introspection.js +298 -0
- package/dist/bin/alpha-zero/metricsTracker.js +207 -0
- package/dist/bin/alpha-zero/security/core.js +269 -0
- package/dist/bin/alpha-zero/security/google.js +308 -0
- package/dist/bin/alpha-zero/security/googleLoader.js +40 -0
- package/dist/bin/alpha-zero/security/index.js +31 -0
- package/dist/bin/alpha-zero/security/simulation.js +274 -0
- package/dist/bin/alpha-zero/selfModification.js +231 -0
- package/dist/bin/alpha-zero/types.js +30 -0
- package/dist/bin/bin/erosolar-optimized.js +205 -0
- package/dist/bin/capabilities/agentSpawningCapability.js +116 -0
- package/dist/bin/capabilities/bashCapability.js +22 -0
- package/dist/bin/capabilities/cloudCapability.js +36 -0
- package/dist/bin/capabilities/codeAnalysisCapability.js +22 -0
- package/dist/bin/capabilities/codeQualityCapability.js +23 -0
- package/dist/bin/capabilities/dependencySecurityCapability.js +22 -0
- package/dist/bin/capabilities/devCapability.js +22 -0
- package/dist/bin/capabilities/editCapability.js +28 -0
- package/dist/bin/capabilities/emailCapability.js +20 -0
- package/dist/bin/capabilities/enhancedGitCapability.js +221 -0
- package/dist/bin/capabilities/filesystemCapability.js +22 -0
- package/dist/bin/capabilities/globCapability.js +28 -0
- package/dist/bin/capabilities/interactionCapability.js +20 -0
- package/dist/bin/capabilities/learnCapability.js +22 -0
- package/dist/bin/capabilities/mcpCapability.js +20 -0
- package/dist/bin/capabilities/notebookCapability.js +28 -0
- package/dist/bin/capabilities/planningCapability.js +27 -0
- package/dist/bin/capabilities/refactoringCapability.js +23 -0
- package/dist/bin/capabilities/repoChecksCapability.js +22 -0
- package/dist/bin/capabilities/searchCapability.js +22 -0
- package/dist/bin/capabilities/skillCapability.js +76 -0
- package/dist/bin/capabilities/taskManagementCapability.js +20 -0
- package/dist/bin/capabilities/testingCapability.js +23 -0
- package/dist/bin/capabilities/toolManifest.js +159 -0
- package/dist/bin/capabilities/toolRegistry.js +114 -0
- package/dist/bin/capabilities/webCapability.js +20 -0
- package/dist/bin/config.js +139 -0
- package/dist/bin/contracts/v1/agent.js +7 -0
- package/dist/bin/contracts/v1/agentProfileManifest.js +8 -0
- package/dist/bin/contracts/v1/agentRules.js +9 -0
- package/dist/bin/contracts/v1/toolAccess.js +8 -0
- package/dist/bin/core/agent.js +362 -0
- package/dist/bin/core/agentProfileManifest.js +187 -0
- package/dist/bin/core/agentProfiles.js +34 -0
- package/dist/bin/core/agentRulebook.js +135 -0
- package/dist/bin/core/agentSchemaLoader.js +233 -0
- package/dist/bin/core/contextManager.js +412 -0
- package/dist/bin/core/contextWindow.js +122 -0
- package/dist/bin/core/customCommands.js +80 -0
- package/dist/bin/core/errors/apiKeyErrors.js +114 -0
- package/dist/bin/core/errors/errorTypes.js +340 -0
- package/dist/bin/core/errors/safetyValidator.js +304 -0
- package/dist/bin/core/errors.js +32 -0
- package/dist/bin/core/modelDiscovery.js +755 -0
- package/dist/bin/core/preferences.js +224 -0
- package/dist/bin/core/schemaValidator.js +92 -0
- package/dist/bin/core/secretStore.js +199 -0
- package/dist/bin/core/sessionStore.js +187 -0
- package/dist/bin/core/toolRuntime.js +290 -0
- package/dist/bin/core/types.js +1 -0
- package/dist/bin/erosolar-optimized.d.ts +12 -0
- package/dist/bin/erosolar-optimized.d.ts.map +1 -0
- package/dist/bin/erosolar-optimized.js +239 -0
- package/dist/bin/erosolar-optimized.js.map +1 -0
- package/dist/bin/erosolar.js +14 -0
- package/dist/bin/erosolar.js.map +1 -1
- package/dist/bin/headless/headlessApp.js +172 -0
- package/dist/bin/mcp/config.js +202 -0
- package/dist/bin/mcp/stdioClient.js +172 -0
- package/dist/bin/mcp/toolBridge.js +104 -0
- package/dist/bin/mcp/types.js +1 -0
- package/dist/bin/plugins/index.js +113 -0
- package/dist/bin/plugins/providers/anthropic/index.js +25 -0
- package/dist/bin/plugins/providers/deepseek/index.js +24 -0
- package/dist/bin/plugins/providers/google/index.js +26 -0
- package/dist/bin/plugins/providers/index.js +19 -0
- package/dist/bin/plugins/providers/ollama/index.js +59 -0
- package/dist/bin/plugins/providers/openai/index.js +26 -0
- package/dist/bin/plugins/providers/xai/index.js +24 -0
- package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +8 -0
- package/dist/bin/plugins/tools/bash/localBashPlugin.js +13 -0
- package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +13 -0
- package/dist/bin/plugins/tools/cloud/cloudPlugin.js +13 -0
- package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +13 -0
- package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +13 -0
- package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +11 -0
- package/dist/bin/plugins/tools/development/devPlugin.js +13 -0
- package/dist/bin/plugins/tools/edit/editPlugin.js +14 -0
- package/dist/bin/plugins/tools/email/emailPlugin.js +11 -0
- package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +8 -0
- package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +13 -0
- package/dist/bin/plugins/tools/glob/globPlugin.js +14 -0
- package/dist/bin/plugins/tools/index.js +2 -0
- package/dist/bin/plugins/tools/interaction/interactionPlugin.js +11 -0
- package/dist/bin/plugins/tools/learn/learnPlugin.js +13 -0
- package/dist/bin/plugins/tools/mcp/mcpPlugin.js +8 -0
- package/dist/bin/plugins/tools/nodeDefaults.js +56 -0
- package/dist/bin/plugins/tools/notebook/notebookPlugin.js +14 -0
- package/dist/bin/plugins/tools/planning/planningPlugin.js +14 -0
- package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +11 -0
- package/dist/bin/plugins/tools/registry.js +57 -0
- package/dist/bin/plugins/tools/search/localSearchPlugin.js +13 -0
- package/dist/bin/plugins/tools/skills/skillPlugin.js +8 -0
- package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +11 -0
- package/dist/bin/plugins/tools/testing/testingPlugin.js +11 -0
- package/dist/bin/plugins/tools/web/webPlugin.js +11 -0
- package/dist/bin/providers/anthropicProvider.js +329 -0
- package/dist/bin/providers/googleProvider.js +203 -0
- package/dist/bin/providers/openaiChatCompletionsProvider.js +208 -0
- package/dist/bin/providers/openaiResponsesProvider.js +249 -0
- package/dist/bin/providers/providerFactory.js +24 -0
- package/dist/bin/runtime/agentController.js +321 -0
- package/dist/bin/runtime/agentHost.js +153 -0
- package/dist/bin/runtime/agentSession.js +195 -0
- package/dist/bin/runtime/node.js +10 -0
- package/dist/bin/runtime/universal.js +28 -0
- package/dist/bin/shell/bracketedPasteManager.js +350 -0
- package/dist/bin/shell/fileChangeTracker.js +65 -0
- package/dist/bin/shell/interactiveShell.js +2908 -0
- package/dist/bin/shell/liveStatus.js +78 -0
- package/dist/bin/shell/shellApp.js +290 -0
- package/dist/bin/shell/systemPrompt.js +60 -0
- package/dist/bin/shell/updateManager.js +108 -0
- package/dist/bin/skills/skillRepository.js +236 -0
- package/dist/bin/skills/types.js +1 -0
- package/dist/bin/subagents/taskRunner.js +269 -0
- package/dist/bin/tools/backgroundBashTools.js +211 -0
- package/dist/bin/tools/bashTools.js +159 -0
- package/dist/bin/tools/cloudTools.js +864 -0
- package/dist/bin/tools/codeAnalysisTools.js +641 -0
- package/dist/bin/tools/codeQualityTools.js +294 -0
- package/dist/bin/tools/dependencyTools.js +282 -0
- package/dist/bin/tools/devTools.js +238 -0
- package/dist/bin/tools/diffUtils.js +137 -0
- package/dist/bin/tools/editTools.js +134 -0
- package/dist/bin/tools/emailTools.js +448 -0
- package/dist/bin/tools/fileTools.js +282 -0
- package/dist/bin/tools/globTools.js +173 -0
- package/dist/bin/tools/grepTools.js +332 -0
- package/dist/bin/tools/interactionTools.js +170 -0
- package/dist/bin/tools/learnTools.js +1818 -0
- package/dist/bin/tools/notebookEditTools.js +196 -0
- package/dist/bin/tools/planningTools.js +46 -0
- package/dist/bin/tools/refactoringTools.js +293 -0
- package/dist/bin/tools/repoChecksTools.js +160 -0
- package/dist/bin/tools/searchTools.js +206 -0
- package/dist/bin/tools/skillTools.js +177 -0
- package/dist/bin/tools/taskManagementTools.js +156 -0
- package/dist/bin/tools/testingTools.js +232 -0
- package/dist/bin/tools/webTools.js +480 -0
- package/dist/bin/ui/ShellUIAdapter.js +459 -0
- package/dist/bin/ui/UnifiedUIController.js +183 -0
- package/dist/bin/ui/animation/AnimationScheduler.js +430 -0
- package/dist/bin/ui/codeHighlighter.js +854 -0
- package/dist/bin/ui/designSystem.js +121 -0
- package/dist/bin/ui/display.js +1222 -0
- package/dist/bin/ui/interrupts/InterruptManager.js +437 -0
- package/dist/bin/ui/layout.js +139 -0
- package/dist/bin/ui/orchestration/StatusOrchestrator.js +403 -0
- package/dist/bin/ui/outputMode.js +38 -0
- package/dist/bin/ui/persistentPrompt.js +183 -0
- package/dist/bin/ui/richText.js +338 -0
- package/dist/bin/ui/shortcutsHelp.js +87 -0
- package/dist/bin/ui/telemetry/UITelemetry.js +443 -0
- package/dist/bin/ui/textHighlighter.js +210 -0
- package/dist/bin/ui/theme.js +116 -0
- package/dist/bin/ui/toolDisplay.js +423 -0
- package/dist/bin/ui/toolDisplayAdapter.js +357 -0
- package/dist/bin/workspace.js +106 -0
- package/dist/bin/workspace.validator.js +213 -0
- package/dist/capabilities/cloudCapability.d.ts +13 -0
- package/dist/capabilities/cloudCapability.d.ts.map +1 -0
- package/dist/capabilities/cloudCapability.js +38 -0
- package/dist/capabilities/cloudCapability.js.map +1 -0
- package/dist/capabilities/index.d.ts +1 -0
- package/dist/capabilities/index.d.ts.map +1 -1
- package/dist/capabilities/index.js +1 -0
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/offensiveSecurityCapability.d.ts +26 -0
- package/dist/capabilities/offensiveSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/offensiveSecurityCapability.js +58 -0
- package/dist/capabilities/offensiveSecurityCapability.js.map +1 -0
- package/dist/capabilities/realSecurityCapability.d.ts +26 -0
- package/dist/capabilities/realSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/realSecurityCapability.js +53 -0
- package/dist/capabilities/realSecurityCapability.js.map +1 -0
- package/dist/capabilities/securityCapability.d.ts +32 -0
- package/dist/capabilities/securityCapability.d.ts.map +1 -0
- package/dist/capabilities/securityCapability.js +57 -0
- package/dist/capabilities/securityCapability.js.map +1 -0
- package/dist/capabilities/ultimateSecurityCapability.d.ts +42 -0
- package/dist/capabilities/ultimateSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/ultimateSecurityCapability.js +96 -0
- package/dist/capabilities/ultimateSecurityCapability.js.map +1 -0
- package/dist/core/LazyLoader.d.ts +129 -0
- package/dist/core/LazyLoader.d.ts.map +1 -0
- package/dist/core/LazyLoader.js +240 -0
- package/dist/core/LazyLoader.js.map +1 -0
- package/dist/core/intelligenceTools.d.ts +19 -0
- package/dist/core/intelligenceTools.d.ts.map +1 -0
- package/dist/core/intelligenceTools.js +453 -0
- package/dist/core/intelligenceTools.js.map +1 -0
- package/dist/core/operationalTools.d.ts +19 -0
- package/dist/core/operationalTools.d.ts.map +1 -0
- package/dist/core/operationalTools.js +467 -0
- package/dist/core/operationalTools.js.map +1 -0
- package/dist/offensive/core/offensive-engine.d.ts +171 -0
- package/dist/offensive/core/offensive-engine.d.ts.map +1 -0
- package/dist/offensive/core/offensive-engine.js +345 -0
- package/dist/offensive/core/offensive-engine.js.map +1 -0
- package/dist/offensive/core/offensive-integration.d.ts +129 -0
- package/dist/offensive/core/offensive-integration.d.ts.map +1 -0
- package/dist/offensive/core/offensive-integration.js +364 -0
- package/dist/offensive/core/offensive-integration.js.map +1 -0
- package/dist/offensive/core/offensive-tools.d.ts +55 -0
- package/dist/offensive/core/offensive-tools.d.ts.map +1 -0
- package/dist/offensive/core/offensive-tools.js +438 -0
- package/dist/offensive/core/offensive-tools.js.map +1 -0
- package/dist/offensive/offensive-cli.d.ts +48 -0
- package/dist/offensive/offensive-cli.d.ts.map +1 -0
- package/dist/offensive/offensive-cli.js +233 -0
- package/dist/offensive/offensive-cli.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/tools/cloud/cloudPlugin.d.ts +3 -0
- package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/cloud/cloudPlugin.js +14 -0
- package/dist/plugins/tools/cloud/cloudPlugin.js.map +1 -0
- 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/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/apt-simulation-cli.d.ts +57 -0
- package/dist/security/apt-simulation-cli.d.ts.map +1 -0
- package/dist/security/apt-simulation-cli.js +278 -0
- package/dist/security/apt-simulation-cli.js.map +1 -0
- package/dist/security/apt-simulation-engine-complete.d.ts +97 -0
- package/dist/security/apt-simulation-engine-complete.d.ts.map +1 -0
- package/dist/security/apt-simulation-engine-complete.js +441 -0
- package/dist/security/apt-simulation-engine-complete.js.map +1 -0
- package/dist/security/apt-simulation-engine.d.ts +97 -0
- package/dist/security/apt-simulation-engine.d.ts.map +1 -0
- package/dist/security/apt-simulation-engine.js +441 -0
- package/dist/security/apt-simulation-engine.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/authorization.d.ts +45 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/authorization.js +128 -0
- package/dist/security/authorization.js.map +1 -0
- package/dist/security/comprehensive-security-research.d.ts +84 -0
- package/dist/security/comprehensive-security-research.d.ts.map +1 -0
- package/dist/security/comprehensive-security-research.js +211 -0
- package/dist/security/comprehensive-security-research.js.map +1 -0
- package/dist/security/offensive/exploitationEngine.d.ts +54 -0
- package/dist/security/offensive/exploitationEngine.d.ts.map +1 -0
- package/dist/security/offensive/exploitationEngine.js +263 -0
- package/dist/security/offensive/exploitationEngine.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 +100 -0
- package/dist/security/persistence-research.d.ts.map +1 -0
- package/dist/security/persistence-research.js +372 -0
- package/dist/security/persistence-research.js.map +1 -0
- package/dist/security/real/networkExploitation.d.ts +92 -0
- package/dist/security/real/networkExploitation.d.ts.map +1 -0
- package/dist/security/real/networkExploitation.js +316 -0
- package/dist/security/real/networkExploitation.js.map +1 -0
- package/dist/security/real/persistenceImplementation.d.ts +62 -0
- package/dist/security/real/persistenceImplementation.d.ts.map +1 -0
- package/dist/security/real/persistenceImplementation.js +323 -0
- package/dist/security/real/persistenceImplementation.js.map +1 -0
- package/dist/security/real/vulnerabilityScanner.d.ts +73 -0
- package/dist/security/real/vulnerabilityScanner.d.ts.map +1 -0
- package/dist/security/real/vulnerabilityScanner.js +341 -0
- package/dist/security/real/vulnerabilityScanner.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-testing-framework.d.ts +120 -0
- package/dist/security/security-testing-framework.d.ts.map +1 -0
- package/dist/security/security-testing-framework.js +372 -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/shell/bracketedPasteManager.d.ts +76 -0
- package/dist/shell/bracketedPasteManager.d.ts.map +1 -1
- package/dist/shell/bracketedPasteManager.js +267 -9
- package/dist/shell/bracketedPasteManager.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +34 -1
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +304 -24
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/taskCompletionDetector.d.ts +101 -0
- package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
- package/dist/shell/taskCompletionDetector.js +343 -0
- package/dist/shell/taskCompletionDetector.js.map +1 -0
- package/dist/tools/cloudTools.d.ts +57 -0
- package/dist/tools/cloudTools.d.ts.map +1 -0
- package/dist/tools/cloudTools.js +865 -0
- package/dist/tools/cloudTools.js.map +1 -0
- package/dist/tools/enhancedSecurityTools.d.ts +19 -0
- package/dist/tools/enhancedSecurityTools.d.ts.map +1 -0
- package/dist/tools/enhancedSecurityTools.js +215 -0
- package/dist/tools/enhancedSecurityTools.js.map +1 -0
- package/dist/tools/offensiveSecurityTools.d.ts +16 -0
- package/dist/tools/offensiveSecurityTools.d.ts.map +1 -0
- package/dist/tools/offensiveSecurityTools.js +285 -0
- package/dist/tools/offensiveSecurityTools.js.map +1 -0
- package/dist/tools/realSecurityTools.d.ts +18 -0
- package/dist/tools/realSecurityTools.d.ts.map +1 -0
- package/dist/tools/realSecurityTools.js +468 -0
- package/dist/tools/realSecurityTools.js.map +1 -0
- package/dist/tools/securityTools.d.ts +20 -0
- package/dist/tools/securityTools.d.ts.map +1 -0
- package/dist/tools/securityTools.js +449 -0
- package/dist/tools/securityTools.js.map +1 -0
- package/package.json +27 -12
- package/scripts/deploy-security-capabilities.js +178 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusOrchestrator - Unified status management system
|
|
3
|
+
* Coordinates between tool execution, live status tracking, and overlay display
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
export class StatusOrchestrator extends EventEmitter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.statusListeners = new Set();
|
|
10
|
+
this.context = {
|
|
11
|
+
base: null,
|
|
12
|
+
overrides: new Map(),
|
|
13
|
+
tools: new Map(),
|
|
14
|
+
animations: new Map(),
|
|
15
|
+
interrupts: {
|
|
16
|
+
pending: [],
|
|
17
|
+
active: null,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
// Default priority resolver
|
|
21
|
+
this.priorityResolver = (a, b) => {
|
|
22
|
+
const tonePriority = {
|
|
23
|
+
danger: 4,
|
|
24
|
+
warning: 3,
|
|
25
|
+
success: 2,
|
|
26
|
+
info: 1,
|
|
27
|
+
};
|
|
28
|
+
const aPriority = tonePriority[a.tone || 'info'];
|
|
29
|
+
const bPriority = tonePriority[b.tone || 'info'];
|
|
30
|
+
return bPriority - aPriority;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set base status
|
|
35
|
+
*/
|
|
36
|
+
setBaseStatus(status) {
|
|
37
|
+
this.context.base = status;
|
|
38
|
+
this.emitEvent({
|
|
39
|
+
type: 'status.base.changed',
|
|
40
|
+
timestamp: Date.now(),
|
|
41
|
+
data: { status },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Push status override
|
|
46
|
+
*/
|
|
47
|
+
pushOverride(id, status) {
|
|
48
|
+
this.context.overrides.set(id, status);
|
|
49
|
+
this.emitEvent({
|
|
50
|
+
type: 'status.override.pushed',
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
data: { id, status },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Clear status override
|
|
57
|
+
*/
|
|
58
|
+
clearOverride(id) {
|
|
59
|
+
const removed = this.context.overrides.delete(id);
|
|
60
|
+
if (removed) {
|
|
61
|
+
this.emitEvent({
|
|
62
|
+
type: 'status.override.cleared',
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
data: { id },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle tool lifecycle events
|
|
70
|
+
*/
|
|
71
|
+
onToolStart(toolCall) {
|
|
72
|
+
const toolStatus = {
|
|
73
|
+
toolId: toolCall.id,
|
|
74
|
+
tool: toolCall.name,
|
|
75
|
+
status: 'starting',
|
|
76
|
+
description: this.describeToolOperation(toolCall),
|
|
77
|
+
startedAt: Date.now(),
|
|
78
|
+
updatedAt: Date.now(),
|
|
79
|
+
tone: this.getToolTone(toolCall.name),
|
|
80
|
+
};
|
|
81
|
+
this.context.tools.set(toolCall.id, toolStatus);
|
|
82
|
+
this.emitEvent({
|
|
83
|
+
type: 'tool.start',
|
|
84
|
+
timestamp: Date.now(),
|
|
85
|
+
data: { toolCall, toolStatus },
|
|
86
|
+
});
|
|
87
|
+
// Update to running status after a brief delay
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
const status = this.context.tools.get(toolCall.id);
|
|
90
|
+
if (status && status.status === 'starting') {
|
|
91
|
+
status.status = 'running';
|
|
92
|
+
status.updatedAt = Date.now();
|
|
93
|
+
this.emitEvent({
|
|
94
|
+
type: 'tool.progress',
|
|
95
|
+
timestamp: Date.now(),
|
|
96
|
+
data: { toolCall, toolStatus: status },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, 100);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update tool progress
|
|
103
|
+
*/
|
|
104
|
+
onToolProgress(toolId, progress) {
|
|
105
|
+
const toolStatus = this.context.tools.get(toolId);
|
|
106
|
+
if (!toolStatus)
|
|
107
|
+
return;
|
|
108
|
+
toolStatus.progress = {
|
|
109
|
+
current: progress.current,
|
|
110
|
+
total: progress.total,
|
|
111
|
+
percentage: Math.round((progress.current / progress.total) * 100),
|
|
112
|
+
};
|
|
113
|
+
if (progress.message) {
|
|
114
|
+
toolStatus.detail = progress.message;
|
|
115
|
+
}
|
|
116
|
+
toolStatus.updatedAt = Date.now();
|
|
117
|
+
this.emitEvent({
|
|
118
|
+
type: 'tool.progress',
|
|
119
|
+
timestamp: Date.now(),
|
|
120
|
+
data: { toolId, toolStatus, progress },
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handle tool completion
|
|
125
|
+
*/
|
|
126
|
+
onToolComplete(toolId, result) {
|
|
127
|
+
const toolStatus = this.context.tools.get(toolId);
|
|
128
|
+
if (!toolStatus)
|
|
129
|
+
return;
|
|
130
|
+
toolStatus.status = 'completed';
|
|
131
|
+
toolStatus.updatedAt = Date.now();
|
|
132
|
+
this.emitEvent({
|
|
133
|
+
type: 'tool.complete',
|
|
134
|
+
timestamp: Date.now(),
|
|
135
|
+
data: { toolId, toolStatus, result },
|
|
136
|
+
});
|
|
137
|
+
// Remove from active tools after animation
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
this.context.tools.delete(toolId);
|
|
140
|
+
}, 1000);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle tool error
|
|
144
|
+
*/
|
|
145
|
+
onToolError(toolId, error) {
|
|
146
|
+
const toolStatus = this.context.tools.get(toolId);
|
|
147
|
+
if (!toolStatus)
|
|
148
|
+
return;
|
|
149
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
150
|
+
toolStatus.status = 'error';
|
|
151
|
+
toolStatus.tone = 'danger';
|
|
152
|
+
toolStatus.detail = errorMessage || 'An error occurred';
|
|
153
|
+
toolStatus.updatedAt = Date.now();
|
|
154
|
+
this.emitEvent({
|
|
155
|
+
type: 'tool.error',
|
|
156
|
+
timestamp: Date.now(),
|
|
157
|
+
data: { toolId, toolStatus, error },
|
|
158
|
+
});
|
|
159
|
+
// Remove from active tools after delay
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
this.context.tools.delete(toolId);
|
|
162
|
+
}, 2000);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Queue an interrupt
|
|
166
|
+
*/
|
|
167
|
+
queueInterrupt(interrupt) {
|
|
168
|
+
const id = `interrupt-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
169
|
+
const fullInterrupt = {
|
|
170
|
+
...interrupt,
|
|
171
|
+
id,
|
|
172
|
+
timestamp: Date.now(),
|
|
173
|
+
};
|
|
174
|
+
// Insert based on priority
|
|
175
|
+
const index = this.context.interrupts.pending.findIndex((i) => i.priority < interrupt.priority);
|
|
176
|
+
if (index === -1) {
|
|
177
|
+
this.context.interrupts.pending.push(fullInterrupt);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
this.context.interrupts.pending.splice(index, 0, fullInterrupt);
|
|
181
|
+
}
|
|
182
|
+
this.emitEvent({
|
|
183
|
+
type: 'interrupt.received',
|
|
184
|
+
timestamp: Date.now(),
|
|
185
|
+
data: { interrupt: fullInterrupt },
|
|
186
|
+
});
|
|
187
|
+
// Process interrupt queue
|
|
188
|
+
this.processInterrupts();
|
|
189
|
+
return id;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Process pending interrupts
|
|
193
|
+
*/
|
|
194
|
+
processInterrupts() {
|
|
195
|
+
if (this.context.interrupts.active || this.context.interrupts.pending.length === 0) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const interrupt = this.context.interrupts.pending.shift();
|
|
199
|
+
if (!interrupt)
|
|
200
|
+
return;
|
|
201
|
+
this.context.interrupts.active = interrupt;
|
|
202
|
+
// Auto-clear interrupt after 3 seconds if not cleared manually
|
|
203
|
+
setTimeout(() => {
|
|
204
|
+
if (this.context.interrupts.active?.id === interrupt.id) {
|
|
205
|
+
this.clearInterrupt(interrupt.id);
|
|
206
|
+
}
|
|
207
|
+
}, 3000);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Clear an active interrupt
|
|
211
|
+
*/
|
|
212
|
+
clearInterrupt(id) {
|
|
213
|
+
if (this.context.interrupts.active?.id === id) {
|
|
214
|
+
this.context.interrupts.active = null;
|
|
215
|
+
this.processInterrupts(); // Process next in queue
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get the current aggregated status
|
|
220
|
+
*/
|
|
221
|
+
getCurrentStatus() {
|
|
222
|
+
// Priority order:
|
|
223
|
+
// 1. Active interrupt
|
|
224
|
+
// 2. Active tools
|
|
225
|
+
// 3. Overrides
|
|
226
|
+
// 4. Base status
|
|
227
|
+
if (this.context.interrupts.active) {
|
|
228
|
+
return {
|
|
229
|
+
text: this.context.interrupts.active.message,
|
|
230
|
+
tone: 'warning',
|
|
231
|
+
startedAt: this.context.interrupts.active.timestamp,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// Get most important tool status
|
|
235
|
+
if (this.context.tools.size > 0) {
|
|
236
|
+
const toolStatuses = Array.from(this.context.tools.values());
|
|
237
|
+
const activeTools = toolStatuses.filter((t) => t.status === 'running');
|
|
238
|
+
if (activeTools.length > 0) {
|
|
239
|
+
const mostRecent = activeTools.sort((a, b) => b.updatedAt - a.updatedAt)[0];
|
|
240
|
+
if (mostRecent) {
|
|
241
|
+
return {
|
|
242
|
+
text: mostRecent.description,
|
|
243
|
+
detail: mostRecent.detail,
|
|
244
|
+
tone: mostRecent.tone,
|
|
245
|
+
startedAt: mostRecent.startedAt,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Get highest priority override
|
|
251
|
+
if (this.context.overrides.size > 0) {
|
|
252
|
+
const overrides = Array.from(this.context.overrides.values());
|
|
253
|
+
const sorted = overrides.sort(this.priorityResolver);
|
|
254
|
+
return sorted[0] || null;
|
|
255
|
+
}
|
|
256
|
+
return this.context.base;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Register animation
|
|
260
|
+
*/
|
|
261
|
+
registerAnimation(id, type, data) {
|
|
262
|
+
this.context.animations.set(id, {
|
|
263
|
+
id,
|
|
264
|
+
type,
|
|
265
|
+
frame: 0,
|
|
266
|
+
startedAt: Date.now(),
|
|
267
|
+
data,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Update animation frame
|
|
272
|
+
*/
|
|
273
|
+
updateAnimationFrame(id) {
|
|
274
|
+
const animation = this.context.animations.get(id);
|
|
275
|
+
if (animation) {
|
|
276
|
+
animation.frame++;
|
|
277
|
+
this.emitEvent({
|
|
278
|
+
type: 'animation.frame',
|
|
279
|
+
timestamp: Date.now(),
|
|
280
|
+
data: { animation },
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Clear animation
|
|
286
|
+
*/
|
|
287
|
+
clearAnimation(id) {
|
|
288
|
+
this.context.animations.delete(id);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Subscribe to status events
|
|
292
|
+
*/
|
|
293
|
+
subscribe(listener) {
|
|
294
|
+
this.statusListeners.add(listener);
|
|
295
|
+
return () => this.statusListeners.delete(listener);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Emit status event
|
|
299
|
+
*/
|
|
300
|
+
emitEvent(event) {
|
|
301
|
+
this.emit(event.type, event);
|
|
302
|
+
this.statusListeners.forEach((listener) => listener(event));
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Get tool operation description
|
|
306
|
+
*/
|
|
307
|
+
describeToolOperation(toolCall) {
|
|
308
|
+
const params = toolCall.arguments;
|
|
309
|
+
switch (toolCall.name) {
|
|
310
|
+
case 'read_file':
|
|
311
|
+
return `Reading ${this.truncatePath(params.path)}`;
|
|
312
|
+
case 'write_file':
|
|
313
|
+
return `Writing ${this.truncatePath(params.path)}`;
|
|
314
|
+
case 'edit_file':
|
|
315
|
+
return `Editing ${this.truncatePath(params.path)}`;
|
|
316
|
+
case 'bash':
|
|
317
|
+
return `Running: ${this.truncateCommand(params.command)}`;
|
|
318
|
+
case 'search_files':
|
|
319
|
+
return `Searching for: ${this.truncateQuery(params.query)}`;
|
|
320
|
+
case 'list_directory':
|
|
321
|
+
return `Listing ${this.truncatePath(params.path || '.')}`;
|
|
322
|
+
default:
|
|
323
|
+
return `Running ${toolCall.name}`;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get tone for tool type
|
|
328
|
+
*/
|
|
329
|
+
getToolTone(tool) {
|
|
330
|
+
const dangerousTools = ['bash', 'write_file', 'edit_file', 'delete_file'];
|
|
331
|
+
const warningTools = ['install', 'uninstall', 'update'];
|
|
332
|
+
if (dangerousTools.includes(tool)) {
|
|
333
|
+
return 'warning';
|
|
334
|
+
}
|
|
335
|
+
if (warningTools.includes(tool)) {
|
|
336
|
+
return 'warning';
|
|
337
|
+
}
|
|
338
|
+
return 'info';
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Helper to truncate paths
|
|
342
|
+
*/
|
|
343
|
+
truncatePath(path, maxLength = 40) {
|
|
344
|
+
if (!path)
|
|
345
|
+
return '';
|
|
346
|
+
if (path.length <= maxLength)
|
|
347
|
+
return path;
|
|
348
|
+
const parts = path.split('/');
|
|
349
|
+
if (parts.length <= 2) {
|
|
350
|
+
return '...' + path.slice(-(maxLength - 3));
|
|
351
|
+
}
|
|
352
|
+
// Keep first and last parts
|
|
353
|
+
const first = parts[0] || '';
|
|
354
|
+
const last = parts[parts.length - 1] || '';
|
|
355
|
+
const middle = '...';
|
|
356
|
+
const result = `${first}/${middle}/${last}`;
|
|
357
|
+
if (result.length > maxLength) {
|
|
358
|
+
return '...' + last.slice(-(maxLength - 3));
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Helper to truncate commands
|
|
364
|
+
*/
|
|
365
|
+
truncateCommand(command, maxLength = 40) {
|
|
366
|
+
if (!command)
|
|
367
|
+
return '';
|
|
368
|
+
if (command.length <= maxLength)
|
|
369
|
+
return command;
|
|
370
|
+
return command.slice(0, maxLength - 3) + '...';
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Helper to truncate search queries
|
|
374
|
+
*/
|
|
375
|
+
truncateQuery(query, maxLength = 30) {
|
|
376
|
+
if (!query)
|
|
377
|
+
return '';
|
|
378
|
+
if (query.length <= maxLength)
|
|
379
|
+
return query;
|
|
380
|
+
return query.slice(0, maxLength - 3) + '...';
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get full context for debugging
|
|
384
|
+
*/
|
|
385
|
+
getContext() {
|
|
386
|
+
return { ...this.context };
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Reset all status
|
|
390
|
+
*/
|
|
391
|
+
reset() {
|
|
392
|
+
this.context = {
|
|
393
|
+
base: null,
|
|
394
|
+
overrides: new Map(),
|
|
395
|
+
tools: new Map(),
|
|
396
|
+
animations: new Map(),
|
|
397
|
+
interrupts: {
|
|
398
|
+
pending: [],
|
|
399
|
+
active: null,
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output mode configuration for terminal UI
|
|
3
|
+
*
|
|
4
|
+
* Controls whether to use decorative box-drawing characters or plain text.
|
|
5
|
+
* Plain mode outputs clipboard-friendly text without Unicode borders.
|
|
6
|
+
*
|
|
7
|
+
* Environment variable: EROSOLAR_PLAIN_OUTPUT=true
|
|
8
|
+
*/
|
|
9
|
+
let _plainMode = null;
|
|
10
|
+
/**
|
|
11
|
+
* Check if plain output mode is enabled.
|
|
12
|
+
* Plain mode outputs text without box-drawing characters for clean clipboard copying.
|
|
13
|
+
*/
|
|
14
|
+
export function isPlainOutputMode() {
|
|
15
|
+
if (_plainMode !== null) {
|
|
16
|
+
return _plainMode;
|
|
17
|
+
}
|
|
18
|
+
const envValue = process.env['EROSOLAR_PLAIN_OUTPUT'];
|
|
19
|
+
if (envValue !== undefined) {
|
|
20
|
+
_plainMode = ['true', '1', 'yes', 'on'].includes(envValue.toLowerCase());
|
|
21
|
+
return _plainMode;
|
|
22
|
+
}
|
|
23
|
+
// Default to plain output unless explicitly disabled
|
|
24
|
+
_plainMode = true;
|
|
25
|
+
return _plainMode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Override the plain output mode setting (useful for testing)
|
|
29
|
+
*/
|
|
30
|
+
export function setPlainOutputMode(enabled) {
|
|
31
|
+
_plainMode = enabled;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reset plain output mode to check environment variable again
|
|
35
|
+
*/
|
|
36
|
+
export function resetPlainOutputMode() {
|
|
37
|
+
_plainMode = null;
|
|
38
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PersistentPrompt - Minimal, stable chat input at bottom of terminal
|
|
3
|
+
*
|
|
4
|
+
* Design principles:
|
|
5
|
+
* - Simple: No complex cursor manipulation or multi-line rendering
|
|
6
|
+
* - Stable: Uses standard readline without fighting it
|
|
7
|
+
* - Reliable: Clear separation between output area and input area
|
|
8
|
+
*/
|
|
9
|
+
import * as readline from 'node:readline';
|
|
10
|
+
import { theme } from './theme.js';
|
|
11
|
+
/**
|
|
12
|
+
* Minimal prompt manager that doesn't fight with readline
|
|
13
|
+
*/
|
|
14
|
+
export class PersistentPrompt {
|
|
15
|
+
constructor(writeStream, promptText = '> ') {
|
|
16
|
+
this.isEnabled = true;
|
|
17
|
+
this.writeStream = writeStream;
|
|
18
|
+
this.promptText = promptText;
|
|
19
|
+
this.statusBarState = {};
|
|
20
|
+
this.promptState = {
|
|
21
|
+
userInput: '',
|
|
22
|
+
cursorPosition: 0,
|
|
23
|
+
isVisible: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Update the prompt text
|
|
28
|
+
*/
|
|
29
|
+
setPromptText(text) {
|
|
30
|
+
this.promptText = text;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the formatted prompt string
|
|
34
|
+
*/
|
|
35
|
+
getPrompt() {
|
|
36
|
+
return this.promptText;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update user input state (for tracking only - readline handles display)
|
|
40
|
+
*/
|
|
41
|
+
updateInput(input, cursorPos) {
|
|
42
|
+
this.promptState.userInput = input;
|
|
43
|
+
this.promptState.cursorPosition = cursorPos;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Update status bar information
|
|
47
|
+
*/
|
|
48
|
+
updateStatusBar(state) {
|
|
49
|
+
this.statusBarState = { ...this.statusBarState, ...state };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Show a status line above the prompt (call before readline.prompt())
|
|
53
|
+
*/
|
|
54
|
+
showStatus() {
|
|
55
|
+
if (!this.isEnabled)
|
|
56
|
+
return;
|
|
57
|
+
const status = this.buildStatusLine();
|
|
58
|
+
if (status) {
|
|
59
|
+
this.writeStream.write('\n' + status + '\n');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Show the prompt
|
|
64
|
+
*/
|
|
65
|
+
show() {
|
|
66
|
+
this.promptState.isVisible = true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Hide the prompt
|
|
70
|
+
*/
|
|
71
|
+
hide() {
|
|
72
|
+
this.promptState.isVisible = false;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Enable or disable
|
|
76
|
+
*/
|
|
77
|
+
setEnabled(enabled) {
|
|
78
|
+
this.isEnabled = enabled;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Clear - no-op for minimal implementation
|
|
82
|
+
*/
|
|
83
|
+
clear() {
|
|
84
|
+
// Intentionally minimal - let readline handle clearing
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Build status line string
|
|
88
|
+
*/
|
|
89
|
+
buildStatusLine() {
|
|
90
|
+
const parts = [];
|
|
91
|
+
if (this.statusBarState.fileChanges) {
|
|
92
|
+
parts.push(this.statusBarState.fileChanges);
|
|
93
|
+
}
|
|
94
|
+
if (typeof this.statusBarState.contextUsage === 'number') {
|
|
95
|
+
const remaining = Math.max(0, 100 - this.statusBarState.contextUsage);
|
|
96
|
+
parts.push(`${remaining}% context`);
|
|
97
|
+
}
|
|
98
|
+
if (this.statusBarState.message?.trim()) {
|
|
99
|
+
parts.push(this.statusBarState.message.trim());
|
|
100
|
+
}
|
|
101
|
+
if (!parts.length) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return theme.ui.muted(parts.join(' • '));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Handle terminal resize - no-op for minimal implementation
|
|
108
|
+
*/
|
|
109
|
+
handleResize() {
|
|
110
|
+
// Readline handles resize
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Dispose
|
|
114
|
+
*/
|
|
115
|
+
dispose() {
|
|
116
|
+
// Nothing to clean up in minimal implementation
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Simple input box that wraps readline with stable behavior
|
|
121
|
+
*/
|
|
122
|
+
export class SimpleInputBox {
|
|
123
|
+
constructor(promptText = '> ') {
|
|
124
|
+
this.rl = null;
|
|
125
|
+
this.statusText = '';
|
|
126
|
+
this.promptText = promptText;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Initialize readline interface
|
|
130
|
+
*/
|
|
131
|
+
init(input, output) {
|
|
132
|
+
this.rl = readline.createInterface({
|
|
133
|
+
input,
|
|
134
|
+
output,
|
|
135
|
+
prompt: this.promptText,
|
|
136
|
+
terminal: true,
|
|
137
|
+
});
|
|
138
|
+
return this.rl;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Set prompt text
|
|
142
|
+
*/
|
|
143
|
+
setPrompt(text) {
|
|
144
|
+
this.promptText = text;
|
|
145
|
+
if (this.rl) {
|
|
146
|
+
this.rl.setPrompt(text);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Set status text (shown above prompt on next prompt())
|
|
151
|
+
*/
|
|
152
|
+
setStatus(text) {
|
|
153
|
+
this.statusText = text;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Show prompt with optional status line
|
|
157
|
+
*/
|
|
158
|
+
prompt(preserveCursor) {
|
|
159
|
+
if (!this.rl)
|
|
160
|
+
return;
|
|
161
|
+
// Show status line if set
|
|
162
|
+
if (this.statusText) {
|
|
163
|
+
process.stdout.write('\n' + theme.ui.muted(this.statusText) + '\n');
|
|
164
|
+
this.statusText = '';
|
|
165
|
+
}
|
|
166
|
+
this.rl.prompt(preserveCursor);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get readline interface
|
|
170
|
+
*/
|
|
171
|
+
getInterface() {
|
|
172
|
+
return this.rl;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Close and cleanup
|
|
176
|
+
*/
|
|
177
|
+
close() {
|
|
178
|
+
if (this.rl) {
|
|
179
|
+
this.rl.close();
|
|
180
|
+
this.rl = null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|