opencode-mem 2.8.8 → 2.8.9

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.
@@ -10,6 +10,10 @@ export interface TagInfo {
10
10
  export declare function getGitEmail(): string | null;
11
11
  export declare function getGitName(): string | null;
12
12
  export declare function getGitRepoUrl(directory: string): string | null;
13
+ export declare function getGitCommonDir(directory: string): string | null;
14
+ export declare function getGitTopLevel(directory: string): string | null;
15
+ export declare function getProjectRoot(directory: string): string;
16
+ export declare function getProjectIdentity(directory: string): string;
13
17
  export declare function getProjectName(directory: string): string;
14
18
  export declare function getUserTagInfo(): TagInfo;
15
19
  export declare function getProjectTagInfo(directory: string): TagInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/services/tags.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAO3C;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAO1C;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAU9D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAoBxC;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAW5D;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAKA"}
1
+ {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/services/tags.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAU3C;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAU1C;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW9D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBhE;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW/D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAYxD;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAoBxC;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAa5D;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAKA"}
@@ -1,13 +1,16 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { execSync } from "node:child_process";
3
3
  import { CONFIG } from "../config.js";
4
- import { sep, normalize } from "node:path";
4
+ import { sep, normalize, resolve, isAbsolute, basename, dirname } from "node:path";
5
5
  function sha256(input) {
6
6
  return createHash("sha256").update(input).digest("hex").slice(0, 16);
7
7
  }
8
8
  export function getGitEmail() {
9
9
  try {
10
- const email = execSync("git config user.email", { encoding: "utf-8" }).trim();
10
+ const email = execSync("git config user.email", {
11
+ encoding: "utf-8",
12
+ stdio: ["ignore", "pipe", "ignore"],
13
+ }).trim();
11
14
  return email || null;
12
15
  }
13
16
  catch {
@@ -16,7 +19,10 @@ export function getGitEmail() {
16
19
  }
17
20
  export function getGitName() {
18
21
  try {
19
- const name = execSync("git config user.name", { encoding: "utf-8" }).trim();
22
+ const name = execSync("git config user.name", {
23
+ encoding: "utf-8",
24
+ stdio: ["ignore", "pipe", "ignore"],
25
+ }).trim();
20
26
  return name || null;
21
27
  }
22
28
  catch {
@@ -28,6 +34,7 @@ export function getGitRepoUrl(directory) {
28
34
  const url = execSync("git config --get remote.origin.url", {
29
35
  encoding: "utf-8",
30
36
  cwd: directory,
37
+ stdio: ["ignore", "pipe", "ignore"],
31
38
  }).trim();
32
39
  return url || null;
33
40
  }
@@ -35,6 +42,57 @@ export function getGitRepoUrl(directory) {
35
42
  return null;
36
43
  }
37
44
  }
45
+ export function getGitCommonDir(directory) {
46
+ try {
47
+ const commonDir = execSync("git rev-parse --git-common-dir", {
48
+ encoding: "utf-8",
49
+ cwd: directory,
50
+ stdio: ["ignore", "pipe", "ignore"],
51
+ }).trim();
52
+ if (!commonDir) {
53
+ return null;
54
+ }
55
+ return isAbsolute(commonDir) ? normalize(commonDir) : normalize(resolve(directory, commonDir));
56
+ }
57
+ catch {
58
+ return null;
59
+ }
60
+ }
61
+ export function getGitTopLevel(directory) {
62
+ try {
63
+ const topLevel = execSync("git rev-parse --show-toplevel", {
64
+ encoding: "utf-8",
65
+ cwd: directory,
66
+ stdio: ["ignore", "pipe", "ignore"],
67
+ }).trim();
68
+ return topLevel || null;
69
+ }
70
+ catch {
71
+ return null;
72
+ }
73
+ }
74
+ export function getProjectRoot(directory) {
75
+ const commonDir = getGitCommonDir(directory);
76
+ if (commonDir && basename(commonDir) === ".git") {
77
+ return dirname(commonDir);
78
+ }
79
+ const topLevel = getGitTopLevel(directory);
80
+ if (topLevel) {
81
+ return topLevel;
82
+ }
83
+ return directory;
84
+ }
85
+ export function getProjectIdentity(directory) {
86
+ const commonDir = getGitCommonDir(directory);
87
+ if (commonDir) {
88
+ return `git-common:${commonDir}`;
89
+ }
90
+ const gitRepoUrl = getGitRepoUrl(directory);
91
+ if (gitRepoUrl) {
92
+ return `remote:${gitRepoUrl}`;
93
+ }
94
+ return `path:${normalize(directory)}`;
95
+ }
38
96
  export function getProjectName(directory) {
39
97
  // Normalize path to handle both Unix and Windows separators
40
98
  const normalized = normalize(directory);
@@ -61,12 +119,14 @@ export function getUserTagInfo() {
61
119
  };
62
120
  }
63
121
  export function getProjectTagInfo(directory) {
64
- const projectName = getProjectName(directory);
122
+ const projectRoot = getProjectRoot(directory);
123
+ const projectName = getProjectName(projectRoot);
65
124
  const gitRepoUrl = getGitRepoUrl(directory);
125
+ const projectIdentity = getProjectIdentity(projectRoot);
66
126
  return {
67
- tag: `${CONFIG.containerTagPrefix}_project_${sha256(directory)}`,
68
- displayName: directory,
69
- projectPath: directory,
127
+ tag: `${CONFIG.containerTagPrefix}_project_${sha256(projectIdentity)}`,
128
+ displayName: projectRoot,
129
+ projectPath: projectRoot,
70
130
  projectName,
71
131
  gitRepoUrl: gitRepoUrl || undefined,
72
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mem",
3
- "version": "2.8.8",
3
+ "version": "2.8.9",
4
4
  "description": "OpenCode plugin that gives coding agents persistent memory using local vector database",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",