Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tidy-apes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"opencode-drive": patch
---

Support current OpenCode V2 development checkouts and reject checkouts without simulation support.
6 changes: 6 additions & 0 deletions packages/drive/src/instance/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ export const prepareDev = Effect.fn("OpenCodeInstance.prepareDev")(function* (
const root = resolve(directory)
const entrypoint = join(root, "packages", "cli", "src", "index.ts")
const solid = join(root, "packages", "tui", "node_modules", "@opentui", "solid")
const simulation = join(root, "packages", "simulation", "package.json")
const standalone = yield* Effect.tryPromise({
try: async () => {
if (!(await Bun.file(entrypoint).exists()))
throw new Error(`OpenCode development entrypoint not found: ${entrypoint}`)
if (!(await Bun.file(join(solid, "package.json")).exists()))
throw new Error(`OpenCode development dependency not found: ${solid}; run bun install in ${root}`)
if (!(await Bun.file(simulation).exists()))
throw new Error(
`OpenCode development checkout does not include simulation support: ${simulation}; --dev requires a V2 checkout with packages/simulation`,
)
const preload = join(artifacts, "node_modules", "@opentui", "solid")
await mkdir(join(artifacts, "node_modules", "@opentui"), {
recursive: true,
Expand All @@ -38,6 +43,7 @@ export const prepareDev = Effect.fn("OpenCodeInstance.prepareDev")(function* (
return {
command: [...base, ...(standalone ? ["--standalone"] : [])],
scriptedCommand: base,
serviceFlag: standalone ? "--service" : "--register",
preloads,
}
})
2 changes: 1 addition & 1 deletion packages/drive/src/instance/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export const make = Effect.fn("OpenCodeInstance.make")(function* (
const serverCommand = [
...scriptedCommand,
"serve",
"--service",
dev?.serviceFlag ?? "--service",
"--port",
String(yield* freePort),
]
Expand Down
36 changes: 36 additions & 0 deletions packages/drive/test/instance/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,54 @@ test("uses standalone mode and inheritable preloads for V2 development checkouts
directories.push(root, artifacts)
await mkdir(join(root, "packages", "cli", "src", "services"), { recursive: true })
await mkdir(join(root, "packages", "tui", "node_modules", "@opentui", "solid"), { recursive: true })
await mkdir(join(root, "packages", "simulation"), { recursive: true })
await Promise.all([
Bun.write(join(root, "packages", "cli", "src", "index.ts"), ""),
Bun.write(join(root, "packages", "cli", "src", "services", "standalone.ts"), ""),
Bun.write(join(root, "packages", "tui", "node_modules", "@opentui", "solid", "package.json"), "{}"),
Bun.write(join(root, "packages", "simulation", "package.json"), "{}"),
])

const result = await Effect.runPromise(prepareDev(artifacts, root))

expect(result.command.at(-1)).toBe("--standalone")
expect(result.scriptedCommand.at(-1)).toBe(join(root, "packages", "cli", "src", "index.ts"))
expect(result.serviceFlag).toBe("--service")
expect(result.preloads).toContain("--conditions=browser")
expect(result.preloads).toContain(
`--preload=${join(root, "packages", "tui", "node_modules", "@opentui", "solid", "scripts", "preload.js")}`,
)
})

test("uses the register serve dialect for current V2 development checkouts", async () => {
const root = await mkdtemp(join(tmpdir(), "opencode-drive-dev-"))
const artifacts = await mkdtemp(join(tmpdir(), "opencode-drive-artifacts-"))
directories.push(root, artifacts)
await mkdir(join(root, "packages", "cli", "src"), { recursive: true })
await mkdir(join(root, "packages", "tui", "node_modules", "@opentui", "solid"), { recursive: true })
await mkdir(join(root, "packages", "simulation"), { recursive: true })
await Promise.all([
Bun.write(join(root, "packages", "cli", "src", "index.ts"), ""),
Bun.write(join(root, "packages", "tui", "node_modules", "@opentui", "solid", "package.json"), "{}"),
Bun.write(join(root, "packages", "simulation", "package.json"), "{}"),
])

const result = await Effect.runPromise(prepareDev(artifacts, root))

expect(result.command.at(-1)).toBe(join(root, "packages", "cli", "src", "index.ts"))
expect(result.serviceFlag).toBe("--register")
})

test("rejects development checkouts without simulation support", async () => {
const root = await mkdtemp(join(tmpdir(), "opencode-drive-dev-"))
const artifacts = await mkdtemp(join(tmpdir(), "opencode-drive-artifacts-"))
directories.push(root, artifacts)
await mkdir(join(root, "packages", "cli", "src"), { recursive: true })
await mkdir(join(root, "packages", "tui", "node_modules", "@opentui", "solid"), { recursive: true })
await Promise.all([
Bun.write(join(root, "packages", "cli", "src", "index.ts"), ""),
Bun.write(join(root, "packages", "tui", "node_modules", "@opentui", "solid", "package.json"), "{}"),
])

await expect(Effect.runPromise(prepareDev(artifacts, root))).rejects.toThrow("does not include simulation support")
})