opencode-self-improvement 0.14.21 → 0.14.22

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 CHANGED
@@ -305,6 +305,8 @@ bun run gate # typecheck + lint + unit tests + terminal smoke & BDD
305
305
  bun run gate:hooks # once per clone: run the gate on `git push`
306
306
  ```
307
307
 
308
+ Use Bun **1.4.4** for development checks, matching CI. `bun run test` and `bun run test:e2e` run files across at most four worker processes with Bun's file isolation; cases inside each file stay sequential because fixtures share environment variables and module state. The local gate uses those same scripts. To diagnose order-dependent failures in the original shared-process mode, run `bun test ./test/` or `bun test ./e2e/ --timeout 240000` directly.
309
+
308
310
  **Feature order is BDD-first.** A new feature starts by adding or fixing a scenario in `e2e/` that describes the behavior as a user would observe it — before implementation code and before unit tests. Then the unit tests for the pieces, then the code until everything is green. If no scenario turns red first, the feature has no observable contract.
309
311
 
310
312
  `e2e/` boots the **real opencode CLI** against each candidate in a fully isolated instance (fresh config, fresh db, fresh memory store, empty `HOME`) driven by a scripted OpenAI-compatible fake model — no API keys. It covers loading from the source tree and from the packed npm artifact installed runtime-deps-only, plus BDD flows for remember, recall, exact and near duplicates, ungrounded claims, and forget. Needs `opencode` on `PATH` locally, or set `OPENCODE_BIN`. A `test-windows` leg also runs the suite on Windows; it reports without gating merges.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.14.21",
3
+ "version": "0.14.22",
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": {
@@ -60,8 +60,8 @@
60
60
  "typescript": "^7.0.2"
61
61
  },
62
62
  "scripts": {
63
- "test": "bun test ./test/",
64
- "test:e2e": "bun test ./e2e/ --timeout 240000",
63
+ "test": "bun test ./test/ --parallel=4",
64
+ "test:e2e": "bun test ./e2e/ --parallel=4 --timeout 240000",
65
65
  "gate": "bun scripts/merge-gate.ts",
66
66
  "gate:hooks": "git config core.hooksPath .githooks",
67
67
  "typecheck": "bun x tsc --noEmit -p tsconfig.json",
package/src/state.ts CHANGED
@@ -33,7 +33,9 @@ export interface SessionState {
33
33
  pendingGate: {
34
34
  call: string;
35
35
  cmd: string;
36
- chain: ToolResult[];
36
+ chain: string[];
37
+ count: number;
38
+ fix?: { call: string; index: number };
37
39
  } | null;
38
40
  // Bounded provenance for write telemetry (#163), independent of the full
39
41
  // calls ledger used by grounding, attribution, and convergence.
package/src/triggers.ts CHANGED
@@ -33,6 +33,17 @@ export interface AfterOutput {
33
33
  const ENGAGEMENT_TOOLS = new Set(["grep", "glob", "read", "edit", "write", "bash", "shell"]);
34
34
 
35
35
  const RECENT_EVIDENCE_CALLS = 10;
36
+ // Pending recovery stores IDs only; the full attribution ledger stays in calls.
37
+ function trackPending(s: SessionState, rec: ToolResult): void {
38
+ const pending = s.pendingGate;
39
+ if (!pending) return;
40
+ pending.count++;
41
+ if (rec.tool === "edit" || rec.tool === "write") {
42
+ pending.fix = { call: rec.call, index: pending.count };
43
+ }
44
+ pending.chain.push(rec.call);
45
+ if (pending.chain.length > RECENT_EVIDENCE_CALLS) pending.chain.shift();
46
+ }
36
47
  // Recent engagement + latest gate check + FAIL/fix/PASS + tool FAIL/PASS.
37
48
  export const MAX_WRITE_EVIDENCE_REFS = RECENT_EVIDENCE_CALLS + 1 + 3 + 2;
38
49
 
@@ -149,12 +160,12 @@ export async function afterTool(input: AfterInput, out: AfterOutput): Promise<vo
149
160
  rec.cmd = family;
150
161
  await record("gate_check", { cmd: family, status }, true, sid);
151
162
  if (status === "FAIL") {
152
- s.pendingGate = { call, cmd: family, chain: [] };
163
+ s.pendingGate = { call, cmd: family, chain: [], count: 0 };
153
164
  } else if (s.pendingGate && s.pendingGate.cmd === family) {
154
165
  const pend = s.pendingGate;
155
- const chainCalls = [pend.call, ...pend.chain.map((c) => c.call), call];
156
- const edits = pend.chain.filter((c) => c.tool === "edit" || c.tool === "write");
157
- const fix = edits.length ? edits[edits.length - 1].call : call;
166
+ const fix = pend.fix?.call ?? call;
167
+ const oldFix = pend.fix && pend.fix.index <= pend.count - pend.chain.length;
168
+ const chainCalls = [pend.call, ...(oldFix ? [fix] : []), ...pend.chain, call];
158
169
  await record(
159
170
  "t4_learning",
160
171
  {
@@ -164,6 +175,7 @@ export async function afterTool(input: AfterInput, out: AfterOutput): Promise<vo
164
175
  to: "PASS",
165
176
  gate_couple: true,
166
177
  evidence_chain: `[${chainCalls.join(",")}]`,
178
+ evidence_chain_count: pend.count + 2,
167
179
  fix_ref: fix,
168
180
  },
169
181
  false,
@@ -173,14 +185,14 @@ export async function afterTool(input: AfterInput, out: AfterOutput): Promise<vo
173
185
  s.writeEvidence.gateRecovery = [pend.call, fix, call];
174
186
  s.pendingGate = null;
175
187
  } else if (s.pendingGate) {
176
- s.pendingGate.chain.push(rec);
188
+ trackPending(s, rec);
177
189
  }
178
190
  trackCall(s, rec);
179
191
  return;
180
192
  }
181
193
 
182
194
  // Keep the pending gate chain (grep/read/edit between FAIL and PASS).
183
- if (s.pendingGate) s.pendingGate.chain.push(rec);
195
+ trackPending(s, rec);
184
196
  trackCall(s, rec);
185
197
 
186
198
  // ---- Failed -> fixed retry (non-gate tools) -------------------------------