+17





![opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)

![opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)
![opencode-agent[bot]](/assets/img/avatar_default.png)
opencode-agent[bot]
opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
LukeParkerDev
opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Aiden Cline
Brendan Allan
Aarav Sareen
Julian Coy
Brendan Allan
usrnk1
opencode
Vladimir Glafirov
Adam
Frank
Jay
Dustin Deus
Kit Langton
James Long
Simon Klee
Jay
Jack
David Hill
Aiden Cline
James Long
冯基魁
Aiden Cline
Victor Navarro
43ecf3ff1b
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Julian Coy <julian@ex-machina.co> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Jay <air@live.ca> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: James Long <jlongster@users.noreply.github.com> Co-authored-by: 冯基魁 <56265583+fengjikui@users.noreply.github.com> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com> Co-authored-by: Victor Navarro <vn4varro@gmail.com>
90 lines
3.1 KiB
TypeScript
90 lines
3.1 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { Effect } from "effect"
|
|
import fs from "fs/promises"
|
|
import path from "path"
|
|
import yargs from "yargs"
|
|
import { tmpdir } from "../../fixture/fixture"
|
|
import { TuiThreadCommand, resolveThreadDirectory } from "../../../src/cli/cmd/tui"
|
|
import { cliIt } from "../../lib/cli-process"
|
|
|
|
describe("tui thread", () => {
|
|
test("loads the TUI integration lazily", async () => {
|
|
const source = await Bun.file(new URL("../../../src/cli/cmd/tui.ts", import.meta.url)).text()
|
|
|
|
expect(source).toContain('await import("../tui/layer")')
|
|
expect(source).toMatch(/await import\(["']@\/plugin\/tui\/runtime["']\)/)
|
|
expect(source).not.toContain('import("./app")')
|
|
})
|
|
|
|
test("forwards the CLI environment to the TUI worker", async () => {
|
|
const source = await Bun.file(new URL("../../../src/cli/cmd/tui.ts", import.meta.url)).text()
|
|
|
|
expect(source).toMatch(/new Worker\(file, \{\s*env: Object\.fromEntries\(\s*Object\.entries\(process\.env\)/)
|
|
})
|
|
|
|
async function check(project?: string) {
|
|
await using tmp = await tmpdir({ git: true })
|
|
const link = path.join(path.dirname(tmp.path), path.basename(tmp.path) + "-link")
|
|
const type = process.platform === "win32" ? "junction" : "dir"
|
|
|
|
try {
|
|
await fs.symlink(tmp.path, link, type)
|
|
expect(resolveThreadDirectory(project, link, tmp.path)).toBe(tmp.path)
|
|
} finally {
|
|
await fs.rm(link, { recursive: true, force: true }).catch(() => undefined)
|
|
}
|
|
}
|
|
|
|
test("uses the real cwd when PWD points at a symlink", async () => {
|
|
await check()
|
|
})
|
|
|
|
test("uses the real cwd after resolving a relative project from PWD", async () => {
|
|
await check(".")
|
|
})
|
|
|
|
test("resolves a relative project from PWD when cwd differs", async () => {
|
|
await using pwd = await tmpdir({ git: true })
|
|
await using cwd = await tmpdir({ git: true })
|
|
|
|
expect(resolveThreadDirectory(".", pwd.path, cwd.path)).toBe(pwd.path)
|
|
expect(resolveThreadDirectory(undefined, pwd.path, cwd.path)).toBe(cwd.path)
|
|
})
|
|
|
|
test("preserves boolean negation for existing options", async () => {
|
|
const args = await yargs([])
|
|
.command({ ...TuiThreadCommand, handler: () => {} })
|
|
.exitProcess(false)
|
|
.parse(["--mdns", "--no-mdns"])
|
|
|
|
expect(args.mdns).toBe(false)
|
|
})
|
|
|
|
cliIt.live("rejects removed top-level mini alias", ({ opencode }) =>
|
|
Effect.gen(function* () {
|
|
const result = yield* opencode.spawn(["--mini"])
|
|
|
|
opencode.expectExit(result, 1)
|
|
expect(result.stderr).not.toContain("opencode mini requires a TTY stdout")
|
|
}),
|
|
)
|
|
|
|
cliIt.live("rejects removed run mini flag", ({ opencode }) =>
|
|
Effect.gen(function* () {
|
|
const result = yield* opencode.spawn(["run", "--mini"])
|
|
|
|
opencode.expectExit(result, 1)
|
|
expect(result.stderr).not.toContain("opencode mini requires a TTY stdout")
|
|
}),
|
|
)
|
|
|
|
cliIt.live("rejects removed attach mini alias", ({ opencode }) =>
|
|
Effect.gen(function* () {
|
|
const result = yield* opencode.spawn(["attach", "http://127.0.0.1:1", "--mini"])
|
|
|
|
opencode.expectExit(result, 1)
|
|
expect(result.stderr).not.toContain("opencode mini requires a TTY stdout")
|
|
}),
|
|
)
|
|
})
|