AIMindLink commited on
Commit
e3299f0
Β·
verified Β·
1 Parent(s): 2186dcb

Upload 3 files

Browse files

Added new slash-functions to restore memory and set the metronome time at runtime

Files changed (3) hide show
  1. README.md +38 -13
  2. config.py +8 -4
  3. main.py +118 -28
README.md CHANGED
@@ -11,7 +11,7 @@ license: apache-2.0
11
  # Lambda Mindlink Memotron
12
 
13
  **A three-hemisphere cognitive AI** architecture running entirely locally via `llama-cpp-python`:
14
- - 1 laptop 16GB-32GB (32GB for larger AIs and larger context)
15
  - 1 Terminal app (CMD app) with API included
16
  - Light-weight
17
  - Language: Python (SQLite internal database)
@@ -93,6 +93,9 @@ The `ai/` folder is excluded from git. GGUFs are never committed to this reposit
93
  - ~6 GB disk space per GGUF
94
 
95
  ---
 
 
 
96
 
97
  ## Installation β€” Linux (Debian/Ubuntu)
98
 
@@ -302,11 +305,13 @@ To deactivate the virtual environment when done:
302
  deactivate
303
  ```
304
 
 
305
  ---
306
 
307
  ## Slash Commands
308
 
309
- > **Note:** *You need to execute a command using an additional RETURN key-press (Example: /exit -> wait 3 seconds -> then RETURN)*
 
310
 
311
  | Command | Description |
312
  |---|---|
@@ -316,6 +321,10 @@ deactivate
316
  | `/history` | List all past sessions from the database |
317
  | `/session <id>` | Print all turns from a session |
318
  | `/export <id> <file>` | Export a session to a `.md` file |
 
 
 
 
319
  | `/help` | Show the command list |
320
  | `/exit` or `/quit` | Quit the app |
321
 
@@ -326,26 +335,28 @@ deactivate
326
  All settings are in `config.py`:
327
 
328
  ```python
 
329
  _ALPHA_INTELLIGENCE_TO_LOAD: dict = {
330
  "logic": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
331
  "muse": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
332
  "mind": "gemma-4-E2B-it-UD-Q4_K_XL.gguf"
333
  }
334
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
335
- N_METATRON_TO_LOAD: int = 2
336
- METATRON_METRONOME: int = 12 # Metatron Time
 
337
 
338
  # ── Context model n_ctx length ───────────────────────────────────────────────────
339
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
340
  _N_CTX: int = 49152 # 49152 2048 3072 4096 8192 (12288) 16384 24576 32768 49152
341
  # ── Context condensatron garden ──────────────────────────────────────────────────
342
- GARDEN_Z_THRESHOLD: int = 4096 # Context length garden["Z"]
343
- GARDEN_C_THRESHOLD: int = 4096 # Context length garden["C"]
344
- GARDEN_F_THRESHOLD: int = 4096 # Context length garden["F"]
345
 
346
- GARDEN_F_REDUCTION: int = 0 # Leave condensatron reduction level at 0
347
- GARDEN_C_REDUCTION: int = 0 # Leave condensatron reduction level at 0
348
  GARDEN_Z_REDUCTION: int = 0 # Leave condensatron reduction level at 0
 
 
349
 
350
  LEAVE_POSTS_IN_MEMOTRON = 0 # Must be turn based: 0, 2, 4, 6... (user + assistant)
351
 
@@ -355,8 +366,9 @@ FETCH_NEWS_FROM: dict = {
355
  "duckduckgo": False # Privacy based request but lean result summaries
356
  }
357
  ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
358
- AWARENESS_CONSCIOUSNESS_METRONOME: int = 60 # Fetch news every N heartbeats
359
  AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
 
360
  ```
361
 
362
  To swap AIs, update the `"_ALPHA_INTELLIGENCE_TO_LOAD"`, and the stop/think tokens at the top of `config.py`.
@@ -385,7 +397,7 @@ lambda-mindlink-memotron/
385
 
386
  ```
