opencode-self-improvement 0.14.9 → 0.14.10
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.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/index.ts +92 -2
package/README.md
CHANGED
|
@@ -293,5 +293,6 @@ bun run gate:hooks # once per clone: run the gate on `git push`
|
|
|
293
293
|
| `/repo-init` missing from the command list | The self-install couldn't write to `~/.config/opencode/commands/`. Create it and restart, or ask the model to "init memory for this repo" — the same tool. |
|
|
294
294
|
| Init says `Graph: unavailable` | `codebase-memory-mcp` couldn't start. Install pinned `0.11.0` or point `OPENCODE_CBM_BIN` at the binary. Scripts are still remembered without it. |
|
|
295
295
|
| Stale plugin after an update | `opencode plugin update opencode-self-improvement` (or bump the pinned `@version` in the `plugins` entry) and restart opencode. |
|
|
296
|
+
| `Error: Plugin is not configured` right after `plugin add` | An opencode bug ([#54654](https://github.com/anomalyco/opencode/issues/54654)), not a config problem: the first `plugin list/check/update` against a cold background service reads the plugin inventory before activation finishes. The plugin is installed and loading — just run the command again. |
|
|
296
297
|
| Auto-capture does nothing | `autoCapture` needs a valid `captureModel` in `provider/id` form; a bad one disables capture with a startup warning. `captureOnCompact` alone does nothing. Rejected candidates are logged as evidence, not errors — check `memory_evidence`. |
|
|
297
298
|
| Reset all memories | Delete `~/.config/opencode/memory/`. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-self-improvement",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.10",
|
|
4
4
|
"description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"exports": {
|
package/src/index.ts
CHANGED
|
@@ -225,6 +225,48 @@ export function resetCaptureCooldowns(): void {
|
|
|
225
225
|
lastCaptureRun.clear();
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
// ---- capture trigger vocabulary (#136) -------------------------------------
|
|
229
|
+
// opencode 2.x has no `session.idle`. The subscription used to wait for exactly
|
|
230
|
+
// that string, so auto-capture was dead on every 2.x host with no warning
|
|
231
|
+
// anywhere: live proof is in the issue (45 s of the running service's own SSE
|
|
232
|
+
// stream over a complete turn, and zero `capture_lag` lines in the whole
|
|
233
|
+
// evidence history). What the host really publishes when a turn ends is the
|
|
234
|
+
// `session.execution.*` family; `session.status` is the ephemeral variant whose
|
|
235
|
+
// `status.type` says "idle".
|
|
236
|
+
//
|
|
237
|
+
// These lists are the single source of truth for what the capture subscription
|
|
238
|
+
// reacts to, and test/event-fidelity.test.ts asserts every name here appears in
|
|
239
|
+
// the installed @opencode/schema event manifest. Invented event names are the
|
|
240
|
+
// bug class that caused #78 and then survived a review, a merge and 480 green
|
|
241
|
+
// tests, because the tests fabricated the same invented payload.
|
|
242
|
+
// Recorded live, not guessed: `succeeded` and `interrupted` were both observed
|
|
243
|
+
// on a running desktop service (test/fixtures/host-events.jsonl).
|
|
244
|
+
export const TURN_END_EVENTS = ["session.execution.succeeded", "session.execution.interrupted"] as const;
|
|
245
|
+
|
|
246
|
+
/** Every event type the capture subscription reacts to (fidelity-tested). */
|
|
247
|
+
export const CAPTURE_EVENT_TYPES: readonly string[] = [...TURN_END_EVENTS];
|
|
248
|
+
|
|
249
|
+
// Deliberately NOT triggers, because a live host was never observed sending
|
|
250
|
+
// them, and dead branches are what caused #136 in the first place:
|
|
251
|
+
// • `session.idle` - declared, never emitted (the original bug).
|
|
252
|
+
// • `session.status` - declared, never emitted; would also need
|
|
253
|
+
// `data.status.type === "idle"` filtering.
|
|
254
|
+
// • `session.execution.failed` - declared, not reproduced here. A failed turn
|
|
255
|
+
// simply does not capture, which costs nothing; adding it
|
|
256
|
+
// later is allowed the moment a recording shows it.
|
|
257
|
+
// test/event-fidelity.test.ts enforces that nothing enters TURN_END_EVENTS
|
|
258
|
+
// without appearing in the recording.
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* True when a host event means "this session just went quiet". The internal
|
|
262
|
+
* trigger name stays "idle" (cooldown keys, `auto_capture_*` evidence lines and
|
|
263
|
+
* the historical idle-vs-compaction bench all use it).
|
|
264
|
+
*/
|
|
265
|
+
export function captureTriggerFor(event: unknown): boolean {
|
|
266
|
+
const type = (event as { type?: unknown } | null)?.type;
|
|
267
|
+
return typeof type === "string" && (TURN_END_EVENTS as readonly string[]).includes(type);
|
|
268
|
+
}
|
|
269
|
+
|
|
228
270
|
// The real setup implementation, written against the loose local PluginCtx
|
|
229
271
|
// (the only members of the V2 context this plugin actually touches).
|
|
230
272
|
const impl = {
|
|
@@ -1238,8 +1280,10 @@ const impl = {
|
|
|
1238
1280
|
try {
|
|
1239
1281
|
for await (const raw of eventApi.subscribe({ signal: controller.signal })) {
|
|
1240
1282
|
const event = raw as Record<string, any>;
|
|
1241
|
-
if (event
|
|
1242
|
-
|
|
1283
|
+
if (!captureTriggerFor(event)) continue;
|
|
1284
|
+
// 2.x carries the session inside `data`; the other two shapes are
|
|
1285
|
+
// kept because the measured listener sees both across host modes.
|
|
1286
|
+
const sid = event.data?.sessionID ?? event.sessionID ?? event.properties?.sessionID;
|
|
1243
1287
|
if (typeof sid !== "string") continue;
|
|
1244
1288
|
setCurrent({ sessionID: sid });
|
|
1245
1289
|
const now = Date.now();
|
|
@@ -1279,6 +1323,52 @@ const impl = {
|
|
|
1279
1323
|
"[opencode-self-improvement] captureOnCompact is on but autoCapture is off; compaction capture stays disabled (autoCapture is the master switch).",
|
|
1280
1324
|
);
|
|
1281
1325
|
}
|
|
1326
|
+
// ---- startup heartbeat (#138) ------------------------------------------
|
|
1327
|
+
// Every other evidence line is written BY something that already worked,
|
|
1328
|
+
// so "capture is off", "capture is misconfigured" and "capture is armed and
|
|
1329
|
+
// inert" were indistinguishable from anything a user could read - which is
|
|
1330
|
+
// exactly how a pipeline that had never run in ten days survived a review
|
|
1331
|
+
// and a merge. This one line makes the ABSENCE of capture activity
|
|
1332
|
+
// interpretable: `capture=` names why, `subscribed=` lists the event types
|
|
1333
|
+
// the subscription actually reacts to. Guarded like every other hook: a
|
|
1334
|
+
// broken store must not turn plugin load into a throw.
|
|
1335
|
+
await guarded("plugin_load heartbeat", async () => {
|
|
1336
|
+
let pluginVersion = "unknown";
|
|
1337
|
+
try {
|
|
1338
|
+
const pkg = await Bun.file(new URL("../package.json", import.meta.url)).json();
|
|
1339
|
+
if (typeof pkg?.version === "string") pluginVersion = pkg.version;
|
|
1340
|
+
} catch {
|
|
1341
|
+
// a heartbeat with an unknown version still beats no heartbeat
|
|
1342
|
+
}
|
|
1343
|
+
const wantCapture = ctx.options?.autoCapture === true;
|
|
1344
|
+
const modelOk = !!parseModelRef(
|
|
1345
|
+
typeof ctx.options?.captureModel === "string" ? ctx.options.captureModel : "",
|
|
1346
|
+
);
|
|
1347
|
+
const capabilities = ["event.subscribe", "generate.text", "session.context"].filter((name) => {
|
|
1348
|
+
const [domain, method] = name.split(".");
|
|
1349
|
+
return typeof (ctx as unknown as Record<string, any>)?.[domain]?.[method] === "function";
|
|
1350
|
+
});
|
|
1351
|
+
const captureState = !wantCapture
|
|
1352
|
+
? "off"
|
|
1353
|
+
: !modelOk
|
|
1354
|
+
? "invalid_model"
|
|
1355
|
+
: capabilities.length < 3
|
|
1356
|
+
? "no_capabilities"
|
|
1357
|
+
: "on";
|
|
1358
|
+
await record(
|
|
1359
|
+
"plugin_load",
|
|
1360
|
+
{
|
|
1361
|
+
version: pluginVersion,
|
|
1362
|
+
capture: captureState,
|
|
1363
|
+
capture_on_compact: ctx.options?.captureOnCompact !== false,
|
|
1364
|
+
capabilities: `[${capabilities.join(",")}]`,
|
|
1365
|
+
subscribed: `[${CAPTURE_EVENT_TYPES.join(",")}]`,
|
|
1366
|
+
inject_budget: injectBudget(),
|
|
1367
|
+
store_rows: (await loadAll()).length,
|
|
1368
|
+
},
|
|
1369
|
+
false,
|
|
1370
|
+
);
|
|
1371
|
+
});
|
|
1282
1372
|
// Single cleanup returned by setup: tears down the measured listener and,
|
|
1283
1373
|
// when enabled, the capture subscription. Future teardowns merge in here.
|
|
1284
1374
|
return () => {
|