@ephemushroom/opencode-claude-mem 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +37 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -119,8 +119,32 @@ var ClaudeMemPlugin = async (ctx) => {
119
119
  });
120
120
  } catch {}
121
121
  }
122
+ async function sendStatusMessage(sessionId, text) {
123
+ try {
124
+ await client.session.prompt({
125
+ path: { id: sessionId },
126
+ body: {
127
+ noReply: true,
128
+ parts: [{ type: "text", text, ignored: true }]
129
+ }
130
+ });
131
+ } catch {
132
+ await toast(text.slice(0, 200), "info");
133
+ }
134
+ }
135
+ const CONTEXT_CACHE_TTL = 30000;
136
+ let contextCache = null;
137
+ async function getCachedContext() {
138
+ if (contextCache && Date.now() < contextCache.expiry) {
139
+ return contextCache.value;
140
+ }
141
+ const context = await WorkerClient.getContext(projectName);
142
+ contextCache = { value: context, expiry: Date.now() + CONTEXT_CACHE_TTL };
143
+ return context;
144
+ }
122
145
  let workerHealthy = null;
123
146
  let initToastShown = false;
147
+ let contextDisplayedInline = false;
124
148
  async function checkWorkerAndToast() {
125
149
  if (workerHealthy === null) {
126
150
  workerHealthy = await WorkerClient.isHealthy();
@@ -128,7 +152,9 @@ var ClaudeMemPlugin = async (ctx) => {
128
152
  if (!initToastShown) {
129
153
  initToastShown = true;
130
154
  if (workerHealthy) {
131
- await toast(`Memory active \xB7 ${projectName}`, "success");
155
+ if (!contextDisplayedInline) {
156
+ await toast(`Memory active \xB7 ${projectName}`, "success");
157
+ }
132
158
  } else {
133
159
  await toast("Worker offline \u2014 start Claude Code first", "warning", 5000);
134
160
  }
@@ -169,9 +195,17 @@ var ClaudeMemPlugin = async (ctx) => {
169
195
  return;
170
196
  }
171
197
  currentSessionId = sessionId;
198
+ const context = await getCachedContext();
199
+ if (context) {
200
+ contextDisplayedInline = true;
201
+ }
172
202
  const isHealthy = await checkWorkerAndToast();
173
203
  if (isHealthy) {
174
- await toast("Session linked to memory", "info", 2000);
204
+ if (context) {
205
+ await sendStatusMessage(sessionId, context);
206
+ } else {
207
+ await toast(`Memory active \xB7 ${projectName}`, "success", 2000);
208
+ }
175
209
  }
176
210
  }
177
211
  if (event.type === "session.idle") {
@@ -225,7 +259,7 @@ var ClaudeMemPlugin = async (ctx) => {
225
259
  return;
226
260
  }
227
261
  try {
228
- const context = await WorkerClient.getContext(projectName);
262
+ const context = await getCachedContext();
229
263
  if (context) {
230
264
  output.system.push(`[Claude-Mem] Memory Active. Previous Context:
231
265
  ${context}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ephemushroom/opencode-claude-mem",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "OpenCode plugin for Claude-Mem persistent memory system",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",