387
  heartbeats_startup timer:
388
- prompt/valka_memory.md ──► garden["C"] (pre-load memory capsules)
389
 
390
  Each turn:
391
  sensor["Z"] ──► Mindlink + Lambda ──► Memotron ──► garden["Z"]
@@ -414,15 +426,28 @@ if heartbeats:
414
 
415
  ## Database
416
 
417
- Each run creates a new SQLite database in `db/` named by timestamp:
418
  ```
419
- db/mindlink_2025-09-18_14-32-07.db
420
  ```
421
 
422
  Use `/history`, `/session <id>`, and `/export <id> <file>` to inspect and export sessions.
423
 
424
  ---
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  ## License
427
 
428
  Apache 2.0 β€” see `LICENSE`.
 
11
  # Lambda Mindlink Memotron
12
 
13
  **A three-hemisphere cognitive AI** architecture running entirely locally via `llama-cpp-python`:
14
+ - 1 Laptop 16GB-32GB (32GB for larger AIs and larger context)
15
  - 1 Terminal app (CMD app) with API included
16
  - Light-weight
17
  - Language: Python (SQLite internal database)
 
93
  - ~6 GB disk space per GGUF
94
 
95
  ---
96
+ ---
97
+
98
+ # Choose your installation for Linux (Debian/Ubuntu), Linux (Fedora/RedHat) or Windows
99
 
100
  ## Installation β€” Linux (Debian/Ubuntu)
101
 
 
305
  deactivate
306
  ```
307
 
308
+ ---
309
  ---
310
 
311
  ## Slash Commands
312
 
313
+ > **Note:** *To exit/quit the app, execute the command using an additional RETURN key-press*
314
+ > **Example:** */exit -> wait 3 seconds -> then RETURN*
315
 
316
  | Command | Description |
317
  |---|---|
 
321
  | `/history` | List all past sessions from the database |
322
  | `/session <id>` | Print all turns from a session |
323
  | `/export <id> <file>` | Export a session to a `.md` file |
324
+ | `/metatron <number>` | Set number of Memory Capsules to load |
325
+ | `/loaded <number>` | Set number of Memory Capsules loaded |
326
+ | `/metronome <seconds>` | Set awareness/consciousness interval |
327
+ | `/garden <save> or <load> or <clear>` | garden history handling |
328
  | `/help` | Show the command list |
329
  | `/exit` or `/quit` | Quit the app |
330
 
 
335
  All settings are in `config.py`:
336
 
337
  ```python
338
+ # ── AI to load for each hemisphere ───────────────────────────────────────────────
339
  _ALPHA_INTELLIGENCE_TO_LOAD: dict = {
340
  "logic": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
341
  "muse": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
342
  "mind": "gemma-4-E2B-it-UD-Q4_K_XL.gguf"
343
  }
344
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
345
+ METATRON_METRONOME: int = 60 # Startup Memory Capsules load interval
346
+ n_metatron_to_load = 0 # Set number of Memory Capsules to load (slash-command)
347
+ n_metatron_loaded = 0 # Start with n Memory Capsule to load (slash-command)
348
 
349
  # ── Context model n_ctx length ───────────────────────────────────────────────────
350
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
351
  _N_CTX: int = 49152 # 49152 2048 3072 4096 8192 (12288) 16384 24576 32768 49152
352
  # ── Context condensatron garden ──────────────────────────────────────────────────
353
+ GARDEN_Z_THRESHOLD: int = 12288 # Context length garden["Z"]
354
+ GARDEN_C_THRESHOLD: int = 12288 # Context length garden["C"]
355
+ GARDEN_F_THRESHOLD: int = 12288 # Context length garden["F"]
356
 
 
 
357
  GARDEN_Z_REDUCTION: int = 0 # Leave condensatron reduction level at 0
