Skip to content

Add opencode support#35

Open
bhavesh80 wants to merge 6 commits intomainfrom
feature/add-opencode-support
Open

Add opencode support#35
bhavesh80 wants to merge 6 commits intomainfrom
feature/add-opencode-support

Conversation

@bhavesh80
Copy link
Copy Markdown

@bhavesh80 bhavesh80 commented Apr 25, 2026

Add opencode support

Bee now runs on opencode the same way it runs on Claude Code: 35 subagents, 12 commands, 20 skills, full SDD lifecycle (brainstorm → spec → architecture → slice loop → review). No runtime bridge, no JS plugin — just generated markdown twins under bee/.opencode/ and a per-file symlink installer.

Demo

30s walkthrough: fresh opencode session → /bee-brainstorm/bee-sdd → SDD complete with 29 passing tests, all driven through the opencode web UI on Kimi K2.6.

https://github.com/incubyte/ai-plugins/releases/download/untagged-02385493534a294c71e2/bee-opencode-demo.mp4

The demo builds a small CLI URL shortener (tinyurl) end-to-end: brainstorm decides on SHA-256 hex slugs + functional split, SDD triages it as SMALL, slice-coder/slice-tester/sdd-verifier deliver two slices, and the final test suite is green.

What ships

Path What it is
bee/scripts/generate-opencode-{agents,commands}.py Generators that transform Claude-side bee/{agents,commands}/*.md into opencode twins under bee/.opencode/. Single source of truth stays on the Claude side.
bee/.opencode/agents/*.md (×35) Generated agent definitions. Frontmatter rewritten to opencode's schema (description, mode: subagent, category). Body has skill-load preamble, bee:foobee-foo cross-references, and Claude-specific tool names mapped to opencode equivalents.
bee/.opencode/commands/*.md (×12) Generated slash commands. Same transformations.
bee/.opencode/bin/install.sh Idempotent installer. Per-file symlinks for agents and commands (so they install as bee-<name> cleanly), directory symlinks for skills and scripts. Refuses to overwrite anything not already pointing into the plugin.
docs/opencode-install.md User-facing install guide, including the one real gotcha (opencode caches config at server startup — restart after install).
docs/opencode-port-findings.md Full findings doc — opencode's discovery surfaces, the foot-guns hit (frontmatter name: clobbering filename), and the runtime gotchas. Useful background for the next person extending this.

How it works (the short version)

Opencode discovers agents/commands/skills from a small set of fixed config directories (~/.config/opencode/, walked-up .opencode/, $OPENCODE_CONFIG_DIR). Plugin paths are not scanned. So instead of fighting the discovery model, we symlink each markdown file individually from the plugin into ~/.config/opencode/{agent,command,skill}/. Agents and commands get a bee- prefix from the filename (cross-references like Task(subagent_type=bee:foo) are rewritten to bee-foo by the generator); skills keep their bare names.

The Claude-side files in bee/{agents,commands}/ remain the single source of truth. Re-run the generator after editing.

Full discovery walk-through, foot-guns hit, and rationale: see docs/opencode-port-findings.md.

Notes on the model side

The demo was built using Kimi K2.6 through opencode's kimi-for-coding provider. It executed the full SDD pipeline — context-gather, slice-coder, slice-tester, sdd-verifier — with parallel subagent dispatch working correctly and returning clean structured output. The interesting bit isn't really the model: it's that Bee's prompts (skill-loading discipline, agent role separation, AC-driven verification) translate cleanly to whatever model the developer is using. With detailed instructions, an open-source model holds its own on a multi-step structured task.

Bundled refactor: review-orchestration

bee/commands/review.md was 175 lines of orchestration logic. Extracted the body (scope detection, parallel agent spawn, merging, hotspot-prioritized roadmap, dedup rules, output format) into a new bee/skills/review-orchestration/SKILL.md. The command is now ~36 lines of wiring: load skill, spawn 7 specialists, follow skill instructions.

This is the same pattern Bee already uses for brainstorming, clean-code, etc. — keeping commands thin and putting the methodology in skills.

Bundled because it's small, doesn't conflict with the opencode work, and shipping two PRs for one branch felt like extra ceremony. Happy to split if reviewers prefer.

Tested

End-to-end on opencode web (default model: Kimi K2.6):

  • bash bee/.opencode/bin/install.sh symlinks 35 agents, 12 commands, 20 skills, scripts dir
  • ✅ Restart opencode → /bee-help runs and lists all commands/skills
  • /bee-brainstorm runs full diverge/converge loop with question tool
  • /bee-sdd "build a CLI URL shortener..." triages, codes, tests, verifies — 29/29 tests passing on the demo project
  • ✅ Subagent dispatch via Task(subagent_type=bee-context-gatherer) resolves and runs (the original blocker)
  • /bee-review (the refactored one) loads review-orchestration skill and spawns 7 reviewers in parallel
Screenshot_20260425_060417

Claude Code side: unchanged. Source-of-truth files in bee/{agents,commands}/ were edited only where the change benefits both platforms (e.g., the platform-aware skill-loading instructions in help.md).

Out of scope (intentional v1)

  • No JS plugin (bee/.opencode/plugins/*.js). The opencode Hooks interface has no agent/command registration hook, so a plugin can't help discovery. v2 could add one for skill-aware autoload or intercepting subagent dispatch — open question, not blocking v1.
  • Skill names are bare (e.g. clean-code, not bee-clean-code). Renaming would mean ~50 cross-reference updates across both Claude and opencode files. Cosmetic inconsistency accepted; help text was updated to be platform-aware.
  • No tests. The generator and installer are simple enough to verify by inspection + the end-to-end smoke test above. If reviewers want pytest coverage of the generator transformations, easy to add.

Bee now runs on opencode the same way it runs on Claude Code: 35 subagents,
12 commands, 20 skills, full SDD lifecycle. Approach is to keep the
Claude-side files in bee/{agents,commands}/ as the single source of truth
and generate opencode twins under bee/.opencode/ via two Python scripts.
The installer symlinks each file into ~/.config/opencode/ so opencode's
discovery model picks them up without a JS plugin.

Key transformations the generators apply:
- bee:foo cross-references → bee-foo (matches the prefixed install names)
- frontmatter rewritten to opencode's schema (description, mode, category)
- Claude-specific tools mapped to opencode equivalents
  (AskUserQuestion → question, TodoWrite/Task* → todowrite, etc.)
- Deferred Tool Loading preamble stripped (opencode has no equivalent)
- $CLAUDE_PLUGIN_ROOT/scripts → $HOME/.config/opencode/bee/scripts
- Skills get an explicit load preamble (no frontmatter auto-load on opencode)

Foot-gun resolved: opencode's ConfigAgent reads frontmatter via
{ name, ...md.data, prompt }, so writing a name: field clobbers the
filename-derived name and breaks the bee- prefix. Generator no longer
emits name:.

Bundled: refactor of /bee:review (175 → 36 lines). Orchestration logic
moved into a new review-orchestration skill, matching the pattern Bee
already uses for brainstorming, clean-code, etc. Pilot validation in
docs/brainstorms/pilot-phase-0-findings.md.

Tested end-to-end on opencode web with Kimi K2.6: install → restart →
/bee-help → /bee-brainstorm → /bee-sdd → 29 passing tests on the demo
project. Subagent dispatch (the original blocker) resolves cleanly.
@bhavesh80 bhavesh80 requested a review from a team April 25, 2026 00:08
Add an "On opencode" section pointing to the symlink installer
(bash bee/.opencode/bin/install.sh) with the restart-required
gotcha called out, and link to the full INSTALL.md and ARCHITECTURE
notes for details.

Also refresh the Bee plugin description: notes both Claude Code and
opencode, updates counts (12 commands, 35 agents, 20 skills) which
had drifted from the prior 10/26.
Removes opencode-advanced-integration-brainstorm.md and
pilot-phase-0-findings.md. Both were session artifacts (working notes
from earlier exploration) that didn't add reviewable value to the PR
and referenced a since-renamed branch. Keeping docs/opencode-port-findings.md
as the consolidated reference.
@bhavesh80 bhavesh80 self-assigned this Apr 25, 2026
Per review feedback: keep the bee/ folder for plugin code (agents,
commands, scripts, generators) and put user-facing docs in the repo's
top-level docs/ directory.

- bee/.opencode/INSTALL.md → docs/opencode-install.md
- Updated all internal links (README.md, opencode-port-findings.md, ARCHITECTURE.md tree diagram)
Most of the doc was forward-looking — Phase 2 routing, future migration
paths, open questions, contributor guides for hypothetical patterns.
What's actually shipped is described in docs/opencode-port-findings.md
(discovery surfaces, generators, install mechanism, gotchas).

Updated all internal links: README, docs/opencode-install.md, and
docs/opencode-port-findings.md (removed stale tree entries for
ARCHITECTURE.md, the deleted brainstorms, and demos/ that we already
moved out of the repo).
- Add .claude/ -> .opencode/ substitution to all generators
- Add bare CLAUDE.md -> AGENTS.md substitution for opencode convention file
- Create generate-opencode-skills.py to transform skills for opencode
- Extract shared BODY_SUBS to opencode_subs.py module
- Parameterize update-bee-state.sh with BEE_DIR env var
- Fix install.sh to symlink generated skills instead of raw source
- Add .idea/ and __pycache__/ to .gitignore
@bhavesh80 bhavesh80 force-pushed the feature/add-opencode-support branch from 9ee9d0d to 0bafdd3 Compare April 26, 2026 03:12
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