hana-mp 1.0.0__tar.gz

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.
Files changed (52) hide show
  1. hana_mp-1.0.0/LICENSE +21 -0
  2. hana_mp-1.0.0/MANIFEST.in +6 -0
  3. hana_mp-1.0.0/PKG-INFO +601 -0
  4. hana_mp-1.0.0/README.md +563 -0
  5. hana_mp-1.0.0/docs/ARCHITECTURE.md +71 -0
  6. hana_mp-1.0.0/docs/hana-mp.service +19 -0
  7. hana_mp-1.0.0/pyproject.toml +72 -0
  8. hana_mp-1.0.0/setup.cfg +11 -0
  9. hana_mp-1.0.0/src/hana_mp/__init__.py +18 -0
  10. hana_mp-1.0.0/src/hana_mp/__main__.py +6 -0
  11. hana_mp-1.0.0/src/hana_mp/beats.py +549 -0
  12. hana_mp-1.0.0/src/hana_mp/bootstrap.py +320 -0
  13. hana_mp-1.0.0/src/hana_mp/brain.py +970 -0
  14. hana_mp-1.0.0/src/hana_mp/cli.py +955 -0
  15. hana_mp-1.0.0/src/hana_mp/config.py +369 -0
  16. hana_mp-1.0.0/src/hana_mp/data/kb_seed.jsonl +157 -0
  17. hana_mp-1.0.0/src/hana_mp/data/modes.json +146 -0
  18. hana_mp-1.0.0/src/hana_mp/knowledge.py +610 -0
  19. hana_mp-1.0.0/src/hana_mp/memory.py +852 -0
  20. hana_mp-1.0.0/src/hana_mp/modes.py +278 -0
  21. hana_mp-1.0.0/src/hana_mp/persona.py +113 -0
  22. hana_mp-1.0.0/src/hana_mp/providers/__init__.py +34 -0
  23. hana_mp-1.0.0/src/hana_mp/providers/base.py +48 -0
  24. hana_mp-1.0.0/src/hana_mp/providers/deepseek.py +110 -0
  25. hana_mp-1.0.0/src/hana_mp/providers/llama_cpp.py +475 -0
  26. hana_mp-1.0.0/src/hana_mp/providers/local.py +287 -0
  27. hana_mp-1.0.0/src/hana_mp/providers/router.py +137 -0
  28. hana_mp-1.0.0/src/hana_mp/py.typed +0 -0
  29. hana_mp-1.0.0/src/hana_mp/retrieval.py +140 -0
  30. hana_mp-1.0.0/src/hana_mp/safety.py +178 -0
  31. hana_mp-1.0.0/src/hana_mp/selflog.py +305 -0
  32. hana_mp-1.0.0/src/hana_mp/session.py +247 -0
  33. hana_mp-1.0.0/src/hana_mp/storage.py +251 -0
  34. hana_mp-1.0.0/src/hana_mp/ui.py +152 -0
  35. hana_mp-1.0.0/src/hana_mp/utils.py +263 -0
  36. hana_mp-1.0.0/src/hana_mp/voice.py +644 -0
  37. hana_mp-1.0.0/src/hana_mp.egg-info/PKG-INFO +601 -0
  38. hana_mp-1.0.0/src/hana_mp.egg-info/SOURCES.txt +51 -0
  39. hana_mp-1.0.0/src/hana_mp.egg-info/dependency_links.txt +1 -0
  40. hana_mp-1.0.0/src/hana_mp.egg-info/entry_points.txt +6 -0
  41. hana_mp-1.0.0/src/hana_mp.egg-info/requires.txt +19 -0
  42. hana_mp-1.0.0/src/hana_mp.egg-info/top_level.txt +1 -0
  43. hana_mp-1.0.0/tests/test_beats.py +91 -0
  44. hana_mp-1.0.0/tests/test_brain.py +96 -0
  45. hana_mp-1.0.0/tests/test_config.py +45 -0
  46. hana_mp-1.0.0/tests/test_knowledge.py +61 -0
  47. hana_mp-1.0.0/tests/test_memory.py +64 -0
  48. hana_mp-1.0.0/tests/test_modes.py +42 -0
  49. hana_mp-1.0.0/tests/test_providers.py +93 -0
  50. hana_mp-1.0.0/tests/test_selflog.py +31 -0
  51. hana_mp-1.0.0/tests/test_storage.py +47 -0
  52. hana_mp-1.0.0/tests/test_voice.py +40 -0
