computeBashCommandsDiff builds bash-specific analysis from pre-filtered bash tool call maps. The maps should contain only bash-related entries (generic "bash"/"Bash" and per-command "bash_*"). Returns nil when no bash tool calls are present in either map.
(run1Tools, run2Tools map[string]ToolCallInfo)
| 732 | // The maps should contain only bash-related entries (generic "bash"/"Bash" and per-command "bash_*"). |
| 733 | // Returns nil when no bash tool calls are present in either map. |
| 734 | func computeBashCommandsDiff(run1Tools, run2Tools map[string]ToolCallInfo) *BashCommandsDiff { |
| 735 | allNames := make(map[string]struct{}) |
| 736 | for k := range run1Tools { |
| 737 | allNames[k] = struct{}{} |
| 738 | } |
| 739 | for k := range run2Tools { |
| 740 | allNames[k] = struct{}{} |
| 741 | } |
| 742 | |
| 743 | if len(allNames) == 0 { |
| 744 | return nil |
| 745 | } |
| 746 | |
| 747 | sortedNames := sliceutil.SortedKeys(allNames) |
| 748 | |
| 749 | bashDiff := &BashCommandsDiff{} |
| 750 | for _, name := range sortedNames { |
| 751 | tc1 := run1Tools[name] |
| 752 | tc2 := run2Tools[name] |
| 753 | bashDiff.Run1TotalCalls += tc1.CallCount |
| 754 | bashDiff.Run2TotalCalls += tc2.CallCount |
| 755 | |
| 756 | var status string |
| 757 | switch { |
| 758 | case tc1.CallCount == 0 && tc2.CallCount > 0: |
| 759 | status = "new" |
| 760 | case tc1.CallCount > 0 && tc2.CallCount == 0: |
| 761 | status = "removed" |
| 762 | case tc1.CallCount != tc2.CallCount: |
| 763 | status = "changed" |
| 764 | default: |
| 765 | status = "unchanged" |
| 766 | } |
| 767 | |
| 768 | cmd := ToolCallDiffEntry{ |
| 769 | Name: name, |
| 770 | Status: status, |
| 771 | Run1CallCount: tc1.CallCount, |
| 772 | Run2CallCount: tc2.CallCount, |
| 773 | Run1MaxInputSize: tc1.MaxInputSize, |
| 774 | Run2MaxInputSize: tc2.MaxInputSize, |
| 775 | Run1MaxOutputSize: tc1.MaxOutputSize, |
| 776 | Run2MaxOutputSize: tc2.MaxOutputSize, |
| 777 | } |
| 778 | if tc1.CallCount != tc2.CallCount { |
| 779 | cmd.CallCountChange = formatCountChange(tc1.CallCount, tc2.CallCount) |
| 780 | } |
| 781 | bashDiff.Commands = append(bashDiff.Commands, cmd) |
| 782 | } |
| 783 | |
| 784 | if bashDiff.Run1TotalCalls > 0 || bashDiff.Run2TotalCalls > 0 { |
| 785 | bashDiff.TotalCallsChange = formatCountChange(bashDiff.Run1TotalCalls, bashDiff.Run2TotalCalls) |
| 786 | } |
| 787 | |
| 788 | return bashDiff |
| 789 | } |
| 790 | |
| 791 | // computeGitHubRateLimitDiff computes the diff of GitHub API quota consumption between two |