opencode-self-improvement 0.14.11 → 0.14.13

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.
@@ -9,6 +9,7 @@
9
9
  import { deletionsFile } from "../config.ts";
10
10
  import { addBlock, removeBlock } from "../blocklist.ts";
11
11
  import { record, chainId } from "../evidence.ts";
12
+ import { redactSecrets } from "../secrets.ts";
12
13
  import { appendLog, fileIdentity, formatLine, parseLine, readLines, writeAtomic } from "../logfmt.ts";
13
14
  import { withStoreLock, LOCK_WRITE } from "../lock.ts";
14
15
  import {
@@ -55,6 +56,18 @@ async function findMemory(ts: string): Promise<Memory> {
55
56
 
56
57
  // Non-destructive edit: snapshot the pre-state, supersede the old entry, then
57
58
  // append the edited replacement (added ONLY because the edit requires it).
59
+ //
60
+ // ORIGIN PRESERVATION (#129): the replacement carries the target's repo stamp
61
+ // verbatim. The viewer is an ADMIN entry point with no repository scope of
62
+ // its own; letting appendMemory resolve the stamp from that null scope used
63
+ // to leave every edited row unstamped — i.e. silently GLOBAL, recallable and
64
+ // injectable in every other project. An edit must never widen visibility: a
65
+ // row from repo A stays invisible everywhere except A (and global rows, as
66
+ // before) after an edit. Making a row global is a deliberate action (the
67
+ // `global` flag on memory_remember), never a side effect of who clicked edit.
68
+ // An unstamped target (legacy row, or one explicitly stored global) has no
69
+ // origin to carry: the replacement is stamped explicitly "global" — same
70
+ // visibility as the absent stamp, and now honest about it on the line itself.
58
71
  export async function editMemory(input: EditInput): Promise<MutationResult> {
59
72
  requireReason(input.reason);
60
73
  const chain = chainId();
@@ -65,9 +78,16 @@ export async function editMemory(input: EditInput): Promise<MutationResult> {
65
78
  type: input.type || target.type,
66
79
  scope: input.scope || target.scope,
67
80
  content: input.content,
68
- issue: input.issue,
69
- tags: input.tags,
81
+ // Omitted metadata survives the edit (#129): the usual UI sends
82
+ // type/scope/content/reason, and dropping the old issue/tags/kw erased
83
+ // import/auto-capture provenance and retrieval aliases from a row whose
84
+ // prose only got a typo fix.
85
+ issue: input.issue ?? target.issue,
86
+ tags: input.tags ?? target.tags,
87
+ kw: target.kw,
70
88
  status: target.status,
89
+ repo: target.repo ?? "global",
90
+ repoPath: target.repo ? target.repoPath : undefined,
71
91
  });
72
92
  await markSuperseded(input.ts, {
73
93
  superseded_by: newTs,
@@ -155,7 +175,15 @@ async function audit(
155
175
  type: mem.type,
156
176
  scope: mem.scope,
157
177
  content: mem.content,
158
- reason,
178
+ // Origin survives the audit record (#129): the viewer's restore-entry
179
+ // path reads these lines, and a restore of a repo-private row must be
180
+ // able to re-stamp what was deleted. A line with no stamp is the
181
+ // legacy/unstamped case — restore leaves it global, as documented.
182
+ repo: mem.repo,
183
+ repoPath: mem.repoPath,
184
+ // Same write-boundary rule as evidence (#128): an audit reason is
185
+ // human prose and must not persist a recognized credential.
186
+ reason: redactSecrets(reason),
159
187
  }),
160
188
  );
161
189
  }
@@ -209,7 +209,7 @@ function render() {
209
209
  const actions = kind === "blocked"
210
210
  ? `<button class="btn warn" data-action="unblock" data-ts="${esc(m.ts)}" title="Restore this memory to the read paths">unblock</button>`
211
211
  : kind === "deleted"
212
- ? `<button class="btn warn" data-action="restore-deleted" data-ts="${esc(m.ts)}" data-type="${esc(m.type)}" data-scope="${esc(m.scope)}" data-content="${esc(m.content)}" title="Re-add this deleted entry to memory">restore</button>`
212
+ ? `<button class="btn warn" data-action="restore-deleted" data-ts="${esc(m.ts)}" data-type="${esc(m.type)}" data-scope="${esc(m.scope)}" data-content="${esc(m.content)}" data-repo="${esc(m.repo ?? "")}" data-repo-path="${esc(m.repoPath ?? "")}" title="Re-add this deleted entry to memory">restore</button>`
213
213
  : `<button class="btn" data-action="edit" data-ts="${esc(m.ts)}" title="Edit: snapshot, supersede this entry, append the replacement">edit</button>
214
214
  <button class="btn danger" data-action="delete" data-ts="${esc(m.ts)}" title="Delete: snapshot the file, then remove this entry (audited)">delete</button>
215
215
  <button class="btn danger" data-action="block" data-ts="${esc(m.ts)}" title="Block (poison): keep on disk but hide from recall/inject">block</button>`;
@@ -306,14 +306,16 @@ async function unblock(ts) {
306
306
  } catch (e) { toast(String(e.message), true); }
307
307
  }
308
308
 
309
- function restoreEntry(type, scope, content) {
309
+ function restoreEntry(type, scope, content, repo, repoPath) {
310
310
  askModal(
311
311
  "Restore deleted memory?",
312
312
  "Re-adds this entry to memory from its audit record.",
313
313
  "Restore",
314
314
  async () => {
315
315
  try {
316
- await api("/api/restore-entry", { type, scope, content });
316
+ // The audit line's origin stamp rides along (#129): a restore keeps the
317
+ // row's ORIGINAL visibility instead of silently landing global.
318
+ await api("/api/restore-entry", { type, scope, content, repo: repo || undefined, repoPath: repoPath || undefined });
317
319
  toast("restored to memory");
318
320
  await refresh();
319
321
  } catch (e) { toast(String(e.message), true); }
@@ -336,8 +338,8 @@ $("rows").addEventListener("click", (e) => {
336
338
  else if (action === "block") block(ts);
337
339
  else if (action === "unblock") unblock(ts);
338
340
  else if (action === "restore-deleted") {
339
- const { type, scope, content } = btn.dataset;
340
- restoreEntry(type, scope, content);
341
+ const { type, scope, content, repo, repoPath } = btn.dataset;
342
+ restoreEntry(type, scope, content, repo, repoPath);
341
343
  }
342
344
  });
343
345
 
@@ -76,6 +76,10 @@ interface Row {
76
76
  scope: string;
77
77
  content: string;
78
78
  reason?: string;
79
+ // Origin stamp (#129): what the row carried when it was deleted, so the
80
+ // restore-entry round trip can restore the row's ORIGINAL visibility.
81
+ repo?: string;
82
+ repoPath?: string;
79
83
  }
80
84
 
81
85
  // Deleted entries live only in the audit log (their memory line was removed),
@@ -91,6 +95,8 @@ async function deletedRows(): Promise<Row[]> {
91
95
  scope: String(f.scope ?? ""),
92
96
  content: String(f.content ?? ""),
93
97
  reason: String(f.reason ?? ""),
98
+ ...(typeof f.repo === "string" && f.repo ? { repo: f.repo } : {}),
99
+ ...(typeof f.repoPath === "string" && f.repoPath ? { repoPath: f.repoPath } : {}),
94
100
  }));
95
101
  }
96
102
 
@@ -186,6 +192,10 @@ async function loaded(): Promise<Record<string, unknown>> {
186
192
  tags: m.tags,
187
193
  superseded_by: m.superseded_by,
188
194
  reason: m.reason,
195
+ // The viewer is the explicit ADMIN read surface (header comment): it
196
+ // lists every repository, and now says WHICH one each row belongs to.
197
+ repo: m.repo,
198
+ repoPath: m.repoPath,
189
199
  blocked: blockedByTs.has(m.ts),
190
200
  })),
191
201
  blocked,
@@ -256,7 +266,17 @@ async function unblockRoute(body: z.infer<typeof UnblockBody>): Promise<Response
256
266
  }
257
267
 
258
268
  async function restoreEntryRoute(body: z.infer<typeof RestoreEntryBody>): Promise<Response> {
259
- const t = await appendMemory({ type: body.type, scope: body.scope, content: body.content });
269
+ // Origin survives the restore round trip (#129): when the audit line carried
270
+ // a repo stamp, the restored row carries it again — the viewer's own missing
271
+ // repository scope must never be what decides a row's visibility. No repo
272
+ // fields = the documented legacy/global restore path, unchanged.
273
+ const t = await appendMemory({
274
+ type: body.type,
275
+ scope: body.scope,
276
+ content: body.content,
277
+ repo: body.repo,
278
+ repoPath: body.repoPath,
279
+ });
260
280
  return json({ restored: t });
261
281
  }
262
282