mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
This commit addresses the remaining Minor issues from PR #94 code review: Minor #12: Unicode Symbol Compatibility - Added CODEAGENT_ASCII_MODE environment variable support - When set to "true", uses ASCII symbols: PASS/WARN/FAIL - Default behavior (unset or "false"): Unicode symbols ✓/⚠️/✗ - Updated help text to document the environment variable - Added tests for both ASCII and Unicode modes Implementation: - executor.go:514: New getStatusSymbols() function - executor.go:531: Dynamic symbol selection in generateFinalOutputWithMode - main.go:34: useASCIIMode variable declaration - main.go:495: Environment variable documentation in help - executor_concurrent_test.go:292: Tests for ASCII mode - main_integration_test.go:89: Parser updated for both symbol formats Minor #13: Performance Optimization - Reduce Repeated String Operations - Optimized Message parsing to split only once per task result - Added *FromLines() variants of all extractor functions - Original extract*() functions now wrap *FromLines() for compatibility - Reduces memory allocations and CPU usage in parallel execution Implementation: - utils.go:300: extractCoverageFromLines() - utils.go:390: extractFilesChangedFromLines() - utils.go:455: extractTestResultsFromLines() - utils.go:551: extractKeyOutputFromLines() - main.go:255: Single split with reuse: lines := strings.Split(...) Backward Compatibility: - All original extract*() functions preserved - Tests updated to handle both symbol formats - No breaking changes to public API Test Results: - All tests pass: go test ./... (40.164s) - ASCII mode verified: PASS/WARN/FAIL symbols display correctly - Unicode mode verified: ✓/⚠️/✗ symbols remain default - Performance: Single split per Message instead of 4+ Usage Examples: # Unicode mode (default) ./codeagent-wrapper --parallel < tasks.txt # ASCII mode (for terminals without Unicode support) CODEAGENT_ASCII_MODE=true ./codeagent-wrapper --parallel < tasks.txt Benefits: - Improved terminal compatibility across different environments - Reduced memory allocations in parallel execution - Better performance for large-scale parallel tasks - User choice between Unicode aesthetics and ASCII compatibility Related: #94 Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
This commit is contained in:
@@ -511,6 +511,14 @@ func shouldSkipTask(task TaskSpec, failed map[string]TaskResult) (bool, string)
|
||||
return true, fmt.Sprintf("skipped due to failed dependencies: %s", strings.Join(blocked, ","))
|
||||
}
|
||||
|
||||
// getStatusSymbols returns status symbols based on ASCII mode.
|
||||
func getStatusSymbols() (success, warning, failed string) {
|
||||
if os.Getenv("CODEAGENT_ASCII_MODE") == "true" {
|
||||
return "PASS", "WARN", "FAIL"
|
||||
}
|
||||
return "✓", "⚠️", "✗"
|
||||
}
|
||||
|
||||
func generateFinalOutput(results []TaskResult) string {
|
||||
return generateFinalOutputWithMode(results, true) // default to summary mode
|
||||
}
|
||||
@@ -520,6 +528,7 @@ func generateFinalOutput(results []TaskResult) string {
|
||||
// summaryOnly=false: full output with complete messages (legacy behavior)
|
||||
func generateFinalOutputWithMode(results []TaskResult, summaryOnly bool) string {
|
||||
var sb strings.Builder
|
||||
successSymbol, warningSymbol, failedSymbol := getStatusSymbols()
|
||||
|
||||
reportCoverageTarget := defaultCoverageTarget
|
||||
for _, res := range results {
|
||||
@@ -577,7 +586,7 @@ func generateFinalOutputWithMode(results []TaskResult, summaryOnly bool) string
|
||||
|
||||
if isSuccess && !isBelowTarget {
|
||||
// Passed task: one block with Did/Files/Tests
|
||||
sb.WriteString(fmt.Sprintf("\n### %s ✓", taskID))
|
||||
sb.WriteString(fmt.Sprintf("\n### %s %s", taskID, successSymbol))
|
||||
if coverage != "" {
|
||||
sb.WriteString(fmt.Sprintf(" %s", coverage))
|
||||
}
|
||||
@@ -598,7 +607,7 @@ func generateFinalOutputWithMode(results []TaskResult, summaryOnly bool) string
|
||||
|
||||
} else if isSuccess && isBelowTarget {
|
||||
// Below target: add Gap info
|
||||
sb.WriteString(fmt.Sprintf("\n### %s ⚠️ %s (below %.0f%%)\n", taskID, coverage, target))
|
||||
sb.WriteString(fmt.Sprintf("\n### %s %s %s (below %.0f%%)\n", taskID, warningSymbol, coverage, target))
|
||||
|
||||
if keyOutput != "" {
|
||||
sb.WriteString(fmt.Sprintf("Did: %s\n", keyOutput))
|
||||
@@ -620,7 +629,7 @@ func generateFinalOutputWithMode(results []TaskResult, summaryOnly bool) string
|
||||
|
||||
} else {
|
||||
// Failed task: show error detail
|
||||
sb.WriteString(fmt.Sprintf("\n### %s ✗ FAILED\n", taskID))
|
||||
sb.WriteString(fmt.Sprintf("\n### %s %s FAILED\n", taskID, failedSymbol))
|
||||
sb.WriteString(fmt.Sprintf("Exit code: %d\n", res.ExitCode))
|
||||
if errText := sanitizeOutput(res.Error); errText != "" {
|
||||
sb.WriteString(fmt.Sprintf("Error: %s\n", errText))
|
||||
|
||||
Reference in New Issue
Block a user