Skip to content

feat(cli): build opencode commands in flat builds - #1390

Merged
blafourcade merged 4 commits into
nextfrom
feat/opencode-flat-commands
Nov 26, 2026
Merged

blafourcade merged 4 commits into
nextfrom
feat/opencode-flat-commands

Conversation

@blafourcade

@blafourcade blafourcade commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🎯 What & why

The OpenCode flat build now carries plugin commands. Before, translate --as flat for OpenCode dropped every commands/ entry, so a flat OpenCode install had no commands.

🛠️ How it works

  • Commands are written under .opencode/commands/<plugin>/ by the same flat install plan the install route already uses (flatCommandPlan: flatSectionPath plus prefixCommandName). The build reuses that route rather than capabilities.commands, so the build output matches the install route byte for byte.
  • OpenCode names a command by its frontmatter name, so two plugins shipping the same file name (implement.md) do not collide.
  • One owner for the path basename: basename in cli/src/shared/domain/paths.model.ts. The duplicate copies in plugin-paths.ts, build-shared.ts and copilot-content.model.ts are removed.
  • Link syntax for command bodies is [] in the build contract (one-line limit comment). The profile's linkSyntax keeps its original form.
  • installedCommandPlan takes prefix and link syntax from the build's commandMarkdown when the build carries commands, and from the profile otherwise. A unit test pins both branches with a link the two syntaxes write differently (Kilo keeps its tool syntax, OpenCode its build's); each mutation of the line turns its own test red.
  • OpenCode's command prefix is read from its flat placement, so the prefix has one owner.
  • Install route output change: OpenCode's install no longer rewrites a command's .opencode/commands/NN_x/... link through the profile's linkSyntax (the build's is []), and a link to a plugin file now lands where that file lands. Every other tool's install is unchanged.

Open question for the reviewer: the route is flatCommandPlan, not capabilities.commands (aiddCommandsUnder, convertCommandFrontmatterNoHint). Confirm this is the intended route. If yes, capabilities.commands remains the setup route only.

🧪 How to verify

  • cd cli && pnpm exec vitest run tests/shared/domain/paths.model.unit.test.ts tests/contexts/translate/domain/layouts/build-flat-commands.unit.test.ts
  • Mutation: basename replaced by return path; turns five tests red (the new "the file name of a path" test and four in build-flat-commands.unit.test.ts). Restored.
  • Manual probe, OpenCode 1.19.3 (opencode --version), model opencode/big-pickle, throwaway HOME and project:
    • opencode debug config lists both nested commands, keyed aidd-aidd-one:implement and aidd-aidd-two:implement.
    • opencode run --command on each returns its marker. Rebuild with --force leaves the tree hash unchanged.

⚠️ Heads-up

  • Goldens moved, by this change: cli/tests/golden/snapshots/tool-support/surface.json and docs/COMPATIBILITY.md. A flat cell now reads the build contract, a marketplace cell the install profile. Cells that moved against next:
    • OpenCode, flat, Commands: no to yes. Its flat build now writes commands, and the golden fails when its build contract drops them (mutation run).
    • Claude Code, Cursor, GitHub Copilot, marketplace, Commands: no to yes. Their install profile ships commands.
    • Kilo and the other flat cells stay no: a flat build writes no commands for them, so the record does not claim them (their flat install still writes commands from the install profile; the record does not state install-only output for a flat layout).
  • Runtime coverage is manual only. No build-output golden carries a plugin with commands, so a regression in the flat command output is caught only by the unit tests above and the support-record golden.
  • Limit: OpenCode applies the aidd- prefix twice for a plugin whose own name starts with aidd- (aidd-aidd-one). The install route already writes it this way, and the build matches it.
  • Limit: a command body is a prompt template. OpenCode does not follow its relative link to the plugin skill.
  • Bundle: cli build 924.0 KB against the 941 KB budget.

🔗 Linked issue

Refs #789

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

Support table

The support record reads rules and commands from the install profile on every layout, the same rule #1380 set for rules. A cell says what aidd delivers. The flat commands cell moved from no to yes for Claude Code, Cursor, Copilot and Kilo, whose install profiles place commands, and for OpenCode, whose flat build now writes them.

Not covered yet: no build-output golden carries a plugin with commands/. The runtime check is one manual probe, on OpenCode 1.19.3.

🤖 Generated with Claude Code

blafourcade and others added 4 commits November 26, 2026 09:35
A flat build for OpenCode dropped a plugin's commands and warned they were
out of scope, while an install delivered them.

The tool's build contract now declares a commands artifact. A build and an
install plan a command through one owner: placed in a folder of its
plugin's name, named after the plugin, its links written in the tool's
syntax and resolved to where the linked skill, agent or command lands. An
install from a built tree owns those paths, and the out-of-scope warning no
longer names commands for a tool whose build carries them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The support record read a tool's commands from its install profile for every layout, so a flat cell claimed commands a flat build does not write. A flat cell now reads the build contract; the marketplace cell reads the install profile.

The command name prefix of opencode is read from its flat placement, one owner. A test proves an install keeps the tool's link syntax when its build carries no commands and the build's when it does. One built-tree read test covers commands, and the tests share the plugin root token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blafourcade
blafourcade marked this pull request as ready for review November 26, 2026 09:33
@blafourcade
blafourcade requested a review from a team as a code owner November 26, 2026 09:33
@blafourcade
blafourcade merged commit be27be8 into next Nov 26, 2026
@blafourcade
blafourcade deleted the feat/opencode-flat-commands branch November 26, 2026 09:33
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