Skip to content

feat(flow): add support for new CrewAI Flow decorators (#40)#64

Open
cassiocouto wants to merge 1 commit intoTrusera:mainfrom
cassiocouto:feat/crewai-decorators
Open

feat(flow): add support for new CrewAI Flow decorators (#40)#64
cassiocouto wants to merge 1 commit intoTrusera:mainfrom
cassiocouto:feat/crewai-decorators

Conversation

@cassiocouto
Copy link

Summary

Implements Issue #40 — adds detection for CrewAI Flow decorators and class inheritance.

  • Config & regex patterns: Added @start, @listen, @router to CREWAI_FLOW_PATTERNS (config.py) and CrewAI usage_patterns (llm_patterns.py)
  • Flow class inheritance detection: New _detect_flow_classes method in the AST scanner that detects class MyFlow(Flow) with alias-resilient matching (handles Flow as BaseFlow, crewai.flow.Flow, etc.)
  • Flow relationship mapping: Enhanced _detect_decorators to extract @listen(...) / @router(...) arguments into metadata (listens_to, routes_from), supporting name refs, attribute refs (self.begin), string literals, and multiple arguments
  • Semantic usage type: Flow-specific detections use UsageType.orchestration instead of generic UsageType.agent for better reporting
  • Test fixture + 17 new tests: sample_crew_flow.py fixture and comprehensive TestCrewAIFlowDecorators class covering decorator detection, class inheritance (direct, aliased, attribute chain), relationship edge cases, and a full integration test

Files Changed

File Change
src/ai_bom/config.py Added @start, @listen, @router to CREWAI_FLOW_PATTERNS
src/ai_bom/detectors/llm_patterns.py Added regex patterns for new decorators
src/ai_bom/scanners/ast_scanner.py Added _detect_flow_classes, _collect_flow_aliases, _extract_decorator_refs; enhanced _detect_decorators
tests/fixtures/sample_crew_flow.py New realistic CrewAI Flow fixture
tests/test_detection_enhanced.py 17 new tests + updated existing assertions

Test plan

  • All 65 enhanced detection tests pass (tests/test_detection_enhanced.py)
  • Full test suite: 759 passed, 21 skipped (only pre-existing SARIF Windows path test fails, unrelated)
  • Ruff linting passes on all changed files

Closes #40

@cassiocouto cassiocouto requested a review from Zie619 as a code owner March 2, 2026 15:21
@cassiocouto cassiocouto force-pushed the feat/crewai-decorators branch from b538637 to c64719c Compare March 2, 2026 15:25
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.

Add support for new CrewAI Flow decorators

1 participant