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>
112 lines
6.4 KiB
Python
112 lines
6.4 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
import uuid
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).parents[2]
|
|
|
|
|
|
class UserCustomizationTests(unittest.TestCase):
|
|
def test_build_references_the_shell_specific_credential_helper(self):
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/build.ps1'), '-Summary',
|
|
], capture_output=True, text=True, timeout=30)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
self.assertIn('with-credential.ps1', (ROOT / 'generated/codex-powershell/AGENTS.md').read_text())
|
|
self.assertIn('with-credential.sh', (ROOT / 'generated/claude-bash/CLAUDE.md').read_text())
|
|
for client, name in (('codex', 'AGENTS.md'), ('claude', 'CLAUDE.md')):
|
|
for shell in ('powershell', 'bash'):
|
|
self.assertNotIn('.my-ai-configuration/instructions/',
|
|
(ROOT / 'generated' / f'{client}-{shell}' / name).read_text())
|
|
|
|
def test_add_instruction_creates_client_overlays_outside_managed_configuration(self):
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
home = Path(directory)
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-instruction.ps1'),
|
|
'-Client', 'Both', '-Instruction', 'Always use the local release process.',
|
|
'-HomePath', str(home),
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
for client in ('codex', 'claude'):
|
|
self.assertEqual('Always use the local release process.\n',
|
|
(home / '.my-ai-configuration/instructions' / f'{client}.md').read_text())
|
|
appended = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-instruction.ps1'),
|
|
'-Client', 'Codex', '-Instruction', 'Keep the release notes current.',
|
|
'-HomePath', str(home),
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, appended.returncode, appended.stderr)
|
|
self.assertEqual('Always use the local release process.\nKeep the release notes current.\n',
|
|
(home / '.my-ai-configuration/instructions/codex.md').read_text())
|
|
|
|
def test_add_credentials_installs_a_client_scoped_helper(self):
|
|
if os.name != 'nt':
|
|
self.skipTest('The OS credential store is supported on Windows only.')
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
home = Path(directory)
|
|
key = f'MY_TEST_TOKEN_{uuid.uuid4().hex}'
|
|
stored = False
|
|
stale = home / '.my-ai-configuration/bin/with-credential.ps1'
|
|
stale.parent.mkdir(parents=True)
|
|
stale.write_text('# outdated helper\n', encoding='utf-8')
|
|
try:
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-credentials.ps1'),
|
|
'-Client', 'Codex', '-Key', key, '-ValueFromStdin',
|
|
'-HomePath', str(home),
|
|
], input='test-value', capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
stored = True
|
|
helper = home / '.my-ai-configuration/bin/with-credential.ps1'
|
|
self.assertEqual((ROOT / 'scripts/lib/with-credential.ps1').read_bytes(), helper.read_bytes(),
|
|
'add-credentials must replace an outdated helper')
|
|
self.assertTrue((home / '.my-ai-configuration/bin/with-credential.sh').is_file())
|
|
child = (f"if ([Environment]::GetEnvironmentVariable('{key}', 'Process')) "
|
|
"{ Write-Output 'child-output'; exit 3 }; exit 1")
|
|
injected = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(helper),
|
|
'-Client', 'Codex', '-Key', key, '-FilePath', powershell,
|
|
'-NoProfile', '-Command', child,
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(3, injected.returncode, injected.stderr)
|
|
self.assertIn('child-output', injected.stdout)
|
|
helper_call = [powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(helper), '-Client', 'Codex', '-Key', key]
|
|
# Child flags that abbreviate helper or common parameters (-k, -d, -v, -c) must reach the child unchanged.
|
|
echoed = subprocess.run(helper_call + ['-FilePath', sys.executable, '-c', 'import sys; print(chr(124).join(sys.argv[1:]))',
|
|
'-k', '-d', '-v', '-Key', 'x'], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, echoed.returncode, echoed.stderr)
|
|
self.assertEqual('-k|-d|-v|-Key|x', echoed.stdout.strip())
|
|
# A command name found on PATH works without a full path.
|
|
on_path = subprocess.run(helper_call + ['-FilePath', 'cmd.exe', '/c', 'exit', '4'], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(4, on_path.returncode, on_path.stderr)
|
|
finally:
|
|
cleanup = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
|
f". '{ROOT / 'scripts/lib/with-credential.ps1'}'; Remove-ManagedCredential -Client Codex -Key {key}",
|
|
], capture_output=True, text=True, timeout=20)
|
|
if stored:
|
|
self.assertEqual(0, cleanup.returncode, cleanup.stderr)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|