Skip to content

Conversation

@potofpie
Copy link
Member

@potofpie potofpie commented Sep 30, 2025

Summary by CodeRabbit

  • New Features
    • Added feature flag support (disabled by default).
    • Introduced a hidden CLI flag to enable Prompts Evaluations.
    • Feature flags are initialized at startup.
    • Version command (with --long) now shows Prompts Evaluations status.
    • Bundle command logs when Prompts Evaluations is enabled.

https://screen.studio/share/BiwDiMBl?state=uploading

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Adds a feature-flag subsystem for "prompts evaluations", initializes it during CLI startup, exposes helpers to query the flag, logs the flag state in the bundle command when enabled, and prints the flag status in the long version output. No other control flow or error handling changes.

Changes

Cohort / File(s) Change Summary
Feature flags subsystem
cmd/feature_flags.go
New feature-flag implementation using Cobra + Viper: defines FeaturePromptsEvals, registers a hidden persistent CLI flag --enable-prompts-evals (default false) without automatic Viper binding, provides IsFeatureEnabled, CheckFeatureFlag (prefers CLI flag, updates config only when explicitly enabled), IsPromptsEvalsEnabled, GetEnabledFeatures, and IsAnyFeatureEnabled.
Initialization
cmd/root.go
Calls SetupFeatureFlags(rootCmd) during init (before cobra.OnInitialize(initConfig)) to register the feature flag.
Command usage
cmd/bundle.go, cmd/version.go
bundle.go: queries IsPromptsEvalsEnabled() and logs "Prompts evaluations feature is enabled" when true; version.go: when --long is used, prints Prompts Evals: Enabled if the feature is enabled.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant CLI as CLI (cobra)
  participant FF as Feature Flags (viper)
  participant Cmd as Command (bundle/version)

  Note over CLI: binary startup
  U->>CLI: invoke
  CLI->>FF: SetupFeatureFlags(rootCmd)
  Note over FF: register hidden flag (--enable-prompts-evals), no auto-bind
  CLI->>Cmd: execute chosen command

  alt bundle command
    Cmd->>FF: IsPromptsEvalsEnabled()
    FF-->>Cmd: bool
    opt enabled
      Cmd->>Cmd: log "Prompts evaluations feature is enabled"
    end
    Cmd->>Cmd: continue bundling
  else version --long
    Cmd->>FF: IsPromptsEvalsEnabled()
    FF-->>Cmd: bool
    opt enabled
      Cmd->>U: print "Prompts Evals: Enabled"
    end
    Cmd->>U: print version details
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I toggled a flag with a flick of my ear,
A hush-hidden switch only devs can hear.
In bundles I whisper, “evals are on,”
In versions I note it, then quickly hop on.
Carrot-shaped configs, neatly aligned—
Feature burrows opened, cleanly defined. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly reflects the primary change in this PR, namely adding support for a feature flag mechanism to the CLI configuration, and it is concise, clear, and directly related to the main change without extraneous details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-flag-cli

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1f9081 and 2836c50.

📒 Files selected for processing (2)
  • cmd/bundle.go (1 hunks)
  • cmd/feature_flags.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/bundle.go
  • cmd/feature_flags.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)

Comment @coderabbitai help to get the list of available commands and usage tips.

@potofpie potofpie changed the title Added feature flag to the config Added feature flag to the CLI config Sep 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (7)
cmd/feature_flags.go (4)

15-21: BindPFlag/MarkHidden errors are ignored; handle them to avoid silent misconfig

Cobra/Viper return errors here; capture them so a bind/flag regression doesn’t silently disable the feature.

 func SetupFeatureFlags(rootCmd *cobra.Command) {
   // Set default values
   viper.SetDefault("features.enable_prompts_evals", false)
   // Add command line flags
-  rootCmd.PersistentFlags().Bool("enable-prompts-evals", false, "Enable prompts evals")
-  rootCmd.PersistentFlags().MarkHidden("enable-prompts-evals")
-  viper.BindPFlag("features.enable_prompts_evals", rootCmd.PersistentFlags().Lookup("enable-prompts-evals"))
+  rootCmd.PersistentFlags().Bool("enable-prompts-evals", false, "Enable prompt evaluations")
+  if err := rootCmd.PersistentFlags().MarkHidden("enable-prompts-evals"); err != nil {
+    cobra.CheckErr(err)
+  }
+  if err := viper.BindPFlag("features.enable_prompts_evals", rootCmd.PersistentFlags().Lookup("enable-prompts-evals")); err != nil {
+    cobra.CheckErr(err)
+  }
 }

