@@ -10,68 +10,102 @@ inputs:
1010 default : " ."
1111 required : false
1212
13+ staged_only :
14+ type : bool
15+ description : If true, only analyze staged changes (default). Set false to include unstaged/untracked.
16+ default : true
17+ required : false
18+
1319blocks :
14- - id : changes
20+ - id : get_staged_summary
1521 type : Shell
22+ description : " Get diff statistics for staged changes"
1623 inputs :
17- command : |
18- # Check for any changes: staged, unstaged, or untracked
19- if [ -z "$(git status --porcelain)" ]; then
20- printf "false" > $SCRATCH/changes.txt
21- else
22- printf "true" > $SCRATCH/changes.txt
23- fi
24+ command : git diff --cached --stat --compact-summary > $SCRATCH/summary.txt
2425 working_dir : " ${inputs.working_dir}"
25- outputs :
26- detected :
27- type : bool
28- description : " Indicates if there are any changes (staged, unstaged, or untracked)"
29- path : " $SCRATCH/changes.txt"
26+ condition : " ${inputs.staged_only}"
3027
31- - id : get_file_status
28+ - id : get_staged_diff
3229 type : Shell
30+ description : " Generate compact diff of staged changes"
3331 inputs :
34- command : git status --short --porcelain
32+ command : git diff --cached -U0 --inter-hunk-context=0 --no-color --no-prefix > $SCRATCH/raw_diff.txt
3533 working_dir : " ${inputs.working_dir}"
36- condition : ${blocks.changes.outputs.detected}
37- depends_on :
38- - changes
34+ condition : " ${inputs.staged_only}"
3935
40- - id : get_staged_diff
36+ - id : get_all_summary
4137 type : Shell
38+ description : " Get diff statistics for all changes (staged + unstaged)"
4239 inputs :
43- command : git diff --cached
40+ command : git diff HEAD --stat --compact-summary > $SCRATCH/summary.txt
4441 working_dir : " ${inputs.working_dir}"
45- condition : ${blocks.changes.outputs.detected}
46- depends_on :
47- - changes
42+ condition : " not ${inputs.staged_only}"
4843
49- - id : get_unstaged_diff
44+ - id : get_all_diff
5045 type : Shell
46+ description : " Generate compact diff of all changes (staged + unstaged)"
5147 inputs :
52- command : git diff
48+ command : |
49+ git diff HEAD -U0 --inter-hunk-context=0 --no-color --no-prefix > $SCRATCH/raw_diff.txt
5350 working_dir : " ${inputs.working_dir}"
54- condition : ${blocks.changes.outputs.detected}
55- depends_on :
56- - changes
51+ condition : " not ${inputs.staged_only}"
5752
58- - id : get_diff_stat
53+ - id : processing
5954 type : Shell
55+ description : " Process and consolidate analysis results"
6056 inputs :
6157 command : |
62- echo "=== Staged Changes ==="
63- git diff --cached --stat || echo "No staged changes"
64- echo ""
65- echo "=== Unstaged Changes ==="
66- git diff --stat || echo "No unstaged changes"
58+ MAX_LINES=40
59+
60+ # Process raw diff with line limiting
61+ if [ -f "$SCRATCH/raw_diff.txt" ]; then
62+ awk -v max="$MAX_LINES" '
63+ BEGIN { lines = 0; truncated = 0 }
64+ /^diff --git/ {
65+ if (truncated) {
66+ print " ... (truncated " truncated " lines)\n"
67+ }
68+ lines = 0
69+ truncated = 0
70+ print
71+ next
72+ }
73+ {
74+ if (lines < max) {
75+ print
76+ lines++
77+ } else {
78+ truncated++
79+ }
80+ }
81+ END {
82+ if (truncated) {
83+ print " ... (truncated " truncated " lines)"
84+ }
85+ }
86+ ' "$SCRATCH/raw_diff.txt" > "$SCRATCH/processed_diff.txt"
87+ else
88+ touch "$SCRATCH/processed_diff.txt"
89+ fi
6790 working_dir : " ${inputs.working_dir}"
68- condition : ${blocks.changes.outputs.detected}
6991 depends_on :
70- - changes
92+ - block : get_staged_summary
93+ required : false
94+ - block : get_staged_diff
95+ required : false
96+ - block : get_all_summary
97+ required : false
98+ - block : get_all_diff
99+ required : false
100+ outputs :
101+ summary :
102+ type : str
103+ path : " $SCRATCH/summary.txt"
104+ diff :
105+ type : str
106+ path : " $SCRATCH/processed_diff.txt"
71107
72108outputs :
73- has_changes : " ${blocks.changes.outputs.detected}"
74- file_status : " ${blocks.get_file_status.outputs.stdout}"
75- staged_diff : " ${blocks.get_staged_diff.outputs.stdout}"
76- unstaged_diff : " ${blocks.get_unstaged_diff.outputs.stdout}"
77- diff_stat : " ${blocks.get_diff_stat.outputs.stdout}"
109+ has_changes : " ${blocks.get_staged_diff.succeeded} or ${blocks.get_all_diff.succeeded}"
110+ summary : " ${blocks.processing.outputs.summary}"
111+ diff : " ${blocks.processing.outputs.diff}"
0 commit comments