toon-memory 1.1.0 → 1.1.1
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/bin/toon-memory.js +1 -1
- package/dist/cli/setup.js +237 -0
- package/dist/cli/toon-memory.js +9 -0
- package/package.json +8 -5
- package/{bin/setup.js → src/cli/setup.ts} +23 -17
- package/src/cli/toon-memory.ts +14 -0
package/bin/toon-memory.js
CHANGED
|
@@ -8,7 +8,7 @@ const args = process.argv.slice(2)
|
|
|
8
8
|
|
|
9
9
|
const target = args[0] === "mcp"
|
|
10
10
|
? join(__dirname, "..", "mcp", "server.js")
|
|
11
|
-
: join(__dirname, "setup.js")
|
|
11
|
+
: join(__dirname, "..", "dist", "cli", "setup.js")
|
|
12
12
|
|
|
13
13
|
const extraArgs = args[0] === "mcp" ? [] : args
|
|
14
14
|
const child = spawn("node", [target, ...extraArgs], { stdio: "inherit" })
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, cpSync, unlinkSync } from "fs";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import { createInterface } from "readline";
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const projectRoot = process.cwd();
|
|
9
|
+
const sourceDir = join(__dirname, "..", "src");
|
|
10
|
+
const HOME = process.env.HOME || process.env.USERPROFILE || "~";
|
|
11
|
+
try {
|
|
12
|
+
createRequire(import.meta.url).resolve("@toon-format/toon");
|
|
13
|
+
} catch {
|
|
14
|
+
console.log("Installing @toon-format/toon...");
|
|
15
|
+
execSync("npm install @toon-format/toon", { cwd: projectRoot, stdio: "inherit" });
|
|
16
|
+
}
|
|
17
|
+
function detectAgents() {
|
|
18
|
+
const agents2 = [];
|
|
19
|
+
const opencodeGlobal = join(HOME, ".config", "opencode", "opencode.json");
|
|
20
|
+
const opencodeLocal = join(projectRoot, ".opencode", "opencode.json");
|
|
21
|
+
agents2.push({
|
|
22
|
+
name: "opencode",
|
|
23
|
+
global: opencodeGlobal,
|
|
24
|
+
local: opencodeLocal,
|
|
25
|
+
mcpKey: "mcp"
|
|
26
|
+
});
|
|
27
|
+
const vscodeLocal = join(projectRoot, ".vscode", "mcp.json");
|
|
28
|
+
agents2.push({
|
|
29
|
+
name: "vscode/copilot",
|
|
30
|
+
local: vscodeLocal,
|
|
31
|
+
mcpKey: "servers"
|
|
32
|
+
});
|
|
33
|
+
const claudeGlobal = join(HOME, ".claude", "settings.json");
|
|
34
|
+
const claudeLocal = join(projectRoot, ".claude", "settings.json");
|
|
35
|
+
agents2.push({
|
|
36
|
+
name: "claude",
|
|
37
|
+
global: claudeGlobal,
|
|
38
|
+
local: claudeLocal,
|
|
39
|
+
mcpKey: "mcpServers"
|
|
40
|
+
});
|
|
41
|
+
const cursorLocal = join(projectRoot, ".cursor", "mcp.json");
|
|
42
|
+
agents2.push({
|
|
43
|
+
name: "cursor",
|
|
44
|
+
local: cursorLocal,
|
|
45
|
+
mcpKey: "mcpServers"
|
|
46
|
+
});
|
|
47
|
+
const windsurfGlobal = join(HOME, ".codeium", "windsurf", "mcp_config.json");
|
|
48
|
+
agents2.push({
|
|
49
|
+
name: "windsurf",
|
|
50
|
+
global: windsurfGlobal,
|
|
51
|
+
mcpKey: "mcpServers"
|
|
52
|
+
});
|
|
53
|
+
const clineLocal = join(projectRoot, ".cline", "mcp.json");
|
|
54
|
+
agents2.push({
|
|
55
|
+
name: "cline",
|
|
56
|
+
local: clineLocal,
|
|
57
|
+
mcpKey: "mcpServers"
|
|
58
|
+
});
|
|
59
|
+
const continueLocal = join(projectRoot, ".continue", "config.json");
|
|
60
|
+
agents2.push({
|
|
61
|
+
name: "continue",
|
|
62
|
+
local: continueLocal,
|
|
63
|
+
mcpKey: "mcpServers"
|
|
64
|
+
});
|
|
65
|
+
return agents2;
|
|
66
|
+
}
|
|
67
|
+
function installOpenCodeTools() {
|
|
68
|
+
const toolsDir = join(projectRoot, ".opencode", "tools");
|
|
69
|
+
const memoryDir = join(projectRoot, ".opencode", "memory");
|
|
70
|
+
const memoryFile = join(memoryDir, "data.toon");
|
|
71
|
+
if (!existsSync(toolsDir)) mkdirSync(toolsDir, { recursive: true });
|
|
72
|
+
if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true });
|
|
73
|
+
cpSync(join(sourceDir, "memory.ts"), join(toolsDir, "memory.ts"));
|
|
74
|
+
console.log(" Copied memory.ts to .opencode/tools/");
|
|
75
|
+
if (!existsSync(memoryFile)) {
|
|
76
|
+
writeFileSync(memoryFile, "version: 1\nentries[0|]{id|category|key|content|file|tags|date}:\n");
|
|
77
|
+
console.log(" Created .opencode/memory/data.toon");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function installMCPConfig(agent, scope) {
|
|
81
|
+
const configPath = scope === "global" ? agent.global : agent.local;
|
|
82
|
+
if (!configPath) {
|
|
83
|
+
console.log(` No ${scope} config path for ${agent.name}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const configDir = dirname(configPath);
|
|
87
|
+
if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true });
|
|
88
|
+
let config = {};
|
|
89
|
+
if (existsSync(configPath)) {
|
|
90
|
+
try {
|
|
91
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
92
|
+
} catch {
|
|
93
|
+
config = {};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const mcpKey = agent.mcpKey || "mcpServers";
|
|
97
|
+
if (!config[mcpKey]) config[mcpKey] = {};
|
|
98
|
+
config[mcpKey]["toon-memory"] = {
|
|
99
|
+
command: "npx",
|
|
100
|
+
args: ["-y", "toon-memory", "mcp"]
|
|
101
|
+
};
|
|
102
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
103
|
+
console.log(` MCP server added to ${configPath}`);
|
|
104
|
+
}
|
|
105
|
+
function uninstall() {
|
|
106
|
+
console.log("\n\u{1F9E0} toon-memory uninstaller\n");
|
|
107
|
+
const agents2 = detectAgents();
|
|
108
|
+
for (const agent of agents2) {
|
|
109
|
+
const configs = [agent.global, agent.local].filter(Boolean);
|
|
110
|
+
for (const configPath of configs) {
|
|
111
|
+
if (!existsSync(configPath)) continue;
|
|
112
|
+
try {
|
|
113
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
114
|
+
const mcpKey = agent.mcpKey || "mcpServers";
|
|
115
|
+
if (config[mcpKey]?.["toon-memory"]) {
|
|
116
|
+
delete config[mcpKey]["toon-memory"];
|
|
117
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
118
|
+
console.log(` \u2705 Removed from ${agent.name} (${configPath})`);
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const toolsFile = join(projectRoot, ".opencode", "tools", "memory.ts");
|
|
125
|
+
if (existsSync(toolsFile)) {
|
|
126
|
+
unlinkSync(toolsFile);
|
|
127
|
+
console.log(" \u2705 Removed .opencode/tools/memory.ts");
|
|
128
|
+
}
|
|
129
|
+
console.log("\n\u2705 toon-memory uninstalled from all agents\n");
|
|
130
|
+
}
|
|
131
|
+
function init(scope = "local") {
|
|
132
|
+
console.log("\n\u{1F9E0} toon-memory init\n");
|
|
133
|
+
const agents2 = detectAgents();
|
|
134
|
+
for (const agent of agents2) {
|
|
135
|
+
console.log(`${agent.name}:`);
|
|
136
|
+
if (agent.name === "opencode") {
|
|
137
|
+
installOpenCodeTools();
|
|
138
|
+
}
|
|
139
|
+
installMCPConfig(agent, scope);
|
|
140
|
+
console.log("");
|
|
141
|
+
}
|
|
142
|
+
console.log("Done! Restart your agent to use memory tools.\n");
|
|
143
|
+
}
|
|
144
|
+
function status() {
|
|
145
|
+
console.log("\n\u{1F9E0} toon-memory status\n");
|
|
146
|
+
try {
|
|
147
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
148
|
+
console.log(`Version: ${pkg.version}`);
|
|
149
|
+
} catch {
|
|
150
|
+
console.log("Version: unknown");
|
|
151
|
+
}
|
|
152
|
+
const memoryFile = join(projectRoot, ".opencode", "memory", "data.toon");
|
|
153
|
+
if (existsSync(memoryFile)) {
|
|
154
|
+
const data = readFileSync(memoryFile, "utf-8");
|
|
155
|
+
const lines = data.split("\n").filter((l) => l.startsWith(" ") && l.includes("|"));
|
|
156
|
+
console.log(`Memory: ${lines.length} entries`);
|
|
157
|
+
} else {
|
|
158
|
+
console.log("Memory: not initialized");
|
|
159
|
+
}
|
|
160
|
+
const agents2 = detectAgents();
|
|
161
|
+
console.log("\nAgent configs:");
|
|
162
|
+
for (const agent of agents2) {
|
|
163
|
+
const configs = [agent.global, agent.local].filter(Boolean);
|
|
164
|
+
let found = false;
|
|
165
|
+
for (const configPath of configs) {
|
|
166
|
+
if (!existsSync(configPath)) continue;
|
|
167
|
+
try {
|
|
168
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
169
|
+
const mcpKey = agent.mcpKey || "mcpServers";
|
|
170
|
+
if (config[mcpKey]?.["toon-memory"]) {
|
|
171
|
+
console.log(` \u2705 ${agent.name} (${configPath})`);
|
|
172
|
+
found = true;
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!found) {
|
|
178
|
+
console.log(` \u274C ${agent.name} (not configured)`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
console.log("");
|
|
182
|
+
}
|
|
183
|
+
function upgrade() {
|
|
184
|
+
console.log("\n\u{1F9E0} toon-memory upgrade\n");
|
|
185
|
+
try {
|
|
186
|
+
console.log("Checking for updates...");
|
|
187
|
+
const latest = execSync("npm view toon-memory version", { encoding: "utf-8" }).trim();
|
|
188
|
+
console.log(`Latest version: ${latest}`);
|
|
189
|
+
console.log("Upgrading...");
|
|
190
|
+
execSync("npm install -g toon-memory@" + latest, { stdio: "inherit" });
|
|
191
|
+
console.log(`
|
|
192
|
+
\u2705 Upgraded to toon-memory@${latest}`);
|
|
193
|
+
console.log("Restart your agent to use the new version.\n");
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error("Upgrade failed:", error.message);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const args = process.argv.slice(2);
|
|
199
|
+
if (args[0] === "uninstall") {
|
|
200
|
+
uninstall();
|
|
201
|
+
process.exit(0);
|
|
202
|
+
}
|
|
203
|
+
if (args[0] === "init") {
|
|
204
|
+
init(args[1] || "local");
|
|
205
|
+
process.exit(0);
|
|
206
|
+
}
|
|
207
|
+
if (args[0] === "status") {
|
|
208
|
+
status();
|
|
209
|
+
process.exit(0);
|
|
210
|
+
}
|
|
211
|
+
if (args[0] === "upgrade") {
|
|
212
|
+
upgrade();
|
|
213
|
+
process.exit(0);
|
|
214
|
+
}
|
|
215
|
+
const agents = detectAgents();
|
|
216
|
+
console.log("\n\u{1F9E0} toon-memory installer\n");
|
|
217
|
+
console.log("Supported agents:");
|
|
218
|
+
agents.forEach((a, i) => console.log(` ${i + 1}. ${a.name}`));
|
|
219
|
+
console.log("");
|
|
220
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
221
|
+
rl.question("Install (1) Local or (2) Global? [1/2]: ", (answer) => {
|
|
222
|
+
const scope = answer === "2" ? "global" : "local";
|
|
223
|
+
console.log(`
|
|
224
|
+
Installing ${scope}ly...
|
|
225
|
+
`);
|
|
226
|
+
for (const agent of agents) {
|
|
227
|
+
console.log(`${agent.name}:`);
|
|
228
|
+
if (agent.name === "opencode") {
|
|
229
|
+
installOpenCodeTools();
|
|
230
|
+
}
|
|
231
|
+
installMCPConfig(agent, scope);
|
|
232
|
+
console.log("");
|
|
233
|
+
}
|
|
234
|
+
console.log("Done! Restart your agent to use memory tools.");
|
|
235
|
+
console.log("Run 'npx toon-memory uninstall' to remove.\n");
|
|
236
|
+
rl.close();
|
|
237
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { dirname, join } from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { spawn } from "child_process";
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const target = args[0] === "mcp" ? join(__dirname, "..", "mcp", "server.js") : join(__dirname, "..", "dist", "cli", "setup.js");
|
|
7
|
+
const extraArgs = args[0] === "mcp" ? [] : args;
|
|
8
|
+
const child = spawn("node", [target, ...extraArgs], { stdio: "inherit" });
|
|
9
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Persistent memory system for AI coding agents using TOON format (40% fewer tokens than JSON)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"src/",
|
|
11
11
|
"bin/",
|
|
12
|
+
"dist/",
|
|
12
13
|
"mcp/",
|
|
13
14
|
"skills/",
|
|
14
15
|
"install.sh",
|
|
@@ -16,7 +17,9 @@
|
|
|
16
17
|
"uninstall.sh"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"build": "
|
|
20
|
+
"build": "npm run build:mcp && npm run build:cli",
|
|
21
|
+
"build:mcp": "esbuild src/mcp/server.ts --bundle --platform=node --format=esm --outfile=mcp/server.js",
|
|
22
|
+
"build:cli": "esbuild src/cli/setup.ts --platform=node --format=esm --outfile=dist/cli/setup.js && esbuild src/cli/toon-memory.ts --platform=node --format=esm --outfile=dist/cli/toon-memory.js",
|
|
20
23
|
"prepublishOnly": "npm run build"
|
|
21
24
|
},
|
|
22
25
|
"dependencies": {
|
|
@@ -47,10 +50,10 @@
|
|
|
47
50
|
"license": "MIT",
|
|
48
51
|
"repository": {
|
|
49
52
|
"type": "git",
|
|
50
|
-
"url": "https://github.com/
|
|
53
|
+
"url": "https://github.com/LuiggiVal08/toon-memory.git"
|
|
51
54
|
},
|
|
52
|
-
"homepage": "https://github.com/
|
|
55
|
+
"homepage": "https://github.com/LuiggiVal08/toon-memory#readme",
|
|
53
56
|
"bugs": {
|
|
54
|
-
"url": "https://github.com/
|
|
57
|
+
"url": "https://github.com/LuiggiVal08/toon-memory/issues"
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, cpSync, unlinkSync } from "fs"
|
|
3
2
|
import { dirname, join } from "path"
|
|
4
3
|
import { fileURLToPath } from "url"
|
|
@@ -11,6 +10,13 @@ const projectRoot = process.cwd()
|
|
|
11
10
|
const sourceDir = join(__dirname, "..", "src")
|
|
12
11
|
const HOME = process.env.HOME || process.env.USERPROFILE || "~"
|
|
13
12
|
|
|
13
|
+
interface Agent {
|
|
14
|
+
name: string
|
|
15
|
+
global?: string
|
|
16
|
+
local?: string
|
|
17
|
+
mcpKey: string
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
// Auto-install @toon-format/toon if not present
|
|
15
21
|
try {
|
|
16
22
|
createRequire(import.meta.url).resolve("@toon-format/toon")
|
|
@@ -20,8 +26,8 @@ try {
|
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
// Detect all supported agents
|
|
23
|
-
function detectAgents() {
|
|
24
|
-
const agents = []
|
|
29
|
+
function detectAgents(): Agent[] {
|
|
30
|
+
const agents: Agent[] = []
|
|
25
31
|
|
|
26
32
|
// OpenCode
|
|
27
33
|
const opencodeGlobal = join(HOME, ".config", "opencode", "opencode.json")
|
|
@@ -87,7 +93,7 @@ function detectAgents() {
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
// Install custom tools for OpenCode
|
|
90
|
-
function installOpenCodeTools() {
|
|
96
|
+
function installOpenCodeTools(): void {
|
|
91
97
|
const toolsDir = join(projectRoot, ".opencode", "tools")
|
|
92
98
|
const memoryDir = join(projectRoot, ".opencode", "memory")
|
|
93
99
|
const memoryFile = join(memoryDir, "data.toon")
|
|
@@ -105,7 +111,7 @@ function installOpenCodeTools() {
|
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
// Install MCP server config for different agents
|
|
108
|
-
function installMCPConfig(agent, scope) {
|
|
114
|
+
function installMCPConfig(agent: Agent, scope: string): void {
|
|
109
115
|
const configPath = scope === "global" ? agent.global : agent.local
|
|
110
116
|
|
|
111
117
|
if (!configPath) {
|
|
@@ -116,7 +122,7 @@ function installMCPConfig(agent, scope) {
|
|
|
116
122
|
const configDir = dirname(configPath)
|
|
117
123
|
if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true })
|
|
118
124
|
|
|
119
|
-
let config = {}
|
|
125
|
+
let config: Record<string, any> = {}
|
|
120
126
|
if (existsSync(configPath)) {
|
|
121
127
|
try {
|
|
122
128
|
config = JSON.parse(readFileSync(configPath, "utf-8"))
|
|
@@ -138,13 +144,13 @@ function installMCPConfig(agent, scope) {
|
|
|
138
144
|
}
|
|
139
145
|
|
|
140
146
|
// Uninstall from all agents
|
|
141
|
-
function uninstall() {
|
|
147
|
+
function uninstall(): void {
|
|
142
148
|
console.log("\n🧠 toon-memory uninstaller\n")
|
|
143
149
|
|
|
144
150
|
const agents = detectAgents()
|
|
145
151
|
|
|
146
152
|
for (const agent of agents) {
|
|
147
|
-
const configs = [agent.global, agent.local].filter(Boolean)
|
|
153
|
+
const configs = [agent.global, agent.local].filter(Boolean) as string[]
|
|
148
154
|
|
|
149
155
|
for (const configPath of configs) {
|
|
150
156
|
if (!existsSync(configPath)) continue
|
|
@@ -173,7 +179,7 @@ function uninstall() {
|
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
// Quick init without interactive prompts
|
|
176
|
-
function init(scope = "local") {
|
|
182
|
+
function init(scope: string = "local"): void {
|
|
177
183
|
console.log("\n🧠 toon-memory init\n")
|
|
178
184
|
|
|
179
185
|
const agents = detectAgents()
|
|
@@ -193,7 +199,7 @@ function init(scope = "local") {
|
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
// Show installation status
|
|
196
|
-
function status() {
|
|
202
|
+
function status(): void {
|
|
197
203
|
console.log("\n🧠 toon-memory status\n")
|
|
198
204
|
|
|
199
205
|
// Check npm package
|
|
@@ -208,7 +214,7 @@ function status() {
|
|
|
208
214
|
const memoryFile = join(projectRoot, ".opencode", "memory", "data.toon")
|
|
209
215
|
if (existsSync(memoryFile)) {
|
|
210
216
|
const data = readFileSync(memoryFile, "utf-8")
|
|
211
|
-
const lines = data.split("\n").filter((l) => l.startsWith(" ") && l.includes("|"))
|
|
217
|
+
const lines = data.split("\n").filter((l: string) => l.startsWith(" ") && l.includes("|"))
|
|
212
218
|
console.log(`Memory: ${lines.length} entries`)
|
|
213
219
|
} else {
|
|
214
220
|
console.log("Memory: not initialized")
|
|
@@ -219,7 +225,7 @@ function status() {
|
|
|
219
225
|
console.log("\nAgent configs:")
|
|
220
226
|
|
|
221
227
|
for (const agent of agents) {
|
|
222
|
-
const configs = [agent.global, agent.local].filter(Boolean)
|
|
228
|
+
const configs = [agent.global, agent.local].filter(Boolean) as string[]
|
|
223
229
|
let found = false
|
|
224
230
|
|
|
225
231
|
for (const configPath of configs) {
|
|
@@ -245,7 +251,7 @@ function status() {
|
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
// Upgrade to latest version
|
|
248
|
-
function upgrade() {
|
|
254
|
+
function upgrade(): void {
|
|
249
255
|
console.log("\n🧠 toon-memory upgrade\n")
|
|
250
256
|
|
|
251
257
|
try {
|
|
@@ -256,10 +262,10 @@ function upgrade() {
|
|
|
256
262
|
console.log("Upgrading...")
|
|
257
263
|
execSync("npm install -g toon-memory@" + latest, { stdio: "inherit" })
|
|
258
264
|
|
|
259
|
-
console.log(
|
|
265
|
+
console.log(`\n✅ Upgraded to toon-memory@${latest}`)
|
|
260
266
|
console.log("Restart your agent to use the new version.\n")
|
|
261
267
|
} catch (error) {
|
|
262
|
-
console.error("Upgrade failed:", error.message)
|
|
268
|
+
console.error("Upgrade failed:", (error as Error).message)
|
|
263
269
|
}
|
|
264
270
|
}
|
|
265
271
|
|
|
@@ -290,11 +296,11 @@ const agents = detectAgents()
|
|
|
290
296
|
console.log("\n🧠 toon-memory installer\n")
|
|
291
297
|
|
|
292
298
|
console.log("Supported agents:")
|
|
293
|
-
agents.forEach((a, i) => console.log(` ${i + 1}. ${a.name}`))
|
|
299
|
+
agents.forEach((a: Agent, i: number) => console.log(` ${i + 1}. ${a.name}`))
|
|
294
300
|
console.log("")
|
|
295
301
|
|
|
296
302
|
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
297
|
-
rl.question("Install (1) Local or (2) Global? [1/2]: ", (answer) => {
|
|
303
|
+
rl.question("Install (1) Local or (2) Global? [1/2]: ", (answer: string) => {
|
|
298
304
|
const scope = answer === "2" ? "global" : "local"
|
|
299
305
|
console.log(`\nInstalling ${scope}ly...\n`)
|
|
300
306
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { dirname, join } from "path"
|
|
2
|
+
import { fileURLToPath } from "url"
|
|
3
|
+
import { spawn } from "child_process"
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
const args = process.argv.slice(2)
|
|
7
|
+
|
|
8
|
+
const target = args[0] === "mcp"
|
|
9
|
+
? join(__dirname, "..", "mcp", "server.js")
|
|
10
|
+
: join(__dirname, "..", "dist", "cli", "setup.js")
|
|
11
|
+
|
|
12
|
+
const extraArgs = args[0] === "mcp" ? [] : args
|
|
13
|
+
const child = spawn("node", [target, ...extraArgs], { stdio: "inherit" })
|
|
14
|
+
child.on("exit", (code) => process.exit(code ?? 0))
|