Skip to content

fix(opencode): stop asking on the phone after terminal turns - #26

Merged
tak-bro merged 2 commits into
mainfrom
fix/opencode-remote-hook
Oct 29, 2026
Merged

tak-bro merged 2 commits into
mainfrom
fix/opencode-remote-hook

Conversation

@tak-bro

@tak-bro tak-bro commented Oct 29, 2026

Copy link
Copy Markdown
Member

Summary

PC 터미널에서 OpenCode 에 지시했는데, 턴이 끝날 때 OpenCode 가 폰으로 hwip_ask 를 보냈다. 원인은 OpenCode 규칙에 들어간 "Entering REMOTE without a prompt hook" 절이다. 이 절은 NORMAL 에서도 큰 작업 뒤에 hwip_ask 를 보내라고 시킨다. OpenCode 규칙에서 이 절을 뺐다.

Changes

  • src/templates.ts — OPENCODE_RULE 에서 remoteEntry: REMOTE_ENTRY_NO_HOOK 를 제거했다. full core 는 그대로 둔다(REMOTE 규칙을 넣어 줄 훅이 없어서). 사유는 문서 주석에 적었다. 헤더와 preamble 주석도 고쳤다.
  • src/rules-sync.test.ts — "OpenCode does not order a hwip_ask after NORMAL work" 테스트를 추가하고, 훅 없는 에이전트 목록에서 OpenCode 를 뺐다.
  • src/templates.test.ts — 규칙과 훅 레지스트리가 맞는지 보는 검사에 PREAMBLE_OPT_OUT = ['opencode'] 를 추가했다.
  • README.md — 훅 없는 에이전트 절에 OpenCode 예외와 그 대가를 적었다.

Why not wire OpenCode to remote-hook

OpenCode 1.x 플러그인에는 chat.message·experimental.chat.system.transform 훅이 있다. 2.1.3 바이너리에는 둘 다 없다. 2.x 플러그인은 setup 이벤트 스트림만 받는다. 턴 컨텍스트를 넣을 후보로 실험 API session.instructions.entry.put 이 있지만, 플러그인 context 에서 접근할 수 있는지와 첫 모델 호출 전에 반영되는지를 검증하지 못했다.

How to Test

npx vitest run src/rules-sync.test.ts src/templates.test.ts
npm run build

Evidence

  • red(수정 전): 새 테스트 2건 실패. OPENCODE_RULE 에 after substantial work in NORMAL, end the response with 가 있었다.
  • green(수정 후): 같은 테스트 통과. 전체는 208/208 파일, 5554 tests 통과(src/http-proxy.test.ts 제외).
  • src/http-proxy.test.ts 는 8건이 실패한다. 깨끗한 origin/main 에서도 같은 8건이 실패하므로 이 PR 과 무관한 기존 문제다.

Risks

  • 폰에서 OpenCode 세션으로 메시지를 보내면 버튼 없이 완료 push 만 간다. REMOTE 루프는 에이전트가 직접 ask 를 보낼 때만 시작된다.
  • 설치된 ~/.config/opencode/AGENTS.md 는 재설치(hwip setup)해야 바뀐다.

Merge danger

Door: two-way · Blast radius: opencode-rules

Alternatives considered

  • 2.x 실험 API 로 remote-hook 을 연결: 5파일 이상이고, 실험 API 와 반영 타이밍부터 spike 로 확인해야 해서 보류했다.
  • 다른 훅 없는 에이전트(Cursor·Windsurf·Copilot·Cline·Aider)도 같은 절을 쓴다. 설계 의도이고 같은 증상 보고가 없어서 그대로 뒀다.

Checklist

  • regression test (red → green)
  • build
  • README sync

🤖 Generated with Claude Code

The OpenCode rule carried the no-hook REMOTE entry preamble, which
orders a hwip_ask after substantial work even in NORMAL. On OpenCode
2.1.3 that pushed an ask to the phone at the end of a turn the user
had typed at the PC terminal.

The preamble exists because a hook-less agent has no other way into
REMOTE. OpenCode's 2.x plugin API is an event stream with no per-turn
hook, so the phone-vs-terminal check cannot be added there. Drop the
preamble for OpenCode instead: NORMAL owes no ask, and REMOTE starts
only from an ask the agent chooses to send. A phone message to an
OpenCode session now gets the completion push rather than buttons.
@tak-bro
tak-bro marked this pull request as ready for review October 29, 2026 02:55
@tak-bro
tak-bro merged commit 0d18945 into main Oct 29, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.1.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tak-bro
tak-bro deleted the fix/opencode-remote-hook branch October 29, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant