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
9 changes: 9 additions & 0 deletions pkg/cli/add_workflow_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func ResolveWorkflows(workflows []string, verbose bool) (*ResolvedWorkflows, err
// Skip this check if we can't determine the current repository (e.g., not in a git repo)
currentRepoSlug, repoErr := GetCurrentRepoSlug()
if repoErr == nil {
resolutionLog.Printf("Current repository: %s", currentRepoSlug)
// We successfully determined the current repository, check all workflow specs
for _, spec := range parsedSpecs {
// Skip local workflow specs
Expand All @@ -90,6 +91,8 @@ func ResolveWorkflows(workflows []string, verbose bool) (*ResolvedWorkflows, err
return nil, fmt.Errorf("cannot add workflows from the current repository (%s). The 'add' command is for installing workflows from other repositories", currentRepoSlug)
}
}
} else {
resolutionLog.Printf("Could not determine current repository: %v", repoErr)
}
// If we can't determine the current repository, proceed without the check

Expand Down Expand Up @@ -140,6 +143,9 @@ func ResolveWorkflows(workflows []string, verbose bool) (*ResolvedWorkflows, err
hasWorkflowDispatch = true
}

resolutionLog.Printf("Resolved workflow: spec=%s, engine=%s, has_dispatch=%t, content_size=%d bytes",
spec.String(), engine, workflowHasDispatch, len(fetched.Content))

resolvedWorkflows = append(resolvedWorkflows, &ResolvedWorkflow{
Spec: spec,
Content: fetched.Content,
Expand All @@ -151,6 +157,9 @@ func ResolveWorkflows(workflows []string, verbose bool) (*ResolvedWorkflows, err
})
}

resolutionLog.Printf("Resolution complete: resolved=%d workflows, has_wildcard=%t, has_dispatch=%t",
len(resolvedWorkflows), hasWildcard, hasWorkflowDispatch)

return &ResolvedWorkflows{
Workflows: resolvedWorkflows,
HasWildcard: hasWildcard,
Expand Down
9 changes: 9 additions & 0 deletions pkg/cli/mcp_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func InspectWorkflowMCP(workflowFile string, serverFilter string, toolFilter str
return fmt.Errorf("failed to parse workflow file: %w", err)
}

mcpInspectLog.Printf("Workflow parsed: name=%s, has_safe_inputs=%t",
workflowData.Name, workflowData.SafeInputs != nil)

if verbose {
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Workflow parsed successfully"))
}
Expand All @@ -82,24 +85,30 @@ func InspectWorkflowMCP(workflowFile string, serverFilter string, toolFilter str
return fmt.Errorf("failed to extract MCP configurations: %w", err)
}

mcpInspectLog.Printf("Extracted %d MCP configs (server_filter=%q)", len(mcpConfigs), serverFilter)

// Filter out safe-outputs MCP servers for inspection
mcpConfigs = filterOutSafeOutputs(mcpConfigs)
mcpInspectLog.Printf("After filtering safe-outputs: %d MCP configs remain", len(mcpConfigs))

// Start safe-inputs server if present
var safeInputsServerCmd *exec.Cmd
var safeInputsTmpDir string
if workflowData != nil && workflowData.SafeInputs != nil && len(workflowData.SafeInputs.Tools) > 0 {
mcpInspectLog.Printf("Starting safe-inputs server: tools=%d", len(workflowData.SafeInputs.Tools))
// Start safe-inputs server and add it to the list of MCP configs
config, serverCmd, tmpDir, err := startSafeInputsServer(workflowData.SafeInputs, verbose)
if err != nil {
if verbose {
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to start safe-inputs server: %v", err)))
}
mcpInspectLog.Printf("Failed to start safe-inputs server: %v", err)
} else {
safeInputsServerCmd = serverCmd
safeInputsTmpDir = tmpDir
// Add safe-inputs config to the list of MCP servers to inspect
mcpConfigs = append(mcpConfigs, *config)
mcpInspectLog.Print("Safe-inputs server started successfully")
}
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/cli/mcp_list_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func ListToolsForMCP(workflowFile string, mcpServerName string, verbose bool) er
return err
}

mcpListToolsLog.Printf("Found %d MCP configs in workflow, searching for server: %s", len(mcpConfigs), mcpServerName)

// Find the specific MCP server
var targetConfig *parser.MCPServerConfig
for _, config := range mcpConfigs {
Expand All @@ -66,6 +68,7 @@ func ListToolsForMCP(workflowFile string, mcpServerName string, verbose bool) er
}

if targetConfig == nil {
mcpListToolsLog.Printf("MCP server %q not found in workflow %q", mcpServerName, filepath.Base(workflowPath))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("MCP server '%s' not found in workflow '%s'", mcpServerName, filepath.Base(workflowPath))))

// Show available servers
Expand All @@ -77,6 +80,8 @@ func ListToolsForMCP(workflowFile string, mcpServerName string, verbose bool) er
return nil
}

