MCPcopy Create free account
hub / github.com/github/gh-aw / ResolveWorkflowPath

Function ResolveWorkflowPath

pkg/cli/resolver.go:22–64  ·  view source on GitHub ↗

ResolveWorkflowPath resolves a workflow file path from various formats: - Absolute path to .md file - Relative path to .md file - Workflow name or subpath (e.g., "a.md" -> ".github/workflows/a.md", "shared/b.md" -> ".github/workflows/shared/b.md")

(workflowFile string)

Source from the content-addressed store, hash-verified

20// - Relative path to .md file
21// - Workflow name or subpath (e.g., "a.md" -> ".github/workflows/a.md", "shared/b.md" -> ".github/workflows/shared/b.md")
22func ResolveWorkflowPath(workflowFile string) (string, error) {
23 resolverLog.Printf("Resolving workflow path: %s", workflowFile)
24 workflowsDir := constants.GetWorkflowDir()
25
26 // Add .md extension if not present
27 searchPath := workflowFile
28 if !strings.HasSuffix(searchPath, ".md") {
29 searchPath += ".md"
30 }
31
32 // 1. If it's a path that exists as-is (absolute or relative), use it
33 if _, err := os.Stat(searchPath); err == nil {
34 resolverLog.Printf("Found workflow at direct path: %s", searchPath)
35 return searchPath, nil
36 }
37
38 // 2. Try exact relative path under .github/workflows
39 workflowPath := filepath.Join(workflowsDir, searchPath)
40 if fileutil.FileExists(workflowPath) {
41 resolverLog.Printf("Found workflow at: %s", workflowPath)
42 return workflowPath, nil
43 }
44
45 // No matches found - suggest similar workflow names
46 resolverLog.Printf("Workflow file not found: %s", workflowPath)
47
48 suggestions := []string{
49 fmt.Sprintf("Run '%s status' to see all available workflows", string(constants.CLIExtensionPrefix)),
50 "Check for typos in the workflow name",
51 "Ensure the workflow file exists in .github/workflows/",
52 }
53
54 // Add fuzzy match suggestions if available
55 similarNames := suggestWorkflowNames(searchPath)
56 if len(similarNames) > 0 {
57 suggestions = append([]string{fmt.Sprintf("Did you mean: %s?", strings.Join(similarNames, ", "))}, suggestions...)
58 }
59
60 return "", errors.New(console.FormatErrorWithSuggestions(
61 "workflow file not found: "+workflowPath,
62 suggestions,
63 ))
64}

Callers 10

InspectWorkflowMCPFunction · 0.85
ListToolsForMCPFunction · 0.85
ListWorkflowMCPFunction · 0.85
spawnMCPInspectorFunction · 0.85
TestResolveWorkflowPathFunction · 0.85
AddMCPToolFunction · 0.85
RunWorkflowDomainsFunction · 0.85

Calls 5

GetWorkflowDirFunction · 0.92
FileExistsFunction · 0.92
suggestWorkflowNamesFunction · 0.85
PrintfMethod · 0.45