opencode-self-improvement 0.15.12 → 0.15.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.
@@ -1,5 +1,6 @@
1
- // visibility — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
2
- import { repoScopeFor, sessionScope, type RepoScope } from "../../identity/repokey.ts";
1
+ // Repository visibility, shared by memory rows, restore lines, and evidence.
2
+ import { createHash } from "node:crypto";
3
+ import { normalizeDirPath, repoScopeFor, sessionScope, type RepoScope } from "../../identity/repokey.ts";
3
4
  import { getCurrent } from "../../core/state.ts";
4
5
  import { parseLine } from "../../core/logfmt/format.ts";
5
6
  import { prune } from "../files/prune.ts";
@@ -60,6 +61,25 @@ export function readerFromSid(sid?: unknown): Reader {
60
61
  : readerForAmbient();
61
62
  }
62
63
 
64
+ // Before #109, path-derived keys on win32/darwin hashed the whole canonical
65
+ // path in lowercase, even on case-sensitive volumes. Such a key can equal a
66
+ // distinct lowercase sibling's current key (#254). The stored path identifies
67
+ // these legacy stamps without a migration: require the same directory, allowing
68
+ // real symlink/case-insensitive aliases, instead of trusting that key alone.
69
+ // Remote-derived keys still share across clones with different paths. A stamp
70
+ // without repoPath cannot be classified this way and keeps key-only matching.
71
+ function matchesRepository(repo: string, repoPath: string | undefined, scope: RepoScope): boolean {
72
+ if (repoPath === scope.path) return true; // pre-hash and legacy owner access
73
+ if (repoPath) {
74
+ // The historical hash used realpath too: repoPath itself may name a
75
+ // symlink/junction, a short Windows spelling, or contain dot segments.
76
+ const canonical = normalizeDirPath(repoPath);
77
+ const legacyKey = createHash("sha1").update(canonical.toLowerCase()).digest("hex").slice(0, 12);
78
+ if (repo === legacyKey) return canonical === normalizeDirPath(scope.path);
79
+ }
80
+ return repo === scope.key;
81
+ }
82
+
63
83
  // The ONLY repo filter every read path uses (injection sinks, recall, list,
64
84
  // update targeting, prune, decay, gate scope reads). A row is visible when it
65
85
  // is global (explicit marker OR no stamp — legacy rows and writes by
@@ -70,7 +90,7 @@ export function isVisibleTo(m: Pick<Memory, "repo" | "repoPath">, reader: Reader
70
90
  if (reader.kind === "admin") return true;
71
91
  if (!m.repo || m.repo === "global") return true;
72
92
  if (reader.kind === "global-only") return false;
73
- return m.repo === reader.scope.key || (!!m.repoPath && m.repoPath === reader.scope.path);
93
+ return matchesRepository(m.repo, m.repoPath, reader.scope);
74
94
  }
75
95
 
76
96
  export function visibleTo(mems: Memory[], reader: Reader): Memory[] {
@@ -116,10 +136,7 @@ export function evidenceVisibleTo(
116
136
  if (repo === "global") return true;
117
137
  if (reader.kind === "global-only") return false;
118
138
  const repoPath = fields.repoPath;
119
- return (
120
- repo === reader.scope.key ||
121
- (typeof repoPath === "string" && !!repoPath && repoPath === reader.scope.path)
122
- );
139
+ return matchesRepository(repo, typeof repoPath === "string" ? repoPath : undefined, reader.scope);
123
140
  }
124
141
  const sid = fields.sid;
125
142
  if (typeof sid === "string" && sid !== "" && sid !== "?") {