358
+ GARDEN_C_REDUCTION: int = 0 # Leave condensatron reduction level at 0
359
+ GARDEN_F_REDUCTION: int = 0 # Leave condensatron reduction level at 0
360
 
361
  LEAVE_POSTS_IN_MEMOTRON = 0 # Must be turn based: 0, 2, 4, 6... (user + assistant)
362
 
 
366
  "duckduckgo": False # Privacy based request but lean result summaries
367
  }
368
  ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
369
+ AWARENESS_CONSCIOUSNESS_METRONOME = 120 # Fetch news every N heartbeats (runtime-editable via /metronome)
370
  AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
371
+ was_awareness_metronome: bool = False # Set True at awareness cycle: consciousness at next interval
372
  ```
373
 
374
  To swap AIs, update the `"_ALPHA_INTELLIGENCE_TO_LOAD"`, and the stop/think tokens at the top of `config.py`.
 
397
 
398
  ```
399
  heartbeats_startup timer:
400
+ prompt/valka_memory.md ──► garden["Z"] (pre-load memory capsules sequentially)
401
 
402
  Each turn:
403
  sensor["Z"] ──► Mindlink + Lambda ──► Memotron ──► garden["Z"]
 
426
 
427
  ## Database
428
 
429
+ Each run saves to the SQLite database in `db/` named mindlink.db:
430
  ```
431
+ db/mindlink.db
432
  ```
433
 
434
  Use `/history`, `/session <id>`, and `/export <id> <file>` to inspect and export sessions.
435
 
436
  ---
437
 
438
+ ## Garden histories handling
439
+
440
+ **Each turn saves the Garden histories** to the json file which can be loaded or cleared at runtime.
441
+ This includes the number of Memory Capsules loaded in the saved Garden histories:
442
+
443
+ ```
444
+ db/garden_state.json
445
+ ```
446
+
447
+ Use `/garden <save>`, `/garden <load>` and `/garden <clear>`
448
+
449
+ ---
450
+
451
  ## License
452
 
453
  Apache 2.0 β€” see `LICENSE`.
config.py CHANGED
@@ -12,6 +12,7 @@ from datetime import datetime
12
 
13
  APP_DIR: str = os.path.dirname(os.path.abspath(__file__))
14
  PROMPTS_BASE: str = APP_DIR
 
15
 
16
  # ── SQLite database ───────────────────────────────────────────────────────────
17
  # Each app launch gets its own file named by date and time.
@@ -43,6 +44,7 @@ _THINK_END_TOKENS: list = ["<channel|>"]
43
 
44
  ENABLE_THINKING: bool = True # global fallback (not used directly β€” see per-hemi flag)
