feat(extensions): add Roast Room, bring Codex to parity, fix audit findings

Roast Room is installed as a managed Git clone under
~/.my-ai-configuration/roast-room, shared by Claude and Codex. A personal
launcher skill runs it from any folder, starts its live room when needed,
and only runs when invoked by name (/roast-room, $roast-room).

Codex now gets what was Claude-only before: the Caveman skill with a
SessionStart hook that keeps it on, PreCompact and session-pointer hooks,
execpolicy deny rules mirroring Claude's permissions.deny, and Impeccable's
custom agents registered in ~/.codex/agents. The command-safety hook checks
both shell dialects for Codex on Windows, where PowerShell text arrives as
Bash, in both the PowerShell and Bash packages.

Audit fixes:
- command-safety blocks git checkout -- / restore / push --force /
  stash clear and find -delete, and treats heredoc bodies as text
- removing a clone clears read-only Git files, git errors no longer abort
  the extension sync, and a lock left by a dead process is replaced
- with-credential passes child flags such as -k or -d through unchanged
  and resolves commands from PATH
- uninstall strips only owned hooks from settings.json and config.toml and
  keeps the selection while another client is installed; update keeps
  CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY; Bash merges write the same bytes as
  PowerShell
- qmd no longer trusts a stale daemon.json after a lost start race and
  prunes collections of deleted repositories
- Bash scripts avoid GNU-only find -printf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-19 09:02:47 +01:00
1 parent 63a36d90e0
commit b35e2254b3
48 files changed
+1059 -98

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
This directory contains registered hooks and optional utilities. They do not bypass client permission prompts or grant access.
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.
When Flashbang is enabled, both clients register `Stop` (`flashbang`) for finish notifications. Both clients also register `PreCompact` (`Record-Compact`/`record-compact.sh`) and `SessionStart` (`Show-SessionStatePointer`/`show-session-state-pointer.sh`). Codex additionally registers `SessionStart` (`Show-CavemanMode`/`show-caveman-mode.sh`), which prints the installed Caveman skill so caveman style is always on, as the Claude plugin's own hook does. 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 `PreToolUse` (`Validate-CommandSafety`/`validate-command-safety.sh`), which blocks clearly destructive shell commands by exiting 2; it parses command text, so it is a guard rail rather than a security boundary, and it fails open. Both clients also 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. A second `PreToolUse` hook (`Show-SearchReminder`/`show-search-reminder.sh`, also through `agent-guards.py`) reminds the agent to run `semantic-search` before the first open search and again after every 10 open searches without `qmd-search.mjs`, which also covers context lost to compaction; it never blocks, stays silent while the session keeps using `qmd-search.mjs`, does nothing unless QMD is installed, and keeps only hashed per-session markers under `~/.my-ai-configuration/state/search-reminder/`.
+16
View File
@@ -0,0 +1,16 @@
[CmdletBinding()]
param()
# Codex SessionStart hook: Codex adds plain stdout to the session context, so printing the installed
# Caveman skill makes caveman style always-on like the Claude plugin. CAVEMAN_DEFAULT_MODE=off disables it.
try {
$ErrorActionPreference = 'Stop'
$mode = if ($env:CAVEMAN_DEFAULT_MODE) { $env:CAVEMAN_DEFAULT_MODE.ToLowerInvariant() } else { 'caveman' }
if ($mode -in @('off', 'manual')) { exit 0 }
$userHome = if ($env:USERPROFILE) { $env:USERPROFILE } elseif ($env:HOME) { $env:HOME } else { [Environment]::GetFolderPath('UserProfile') }
$skill = Join-Path $userHome '.agents/skills/caveman/SKILL.md'
if (-not (Test-Path -LiteralPath $skill -PathType Leaf)) { exit 0 }
$text = [IO.File]::ReadAllText($skill)
$body = [regex]::Replace($text, '\A---\r?\n.*?\r?\n---\r?\n', '', 'Singleline')
[Console]::Out.Write("CAVEMAN MODE ACTIVE (mode: $mode). Follow these rules for every response until the user says ""stop caveman"" or ""normal mode"".`n`n$body")
} catch {}
exit 0
@@ -1,7 +1,8 @@
# Without -Command this runs as a PreToolUse hook: it reads the event from stdin and exits 2 to block.
# With -Command it checks one command and also rejects absolute paths outside -Workspace.
# Pattern checks are a guard rail against accidents, not a security boundary.
param([string]$Command, [string]$Workspace = (Get-Location).Path)
# -Shell (bash, powershell, unknown) overrides the dialect taken from the hook's tool name.
param([string]$Command, [string]$Workspace = (Get-Location).Path, [ValidateSet('', 'bash', 'powershell', 'unknown')][string]$Shell = '')
. (Join-Path $PSScriptRoot 'Resolve-Python.ps1')
$python = Get-PythonCommand
$script = Join-Path $PSScriptRoot 'command-safety.py'
@@ -13,5 +14,6 @@ if ($PSBoundParameters.ContainsKey('Command')) {
}
# Registered hooks fail open without Python; doctor reports that case.
if (-not $python) { exit 0 }
& $python.Path @($python.Arguments) $script --hook
$shellArguments = if ($Shell) { @('--shell', $Shell) } else { @() }
& $python.Path @($python.Arguments) $script --hook @shellArguments
exit $LASTEXITCODE
+41 -4
View File
@@ -20,6 +20,7 @@ WRAPPERS = {'sudo', 'doas', 'command', 'builtin', 'exec', 'nohup', 'time', 'env'
# Shell keywords that can precede a command in the same segment.
KEYWORDS = {'if', 'then', 'else', 'elif', 'do', 'while', 'until', '!'}
LINE_CONTINUATION = re.compile(r'[\\`]\r?\n')
HEREDOC = re.compile(r'<<(-?)\s*([\'"]?)([A-Za-z_][A-Za-z0-9_]*)\2')
POSIX_SHELLS = {'bash', 'sh', 'zsh', 'dash', 'ksh'}
POWERSHELL_HOSTS = {'pwsh', 'powershell'}
POWERSHELL_REMOVE = {'remove-item', 'ri'}
@@ -31,11 +32,33 @@ MAX_DEPTH = 3
def split_segments(command):
"""Split on ;, &, |, &&, ||, newlines, and braces outside quotes; drop # comments; join continued lines."""
"""Split on ;, &, |, &&, ||, newlines, and braces outside quotes; drop # comments and heredoc bodies; join continued lines."""
command = LINE_CONTINUATION.sub(' ', command)
segments, current, quote, index = [], [], None, 0
segments, current, quote, index, heredocs = [], [], None, 0, []
while index < len(command):
character = command[index]
if not quote and command.startswith('<<', index) and not command.startswith('<<<', index):
match = HEREDOC.match(command, index)
if match:
heredocs.append((match.group(1) == '-', match.group(3)))
current.append(match.group(0))
index = match.end()
continue
if not quote and character == '\n' and heredocs:
# The body is text for the command, not commands: skip to each delimiter line.
segments.append(''.join(current))
current = []
lines = command[index + 1:].split('\n')
consumed = 0
for strip_tabs, word in heredocs:
while consumed < len(lines):
line = lines[consumed].rstrip('\r')
consumed += 1
if (line.lstrip('\t') if strip_tabs else line) == word:
break
heredocs = []
index += 1 + sum(len(line) + 1 for line in lines[:consumed])
continue
if character == '\\' and quote != "'" and index + 1 < len(command):
current.append(command[index:index + 2])
index += 2
@@ -134,6 +157,16 @@ def check_tokens(tokens, shell=None):
return 'discarding work tree changes (git reset --hard)'
if subcommand == 'clean' and ('f' in short_flags(rest) or '--force' in rest):
return 'deleting untracked files (git clean -f)'
if subcommand == 'checkout' and ('--' in rest or '.' in rest):
return 'discarding file changes (git checkout -- <path>)'
if subcommand == 'restore' and rest and ('--staged' not in rest or '--worktree' in rest):
return 'discarding file changes (git restore)'
if subcommand == 'push' and ('f' in short_flags(rest) or any(item.startswith(('--force', '+')) for item in rest)):
return 'overwriting remote history (git push --force)'
if subcommand == 'stash' and rest[:1] == ['clear']:
return 'deleting all stashes (git stash clear)'
if program == 'find' and '-delete' in lowered:
return 'deleting found files (find -delete)'
powershell_remove = program in POWERSHELL_REMOVE or (shell != 'bash' and program in POWERSHELL_REMOVE_ALIASES)
if powershell_remove and any(RECURSE_PARAMETER.fullmatch(item) for item in lowered):
return 'recursive deletion (Remove-Item -Recurse)'
@@ -200,7 +233,7 @@ def outside_workspace(command, workspace):
return None
def run_hook(data):
def run_hook(data, shell_override=None):
try:
event = json.loads(data.decode('utf-8', errors='replace'))
command = event.get('tool_input', {}).get('command')
@@ -210,6 +243,9 @@ def run_hook(data):
if not isinstance(command, str):
return 0
shell = tool if tool in ('bash', 'powershell') else None
if shell_override:
# Codex reports every shell command as Bash, even PowerShell script text on Windows.
shell = None if shell_override == 'unknown' else shell_override
reason = find_violation(command, shell)
if reason:
print(f'Blocked by command-safety hook: {reason}. Ask the user to run this command themselves if it is intended.', file=sys.stderr)
@@ -236,9 +272,10 @@ def main():
mode.add_argument('--hook', action='store_true', help='read a PreToolUse event from stdin')
mode.add_argument('--command', help="command text to check, or '-' to read it from stdin")
parser.add_argument('--workspace', default=os.getcwd())
parser.add_argument('--shell', choices=('bash', 'powershell', 'unknown'), help='hook mode: dialect to assume instead of the tool name')
args = parser.parse_args()
if args.hook:
return run_hook(sys.stdin.buffer.read())
return run_hook(sys.stdin.buffer.read(), args.shell)
# Windows PowerShell 5.1 prefixes piped stdin with a UTF-8 byte order mark.
command = sys.stdin.buffer.read().decode('utf-8-sig', errors='replace') if args.command == '-' else args.command
return run_check(command, args.workspace)
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Codex SessionStart hook: Codex adds plain stdout to the session context, so printing the installed
# Caveman skill makes caveman style always-on like the Claude plugin. CAVEMAN_DEFAULT_MODE=off disables it.
mode=$(printf '%s' "${CAVEMAN_DEFAULT_MODE:-caveman}" | tr '[:upper:]' '[:lower:]')
case "$mode" in off|manual) exit 0 ;; esac
skill="${HOME:-}/.agents/skills/caveman/SKILL.md"
[ -f "$skill" ] || exit 0
printf 'CAVEMAN MODE ACTIVE (mode: %s). Follow these rules for every response until the user says "stop caveman" or "normal mode".\n\n' "$mode"
awk 'NR == 1 && /^---/ { front = 1; next } front && /^---/ { front = 0; next } !front' "$skill" 2>/dev/null
exit 0
@@ -7,6 +7,12 @@ set -uo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=resolve-python.sh
. "$script_dir/resolve-python.sh"
hook_arguments=()
# Codex hook commands pass -Shell <bash|powershell|unknown>; that is still hook mode.
if [ "${1:-}" = -Shell ] && [ $# -eq 2 ]; then
hook_arguments=(--shell "$2")
shift 2
fi
if [ $# -gt 0 ]; then
resolve_python || { python_missing_message >&2; exit 1; }
printf '%s' "$1" | run_python "$script_dir/command-safety.py" --command - --workspace "${2:-$PWD}"
@@ -14,4 +20,4 @@ if [ $# -gt 0 ]; then
fi
# Registered hooks fail open without Python; doctor reports that case.
resolve_python || exit 0
run_python "$script_dir/command-safety.py" --hook
run_python "$script_dir/command-safety.py" --hook ${hook_arguments[@]+"${hook_arguments[@]}"}