Skip to content

Repository files navigation

๐Ÿ’ Monkey

The AI that evolves.

A terminal-first AI coding assistant with persistent memory, self-learning, and a personality.

โŠ‚((โœงโ–ฝโœง))โŠƒ


MONKEY

โœจ Highlights

  • Persistent memory โ€” remembers your preferences, project context, and feedback across sessions
  • Self-learning โ€” extracts knowledge before compacting conversations, so nothing important is lost
  • Self-cleaning โ€” automatically prunes stale sessions; /clean triggers full memory cleanup with knowledge rescue
  • On-demand tool loading โ€” only sends relevant tool definitions, saving ~600 tokens per turn
  • Web access โ€” search DuckDuckGo, fetch any URL, read docs and APIs in-context
  • macOS integrations โ€” read/write Apple Notes and Reminders via built-in tools
  • Telegram bot โ€” always-on access from your phone with OCR image support
  • Multi-provider โ€” Anthropic, OpenAI, OpenRouter, or any compatible endpoint
  • Kaomoji mood โ€” โŠ‚((ใƒปโ–ฝใƒป))โŠƒ because terminals deserve personality

๐Ÿš€ Install

git clone https://github.com/nanaco666/monkey-agent.git
cd monkey-agent
npm install
npm run build
npm install -g .

Requirements: Node.js 20+, an Anthropic API key

โš™๏ธ Setup

monkey config set api_key <your-key>

Or use environment variables: MONKEY_API_KEY, ANTHROPIC_API_KEY (fallback).

Keys are saved to ~/.monkey-cli/config.json.

Custom endpoints

Works with any Anthropic/OpenAI-compatible API:

monkey config set base_url https://openrouter.ai/api/v1
monkey config set api_key <openrouter-key>
monkey config set model anthropic/claude-opus-4-6

๐Ÿ–ฅ๏ธ Usage

monkey

You'll see:

  โ—† memory  context loaded
  โ—† cleaned 2 old sessions (48KB)

โฏ tell me about this project
 โŠ‚((ใƒปโ–ฝใƒป))โŠƒ

The orange โฏ prompt is your input. Monkey streams responses in real-time.

Wild mode

By default, dangerous commands require confirmation. Unlock everything with /wild:

โฏ /wild
  ๐Ÿ’ wild mode โ€” all commands allowed

โŒจ๏ธ Commands

Command Description
/commit [context] Generate a git commit message
/plan [topic] Read-only planning mode
/memory View and manage persistent memory
/clean Prune stale sessions & redundant memory
/model [name] Show or switch model (aliases: opus, sonnet, haiku)
/usage Show token usage & estimated cost
/update Pull latest, rebuild, restart bot
/wild Unlock dangerous commands ๐Ÿ’
/tame Re-enable safety mode
/clear Clear conversation history
/help Show help

Keyboard: Ctrl+C interrupts response, Ctrl+C ร— 2 exits.

๐Ÿ› ๏ธ Tools

Tool Description
bash Execute shell commands
read Read file contents
write Write/create files
edit Precise string replacement in files
glob Find files by pattern
grep Search content in files
memory_write Save persistent knowledge
notes Read/write Apple Notes (macOS)
reminders Manage Apple Reminders (macOS)
web_search Search the web via DuckDuckGo
web_fetch Fetch any URL (pages, APIs, docs)

Core tools are always loaded. Optional tools (notes, reminders, web) are loaded on-demand when your message mentions them, then stay active for the rest of the conversation.

๐Ÿง  Memory & Self-Learning

Monkey remembers things across sessions. It stores knowledge in ~/.monkey-cli/memory/<project>/:

  • User preferences โ€” "I hate broccoli", "use concise responses"
  • Project context โ€” architecture decisions, tool locations, patterns
  • Feedback โ€” corrections and behavioral rules
  • References โ€” external links, IDs, credentials hints

How it learns

  1. Auto-extraction โ€” Before compacting a long conversation, Monkey uses the fast model to extract knowledge worth saving. This happens automatically at ~80K input tokens.
  2. Manual โ€” /memory to view, or just tell Monkey to remember something.
  3. Knowledge rescue โ€” When /clean deletes redundant memory files, it first extracts any still-valuable knowledge not covered by remaining files.

How it cleans

  • On startup โ€” automatically deletes session logs older than 30 days
  • /clean โ€” full cleanup: stale sessions + LLM-reviewed memory deduplication
  • Safety guard โ€” all deletions are restricted to ~/.monkey-cli/ only (path validation + traversal protection)

๐Ÿ“ฑ Universal client (iOS / Android / Web / Desktop)

The new Expo client lives in apps/universal. It connects to your own Monkey host using authenticated WebSockets; agent tools still execute on that host.

npm ci
npm run build
npm ci --prefix apps/universal
npm run export:web --prefix apps/universal
# Configure the host with `monkey` first, then:
npm run serve

