refacil-sdd-ai 5.0.9 → 5.0.10
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/lib/hooks.js +6 -1
- package/lib/installer.js +36 -0
- package/package.json +1 -1
package/lib/hooks.js
CHANGED
|
@@ -361,7 +361,12 @@ function removeProjectLevelHooks(projectRoot) {
|
|
|
361
361
|
try {
|
|
362
362
|
const config = JSON.parse(fs.readFileSync(cursorPath, 'utf8'));
|
|
363
363
|
const hooksObj = config.hooks;
|
|
364
|
-
if (!hooksObj)
|
|
364
|
+
if (!hooksObj) {
|
|
365
|
+
// No hooks key — delete if only a meaningless stub (version-only or empty)
|
|
366
|
+
const meaningfulKeys = Object.keys(config).filter(k => k !== 'version');
|
|
367
|
+
if (meaningfulKeys.length === 0) fs.unlinkSync(cursorPath);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
365
370
|
let changed = false;
|
|
366
371
|
for (const evt of evts) {
|
|
367
372
|
if (!Array.isArray(hooksObj[evt])) continue;
|
package/lib/installer.js
CHANGED
|
@@ -328,6 +328,42 @@ function removeProjectLevelArtifacts(projectRoot) {
|
|
|
328
328
|
try { fs.unlinkSync(versionFile); removed++; } catch (_) {}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
+
|
|
332
|
+
// Clean .opencode/opencode.json — strip SDD-managed $schema key; delete file if no user keys remain
|
|
333
|
+
const ocJsonPath = path.join(projectRoot, '.opencode', 'opencode.json');
|
|
334
|
+
if (fs.existsSync(ocJsonPath)) {
|
|
335
|
+
try {
|
|
336
|
+
const json = JSON.parse(fs.readFileSync(ocJsonPath, 'utf8'));
|
|
337
|
+
delete json['$schema'];
|
|
338
|
+
if (Object.keys(json).length === 0) {
|
|
339
|
+
fs.unlinkSync(ocJsonPath);
|
|
340
|
+
removed++;
|
|
341
|
+
} else {
|
|
342
|
+
fs.writeFileSync(ocJsonPath, JSON.stringify(json, null, 2) + '\n');
|
|
343
|
+
}
|
|
344
|
+
} catch (_) {}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Remove .opencode/plugins/refacil-hooks.js if present
|
|
348
|
+
const ocPlugin = path.join(projectRoot, '.opencode', 'plugins', 'refacil-hooks.js');
|
|
349
|
+
if (fs.existsSync(ocPlugin)) {
|
|
350
|
+
try { fs.unlinkSync(ocPlugin); removed++; } catch (_) {}
|
|
351
|
+
}
|
|
352
|
+
// Remove .opencode/plugins/ if now empty
|
|
353
|
+
const ocPluginsDir = path.join(projectRoot, '.opencode', 'plugins');
|
|
354
|
+
try {
|
|
355
|
+
if (fs.existsSync(ocPluginsDir) && fs.readdirSync(ocPluginsDir).length === 0) {
|
|
356
|
+
fs.rmdirSync(ocPluginsDir);
|
|
357
|
+
}
|
|
358
|
+
} catch (_) {}
|
|
359
|
+
// Remove .opencode/ itself if now empty
|
|
360
|
+
const ocDir = path.join(projectRoot, '.opencode');
|
|
361
|
+
try {
|
|
362
|
+
if (fs.existsSync(ocDir) && fs.readdirSync(ocDir).length === 0) {
|
|
363
|
+
fs.rmdirSync(ocDir);
|
|
364
|
+
}
|
|
365
|
+
} catch (_) {}
|
|
366
|
+
|
|
331
367
|
return removed;
|
|
332
368
|
}
|
|
333
369
|
|
package/package.json
CHANGED