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
@@ -20,6 +20,7 @@
{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__SESSION_POINTER_SCRIPT__\"", "timeout": 4}]},
{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__QMD_WARM_SCRIPT__\"", "timeout": 4}]}
],
"UserPromptSubmit": [{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__CORRECTION_PROMPT_SCRIPT__\"", "timeout": 4}]}],
"Stop": [
{
"hooks": [
@@ -29,7 +30,8 @@
"timeout": 8
}
]
}
},
{"hooks": [{"type": "command", "command": "__HOOK_COMMAND__ \"__AI_CONFIG_ROOT__/hooks/scripts/__COMPLETION_EVIDENCE_SCRIPT__\"", "timeout": 6}]}
]
}
}
+14
View File
@@ -21,6 +21,20 @@ command = '__HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/__HOOK_SCRIPT__"'
command_windows = '__POWERSHELL_HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/__POWERSHELL_HOOK_SCRIPT__"'
timeout = 8
[[hooks.Stop]]
[[hooks.Stop.hooks]]
type = "command"
command = '__HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/scripts/__COMPLETION_EVIDENCE_SCRIPT__"'
command_windows = '__POWERSHELL_HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/scripts/__COMPLETION_EVIDENCE_SCRIPT__"'
timeout = 6
[[hooks.UserPromptSubmit]]
[[hooks.UserPromptSubmit.hooks]]
type = "command"
command = '__HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/scripts/__CORRECTION_PROMPT_SCRIPT__"'
command_windows = '__POWERSHELL_HOOK_COMMAND__ "__AI_CONFIG_ROOT__/hooks/scripts/__CORRECTION_PROMPT_SCRIPT__"'
timeout = 4
[[hooks.SessionStart]]
[[hooks.SessionStart.hooks]]
type = "command"
+4
View File
@@ -7,6 +7,8 @@ The adapters register these events:
| Client | Event | Action |
| --- | --- | --- |
| Codex and Claude | `Stop` | Run the finish notification (`flashbang`). |
| Codex and Claude | `Stop` | Push back once on an unbacked completion claim (`Check-CompletionEvidence`/`check-completion-evidence.sh`). |
| Codex and Claude | `UserPromptSubmit` | Ask the agent to propose a durable rule when a prompt looks like a correction (`Show-CorrectionPrompt`/`show-correction-prompt.sh`). |
| Claude | `PreCompact` | Record the compaction timestamp under the installed configuration root and point to existing workspace task state. |
| Claude | `SessionStart` | Print an absolute pointer if the workspace's `.ai-session/state.json` exists. |
| Codex and Claude | `SessionStart` | Warm the QMD index and search daemon in the background (only while local QMD search is enabled). |
@@ -17,6 +19,8 @@ The QMD warm-up hook uses the process working directory and starts only inside a
When enabled during installation or update, Flashbang runs on `Stop`, after the main agent finishes responding. The default flash lasts about 500 milliseconds. The PowerShell command omits `-WindowStyle Hidden`, which can hide or minimize the shared terminal. The PowerShell hook creates a low-opacity click-through overlay without activating another window when its native GUI APIs are available; unsupported runtimes exit safely. Its native DLL cache is optional: a missing `LOCALAPPDATA` environment variable or an unusable cache falls back to in-process compilation instead of suppressing the notification. The Bash hook uses Python's `tkinter`, uses `xrandr` for multi-monitor bounds when available, and falls back to `notify-send` when the overlay is unavailable. Registered hooks are best effort: errors do not fail a Claude session.
The completion hook blocks a stop only when the last message claims completion, names no check, and the Git working tree has non-prose changes. It uses the message wording, not command output, so it is a nudge rather than proof, and it never blocks twice in a row. The correction hook matches German and English phrases, adds a fixed instruction, and stores nothing; it skips slash commands and prompts over 2,000 characters. Rules change only after user approval. Both hooks need Python and fail open. Codex skips new or changed hooks until they are trusted through `/hooks`.
`Validate-CommandSafety`/`validate-command-safety.sh` and `Invoke-PostChangeVerification`/`invoke-post-change-verification.sh` are unregistered utilities. The safety utilities check command text for selected dangerous patterns; the PowerShell variant also checks some absolute paths. Neither is a complete security boundary. The verification utilities explicitly run the repository build when invoked; they are not an automatic requirement after each change.
`Test-SessionConfig`/`test-session-config.sh` checks required repository inputs and is called by the build. Build and doctor do not execute the registered notification or session-state hooks. Claude's status line is a separate `statusLine` command, not a hook event.
+1 -1
View File
@@ -6,7 +6,7 @@ The current baseline includes Ponytail, i-have-adhd, Superpowers, Context7, Cave
### Automatic workflow integration
The always-loaded general rules route both clients to the shared `plugin-workflow` skill at session start/resume and task or phase changes. The policy requires Superpowers at development phase boundaries, Ponytail for implementation and review, Impeccable for UI planning through verification, and i-have-adhd response structure with Caveman's concise style when available. Superpowers owns process; Ponytail constrains implementation to the smallest complete, verified change; Impeccable owns UI decisions; Frontend Design supplements uncovered needs without starting another workflow. User authorization, research gates, and proportionate checks retain precedence.
The always-loaded general rules route both clients to the shared `plugin-workflow` skill for development tasks, on resume, and at phase changes; questions and prose-only changes skip it, and the general rules carry the core response style. The policy requires Superpowers at development phase boundaries, Ponytail for implementation and review, Impeccable for UI planning through verification, and i-have-adhd response structure with Caveman's concise style when available. Superpowers owns process; Ponytail constrains implementation to the smallest complete, verified change; Impeccable owns UI decisions; Frontend Design supplements uncovered needs without starting another workflow. User authorization, research gates, and proportionate checks retain precedence.
The installed i-have-adhd 0.4.1 skill declares `disable-model-invocation: true`. The shared policy therefore supplies automatic response guidance without forcing a manual-only skill invocation or relying on its optional hook. It does not diagnose the user. Style stop commands persist through task changes and resume; `normal mode` disables i-have-adhd, Caveman, and Ponytail for the session. Explicit mode levels override defaults. Missing plugins are reported once and do not trigger installation. These are instruction-level requirements, not runtime interception or a guarantee of model compliance. Existing installations receive them through the normal configuration update; builds do not modify local plugin caches or hook trust.
+1
View File
@@ -77,6 +77,7 @@ On Windows, an unavailable profile-folder lookup falls back to PowerShell's home
| `tests/test-qmd-lib.mjs`, `test-qmd-daemon.mjs`, `test-qmd-search.mjs`, `test-qmd-warm.mjs`, `test-qmd-benchmark.mjs` | Model-free QMD unit tests; require the YAML dependency. |
| `tests/test-qmd-integration.mjs` | Manual integration test using real QMD and downloaded models; excluded from CI. |
| `tests/test-qmd-setup.py` | Validate QMD installation, migration, and removal. |
| `tests/test-agent-guards.py` | Validate the completion-evidence and correction-prompt hooks. |
| `tests/test-session-state.py` | Validate session-state helpers. |
| `tests/test-shell-packages.ps1`, `tests/test-shell-packages.sh` | Validate generated package contents and client settings. |
| `tests/test-runtime-status.ps1`, `tests/test-runtime-status.sh` | Validate build summaries and status-line output. |
+2 -2
View File
@@ -5,7 +5,7 @@ Skills are reusable workflows. Rules are persistent constraints and agents are s
The current structure is organized by purpose:
- `planning/`: impact analysis and work-item definition
- `research/`: mandatory `research` gate for every search, with technical and repository specialists, plus `semantic-search`, which is installed only while local QMD search is enabled
- `research/`: `research` gate for open searches, with technical and repository specialists, plus `semantic-search`, which is installed only while local QMD search is enabled
- `reviews/`: security, performance, WPF, UI/UX, business, API, and EF Core reviews
- `implementation/`: SQL, unit-test, and integration-test writing
- `verification/`: facts and work-item verification
@@ -17,7 +17,7 @@ The current structure is organized by purpose:
General planning, debugging, code review, and completion verification workflows come from Superpowers, so the catalog does not duplicate their triggers. The remaining skills cover focused domains Superpowers does not.
The shared `plugin-workflow` skill coordinates automatic plugin use: Superpowers for process, Ponytail for implementation and review, Impeccable for UI, and i-have-adhd with Caveman for responses. Global instructions require it at session start/resume and task or phase changes. It routes to installed skills, preserves explicit opt-outs, and handles missing or manual-only plugins without replacing upstream workflows.
The shared `plugin-workflow` skill coordinates automatic plugin use: Superpowers for process, Ponytail for implementation and review, Impeccable for UI, and i-have-adhd with Caveman for responses. Global instructions require it for development tasks, on resume, and at phase changes; questions and prose-only changes skip it. It routes to installed skills, preserves explicit opt-outs, and handles missing or manual-only plugins without replacing upstream workflows.
Each skill defines a focused workflow with the investigation, decision points, and output expected for that task. Keep guidance specific to the skill; shared repository constraints belong in the rules.
+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"
+2 -2
View File
@@ -4,11 +4,11 @@ For credentials, run the child command through `~/.my-ai-configuration/bin/with-
## Loading rules
Load rules just in time. First identify the changed area, languages, frameworks, tools, and security or workflow concerns from the task and nearby files. Then load the mandatory baseline and only rules whose triggers match; never preload or recursively read the complete rules tree.
Load rules just in time. First identify the changed area, languages, frameworks, tools, and security or workflow concerns from the task and nearby files. Then load only rules whose triggers match; never preload or recursively read the complete rules tree.
For Codex, read the listed rule path directly. For Claude, invoke the matching `rules-*` skill by its exact name. When a technology directory applies, load its index skill/file first, then load only the topic skills/files that match the work. An index is a small routing map, not a request to load every linked topic. Load cross-cutting rules independently when their stated trigger applies. If a needed rule is not listed or installed, continue with applicable rules and repository conventions.
Every code, configuration, infrastructure, review, test, script, hook, or integration task: `rules/security/index.md` / `rules-security`.
Changes to or reviews of code, scripts, hooks, tests, infrastructure, integrations, or executable configuration: `rules/security/index.md` / `rules-security`. Skip it for prose-only changes.
Focused security: authentication, authorization, sessions, tokens, permissions, tenants => `rules/security/references/auth.md` / `rules-security-auth`; HTTP, requests, serialization, endpoints => `api.md` / `rules-security-api`; browser, cookies, redirects, XSS, CSRF => `web.md` / `rules-security-web`; databases, queries, persistence, sensitive data => `data.md` / `rules-security-data`; files, uploads, archives, paths, processes, IPC, deserialization => `files.md` / `rules-security-files`; network, URLs, proxies, TLS, SSRF => `network.md` / `rules-security-network`; cryptography, secrets, keys, credentials => `crypto.md` / `rules-security-crypto`; dependencies, packages, plugins, builds, deployment, CI => `supply-chain.md` / `rules-security-supply-chain`; active security testing => `testing.md` / `rules-security-testing`.
+2
View File
@@ -4,6 +4,8 @@ This directory contains registered hooks and optional utilities. They do not byp
When Flashbang is enabled, both clients register `Stop` (`flashbang`) for finish notifications. Claude also registers `PreCompact` (`Record-Compact`/`record-compact.sh`) and `SessionStart` (`Show-SessionStatePointer`/`show-session-state-pointer.sh`). PreCompact records its timestamp under the installed configuration root. Both session hooks point to an existing workspace `.ai-session/state.json`, using event `cwd` or the process working directory. The main agent owns that state; hooks never write it or print its contents. Missing state is a successful no-op.
Both clients register `Stop` (`Check-CompletionEvidence`/`check-completion-evidence.sh`) and `UserPromptSubmit` (`Show-CorrectionPrompt`/`show-correction-prompt.sh`). Both call `agent-guards.py`, store nothing, and fail open. The first pushes back once on a completion claim without a named check while non-prose changes exist; the second asks the agent to propose a durable rule after a likely correction.
`Validate-CommandSafety`/`validate-command-safety.sh` and `Invoke-PostChangeVerification`/`invoke-post-change-verification.sh` are not registered or invoked automatically. The safety utility checks selected command-text patterns; the verification utility runs the repository build only when explicitly invoked. `Test-SessionConfig`/`test-session-config.sh` checks repository inputs during a build.
When local QMD search is enabled, both clients also register a `SessionStart` warm-up hook (`Start-QmdWarm.ps1`/`qmd-warm.sh`). It starts the installed Node wrapper in the background from the process working directory, only inside a Git repository. Warm-up errors are recorded in `~/.my-ai-configuration/qmd/warm.log`; they do not fail the session. Disabling local search removes the hook registration.
@@ -0,0 +1,7 @@
[CmdletBinding()]
param()
try {
$ErrorActionPreference = 'Stop'
& python (Join-Path $PSScriptRoot 'agent-guards.py') stop 2>$null
} catch {}
exit 0
@@ -0,0 +1,7 @@
[CmdletBinding()]
param()
try {
$ErrorActionPreference = 'Stop'
& python (Join-Path $PSScriptRoot 'agent-guards.py') prompt 2>$null
} catch {}
exit 0
+77
View File
@@ -0,0 +1,77 @@
import json
import os
from pathlib import Path
import re
import subprocess
import sys
MAX_EVENT_BYTES = 1048576
MAX_PROMPT_CHARS = 2000
PROSE_SUFFIXES = ('.md', '.mdx', '.rst', '.txt')
CLAIM = re.compile(r'\b(?:done|finished|completed?|fixed|implemented|resolved|works|fertig|erledigt|behoben|umgesetzt|'
r'funktioniert|implementiert|abgeschlossen)\b', re.I)
# shortcut: matches the wording, not real command output; parse each client's transcript if claims get faked.
EVIDENCE = re.compile(r'\b(?:tests?|builds?|lint\w*|typecheck\w*|compiled?|pass(?:ed|es)?|fail(?:ed|s|ures?)?|exit|'
r'verified|verification|not run|skipped|unverified|getestet|geprüft|ungeprüft|doctor|prüfung)\b', re.I)
CORRECTION = re.compile(r"^\s*(?:nein|nope|no|falsch|wrong)\b"
r"|\b(?:ist|war) (?:falsch|nicht richtig|nicht korrekt)\b|\b(?:stimmt|passt) nicht\b"
r"|\b(?:schon wieder|immer noch nicht|nicht so|so nicht|niemals|du sollst (?:nicht|doch)|"
r"(?:habe|hab|hatte) ich (?:doch )?gesagt|ich (?:sagte|hatte gesagt))\b"
r"|\b(?:that'?s (?:wrong|not right)|not what i (?:asked|wanted|said)|i (?:said|told you)|"
r"you (?:forgot|missed|ignored)|you (?:should|must) not|don'?t (?:do|use|add)|"
r"stop (?:doing|using|adding)|never)\b", re.I)
BLOCK_REASON = ('The last message claims completion for changed code but cites no check. Run the cheapest relevant check '
'and report its real result, or state plainly that it was not run and why.')
CORRECTION_CONTEXT = ('This prompt may correct you. If it reveals a durable rule rather than a one-off fix, propose that rule '
'in one line and ask for approval. After approval, store it in the user\'s configuration repository: '
'`shared/` for all clients, or `scripts/commands/add-instruction` for one client. Ask for the '
'repository path if unknown. Never change instructions without approval.')
def read_event():
raw = '' if sys.stdin.isatty() else sys.stdin.buffer.read(MAX_EVENT_BYTES + 1).decode('utf-8-sig')
if len(raw) > MAX_EVENT_BYTES or not raw.strip():
return {}
event = json.loads(raw)
return event if isinstance(event, dict) else {}
def has_code_changes(workspace):
if not isinstance(workspace, str) or not Path(workspace).is_dir():
return False
# core.fsmonitor from a repository's config would otherwise run its command here.
status = subprocess.check_output(['git', '-c', 'core.fsmonitor=false', '-C', workspace, 'status', '--porcelain', '-z'],
stderr=subprocess.DEVNULL, timeout=3)
entries = status.decode('utf-8', 'replace').split('\0')
return any(entry and not entry.lower().endswith(PROSE_SUFFIXES) for entry in entries)
def check_completion(event):
message = event.get('last_assistant_message')
# stop_hook_active means this hook already pushed back once; a second block could loop forever.
if event.get('stop_hook_active') or not isinstance(message, str):
return
if CLAIM.search(message) and not EVIDENCE.search(message) and has_code_changes(event.get('cwd', os.getcwd())):
print(json.dumps({'decision': 'block', 'reason': BLOCK_REASON}))
def show_correction(event):
prompt = event.get('prompt')
if not isinstance(prompt, str) or len(prompt) > MAX_PROMPT_CHARS or prompt.lstrip().startswith('/'):
return
if CORRECTION.search(prompt):
print(json.dumps({'hookSpecificOutput': {'hookEventName': 'UserPromptSubmit', 'additionalContext': CORRECTION_CONTEXT}}))
def main():
handlers = {'stop': check_completion, 'prompt': show_correction}
try:
handlers[sys.argv[1]](read_event())
except (IndexError, KeyError, ValueError, OSError, RecursionError, subprocess.SubprocessError):
return
if __name__ == '__main__':
main()
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -uo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
python3 "$script_dir/agent-guards.py" stop 2>/dev/null || true
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -uo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
python3 "$script_dir/agent-guards.py" prompt 2>/dev/null || true
+5 -4
View File
@@ -4,12 +4,13 @@ Apply instructions in this order: direct user instructions; security and data-lo
Preserve security, data, compatibility, and unrelated user work. Ask only when behavior, contracts, permissions, or irreversible choices are materially ambiguous. Otherwise choose the smallest reversible change.
Use one applicable workflow per task, with mandatory research gates for every search within it. Treat skills and plugins as guidance subordinate to these rules. Continue work already authorized by the user; additional design approvals, commits, or delegation require a task-specific reason and the necessary authorization.
Use one applicable workflow per task, with the research gates below for searches within it. Treat skills and plugins as guidance subordinate to these rules. Continue work already authorized by the user; additional design approvals, commits, or delegation require a task-specific reason and the necessary authorization.
MUST apply `plugin-workflow` before the first response, on resume, and at task or phase changes. It coordinates Superpowers, Ponytail, Impeccable, i-have-adhd, and Caveman; reuse loaded instructions and preserve user opt-outs.
For development tasks (code, script, hook, configuration, or UI changes; debugging; code review), MUST apply `plugin-workflow` before the first action, on resume, and at phase changes. Skip it for questions and prose-only changes. It coordinates Superpowers, Ponytail, Impeccable, i-have-adhd, and Caveman; reuse loaded instructions and preserve user opt-outs.
Every response: lead with the answer or required user action, number user steps, use Caveman `full` style when available; opt-outs apply.
Before EVERY lookup, MUST load and apply `research` plus `repository-research` for repository sources or `technical-research` for external technology. Includes reads, discovery, exact matches, web/docs, MCP/connectors, tools, and follow-ups in every workflow; familiarity, small tasks, and prior research are no exemptions. Reuse loaded instructions, applying checks each time. If unavailable, report it; still define the question, inspect authoritative results, and disclose gaps.
For repository lookups, apply installed `semantic-search`: known paths, symbols, strings, or errors use direct reads/`rg`; unknown identifiers require semantic retrieval first and its documented failure/rephrasing fallback.
Before open searches (unknown locations or identifiers, behavior questions, discovery), MUST load and apply `research` plus `repository-research` for repository sources; before every external technology lookup, MUST load `technical-research`. Direct reads of known paths and exact matches of known identifiers need no skill load. Every lookup: define the question, inspect authoritative results, and disclose gaps. If a required skill is unavailable, report it and apply these checks.
Known paths, symbols, strings, or errors use direct reads/`rg`. For unknown identifiers, apply installed `semantic-search`: semantic retrieval first, with its documented failure/rephrasing fallback.
Before relying on external technology behavior in any answer, plan, code, review, debugging, configuration, test, or upgrade, MUST automatically apply `technical-research`'s Context7-first gate and phase checkpoints, including inside plugin workflows. Follow its version checks, evidence reuse, query limits, and explicit source fallback.
Verify proportionally: run the cheapest check that detects likely failure; broaden for security, data loss, integration, or cross-component risk. Never claim unrun checks passed. Report failures and material gaps.
+5 -2
View File
@@ -93,8 +93,9 @@ Examples of valid commit messages:
## Branches
* Do not create a branch unless explicitly requested.
* Do not switch branches unless necessary for the requested task.
* Never create a branch without first asking the user and receiving approval.
* Never switch branches without first asking the user and receiving approval, even when the task appears to require it.
* Never create a worktree without first asking the user and receiving approval.
* Never delete branches unless explicitly requested.
* Never rename branches unless explicitly requested.
* Never assume the target branch for a merge, rebase, or push.
@@ -159,6 +160,8 @@ The agent must not autonomously:
* amend commits
* create pull requests
* create or delete tags
* create or switch branches
* create worktrees
* delete branches
* rewrite Git history
* discard working-tree changes
+1 -1
View File
@@ -1,6 +1,6 @@
# Security Baseline
Apply this language- and framework-independent baseline to every code, configuration, infrastructure, and review task. Use the platform's established controls to implement it. Load focused security rules only for boundaries affected by the task; triggers are listed in the global instructions.
Apply this language- and framework-independent baseline to changes to or reviews of code, scripts, hooks, tests, infrastructure, integrations, and executable configuration. Use the platform's established controls to implement it. Load focused security rules only for boundaries affected by the task; triggers are listed in the global instructions.
* Prioritize confidentiality, integrity, and availability. When security and performance conflict, preserve the security control and find a more efficient implementation; explain unavoidable cost.
* Identify trust boundaries and likely abuse paths. Treat external input as untrusted; validate it before use and enforce authorization at the resource or operation boundary.
+2 -2
View File
@@ -1,6 +1,6 @@
---
name: plugin-workflow
description: MUST use at session start/resume, task changes, and development phase transitions to coordinate installed workflow, UI, and communication plugins.
description: MUST use for development tasks (code, script, hook, configuration, or UI changes; debugging; code review), on their resume, and at phase transitions to coordinate installed workflow, UI, and communication plugins. Not for questions or documentation and instruction-text changes.
---
# Plugin Workflow
@@ -18,7 +18,7 @@ MUST load `using-superpowers` for development tasks and the matching skill befor
- Review requests/feedback: `requesting-code-review`/`receiving-code-review`.
- Completion claims: `verification-before-completion`, with matching evidence.
Keep Context7 checkpoints within this workflow. Existing authorization stands; ask only about material unresolved decisions. Plugin defaults do not authorize commits, publishing, or additional approval rounds.
Keep Context7 checkpoints within this workflow. Existing authorization stands; ask only about material unresolved decisions. Plugin defaults do not authorize commits, publishing, branch creation or switching, worktree creation, or additional approval rounds.
## Ponytail: implementation and review
@@ -1,11 +1,11 @@
---
name: repository-research
description: MUST use before EVERY repository search or lookup, including direct reads, file discovery, exact strings, known symbols, familiar areas, and follow-up searches in any workflow; also before repository changes, reviews, or answers.
description: MUST use before open repository searches - unknown locations or identifiers, behavior questions, and cross-file tracing for changes, reviews, or answers. Not needed for direct reads of known paths or exact matches of known identifiers.
---
# Repository Research
Apply `research` and this skill to every repository lookup. Earlier inspection and known identifiers do not waive the workflow. Reuse loaded instructions, but check the question, scope, and evidence for each lookup. Ground changes and answers in current files.
Apply `research` and this skill to open repository searches. Direct reads of known paths and exact matches of known identifiers need no skill load. Reuse loaded instructions, but check the question, scope, and evidence for each lookup. Ground changes and answers in current files.
## Workflow
+4 -4
View File
@@ -1,13 +1,13 @@
---
name: research
description: MUST use before EVERY search or lookup, without exception for exact matches, familiar subjects, quick checks, or follow-up queries. Covers repository, filesystem, web, documentation, MCP, connector, and tool discovery searches in every workflow.
description: MUST use before open searches - unknown locations or identifiers, behavior questions, and repository, filesystem, web, documentation, MCP, connector, or tool discovery. Not needed for direct reads of known paths or exact matches of known identifiers.
---
# Research
## Mandatory gate
## Gate
Apply this skill before every search or lookup, including file discovery, direct source reads, exact-string searches, semantic queries, web searches, documentation fetches, and MCP or connector queries. This includes searches during planning, implementation, debugging, review, and verification. Task size, known identifiers, prior research, and urgency do not waive the gate.
Apply this skill before open searches, including file discovery, semantic queries, web searches, documentation fetches, and MCP or connector queries, during planning, implementation, debugging, review, and verification. Direct reads of known paths and exact matches of known identifiers need no skill load.
Load this skill before the first search; retain and apply it to every subsequent search. Reuse instructions already in context rather than rereading them for each call. Reading the instructions needed to enter this workflow is its bootstrap step.
@@ -15,7 +15,7 @@ Load this skill before the first search; retain and apply it to every subsequent
1. Identify the question, the scope to search, and the evidence that would answer it. Keep this brief; no separate document is required.
2. Apply the matching specialist before executing the lookup:
- Repository code, files, configuration, history, or local documentation: `repository-research`, including known paths and exact matches.
- Repository code, files, configuration, history, or local documentation: `repository-research`.
- External technologies, APIs, tools, packages, standards, or technical documentation: `technical-research` and its mandatory Context7 gate, including familiar technologies and previously researched versions. Apply that specialist before relying on external behavior in answers, code, reviews, debugging, or configuration, even when no search was explicitly requested.
- Other web, filesystem, MCP, connector, or discovery searches: apply this workflow directly and select the authoritative source for the question.
3. Select the smallest query that can answer the question. Batch independent lookups; let dependent queries follow verified results.
@@ -1,6 +1,6 @@
---
name: semantic-search
description: MUST apply before EVERY repository search or lookup, including direct reads, exact matches, and follow-up searches. Route known identifiers to direct reads or rg; run semantic retrieval first for unknown identifiers and behavior questions.
description: MUST apply before open repository searches - run semantic retrieval first for unknown identifiers and behavior questions. Not needed for known paths, symbols, or exact strings, which use direct reads or rg.
---
# Semantic Search
@@ -9,7 +9,7 @@ Search the current Git repository, plus the user's registered QMD collections, b
## Rule
Apply `research`, `repository-research`, and this routing rule before each repository lookup. Known exact identifiers, paths, or strings use direct reads or `rg` under the same research checks. Unknown identifiers require semantic retrieval first; guessed keywords are not known identifiers. Reevaluate the route for every follow-up query. Reuse instructions already in context.
Apply `research`, `repository-research`, and this routing rule before each open repository search. Known exact identifiers, paths, or strings use direct reads or `rg` without loading these skills. Unknown identifiers require semantic retrieval first; guessed keywords are not known identifiers. Reevaluate the route for every follow-up query. Reuse instructions already in context.
## Run