s9n-devops-agent 2.0.18-dev.6 → 2.0.18-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s9n-devops-agent",
3
- "version": "2.0.18-dev.6",
3
+ "version": "2.0.18-dev.7",
4
4
  "description": "CS_DevOpsAgent - Intelligent Git Automation System with multi-agent support and session management",
5
5
  "type": "module",
6
6
  "main": "src/cs-devops-agent-worker.js",
@@ -203,16 +203,42 @@ async function checkContractsExist(projectRoot) {
203
203
  let hasChanges = false;
204
204
 
205
205
  // Process each contract type
206
+ let scatteredCount = 0;
207
+ let centralCount = 0;
208
+ let missingCount = 0;
209
+
210
+ // Print summary header
211
+ console.log(`\n${colors.bright}Contract Search Results:${colors.reset}`);
212
+
206
213
  for (const [type, foundFiles] of Object.entries(contractMap)) {
207
214
  // Filter out unique paths (resolve them)
208
215
  const uniqueFiles = [...new Set(foundFiles.map(f => path.resolve(f)))];
216
+ const isCentral = fs.existsSync(path.join(targetDir, type));
217
+
218
+ let statusIcon = '';
219
+ let statusText = '';
220
+
221
+ if (isCentral) {
222
+ statusIcon = colors.green + '✓' + colors.reset;
223
+ statusText = colors.green + 'Present (Central)' + colors.reset;
224
+ centralCount++;
225
+ } else if (uniqueFiles.length > 0) {
226
+ statusIcon = colors.yellow + '⚠️' + colors.reset;
227
+ statusText = colors.yellow + `Found ${uniqueFiles.length} scattered file(s)` + colors.reset;
228
+ scatteredCount++;
229
+ } else {
230
+ statusIcon = colors.red + '✗' + colors.reset;
231
+ statusText = colors.red + 'Missing' + colors.reset;
232
+ missingCount++;
233
+ }
209
234
 
210
- if (uniqueFiles.length > 1) {
211
- console.log();
212
- log.info(`Found multiple files for contract type: ${colors.cyan}${type}${colors.reset}`);
213
- uniqueFiles.forEach(f => console.log(` - ${path.relative(projectRoot, f)}`));
235
+ console.log(` ${statusIcon} ${type.padEnd(30)} : ${statusText}`);
236
+
237
+ if (uniqueFiles.length > 0 && !isCentral) {
238
+ // Show locations for scattered files
239
+ uniqueFiles.forEach(f => console.log(` ${colors.dim}- ${path.relative(projectRoot, f)}${colors.reset}`));
214
240
 
215
- const shouldMerge = await confirm(`Do you want to merge these into House_Rules_Contracts/${type}?`, true);
241
+ const shouldMerge = await confirm(` Merge/Copy ${uniqueFiles.length} file(s) to House_Rules_Contracts/${type}?`, true);
216
242
 
217
243
  if (shouldMerge) {
218
244
  ensureDirectoryExists(targetDir);
@@ -244,47 +270,36 @@ async function checkContractsExist(projectRoot) {
244
270
  }
245
271
 
246
272
  fs.writeFileSync(targetPath, mergedContent);
247
- log.success(`Merged contracts into ${path.relative(projectRoot, targetPath)}`);
273
+ log.success(` Merged into ${path.relative(projectRoot, targetPath)}`);
248
274
  hasChanges = true;
275
+ centralCount++; // Now it's central
276
+ scatteredCount--;
249
277
  }
250
- } else if (uniqueFiles.length === 1) {
251
- // If single file exists but is NOT in House_Rules_Contracts, ask to move/copy
252
- const file = uniqueFiles[0];
253
- const targetPath = path.join(targetDir, type);
254
-
255
- if (file !== path.resolve(targetPath)) {
256
- console.log();
257
- log.info(`Found ${type} at: ${path.relative(projectRoot, file)}`);
258
- const shouldCopy = await confirm(`Copy this to central House_Rules_Contracts/${type}?`, true);
259
- if (shouldCopy) {
260
- ensureDirectoryExists(targetDir);
261
- fs.copyFileSync(file, targetPath);
262
- log.success(`Copied to ${path.relative(projectRoot, targetPath)}`);
263
- hasChanges = true;
264
- }
265
- }
266
278
  }
267
279
  }
268
280
 
269
- // Final check: Do we have all required contracts?
270
- // We check if they exist in the target directory OR if we found them elsewhere (and user maybe declined to merge)
271
- const missing = requiredContracts.filter(contractName => {
272
- // 1. Check central folder
273
- if (fs.existsSync(path.join(targetDir, contractName))) return false;
274
-
275
- // 2. Check if we found it anywhere else
276
- if (contractMap[contractName] && contractMap[contractName].length > 0) return false;
277
-
281
+ console.log(); // Spacing
282
+
283
+ // Final check logic
284
+ if (missingCount === 0) {
285
+ if (hasChanges) log.success('Contracts consolidated and verified.');
286
+ else log.info('All required contracts are present.');
278
287
  return true;
279
- });
288
+ }
280
289
 
281
- if (missing.length === 0) {
282
- if (hasChanges) log.success('Contract files consolidated successfully.');
283
- else log.info('All contract files found in repository.');
284
- return true;
290
+ if (scatteredCount > 0) {
291
+ log.warn(`${scatteredCount} contract types exist but are not centralized.`);
292
+ log.warn('We recommend merging them, but you can proceed without it.');
293
+ // If we have files but user chose not to merge, we consider them "present" enough to skip generation
294
+ // UNLESS there are also missing ones.
295
+ }
296
+
297
+ if (missingCount > 0) {
298
+ log.warn(`${missingCount} contract types are completely missing.`);
299
+ return false; // Trigger generation prompt
285
300
  }
286
301
 
287
- // If we are missing some, but have others, we still return false so generateContracts can run for the missing ones?
302
+ return true; // All accounted for (either central or scattered)
288
303
  // Or we return false and generateContracts will run.
289
304
  return false;
290
305