vibecodingmachine-core 2026.2.20-438 → 2026.2.26-1739

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,373 @@
1
+ /**
2
+ * Agent Defaults Registry
3
+ *
4
+ * Manages default agent configurations and global settings.
5
+ * Follows constitutional requirements: <555 lines, test-first approach.
6
+ */
7
+
8
+ const Agent = require('../Agent');
9
+ const InstallationMethod = require('../InstallationMethod');
10
+ const { InstallationType } = require('../InstallationType');
11
+
12
+ /**
13
+ * Agent defaults registry class
14
+ */
15
+ class AgentDefaultsRegistry {
16
+ /**
17
+ * Create registry instance
18
+ */
19
+ constructor() {
20
+ this.defaultAgents = new Map();
21
+ this.globalDefaults = {};
22
+ this.initializeDefaults();
23
+ }
24
+
25
+ /**
26
+ * Initialize default agent configurations
27
+ */
28
+ initializeDefaults() {
29
+ this.setupDefaultAgents();
30
+ this.setupGlobalDefaults();
31
+ }
32
+
33
+ /**
34
+ * Setup default agent configurations
35
+ */
36
+ setupDefaultAgents() {
37
+ const defaultAgentConfigs = {
38
+ 'claude-code': {
39
+ id: 'claude-code',
40
+ name: 'Claude Code',
41
+ description: 'Anthropic Claude CLI assistant',
42
+ enabled: true,
43
+ verificationCommands: ['claude --version'],
44
+ installationMethods: [
45
+ new InstallationMethod({
46
+ type: InstallationType.NPM,
47
+ packageId: '@anthropic-ai/claude-cli',
48
+ command: 'npm install -g @anthropic-ai/claude-cli',
49
+ verificationCommand: 'claude --version',
50
+ priority: 1
51
+ })
52
+ ]
53
+ },
54
+ 'github-copilot': {
55
+ id: 'github-copilot',
56
+ name: 'GitHub Copilot',
57
+ description: 'GitHub Copilot CLI assistant',
58
+ enabled: true,
59
+ verificationCommands: ['gh copilot --version'],
60
+ installationMethods: [
61
+ new InstallationMethod({
62
+ type: InstallationType.NPM,
63
+ packageId: 'github/gh-copilot',
64
+ command: 'gh extension install github/gh-copilot',
65
+ verificationCommand: 'gh copilot --version',
66
+ priority: 1
67
+ })
68
+ ]
69
+ },
70
+ 'gemini-cli': {
71
+ id: 'gemini-cli',
72
+ name: 'Gemini CLI',
73
+ description: 'Google Gemini CLI assistant',
74
+ enabled: true,
75
+ verificationCommands: ['gemini --version'],
76
+ installationMethods: [
77
+ new InstallationMethod({
78
+ type: InstallationType.NPM,
79
+ packageId: '@google/gemini-cli',
80
+ command: 'npm install -g @google/gemini-cli',
81
+ verificationCommand: 'gemini --version',
82
+ priority: 1
83
+ })
84
+ ]
85
+ },
86
+ 'cursor-cli': {
87
+ id: 'cursor-cli',
88
+ name: 'Cursor CLI',
89
+ description: 'Cursor AI assistant CLI',
90
+ enabled: false, // Disabled by default due to WSL requirement
91
+ verificationCommands: ['cursor --version'],
92
+ installationMethods: [
93
+ new InstallationMethod({
94
+ type: InstallationType.WINGET,
95
+ packageId: 'Cursor.Cursor',
96
+ command: 'winget install Cursor.Cursor',
97
+ verificationCommand: 'cursor --version',
98
+ priority: 1
99
+ })
100
+ ]
101
+ },
102
+ 'opencode-cli': {
103
+ id: 'opencode-cli',
104
+ name: 'OpenCode CLI',
105
+ description: 'OpenCode.ai command-line interface for AI-powered coding',
106
+ enabled: true,
107
+ verificationCommands: ['opencode --version'],
108
+ installationMethods: [
109
+ new InstallationMethod({
110
+ type: InstallationType.DIRECT,
111
+ packageId: 'opencode',
112
+ command: 'curl -fsSL https://raw.githubusercontent.com/opencode-ai/opencode/refs/heads/main/install | bash',
113
+ verificationCommand: 'opencode --version',
114
+ priority: 1
115
+ }),
116
+ new InstallationMethod({
117
+ type: InstallationType.HOMEBREW,
118
+ packageId: 'opencode-ai/tap/opencode',
119
+ command: 'brew install opencode-ai/tap/opencode',
120
+ verificationCommand: 'opencode --version',
121
+ priority: 2
122
+ }),
123
+ new InstallationMethod({
124
+ type: InstallationType.GO,
125
+ packageId: 'github.com/opencode-ai/opencode@latest',
126
+ command: 'go install github.com/opencode-ai/opencode@latest',
127
+ verificationCommand: 'opencode --version',
128
+ priority: 3
129
+ })
130
+ ]
131
+ }
132
+ };
133
+
134
+ Object.entries(defaultAgentConfigs).forEach(([id, config]) => {
135
+ this.defaultAgents.set(id, new Agent(config));
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Setup global default settings
141
+ */
142
+ setupGlobalDefaults() {
143
+ this.globalDefaults = {
144
+ version: '1.0.0',
145
+ global: {
146
+ parallelInstallation: true,
147
+ timeoutSeconds: 300,
148
+ retryAttempts: 3,
149
+ logLevel: 'info'
150
+ }
151
+ };
152
+ }
153
+
154
+ /**
155
+ * Get default agent configuration by ID (raw config, not Agent instance)
156
+ * @param {string} agentId - Agent identifier
157
+ * @returns {Object|null} - Default agent configuration or null
158
+ */
159
+ getDefaultAgentConfig(agentId) {
160
+ return this.defaultAgents.get(agentId) || null;
161
+ }
162
+
163
+ /**
164
+ * Get all default agent configurations (raw configs, not Agent instances)
165
+ * @returns {Object[]} - Array of default agent configurations
166
+ */
167
+ getAllDefaultAgentConfigs() {
168
+ return Array.from(this.defaultAgents.entries()).map(([agentId, config]) => ({
169
+ id: agentId,
170
+ ...config
171
+ }));
172
+ }
173
+
174
+ /**
175
+ * Get default agent by ID
176
+ * @param {string} agentId - Agent identifier
177
+ * @returns {Agent|null} - Default agent or null
178
+ */
179
+ getDefaultAgent(agentId) {
180
+ const config = this.defaultAgents.get(agentId);
181
+ if (!config) {
182
+ return null;
183
+ }
184
+
185
+ // Convert installation method configs to InstallationMethod instances
186
+ const installationMethods = (config.installationMethods || []).map(methodConfig =>
187
+ new InstallationMethod(methodConfig)
188
+ );
189
+
190
+ return new Agent({
191
+ id: agentId,
192
+ ...config,
193
+ installationMethods
194
+ });
195
+ }
196
+
197
+ /**
198
+ * Get all default agents
199
+ * @returns {Agent[]} - Array of default agents
200
+ */
201
+ getAllDefaultAgents() {
202
+ return Array.from(this.defaultAgents.entries()).map(([agentId, config]) => {
203
+ // Convert installation method configs to InstallationMethod instances
204
+ const installationMethods = (config.installationMethods || []).map(methodConfig =>
205
+ new InstallationMethod(methodConfig)
206
+ );
207
+
208
+ return new Agent({
209
+ id: agentId,
210
+ ...config,
211
+ installationMethods
212
+ });
213
+ });
214
+ }
215
+
216
+ /**
217
+ * Get default agent IDs
218
+ * @returns {string[]} - Array of default agent IDs
219
+ */
220
+ getDefaultAgentIds() {
221
+ return Array.from(this.defaultAgents.keys());
222
+ }
223
+
224
+ /**
225
+ * Check if agent ID is a default agent
226
+ * @param {string} agentId - Agent identifier
227
+ * @returns {boolean} - True if agent is a default
228
+ */
229
+ isDefaultAgent(agentId) {
230
+ return this.defaultAgents.has(agentId);
231
+ }
232
+
233
+ /**
234
+ * Get global default settings
235
+ * @returns {Object} - Global default settings
236
+ */
237
+ getGlobalDefaults() {
238
+ return { ...this.globalDefaults };
239
+ }
240
+
241
+ /**
242
+ * Get default configuration for new setup
243
+ * @returns {Object} - Complete default configuration
244
+ */
245
+ getDefaultConfiguration() {
246
+ return {
247
+ version: this.globalDefaults.version,
248
+ lastUpdated: new Date().toISOString(),
249
+ global: { ...this.globalDefaults.global },
250
+ agents: this.getAllDefaultAgents().map(agent => agent.toJSON())
251
+ };
252
+ }
253
+
254
+ /**
255
+ * Validate default configuration
256
+ * @returns {Object} - Validation result
257
+ */
258
+ validateDefaults() {
259
+ const result = {
260
+ valid: true,
261
+ errors: [],
262
+ warnings: []
263
+ };
264
+
265
+ try {
266
+ // Validate each default agent configuration
267
+ for (const [agentId, config] of this.defaultAgents) {
268
+ try {
269
+ // Create temporary agent instance for validation
270
+ const agent = new Agent({
271
+ id: agentId,
272
+ ...config
273
+ });
274
+ agent.validate();
275
+ } catch (error) {
276
+ result.valid = false;
277
+ result.errors.push(`Default agent ${agentId}: ${error.message}`);
278
+ }
279
+ }
280
+
281
+ // Validate global defaults
282
+ if (!this.globalDefaults.version) {
283
+ result.valid = false;
284
+ result.errors.push('Global defaults missing version');
285
+ }
286
+
287
+ if (!this.globalDefaults.global) {
288
+ result.valid = false;
289
+ result.errors.push('Global defaults missing global settings');
290
+ }
291
+
292
+ // Check for required default agents
293
+ const requiredAgents = ['claude-code', 'github-copilot'];
294
+ requiredAgents.forEach(agentId => {
295
+ if (!this.defaultAgents.has(agentId)) {
296
+ result.warnings.push(`Required default agent ${agentId} is missing`);
297
+ }
298
+ });
299
+
300
+ } catch (error) {
301
+ result.valid = false;
302
+ result.errors.push(`Default validation failed: ${error.message}`);
303
+ }
304
+
305
+ return result;
306
+ }
307
+
308
+ /**
309
+ * Get missing default agents compared to current configuration
310
+ * @param {Object[]} existingAgents - Existing agents or agent configurations
311
+ * @returns {Object[]} - Missing default agent configurations
312
+ */
313
+ getMissingDefaultAgents(existingAgents = []) {
314
+ const existingIds = new Set(existingAgents.map(agent => agent.id || agent));
315
+ const missingIds = this.getDefaultAgentIds().filter(id => !existingIds.has(id));
316
+
317
+ return missingIds.map(id => this.getDefaultAgentConfig(id)).filter(config => config !== null);
318
+ }
319
+
320
+ /**
321
+ * Check if default configuration needs update
322
+ * @param {Object} existingConfig - Existing configuration
323
+ * @returns {Object} - Update analysis
324
+ */
325
+ analyzeConfiguration(existingConfig) {
326
+ const analysis = {
327
+ needsUpdate: false,
328
+ missingAgents: [],
329
+ outdatedSettings: false,
330
+ recommendations: []
331
+ };
332
+
333
+ try {
334
+ // Check for missing default agents
335
+ const existingAgents = (existingConfig.agents || [])
336
+ .map(data => Agent.fromJSON(data));
337
+
338
+ analysis.missingAgents = this.getMissingDefaultAgents(existingAgents);
339
+
340
+ if (analysis.missingAgents.length > 0) {
341
+ analysis.needsUpdate = true;
342
+ analysis.recommendations.push(`Add ${analysis.missingAgents.length} missing default agents`);
343
+ }
344
+
345
+ // Check global settings
346
+ if (!existingConfig.global) {
347
+ analysis.needsUpdate = true;
348
+ analysis.outdatedSettings = true;
349
+ analysis.recommendations.push('Add global default settings');
350
+ } else {
351
+ // Compare with current defaults
352
+ const currentDefaults = this.globalDefaults.global;
353
+ const existingSettings = existingConfig.global;
354
+
355
+ Object.keys(currentDefaults).forEach(key => {
356
+ if (existingSettings[key] === undefined) {
357
+ analysis.needsUpdate = true;
358
+ analysis.outdatedSettings = true;
359
+ analysis.recommendations.push(`Update global setting: ${key}`);
360
+ }
361
+ });
362
+ }
363
+
364
+ } catch (error) {
365
+ analysis.needsUpdate = true;
366
+ analysis.recommendations.push('Configuration appears corrupted, recommend full reset');
367
+ }
368
+
369
+ return analysis;
370
+ }
371
+ }
372
+
373
+ module.exports = AgentDefaultsRegistry;
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Agent Configuration Validator
3
+ *
4
+ * Validates agent configurations.
5
+ * Follows constitutional requirements: <555 lines, test-first approach.
6
+ */
7
+
8
+ /**
9
+ * Agent Configuration Validator class
10
+ */
11
+ class ConfigValidator {
12
+ /**
13
+ * Create configuration validator instance
14
+ * @param {Object} options - Validator options
15
+ */
16
+ constructor(options = {}) {
17
+ this.requiredFields = options.requiredFields || ['id', 'name', 'path', 'version', 'description', 'type'];
18
+ this.optionalFields = options.optionalFields || ['capabilities', 'author', 'homepage', 'license', 'tags'];
19
+ this.agentTypes = options.agentTypes || ['CLI', 'GUI', 'Service'];
20
+ this.maxNameLength = options.maxNameLength || 50;
21
+ this.maxDescriptionLength = options.maxDescriptionLength || 200;
22
+ this.maxPathLength = options.maxPathLength || 255;
23
+ this.maxVersionLength = options.maxVersionLength || 20;
24
+ this.maxCapabilitiesCount = options.maxCapabilitiesCount || 10;
25
+ this.logger = options.logger || null;
26
+ }
27
+
28
+ /**
29
+ * Validate agent configuration
30
+ * @param {Object} agent - Agent configuration to validate
31
+ * @returns {Object} - Validation result
32
+ */
33
+ validateAgent(agent) {
34
+ const errors = [];
35
+ const warnings = [];
36
+
37
+ // Check required fields
38
+ for (const field of this.requiredFields) {
39
+ if (!agent[field] || (typeof agent[field] !== 'string' || agent[field].trim() === '')) {
40
+ errors.push(`${field} is required and cannot be empty`);
41
+ }
42
+ }
43
+
44
+ // Check field lengths
45
+ if (agent.name && agent.name.length > this.maxNameLength) {
46
+ errors.push(`Name cannot exceed ${this.maxNameLength} characters`);
47
+ warnings.push(`Name truncated to ${this.maxNameLength} characters`);
48
+ }
49
+
50
+ if (agent.description && agent.description.length > this.maxDescriptionLength) {
51
+ errors.push(`Description cannot exceed ${this.maxDescriptionLength} characters`);
52
+ warnings.push(`Description truncated to ${this.maxDescriptionLength} characters`);
53
+ }
54
+
55
+ if (agent.version && agent.version.length > this.maxVersionLength) {
56
+ errors.push(`Version cannot exceed ${this.maxVersionLength} characters`);
57
+ warnings.push(`Version truncated to ${this.maxVersionLength} characters`);
58
+ }
59
+
60
+ if (agent.path && agent.path.length > this.maxPathLength) {
61
+ errors.push(`Path cannot exceed ${this.maxPathLength} characters`);
62
+ warnings.push(`Path truncated to ${this.maxPathLength} characters`);
63
+ }
64
+
65
+ // Validate agent type
66
+ if (!this.agentTypes.includes(agent.type)) {
67
+ errors.push(`Type must be one of: ${this.agentTypes.join(', ')}`);
68
+ }
69
+
70
+ // Validate version format
71
+ if (agent.version && !this.isValidVersion(agent.version)) {
72
+ errors.push('Version must be in format: major.minor.patch');
73
+ warnings.push('Version should follow semantic versioning');
74
+ }
75
+
76
+ // Validate path format
77
+ if (agent.path && !this.isValidPath(agent.path)) {
78
+ errors.push('Path must be absolute or relative path');
79
+ warnings.push('Path should be absolute or relative path');
80
+ }
81
+
82
+ // Validate capabilities
83
+ if (agent.capabilities && !Array.isArray(agent.capabilities)) {
84
+ errors.push('Capabilities must be an array');
85
+ warnings.push('Capabilities must be an array');
86
+ }
87
+
88
+ // Validate optional fields
89
+ for (const field of this.optionalFields) {
90
+ if (agent[field] && typeof agent[field] !== 'string') {
91
+ errors.push(`${field} must be a string if provided`);
92
+ }
93
+ }
94
+
95
+ // Validate homepage URL
96
+ if (agent.homepage && !this.isValidUrl(agent.homepage)) {
97
+ errors.push('Homepage must be a valid URL');
98
+ warnings.push('Homepage must be a valid URL');
99
+ }
100
+
101
+ // Validate license
102
+ if (agent.license && !this.isValidLicense(agent.license)) {
103
+ errors.push('License must be a valid license identifier');
104
+ warnings.push('License must be a valid license identifier');
105
+ }
106
+
107
+ return {
108
+ valid: errors.length === 0,
109
+ errors,
110
+ warnings,
111
+ agent
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Check if version string is valid
117
+ * @param {string} version - Version string
118
+ * @returns {boolean} - Whether version is valid
119
+ */
120
+ isValidVersion(version) {
121
+ if (!version || typeof version !== 'string') {
122
+ return false;
123
+ }
124
+
125
+ // Check semantic version format: major.minor.patch
126
+ const versionPattern = /^(\d+)\.(\d+)(\.\d+)(\d+)([a-zA-Z0-9])/;
127
+ return versionPattern.test(version);
128
+ }
129
+
130
+ /**
131
+ * Check if path is valid
132
+ * @param {string} path - Path to validate
133
+ * @returns {boolean} - Whether path is valid
134
+ */
135
+ isValidPath(path) {
136
+ if (!path || typeof path !== 'string') {
137
+ return false;
138
+ }
139
+
140
+ // Check if it's a valid file path (basic validation)
141
+ return /^[a-zA-Z]:\\|^[./]|^\//.test(path) || /^[^\\/:*?"<>|]+$/.test(path);
142
+ }
143
+
144
+ /**
145
+ * Check if URL is valid
146
+ * @param {string} url - URL to validate
147
+ * @returns {boolean} - Whether URL is valid
148
+ */
149
+ isValidUrl(url) {
150
+ if (!url || typeof url !== 'string') {
151
+ return false;
152
+ }
153
+
154
+ try {
155
+ new URL(url);
156
+ return true;
157
+ } catch {
158
+ return false;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Check if license is valid
164
+ * @param {string} license - License string
165
+ * @returns {boolean} - Whether license is valid
166
+ */
167
+ isValidLicense(license) {
168
+ if (!license || typeof license !== 'string') {
169
+ return false;
170
+ }
171
+
172
+ // Common license identifiers
173
+ const validLicenses = [
174
+ 'MIT', 'Apache-2.0', 'GPL-3.0', 'BSD-3-Clause', 'ISC', 'MPL-2.0',
175
+ 'LGPL-2.1', 'LGPL-3.0', 'Apache-2.0',
176
+ 'BSD-2-Clause', 'Boost Software License 1.0'
177
+ ];
178
+
179
+ return validLicenses.includes(license);
180
+ }
181
+
182
+ /**
183
+ * Get validation rules for a field
184
+ * @param {string} field - Field name
185
+ * @returns {Object} - Validation rules
186
+ */
187
+ getValidationRules(field) {
188
+ const rules = {
189
+ required: this.requiredFields.includes(field),
190
+ optional: this.optionalFields.includes(field),
191
+ maxLength: field === 'name' ? this.maxNameLength :
192
+ field === 'description' ? this.maxDescriptionLength :
193
+ field === 'version' ? this.maxVersionLength :
194
+ field === 'path' ? this.maxPathLength : 0,
195
+ minLength: field === 'id' ? 1 :
196
+ field === 'description' ? 10 : 0
197
+ };
198
+
199
+ return rules;
200
+ }
201
+
202
+ /**
203
+ * Get validation error message
204
+ * @param {string} field - Field name
205
+ * @param {string} error - Error type
206
+ * @returns {string} - Error message
207
+ */
208
+ getErrorMessage(field, error) {
209
+ switch (field) {
210
+ case 'id':
211
+ return 'Agent ID is required';
212
+ case 'name':
213
+ return 'Agent name is required';
214
+ case 'path':
215
+ return 'Agent path is required';
216
+ case 'version':
217
+ return 'Agent version is required';
218
+ case 'description':
219
+ return 'Agent description is required';
220
+ default:
221
+ return `${field} is invalid`;
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Get validation warning message
227
+ * @param {string} field - Field name
228
+ * @param {string} warning - Warning type
229
+ * @returns {string} - Warning message
230
+ */
231
+ getWarningMessage(field, value) {
232
+ switch (field) {
233
+ case 'name':
234
+ return `Agent name is too long (${value.length} characters, max: ${this.maxNameLength})`;
235
+ case 'description':
236
+ return `Agent description is too long (${value.length} characters, max: ${this.maxDescriptionLength})`;
237
+ case 'version':
238
+ return `Version format is invalid`;
239
+ case 'path':
240
+ return `Agent path is too long (${value.length} characters, max: ${this.maxPathLength})`;
241
+ case 'capabilities':
242
+ return `Too many capabilities (max: ${this.maxCapabilitiesCount})`;
243
+ default:
244
+ return `${field} is invalid`;
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Get validation info for field
250
+ * @param {string} field - Field name
251
+ * @returns {Object} - Validation info
252
+ */
253
+ getFieldInfo(field) {
254
+ const rules = this.getValidationRules(field);
255
+
256
+ return {
257
+ field,
258
+ required: rules.required,
259
+ optional: rules.optional,
260
+ maxLength: rules.maxLength,
261
+ minLength: rules.minLength,
262
+ description: rules.description
263
+ };
264
+ }
265
+
266
+ /**
267
+ * Get all validation rules
268
+ * @returns {Object} - All validation rules
269
+ */
270
+ getAllValidationRules() {
271
+ const allRules = {};
272
+
273
+ for (const field of [...this.requiredFields, ...this.optionalFields]) {
274
+ allRules[field] = this.getValidationRules(field);
275
+ }
276
+
277
+ return allRules;
278
+ }
279
+ }
280
+
281
+ module.exports = ConfigValidator;