Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/cli/mcp_registry_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import (
"os"

"github.com/github/gh-aw/pkg/console"
"github.com/github/gh-aw/pkg/logger"
)

var mcpRegistryListLog = logger.New("cli:mcp_registry_list")

// listAvailableServers shows a list of available MCP servers from the registry
func listAvailableServers(registryURL string, verbose bool) error {
mcpRegistryListLog.Printf("Listing available MCP servers: registry_url=%s", registryURL)
// Create registry client
registryClient := NewMCPRegistryClient(registryURL)

Expand All @@ -19,9 +23,12 @@ func listAvailableServers(registryURL string, verbose bool) error {

servers, err := registryClient.SearchServers("")
if err != nil {
mcpRegistryListLog.Printf("Failed to fetch MCP servers: %v", err)
return fmt.Errorf("failed to fetch MCP servers: %w", err)
}

mcpRegistryListLog.Printf("Retrieved %d servers from registry", len(servers))

if verbose {
fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Retrieved %d servers from registry", len(servers))))
if len(servers) > 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/cli/run_workflow_tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"time"

"github.com/github/gh-aw/pkg/console"
"github.com/github/gh-aw/pkg/logger"
"github.com/github/gh-aw/pkg/workflow"
)

var runWorkflowTrackingLog = logger.New("cli:run_workflow_tracking")

// WorkflowRunInfo contains information about a workflow run
type WorkflowRunInfo struct {
URL string
Expand All @@ -23,6 +26,7 @@ type WorkflowRunInfo struct {
// getLatestWorkflowRunWithRetry gets information about the most recent run of the specified workflow
// with retry logic to handle timing issues when a workflow has just been triggered
func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose bool) (*WorkflowRunInfo, error) {
runWorkflowTrackingLog.Printf("Getting latest workflow run: workflow=%s, repo=%s, max_retries=6", lockFileName, repo)
const maxRetries = 6
const initialDelay = 2 * time.Second
const maxDelay = 10 * time.Second
Expand All @@ -36,6 +40,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo
// Capture the current time before we start polling
// This helps us identify runs that were created after the workflow was triggered
startTime := time.Now().UTC()
runWorkflowTrackingLog.Printf("Start time for polling: %s", startTime.Format(time.RFC3339))

// Create spinner outside the loop so we can update it
var spinner *console.SpinnerWrapper
Expand Down Expand Up @@ -81,6 +86,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo
output, err := cmd.Output()
if err != nil {
lastErr = fmt.Errorf("failed to get workflow runs: %w", err)
runWorkflowTrackingLog.Printf("Attempt %d/%d failed to get runs: %v", attempt+1, maxRetries, err)
if verbose {
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Attempt %d/%d failed: %v", attempt+1, maxRetries, err)))
}
Expand All @@ -89,6 +95,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo

if len(output) == 0 || string(output) == "[]" {
lastErr = fmt.Errorf("no runs found for workflow")
runWorkflowTrackingLog.Printf("Attempt %d/%d: no runs found, output empty or []", attempt+1, maxRetries)
console.LogVerbose(verbose, fmt.Sprintf("Attempt %d/%d: no runs found yet", attempt+1, maxRetries))
continue
}
Expand Down Expand Up @@ -139,6 +146,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo
// If we found a run and it was created after we started (within 30 seconds tolerance),
// it's likely the run we just triggered
if !createdAt.IsZero() && createdAt.After(startTime.Add(-30*time.Second)) {
runWorkflowTrackingLog.Printf("Found matching run: id=%d, created_at=%s, within_tolerance=true", run.DatabaseID, createdAt.Format(time.RFC3339))
console.LogVerbose(verbose, fmt.Sprintf("Found recent run (ID: %d) created at %v (started polling at %v)",
run.DatabaseID, createdAt.Format(time.RFC3339), startTime.Format(time.RFC3339)))
if spinner != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/cli/validation_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (
"os"

"github.com/github/gh-aw/pkg/console"
"github.com/github/gh-aw/pkg/logger"
)

var validationOutputLog = logger.New("cli:validation_output")

// FormatValidationError formats validation errors for console output
// Preserves structured error content while applying console styling
//
Expand All @@ -24,6 +27,7 @@ func FormatValidationError(err error) string {
}

errMsg := err.Error()
validationOutputLog.Printf("Formatting validation error: %s", errMsg)

// Apply console formatting to the entire error message
// This preserves structured multi-line errors while adding visual styling
Expand Down