Skip to content

fix(init): make --opencode additive instead of replacing Claude setup - #4049

Closed
dopaemon wants to merge 1 commit into
rtk-ai:developfrom
dopaemon:fix/init-opencode-additive
Closed

dopaemon wants to merge 1 commit into
rtk-ai:developfrom
dopaemon:fix/init-opencode-additive

Conversation

@dopaemon

Copy link
Copy Markdown

Fixes #4046

Problem

rtk init -g --opencode installed only the OpenCode plugin and skipped Claude hook registration, even though the flag's help text says "Install OpenCode plugin (in addition to Claude Code)". Users had to run rtk init -g separately afterwards.

Root cause

src/main.rs: let install_claude = !opencode; — the flag replaced the Claude setup. hooks::init::run already handled the combined case via its (true, opencode, …) match arms, so nothing else was missing.

Changes

  • src/main.rs: install_claude is always true; --opencode is purely additive.
  • src/hooks/init.rs: removed the now-unreachable (false, true, …) arm and run_opencode_only_mode(); updated the rtk init --show hint.
  • README.md: # Claude Code hook + OpenCode plugin instead of "instead of Claude Code".
  • tests/init_opencode_additive_test.rs: regression test — rtk init -g --opencode --dry-run under a temp $HOME must report both the OpenCode plugin and the Claude hook (RTK.md + settings.json).

Verification

$ rtk init -g --opencode --dry-run
[dry-run] would create RTK.md: .../.claude/RTK.md
[dry-run] would create OpenCode plugin: .../.config/opencode/plugins/rtk.ts
[dry-run] would add @RTK.md reference to CLAUDE.md: .../.claude/CLAUDE.md
[dry-run] would patch settings.json: .../.claude/settings.json

cargo fmt --all + cargo clippy --all-targets clean, lib suite (3613 tests) and all integration test binaries pass locally. Note: tests/guard_integration_test.rs could not be run locally (its git subprocesses hang in my sandbox); it is untouched by this change and left to CI.

@CLAassistant

CLAassistant commented Sep 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working init opencode labels Sep 14, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk init -g --opencode so it additionally installs the Claude Code hook instead of replacing it, matching the flag's documented behavior. Removes the now-unreachable opencode-only code path and updates help text/README accordingly, with a regression test verifying both installs occur.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4046


Analyzed automatically by wshm · This is an automated analysis, not a human review.

`rtk init -g --opencode` installed only the OpenCode plugin and skipped
Claude hook registration, contradicting the flag's help text ("in addition
to Claude Code"). Root cause: `install_claude = !opencode` in the CLI
mapping — `init::run` already supported the combined case.

- always install the Claude Code hook; --opencode only adds the plugin
- drop the now-unreachable opencode-only mode and its match arm
- update `--show` hint and README accordingly
- add regression test on `rtk init -g --opencode --dry-run`

Fixes rtk-ai#4046

Signed-off-by: dopaemon <[email protected]>
@KuSh

KuSh commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, and sorry for the duplicated effort — closing as DUPLICATE, recommend closing in favour of #4052.

The reason is timing on the issue rather than anything about the code: @TechWizard9999 asked to be assigned #4046 at 09:28Z and was assigned at 11:02:21Z; this PR was opened at 11:23:40Z, about 20 minutes after the issue was already assigned. #4052 is the assignee's PR, so that one carries.

For the record, I reviewed both against real runs rather than assuming they were interchangeable, and they are equivalent on correctness — both share the same blocking regression:

fresh HOME, no ~/.claude
develop d402152f : rtk init -g --opencode --auto-patch -> EXIT=0  plugin installed
#4049   43f078e7 : rtk init -g --opencode --auto-patch -> EXIT=1  nothing installed
#4052   1ee24fe6 : rtk init -g --opencode --auto-patch -> EXIT=1  nothing installed

Routing --opencode through the Claude path exposes #2519 (~/.claude is never created), and since RTK.md is written before ensure_opencode_plugin_installed, the plugin never lands. Details and the verified fix are on #4052 and #2519.

One thing your PR does that #4052 doesn't, and that I'd like to keep: removing run_opencode_only_mode and the (false, true, _, _) arm once install_claude is unconditionally true. I checked, and it doesn't trip dead_code or clippy (the arms still reference the function), so it's cosmetic rather than required — but it's the right cleanup and I've pointed @TechWizard9999 at it to carry over, with credit to you.

Your diagnosis in the PR body was accurate, and the --dry-run regression test was a good instinct. Please do pick up another issue — and it's worth checking the assignee field first to avoid this happening again.

@KuSh KuSh closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working init opencode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init --opencode appears to skip Claude hook installation

3 participants