You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit abb5934
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cavekit): drop messages-transform hook, use synthetic part instead
Old two-hook design caused provider error 2013 (messages must not be empty)
when messages.transform set output.messages = []. New design uses single
command.execute.before hook with synthetic: true part to signal no LLM reply.
Refs anomalyco/opencode#9306
**Pattern: two parts —`ignored: true`(user-visible result) + `synthetic: true` (no-LLM signal)**
25
25
26
-
Two hooks in concert — no shared state needed:
26
+
Single hook, no `messages.transform`:
27
27
28
-
1.`command.execute.before` — copies file, replaces `output.parts` with a single `{ type: "text", ignored: true }` part containing the result message. This surfaces output in the TUI without LLM inference.
29
-
2.`experimental.chat.messages.transform` — if the last user message text is `/ck:init`, empties `output.messages` → LLM inference skipped entirely.
28
+
`command.execute.before` copies the file, then replaces `output.parts` with two entries:
29
+
1.`{ type: "text", ignored: true }` — the result message, shown in the TUI, excluded from LLM context.
30
+
2.`{ type: "text", synthetic: true }` — signals to OpenCode that the command produced its own response and no LLM reply is needed.
30
31
31
32
**`hooks/command.ts`:**
32
33
33
34
```ts
34
-
output.parts.splice(0, output.parts.length, {
35
-
id: output.parts[0].id,
36
-
messageID: output.parts[0].messageID,
37
-
sessionID: input.sessionID,
38
-
type: "text",
39
-
text, // "FORMAT.md copied to ..." or "FORMAT.md already exists at ..."
40
-
ignored: true,
41
-
});
35
+
output.parts.splice(
36
+
0,
37
+
output.parts.length,
38
+
{
39
+
id: output.parts[0].id,
40
+
messageID: output.parts[0].messageID,
41
+
sessionID: input.sessionID,
42
+
type: "text",
43
+
text, // "FORMAT.md copied to ..." or "FORMAT.md already exists at ..."
44
+
ignored: true,
45
+
},
46
+
{
47
+
id: partId(),
48
+
messageID: output.parts[0].messageID,
49
+
sessionID: input.sessionID,
50
+
type: "text",
51
+
text: "FORMAT.md copied, no further action.",
52
+
synthetic: true,
53
+
},
54
+
);
42
55
```
43
56
44
57
Source path: `path.join(__dirname, "../assets/FORMAT.md")` — bundled alongside the plugin.
output.messages= []; // drop /ck:init → no LLM inference
59
-
},
60
-
```
59
+
> **Why not `experimental.chat.messages.transform`?**
60
+
> An earlier design used that hook to set `output.messages = []`, intending to skip LLM inference entirely. This caused provider error 2013 (`messages must not be empty`) because OpenCode still dispatches the LLM call after the transform. Tracked upstream as [anomalyco/opencode#9306](https://github.com/anomalyco/opencode/issues/9306) — when `noReply` lands, the `synthetic` part can be removed.
61
61
62
62
**No caching impact.** File copy is a pure side effect — no model context mutated.
Cavekit no longer contributes a `system.transform` or `event` handler, so merging is simpler — only `command.execute.before`, `experimental.chat.messages.transform`, and `config` come from this module.
114
+
Cavekit no longer contributes a `system.transform` or `event` handler, so merging is simpler — only `command.execute.before` and `config` come from this module.
115
115
116
116
---
117
117
@@ -121,8 +121,7 @@ Cavekit no longer contributes a `system.transform` or `event` handler, so mergin
121
121
src/modules/cavekit/
122
122
index.ts # cavekitHooks(ctx) factory — composes all hooks
0 commit comments