Compare commits

..
Author SHA1 Message Date
Paul Bakaus 611147a333 Sync marketplace Claude hook repair
Keep the committed marketplace repair script aligned with Claude Code's supported Edit and Write tools, and strengthen regression coverage after automated review.\n\nThis change was prepared with AI assistance under maintainer authorization.
2026-08-19 10:04:14 -07:00
Paul Bakaus 7d5c60d291 Remove stale Claude MultiEdit matcher
Claude Code now folds multi-edit behavior into Edit, so keep generated and repaired hook manifests aligned with the current Edit and Write tools. Grok keeps its compatibility matcher unchanged.

AI assistance was used to implement and validate this change.
2026-08-19 09:28:28 -07:00
13 changed files with 104 additions and 83 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
{
"description": "Impeccable design detector: immediate-tier checks after Edit/Write/MultiEdit on UI files, full-rule deep pass on Stop.",
"description": "Impeccable design detector: immediate-tier checks after Edit/Write on UI files, full-rule deep pass on Stop.",
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
+1 -1
View File
@@ -2,7 +2,7 @@
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
+1 -1
View File
@@ -44,7 +44,7 @@ The first argument is the action. Defaults to `status`.
```
3. If `<action>` is `off`, follow up with a one-line note: "Done. New edits will not trigger the design hook in this project until you run `/impeccable hooks on`."
4. If `<action>` is `on`, follow up with: "Done. The design hook will fire after the next Edit/Write/MultiEdit on a UI file."
4. If `<action>` is `on`, follow up with: "Done. The design hook will fire after the next Edit/Write on a UI file."
5. If `<action>` is `ignore-value`, `ignore-file`, or `ignore-rule`, just print the script output. The default scope is shared `.impeccable/config.json`; add `--local` only when the user explicitly asks for a private exception.
6. If `<action>` is `status`, just print the script output. Do not add commentary unless the user asked a follow-up question.
@@ -75,11 +75,11 @@ const HOOK_MANIFEST_TARGETS = [
destRel: '.claude/settings.local.json',
sharedDestRel: '.claude/settings.json',
manifest: () => ({
description: 'Impeccable design detector: immediate-tier checks after Edit/Write/MultiEdit on UI files, full-rule deep pass on Stop.',
description: 'Impeccable design detector: immediate-tier checks after Edit/Write on UI files, full-rule deep pass on Stop.',
hooks: {
PostToolUse: [
{
matcher: 'Edit|Write|MultiEdit',
matcher: 'Edit|Write',
hooks: [
{
type: 'command',
+3 -3
View File
@@ -137,9 +137,9 @@ const GROK_PROJECT_HOOK = '.grok/skills/impeccable/scripts/hook.mjs';
export function buildClaudeSettingsManifest() {
return {
description: 'Impeccable design detector: immediate-tier checks after Edit/Write/MultiEdit on UI files, full-rule deep pass on Stop.',
description: 'Impeccable design detector: immediate-tier checks after Edit/Write on UI files, full-rule deep pass on Stop.',
hooks: buildClaudeCompatibleHooks(
'Edit|Write|MultiEdit',
'Edit|Write',
CLAUDE_PROJECT_HOOK,
SYSTEM_MESSAGE_NOTICE,
),
@@ -155,7 +155,7 @@ export function buildClaudeSettingsManifest() {
export function buildClaudePluginHooksManifest() {
return {
hooks: buildClaudeCompatibleHooks(
'Edit|Write|MultiEdit',
'Edit|Write',
CLAUDE_PLUGIN_HOOK,
SYSTEM_MESSAGE_NOTICE,
),
+1 -1
View File
@@ -44,7 +44,7 @@ The first argument is the action. Defaults to `status`.
```
3. If `<action>` is `off`, follow up with a one-line note: "Done. New edits will not trigger the design hook in this project until you run `{{command_prefix}}impeccable hooks on`."
4. If `<action>` is `on`, follow up with: "Done. The design hook will fire after the next Edit/Write/MultiEdit on a UI file."
4. If `<action>` is `on`, follow up with: "Done. The design hook will fire after the next Edit/Write on a UI file."
5. If `<action>` is `ignore-value`, `ignore-file`, or `ignore-rule`, just print the script output. The default scope is shared `.impeccable/config.json`; add `--local` only when the user explicitly asks for a private exception.
6. If `<action>` is `status`, just print the script output. Do not add commentary unless the user asked a follow-up question.
+2 -2
View File
@@ -75,11 +75,11 @@ const HOOK_MANIFEST_TARGETS = [
destRel: '.claude/settings.local.json',
sharedDestRel: '.claude/settings.json',
manifest: () => ({
description: 'Impeccable design detector: immediate-tier checks after Edit/Write/MultiEdit on UI files, full-rule deep pass on Stop.',
description: 'Impeccable design detector: immediate-tier checks after Edit/Write on UI files, full-rule deep pass on Stop.',
hooks: {
PostToolUse: [
{
matcher: 'Edit|Write|MultiEdit',
matcher: 'Edit|Write',
hooks: [
{
type: 'command',
-37
View File
@@ -1,37 +0,0 @@
/**
* Convert a live-config glob pattern to a RegExp.
*
* Supports `**` across path segments, `*` within one segment, and `?` for one
* character. Callers normalize project-relative paths to forward slashes.
*/
export function livePathGlobToRegex(pattern) {
let re = '';
let i = 0;
while (i < pattern.length) {
const c = pattern[i];
if (c === '*') {
if (pattern[i + 1] === '*') {
if (pattern[i + 2] === '/') {
re += '(?:.*/)?';
i += 3;
} else {
re += '.*';
i += 2;
}
} else {
re += '[^/]*';
i += 1;
}
} else if (c === '?') {
re += '[^/]';
i += 1;
} else if (/[.+^${}()|[\]\\]/.test(c)) {
re += `\\${c}`;
i += 1;
} else {
re += c;
i += 1;
}
}
return new RegExp(`^${re}$`);
}
+42 -2
View File
@@ -27,7 +27,6 @@ import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { resolveLiveConfigPath } from './lib/impeccable-paths.mjs';
import { livePathGlobToRegex } from './lib/live-path-globs.mjs';
import {
describeInjectArtifacts,
frameworkIgnorePatterns,
@@ -365,7 +364,7 @@ export function resolveFiles(rootDir, config) {
const patterns = config.files;
const userExcludes = Array.isArray(config.exclude) ? config.exclude : [];
const allExcludes = [...HARD_EXCLUDES, ...userExcludes];
const excludeRegexes = allExcludes.map(livePathGlobToRegex);
const excludeRegexes = allExcludes.map(globToRegex);
const isExcluded = (relPath) => excludeRegexes.some((re) => re.test(relPath));
const isGlob = (s) => /[*?[]/.test(s);
@@ -402,6 +401,47 @@ export function resolveFiles(rootDir, config) {
return out;
}
/**
* Convert a glob pattern to a RegExp. Supports:
* ** → any number of path segments (including zero)
* * → any chars except `/`
* ? → any single char except `/`
* Paths are normalized to forward slashes before matching.
*/
function globToRegex(pattern) {
let re = '';
let i = 0;
while (i < pattern.length) {
const c = pattern[i];
if (c === '*') {
if (pattern[i + 1] === '*') {
// ** — any number of segments, including zero. Handle the common
// **/ and /** forms so `a/**/b` matches `a/b` as well as `a/x/y/b`.
if (pattern[i + 2] === '/') {
re += '(?:.*/)?';
i += 3;
} else {
re += '.*';
i += 2;
}
} else {
re += '[^/]*';
i += 1;
}
} else if (c === '?') {
re += '[^/]';
i += 1;
} else if (/[.+^${}()|[\]\\]/.test(c)) {
re += '\\' + c;
i += 1;
} else {
re += c;
i += 1;
}
}
return new RegExp('^' + re + '$');
}
// ---------------------------------------------------------------------------
// Core operations
// ---------------------------------------------------------------------------
+33 -2
View File
@@ -24,7 +24,6 @@ import { fileURLToPath } from 'node:url';
import { resolveTargetSelection } from './context.mjs';
import { resolveFiles } from './live-inject.mjs';
import { readLiveServerInfo } from './lib/impeccable-paths.mjs';
import { livePathGlobToRegex } from './lib/live-path-globs.mjs';
import { resolveSurfaceBrief } from './lib/surface-briefs.mjs';
import { resolveLiveTarget } from './live-target.mjs';
import { bootInstructions } from './live/instructions.mjs';
@@ -241,7 +240,7 @@ function scanForDrift(rootDir, resolvedFiles, config) {
// Files matching the user's `exclude` globs are intentional omissions,
// not drift. Compile them to regexes so the orphan list stays signal.
const userExcludeRegexes = (Array.isArray(config.exclude) ? config.exclude : [])
.map(livePathGlobToRegex);
.map((p) => globToRegex(p));
const isUserExcluded = (rel) => userExcludeRegexes.some((re) => re.test(rel));
const orphans = [];
@@ -279,6 +278,38 @@ function scanForDrift(rootDir, resolvedFiles, config) {
};
}
/**
* Same glob-to-regex mapping used by live-inject.mjs. Kept inline here
* to avoid a circular import (live-inject.mjs already imports nothing
* from live.mjs). The two must stay in sync.
*/
function globToRegex(pattern) {
let re = '';
let i = 0;
while (i < pattern.length) {
const c = pattern[i];
if (c === '*') {
if (pattern[i + 1] === '*') {
if (pattern[i + 2] === '/') { re += '(?:.*/)?'; i += 3; }
else { re += '.*'; i += 2; }
} else {
re += '[^/]*';
i += 1;
}
} else if (c === '?') {
re += '[^/]';
i += 1;
} else if (/[.+^${}()|[\]\\]/.test(c)) {
re += '\\' + c;
i += 1;
} else {
re += c;
i += 1;
}
}
return new RegExp('^' + re + '$');
}
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
+12 -2
View File
@@ -72,7 +72,8 @@ describe('hook manifest builders', () => {
const group = manifest.hooks.PostToolUse[0];
const handler = group.hooks[0];
assert.equal(group.matcher, 'Edit|Write|MultiEdit');
assert.equal(group.matcher, 'Edit|Write');
assert.doesNotMatch(manifest.description, /MultiEdit/);
assert.equal(handler.type, 'command');
assert.equal(handler.timeout, 5);
assert.equal(handler.statusMessage, 'Checking UI changes');
@@ -356,7 +357,7 @@ describe('generated hook artifacts in repo', () => {
assert.equal(manifest.description, undefined);
const handler = manifest.hooks.PostToolUse[0].hooks[0];
assert.equal(manifest.hooks.PostToolUse[0].matcher, 'Edit|Write|MultiEdit');
assert.equal(manifest.hooks.PostToolUse[0].matcher, 'Edit|Write');
expectCommand(handler.command, 'skills/impeccable/scripts/hook.mjs');
// Resolves relative to the installed plugin, not a `.claude/skills/` layout.
assert.ok(handler.command.includes('${CLAUDE_PLUGIN_ROOT}'),
@@ -375,6 +376,15 @@ describe('generated hook artifacts in repo', () => {
assert.ok(fs.existsSync(path.join(REPO_ROOT, 'plugin/skills/impeccable/scripts/hook-lib.mjs')));
});
it('keeps the marketplace hook repair matcher aligned with Claude Code', () => {
const hookAdmin = fs.readFileSync(
path.join(REPO_ROOT, 'plugin/skills/impeccable/scripts/hook-admin.mjs'),
'utf8',
);
assert.match(hookAdmin, /matcher: 'Edit\|Write'/);
assert.doesNotMatch(hookAdmin, /matcher: 'Edit\|Write\|MultiEdit'/);
});
it('generated hook runtime can import the bundled detector', async () => {
for (const scriptDir of [
'.claude/skills/impeccable/scripts',
+5
View File
@@ -947,6 +947,11 @@ describe('hook-admin.mjs', () => {
// impeccable entry must have been stripped, not accumulated.
assert.equal(claude.split('skills/impeccable/scripts/hook.mjs').length - 1, 2);
assert.match(claude, /"Stop"/);
const claudeManifest = JSON.parse(claude);
const impeccableGroup = claudeManifest.hooks.PostToolUse.find((group) =>
group.hooks?.some((hook) => hook.command?.includes('skills/impeccable/scripts/hook.mjs')));
assert.ok(impeccableGroup, 'repaired Claude settings should contain the Impeccable PostToolUse group');
assert.equal(impeccableGroup.matcher, 'Edit|Write');
const codex = fs.readFileSync(path.join(cwd, '.codex', 'hooks.json'), 'utf-8');
assert.match(codex, /\.agents\/skills\/impeccable\/scripts\/hook\.mjs/);
-28
View File
@@ -10,38 +10,10 @@ import { dirname, join, relative, resolve } from 'node:path';
import { tmpdir } from 'node:os';
import { fileURLToPath } from 'node:url';
import { execFileSync } from 'node:child_process';
import { livePathGlobToRegex } from '../skill/scripts/lib/live-path-globs.mjs';
const __dirname = dirname(fileURLToPath(import.meta.url));
const INJECT = resolve(__dirname, '..', 'skill/scripts/live-inject.mjs');
describe('live path globs', () => {
it('matches recursive segments, including zero segments', () => {
const anywhere = livePathGlobToRegex('**/index.html');
assert.equal(anywhere.test('index.html'), true);
assert.equal(anywhere.test('public/index.html'), true);
assert.equal(anywhere.test('apps/web/public/index.html'), true);
const underPublic = livePathGlobToRegex('public/**/*.html');
assert.equal(underPublic.test('public/index.html'), true);
assert.equal(underPublic.test('public/docs/index.html'), true);
assert.equal(underPublic.test('src/index.html'), false);
});
it('keeps single-star and question-mark matches inside one segment', () => {
const pattern = livePathGlobToRegex('pages/*/item?.html');
assert.equal(pattern.test('pages/docs/item1.html'), true);
assert.equal(pattern.test('pages/docs/deep/item1.html'), false);
assert.equal(pattern.test('pages/docs/item12.html'), false);
});
it('treats regular-expression punctuation as literal path text', () => {
const pattern = livePathGlobToRegex('pages/[draft]/item+.html');
assert.equal(pattern.test('pages/[draft]/item+.html'), true);
assert.equal(pattern.test('pages/d/itemm.html'), false);
});
});
function runInject(cwd, configPath, args) {
try {
const out = execFileSync('node', [INJECT, ...args], {