erosolar-cli 2.0.4 → 2.1.1

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.
Files changed (134) hide show
  1. package/agents/erosolar-security.rules.json +147 -0
  2. package/dist/capabilities/enhancedAnalysisCapability.d.ts +13 -0
  3. package/dist/capabilities/enhancedAnalysisCapability.d.ts.map +1 -0
  4. package/dist/capabilities/enhancedAnalysisCapability.js +20 -0
  5. package/dist/capabilities/enhancedAnalysisCapability.js.map +1 -0
  6. package/dist/capabilities/offsecOpsCapability.d.ts +6 -0
  7. package/dist/capabilities/offsecOpsCapability.d.ts.map +1 -0
  8. package/dist/capabilities/offsecOpsCapability.js +20 -0
  9. package/dist/capabilities/offsecOpsCapability.js.map +1 -0
  10. package/dist/capabilities/offsecSearchCapability.d.ts +12 -0
  11. package/dist/capabilities/offsecSearchCapability.d.ts.map +1 -0
  12. package/dist/capabilities/offsecSearchCapability.js +27 -0
  13. package/dist/capabilities/offsecSearchCapability.js.map +1 -0
  14. package/dist/capabilities/taoCapability.d.ts +6 -0
  15. package/dist/capabilities/taoCapability.d.ts.map +1 -0
  16. package/dist/capabilities/taoCapability.js +20 -0
  17. package/dist/capabilities/taoCapability.js.map +1 -0
  18. package/dist/capabilities/toolRegistry.d.ts +2 -1
  19. package/dist/capabilities/toolRegistry.d.ts.map +1 -1
  20. package/dist/capabilities/toolRegistry.js +6 -1
  21. package/dist/capabilities/toolRegistry.js.map +1 -1
  22. package/dist/contracts/agent-schemas.json +18 -19
  23. package/dist/contracts/tools.schema.json +38 -8
  24. package/dist/core/contextManager.d.ts +8 -2
  25. package/dist/core/contextManager.d.ts.map +1 -1
  26. package/dist/core/contextManager.js +15 -2
  27. package/dist/core/contextManager.js.map +1 -1
  28. package/dist/core/deepBugAnalyzer.d.ts +128 -0
  29. package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
  30. package/dist/core/deepBugAnalyzer.js +406 -0
  31. package/dist/core/deepBugAnalyzer.js.map +1 -0
  32. package/dist/core/hypothesisEngine.d.ts +113 -0
  33. package/dist/core/hypothesisEngine.d.ts.map +1 -0
  34. package/dist/core/hypothesisEngine.js +264 -0
  35. package/dist/core/hypothesisEngine.js.map +1 -0
  36. package/dist/core/intelligentSummarizer.d.ts +79 -0
  37. package/dist/core/intelligentSummarizer.d.ts.map +1 -0
  38. package/dist/core/intelligentSummarizer.js +273 -0
  39. package/dist/core/intelligentSummarizer.js.map +1 -0
  40. package/dist/core/offsecAlphaZero.d.ts +3 -0
  41. package/dist/core/offsecAlphaZero.d.ts.map +1 -1
  42. package/dist/core/offsecAlphaZero.js +166 -5
  43. package/dist/core/offsecAlphaZero.js.map +1 -1
  44. package/dist/core/productTestHarness.d.ts +113 -0
  45. package/dist/core/productTestHarness.d.ts.map +1 -0
  46. package/dist/core/productTestHarness.js +345 -0
  47. package/dist/core/productTestHarness.js.map +1 -0
  48. package/dist/core/toolPatternAnalyzer.d.ts +87 -0
  49. package/dist/core/toolPatternAnalyzer.d.ts.map +1 -0
  50. package/dist/core/toolPatternAnalyzer.js +272 -0
  51. package/dist/core/toolPatternAnalyzer.js.map +1 -0
  52. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts +3 -0
  53. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts.map +1 -0
  54. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js +14 -0
  55. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js.map +1 -0
  56. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts +3 -0
  57. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts.map +1 -0
  58. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js +12 -0
  59. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js.map +1 -0
  60. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts +3 -0
  61. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts.map +1 -0
  62. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js +12 -0
  63. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js.map +1 -0
  64. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  65. package/dist/plugins/tools/nodeDefaults.js +12 -0
  66. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  67. package/dist/plugins/tools/offsec/offsecOpsPlugin.d.ts +3 -0
  68. package/dist/plugins/tools/offsec/offsecOpsPlugin.d.ts.map +1 -0
  69. package/dist/plugins/tools/offsec/offsecOpsPlugin.js +10 -0
  70. package/dist/plugins/tools/offsec/offsecOpsPlugin.js.map +1 -0
  71. package/dist/plugins/tools/offsec/offsecSearchPlugin.d.ts +3 -0
  72. package/dist/plugins/tools/offsec/offsecSearchPlugin.d.ts.map +1 -0
  73. package/dist/plugins/tools/offsec/offsecSearchPlugin.js +12 -0
  74. package/dist/plugins/tools/offsec/offsecSearchPlugin.js.map +1 -0
  75. package/dist/plugins/tools/tao/taoPlugin.d.ts +3 -0
  76. package/dist/plugins/tools/tao/taoPlugin.d.ts.map +1 -0
  77. package/dist/plugins/tools/tao/taoPlugin.js +10 -0
  78. package/dist/plugins/tools/tao/taoPlugin.js.map +1 -0
  79. package/dist/shell/interactiveShell.d.ts +7 -0
  80. package/dist/shell/interactiveShell.d.ts.map +1 -1
  81. package/dist/shell/interactiveShell.js +70 -22
  82. package/dist/shell/interactiveShell.js.map +1 -1
  83. package/dist/shell/shellApp.js +1 -1
  84. package/dist/shell/shellApp.js.map +1 -1
  85. package/dist/shell/systemPrompt.d.ts.map +1 -1
  86. package/dist/shell/systemPrompt.js +3 -0
  87. package/dist/shell/systemPrompt.js.map +1 -1
  88. package/dist/tools/enhancedAnalysisTools.d.ts +9 -0
  89. package/dist/tools/enhancedAnalysisTools.d.ts.map +1 -0
  90. package/dist/tools/enhancedAnalysisTools.js +382 -0
  91. package/dist/tools/enhancedAnalysisTools.js.map +1 -0
  92. package/dist/tools/enhancedCodeIntelligenceTools.d.ts +1 -21
  93. package/dist/tools/enhancedCodeIntelligenceTools.d.ts.map +1 -1
  94. package/dist/tools/enhancedCodeIntelligenceTools.js +378 -256
  95. package/dist/tools/enhancedCodeIntelligenceTools.js.map +1 -1
  96. package/dist/tools/enhancedDevWorkflowTools.d.ts +2 -10
  97. package/dist/tools/enhancedDevWorkflowTools.d.ts.map +1 -1
  98. package/dist/tools/enhancedDevWorkflowTools.js +293 -165
  99. package/dist/tools/enhancedDevWorkflowTools.js.map +1 -1
  100. package/dist/tools/interactionTools.d.ts.map +1 -1
  101. package/dist/tools/interactionTools.js +55 -0
  102. package/dist/tools/interactionTools.js.map +1 -1
  103. package/dist/tools/offsec/offsecOperationsTools.d.ts +3 -0
  104. package/dist/tools/offsec/offsecOperationsTools.d.ts.map +1 -0
  105. package/dist/tools/offsec/offsecOperationsTools.js +333 -0
  106. package/dist/tools/offsec/offsecOperationsTools.js.map +1 -0
  107. package/dist/tools/offsecSearchTools.d.ts +3 -0
  108. package/dist/tools/offsecSearchTools.d.ts.map +1 -0
  109. package/dist/tools/offsecSearchTools.js +330 -0
  110. package/dist/tools/offsecSearchTools.js.map +1 -0
  111. package/dist/tools/taoOperations.d.ts +7 -0
  112. package/dist/tools/taoOperations.d.ts.map +1 -0
  113. package/dist/tools/taoOperations.js +744 -0
  114. package/dist/tools/taoOperations.js.map +1 -0
  115. package/dist/ui/PromptController.d.ts +5 -1
  116. package/dist/ui/PromptController.d.ts.map +1 -1
  117. package/dist/ui/PromptController.js +6 -0
  118. package/dist/ui/PromptController.js.map +1 -1
  119. package/dist/ui/ShellUIAdapter.d.ts +10 -6
  120. package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
  121. package/dist/ui/ShellUIAdapter.js +68 -66
  122. package/dist/ui/ShellUIAdapter.js.map +1 -1
  123. package/dist/ui/UnifiedUIRenderer.d.ts +2 -0
  124. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
  125. package/dist/ui/UnifiedUIRenderer.js +22 -0
  126. package/dist/ui/UnifiedUIRenderer.js.map +1 -1
  127. package/dist/ui/globalWriteLock.d.ts.map +1 -1
  128. package/dist/ui/globalWriteLock.js +6 -0
  129. package/dist/ui/globalWriteLock.js.map +1 -1
  130. package/dist/ui/streamingFormatter.d.ts +11 -0
  131. package/dist/ui/streamingFormatter.d.ts.map +1 -1
  132. package/dist/ui/streamingFormatter.js +27 -1
  133. package/dist/ui/streamingFormatter.js.map +1 -1
  134. package/package.json +4 -13
