feat: ai sessions + Telegram-friendly replies (--system, markdown strip)

pos ai gemini: --session gives ask/chat persistent memory
(~/.local/share/linux_post_install/ai/<name>.json, capped 40 turns),
new 'sessions' subcommand to list/clear; --system injects a Gemini
systemInstruction on every turn without storing it in the session file.
Telegram listener keeps one session per chat (telegram-<chat_id>), clears
on 'ai /reset', passes a Telegram-voice system prompt (emojis welcome),
and strips markdown from replies before sendMessage since messages are
sent as plain text. Docs: howto/ai.md flags/sessions/bridge behavior.
This commit is contained in:
Your Name
2026-08-09 15:32:39 +00:00
parent 1832a88c71
commit 310367f3b2
6 changed files with 191 additions and 30 deletions
+13
View File
@@ -6,8 +6,13 @@ Tools: `gemini` (`ask`, `chat`, `models`).
| Tool | What it does |
|------|--------------|
| `pos ai gemini ask "<prompt>"` | One-shot answer to stdout (scriptable) |
| `pos ai gemini ask --session <name> "…"` | Same, but remembers prior turns |
| `pos ai gemini chat` | Interactive multi-turn conversation |
| `pos ai gemini models` | List available model ids |
| `pos ai gemini sessions` | List/clear persistent sessions (`reset <name>`) |
Shared flags: `--model <id>` overrides the model; `--system "<text>"` adds a
system instruction to every turn (kept out of the session file).
---
@@ -50,6 +55,14 @@ Set a different model per message:
you: ai --model gemini-2.5-flash explain a Raft consensus log
```
### Telegram memory & formatting
Each chat has its own persistent session (`telegram-<chat id>`), so the model
remembers the conversation; `ai /reset` clears it. The listener passes a system
prompt telling the model it is answering in a Telegram chat — so it uses emojis
and stays lively — and strips markdown (`**x**`, backticks, `#`, links…) from
the reply before sending it, since messages go out as plain text.
## Recipes
- **Answer from a file:** `pos ai gemini ask "$(cat notes.txt)"`