🐾 Terminal companion mascot extension for Pi Coding Agent featuring Perrogato (the dog-cat hybrid companion).
pi-mascot provides real-time, terminal-safe visual status and feedback as your Pi Coding Agent works through plans, file inspections, code generation, testing, and error recovery.
- 🐶🐱 Perrogato Mascot: Expressive ASCII & Unicode companion blending feline agility and canine loyalty.
- 🔄 State Reducer & Activity Mapper: Maps agent lifecycle events and tool calls directly into 9 well-defined states:
idle- Waiting for user instructionsthinking- Reasoning, planning, or generating tokensreading- Inspecting files, reading URLs, ripgrep / fd searcheswriting- Creating or editing source filestesting- Running test suites and CLI commandssuccess- Completed steps and task resolutionwarning- Warnings, lint errors, or retriesblocked- Waiting on user confirmations or approvalresting- Extended inactivity and rest
- ♿ Motion Accessibility & Fallbacks:
auto: Automatically adapts to terminal capabilities andREDUCED_MOTIONenvironment variable.full: Multi-frame animation loops.reduced: Calm, static single-frame rendering.off: Static rendering with animation timers stopped.
- 📱 Compact-Width Mode: Auto-scales to compact single-line badges for terminals narrower than 40 columns or constrained status areas.
- 🛡️ Defensive Pi Compatibility Boundary:
- Isolates all host API assumptions in
src/api-types.ts. - Tolerates missing host APIs without throwing or crashing the agent session.
- Isolates all host API assumptions in
- 🧹 Lifecycle Cleanup:
- Automatically clears all interval timers on
session_shutdownor explicitdispose(). - Zero memory leaks or dangling processes.
- Automatically clears all interval timers on
Phase 1 is strictly scoped as a lightweight, zero-dependency visual companion:
- ✅ Included: In-memory state machine, tool activity mapper, terminal-safe frames, compact mode, motion controls, Pi slash commands, lifecycle cleanup.
- ❌ Excluded (Phase 1):
- No persistent disk storage or SQLite databases.
- No Git execution or branch manipulations.
- No network calls, telemetry, or external integrations.
- No autonomous code mutations or file modifications.
- Zero Network Activity:
pi-mascotperforms zero HTTP/WebSocket requests, collects zero telemetry, and contacts zero external servers. - Zero Persistent Data: All mascot states are held strictly in memory for the duration of the agent session. No logs, history, or agent prompts are written to disk.
- Zero Code Telemetry: File names, code contents, and command arguments analyzed by the activity mapper are never cached, leaked, or sent anywhere.
- Node.js >= 18.0.0
- Pi Coding Agent
# Clone the repository
git clone https://github.com/lleontor705/pi-mascot.git
cd pi-mascot
# Install development dependencies
npm install
# Build TypeScript to dist/
npm run build
# Run behavior tests
npm testIn your Pi configuration or extensions list, add pi-mascot:
{
"extensions": [
"/path/to/pi-mascot/src/index.ts"
]
}Or install directly via npm when published:
npm install -g pi-mascotpi-mascot registers the /mascot command defensively with Pi:
| Command | Description |
|---|---|
/mascot status |
Displays the current mascot, active state, motion mode, and rendered frame |
/mascot on |
Enables mascot visualization |
/mascot off |
Disables mascot visualization |
/mascot motion auto |
Automatic motion detection (respects REDUCED_MOTION) |
/mascot motion full |
Enables multi-frame animation loops |
/mascot motion reduced |
Enables static, single-frame display |
/mascot motion off |
Disables animation ticks |
/mascot select perrogato |
Selects Perrogato (the only mascot supported in Phase 1) |
/mascot help |
Shows usage instructions and available commands |
pi-mascot/
├── src/
│ ├── api-types.ts # Pi host extension API contracts & assumptions
│ ├── types.ts # Core mascot models, actions, activities, options
│ ├── reducer.ts # Pure state reducer and transition rules
│ ├── mapper.ts # Tool name & host event activity mapper
│ ├── frames.ts # Terminal-safe Unicode and ASCII frames for Perrogato
│ ├── renderer.ts # String and status renderer with compact fallbacks
│ ├── boundary.ts # Defensive Pi API compatibility bridge
│ ├── mascot.ts # MascotController orchestrator and command dispatcher
│ └── index.ts # Extension entrypoint for Pi
├── test/
│ ├── boundary.test.js # Compatibility boundary tests
│ ├── controller.test.js # Controller and command tests
│ ├── extension.test.js # Extension lifecycle and host wiring tests
│ ├── frames.test.js # Frame correctness and safety tests
│ ├── mapper.test.js # Tool & event mapping tests
│ ├── reducer.test.js # State reducer transition tests
│ └── renderer.test.js # Rendering and fallback tests
├── tsconfig.json
├── package.json
└── LICENSE
All behavior tests use Node.js built-in test runner (node:test and node:assert/strict), requiring zero external test frameworks:
npm testSample output:
✔ Boundary - Safe initialization with undefined or empty object
✔ Controller - Initialization
✔ Controller - Command: status
✔ Controller - Command: on / off
✔ Frames - Covers all 9 required activities for Perrogato
✔ Frames - Compact-width fallback fits compact terminals (<= 14 chars)
✔ Mapper - Maps reading tools
✔ Mapper - Maps writing tools
✔ Mascot Reducer - Activity Transitions for all 9 states
✔ Mascot Reducer - Select mascot accepts perrogato and rejects others
✔ Renderer - Compact width fallback for narrow terminals (< 40 cols)
...
ℹ tests 40
ℹ pass 40
ℹ fail 0
- Phase 1 (Current): Perrogato MVP, in-memory state reducer, terminal-safe frames, motion modes, compact width fallback, defensive Pi bridge.
- Phase 2: Additional mascots (e.g. Capybara, Robo-Owl, Axolotl), customizable ASCII color palettes (ANSI truecolor/256-color), optional status-bar widget slot integration.
- Phase 3: Sound/haptic cues (optional bell/audio hooks), interactive mood reactions based on build success rates, session statistics summaries.
MIT © Luis Leon