s9n-devops-agent 2.0.18-dev.5 → 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 +1 -1
- package/src/setup-cs-devops-agent.js +55 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "s9n-devops-agent",
|
|
3
|
-
"version": "2.0.18-dev.
|
|
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",
|
|
@@ -168,7 +168,8 @@ async function checkContractsExist(projectRoot) {
|
|
|
168
168
|
|
|
169
169
|
// Find all files that look like contracts
|
|
170
170
|
// We look for files containing "CONTRACT" in the name, excluding typical ignores
|
|
171
|
-
|
|
171
|
+
// Use -iname for case-insensitive matching
|
|
172
|
+
const findCommand = `find "${projectRoot}" -type f \\( -iname "*CONTRACT*.md" -o -iname "*CONTRACT*.json" \\) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/local_deploy/*"`;
|
|
172
173
|
|
|
173
174
|
let files = [];
|
|
174
175
|
try {
|
|
@@ -202,16 +203,42 @@ async function checkContractsExist(projectRoot) {
|
|
|
202
203
|
let hasChanges = false;
|
|
203
204
|
|
|
204
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
|
+
|
|
205
213
|
for (const [type, foundFiles] of Object.entries(contractMap)) {
|
|
206
214
|
// Filter out unique paths (resolve them)
|
|
207
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
|
+
}
|
|
234
|
+
|
|
235
|
+
console.log(` ${statusIcon} ${type.padEnd(30)} : ${statusText}`);
|
|
208
236
|
|
|
209
|
-
if (uniqueFiles.length >
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
uniqueFiles.forEach(f => console.log(` - ${path.relative(projectRoot, f)}`));
|
|
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}`));
|
|
213
240
|
|
|
214
|
-
const shouldMerge = await confirm(`
|
|
241
|
+
const shouldMerge = await confirm(` Merge/Copy ${uniqueFiles.length} file(s) to House_Rules_Contracts/${type}?`, true);
|
|
215
242
|
|
|
216
243
|
if (shouldMerge) {
|
|
217
244
|
ensureDirectoryExists(targetDir);
|
|
@@ -243,37 +270,36 @@ async function checkContractsExist(projectRoot) {
|
|
|
243
270
|
}
|
|
244
271
|
|
|
245
272
|
fs.writeFileSync(targetPath, mergedContent);
|
|
246
|
-
log.success(`Merged
|
|
273
|
+
log.success(` Merged into ${path.relative(projectRoot, targetPath)}`);
|
|
247
274
|
hasChanges = true;
|
|
275
|
+
centralCount++; // Now it's central
|
|
276
|
+
scatteredCount--;
|
|
248
277
|
}
|
|
249
|
-
} else if (uniqueFiles.length === 1) {
|
|
250
|
-
// If single file exists but is NOT in House_Rules_Contracts, ask to move/copy
|
|
251
|
-
const file = uniqueFiles[0];
|
|
252
|
-
const targetPath = path.join(targetDir, type);
|
|
253
|
-
|
|
254
|
-
if (file !== path.resolve(targetPath)) {
|
|
255
|
-
console.log();
|
|
256
|
-
log.info(`Found ${type} at: ${path.relative(projectRoot, file)}`);
|
|
257
|
-
const shouldCopy = await confirm(`Copy this to central House_Rules_Contracts/${type}?`, true);
|
|
258
|
-
if (shouldCopy) {
|
|
259
|
-
ensureDirectoryExists(targetDir);
|
|
260
|
-
fs.copyFileSync(file, targetPath);
|
|
261
|
-
log.success(`Copied to ${path.relative(projectRoot, targetPath)}`);
|
|
262
|
-
hasChanges = true;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
278
|
}
|
|
266
279
|
}
|
|
267
280
|
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (
|
|
272
|
-
if (hasChanges) log.success('
|
|
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.');
|
|
273
287
|
return true;
|
|
274
288
|
}
|
|
275
289
|
|
|
276
|
-
|
|
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
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return true; // All accounted for (either central or scattered)
|
|
277
303
|
// Or we return false and generateContracts will run.
|
|
278
304
|
return false;
|
|
279
305
|
|