feat: add experimental feature-flag system - #205
Conversation
🦋 Changeset detectedLatest commit: 51fdd6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71275b0a29
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
3d84d46 to
85aaf54
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85aaf54e00
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
390215a to
6a478de
Compare
Introduce a central, env-driven flag registry in agent-core. Each flag is declared once with an id, full env var name, default, and surface. Within agent-core, flags are consulted through a process-global 'flags' constant that reads live process.env. Resolution precedence: master switch KIMI_CODE_EXPERIMENTAL_FLAG > per-feature KIMI_CODE_EXPERIMENTAL_<NAME> > registry default, with lenient boolean parsing via parseBooleanEnv. FlagId is a literal union derived from the registry for compile-time autocomplete and typo-checking.
SDK boundary: KimiHarness.getExperimentalFlags() returns the resolved values over RPC, and the SDK re-exports only the flag *types* — no runtime value crosses the boundary. The TUI caches that snapshot once at startup and reads it synchronously for command gating.
Gate the plugin system behind the 'plugins' flag, off by default: PluginManager.load() consults flags.enabled('plugins'), so when off no installed plugins are loaded or activated, and the TUI /plugins command is hidden from the palette and resolves as an unknown command.
Tests cover the resolver precedence matrix, registry invariants, the FlagId type guard, the live-env singleton, the plugin-load gate, the getExperimentalFlags RPC, and the TUI command gating.
6a478de to
904985d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51fdd6c4da
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/agent-core": minor | |||
There was a problem hiding this comment.
Add the affected packages to the changeset
This changeset only selects @moonshot-ai/agent-core, but the diff also changes apps/kimi-code startup/command behavior and packages/node-sdk public API (KimiHarness.getExperimentalFlags and exported flag types). The repo’s gen-changesets rules require listing packages that were actually changed and adding @moonshot-ai/kimi-code when bundled internal changes enter the CLI; otherwise the release PR can omit the CLI/SDK version and changelog entries for this user-visible/API change.
Useful? React with 👍 / 👎.
Related Issue
No tracking issue — the problem is explained below.
Problem
Experimental features have to live in the codebase before they are ready for all users, but today they are gated only by ad-hoc
process.envreads scattered across packages, with several different boolean-parsing styles and no single place to see what exists.What changed
Adds the experimental-flag infrastructure. No flags are defined yet — the registry ships empty; adding the first one is a one-line edit plus a
flags.enabled('id')check.packages/agent-core/src/flags/): each flag is declared once as{ id, env, default, surface }inFLAG_DEFINITIONS, resolved by a process-globalflagsconstant that reads liveprocess.env. Precedence (high → low): master switchKIMI_CODE_EXPERIMENTAL_FLAG→ per-featureKIMI_CODE_EXPERIMENTAL_<NAME>→ registry default, with lenient boolean parsing viaparseBooleanEnv.FlagIdis a literal union derived from the registry, givingflags.enabled('…')autocomplete and typo-checking.KimiHarness.getExperimentalFlags()returns the resolved values over RPC; the SDK re-exports only the flag types — no runtime value crosses the boundary.experimentalFlag; when that flag is off the command is hidden from the palette and resolved as an unknown command. Inert today since no command is gated.AGENTS.mdpoints to the registry.The changeset intentionally lists only
@moonshot-ai/agent-core(the home of the flag system).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.