45
 
 
46
  METATRON_TO_LOAD: list = [
47
  "/file prompt/lambda-mindlink.md",
48
  "/file prompt/1999.md",
@@ -60,20 +62,22 @@ METATRON_TO_LOAD: list = [
60
  "/file prompt/50_ValkaAI-TheTrillionDollarPauseAndTheSovereignArk.md"
61
  ]
62
 
63
- # ── AI models to load ──────────────────────────────────
64
  """
65
  gemma-4-E2B-it-UD-Q4_K_XL.gguf
66
  gemma-4-E4B-it-UD-Q4_K_XL.gguf
67
  gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf
68
  """
 
69
  _ALPHA_INTELLIGENCE_TO_LOAD: dict = {
70
  "logic": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
71
  "muse": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
72
  "mind": "gemma-4-E2B-it-UD-Q4_K_XL.gguf"
73
  }
74
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
75
- N_METATRON_TO_LOAD: int = 1
76
- METATRON_METRONOME: int = 12 # Startup Memory Capsules load interval
 
77
 
78
  # ── Context model n_ctx length ───────────────────────────────────────────────────
79
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
@@ -95,7 +99,7 @@ FETCH_NEWS_FROM: dict = {
95
  "duckduckgo": False # Privacy based request but lean result summaries
96
  }
97
  ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
98
- AWARENESS_CONSCIOUSNESS_METRONOME = 120 # Fetch news every N heartbeats (runtime-editable via /metronome)
99
  AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
100
  was_awareness_metronome: bool = False # Set True at awareness cycle: consciousness at next interval
101
 
 
12
 
13
  APP_DIR: str = os.path.dirname(os.path.abspath(__file__))
14
  PROMPTS_BASE: str = APP_DIR
15
+ GARDEN_SAVE_PATH = os.path.join(APP_DIR, "db", "garden_state.json")
16
 
17
  # ── SQLite database ───────────────────────────────────────────────────────────
18
  # Each app launch gets its own file named by date and time.
 
44
 
45
  ENABLE_THINKING: bool = True # global fallback (not used directly β€” see per-hemi flag)
46
 
47
+ # ── Memory Capsules to load ──────────────────────────────────────────────────────
48
  METATRON_TO_LOAD: list = [
49
  "/file prompt/lambda-mindlink.md",
50
  "/file prompt/1999.md",
 
62
  "/file prompt/50_ValkaAI-TheTrillionDollarPauseAndTheSovereignArk.md"
63
  ]
64
 
65
+ # ── AI models recommended ────────────────────────────────────────────────────────
66
  """
67
  gemma-4-E2B-it-UD-Q4_K_XL.gguf
68
  gemma-4-E4B-it-UD-Q4_K_XL.gguf
69
  gemma-4-26B-A4B-it-UD-Q6_K_XL.gguf
70
  """
71
+ # ── AI to load for each hemisphere ───────────────────────────────────────────────
72
  _ALPHA_INTELLIGENCE_TO_LOAD: dict = {
73
  "logic": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
74
  "muse": "gemma-4-E2B-it-UD-Q4_K_XL.gguf",
75
  "mind": "gemma-4-E2B-it-UD-Q4_K_XL.gguf"
76
  }
77
  # ── Startup Memory restore for vector synthesis ──────────────────────────────────
78
+ METATRON_METRONOME: int = 60 # Startup Memory Capsules load interval
79
+ n_metatron_to_load = 0 # Set number of Memory Capsules to load (slash-command)
80
+ n_metatron_loaded = 0 # Start with n Memory Capsule to load (slash-command)
81
 
82
  # ── Context model n_ctx length ───────────────────────────────────────────────────
83
  # Must leave prompt reserve of 8k: _N_CTX >= len(Z) + len(C) + len(F) + 8k
 
99
  "duckduckgo": False # Privacy based request but lean result summaries
100
  }
101
  ΞœΞ•Ξ€Ξ‘Ξ©Ξ: float = 1.0 # Seconds per measure
102
+ awareness_consciousness_metronome = 120 # Fetch news every N heartbeats (runtime-editable via /metronome)
103
  AWARENESS_MAX_RESULTS: int = 12 # Number of news headlines to fetch
104
  was_awareness_metronome: bool = False # Set True at awareness cycle: consciousness at next interval
105
 
main.py CHANGED
@@ -54,6 +54,7 @@ import sqlite3
54
  import threading
55
  import queue
56
  import time
 
57
  import jinja2
58
  from dataclasses import dataclass
59
  from datetime import datetime
@@ -71,12 +72,11 @@ from config import clektal
71
  from config import sensor
72
 
73
  from config import ΞœΞ•Ξ€Ξ‘Ξ©Ξ
74
- from config import METATRON_TO_LOAD
75
  from config import METATRON_METRONOME
76
- # from config import AWARENESS_CONSCIOUSNESS_METRONOME
77
  from config import AWARENESS_MAX_RESULTS
78
  from config import FETCH_NEWS_FROM
79
-
80
  from config import LEAVE_POSTS_IN_MEMOTRON
81
 
