Skip to content

CM-62381-add-session-start-hook#434

Open
RoniCycode wants to merge 1 commit intomainfrom
CM-62381-refactor-ensure-auth-command
Open

CM-62381-add-session-start-hook#434
RoniCycode wants to merge 1 commit intomainfrom
CM-62381-refactor-ensure-auth-command

Conversation

@RoniCycode
Copy link
Copy Markdown
Collaborator

  • Change "ensure-auth" to "session-start" which includes conversation creation and MCP usage checks (once per session)

def _build_session_payload(payload: dict, ide: str) -> AIHookPayload:
"""Build an AIHookPayload from a session-start stdin payload."""
if ide == AIIDEType.CLAUDE_CODE:
ide_version, model, _ = _extract_from_claude_transcript(payload.get('transcript_path'))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably get rid of _extract_from_claude_transcript now, i created it because other hooks didn't provide the model, as far as i know session start provides the model in stdin
Regarding ide_version, do we have it in stdin / claude.json file?

ide_user_email = get_user_email(claude_config) if claude_config else None

return AIHookPayload(
event_name='session_start',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need - its not used later when creating conversation

except Exception as e:
logger.debug('Failed to create conversation during session start', exc_info=e)

# Step 5: Report data flow (MCP servers, Claude Code only)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should handle cursor too, also extract to func


_CONVERSATIONS_PATH = 'v4/ai-security/interactions/conversations'
_EVENTS_PATH = 'v4/ai-security/interactions/events'
_DATA_FLOW_PATH = 'v4/ai-security/interactions/data-flow'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont know if i like that route name

Comment on lines +71 to +75
# Step 2: Read stdin payload (backward compat: old hooks pipe no stdin)
if sys.stdin.isatty():
logger.debug('No stdin payload (TTY), skipping session initialization')
return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants