Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cycode/cli/apps/ai_guardrails/ides/claude_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def render_hooks_config(self, async_mode: bool = False) -> dict:
'hooks': {
'SessionStart': [
{
'matcher': 'startup|clear',
'hooks': [{'type': 'command', 'command': _SESSION_START_COMMAND}],
}
],
Expand Down
1 change: 0 additions & 1 deletion cycode/cli/apps/ai_guardrails/ides/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def render_hooks_config(self, async_mode: bool = False) -> dict:
'hooks': {
'SessionStart': [
{
'matcher': 'startup|clear',
'hooks': [{'type': 'command', 'command': _SESSION_START_COMMAND}],
}
],
Expand Down
7 changes: 4 additions & 3 deletions tests/cli/commands/ai_guardrails/ides/test_codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ def test_settings_path_honors_codex_home_env(fs: FakeFilesystem, monkeypatch: py
# --- hooks config rendering --------------------------------------------------


def test_render_hooks_session_start_matcher_includes_clear() -> None:
"""SessionStart must fire on /clear too (conversation_id rotates)."""
def test_render_hooks_session_start_matches_all_sources() -> None:
"""SessionStart must fire on every source (a forked session reports 'resume',
so no matcher is set -> match-all)."""
rendered = Codex().render_hooks_config()
assert rendered['hooks']['SessionStart'][0]['matcher'] == 'startup|clear'
assert 'matcher' not in rendered['hooks']['SessionStart'][0]
assert '--ide codex' in rendered['hooks']['SessionStart'][0]['hooks'][0]['command']


Expand Down
5 changes: 3 additions & 2 deletions tests/cli/commands/ai_guardrails/test_hooks_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ def test_claude_code_render_hooks_async() -> None:


def test_claude_code_render_hooks_session_start() -> None:
"""Claude Code SessionStart fires on startup and /clear."""
"""Claude Code SessionStart fires on every source (a forked session reports
'resume', so the matcher is empty -> match-all)."""
config = ClaudeCode().render_hooks_config()
entries = config['hooks']['SessionStart']
assert len(entries) == 1
assert entries[0]['matcher'] == 'startup|clear'
assert 'matcher' not in entries[0]
assert CYCODE_SESSION_START_COMMAND in entries[0]['hooks'][0]['command']
assert '--ide claude-code' in entries[0]['hooks'][0]['command']

Expand Down
Loading