src.detection.context_detector module#

Context Detection for Marcus Hybrid Approach.

Determines which Marcus mode would be most helpful based on board state, user interactions, and explicit preferences.

class src.detection.context_detector.MarcusMode[source]#

Bases: Enum

Available Marcus operating modes.

CREATOR = 'creator'#
ENRICHER = 'enricher'#
ADAPTIVE = 'adaptive'#
class src.detection.context_detector.UserIntent[source]#

Bases: Enum

Detected user intents from messages.

CREATE = 'create'#
ORGANIZE = 'organize'#
COORDINATE = 'coordinate'#
QUERY = 'query'#
UNKNOWN = 'unknown'#
class src.detection.context_detector.ModeRecommendation[source]#

Bases: object

Recommendation for which mode to use.

recommended_mode: MarcusMode#
confidence: float#
reasoning: str#
alternative_modes: List[MarcusMode]#
__init__(recommended_mode, confidence, reasoning, alternative_modes)#
Parameters:
Return type:

None

class src.detection.context_detector.UserContext[source]#

Bases: object

Context about the user’s recent interactions.

recent_messages: List[str]#
last_mode_switch: datetime | None#
mode_preferences: Dict[MarcusMode, int]#
current_mode: MarcusMode | None#
__init__(recent_messages, last_mode_switch, mode_preferences, current_mode)#
Parameters:
Return type:

None

class src.detection.context_detector.ContextDetector[source]#

Bases: object

Determines which Marcus mode would be most helpful.

INTENT_PATTERNS = {UserIntent.COORDINATE: ['assign', 'next.*task', 'who.*should', 'coordinate', 'ready.*for.*work', 'what.*should.*work'], UserIntent.CREATE: ['create.*project', 'new.*project', 'start.*from.*scratch', 'generate.*tasks', 'from.*prd', 'build.*mvp', 'need.*structure', 'empty.*board'], UserIntent.ORGANIZE: ['organize', 'structure', 'clean.*up', 'add.*metadata', 'enrich', 'improve.*board', 'mess', 'chaotic']}#
__init__(board_analyzer)[source]#
Parameters:

board_analyzer (BoardAnalyzer)

user_contexts: Dict[str, UserContext]#
async detect_optimal_mode(user_id, board_id, tasks, recent_message=None)[source]#

Decision tree for mode selection.

  1. Check board state

  2. Check recent user interactions

  3. Check explicit preferences

  4. Make recommendation

Parameters:
  • user_id (str) – User making the request.

  • board_id (str) – Board to analyze.

  • tasks (List[Task]) – Current tasks on the board.

  • recent_message (Optional[str]) – Most recent user message (if any).

Returns:

Mode recommendation with confidence.

Return type:

ModeRecommendation

async detect_user_intent(message)[source]#

Parse user messages for intent.

Parameters:

message (str) – User’s message.

Returns:

Detected intent.

Return type:

UserIntent

record_mode_switch(user_id, new_mode)[source]#

Record when a user switches modes.

Return type:

None

Parameters:
get_mode_suggestions(board_state)[source]#

Get helpful suggestions based on board state.

Return type:

List[str]

Parameters:

board_state (BoardState)