opencode
opencode copied to clipboard
Chat messages transform hook
Add a chat messages transform hook to allow plugins to alter chat messages.
We expose the MessageV2.WithParts through the new hook, but give deep copies of the chat history to avoid plugins altering the original messages
Previously, the chain would look something like this:
MessageV2.WithParts -> ModelMessage -> ...
Now, with the new changes:
MessageV2.WithParts -> MessageV2.WithParts (in-memory copy) -> ModelMessage -> ...
|
chat.messages.transform
|
|-----------------|
| Plugin |
|-----------------|
/review
/review
lgtm
/review
lgtm