toon-memory 1.0.6 ā 1.0.7
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 +101 -16
- package/bin/toon-memory.js +0 -1
- package/mcp/server.js +1 -1
- package/package.json +1 -1
- package/skills/toon-memory.md +13 -2
- package/src/mcp/server.ts +1 -1
package/bin/setup.js
CHANGED
|
@@ -1,36 +1,121 @@
|
|
|
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")
|
|
13
12
|
|
|
14
13
|
// Auto-install @toon-format/toon if not present
|
|
15
14
|
try {
|
|
16
|
-
|
|
15
|
+
createRequire(import.meta.url).resolve("@toon-format/toon")
|
|
17
16
|
} catch {
|
|
18
17
|
console.log("Installing @toon-format/toon...")
|
|
19
18
|
execSync("npm install @toon-format/toon", { cwd: projectRoot, stdio: "inherit" })
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
// Detect agents
|
|
22
|
+
function detectAgents() {
|
|
23
|
+
const agents = []
|
|
24
|
+
|
|
25
|
+
// OpenCode
|
|
26
|
+
const opencodeGlobal = join(process.env.HOME || "~", ".config", "opencode", "opencode.json")
|
|
27
|
+
const opencodeLocal = join(projectRoot, ".opencode", "opencode.json")
|
|
28
|
+
if (existsSync(opencodeGlobal) || existsSync(opencodeLocal)) {
|
|
29
|
+
agents.push({ name: "opencode", global: opencodeGlobal, local: opencodeLocal })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Claude Code
|
|
33
|
+
const claudeGlobal = join(process.env.HOME || "~", ".claude", "settings.json")
|
|
34
|
+
const claudeLocal = join(projectRoot, ".claude", "settings.json")
|
|
35
|
+
if (existsSync(claudeGlobal) || existsSync(claudeLocal)) {
|
|
36
|
+
agents.push({ name: "claude", global: claudeGlobal, local: claudeLocal })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Cursor
|
|
40
|
+
const cursorLocal = join(projectRoot, ".cursor", "mcp.json")
|
|
41
|
+
if (existsSync(cursorLocal)) {
|
|
42
|
+
agents.push({ name: "cursor", local: cursorLocal })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return agents
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Install custom tools for OpenCode
|
|
49
|
+
function installOpenCodeTools() {
|
|
50
|
+
const toolsDir = join(projectRoot, ".opencode", "tools")
|
|
51
|
+
const memoryDir = join(projectRoot, ".opencode", "memory")
|
|
52
|
+
const memoryFile = join(memoryDir, "data.toon")
|
|
53
|
+
|
|
54
|
+
if (!existsSync(toolsDir)) mkdirSync(toolsDir, { recursive: true })
|
|
55
|
+
if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true })
|
|
25
56
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
57
|
+
cpSync(join(sourceDir, "memory.ts"), join(toolsDir, "memory.ts"))
|
|
58
|
+
console.log(" Copied memory.ts to .opencode/tools/")
|
|
59
|
+
|
|
60
|
+
if (!existsSync(memoryFile)) {
|
|
61
|
+
writeFileSync(memoryFile, "version: 1\nentries[0|]{id|category|key|content|file|tags|date}:\n")
|
|
62
|
+
console.log(" Created .opencode/memory/data.toon")
|
|
63
|
+
}
|
|
64
|
+
}
|
|
29
65
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
66
|
+
// Install MCP server config for OpenCode
|
|
67
|
+
function installOpenCodeMCP(scope) {
|
|
68
|
+
const configPath = scope === "global"
|
|
69
|
+
? join(process.env.HOME || "~", ".config", "opencode", "opencode.json")
|
|
70
|
+
: join(projectRoot, ".opencode", "opencode.json")
|
|
71
|
+
|
|
72
|
+
const configDir = dirname(configPath)
|
|
73
|
+
if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true })
|
|
74
|
+
|
|
75
|
+
let config = {}
|
|
76
|
+
if (existsSync(configPath)) {
|
|
77
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!config.mcp) config.mcp = {}
|
|
81
|
+
config.mcp["toon-memory"] = {
|
|
82
|
+
type: "local",
|
|
83
|
+
command: ["npx", "-y", "toon-memory", "mcp"],
|
|
84
|
+
enabled: true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2))
|
|
88
|
+
console.log(` MCP server added to ${configPath}`)
|
|
34
89
|
}
|
|
35
90
|
|
|
36
|
-
|
|
91
|
+
// Main
|
|
92
|
+
const agents = detectAgents()
|
|
93
|
+
console.log("\nš§ toon-memory installer\n")
|
|
94
|
+
|
|
95
|
+
if (agents.length === 0) {
|
|
96
|
+
console.log("No supported agents detected. Installing custom tools...")
|
|
97
|
+
installOpenCodeTools()
|
|
98
|
+
console.log("\nDone! Restart your agent to use memory tools.")
|
|
99
|
+
process.exit(0)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log("Detected agents:")
|
|
103
|
+
agents.forEach((a, i) => console.log(` ${i + 1}. ${a.name}`))
|
|
104
|
+
console.log("")
|
|
105
|
+
|
|
106
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
107
|
+
rl.question("Install (1) Local or (2) Global? [1/2]: ", (answer) => {
|
|
108
|
+
const scope = answer === "2" ? "global" : "local"
|
|
109
|
+
console.log(`\nInstalling ${scope}ly...\n`)
|
|
110
|
+
|
|
111
|
+
for (const agent of agents) {
|
|
112
|
+
if (agent.name === "opencode") {
|
|
113
|
+
console.log("OpenCode:")
|
|
114
|
+
installOpenCodeTools()
|
|
115
|
+
installOpenCodeMCP(scope)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log("\nDone! Restart your agent to use memory tools.")
|
|
120
|
+
rl.close()
|
|
121
|
+
})
|
package/bin/toon-memory.js
CHANGED
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.
|
|
27667
|
+
{ name: "toon-memory", version: "1.0.7" },
|
|
27668
27668
|
{ capabilities: { tools: { listChanged: true } } }
|
|
27669
27669
|
);
|
|
27670
27670
|
server.registerTool(
|
package/package.json
CHANGED
package/skills/toon-memory.md
CHANGED
|
@@ -16,7 +16,18 @@ A persistent memory system for the OpenCode AI agent. It remembers decisions, pa
|
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
|
-
### Option 1:
|
|
19
|
+
### Option 1: Interactive installer (recommended)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx toon-memory
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This will:
|
|
26
|
+
1. Detect installed agents (OpenCode, Claude, Cursor)
|
|
27
|
+
2. Ask if you want local or global installation
|
|
28
|
+
3. Configure the MCP server automatically
|
|
29
|
+
|
|
30
|
+
### Option 2: Global MCP Server
|
|
20
31
|
|
|
21
32
|
Add to `~/.config/opencode/opencode.json`:
|
|
22
33
|
|
|
@@ -32,7 +43,7 @@ Add to `~/.config/opencode/opencode.json`:
|
|
|
32
43
|
}
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
### Option
|
|
46
|
+
### Option 3: Project-level MCP Server
|
|
36
47
|
|
|
37
48
|
Add to `.opencode/opencode.json`:
|
|
38
49
|
|
package/src/mcp/server.ts
CHANGED