GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(core): run Code Mode on the bytecode VM behind experimental.codemodeVm by jlongster · Pull Request #62358 · anomalyco/opencode Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Benchmark | Legacy (median / min) | VM (median / min) | Speedup (min) |
|---|---|---|---|
| numeric loop | 48.3 ms / 47.6 ms | 17.6 ms / 14.8 ms | 3.2× |
| closure recursion (fib 22) | 35.4 ms / 33.0 ms | 4.7 ms / 4.5 ms | 7.3× |
| array callbacks (50k) | 275.8 ms / 256.5 ms | 81.9 ms / 78.3 ms | 3.3× |
| promise fan-out (5k) | 34.4 ms / 31.1 ms | 14.8 ms / 8.5 ms | 3.7× |
| tool fan-out (1k) | 15.0 ms / 13.6 ms | 8.8 ms / 7.2 ms | 1.9× |
| JSON round-trip | 194.9 ms / 185.7 ms | 53.7 ms / 48.9 ms | 3.8× |
| generator iteration | 85.2 ms / 74.0 ms | 5.1 ms / 4.9 ms | 15.1× |
| string building | 82.9 ms / 75.2 ms | 18.8 ms / 16.6 ms | 4.5× |
| Map/Set ops | 74.8 ms / 70.4 ms | 14.0 ms / 12.9 ms | 5.5× |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 72" width="240" height="72" fill="none"> <style> .t { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: currentColor; } .m { font: 500 8px ui-monospace, SFMono-Regular, Menlo, monospace; fill: currentColor; opacity: 0.55; } .box { stroke: currentColor; stroke-width: 1.25; rx: 5; } .knob { animation: slide 3s ease-in-out infinite; } .vm { animation: glow 3s ease-in-out infinite; } @keyframes slide { 0%, 40% { transform: translateX(0px); } 55%, 90% { transform: translateX(10px); } 100% { transform: translateX(0px); } } @keyframes glow { 0%, 40% { opacity: 0.35; } 55%, 90% { opacity: 0.95; } 100% { opacity: 0.35; } } @media (prefers-reduced-motion: reduce) { .knob { animation: none; transform: translateX(10px); } .vm { animation: none; opacity: 0.9; } } </style> <rect class="box" x="8" y="12" width="108" height="48" opacity="0.45"/> <text class="m" x="16" y="27">experimental</text> <text class="t" x="16" y="42">codemode_vm</text> <rect x="84" y="34" width="22" height="11" rx="5.5" stroke="currentColor" stroke-width="1.2" opacity="0.6"/> <circle class="knob" cx="90" cy="39.5" r="3.5" fill="currentColor"/> <path d="M116 36 H136" stroke="currentColor" stroke-width="1.25" opacity="0.45"/> <polygon points="136,36 131,33 131,39" fill="currentColor" opacity="0.6"/> <rect class="box vm" x="140" y="12" width="92" height="48"/> <text class="t" x="150" y="29">execute</text> <text class="m" x="150" y="42">engine: "vm"</text> <text class="m" x="150" y="52">legacy when off</text> </svg>
Added by the opencode bot (AI-generated).
Public API: adds the optional experimental.codemode_vm config key, default off (backwards compatible)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0cf2d0b to
d500c7f
Compare
d500c7f to
122885f
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The core change looks sound: with the flag off, the code path is the same as dev, and the engine is chosen per call from config, with a separate runtime cache for each engine.
How I checked: core Code Mode, config and normalization tests pass (93/0), and typecheck:tsc is clean. packages/codemode tests pass (1595/0). Sandbox-escape probes against both engines gave identical, contained results: no process or globalThis, the Function constructor is blocked, and an infinite loop ends at the timeout. My end-to-end TUI drive run with the flag on finished the turn, but the execute call never appeared, so it did not confirm anything.
Public API: one addition, the optional boolean config key experimental.codemode_vm (default off), shown in the OpenAPI spec and the generated client types. Config also accepts experimental.codemodeVm as an alias, and OPENCODE_FLAGS accepts codemode_vm / -codemode_vm. All of this is backwards compatible; existing configs are unaffected.
Concerns, both inline:
OPENCODE_FLAGS with its own parser instead of Flag. As a result, all and experimental.all_flags don't turn it on.codemodeVm alias in normalization is a one-off that no other experimental key has.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -71,6 +73,22 @@ export type Inventory = { | |||
| readonly namespaces?: ReadonlyMap<string, ToolNamespace> | |||
| } | |||
|
|
|||
| /** Reads `experimental.codemode_vm` (or `OPENCODE_FLAGS`) on every call; without one, it is off. */ | |||
| const vmEnabled = Effect.gen(function* () { | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This reparses OPENCODE_FLAGS by hand instead of going through Flag, so it doesn't match how the other flags work: OPENCODE_FLAGS=all and experimental.all_flags: true won't turn it on, even though ConfigFlag documents both as turning every flag on. It also accepts codemodeVm in the environment variable. I'd pick one of these:
ConfigFlag.registry and read it with Flag.enabled("codemode_vm"). Note that this would turn it on by default in local and dev builds.partRowsEnabled in session/projector.ts, and drop the environment-variable handling.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -465,6 +465,15 @@ function normalizeExperimental( | |||
| const value = decodeEncoded(schema, experimental[key], ["experimental", key], diagnostics) | |||
| if (value !== undefined) result[key] = value | |||
| }) | |||
| if (!own(experimental, "codemode_vm") && own(experimental, "codemodeVm")) { | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No other experimental key has a camelCase alias, and the schema doesn't mention codemodeVm. A one-off alias for a brand-new key is extra surface we'd have to keep supporting. Unless there's a reason for it, I'd drop it and accept only codemode_vm.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This push only rebases the branch onto dev now that #62357 has merged. The two core commits are unchanged, and the core Code Mode and config tests still pass (93/0) with typecheck:tsc clean.
Both earlier points are still open: the hand-rolled OPENCODE_FLAGS parsing in tool.ts, and the one-off codemodeVm alias in normalization.
Public API: unchanged since the last review. It adds the optional experimental.codemode_vm config key (default off), which shows up in the OpenAPI spec and the generated client types. This is backwards compatible.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.