toon-memory 1.6.8 → 1.6.9

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/mcp/server.js CHANGED
@@ -27648,7 +27648,6 @@ var MEMORY_DIR = join(process.cwd(), ".opencode", "memory");
27648
27648
  var MEMORY_FILE = join(MEMORY_DIR, "data.toon");
27649
27649
  var ARCHIVE_FILE = join(MEMORY_DIR, "archive.toon");
27650
27650
  var CONFIG_FILE = join(MEMORY_DIR, "config.json");
27651
- var ENV_FILE = join(MEMORY_DIR, ".env");
27652
27651
  var ARCHIVE_DAYS = 30;
27653
27652
  var ALGORITHM = "aes-256-gcm";
27654
27653
  function loadConfig() {
@@ -27665,20 +27664,8 @@ function saveConfig(config2) {
27665
27664
  ensureMemoryDir();
27666
27665
  writeFileSync(CONFIG_FILE, JSON.stringify(config2, null, 2));
27667
27666
  }
27668
- function readEnvKey() {
27669
- try {
27670
- if (!existsSync(ENV_FILE)) return void 0;
27671
- const content = readFileSync(ENV_FILE, "utf-8").trim();
27672
- const match = content.match(/^TOON_MEMORY_KEY=(.+)$/m);
27673
- return match ? match[1] : void 0;
27674
- } catch {
27675
- return void 0;
27676
- }
27677
- }
27678
- function writeEnvKey(key) {
27679
- ensureMemoryDir();
27680
- writeFileSync(ENV_FILE, `TOON_MEMORY_KEY=${key}
27681
- `);
27667
+ function getKey() {
27668
+ return process.env.TOON_MEMORY_KEY;
27682
27669
  }
27683
27670
  function ensureMemoryDir() {
27684
27671
  if (!existsSync(MEMORY_DIR)) mkdirSync(MEMORY_DIR, { recursive: true });
@@ -27717,7 +27704,7 @@ function readMemory() {
27717
27704
  const config2 = loadConfig();
27718
27705
  const data = readFileSync(MEMORY_FILE, "utf-8");
27719
27706
  if (config2.encrypted) {
27720
- const key = readEnvKey();
27707
+ const key = getKey();
27721
27708
  if (!key) return "";
27722
27709
  try {
27723
27710
  return decrypt(data, key);
@@ -27731,7 +27718,7 @@ function writeMemory(content) {
27731
27718
  ensureMemoryFile();
27732
27719
  const config2 = loadConfig();
27733
27720
  if (config2.encrypted) {
27734
- const key = readEnvKey();
27721
+ const key = getKey();
27735
27722
  if (!key) return;
27736
27723
  const encrypted = encrypt(content, key);
27737
27724
  writeFileSync(MEMORY_FILE, encrypted);
@@ -28043,9 +28030,13 @@ server.registerTool(
28043
28030
  const encrypted = encrypt(data, key);
28044
28031
  writeFileSync(MEMORY_FILE, encrypted);
28045
28032
  saveConfig({ encrypted: true });
28046
- writeEnvKey(key);
28047
28033
  return {
28048
- content: [{ type: "text", text: "\u{1F510} Encriptaci\xF3n habilitada" }]
28034
+ content: [{
28035
+ type: "text",
28036
+ text: `\u{1F510} Encriptaci\xF3n habilitada
28037
+ \u26A0\uFE0F Guarda esta clave en TOON_MEMORY_KEY (no se puede recuperar):
28038
+ ${key}`
28039
+ }]
28049
28040
  };
28050
28041
  }
28051
28042
  );
@@ -28063,7 +28054,7 @@ server.registerTool(
28063
28054
  if (!config2.encrypted) {
28064
28055
  return { content: [{ type: "text", text: "La encriptaci\xF3n no est\xE1 habilitada" }] };
28065
28056
  }
28066
- const resolvedKey = key || readEnvKey() || "";
28057
+ const resolvedKey = key || getKey() || "";
28067
28058
  if (!resolvedKey) {
28068
28059
  return { content: [{ type: "text", text: "\u274C No hay clave. P\xE1sala como argumento o la del archivo .env" }] };
28069
28060
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "description": "Persistent memory system for AI coding agents using TOON format (40% fewer tokens than JSON)",
5
5
  "type": "module",
6
6
  "bin": {
package/src/mcp/server.ts CHANGED
@@ -20,9 +20,6 @@ const ARCHIVE_FILE = join(MEMORY_DIR, "archive.toon")
20
20
  /** Configuration file for encryption settings */
21
21
  const CONFIG_FILE = join(MEMORY_DIR, "config.json")
22
22
 
23
- /** Env file storing the encryption key (gitignored via .opencode/) */
24
- const ENV_FILE = join(MEMORY_DIR, ".env")
25
-
26
23
  /** Maximum active entries before auto-archive */
27
24
  const MAX_ENTRIES = 100
28
25
 
@@ -73,29 +70,12 @@ function saveConfig(config: MemoryConfig): void {
73
70
  }
74
71
 
75
72
  /**
76
- * Read the encryption key from .env file.
73
+ * Get the encryption key from environment variable.
77
74
  *
78
75
  * @returns The key string, or undefined if not set
79
76
  */
80
- function readEnvKey(): string | undefined {
81
- try {
82
- if (!existsSync(ENV_FILE)) return undefined
83
- const content = readFileSync(ENV_FILE, "utf-8").trim()
84
- const match = content.match(/^TOON_MEMORY_KEY=(.+)$/m)
85
- return match ? match[1] : undefined
86
- } catch {
87
- return undefined
88
- }
89
- }
90
-
91
- /**
92
- * Write the encryption key to .env file.
93
- *
94
- * @param key - Hex-encoded encryption key
95
- */
96
- function writeEnvKey(key: string): void {
97
- ensureMemoryDir()
98
- writeFileSync(ENV_FILE, `TOON_MEMORY_KEY=${key}\n`)
77
+ function getKey(): string | undefined {
78
+ return process.env.TOON_MEMORY_KEY
99
79
  }
100
80
 
101
81
  /**
@@ -185,7 +165,7 @@ function readMemory(): string {
185
165
  const data = readFileSync(MEMORY_FILE, "utf-8")
186
166
 
187
167
  if (config.encrypted) {
188
- const key = readEnvKey()
168
+ const key = getKey()
189
169
  if (!key) return ""
190
170
  try {
191
171
  return decrypt(data, key)
@@ -208,7 +188,7 @@ function writeMemory(content: string): void {
208
188
  const config = loadConfig()
209
189
 
210
190
  if (config.encrypted) {
211
- const key = readEnvKey()
191
+ const key = getKey()
212
192
  if (!key) return
213
193
  const encrypted = encrypt(content, key)
214
194
  writeFileSync(MEMORY_FILE, encrypted)
@@ -683,10 +663,12 @@ server.registerTool(
683
663
  writeFileSync(MEMORY_FILE, encrypted)
684
664
 
685
665
  saveConfig({ encrypted: true })
686
- writeEnvKey(key)
687
666
 
688
667
  return {
689
- content: [{ type: "text" as const, text: "🔐 Encriptación habilitada" }],
668
+ content: [{
669
+ type: "text" as const,
670
+ text: `🔐 Encriptación habilitada\n⚠️ Guarda esta clave en TOON_MEMORY_KEY (no se puede recuperar):\n${key}`
671
+ }],
690
672
  }
691
673
  }
692
674
  )
@@ -717,7 +699,7 @@ server.registerTool(
717
699
  return { content: [{ type: "text" as const, text: "La encriptación no está habilitada" }] }
718
700
  }
719
701
 
720
- const resolvedKey = key || readEnvKey() || ""
702
+ const resolvedKey = key || getKey() || ""
721
703
  if (!resolvedKey) {
722
704
  return { content: [{ type: "text" as const, text: "❌ No hay clave. Pásala como argumento o la del archivo .env" }] }
723
705
  }