toon-memory 1.0.6 → 1.0.8

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/setup.js CHANGED
@@ -1,36 +1,214 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, mkdirSync, writeFileSync, cpSync } from "fs"
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, cpSync } from "fs"
3
3
  import { dirname, join } from "path"
4
4
  import { fileURLToPath } from "url"
5
5
  import { execSync } from "child_process"
6
+ import { createInterface } from "readline"
7
+ import { createRequire } from "module"
6
8
 
7
9
  const __dirname = dirname(fileURLToPath(import.meta.url))
8
10
  const projectRoot = process.cwd()
9
- const toolsDir = join(projectRoot, ".opencode", "tools")
10
- const memoryDir = join(projectRoot, ".opencode", "memory")
11
- const memoryFile = join(memoryDir, "data.toon")
12
11
  const sourceDir = join(__dirname, "..", "src")
12
+ const HOME = process.env.HOME || "~"
13
13
 
14
14
  // Auto-install @toon-format/toon if not present
15
15
  try {
16
- require.resolve("@toon-format/toon")
16
+ createRequire(import.meta.url).resolve("@toon-format/toon")
17
17
  } catch {
18
18
  console.log("Installing @toon-format/toon...")
19
19
  execSync("npm install @toon-format/toon", { cwd: projectRoot, stdio: "inherit" })
20
20
  }
21
21
 
22
- // Create directories
23
- if (!existsSync(toolsDir)) mkdirSync(toolsDir, { recursive: true })
24
- if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true })
22
+ // Detect all supported agents
23
+ function detectAgents() {
24
+ const agents = []
25
+
26
+ // OpenCode
27
+ const opencodeGlobal = join(HOME, ".config", "opencode", "opencode.json")
28
+ const opencodeLocal = join(projectRoot, ".opencode", "opencode.json")
29
+ if (existsSync(opencodeGlobal) || existsSync(opencodeLocal) || true) { // Always show opencode
30
+ agents.push({
31
+ name: "opencode",
32
+ global: opencodeGlobal,
33
+ local: opencodeLocal,
34
+ mcpKey: "mcp"
35
+ })
36
+ }
37
+
38
+ // VS Code / GitHub Copilot
39
+ const vscodeLocal = join(projectRoot, ".vscode", "mcp.json")
40
+ const vscodeGlobal = join(HOME, ".config", "Code", "User", "globalStorage", "github.copilot-chat", "mcp.json")
41
+ if (existsSync(vscodeLocal) || existsSync(vscodeGlobal) || true) {
42
+ agents.push({
43
+ name: "vscode/copilot",
44
+ global: vscodeGlobal,
45
+ local: vscodeLocal,
46
+ mcpKey: "servers"
47
+ })
48
+ }
49
+
50
+ // Claude Code
51
+ const claudeGlobal = join(HOME, ".claude", "settings.json")
52
+ const claudeLocal = join(projectRoot, ".claude", "settings.json")
53
+ if (existsSync(claudeGlobal) || existsSync(claudeLocal)) {
54
+ agents.push({
55
+ name: "claude",
56
+ global: claudeGlobal,
57
+ local: claudeLocal,
58
+ mcpKey: "mcpServers"
59
+ })
60
+ }
61
+
62
+ // Cursor
63
+ const cursorLocal = join(projectRoot, ".cursor", "mcp.json")
64
+ if (existsSync(cursorLocal)) {
65
+ agents.push({
66
+ name: "cursor",
67
+ local: cursorLocal,
68
+ mcpKey: "mcpServers"
69
+ })
70
+ }
71
+
72
+ // Windsurf
73
+ const windsurfLocal = join(projectRoot, ".windsurfrules")
74
+ const windsurfGlobal = join(HOME, ".codeium", "windsurf", "mcp_config.json")
75
+ if (existsSync(windsurfLocal) || existsSync(windsurfGlobal)) {
76
+ agents.push({
77
+ name: "windsurf",
78
+ global: windsurfGlobal,
79
+ local: windsurfLocal,
80
+ mcpKey: "mcpServers"
81
+ })
82
+ }
83
+
84
+ // Cline
85
+ const clineLocal = join(projectRoot, ".cline", "mcp.json")
86
+ if (existsSync(clineLocal)) {
87
+ agents.push({
88
+ name: "cline",
89
+ local: clineLocal,
90
+ mcpKey: "mcpServers"
91
+ })
92
+ }
93
+
94
+ // Continue
95
+ const continueLocal = join(projectRoot, ".continue", "config.json")
96
+ if (existsSync(continueLocal)) {
97
+ agents.push({
98
+ name: "continue",
99
+ local: continueLocal,
100
+ mcpKey: "mcpServers"
101
+ })
102
+ }
103
+
104
+ // Aider
105
+ const aiderLocal = join(projectRoot, ".aider.conf.yml")
106
+ if (existsSync(aiderLocal)) {
107
+ agents.push({
108
+ name: "aider",
109
+ local: aiderLocal
110
+ })
111
+ }
112
+
113
+ return agents
114
+ }
115
+
116
+ // Install custom tools for OpenCode
117
+ function installOpenCodeTools() {
118
+ const toolsDir = join(projectRoot, ".opencode", "tools")
119
+ const memoryDir = join(projectRoot, ".opencode", "memory")
120
+ const memoryFile = join(memoryDir, "data.toon")
121
+
122
+ if (!existsSync(toolsDir)) mkdirSync(toolsDir, { recursive: true })
123
+ if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true })
25
124
 
