opencode-self-improvement 0.15.2 → 0.15.4

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
@@ -47,6 +47,8 @@ After that, memory is just conversation: ask the agent to remember something and
47
47
  - **Surfaces** — a terminal footer badge and `/memory` panel, `/memory-report` for chat clients, a `memory_status` tool, and a browser admin editor. See [Surfaces](#surfaces).
48
48
  - **Secret redaction** — credential-shaped values in content become `[redacted]`. See [Secret redaction](#secret-redaction).
49
49
 
50
+ Daily memory writes publish a complete replacement file under that lock, so concurrent readers see the previous or new complete file rather than a partially appended record. Appending a row therefore rewrites the day file (in addition to the existing timestamp-uniqueness read). On Windows, a reader handle that prevents replacement can make the write refuse after the replacement retry window; the previous bytes remain intact and the caller can retry once the handle closes. This publication rule applies to daily memory files, not append-only evidence, use, rejection, or audit logs; [#198](https://github.com/abogartz/opencode-self-improvement/issues/198) tracks the broader read boundary.
51
+
50
52
  Memory is stored outside every repository, under `~/.config/opencode/memory` by default (override with `OPENCODE_MEMORY_DIR`). To start over, delete that directory.
51
53
 
52
54
  ## Options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
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/memory.ts CHANGED
@@ -215,9 +215,9 @@ export interface AppendMemoryInput {
215
215
  // it can collide with are ones this same file received in the same millisecond;
216
216
  // scanning just it keeps the locked section to one read of one file. (A row
217
217
  // hand-placed with today's ts in another day's file is outside this promise.)
218
- async function existingTs(file: string): Promise<Set<string>> {
218
+ function existingTs(text: string): Set<string> {
219
219
  const set = new Set<string>();
220
- for (const line of await readLines(file)) {
220
+ for (const line of text.split("\n")) {
221
221
  const f = parseLine(line);
222
222
  if (f && typeof f.ts === "string") set.add(f.ts);
223
223
  }
@@ -323,28 +323,34 @@ export async function appendMemory(input: AppendMemoryInput): Promise<string> {
323
323
  // two rows with the same identity, and an append that lands inside someone
324
324
  // else's whole-file rewrite is simply not there afterwards.
325
325
  return withStoreLock(file, async () => {
326
- const taken = await existingTs(file);
326
+ const since = await fileIdentity(file);
327
+ let prior = "";
328
+ try { prior = await readFile(file, "utf8"); }
329
+ catch (err) { if ((err as NodeJS.ErrnoException).code !== "ENOENT") throw err; }
330
+ const taken = existingTs(prior);
327
331
  let ts = new Date().toISOString();
328
332
  let guard = 0;
329
333
  while (taken.has(ts) && guard++ < 1000) {
330
334
  ts = new Date(new Date(ts).getTime() + 1).toISOString();
331
335
  }
332
336
  const kw = normalizeKeywords(input.kw);
333
- await appendLog(
334
- file,
335
- formatLine({
336
- ts,
337
- type: input.type,
338
- scope: input.scope,
339
- content,
340
- issue: input.issue,
341
- tags: input.tags?.length ? input.tags.join(",") : undefined,
342
- kw: kw?.join(","),
343
- status: input.status,
344
- repo,
345
- repoPath,
346
- }),
347
- );
337
+ const line = formatLine({
338
+ ts,
339
+ type: input.type,
340
+ scope: input.scope,
341
+ content,
342
+ issue: input.issue,
343
+ tags: input.tags?.length ? input.tags.join(",") : undefined,
344
+ kw: kw?.join(","),
345
+ status: input.status,
346
+ repo,
347
+ repoPath,
348
+ });
349
+ // A lock excludes writers, not readers: an O_APPEND read can end mid-row.
350
+ // Publish the complete day file using the read already needed for IDs.
351
+ // This costs a whole-file write and can refuse on Windows reader handles;
352
+ // the old destination remains intact if publication fails (#198).
353
+ await writeAtomic(file, prior + (prior && !prior.endsWith("\n") ? "\n" : "") + line + "\n", since);
348
354
  return ts;
349
355
  }, LOCK_WRITE);
350
356
  }
package/tsconfig.json CHANGED
@@ -13,5 +13,5 @@
13
13
  "jsx": "preserve",
14
14
  "jsxImportSource": "@opentui/solid"
15
15
  },
16
- "include": ["index.ts", "src", "test", "bench", "e2e"]
17
- }
16
+ "include": ["index.ts", "src", "test", "bench", "e2e", "scripts"]
17
+ }