Skip to content

Add OpenCode support - #150

Open
18dew wants to merge 1 commit into
haydenschmitty:mainfrom
18dew:feat/opencode-support
Open

18dew wants to merge 1 commit into
haydenschmitty:mainfrom
18dew:feat/opencode-support

Conversation

@18dew

@18dew 18dew commented Nov 20, 2026

Copy link
Copy Markdown

What this changes

Floorplan now runs in OpenCode, alongside Claude Code and Codex: the same skill, scripts, map and Health check, on whichever models and providers you've connected there. Install is one line in opencode.json (a generated skills/index.json catalog), then ask for a floorplan or mention @floorplan.

  • Detection (scripts/lib/agent.mjs): OpenCode is recognised by OPENCODE_SESSION_ID / AI_AGENT=opencode, which it sets on every command it runs. Maps record agent: "opencode", so prompts say "Fix with OpenCode" and "Build this with OpenCode" (new branch in the viewer's AGENT mapping).
  • Ask bar (assets/serve.mjs): a new opencode engine runs opencode run --standalone --format json --archived with the prompt on stdin. --standalone starts a private server for the run, which is what makes it read-only: the server's configuration (passed through the OPENCODE_CONFIG_CONTENT environment variable, a layer that loads above the project's own config) denies edits, subagents, web access and shell, except node floorplan/query.mjs * — enforced by OpenCode's permission rules, not the prompt. Runs are archived so they stay out of the session list; follow-ups carry the conversation, as with Codex. The engine is unstructured (OpenCode's CLI has no output schema), so a blueprint's Change switch stays hidden with it, per the existing rule.
  • Tests: a stand-in CLI (tests/fixtures/fake-cli/fake-opencode.mjs) mirrors the real --format json events; new cases in tests/ask.test.mjs (engine fallback, the read-only config and working directory reaching the child, --archived, progress, follow-ups, sign-out) and tests/agents.test.mjs (detection, maps recording the agent, CLI labels). The supply-chain tripwire needed no new assertions — the engine spawns through the same allowed cli.cmd — and its programs list in docs/is-it-safe.md was updated alongside, as that test requires.
  • Docs: new Floorplan in OpenCode, a CHANGELOG entry under Unreleased, and the agent mentions updated across the guides and README.

The flags and event shapes were verified against OpenCode's own V2 source (packages/cli/src/commands/commands.ts, run/run.ts, run/noninteractive.ts, packages/core/src/config.ts): --standalone is what delivers our env-injected config to the server that enforces permissions (a shared background service would not load it), the JSONL events are text deltas plus tool_use and error with no completion event (hence run.onClose), and --archived keeps runs out of session lists.

How I tested it

  • Stand-in CLI tests as above; node --check passes on every edited script; skills/index.json generated and verified (54 files).
  • Not yet run: the full suite, claude plugin validate, and one live Ask through a signed-in opencode — left for the checklist.

Checklist

  • No new dependencies
  • Anything the map shows people is in plain language
  • No secret values stored or printed
  • No details of a real private project in code, comments, docs or screenshots
  • npm test passes
  • claude plugin validate . passes
  • CHANGELOG.md updated, if people will notice the change

Floorplan ran in Claude Code and Codex only. OpenCode discovers the same
SKILL.md natively, so loading needed no changes; what was missing was
recognising it (every command it runs carries OPENCODE_SESSION_ID), naming
it in the map's prompts, and answering the Ask bar through it.

Questions now run `opencode run` against a private server (--standalone)
whose configuration, passed as OPENCODE_CONFIG_CONTENT, denies every
write: reads, globs and greps stay allowed and shell is limited to
floorplan/query.mjs. That config layer loads above the project's own, so
the rules are enforced by OpenCode's server, not just the prompt. Runs are
archived so they stay out of the session list, and follow-ups carry the
conversation, as with Codex. OpenCode's CLI holds no answer schema, so the
engine is unstructured and a blueprint's Change switch stays hidden with
it, per the existing rule.

Installing is one line in opencode.json, served by a generated
skills/index.json catalog (tools/skill-catalog.mjs, re-run on release).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant