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
8 changes: 8 additions & 0 deletions pkg/cli/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import (

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

var enableLog = logger.New("cli:enable")

// EnableWorkflowsByNames enables workflows by specific names, or all if no names provided
func EnableWorkflowsByNames(workflowNames []string, repoOverride string) error {
return toggleWorkflowsByNames(workflowNames, true, repoOverride)
Expand Down Expand Up @@ -46,8 +49,11 @@ func toggleWorkflowsByNames(workflowNames []string, enable bool, repoOverride st
action = "disable"
}

enableLog.Printf("Toggle workflows: action=%s, count=%d, repo=%s", action, len(workflowNames), repoOverride)

// If no specific workflow names provided, enable/disable all workflows
if len(workflowNames) == 0 {
enableLog.Print("No specific workflows provided, processing all workflows")
fmt.Fprintf(os.Stderr, "No specific workflows provided. %sing all workflows...\n", strings.ToUpper(action[:1])+action[1:])
// Get all workflow names and process them
mdFiles, err := getMarkdownWorkflowFiles()
Expand Down Expand Up @@ -270,6 +276,7 @@ func toggleWorkflowsByNames(workflowNames []string, enable bool, repoOverride st
// DisableAllWorkflowsExcept disables all workflows except the specified ones
// Typically used to disable all workflows except the one being trialled
func DisableAllWorkflowsExcept(repoSlug string, exceptWorkflows []string, verbose bool) error {
enableLog.Printf("Disabling all workflows except: count=%d, repo=%s", len(exceptWorkflows), repoSlug)
workflowsDir := ".github/workflows"

// Check if workflows directory exists
Expand All @@ -285,6 +292,7 @@ func DisableAllWorkflowsExcept(repoSlug string, exceptWorkflows []string, verbos
yamlFiles, _ := filepath.Glob(filepath.Join(workflowsDir, "*.yaml"))
allYAMLFiles := append(ymlFiles, yamlFiles...)

enableLog.Printf("Found %d YAML workflow files", len(allYAMLFiles))
if len(allYAMLFiles) == 0 {
if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No YAML workflow files found"))
Expand Down
13 changes: 13 additions & 0 deletions pkg/cli/mcp_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import (

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

var mcpRegistryLog = logger.New("cli:mcp_registry")

// MCPRegistryServerForProcessing represents a flattened server for internal use
type MCPRegistryServerForProcessing struct {
Name string `json:"name"`
Expand All @@ -38,6 +41,8 @@ func NewMCPRegistryClient(registryURL string) *MCPRegistryClient {
registryURL = constants.DefaultMCPRegistryURL
}

mcpRegistryLog.Printf("Creating MCP registry client: url=%s", registryURL)

return &MCPRegistryClient{
registryURL: registryURL,
httpClient: &http.Client{
Expand All @@ -62,6 +67,8 @@ func (c *MCPRegistryClient) createRegistryRequest(method, url string) (*http.Req

// SearchServers searches for MCP servers in the registry by fetching all servers and filtering locally
func (c *MCPRegistryClient) SearchServers(query string) ([]MCPRegistryServerForProcessing, error) {
mcpRegistryLog.Printf("Searching MCP servers: query=%q", query)

// Always use servers endpoint for listing all servers
searchURL := fmt.Sprintf("%s/servers", c.registryURL)

Expand Down Expand Up @@ -112,6 +119,7 @@ func (c *MCPRegistryClient) SearchServers(query string) ([]MCPRegistryServerForP
}

// Convert servers to flattened format and filter by status
mcpRegistryLog.Printf("Processing %d servers from registry", len(response.Servers))
servers := make([]MCPRegistryServerForProcessing, 0, len(response.Servers))
for _, server := range response.Servers {
// Only include active servers
Expand Down Expand Up @@ -225,6 +233,7 @@ func (c *MCPRegistryClient) SearchServers(query string) ([]MCPRegistryServerForP
}
}

mcpRegistryLog.Printf("Filtered to %d servers matching query", len(filteredServers))
return filteredServers, nil
}

Expand All @@ -240,6 +249,8 @@ func (c *MCPRegistryClient) SearchServers(query string) ([]MCPRegistryServerForP

// GetServer gets a specific server by name from the registry
func (c *MCPRegistryClient) GetServer(serverName string) (*MCPRegistryServerForProcessing, error) {
mcpRegistryLog.Printf("Getting MCP server: name=%s", serverName)

// Use the servers endpoint and filter locally, just like SearchServers
serversURL := fmt.Sprintf("%s/servers", c.registryURL)

Expand Down Expand Up @@ -382,10 +393,12 @@ func (c *MCPRegistryClient) GetServer(serverName string) (*MCPRegistryServerForP
processedServer.Transport = "stdio" // default fallback
}

mcpRegistryLog.Printf("Found MCP server: name=%s, transport=%s", serverName, processedServer.Transport)
return &processedServer, nil
}
}

mcpRegistryLog.Printf("MCP server not found: name=%s", serverName)
return nil, fmt.Errorf("MCP server '%s' not found in registry", serverName)
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/cli/remove_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import (

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

var removeLog = logger.New("cli:remove_command")

// RemoveWorkflows removes workflows matching a pattern
func RemoveWorkflows(pattern string, keepOrphans bool) error {
removeLog.Printf("Removing workflows: pattern=%q, keepOrphans=%v", pattern, keepOrphans)
workflowsDir := getWorkflowsDir()

if _, err := os.Stat(workflowsDir); os.IsNotExist(err) {
Expand All @@ -27,6 +31,7 @@ func RemoveWorkflows(pattern string, keepOrphans bool) error {
return fmt.Errorf("failed to find workflow files: %w", err)
}

removeLog.Printf("Found %d workflow files", len(mdFiles))
if len(mdFiles) == 0 {
fmt.Println("No workflow files found to remove.")
return nil
Expand Down Expand Up @@ -65,10 +70,13 @@ func RemoveWorkflows(pattern string, keepOrphans bool) error {
}

if len(filesToRemove) == 0 {
removeLog.Printf("No workflows matched pattern: %q", pattern)
fmt.Printf("No workflows found matching pattern: %s\n", pattern)
return nil
}

removeLog.Printf("Found %d workflows to remove", len(filesToRemove))

// Preview orphaned includes that would be removed (if orphan removal is enabled)
var orphanedIncludes []string
if !keepOrphans {
Expand Down Expand Up @@ -154,10 +162,12 @@ func RemoveWorkflows(pattern string, keepOrphans bool) error {

// cleanupOrphanedIncludes removes include files that are no longer used by any workflow
func cleanupOrphanedIncludes(verbose bool) error {
removeLog.Print("Cleaning up orphaned include files")
// Get all remaining markdown files
mdFiles, err := getMarkdownWorkflowFiles()
if err != nil {
// No markdown files means we can clean up all includes
removeLog.Print("No markdown files found, cleaning up all includes")
if verbose {
fmt.Printf("No markdown files found, cleaning up all includes\n")
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/cli/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
"path/filepath"
"strings"

"github.com/githubnext/gh-aw/pkg/logger"
"github.com/githubnext/gh-aw/pkg/parser"
)

var specLog = logger.New("cli:spec")

// RepoSpec represents a parsed repository specification
type RepoSpec struct {
RepoSlug string // e.g., "owner/repo"
Expand Down Expand Up @@ -72,6 +75,7 @@ func isRepoOnlySpec(spec string) bool {
// parseRepoSpec parses repository specification like "org/repo@version" or "org/repo@branch" or "org/repo@commit"
// Also supports GitHub URLs like "https://github.com/owner/repo[@version]"
func parseRepoSpec(repoSpec string) (*RepoSpec, error) {
specLog.Printf("Parsing repo spec: %q", repoSpec)
parts := strings.SplitN(repoSpec, "@", 2)
repo := parts[0]
var version string
Expand Down Expand Up @@ -168,13 +172,17 @@ func parseGitHubURL(spec string) (*WorkflowSpec, error) {
// Also supports full GitHub URLs like https://github.com/owner/repo/blob/branch/path/to/workflow.md
// Also supports local paths like ./workflows/workflow-name.md
func parseWorkflowSpec(spec string) (*WorkflowSpec, error) {
specLog.Printf("Parsing workflow spec: %q", spec)

// Check if this is a GitHub URL
if strings.HasPrefix(spec, "http://") || strings.HasPrefix(spec, "https://") {
specLog.Print("Detected GitHub URL format")
return parseGitHubURL(spec)
}

// Check if this is a local path starting with "./"
if strings.HasPrefix(spec, "./") {
specLog.Print("Detected local path format")
return parseLocalWorkflowSpec(spec)
}

Expand Down Expand Up @@ -287,6 +295,7 @@ func parseLocalWorkflowSpec(spec string) (*WorkflowSpec, error) {
// parseSourceSpec parses a source specification like "owner/repo/path@ref"
// This is used for parsing the source field from workflow frontmatter
func parseSourceSpec(source string) (*SourceSpec, error) {
specLog.Printf("Parsing source spec: %q", source)
// Split on @ to separate ref
parts := strings.SplitN(source, "@", 2)
pathPart := parts[0]
Expand All @@ -306,6 +315,7 @@ func parseSourceSpec(source string) (*SourceSpec, error) {
spec.Ref = parts[1]
}

specLog.Printf("Parsed source spec: repo=%s, path=%s, ref=%s", spec.Repo, spec.Path, spec.Ref)
return spec, nil
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/workflow/expression_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package workflow
import (
"fmt"
"strings"

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

var expressionNodesLog = logger.New("workflow:expression_nodes")

// ConditionNode represents a node in a condition expression tree
type ConditionNode interface {
Render() string
Expand Down Expand Up @@ -97,6 +101,8 @@ func (d *DisjunctionNode) RenderMultiline() string {
return d.Terms[0].Render()
}

expressionNodesLog.Printf("Rendering multiline disjunction with %d terms", len(d.Terms))

var lines []string
for i, term := range d.Terms {
var line string
Expand Down