diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..570428d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,3 @@ +# CI-safe tests and scripts + +Do not assume local directories, files, tools, or generated artifacts exist in a clean CI environment. In particular, `/tmp/opencode` is an agent-environment convenience, not a CI guarantee. Tests should create temporary directories with `node:os` `tmpdir()` and `mkdtemp(join(tmpdir(), prefix))`, explicitly create required parent directories and fixtures, and clean up the files they create. diff --git a/tests/install.test.ts b/tests/install.test.ts index 3e5906a..91023cb 100644 --- a/tests/install.test.ts +++ b/tests/install.test.ts @@ -10,6 +10,7 @@ import { symlink, writeFile, } from "node:fs/promises"; +import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { createHash } from "node:crypto"; import { install } from "../scripts/install.js"; @@ -56,7 +57,7 @@ async function run( return { exitCode, stdout, stderr }; } async function fixture() { - const directory = await mkdtemp("/tmp/opencode/plugin-install-"); + const directory = await mkdtemp(join(tmpdir(), "plugin-install-")); directories.push(directory); const source = join(directory, "package with spaces"); const config = join(directory, "config with spaces"); diff --git a/tests/package.test.ts b/tests/package.test.ts index 474fcd1..9318d30 100644 --- a/tests/package.test.ts +++ b/tests/package.test.ts @@ -1,12 +1,13 @@ import { expect, test } from "bun:test"; import { mkdir, mkdtemp, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; import { join } from "node:path"; import { Host } from "@opencode/plugin/host"; import { build } from "../scripts/build.js"; import { install } from "../scripts/install.js"; test("packed package has independent native plugins and quota-only TUI discovery", async () => { - const directory = await mkdtemp("/tmp/opencode/plugin-package-"); + const directory = await mkdtemp(join(tmpdir(), "plugin-package-")); try { await build(); const archive = join(directory, "stanp-opencode.tgz");