Based on learnings.


30-33: Fix inaccurate docstring

The comment says “IsExperimentalEnabled” but the function is IsPromptsEvalsEnabled.

-// IsExperimentalEnabled checks if experimental features are enabled
+// IsPromptsEvalsEnabled reports whether the "prompt evaluations" feature flag is enabled.
 func IsPromptsEvalsEnabled() bool {
   return IsFeatureEnabled(FeaturePromptsEvals)
 }

45-48: Future‑proof IsAnyFeatureEnabled

Route through GetEnabledFeatures so adding more flags doesn’t require touching this helper.

-func IsAnyFeatureEnabled() bool {
-  return IsPromptsEvalsEnabled()
-}
+func IsAnyFeatureEnabled() bool {
+  return len(GetEnabledFeatures()) > 0
+}

8-11: Consider constants for CLI flag and viper key to avoid string drift

Small ergonomics tweak: define flag/key constants so usage sites don’t diverge as features grow.

Example:

const (
  viperKeyPrefix        = "features."
  FlagPromptsEvals      = "enable-prompts-evals"
  ViperKeyPromptsEvals  = viperKeyPrefix + FeaturePromptsEvals
)

Then bind using ViperKeyPromptsEvals and FlagPromptsEvals.

cmd/version.go (1)

38-41: Unify terminology and optionally show disabled state

Current label (“Prompts Evals”) differs from bundle log (“Prompts evaluations”). Consider “Prompt Evaluations” everywhere and print both states for clarity.

-// Example of using feature flags
-if IsPromptsEvalsEnabled() {
-  fmt.Println("Prompts Evals: Enabled")
-}
+// Feature flags
+if IsPromptsEvalsEnabled() {
+  fmt.Println("Prompt Evaluations: Enabled")
+} else {
+  fmt.Println("Prompt Evaluations: Disabled")
+}
cmd/bundle.go (1)

42-45: Align wording with version output; consider debug level

Use consistent phrasing (“Prompt Evaluations”) and optionally lower to Debug to reduce noise in normal runs.

-// Check for prompts evals feature flag
-if IsPromptsEvalsEnabled() {
-  projectContext.Logger.Info("Prompts evaluations feature is enabled")
-}
+// Check for prompt evaluations feature flag
+if IsPromptsEvalsEnabled() {
+  projectContext.Logger.Info("Prompt Evaluations feature is enabled")
+  // or: projectContext.Logger.Debug("Prompt Evaluations feature is enabled")
+}
cmd/root.go (1)

138-140: Enable Viper env overrides for dotted feature flags
In initConfig(), before viper.AutomaticEnv(), add:

// allow env vars to override dotted keys
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
cobra.CheckErr(viper.BindEnv("features.enable_prompts_evals"))

Also import "strings" at the top of cmd/root.go. This ensures FEATURES_ENABLE_PROMPTS_EVALS maps correctly to features.enable_prompts_evals.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4309367 and e1f9081.

📒 Files selected for processing (4)
  • cmd/bundle.go (1 hunks)
  • cmd/feature_flags.go (1 hunks)
  • cmd/root.go (1 hunks)
  • cmd/version.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
cmd/bundle.go (1)
cmd/feature_flags.go (1)
  • IsPromptsEvalsEnabled (31-33)
cmd/version.go (1)
cmd/feature_flags.go (1)
  • IsPromptsEvalsEnabled (31-33)
cmd/root.go (1)
cmd/feature_flags.go (1)
  • SetupFeatureFlags (14-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)

@potofpie potofpie merged commit ee4f8a0 into main Sep 30, 2025
14 checks passed
@potofpie potofpie deleted the feature-flag-cli branch September 30, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants