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:
1 parent
63a36d90e0
commit
b35e2254b3
48 files changed
+1059
-98
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user