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

Function extractEngineConfigFromFile

pkg/cli/workflow_secrets.go:97–118  ·  view source on GitHub ↗

extractEngineConfigFromFile parses a workflow file and returns the engine ID and config. Returns ("", nil) when the file cannot be read or parsed.

(filePath string)

Source from the content-addressed store, hash-verified

95// extractEngineConfigFromFile parses a workflow file and returns the engine ID and config.
96// Returns ("", nil) when the file cannot be read or parsed.
97func extractEngineConfigFromFile(filePath string) (string, *workflow.EngineConfig, map[string]any) {
98 content, err := readWorkflowFileContent(filePath)
99 if err != nil {
100 return "", nil, nil
101 }
102
103 result, err := parser.ExtractFrontmatterFromContent(content)
104 if err != nil {
105 return "", nil, nil
106 }
107
108 compiler := &workflow.Compiler{}
109 engineSetting, engineConfig := compiler.ExtractEngineConfig(result.Frontmatter)
110
111 if engineConfig != nil && engineConfig.ID != "" {
112 return engineConfig.ID, engineConfig, result.Frontmatter
113 }
114 if engineSetting != "" {
115 return engineSetting, engineConfig, result.Frontmatter
116 }
117 return "copilot", engineConfig, result.Frontmatter // Default engine
118}
119
120func hasCopilotRequestsWritePermission(frontmatter map[string]any) bool {
121 if frontmatter == nil {

Callers 1

Calls 3

ExtractEngineConfigMethod · 0.95
readWorkflowFileContentFunction · 0.85

Tested by

no test coverage detected