Skip to content

fix(setup): install namespaced /gstack-review OpenCode command without shadowing the builtin /review - #2651

Open
Lockyer228 wants to merge 3 commits into
garrytan:mainfrom
Lockyer228:2629-opencode-slash-gstack-review
Open

fix(setup): install namespaced /gstack-review OpenCode command without shadowing the builtin /review#2651
Lockyer228 wants to merge 3 commits into
garrytan:mainfrom
Lockyer228:2629-opencode-slash-gstack-review

Conversation

@Lockyer228

Copy link
Copy Markdown
Contributor

Why (in your own words)

./setup --host opencode links gstack's generated skills into ~/.config/opencode/skills/, but never writes anything under ~/.config/opencode/commands/. OpenCode 1.18.3 ships a built-in /review slash command with subtask: true, and its command-registration loop skips any skill whose frontmatter name: matches an existing command — so gstack's review skill (frontmatter name: review) never becomes a working /review. Typing /review runs the builtin subtask instead, and with plan as the primary agent that comes back as "Task cancelled." (skill({ name: "review" }) still works, so the skill itself is fine.)

This change makes the collision explicit and safe: setup installs a namespaced ~/.config/opencode/commands/gstack-review.md command (subtask: false) that loads the gstack review skill by its frontmatter name, so /gstack-review works and OpenCode's builtin /review is left untouched. Non-colliding skills (qa, ship, ...) are deliberately not turned into command files — OpenCode already registers those from the skill name. Files that don't carry the generated banner are never overwritten.

Live evidence

BEFORE — origin/main @ 51932ece (v1.68.2.0). The OpenCode install path has no commands/ handling at all; only skills/ is linked:

$ git show origin/main:setup | grep -c "opencode/commands"
0

AFTER — this branch, the real install_opencode_collision_commands run against a throwaway $HOME with a gstack-review skill installed:

$ install_opencode_collision_commands "$OPENCODE_SKILLS" "$OPENCODE_COMMANDS"
opencode commands: gstack-review

$ find $HOME/.config/opencode/commands -type f
$TMP/home/.config/opencode/commands/gstack-review.md

$ cat $HOME/.config/opencode/commands/gstack-review.md
---
description: Run the gstack review skill
subtask: false
---

<!-- AUTO-GENERATED from setup — do not edit directly -->

Use the skill tool with name "review" (the skill frontmatter name). Follow that skill, including its preamble.

review.md and init.md are not created, so OpenCode's builtin commands keep working unchanged.

Behavior tests (bun 1.3.13):

$ bun test test/setup-opencode-collision-commands.test.ts
 9 pass
 0 fail
 60 expect() calls

The wiring is pinned: a static test asserts OPENCODE_COMMANDS is exactly $HOME/.config/opencode/commands, and a behavior test drives the real constant and the real function through a temporary $HOME. Mutating that constant to a wrong directory makes the suite fail (verified: 7 pass / 2 fail, non-zero exit), so a future regression in the target path is caught.

Scope

  • Changed: setup (new install_opencode_collision_commands + wiring in the OpenCode install block), test/setup-opencode-collision-commands.test.ts, README.md (install table + manual-uninstall entry for the new command file).
  • Verified live by: the behavior tests above, run against the real setup source in a throwaway $HOME. This host cannot drive the interactive OpenCode TUI (no configured provider or credentials).
  • Did NOT test: full Tier 1 bun run test — this environment's Playwright/browse lane fails with "Target page, context or browser has been closed", unrelated to this diff (the OpenCode: slash commands route to non-existent 'plan' subagent #2629 tests pass in the shard logs). Interactive /gstack-review inside the real OpenCode TUI, and Windows (the bash behavior tests follow the repo's existing skipIf(win32) convention).

Linked issue

Fixes #2629

OpenCode's builtin /review is a subtask command and shadows gstack's
review skill. Write commands/gstack-review.md with subtask: false
instead of overriding the builtin.
Do not clobber a user-owned gstack-review.md. Drop the dead init
branch. Tell installers to type /gstack-review instead of /review.
Tests now fail if OPENCODE_COMMANDS is retargeted. README lists
commands/gstack-review.md for install and manual removal.
@trunk-io

trunk-io Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@trunk-io

trunk-io Bot commented Aug 23, 2026

Copy link
Copy Markdown

An error occurred while submitting your PR to the queue: Only users that are a part of this repo's Trunk organization or have write permissions to the repo can submit a PR to the queue

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.

OpenCode: slash commands route to non-existent 'plan' subagent

1 participant