|
10 | 10 | from typing import Optional |
11 | 11 |
|
12 | 12 | from cycode.cli.apps.ai_guardrails.consts import ( |
13 | | - CYCODE_MARKER, |
14 | 13 | CYCODE_SCAN_PROMPT_COMMAND, |
15 | 14 | DEFAULT_IDE, |
16 | 15 | IDE_CONFIGS, |
@@ -100,9 +99,6 @@ def install_hooks( |
100 | 99 | for entry in entries: |
101 | 100 | existing['hooks'][event].append(entry) |
102 | 101 |
|
103 | | - # Add marker |
104 | | - existing[CYCODE_MARKER] = True |
105 | | - |
106 | 102 | # Save |
107 | 103 | if save_hooks_file(hooks_path, existing): |
108 | 104 | return True, f'AI guardrails hooks installed: {hooks_path}' |
@@ -140,11 +136,6 @@ def uninstall_hooks( |
140 | 136 | if not existing['hooks'][event]: |
141 | 137 | del existing['hooks'][event] |
142 | 138 |
|
143 | | - # Remove marker |
144 | | - if CYCODE_MARKER in existing: |
145 | | - del existing[CYCODE_MARKER] |
146 | | - modified = True |
147 | | - |
148 | 139 | if not modified: |
149 | 140 | return True, 'No Cycode hooks found to remove' |
150 | 141 |
|
@@ -190,17 +181,20 @@ def get_hooks_status(scope: str = 'user', repo_path: Optional[Path] = None, ide: |
190 | 181 | if existing is None: |
191 | 182 | return status |
192 | 183 |
|
193 | | - status['cycode_installed'] = existing.get(CYCODE_MARKER, False) |
194 | | - |
195 | 184 | # Check each hook event for this IDE |
196 | 185 | ide_config = IDE_CONFIGS[ide] |
| 186 | + has_cycode_hooks = False |
197 | 187 | for event in ide_config.hook_events: |
198 | 188 | entries = existing.get('hooks', {}).get(event, []) |
199 | 189 | cycode_entries = [e for e in entries if is_cycode_hook_entry(e)] |
| 190 | + if cycode_entries: |
| 191 | + has_cycode_hooks = True |
200 | 192 | status['hooks'][event] = { |
201 | 193 | 'total_entries': len(entries), |
202 | 194 | 'cycode_entries': len(cycode_entries), |
203 | 195 | 'enabled': len(cycode_entries) > 0, |
204 | 196 | } |
205 | 197 |
|
| 198 | + status['cycode_installed'] = has_cycode_hooks |
| 199 | + |
206 | 200 | return status |
0 commit comments