Skip to content

chore(codemode): bump psychoscript to 0.5.0 - #67613

Merged
rekram1-node merged 1 commit into
devfrom
psychoscript-0-4
Dec 1, 2026
Merged

rekram1-node merged 1 commit into
devfrom
psychoscript-0-4

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Bumps psychoscript, the Code Mode interpreter, from 0.3.0 to 0.5.0. Nothing in OpenCode needed changes; I want it for Runtime.compile (a follow-up uses it to share one parse between the background check and the run) and for 0.5.0's perf work.

Behavior changes models will see in execute programs (from the psychoscript changelog, 0.4.0 and 0.5.0):

- [10, 9, 1].sort()              // [1, 10, 9]
+ [10, 9, 1].sort()              // [1, 9, 10], numbers-only (or BigInt-only) default sort is numeric
- [{a: 1}, {a: 2}].sort()        // sorted by "[object Object]"
+ [{a: 1}, {a: 2}].sort()        // TypeError asking for a comparator
  Object.entries(o).sort()       // still sorts by key: arrays, Dates, URLs, Errors etc. sort by their strings
- JSON.parse(alreadyParsed)      // parses "[object Object]" and throws
+ JSON.parse(alreadyParsed)      // returns the object or array unchanged
- fn.toString()                  // no source text
+ fn.toString()                  // the function's source as written

0.4.0 threw on a default sort over any object, arrays and Dates included; 0.5.0 narrowed that to plain objects and class instances, so sorting entries or dates without a comparator works again.

Also new: ArrayBuffer, BigInt (a too-large BigInt literal now fails to parse), more Symbol support, more console methods (assert, count, group, time, ...), Array.fromAsync, callable host functions with their own properties, fuel checks when new and super() enter a constructor, long sparse arrays in map/filter/etc., and RegExp, Uint8Array/Buffer and Promise fixes. None of OpenCode's tests depended on the old sort or JSON.parse behavior.

0.5.0's perf work: a runtime hands untouched built-ins from one run to the next, runs of the same source share their parse and bytecode, callback built-ins (map, filter, sort, ...) loop natively, plain host results and JSON copy directly, and a Bun process that has run many different programs no longer runs later ones 2-4x slower.

I left the new Runtime.make options at their defaults. engine is only a warm-up hint and defaults to JavaScriptCore on Bun and V8 on Node, which is what OpenCode runs on. reuse defaults to on and only hands over built-ins no program changed, so isolation between runs stays the same.

The snapshot format went to 4, so runs saved by 0.3.0 don't resume. Nothing in OpenCode persists snapshots: toBytes/fromBytes/resume are exported from @opencode/codemode but nothing in core, server or sdk calls them, so no saved runs break.

I ran the sort, JSON.parse and toString examples above through CodeMode.execute on 0.5.0 and they behave as shown.

Checks:

  • packages/codemode: bun test, 326 pass
  • packages/core: Code Mode, automation, tool and job tests, 797 pass, 1 fail: ShellTool conditional process substitution > conditional substitutions respect always fails locally with wait: pid ... is not a child of this shell, a bash issue unrelated to Code Mode
  • bun run check at the root
  • bunx tsc -p tsconfig.build.json --noEmit in packages/server, packages/sdk, packages/simulation

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. I installed 0.4.0 and ran the codemode tests (326 pass) and core's Code Mode tests (80 pass). tsc --noEmit is clean in both packages. I also ran a few programs through CodeMode.execute: the numeric default sort, the comparator error when sorting objects, JSON.parse on an already-parsed object, fn.toString(), and ArrayBuffer/BigInt all behave as described. Nothing in core, server or sdk persists snapshots, so the move to snapshot format 4 breaks no saved runs.

psychoscript now brings its own acorn 8.16.0 while codemode pins 8.15.0, so the lockfile has two acorn copies. That's harmless, since scan.ts only imports acorn's types.

Public API: unchanged.

@rekram1-node rekram1-node changed the title chore(codemode): bump psychoscript to 0.4.0 chore(codemode): bump psychoscript to 0.5.0 Dec 1, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still looks good on 0.5.0. Codemode tests pass (326) and core's Code Mode tests pass (80), and tsc --noEmit is clean in both packages. I ran the changelog examples through CodeMode.execute and they behave as described, including Object.entries(...).sort() and Date sorts without a comparator working again.

Because built-in reuse is now on by default, I also checked isolation between runs: a run that changed Array.prototype, Math.max and JSON.stringify didn't affect the next run on the same runtime.

Public API: unchanged.

@rekram1-node
rekram1-node merged commit 31aa826 into dev Dec 1, 2026
12 checks passed
@rekram1-node
rekram1-node deleted the psychoscript-0-4 branch December 1, 2026 23:09
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.

1 participant