opencode-self-improvement 0.14.5 → 0.14.7
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/package.json +1 -1
- package/src/gates.ts +7 -1
- package/src/index.ts +20 -9
- package/src/memory.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-self-improvement",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
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/gates.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface GateContext {
|
|
|
50
50
|
liveRoot: string;
|
|
51
51
|
evidenceCalls: string[];
|
|
52
52
|
hasGateCheck: boolean;
|
|
53
|
+
// The session this write belongs to, when the caller knows it by name.
|
|
54
|
+
// Repo-stamp resolution prefers it over the mutable global current, which
|
|
55
|
+
// a capture's model-call await can outlive into another session (#116).
|
|
56
|
+
sessionID?: string;
|
|
53
57
|
// True when the session exercised the code (read/grep/edit/bash results
|
|
54
58
|
// recorded). Empirical engagement substitutes for hand-copied refs (gate
|
|
55
59
|
// injection): the write encodes behavior that actually happened here, so the
|
|
@@ -606,7 +610,9 @@ export async function runWriteGate(
|
|
|
606
610
|
}
|
|
607
611
|
|
|
608
612
|
const snapshot = await snapshotFiles([join(memoryRoot(), `${new Date().toISOString().split("T")[0]}.logfmt`)]);
|
|
609
|
-
|
|
613
|
+
// The write carries the CALLER's session, not whatever current says after
|
|
614
|
+
// the gate's own awaits - capture's stamp must follow the captured session.
|
|
615
|
+
const ts = await appendMemory({ ...candidate, sessionID: ctx.sessionID });
|
|
610
616
|
await record("write_promoted", {
|
|
611
617
|
gate: 4,
|
|
612
618
|
op: "write",
|
package/src/index.ts
CHANGED
|
@@ -268,12 +268,21 @@ const impl = {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
const gateContext = (): GateContext =>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
const gateContext = (sid?: string): GateContext => {
|
|
272
|
+
// Every session-scoped member resolves for the CALLER's session when it
|
|
273
|
+
// knows one (#116): capture awaits a model call between setCurrent and
|
|
274
|
+
// persistence, and on a multi-session server the global current moves
|
|
275
|
+
// during that await. Falling back to getCurrent() is exactly today's
|
|
276
|
+
// behavior for callers whose current IS their session (tool hooks).
|
|
277
|
+
const bound = sid ?? getCurrent().sid;
|
|
278
|
+
return {
|
|
279
|
+
sessionID: sid,
|
|
280
|
+
liveRoot: sessionDir(bound) ?? liveRoot,
|
|
281
|
+
evidenceCalls: evidenceCalls(bound),
|
|
282
|
+
hasGateCheck: hasGateCheck(bound),
|
|
283
|
+
hasEngagement: hasEngagement(bound),
|
|
284
|
+
};
|
|
285
|
+
};
|
|
277
286
|
|
|
278
287
|
// Identity-event race backstop: a resumed session's FIRST turn can write
|
|
279
288
|
// before the subscription has delivered its execution.started, and the
|
|
@@ -1124,8 +1133,10 @@ const impl = {
|
|
|
1124
1133
|
trigger: "idle" | "compaction",
|
|
1125
1134
|
seededMsgs?: unknown,
|
|
1126
1135
|
): Promise<void> {
|
|
1127
|
-
// Bind the capturing session
|
|
1128
|
-
//
|
|
1136
|
+
// Bind the capturing session for the synchronous stretches of this
|
|
1137
|
+
// path - but NOT as a promise: the awaits below let another session
|
|
1138
|
+
// move current, so the gate context and the persisted rows thread
|
|
1139
|
+
// `sid` explicitly instead of reading it back from the global (#116).
|
|
1129
1140
|
setCurrent({ sessionID: sid });
|
|
1130
1141
|
let transcript = seeded;
|
|
1131
1142
|
let msgs = seededMsgs;
|
|
@@ -1154,7 +1165,7 @@ const impl = {
|
|
|
1154
1165
|
? ["auto-capture", CAPTURE_COMPACT_TAG]
|
|
1155
1166
|
: ["auto-capture"],
|
|
1156
1167
|
},
|
|
1157
|
-
gateContext(),
|
|
1168
|
+
gateContext(sid),
|
|
1158
1169
|
);
|
|
1159
1170
|
await record(
|
|
1160
1171
|
trigger === "compaction"
|
package/src/memory.ts
CHANGED
|
@@ -200,6 +200,9 @@ export interface AppendMemoryInput {
|
|
|
200
200
|
// appendMemory against the live repo scope.
|
|
201
201
|
repo?: string;
|
|
202
202
|
repoPath?: string;
|
|
203
|
+
// Which session the write belongs to, when the caller knows it (the gate
|
|
204
|
+
// threads it from GateContext, #116). Preferred over the ambient current.
|
|
205
|
+
sessionID?: string;
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
// ts values already in `file`. An appended row's ts is "now", so the only rows
|
|
@@ -262,7 +265,11 @@ export async function appendMemory(input: AppendMemoryInput): Promise<string> {
|
|
|
262
265
|
let repo = input.repo;
|
|
263
266
|
let repoPath = input.repoPath;
|
|
264
267
|
if (repo === undefined) {
|
|
265
|
-
|
|
268
|
+
// The caller's session when it named one: capture awaits a model call, and
|
|
269
|
+
// the last setCurrent before persistence may belong to another session
|
|
270
|
+
// entirely (#116). Unnamed writers (tools, viewer, restore) keep the
|
|
271
|
+
// ambient binding.
|
|
272
|
+
const cur = repoScopeFor(input.sessionID ?? getCurrent().sid);
|
|
266
273
|
if (cur) {
|
|
267
274
|
repo = cur.key;
|
|
268
275
|
repoPath = cur.path;
|