toon-memory 2.5.1 → 2.7.0
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/README.md +124 -3
- package/dist/cli/setup.js +463 -425
- package/install.sh +8 -1
- package/mcp/server.js +2058 -1084
- package/package.json +5 -3
- package/skills/toon-memory.md +7 -2
- package/src/cli/agents.ts +184 -0
- package/src/cli/capture-toggle.ts +29 -0
- package/src/cli/commands.ts +532 -0
- package/src/cli/config-writer.ts +133 -0
- package/src/cli/constants.ts +56 -0
- package/src/cli/hooks.ts +202 -0
- package/src/cli/instructions.ts +35 -0
- package/src/cli/memory.ts +104 -0
- package/src/cli/opencode-plugin.ts +84 -0
- package/src/cli/setup.ts +5 -1596
- package/src/cli/types.ts +29 -0
- package/src/cli/watch.ts +169 -0
- package/src/lib/code-search.ts +192 -0
- package/src/lib/context.ts +658 -0
- package/src/lib/git.ts +263 -0
- package/src/lib/project-scan.ts +224 -0
- package/src/mcp/archive.ts +129 -0
- package/src/mcp/config.ts +88 -0
- package/src/mcp/consolidation.ts +70 -0
- package/src/mcp/crypto.ts +41 -0
- package/src/mcp/entries.ts +110 -0
- package/src/mcp/memory-io.ts +53 -0
- package/src/mcp/observations.ts +16 -0
- package/src/mcp/resources.ts +57 -0
- package/src/mcp/scoring.ts +77 -0
- package/src/mcp/server.ts +7 -1482
- package/src/mcp/tools.ts +826 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "MCP server giving AI coding agents offline, token-efficient persistent memory — recall decisions, patterns, and bugs across sessions
|
|
3
|
+
"version": "2.7.0",
|
|
4
|
+
"description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 20 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"toon-memory": "./bin/toon-memory.js"
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "npm run build:bin && npm run build:mcp && npm run build:cli",
|
|
21
21
|
"build:bin": "esbuild src/bin/toon-memory.ts --platform=node --format=esm --outfile=bin/toon-memory.js",
|
|
22
|
-
"build:mcp": "esbuild
|
|
22
|
+
"build:mcp": "node -e \"const{version}=require('./package.json');const esbuild=require('esbuild');esbuild.build({entryPoints:['src/mcp/server.ts'],bundle:true,platform:'node',format:'esm',outfile:'mcp/server.js',define:{TOON_VERSION:JSON.stringify(version)}})\"",
|
|
23
23
|
"build:cli": "esbuild src/cli/setup.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/cli/setup.js && esbuild src/cli/toon-memory.ts --bundle --platform=node --format=esm --outfile=dist/cli/toon-memory.js && esbuild src/cli/capture.ts --bundle --platform=node --format=esm --outfile=dist/cli/capture.js && esbuild src/cli/session-start.ts --bundle --platform=node --format=esm --outfile=dist/cli/session-start.js",
|
|
24
24
|
"test": "vitest run",
|
|
25
25
|
"test:watch": "vitest",
|
|
26
26
|
"bench": "node scripts/benchmark-toon.mjs",
|
|
27
27
|
"bench:impact": "node scripts/benchmark-impact.mjs",
|
|
28
|
+
"bench:context": "node scripts/bench-context-tools.mjs",
|
|
29
|
+
"bench:full": "node scripts/bench-full-impact.mjs",
|
|
28
30
|
"inspect": "npm run build && npx @modelcontextprotocol/inspector node bin/toon-memory.js mcp",
|
|
29
31
|
"prepublishOnly": "npm run build && npm test"
|
|
30
32
|
},
|
package/skills/toon-memory.md
CHANGED
|
@@ -35,9 +35,14 @@ A persistent memory system for AI coding agents. It remembers decisions, pattern
|
|
|
35
35
|
| `memory_summary` | Save/retrieve file summaries |
|
|
36
36
|
| `memory_archive` | Archive old entries and expired TTL entries |
|
|
37
37
|
| `memory_diff` | Show changes since a date (24h, 7d, or exact date) |
|
|
38
|
+
| `memory_smart_recall` | Unified retrieval: BM25 + graph + decay + quality in one call (use at session start) |
|
|
38
39
|
| `memory_suggest` | Find related entries for a given context |
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
40
|
+
| `memory_captured` | Show activity log captured automatically by hooks |
|
|
41
|
+
| `memory_consolidate` | Deduplicate identical entries (keeps first, deterministic, no LLM) |
|
|
42
|
+
| `memory_sessions` | Show active agent sessions and detect file conflicts |
|
|
43
|
+
| `context_brief` | One-call context briefing: memory + sessions + health in compact markdown |
|
|
44
|
+
| `memory_encrypt` | Enable AES-256-GCM encryption |
|
|
45
|
+
| `memory_decrypt` | Disable encryption and decode memory |
|
|
41
46
|
|
|
42
47
|
## MCP Resources
|
|
43
48
|
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs"
|
|
2
|
+
import { dirname, join } from "path"
|
|
3
|
+
import type { Agent } from "./types"
|
|
4
|
+
import { HOME, projectRoot } from "./constants"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolve this package's package.json by walking up from the module location.
|
|
8
|
+
* Setup logic may run from dist/cli/setup.js, so a fixed relative path is wrong.
|
|
9
|
+
*/
|
|
10
|
+
export function resolvePackageJson(): string | null {
|
|
11
|
+
let dir = dirname(process.argv[1] || ".")
|
|
12
|
+
while (true) {
|
|
13
|
+
const candidate = join(dir, "package.json")
|
|
14
|
+
if (existsSync(candidate)) {
|
|
15
|
+
try {
|
|
16
|
+
const p = JSON.parse(readFileSync(candidate, "utf-8"))
|
|
17
|
+
if (p && p.name === "toon-memory") return candidate
|
|
18
|
+
} catch {
|
|
19
|
+
// ignore and keep walking
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const parent = dirname(dir)
|
|
23
|
+
if (parent === dir) return null
|
|
24
|
+
dir = parent
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Detect all supported AI coding agents on the system.
|
|
30
|
+
*
|
|
31
|
+
* Scans for configuration files in both global (~/.config/) and local
|
|
32
|
+
* (.opencode/, .vscode/, etc.) locations.
|
|
33
|
+
*/
|
|
34
|
+
export function detectAgents(): Agent[] {
|
|
35
|
+
const agents: Agent[] = []
|
|
36
|
+
|
|
37
|
+
agents.push({
|
|
38
|
+
name: "opencode",
|
|
39
|
+
global: join(HOME, ".config", "opencode", "opencode.json"),
|
|
40
|
+
local: join(projectRoot, ".opencode", "opencode.json"),
|
|
41
|
+
mcpKey: "mcp",
|
|
42
|
+
format: "json",
|
|
43
|
+
needsHooks: false,
|
|
44
|
+
needsPlugin: true,
|
|
45
|
+
needsInstructions: true,
|
|
46
|
+
instructionFile: join(projectRoot, "AGENTS.md")
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
agents.push({
|
|
50
|
+
name: "vscode/copilot",
|
|
51
|
+
local: join(projectRoot, ".vscode", "mcp.json"),
|
|
52
|
+
mcpKey: "servers",
|
|
53
|
+
format: "json",
|
|
54
|
+
needsHooks: false,
|
|
55
|
+
needsInstructions: false
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
agents.push({
|
|
59
|
+
name: "claude",
|
|
60
|
+
global: join(HOME, ".claude", "settings.json"),
|
|
61
|
+
local: join(projectRoot, ".claude", "settings.json"),
|
|
62
|
+
mcpKey: "mcpServers",
|
|
63
|
+
format: "json",
|
|
64
|
+
needsHooks: true,
|
|
65
|
+
needsInstructions: true,
|
|
66
|
+
instructionFile: join(projectRoot, ".claude", "AGENTS.md"),
|
|
67
|
+
captureJson: ["PostToolUse", "Stop"]
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
agents.push({
|
|
71
|
+
name: "cursor",
|
|
72
|
+
local: join(projectRoot, ".cursor", "mcp.json"),
|
|
73
|
+
mcpKey: "mcpServers",
|
|
74
|
+
format: "json",
|
|
75
|
+
needsHooks: false,
|
|
76
|
+
needsInstructions: false
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
agents.push({
|
|
80
|
+
name: "windsurf",
|
|
81
|
+
global: join(HOME, ".codeium", "windsurf", "mcp_config.json"),
|
|
82
|
+
mcpKey: "mcpServers",
|
|
83
|
+
format: "json",
|
|
84
|
+
needsHooks: false,
|
|
85
|
+
needsInstructions: false
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
agents.push({
|
|
89
|
+
name: "cline",
|
|
90
|
+
local: join(projectRoot, ".cline", "mcp.json"),
|
|
91
|
+
mcpKey: "mcpServers",
|
|
92
|
+
format: "json",
|
|
93
|
+
needsHooks: false,
|
|
94
|
+
needsInstructions: false
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
agents.push({
|
|
98
|
+
name: "continue",
|
|
99
|
+
local: join(projectRoot, ".continue", "config.json"),
|
|
100
|
+
mcpKey: "mcpServers",
|
|
101
|
+
format: "json",
|
|
102
|
+
needsHooks: false,
|
|
103
|
+
needsInstructions: false
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
agents.push({
|
|
107
|
+
name: "codex",
|
|
108
|
+
local: join(projectRoot, ".codex", "config.toml"),
|
|
109
|
+
mcpKey: "mcpServers",
|
|
110
|
+
format: "toml",
|
|
111
|
+
needsHooks: true,
|
|
112
|
+
needsInstructions: true,
|
|
113
|
+
instructionFile: join(projectRoot, ".codex", "AGENTS.md"),
|
|
114
|
+
captureToml: ["PostToolUse", "Stop"]
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
agents.push({
|
|
118
|
+
name: "gemini",
|
|
119
|
+
local: join(projectRoot, ".gemini", "settings.json"),
|
|
120
|
+
mcpKey: "mcpServers",
|
|
121
|
+
format: "json",
|
|
122
|
+
needsHooks: true,
|
|
123
|
+
needsInstructions: true,
|
|
124
|
+
instructionFile: join(projectRoot, ".gemini", "GEMINI.md")
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
agents.push({
|
|
128
|
+
name: "zed",
|
|
129
|
+
global: join(HOME, ".config", "zed", "settings.json"),
|
|
130
|
+
mcpKey: "mcp_servers",
|
|
131
|
+
format: "jsonc",
|
|
132
|
+
needsHooks: false,
|
|
133
|
+
needsInstructions: false
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
agents.push({
|
|
137
|
+
name: "antigravity",
|
|
138
|
+
local: join(projectRoot, ".gemini", "config", "mcp_config.json"),
|
|
139
|
+
mcpKey: "mcpServers",
|
|
140
|
+
format: "json",
|
|
141
|
+
needsHooks: true,
|
|
142
|
+
needsInstructions: true,
|
|
143
|
+
instructionFile: join(projectRoot, "antigravity-cli", "AGENTS.md")
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
agents.push({
|
|
147
|
+
name: "aider",
|
|
148
|
+
mcpKey: "",
|
|
149
|
+
format: "none",
|
|
150
|
+
needsHooks: false,
|
|
151
|
+
needsInstructions: true,
|
|
152
|
+
instructionFile: join(projectRoot, "CONVENTIONS.md")
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
agents.push({
|
|
156
|
+
name: "kilocode",
|
|
157
|
+
global: join(HOME, ".kilocode", "mcp_settings.json"),
|
|
158
|
+
mcpKey: "mcpServers",
|
|
159
|
+
format: "json",
|
|
160
|
+
needsHooks: false,
|
|
161
|
+
needsInstructions: true,
|
|
162
|
+
instructionFile: join(HOME, ".kilocode", "rules", "toon-memory.md")
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
agents.push({
|
|
166
|
+
name: "openclaw",
|
|
167
|
+
local: join(projectRoot, ".openclaw.json"),
|
|
168
|
+
mcpKey: "mcpServers",
|
|
169
|
+
format: "json",
|
|
170
|
+
needsHooks: false,
|
|
171
|
+
needsInstructions: false
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
agents.push({
|
|
175
|
+
name: "kiro",
|
|
176
|
+
local: join(projectRoot, ".kiro", "settings", "mcp.json"),
|
|
177
|
+
mcpKey: "mcpServers",
|
|
178
|
+
format: "json",
|
|
179
|
+
needsHooks: false,
|
|
180
|
+
needsInstructions: false
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return agents
|
|
184
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
|
|
2
|
+
import { MEMORY_DIR, CAPTURE_CONFIG } from "./constants"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enable or disable activity capture (the opt-in hook log).
|
|
6
|
+
*/
|
|
7
|
+
export function captureToggle(enable: boolean): void {
|
|
8
|
+
if (!existsSync(MEMORY_DIR)) mkdirSync(MEMORY_DIR, { recursive: true })
|
|
9
|
+
|
|
10
|
+
let config: Record<string, any> = {}
|
|
11
|
+
if (existsSync(CAPTURE_CONFIG)) {
|
|
12
|
+
try {
|
|
13
|
+
config = JSON.parse(readFileSync(CAPTURE_CONFIG, "utf-8"))
|
|
14
|
+
} catch {
|
|
15
|
+
config = {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
config.capture = enable
|
|
20
|
+
writeFileSync(CAPTURE_CONFIG, JSON.stringify(config, null, 2))
|
|
21
|
+
|
|
22
|
+
if (enable) {
|
|
23
|
+
console.log("\n🔴 Captura de actividad HABILITADA.")
|
|
24
|
+
console.log("Los hooks grabarán observaciones en .toon-memory/memory/observations.toon.")
|
|
25
|
+
console.log("Revisa con `memory_captured` y promuévelas con `memory_remember`.\n")
|
|
26
|
+
} else {
|
|
27
|
+
console.log("\n⚪ Captura de actividad DESHABILITADA.\n")
|
|
28
|
+
}
|
|
29
|
+
}
|