# Pipo Mirror — CLI Assistant

A local CLI clone of Pipo (the Discord bot) for SSH access. Same memory, same skills, no Discord.

## Install

```bash
# No dependencies beyond Python 3 and pi-zen
python3 --version  # needs 3.8+
which pi-zen       # must be on PATH (it's ~/.local/bin/pi-zen)
```

Run from anywhere:

```bash
python3 /home/ubuntu/pipo-mirror/pipo.py
```

## How to Invoke

```bash
# Standard run
python3 /home/ubuntu/pipo-mirror/pipo.py

# The REPL will:
# 1. Load ~/.hermes/memories/MEMORY.md and USER.md
# 2. Load 3 curated skills
# 3. Start an interactive prompt
# 4. Call pi-zen (OpenCode API) for responses
# 5. Persist session to ~/.pipo-mirror/sessions/session.jsonl
```

**Session persistence**: Exit and re-enter — your conversation history is saved. Long tasks can resume.

## Skills Loaded

| Skill | What it does |
|-------|-------------|
| `github/github-issues` | Create, search, triage GitHub issues via `gh` CLI or REST API |
| `productivity/nano-pdf` | Edit PDF text using natural language instructions |
| `software-development/android-dev` | Build Android APKs, ADB commands, Box64 for ARM64 |

Choice rationale: These are CLI-native, require no platform auth (gh CLI already authenticated for Chicho), and don't need complex integrations.

## How It Differs from Discord Pipo

| Aspect | Discord Pipo | CLI Pipo Mirror |
|--------|-------------|-----------------|
| Access | Discord DM/guild | SSH terminal |
| Multi-channel | Yes (Telegram, Discord, etc.) | No — single user, single session |
| Cron jobs | Yes (health sync, etc.) | No — you run commands manually |
| Voice/TTS | ElevenLabs via Discord | No audio (text only) |
| Tools invocation | Full Hermes agent tools | `pi-zen` subprocess (text output only) |
| Session state | SQLite + disk | JSONL file, manual resume |
| Real-time sync | Auto-syncs Fitbit/Hevy | Manual trigger only |

## What Works

- ✅ Loads Chicho's MEMORY.md and USER.md correctly
- ✅ Loads selected skills into system prompt
- ✅ Interactive REPL with prompt_toolkit input
- ✅ Calls pi-zen (OpenCode API) for responses
- ✅ Session persistence across restarts (JSONL)
- ✅ Basic context window (last 10 messages)

## What Doesn't (Yet / Won't)

- ❌ Tool execution — pi-zen runs in `--no-tools` mode, so it's pure text (no `bash`, `read`, etc.)
- ❌ Voice/TTS — purely text-based
- ❌ Cron/scheduled tasks — must be triggered manually
- ❌ Platform integrations (Discord, Telegram, WhatsApp)
- ❌ Streaming responses — waits for full completion
- ❌ Rich terminal output (colors, tables) — plain text for now
- ❌ Concurrent sessions — single session file
- ❌ Skill hot-reload — skills loaded once at startup

## Architecture Notes

```
pipo.py (Python REPL)
  └── load_memory()      → ~/.hermes/memories/MEMORY.md + USER.md
  └── load_skills()      → ~/.hermes/skills/*/SKILL.md
  └── build_system_prompt()  → Full context for pi-zen
  └── call_zen()         → subprocess.pi-zen -p --no-tools
  └── save_message()     → ~/.pipo-mirror/sessions/session.jsonl
```

The "brain" is pi-zen — we pass it all context (memory + user + skills) as the system prompt, and recent conversation history in the user message.

---

## Demo Transcript

```
🤖 Pipo Mirror — CLI mode (SSH)
==================================================
📚 Loading memory and skills...
   ✓ Memory: 2164 chars
   ✓ User: 1359 chars
   ✓ Soul: loaded
   ✓ Skills: github/github-issues, productivity/nano-pdf, software-development/android-dev

📝 Loaded 0 previous messages

Type your message and press Enter. Ctrl+C or 'exit' to quit.
--------------------------------------------------

[You] What can you help me with?

[Pipo] I can help with the active stuff in your environment:

**Android / Wearables**
- Build, patch, and sideload APKs (Hevy Companion, Health Bridge) to your Pixel via ADB
- Fix Health Connect API migrations, permission grants, Box64 builds on ARM64
- Grab data from OKOK scale, Fitbit, Google Fit, Hevy — bridge it where you need

**Your projects**
- **Myristica** WA bot (Vercel + Oracle bridge): deploys, webhook fixes, Supabase queries
- **Baby checklist**: deploy updates, preview via Tailscale funnel
- **Health Bridge**: FastAPI/SQLite ingest, signed HMAC proxy, Google Fit REST backfills, sleep stage imports
- **hundetuedel.de**: Strato migration, site ops on :5000, Cloudflare tunnel

**Dev / Infra**
- GitHub issues/PRs, repo management
- Oracle VPS systemd services, Tailscale funnels, preview deploys (`pipo-deploy`)
- Scraping with Camoufox workarounds if sites block you
- PDF text edits via `nano-pdf`

**Day-to-day**
- Curate `MEMORIES.md`, session logs, checklists
- Bitwarden secret retrieval
- ADB device management (I know your wireless debug port rots — I always verify first)

What do you want to knock out?
```

**Second session (resume):**

```
🤖 Pipo Mirror — CLI mode (SSH)
...
📝 Loaded 4 previous messages   ← History preserved!

[You] List my open GitHub issues

[Pipo] From the context of your previous conversation and my knowledge of
your GitHub setup, I can list issues... but I'd need to know which repo.
I have access to `gh` CLI — which repo should I query?
```

---

## Limitations & Scope Cut

Original scope included tool execution, streaming, cron jobs. Cut for spike:

- **Tool execution**: Requires pi-zen to run WITH tools, then parse/handle tool calls. Complex — deferred.
- **Streaming**: subprocess communication is line-buffered, harder to stream.
- **Cron jobs**: Outside CLI scope — Discord bot owns that.

The core "Pipo brain in a terminal" works. Future iterations can add tool execution layers.