@@ -36,8 +36,7 @@ import { analyzeTokenUsage, discoverModularTargets, getModularStatusDisplay, gen
36
36
  import { startOffsecRun, resumeOffsecRun, recordOffsecOutcome, getOffsecNextActions, simulateOffsecRollout, formatOffsecStatus, listOffsecRuns, } from '../core/offsecAlphaZero.js';
37
37
  import { generateTestFlows, detectBugs, detectUIUpdates, saveTestFlows, saveBugReports, saveUIUpdates, getTestFlowStatus, } from '../core/intelligentTestFlows.js';
38
38
  import { PromptController } from '../ui/PromptController.js';
39
- import { writeLock } from '../ui/writeLock.js';
40
- import { enterStreamingMode, exitStreamingMode } from '../ui/globalWriteLock.js';
39
+ import { enterStreamingMode, exitStreamingMode, isStreamingMode } from '../ui/globalWriteLock.js';
41
40
  import { setGlobalAIEnhancer } from '../tools/localExplore.js';
42
41
  import { createProvider } from '../providers/providerFactory.js';
43
42
  import { getParallelAgentManager } from '../subagents/parallelAgentManager.js';
@@ -96,6 +95,7 @@ export class InteractiveShell {
96
95
  pendingSecretRetry = null;
97
96
  terminalInput;
98
97
  currentInput = '';
98
+ currentCursor = 0;
99
99
  ctrlCPressCount = 0;
100
100
  ctrlCHandledThisPress = false;
101
101
  pendingCleanup = null;
@@ -175,6 +175,8 @@ export class InteractiveShell {
175
175
  alternateScreenEnabled;
176
176
  welcomeShown = false;
177
177
  renderer;
178
+ // Message queue for streaming mode coordination - prevents race conditions
179
+ pendingMessages = [];
178
180
  constructor(config) {
179
181
  this.profile = config.profile;
180
182
  this.profileLabel = config.profileLabel;
@@ -264,7 +266,7 @@ export class InteractiveShell {
264
266
  onQueue: (text) => this.handleQueuedInput(text),
265
267
  onCtrlC: ({ hadBuffer }) => this.handleCtrlCPress(hadBuffer),
266
268
  onInterrupt: () => this.handleInterrupt(),
267
- onChange: (text) => this.handleInputChange(text),
269
+ onChange: ({ text, cursor }) => this.handleInputChange(text, cursor, 'renderer'),
268
270
  onEditModeChange: (mode) => this.handleEditModeChange(mode),
269
271
  onToggleVerify: () => this.toggleVerificationMode(),
270
272
  onToggleAutoContinue: () => this.toggleAutoContinueMode(),
@@ -521,9 +523,15 @@ export class InteractiveShell {
521
523
  }
522
524
  return { version: '1.7.458' };
523
525
  }
524
- syncRendererInput() {
525
- // No-op: UnifiedUIRenderer handles its own input state now
526
- // The new architecture doesn't require separate input syncing
526
+ syncRendererInput(force = false) {
527
+ const targetText = this.currentInput ?? '';
528
+ const targetCursor = Number.isFinite(this.currentCursor) ? this.currentCursor : targetText.length;
529
+ const rendererBuffer = this.terminalInput.getBuffer();
530
+ const rendererCursor = this.terminalInput.getCursor();
531
+ if (!force && rendererBuffer === targetText && rendererCursor === targetCursor) {
532
+ return;
533
+ }
534
+ this.terminalInput.setBuffer(targetText, targetCursor);
527
535
  }
528
536
  pushUiEvent(type, content) {
529
537
  if (!content) {
@@ -681,12 +689,15 @@ export class InteractiveShell {
681
689
  /**
682
690
  * TerminalInputAdapter change handler
683
691
  */
684
- handleInputChange(text) {
692
+ handleInputChange(text, cursor = text.length, source = 'programmatic') {
685
693
  this.currentInput = text;
686
- this.syncRendererInput();
694
+ this.currentCursor = Math.max(0, Math.min(cursor, text.length));
687
695
  if (text.length > 0) {
688
696
  this.resetCtrlCSequence();
689
697
  }
698
+ if (source === 'programmatic') {
699
+ this.syncRendererInput();
700
+ }
690
701
  }
691
702
  /**
692
703
  * Edit guard mode change handler (Shift+Tab from terminal input)
@@ -960,7 +971,7 @@ export class InteractiveShell {
960
971
  return;
961
972
  }
962
973
  if (normalized === 'defaults') {
963
- pending.selection = buildEnabledToolSet(null);
974
+ pending.selection = buildEnabledToolSet(null, this.profile);
964
975
  this.renderToolMenu(pending);
965
976
  this.syncRendererInput();
966
977
  return;
@@ -1002,7 +1013,7 @@ export class InteractiveShell {
1002
1013
  display.showInfo('No changes to save.');
1003
1014
  return;
1004
1015
  }
1005
- const defaults = buildEnabledToolSet(null);
1016
+ const defaults = buildEnabledToolSet(null, this.profile);
1006
1017
  if (setsEqual(interaction.selection, defaults)) {
1007
1018
  clearToolSettings();
1008
1019
  display.showInfo('Tool settings cleared. Defaults will be used on the next launch.');
@@ -1322,15 +1333,46 @@ export class InteractiveShell {
1322
1333
  if (!content) {
1323
1334
  return;
1324
1335
  }
1325
- // If lock is already held, write directly - we're in a protected context
1326
- // This prevents queuing issues where content gets delayed
1327
- if (writeLock.isLocked()) {
1328
- process.stdout.write(content);
1329
- return;
1336
+ const payload = content.endsWith('\n') ? content : `${content}\n`;
1337
+ // Coordinate with streaming mode to prevent output corruption
1338
+ // During AI streaming, queue this output instead of writing immediately
1339
+ if (isStreamingMode()) {
1340
+ // Queue message with timestamp for debugging and proper FIFO ordering
1341
+ this.pendingMessages.push({
1342
+ content: payload,
1343
+ timestamp: Date.now()
1344
+ });
1345
+ }
1346
+ else {
1347
+ // Flush any pending messages first (in order) before writing new content
1348
+ this.flushPendingMessages();
1349
+ display.stream(payload);
1350
+ }
1351
+ }
1352
+ /**
1353
+ * Flush all pending messages in FIFO order with error handling
1354
+ * Called when exiting streaming mode to ensure no messages are lost
1355
+ */
1356
+ flushPendingMessages() {
1357
+ // Process messages in FIFO order
1358
+ while (this.pendingMessages.length > 0) {
1359
+ const msg = this.pendingMessages.shift();
1360
+ if (msg) {
1361
+ try {
1362
+ display.stream(msg.content);
1363
+ }
1364
+ catch (error) {
1365
+ // Fallback to direct stdout write if display fails
1366
+ console.error('Failed to flush message:', error);
1367
+ try {
1368
+ process.stdout.write(msg.content);
1369
+ }
1370
+ catch (fallbackError) {
1371
+ console.error('Critical: Unable to write message:', fallbackError);
1372
+ }
1373
+ }
1374
+ }
1330
1375
  }
1331
- writeLock.withLock(() => {
1332
- process.stdout.write(content);
1333
- }, 'interactiveShell.stdout');
1334
1376
  }
1335
1377
  beginAiRuntime() {
1336
1378
  if (this.aiRuntimeStart === null) {
@@ -1422,7 +1464,8 @@ export class InteractiveShell {
1422
1464
  * Ensure the terminal input is ready for interactive input.
1423
1465
  */
1424
1466
  ensureReadlineReady() {
1425
- // Unified in-stream UI handles prompt visibility; skip forcing an extra render here.
1467
+ this.syncRendererInput(true);
1468
+ this.renderer?.render();
1426
1469
  }
1427
1470
  /**
1428
1471
  * Log user prompt to the scroll region so it's part of the conversation flow.
@@ -1482,6 +1525,9 @@ export class InteractiveShell {
1482
1525
  const quiet = options.quiet === true;
1483
1526
  // Exit global streaming mode - allows UI to render again
1484
1527
  exitStreamingMode();
1528
+ // CRITICAL: Flush all pending messages before continuing
1529
+ // This ensures messages queued during streaming are displayed in order
1530
+ this.flushPendingMessages();
1485
1531
  // Preserve final elapsed time before clearing heartbeat start
1486
1532
  if (this.streamingHeartbeatStart) {
1487
1533
  this.lastStreamingElapsedSeconds = Math.max(0, Math.floor((Date.now() - this.streamingHeartbeatStart) / 1000));
@@ -2040,7 +2086,7 @@ export class InteractiveShell {
2040
2086
  lines.push('');
2041
2087
  lines.push(theme.bold('Tool suites'));
2042
2088
  const toolSettings = loadToolSettings();
2043
- const selection = buildEnabledToolSet(toolSettings);
2089
+ const selection = buildEnabledToolSet(toolSettings, this.profile);
2044
2090
  const permissions = evaluateToolPermissions(selection);
2045
2091
  const options = getToolToggleOptions();
2046
2092
  const enabledLabels = options
@@ -4037,7 +4083,7 @@ export class InteractiveShell {
4037
4083
  }
4038
4084
  getToolSelectionSummary() {
4039
4085
  const toolSettings = loadToolSettings();
4040
- const selection = buildEnabledToolSet(toolSettings);
4086
+ const selection = buildEnabledToolSet(toolSettings, this.profile);
4041
4087
  const options = getToolToggleOptions();
4042
4088
  if (!options.length) {
4043
4089
  return null;
@@ -4264,7 +4310,7 @@ export class InteractiveShell {
4264
4310
  display.showWarning('No configurable tools are available.');
4265
4311
  return;
4266
4312
  }
4267
- const selection = buildEnabledToolSet(loadToolSettings());
4313
+ const selection = buildEnabledToolSet(loadToolSettings(), this.profile);
4268
4314
  const interaction = {
4269
4315
  type: 'tool-settings',
4270
4316
  options,
@@ -5463,6 +5509,7 @@ What's the next action?`;
5463
5509
  display.showSystemMessage('✅ Build succeeded.');
5464
5510
  if (outputText && outputText.length < 500) {
5465
5511
  this.writeLocked(`${outputText}\n`);
5512
+ this.ensureReadlineReady();
5466
5513
  }
5467
5514
  this.statusTracker.clearOverride('build');
5468
5515
  return true;
@@ -5475,6 +5522,7 @@ What's the next action?`;
5475
5522
  display.showWarning('⚠️ Build failed. Feeding errors back to agent...');
5476
5523
  if (errorOutput) {
5477
5524
  this.writeLocked(`${errorOutput}\n`);
5525
+ this.ensureReadlineReady();
5478
5526
  }
5479
5527
  this.statusTracker.pushOverride('build', 'Build failing', {
5480
5528
  detail: 'Auto-run npm run build failed',