26
- // Copy memory.ts
27
- cpSync(join(sourceDir, "memory.ts"), join(toolsDir, "memory.ts"))
28
- console.log("Copied memory.ts to .opencode/tools/")
125
+ cpSync(join(sourceDir, "memory.ts"), join(toolsDir, "memory.ts"))
126
+ console.log(" Copied memory.ts to .opencode/tools/")
127
+
128
+ if (!existsSync(memoryFile)) {
129
+ writeFileSync(memoryFile, "version: 1\nentries[0|]{id|category|key|content|file|tags|date}:\n")
130
+ console.log(" Created .opencode/memory/data.toon")
131
+ }
132
+ }
29
133
 
30
- // Create empty memory file if it doesn't exist
31
- if (!existsSync(memoryFile)) {
32
- writeFileSync(memoryFile, "version: 1\nentries[0|]{id|category|key|content|file|tags|date}:\n")
33
- console.log("Created .opencode/memory/data.toon")
134
+ // Install MCP server config for different agents
135
+ function installMCPConfig(agent, scope) {
136
+ const configPath = scope === "global" ? agent.global : agent.local
137
+
138
+ if (!configPath) {
139
+ console.log(` No ${scope} config path for ${agent.name}`)
140
+ return
141
+ }
142
+
143
+ const configDir = dirname(configPath)
144
+ if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true })
145
+
146
+ let config = {}
147
+ if (existsSync(configPath)) {
148
+ try {
149
+ config = JSON.parse(readFileSync(configPath, "utf-8"))
150
+ } catch {
151
+ config = {}
152
+ }
153
+ }
154
+
155
+ const mcpKey = agent.mcpKey || "mcp"
156
+ if (!config[mcpKey]) config[mcpKey] = {}
157
+
158
+ // Different agents use different config formats
159
+ if (agent.name === "vscode/copilot") {
160
+ config[mcpKey]["toon-memory"] = {
161
+ command: "npx",
162
+ args: ["-y", "toon-memory", "mcp"],
163
+ env: {}
164
+ }
165
+ } else if (agent.name === "aider") {
166
+ // Aider uses YAML, skip JSON config
167
+ console.log(` ${agent.name}: Add to .aider.conf.yml:`)
168
+ console.log(` mcp Servers:\n toon-memory:\n command: npx\n args: ["-y", "toon-memory", "mcp"]`)
169
+ return
170
+ } else {
171
+ config[mcpKey]["toon-memory"] = {
172
+ command: "npx",
173
+ args: ["-y", "toon-memory", "mcp"]
174
+ }
175
+ }
176
+
177
+ writeFileSync(configPath, JSON.stringify(config, null, 2))
178
+ console.log(` MCP server added to ${configPath}`)
34
179
  }
35
180
 
36
- console.log("toon-memory installed! Restart opencode to use memory tools.")
181
+ // Main
182
+ const agents = detectAgents()
183
+ console.log("\n🧠 toon-memory installer\n")
184
+
185
+ if (agents.length === 0) {
186
+ console.log("No supported agents detected. Installing custom tools...")
187
+ installOpenCodeTools()
188
+ console.log("\nDone! Restart your agent to use memory tools.")
189
+ process.exit(0)
190
+ }
191
+
192
+ console.log("Detected/supported agents:")
193
+ agents.forEach((a, i) => console.log(` ${i + 1}. ${a.name}`))
194
+ console.log("")
195
+
196
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
197
+ rl.question("Install (1) Local or (2) Global? [1/2]: ", (answer) => {
198
+ const scope = answer === "2" ? "global" : "local"
199
+ console.log(`\nInstalling ${scope}ly...\n`)
200
+
201
+ for (const agent of agents) {
202
+ console.log(`${agent.name}:`)
203
+
204
+ if (agent.name === "opencode") {
205
+ installOpenCodeTools()
206
+ }
207
+
208
+ installMCPConfig(agent, scope)
209
+ console.log("")
210
+ }
211
+
212
+ console.log("Done! Restart your agent to use memory tools.")
213
+ rl.close()
214
+ })
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "module"
3
2
  import { dirname, join } from "path"
