@codemem/opencode-plugin 0.48.1 → 0.49.0-beta.1
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.
|
@@ -9,11 +9,55 @@ import {
|
|
|
9
9
|
RAW_EVENT_SPOOL_FULL_CODE,
|
|
10
10
|
removeRawEventSpoolEntry,
|
|
11
11
|
resolveSpoolDirectory,
|
|
12
|
+
retainRejectedRawEventSpoolEntry,
|
|
12
13
|
writeRawEventSpoolEntry,
|
|
13
14
|
} from "./raw-event-spool.js";
|
|
14
15
|
|
|
15
16
|
const rawEventSpoolDrainsInFlight = new Map();
|
|
16
17
|
|
|
18
|
+
// Mirror the Viewer's explicit validation responses without importing server code.
|
|
19
|
+
const TERMINAL_VALIDATION_MESSAGES = new Set([
|
|
20
|
+
"source must be string",
|
|
21
|
+
"source is required",
|
|
22
|
+
"source must use 1-64 letters, digits, dots, underscores, or hyphens",
|
|
23
|
+
"session_stream_id must be string",
|
|
24
|
+
"session_id must be string",
|
|
25
|
+
"stream_id must be string",
|
|
26
|
+
"opencode_session_id must be string",
|
|
27
|
+
"conflicting session id fields",
|
|
28
|
+
"invalid session id",
|
|
29
|
+
"event source conflicts with request source",
|
|
30
|
+
"session id required",
|
|
31
|
+
"event_type must be string",
|
|
32
|
+
"event_type required",
|
|
33
|
+
"event_type has invalid syntax",
|
|
34
|
+
"event_id must be string",
|
|
35
|
+
"event_id required",
|
|
36
|
+
"event_id has invalid syntax",
|
|
37
|
+
"event_seq must be int",
|
|
38
|
+
"ts_wall_ms must be number",
|
|
39
|
+
"ts_mono_ms must be number",
|
|
40
|
+
"payload must be an object",
|
|
41
|
+
"cwd must be string",
|
|
42
|
+
"project must be string",
|
|
43
|
+
"started_at must be string",
|
|
44
|
+
"events must be a list",
|
|
45
|
+
"event must be an object",
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
export const classifyRawEventTerminalRejection = ({ status, responseBody, outgoingBytes }) => {
|
|
49
|
+
if (!responseBody || typeof responseBody !== "object" || Array.isArray(responseBody)) return null;
|
|
50
|
+
if (status === 400 && TERMINAL_VALIDATION_MESSAGES.has(responseBody.error)) {
|
|
51
|
+
return { status: 400, reason: "invalid_payload" };
|
|
52
|
+
}
|
|
53
|
+
if (status === 413 && responseBody.error === "payload too large"
|
|
54
|
+
&& Number.isFinite(responseBody.max_bytes) && responseBody.max_bytes > 0
|
|
55
|
+
&& Number.isFinite(outgoingBytes) && outgoingBytes > responseBody.max_bytes) {
|
|
56
|
+
return { status: 413, reason: "payload_too_large" };
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
|
|
17
61
|
export const classifyRawEventTransportCause = (error) => {
|
|
18
62
|
const diagnostic = [
|
|
19
63
|
error?.name,
|
|
@@ -49,6 +93,7 @@ const createDeliveryState = (options) => ({
|
|
|
49
93
|
latestViewerFailure: null,
|
|
50
94
|
lastToastAtBySession: new Map(),
|
|
51
95
|
options,
|
|
96
|
+
retainedPayloads: new WeakSet(),
|
|
52
97
|
spoolDirectory: resolveSpoolDirectory(options.spoolHome),
|
|
53
98
|
spoolCorruptionNoted: false,
|
|
54
99
|
spoolLoadFailureNoted: false,
|
|
@@ -146,12 +191,16 @@ const persistSafeSpoolDiagnostic = async (state, line) => {
|
|
|
146
191
|
|
|
147
192
|
const persistForRetry = async (state, { body, serialized, payload, sessionID }) => {
|
|
148
193
|
try {
|
|
149
|
-
await writeRawEventSpoolEntry({
|
|
194
|
+
const stored = await writeRawEventSpoolEntry({
|
|
150
195
|
envelope: body,
|
|
151
196
|
serialized,
|
|
152
197
|
homeDir: state.options.spoolHome,
|
|
153
198
|
maxEntries: state.options.spoolMaxEntries,
|
|
154
199
|
});
|
|
200
|
+
if (typeof stored?.serialized === "string" && stored.serialized !== serialized
|
|
201
|
+
&& payload && typeof payload === "object") {
|
|
202
|
+
state.envelopes.set(payload, { body: JSON.parse(stored.serialized), serialized: stored.serialized });
|
|
203
|
+
}
|
|
155
204
|
state.spoolPersistenceFailureNoted = null;
|
|
156
205
|
if (payload && typeof payload === "object") payload._raw_spooled = true;
|
|
157
206
|
return true;
|
|
@@ -295,6 +344,48 @@ const armViewerBackoff = (state, error, timing) => {
|
|
|
295
344
|
return viewerFailure;
|
|
296
345
|
};
|
|
297
346
|
|
|
347
|
+
const warnRejectedEntry = async (state, { rejection, outcome, sessionID }) => {
|
|
348
|
+
const messages = {
|
|
349
|
+
retained: "codemem retained a rejected raw event; inspect it with codemem diagnostics capture list-rejected",
|
|
350
|
+
retain_failed: "codemem could not retain a rejected raw event outside retries; inspect saved events before retrying",
|
|
351
|
+
lock_release_failed: "codemem could not release a rejected-event lock; stop capture and inspect saved events before repairing the lock",
|
|
352
|
+
};
|
|
353
|
+
const message = messages[outcome];
|
|
354
|
+
await state.options.logLine(
|
|
355
|
+
`raw_events.spool.${outcome} status=${rejection.status} reason=${rejection.reason}`
|
|
356
|
+
);
|
|
357
|
+
await bestEffortHostLog(state, {
|
|
358
|
+
service: "codemem",
|
|
359
|
+
level: outcome === "retained" ? "warn" : "error",
|
|
360
|
+
message,
|
|
361
|
+
extra: { category: "rejection", status: rejection.status, reason: rejection.reason, outcome },
|
|
362
|
+
});
|
|
363
|
+
if (!state.options.hostNotify || !shouldToast(state, sessionID, `rejection:${outcome}`)) return;
|
|
364
|
+
await bestEffortNotify(state, { message, variant: outcome === "retained" ? "warning" : "error" });
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
const retainRejectedEntry = async (state, { eventId, rejection, sessionID, payload }) => {
|
|
368
|
+
let retained;
|
|
369
|
+
try {
|
|
370
|
+
retained = await retainRejectedRawEventSpoolEntry({
|
|
371
|
+
eventId,
|
|
372
|
+
...rejection,
|
|
373
|
+
homeDir: state.options.spoolHome,
|
|
374
|
+
});
|
|
375
|
+
} catch (error) {
|
|
376
|
+
await warnRejectedEntry(state, { rejection, sessionID, outcome: "retain_failed" });
|
|
377
|
+
if (error?.lock === "release_failed") {
|
|
378
|
+
await warnRejectedEntry(state, { rejection, sessionID, outcome: "lock_release_failed" });
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (payload && typeof payload === "object") state.retainedPayloads.add(payload);
|
|
383
|
+
await warnRejectedEntry(state, { rejection, sessionID, outcome: "retained" });
|
|
384
|
+
if (retained.lock === "release_failed") {
|
|
385
|
+
await warnRejectedEntry(state, { rejection, sessionID, outcome: "lock_release_failed" });
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
298
389
|
const drainLoadedEntries = async (state, loaded) => {
|
|
299
390
|
if (loaded.corruptCount > 0) {
|
|
300
391
|
await state.options.logLine(`raw_events.spool.corrupt_retained count=${loaded.corruptCount}`);
|
|
@@ -308,6 +399,10 @@ const drainLoadedEntries = async (state, loaded) => {
|
|
|
308
399
|
await postToViewer(state, entry.envelope);
|
|
309
400
|
await removeFromSpool(state, { eventId: entry.eventId });
|
|
310
401
|
} catch (error) {
|
|
402
|
+
if (error?.rawEventTerminalRejection) {
|
|
403
|
+
await retainRejectedEntry(state, { eventId: entry.eventId, rejection: error.rawEventTerminalRejection });
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
311
406
|
await state.options.logLine("raw_events.spool.drain_deferred category=fallback");
|
|
312
407
|
const status = error?.rawEventFailure?.status;
|
|
313
408
|
if (!Number.isInteger(status) || status >= 500 || status === 409) {
|
|
@@ -409,6 +504,7 @@ const checkViewerAvailability = async (state, now) => {
|
|
|
409
504
|
|
|
410
505
|
const postToViewer = async (state, body) => {
|
|
411
506
|
const options = state.options;
|
|
507
|
+
const outgoing = JSON.stringify({ ...body, db_path: options.promptPackDbPath, identity_target: options.identityTarget });
|
|
412
508
|
const response = await fetch(options.rawEventsUrl, {
|
|
413
509
|
method: "POST",
|
|
414
510
|
headers: { "Content-Type": "application/json" },
|
|
@@ -416,7 +512,7 @@ const postToViewer = async (state, body) => {
|
|
|
416
512
|
state.abortController.signal,
|
|
417
513
|
AbortSignal.timeout(options.rawEventsStatusTimeoutMs),
|
|
418
514
|
]),
|
|
419
|
-
body:
|
|
515
|
+
body: outgoing,
|
|
420
516
|
});
|
|
421
517
|
if (response.ok) return response;
|
|
422
518
|
let responseBody = null;
|
|
@@ -426,6 +522,11 @@ const postToViewer = async (state, body) => {
|
|
|
426
522
|
// Generic connection guidance remains the safe fallback.
|
|
427
523
|
}
|
|
428
524
|
const error = new Error(`raw-events post failed (${response.status})`);
|
|
525
|
+
error.rawEventTerminalRejection = classifyRawEventTerminalRejection({
|
|
526
|
+
status: response.status,
|
|
527
|
+
responseBody,
|
|
528
|
+
outgoingBytes: Buffer.byteLength(outgoing, "utf8"),
|
|
529
|
+
});
|
|
429
530
|
error.rawEventFailureCategory = options.classifyViewerFailure(responseBody);
|
|
430
531
|
error.rawEventFailure = {
|
|
431
532
|
stage: "post",
|
|
@@ -436,6 +537,23 @@ const postToViewer = async (state, body) => {
|
|
|
436
537
|
};
|
|
437
538
|
|
|
438
539
|
const handleViewerFailure = async (state, input, error, timing) => {
|
|
540
|
+
if (error?.rawEventTerminalRejection) {
|
|
541
|
+
const durable = await persistForRetry(state, input);
|
|
542
|
+
if (durable) {
|
|
543
|
+
const canonical = input.payload && typeof input.payload === "object"
|
|
544
|
+
? state.envelopes.get(input.payload) : null;
|
|
545
|
+
// A size rejection proves only the posted copy was too large. Retry changed saved bytes first.
|
|
546
|
+
if (error.rawEventTerminalRejection.status === 413
|
|
547
|
+
&& canonical && canonical.serialized !== input.serialized) return durable;
|
|
548
|
+
await retainRejectedEntry(state, {
|
|
549
|
+
eventId: input.body.event_id,
|
|
550
|
+
rejection: error.rawEventTerminalRejection,
|
|
551
|
+
sessionID: input.sessionID,
|
|
552
|
+
payload: input.payload,
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return durable;
|
|
556
|
+
}
|
|
439
557
|
if (!state.options.isActive()) return persistForRetry(state, input);
|
|
440
558
|
const category = error?.rawEventFailureCategory || "connection";
|
|
441
559
|
const viewerFailure = armViewerBackoff(state, error, timing);
|
|
@@ -461,6 +579,7 @@ const deliver = async (state, { sessionID, type, payload }) => {
|
|
|
461
579
|
if (!state.options.enabled) return true;
|
|
462
580
|
if (!sessionID || !type) return false;
|
|
463
581
|
if (payload?._raw_enqueued) return true;
|
|
582
|
+
if (payload && typeof payload === "object" && state.retainedPayloads.has(payload)) return true;
|
|
464
583
|
const now = Date.now();
|
|
465
584
|
const envelope = cachedEnvelope(state, sessionID, type, payload, now);
|
|
466
585
|
const input = { ...envelope, payload, sessionID };
|
|
@@ -71,12 +71,13 @@ export type RejectedRawEventRecoveryResult = {
|
|
|
71
71
|
| {
|
|
72
72
|
delivery: "accepted";
|
|
73
73
|
acknowledgement: "queued" | "ingested";
|
|
74
|
-
cleanup: "changed" | "failed" | "removed" | "uncertain";
|
|
74
|
+
cleanup: "changed" | "failed" | "removed" | "kept" | "uncertain";
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
export function recoverRejectedRawEventSpoolEntry(options: {
|
|
78
78
|
receipt: string;
|
|
79
79
|
homeDir?: string;
|
|
80
|
+
keepReceipt?: boolean;
|
|
80
81
|
/** Runs under the directory serializer. Must not await another mutation in the same spool. */
|
|
81
82
|
deliver: (entry: {
|
|
82
83
|
serialized: string;
|
|
@@ -155,7 +155,15 @@ const changedConflictFields = (existing, incoming, schema = CONFLICT_FIELDS, pre
|
|
|
155
155
|
return { fields, other: other || !isDeepStrictEqual(left, right) };
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
const RUNTIME_CONTEXT_FIELDS = ["cwd", "project", "started_at"];
|
|
159
|
+
const hasRuntimeContext = (event) => RUNTIME_CONTEXT_FIELDS.every((key) =>
|
|
160
|
+
Object.hasOwn(event, key) && (event[key] === null || typeof event[key] === "string"));
|
|
161
|
+
const withoutRuntimeContext = ({ cwd: _cwd, project: _project, started_at: _started, ...event }) => event;
|
|
162
|
+
const differsOnlyInRuntimeContext = (left, right) =>
|
|
163
|
+
hasRuntimeContext(left) && hasRuntimeContext(right)
|
|
164
|
+
&& isDeepStrictEqual(withoutRuntimeContext(left), withoutRuntimeContext(right));
|
|
165
|
+
|
|
166
|
+
/** Content-derived IDs can be shared by runtimes with different directory context. Keep the first saved context. */
|
|
159
167
|
const compareEventApartFromDeliveryTime = (existingBytes, incomingBytes) => {
|
|
160
168
|
if (existingBytes === incomingBytes) return null;
|
|
161
169
|
try {
|
|
@@ -166,6 +174,7 @@ const compareEventApartFromDeliveryTime = (existingBytes, incomingBytes) => {
|
|
|
166
174
|
const left = withoutDeliveryTime(existing);
|
|
167
175
|
const right = withoutDeliveryTime(incoming);
|
|
168
176
|
if (isDeepStrictEqual(left, right)) return null;
|
|
177
|
+
if (differsOnlyInRuntimeContext(left, right)) return null;
|
|
169
178
|
return { reason: "field_mismatch", ...changedConflictFields(left, right) };
|
|
170
179
|
} catch {
|
|
171
180
|
// Malformed retained data is not proof that the new event is already durable.
|
|
@@ -281,6 +290,7 @@ const requireSpoolCapacity = async (directory, maxEntries) =>
|
|
|
281
290
|
});
|
|
282
291
|
|
|
283
292
|
const publishSpoolEntry = async (temporary, destination, bytes) => {
|
|
293
|
+
let published = bytes;
|
|
284
294
|
try {
|
|
285
295
|
await atSpoolStage("temporary_write", () => writeDurableFile(temporary, bytes));
|
|
286
296
|
await atSpoolStage("publish", async () => {
|
|
@@ -291,6 +301,7 @@ const publishSpoolEntry = async (temporary, destination, bytes) => {
|
|
|
291
301
|
const existing = await readFile(destination, "utf8");
|
|
292
302
|
const mismatch = compareEventApartFromDeliveryTime(existing, bytes);
|
|
293
303
|
if (mismatch) throw conflictingEntry({ branch: "publish_comparison", ...mismatch });
|
|
304
|
+
published = existing;
|
|
294
305
|
await chmod(destination, 0o600);
|
|
295
306
|
}
|
|
296
307
|
await chmod(destination, 0o600);
|
|
@@ -298,6 +309,7 @@ const publishSpoolEntry = async (temporary, destination, bytes) => {
|
|
|
298
309
|
} finally {
|
|
299
310
|
await rm(temporary, { force: true }).catch(() => {});
|
|
300
311
|
}
|
|
312
|
+
return published;
|
|
301
313
|
};
|
|
302
314
|
|
|
303
315
|
const writeRawEventSpoolEntryUnlocked = async ({
|
|
@@ -324,10 +336,10 @@ const writeRawEventSpoolEntryUnlocked = async ({
|
|
|
324
336
|
readMatchingRejectedEntry(directory, eventId, bytes));
|
|
325
337
|
if (rejected || existing) return rejected || existing;
|
|
326
338
|
await requireSpoolCapacity(directory, normalizedMaxEntries);
|
|
327
|
-
await publishSpoolEntry(temporary, destination, bytes);
|
|
339
|
+
const published = await publishSpoolEntry(temporary, destination, bytes);
|
|
328
340
|
await atSpoolStage("directory_sync", () => syncDirectory(directory));
|
|
329
341
|
|
|
330
|
-
return { eventId, serialized:
|
|
342
|
+
return { eventId, serialized: published };
|
|
331
343
|
};
|
|
332
344
|
|
|
333
345
|
const serializeSpoolMutation = (directory, action) => {
|
|
@@ -650,7 +662,7 @@ const deliveryAcknowledgement = async (deliver, serialized) => {
|
|
|
650
662
|
return { delivery: "unacknowledged", cleanup: "not_attempted", reason: "invalid_acknowledgement" };
|
|
651
663
|
};
|
|
652
664
|
|
|
653
|
-
const
|
|
665
|
+
const finishRecoveredSnapshot = async (snapshot, lock, { keepReceipt }) => {
|
|
654
666
|
let current;
|
|
655
667
|
try {
|
|
656
668
|
await requirePrivateSpoolDirectory(snapshot.directory);
|
|
@@ -671,6 +683,7 @@ const removeRecoveredSnapshot = async (snapshot, lock) => {
|
|
|
671
683
|
try {
|
|
672
684
|
await assertRejectedSpoolLock(lock);
|
|
673
685
|
if (!sameFileSnapshot(await lstat(snapshot.path), snapshot.details)) return "changed";
|
|
686
|
+
if (keepReceipt === true) return "kept";
|
|
674
687
|
await rm(snapshot.path);
|
|
675
688
|
} catch {
|
|
676
689
|
return "failed";
|
|
@@ -683,7 +696,7 @@ const removeRecoveredSnapshot = async (snapshot, lock) => {
|
|
|
683
696
|
}
|
|
684
697
|
};
|
|
685
698
|
|
|
686
|
-
const deliverRejectedSnapshot = async ({ directory, receipt, entry, deliver }, lock) => {
|
|
699
|
+
const deliverRejectedSnapshot = async ({ directory, receipt, entry, deliver, keepReceipt }, lock) => {
|
|
687
700
|
let handle;
|
|
688
701
|
try {
|
|
689
702
|
const path = join(directory, receipt);
|
|
@@ -700,7 +713,7 @@ const deliverRejectedSnapshot = async ({ directory, receipt, entry, deliver }, l
|
|
|
700
713
|
digest: createHash("sha256").update(inspection.serialized, "utf8").digest("hex") };
|
|
701
714
|
const delivery = await deliveryAcknowledgement(deliver, snapshot.serialized);
|
|
702
715
|
if (delivery.delivery !== "accepted") return delivery;
|
|
703
|
-
return { ...delivery, cleanup: await
|
|
716
|
+
return { ...delivery, cleanup: await finishRecoveredSnapshot(snapshot, lock, { keepReceipt }) };
|
|
704
717
|
} finally {
|
|
705
718
|
await handle?.close().catch(() => {});
|
|
706
719
|
}
|
|
@@ -732,7 +745,7 @@ const recoverRejectedEntryUnlocked = async (options) => {
|
|
|
732
745
|
}
|
|
733
746
|
};
|
|
734
747
|
|
|
735
|
-
const recoverRejectedRawEventSpoolEntry = async ({ receipt, homeDir = homedir(), deliver } = {}) => {
|
|
748
|
+
const recoverRejectedRawEventSpoolEntry = async ({ receipt, homeDir = homedir(), deliver, keepReceipt } = {}) => {
|
|
736
749
|
const entry = typeof receipt === "string" ? parseRejectedFilename(receipt) : null;
|
|
737
750
|
if (!entry || typeof deliver !== "function") {
|
|
738
751
|
return { delivery: "not_attempted", cleanup: "not_attempted", lock: "not_acquired",
|
|
@@ -741,7 +754,7 @@ const recoverRejectedRawEventSpoolEntry = async ({ receipt, homeDir = homedir(),
|
|
|
741
754
|
try {
|
|
742
755
|
const directory = resolveSpoolDirectory(homeDir);
|
|
743
756
|
return await serializeSpoolMutation(directory, () =>
|
|
744
|
-
recoverRejectedEntryUnlocked({ directory, receipt, entry, deliver }));
|
|
757
|
+
recoverRejectedEntryUnlocked({ directory, receipt, entry, deliver, keepReceipt }));
|
|
745
758
|
} catch (error) {
|
|
746
759
|
return { ...recoveryFailure(error), lock: "not_acquired" };
|
|
747
760
|
}
|
package/.opencode/lib/runtime.js
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
|
|
39
39
|
const TRUTHY_VALUES = ["1", "true", "yes"];
|
|
40
40
|
const DISABLED_VALUES = ["0", "false", "off"];
|
|
41
|
-
const PINNED_BACKEND_VERSION = "0.
|
|
41
|
+
const PINNED_BACKEND_VERSION = "0.49.0-beta.1";
|
|
42
42
|
const COMPAT_CHECK_DELAY_MS = 1500;
|
|
43
43
|
const COMPAT_CHECK_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
44
44
|
const MAX_UPDATE_STATUS_BYTES = 16 * 1024;
|
|
@@ -311,8 +311,9 @@ const hashPromptPackQuery = (query) =>
|
|
|
311
311
|
|
|
312
312
|
const redactPackCommand = (runner, runnerArgs, packArgs) => {
|
|
313
313
|
const safePackArgs = [...packArgs];
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
const queryIndex = safePackArgs[0] === "memory" ? 2 : 1;
|
|
315
|
+
if (safePackArgs[queryIndex - 1] === "pack" && safePackArgs.length > queryIndex) {
|
|
316
|
+
safePackArgs[queryIndex] = "[query-redacted]";
|
|
316
317
|
}
|
|
317
318
|
for (let index = 0; index < safePackArgs.length - 1; index += 1) {
|
|
318
319
|
if (safePackArgs[index] === "--working-set-file") {
|
|
@@ -722,7 +723,7 @@ const buildPackArgs = ({ query, filesModified, injectLimit, injectTokenBudget, i
|
|
|
722
723
|
.slice(-8)
|
|
723
724
|
.map((value) => String(value || "").trim())
|
|
724
725
|
.filter(Boolean);
|
|
725
|
-
const args = ["pack", query, "--json"];
|
|
726
|
+
const args = ["memory", "pack", query, "--json"];
|
|
726
727
|
if (internalLedger) {
|
|
727
728
|
args.push("--internal-ledger");
|
|
728
729
|
}
|
|
@@ -2303,8 +2304,8 @@ const createCliStatusTools = ({ runCli, viewerUrlHost, viewerPort, logPath }) =>
|
|
|
2303
2304
|
description: "Show codemem stats and recent entries",
|
|
2304
2305
|
args: {},
|
|
2305
2306
|
async execute() {
|
|
2306
|
-
const stats = await runCli(["stats"]);
|
|
2307
|
-
const recent = await runCli(["
|
|
2307
|
+
const stats = await runCli(["memory", "stats"]);
|
|
2308
|
+
const recent = await runCli(["memory", "list", "--limit", "5"]);
|
|
2308
2309
|
const lines = [
|
|
2309
2310
|
`viewer: http://${viewerUrlHost}:${viewerPort}`,
|
|
2310
2311
|
`log: ${logPath || "disabled"}`,
|
|
@@ -2328,7 +2329,7 @@ const createCliStatusTools = ({ runCli, viewerUrlHost, viewerPort, logPath }) =>
|
|
|
2328
2329
|
// Number.isFinite accepts floats and negatives; coerce to a positive
|
|
2329
2330
|
// integer (default 5) before forwarding to the CLI.
|
|
2330
2331
|
const safeLimit = String(parsePositiveInt(limit, 5));
|
|
2331
|
-
const recent = await runCli(["
|
|
2332
|
+
const recent = await runCli(["memory", "list", "--limit", safeLimit]);
|
|
2332
2333
|
if (recent.exitCode === 0) {
|
|
2333
2334
|
return recent.stdout.trim() || "No recent memories.";
|
|
2334
2335
|
}
|
|
@@ -2340,7 +2341,7 @@ const createCliStatusTools = ({ runCli, viewerUrlHost, viewerPort, logPath }) =>
|
|
|
2340
2341
|
description: "Show codemem stats",
|
|
2341
2342
|
args: {},
|
|
2342
2343
|
async execute() {
|
|
2343
|
-
const stats = await runCli(["stats"]);
|
|
2344
|
+
const stats = await runCli(["memory", "stats"]);
|
|
2344
2345
|
if (stats.exitCode === 0) {
|
|
2345
2346
|
return stats.stdout.trim() || "No stats yet.";
|
|
2346
2347
|
}
|
|
@@ -3191,7 +3192,7 @@ export const createCodememRuntime = async ({ location, host, hostGeneration = nu
|
|
|
3191
3192
|
return;
|
|
3192
3193
|
}
|
|
3193
3194
|
|
|
3194
|
-
const versionResult = await runCli(["version"]);
|
|
3195
|
+
const versionResult = await runCli(["--version"]);
|
|
3195
3196
|
if (versionResult?.exitCode !== 0) {
|
|
3196
3197
|
await logLine(
|
|
3197
3198
|
`compat.version_check_failed exit=${versionResult?.exitCode ?? "unknown"} stderr=${
|
|
@@ -3280,7 +3281,7 @@ export const createCodememRuntime = async ({ location, host, hostGeneration = nu
|
|
|
3280
3281
|
)}`
|
|
3281
3282
|
);
|
|
3282
3283
|
|
|
3283
|
-
const refreshedResult = await runCli(["version"]);
|
|
3284
|
+
const refreshedResult = await runCli(["--version"]);
|
|
3284
3285
|
const refreshedVersion = (refreshedResult?.stdout || "").trim();
|
|
3285
3286
|
if (
|
|
3286
3287
|
refreshedResult?.exitCode === 0
|
|
@@ -3353,7 +3354,7 @@ export const createCodememRuntime = async ({ location, host, hostGeneration = nu
|
|
|
3353
3354
|
await logLine(`release.auto_update_start cmd=${autoPlan.commandText}`);
|
|
3354
3355
|
const installation = await installCliUpdate(autoPlan.command);
|
|
3355
3356
|
if (installation?.exitCode === 0) {
|
|
3356
|
-
const verification = await runCli(["version"]);
|
|
3357
|
+
const verification = await runCli(["--version"]);
|
|
3357
3358
|
const installedVersion = (verification?.stdout || "").trim();
|
|
3358
3359
|
if (verification?.exitCode !== 0 || installedVersion !== notification.latestVersion) {
|
|
3359
3360
|
await logLine(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemem/opencode-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0-beta.1",
|
|
4
4
|
"description": "CodeMem plugin for OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"@opencode/plugin": "2.0.24"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"
|
|
42
|
+
"@babel/parser": "8.1.0",
|
|
43
43
|
"@opencode/cli": "2.0.24",
|
|
44
44
|
"@types/node": "^24.12.4",
|
|
45
|
+
"codemem": "^0.49.0-beta.1",
|
|
45
46
|
"vitest": "^4.1.11"
|
|
46
47
|
},
|
|
47
48
|
"repository": {
|