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
20 changes: 10 additions & 10 deletions pkg/cli/compile_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func compileAllWorkflowFiles(compiler *workflow.Compiler, workflowsDir string, v
if len(mdFiles) == 0 {
compileHelpersLog.Printf("No markdown files found in %s", workflowsDir)
if verbose {
fmt.Printf("No markdown files found in %s\n", workflowsDir)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("No markdown files found in %s", workflowsDir)))
}
return stats, nil
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func compileAllWorkflowFiles(compiler *workflow.Compiler, workflowsDir string, v
if successCount > 0 || hasActionCacheEntries {
if err := ensureGitAttributes(); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to update .gitattributes: %v\n", err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to update .gitattributes: %v", err)))
}
}
} else {
Expand Down Expand Up @@ -252,7 +252,7 @@ func compileModifiedFiles(compiler *workflow.Compiler, files []string, verbose b
if successCount > 0 || hasActionCacheEntries {
if err := ensureGitAttributes(); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to update .gitattributes: %v\n", err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to update .gitattributes: %v", err)))
}
}
} else {
Expand Down Expand Up @@ -336,7 +336,7 @@ func compileModifiedFilesWithDependencies(compiler *workflow.Compiler, depGraph
if successCount > 0 || hasActionCacheEntries {
if err := ensureGitAttributes(); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to update .gitattributes: %v\n", err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to update .gitattributes: %v", err)))
}
}
} else {
Expand All @@ -356,11 +356,11 @@ func handleFileDeleted(mdFile string, verbose bool) {
if _, err := os.Stat(orchestratorFile); err == nil {
if err := os.Remove(orchestratorFile); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to remove orchestrator file %s: %v\n", orchestratorFile, err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to remove orchestrator file %s: %v", orchestratorFile, err)))
}
} else {
if verbose {
fmt.Printf("🗑️ Removed generated orchestrator: %s\n", orchestratorFile)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Removed generated orchestrator: %s", orchestratorFile)))
}
}
}
Expand All @@ -370,11 +370,11 @@ func handleFileDeleted(mdFile string, verbose bool) {
if _, err := os.Stat(orchestratorLockFile); err == nil {
if err := os.Remove(orchestratorLockFile); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to remove orchestrator lock file %s: %v\n", orchestratorLockFile, err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to remove orchestrator lock file %s: %v", orchestratorLockFile, err)))
}
} else {
if verbose {
fmt.Printf("🗑️ Removed orchestrator lock file: %s\n", orchestratorLockFile)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Removed orchestrator lock file: %s", orchestratorLockFile)))
}
}
}
Expand All @@ -388,11 +388,11 @@ func handleFileDeleted(mdFile string, verbose bool) {
if _, err := os.Stat(lockFile); err == nil {
if err := os.Remove(lockFile); err != nil {
if verbose {
fmt.Printf("⚠️ Failed to remove lock file %s: %v\n", lockFile, err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to remove lock file %s: %v", lockFile, err)))
}
} else {
if verbose {
fmt.Printf("🗑️ Removed corresponding lock file: %s\n", lockFile)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Removed corresponding lock file: %s", lockFile)))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/compile_orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func compileAllFilesInDirectory(

compileOrchestrationLog.Printf("Scanning for markdown files in %s", workflowsDir)
if config.Verbose {
fmt.Printf("Scanning for markdown files in %s\n", workflowsDir)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Scanning for markdown files in %s", workflowsDir)))
}

// Find all markdown files
Expand All @@ -238,7 +238,7 @@ func compileAllFilesInDirectory(

compileOrchestrationLog.Printf("Found %d markdown files to compile", len(mdFiles))
if config.Verbose {
fmt.Printf("Found %d markdown files to compile\n", len(mdFiles))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d markdown files to compile", len(mdFiles))))
}

// Handle purge logic: collect existing files before compilation
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/compile_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func watchAndCompileWorkflows(markdownFile string, compiler *workflow.Compiler,

// Always emit the begin pattern for task integration
if markdownFile != "" {
fmt.Printf("Watching for file changes to %s...\n", markdownFile)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Watching for file changes to %s...", markdownFile)))
} else {
fmt.Printf("Watching for file changes in %s...\n", workflowsDir)
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Watching for file changes in %s...", workflowsDir)))
}

if verbose {
Expand Down Expand Up @@ -174,7 +174,7 @@ func watchAndCompileWorkflows(markdownFile string, compiler *workflow.Compiler,

compileWatchLog.Printf("Detected change: %s (%s)", event.Name, event.Op.String())
if verbose {
fmt.Printf("📝 Detected change: %s (%s)\n", event.Name, event.Op.String())
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Detected change: %s (%s)", event.Name, event.Op.String())))
}

// Handle file operations
Expand Down Expand Up @@ -211,7 +211,7 @@ func watchAndCompileWorkflows(markdownFile string, compiler *workflow.Compiler,
}
compileWatchLog.Printf("Watcher error: %v", err)
if verbose {
fmt.Printf("⚠️ Watcher error: %v\n", err)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Watcher error: %v", err)))
}

case <-sigChan:
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/mcp_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func AddMCPTool(workflowFile string, mcpServerID string, registryURL string, tra
if err := checkAndSuggestSecrets(mcpConfig, verbose); err != nil {
// Don't fail the command if secret checking fails, just log a warning
if verbose {
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Could not check repository secrets: %v", err)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not check repository secrets: %v", err)))
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ func createMCPToolConfig(server *MCPRegistryServerForProcessing, preferredTransp
case "stdio", "http", "docker":
transport = preferredTransport
if verbose {
fmt.Println(console.FormatInfoMessage(fmt.Sprintf("Using preferred transport: %s", transport)))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Using preferred transport: %s", transport)))
}
default:
return nil, fmt.Errorf("unsupported transport type: %s (supported: stdio, http, docker)", preferredTransport)
Expand Down
64 changes: 32 additions & 32 deletions pkg/cli/mcp_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ func InspectWorkflowMCP(workflowFile string, serverFilter string, toolFilter str
if toolFilter != "" {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d MCP server(s), looking for tool '%s'", len(mcpConfigs), toolFilter)))
} else {
fmt.Println(console.FormatInfoMessage(fmt.Sprintf("Found %d MCP server(s) to inspect", len(mcpConfigs))))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d MCP server(s) to inspect", len(mcpConfigs))))
}
fmt.Println()
fmt.Fprintln(os.Stderr)

for i, config := range mcpConfigs {
if i > 0 {
fmt.Println()
fmt.Fprintln(os.Stderr)
}
if err := inspectMCPServer(config, toolFilter, verbose, useActionsSecrets); err != nil {
fmt.Println(console.FormatError(console.CompilerError{
fmt.Fprintln(os.Stderr, console.FormatError(console.CompilerError{
Type: "error",
Message: fmt.Sprintf("Failed to inspect MCP server '%s': %v", config.Name, err),
}))
Expand Down Expand Up @@ -298,15 +298,15 @@ func listWorkflowsWithMCP(workflowsDir string, verbose bool) error {
}

if len(workflowsWithMCP) == 0 {
fmt.Println(console.FormatInfoMessage("No workflows with MCP servers found"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No workflows with MCP servers found"))
return nil
}

fmt.Println(console.FormatInfoMessage("Workflows with MCP servers:"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Workflows with MCP servers:"))
for _, workflow := range workflowsWithMCP {
fmt.Printf(" • %s\n", workflow)
fmt.Fprintf(os.Stderr, " • %s\n", workflow)
}
fmt.Printf("\nRun 'gh aw mcp inspect <workflow-name>' to inspect MCP servers in a specific workflow.\n")
fmt.Fprintf(os.Stderr, "\nRun 'gh aw mcp inspect <workflow-name>' to inspect MCP servers in a specific workflow.\n")

return nil
}
Expand Down Expand Up @@ -665,7 +665,7 @@ func spawnSafeInputsInspector(workflowFile string, verbose bool) error {

fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Safe-inputs HTTP server started successfully"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Server running on: http://localhost:%d", port)))
fmt.Println()
fmt.Fprintln(os.Stderr)

// Create MCP server config for the safe-inputs server
safeInputsMCPConfig := parser.MCPServerConfig{
Expand Down Expand Up @@ -741,11 +741,11 @@ func spawnMCPInspector(workflowFile string, serverFilter string, verbose bool) e
}

if len(mcpConfigs) > 0 {
fmt.Println(console.FormatInfoMessage(fmt.Sprintf("Found %d MCP server(s) in workflow:", len(mcpConfigs))))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Found %d MCP server(s) in workflow:", len(mcpConfigs))))
for _, config := range mcpConfigs {
fmt.Printf(" • %s (%s)\n", config.Name, config.Type)
fmt.Fprintf(os.Stderr, " • %s (%s)\n", config.Name, config.Type)
}
fmt.Println()
fmt.Fprintln(os.Stderr)

// Start stdio MCP servers in the background
stdioServers := []parser.MCPServerConfig{}
Expand All @@ -756,11 +756,11 @@ func spawnMCPInspector(workflowFile string, serverFilter string, verbose bool) e
}

if len(stdioServers) > 0 {
fmt.Println(console.FormatInfoMessage("Starting stdio MCP servers..."))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Starting stdio MCP servers..."))

for _, config := range stdioServers {
if verbose {
fmt.Println(console.FormatInfoMessage(fmt.Sprintf("Starting server: %s", config.Name)))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Starting server: %s", config.Name)))
}

// Create the command for the MCP server
Expand Down Expand Up @@ -788,7 +788,7 @@ func spawnMCPInspector(workflowFile string, serverFilter string, verbose bool) e

// Start the server process
if err := cmd.Start(); err != nil {
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to start server %s: %v", config.Name, err)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to start server %s: %v", config.Name, err)))
continue
}

Expand All @@ -804,50 +804,50 @@ func spawnMCPInspector(workflowFile string, serverFilter string, verbose bool) e
}(cmd, config.Name)

if verbose {
fmt.Println(console.FormatSuccessMessage(fmt.Sprintf("Started server: %s (PID: %d)", config.Name, cmd.Process.Pid)))
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Started server: %s (PID: %d)", config.Name, cmd.Process.Pid)))
}
}

// Give servers a moment to start up
time.Sleep(2 * time.Second)
fmt.Println(console.FormatSuccessMessage("All stdio servers started successfully"))
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("All stdio servers started successfully"))
}

fmt.Println(console.FormatInfoMessage("Configuration details for MCP inspector:"))
for _, config := range mcpConfigs {
fmt.Printf("\n📡 %s (%s):\n", config.Name, config.Type)
fmt.Fprintf(os.Stderr, "\n📡 %s (%s):\n", config.Name, config.Type)
switch config.Type {
case "stdio":
if config.Container != "" {
fmt.Printf(" Container: %s\n", config.Container)
fmt.Fprintf(os.Stderr, " Container: %s\n", config.Container)
} else {
fmt.Printf(" Command: %s\n", config.Command)
fmt.Fprintf(os.Stderr, " Command: %s\n", config.Command)
if len(config.Args) > 0 {
fmt.Printf(" Args: %s\n", strings.Join(config.Args, " "))
fmt.Fprintf(os.Stderr, " Args: %s\n", strings.Join(config.Args, " "))
}
}
case "http":
fmt.Printf(" URL: %s\n", config.URL)
fmt.Fprintf(os.Stderr, " URL: %s\n", config.URL)
}
if len(config.Env) > 0 {
fmt.Printf(" Environment Variables: %v\n", config.Env)
fmt.Fprintf(os.Stderr, " Environment Variables: %v\n", config.Env)
}
}
fmt.Println()
fmt.Fprintln(os.Stderr)
} else {
fmt.Println(console.FormatWarningMessage("No MCP servers found in workflow"))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("No MCP servers found in workflow"))
return nil
}
}

// Set up cleanup function for stdio servers
defer func() {
if len(serverProcesses) > 0 {
fmt.Println(console.FormatInfoMessage("Cleaning up MCP servers..."))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Cleaning up MCP servers..."))
for i, cmd := range serverProcesses {
if cmd.Process != nil {
if err := cmd.Process.Kill(); err != nil && verbose {
fmt.Println(console.FormatWarningMessage(fmt.Sprintf("Failed to kill server process %d: %v", cmd.Process.Pid, err)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to kill server process %d: %v", cmd.Process.Pid, err)))
}
}
// Give each process a chance to clean up
Expand All @@ -868,17 +868,17 @@ func spawnMCPInspector(workflowFile string, serverFilter string, verbose bool) e
case <-time.After(5 * time.Second):
// Timeout waiting for cleanup
if verbose {
fmt.Println(console.FormatWarningMessage("Timeout waiting for server cleanup"))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Timeout waiting for server cleanup"))
}
}
}
}()

fmt.Println(console.FormatInfoMessage("Launching @modelcontextprotocol/inspector..."))
fmt.Println(console.FormatInfoMessage("Visit http://localhost:5173 after the inspector starts"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Launching @modelcontextprotocol/inspector..."))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Visit http://localhost:5173 after the inspector starts"))
if len(serverProcesses) > 0 {
fmt.Println(console.FormatInfoMessage(fmt.Sprintf("%d stdio MCP server(s) are running in the background", len(serverProcesses))))
fmt.Println(console.FormatInfoMessage("Configure them in the inspector using the details shown above"))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("%d stdio MCP server(s) are running in the background", len(serverProcesses))))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Configure them in the inspector using the details shown above"))
}

cmd := exec.Command("npx", "@modelcontextprotocol/inspector")
Expand Down
Loading
Loading