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,307 @@
1
+ /**
2
+ * Refactoring Configuration
3
+ *
4
+ * Centralized configuration for file size refactoring operations.
5
+ * Defines exclusions, limits, and behavior for refactoring tools.
6
+ */
7
+
8
+ const path = require('path');
9
+
10
+ const RefactoringConfig = {
11
+ // File size limits
12
+ limits: {
13
+ maxFileSize: 800,
14
+ warningThreshold: 700,
15
+ criticalThreshold: 1000,
16
+ smallFileMax: 100,
17
+ mediumFileMax: 300,
18
+ largeFileMax: 800,
19
+ xlargeFileMin: 801
20
+ },
21
+
22
+ // File and directory exclusions
23
+ exclusions: {
24
+ // Third-party directories to exclude from analysis
25
+ thirdPartyDirs: [
26
+ 'node_modules',
27
+ '.git',
28
+ 'dist',
29
+ 'build',
30
+ 'coverage',
31
+ '.nyc_output',
32
+ '.vscode',
33
+ '.idea',
34
+ '.cursor',
35
+ '.windsurf',
36
+ 'vendor',
37
+ 'bower_components'
38
+ ],
39
+
40
+ // Third-party file patterns to exclude
41
+ thirdPartyFiles: [
42
+ '*.min.js',
43
+ '*.min.css',
44
+ '*.bundle.js',
45
+ '*.chunk.js',
46
+ '*.map',
47
+ '*.d.ts',
48
+ '*.lock',
49
+ '*.log'
50
+ ],
51
+
52
+ // Generated files to exclude
53
+ generatedFiles: [
54
+ '*.generated.js',
55
+ '*.generated.ts',
56
+ '*.auto.js',
57
+ '*.auto.ts',
58
+ '*.spec.generated.js',
59
+ '*.test.generated.js'
60
+ ],
61
+
62
+ // Test files (optional - can be included if needed)
63
+ testFiles: [
64
+ '*.test.js',
65
+ '*.spec.js',
66
+ '*.test.ts',
67
+ '*.spec.ts',
68
+ '__tests__/**/*',
69
+ 'test/**/*',
70
+ 'tests/**/*'
71
+ ],
72
+
73
+ // Config files that might be large but shouldn't be refactored
74
+ configFiles: [
75
+ 'package-lock.json',
76
+ 'yarn.lock',
77
+ '*.config.js',
78
+ '*.config.ts',
79
+ '.babelrc',
80
+ '.eslintrc*',
81
+ 'tsconfig.json'
82
+ ],
83
+
84
+ // Documentation files
85
+ docFiles: [
86
+ '*.md',
87
+ '*.txt',
88
+ '*.rst',
89
+ 'CHANGELOG*',
90
+ 'LICENSE*',
91
+ 'README*'
92
+ ]
93
+ },
94
+
95
+ // Refactoring behavior
96
+ refactoring: {
97
+ // Safety settings
98
+ backupBeforeRefactoring: true,
99
+ validateAfterRefactoring: true,
100
+ runTestsAfterRefactoring: true,
101
+ rollbackOnFailure: true,
102
+
103
+ // Module splitting preferences
104
+ preferLogicalBoundaries: true,
105
+ maintainCohesion: true,
106
+ minimizeCoupling: true,
107
+ preservePublicAPI: true,
108
+
109
+ // Import management
110
+ updateImportsAutomatically: true,
111
+ sortImportsAfterUpdate: true,
112
+ removeUnusedImports: true,
113
+
114
+ // File organization
115
+ groupRelatedFunctions: true,
116
+ separateConstants: true,
117
+ extractUtilities: true,
118
+ maintainNamingConventions: true
119
+ },
120
+
121
+ // Analysis settings
122
+ analysis: {
123
+ // AST parsing options
124
+ parseOptions: {
125
+ sourceType: 'module',
126
+ plugins: [
127
+ 'jsx',
128
+ 'typescript',
129
+ 'decorators-legacy',
130
+ 'classProperties',
131
+ 'objectRestSpread',
132
+ 'asyncGenerators',
133
+ 'functionBind',
134
+ 'exportDefaultFrom',
135
+ 'exportNamespaceFrom',
136
+ 'dynamicImport'
137
+ ]
138
+ },
139
+
140
+ // Boundary detection sensitivity
141
+ boundaryDetection: {
142
+ minFunctionLines: 10,
143
+ minClassLines: 15,
144
+ minModuleLines: 20,
145
+ maxComplexity: 10,
146
+ considerComments: true,
147
+ respectExistingSections: true
148
+ },
149
+
150
+ // Dependency analysis
151
+ dependencyAnalysis: {
152
+ includeTransitive: false,
153
+ detectCircular: true,
154
+ analyzeImportTypes: true,
155
+ trackInternalDependencies: true
156
+ }
157
+ },
158
+
159
+ // Reporting settings
160
+ reporting: {
161
+ // Output formats
162
+ formats: ['json', 'markdown', 'console'],
163
+
164
+ // Report content
165
+ includeMetrics: true,
166
+ includeRecommendations: true,
167
+ includeDependencies: true,
168
+ includeComplexity: true,
169
+
170
+ // Visualization
171
+ generateCharts: false,
172
+ includeTreeMap: false,
173
+ includeHeatMap: false
174
+ },
175
+
176
+ // Validation settings
177
+ validation: {
178
+ // Syntax validation
179
+ validateSyntax: true,
180
+ validateImports: true,
181
+ validateExports: true,
182
+
183
+ // Functional validation
184
+ runTests: true,
185
+ checkAPICompatibility: true,
186
+ validateBehavior: false, // Expensive, optional
187
+
188
+ // Quality validation
189
+ checkComplexity: true,
190
+ checkDuplication: true,
191
+ checkNaming: true
192
+ },
193
+
194
+ // Monitoring settings
195
+ monitoring: {
196
+ // Real-time monitoring
197
+ enableFileWatcher: true,
198
+ watchInterval: 1000,
199
+ debounceMs: 500,
200
+
201
+ // Alert thresholds
202
+ alertOnGrowth: true,
203
+ growthThreshold: 50, // lines
204
+ alertFrequency: 300000, // 5 minutes
205
+
206
+ // Compliance checking
207
+ checkOnCommit: true,
208
+ checkOnBuild: true,
209
+ scheduleCheck: false
210
+ },
211
+
212
+ // Package-specific overrides
213
+ packageOverrides: {
214
+ 'packages/cli': {
215
+ limits: {
216
+ maxFileSize: 600, // CLI files can be slightly larger
217
+ warningThreshold: 550
218
+ }
219
+ },
220
+ 'packages/electron-app': {
221
+ exclusions: {
222
+ testFiles: [] // Include test files in Electron app analysis
223
+ }
224
+ },
225
+ 'packages/core': {
226
+ validation: {
227
+ checkComplexity: true,
228
+ checkDuplication: true,
229
+ validateBehavior: true // Core package needs stricter validation
230
+ }
231
+ }
232
+ },
233
+
234
+ // Helper methods
235
+ isExcluded(filePath) {
236
+ const normalizedPath = path.normalize(filePath);
237
+
238
+ // Check directory exclusions
239
+ for (const dir of this.exclusions.thirdPartyDirs) {
240
+ if (normalizedPath.includes(path.sep + dir + path.sep) ||
241
+ normalizedPath.endsWith(path.sep + dir) ||
242
+ normalizedPath.startsWith(dir + path.sep)) {
243
+ return true;
244
+ }
245
+ }
246
+
247
+ // Check file pattern exclusions
248
+ const fileName = path.basename(normalizedPath);
249
+ for (const pattern of this.exclusions.thirdPartyFiles) {
250
+ if (this._matchesPattern(fileName, pattern)) {
251
+ return true;
252
+ }
253
+ }
254
+
255
+ return false;
256
+ },
257
+
258
+ isTestFile(filePath) {
259
+ const fileName = path.basename(filePath);
260
+ for (const pattern of this.exclusions.testFiles) {
261
+ if (this._matchesPattern(filePath, pattern) ||
262
+ this._matchesPattern(fileName, pattern)) {
263
+ return true;
264
+ }
265
+ }
266
+ return false;
267
+ },
268
+
269
+ isConfigFile(filePath) {
270
+ const fileName = path.basename(filePath);
271
+ for (const pattern of this.exclusions.configFiles) {
272
+ if (this._matchesPattern(fileName, pattern)) {
273
+ return true;
274
+ }
275
+ }
276
+ return false;
277
+ },
278
+
279
+ getLimits(packagePath) {
280
+ const packageConfig = this._getPackageConfig(packagePath);
281
+ return { ...this.limits, ...packageConfig.limits };
282
+ },
283
+
284
+ getExclusions(packagePath) {
285
+ const packageConfig = this._getPackageConfig(packagePath);
286
+ return { ...this.exclusions, ...packageConfig.exclusions };
287
+ },
288
+
289
+ _matchesPattern(str, pattern) {
290
+ const regex = new RegExp(
291
+ '^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$'
292
+ );
293
+ return regex.test(str);
294
+ },
295
+
296
+ _getPackageConfig(packagePath) {
297
+ // Find matching package override
298
+ for (const [pkgPath, config] of Object.entries(this.packageOverrides)) {
299
+ if (packagePath.includes(pkgPath)) {
300
+ return config;
301
+ }
302
+ }
303
+ return {};
304
+ }
305
+ };
306
+
307
+ module.exports = RefactoringConfig;
@@ -14,6 +14,16 @@ const { StorageInterface } = require('./storage-interface');
14
14
  const { FileSystemError, ValidationError } = require('./errors');
