isFeatureEnabled checks if a feature flag is enabled by merging information from the frontmatter features field and the GH_AW_FEATURES environment variable. Features from frontmatter take precedence over environment variables. If workflowData is nil or has no features, it falls back to checking the
(flag constants.FeatureFlag, workflowData *WorkflowData)
| 16 | // |
| 17 | // If workflowData is nil or has no features, it falls back to checking the environment variable only. |
| 18 | func isFeatureEnabled(flag constants.FeatureFlag, workflowData *WorkflowData) bool { |
| 19 | flagLower := strings.ToLower(strings.TrimSpace(string(flag))) |
| 20 | logEnabled := featuresLog.Enabled() |
| 21 | if logEnabled { |
| 22 | featuresLog.Printf("Checking if feature is enabled: %s", flagLower) |
| 23 | } |
| 24 | |
| 25 | // Inline sub-agents are now enabled by default and the corresponding |
| 26 | // frontmatter flag is deprecated/no-op. |
| 27 | if strings.EqualFold(flagLower, "inline-agents") { |
| 28 | if logEnabled { |
| 29 | featuresLog.Printf("Feature %s is deprecated and always enabled", flagLower) |
| 30 | } |
| 31 | return true |
| 32 | } |
| 33 | |
| 34 | // First, check if the feature is explicitly set in frontmatter. |
| 35 | // Frontmatter values always take precedence. |
| 36 | if enabled, found := getFeatureValueFromFrontmatter(flagLower, workflowData, logEnabled); found { |
| 37 | return enabled |
| 38 | } |
| 39 | |
| 40 | // Fall back to checking the environment variable |
| 41 | if isFeatureInEnvironment(flagLower, logEnabled) { |
| 42 | if logEnabled { |
| 43 | featuresLog.Printf("Feature found in GH_AW_FEATURES: %s=true", flagLower) |
| 44 | } |
| 45 | return true |
| 46 | } |
| 47 | |
| 48 | if logEnabled { |
| 49 | featuresLog.Printf("Feature not found: %s=false", flagLower) |
| 50 | } |
| 51 | return false |
| 52 | } |
| 53 | |
| 54 | func getFeatureValueFromFrontmatter(flagLower string, workflowData *WorkflowData, logEnabled bool) (bool, bool) { |
| 55 | if workflowData == nil || workflowData.Features == nil { |