mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
1c40655e17
OpenCode's command dispatcher appends `arguments` to the `.md` body and runs `resolvePromptParts()` over the combined string, which auto-attaches any file path it finds as a `FilePart`. With `/plannotator-annotate /path/to/huge.md`, that meant the agent received the file's content as a user message before the annotation UI even opened — blowing the context on large files (GLM-5 auto-compact reported in #713). Move `plannotator-annotate`, `plannotator-review`, and `plannotator-archive` from the post-hoc `event` handler to `command.execute.before`, matching the pattern `plannotator-last` already used. The hook clears `output.parts` in place so the agent never receives the command turn; handlers then run the UI and inject feedback via `client.session.prompt` as a separate turn. Empty the bodies of the three `.md` files for defense in depth — only the frontmatter is needed for OpenCode to register the slash command. Also fixes a latent bug in the `plannotator-last` path: `output.parts = []` reassigns the throwaway wrapper object's property but doesn't touch the `parts` array the caller in `prompt.ts:1944` uses directly. Switched to `output.parts.length = 0` to mutate in place. `plannotator-last` only escaped notice because its parts array was always a single benign text part.