# Example: MapReduce workflow using command output as input
# This demonstrates using shell commands to generate work items
name: analyze-rust-files
mode: mapreduce
# Setup phase - runs once before map phase
setup:
- shell: "echo 'Starting analysis of Rust files...'"
- shell: "pwd | xargs -I {} echo 'Repository: {}'"
# Map phase - processes items in parallel
map:
# Use find command to generate list of Rust files
input: "find . -name '*.rs' -type f | head -20"
# Template for each parallel agent
agent_template:
- shell: echo "Analyzing ${item}"
- shell: |
wc -l "${item}" | awk '{print "Lines in " $2 ": " $1}'
# Run up to 5 agents in parallel
max_parallel: 5
# Timeout configuration (optional)
# Note: agent_timeout_secs can also be configured via timeout_config block
# See docs/examples.md Example 8 for full timeout_config syntax
timeout_config:
agent_timeout_secs: 30 # Maximum time per agent (seconds)
# Reduce phase - runs once after all map agents complete
reduce:
- shell: echo "Analysis complete. Results available in map.results"
- shell: echo "Total items processed"