Skip to content

Commit 971ffbb

Browse files
committed
fix more docs and do some renaming for clarification
1 parent c6f2a59 commit 971ffbb

File tree

8 files changed

+52
-52
lines changed

8 files changed

+52
-52
lines changed

pkg/cli/copilot_agent.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,69 +12,69 @@ import (
1212
"github.com/github/gh-aw/pkg/workflow"
1313
)
1414

15-
var copilotAgentLog = logger.New("cli:copilot_agent")
15+
var copilotCodingAgentLog = logger.New("cli:copilot_agent")
1616

17-
// CopilotAgentDetector contains heuristics to detect if a workflow run was executed by GitHub Copilot coding agent
18-
type CopilotAgentDetector struct {
17+
// CopilotCodingAgentDetector contains heuristics to detect if a workflow run was executed by GitHub Copilot coding agent
18+
type CopilotCodingAgentDetector struct {
1919
runDir string
2020
verbose bool
2121
workflowPath string // Optional: workflow file path from GitHub API (e.g., .github/workflows/copilot-swe-agent.yml)
2222
}
2323

24-
// NewCopilotAgentDetector creates a new detector for GitHub Copilot coding agent runs
25-
func NewCopilotAgentDetector(runDir string, verbose bool) *CopilotAgentDetector {
26-
return &CopilotAgentDetector{
24+
// NewCopilotCodingAgentDetector creates a new detector for GitHub Copilot coding agent runs
25+
func NewCopilotCodingAgentDetector(runDir string, verbose bool) *CopilotCodingAgentDetector {
26+
return &CopilotCodingAgentDetector{
2727
runDir: runDir,
2828
verbose: verbose,
2929
}
3030
}
3131

32-
// NewCopilotAgentDetectorWithPath creates a detector with workflow path hint
33-
func NewCopilotAgentDetectorWithPath(runDir string, verbose bool, workflowPath string) *CopilotAgentDetector {
34-
return &CopilotAgentDetector{
32+
// NewCopilotCodingAgentDetectorWithPath creates a detector with workflow path hint
33+
func NewCopilotCodingAgentDetectorWithPath(runDir string, verbose bool, workflowPath string) *CopilotCodingAgentDetector {
34+
return &CopilotCodingAgentDetector{
3535
runDir: runDir,
3636
verbose: verbose,
3737
workflowPath: workflowPath,
3838
}
3939
}
4040

41-
// IsGitHubCopilotAgent uses heuristics to determine if this run was executed by GitHub Copilot coding agent
41+
// IsGitHubCopilotCodingAgent uses heuristics to determine if this run was executed by GitHub Copilot coding agent
4242
// (not the Copilot CLI engine or agentic workflows)
43-
func (d *CopilotAgentDetector) IsGitHubCopilotAgent() bool {
44-
copilotAgentLog.Printf("Detecting if run is GitHub Copilot coding agent: %s", d.runDir)
43+
func (d *CopilotCodingAgentDetector) IsGitHubCopilotCodingAgent() bool {
44+
copilotCodingAgentLog.Printf("Detecting if run is GitHub Copilot coding agent: %s", d.runDir)
4545

4646
// If aw_info.json exists, this is an agentic workflow, NOT a GitHub Copilot coding agent run
4747
awInfoPath := filepath.Join(d.runDir, "aw_info.json")
4848
if _, err := os.Stat(awInfoPath); err == nil {
49-
copilotAgentLog.Print("Found aw_info.json - this is an agentic workflow, not a GitHub Copilot coding agent")
49+
copilotCodingAgentLog.Print("Found aw_info.json - this is an agentic workflow, not a GitHub Copilot coding agent")
5050
return false
5151
}
5252

5353
// Heuristic 1: Check workflow path if provided (most reliable hint from GitHub API)
5454
if d.hasAgentWorkflowPath() {
55-
copilotAgentLog.Print("Detected copilot-swe-agent in workflow path")
55+
copilotCodingAgentLog.Print("Detected copilot-swe-agent in workflow path")
5656
return true
5757
}
5858

5959
// Heuristic 2: Check for agent-specific log patterns
6060
if d.hasAgentLogPatterns() {
61-
copilotAgentLog.Print("Detected agent log patterns")
61+
copilotCodingAgentLog.Print("Detected agent log patterns")
6262
return true
6363
}
6464

6565
// Heuristic 3: Check for agent-specific artifacts
6666
if d.hasAgentArtifacts() {
67-
copilotAgentLog.Print("Detected agent artifacts")
67+
copilotCodingAgentLog.Print("Detected agent artifacts")
6868
return true
6969
}
7070

71-
copilotAgentLog.Print("No GitHub Copilot coding agent indicators found")
71+
copilotCodingAgentLog.Print("No GitHub Copilot coding agent indicators found")
7272
return false
7373
}
7474

7575
// hasAgentWorkflowPath checks if the workflow path indicates a Copilot coding agent run
7676
// The workflow ID is always "copilot-swe-agent" for GitHub Copilot coding agent runs
77-
func (d *CopilotAgentDetector) hasAgentWorkflowPath() bool {
77+
func (d *CopilotCodingAgentDetector) hasAgentWorkflowPath() bool {
7878
if d.workflowPath == "" {
7979
return false
8080
}
@@ -97,7 +97,7 @@ func (d *CopilotAgentDetector) hasAgentWorkflowPath() bool {
9797
}
9898

9999
// hasAgentLogPatterns checks log files for patterns specific to GitHub Copilot coding agent
100-
func (d *CopilotAgentDetector) hasAgentLogPatterns() bool {
100+
func (d *CopilotCodingAgentDetector) hasAgentLogPatterns() bool {
101101
// Patterns that indicate GitHub Copilot coding agent (not Copilot CLI)
102102
agentPatterns := []*regexp.Regexp{
103103
regexp.MustCompile(`(?i)github.*copilot.*agent`),
@@ -141,7 +141,7 @@ func (d *CopilotAgentDetector) hasAgentLogPatterns() bool {
141141
}
142142

143143
// hasAgentArtifacts checks for artifacts specific to GitHub Copilot coding agent runs
144-
func (d *CopilotAgentDetector) hasAgentArtifacts() bool {
144+
func (d *CopilotCodingAgentDetector) hasAgentArtifacts() bool {
145145
// Check for agent-specific artifact patterns
146146
agentArtifacts := []string{
147147
"copilot-agent-output",
@@ -180,10 +180,10 @@ func readLogHeader(path string, maxBytes int) (string, error) {
180180
return string(buffer[:n]), nil
181181
}
182182

183-
// ParseCopilotAgentLogMetrics extracts metrics from GitHub Copilot coding agent logs
183+
// ParseCopilotCodingAgentLogMetrics extracts metrics from GitHub Copilot coding agent logs
184184
// This is different from Copilot CLI logs and requires specialized parsing
185-
func ParseCopilotAgentLogMetrics(logContent string, verbose bool) workflow.LogMetrics {
186-
copilotAgentLog.Printf("Parsing GitHub Copilot coding agent log metrics: %d bytes", len(logContent))
185+
func ParseCopilotCodingAgentLogMetrics(logContent string, verbose bool) workflow.LogMetrics {
186+
copilotCodingAgentLog.Printf("Parsing GitHub Copilot coding agent log metrics: %d bytes", len(logContent))
187187

188188
var metrics workflow.LogMetrics
189189
var maxTokenUsage int
@@ -231,7 +231,7 @@ func ParseCopilotAgentLogMetrics(logContent string, verbose bool) workflow.LogMe
231231
currentSequence = append(currentSequence, toolName)
232232

233233
if verbose {
234-
copilotAgentLog.Printf("Found tool call: %s", toolName)
234+
copilotCodingAgentLog.Printf("Found tool call: %s", toolName)
235235
}
236236
}
237237
}
@@ -261,7 +261,7 @@ func ParseCopilotAgentLogMetrics(logContent string, verbose bool) workflow.LogMe
261261
metrics.TokenUsage = maxTokenUsage
262262
metrics.Turns = turns
263263

264-
copilotAgentLog.Printf("Parsed metrics: tokens=%d, cost=$%.4f, turns=%d",
264+
copilotCodingAgentLog.Printf("Parsed metrics: tokens=%d, cost=$%.4f, turns=%d",
265265
metrics.TokenUsage, metrics.EstimatedCost, metrics.Turns)
266266

267267
return metrics

pkg/cli/copilot_agent_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/github/gh-aw/pkg/logger"
1212
)
1313

14-
func TestCopilotAgentDetector_IsGitHubCopilotAgent(t *testing.T) {
14+
func TestCopilotCodingAgentDetector_IsGitHubCopilotCodingAgent(t *testing.T) {
1515
tests := []struct {
1616
name string
1717
setupFunc func(string) error
@@ -111,13 +111,13 @@ func TestCopilotAgentDetector_IsGitHubCopilotAgent(t *testing.T) {
111111
}
112112

113113
// Run detector with workflow path if provided
114-
var detector *CopilotAgentDetector
114+
var detector *CopilotCodingAgentDetector
115115
if tt.workflowPath != "" {
116-
detector = NewCopilotAgentDetectorWithPath(tmpDir, false, tt.workflowPath)
116+
detector = NewCopilotCodingAgentDetectorWithPath(tmpDir, false, tt.workflowPath)
117117
} else {
118-
detector = NewCopilotAgentDetector(tmpDir, false)
118+
detector = NewCopilotCodingAgentDetector(tmpDir, false)
119119
}
120-
result := detector.IsGitHubCopilotAgent()
120+
result := detector.IsGitHubCopilotCodingAgent()
121121

122122
if result != tt.expectedResult {
123123
t.Errorf("Expected %v, got %v", tt.expectedResult, result)
@@ -126,7 +126,7 @@ func TestCopilotAgentDetector_IsGitHubCopilotAgent(t *testing.T) {
126126
}
127127
}
128128

129-
func TestParseCopilotAgentLogMetrics(t *testing.T) {
129+
func TestParseCopilotCodingAgentLogMetrics(t *testing.T) {
130130
tests := []struct {
131131
name string
132132
logContent string
@@ -189,7 +189,7 @@ Task step 1 complete
189189

190190
for _, tt := range tests {
191191
t.Run(tt.name, func(t *testing.T) {
192-
metrics := ParseCopilotAgentLogMetrics(tt.logContent, false)
192+
metrics := ParseCopilotCodingAgentLogMetrics(tt.logContent, false)
193193

194194
if tt.expectedTurns > 0 && metrics.Turns != tt.expectedTurns {
195195
t.Errorf("Expected %d turns, got %d", tt.expectedTurns, metrics.Turns)
@@ -288,7 +288,7 @@ func TestExtractErrorMessage(t *testing.T) {
288288
}
289289
}
290290

291-
func TestIntegration_CopilotAgentWithAudit(t *testing.T) {
291+
func TestIntegration_CopilotCodingAgentWithAudit(t *testing.T) {
292292
// Create a temporary directory that simulates a GitHub Copilot coding agent run
293293
// NOTE: GitHub Copilot coding agent runs do NOT have aw_info.json (that's for agentic workflows)
294294
tmpDir, err := os.MkdirTemp("", "copilot-agent-integration-*")
@@ -314,8 +314,8 @@ Tool call: github_create_pr
314314
}
315315

316316
// Verify detector recognizes this as a GitHub Copilot coding agent run (no aw_info.json)
317-
detector := NewCopilotAgentDetector(tmpDir, false)
318-
if !detector.IsGitHubCopilotAgent() {
317+
detector := NewCopilotCodingAgentDetector(tmpDir, false)
318+
if !detector.IsGitHubCopilotCodingAgent() {
319319
t.Error("Expected GitHub Copilot coding agent to be detected from log patterns")
320320
}
321321

@@ -372,7 +372,7 @@ Task iteration 1
372372
Tool call: github
373373
ERROR: Test error
374374
`
375-
metrics := ParseCopilotAgentLogMetrics(logContent, false)
375+
metrics := ParseCopilotCodingAgentLogMetrics(logContent, false)
376376

377377
// Verify the returned type is workflow.LogMetrics
378378
var _ = metrics

pkg/cli/logs_metrics.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ func extractLogMetrics(logDir string, verbose bool, workflowPath ...string) (Log
4242
}
4343

4444
// First check if this is a GitHub Copilot coding agent run (not Copilot CLI)
45-
var detector *CopilotAgentDetector
45+
var detector *CopilotCodingAgentDetector
4646
if len(workflowPath) > 0 && workflowPath[0] != "" {
47-
detector = NewCopilotAgentDetectorWithPath(logDir, verbose, workflowPath[0])
47+
detector = NewCopilotCodingAgentDetectorWithPath(logDir, verbose, workflowPath[0])
4848
} else {
49-
detector = NewCopilotAgentDetector(logDir, verbose)
49+
detector = NewCopilotCodingAgentDetector(logDir, verbose)
5050
}
51-
isGitHubCopilotAgent := detector.IsGitHubCopilotAgent()
52-
logsMetricsLog.Printf("GitHub Copilot coding agent detected: %v", isGitHubCopilotAgent)
51+
isGitHubCopilotCodingAgent := detector.IsGitHubCopilotCodingAgent()
52+
logsMetricsLog.Printf("GitHub Copilot coding agent detected: %v", isGitHubCopilotCodingAgent)
5353

54-
if isGitHubCopilotAgent && verbose {
54+
if isGitHubCopilotCodingAgent && verbose {
5555
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Detected GitHub Copilot coding agent run, using specialized parser"))
5656
}
5757

@@ -143,7 +143,7 @@ func extractLogMetrics(logDir string, verbose bool, workflowPath ...string) (Log
143143
!strings.Contains(fileName, "aw_output") &&
144144
fileName != constants.AgentOutputFilename {
145145

146-
fileMetrics, err := parseLogFileWithEngine(path, detectedEngine, isGitHubCopilotAgent, verbose)
146+
fileMetrics, err := parseLogFileWithEngine(path, detectedEngine, isGitHubCopilotCodingAgent, verbose)
147147
if err != nil && verbose {
148148
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to parse log file %s: %v", path, err)))
149149
return nil // Continue processing other files

pkg/cli/logs_parsing_engines.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
var logsParsingEnginesLog = logger.New("cli:logs_parsing_engines")
2222

2323
// parseLogFileWithEngine parses a log file using a specific engine or falls back to auto-detection
24-
func parseLogFileWithEngine(filePath string, detectedEngine workflow.CodingAgentEngine, isGitHubCopilotAgent bool, verbose bool) (LogMetrics, error) {
25-
logsParsingEnginesLog.Printf("Parsing log file: %s, isGitHubCopilotAgent=%v", filePath, isGitHubCopilotAgent)
24+
func parseLogFileWithEngine(filePath string, detectedEngine workflow.CodingAgentEngine, isGitHubCopilotCodingAgent bool, verbose bool) (LogMetrics, error) {
25+
logsParsingEnginesLog.Printf("Parsing log file: %s, isGitHubCopilotCodingAgent=%v", filePath, isGitHubCopilotCodingAgent)
2626
// Read the entire log file at once to avoid JSON parsing issues from chunked reading
2727
content, err := os.ReadFile(filePath)
2828
if err != nil {
@@ -34,9 +34,9 @@ func parseLogFileWithEngine(filePath string, detectedEngine workflow.CodingAgent
3434
logsParsingEnginesLog.Printf("Read %d bytes from log file", len(logContent))
3535

3636
// If this is a GitHub Copilot coding agent run, use the specialized parser
37-
if isGitHubCopilotAgent {
37+
if isGitHubCopilotCodingAgent {
3838
logsParsingEnginesLog.Print("Using GitHub Copilot coding agent parser")
39-
return ParseCopilotAgentLogMetrics(logContent, verbose), nil
39+
return ParseCopilotCodingAgentLogMetrics(logContent, verbose), nil
4040
}
4141

4242
// If we have a detected engine from aw_info.json, use it directly

pkg/workflow/agentic_engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ func (r *EngineRegistry) GetAllEngines() []CodingAgentEngine {
460460
return engines
461461
}
462462

463-
// GetCopilotAgentPlaywrightTools returns the list of playwright tools available in the copilot agent
463+
// GetPlaywrightTools returns the list of playwright tools available in the copilot agent
464464
// This matches the tools available in the copilot agent MCP server configuration
465465
// This is a shared function used by all engines for consistent playwright tool configuration
466-
func GetCopilotAgentPlaywrightTools() []any {
466+
func GetPlaywrightTools() []any {
467467
tools := []string{
468468
"browser_click",
469469
"browser_close",

pkg/workflow/claude_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (e *ClaudeEngine) expandNeutralToolsToClaudeTools(tools map[string]any) map
102102
if _, hasPlaywright := tools["playwright"]; hasPlaywright {
103103
// Create playwright as an MCP tool with the same tools available as copilot agent
104104
playwrightMCP := map[string]any{
105-
"allowed": GetCopilotAgentPlaywrightTools(),
105+
"allowed": GetPlaywrightTools(),
106106
}
107107
result["playwright"] = playwrightMCP
108108
}

pkg/workflow/codex_engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func (e *CodexEngine) expandNeutralToolsToCodexTools(toolsConfig *ToolsConfig) *
413413

414414
// Also update the Custom map entry for playwright with allowed tools list
415415
playwrightMCP := map[string]any{
416-
"allowed": GetCopilotAgentPlaywrightTools(),
416+
"allowed": GetPlaywrightTools(),
417417
}
418418
if playwrightConfig.Version != "" {
419419
playwrightMCP["version"] = playwrightConfig.Version

pkg/workflow/codex_playwright_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestCodexEnginePlaywrightToolsExpansion(t *testing.T) {
7676
}
7777

7878
// Verify that all expected copilot agent tools are present
79-
expectedTools := GetCopilotAgentPlaywrightTools()
79+
expectedTools := GetPlaywrightTools()
8080
if len(allowedSlice) != len(expectedTools) {
8181
t.Errorf("Expected %d tools to match copilot agent tools, got %d", len(expectedTools), len(allowedSlice))
8282
}

0 commit comments

Comments
 (0)