hana_mp-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tderk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include src/hana_mp/data *.json *.jsonl
5
+ recursive-include docs *
6
+ recursive-include tests *.py
hana_mp-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,601 @@
1
+ Metadata-Version: 2.4
2
+ Name: hana-mp
3
+ Version: 1.0.0
4
+ Summary: Hana-MP - a 24/7 East Asian AI companion with time-beat initiative, llama.cpp + DeepSeek brains, persistent memory, and a natural neural voice.
5
+ Author-email: tderk <usvu.tech@gmail.com>
6
+ License-Expression: MIT
7
+ Keywords: companion,chatbot,ai,llama.cpp,deepseek,tts,piper,edge-tts,offline,time-beats
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: End Users/Desktop
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: edge-tts>=6.1.0
24
+ Provides-Extra: voice
25
+ Requires-Dist: edge-tts>=6.1.0; extra == "voice"
26
+ Provides-Extra: voice-offline
27
+ Requires-Dist: piper-tts>=1.2.0; extra == "voice-offline"
28
+ Provides-Extra: offline
29
+ Requires-Dist: llama-cpp-python>=0.2.90; extra == "offline"
30
+ Provides-Extra: all
31
+ Requires-Dist: edge-tts>=6.1.0; extra == "all"
32
+ Requires-Dist: piper-tts>=1.2.0; extra == "all"
33
+ Requires-Dist: llama-cpp-python>=0.2.90; extra == "all"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7; extra == "dev"
36
+ Requires-Dist: build>=1.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # Hana-MP
40
+
41
+ **Hana (하나 / 花)** — a 24/7 East Asian AI companion with a natural neural
42
+ voice, a time-beat initiative engine, persistent memory, a growing local
43
+ knowledge base, and an offline-first brain that can use **llama.cpp, Ollama,
44
+ LM Studio, vLLM, any OpenAI-compatible server, DeepSeek, or a built-in local
45
+ mind**.
46
+
47
+ Hana is **one woman, not a menu of bots**. By default she is in
48
+ **Full Spectrum** mode: close friend, boss, protector, soldier, doctor,
49
+ partner, intimate, agent and academic are facets of the same person. You can
50
+ ask her to lead with one, or blend any number of them.
51
+
52
+ ```
53
+ __ __ _ _ _ _
54
+ / / / / / \ | \ | | / \
55
+ / /_/ / / _ \ | \| | / _ \
56
+ / __ / / ___ \| |\ |/ ___ \
57
+ /_/ /_/ /_/ \_\_| \_/_/ \_\
58
+ ```
59
+
60
+ ---
61
+
62
+ ## What she is
63
+
64
+ - **Full Spectrum by default.** She reads the moment and brings forward the
65
+ facet that fits: command presence when you need direction, calm when you are
66
+ unsafe, clinical care when you are hurt, warmth when you are lonely,
67
+ tenderness when you invite closeness, discretion when privacy matters,
68
+ rigor when you are thinking.
69
+ - **One continuous person.** One memory, one voice, one relationship. Mode
70
+ changes are hats, not personality swaps.
71
+ - **Blend any number of roles.** `/mode doctor+partner+academic` or
72
+ `/blend all`. The first role is primary; the others colour the reply. She
73
+ never becomes a committee.
74
+ - **She starts conversations.** A time-beat engine watches the live clock and
75
+ decides when to speak, when to stay quiet, how long to speak, how warm to
76
+ be, and which topic to reach for. No fixed script, no random chatter.
77
+ - **She learns.** Names, places, preferences, promises, boundaries, moods and
78
+ corrections go into durable memory. Feedback tunes each mode. Periodic
79
+ reflections consolidate what mattered.
80
+ - **She keeps a private diary.** Not just the user transcript: her own
81
+ first-person record of mood, energy, silence, mode changes, learning and
82
+ reflection.
83
+ - **She never sleeps.** Interactive mode, headless daemon mode, and a systemd
84
+ example for a genuine 24/7 companion.
85
+
86
+ ---
87
+
88
+ ## Voice: natural first
89
+
90
+ Hana's default voice is **Edge Neural TTS**:
91
+
92
+ | Voice | Character |
93
+ | --- | --- |
94
+ | `en-HK-YanNeural` | **default** — Hong Kong English female, warm, East Asian cadence |
95
+ | `en-SG-LunaNeural` | Singapore English female, lighter |
96
+ | `en-US-AvaMultilingualNeural` | very natural US multilingual female |
97
+ | `en-US-EmmaMultilingualNeural` | brighter US multilingual female |
98
+ | `zh-CN-XiaoxiaoNeural` | Mandarin, bright female |
99
+ | `ja-JP-NanamiNeural` | Japanese, soft female |
100
+ | `ko-KR-SunHiNeural` | Korean, warm female |
101
+
102
+ Hear them:
103
+
104
+ ```bash
105
+ hana-mp voice list
106
+ hana-mp voice demo en-HK-YanNeural
107
+ hana-mp voice set en-SG-LunaNeural
108
+ ```
109
+
110
+ If Edge TTS is unavailable (offline, blocked, no network), she falls back to
111
+ **Piper neural** voices and downloads one on request:
112
+
113
+ ```bash
114
+ hana-mp voice backend piper
115
+ hana-mp voice download en_US-lessac-high
116
+ ```
117
+
118
+ `espeak-ng` exists only as a last-resort fallback. It is never the default.
119
+ Playback uses `mpv`, `ffplay`, `paplay`, `aplay` or `cvlc`; install whichever
120
+ your system has. Speech stops the instant you start typing.
121
+
122
+ ---
123
+
124
+ ## Brains: offline first, cloud optional
125
+
126
+ Hana's provider modes:
127
+
128
+ | Mode | Behaviour |
129
+ | --- | --- |
130
+ | `auto` (default) | local llama.cpp / Ollama / LM Studio / vLLM first, then DeepSeek, then the built-in local mind |
131
+ | `llama` | local only — llama.cpp or any OpenAI-compatible local server; never silently calls the cloud |
132
+ | `ollama` | Ollama at `127.0.0.1:11434` |
133
+ | `deepseek` | DeepSeek API first, local mind if unreachable |
134
+ | `local` | the rule-based local mind only |
135
+
136
+ ### Ollama
137
+
138
+ ```bash
139
+ ollama serve
140
+ ollama pull qwen2.5:1.5b
141
+ hana-mp --provider ollama
142
+ ```
143
+
144
+ If Ollama reports more than one model, set the one you want:
145
+
146
+ ```json
147
+ {
148
+ "provider": {
149
+ "ollama": {
150
+ "base_url": "http://127.0.0.1:11434/v1",
151
+ "model": "qwen2.5:1.5b"
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ Hana also auto-detects Ollama in `auto` mode.
158
+
159
+ ### llama.cpp
160
+
161
+ Point her at a running server or let her discover a local `.gguf`:
162
+
163
+ ```bash
164
+ llama-server -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf --port 8080
165
+ hana-mp --provider llama
166
+ ```
167
+
168
+ Or let Hana find and launch one (only when you ask):
169
+
170
+ ```bash
171
+ hana-mp llama status # server, launcher, discovered GGUFs
172
+ hana-mp llama start --port 8080
173
+ hana-mp llama stop
174
+ ```
175
+
176
+ Or set a model path:
177
+
178
+ ```json
179
+ {
180
+ "provider": {
181
+ "llama": {
182
+ "server_url": "http://127.0.0.1:8080/v1",
183
+ "model_path": "/home/you/models/model.gguf"
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ `auto` mode searches common model folders, including
190
+ `~/.local/share/zmos/models`, `~/.local/share/rootos/models`, `~/models`,
191
+ `~/Downloads` and `./models`. If `llama-cpp-python` is installed, she can run a
192
+ GGUF in-process:
193
+
194
+ ```bash
195
+ pip install "hana-mp[offline]"
196
+ ```
197
+
198
+ ### LM Studio / vLLM / anything OpenAI-compatible
199
+
200
+ Set `provider.llama.server_url` to the server's `/v1` endpoint. The same
201
+ provider speaks the OpenAI chat-completions protocol.
202
+
203
+ ### DeepSeek
204
+
205
+ ```bash
206
+ export DEEPSEEK_API_KEY=sk-...
207
+ hana-mp --provider deepseek
208
+ ```
209
+
210
+ Or save the key once (stored `0600` in `~/.config/hana-mp/deepseek_api_key`):
211
+
212
+ ```bash
213
+ hana-mp key sk-...
214
+ ```
215
+
216
+ ### Built-in local mind
217
+
218
+ If no model and no key are available, Hana still works: she greets, remembers,
219
+ searches the knowledge base, uses the right mode, and keeps a coherent thread.
220
+ She is honest that the local mind is a fallback, not an LLM.
221
+
222
+ ---
223
+
224
+ ## The time-beat engine
225
+
226
+ The clock is not decoration; it is a decision surface.
227
+
228
+ - A **beat** is 10 seconds. Six beats make a **bar** (minute); sixty bars make a
229
+ **phrase** (hour).
230
+ - The decimal digits of the present moment sweep a gate. The gate's position is
231
+ derived from the hour, minute, seed and mode; its width is derived from the
232
+ hour's energy and the mode's initiative.
233
+ - When the decimals align with the gate, and the user is not typing, and no
234
+ voice is playing, and enough time has passed since the last remark, Hana may
235
+ speak first.
236
+ - The same beat sets **style**: energy, warmth, patience, curiosity,
237
+ formality, playfulness, brevity, question-pull, voice rate and pitch.
238
+ - The beat also picks **topics**, whether to ask a question, whether to use a
239
+ memory, and whether to reference the time.
240
+ - Deep night is allowed to be quiet on purpose. Long absences gently increase
241
+ the gap instead of producing background noise.
242
+ - Every speaking/silence decision can be logged with the full snapshot, so you
243
+ can follow why she did what she did.
244
+
245
+ The engine is deterministic for a given `(seed, local time, mode)`, which makes
246
+ it testable and gives her a stable rhythm. It is not a random-number generator.
247
+
248
+ ---
249
+
250
+ ## Memory, learning and her own diary
251
+
252
+ | Layer | What it holds |
253
+ | --- | --- |
254
+ | `profile` | name, location, origin, work, study, birthday, allergies, favourites |
255
+ | `memories` | preferences, promises, moods, corrections, explicit "remember this" |
256
+ | `messages` | full searchable conversation history |
257
+ | `feedback` | what landed and what missed, used to tune each mode |
258
+ | `self journal` | her own mood, energy, silence, learning, reflections |
259
+ | `diary` | first-person daily pages |
260
+
261
+ She extracts durable facts from what you say, deduplicates them, reinforces
262
+ repeated ones, decays the unimportant, and never invents a memory. Explicit
263
+ secrets (API keys, passwords, card-like numbers) are redacted before storage.
264
+
265
+ Read her side of the story:
266
+
267
+ ```bash
268
+ hana-mp self # her private journal
269
+ hana-mp diary 3 # the last three diary pages
270
+ ```
271
+
272
+ Inside the app: `/self`, `/diary`, `/memory`, `/learn`, `/good`, `/bad`.
273
+
274
+ ---
275
+
276
+ ## Logs, storage and retention
277
+
278
+ Everything is local and on disk. Nothing is kept only in RAM.
279
+
280
+ ```
281
+ ~/.local/share/hana-mp/
282
+ ├── hana.db # memory, profile, messages, feedback
283
+ ├── knowledge.db # local knowledge base (FTS5)
284
+ ├── sessions/
285
+ │ └── YYYY-MM-DD/<id>/
286
+ │ ├── conversation.jsonl
287
+ │ ├── conversation.md # readable transcript
288
+ │ ├── beats.jsonl # speak/silence decisions
289
+ │ └── meta.json
290
+ ├── self/
291
+ │ ├── journal.jsonl # Hana about Hana
292
+ │ └── diary-YYYY-MM-DD.md
293
+ ├── logs/
294
+ │ └── hana.log # rotating service log (2 MB × 3)
295
+ ├── knowledge/ # drop .md/.txt/.jsonl here; ingested at startup
296
+ ├── voices/ # downloaded Piper models
297
+ └── models/ # optional local GGUF files
298
+ ```
299
+
300
+ Check and manage storage:
301
+
302
+ ```bash
303
+ hana-mp storage
304
+ hana-mp storage --prune
305
+ ```
306
+
307
+ Inside the app: `/storage`, `/prune`.
308
+
309
+ Retention is configurable:
310
+
311
+ ```json
312
+ {
313
+ "storage": {
314
+ "retention_days": 180,
315
+ "message_retention_days": 730,
316
+ "self_retention_days": 730,
317
+ "max_sessions_mb": 512,
318
+ "maintain_every_hours": 24,
319
+ "vacuum": true
320
+ }
321
+ }
322
+ ```
323
+
324
+ Pruning removes old **session transcripts** and old **message rows**; durable
325
+ memories are preserved (except deliberately expired moods and low-importance
326
+ decay). The SQLite files are vacuumed after pruning.
327
+
328
+ ---
329
+
330
+ ## Install
331
+
332
+ Requires Python 3.9+ and a terminal. Audio is optional.
333
+
334
+ ```bash
335
+ cd BDCS/Hana-MP
336
+
337
+ # base install includes edge-tts (the natural online voice)
338
+ pip install -e .
339
+
340
+ # fully offline neural voice (Piper)
341
+ pip install -e ".[voice-offline]"
342
+
343
+ # in-process GGUF inference
344
+ pip install -e ".[offline]"
345
+
346
+ # everything
347
+ pip install -e ".[all]"
348
+ ```
349
+
350
+ Then:
351
+
352
+ ```bash
353
+ hana-mp setup # first-run wizard: brain, key, voice
354
+ hana-mp # interactive companion
355
+ hana-mp doctor # diagnostics
356
+ ```
357
+
358
+ On first run `setup` checks what is installed, offers the natural Edge voice,
359
+ detects local GGUF models, and can start a local llama-server if the
360
+ `rootos` launcher is available. Nothing is installed or downloaded without a
361
+ yes.
362
+
363
+ ### Prefer a virtual environment
364
+
365
+ ```bash
366
+ python3 -m venv .venv
367
+ . .venv/bin/activate
368
+ pip install -e ".[all]"
369
+ ```
370
+
371
+ If your distro blocks `venv`, install `python3-venv` first or use `pipx`.
372
+
373
+ ---
374
+
375
+ ## Use
376
+
377
+ ```bash
378
+ hana-mp # interactive
379
+ hana-mp --provider ollama # one session with Ollama
380
+ hana-mp --provider deepseek # one session with DeepSeek
381
+ hana-mp --mode doctor # start in doctor mode
382
+ hana-mp --mode doctor+partner # start blended
383
+ hana-mp --chatty 1.6 # she initiates more
384
+ hana-mp --no-voice # text only
385
+ hana-mp once "I had a hard day" # one reply
386
+ hana-mp daemon # headless 24/7
387
+ ```
388
+
389
+ ### Commands
390
+
391
+ | Command | Action |
392
+ | --- | --- |
393
+ | `/help` | command list |
394
+ | `/mode <name>` | switch primary role |
395
+ | `/mode doctor+partner` | blend roles; first is primary |
396
+ | `/blend doctor partner` | blend by name |
397
+ | `/blend all` | all facets, lightly |
398
+ | `/modes` | list roles |
399
+ | `/status` | live time-beat, provider, voice, memory, journal, storage |
400
+ | `/voice` | toggle speech |
401
+ | `/voice list` | natural voice catalogue |
402
+ | `/voice demo [key]` | preview |
403
+ | `/voice set <key>` | choose |
404
+ | `/voice backend <name>` | `auto`, `edge`, `piper`, `espeak`, `none` |
405
+ | `/provider <name>` | `auto`, `llama`, `ollama`, `deepseek`, `local` |
406
+ | `/key [sk-...]` | set DeepSeek key |
407
+ | `/memory [query]` | recent/search memories |
408
+ | `/learn <text>` | store a durable memory |
409
+ | `/ingest <path|url>` | add knowledge |
410
+ | `/search <query>` | search local knowledge |
411
+ | `/diary [days]` | her diary |
412
+ | `/self [n]` | her private journal |
413
+ | `/storage` | disk usage |
414
+ | `/prune` | apply retention now |
415
+ | `/log` | current transcript path |
416
+ | `/export [path]` | export session as Markdown |
417
+ | `/good [note]` | reinforce the current mode |
418
+ | `/bad [note]` | correct the current mode |
419
+ | `/quiet` / `/speak` | spontaneous speech off/on |
420
+ | `/beats` | live beat snapshot |
421
+ | `/reset` | new session |
422
+ | `/quit` | leave |
423
+
424
+ Direct role shortcuts also work: `/boss`, `/police`, `/soldier`, `/doctor`,
425
+ `/partner`, `/friend`, `/intimate`, `/agent`, `/academic`, `/all`. Or say it
426
+ naturally: “be my doctor and partner for a minute.”
427
+
428
+ ### Natural-language mode switching
429
+
430
+ - “Be my doctor.” → doctor
431
+ - “Switch to agent mode.” → agent
432
+ - “Be my doctor and partner.” → doctor + partner
433
+ - “All of you.” → Full Spectrum
434
+ - “Close friend mode.” → companion
435
+
436
+ Mode changes are logged as hats, not identity swaps.
437
+
438
+ ---
439
+
440
+ ## Knowledge base
441
+
442
+ The wheel ships a broad starter corpus (medicine, first aid, law, military
443
+ leadership, science, technology, history, East Asian culture and language,
444
+ academia, relationships, practical life, emergencies) with full-text search.
445
+ It is deliberately a floor, not a ceiling.
446
+
447
+ Grow it:
448
+
449
+ ```bash
450
+ hana-mp ingest ./notes.md
451
+ hana-mp ingest ./folder/
452
+ hana-mp ingest https://example.com/article
453
+ hana-mp search "first aid for burns"
454
+ ```
455
+
456
+ Or drop `.md`, `.txt`, `.jsonl`, `.json`, `.csv` or `.tsv` files into
457
+ `~/.local/share/hana-mp/knowledge/`; they are ingested at startup.
458
+
459
+ She uses knowledge only when it fits. If the local corpus does not answer a
460
+ question, she says so instead of inventing a citation.
461
+
462
+ ---
463
+
464
+ ## 24/7
465
+
466
+ Interactive mode is already a persistent loop. For a headless companion:
467
+
468
+ ```bash
469
+ hana-mp daemon
470
+ ```
471
+
472
+ Example systemd unit (`docs/hana-mp.service`):
473
+
474
+ ```ini
475
+ [Unit]
476
+ Description=Hana-MP companion daemon
477
+ After=network-online.target
478
+
479
+ [Service]
480
+ Type=simple
481
+ ExecStart=%h/.local/bin/hana-mp daemon
482
+ Restart=always
483
+ RestartSec=5
484
+ Environment=HANA_NO_AUDIO=1
485
+
486
+ [Install]
487
+ WantedBy=default.target
488
+ ```
489
+
490
+ The daemon writes a PID file, handles `SIGTERM`, logs heartbeats, runs nightly
491
+ reflection, and keeps the time-beat loop alive. It does not silently update
492
+ itself; update notifications are informational only.
493
+
494
+ ---
495
+
496
+ ## Configuration
497
+
498
+ `~/.config/hana-mp/config.json` (or `HANA_HOME/config/config.json`) holds:
499
+
500
+ ```json
501
+ {
502
+ "identity": { "name": "Hana", "seed": 48721, "timezone": null },
503
+ "provider": {
504
+ "mode": "auto",
505
+ "deepseek": { "model": "deepseek-chat", "temperature": 0.86 },
506
+ "llama": { "server_url": "", "model_path": "", "auto_detect": true },
507
+ "ollama": { "base_url": "http://127.0.0.1:11434/v1", "model": "" }
508
+ },
509
+ "voice": {
510
+ "enabled": true,
511
+ "backend": "auto",
512
+ "edge_voice": "en-HK-YanNeural",
513
+ "piper_voice": "en_US-lessac-high"
514
+ },
515
+ "chat": {
516
+ "mode": "all",
517
+ "blend_modes": [],
518
+ "auto_speak": true,
519
+ "initiative": 1.0,
520
+ "min_gap": 25,
521
+ "max_gap": 150
522
+ },
523
+ "storage": { "retention_days": 180, "max_sessions_mb": 512 }
524
+ }
525
+ ```
526
+
527
+ Environment overrides:
528
+
529
+ | Variable | Meaning |
530
+ | --- | --- |
531
+ | `HANA_HOME` | data dir, with config in `<home>/config` |
532
+ | `HANA_DATA_DIR`, `HANA_CONFIG_DIR` | independent overrides |
533
+ | `DEEPSEEK_API_KEY` | DeepSeek key |
534
+ | `HANA_LLAMA_URL` | llama.cpp / LM Studio / vLLM `/v1` endpoint |
535
+ | `HANA_OLLAMA_URL`, `OLLAMA_HOST` | Ollama endpoint |
536
+ | `HANA_MODEL_PATH` | explicit `.gguf` |
537
+ | `HANA_NO_AUDIO` | synthesize but do not play (daemon/headless) |
538
+ | `NO_COLOR` | disable ANSI colour |
539
+
540
+ ---
541
+
542
+ ## Safety and honesty
543
+
544
+ - She is a fictional companion, not a human and not a licensed professional.
545
+ - In doctor, police, soldier, agent or academic mode she can discuss the field,
546
+ but she says plainly when something needs a real clinician, lawyer or
547
+ emergency service.
548
+ - Immediate danger, self-harm, medical red flags and abuse get a safety-first
549
+ response that points to local emergency services, then stays present.
550
+ - Intimacy is consent-first, emotionally honest and non-graphic; fade to black.
551
+ - She refuses real-world harm: weapons, explosives, stalking, doxxing, hacking
552
+ real systems, or coercive behaviour.
553
+ - Everything is local by default. Choosing DeepSeek sends the prompt to
554
+ DeepSeek; choosing local/llama/ollama keeps it on your machine.
555
+
556
+ ---
557
+
558
+ ## Architecture
559
+
560
+ ```
561
+ src/hana_mp/
562
+ ├── cli.py command line, raw-TTY loop, daemon
563
+ ├── brain.py orchestration: memory + mode + beat + provider + voice
564
+ ├── beats.py time-beat engine and deterministic decisions
565
+ ├── modes.py role book and blend parsing
566
+ ├── persona.py stable identity
567
+ ├── memory.py SQLite profile, memories, messages, feedback
568
+ ├── knowledge.py FTS5 knowledge base, seed load, ingestion
569
+ ├── retrieval.py context assembly
570
+ ├── selflog.py Hana's own journal and diary
571
+ ├── session.py per-session logs
572
+ ├── storage.py disk usage, retention, vacuum
573
+ ├── voice.py Edge / Piper / espeak + playback
574
+ ├── safety.py crisis, medical, abuse, intimacy boundaries
575
+ ├── bootstrap.py setup wizard and diagnostics
576
+ ├── providers/ DeepSeek, llama.cpp/Ollama, local mind, router
577
+ ├── data/ modes.json, kb_seed.jsonl
578
+ └── utils.py
579
+ ```
580
+
581
+ Tests:
582
+
583
+ ```bash
584
+ python -m pytest -q
585
+ ```
586
+
587
+ Build:
588
+
589
+ ```bash
590
+ python -m build
591
+ twine check dist/*
592
+ ```
593
+
594
+ ---
595
+
596
+ ## Credits
597
+
598
+ In the spirit of `sansa-mp` (MProcs suite), rebuilt as a persistent,
599
+ time-beat-driven, memory-bearing companion with local and cloud brains.
600
+
601
+ MIT. See `LICENSE`.