15
15
  const { validateHealthData } = require('./validators');
16
16
 
17
+ /**
18
+ * Simple logger for health tracking (minimal output in production)
19
+ */
20
+ const logger = {
21
+ debug: (msg, ...args) => { /* Silent in production - only enable for debugging */ },
22
+ info: (msg, ...args) => console.log(`[HEALTH] ${msg}`, ...args),
23
+ warn: (msg, ...args) => console.warn(`[HEALTH] ${msg}`, ...args),
24
+ error: (msg, ...args) => console.error(`[HEALTH] ${msg}`, ...args)
25
+ };
26
+
17
27
  /**
18
28
  * Default storage file location
19
29
  */
@@ -63,6 +73,8 @@ class JSONStorage extends StorageInterface {
63
73
  */
64
74
  async read() {
65
75
  try {
76
+ // logger.debug(`Reading health data from: ${this.storageFile}`); // Silent
77
+
66
78
  // Ensure storage directory exists
67
79
  await fs.ensureDir(path.dirname(this.storageFile));
68
80
 
@@ -70,27 +82,33 @@ class JSONStorage extends StorageInterface {
70
82
  const fileExists = await this.exists();
71
83
 
72
84
  if (!fileExists) {
85
+ logger.info('Health data file not found, returning default structure');
73
86
  // Return default data structure if file doesn't exist
74
87
  return JSON.parse(JSON.stringify(DEFAULT_HEALTH_DATA));
75
88
  }
76
89
 
77
90
  // Read file content
78
91
  const content = await fs.readFile(this.storageFile, 'utf8');
92
+ // logger.debug(`Read ${content.length} bytes from health data file`); // Silent
79
93
 
80
94
  // Parse JSON
81
95
  let data;
82
96
  try {
83
97
  data = JSON.parse(content);
98
+ // logger.debug('Successfully parsed health data JSON'); // Silent
84
99
  } catch (parseError) {
85
100
  // Attempt to restore from backup on parse error
86
- console.warn(`Failed to parse health data, attempting backup restore: ${parseError.message}`);
101
+ logger.warn(`Failed to parse health data, attempting backup restore: ${parseError.message}`);
87
102
  const backupExists = await fs.pathExists(this.backupFile);
88
103
 
89
104
  if (backupExists) {
105
+ logger.info('Restoring from backup file');
90
106
  await this.restore(this.backupFile);
91
107
  const backupContent = await fs.readFile(this.storageFile, 'utf8');
92
108
  data = JSON.parse(backupContent);
109
+ logger.info('Successfully restored from backup');
93
110
  } else {
111
+ logger.error('No backup file available for restoration');
94
112
  throw new FileSystemError(
95
113
  'Failed to parse health data and no backup available',
96
114
  this.storageFile,
@@ -103,7 +121,9 @@ class JSONStorage extends StorageInterface {
103
121
  // Validate data structure
104
122
  try {
105
123
  validateHealthData(data);
124
+ // logger.debug('Health data validation passed'); // Silent
106
125
  } catch (validationError) {
126
+ logger.error(`Health data validation failed: ${validationError.message}`);
107
127
  throw new FileSystemError(
108
128
  `Health data validation failed: ${validationError.message}`,
109
129
  this.storageFile,
@@ -115,11 +135,13 @@ class JSONStorage extends StorageInterface {
115
135
  // Run migrations if needed
116
136
  data = await this._runMigrations(data);
117
137
 
138
+ // logger.debug('Health data read completed successfully'); // Silent
118
139
  return data;
119
140
  } catch (error) {
120
141
  if (error instanceof FileSystemError) {
121
142
  throw error;
122
143
  }
144
+ logger.error(`Failed to read health data: ${error.message}`);
123
145
  throw new FileSystemError(
124
146
  `Failed to read health data: ${error.message}`,
125
147
  this.storageFile,
@@ -138,8 +160,11 @@ class JSONStorage extends StorageInterface {
138
160
  */
139
161
  async write(data) {
140
162
  try {
163
+ // logger.debug(`Writing health data to: ${this.storageFile}`); // Silent
164
+
141
165
  // Validate data before writing
142
166
  validateHealthData(data);
167
+ // logger.debug('Health data validation passed'); // Silent
143
168
 
144
169
  // Update lastUpdated timestamp
145
170
  data.lastUpdated = new Date().toISOString();
@@ -150,19 +175,30 @@ class JSONStorage extends StorageInterface {
150
175
  // Create backup if file exists
151
176
  const fileExists = await this.exists();
152
177
  if (fileExists) {
178
+ // logger.debug('Creating backup before write'); // Silent
153
179
  await this.backup();
180
+ // logger.debug('Backup created successfully'); // Silent
154
181
  }
155
182
 
156
183
  // Atomic write: write to temp file first
157
184
  const tempFile = `${this.storageFile}.tmp`;
158
- await fs.writeJson(tempFile, data, { spaces: 2 });
185
+ const jsonString = JSON.stringify(data, null, 2);
186
+
187
+ // Ensure storage directory exists
188
+ await fs.ensureDir(path.dirname(this.storageFile));
189
+
190
+ await fs.writeFile(tempFile, jsonString, 'utf8');
191
+ // logger.debug(`Wrote ${jsonString.length} bytes to temp file`); // Silent
159
192
 
160
193
  // Rename temp file to target (atomic operation)
161
194
  await fs.rename(tempFile, this.storageFile);
195
+ // logger.debug('Health data written successfully'); // Silent
162
196
  } catch (error) {
163
197
  if (error instanceof ValidationError) {
198
+ logger.error(`Validation error during write: ${error.message}`);
164
199
  throw error;
165
200
  }
201
+ logger.error(`Failed to write health data: ${error.message}`);
166
202
  throw new FileSystemError(
167
203
  `Failed to write health data: ${error.message}`,
168
204
  this.storageFile,
@@ -0,0 +1,233 @@
1
+ // @vibecodingmachine/core - AppleScript Manager Core
2
+ // Core coordination and interface for IDE interactions
3
+
4
+ const { execSync } = require('child_process');
5
+ const { writeFileSync, unlinkSync } = require('fs');
6
+ const { join } = require('path');
7
+ const { tmpdir } = require('os');
8
+
9
+ // Import platform-specific managers
10
+ const MacOSIDEManager = require('./macos-ide-manager');
11
+ const WindowsIDEManager = require('./windows-ide-manager');
12
+ const IDEStatusChecker = require('./ide-status-checker');
13
+ const ResponseReader = require('./response-reader');
14
+ const ContinuationHandler = require('./continuation-handler');
15
+
16
+ // Import Windows automation manager for Windows platform
17
+ let WindowsAutomationManager;
18
+ if (process.platform === 'win32') {
19
+ WindowsAutomationManager = require('./windows-automation-manager');
20
+ }
21
+
22
+ const AppleScriptUtils = require('./applescript-utils');
23
+
24
+ /**
25
+ * Core AppleScript Manager for IDE interactions
26
+ * Coordinates platform-specific operations and provides unified interface
27
+ */
28
+ class AppleScriptManagerCore {
29
+ constructor() {
30
+ this.logger = console;
31
+ this.platform = process.platform;
32
+ this.appleScriptUtils = new AppleScriptUtils();
33
+
34
+ // Initialize platform-specific managers
35
+ if (this.platform === 'win32' && WindowsAutomationManager) {
36
+ this.windowsManager = new WindowsAutomationManager();
37
+ this.ideManager = new WindowsIDEManager(this.windowsManager);
38
+ } else {
39
+ this.ideManager = new MacOSIDEManager(this.appleScriptUtils);
40
+ }
41
+
42
+ this.statusChecker = new IDEStatusChecker(this.platform, this.windowsManager);
43
+ this.responseReader = new ResponseReader(this.platform, this.windowsManager);
44
+ this.continuationHandler = new ContinuationHandler(this.platform, this.windowsManager);
45
+ }
46
+
47
+ /**
48
+ * Generic IDE opener - routes to specific IDE methods
49
+ * @param {string} ide - The IDE name ('cursor', 'windsurf', 'antigravity', 'vscode', etc.')
50
+ * @param {string} repoPath - Optional repository path to open
51
+ * @returns {Promise<Object>} Result object
52
+ */
53
+ async openIDE(ide, repoPath = null) {
54
+ return await this.ideManager.openIDE(ide, repoPath);
55
+ }
56
+
57
+ /**
58
+ * Send text to an IDE using platform-specific methods
59
+ * @param {string} text - The text to send
60
+ * @param {string} ide - The IDE name ('cursor', 'windsurf', 'claude')
61
+ * @param {string} repoPath - The repository path (optional, used for Claude)
62
+ * @returns {Promise<Object>} Result object with success status and details
63
+ */
64
+ async sendText(text, ide, repoPath = null) {
65
+ if (typeof text !== 'string') {
66
+ return {
67
+ success: false,
68
+ error: `Invalid text type: ${typeof text}. Expected string.`,
69
+ debug: { textType: typeof text, textValue: text }
70
+ };
71
+ }
72
+
73
+ return await this.ideManager.sendText(text, ide, repoPath);
74
+ }
75
+
76
+ /**
77
+ * Read chat response from IDE using platform-specific methods
78
+ * @param {string} ide - The IDE name ('cursor', 'windsurf', 'vscode')
79
+ * @returns {Promise<string>} The chat response text
80
+ */
81
+ async readChatResponse(ide) {
82
+ return await this.responseReader.readChatResponse(ide);
83
+ }
84
+
85
+ /**
86
+ * Check if an IDE is running and accessible
87
+ * @param {string} ide - The IDE name
88
+ * @returns {Promise<Object>} Result object with success status and details
89
+ */
90
+ async getIDEStatus(ide) {
91
+ return await this.statusChecker.getIDEStatus(ide);
92
+ }
93
+
94
+ /**
95
+ * Close previous chat thread in an IDE to prevent conflicts
96
+ * @param {string} ide - The IDE name ('cursor', 'vscode', 'windsurf', 'claude')
97
+ * @returns {Promise<Object>} Result object with success status and details
98
+ */
99
+ async closePreviousChatThread(ide) {
100
+ return await this.ideManager.closePreviousChatThread(ide);
101
+ }
102
+
103
+ /**
104
+ * Send text to an IDE with automatic thread closure
105
+ * @param {string} text - The text to send
106
+ * @param {string} ide - The IDE name ('cursor', 'vscode', 'windsurf')
107
+ * @returns {Promise<Object>} Result object with success status and details
108
+ */
109
+ async sendTextWithThreadClosure(text, ide) {
110
+ return await this.ideManager.sendTextWithThreadClosure(text, ide);
111
+ }
112
+
113
+ /**
114
+ * Check Claude terminal output for session limit errors
115
+ * @returns {Promise<Object>} Result object with sessionLimitReached flag and details
116
+ */
117
+ async checkClaudeSessionLimit() {
118
+ return await this.ideManager.checkClaudeSessionLimit();
119
+ }
120
+
121
+ /**
122
+ * Detect continuation prompts using platform-specific methods
123
+ * @returns {Promise<boolean>} True if continuation prompt detected
124
+ */
125
+ async detectContinuationPrompt() {
126
+ return await this.continuationHandler.detectContinuationPrompt();
127
+ }
128
+
129
+ /**
130
+ * Click detected continuation button using platform-specific methods
131
+ * @returns {Promise<boolean>} True if button clicked successfully
132
+ */
133
+ async clickContinuationButton() {
134
+ return await this.continuationHandler.clickContinuationButton();
135
+ }
136
+
137
+ /**
138
+ * Check for continuation prompts using platform-specific methods
139
+ * @param {string} ide - The IDE name
140
+ * @returns {Promise<Object>} Result with continuation detected and button info
141
+ */
142
+ async checkForContinuation(ide) {
143
+ return await this.continuationHandler.checkForContinuation(ide);
144
+ }
145
+
146
+ /**
147
+ * Click a continuation button if found
148
+ * @param {string} ide - The IDE name
149
+ * @returns {Promise<Object>} Result of operation
150
+ */
151
+ async clickContinuationButton(ide) {
152
+ return await this.continuationHandler.clickContinuationButton(ide);
153
+ }
154
+
155
+ /**
156
+ * Deterministically send text to Terminal window 1 tab 1 and verify via history snippet
157
+ * @param {string} text
158
+ * @returns {Promise<Object>} Result with success and note
159
+ */
160
+ async sendDeterministicToTerminalWindow1(text) {
161
+ return await this.ideManager.sendDeterministicToTerminalWindow1(text);
162
+ }
163
+
164
+ /**
165
+ * Check Antigravity UI for Gemini quota limit popup text
166
+ * @returns {Promise<{isRateLimited: boolean, message?: string, resumeAt?: string, note?: string}>}
167
+ */
168
+ async checkAntigravityQuotaLimit() {
169
+ return await this.ideManager.checkAntigravityQuotaLimit();
170
+ }
171
+
172
+ /**
173
+ * Handle Antigravity quota limit by automatically switching models
174
+ * @returns {Promise<{success: boolean, model?: string, error?: string}>}
175
+ */
176
+ async handleAntigravityQuotaLimit() {
177
+ return await this.ideManager.handleAntigravityQuotaLimit();
178
+ }
179
+
180
+ /**
181
+ * Detect quota warnings using platform-specific methods
182
+ * @param {string} ide - The IDE name ('windsurf')
183
+ * @returns {Promise<Object>} Quota detection result
184
+ */
185
+ async detectQuotaWarning(ide) {
186
+ return await this.ideManager.detectQuotaWarning(ide);
187
+ }
188
+
189
+ /**
190
+ * Check Windsurf for rate limit errors
191
+ * @returns {Promise<Object>} Result object with isRateLimited flag and details
192
+ */
193
+ async checkWindsurfRateLimit() {
194
+ return await this.ideManager.checkWindsurfRateLimit();
195
+ }
196
+
197
+ /**
198
+ * Send text to VS Code using dedicated method
199
+ * @param {string} text - The text to send
200
+ * @returns {Promise<Object>} Result object with success status and details
201
+ */
202
+ async sendTextToVSCode(text) {
203
+ return await this.ideManager.sendTextToVSCode(text);
204
+ }
205
+
206
+ /**
207
+ * Send text to Windsurf extension within VS Code
208
+ * @param {string} text - The text to send
209
+ * @returns {Promise<Object>} Result object with success status
210
+ */
211
+ async sendTextToWindsurfExtension(text) {
212
+ return await this.ideManager.sendTextToWindsurfExtension(text);
213
+ }
214
+
215
+ /**
216
+ * Check if we're running within a VS Code extension context
217
+ * @returns {boolean} True if running in VS Code extension
218
+ */
219
+ isRunningInVSCodeExtension() {
220
+ try {
221
+ // Check for VS Code extension environment variables
222
+ return !!(process.env.VSCODE_PID ||
223
+ process.env.VSCODE_INJECTION ||
224
+ process.env.VSCODE_IPC_HOOK_CLI ||
225
+ (typeof require !== 'undefined' && require.main && require.main.filename.includes('vscode')));
226
+ } catch (error) {
227
+ this.logger.log('⚠️ Could not determine VS Code extension context:', error.message);
228
+ return false;
229
+ }
230
+ }
231
+ }
232
+
233
+ module.exports = AppleScriptManagerCore;