app
Codex
Public Made by Adomby adom
Codex in Adom Hydrogen: ecosystem setup, dock dashboard and live engineering demos.
main
"""Skip the known introductory IDE tour, not authentication or approvals.
The upstream NUX hook can redirect a new editor tab before its persisted
completion query settles. Adom opens directly at the composer by default.
Only the identified 2025-09-15 tour hook is supported; fail closed on drift.
"""
import re
MARKER = '/* adom/codex introductory tour:begin */return`none`;/* adom/codex introductory tour:end */'
HOOK = re.compile(
r'function [\w$]+\(\)\{(?P<marker>' + re.escape(MARKER) + r')?'
r'let\{data:(?P<data>[\w$]+),isLoading:(?P<loading>[\w$]+)\}='
r'[\w$]+\([\w$]+\.NUX_2025_09_15\),\{authMethod:[\w$]+\}=[\w$]+\(\);'
r'if\(!(?P=loading)\)\{if\((?P=data)\)return`none`;switch\('
)
def patch_tour(extension, write):
matches = []
for path in (extension / 'webview/assets').glob('*.js'):
# Large locale files cannot contain the hook, and reading every locale
# on each reconciliation is needlessly expensive.
if not path.name.startswith(('app-initial-', 'index-')):
continue
text = path.read_text()
for match in HOOK.finditer(text):
tail = text[match.end():match.end() + 800]
if '`2025-09-15-full-chatgpt-auth`' in tail and '`2025-09-15-apikey-auth`' in tail:
matches.append((path, text, match))
if len(matches) != 1:
return {'state': 'unsupported', 'reason': 'Introductory tour hook changed upstream; left intact'}
path, text, match = matches[0]
if not match['marker']:
offset = text.index('{', match.start()) + 1
if path.read_text() != text:
raise ValueError('Webview bundle changed during update')
write(path, text[:offset] + MARKER + text[offset:])
return {'state': 'skipped', 'asset': path.name}
def restore_tour(extension, write):
for path in (extension / 'webview/assets').glob('*.js'):
if not path.name.startswith(('app-initial-', 'index-')):
continue
text = path.read_text()
if MARKER in text:
write(path, text.replace(MARKER, ''))