opencode-self-improvement 0.8.4 → 0.8.5

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
@@ -302,6 +302,8 @@ Run `/repo-init` once in every repo you work in. It:
302
302
  Ongoing use is just the memory tools. Ask the agent to remember something and it
303
303
  sticks across sessions; check what's stored with `memory_list`, refine with
304
304
  `memory_update`, retract with `memory_forget`, roll back with `memory_undo`.
305
+ `memory_undo` only lists and restores its own `<stamp>-YYYY-MM-DD.logfmt`
306
+ snapshots; any other file in `snapshots/` is ignored.
305
307
 
306
308
  `memory_update` takes a `query` that picks the row: its id, a clock fragment such
307
309
  as `00:11:25.867`, or a unique substring of its text. Omit it to update the newest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
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
@@ -399,7 +399,7 @@ const impl = {
399
399
  editor.add(validated(UndoArgs, {
400
400
  name: "memory_undo",
401
401
  description:
402
- "List memory snapshots, or restore one (rollback). Only snapshots inside this store's snapshots directory are accepted: pass a bare name from the list or its full path. SAFE BY DEFAULT: restore refuses if the current file has rows added or edited since the snapshot, and audited human/tool deletions stay deleted. Re-run with merge=true to restore AND keep divergent rows, or force=true for an explicit exact rollback. Blocklisted rows remain inactive in every mode.",
402
+ "List memory snapshots, or restore one (rollback). Only snapshots inside this store's snapshots directory are accepted: pass a bare name from the list or its full path. Non-standard files in snapshots/ are not listed or restorable. SAFE BY DEFAULT: restore refuses if the current file has rows added or edited since the snapshot, and audited human/tool deletions stay deleted. Re-run with merge=true to restore AND keep divergent rows, or force=true for an explicit exact rollback. Blocklisted rows remain inactive in every mode.",
403
403
  options: direct,
404
404
  async execute(args): Promise<{ content: string }> {
405
405
  if (args.snapshot) {
package/src/undo.ts CHANGED
@@ -19,6 +19,23 @@ import { snapshotFiles } from "./memory.ts";
19
19
 
20
20
  const SNAPSHOT_NAME = /^(\d+)-(\d{4}-\d{2}-\d{2}\.logfmt)$/;
21
21
 
22
+ function matchSnapshotName(name: string): RegExpExecArray | null {
23
+ const match = SNAPSHOT_NAME.exec(name);
24
+ if (!match) return null;
25
+ const original = match[2];
26
+ if (!original) return null;
27
+ const year = Number(original.slice(0, 4));
28
+ const month = Number(original.slice(5, 7));
29
+ const day = Number(original.slice(8, 10));
30
+ const date = new Date(0);
31
+ date.setUTCFullYear(year, month - 1, day);
32
+ return date.getUTCFullYear() === year &&
33
+ date.getUTCMonth() === month - 1 &&
34
+ date.getUTCDate() === day
35
+ ? match
36
+ : null;
37
+ }
38
+
22
39
  export interface SnapshotInfo {
23
40
  file: string;
24
41
  name: string;
@@ -31,7 +48,7 @@ export async function listSnapshots(): Promise<SnapshotInfo[]> {
31
48
  const out: SnapshotInfo[] = [];
32
49
  try {
33
50
  for await (const f of glob.scan(snapshotDir())) {
34
- if (!SNAPSHOT_NAME.test(f)) continue;
51
+ if (!matchSnapshotName(f)) continue;
35
52
  const info = Bun.file(join(snapshotDir(), f));
36
53
  out.push({
37
54
  file: join(snapshotDir(), f),
@@ -83,7 +100,7 @@ async function resolveSnapshot(
83
100
  memoryRootDir: string,
84
101
  ): Promise<{ path: string; original: string }> {
85
102
  const name = basename(snapshot);
86
- const match = SNAPSHOT_NAME.exec(name);
103
+ const match = matchSnapshotName(name);
87
104
  const original = match?.[2];
88
105
  const stamp = match ? Number(match[1]) : Number.NaN;
89
106
  if (!original || !Number.isSafeInteger(stamp)) {