Overview
The handoff module provides utilities for constructing structured handoff objects that package worker results with comprehensive git diff statistics. These handoffs are the primary output format for worker tasks.Main Function
buildHandoff()
Constructs a complete handoff object with git diff statistics.
taskId- Unique identifier for the taskstatus- Task completion status ('complete','failed','partial')summary- Human-readable summary of what was accomplishedmetrics- Performance metrics object containing:tokensUsed- Total LLM tokens consumedtoolCallCount- Number of tool invocationsdurationMs- Task execution duration in milliseconds
Handoff object with git statistics merged in
Example Usage:
Git Diff Extraction
getGitDiffStat()
Internal function that extracts comprehensive statistics from git diff.
filesChanged- Array of file paths that were modifiedlinesAdded- Total lines added across all fileslinesRemoved- Total lines removed across all filesfilesCreated- Count of newly created filesfilesModified- Count of existing files that were modified
undefined if git operations fail.
Implementation Details:
- Get numstat for line counts:
- Detect new files:
- in numstat output and are handled gracefully:
Error Handling
Git Operation Failures
When git commands fail, the function handles it gracefully:getGitDiffStat() returns undefined, buildHandoff() provides:
Default Values:
Handoff Structure
The complete handoff object returned bybuildHandoff():
taskId- Matches the input task identifierstatus- Final task statussummary- Human-readable completion summarydiff- Full unified diff (populated elsewhere)filesChanged- List of all modified file pathsconcerns- Array of warnings or issues encounteredsuggestions- Recommended next steps or fixesmetrics- Combined performance and change metrics