test(codemode): drop leftover $codemode references (#36451)

This commit is contained in:
Aiden Cline 2026-07-11 14:15:11 -05:00 committed by GitHub
commit 75e8fd4da2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 23 deletions

View file

@ -1,13 +1,14 @@
# @opencode-ai/codemode # @opencode-ai/codemode
CodeMode is a lightweight, JavaScript-like DSL for model-written orchestration programs, backed by a pure JavaScript This is our take on code mode. Programs are written in a lightweight, JavaScript-like DSL and run in the package's
interpreter - no `eval`, no VM, no code generation. A program can only call the schema-described tools its host own interpreter. They never execute as actual JavaScript, so there is no runtime to escape into. The interpreter
supplies: it can sequence calls, transform plain data, branch, loop, and run independent calls in parallel, without itself can reach nothing; every effect a program has goes through a tool you explicitly supplied. The tradeoff is a
ambient filesystem, process, network, module, or application authority. Instead of many model round trips, the model bounded language rather than full JavaScript: the [interpreter support checklist](./interpreter-support.md) documents
writes one small program that does the orchestration in code. exactly what is supported.
The supported language and standard-library surface is documented exhaustively in the [Cloudflare's post](https://blog.cloudflare.com/code-mode/) introduced the idea. Their implementation executes
[interpreter support checklist](./interpreter-support.md). generated code in isolate sandboxes. We took a lighter route: a pure interpreter that runs wherever your application
runs, no sandbox required.
## How it differs from JavaScript ## How it differs from JavaScript

View file

@ -761,11 +761,6 @@ describe("CodeMode public contract", () => {
"tools.thread.generateImage", "tools.thread.generateImage",
) )
} }
// The retired $codemode namespace is gone from the tools tree entirely.
const removed = await Effect.runPromise(runtime.execute(`return await tools.$codemode.search({ query: "file" })`))
expect(removed.ok).toBe(false)
if (!removed.ok) expect(removed.error.kind).toBe("UnknownTool")
}) })
test("search is a counted tool call: it burns maxToolCalls and fires the hooks", async () => { test("search is a counted tool call: it burns maxToolCalls and fires the hooks", async () => {
@ -1195,11 +1190,4 @@ describe("CodeMode public contract", () => {
} }
expect(elapsedMs).toBeLessThan(3_000) expect(elapsedMs).toBeLessThan(3_000)
}) })
test("a host $codemode namespace is an ordinary namespace now that search is a built-in", async () => {
const runtime = CodeMode.make({ tools: { $codemode: { lookup } } })
const result = await Effect.runPromise(runtime.execute(`return await tools.$codemode.lookup({ id: "order_1" })`))
expect(result.ok).toBe(true)
if (result.ok) expect(result.value).toStrictEqual({ id: "order_1", status: "open" })
})
}) })

View file

@ -52,10 +52,8 @@ describe("Object.keys over tool references", () => {
expect(await value(`return Object.keys(tools.github.list_issues)`)).toEqual([]) expect(await value(`return Object.keys(tools.github.list_issues)`)).toEqual([])
}) })
test("search is a global built-in function, not a tools namespace", async () => { test("search is a global built-in function", async () => {
expect(await value(`return typeof search`)).toBe("function") expect(await value(`return typeof search`)).toBe("function")
const failure = await error(`return Object.keys(tools.$codemode)`)
expect(failure.kind).toBe("UnknownTool")
}) })
test("an unknown namespace is an UnknownTool error pointing at the discovery idioms", async () => { test("an unknown namespace is an UnknownTool error pointing at the discovery idioms", async () => {