Updates
CI / PowerShell tests on Ubuntu (push) Failing after 3s
CI / CI configuration security checks (push) Successful in 2s
CI / Capabilities and shell quality (push) Successful in 12s
CI / Python tests and compilation (push) Successful in 22s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 11s
CI / Installed client configuration smoke tests (push) Successful in 59s
CI / Bash integration and installation guards (push) Successful in 1m31s

This commit is contained in:
fraujulian committed 2026-11-05 08:31:07 +01:00
1 parent 2192b4613d
commit e19aa2e27c
26 files changed
+278 -31

No files matched your search

+3 -1
View File
@@ -210,7 +210,9 @@ foreach ($shell in @('powershell','bash')) {
$compactScript = if ($shell -eq 'powershell') { 'Record-Compact.ps1' } else { 'record-compact.sh' }
$pointerScript = if ($shell -eq 'powershell') { 'Show-SessionStatePointer.ps1' } else { 'show-session-state-pointer.sh' }
$qmdWarmScript = if ($shell -eq 'powershell') { 'Start-QmdWarm.ps1' } else { 'qmd-warm.sh' }
$content = $content.Replace('__HOOK_COMMAND__', $command).Replace('__POWERSHELL_HOOK_COMMAND__', $command).Replace('__HOOK_SCRIPT__', $script).Replace('__POWERSHELL_HOOK_SCRIPT__', $script).Replace('__COMPACT_SCRIPT__', $compactScript).Replace('__SESSION_POINTER_SCRIPT__', $pointerScript).Replace('__QMD_WARM_SCRIPT__', $qmdWarmScript).Replace('__STATUSLINE_COMMAND__', $command).Replace('__STATUSLINE_SCRIPT__', $statusLineScript).Replace('__CLAUDE_SANDBOX__', $claudeSandbox).Replace('__CLAUDE_DENY_RULES__', $denyRulesJson).Replace('__CLAUDE_ALLOW_RULES__', $allowRulesJson)
$correctionPromptScript = if ($shell -eq 'powershell') { 'Show-CorrectionPrompt.ps1' } else { 'show-correction-prompt.sh' }
$completionEvidenceScript = if ($shell -eq 'powershell') { 'Check-CompletionEvidence.ps1' } else { 'check-completion-evidence.sh' }
$content = $content.Replace('__HOOK_COMMAND__', $command).Replace('__POWERSHELL_HOOK_COMMAND__', $command).Replace('__HOOK_SCRIPT__', $script).Replace('__POWERSHELL_HOOK_SCRIPT__', $script).Replace('__COMPACT_SCRIPT__', $compactScript).Replace('__SESSION_POINTER_SCRIPT__', $pointerScript).Replace('__QMD_WARM_SCRIPT__', $qmdWarmScript).Replace('__CORRECTION_PROMPT_SCRIPT__', $correctionPromptScript).Replace('__COMPLETION_EVIDENCE_SCRIPT__', $completionEvidenceScript).Replace('__STATUSLINE_COMMAND__', $command).Replace('__STATUSLINE_SCRIPT__', $statusLineScript).Replace('__CLAUDE_SANDBOX__', $claudeSandbox).Replace('__CLAUDE_DENY_RULES__', $denyRulesJson).Replace('__CLAUDE_ALLOW_RULES__', $allowRulesJson)
Set-Content -LiteralPath $path -Value $content -Encoding UTF8
}
+6
View File
@@ -196,6 +196,8 @@ for client in codex claude; do
compact_script=record-compact.sh
pointer_script=show-session-state-pointer.sh
qmd_warm_script=qmd-warm.sh
correction_prompt_script=show-correction-prompt.sh
completion_evidence_script=check-completion-evidence.sh
if [ "$shell" = powershell ]; then
command='__POWERSHELL_COMMAND__'
script=flashbang.ps1
@@ -203,6 +205,8 @@ for client in codex claude; do
compact_script=Record-Compact.ps1
pointer_script=Show-SessionStatePointer.ps1
qmd_warm_script=Start-QmdWarm.ps1
correction_prompt_script=Show-CorrectionPrompt.ps1
completion_evidence_script=Check-CompletionEvidence.ps1
fi
path="$output/$client-$shell/$file"
content=$(<"$path")
@@ -220,6 +224,8 @@ for client in codex claude; do
content=${content//__COMPACT_SCRIPT__/$compact_script}
content=${content//__SESSION_POINTER_SCRIPT__/$pointer_script}
content=${content//__QMD_WARM_SCRIPT__/$qmd_warm_script}
content=${content//__CORRECTION_PROMPT_SCRIPT__/$correction_prompt_script}
content=${content//__COMPLETION_EVIDENCE_SCRIPT__/$completion_evidence_script}
content=${content//__STATUSLINE_COMMAND__/$command}
content=${content//__STATUSLINE_SCRIPT__/$statusline_script}
content=${content//__CLAUDE_SANDBOX__/$sandbox}
+3 -3
View File
@@ -108,7 +108,7 @@ def merge_json(current, managed):
for key, value in managed.items():
if key == 'hooks' and isinstance(value, dict) and isinstance(result.get(key), dict):
hooks = dict(result[key])
for event in set(value) | {'Stop', 'SessionStart'}:
for event in set(value) | {'Stop', 'SessionStart', 'UserPromptSubmit'}:
groups = value.get(event, [])
old_groups = hooks.get(event, [])
if isinstance(groups, list) and isinstance(old_groups, list):
@@ -118,7 +118,7 @@ def merge_json(current, managed):
retained.append(group)
continue
foreign = [hook for hook in group['hooks'] if not (isinstance(hook, dict) and re.search(
r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm)\.(?:ps1|sh)',
r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm|completion-?evidence|correction-?prompt)\.(?:ps1|sh)',
str(hook.get('command', '')) + str(hook.get('command_windows', '')), re.I))]
if foreign:
retained.append(dict(group, hooks=foreign))
@@ -167,7 +167,7 @@ def merge_toml(current_text, managed_text, statusline_enabled=True):
managed_headers = {header for header, _ in managed_sections}
extras = []
fields_by_header = {}
owned_pattern = r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm)\.(?:ps1|sh)'
owned_pattern = r'(?:flashbang|statusline|record-compact|session-state-pointer|qmd-warm|Start-QmdWarm|completion-?evidence|correction-?prompt)\.(?:ps1|sh)'
for index, (header, block) in enumerate(current_sections):
plugin_table = re.match(r'^\[(?:plugins|marketplaces)(?:\.|\])', header)
array_table = header.startswith('[[')
+113
View File
@@ -0,0 +1,113 @@
import json
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[2]
SCRIPTS = ROOT / 'shared/hooks/scripts'
GUARDS = SCRIPTS / 'agent-guards.py'
def guard(mode, event, cwd=None):
payload = event if isinstance(event, str) else json.dumps(event)
result = subprocess.run([sys.executable, str(GUARDS), mode], cwd=cwd, input=payload, capture_output=True,
encoding='utf-8', timeout=20)
assert result.returncode == 0, result.stderr
return result.stdout
def git(workspace, *args):
subprocess.run(['git', '-C', str(workspace), *args], check=True, capture_output=True)
class CompletionEvidenceTests(unittest.TestCase):
def setUp(self):
directory = tempfile.TemporaryDirectory()
self.addCleanup(directory.cleanup)
self.workspace = Path(directory.name)
git(self.workspace, 'init', '--quiet')
def event(self, message, **overrides):
return dict({'cwd': str(self.workspace), 'stop_hook_active': False, 'last_assistant_message': message}, **overrides)
def test_blocks_unbacked_claim_with_changed_code(self):
(self.workspace / 'app.py').write_text('x = 1\n')
for message in ('All done.', 'Fehler ist behoben.'):
self.assertEqual(json.loads(guard('stop', self.event(message)))['decision'], 'block')
def test_allows_other_stops(self):
(self.workspace / 'app.py').write_text('x = 1\n')
cases = (self.event('Done. Tests: 12 passed.'), self.event('Fertig, aber nicht getestet.'),
self.event('Which option do you prefer?'), self.event('All done.', stop_hook_active=True))
for event in cases:
self.assertEqual(guard('stop', event), '')
def test_allows_clean_or_prose_only_workspace(self):
self.assertEqual(guard('stop', self.event('All done.')), '')
(self.workspace / 'notes.md').write_text('text\n')
self.assertEqual(guard('stop', self.event('All done.')), '')
def test_fails_open_on_malformed_events(self):
for event in ('', 'not json', '[]', {'cwd': 7, 'last_assistant_message': 'done'},
{'cwd': str(self.workspace / 'missing'), 'last_assistant_message': 'done'},
{'cwd': str(self.workspace), 'last_assistant_message': None}):
self.assertEqual(guard('stop', event, cwd=self.workspace), '')
def test_does_not_run_repository_fsmonitor(self):
marker = self.workspace / 'fsmonitor-ran'
hook = self.workspace / 'monitor.py'
hook.write_text(f'open({str(marker)!r}, "w")\n')
git(self.workspace, 'config', 'core.fsmonitor', f'{Path(sys.executable).as_posix()} {hook.as_posix()}')
guard('stop', self.event('All done.'))
self.assertFalse(marker.exists())
class CorrectionPromptTests(unittest.TestCase):
def test_flags_corrections(self):
for prompt in ('Nein, nimm die andere Datei', 'das ist falsch', 'Er darf niemals pushen', "that's wrong",
'you forgot the tests', 'not what I asked', 'Schon wieder ohne Tests'):
output = json.loads(guard('prompt', {'prompt': prompt}))['hookSpecificOutput']
self.assertEqual(output['hookEventName'], 'UserPromptSubmit')
self.assertIn('approval', output['additionalContext'])
def test_ignores_other_prompts(self):
for prompt in ('Add a logout button', 'was würdest du mir stattdessen empfehlen?', '/nein', 'no' + ' x' * 1500,
'Der Test ist nicht grün'):
self.assertEqual(guard('prompt', {'prompt': prompt}), '')
def test_never_echoes_the_prompt(self):
self.assertNotIn('geheim', guard('prompt', {'prompt': 'Nein, das Passwort geheim bleibt'}))
def test_fails_open_on_malformed_events(self):
for event in ('', 'not json', {}, {'prompt': 3}):
self.assertEqual(guard('prompt', event), '')
class EntryPointTests(unittest.TestCase):
def test_shell_entry_points(self):
shells = (('powershell', shutil.which('pwsh') or shutil.which('powershell'), 0), ('bash', shutil.which('bash'), 1))
names = ((('Show-CorrectionPrompt.ps1', 'show-correction-prompt.sh'), {'prompt': 'Nein, anders'}, 'additionalContext'),
(('Check-CompletionEvidence.ps1', 'check-completion-evidence.sh'), None, 'decision'))
for shell, executable, index in shells:
if not executable or (shell == 'bash' and sys.platform == 'win32'):
continue
with self.subTest(shell=shell), tempfile.TemporaryDirectory() as directory:
workspace = Path(directory)
git(workspace, 'init', '--quiet')
(workspace / 'app.py').write_text('x = 1\n')
for scripts, event, expected in names:
event = event or {'cwd': str(workspace), 'last_assistant_message': 'All done.'}
script = str(SCRIPTS / scripts[index])
command = ([executable, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script]
if shell == 'powershell' else [executable, script])
result = subprocess.run(command, input=json.dumps(event), capture_output=True, encoding='utf-8', timeout=30)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stderr, '')
self.assertIn(expected, json.loads(result.stdout) | json.loads(result.stdout).get('hookSpecificOutput', {}))
if __name__ == '__main__':
unittest.main()
+2 -2
View File
@@ -61,12 +61,12 @@ 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 'SessionStart,Stop' -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 '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 ($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" }
if ($content -notmatch 'status_line\s*=\s*\["model", "reasoning", "fast-mode", "approval-mode", "five-hour-limit", "weekly-limit", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"\]') { throw "Codex status line is incorrect in $package" }
} elseif ((($settings.hooks.PSObject.Properties.Name | Sort-Object) -join ',') -ne 'PreCompact,SessionStart,Stop' -or $content -match 'flashbang-if-input' -or $settings.hooks.Stop[0].hooks[0].async) {
} elseif ((($settings.hooks.PSObject.Properties.Name | Sort-Object) -join ',') -ne 'PreCompact,SessionStart,Stop,UserPromptSubmit' -or $content -match 'flashbang-if-input' -or $settings.hooks.Stop[0].hooks[0].async) {
throw "Claude finish hook is incorrect in $package"
} elseif ($content -notmatch '"defaultMode"\s*:\s*"auto"') {
throw "Claude auto permission mode is missing in $package"
+2 -2
View File
@@ -79,7 +79,7 @@ for shell in powershell bash; do
grep -q 'bash .*flashbang.sh' "$package/$file"
fi
if [ "$client" = codex ]; then
[ "$(sed -n 's/^\[\[hooks\.\([^].]*\)\]\]$/\1/p' "$package/$file" | sort)" = $'SessionStart\nStop' ]
[ "$(sed -n 's/^\[\[hooks\.\([^].]*\)\]\]$/\1/p' "$package/$file" | sort)" = $'SessionStart\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"
@@ -87,7 +87,7 @@ for shell in powershell bash; do
grep -Eq '^max_depth[[:space:]]*=[[:space:]]*1[[:space:]]*$' "$package/$file"
grep -Fq 'status_line = ["model", "reasoning", "fast-mode", "approval-mode", "five-hour-limit", "weekly-limit", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"]' "$package/$file"
else
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); assert set(settings["hooks"]) == {"PreCompact", "SessionStart", "Stop"}' "$package/$file"
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); assert set(settings["hooks"]) == {"PreCompact", "SessionStart", "Stop", "UserPromptSubmit"}' "$package/$file"
! grep -q 'flashbang-if-input' "$package/$file"
! grep -q '"async"[[:space:]]*:[[:space:]]*true' "$package/$file"
grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file"