Skip to content

The design language that makes your AI harness better at design.

JavaScript

Preserve detector extensions

Paul Bakaus57ce11288f55
diff --git a/skill/scripts/hook-admin.mjs b/skill/scripts/hook-admin.mjs
index ac3363d27..5a0c29abd 100644
--- a/skill/scripts/hook-admin.mjs
+++ b/skill/scripts/hook-admin.mjs
@@ -223,7 +223,11 @@ function writeHookConfig(cwd, hookConfig, opts = {}) {
// (consent, quiet, auditLog) survive an Impeccable hooks edit.
const next = { ...existing, hook: { ...existingHook, ...hookConfig } };
if (Object.keys(legacyDetector).length > 0) {
- next.detector = mergeDetectorConfig(detectorSection(existing), mergeDetectorConfig(legacyDetector));
+ const existingDetector = detectorSection(existing) || {};
+ next.detector = {
+ ...existingDetector,
+ ...mergeDetectorConfig(existingDetector, mergeDetectorConfig(legacyDetector)),
+ };
}
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, JSON.stringify(next, null, 2) + '\n');
diff --git a/tests/hook.test.mjs b/tests/hook.test.mjs
index 87c55183a..18012f5c7 100644
--- a/tests/hook.test.mjs
+++ b/tests/hook.test.mjs
@@ -1026,7 +1026,10 @@ describe('hook-admin.mjs', () => {
fs.mkdirSync(path.dirname(getConfigPath(cwd)), { recursive: true });
fs.writeFileSync(getConfigPath(cwd), JSON.stringify({
hook: { advisoryRules: 'include' },
- detector: { advisoryRules: 'exclude' },
+ detector: {
+ advisoryRules: 'exclude',
+ extensions: [{ ext: '.blade.php', engine: 'html' }],
+ },
}));
runAdmin(['on']);
@@ -1034,6 +1037,7 @@ describe('hook-admin.mjs', () => {
const config = JSON.parse(fs.readFileSync(getConfigPath(cwd), 'utf-8'));
assert.equal(config.hook.advisoryRules, undefined);
assert.equal(config.detector.advisoryRules, 'exclude');
+ assert.deepEqual(config.detector.extensions, [{ ext: '.blade.php', engine: 'html' }]);
});
it('ignore-file refuses unsupported reasons and unknown flags', () => {