Step 3: Extract Components
Objective
Find all component instances using patterns from Step 2 and add them to the graph via CLI.
Prerequisites
- Do not use plan mode. Execute directly.
- Read
.riviere/config/metadata.mdfor domains and conventions - Read
.riviere/config/component-definitions.mdfor extraction rules - CLI available (user will provide path)
Initialize Graph
Create graph with sources and domains:
riviere builder init \
--source "https://github.com/org/[repo-name]" \
--domain '{"name":"[name]","description":"[desc]","systemType":"domain"}'Add additional sources if needed:
riviere builder add-source --repository "https://github.com/org/[repo-name]"Add additional domains if needed:
riviere builder add-domain --name "[name]" --system-type "[domain|bff|ui|other]" --description "[desc]"Extract Components
No planning or counting. Extract directly using patterns from Step 2.
1. Find All Instances
For each component type, grep for its code signature:
# Examples - actual patterns come from Step 2
grep -rn "@Controller" src/
grep -rn "extends BaseUseCase" src/
grep -rn "@EventHandler" src/This gives file paths and line numbers for ALL occurrences.
2. Process Each Match
For each grep result:
- Read the file at that location
- Extract component details (name, domain, HTTP method, etc.)
- Add via CLI
riviere builder add-component \
--type "[API|UseCase|DomainOp|Event|EventHandler|UI|Custom]" \
--domain "[domain]" \
--module "[module]" \
--name "[name]" \
--repository "[repo]" \
--file-path "[path]" \
--line-number "[line]"Type-specific options:
- API:
--http-method,--path - DomainOp:
--entity,--operation-name - Event:
--event-name - EventHandler:
--subscribed-events - UI:
--route
3. Complete Each Type
Finish ALL matches for one component type before starting the next:
APIs (@Controller): 12 matches → 18 endpoints extracted
UseCases (extends BaseUseCase): 8 matches → 8 use cases extractedIf grep pattern doesn't work (e.g., complex dynamic patterns), note it and ask user if a script is needed.
Verify Extraction
Generate summary:
riviere builder component-summary --output ".riviere/step-3-summary.md"Check for:
- Domains with zero components
- Component types with zero instances
- Unexpected counts suggesting missed patterns
Offer to run a sub-agent to scan for components that may have been missed.
Feedback
If user reports missing components, update .riviere/config/component-definitions.md with corrected patterns and re-extract.
Output
Graph: .riviere/[project-name]-[commit].json
Completion
Present extraction summary showing component counts by domain and type.
Step 3 complete. Wait for user feedback before proceeding.