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
@@ -193,7 +193,7 @@ class Manager:
|
||||
raise ValueError('Invalid extension ownership ledger.')
|
||||
identities = set()
|
||||
for resource in self.state['resources']:
|
||||
if not isinstance(resource, dict) or resource.get('client') not in ('codex', 'claude', 'shared') or resource.get('kind') not in ('plugin', 'skill', 'qmd', 'cli', 'mcp'):
|
||||
if not isinstance(resource, dict) or resource.get('client') not in ('codex', 'claude', 'shared') or resource.get('kind') not in ('plugin', 'skill', 'qmd', 'cli', 'mcp', 'clone'):
|
||||
raise ValueError('Invalid extension ownership record.')
|
||||
if not isinstance(resource.get('name'), str) or not resource['name']:
|
||||
raise ValueError('Invalid extension ownership name.')
|
||||
@@ -220,6 +220,13 @@ class Manager:
|
||||
if not relative.startswith(directory + '/') or not re.fullmatch(r'[a-f0-9]{64}', value):
|
||||
raise ValueError('Invalid owned skill file record.')
|
||||
safe_path(self.home, relative)
|
||||
for relative, value in resource.get('agents', {}).items():
|
||||
if resource['client'] != 'codex' or not re.fullmatch(r'\.codex/agents/[A-Za-z0-9_-]+\.toml', relative) or not re.fullmatch(r'[a-f0-9]{64}', value):
|
||||
raise ValueError('Invalid owned skill agent record.')
|
||||
elif resource['kind'] == 'clone':
|
||||
if resource['client'] != 'shared' or not re.fullmatch(r'\.my-ai-configuration/[A-Za-z0-9_-]+', resource.get('directory', '')):
|
||||
raise ValueError('Invalid owned clone record.')
|
||||
safe_path(self.home, resource['directory'])
|
||||
elif resource['kind'] == 'qmd' and (resource.get('package') != '@tobilu/qmd' or resource['client'] not in ('codex', 'shared')):
|
||||
raise ValueError('Invalid owned QMD record.')
|
||||
elif resource['kind'] == 'cli' and not re.fullmatch(r'[a-z0-9@/_.-]+', resource.get('package', '')):
|
||||
@@ -297,6 +304,14 @@ class Manager:
|
||||
self.command(arguments)
|
||||
self.cache[client].pop(selector, None)
|
||||
elif record['kind'] == 'skill':
|
||||
for relative, expected in list(record.get('agents', {}).items()):
|
||||
path = safe_path(self.home, relative)
|
||||
if path.exists() and (not path.is_file() or digest(path) != expected):
|
||||
print(f'WARN Preserving modified agent file: {relative}')
|
||||
continue
|
||||
path.unlink(missing_ok=True)
|
||||
del record['agents'][relative]
|
||||
self.save()
|
||||
empty_candidates = set()
|
||||
for relative, expected in list(record['files'].items()):
|
||||
path = safe_path(self.home, relative)
|
||||
@@ -326,6 +341,22 @@ class Manager:
|
||||
pass
|
||||
if record['files']:
|
||||
return
|
||||
elif record['kind'] == 'clone':
|
||||
directory = safe_path(self.home, record['directory'])
|
||||
if directory.exists():
|
||||
# Saved sessions, .env files, and local edits live in the clone; never delete them.
|
||||
try:
|
||||
status = run_command(['git', '-C', str(directory), 'status', '--porcelain', '--ignored', '--untracked-files=all'], True, self.home)
|
||||
except ValueError as error:
|
||||
print(f'WARN Preserving {record["directory"]}: cannot read its Git status ({str(error).splitlines()[0]}).')
|
||||
return
|
||||
local = [line for line in status.splitlines() if not line[3:].startswith('node_modules/')]
|
||||
if local:
|
||||
print(f'WARN Preserving {record["directory"]}: it holds local files ({len(local)}); delete it yourself if they are not needed.')
|
||||
return
|
||||
# Git marks pack files read-only, which Windows refuses to delete.
|
||||
retry = lambda _, path, __: (os.chmod(path, stat.S_IWRITE), os.unlink(path))
|
||||
shutil.rmtree(directory, **({'onexc': retry} if sys.version_info >= (3, 12) else {'onerror': retry}))
|
||||
elif record['kind'] == 'mcp':
|
||||
self.command(['mcporter', '--config', str(self.home / '.mcporter/mcporter.json'), 'config', 'remove', record['server']])
|
||||
else:
|
||||
@@ -338,6 +369,9 @@ class Manager:
|
||||
if entry['codex_method'] == 'cli':
|
||||
self.ensure_cli(client, entry)
|
||||
return
|
||||
if entry['codex_method'] == 'clone':
|
||||
self.ensure_clone(client, entry)
|
||||
return
|
||||
# A Claude row without a plugin ('-') reuses the skill payload from codex_source.
|
||||
skill = entry['codex_method'] == 'skill' and (client == 'codex' or entry['claude_plugin'] == '-')
|
||||
kind = 'skill' if skill else 'plugin'
|
||||
@@ -429,6 +463,42 @@ class Manager:
|
||||
self.state['resources'].append(dict(client='shared', name=entry['name'], kind='cli', package=package, clients=[client]))
|
||||
self.save()
|
||||
|
||||
def ensure_clone(self, client, entry):
|
||||
"""Keep a project repository (skills, agents, app) cloned under ~/.my-ai-configuration, shared by both clients."""
|
||||
source, folder = entry['codex_source'], entry['codex_skill']
|
||||
if not re.fullmatch(r'[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', source) or not re.fullmatch(r'[A-Za-z0-9_-]+', folder):
|
||||
raise ValueError('Invalid clone source or folder.')
|
||||
directory = '.my-ai-configuration/' + folder
|
||||
target = safe_path(self.home, directory)
|
||||
record = next((r for r in self.state['resources'] if r['client'] == 'shared' and r['name'] == entry['name']), None)
|
||||
if record is None and target.exists():
|
||||
if not self.summary:
|
||||
print(f'PASS Preserving pre-existing folder: {directory}')
|
||||
return
|
||||
if self.dry_run:
|
||||
if not self.summary:
|
||||
print(f'DRYRUN ensure {client} clone: {entry["name"]}')
|
||||
return
|
||||
if record is not None and client not in record['clients']:
|
||||
record['clients'] = sorted(set(record['clients']) | {client})
|
||||
self.save()
|
||||
if not target.exists():
|
||||
self.command(['git', 'clone', '--depth', '1', f'https://github.com/{source}.git', str(target)])
|
||||
elif self.update and entry['name'] not in self.updated_packages:
|
||||
# Both clients share the folder; check and pull it once per run. A broken clone must not stop the other extensions.
|
||||
self.updated_packages.add(entry['name'])
|
||||
try:
|
||||
changed = run_command(['git', '-C', str(target), 'status', '--porcelain', '--untracked-files=no'], True, self.home)
|
||||
if changed.strip():
|
||||
print(f'WARN Not updating {directory}: tracked files were changed locally.')
|
||||
else:
|
||||
self.command(['git', '-C', str(target), 'pull', '--ff-only', '--quiet'])
|
||||
except ValueError as error:
|
||||
print(f'WARN Not updating {directory}: {str(error).splitlines()[0]}')
|
||||
if record is None:
|
||||
self.state['resources'].append(dict(client='shared', name=entry['name'], kind='clone', directory=directory, source=source, clients=[client]))
|
||||
self.save()
|
||||
|
||||
def ensure_ponytail_mode(self):
|
||||
# Same lookup as Ponytail's hooks/ponytail-config.js; PONYTAIL_DEFAULT_MODE still wins over this file.
|
||||
if os.environ.get('XDG_CONFIG_HOME'):
|
||||
@@ -552,9 +622,33 @@ class Manager:
|
||||
path.unlink(missing_ok=True)
|
||||
del record['files'][relative]
|
||||
self.save()
|
||||
if client == 'codex':
|
||||
self.sync_skill_agents(record, files)
|
||||
record['complete'] = True
|
||||
self.save()
|
||||
|
||||
def sync_skill_agents(self, record, files):
|
||||
"""Codex loads custom agents only from ~/.codex/agents, so register the skill's agents/*.toml there."""
|
||||
agents = {'.codex/agents/' + name.split('/', 1)[1]: content for name, (content, _) in files.items()
|
||||
if re.fullmatch(r'agents/[A-Za-z0-9_-]+\.toml', name)}
|
||||
owned = record.setdefault('agents', {})
|
||||
for relative, content in agents.items():
|
||||
path = safe_path(self.home, relative)
|
||||
if path.exists() and (relative not in owned or not path.is_file() or digest(path) != owned[relative]):
|
||||
print(f'WARN Preserving modified or foreign agent file: {relative}')
|
||||
continue
|
||||
atomic_write(path, content)
|
||||
owned[relative] = hashlib.sha256(content).hexdigest()
|
||||
self.save()
|
||||
for relative in [name for name in owned if name not in agents]:
|
||||
path = safe_path(self.home, relative)
|
||||
if path.exists() and (not path.is_file() or digest(path) != owned[relative]):
|
||||
print(f'WARN Preserving modified stale agent file: {relative}')
|
||||
continue
|
||||
path.unlink(missing_ok=True)
|
||||
del owned[relative]
|
||||
self.save()
|
||||
|
||||
def sync(self, entries, clients, selected, action='sync'):
|
||||
self.normalize_global_records()
|
||||
desired = {entry['name']: entry for entry in entries if entry['name'] in selected}
|
||||
@@ -590,6 +684,47 @@ class Manager:
|
||||
print('EXTENSIONS: reconciliation complete' + (' (dry run)' if self.dry_run else ''))
|
||||
|
||||
|
||||
def process_alive(pid):
|
||||
if os.name == 'nt':
|
||||
import ctypes
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
handle = kernel32.OpenProcess(0x1000, False, pid) # PROCESS_QUERY_LIMITED_INFORMATION
|
||||
if not handle:
|
||||
return False
|
||||
code = ctypes.c_ulong()
|
||||
try:
|
||||
return bool(kernel32.GetExitCodeProcess(handle, ctypes.byref(code))) and code.value == 259 # STILL_ACTIVE
|
||||
finally:
|
||||
kernel32.CloseHandle(handle)
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except ProcessLookupError:
|
||||
return False
|
||||
except PermissionError:
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
def acquire_lock(lock):
|
||||
"""Create the lock with this PID; replace a lock whose process is gone (closed terminal, kill)."""
|
||||
for _ in range(2):
|
||||
try:
|
||||
descriptor = os.open(lock, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)
|
||||
except FileExistsError:
|
||||
try:
|
||||
pid = int(lock.read_text(encoding='utf-8').strip() or 0)
|
||||
except (OSError, ValueError):
|
||||
pid = 0
|
||||
if pid and process_alive(pid):
|
||||
raise ValueError(f'Another install or update is running (PID {pid}). If it is not, delete {lock}.')
|
||||
lock.unlink(missing_ok=True)
|
||||
continue
|
||||
with os.fdopen(descriptor, 'w', encoding='utf-8') as stream:
|
||||
stream.write(str(os.getpid()))
|
||||
return
|
||||
raise ValueError(f'Cannot acquire {lock}.')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('action', choices=('sync', 'install', 'remove'))
|
||||
@@ -616,9 +751,8 @@ def main():
|
||||
return
|
||||
lock = safe_path(manager.home, '.my-ai-configuration/extensions.lock')
|
||||
lock.parent.mkdir(parents=True, exist_ok=True)
|
||||
descriptor = os.open(lock, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)
|
||||
acquire_lock(lock)
|
||||
try:
|
||||
os.close(descriptor)
|
||||
manager = Manager(args.home, args.dry_run, args.update, args.summary)
|
||||
manager.sync(entries, clients, selected, args.action)
|
||||
finally:
|
||||
|
||||
Reference in new issue
Block a user