vibecodingmachine-core 2026.2.20-438 → 2026.2.26-1642

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 (202) hide show
  1. package/README.md +240 -0
  2. package/package.json +10 -2
  3. package/src/agents/Agent.js +300 -0
  4. package/src/agents/AgentAdditionService.js +311 -0
  5. package/src/agents/AgentCheckService.js +690 -0
  6. package/src/agents/AgentInstallationService.js +140 -0
  7. package/src/agents/AgentSetupService.js +467 -0
  8. package/src/agents/AgentStatus.js +183 -0
  9. package/src/agents/AgentVerificationService.js +634 -0
  10. package/src/agents/ConfigurationSchemaValidator.js +543 -0
  11. package/src/agents/EnvironmentConfigurationManager.js +602 -0
  12. package/src/agents/InstallationErrorHandler.js +372 -0
  13. package/src/agents/InstallationLog.js +363 -0
  14. package/src/agents/InstallationMethod.js +510 -0
  15. package/src/agents/InstallationOrchestrator.js +352 -0
  16. package/src/agents/InstallationProgressReporter.js +372 -0
  17. package/src/agents/InstallationRetryManager.js +322 -0
  18. package/src/agents/InstallationType.js +254 -0
  19. package/src/agents/OperationTypes.js +310 -0
  20. package/src/agents/PerformanceMetricsCollector.js +493 -0
  21. package/src/agents/SecurityValidationService.js +534 -0
  22. package/src/agents/VerificationTest.js +354 -0
  23. package/src/agents/VerificationType.js +226 -0
  24. package/src/agents/WindowsPermissionHandler.js +518 -0
  25. package/src/agents/config/AgentConfigManager.js +393 -0
  26. package/src/agents/config/AgentDefaultsRegistry.js +373 -0
  27. package/src/agents/config/ConfigValidator.js +281 -0
  28. package/src/agents/discovery/AgentDiscoveryService.js +707 -0
  29. package/src/agents/logging/AgentLogger.js +511 -0
  30. package/src/agents/status/AgentStatusManager.js +481 -0
  31. package/src/agents/storage/FileManager.js +454 -0
  32. package/src/agents/verification/AgentCommunicationTester.js +474 -0
  33. package/src/agents/verification/BaseVerifier.js +430 -0
  34. package/src/agents/verification/CommandVerifier.js +480 -0
  35. package/src/agents/verification/FileOperationVerifier.js +453 -0
  36. package/src/agents/verification/ResultAnalyzer.js +707 -0
  37. package/src/agents/verification/TestRequirementManager.js +495 -0
  38. package/src/agents/verification/VerificationRunner.js +433 -0
  39. package/src/agents/windows/BaseWindowsInstaller.js +441 -0
  40. package/src/agents/windows/ChocolateyInstaller.js +509 -0
  41. package/src/agents/windows/DirectInstaller.js +443 -0
  42. package/src/agents/windows/InstallerFactory.js +391 -0
  43. package/src/agents/windows/NpmInstaller.js +505 -0
  44. package/src/agents/windows/PowerShellInstaller.js +458 -0
  45. package/src/agents/windows/WinGetInstaller.js +390 -0
  46. package/src/analysis/analysis-reporter.js +132 -0
  47. package/src/analysis/boundary-detector.js +712 -0
  48. package/src/analysis/categorizer.js +340 -0
  49. package/src/analysis/codebase-scanner.js +384 -0
  50. package/src/analysis/line-counter.js +513 -0
  51. package/src/analysis/priority-calculator.js +679 -0
  52. package/src/analysis/report/analysis-report.js +250 -0
  53. package/src/analysis/report/package-analyzer.js +278 -0
  54. package/src/analysis/report/recommendation-generator.js +382 -0
  55. package/src/analysis/report/statistics-generator.js +515 -0
  56. package/src/analysis/reports/analysis-report-model.js +101 -0
  57. package/src/analysis/reports/recommendation-generator.js +283 -0
  58. package/src/analysis/reports/report-generators.js +191 -0
  59. package/src/analysis/reports/statistics-calculator.js +231 -0
  60. package/src/analysis/reports/trend-analyzer.js +219 -0
  61. package/src/analysis/strategy-generator.js +814 -0
  62. package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
  63. package/src/config/refactoring-config.js +307 -0
  64. package/src/health-tracking/json-storage.js +38 -2
  65. package/src/ide-integration/applescript-manager-core.js +233 -0
  66. package/src/ide-integration/applescript-manager.cjs +357 -28
  67. package/src/ide-integration/applescript-manager.js +89 -3599
  68. package/src/ide-integration/cdp-manager.js +306 -0
  69. package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
  70. package/src/ide-integration/continuation-handler.js +337 -0
  71. package/src/ide-integration/ide-status-checker.js +292 -0
  72. package/src/ide-integration/macos-ide-manager.js +627 -0
  73. package/src/ide-integration/macos-text-sender.js +528 -0
  74. package/src/ide-integration/response-reader.js +548 -0
  75. package/src/ide-integration/windows-automation-manager.js +121 -0
  76. package/src/ide-integration/windows-ide-manager.js +373 -0
  77. package/src/index.cjs +25 -3
  78. package/src/index.js +15 -1
  79. package/src/llm/direct-llm-manager.cjs +90 -2
  80. package/src/models/compliance-report.js +538 -0
  81. package/src/models/file-analysis.js +681 -0
  82. package/src/models/refactoring-plan.js +770 -0
  83. package/src/monitoring/alert-system.js +834 -0
  84. package/src/monitoring/compliance-progress-tracker.js +437 -0
  85. package/src/monitoring/continuous-scan-notifications.js +661 -0
  86. package/src/monitoring/continuous-scanner.js +279 -0
  87. package/src/monitoring/file-monitor/file-analyzer.js +262 -0
  88. package/src/monitoring/file-monitor/file-monitor.js +237 -0
  89. package/src/monitoring/file-monitor/watcher.js +194 -0
  90. package/src/monitoring/file-monitor.js +17 -0
  91. package/src/monitoring/notification-manager.js +437 -0
  92. package/src/monitoring/scanner-core.js +368 -0
  93. package/src/monitoring/scanner-events.js +214 -0
  94. package/src/monitoring/violation-notification-system.js +515 -0
  95. package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
  96. package/src/refactoring/boundaries/extraction-result.js +285 -0
  97. package/src/refactoring/boundaries/extraction-strategies.js +392 -0
  98. package/src/refactoring/boundaries/module-boundary.js +209 -0
  99. package/src/refactoring/boundary/boundary-detector.js +741 -0
  100. package/src/refactoring/boundary/boundary-types.js +405 -0
  101. package/src/refactoring/boundary/extraction-strategies.js +554 -0
  102. package/src/refactoring/boundary-extraction-result.js +77 -0
  103. package/src/refactoring/boundary-extraction-strategies.js +330 -0
  104. package/src/refactoring/boundary-extractor.js +384 -0
  105. package/src/refactoring/boundary-types.js +46 -0
  106. package/src/refactoring/circular/circular-dependency.js +88 -0
  107. package/src/refactoring/circular/cycle-detection.js +147 -0
  108. package/src/refactoring/circular/dependency-node.js +82 -0
  109. package/src/refactoring/circular/dependency-result.js +107 -0
  110. package/src/refactoring/circular/dependency-types.js +58 -0
  111. package/src/refactoring/circular/graph-builder.js +213 -0
  112. package/src/refactoring/circular/resolution-strategy.js +72 -0
  113. package/src/refactoring/circular/strategy-generator.js +229 -0
  114. package/src/refactoring/circular-dependency-resolver-original.js +809 -0
  115. package/src/refactoring/circular-dependency-resolver.js +200 -0
  116. package/src/refactoring/code-mover.js +761 -0
  117. package/src/refactoring/file-splitter.js +696 -0
  118. package/src/refactoring/functionality-validator.js +816 -0
  119. package/src/refactoring/import-manager.js +774 -0
  120. package/src/refactoring/module-boundary.js +107 -0
  121. package/src/refactoring/refactoring-executor.js +672 -0
  122. package/src/refactoring/refactoring-rollback.js +614 -0
  123. package/src/refactoring/test-validator.js +631 -0
  124. package/src/requirement-management/default-requirement-manager.js +321 -0
  125. package/src/requirement-management/requirement-file-parser.js +159 -0
  126. package/src/requirement-management/requirement-sequencer.js +221 -0
  127. package/src/rui/commands/AgentCommandParser.js +600 -0
  128. package/src/rui/commands/AgentCommands.js +487 -0
  129. package/src/rui/commands/AgentResponseFormatter.js +832 -0
  130. package/src/scripts/verify-full-compliance.js +269 -0
  131. package/src/sync/sync-engine-core.js +1 -0
  132. package/src/sync/sync-engine-remote-handlers.js +135 -0
  133. package/src/task-generation/automated-task-generator.js +351 -0
  134. package/src/task-generation/prioritizer.js +287 -0
  135. package/src/task-generation/task-list-updater.js +215 -0
  136. package/src/task-generation/task-management-integration.js +480 -0
  137. package/src/task-generation/task-manager-integration.js +270 -0
  138. package/src/task-generation/violation-task-generator.js +474 -0
  139. package/src/task-management/continuous-scan-integration.js +342 -0
  140. package/src/timeout-management/index.js +12 -3
  141. package/src/timeout-management/response-time-tracker.js +167 -0
  142. package/src/timeout-management/timeout-calculator.js +159 -0
  143. package/src/timeout-management/timeout-config-manager.js +172 -0
  144. package/src/utils/ast-analyzer.js +417 -0
  145. package/src/utils/current-requirement-manager.js +276 -0
  146. package/src/utils/current-requirement-operations.js +472 -0
  147. package/src/utils/dependency-mapper.js +456 -0
  148. package/src/utils/download-with-progress.js +4 -2
  149. package/src/utils/electron-update-checker.js +4 -1
  150. package/src/utils/file-size-analyzer.js +272 -0
  151. package/src/utils/import-updater.js +280 -0
  152. package/src/utils/refactoring-tools.js +512 -0
  153. package/src/utils/report-generator.js +569 -0
  154. package/src/utils/reports/report-analysis.js +218 -0
  155. package/src/utils/reports/report-types.js +55 -0
  156. package/src/utils/reports/summary-generators.js +102 -0
  157. package/src/utils/requirement-file-management.js +157 -0
  158. package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
  159. package/src/utils/requirement-helpers/requirement-mover.js +414 -0
  160. package/src/utils/requirement-helpers/requirement-parser.js +326 -0
  161. package/src/utils/requirement-helpers/requirement-status.js +320 -0
  162. package/src/utils/requirement-helpers-new.js +55 -0
  163. package/src/utils/requirement-helpers-refactored.js +367 -0
  164. package/src/utils/requirement-helpers.js +291 -1191
  165. package/src/utils/requirement-movement-operations.js +450 -0
  166. package/src/utils/requirement-movement.js +312 -0
  167. package/src/utils/requirement-parsing-helpers.js +56 -0
  168. package/src/utils/requirement-statistics.js +200 -0
  169. package/src/utils/requirement-text-utils.js +58 -0
  170. package/src/utils/rollback/rollback-handlers.js +125 -0
  171. package/src/utils/rollback/rollback-operation.js +63 -0
  172. package/src/utils/rollback/rollback-recorder.js +166 -0
  173. package/src/utils/rollback/rollback-state-manager.js +175 -0
  174. package/src/utils/rollback/rollback-types.js +33 -0
  175. package/src/utils/rollback/rollback-utils.js +110 -0
  176. package/src/utils/rollback-manager-original.js +569 -0
  177. package/src/utils/rollback-manager.js +202 -0
  178. package/src/utils/smoke-test-cli.js +362 -0
  179. package/src/utils/smoke-test-gui.js +351 -0
  180. package/src/utils/smoke-test-orchestrator.js +321 -0
  181. package/src/utils/smoke-test-runner.js +60 -0
  182. package/src/utils/smoke-test-web.js +347 -0
  183. package/src/utils/specification-helpers.js +39 -13
  184. package/src/utils/specification-migration.js +97 -0
  185. package/src/utils/test-runner.js +579 -0
  186. package/src/utils/validation-framework.js +518 -0
  187. package/src/validation/compliance-analyzer.js +197 -0
  188. package/src/validation/compliance-report-generator.js +343 -0
  189. package/src/validation/compliance-reporter.js +711 -0
  190. package/src/validation/compliance-rules.js +127 -0
  191. package/src/validation/constitution-validator-new.js +196 -0
  192. package/src/validation/constitution-validator.js +17 -0
  193. package/src/validation/file-validators.js +170 -0
  194. package/src/validation/line-limit/file-analyzer.js +201 -0
  195. package/src/validation/line-limit/line-limit-validator.js +208 -0
  196. package/src/validation/line-limit/validation-result.js +144 -0
  197. package/src/validation/line-limit-core.js +225 -0
  198. package/src/validation/line-limit-reporter.js +134 -0
  199. package/src/validation/line-limit-result.js +125 -0
  200. package/src/validation/line-limit-validator.js +41 -0
  201. package/src/validation/metrics-calculator.js +660 -0
  202. package/src/sync/sync-engine-backup.js +0 -559
