feat(plugins): enable Impeccable hooks for Codex and trim extensions

- Register Impeccable's design-detector PostToolUse and Stop hooks in the
  Codex config through new no-op-safe wrappers; Claude already gets them
  from the Impeccable plugin.
- Make Caveman Claude-only: a '-' codex_method marks Claude-only entries,
  which the Codex selector omits and sync removes from owned Codex
  installs. Drop the thinkhome Caveman Windows hook repair.
- Remove Anthropic Frontend Design from the manifest, plugin workflow,
  and docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-16 10:57:56 +01:00
1 parent eb7cecaaa2
commit f7222a90c2
20 files changed
+109 -95

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ from personal_instructions import CLIENT_FILES, render
# Hook scripts this configuration installs; merges replace these and keep any foreign hooks.
OWNED_HOOK_PATTERN = r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm|completion-?evidence|correction-?prompt|command-?safety)\.(?:ps1|sh)'
OWNED_HOOK_PATTERN = r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm|completion-?evidence|correction-?prompt|command-?safety|impeccable-?hook)\.(?:ps1|sh)'
def is_flashbang(hook):
+6 -28
View File
@@ -424,30 +424,6 @@ class Manager:
self.state['resources'].append(dict(client='shared', name=entry['name'], kind='cli', package=package, clients=[client]))
self.save()
def repair_caveman_windows_hooks(self):
if self.dry_run or os.name != 'nt':
return
if not any(r['client'] == 'codex' and r['kind'] == 'plugin'
and r['selector'] == 'caveman@thinkhome-caveman' for r in self.state['resources']):
return
# ponytail: only the known 1.0.0 command; remove when upstream ships a portable launcher.
path = safe_path(self.home, '.codex/plugins/cache/thinkhome-caveman/caveman/1.0.0/hooks/hooks.json')
if not path.is_file():
return
content = json.loads(path.read_text(encoding='utf-8'))
changed = False
for groups in content.get('hooks', {}).values():
for group in groups:
for hook in group.get('hooks', []):
if hook.get('commandWindows') == 'node "%PLUGIN_ROOT%\\hooks\\caveman-hook.mjs"':
hook['commandWindows'] = ('node -e "import(require(\'node:url\').pathToFileURL('
'require(\'node:path\').join(process.env.PLUGIN_ROOT,'
'\'hooks\',\'caveman-hook.mjs\')).href)"')
changed = True
if changed:
atomic_write(path, (json.dumps(content, indent=2) + '\n').encode('utf-8'))
print('Repaired Caveman Windows hook commands; review the changed hooks in Codex /hooks.')
def ensure_mcporter(self, entry, clients):
server, url = entry['mcporter_name'], entry['mcporter_url']
if not re.fullmatch(r'[a-z0-9-]+', server) or not re.fullmatch(r'https://[^\s]+', url):
@@ -540,11 +516,14 @@ class Manager:
use_mcporter = 'MCPorter' in desired
mcporter_entries = {name: entry for name, entry in desired.items() if use_mcporter and entry.get('mcporter_name') and entry.get('mcporter_url') not in ('', '-')}
direct_entries = {name: entry for name, entry in desired.items() if name not in mcporter_entries}
# codex_method '-' marks a Claude-only extension; owned Codex installs of it are removed.
claude_only = {name for name, entry in direct_entries.items() if entry['codex_method'] == '-'}
for record in sorted(self.state['resources'], key=lambda record: record['kind'] != 'mcp'):
if record['client'] != 'shared' and record['client'] not in clients:
continue
selected_entries = mcporter_entries if record['kind'] == 'mcp' else direct_entries
if (action == 'sync' and record['name'] not in selected_entries) or (action == 'remove' and record['name'] in selected):
if ((action == 'sync' and record['name'] not in selected_entries) or (action == 'remove' and record['name'] in selected)
or (action != 'remove' and record['client'] == 'codex' and record['name'] in claude_only)):
if record['client'] == 'shared':
remaining = [client for client in record.get('clients', ['claude', 'codex']) if client not in clients]
if remaining:
@@ -555,9 +534,8 @@ class Manager:
if action != 'remove':
for client in clients:
for entry in direct_entries.values():
self.ensure(client, entry)
if client == 'codex' and entry.get('codex_plugin') == 'caveman@thinkhome-caveman':
self.repair_caveman_windows_hooks()
if client != 'codex' or entry['name'] not in claude_only:
self.ensure(client, entry)
for entry in mcporter_entries.values():
self.ensure_mcporter(entry, clients)
print('EXTENSIONS: reconciliation complete' + (' (dry run)' if self.dry_run else ''))
+3
View File
@@ -121,6 +121,8 @@ function Select-ConfiguredPlugins {
[switch]$DryRun
)
$entries = @(Get-ConfiguredPluginEntries -RepositoryRoot $RepositoryRoot)
# codex_method '-' marks a Claude-only extension.
if ($Client -eq 'Codex') { $entries = @($entries | Where-Object { $_.codex_method -ne '-' }) }
$toggleable = @($entries)
$fixed = @($entries | Where-Object { $toggleable -notcontains $_ })
if ($toggleable.Count -eq 0 -or ($DryRun -and $Mode -eq 'Install')) { return @{ Selected = $entries; Deselected = @() } }
@@ -136,6 +138,7 @@ function Select-ConfiguredPlugins {
Test-InstalledMCPServer -HomePath $HomePath -Name $entry.mcporter_name -Url $entry.mcporter_url
} else { $false }
foreach ($referenceClient in $referenceClients) {
if ($referenceClient -eq 'Codex' -and $entry.codex_method -eq '-') { continue }
$selector = if ($referenceClient -eq 'Claude') { $entry.claude_plugin } else { $entry.codex_plugin }
if ($referenceClient -eq 'Codex' -and $entry.codex_method -ne 'plugin') {
$found = $found -or (Test-Path -LiteralPath (Join-Path $HomePath ('.agents/skills/' + $entry.codex_skill))) -or (Test-Path -LiteralPath (Join-Path $HomePath ('.codex/skills/' + $entry.codex_skill)))
+3
View File
@@ -146,6 +146,8 @@ select_configured_plugins() {
local name all_names=() toggle_names=() fixed_names=()
while IFS= read -r name; do
# codex_method '-' marks a Claude-only extension.
if [ "$client" = codex ] && [ "$(plugin_field "$root" "$name" codex_method)" = - ]; then continue; fi
all_names+=("$name")
if plugin_toggleable "$root" "$name" "$client"; then toggle_names+=("$name"); else fixed_names+=("$name"); fi
done < <(get_plugin_names "$root")
@@ -178,6 +180,7 @@ select_configured_plugins() {
else status=$?; [ "$status" -eq 1 ] || return "$status"; fi
fi
for reference_client in "${reference_clients[@]}"; do
if [ "$reference_client" = codex ] && [ "$(plugin_field "$root" "$name" codex_method)" = - ]; then continue; fi
if [ "$reference_client" = claude ]; then selector=$(plugin_field "$root" "$name" claude_plugin); else selector=$(plugin_field "$root" "$name" codex_plugin); fi
if [ "$reference_client" = codex ] && [ "$(plugin_field "$root" "$name" codex_method)" != plugin ]; then
local skill_name
+33
View File
@@ -109,6 +109,39 @@ class InstallOptionsTests(unittest.TestCase):
self.assertNotIn('qmd-warm', result)
self.assertNotIn('hooks.SessionStart', result)
def test_codex_merge_registers_impeccable_hooks_once(self):
managed = (ROOT / 'adapters/codex/config/config.toml').read_text(encoding='utf-8')
managed = managed.replace('__IMPECCABLE_HOOK_SCRIPT__', 'invoke-impeccable-hook.sh')
merged = OPTIONS.merge_toml(OPTIONS.merge_toml('', managed), managed)
hooks = tomllib.loads(merged)['hooks']
impeccable = lambda groups: [group for group in groups if 'impeccable-hook' in group['hooks'][0]['command']]
self.assertEqual(1, len(impeccable(hooks['PostToolUse'])))
self.assertEqual('Edit|Write|apply_patch', impeccable(hooks['PostToolUse'])[0]['matcher'])
self.assertEqual(1, len(impeccable(hooks['Stop'])))
def test_impeccable_hook_wrappers_forward_event_or_are_noops(self):
scripts = ROOT / 'shared/hooks/scripts'
shells = [(shutil.which('bash'), [], 'invoke-impeccable-hook.sh', 'impeccable', 'printf "%s:" "$1"; cat\n')]
if os.name == 'nt':
shells.append((shutil.which('powershell'), ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File'],
'Invoke-ImpeccableHook.ps1', 'impeccable.cmd', '@echo off\r\n<nul set /p=%1:\r\nmore\r\n'))
for executable, arguments, name, launcher_name, launcher_body in shells:
if not executable:
continue
with self.subTest(shell=name), tempfile.TemporaryDirectory() as directory:
home = Path(directory)
env = dict(os.environ, HOME=str(home), USERPROFILE=str(home), CODEX_HOME=str(home / '.codex'))
run = lambda: subprocess.run([executable, *arguments, str(scripts / name)], input='{"event":1}',
env=env, capture_output=True, text=True, timeout=60)
result = run()
self.assertEqual((0, ''), (result.returncode, result.stdout), result.stderr)
launcher = home / '.agents/skills/impeccable/scripts' / launcher_name
launcher.parent.mkdir(parents=True)
launcher.write_text(launcher_body, newline='')
result = run()
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('hook:{"event":1}', result.stdout.strip())
def test_instruction_line_only_with_semantic_search(self):
text = 'Line one.\nWhen `semantic-search` is installed, run it first.\nLine three.\n'
self.assertEqual(OPTIONS.filter_instructions(text, False), 'Line one.\nLine three.\n')
+8 -49
View File
@@ -224,55 +224,14 @@ class ManagedExtensionTests(unittest.TestCase):
self.manager().sync([plugin()], ['claude'], {'Example'})
self.assertEqual(3, command.call_count)
@unittest.skipUnless(os.name == 'nt', 'Windows hook compatibility')
def test_owned_caveman_hook_repair_runs_in_powershell_and_is_idempotent(self):
entry = dict(plugin('Caveman'), codex_plugin='caveman@thinkhome-caveman')
root = self.home / '.codex/plugins/cache/thinkhome-caveman/caveman/1.0.0'
path = root / 'hooks/hooks.json'
path.parent.mkdir(parents=True)
hook = {'type': 'command', 'command': 'unchanged',
'commandWindows': 'node "%PLUGIN_ROOT%\\hooks\\caveman-hook.mjs"'}
path.write_text(json.dumps({'hooks': {event: [{'hooks': [dict(hook)]}]
for event in ['SessionStart', 'UserPromptSubmit', 'SubagentStart']}}))
upstream = path.read_bytes()
self.manager().sync([entry], ['codex'], {'Caveman'})
repaired = path.read_bytes()
for groups in json.loads(repaired)['hooks'].values():
self.assertNotIn('%PLUGIN_ROOT%', groups[0]['hooks'][0]['commandWindows'])
self.assertEqual('unchanged', groups[0]['hooks'][0]['command'])
self.manager().sync([entry], ['codex'], {'Caveman'})
self.assertEqual(repaired, path.read_bytes())
path.write_bytes(upstream)
self.manager(update=True).sync([entry], ['codex'], {'Caveman'})
self.assertEqual(repaired, path.read_bytes())
if not shutil.which('node'):
self.skipTest('Node is unavailable for launcher execution')
(root / 'hooks/caveman-hook.mjs').write_text("process.stdout.write('hook-ok');")
command = json.loads(repaired)['hooks']['SessionStart'][0]['hooks'][0]['commandWindows']
result = subprocess.run(['powershell', '-NoProfile', '-Command', command],
env=dict(os.environ, PLUGIN_ROOT=str(root)), capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('hook-ok', result.stdout)
@unittest.skipUnless(os.name == 'nt', 'Windows hook compatibility')
def test_caveman_repair_preserves_foreign_and_custom_hooks_and_dry_runs(self):
entry = dict(plugin('Caveman'), codex_plugin='caveman@thinkhome-caveman')
path = self.home / '.codex/plugins/cache/thinkhome-caveman/caveman/1.0.0/hooks/hooks.json'
path.parent.mkdir(parents=True)
original = json.dumps({'hooks': {'SessionStart': [{'hooks': [{'commandWindows':
'node "%PLUGIN_ROOT%\\hooks\\caveman-hook.mjs"'}]}]}}).encode()
path.write_bytes(original)
self.installed['codex'][entry['codex_plugin']] = {}
self.manager().sync([entry], ['codex'], {'Caveman'})
self.assertEqual([], self.manager().state['resources'])
self.assertEqual(original, path.read_bytes())
self.installed['codex'].clear()
self.manager(dry_run=True).sync([entry], ['codex'], {'Caveman'})
self.assertEqual(original, path.read_bytes())
original = b'{"hooks":{"SessionStart":[{"hooks":[{"commandWindows":"custom"}]}]}}'
path.write_bytes(original)
self.manager().sync([entry], ['codex'], {'Caveman'})
self.assertEqual(original, path.read_bytes())
def test_claude_only_entry_removes_owned_codex_install_and_keeps_claude(self):
self.manager().sync([plugin('Caveman')], ['claude', 'codex'], {'Caveman'})
installed = len(self.commands)
claude_only = dict(plugin('Caveman'), codex_method='-', codex_plugin='-')
for action in ('install', 'sync'):
self.manager().sync([claude_only], ['claude', 'codex'], {'Caveman'}, action)
self.assertEqual([['codex', 'plugin', 'remove', 'caveman@test']], [c for c in self.commands[installed:] if c[0] == 'codex'])
self.assertEqual(['claude'], [r['client'] for r in self.manager().state['resources']])
def test_dry_run_summary_has_one_line(self):
with contextlib.redirect_stdout(io.StringIO()) as output:
+3 -2
View File
@@ -37,7 +37,7 @@ catch { $failed = $true }
$env:AI_CONFIG_VERBOSE = $null
if (-not $failed -or $diagnostics -notcontains 'download progress' -or $diagnostics -notcontains 'WARN test warning') { throw 'Plugin failure must retain full diagnostics and fail.' }
$global:LASTEXITCODE = 0
$script:codexInventory = '{"installed":[{"pluginId":"ponytail@ponytail"},{"pluginId":"i-have-adhd@i-have-adhd"},{"pluginId":"superpowers@openai-curated-remote"},{"pluginId":"context7@context7-marketplace"},{"pluginId":"caveman@thinkhome-caveman"}],"available":[]}'
$script:codexInventory = '{"installed":[{"pluginId":"ponytail@ponytail"},{"pluginId":"i-have-adhd@i-have-adhd"},{"pluginId":"superpowers@openai-curated-remote"},{"pluginId":"context7@context7-marketplace"}],"available":[]}'
function codex { $script:observedCodexHome = $env:CODEX_HOME; $script:observedProfile = $env:USERPROFILE; $script:codexInventory }
$testHome = Join-Path ([System.IO.Path]::GetTempPath()) 'ai-config-plugin-test-home'
$previousCodexHome = [Environment]::GetEnvironmentVariable('CODEX_HOME', 'Process')
@@ -47,7 +47,8 @@ if ($observedCodexHome -ne (Join-Path $testHome '.codex') -or $observedProfile -
if ([Environment]::GetEnvironmentVariable('CODEX_HOME', 'Process') -ne $previousCodexHome -or [Environment]::GetEnvironmentVariable('USERPROFILE', 'Process') -ne $previousProfile) { throw 'Plugin inspection must restore the process environment.' }
$script:answers.Enqueue('done')
$selection = Select-ConfiguredPlugins -RepositoryRoot (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Client Codex -Mode Update
if (@($selection.Selected | Where-Object { $_.codex_method -eq 'plugin' }).Count -ne 5) { throw 'All installed Codex plugins must start checked when updating.' }
if (@($selection.Selected | Where-Object { $_.codex_method -eq 'plugin' }).Count -ne 4) { throw 'All installed Codex plugins must start checked when updating.' }
if (@($selection.Selected + $selection.Deselected | Where-Object { $_.name -eq 'Caveman' }).Count) { throw 'Claude-only extensions must not be offered for Codex.' }
$script:answers.Enqueue('4')
$script:answers.Enqueue('done')
$selection = Select-ConfiguredPlugins -RepositoryRoot (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Client Codex -Mode Update
+1
View File
@@ -48,6 +48,7 @@ select_configured_plugins "$root" codex Update true selected deselected
printf '%s\n' '{"mcpServers":{"context7":{"baseUrl":"https://example.invalid/mcp"}}}' > "$test_home/.mcporter/mcporter.json"
select_configured_plugins "$root" codex Update true selected deselected
[[ " ${deselected[*]} " == *' Context7 '* ]] || { printf 'A different MCPorter server must not select Context7.\n' >&2; exit 1; }
[[ " ${selected[*]} ${deselected[*]} " != *' Caveman '* ]] || { printf 'Claude-only extensions must not be offered for Codex.\n' >&2; exit 1; }
npm_prefix=$(mktemp -d "$root/.npm-test.XXXXXX")
cli_name="ai-config-test-cli-${npm_prefix##*.}"
npm() { printf '%s\n' "$npm_prefix"; }
+3 -3
View File
@@ -35,15 +35,15 @@ class SelectionTests(unittest.TestCase):
self.assertFalse(self.path.exists())
def test_selection_round_trip_and_last_successful_write(self):
self.save('--selected', 'Superpowers', 'Anthropic Frontend Design', '--deselected', 'Context7')
self.save('--selected', 'Superpowers', 'Humanizer', '--deselected', 'Context7')
original = self.path.read_bytes()
state = json.loads(self.run_state('read').stdout)
self.assertEqual(state['shell'], 'powershell')
self.assertEqual(state['client'], 'both')
self.assertEqual(state['selected'], ['Superpowers', 'Anthropic Frontend Design'])
self.assertEqual(state['selected'], ['Superpowers', 'Humanizer'])
self.assertEqual(state['deselected'], ['Context7'])
self.assertEqual(self.path.read_bytes(), original)
self.assertIn('selected\tAnthropic Frontend Design', self.run_state('read', '--format', 'tsv').stdout)
self.assertIn('selected\tHumanizer', self.run_state('read', '--format', 'tsv').stdout)
self.save('--selected', 'Context7')
self.assertEqual(json.loads(self.run_state('read').stdout)['selected'], ['Context7'])
+1 -1
View File
@@ -61,7 +61,7 @@ foreach ($shell in @('powershell','bash')) {
if ($shell -eq 'powershell' -and $content -match 'WindowStyle\s+Hidden') { throw "PowerShell hook hides the terminal in $package" }
if ($client -eq 'codex') {
$events = @([regex]::Matches($content, '(?m)^\[\[hooks\.([^.\]]+)\]\]\s*$') | ForEach-Object { $_.Groups[1].Value })
if ((($events | Sort-Object) -join ',') -ne 'PreToolUse,SessionStart,Stop,Stop,UserPromptSubmit' -or $content -match 'flashbang-if-input' -or $content -match '(?m)^async\s*=\s*true\s*$') { throw "Codex finish hook is incorrect in $package" }
if ((($events | Sort-Object) -join ',') -ne 'PostToolUse,PreToolUse,SessionStart,Stop,Stop,Stop,UserPromptSubmit' -or $content -match 'flashbang-if-input' -or $content -match '(?m)^async\s*=\s*true\s*$') { throw "Codex finish hook is incorrect in $package" }
if ($content -notmatch 'approvals_reviewer\s*=\s*"auto_review"') { throw "Codex auto review is missing in $package" }
if ($content -notmatch '(?m)^sandbox_mode\s*=\s*"danger-full-access"\s*$') { throw "Codex full access is missing in $package" }
if ($content -notmatch '(?m)^max_depth\s*=\s*1\s*$') { throw "Codex agent depth limit is missing in $package" }
+1 -1
View File
@@ -80,7 +80,7 @@ for shell in powershell bash; do
grep -q 'bash .*flashbang.sh' "$package/$file"
fi
if [ "$client" = codex ]; then
[ "$(sed -n 's/^\[\[hooks\.\([^].]*\)\]\][[:space:]]*$/\1/p' "$package/$file" | sort)" = $'PreToolUse\nSessionStart\nStop\nStop\nUserPromptSubmit' ]
[ "$(sed -n 's/^\[\[hooks\.\([^].]*\)\]\][[:space:]]*$/\1/p' "$package/$file" | sort)" = $'PostToolUse\nPreToolUse\nSessionStart\nStop\nStop\nStop\nUserPromptSubmit' ]
! grep -q 'flashbang-if-input' "$package/$file"
! grep -Eq '^async[[:space:]]*=[[:space:]]*true[[:space:]]*$' "$package/$file"
grep -q 'approvals_reviewer[[:space:]]*=[[:space:]]*"auto_review"' "$package/$file"