toon-memory 1.0.4 ā 1.0.5
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 +25 -62
- package/package.json +1 -1
- package/README.md +0 -66
- package/bin/toon-memory.js +0 -16
- package/mcp/server.js +0 -20966
- package/skills/toon-memory.md +0 -68
- package/src/mcp/server.ts +0 -307
- package/src/memory.ts +0 -244
package/bin/setup.js
CHANGED
|
@@ -1,73 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { join, dirname } from "path"
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync, cpSync } from "fs"
|
|
3
|
+
import { dirname, join } from "path"
|
|
5
4
|
import { fileURLToPath } from "url"
|
|
6
5
|
import { execSync } from "child_process"
|
|
7
6
|
|
|
8
7
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
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
|
+
const sourceDir = join(__dirname, "..", "src")
|
|
13
|
+
|
|
14
|
+
// Auto-install @toon-format/toon if not present
|
|
15
|
+
try {
|
|
16
|
+
require.resolve("@toon-format/toon")
|
|
17
|
+
} catch {
|
|
18
|
+
console.log("Installing @toon-format/toon...")
|
|
19
|
+
execSync("npm install @toon-format/toon", { cwd: projectRoot, stdio: "inherit" })
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// 1. Copy tool file
|
|
25
|
-
ensureDir(TOOLS_DIR)
|
|
26
|
-
const toolSrc = join(PKG_DIR, "src", "memory.ts")
|
|
27
|
-
const toolDest = join(TOOLS_DIR, "memory.ts")
|
|
28
|
-
copyFileSync(toolSrc, toolDest)
|
|
29
|
-
console.log(` ā
Tool: ${toolDest}`)
|
|
30
|
-
|
|
31
|
-
// 2. Create memory directory and initial data file
|
|
32
|
-
ensureDir(MEMORY_DIR)
|
|
33
|
-
if (!existsSync(MEMORY_FILE)) {
|
|
34
|
-
writeFileSync(MEMORY_FILE, "version: 1\nentries[0|]:\nsummaries:\n", "utf-8")
|
|
35
|
-
console.log(` ā
Memory: ${MEMORY_FILE}`)
|
|
36
|
-
} else {
|
|
37
|
-
console.log(` āļø Memory already exists: ${MEMORY_FILE}`)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 3. Copy SKILL.md
|
|
41
|
-
ensureDir(SKILL_DIR)
|
|
42
|
-
const skillSrc = join(PKG_DIR, "skills", "toon-memory.md")
|
|
43
|
-
if (existsSync(skillSrc)) {
|
|
44
|
-
copyFileSync(skillSrc, SKILL_FILE)
|
|
45
|
-
console.log(` ā
Skill: ${SKILL_FILE}`)
|
|
46
|
-
}
|
|
22
|
+
// Create directories
|
|
23
|
+
if (!existsSync(toolsDir)) mkdirSync(toolsDir, { recursive: true })
|
|
24
|
+
if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true })
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"))
|
|
52
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
|
|
53
|
-
if (!deps["@toon-format/toon"]) {
|
|
54
|
-
console.log("\n š¦ Installing @toon-format/toon...")
|
|
55
|
-
try {
|
|
56
|
-
execSync("npm install @toon-format/toon", { cwd: PROJECT_ROOT, stdio: "inherit" })
|
|
57
|
-
console.log(" ā
@toon-format/toon installed")
|
|
58
|
-
} catch {
|
|
59
|
-
console.log(" ā ļø Failed to install. Run manually: npm install @toon-format/toon")
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
26
|
+
// Copy memory.ts
|
|
27
|
+
cpSync(join(sourceDir, "memory.ts"), join(toolsDir, "memory.ts"))
|
|
28
|
+
console.log("Copied memory.ts to .opencode/tools/")
|
|
63
29
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
console.log("
|
|
68
|
-
console.log(" memory_recall ā Search memory before reading files")
|
|
69
|
-
console.log(" memory_forget ā Remove an entry")
|
|
70
|
-
console.log(" memory_summary ā Save/retrieve file summaries")
|
|
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")
|
|
71
34
|
}
|
|
72
35
|
|
|
73
|
-
|
|
36
|
+
console.log("toon-memory installed! Restart opencode to use memory tools.")
|
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# toon-memory
|
|
2
|
-
|
|
3
|
-
Persistent memory system for [OpenCode](https://opencode.ai) AI agent using TOON format.
|
|
4
|
-
|
|
5
|
-
**40% fewer tokens than JSON** for the same data. The agent remembers decisions, patterns, and bugs between sessions.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# In your project
|
|
11
|
-
npm install toon-memory @toon-format/toon
|
|
12
|
-
npx toon-memory
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Or globally:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install -g toon-memory @toon-format/toon
|
|
19
|
-
# Then in any project:
|
|
20
|
-
npx toon-memory
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## What it does
|
|
24
|
-
|
|
25
|
-
Copies 3 files to your project:
|
|
26
|
-
|
|
27
|
-
| File | Purpose |
|
|
28
|
-
|------|---------|
|
|
29
|
-
| `.opencode/tools/memory.ts` | 5 tools for the AI agent |
|
|
30
|
-
| `.opencode/memory/data.toon` | Your project's memory (TOON format) |
|
|
31
|
-
| `.opencode/skills/toon-memory.md` | Usage instructions |
|
|
32
|
-
|
|
33
|
-
## Tools
|
|
34
|
-
|
|
35
|
-
| Tool | Description |
|
|
36
|
-
|------|-------------|
|
|
37
|
-
| `memory_remember` | Save a decision, pattern, bug, or knowledge |
|
|
38
|
-
| `memory_recall` | Search memory (use BEFORE reading files) |
|
|
39
|
-
| `memory_forget` | Remove an entry by key or id |
|
|
40
|
-
| `memory_stats` | View memory state |
|
|
41
|
-
| `memory_summary` | Save/retrieve file summaries |
|
|
42
|
-
|
|
43
|
-
## How it works
|
|
44
|
-
|
|
45
|
-
The agent stores entries in TOON format (Token-Oriented Object Notation):
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
version: 1
|
|
49
|
-
entries[2|]{id|category|key|content|file|tags|date}:
|
|
50
|
-
a1b2c3d4|decision|use-pandas|Use pandas for time series|indicators.py|python;analytics|2026-07-10
|
|
51
|
-
e5f6g7h8|bug|redis-pool|max_connections missing|redis.adapter.ts|redis;pool|2026-07-10
|
|
52
|
-
summaries:
|
|
53
|
-
path/to/file.py: Brief summary of what this file does
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Token savings
|
|
57
|
-
|
|
58
|
-
| Format | Tokens (10 entries) | vs JSON |
|
|
59
|
-
|--------|---------------------|---------|
|
|
60
|
-
| JSON | ~800 | baseline |
|
|
61
|
-
| YAML | ~650 | -19% |
|
|
62
|
-
| **TOON** | **~480** | **-40%** |
|
|
63
|
-
|
|
64
|
-
## License
|
|
65
|
-
|
|
66
|
-
MIT
|
package/bin/toon-memory.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "module"
|
|
3
|
-
import { dirname, join } from "path"
|
|
4
|
-
import { fileURLToPath } from "url"
|
|
5
|
-
import { spawn } from "child_process"
|
|
6
|
-
|
|
7
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
-
const args = process.argv.slice(2)
|
|
9
|
-
|
|
10
|
-
const target = args[0] === "mcp"
|
|
11
|
-
? join(__dirname, "..", "mcp", "server.js")
|
|
12
|
-
: join(__dirname, "setup.js")
|
|
13
|
-
|
|
14
|
-
const extraArgs = args[0] === "mcp" ? [] : args
|
|
15
|
-
const child = spawn("node", [target, ...extraArgs], { stdio: "inherit" })
|
|
16
|
-
child.on("exit", (code) => process.exit(code ?? 0))
|