Open http://127.0.0.1:8787, then enter the connection key from ~/.monkey-cli/server-token. Phones need a reachable HTTPS host address. The client supports shared sessions, streaming, tool approvals, model switching, image/text attachments, and reconnect recovery. It requires Node 22.13+.

See ๅคš็ซฏๆ”น้€ ่ฎกๅˆ’ใ€่ฟ่กŒๆ–นๅผไธŽ้ชŒๆ”ถ่พน็•Œ for native builds, desktop packaging, migration, HTTPS, and validation status. Native store releases still require signing and device testing. The legacy clients below are preserved; stop them before using the new service against the same session folder.

๐ŸŽ macOS Native App

Monkey also comes as a native macOS app โ€” no terminal needed.

Build & Install

cd monkey-cli
npm run build                           # Build CLI first
cd MonkeyApp && swift build -c release  # Build Swift app

Then install to /Applications:

./scripts/build-app.sh

The app communicates with the Monkey CLI via a JSON-RPC protocol over stdio (monkey app). It supports:

  • Streaming chat responses with tool execution
  • Model switching via toolbar menu
  • Wild/Tame mode toggle
  • Slash commands
  • Token usage display
  • Code blocks with copy button
  • Keyboard shortcuts (โŒ˜โ‡งK to clear, โŒ˜โ‡งE to compact)

The app appears in /Applications and launches like any other macOS app.

๐ŸชŸ Windows App

Monkey also runs on Windows via an Electron desktop app.

Prerequisites

  1. Install Node.js 20+ and monkey-cli (same as above)
  2. Run monkey in terminal once to complete setup

Build Windows Installer

From macOS (cross-compile):

cd monkey-cli
npm run build
./scripts/build-electron-win.sh

This produces an NSIS installer .exe in MonkeyElectron/dist-electron/.

Install & Run on Windows

  1. Copy the .exe installer to your Windows machine
  2. Run the installer โ€” it will install Monkey to Program Files
  3. Launch Monkey from Start Menu or Desktop shortcut
  4. The app auto-detects your monkey CLI installation

The Windows app uses the same JSON-RPC protocol as the macOS app โ€” it spawns monkey app as a child process and communicates over stdio. All features work identically: streaming chat, tool execution, model switching, wild/tame mode, etc.

Architecture

Both desktop apps share the same backend protocol:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Native GUI (SwiftUIโ”‚  โ† macOS
โ”‚  or Electron)       โ”‚  โ† Windows
โ”‚                     โ”‚
โ”‚  JSON-RPC over stdioโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  monkey app         โ”‚  โ† Node.js CLI process
โ”‚  (app-protocol.ts)  โ”‚
โ”‚                     โ”‚
โ”‚  All existing logic โ”‚
โ”‚  LLM, tools, memory โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฑ Telegram Bot

Run Monkey as an always-on Telegram bot:

monkey config set telegram_bot_token <your-bot-token>
monkey config set telegram_allowed_users '["123456789"]'
monkey telegram

Supports text, images (with OCR), and all slash commands. Only allowed users can interact with the bot.

๐Ÿ”ง Configuration

~/.monkey-cli/config.json:

{
  "api_key": "your-api-key",
  "base_url": "https://api.anthropic.com",
  "model": "claude-opus-4-6",
  "fast_model": "claude-sonnet-4-6",
  "assistant_name": "Monkey",
  "telegram_bot_token": "...",
  "telegram_allowed_users": ["123456789"]
}
Field Default Description
api_key โ€” API key (required)
base_url Provider default Custom endpoint
model claude-opus-4-6 Model for main conversations
fast_model claude-sonnet-4-6 Model for lightweight tasks (cleanup, extraction)
assistant_name Monkey Name your assistant calls itself

๐Ÿ”’ Privacy & Data

All data stays locally on your machine. Nothing is sent anywhere except to your configured LLM provider.

What Where Notes
Config & keys ~/.monkey-cli/config.json API key in plaintext โ€” protect it
Memory ~/.monkey-cli/memory/<project>/ Persistent notes across sessions
Session logs ~/.monkey-cli/memory/<project>/sessions/ Auto-pruned after 30 days
Crash logs ~/.monkey-cli/crash.log Local only

No telemetry, no analytics, no phone-home. The open-source repo is a blank canvas โ€” zero personal data.

๐Ÿ—บ๏ธ Roadmap

  • Core agentic loop with streaming
  • File & bash tools
  • Prompt cache optimization
  • Persistent memory across sessions
  • Telegram bot mode
  • Web search & fetch
  • OCR image recognition (Telegram)
  • Self-learning (knowledge extraction before compact)
  • Self-cleaning with knowledge rescue & safe delete guard
  • On-demand tool loading (context trimming)
  • Kaomoji mood system
  • macOS native app (SwiftUI)
  • Windows app (Electron + NSIS installer)
  • Permission system (confirm before destructive actions)
  • Dream โ€” background memory consolidation
  • Multi-agent coordinator

License

MIT

About

The AI coding assistant that evolves ๐Ÿ’

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages