Repository navigation
feat(core): enable the Code Mode VM by default in dev builds via the flag registry - #62444
Merged
Merged
Conversation
There was a problem hiding this comment.
The change looks good. The new tool-execute.test.ts cases fail on the base branch (local/dev with no config, and OPENCODE_FLAGS=all on latest, all run the legacy engine) and pass with this PR. The core Code Mode, flag and execute tests pass (60/60), and typecheck:tsc is clean for core and schema. Flag.enabled needs no new services in execute/check: App.Metadata and Flag.Overrides have defaults, and Config is still optional.
Public API impact:
experimental.codemode_vm(config/OpenAPI): the key is kept. Only its description and position in the schema change. The default changes from always off to on inlocal/devbuilds and off in every other channel.experimental.all_flags: trueandOPENCODE_FLAGS=allnow also turn oncodemode_vm.OPENCODE_FLAGS=codemodeVm/-codemodeVm(env): no longer recognised. Users of that form need to switch tocodemode_vm. The camelCase config key still works.
Release builds keep their current behaviour, and configs that set the key explicitly are unaffected. The camelCase env form is the only break.
No blocking concerns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codemode_vmis now a regular entry in the feature-flag registry (ConfigFlag.registry), so it resolves throughFlag.resolveliketodo,media_blob,schedulesandartifacts. The hand-writtenvmEnabledinpackages/core/src/codemode/tool.tsis gone. Bothexecuteandchecknow readFlag.enabled("codemode_vm"). The per-engine runtime caches are unchanged.packages/schema/src/config/flag.ts: registerscodemode_vm.packages/schema/src/config/experimental.ts: drops the hand-writtencodemode_vmfield. The registry spread generatesexperimental.codemode_vmwith the shared "Defaults to on in local and dev builds and off in releases." description. ThecodemodeVm→codemode_vmconfig normalisation is kept.openapi.jsonand the client types. Only the field order and description change.Default per channel
The rule comes from
onByDefaultinpackages/core/src/flag.ts:channel === "local" || channel === "dev".codemode_vmdefaultbun run dev)localdev)devlatestbetapr,<branch>unknownWhy a production binary resolves it to false:
.github/release/plan-release.shsetschannel="latest"for a dispatch with a bump or version ondev.release.ymlpasses it asOPENCODE_CHANNEL.packages/scriptexposes it asScript.channel, andpackages/cli/script/build.tsbakes it in withdefine: { OPENCODE_CHANNEL: "'latest'" }. Thenpackages/cli/src/version.ts→App.Metadata.channel→Flag.resolver→onByDefault("latest") === false.Opt in / opt out
Precedence is
OPENCODE_FLAGS>experimental.codemode_vm>experimental.all_flags: true> channel default.OPENCODE_FLAGS=codemode_vm,OPENCODE_FLAGS=all,experimental.codemode_vm: true(orcodemodeVm), orexperimental.all_flags: true.OPENCODE_FLAGS=-codemode_vm(alsoall,-codemode_vm), orexperimental.codemode_vm: false. An explicitfalsebeatsall_flags: true.OPENCODE_FLAGS=codemodeVmenv form is no longer accepted. Env flags use registry keys, the same as every other flag. The camelCase config key still works.Verification
tool-execute.test.tscases run the realexecutetool and detect which engine ran:local/devwith no config → VMlatest,beta,pr, branch andunknown→ legacylatestplusOPENCODE_FLAGS=codemode_vm, configtrue,allorall_flags→ VMdevplus-codemode_vm,all,-codemode_vm, configfalse, orall_flagswithcodemode_vm: false→ legacyflag.test.ts: every registered flag, includingcodemode_vm, is off onlatest.define: bundled a probe ofcli/src/version.ts+Flag.allwithbun build --define OPENCODE_CHANNEL='latest':latest {"enabled":false,"source":"default"}beta→ falsedev→ truelocal) → truelatestwithOPENCODE_FLAGS=codemode_vm→{"enabled":true,"source":"env"}packages/core:bun test test/codemode* test/flag.test.ts test/tool* test/configpassed 766, failed 0.packages/schema:bun testpassed 92.packages/client:test/promise.test.tspassed 41.typecheck:tscis clean for core, schema, client and protocol.protocol check:generatedis clean.Visual
Added by the opencode bot (AI-generated).
Public API: codemode_vm moves to the flag registry: on by default in local/dev builds, included in all_flags/OPENCODE_FLAGS=all; OPENCODE_FLAGS=codemodeVm (camelCase env) no longer accepted (config keys unchanged)