toon-memory 4.3.0 → 4.3.2
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.de.md +2 -2
- package/README.es.md +2 -2
- package/README.fr.md +2 -2
- package/README.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +2 -2
- package/README.pt-br.md +2 -2
- package/README.zh.md +2 -2
- package/bin/toon-memory.js +18 -7
- package/dist/cli/setup.js +113 -56
- package/dist/cli/toon-memory.js +12 -3
- package/install.ps1 +25 -15
- package/mcp/server.js +109 -13
- package/package.json +3 -3
- package/src/bin/toon-memory.ts +3 -2
- package/src/cli/commands.ts +5 -3
- package/src/cli/config-writer.ts +34 -23
- package/src/cli/constants.ts +7 -4
- package/src/cli/entry.ts +11 -0
- package/src/cli/hooks.ts +33 -11
- package/src/cli/opencode-plugin.ts +57 -18
- package/src/cli/toon-memory.ts +4 -3
- package/src/lib/graph.ts +66 -0
- package/src/mcp/archive.ts +16 -6
- package/src/mcp/tools.ts +56 -7
package/README.de.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Die Kontinuitätsebene für KI-Agenten — KI-Agenten sollten dein Projekt nicht jede Sitzung neu lernen müssen.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
Kannst du dich an diesen Moment erinnern, in dem dein KI-Agent alles aus der Sitzung von gestern vergessen hat? Du erklärst zum dritten Mal dieselbe Architekturentscheidung, und er schlägt immer noch den Ansatz vor, den du bereits abgelehnt hast?
|
|
43
43
|
|
|
44
|
-
**toon-memory löst dieses Problem.** Es
|
|
44
|
+
**toon-memory löst dieses Problem.** Es ist die Kontinuitätsebene für KI-Agenten — ein leichtes System, das das Wissen, die Entscheidungen und die Konventionen deines Projekts zwischen den Sitzungen bewahrt, damit jede Sitzung dort beginnt, wo die letzte endete. 100% lokal und privat, über MCP — kein Cloud, kein Server.
|
|
45
45
|
|
|
46
46
|
📖 **[Dokumentation lesen](https://luiggival08.github.io/toon-memory/)**
|
|
47
47
|
|
package/README.es.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> La capa de continuidad para agentes de IA — los agentes de IA no deberían tener que reaprender tu proyecto en cada sesión.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
¿Alguna vez has tenido esa sensación donde tu agente de IA olvida todo de la sesión de ayer? Explicas la misma decisión de arquitectura por tercera vez, y aún así sugiere el enfoque que ya rechazaste?
|
|
43
43
|
|
|
44
|
-
**toon-memory soluciona esto.**
|
|
44
|
+
**toon-memory soluciona esto.** Es la capa de continuidad para agentes de IA — un sistema ligero que conserva el conocimiento, las decisiones y las convenciones de tu proyecto entre sesiones, para que cada sesión empiece donde terminó la anterior. 100% local y privado, vía MCP — sin nube, sin servidor.
|
|
45
45
|
|
|
46
46
|
📖 **[Lee la documentación](https://luiggival08.github.io/toon-memory/)**
|
|
47
47
|
|
package/README.fr.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> La couche de continuité pour les agents IA — les agents IA ne devraient pas avoir à réapprendre votre projet à chaque session.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
Vous avez déjà vécu cette situation où votre agent IA oublie tout de la session d'hier ? Vous lui réexpliquez la même décision d'architecture pour la troisième fois, et il propose encore l'approche que vous avez déjà rejetée ?
|
|
42
42
|
|
|
43
|
-
**toon-memory résout ce problème.**
|
|
43
|
+
**toon-memory résout ce problème.** C'est la couche de continuité pour les agents IA — un système léger qui préserve le savoir, les décisions et les conventions de votre projet entre les sessions, pour que chaque session commence là où la précédente s'est arrêtée. 100% local et privé, via MCP — sans cloud, sans serveur.
|
|
44
44
|
|
|
45
45
|
📖 **[Lire la documentation](https://luiggival08.github.io/toon-memory/)**
|
|
46
46
|
|
package/README.ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
> AI
|
|
5
|
+
> AIエージェントのための継続性レイヤー — AIエージェントは毎セッションでプロジェクトを学び直すべきではありません。
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
AIエージェントが昨日のセッションの内容を全て忘れてしまう経験はありますか?同じアーキテクチャの意思決定を3回目の説明しても、すでに却下したアプローチを再び提案されてしまう……
|
|
41
41
|
|
|
42
|
-
**toon-memoryはこの問題を解決します。**
|
|
42
|
+
**toon-memoryはこの問題を解決します。** AIエージェントのための継続性レイヤー — セッションをまたいでプロジェクトの知識・決定・規約を保存する軽量システムで、各セッションが前回の終わりから始まります。100% ローカルでプライベート、MCP 経由 — クラウドもサーバーも不要。
|
|
43
43
|
|
|
44
44
|
📖 **[ドキュメントを読む](https://luiggival08.github.io/toon-memory/)**
|
|
45
45
|
|
package/README.ko.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> AI 에이전트를 위한 연속성 레이어 — AI 에이전트는 매 세션마다 프로젝트를 다시 배우지 않아야 합니다.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
어제 세션에서 AI 에이전트가 모든 것을 잊어버린 경험 있으신가요? 같은 아키텍처 결정을 세 번째로 설명하는데, 이미 거절한 접근법을 또 제안하나요?
|
|
43
43
|
|
|
44
|
-
**toon-memory는 이 문제를 해결합니다.** AI
|
|
44
|
+
**toon-memory는 이 문제를 해결합니다.** AI 에이전트를 위한 연속성 레이어 — 세션 간에 프로젝트의 지식, 결정, 관례를 보존하는 가벼운 시스템으로, 모든 세션이 이전 세션이 끝난 곳에서 시작됩니다. 100% 로컬 및 프라이빗, MCP 기반 — 클라우드도 서버도 필요 없습니다.
|
|
45
45
|
|
|
46
46
|
📖 **[문서 읽기](https://luiggival08.github.io/toon-memory/)**
|
|
47
47
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> The Continuity Layer for AI Agents — AI agents shouldn't have to relearn your project every session.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
Ever had that feeling where your AI agent forgets everything from yesterday's session? You explain the same architecture decision for the third time, and it still suggests the approach you already rejected?
|
|
42
42
|
|
|
43
|
-
**toon-memory fixes this.** It
|
|
43
|
+
**toon-memory fixes this.** It's the Continuity Layer for AI Agents — a lightweight system that preserves your project's knowledge, decisions, and conventions across sessions, so every session starts where the last one ended. Fully local and private, over MCP — no cloud, no server.
|
|
44
44
|
|
|
45
45
|
📖 **[Read the documentation](https://luiggival08.github.io/toon-memory/)**
|
|
46
46
|
|
package/README.pt-br.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> A camada de continuidade para agentes de IA — agentes de IA não deveriam ter que reaprender seu projeto a cada sessão.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
Já teve aquela sensação de que seu agente de IA esquece tudo da sessão de ontem? Você explica a mesma decisão de arquitetura pela terceira vez e ele ainda sugere a abordagem que você já rejeitou?
|
|
41
41
|
|
|
42
|
-
**toon-memory resolve isso.**
|
|
42
|
+
**toon-memory resolve isso.** É a camada de continuidade para agentes de IA — um sistema leve que preserva o conhecimento, as decisões e as convenções do seu projeto entre sessões, para que cada sessão comece onde a anterior terminou. 100% local e privado, via MCP — sem nuvem, sem servidor.
|
|
43
43
|
|
|
44
44
|
📖 **[Leia a documentação](https://luiggival08.github.io/toon-memory/)**
|
|
45
45
|
|
package/README.zh.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toon-memory
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> AI 代理的连续性层 — AI 代理不应在每个会话中重新学习你的项目。
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/toon-memory)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
你是否有过这样的经历:AI 助手完全忘记了昨天会话中的内容?你不得不第三次解释同一个架构决策,而它仍然建议你已经否决的方案?
|
|
42
42
|
|
|
43
|
-
**toon-memory 解决了这个问题。**
|
|
43
|
+
**toon-memory 解决了这个问题。** 它是 AI 代理的连续性层 — 一个轻量系统,在会话之间保存你项目的知识、决策和约定,让每个会话都从上次结束的地方开始。100% 本地且私密,通过 MCP — 无需云、无需服务器。
|
|
44
44
|
|
|
45
45
|
📖 **[阅读文档](https://luiggival08.github.io/toon-memory/)**
|
|
46
46
|
|
package/bin/toon-memory.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/bin/toon-memory.ts
|
|
4
|
+
import { dirname, join as join2 } from "path";
|
|
3
5
|
import { readFileSync } from "fs";
|
|
4
6
|
import { fileURLToPath } from "url";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
// src/cli/entry.ts
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
import { pathToFileURL } from "url";
|
|
11
|
+
function fileImportURL(dirname2, ...parts) {
|
|
12
|
+
return pathToFileURL(join(dirname2, ...parts)).href;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/bin/toon-memory.ts
|
|
16
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
var args = process.argv.slice(2);
|
|
7
18
|
function getVersion() {
|
|
8
19
|
try {
|
|
9
|
-
const pkg = JSON.parse(readFileSync(
|
|
20
|
+
const pkg = JSON.parse(readFileSync(join2(__dirname, "..", "package.json"), "utf-8"));
|
|
10
21
|
return pkg.version || "unknown";
|
|
11
22
|
} catch {
|
|
12
23
|
return "unknown";
|
|
13
24
|
}
|
|
14
25
|
}
|
|
15
|
-
|
|
26
|
+
var HELP = `toon-memory \u2014 MCP memory server for AI coding agents
|
|
16
27
|
|
|
17
28
|
Usage:
|
|
18
29
|
toon-memory <command> [options]
|
|
@@ -49,8 +60,8 @@ if (args[0] === "-h" || args[0] === "--help") {
|
|
|
49
60
|
process.exit(0);
|
|
50
61
|
}
|
|
51
62
|
if (args[0] === "mcp") {
|
|
52
|
-
await import(
|
|
63
|
+
await import(fileImportURL(__dirname, "..", "mcp", "server.js"));
|
|
53
64
|
} else {
|
|
54
65
|
process.argv = ["node", "toon-memory", ...args];
|
|
55
|
-
await import(
|
|
66
|
+
await import(fileImportURL(__dirname, "..", "dist", "cli", "setup.js"));
|
|
56
67
|
}
|
package/dist/cli/setup.js
CHANGED
|
@@ -3,10 +3,11 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
3
3
|
|
|
4
4
|
// src/cli/constants.ts
|
|
5
5
|
import { dirname, join } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
6
7
|
var projectRoot = process.cwd();
|
|
7
8
|
var HOME = process.env.HOME || process.env.USERPROFILE || "~";
|
|
8
9
|
var MEMORY_DIR = join(projectRoot, ".toon-memory", "memory");
|
|
9
|
-
var scriptDir = dirname(
|
|
10
|
+
var scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
var CAPTURE_JS = join(scriptDir, "capture.js");
|
|
11
12
|
var SESSION_START_JS = join(scriptDir, "session-start.js");
|
|
12
13
|
var CAPTURE_CONFIG = join(MEMORY_DIR, "config.json");
|
|
@@ -421,6 +422,14 @@ function dumpMemoryMarkdown() {
|
|
|
421
422
|
// src/cli/config-writer.ts
|
|
422
423
|
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
423
424
|
import { dirname as dirname3 } from "path";
|
|
425
|
+
function loadJSON(file) {
|
|
426
|
+
if (!existsSync5(file)) return {};
|
|
427
|
+
try {
|
|
428
|
+
return JSON.parse(readFileSync5(file, "utf-8"));
|
|
429
|
+
} catch {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
424
433
|
function installJSONConfig(agent, scope) {
|
|
425
434
|
const configPath = scope === "global" ? agent.global : agent.local;
|
|
426
435
|
if (!configPath) {
|
|
@@ -429,13 +438,10 @@ function installJSONConfig(agent, scope) {
|
|
|
429
438
|
}
|
|
430
439
|
const configDir = dirname3(configPath);
|
|
431
440
|
if (!existsSync5(configDir)) mkdirSync3(configDir, { recursive: true });
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
} catch {
|
|
437
|
-
config = {};
|
|
438
|
-
}
|
|
441
|
+
const config = loadJSON(configPath);
|
|
442
|
+
if (config === null) {
|
|
443
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
444
|
+
return;
|
|
439
445
|
}
|
|
440
446
|
const mcpKey = agent.mcpKey || "mcpServers";
|
|
441
447
|
if (!config[mcpKey]) config[mcpKey] = {};
|
|
@@ -483,9 +489,13 @@ function installZedConfig(agent) {
|
|
|
483
489
|
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
484
490
|
config = JSON.parse(stripped);
|
|
485
491
|
} catch {
|
|
486
|
-
config =
|
|
492
|
+
config = null;
|
|
487
493
|
}
|
|
488
494
|
}
|
|
495
|
+
if (config === null) {
|
|
496
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
489
499
|
if (!config.context_servers) config.context_servers = {};
|
|
490
500
|
config.context_servers["toon-memory"] = {
|
|
491
501
|
command: "npx",
|
|
@@ -500,13 +510,10 @@ function installContinueConfig(agent) {
|
|
|
500
510
|
if (!configPath) return;
|
|
501
511
|
const configDir = dirname3(configPath);
|
|
502
512
|
if (!existsSync5(configDir)) mkdirSync3(configDir, { recursive: true });
|
|
503
|
-
|
|
504
|
-
if (
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
} catch {
|
|
508
|
-
config = {};
|
|
509
|
-
}
|
|
513
|
+
const config = loadJSON(configPath);
|
|
514
|
+
if (config === null) {
|
|
515
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
516
|
+
return;
|
|
510
517
|
}
|
|
511
518
|
if (!config.experimental) config.experimental = {};
|
|
512
519
|
if (!config.experimental.modelContextProtocolServers) {
|
|
@@ -534,13 +541,10 @@ function installOpenClawConfig(agent) {
|
|
|
534
541
|
if (!configPath) return;
|
|
535
542
|
const configDir = dirname3(configPath);
|
|
536
543
|
if (!existsSync5(configDir)) mkdirSync3(configDir, { recursive: true });
|
|
537
|
-
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
} catch {
|
|
542
|
-
config = {};
|
|
543
|
-
}
|
|
544
|
+
const config = loadJSON(configPath);
|
|
545
|
+
if (config === null) {
|
|
546
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
547
|
+
return;
|
|
544
548
|
}
|
|
545
549
|
if (!config.mcp) config.mcp = {};
|
|
546
550
|
if (!config.mcp.servers) config.mcp.servers = {};
|
|
@@ -611,6 +615,14 @@ ${content}`);
|
|
|
611
615
|
// src/cli/hooks.ts
|
|
612
616
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5, chmodSync } from "fs";
|
|
613
617
|
import { dirname as dirname5, join as join5 } from "path";
|
|
618
|
+
function readJSON(file) {
|
|
619
|
+
if (!existsSync7(file)) return {};
|
|
620
|
+
try {
|
|
621
|
+
return JSON.parse(readFileSync7(file, "utf-8"));
|
|
622
|
+
} catch {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
614
626
|
function sessionStartHookContent(agentName) {
|
|
615
627
|
return `#!/bin/bash
|
|
616
628
|
# toon-memory session-start hook for ${agentName}
|
|
@@ -665,13 +677,10 @@ function registerCaptureHookJSON(agent, scriptPath) {
|
|
|
665
677
|
if (!configPath) return;
|
|
666
678
|
const configDir = dirname5(configPath);
|
|
667
679
|
if (!existsSync7(configDir)) mkdirSync5(configDir, { recursive: true });
|
|
668
|
-
|
|
669
|
-
if (
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
} catch {
|
|
673
|
-
config = {};
|
|
674
|
-
}
|
|
680
|
+
const config = readJSON(configPath);
|
|
681
|
+
if (config === null) {
|
|
682
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
683
|
+
return;
|
|
675
684
|
}
|
|
676
685
|
if (!config.hooks) config.hooks = {};
|
|
677
686
|
for (const event of agent.captureJson || []) {
|
|
@@ -730,9 +739,13 @@ function registerHookJSON(agent, hookPath) {
|
|
|
730
739
|
config = JSON.parse(readFileSync7(configPath, "utf-8"));
|
|
731
740
|
}
|
|
732
741
|
} catch {
|
|
733
|
-
config =
|
|
742
|
+
config = null;
|
|
734
743
|
}
|
|
735
744
|
}
|
|
745
|
+
if (config === null) {
|
|
746
|
+
console.log(` \u26A0\uFE0F Skipping ${configPath}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
736
749
|
if (agent.name === "claude" || agent.name === "gemini") {
|
|
737
750
|
if (!config.hooks) config.hooks = {};
|
|
738
751
|
if (!config.hooks.SessionStart) config.hooks.SessionStart = [];
|
|
@@ -763,9 +776,13 @@ function registerAntigravityHooks(agent) {
|
|
|
763
776
|
try {
|
|
764
777
|
cfg = JSON.parse(readFileSync7(hooksFile, "utf-8"));
|
|
765
778
|
} catch {
|
|
766
|
-
cfg =
|
|
779
|
+
cfg = null;
|
|
767
780
|
}
|
|
768
781
|
}
|
|
782
|
+
if (cfg === null) {
|
|
783
|
+
console.log(` \u26A0\uFE0F Skipping ${hooksFile}: existing file is not valid JSON \u2014 fix it manually, then re-run.`);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
769
786
|
cfg[ANTIGRAVITY_HOOK_NAME] = {
|
|
770
787
|
PreInvocation: [{ type: "command", command: sessionPath }],
|
|
771
788
|
PostToolUse: [{ matcher: "*", hooks: [{ type: "command", command: capPath }] }],
|
|
@@ -794,6 +811,7 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
794
811
|
const recall = async (query, opts = {}) => {
|
|
795
812
|
try {
|
|
796
813
|
const args = { query, mode: "flat", budget: opts.budget || "tiny", path_scope: opts.path_scope || "" }
|
|
814
|
+
if (opts.category) args.category = opts.category
|
|
797
815
|
const result = await $\`npx -y toon-memory mcp\`.cwd(root)
|
|
798
816
|
.stdin(JSON.stringify({
|
|
799
817
|
jsonrpc: "2.0",
|
|
@@ -807,11 +825,44 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
807
825
|
} catch { return "" }
|
|
808
826
|
}
|
|
809
827
|
|
|
828
|
+
// Pre-edit risk surfacing: warning-category entries scoped to a file path.
|
|
829
|
+
// Injected as a distinct block so the agent sees known risks before it edits.
|
|
830
|
+
const risks = async (filePath) => {
|
|
831
|
+
return await recall(filePath, { budget: "tiny", path_scope: filePath, category: "warning" })
|
|
832
|
+
}
|
|
833
|
+
|
|
810
834
|
const write = (text) => {
|
|
811
835
|
fs.mkdirSync(INS, { recursive: true })
|
|
812
836
|
fs.writeFileSync(OUT, text)
|
|
813
837
|
}
|
|
814
838
|
|
|
839
|
+
const pickPath = (args) => {
|
|
840
|
+
if (!args) return ""
|
|
841
|
+
if (args.file) return args.file
|
|
842
|
+
if (args.path) return args.path
|
|
843
|
+
if (args.filePath) return args.filePath
|
|
844
|
+
if (args.target) return args.target
|
|
845
|
+
return ""
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
const buildQuery = (filePath) => {
|
|
849
|
+
const basename = path.basename(filePath, path.extname(filePath))
|
|
850
|
+
const dirParts = path.dirname(filePath).split(path.sep).filter(Boolean)
|
|
851
|
+
return [basename, ...dirParts.slice(-2)].join(" ")
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const inject = (ctx, key, text) => {
|
|
855
|
+
if (!text || text.includes("(empty)") || text.includes("No results")) return
|
|
856
|
+
if (typeof ctx?.setContext === "function") ctx.setContext(key, text)
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// Edit/write-ish tools are where known risks matter most.
|
|
860
|
+
const isEditTool = (name) => {
|
|
861
|
+
if (!name) return false
|
|
862
|
+
return name === "edit" || name === "write" || name === "apply-patch" ||
|
|
863
|
+
name.includes("edit") || name.includes("write") || name.includes("patch")
|
|
864
|
+
}
|
|
865
|
+
|
|
815
866
|
return {
|
|
816
867
|
"session.created": async () => {
|
|
817
868
|
try {
|
|
@@ -825,6 +876,19 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
825
876
|
if (Array.isArray(output?.context)) output.context.push(out)
|
|
826
877
|
} catch {}
|
|
827
878
|
},
|
|
879
|
+
"tool.execute.before": async (input, output) => {
|
|
880
|
+
// Pre-edit risk surfacing: for edit/write tools, surface known
|
|
881
|
+
// warning entries for the target file BEFORE the tool runs.
|
|
882
|
+
try {
|
|
883
|
+
const toolName = input?.tool || ""
|
|
884
|
+
if (!isEditTool(toolName)) return
|
|
885
|
+
const args = output?.args || input?.args || {}
|
|
886
|
+
const filePath = pickPath(args)
|
|
887
|
+
if (!filePath) return
|
|
888
|
+
const text = await risks(filePath)
|
|
889
|
+
inject(input, "toon-memory:risks:" + filePath, "\u26A0 KNOWN RISKS for " + filePath + ":\\n" + text)
|
|
890
|
+
} catch {}
|
|
891
|
+
},
|
|
828
892
|
"tool.execute.after": async (input) => {
|
|
829
893
|
// Intelligent auto-loading: extract file path from tool result,
|
|
830
894
|
// recall only memory relevant to that file, inject as context.
|
|
@@ -834,11 +898,7 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
834
898
|
const args = input?.args || {}
|
|
835
899
|
|
|
836
900
|
// Extract file path from tool arguments or output
|
|
837
|
-
let filePath =
|
|
838
|
-
if (args.file) filePath = args.file
|
|
839
|
-
else if (args.path) filePath = args.path
|
|
840
|
-
else if (args.filePath) filePath = args.filePath
|
|
841
|
-
else if (args.target) filePath = args.target
|
|
901
|
+
let filePath = pickPath(args)
|
|
842
902
|
|
|
843
903
|
// Also try to extract from tool output text
|
|
844
904
|
if (!filePath && input?.output) {
|
|
@@ -849,15 +909,15 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
849
909
|
|
|
850
910
|
if (filePath) {
|
|
851
911
|
// Build recall query from file path components
|
|
852
|
-
const
|
|
853
|
-
const dirParts = path.dirname(filePath).split(path.sep).filter(Boolean)
|
|
854
|
-
const query = [basename, ...dirParts.slice(-2)].join(" ")
|
|
855
|
-
|
|
912
|
+
const query = buildQuery(filePath)
|
|
856
913
|
const text = await recall(query, { budget: "tiny", path_scope: filePath })
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
914
|
+
inject(input, "toon-memory:" + filePath, text)
|
|
915
|
+
|
|
916
|
+
// Pre-edit risk block for edit/write tools (same key as the before
|
|
917
|
+
// hook \u2014 setContext overwrites, so no duplication when both fire).
|
|
918
|
+
if (isEditTool(toolName)) {
|
|
919
|
+
const riskText = await risks(filePath)
|
|
920
|
+
inject(input, "toon-memory:risks:" + filePath, "\u26A0 KNOWN RISKS for " + filePath + ":\\n" + riskText)
|
|
861
921
|
}
|
|
862
922
|
}
|
|
863
923
|
|
|
@@ -875,11 +935,7 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
|
|
|
875
935
|
|
|
876
936
|
if (toolKeywords.length > 3) {
|
|
877
937
|
const text = await recall(toolKeywords, { budget: "tiny" })
|
|
878
|
-
|
|
879
|
-
if (typeof input?.setContext === "function") {
|
|
880
|
-
input.setContext("toon-memory:" + toolName, text)
|
|
881
|
-
}
|
|
882
|
-
}
|
|
938
|
+
inject(input, "toon-memory:" + toolName, text)
|
|
883
939
|
}
|
|
884
940
|
}
|
|
885
941
|
} catch {}
|
|
@@ -1274,14 +1330,15 @@ function importMemory() {
|
|
|
1274
1330
|
if (existsSync9(memoryFile)) {
|
|
1275
1331
|
const existing = readFileSync9(memoryFile, "utf-8");
|
|
1276
1332
|
const existingCount = existing.split("\n").filter((l) => l.startsWith(" ") && l.includes("|")).length;
|
|
1333
|
+
const newCount = existingCount + newEntries.length;
|
|
1277
1334
|
const updated = existing.replace(
|
|
1278
|
-
|
|
1279
|
-
|
|
1335
|
+
/^(version: 1\n)?(entries)?\[(\d+)\|/,
|
|
1336
|
+
(m, _v, prefix) => `${m.startsWith("version: 1\n") ? "version: 1\n" : ""}${prefix || ""}[${newCount}|`
|
|
1280
1337
|
) + "\n" + newLines;
|
|
1281
1338
|
writeFileSync7(memoryFile, updated);
|
|
1282
1339
|
} else {
|
|
1283
1340
|
writeFileSync7(memoryFile, `version: 1
|
|
1284
|
-
|
|
1341
|
+
[${newEntries.length}|]{id|category|key|content|file|tags|date}:
|
|
1285
1342
|
${newLines}
|
|
1286
1343
|
`);
|
|
1287
1344
|
}
|
|
@@ -1833,14 +1890,14 @@ function buildViewerData() {
|
|
|
1833
1890
|
// src/viewer/html.ts
|
|
1834
1891
|
import { readFileSync as readFileSync13 } from "fs";
|
|
1835
1892
|
import { resolve, dirname as dirname8 } from "path";
|
|
1836
|
-
import { fileURLToPath } from "url";
|
|
1893
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1837
1894
|
var d3Src = (() => {
|
|
1838
1895
|
try {
|
|
1839
|
-
const dir = dirname8(
|
|
1896
|
+
const dir = dirname8(fileURLToPath2(import.meta.url));
|
|
1840
1897
|
return readFileSync13(resolve(dir, "../src/viewer/d3.v7.min.js"), "utf-8");
|
|
1841
1898
|
} catch {
|
|
1842
1899
|
try {
|
|
1843
|
-
const dir = dirname8(
|
|
1900
|
+
const dir = dirname8(fileURLToPath2(import.meta.url));
|
|
1844
1901
|
return readFileSync13(resolve(dir, "d3.v7.min.js"), "utf-8");
|
|
1845
1902
|
} catch {
|
|
1846
1903
|
return null;
|
package/dist/cli/toon-memory.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
// src/cli/toon-memory.ts
|
|
2
|
-
import { dirname
|
|
2
|
+
import { dirname } from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
// src/cli/entry.ts
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import { pathToFileURL } from "url";
|
|
8
|
+
function fileImportURL(dirname2, ...parts) {
|
|
9
|
+
return pathToFileURL(join(dirname2, ...parts)).href;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/cli/toon-memory.ts
|
|
4
13
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
14
|
var args = process.argv.slice(2);
|
|
6
15
|
if (args[0] === "mcp") {
|
|
7
|
-
await import(
|
|
16
|
+
await import(fileImportURL(__dirname, "..", "mcp", "server.js"));
|
|
8
17
|
} else {
|
|
9
18
|
process.argv = ["node", "toon-memory", ...args];
|
|
10
|
-
await import(
|
|
19
|
+
await import(fileImportURL(__dirname, "..", "dist", "cli", "setup.js"));
|
|
11
20
|
}
|
package/install.ps1
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
# toon-memory installer for Windows (PowerShell)
|
|
2
2
|
# Usage: irm https://raw.githubusercontent.com/LuiggiVal08/toon-memory/main/install.ps1 | iex
|
|
3
3
|
|
|
4
|
-
$TOON_VERSION = "1.0.9"
|
|
5
|
-
# SHA-256 checksum of the tarball. Update on each release.
|
|
6
|
-
# Generate with: certutil -hashfile toon-memory-$TOON_VERSION.tgz SHA256
|
|
7
|
-
$TOON_CHECKSUM = "d5b2a8cbe0f3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9"
|
|
8
|
-
|
|
9
4
|
Write-Host "🧠 toon-memory installer" -ForegroundColor Cyan
|
|
10
5
|
Write-Host ""
|
|
11
6
|
|
|
7
|
+
# Resolve the latest version + integrity from the npm registry (mirrors install.sh)
|
|
8
|
+
try {
|
|
9
|
+
$meta = Invoke-RestMethod -Uri "https://registry.npmjs.org/toon-memory/latest" -ErrorAction Stop
|
|
10
|
+
$TOON_VERSION = $meta.version
|
|
11
|
+
$integrity = $meta.dist.integrity
|
|
12
|
+
} catch {
|
|
13
|
+
Write-Host "Error: Could not determine latest toon-memory version." -ForegroundColor Red
|
|
14
|
+
Write-Host "You can install manually: npm install -g toon-memory"
|
|
15
|
+
exit 1
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
# Check if npm is available
|
|
13
19
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
|
14
|
-
Write-Host "Installing toon-memory via npm..."
|
|
15
|
-
npm install -g toon-memory@$TOON_VERSION
|
|
20
|
+
Write-Host "Installing toon-memory v$TOON_VERSION via npm..."
|
|
21
|
+
npm install -g "toon-memory@$TOON_VERSION"
|
|
16
22
|
Write-Host ""
|
|
17
23
|
Write-Host "✅ toon-memory installed!" -ForegroundColor Green
|
|
18
24
|
Write-Host ""
|
|
@@ -35,15 +41,19 @@ if (Get-Command npm -ErrorAction SilentlyContinue) {
|
|
|
35
41
|
$tgzPath = "$INSTALL_DIR\toon-memory.tgz"
|
|
36
42
|
Invoke-WebRequest -Uri $url -OutFile $tgzPath
|
|
37
43
|
|
|
38
|
-
# Verify integrity
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
# Verify integrity (npm dist.integrity is "sha512-<base64>"; compare against SHA512 hex)
|
|
45
|
+
if ($integrity -and $integrity.StartsWith("sha512-")) {
|
|
46
|
+
$expectedHex = -join ([Convert]::FromBase64String($integrity.Substring(7)) | ForEach-Object { $_.ToString("x2") })
|
|
47
|
+
$actualHash = (Get-FileHash -Path $tgzPath -Algorithm SHA512).Hash.ToLower()
|
|
48
|
+
if ($actualHash -ne $expectedHex.ToLower()) {
|
|
49
|
+
Write-Host "❌ Integrity check failed! The downloaded file may be corrupted or tampered with." -ForegroundColor Red
|
|
50
|
+
Remove-Item -Path $tgzPath -Force
|
|
51
|
+
exit 1
|
|
52
|
+
}
|
|
53
|
+
Write-Host "✅ Integrity verified" -ForegroundColor Green
|
|
54
|
+
} else {
|
|
55
|
+
Write-Host "⚠️ No sha512 integrity available from the registry; skipping verification" -ForegroundColor Yellow
|
|
45
56
|
}
|
|
46
|
-
Write-Host "✅ Integrity verified" -ForegroundColor Green
|
|
47
57
|
|
|
48
58
|
# Extract
|
|
49
59
|
cd $INSTALL_DIR
|