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:
@@ -58,7 +58,7 @@ Linux_post_install/
|
||||
├── bin/ # CLI tools — installed to /usr/local/bin/
|
||||
│ ├── pos # Main dispatcher — smart arg matching to pos-* scripts
|
||||
<!-- GEN:START tree -->
|
||||
│ ├── pos-ai-gemini # Chat with Google Gemini (ask, chat, models)
|
||||
│ ├── pos-ai-gemini # Chat with Google Gemini (ask, chat, models, sessions)
|
||||
│ ├── pos-communication-telegram-listener # Telegram bot listener: map /command → bash, run them on chat messages
|
||||
│ ├── pos-communication-telegram-sender # Send Telegram messages/files/links/stickers via Bot API (send, test)
|
||||
│ ├── pos-config # Interactive editor for the tools' runtime config (reads # POS_CONFIG: registry)
|
||||
@@ -253,7 +253,7 @@ All non-interactive `pos` commands log output to `~/.local/share/linux_post_inst
|
||||
| Category | Command | Script | Description |
|
||||
|----------|---------|--------|-------------|
|
||||
<!-- GEN:START dispatch -->
|
||||
| ai | gemini | `pos-ai-gemini` | Chat with Google Gemini (ask, chat, models) |
|
||||
| ai | gemini | `pos-ai-gemini` | Chat with Google Gemini (ask, chat, models, sessions) |
|
||||
| communication | telegram-listener | `pos-communication-telegram-listener` | Telegram bot listener: map /command → bash, run them on chat messages |
|
||||
| communication | telegram-sender | `pos-communication-telegram-sender` | Send Telegram messages/files/links/stickers via Bot API (send, test) |
|
||||
| | config | `pos-config` | Interactive editor for the tools' runtime config (reads # POS_CONFIG: registry) |
|
||||
@@ -560,8 +560,8 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`
|
||||
| `features/autostart.sh` | 14 | Boot-time feature (moved from `bin/`, flag-gated service) |
|
||||
<!-- GEN:START filetable -->
|
||||
| `bin/pos` | 277 | CLI dispatcher with smart arg matching + logging + category help |
|
||||
| `bin/pos-ai-gemini` | 198 | Chat with Google Gemini (ask, chat, models) |
|
||||
| `bin/pos-communication-telegram-listener` | 526 | Telegram bot listener: map /command → bash, run them on chat messages |
|
||||
| `bin/pos-ai-gemini` | 311 | Chat with Google Gemini (ask, chat, models, sessions) |
|
||||
| `bin/pos-communication-telegram-listener` | 559 | Telegram bot listener: map /command → bash, run them on chat messages |
|
||||
| `bin/pos-communication-telegram-sender` | 221 | Send Telegram messages/files/links/stickers via Bot API (send, test) |
|
||||
| `bin/pos-config` | 80 | Interactive editor for the tools' runtime config (reads # POS_CONFIG: registry) |
|
||||
| `bin/pos-docker-compose` | 366 | Docker Compose service manager (ls/up/down/restart/logs/update/config) |
|
||||
|
||||
@@ -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)"`
|
||||
|
||||
Reference in New Issue
Block a user