4
3
  import { fileURLToPath } from "url"
5
4
  import { spawn } from "child_process"
package/mcp/server.js CHANGED
@@ -27664,7 +27664,7 @@ function generateId() {
27664
27664
  return randomBytes(4).toString("hex");
27665
27665
  }
27666
27666
  var server = new McpServer(
27667
- { name: "toon-memory", version: "1.0.5" },
27667
+ { name: "toon-memory", version: "1.0.8" },
27668
27668
  { capabilities: { tools: { listChanged: true } } }
27669
27669
  );
27670
27670
  server.registerTool(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "1.0.6",
4
- "description": "Persistent memory system for OpenCode AI agent using TOON format (40% fewer tokens than JSON)",
3
+ "version": "1.0.8",
4
+ "description": "Persistent memory system for AI coding agents using TOON format (40% fewer tokens than JSON)",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "toon-memory": "./bin/toon-memory.js"
@@ -19,6 +19,13 @@
19
19
  },
20
20
  "keywords": [
21
21
  "opencode",
22
+ "vscode",
23
+ "copilot",
24
+ "claude",
25
+ "cursor",
26
+ "windsurf",
27
+ "cline",
28
+ "continue",
22
29
  "ai-agent",
23
30
  "memory",
24
31
  "toon",
@@ -1,8 +1,21 @@
1
- # toon-memory — Persistent Memory for OpenCode
1
+ # toon-memory — Persistent Memory for AI Agents
2
2
 
3
3
  ## What is this?
4
4
 
5
- A persistent memory system for the OpenCode AI agent. It remembers decisions, patterns, bugs, and knowledge **between sessions** using TOON format (40% fewer tokens than JSON).
5
+ A persistent memory system for AI coding agents. It remembers decisions, patterns, bugs, and knowledge **between sessions** using TOON format (40% fewer tokens than JSON).
6
+
7
+ ## Supported Agents
8
+
9
+ | Agent | Config File | Format |
10
+ |-------|-------------|--------|
11
+ | OpenCode | `.opencode/opencode.json` | MCP server |
12
+ | VS Code / Copilot | `.vscode/mcp.json` | MCP server |
13
+ | Claude | `.claude/settings.json` | MCP server |
14
+ | Cursor | `.cursor/mcp.json` | MCP server |
15
+ | Windsurf | `.windsurfrules` | MCP server |
16
+ | Cline | `.cline/mcp.json` | MCP server |
17
+ | Continue | `.continue/config.json` | MCP server |
18
+ | Aider | `.aider.conf.yml` | Manual config |
6
19
 
7
20
  ## Tools
8
21
 
@@ -16,33 +29,27 @@ A persistent memory system for the OpenCode AI agent. It remembers decisions, pa
16
29
 
17
30
  ## Installation
18
31
 
19
- ### Option 1: Global MCP Server (recommended)
20
-
21
- Add to `~/.config/opencode/opencode.json`:
32
+ ### Interactive installer (recommended)
22
33
 
23
- ```json
24
- {
25
- "mcp": {
26
- "toon-memory": {
27
- "type": "local",
28
- "command": ["npx", "-y", "toon-memory", "mcp"],
29
- "enabled": true
30
- }
31
- }
32
- }
34
+ ```bash
35
+ npx toon-memory
33
36
  ```
34
37
 
35
- ### Option 2: Project-level MCP Server
38
+ This will:
39
+ 1. Detect installed agents
40
+ 2. Ask if you want local or global installation
41
+ 3. Configure the MCP server automatically
42
+
43
+ ### Manual installation
36
44
 
37
- Add to `.opencode/opencode.json`:
45
+ Add to your agent's MCP config:
38
46
 
39
47
  ```json
40
48
  {
41
- "mcp": {
49
+ "mcpServers": {
42
50
  "toon-memory": {
43
- "type": "local",
44
- "command": ["npx", "-y", "toon-memory", "mcp"],
45
- "enabled": true
51
+ "command": "npx",
52
+ "args": ["-y", "toon-memory", "mcp"]
46
53
  }
47
54
  }
48
55
  }
package/src/mcp/server.ts CHANGED
@@ -32,7 +32,7 @@ function generateId(): string {
32
32
  }
33
33
 
34
34
  const server = new McpServer(
35
- { name: "toon-memory", version: "1.0.5" },
35
+ { name: "toon-memory", version: "1.0.8" },
36
36
  { capabilities: { tools: { listChanged: true } } }
37
37
  )
38
38