@@ -0,0 +1,832 @@
1
+ /**
2
+ * RUI Agent Response Formatter
3
+ *
4
+ * Formats agent command responses for different interfaces.
5
+ * Follows constitutional requirements: <555 lines, test-first approach.
6
+ */
7
+
8
+ /**
9
+ * RUI Agent Response Formatter class
10
+ */
11
+ class AgentResponseFormatter {
12
+ /**
13
+ * Create response formatter instance
14
+ * @param {Object} options - Formatter options
15
+ */
16
+ constructor(options = {}) {
17
+ this.defaultFormat = options.defaultFormat || 'json';
18
+ this.includeTimestamp = options.includeTimestamp !== false;
19
+ this.includeMetadata = options.includeMetadata !== false;
20
+ this.prettyPrint = options.prettyPrint !== false;
21
+ this.colorize = options.colorize || false;
22
+ }
23
+
24
+ /**
25
+ * Format response for specified interface
26
+ * @param {Object} response - Response object
27
+ * @param {string} interfaceType - Interface type (cli, trui, grui)
28
+ * @param {Object} options - Formatting options
29
+ * @returns {Object} - Formatted response
30
+ */
31
+ format(response, interfaceType = 'cli', options = {}) {
32
+ const format = options.format || this.defaultFormat;
33
+
34
+ // Add metadata
35
+ const enhancedResponse = this.addMetadata(response, interfaceType);
36
+
37
+ switch (interfaceType) {
38
+ case 'cli':
39
+ return this.formatForCLI(enhancedResponse, format, options);
40
+ case 'trui':
41
+ return this.formatForTRUI(enhancedResponse, format, options);
42
+ case 'grui':
43
+ return this.formatForGRUI(enhancedResponse, format, options);
44
+ default:
45
+ return enhancedResponse;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Format response for CLI interface
51
+ * @param {Object} response - Response object
52
+ * @param {string} format - Output format
53
+ * @param {Object} options - Formatting options
54
+ * @returns {Object} - Formatted response
55
+ */
56
+ formatForCLI(response, format = 'table', options = {}) {
57
+ const formatted = {
58
+ success: response.success,
59
+ data: response.data,
60
+ error: response.error,
61
+ timestamp: response.timestamp,
62
+ interface: 'cli'
63
+ };
64
+
65
+ // Format data based on command type
66
+ if (response.data) {
67
+ if (response.data.agents) {
68
+ formatted.data = this.formatAgentList(response.data.agents, format, options);
69
+ } else if (response.data.summary) {
70
+ formatted.data = this.formatSummary(response.data, format, options);
71
+ } else if (response.data.id) {
72
+ formatted.data = this.formatAgentDetails(response.data, format, options);
73
+ }
74
+ }
75
+
76
+ // Add CLI-specific formatting
77
+ if (options.verbose) {
78
+ formatted.verbose = this.formatVerboseOutput(response);
79
+ }
80
+
81
+ return formatted;
82
+ }
83
+
84
+ /**
85
+ * Format response for TRUI interface
86
+ * @param {Object} response - Response object
87
+ * @param {string} format - Output format
88
+ * @param {Object} options - Formatting options
89
+ * @returns {Object} - Formatted response
90
+ */
91
+ formatForTRUI(response, format = 'json', options = {}) {
92
+ const formatted = {
93
+ success: response.success,
94
+ data: response.data,
95
+ error: response.error,
96
+ timestamp: response.timestamp,
97
+ interface: 'trui'
98
+ };
99
+
100
+ // TRUI-specific formatting
101
+ if (response.data) {
102
+ if (response.data.agents) {
103
+ formatted.data = {
104
+ agents: this.formatAgentListForTRUI(response.data.agents, options),
105
+ navigation: this.generateNavigationOptions('agent-list', response.data.agents)
106
+ };
107
+ } else if (response.data.id) {
108
+ formatted.data = {
109
+ agent: this.formatAgentDetailsForTRUI(response.data, options),
110
+ actions: this.generateActionOptions('agent-details', response.data)
111
+ };
112
+ }
113
+ }
114
+
115
+ // Add TRUI navigation hints
116
+ formatted.navigation = {
117
+ available: this.getAvailableCommands(),
118
+ context: this.getCurrentContext(response)
119
+ };
120
+
121
+ return formatted;
122
+ }
123
+
124
+ /**
125
+ * Format response for GRUI interface
126
+ * @param {Object} response - Response object
127
+ * @param {string} format - Output format
128
+ * @param {Object} options - Formatting options
129
+ * @returns {Object} - Formatted response
130
+ */
131
+ formatForGRUI(response, format = 'json', options = {}) {
132
+ const formatted = {
133
+ success: response.success,
134
+ data: response.data,
135
+ error: response.error,
136
+ timestamp: response.timestamp,
137
+ interface: 'grui'
138
+ };
139
+
140
+ // GRUI-specific formatting
141
+ if (response.data) {
142
+ if (response.data.agents) {
143
+ formatted.data = {
144
+ agents: this.formatAgentListForGRUI(response.data.agents, options),
145
+ ui: {
146
+ component: 'AgentList',
147
+ props: {
148
+ agents: response.data.agents,
149
+ selectable: true,
150
+ actions: ['enable', 'disable', 'check', 'details']
151
+ }
152
+ }
153
+ };
154
+ } else if (response.data.id) {
155
+ formatted.data = {
156
+ agent: this.formatAgentDetailsForGRUI(response.data, options),
157
+ ui: {
158
+ component: 'AgentDetails',
159
+ props: {
160
+ agent: response.data,
161
+ editable: true,
162
+ actions: ['enable', 'disable', 'check', 'remove', 'logs']
163
+ }
164
+ }
165
+ };
166
+ }
167
+ }
168
+
169
+ // Add GRUI event handling
170
+ formatted.events = this.generateUIEvents(response);
171
+ formatted.state = this.generateUIState(response);
172
+
173
+ return formatted;
174
+ }
175
+
176
+ /**
177
+ * Format agent list for CLI
178
+ * @param {Array} agents - Agent list
179
+ * @param {string} format - Output format
180
+ * @param {Object} options - Formatting options
181
+ * @returns {*} - Formatted agent list
182
+ */
183
+ formatAgentList(agents, format = 'table', options = {}) {
184
+ switch (format) {
185
+ case 'table':
186
+ return this.formatAgentListAsTable(agents, options);
187
+ case 'json':
188
+ return agents;
189
+ case 'csv':
190
+ return this.formatAgentListAsCSV(agents, options);
191
+ default:
192
+ return agents;
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Format agent list as table
198
+ * @param {Array} agents - Agent list
199
+ * @param {Object} options - Formatting options
200
+ * @returns {Object} - Table formatted data
201
+ */
202
+ formatAgentListAsTable(agents, options = {}) {
203
+ const includeStatus = options.includeStatus !== false;
204
+ const headers = ['ID', 'Name', 'Enabled'];
205
+
206
+ if (includeStatus) {
207
+ headers.push('Status', 'Last Checked');
208
+ }
209
+
210
+ const rows = agents.map(agent => {
211
+ const row = [
212
+ agent.id,
213
+ agent.name,
214
+ agent.enabled ? 'Yes' : 'No'
215
+ ];
216
+
217
+ if (includeStatus) {
218
+ row.push(
219
+ agent.status || 'Unknown',
220
+ agent.lastChecked || 'Never'
221
+ );
222
+ }
223
+
224
+ return row;
225
+ });
226
+
227
+ return {
228
+ type: 'table',
229
+ headers,
230
+ rows,
231
+ count: agents.length
232
+ };
233
+ }
234
+
235
+ /**
236
+ * Format agent list as CSV
237
+ * @param {Array} agents - Agent list
238
+ * @param {Object} options - Formatting options
239
+ * @returns {Object} - CSV formatted data
240
+ */
241
+ formatAgentListAsCSV(agents, options = {}) {
242
+ const includeStatus = options.includeStatus !== false;
243
+ const headers = ['ID', 'Name', 'Enabled'];
244
+
245
+ if (includeStatus) {
246
+ headers.push('Status', 'Last Checked');
247
+ }
248
+
249
+ const rows = agents.map(agent => {
250
+ const row = [
251
+ agent.id,
252
+ `"${agent.name}"`,
253
+ agent.enabled
254
+ ];
255
+
256
+ if (includeStatus) {
257
+ row.push(
258
+ agent.status || 'Unknown',
259
+ agent.lastChecked || 'Never'
260
+ );
261
+ }
262
+
263
+ return row.join(',');
264
+ });
265
+
266
+ return {
267
+ type: 'csv',
268
+ headers: headers.join(','),
269
+ rows,
270
+ count: agents.length
271
+ };
272
+ }
273
+
274
+ /**
275
+ * Format agent list for TRUI
276
+ * @param {Array} agents - Agent list
277
+ * @param {Object} options - Formatting options
278
+ * @returns {Array} - TRUI formatted agents
279
+ */
280
+ formatAgentListForTRUI(agents, options = {}) {
281
+ return agents.map((agent, index) => ({
282
+ ...agent,
283
+ displayIndex: index + 1,
284
+ statusIcon: this.getStatusIcon(agent.status),
285
+ canSelect: true,
286
+ quickActions: this.getQuickActions(agent)
287
+ }));
288
+ }
289
+
290
+ /**
291
+ * Format agent list for GRUI
292
+ * @param {Array} agents - Agent list
293
+ * @param {Object} options - Formatting options
294
+ * @returns {Array} - GRUI formatted agents
295
+ */
296
+ formatAgentListForGRUI(agents, options = {}) {
297
+ return agents.map(agent => ({
298
+ ...agent,
299
+ ui: {
300
+ status: {
301
+ type: 'badge',
302
+ value: agent.status,
303
+ variant: this.getStatusVariant(agent.status)
304
+ },
305
+ actions: {
306
+ primary: this.getPrimaryAction(agent),
307
+ secondary: this.getSecondaryActions(agent)
308
+ },
309
+ selectable: true,
310
+ editable: ['enabled'].includes(agent.enabled)
311
+ }
312
+ }));
313
+ }
314
+
315
+ /**
316
+ * Format agent details
317
+ * @param {Object} agent - Agent object
318
+ * @param {string} format - Output format
319
+ * @param {Object} options - Formatting options
320
+ * @returns {Object} - Formatted agent details
321
+ */
322
+ formatAgentDetails(agent, format = 'json', options = {}) {
323
+ const formatted = { ...agent };
324
+
325
+ // Add computed properties
326
+ formatted.statusDescription = this.getStatusDescription(agent.status);
327
+ formatted.canInstall = agent.enabled && (!agent.status || agent.status === 'NOT_INSTALLED');
328
+ formatted.canVerify = agent.enabled && ['INSTALLED', 'VERIFIED'].includes(agent.status);
329
+
330
+ if (format === 'detailed') {
331
+ formatted.installationMethods = this.formatInstallationMethods(agent.installationMethods);
332
+ formatted.verificationTests = this.formatVerificationTests(agent.verificationTests);
333
+ }
334
+
335
+ return formatted;
336
+ }
337
+
338
+ /**
339
+ * Format agent details for TRUI
340
+ * @param {Object} agent - Agent object
341
+ * @param {Object} options - Formatting options
342
+ * @returns {Object} - TRUI formatted agent
343
+ */
344
+ formatAgentDetailsForTRUI(agent, options = {}) {
345
+ const formatted = this.formatAgentDetails(agent, 'detailed', options);
346
+
347
+ return {
348
+ ...formatted,
349
+ sections: this.generateAgentSections(agent),
350
+ navigation: {
351
+ back: 'list agents',
352
+ related: ['check ' + agent.id, 'logs ' + agent.id]
353
+ }
354
+ };
355
+ }
356
+
357
+ /**
358
+ * Format agent details for GRUI
359
+ * @param {Object} agent - Agent object
360
+ * @param {Object} options - Formatting options
361
+ * @returns {Object} - GRUI formatted agent
362
+ */
363
+ formatAgentDetailsForGRUI(agent, options = {}) {
364
+ const formatted = this.formatAgentDetails(agent, 'detailed', options);
365
+
366
+ return {
367
+ ...formatted,
368
+ ui: {
369
+ sections: this.generateAgentSections(agent),
370
+ tabs: this.generateAgentTabs(agent),
371
+ panels: this.generateAgentPanels(agent),
372
+ actions: this.generateAgentActions(agent)
373
+ }
374
+ };
375
+ }
376
+
377
+ /**
378
+ * Format summary information
379
+ * @param {Object} summary - Summary object
380
+ * @param {string} format - Output format
381
+ * @param {Object} options - Formatting options
382
+ * @returns {Object} - Formatted summary
383
+ */
384
+ formatSummary(summary, format = 'json', options = {}) {
385
+ const formatted = { ...summary };
386
+
387
+ // Add computed properties
388
+ formatted.successRate = summary.total > 0 ? (summary.successful / summary.total) * 100 : 0;
389
+ formatted.durationFormatted = this.formatDuration(summary.duration);
390
+
391
+ if (format === 'detailed') {
392
+ formatted.breakdown = this.generateSummaryBreakdown(summary);
393
+ }
394
+
395
+ return formatted;
396
+ }
397
+
398
+ /**
399
+ * Add metadata to response
400
+ * @param {Object} response - Original response
401
+ * @param {string} interfaceType - Interface type
402
+ * @returns {Object} - Enhanced response
403
+ */
404
+ addMetadata(response, interfaceType) {
405
+ const enhanced = { ...response };
406
+
407
+ if (this.includeTimestamp) {
408
+ enhanced.timestamp = enhanced.timestamp || new Date().toISOString();
409
+ }
410
+
411
+ if (this.includeMetadata) {
412
+ enhanced.metadata = {
413
+ interface: interfaceType,
414
+ version: '1.0.0',
415
+ formatter: 'AgentResponseFormatter'
416
+ };
417
+ }
418
+
419
+ return enhanced;
420
+ }
421
+
422
+ /**
423
+ * Get status icon
424
+ * @param {string} status - Agent status
425
+ * @returns {string} - Status icon
426
+ */
427
+ getStatusIcon(status) {
428
+ const icons = {
429
+ 'VERIFIED': '✅',
430
+ 'INSTALLED': '📦',
431
+ 'INSTALLING': '⏳',
432
+ 'VERIFYING': '🔍',
433
+ 'NOT_INSTALLED': '❌',
434
+ 'ERROR': '🚫',
435
+ 'RATE_LIMITED': '⏱️',
436
+ 'DISABLED': '🚫'
437
+ };
438
+
439
+ return icons[status] || '❓';
440
+ }
441
+
442
+ /**
443
+ * Get status variant for UI
444
+ * @param {string} status - Agent status
445
+ * @returns {string} - Status variant
446
+ */
447
+ getStatusVariant(status) {
448
+ const variants = {
449
+ 'VERIFIED': 'success',
450
+ 'INSTALLED': 'info',
451
+ 'INSTALLING': 'warning',
452
+ 'VERIFYING': 'warning',
453
+ 'NOT_INSTALLED': 'danger',
454
+ 'ERROR': 'danger',
455
+ 'RATE_LIMITED': 'warning',
456
+ 'DISABLED': 'secondary'
457
+ };
458
+
459
+ return variants[status] || 'secondary';
460
+ }
461
+
462
+ /**
463
+ * Get status description
464
+ * @param {string} status - Agent status
465
+ * @returns {string} - Status description
466
+ */
467
+ getStatusDescription(status) {
468
+ const descriptions = {
469
+ 'VERIFIED': 'Verified and ready',
470
+ 'INSTALLED': 'Installed (not verified)',
471
+ 'INSTALLING': 'Installing...',
472
+ 'VERIFYING': 'Verifying...',
473
+ 'NOT_INSTALLED': 'Not installed',
474
+ 'ERROR': 'Error occurred',
475
+ 'RATE_LIMITED': 'Rate limited',
476
+ 'DISABLED': 'Disabled'
477
+ };
478
+
479
+ return descriptions[status] || 'Unknown';
480
+ }
481
+
482
+ /**
483
+ * Get quick actions for agent
484
+ * @param {Object} agent - Agent object
485
+ * @returns {Array} - Quick actions
486
+ */
487
+ getQuickActions(agent) {
488
+ const actions = [];
489
+
490
+ if (agent.enabled) {
491
+ actions.push({ key: 'check', label: 'Check', shortcut: 'ch' });
492
+ }
493
+
494
+ if (agent.status === 'VERIFIED') {
495
+ actions.push({ key: 'logs', label: 'Logs', shortcut: 'lg' });
496
+ }
497
+
498
+ actions.push({ key: 'details', label: 'Details', shortcut: 'ge' });
499
+
500
+ return actions;
501
+ }
502
+
503
+ /**
504
+ * Get primary action for agent
505
+ * @param {Object} agent - Agent object
506
+ * @returns {Object} - Primary action
507
+ */
508
+ getPrimaryAction(agent) {
509
+ if (agent.enabled && agent.status !== 'VERIFIED') {
510
+ return { key: 'check', label: 'Check Agent', icon: 'play' };
511
+ } else if (agent.status === 'VERIFIED') {
512
+ return { key: 'logs', label: 'View Logs', icon: 'file-text' };
513
+ }
514
+
515
+ return { key: 'details', label: 'View Details', icon: 'info' };
516
+ }
517
+
518
+ /**
519
+ * Get secondary actions for agent
520
+ * @param {Object} agent - Agent object
521
+ * @returns {Array} - Secondary actions
522
+ */
523
+ getSecondaryActions(agent) {
524
+ const actions = [];
525
+
526
+ if (agent.enabled) {
527
+ actions.push({ key: 'disable', label: 'Disable', icon: 'pause' });
528
+ } else {
529
+ actions.push({ key: 'enable', label: 'Enable', icon: 'play' });
530
+ }
531
+
532
+ actions.push({ key: 'remove', label: 'Remove', icon: 'trash', danger: true });
533
+
534
+ return actions;
535
+ }
536
+
537
+ /**
538
+ * Generate navigation options
539
+ * @param {string} context - Current context
540
+ * @param {Array} items - Available items
541
+ * @returns {Object} - Navigation options
542
+ */
543
+ generateNavigationOptions(context, items) {
544
+ return {
545
+ context,
546
+ itemCount: items.length,
547
+ availableActions: this.getAvailableCommands(),
548
+ shortcuts: this.getAvailableShortcuts()
549
+ };
550
+ }
551
+
552
+ /**
553
+ * Generate action options
554
+ * @param {string} context - Current context
555
+ * @param {Object} item - Current item
556
+ * @returns {Array} - Action options
557
+ */
558
+ generateActionOptions(context, item) {
559
+ return this.getQuickActions(item);
560
+ }
561
+
562
+ /**
563
+ * Generate agent sections
564
+ * @param {Object} agent - Agent object
565
+ * @returns {Array} - Agent sections
566
+ */
567
+ generateAgentSections(agent) {
568
+ return [
569
+ {
570
+ id: 'basic',
571
+ title: 'Basic Information',
572
+ fields: ['id', 'name', 'description', 'enabled', 'status']
573
+ },
574
+ {
575
+ id: 'installation',
576
+ title: 'Installation',
577
+ fields: ['installationMethods', 'lastChecked']
578
+ },
579
+ {
580
+ id: 'verification',
581
+ title: 'Verification',
582
+ fields: ['verificationTests', 'lastVerified']
583
+ }
584
+ ];
585
+ }
586
+
587
+ /**
588
+ * Generate agent tabs
589
+ * @param {Object} agent - Agent object
590
+ * @returns {Array} - Agent tabs
591
+ */
592
+ generateAgentTabs(agent) {
593
+ return [
594
+ { id: 'overview', label: 'Overview', active: true },
595
+ { id: 'installation', label: 'Installation' },
596
+ { id: 'verification', label: 'Verification' },
597
+ { id: 'logs', label: 'Logs', disabled: !agent.status || agent.status === 'NOT_INSTALLED' }
598
+ ];
599
+ }
600
+
601
+ /**
602
+ * Generate agent panels
603
+ * @param {Object} agent - Agent object
604
+ * @returns {Array} - Agent panels
605
+ */
606
+ generateAgentPanels(agent) {
607
+ return [
608
+ {
609
+ id: 'status',
610
+ title: 'Status',
611
+ type: 'status-panel',
612
+ data: agent.status
613
+ },
614
+ {
615
+ id: 'actions',
616
+ title: 'Actions',
617
+ type: 'action-panel',
618
+ data: this.generateAgentActions(agent)
619
+ }
620
+ ];
621
+ }
622
+
623
+ /**
624
+ * Generate agent actions
625
+ * @param {Object} agent - Agent object
626
+ * @returns {Object} - Agent actions
627
+ */
628
+ generateAgentActions(agent) {
629
+ return {
630
+ primary: this.getPrimaryAction(agent),
631
+ secondary: this.getSecondaryActions(agent)
632
+ };
633
+ }
634
+
635
+ /**
636
+ * Generate UI events
637
+ * @param {Object} response - Response object
638
+ * @returns {Array} - UI events
639
+ */
640
+ generateUIEvents(response) {
641
+ return [
642
+ 'agent-selected',
643
+ 'agent-status-changed',
644
+ 'agent-action-triggered',
645
+ 'refresh-required'
646
+ ];
647
+ }
648
+
649
+ /**
650
+ * Generate UI state
651
+ * @param {Object} response - Response object
652
+ * @returns {Object} - UI state
653
+ */
654
+ generateUIState(response) {
655
+ return {
656
+ loading: false,
657
+ error: !response.success,
658
+ data: response.data,
659
+ lastUpdated: response.timestamp
660
+ };
661
+ }
662
+
663
+ /**
664
+ * Generate summary breakdown
665
+ * @param {Object} summary - Summary object
666
+ * @returns {Object} - Summary breakdown
667
+ */
668
+ generateSummaryBreakdown(summary) {
669
+ return {
670
+ byStatus: this.groupByStatus(summary.results || {}),
671
+ byDuration: this.groupByDuration(summary.results || {}),
672
+ performance: {
673
+ average: summary.duration / (summary.total || 1),
674
+ min: Math.min(...(summary.durations || [])),
675
+ max: Math.max(...(summary.durations || []))
676
+ }
677
+ };
678
+ }
679
+
680
+ /**
681
+ * Format duration
682
+ * @param {number} duration - Duration in milliseconds
683
+ * @returns {string} - Formatted duration
684
+ */
685
+ formatDuration(duration) {
686
+ if (!duration) return '0s';
687
+
688
+ const seconds = Math.floor(duration / 1000);
689
+ const minutes = Math.floor(seconds / 60);
690
+ const hours = Math.floor(minutes / 60);
691
+
692
+ if (hours > 0) {
693
+ return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
694
+ } else if (minutes > 0) {
695
+ return `${minutes}m ${seconds % 60}s`;
696
+ } else {
697
+ return `${seconds}s`;
698
+ }
699
+ }
700
+
701
+ /**
702
+ * Get available commands
703
+ * @returns {Array} - Available commands
704
+ */
705
+ getAvailableCommands() {
706
+ return [
707
+ 'list agents', 'get agent', 'check agents', 'enable agent',
708
+ 'disable agent', 'remove agent', 'help'
709
+ ];
710
+ }
711
+
712
+ /**
713
+ * Get available shortcuts
714
+ * @returns {Array} - Available shortcuts
715
+ */
716
+ getAvailableShortcuts() {
717
+ return [
718
+ 'la', 'li', 'ge', 'ch', 'en', 'di', 're', 'rm'
719
+ ];
720
+ }
721
+
722
+ /**
723
+ * Get current context
724
+ * @param {Object} response - Response object
725
+ * @returns {string} - Current context
726
+ */
727
+ getCurrentContext(response) {
728
+ if (response.data && response.data.agents) {
729
+ return 'agent-list';
730
+ } else if (response.data && response.data.id) {
731
+ return 'agent-details';
732
+ } else if (response.data && response.data.summary) {
733
+ return 'operation-summary';
734
+ }
735
+ return 'unknown';
736
+ }
737
+
738
+ /**
739
+ * Format verbose output
740
+ * @param {Object} response - Response object
741
+ * @returns {Object} - Verbose output
742
+ */
743
+ formatVerboseOutput(response) {
744
+ return {
745
+ debug: response.debug || {},
746
+ performance: response.performance || {},
747
+ metadata: response.metadata || {},
748
+ raw: response
749
+ };
750
+ }
751
+
752
+ /**
753
+ * Format installation methods
754
+ * @param {Array} methods - Installation methods
755
+ * @returns {Array} - Formatted methods
756
+ */
757
+ formatInstallationMethods(methods) {
758
+ return (methods || []).map(method => ({
759
+ ...method,
760
+ priorityDescription: this.getPriorityDescription(method.priority)
761
+ }));
762
+ }
763
+
764
+ /**
765
+ * Format verification tests
766
+ * @param {Array} tests - Verification tests
767
+ * @returns {Array} - Formatted tests
768
+ */
769
+ formatVerificationTests(tests) {
770
+ return (tests || []).map(test => ({
771
+ ...test,
772
+ typeDescription: this.getTestTypeDescription(test.type)
773
+ }));
774
+ }
775
+
776
+ /**
777
+ * Get priority description
778
+ * @param {number} priority - Priority number
779
+ * @returns {string} - Priority description
780
+ */
781
+ getPriorityDescription(priority) {
782
+ if (priority === 1) return 'Highest';
783
+ if (priority <= 3) return 'High';
784
+ if (priority <= 5) return 'Medium';
785
+ return 'Low';
786
+ }
787
+
788
+ /**
789
+ * Get test type description
790
+ * @param {string} type - Test type
791
+ * @returns {string} - Test type description
792
+ */
793
+ getTestTypeDescription(type) {
794
+ const descriptions = {
795
+ 'FILE_OPERATION': 'File Operation Test',
796
+ 'COMMAND_EXECUTION': 'Command Execution Test',
797
+ 'API_CALL': 'API Call Test',
798
+ 'NETWORK_TEST': 'Network Test'
799
+ };
800
+
801
+ return descriptions[type] || 'Unknown Test';
802
+ }
803
+
804
+ /**
805
+ * Get formatter information
806
+ * @returns {Object} - Formatter info
807
+ */
808
+ getInfo() {
809
+ return {
810
+ name: 'RUI Agent Response Formatter',
811
+ version: '1.0.0',
812
+ defaultFormat: this.defaultFormat,
813
+ includeTimestamp: this.includeTimestamp,
814
+ includeMetadata: this.includeMetadata,
815
+ prettyPrint: this.prettyPrint,
816
+ colorize: this.colorize,
817
+ supportedInterfaces: ['cli', 'trui', 'grui'],
818
+ supportedFormats: ['json', 'table', 'csv', 'detailed'],
819
+ features: [
820
+ 'multi-interface formatting',
821
+ 'response metadata',
822
+ 'status formatting',
823
+ 'action generation',
824
+ 'navigation support',
825
+ 'error handling',
826
+ 'verbose output'
827
+ ]
828
+ };
829
+ }
830
+ }
831
+
832
+ module.exports = AgentResponseFormatter;