opencode-graphiti 0.1.2 → 0.1.3

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MA4CtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAkDtB,CAAC"}
package/esm/src/index.js CHANGED
@@ -19,7 +19,7 @@ export const graphiti = async (input) => {
19
19
  logger.warn("Memory features will be unavailable until connection is established");
20
20
  }
21
21
  const defaultGroupId = makeGroupId(config.groupIdPrefix, input.directory);
22
- const defaultUserGroupId = makeUserGroupId(config.groupIdPrefix);
22
+ const defaultUserGroupId = makeUserGroupId(config.groupIdPrefix, input.directory);
23
23
  logger.info("Plugin initialized. Group ID:", defaultGroupId);
24
24
  const sessionManager = new SessionManager(defaultGroupId, defaultUserGroupId, sdkClient, client);
25
25
  return {
@@ -2,11 +2,11 @@ import type { Part } from "@opencode-ai/sdk";
2
2
  /**
3
3
  * Build a sanitized Graphiti group ID from a prefix and project directory.
4
4
  */
5
- export declare const makeGroupId: (prefix: string, directory?: string) => string;
5
+ export declare const makeGroupId: (prefix?: string, directory?: string) => string;
6
6
  /**
7
7
  * Build a sanitized Graphiti group ID from a prefix and user home directory.
8
8
  */
9
- export declare const makeUserGroupId: (prefix: string) => string;
9
+ export declare const makeUserGroupId: (prefix?: string, directory?: string) => string;
10
10
  /**
11
11
  * Narrow an OpenCode Part to a non-synthetic text part.
12
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,YAAY,MAAM,KAAG,MAKhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAMhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAAI,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAMd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,EAAE,KAAG,MACe,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,kBAAyB,KACxB,MAIF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,kBAAyB,KACxB,MAKF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAAI,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAMd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,EAAE,KAAG,MACe,CAAC"}
package/esm/src/utils.js CHANGED
@@ -1,21 +1,22 @@
1
1
  import os from "node:os";
2
+ import process from "node:process";
3
+ const getProjectName = (directory) => directory.split("/").filter(Boolean).at(-1)?.trim() || "default";
4
+ const getUserName = (home = os.homedir().split("/").filter(Boolean).at(-1)) => home?.trim() || undefined;
2
5
  /**
3
6
  * Build a sanitized Graphiti group ID from a prefix and project directory.
4
7
  */
5
- export const makeGroupId = (prefix, directory) => {
6
- const parts = directory?.split("/").filter(Boolean) ?? [];
7
- const projectName = parts[parts.length - 1] || "default";
8
- const rawGroupId = `${prefix}_${projectName}`;
8
+ export const makeGroupId = (prefix, directory = process.cwd()) => {
9
+ const projectName = getProjectName(directory);
10
+ const rawGroupId = `${prefix?.concat("-")}${projectName}__main`;
9
11
  return rawGroupId.replace(/[^A-Za-z0-9_-]/g, "_");
10
12
  };
11
13
  /**
12
14
  * Build a sanitized Graphiti group ID from a prefix and user home directory.
13
15
  */
14
- export const makeUserGroupId = (prefix) => {
15
- const homeDir = os.homedir() || "user";
16
- const parts = homeDir.split("/").filter(Boolean);
17
- const userName = parts[parts.length - 1] || "user";
18
- const rawGroupId = `${prefix}_user_${userName}`;
16
+ export const makeUserGroupId = (prefix, directory = process.cwd()) => {
17
+ const projectName = getProjectName(directory);
18
+ const userName = getUserName();
19
+ const rawGroupId = `${prefix?.concat("-")}${projectName}__user-${userName}`;
19
20
  return rawGroupId.replace(/[^A-Za-z0-9_-]/g, "_");
20
21
  };
21
22
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-graphiti",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "OpenCode plugin for persistent memory via Graphiti knowledge graph",
5
5
  "license": "MIT",
6
6
  "main": "./esm/mod.js",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MA4CtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAkDtB,CAAC"}
@@ -22,7 +22,7 @@ const graphiti = async (input) => {
22
22
  logger_js_1.logger.warn("Memory features will be unavailable until connection is established");
23
23
  }
24
24
  const defaultGroupId = (0, utils_js_1.makeGroupId)(config.groupIdPrefix, input.directory);
25
- const defaultUserGroupId = (0, utils_js_1.makeUserGroupId)(config.groupIdPrefix);
25
+ const defaultUserGroupId = (0, utils_js_1.makeUserGroupId)(config.groupIdPrefix, input.directory);
26
26
  logger_js_1.logger.info("Plugin initialized. Group ID:", defaultGroupId);
27
27
  const sessionManager = new session_js_1.SessionManager(defaultGroupId, defaultUserGroupId, sdkClient, client);
28
28
  return {
@@ -2,11 +2,11 @@ import type { Part } from "@opencode-ai/sdk";
2
2
  /**
3
3
  * Build a sanitized Graphiti group ID from a prefix and project directory.
4
4
  */
5
- export declare const makeGroupId: (prefix: string, directory?: string) => string;
5
+ export declare const makeGroupId: (prefix?: string, directory?: string) => string;
6
6
  /**
7
7
  * Build a sanitized Graphiti group ID from a prefix and user home directory.
8
8
  */
9
- export declare const makeUserGroupId: (prefix: string) => string;
9
+ export declare const makeUserGroupId: (prefix?: string, directory?: string) => string;
10
10
  /**
11
11
  * Narrow an OpenCode Part to a non-synthetic text part.
12
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,YAAY,MAAM,KAAG,MAKhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAMhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAAI,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAMd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,EAAE,KAAG,MACe,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,kBAAyB,KACxB,MAIF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,kBAAyB,KACxB,MAKF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAAI,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAMd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,EAAE,KAAG,MACe,CAAC"}
@@ -5,24 +5,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.extractTextFromParts = exports.isTextPart = exports.makeUserGroupId = exports.makeGroupId = void 0;
7
7
  const node_os_1 = __importDefault(require("node:os"));
8
+ const node_process_1 = __importDefault(require("node:process"));
9
+ const getProjectName = (directory) => directory.split("/").filter(Boolean).at(-1)?.trim() || "default";
10
+ const getUserName = (home = node_os_1.default.homedir().split("/").filter(Boolean).at(-1)) => home?.trim() || undefined;
8
11
  /**
9
12
  * Build a sanitized Graphiti group ID from a prefix and project directory.
10
13
  */
11
- const makeGroupId = (prefix, directory) => {
12
- const parts = directory?.split("/").filter(Boolean) ?? [];
13
- const projectName = parts[parts.length - 1] || "default";
14
- const rawGroupId = `${prefix}_${projectName}`;
14
+ const makeGroupId = (prefix, directory = node_process_1.default.cwd()) => {
15
+ const projectName = getProjectName(directory);
16
+ const rawGroupId = `${prefix?.concat("-")}${projectName}__main`;
15
17
  return rawGroupId.replace(/[^A-Za-z0-9_-]/g, "_");
16
18
  };
17
19
  exports.makeGroupId = makeGroupId;
18
20
  /**
19
21
  * Build a sanitized Graphiti group ID from a prefix and user home directory.
20
22
  */
21
- const makeUserGroupId = (prefix) => {
22
- const homeDir = node_os_1.default.homedir() || "user";
23
- const parts = homeDir.split("/").filter(Boolean);
24
- const userName = parts[parts.length - 1] || "user";
25
- const rawGroupId = `${prefix}_user_${userName}`;
23
+ const makeUserGroupId = (prefix, directory = node_process_1.default.cwd()) => {
24
+ const projectName = getProjectName(directory);
25
+ const userName = getUserName();
26
+ const rawGroupId = `${prefix?.concat("-")}${projectName}__user-${userName}`;
26
27
  return rawGroupId.replace(/[^A-Za-z0-9_-]/g, "_");
27
28
  };
28
29
  exports.makeUserGroupId = makeUserGroupId;