@memrosetta/cli 0.3.0 → 0.3.2
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.
- package/dist/chunk-326TFH4F.js +605 -0
- package/dist/chunk-CATBN3ZT.js +596 -0
- package/dist/chunk-IS4IKWPL.js +749 -0
- package/dist/index.js +6 -3
- package/dist/init-C335O4TX.js +182 -0
- package/dist/init-YAGOXYWG.js +182 -0
- package/dist/init-Z53FKT6J.js +205 -0
- package/dist/reset-GPV46GSD.js +112 -0
- package/dist/reset-LWRG2LIM.js +129 -0
- package/dist/reset-P63V46RN.js +112 -0
- package/dist/status-PYD6U7U7.js +211 -0
- package/dist/status-TLK2LKG6.js +218 -0
- package/dist/status-XNQRRFWF.js +211 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,11 +38,13 @@ Init Options:
|
|
|
38
38
|
--claude-code Additionally: Claude Code hooks + CLAUDE.md
|
|
39
39
|
--cursor Additionally: Cursor MCP config (~/.cursor/mcp.json)
|
|
40
40
|
--codex Additionally: Codex MCP config (~/.codex/config.toml) + AGENTS.md
|
|
41
|
+
--gemini Additionally: Gemini MCP config (~/.gemini/settings.json) + GEMINI.md
|
|
41
42
|
|
|
42
43
|
Reset Options:
|
|
43
44
|
--claude-code Remove Claude Code hooks + CLAUDE.md section
|
|
44
45
|
--cursor Remove Cursor MCP config
|
|
45
46
|
--codex Remove Codex MCP config + AGENTS.md section
|
|
47
|
+
--gemini Remove Gemini MCP config + GEMINI.md section
|
|
46
48
|
--all Remove all integrations
|
|
47
49
|
|
|
48
50
|
Global Options:
|
|
@@ -57,6 +59,7 @@ Examples:
|
|
|
57
59
|
memrosetta init --claude-code # DB + MCP + Claude Code hooks
|
|
58
60
|
memrosetta init --cursor # DB + MCP + Cursor config
|
|
59
61
|
memrosetta init --codex # DB + MCP + Codex config
|
|
62
|
+
memrosetta init --gemini # DB + MCP + Gemini config
|
|
60
63
|
memrosetta status --format text # Show all status
|
|
61
64
|
memrosetta reset --claude-code # Remove Claude Code integration
|
|
62
65
|
memrosetta reset --all # Remove all integrations
|
|
@@ -150,17 +153,17 @@ async function main() {
|
|
|
150
153
|
break;
|
|
151
154
|
}
|
|
152
155
|
case "status": {
|
|
153
|
-
const mod = await import("./status-
|
|
156
|
+
const mod = await import("./status-TLK2LKG6.js");
|
|
154
157
|
await mod.run(commandOptions);
|
|
155
158
|
break;
|
|
156
159
|
}
|
|
157
160
|
case "init": {
|
|
158
|
-
const mod = await import("./init-
|
|
161
|
+
const mod = await import("./init-Z53FKT6J.js");
|
|
159
162
|
await mod.run(commandOptions);
|
|
160
163
|
break;
|
|
161
164
|
}
|
|
162
165
|
case "reset": {
|
|
163
|
-
const mod = await import("./reset-
|
|
166
|
+
const mod = await import("./reset-LWRG2LIM.js");
|
|
164
167
|
await mod.run(commandOptions);
|
|
165
168
|
break;
|
|
166
169
|
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAgentsMdPath,
|
|
3
|
+
getCodexConfigFilePath,
|
|
4
|
+
getCursorMcpConfigPath,
|
|
5
|
+
getCursorRulesPath,
|
|
6
|
+
getGenericMCPPath,
|
|
7
|
+
isClaudeCodeInstalled,
|
|
8
|
+
registerClaudeCodeHooks,
|
|
9
|
+
registerCodexMCP,
|
|
10
|
+
registerCursorMCP,
|
|
11
|
+
registerGenericMCP,
|
|
12
|
+
updateClaudeMd
|
|
13
|
+
} from "./chunk-CATBN3ZT.js";
|
|
14
|
+
import {
|
|
15
|
+
hasFlag,
|
|
16
|
+
optionalOption
|
|
17
|
+
} from "./chunk-VZQURGWB.js";
|
|
18
|
+
import {
|
|
19
|
+
getDefaultDbPath,
|
|
20
|
+
getEngine
|
|
21
|
+
} from "./chunk-POK32V2J.js";
|
|
22
|
+
import {
|
|
23
|
+
output
|
|
24
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
25
|
+
import {
|
|
26
|
+
getConfig,
|
|
27
|
+
writeConfig
|
|
28
|
+
} from "./chunk-TU5EHSDE.js";
|
|
29
|
+
|
|
30
|
+
// src/commands/init.ts
|
|
31
|
+
import { existsSync } from "fs";
|
|
32
|
+
var LANG_FLAG_TO_PRESET = {
|
|
33
|
+
en: "en",
|
|
34
|
+
multi: "multilingual",
|
|
35
|
+
ko: "ko"
|
|
36
|
+
};
|
|
37
|
+
async function run(options) {
|
|
38
|
+
const { args, format, db, noEmbeddings } = options;
|
|
39
|
+
const wantClaudeCode = hasFlag(args, "--claude-code");
|
|
40
|
+
const wantCursor = hasFlag(args, "--cursor");
|
|
41
|
+
const wantCodex = hasFlag(args, "--codex");
|
|
42
|
+
const langFlag = optionalOption(args, "--lang");
|
|
43
|
+
const embeddingPreset = langFlag ? LANG_FLAG_TO_PRESET[langFlag] : void 0;
|
|
44
|
+
if (langFlag && !LANG_FLAG_TO_PRESET[langFlag]) {
|
|
45
|
+
process.stderr.write(
|
|
46
|
+
`Unknown --lang value: "${langFlag}". Supported: en, multi, ko
|
|
47
|
+
`
|
|
48
|
+
);
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
const config2 = getConfig();
|
|
54
|
+
const updates = {};
|
|
55
|
+
if (db) {
|
|
56
|
+
updates.dbPath = db;
|
|
57
|
+
}
|
|
58
|
+
if (noEmbeddings) {
|
|
59
|
+
updates.enableEmbeddings = false;
|
|
60
|
+
}
|
|
61
|
+
if (embeddingPreset) {
|
|
62
|
+
updates.embeddingPreset = embeddingPreset;
|
|
63
|
+
}
|
|
64
|
+
if (Object.keys(updates).length > 0) {
|
|
65
|
+
writeConfig({ ...config2, ...updates });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const config = getConfig();
|
|
69
|
+
const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
|
|
70
|
+
const existed = existsSync(dbPath);
|
|
71
|
+
const engine = await getEngine({ db: dbPath, noEmbeddings });
|
|
72
|
+
await engine.close();
|
|
73
|
+
const result = {
|
|
74
|
+
database: {
|
|
75
|
+
path: dbPath,
|
|
76
|
+
created: !existed
|
|
77
|
+
},
|
|
78
|
+
integrations: {}
|
|
79
|
+
};
|
|
80
|
+
registerGenericMCP();
|
|
81
|
+
result.integrations.mcp = {
|
|
82
|
+
registered: true,
|
|
83
|
+
path: getGenericMCPPath()
|
|
84
|
+
};
|
|
85
|
+
if (wantClaudeCode) {
|
|
86
|
+
const hooksOk = registerClaudeCodeHooks();
|
|
87
|
+
const claudeMdOk = updateClaudeMd();
|
|
88
|
+
result.integrations.claudeCode = {
|
|
89
|
+
hooks: hooksOk,
|
|
90
|
+
mcp: true,
|
|
91
|
+
claudeMd: claudeMdOk
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (wantCursor) {
|
|
95
|
+
const cursorRulesUpdated = registerCursorMCP();
|
|
96
|
+
result.integrations.cursor = {
|
|
97
|
+
mcp: true,
|
|
98
|
+
path: getCursorMcpConfigPath(),
|
|
99
|
+
cursorRules: cursorRulesUpdated,
|
|
100
|
+
cursorRulesPath: getCursorRulesPath()
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (wantCodex) {
|
|
104
|
+
const agentsMdUpdated = registerCodexMCP();
|
|
105
|
+
result.integrations.codex = {
|
|
106
|
+
mcp: true,
|
|
107
|
+
path: getCodexConfigFilePath(),
|
|
108
|
+
agentsMd: agentsMdUpdated,
|
|
109
|
+
agentsMdPath: getAgentsMdPath()
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (format === "text") {
|
|
113
|
+
printTextOutput(result, wantClaudeCode, wantCursor, wantCodex);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
output(result, format);
|
|
117
|
+
}
|
|
118
|
+
function printTextOutput(result, claudeCode, cursor, codex = false) {
|
|
119
|
+
const w = (s) => process.stdout.write(s);
|
|
120
|
+
w("\nMemRosetta initialized successfully.\n\n");
|
|
121
|
+
w(" What was set up:\n");
|
|
122
|
+
w(" ----------------------------------------\n");
|
|
123
|
+
w(` Database: ${result.database.path}`);
|
|
124
|
+
w(result.database.created ? " (created)\n" : " (already exists)\n");
|
|
125
|
+
w(` MCP Server: ${result.integrations.mcp.path} (always included)
|
|
126
|
+
`);
|
|
127
|
+
const currentConfig = getConfig();
|
|
128
|
+
if (currentConfig.embeddingPreset && currentConfig.embeddingPreset !== "en") {
|
|
129
|
+
const presetLabels = {
|
|
130
|
+
multilingual: "multilingual (multilingual-e5-small)",
|
|
131
|
+
ko: "Korean (ko-sroberta-multitask)"
|
|
132
|
+
};
|
|
133
|
+
w(` Embeddings: ${presetLabels[currentConfig.embeddingPreset] ?? currentConfig.embeddingPreset}
|
|
134
|
+
`);
|
|
135
|
+
}
|
|
136
|
+
if (claudeCode) {
|
|
137
|
+
const cc = result.integrations.claudeCode;
|
|
138
|
+
if (cc.hooks) {
|
|
139
|
+
w(" Stop Hook: ~/.claude/settings.json (auto-save on session end)\n");
|
|
140
|
+
} else if (!isClaudeCodeInstalled()) {
|
|
141
|
+
w(" Stop Hook: SKIPPED (Claude Code not found at ~/.claude)\n");
|
|
142
|
+
w(' Install Claude Code first, then run "memrosetta init --claude-code" again.\n');
|
|
143
|
+
}
|
|
144
|
+
if (cc.claudeMd) {
|
|
145
|
+
w(" CLAUDE.md: ~/.claude/CLAUDE.md (memory instructions added)\n");
|
|
146
|
+
} else {
|
|
147
|
+
w(" CLAUDE.md: already configured\n");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (cursor) {
|
|
151
|
+
w(` Cursor MCP: ${result.integrations.cursor.path}
|
|
152
|
+
`);
|
|
153
|
+
if (result.integrations.cursor.cursorRules) {
|
|
154
|
+
w(` .cursorrules: ${result.integrations.cursor.cursorRulesPath} (memory instructions added)
|
|
155
|
+
`);
|
|
156
|
+
} else {
|
|
157
|
+
w(" .cursorrules: already configured\n");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (codex) {
|
|
161
|
+
w(` Codex MCP: ${result.integrations.codex.path}
|
|
162
|
+
`);
|
|
163
|
+
if (result.integrations.codex.agentsMd) {
|
|
164
|
+
w(` AGENTS.md: ${result.integrations.codex.agentsMdPath} (memory instructions added)
|
|
165
|
+
`);
|
|
166
|
+
} else {
|
|
167
|
+
w(" AGENTS.md: already configured\n");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
w("\n");
|
|
171
|
+
if (!claudeCode && !cursor && !codex) {
|
|
172
|
+
w(" MCP is ready. Add --claude-code, --cursor, or --codex for tool-specific setup.\n");
|
|
173
|
+
w(" Example: memrosetta init --claude-code\n");
|
|
174
|
+
w("\n");
|
|
175
|
+
}
|
|
176
|
+
if (claudeCode) {
|
|
177
|
+
w(" Restart Claude Code to activate.\n\n");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
run
|
|
182
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAgentsMdPath,
|
|
3
|
+
getCodexConfigFilePath,
|
|
4
|
+
getCursorMcpConfigPath,
|
|
5
|
+
getCursorRulesPath,
|
|
6
|
+
getGenericMCPPath,
|
|
7
|
+
isClaudeCodeInstalled,
|
|
8
|
+
registerClaudeCodeHooks,
|
|
9
|
+
registerCodexMCP,
|
|
10
|
+
registerCursorMCP,
|
|
11
|
+
registerGenericMCP,
|
|
12
|
+
updateClaudeMd
|
|
13
|
+
} from "./chunk-326TFH4F.js";
|
|
14
|
+
import {
|
|
15
|
+
hasFlag,
|
|
16
|
+
optionalOption
|
|
17
|
+
} from "./chunk-VZQURGWB.js";
|
|
18
|
+
import {
|
|
19
|
+
getDefaultDbPath,
|
|
20
|
+
getEngine
|
|
21
|
+
} from "./chunk-POK32V2J.js";
|
|
22
|
+
import {
|
|
23
|
+
output
|
|
24
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
25
|
+
import {
|
|
26
|
+
getConfig,
|
|
27
|
+
writeConfig
|
|
28
|
+
} from "./chunk-TU5EHSDE.js";
|
|
29
|
+
|
|
30
|
+
// src/commands/init.ts
|
|
31
|
+
import { existsSync } from "fs";
|
|
32
|
+
var LANG_FLAG_TO_PRESET = {
|
|
33
|
+
en: "en",
|
|
34
|
+
multi: "multilingual",
|
|
35
|
+
ko: "ko"
|
|
36
|
+
};
|
|
37
|
+
async function run(options) {
|
|
38
|
+
const { args, format, db, noEmbeddings } = options;
|
|
39
|
+
const wantClaudeCode = hasFlag(args, "--claude-code");
|
|
40
|
+
const wantCursor = hasFlag(args, "--cursor");
|
|
41
|
+
const wantCodex = hasFlag(args, "--codex");
|
|
42
|
+
const langFlag = optionalOption(args, "--lang");
|
|
43
|
+
const embeddingPreset = langFlag ? LANG_FLAG_TO_PRESET[langFlag] : void 0;
|
|
44
|
+
if (langFlag && !LANG_FLAG_TO_PRESET[langFlag]) {
|
|
45
|
+
process.stderr.write(
|
|
46
|
+
`Unknown --lang value: "${langFlag}". Supported: en, multi, ko
|
|
47
|
+
`
|
|
48
|
+
);
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
const config2 = getConfig();
|
|
54
|
+
const updates = {};
|
|
55
|
+
if (db) {
|
|
56
|
+
updates.dbPath = db;
|
|
57
|
+
}
|
|
58
|
+
if (noEmbeddings) {
|
|
59
|
+
updates.enableEmbeddings = false;
|
|
60
|
+
}
|
|
61
|
+
if (embeddingPreset) {
|
|
62
|
+
updates.embeddingPreset = embeddingPreset;
|
|
63
|
+
}
|
|
64
|
+
if (Object.keys(updates).length > 0) {
|
|
65
|
+
writeConfig({ ...config2, ...updates });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const config = getConfig();
|
|
69
|
+
const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
|
|
70
|
+
const existed = existsSync(dbPath);
|
|
71
|
+
const engine = await getEngine({ db: dbPath, noEmbeddings });
|
|
72
|
+
await engine.close();
|
|
73
|
+
const result = {
|
|
74
|
+
database: {
|
|
75
|
+
path: dbPath,
|
|
76
|
+
created: !existed
|
|
77
|
+
},
|
|
78
|
+
integrations: {}
|
|
79
|
+
};
|
|
80
|
+
registerGenericMCP();
|
|
81
|
+
result.integrations.mcp = {
|
|
82
|
+
registered: true,
|
|
83
|
+
path: getGenericMCPPath()
|
|
84
|
+
};
|
|
85
|
+
if (wantClaudeCode) {
|
|
86
|
+
const hooksOk = registerClaudeCodeHooks();
|
|
87
|
+
const claudeMdOk = updateClaudeMd();
|
|
88
|
+
result.integrations.claudeCode = {
|
|
89
|
+
hooks: hooksOk,
|
|
90
|
+
mcp: true,
|
|
91
|
+
claudeMd: claudeMdOk
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (wantCursor) {
|
|
95
|
+
const cursorRulesUpdated = registerCursorMCP();
|
|
96
|
+
result.integrations.cursor = {
|
|
97
|
+
mcp: true,
|
|
98
|
+
path: getCursorMcpConfigPath(),
|
|
99
|
+
cursorRules: cursorRulesUpdated,
|
|
100
|
+
cursorRulesPath: getCursorRulesPath()
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (wantCodex) {
|
|
104
|
+
const agentsMdUpdated = registerCodexMCP();
|
|
105
|
+
result.integrations.codex = {
|
|
106
|
+
mcp: true,
|
|
107
|
+
path: getCodexConfigFilePath(),
|
|
108
|
+
agentsMd: agentsMdUpdated,
|
|
109
|
+
agentsMdPath: getAgentsMdPath()
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (format === "text") {
|
|
113
|
+
printTextOutput(result, wantClaudeCode, wantCursor, wantCodex);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
output(result, format);
|
|
117
|
+
}
|
|
118
|
+
function printTextOutput(result, claudeCode, cursor, codex = false) {
|
|
119
|
+
const w = (s) => process.stdout.write(s);
|
|
120
|
+
w("\nMemRosetta initialized successfully.\n\n");
|
|
121
|
+
w(" What was set up:\n");
|
|
122
|
+
w(" ----------------------------------------\n");
|
|
123
|
+
w(` Database: ${result.database.path}`);
|
|
124
|
+
w(result.database.created ? " (created)\n" : " (already exists)\n");
|
|
125
|
+
w(` MCP Server: ${result.integrations.mcp.path} (always included)
|
|
126
|
+
`);
|
|
127
|
+
const currentConfig = getConfig();
|
|
128
|
+
if (currentConfig.embeddingPreset && currentConfig.embeddingPreset !== "en") {
|
|
129
|
+
const presetLabels = {
|
|
130
|
+
multilingual: "multilingual (multilingual-e5-small)",
|
|
131
|
+
ko: "Korean (ko-sroberta-multitask)"
|
|
132
|
+
};
|
|
133
|
+
w(` Embeddings: ${presetLabels[currentConfig.embeddingPreset] ?? currentConfig.embeddingPreset}
|
|
134
|
+
`);
|
|
135
|
+
}
|
|
136
|
+
if (claudeCode) {
|
|
137
|
+
const cc = result.integrations.claudeCode;
|
|
138
|
+
if (cc.hooks) {
|
|
139
|
+
w(" Stop Hook: ~/.claude/settings.json (auto-save on session end)\n");
|
|
140
|
+
} else if (!isClaudeCodeInstalled()) {
|
|
141
|
+
w(" Stop Hook: SKIPPED (Claude Code not found at ~/.claude)\n");
|
|
142
|
+
w(' Install Claude Code first, then run "memrosetta init --claude-code" again.\n');
|
|
143
|
+
}
|
|
144
|
+
if (cc.claudeMd) {
|
|
145
|
+
w(" CLAUDE.md: ~/.claude/CLAUDE.md (memory instructions added)\n");
|
|
146
|
+
} else {
|
|
147
|
+
w(" CLAUDE.md: already configured\n");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (cursor) {
|
|
151
|
+
w(` Cursor MCP: ${result.integrations.cursor.path}
|
|
152
|
+
`);
|
|
153
|
+
if (result.integrations.cursor.cursorRules) {
|
|
154
|
+
w(` .cursorrules: ${result.integrations.cursor.cursorRulesPath} (memory instructions added)
|
|
155
|
+
`);
|
|
156
|
+
} else {
|
|
157
|
+
w(" .cursorrules: already configured\n");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (codex) {
|
|
161
|
+
w(` Codex MCP: ${result.integrations.codex.path}
|
|
162
|
+
`);
|
|
163
|
+
if (result.integrations.codex.agentsMd) {
|
|
164
|
+
w(` AGENTS.md: ${result.integrations.codex.agentsMdPath} (memory instructions added)
|
|
165
|
+
`);
|
|
166
|
+
} else {
|
|
167
|
+
w(" AGENTS.md: already configured\n");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
w("\n");
|
|
171
|
+
if (!claudeCode && !cursor && !codex) {
|
|
172
|
+
w(" MCP is ready. Add --claude-code, --cursor, or --codex for tool-specific setup.\n");
|
|
173
|
+
w(" Example: memrosetta init --claude-code\n");
|
|
174
|
+
w("\n");
|
|
175
|
+
}
|
|
176
|
+
if (claudeCode) {
|
|
177
|
+
w(" Restart Claude Code to activate.\n\n");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
run
|
|
182
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAgentsMdPath,
|
|
3
|
+
getCodexConfigFilePath,
|
|
4
|
+
getCursorMcpConfigPath,
|
|
5
|
+
getCursorRulesPath,
|
|
6
|
+
getGeminiMdPath,
|
|
7
|
+
getGeminiSettingsFilePath,
|
|
8
|
+
getGenericMCPPath,
|
|
9
|
+
isClaudeCodeInstalled,
|
|
10
|
+
registerClaudeCodeHooks,
|
|
11
|
+
registerCodexMCP,
|
|
12
|
+
registerCursorMCP,
|
|
13
|
+
registerGeminiMCP,
|
|
14
|
+
registerGenericMCP,
|
|
15
|
+
updateClaudeMd
|
|
16
|
+
} from "./chunk-IS4IKWPL.js";
|
|
17
|
+
import {
|
|
18
|
+
hasFlag,
|
|
19
|
+
optionalOption
|
|
20
|
+
} from "./chunk-VZQURGWB.js";
|
|
21
|
+
import {
|
|
22
|
+
getDefaultDbPath,
|
|
23
|
+
getEngine
|
|
24
|
+
} from "./chunk-POK32V2J.js";
|
|
25
|
+
import {
|
|
26
|
+
output
|
|
27
|
+
} from "./chunk-ET6TNQOJ.js";
|
|
28
|
+
import {
|
|
29
|
+
getConfig,
|
|
30
|
+
writeConfig
|
|
31
|
+
} from "./chunk-TU5EHSDE.js";
|
|
32
|
+
|
|
33
|
+
// src/commands/init.ts
|
|
34
|
+
import { existsSync } from "fs";
|
|
35
|
+
var LANG_FLAG_TO_PRESET = {
|
|
36
|
+
en: "en",
|
|
37
|
+
multi: "multilingual",
|
|
38
|
+
ko: "ko"
|
|
39
|
+
};
|
|
40
|
+
async function run(options) {
|
|
41
|
+
const { args, format, db, noEmbeddings } = options;
|
|
42
|
+
const wantClaudeCode = hasFlag(args, "--claude-code");
|
|
43
|
+
const wantCursor = hasFlag(args, "--cursor");
|
|
44
|
+
const wantCodex = hasFlag(args, "--codex");
|
|
45
|
+
const wantGemini = hasFlag(args, "--gemini");
|
|
46
|
+
const langFlag = optionalOption(args, "--lang");
|
|
47
|
+
const embeddingPreset = langFlag ? LANG_FLAG_TO_PRESET[langFlag] : void 0;
|
|
48
|
+
if (langFlag && !LANG_FLAG_TO_PRESET[langFlag]) {
|
|
49
|
+
process.stderr.write(
|
|
50
|
+
`Unknown --lang value: "${langFlag}". Supported: en, multi, ko
|
|
51
|
+
`
|
|
52
|
+
);
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
{
|
|
57
|
+
const config2 = getConfig();
|
|
58
|
+
const updates = {};
|
|
59
|
+
if (db) {
|
|
60
|
+
updates.dbPath = db;
|
|
61
|
+
}
|
|
62
|
+
if (noEmbeddings) {
|
|
63
|
+
updates.enableEmbeddings = false;
|
|
64
|
+
}
|
|
65
|
+
if (embeddingPreset) {
|
|
66
|
+
updates.embeddingPreset = embeddingPreset;
|
|
67
|
+
}
|
|
68
|
+
if (Object.keys(updates).length > 0) {
|
|
69
|
+
writeConfig({ ...config2, ...updates });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const config = getConfig();
|
|
73
|
+
const dbPath = db ?? config.dbPath ?? getDefaultDbPath();
|
|
74
|
+
const existed = existsSync(dbPath);
|
|
75
|
+
const engine = await getEngine({ db: dbPath, noEmbeddings });
|
|
76
|
+
await engine.close();
|
|
77
|
+
const result = {
|
|
78
|
+
database: {
|
|
79
|
+
path: dbPath,
|
|
80
|
+
created: !existed
|
|
81
|
+
},
|
|
82
|
+
integrations: {}
|
|
83
|
+
};
|
|
84
|
+
registerGenericMCP();
|
|
85
|
+
result.integrations.mcp = {
|
|
86
|
+
registered: true,
|
|
87
|
+
path: getGenericMCPPath()
|
|
88
|
+
};
|
|
89
|
+
if (wantClaudeCode) {
|
|
90
|
+
const hooksOk = registerClaudeCodeHooks();
|
|
91
|
+
const claudeMdOk = updateClaudeMd();
|
|
92
|
+
result.integrations.claudeCode = {
|
|
93
|
+
hooks: hooksOk,
|
|
94
|
+
mcp: true,
|
|
95
|
+
claudeMd: claudeMdOk
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (wantCursor) {
|
|
99
|
+
const cursorRulesUpdated = registerCursorMCP();
|
|
100
|
+
result.integrations.cursor = {
|
|
101
|
+
mcp: true,
|
|
102
|
+
path: getCursorMcpConfigPath(),
|
|
103
|
+
cursorRules: cursorRulesUpdated,
|
|
104
|
+
cursorRulesPath: getCursorRulesPath()
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (wantCodex) {
|
|
108
|
+
const agentsMdUpdated = registerCodexMCP();
|
|
109
|
+
result.integrations.codex = {
|
|
110
|
+
mcp: true,
|
|
111
|
+
path: getCodexConfigFilePath(),
|
|
112
|
+
agentsMd: agentsMdUpdated,
|
|
113
|
+
agentsMdPath: getAgentsMdPath()
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (wantGemini) {
|
|
117
|
+
const geminiMdUpdated = registerGeminiMCP();
|
|
118
|
+
result.integrations.gemini = {
|
|
119
|
+
mcp: true,
|
|
120
|
+
path: getGeminiSettingsFilePath(),
|
|
121
|
+
geminiMd: geminiMdUpdated,
|
|
122
|
+
geminiMdPath: getGeminiMdPath()
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (format === "text") {
|
|
126
|
+
printTextOutput(result, wantClaudeCode, wantCursor, wantCodex, wantGemini);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
output(result, format);
|
|
130
|
+
}
|
|
131
|
+
function printTextOutput(result, claudeCode, cursor, codex = false, gemini = false) {
|
|
132
|
+
const w = (s) => process.stdout.write(s);
|
|
133
|
+
w("\nMemRosetta initialized successfully.\n\n");
|
|
134
|
+
w(" What was set up:\n");
|
|
135
|
+
w(" ----------------------------------------\n");
|
|
136
|
+
w(` Database: ${result.database.path}`);
|
|
137
|
+
w(result.database.created ? " (created)\n" : " (already exists)\n");
|
|
138
|
+
w(` MCP Server: ${result.integrations.mcp.path} (always included)
|
|
139
|
+
`);
|
|
140
|
+
const currentConfig = getConfig();
|
|
141
|
+
if (currentConfig.embeddingPreset && currentConfig.embeddingPreset !== "en") {
|
|
142
|
+
const presetLabels = {
|
|
143
|
+
multilingual: "multilingual (multilingual-e5-small)",
|
|
144
|
+
ko: "Korean (ko-sroberta-multitask)"
|
|
145
|
+
};
|
|
146
|
+
w(` Embeddings: ${presetLabels[currentConfig.embeddingPreset] ?? currentConfig.embeddingPreset}
|
|
147
|
+
`);
|
|
148
|
+
}
|
|
149
|
+
if (claudeCode) {
|
|
150
|
+
const cc = result.integrations.claudeCode;
|
|
151
|
+
if (cc.hooks) {
|
|
152
|
+
w(" Stop Hook: ~/.claude/settings.json (auto-save on session end)\n");
|
|
153
|
+
} else if (!isClaudeCodeInstalled()) {
|
|
154
|
+
w(" Stop Hook: SKIPPED (Claude Code not found at ~/.claude)\n");
|
|
155
|
+
w(' Install Claude Code first, then run "memrosetta init --claude-code" again.\n');
|
|
156
|
+
}
|
|
157
|
+
if (cc.claudeMd) {
|
|
158
|
+
w(" CLAUDE.md: ~/.claude/CLAUDE.md (memory instructions added)\n");
|
|
159
|
+
} else {
|
|
160
|
+
w(" CLAUDE.md: already configured\n");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (cursor) {
|
|
164
|
+
w(` Cursor MCP: ${result.integrations.cursor.path}
|
|
165
|
+
`);
|
|
166
|
+
if (result.integrations.cursor.cursorRules) {
|
|
167
|
+
w(` .cursorrules: ${result.integrations.cursor.cursorRulesPath} (memory instructions added)
|
|
168
|
+
`);
|
|
169
|
+
} else {
|
|
170
|
+
w(" .cursorrules: already configured\n");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (codex) {
|
|
174
|
+
w(` Codex MCP: ${result.integrations.codex.path}
|
|
175
|
+
`);
|
|
176
|
+
if (result.integrations.codex.agentsMd) {
|
|
177
|
+
w(` AGENTS.md: ${result.integrations.codex.agentsMdPath} (memory instructions added)
|
|
178
|
+
`);
|
|
179
|
+
} else {
|
|
180
|
+
w(" AGENTS.md: already configured\n");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (gemini) {
|
|
184
|
+
w(` Gemini MCP: ${result.integrations.gemini.path}
|
|
185
|
+
`);
|
|
186
|
+
if (result.integrations.gemini.geminiMd) {
|
|
187
|
+
w(` GEMINI.md: ${result.integrations.gemini.geminiMdPath} (memory instructions added)
|
|
188
|
+
`);
|
|
189
|
+
} else {
|
|
190
|
+
w(" GEMINI.md: already configured\n");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
w("\n");
|
|
194
|
+
if (!claudeCode && !cursor && !codex && !gemini) {
|
|
195
|
+
w(" MCP is ready. Add --claude-code, --cursor, --codex, or --gemini for tool-specific setup.\n");
|
|
196
|
+
w(" Example: memrosetta init --claude-code\n");
|
|
197
|
+
w("\n");
|
|
198
|
+
}
|
|
199
|
+
if (claudeCode) {
|
|
200
|
+
w(" Restart Claude Code to activate.\n\n");
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
run
|
|
205
|
+
};
|