Skip to content

Commit 14afe21

Browse files
committed
CM-58022 skip scan configuration fetching for prompt command
1 parent 4ecb761 commit 14afe21

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

cycode/cli/apps/scan/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
_AI_GUARDRAILS_RICH_HELP_PANEL = 'AI Guardrails commands'
4848

4949
app.command(
50+
hidden=True,
5051
name='prompt',
5152
short_help='Handle AI guardrails hooks from supported IDEs (reads JSON from stdin).',
5253
rich_help_panel=_AI_GUARDRAILS_RICH_HELP_PANEL,

cycode/cli/apps/scan/prompt/prompt_command.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from cycode.cli.apps.scan.prompt.response_builders import get_response_builder
2121
from cycode.cli.apps.scan.prompt.types import AiHookEventType
2222
from cycode.cli.apps.scan.prompt.utils import output_json, safe_json_parse
23-
from cycode.cli.utils.get_api_client import get_ai_security_manager_client
23+
from cycode.cli.utils.get_api_client import get_ai_security_manager_client, get_scan_cycode_client
2424
from cycode.cli.utils.sentry import add_breadcrumb
2525
from cycode.logger import get_logger
2626

@@ -52,17 +52,11 @@ def prompt_command(
5252
"""
5353
add_breadcrumb('prompt')
5454

55-
# Initialize AI Security Manager client
56-
ai_security_client = get_ai_security_manager_client(ctx)
57-
ctx.obj['ai_security_client'] = ai_security_client
58-
5955
# Read JSON payload from stdin
6056
stdin_data = sys.stdin.read().strip()
6157
payload = safe_json_parse(stdin_data)
6258

6359
tool = ide.lower()
64-
65-
# Get response builder for this IDE
6660
response_builder = get_response_builder(tool)
6761

6862
if not payload:
@@ -77,6 +71,12 @@ def prompt_command(
7771
event_name = unified_payload.event_name
7872
logger.debug('Processing AI guardrails hook', extra={'event_name': event_name, 'tool': tool})
7973

74+
scan_client = get_scan_cycode_client(ctx)
75+
ctx.obj['client'] = scan_client
76+
77+
ai_security_client = get_ai_security_manager_client(ctx)
78+
ctx.obj['ai_security_client'] = ai_security_client
79+
8080
# Load policy (merges defaults <- user config <- repo config)
8181
# Extract first workspace root from payload if available
8282
workspace_roots = payload.get('workspace_roots', ['.'])

cycode/cli/apps/scan/scan_command.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ def scan_command(
160160
ctx.obj['gradle_all_sub_projects'] = gradle_all_sub_projects
161161
ctx.obj['no_restore'] = no_restore
162162

163+
# Skip standard scan initialization for prompt command.
164+
# Prompt command handles its own authentication and doesn't need scan configuration
165+
if ctx.invoked_subcommand == 'prompt':
166+
return
167+
163168
scan_client = get_scan_cycode_client(ctx)
164169
ctx.obj['client'] = scan_client
165170

0 commit comments

Comments
 (0)