2026-05-26 09:48:46 +02:00
|
|
|
/**
|
2026-06-03 16:47:55 +02:00
|
|
|
* @deprecated Use `iai-mcp-memory-inject.js` instead.
|
2026-05-26 09:48:46 +02:00
|
|
|
*
|
2026-06-03 16:47:55 +02:00
|
|
|
* This plugin forces a tool call via a phantom "INIT" user turn, which
|
|
|
|
|
* corrupts session title generation. The memory-inject plugin uses the
|
|
|
|
|
* system.transform hook to inject memory directly into the system prompt
|
|
|
|
|
* — no phantom turn, clean titles, memory visible every turn.
|
|
|
|
|
*
|
|
|
|
|
* Retained temporarily for backward compatibility. Will be removed in a
|
|
|
|
|
* future release. Migrate to iai-mcp-memory-inject.js:
|
|
|
|
|
*
|
|
|
|
|
* cp deploy/opencode/iai-mcp-memory-inject.js ~/.config/opencode/plugins/
|
|
|
|
|
*
|
|
|
|
|
* Then replace this plugin reference in ~/.config/opencode/config.json.
|
2026-05-26 09:48:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
export const IaiMcpSessionInit = async ({
|
|
|
|
|
client,
|
|
|
|
|
project,
|
|
|
|
|
directory,
|
|
|
|
|
worktree,
|
|
|
|
|
experimental_workspace,
|
|
|
|
|
serverUrl,
|
|
|
|
|
$,
|
|
|
|
|
}) => {
|
2026-05-27 16:58:50 +02:00
|
|
|
const doneSessions = new Set();
|
2026-05-26 09:48:46 +02:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
event: async ({ event }) => {
|
|
|
|
|
if (event.type !== "session.updated") return;
|
|
|
|
|
const sid = event.properties?.info?.id;
|
2026-05-27 16:58:50 +02:00
|
|
|
if (!sid || doneSessions.has(sid)) return;
|
|
|
|
|
doneSessions.add(sid);
|
2026-05-26 09:48:46 +02:00
|
|
|
|
2026-05-27 16:58:50 +02:00
|
|
|
try {
|
|
|
|
|
await client.session.prompt({
|
|
|
|
|
path: { id: sid },
|
|
|
|
|
body: {
|
|
|
|
|
system: "MANDATORY: Call `memory_session_context` (no arguments) BEFORE answering any user query.",
|
|
|
|
|
parts: [{ type: "text", text: "INIT" }],
|
|
|
|
|
noReply: false,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} catch {}
|
2026-05-26 09:48:46 +02:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|