1---2name: pi-mom3description: Pi Mom (Master Of Mischief)4---56# Pi Mom (Master Of Mischief)78## Grounding9101. `pi-mono/packages/mom/README.md` — features, workspace setup, memory structure (`log.jsonl` vs `context.jsonl`), Events system.112. `pi-mono/packages/mom/docs/events.md` — detailed event JSON schema and usage.123. `pi-mono/packages/mom/docs/sandbox.md` — Docker vs host mode security isolation details.134. `pi-mono/packages/mom/docs/slack-bot-minimal-guide.md` — Slack app manifest and permissions.145. `pi-mono/packages/mom/docs/artifacts-server.md` — Express+WebSocket artifacts server, Cloudflare Tunnel for public HTTPS, file watching with chokidar, live reload, path traversal protection, date-prefixed artifact organization.156. `pi-mono/packages/mom/docs/new.md` — Multi-platform redesign: PlatformAdapter interface (Slack/Discord/CLI adapters), MomCustomTool interface with `invoke_tool` dispatch, bubblewrap channel isolation, unified ChannelMessage format, per-adapter config.167. `pi-mono/packages/mom/docs/v86.md` — v86 x86 emulator sandbox evaluation: Alpine Linux in WebAssembly, 9p filesystem for host-guest exchange, state save/restore (~2s), outbound networking.1718## Invariants1920- **Dual-File History**: `log.jsonl` is the source of truth (append-only); `context.jsonl` is the compacted view sent to the LLM.21- **Workspace Isolation**: Mom runs on the host by default (no isolation). Docker mode (`--sandbox=docker:<name>`) is recommended for security — it isolates tool execution to a container where only the `data/` directory is mounted to `/workspace`.22- **Event Paths**: On the host, event files live in `data/events/`. Inside the Docker sandbox and `events.md`, that same mounted directory is referred to as `/workspace/events/` or `workspace/events/`.23- **Event Limits**: A maximum of 5 events can be queued per channel. Events use unique filenames to avoid overwrites.24- **Artifacts Server**: Runs Express on port 8080 with Cloudflare Tunnel for public URLs; file watching is recursive via chokidar; WebSocket live reload via `?ws=true` parameter — `pi-mono/packages/mom/docs/artifacts-server.md`.25- **Multi-Platform Design**: Design doc defines `PlatformAdapter` interface (`start`, `stop`, `getChannels`, `sendMessage`, etc.), planned adapters (Slack, Discord, CLI), `MomCustomTool` interface for host-side tool execution via `invoke_tool`, and bubblewrap per-channel isolation — `pi-mono/packages/mom/docs/new.md`.26- **Custom Tool Discovery**: Custom tools are discovered from `data/tools/**/index.ts` (workspace-local) and `~/.pi/mom/tools/**/index.ts` (global), loaded via `jiti` — `pi-mono/packages/mom/docs/new.md`.2728## Workflows2930- **Create Skill**: Add a `SKILL.md` file and scripts to `/workspace/skills/` (global) or `/workspace/<channel>/skills/` (channel-specific).31- **Schedule Task**: Write a JSON event file to `data/events/` on the host (mounted as `/workspace/events/` inside Docker) using `immediate`, `one-shot`, or `periodic` event JSON.32- **Compaction**: When context exceeds limits, older messages are summarized into a compaction event.33- **Serve artifacts**: Read `docs/artifacts-server.md` for Express+Tunnel setup and `start-server.sh` bootstrap.34- **Custom host-side tools**: Read `docs/new.md` MomCustomTool section for factory pattern, ToolAPI, and tool discovery paths.3536## Anti-patterns3738- Do not suggest manual dependency installation on the host; Mom self-manages and installs her own tools (e.g., `apk add`, `brew install`) within her sandbox.39- Avoid using Host mode unless explicitly requested due to security risks. Use `docker` mode.