Skip to content

Commit 72157f4

Browse files
committed
feat(config): add user email and name override options
Add configuration options to override Git user identity for memory tagging. This allows users to specify custom email and name values in the config file, which take precedence over Git's user configuration. Updated the configuration interface, defaults, and template to include these new options. Modified the tag service to use the override values when available, falling back to Git configuration or environment variables.
1 parent 84b7e53 commit 72157f4

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Configure at `~/.config/opencode/opencode-mem.jsonc`:
5252
```jsonc
5353
{
5454
"storagePath": "~/.opencode-mem/data",
55+
"userEmailOverride": "user@example.com",
56+
"userNameOverride": "John Doe",
5557
"embeddingModel": "Xenova/nomic-embed-text-v1",
5658
"webServerEnabled": true,
5759
"webServerPort": 4747,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-mem",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "OpenCode plugin that gives coding agents persistent memory using local vector database",
55
"type": "module",
66
"main": "dist/plugin.js",

src/config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if (!existsSync(DATA_DIR)) {
2222
interface OpenCodeMemConfig {
2323
storagePath?: string;
2424
customSqlitePath?: string;
25+
userEmailOverride?: string;
26+
userNameOverride?: string;
2527
embeddingModel?: string;
2628
embeddingDimensions?: number;
2729
embeddingApiUrl?: string;
@@ -70,6 +72,8 @@ const DEFAULTS: Required<
7072
| "memoryProvider"
7173
| "customSqlitePath"
7274
| "autoCaptureLanguage"
75+
| "userEmailOverride"
76+
| "userNameOverride"
7377
>
7478
> & {
7579
embeddingApiUrl?: string;
@@ -80,6 +84,8 @@ const DEFAULTS: Required<
8084
memoryProvider?: "openai-chat" | "openai-responses" | "anthropic";
8185
customSqlitePath?: string;
8286
autoCaptureLanguage?: string;
87+
userEmailOverride?: string;
88+
userNameOverride?: string;
8389
} = {
8490
storagePath: join(DATA_DIR, "data"),
8591
embeddingModel: "Xenova/nomic-embed-text-v1",
@@ -144,6 +150,9 @@ const CONFIG_TEMPLATE = `{
144150
145151
// Storage location for vector database
146152
"storagePath": "~/.opencode-mem/data",
153+
154+
"userEmailOverride": "",
155+
"userNameOverride": "",
147156
148157
// ============================================
149158
// macOS SQLite Extension Loading (REQUIRED FOR macOS)
@@ -378,6 +387,8 @@ export const CONFIG = {
378387
customSqlitePath: fileConfig.customSqlitePath
379388
? expandPath(fileConfig.customSqlitePath)
380389
: undefined,
390+
userEmailOverride: fileConfig.userEmailOverride,
391+
userNameOverride: fileConfig.userNameOverride,
381392
embeddingModel: fileConfig.embeddingModel ?? DEFAULTS.embeddingModel,
382393
embeddingDimensions:
383394
fileConfig.embeddingDimensions ??

src/services/tags.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export function getProjectName(directory: string): string {
5555
}
5656

5757
export function getUserTagInfo(): TagInfo {
58-
const email = getGitEmail();
59-
const name = getGitName();
58+
const email = CONFIG.userEmailOverride || getGitEmail();
59+
const name = CONFIG.userNameOverride || getGitName();
6060

6161
if (email) {
6262
return {
@@ -67,7 +67,7 @@ export function getUserTagInfo(): TagInfo {
6767
};
6868
}
6969

70-
const fallback = process.env.USER || process.env.USERNAME || "anonymous";
70+
const fallback = name || process.env.USER || process.env.USERNAME || "anonymous";
7171
return {
7272
tag: `${CONFIG.containerTagPrefix}_user_${sha256(fallback)}`,
7373
displayName: fallback,

0 commit comments

Comments
 (0)