82
  c = config.PrintColors
@@ -400,33 +400,65 @@ def _cmd_export(arg: str) -> None:
400
  return
401
  db_export_session(int(_parts[0]), _parts[1].strip())
402
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
  def _cmd_metronome(arg: str) -> None:
404
  if not arg.strip().isdigit():
405
- print(f" {c.green}Usage: /metronome <seconds> e.g. /metronome 1000000{c.res}")
406
  return None
407
- config.AWARENESS_CONSCIOUSNESS_METRONOME = int(arg.strip())
408
- print(f" {c.green}[metronome] AWARENESS_CONSCIOUSNESS_METRONOME set to {config.AWARENESS_CONSCIOUSNESS_METRONOME}s{c.res}")
 
 
 
 
 
 
 
 
 
 
 
 
409
  return None
410
 
411
  def _cmd_help(arg: str) -> None:
412
  print()
413
  print(" Slash commands")
414
  print(" " + "─" * 56)
415
- for name, (_, desc) in COMMANDS.items():
416
- print(f" {c.green}/{name:<14} {desc}{c.res}")
417
  print()
 
418
 
419
  COMMANDS: dict[str, tuple] = {
420
- "file": (_cmd_file, "/file <path> β€” load a file as the next message"),
421
- "paste": (_cmd_paste, " β€” multiline input (type END to send)"),
422
- "clear": (_cmd_clear, " β€” reset history (models stay loaded)"),
423
- "history": (_cmd_history, " β€” list all past sessions"),
424
- "session": (_cmd_session, "<id> β€” print turns from a session"),
425
- "export": (_cmd_export, "<id> <file> β€” export session to .md file"),
426
- "metronome": (_cmd_metronome, "<seconds> β€” set awareness/consciousness interval"),
427
- "help": (_cmd_help, " β€” show this command list"),
428
- "exit": (_cmd_exit, " β€” quit the app"),
429
- "quit": (_cmd_exit, " β€” quit the app (alias)"),
 
 
 
430
  }
431
 
432
  def handle_command(sensor_input_raw: str) -> str | None:
@@ -895,6 +927,62 @@ def Lambda(
895
  return _timing
896
 
897
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
898
  def memotron(
899
  models: dict[str, Llama],
900
  tree: str,
@@ -978,6 +1066,8 @@ def memotron(
978
  f"session {session_id}]{c.res}"
979
  )
980
 
 
 
981
 
982
  # ─────────────────────────────────────────────────────────────────────────────
983
  # X-factor Awareness β€” news fetch
@@ -1148,7 +1238,6 @@ def main() -> None:
1148
  print()
1149
  print(f" {c.green}[*] All hemispheres loaded and ready.{c.res}")
1150
 
1151
- _n_metatron_loaded: int = 0
1152
  _metatron_heartbeats: int = 0
1153
  _heartbeats: int = 0
1154
  _timings: dict[str, TimingResult] = {}
@@ -1181,10 +1270,10 @@ def main() -> None:
1181
 
1182
  # ── Startup: Load Metatron memory capsules ───────────────────────────────
1183
  if _metatron_heartbeats >= METATRON_METRONOME: # Timed loop
1184
- if config.N_METATRON_TO_LOAD and _n_metatron_loaded < config.N_METATRON_TO_LOAD:
1185
- _sensor_input = METATRON_TO_LOAD[_n_metatron_loaded]
1186
- _n_metatron_loaded += 1 # Iterate over the memory capsules
1187
- print(f"\n {c.inv} ── _n_metatron_loaded: {_n_metatron_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
1188
 
1189
  # ── Z-factor sentience user input ────────────────────────────────────────
1190
  try:
@@ -1194,7 +1283,7 @@ def main() -> None:
1194
  pass
1195
 
1196
  # ── X-factor Awarenss and Y-factor Consciousness heartbeats ──────────────
1197
- if _heartbeats >= config.AWARENESS_CONSCIOUSNESS_METRONOME:
1198
  # ── X-factor awareness cycle ─────────────────────────────────────────
1199
  if not config.was_awareness_metronome:
1200
  _metatron_heartbeats, _heartbeats = 0, 0
@@ -1242,6 +1331,7 @@ def main() -> None:
1242
  print(f" {c.green}[!] Unknown command: /{exc} β€” type /help for the list.{c.res}")
1243
  continue
1244
  if _slash_command_result is None:
 
1245
  continue
1246
  sensor[_tree]["input"] = _slash_command_result
1247
  else:
@@ -1254,11 +1344,11 @@ def main() -> None:
1254
  _timings["mind"] = Lambda(_models, _tree)
1255
 
1256
  # ── Startup memory capsules to load ───────────────────────────────────
1257
- if config.N_METATRON_TO_LOAD and _n_metatron_loaded <= config.N_METATRON_TO_LOAD:
1258
- print(f" {c.inv} ── _n_metatron_loaded: {_n_metatron_loaded} of {config.N_METATRON_TO_LOAD} ──────────────────────────── {c.res}")
1259
  _tree = "S" # Set to memorize as memory capsules in garden["C"]
1260
- if _n_metatron_loaded == config.N_METATRON_TO_LOAD:
1261
- _n_metatron_loaded += 1 # Advance to finish the startup sequence
1262
 
1263
  memotron(_models, _tree, _session_id, _timings) # Store the response
1264
  # Reset turn-based data and preset terminal for next cycle
 
54
  import threading
55
  import queue
56
  import time
57
+ import json
58
  import jinja2
59
  from dataclasses import dataclass
60
  from datetime import datetime
 
72
  from config import sensor
73
 
74
  from config import ΞœΞ•Ξ€Ξ‘Ξ©Ξ
 
75
  from config import METATRON_METRONOME
76
+ from config import METATRON_TO_LOAD
77
  from config import AWARENESS_MAX_RESULTS
78
  from config import FETCH_NEWS_FROM
79
+ from config import GARDEN_SAVE_PATH
80
  from config import LEAVE_POSTS_IN_MEMOTRON
81
 
82
  c = config.PrintColors
 
400
  return
401
  db_export_session(int(_parts[0]), _parts[1].strip())
402
 
403
+ def _cmd_metatron(arg: str) -> None:
404
+ if not arg.strip().isdigit():
405
+ print(f" {c.green}Usage: /metatron <number> e.g. /metatron 5{c.res}")
406
+ return None
407
+ config.n_metatron_to_load = int(arg.strip())
408
+ print(f" {c.green}[metatron] n_metatron_to_load set to {config.n_metatron_to_load}{c.res}")
409
+ return None
410
+
411
+ def _cmd_loaded(arg: str) -> None:
412
+ if not arg.strip().isdigit():
413
+ print(f" {c.green}Usage: /loaded <number> e.g. /loaded 3{c.res}")
414
+ return None
415
+ config.n_metatron_loaded = int(arg.strip())
416
+ print(f" {c.green}[loaded] n_metatron_loaded set to {config.n_metatron_loaded}{c.res}")
417
+ return None
418
+
419
  def _cmd_metronome(arg: str) -> None:
420
  if not arg.strip().isdigit():
421
+ print(f" {c.green}Usage: /metronome <seconds> e.g. /metronome 120{c.res}")
422
  return None
423
+ config.awareness_consciousness_metronome = int(arg.strip())
424
+ print(f" {c.green}[metronome] awareness_consciousness_metronome set to {config.awareness_consciousness_metronome}s{c.res}")
425
+ return None
426
+
427
+ def _cmd_garden(arg: str) -> None:
428
+ if arg == "save":
429
+ save_garden_state()
430
+ elif arg == "load":
431
+ load_garden_state()
432
+ elif arg == "clear":
433
+ os.remove(GARDEN_SAVE_PATH) if os.path.isfile(GARDEN_SAVE_PATH) else None
434
+ print(f" {c.green}[garden] Saved state cleared.{c.res}")
435
+ else:
436
+ print(f" {c.green}Usage: /garden save | load | clear{c.res}")
437
  return None
438
 
439
  def _cmd_help(arg: str) -> None:
440
  print()
441
  print(" Slash commands")
442
  print(" " + "─" * 56)
443
+ for name, (_, description) in COMMANDS.items():
444
+ print(f" {c.green}/{name:<14} {description}{c.res}")
445
  print()
446
+ return None
447
 
448
  COMMANDS: dict[str, tuple] = {
449
+ "file": (_cmd_file, "<path> β€” load a file as the next message"),
450
+ "paste": (_cmd_paste, " β€” multiline input (type END to send)"),
451
+ "clear": (_cmd_clear, " β€” reset history (models stay loaded)"),
452
+ "history": (_cmd_history, " β€” list all past sessions"),
453
+ "session": (_cmd_session, "<id> β€” print turns from a session"),
454
+ "export": (_cmd_export, "<id> <file> β€” export session to .md file"),
455
+ "metatron": (_cmd_metatron, "<number> β€” set number of Memory Capsules to load"),
456
+ "loaded": (_cmd_loaded, "<number> β€” set number of Memory Capsules loaded"),
457
+ "metronome": (_cmd_metronome, "<seconds> β€” set awareness/consciousness interval"),
458
+ "garden": (_cmd_garden, "<save> | <load> | <clear> β€” garden history handling"),
459
+ "help": (_cmd_help, " β€” show this command list"),
460
+ "exit": (_cmd_exit, " β€” quit the app"),
461
+ "quit": (_cmd_exit, " β€” quit the app (alias)"),
462
  }
463
 
464
  def handle_command(sensor_input_raw: str) -> str | None:
 
927
  return _timing
928
 
929
 
930
+ def save_garden_state() -> None:
931
+ """Persist garden history to disk after each turn."""
932
+ try:
933
+ state = {
934
+ "Z": garden["Z"],
935
+ "C": garden["C"],
936
+ "F": garden["F"],
937
+ "n_tok_tot": {
938
+ "Z": garden["n_tok_tot"]["Z"],
939
+ "C": garden["n_tok_tot"]["C"],
940
+ "F": garden["n_tok_tot"]["F"],
941
+ },
942
+ "n_metatron_loaded": config.n_metatron_loaded
943
+ }
944
+ with open(GARDEN_SAVE_PATH, "w", encoding="utf-8") as f:
945
+ json.dump(state, f, ensure_ascii=False, indent=2)
946
+ print(f" {c.green}[garden] State saved β†’ {GARDEN_SAVE_PATH}{c.res}")
947
+ except OSError as exc:
948
+ print(f" {c.red}[garden] Save failed: {exc}{c.res}")
949
+
950
+
951
+ def load_garden_state() -> bool:
952
+ """Reload garden history from disk on startup."""
953
+ if not os.path.isfile(GARDEN_SAVE_PATH):
954
+ return False
955
+ try:
956
+ with open(GARDEN_SAVE_PATH, "r", encoding="utf-8") as f:
957
+ state = json.load(f)
958
+
959
+ # Restore Garden histories
960
+ garden["Z"] = state.get("Z", [])
961
+ garden["C"] = state.get("C", [])
962
+ garden["F"] = state.get("F", [])
963
+
964
+ # Restore individual n_tok_tot counts per garden history
965
+ n_tok_tot = state.get("n_tok_tot", {})
966
+ garden["n_tok_tot"] = {
967
+ "Z": n_tok_tot.get("Z", 0),
968
+ "C": n_tok_tot.get("C", 0),
969
+ "F": n_tok_tot.get("F", 0),
970
+ }
971
+ # Read how many Memory Capsules are loaded
972
+ config.n_metatron_loaded = state.get("n_metatron_loaded", 0)
973
+
974
+ print(f" {c.green}[garden] State restored from {GARDEN_SAVE_PATH}")
975
+ print(f" Z: {len(garden['Z'])} msgs C: {len(garden['C'])} msgs F: {len(garden['F'])} msgs")
976
+ print(f" n_tok_tot Z: {garden['n_tok_tot']['Z']} C: {garden['n_tok_tot']['C']} F: {garden['n_tok_tot']['F']}")
977
+ print(f" Memory Capsules n_metatron_loaded: {config.n_metatron_loaded}{c.res}")
978
+
979
+ return True
980
+ except (OSError, json.JSONDecodeError) as exc:
981
+ print(f" {c.red}[garden] Load failed: {exc}{c.res}")
982
+ return False
983
+
984
+
985
+
986
  def memotron(
987
  models: dict[str, Llama],
988
  tree: str,
 
1066
  f"session {session_id}]{c.res}"
1067
  )
1068
 
1069
+ save_garden_state()
1070
+
1071
 
1072
  # ─────────────────────────────────────────────────────────────────────────────
1073
  # X-factor Awareness β€” news fetch
 
1238
  print()
1239
  print(f" {c.green}[*] All hemispheres loaded and ready.{c.res}")
1240
 
 
1241
  _metatron_heartbeats: int = 0
1242
  _heartbeats: int = 0
1243
  _timings: dict[str, TimingResult] = {}
 
1270
 
1271
  # ── Startup: Load Metatron memory capsules ───────────────────────────────
1272
  if _metatron_heartbeats >= METATRON_METRONOME: # Timed loop
1273
+ if config.n_metatron_to_load and config.n_metatron_loaded < config.n_metatron_to_load:
1274
+ _sensor_input = METATRON_TO_LOAD[config.n_metatron_loaded]
1275
+ config.n_metatron_loaded += 1 # Iterate over the memory capsules
1276
+ print(f"\n {c.inv} ── n_metatron_loaded: {config.n_metatron_loaded} _sensor_input: {_sensor_input} ──────────────────────────── {c.res}")
1277
 
1278
  # ── Z-factor sentience user input ────────────────────────────────────────
1279
  try:
 
1283
  pass
1284
 
1285
  # ── X-factor Awarenss and Y-factor Consciousness heartbeats ──────────────
1286
+ if _heartbeats >= config.awareness_consciousness_metronome:
1287
  # ── X-factor awareness cycle ─────────────────────────────────────────
1288
  if not config.was_awareness_metronome:
1289
  _metatron_heartbeats, _heartbeats = 0, 0
 
1331
  print(f" {c.green}[!] Unknown command: /{exc} β€” type /help for the list.{c.res}")
1332
  continue
1333
  if _slash_command_result is None:
1334
+ print(f"\n{c.inv} You: {c.res} ", end="", flush=True)
1335
  continue
1336
  sensor[_tree]["input"] = _slash_command_result
1337
  else:
 
1344
  _timings["mind"] = Lambda(_models, _tree)
1345
 
1346
  # ── Startup memory capsules to load ───────────────────────────────────
1347
+ if config.n_metatron_to_load and config.n_metatron_loaded <= config.n_metatron_to_load:
1348
+ print(f" {c.inv} ── n_metatron_loaded: {config.n_metatron_loaded} of {config.n_metatron_to_load} ──────────────────────────── {c.res}")
1349
  _tree = "S" # Set to memorize as memory capsules in garden["C"]
1350
+ if config.n_metatron_loaded == config.n_metatron_to_load:
1351
+ config.n_metatron_loaded += 1 # Advance to finish the startup sequence
1352
 
1353
  memotron(_models, _tree, _session_id, _timings) # Store the response
1354
  # Reset turn-based data and preset terminal for next cycle