> ## Documentation Index
> Fetch the complete documentation index at: https://midway.hazyio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Send Midway notifications from OpenCode plugins

OpenCode uses plugins for lifecycle events. Save this plugin as `.opencode/plugins/midway-notifications.js`:

```js theme={null}
export const MidwayNotifications = async ({ $ }) => ({
  event: async ({ event }) => {
    if (event.type === "session.idle") {
      await $`midway send-text -m "OpenCode finished"`;
    }
    if (event.type === "permission.asked") {
      await $`midway send-text -m "OpenCode needs approval"`;
    }
  },
});
```

OpenCode loads local plugins from `.opencode/plugins/` when it starts.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.