Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
Point OpenCode at the workspace by setting PWD for dispatched harnesses (#345)
Matthew Kissinger953ab23bbc81
diff --git a/docs/harnesses.md b/docs/harnesses.mdindex 3d127dba..04686404 100644--- a/docs/harnesses.md+++ b/docs/harnesses.md@@ -111,7 +111,7 @@ Verified against the versions in the footer. The traps are not stylistic -- each| agy | `--print=TEXT` | **attached to the flag** | print mode | `--add-dir` || claude | `-p` then `TEXT` | positional; `-p` selects print mode | `--permission-mode acceptEdits` + `--allowedTools` | `--add-dir` || codex | `exec TEXT` | positional after `exec` | `--approve-for-me` | `--cd` |-| opencode | `run --standalone TEXT` | positional | `--auto` | process CWD only |+| opencode | `run --standalone TEXT` | positional | `--auto` | `PWD`, then process CWD || copilot | `-p TEXT` | flag value | `--allow-all-tools` | `-C` and `--add-dir` || cursor-agent | `-p` then `TEXT` | **positional; `-p` is a boolean** | `--force --approve-mcps --trust` | `--workspace` || hermes | `-z TEXT` | flag value | none; `-z` resolves prompts | process CWD only |@@ -129,6 +129,11 @@ The ones that cost real time:- **`codex exec` pins the approval policy to `never`,** under which an MCP call is not askedabout, it is refused. `--approve-for-me` is the flag that both selects a workspace-writesandbox and moves approval to `on-request`.+- **OpenCode 2.2 reads `PWD` before the process working directory.** `opencode run` uses+ `process.env.PWD ?? process.cwd()`, and POSIX shells and Git Bash export `PWD`. A launcher+ that sets only `cwd` sends OpenCode to the caller's directory: it skips the workspace's+ `opencode.json`, so the model never sees the Kiln tools. `scripts/harness.mjs` sets `PWD` to+ the child's working directory; set it yourself when you launch OpenCode another way.- **A bare temp directory is not a trusted directory.** codex needs `--skip-git-repo-check`;cursor-agent needs `--trust`.- **An older Claude Code does not know newer model ids.** On 29 September 2026 a driver'sdiff --git a/scripts/harness.mjs b/scripts/harness.mjsindex 3aa28b25..e88b7c47 100644--- a/scripts/harness.mjs+++ b/scripts/harness.mjs@@ -443,7 +443,11 @@ export function run(// lets `killTree` signal the group rather than just the shell in front of it.// Windows has no process groups to lead; `taskkill /T` covers it there.const detached = process.platform !== 'win32';- const childEnv = env ? { ...process.env, ...env } : process.env;+ // PWD follows cwd. POSIX shells (and Git Bash) export PWD, and OpenCode 2.2's+ // `run` takes its directory from `process.env.PWD ?? process.cwd()`, so an+ // inherited PWD sends it to the caller's directory: it skips the workspace's+ // opencode.json and Kiln MCP server and works in the caller's project.+ const childEnv = { ...process.env, ...env, PWD: resolve(cwd) };const child = resolved.shell? spawn(quoteArg(resolved.cmd), args.map(quoteArg), {cwd,diff --git a/scripts/harness.test.mjs b/scripts/harness.test.mjsindex 129ef45b..9148b734 100644--- a/scripts/harness.test.mjs+++ b/scripts/harness.test.mjs@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process';import { copyFileSync, mkdirSync, mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';-import { HARNESSES, resolveBin } from './harness.mjs';+import { HARNESSES, resolveBin, run } from './harness.mjs';test('OpenCode uses the caller working directory without removed V1 flags', () => {const args = HARNESSES.opencode.argv({@@ -16,6 +16,32 @@ test('OpenCode uses the caller working directory without removed V1 flags', () =expect(args.at(-1)).toBe('Build a curved leaf');});+// OpenCode 2.2.0's `run` takes its directory from `process.env.PWD ?? process.cwd()`+// and changes into it, so a child that inherits the caller's PWD ignores `cwd` and+// loads the caller's project instead of the workspace and its MCP configuration.+test('run gives the child a PWD that matches its working directory', async () => {+ const root = mkdtempSync(join(tmpdir(), 'kiln-harness-pwd-'));+ const saved = process.env.PWD;+ try {+ const workspace = join(root, 'workspace');+ mkdirSync(workspace);+ process.env.PWD = root;+ for (const env of [null, { PWD: root, KILN_HARNESS_PROBE: '1' }]) {+ const result = await run(+ process.execPath,+ ['-e', 'process.stdout.write(JSON.stringify(process.env.PWD ?? null))'],+ { cwd: workspace, env },+ );+ expect(result.code).toBe(0);+ expect(JSON.parse(result.out)).toBe(workspace);+ }+ } finally {+ if (saved === undefined) delete process.env.PWD;+ else process.env.PWD = saved;+ rmSync(root, { recursive: true, force: true });+ }+});+test.skipIf(process.platform !== 'win32')('explicit executable paths bypass the shell even with forward slashes and spaces',() => {