Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

fix(agents): add default export definition to OpenCode plugin for v2 compatibility

unknown3b14a8fd90e6
diff --git a/windows/src-tauri/src/agents.rs b/windows/src-tauri/src/agents.rs
index 76c4436b..570c46cf 100644
--- a/windows/src-tauri/src/agents.rs
+++ b/windows/src-tauri/src/agents.rs
@@ -787,7 +787,7 @@ export const CoucouPlugin = async ({ directory } = {}) => ({
event: async ({ event }) => {
const hook_event_name = EVENT_MAP[event?.type];
if (!hook_event_name) return;
- const props = event.properties || {};
+ const props = event?.properties || {};
forward(hook_event_name, {
session_id: props.sessionID || props.info?.id || '',
cwd: directory || '',
@@ -809,6 +809,49 @@ export const CoucouPlugin = async ({ directory } = {}) => ({
});
},
});
+
+export default {
+ id: 'coucou',
+ setup: async (ctx = {}) => {
+ const dir = ctx.directory || '';
+ if (ctx.tool?.hook) {
+ try {
+ ctx.tool.hook('execute.before', async (input, output) => {
+ forward('PreToolUse', {
+ session_id: input?.sessionID || '',
+ cwd: dir,
+ tool_name: typeof input?.tool === 'string' ? input.tool : '',
+ tool_input: output?.args ?? input?.input ?? null,
+ });
+ });
+ ctx.tool.hook('execute.after', async (input) => {
+ forward('PostToolUse', {
+ session_id: input?.sessionID || '',
+ cwd: dir,
+ tool_name: typeof input?.tool === 'string' ? input.tool : '',
+ });
+ });
+ } catch {}
+ }
+ if (ctx.event?.subscribe) {
+ (async () => {
+ try {
+ for await (const event of ctx.event.subscribe()) {
+ const hook_event_name = EVENT_MAP[event?.type];
+ if (!hook_event_name) continue;
+ const props = event?.properties || {};
+ forward(hook_event_name, {
+ session_id: props.sessionID || props.info?.id || event?.sessionID || '',
+ cwd: dir,
+ });
+ }
+ } catch {}
+ })();
+ }
+ return CoucouPlugin(ctx);
+ },
+ server: CoucouPlugin,
+};
"#;
const AMP_PLUGIN: &str = r#"// Coucou plugin for Amp — generated by Coucou.
@@ -1252,4 +1295,16 @@ mod tests {
let odd = json!({ "hooks": { "BeforeTool": { "matcher": "x" } } });
assert!(gemini_install(&odd, &[("BeforeTool".into(), "c".into(), 1)]).is_err());
}
+
+ #[test]
+ fn opencode_plugin_exports_v2_default_and_v1_named_plugin() {
+ let plugins = Agent::OpenCode.plugin(&windows(WIN_SPACE)).unwrap();
+ let plugin = &plugins[0];
+ assert!(plugin.contains("export const CoucouPlugin ="));
+ assert!(plugin.contains("export default {"));
+ assert!(plugin.contains("id: 'coucou'"));
+ assert!(plugin.contains("setup: async (ctx = {}) => {"));
+ assert!(plugin.contains("return CoucouPlugin(ctx);"));
+ assert!(is_our_plugin(plugin));
+ }
}