mcpListToolsLog.Printf("Found MCP server: name=%s, type=%s", targetConfig.Name, targetConfig.Type)

// Connect to the MCP server and get its tools
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("📡 Connecting to MCP server: %s (%s)",
targetConfig.Name,
Expand All @@ -87,6 +92,8 @@ func ListToolsForMCP(workflowFile string, mcpServerName string, verbose bool) er
return fmt.Errorf("failed to connect to MCP server '%s': %w", mcpServerName, err)
}

mcpListToolsLog.Printf("Connected to MCP server: tools=%d", len(info.Tools))

if verbose {
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Successfully connected to MCP server"))
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/workflow/compiler_workflow_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ func (c *Compiler) injectWorkflowCallOutputs(onSection string, safeOutputs *Safe
return onSection
}

workflowCallLog.Print("Injecting workflow_call outputs for safe-output results")

// Build the auto-generated outputs map based on configured safe output types
generatedOutputs := buildWorkflowCallOutputsMap(safeOutputs)
if len(generatedOutputs) == 0 {
workflowCallLog.Print("No workflow_call outputs to inject (no safe-output types configured)")
return onSection
}

workflowCallLog.Printf("Generated %d workflow_call outputs to inject", len(generatedOutputs))

// Parse the on section YAML
var onData map[string]any
if err := yaml.Unmarshal([]byte(onSection), &onData); err != nil {
Expand Down Expand Up @@ -87,6 +92,7 @@ func (c *Compiler) injectWorkflowCallOutputs(onSection string, safeOutputs *Safe
}
}

workflowCallLog.Printf("Merged workflow_call outputs: total=%d", len(mergedOutputs))
workflowCallMap["outputs"] = mergedOutputs
onMap["workflow_call"] = workflowCallMap

Expand All @@ -104,6 +110,12 @@ func (c *Compiler) injectWorkflowCallOutputs(onSection string, safeOutputs *Safe
// buildWorkflowCallOutputsMap constructs the outputs map for on.workflow_call.outputs
// based on which safe output types are configured.
func buildWorkflowCallOutputsMap(safeOutputs *SafeOutputsConfig) map[string]workflowCallOutputEntry {
workflowCallLog.Printf("Building workflow_call outputs map: create_issues=%t, create_prs=%t, add_comments=%t, push_to_pr=%t",
safeOutputs.CreateIssues != nil,
safeOutputs.CreatePullRequests != nil,
safeOutputs.AddComments != nil,
safeOutputs.PushToPullRequestBranch != nil)

outputs := make(map[string]workflowCallOutputEntry)

if safeOutputs.CreateIssues != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/workflow/repo_memory_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ func buildRepoMemoryPromptSection(config *RepoMemoryConfig) *PromptSection {
// Build wiki note text (non-empty only when wiki mode is enabled)
wikiNoteText := ""
if memory.Wiki {
repoMemoryPromptLog.Print("Wiki mode enabled for repo memory")
wikiNoteText = "\n\n> **GitHub Wiki**: This memory is backed by the GitHub Wiki for this repository. " +
"Files use GitHub Wiki Markdown syntax. Follow GitHub Wiki conventions when creating or editing pages " +
"(e.g., use standard Markdown headers, use `[[Page Name]]` syntax for internal wiki links, " +
"name page files with spaces replaced by hyphens or use the wiki page title as the filename)."
}

repoMemoryPromptLog.Printf("Built single repo memory prompt section: branch=%s, has_constraints=%t, wiki=%t",
memory.BranchName, len(constraintsText) > 2, memory.Wiki)

return &PromptSection{
Content: repoMemoryPromptFile,
IsFile: true,
Expand Down Expand Up @@ -123,6 +127,7 @@ func buildRepoMemoryPromptSection(config *RepoMemoryConfig) *PromptSection {

// If not all the same, build a union of all extensions
if !allSame {
repoMemoryPromptLog.Print("Memories have different allowed extensions, building union set")
extensionSet := make(map[string]bool)
for _, mem := range config.Memories {
for _, ext := range mem.AllowedExtensions {
Expand All @@ -138,6 +143,9 @@ func buildRepoMemoryPromptSection(config *RepoMemoryConfig) *PromptSection {
allowedExtsText = strings.Join(allExtensions, "`, `")
}

repoMemoryPromptLog.Printf("Built multi repo memory prompt section: memories=%d, extensions=%q, all_same_exts=%t",
len(config.Memories), allowedExtsText, allSame)

return &PromptSection{
Content: repoMemoryPromptMultiFile,
IsFile: true,
Expand Down