Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

docs(readme): rewrite README and the Chinese translation

Salman Qureshi36d8241ade1d
diff --git a/README.md b/README.md
index ea714d16..50c2f7b0 100644
--- a/README.md
+++ b/README.md
@@ -1,535 +1,395 @@
<p align="center">
<picture>
- <source media="(prefers-color-scheme: dark)" srcset="docs/img/card-dark.png">
- <source media="(prefers-color-scheme: light)" srcset="docs/img/card-light.png">
- <img alt="Mercury — Soul-Driven AI Agent" src="docs/img/card-light.png" width="600">
+ <source media="(prefers-color-scheme: dark)" srcset="docs/img/readme-hero-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="docs/img/readme-hero-light.png">
+ <img alt="Mercury Agent" src="docs/img/readme-hero-light.png" width="520">
</picture>
</p>
-<p align="center">
- <strong>Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access.</strong>
-</p>
-
-<p align="center">
- Remembers what matters. Asks before it acts. Runs 24/7 from CLI, Telegram, Discord, Slack, Signal, or Web. ~50 built-in tools, Mercury Code, the Mercury Bots fleet, Kanban boards, extensible skills, SQLite-backed Second Brain memory.
-</p>
+<h3 align="center">A personal AI agent that lives on your machine, asks before it acts, and remembers what matters.</h3>
<p align="center">
- <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/v/@cosmicstack/mercury-agent" alt="npm"></a>
- <a href="https://github.com/cosmicstack-labs/mercury-agent"><img src="https://img.shields.io/github/license/cosmicstack-labs/mercury-agent" alt="license"></a>
- <a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@cosmicstack/mercury-agent" alt="node"></a>
+ <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/v/@cosmicstack/mercury-agent?color=0ea5e9&label=npm" alt="npm version"></a>
+ <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/dt/@cosmicstack/mercury-agent?color=0ea5e9&label=downloads" alt="total npm downloads"></a>
+ <a href="https://github.com/cosmicstack-labs/mercury-agent/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/cosmicstack-labs/mercury-agent/ci.yml?branch=main&label=CI" alt="CI"></a>
+ <a href="https://github.com/cosmicstack-labs/mercury-agent/stargazers"><img src="https://img.shields.io/github/stars/cosmicstack-labs/mercury-agent?style=flat&color=f59e0b" alt="GitHub stars"></a>
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@cosmicstack/mercury-agent?color=16a34a" alt="node"></a>
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/cosmicstack-labs/mercury-agent?color=64748b" alt="MIT license"></a>
+ <a href="https://discord.gg/5emMpMJy5J"><img src="https://img.shields.io/badge/discord-join-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
</p>
<p align="center">
- <strong>🔖 Current Stable: v1.3.9 — Steady Mercury</strong>
-</p>
-
-<p align="center">
- English | <a href="README.zh-CN.md">简体中文</a>
+ <a href="https://mercuryagent.sh">Website</a> ·
+ <a href="https://mercuryagent.sh/docs">Docs</a> ·
+ <a href="#quickstart">Quickstart</a> ·
+ <a href="CHANGELOG.md">Changelog</a> ·
+ <a href="https://discord.gg/5emMpMJy5J">Discord</a> ·
+ <a href="README.zh-CN.md">简体中文</a>
</p>
---
-## Quick Start
-
-**One-liner install (no Node.js required)** — downloads the latest standalone binary for your OS:
-
-```bash
-# macOS / Linux
-curl -fsSL https://mercuryagent.sh/install.sh | sh
-```
-
-```powershell
-# Windows
-irm https://mercuryagent.sh/install.ps1 | iex
-```
-
-Or via npm if you already have **Node.js 22+** (required since 1.3.1 — binaries carry their own runtime):
-
-```bash
-npx @cosmicstack/mercury-agent
-```
-
-Or install the npm package globally:
+Mercury is an open-source AI agent you run yourself. It works from your terminal, Telegram, Discord, Slack, Signal and a local web dashboard, all backed by one runtime on your machine. It can read and write files, run commands, use git and GitHub, browse the web and schedule work, and every one of those actions goes through a permission system you control. It keeps a structured long-term memory in a local SQLite database, stays inside a daily token budget, and keeps running in the background after you close the terminal.
-```bash
-npm i -g @cosmicstack/mercury-agent
-mercury
-```
+On top of the agent you talk to, Mercury ships **Mercury Code**, a full-screen coding environment for working inside a repository, and **Mercury Bots**, a fleet of persistent specialist agents that work on their own schedule and deliver files you can open.
-First run triggers the setup wizard (name, provider, optional channels). After setup, Mercury opens the Ink TUI startup screen and asks for your permission mode (`Ask Me` or `Allow All`) before chat starts.
+## At a glance
-To reconfigure later (change keys, name, settings):
+| | |
+|---|---|
+| **Install** | One-line installer with no Node.js required, or `npm i -g @cosmicstack/mercury-agent` on Node.js 22+ |
+| **Runs on** | macOS, Linux, Windows, and Android via Termux |
+| **Talk to it from** | Terminal UI, Telegram, Discord, Slack, Signal, and a local web dashboard |
+| **Models** | DeepSeek, OpenAI, Anthropic, Grok, Ollama (cloud and local), LM Studio, any OpenAI-compatible endpoint, Mercury Cloud, and more, with automatic fallback |
+| **Safety** | Shell blocklist, per-folder read/write scopes, approval prompts, SSRF-guarded fetches, secret redaction in logs |
+| **Memory** | Second Brain: typed, deduplicated facts in SQLite with full-text search, all on your disk |
+| **Tools** | About 50 built in (files, shell, git, GitHub, web, scheduler, memory, sub-agents) plus installable skills |
+| **Always on** | Background daemon with crash recovery and a login service on every OS |
+| **License** | MIT |
-```bash
-mercury doctor
-mercury doctor --platform
-```
-
-## Why Mercury?
+## Why Mercury
-Every AI agent can read files, run commands, and fetch URLs. Most do it silently. **Mercury asks first — and remembers what matters.**
+Most agents can read files, run commands and fetch pages. The differences are in what happens around those actions, and that is where Mercury puts its effort.
-- **Permission-hardened** — Shell blocklist (`sudo`, `rm -rf /`, swapped-flag `rm -fr` variants, and friends never execute). Folder-level read/write scoping per channel, per sender role. Pending approval flow with arrow-key pickers in the TUI. Ask Me or Allow All per session. Members on shared channels can't install skills — escalation paths stay with admins.
-- **Second Brain** — Persistent, structured memory with SQLite + FTS5 full-text search. 10 memory types, auto-extraction, conflict resolution, auto-consolidation. Mercury learns your preferences, goals, and habits without manual entry.
-- **Soul-driven** — Personality defined by markdown files you own (`soul.md`, `persona.md`, `taste.md`, `heartbeat.md`). No corporate wrapper.
-- **Token-aware** — Daily budget enforcement. Token Saver Mode engages automatically under pressure and trims context (tuned via `/saver`). `/budget` to check, reset, or override.
-- **Mercury Code** — A full-screen, repo-aware coding environment (`mercury code` or `/code`): plan + execute in one AUTO flow, live plan checklist, background sub-agents, `/code agent` delegation, honest completion banners with per-file diffs.
-- **Mercury Bots fleet** — Persistent specialist bots with their own persona, provider, scoped memory, and permissions. Onboard and steer from the TUI (`/bots`), the web cockpit, the HTTP API, or chat. They run fail-closed, never block the main agent, and hand work back through a deliverables inbox.
-- **Five messaging channels** — CLI, Telegram, Discord, Slack, and Signal (end-to-end encrypted via `signal-cli`).
-- **Always on** — Run as a background daemon on any OS. Auto-restarts on crash with a crash-flag report. Starts on boot. Cron scheduling, heartbeat monitoring, and proactive notifications.
-- **Extensible** — Install community skills from the registry with a single command. Schedule skills as recurring tasks. Based on the [Agent Skills](https://agentskills.io) specification. A default `web-search` skill is seeded on first run in `~/.mercury/skills/web-search/SKILL.md`.
+**It asks before it acts.** File access is scoped per folder, shell commands pass through a blocklist and an approval step, and outbound requests are checked against private address ranges. You choose per session whether Mercury asks every time or runs freely, and members of a shared Telegram or Discord channel cannot widen their own access.
-New in this line: **Mercury Code** (completion contract, AUTO mode, live plan checklists, stall watchdog, compact-on-pressure, live thinking preview, wheel-scrollable transcripts), **Discord / Slack / Signal channels**, the **Mercury Bots fleet** with a web cockpit, **Mercury Cloud** pairing, SSRF guards on outbound fetches, randomized initial web-dashboard passwords, and secret redaction in logs.
+**It remembers you without being told to.** After each conversation Mercury extracts a few durable facts (preferences, goals, projects, decisions) with confidence scores, resolves conflicts with what it already knows, and recalls the relevant ones before the next answer. Everything lives in a SQLite file under `~/.mercury`, and `/memory` lets you inspect, pause or clear it.
-## Channels
-
-| Channel | Access model | Highlights |
-|---------|--------------|------------|
-| **CLI** | Single user | Ink TUI with live streaming, `/menu` picker, permission prompts, Mercury Code screens, background task bar |
-| **Telegram** | Admin + member roles, pairing codes | HTML formatting, editable streaming messages, file uploads, typing indicators, skill installs (admin-only) |
-| **Discord** | Admin role (default: `Mercury Admin`), guild/channel scoping | Slash commands, streaming edits, rich embeds, DM + channel support, rate limiting |
-| **Slack** | Admin + member | Socket Mode (no public endpoint), streaming edits, @mention awareness, `/mercury` slash command |
-| **Signal** | Pairing codes | End-to-end encrypted via `signal-cli` bridge, group + DM modes, phone-number redaction. Linux (x64/ARM64) native; macOS needs Java 17+; Windows unsupported |
+**It respects a budget.** A daily token budget is enforced on every turn. When usage climbs, Token Saver mode trims context and can route routine work to a cheaper model. `/budget` shows where you stand.
-All channels share one tool registry, permission system, and Second Brain — configure more than one and they route notifications by priority (Signal → Telegram → Discord → Slack → CLI).
+**It is one runtime, not a collection of scripts.** A single background process owns your channels, your bots and the web dashboard. Running `mercury` in a terminal attaches to that process instantly, so closing the terminal never stops a running task or a bot.
-### CLI Shortcuts
+**It writes code like a careful engineer.** Mercury Code plans and builds in one flow, shows a live checklist, asks once before large changes, and only reports success after a build, test or typecheck actually passes.
-- `Ctrl+P` → switch to Plan mode · `Ctrl+X` → Execute mode · `Esc`/`Ctrl+Q` → exit workspace · `Ctrl+V` → toggle progress view (`/view` fallback)
-- `/menu` opens the arrow-key command picker.
+**It works while you are away.** Mercury Bots are persistent specialists with their own persona, model, memory, permissions and daily budget. They run on schedules, hand work to each other, and deliver finished files to `~/Documents/Mercury/<Bot name>/`. You can manage the whole fleet from Telegram with buttons.
-### Spotify in the TUI
+**You own the personality.** Mercury's character is defined by plain Markdown files (`soul.md`, `persona.md`, `taste.md`, `heartbeat.md`) that you can edit.
-Keyboard shortcuts: `N` next, `P` previous, `+`/`-` volume, `Z` now playing. Inline album art is safe-gated: enable with `MERCURY_SPOTIFY_ART=1`; renders only in local iTerm sessions and falls back to text-only elsewhere.
+## Quickstart
-## Mercury Code
-
-Mercury Code is Mercury's full-screen programming environment — it turns the agent into a senior engineer embedded in your repo.
+**1. Install.** The installer downloads a standalone binary for your OS and CPU and verifies its checksum. No Node.js needed.
```bash
-mercury code [dir] # open Mercury Code in a directory
-/code # enter Mercury Code from the running agent
+# macOS / Linux
+curl -fsSL https://mercuryagent.sh/install.sh | sh
```
-- **AUTO mode (default)** — plan and build in one flow. Large/consequential changes get one confirmation before code is written; everything else just happens.
-- **Completion contract** — every task ends in a verdict: verified completion (evidence-gated: a build/test/typecheck must actually run) or an honest pause naming its blocker. Tasks can't fake success or die silently.
-- **Live plan checklist** — every step visible as pending → active → done.
-- **Background delegation** — `/code agent <task>` hands coding work to a sub-agent while you keep chatting.
-- **Guardrails** — stall watchdog (3 min → pulse, 8 min → resume), compact-on-pressure memory handling, write-truncation recovery, provider fallback mid-task.
-- **Workspace IDE** — `/ws` to browse files, stage, commit (`Mercury` co-authors), and undo changes; `/code diff` shows colored working-tree diffs.
-
-## Mercury Bots
-
-Bots are persistent, persona-scoped specialists that live alongside the main agent. Each has its own character, provider/model, scoped memory, and tool permissions — configured once at onboarding, then fully automatic. Bots fail closed (a missing permission is a denial, not a mid-run question), run as async work in the same process, and never block the main agent.
-
-- **Onboard** via the guided wizard: `/bots` in the TUI, the web cockpit, or `POST /api/bots`
-- **Fleet nesting** — leads and crews; bundles export/import a whole fleet (personas + manifests + permissions)
-- **Surfaces** — `/bots` TUI panel, web cockpit with live SSE activity and a deliverables inbox (`outputs/<botId>/`), local HTTP API, and Mercury Cloud relay
-- **Ops hygiene** — per-bot journal, DLQ replay, retention caps on disk, `mercury bots doctor` for fleet health
-
-Full design and decision log: [BOTS-ARCHITECTURE.md](BOTS-ARCHITECTURE.md).
-
-## Daemon Mode
-
-**One command to make Mercury persistent:**
-
-```bash
-mercury up
+```powershell
+# Windows (PowerShell)
+irm https://mercuryagent.sh/install.ps1 | iex
```
-This installs the system service (if not installed), starts the background daemon, and ensures Mercury is running. If Mercury is already running, `mercury up` just confirms it and shows the PID.
-
-Crash recovery: a crash flag (`~/.mercury/.crash-flag`) records ungraceful exits and reports on next startup; the watchdog restarts crashed daemons with exponential backoff (up to 10 restarts per minute) and escalates to a hard stop with last-gasp logging.
-
-### Other daemon commands
+Prefer npm? Mercury needs **Node.js 22 or newer** on that path.
```bash
-mercury restart # Restart the background process
-mercury stop # Stop a background process
-mercury start -d # Start in background (without service install)
-mercury attach # Attach this terminal to an already-running runtime
-mercury logs # View recent daemon logs
-mercury status # Show if daemon is running
+npm i -g @cosmicstack/mercury-agent
```
-In daemon mode, Telegram becomes your primary channel — CLI input goes through `mercury attach` instead, which gives you the full TUI (chat, streaming, `/`-commands) against the existing runtime.
-
-## CLI Commands
-
-| Command | Description |
-|---------|-------------|
-| `mercury up` | **Recommended.** Install service + start daemon + ensure running |
-| `mercury` | Start the agent (same as `mercury start`) |
-| `mercury start [-d]` | Start in foreground or background (daemon) |
-| `mercury attach` | Attach a terminal to an already-running runtime |
-| `mercury code [dir]` | Open the Mercury Code TUI in a directory |
-| `mercury restart` / `mercury stop` | Restart / stop the background process |
-| `mercury logs` | View recent daemon logs |
-| `mercury doctor [--platform]` | Reconfigure setup; `--platform` shows compatibility diagnostics |
-| `mercury setup` | Re-run the setup wizard |
-| `mercury status` | Show config and daemon status |
-| `mercury telegram <sub>` | list / approve / reject / remove / promote / demote / reset access |
-| `mercury signal <sub>` | approve / unpair / reset / status / register / unregister |
-| `mercury discord <sub>` | list / approve / reject / remove / reset / status |
-| `mercury slack <sub>` | list / approve / reject / remove / reset / status |
-| `mercury bots <sub>` | doctor (health check) / list / storage — fleet tooling |
-| `mercury skills <sub>` | search / browse / view / install / remove / update / doctor |
-| `mercury cloud <sub>` | connect / disconnect / status / login / models — Mercury Cloud pairing |
-| `mercury service <sub>` | install / uninstall / status (auto-start on boot) |
-| `mercury web-reset-password` | Reset the web dashboard password |
-| `mercury upgrade` | Upgrade to the latest version |
-| `mercury uninstall [--purge-data]` | Remove Mercury (optionally all data) |
-| `mercury help` | Show the full manual |
-| `mercury --verbose` | Start with debug logging |
-
-## In-Chat Commands
-
-Type these during a conversation — they don't consume API tokens. Highlights (full list: `/help`):
-
-| Command | Description |
-|---------|-------------|
-| `/menu` | Arrow-key command picker |
-| `/status` | Show config, budget, and usage |
-| `/tools`, `/skills` | List loaded tools / installed skills |
-| `/models` | List providers; `/models use <provider>` to switch (persisted) |
-| `/stream` | Toggle Telegram text streaming |
-| `/budget` | Show/override/reset/set token budget |
-| `/saver` | Token Saver Mode status, on/off, threshold, cheap-provider routing |
-| `/permissions` | Change permission mode (Ask Me / Allow All) |
-| `/view` | Toggle progress view (balanced/detailed) |
-| `/code` | Enter/exit Mercury Code (`/code chat` returns to chat) |
-| `/research [topic]` | Toggle deep research mode (web research + rich article output) |
-| `/ws` | Workspace IDE mode (open, stage, commit, undo, refresh, exit) |
-| `/bg` | Background tasks — list, current, cancel, clear, killall |
-| `/agents` | Sub-agents — list, stop, pause, resume, resource config |
-| `/memory` | View and manage Second Brain memory |
-| `/sessions` / `/session` | List, switch, archive, delete sessions |
-| `/cloud` | Mercury Cloud models (`/cloud models`, `/cloud use <id>`) |
-| `/spotify` | Connection status, auth flows, interactive player (CLI) |
-| `/bots` | Mercury Bots fleet panel — onboard, edit, journal, enable/disable |
-| `/halt` / `/stop` / `/reset` | Emergency stops: agents + queue (+ locks, + context) |
-| `/whatsnew` | What's new in this Mercury version |
-| `/unpair` | Reset channel access (Telegram, admins only) |
-
-## Built-in Tools
-
-~50 tools are registered dynamically based on enabled capabilities:
-
-| Category | Tools |
-|----------|-------|
-| **Filesystem** | `read_file`, `write_file`, `create_file`, `edit_file`, `list_dir`, `delete_file`, `send_file`, `approve_scope` |
-| **Shell** | `run_command`, `cd`, `approve_command` |
-| **Messaging** | `send_message` |
-| **Git** | `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_push` |
-| **GitHub** | `create_pr`, `review_pr`, `list_issues`, `create_issue`, `github_api` (auto-registered when `GITHUB_TOKEN` is set) |
-| **Web** | `fetch_url` (SSRF-guarded, private-range blocked, size-capped) |
-| **Skills** | `install_skill`, `list_skills`, `use_skill` |
-| **Scheduler** | `schedule_task`, `list_scheduled_tasks`, `cancel_scheduled_task` |
-| **Memory** | `save_memory`, `search_memory` |
-| **Budget** | `budget_status` |
-| **Spotify** | `spotify_search`, `spotify_play`, `spotify_pause`, `spotify_next`, `spotify_previous`, `spotify_now_playing`, `spotify_devices`, `spotify_queue`, `spotify_like`, `spotify_volume`, `spotify_shuffle`, `spotify_repeat`, `spotify_top_tracks`, `spotify_playlists` |
-| **Sub-agents** | `delegate_task`, `list_agents`, `stop_agent` |
-| **Bot fleet** | `dispatch_bot` (hand tasks to Mercury Bots) |
-| **Interaction** | `ask_user`, `update_plan` |
-
-## Installing Skills
-
-Mercury can pull community-contributed skills from the registry at
-**[skills.mercuryagent.sh](https://skills.mercuryagent.sh)** (126+ skills, no auth required).
+**2. Run it.**
```bash
-mercury skills search prompt # search the registry
-mercury skills browse ai-ml # browse by category
-mercury skills view ai-ml/prompt-engineering # render SKILL.md in the terminal
-mercury skills view ai-ml/prompt-engineering --web # open the registry page
-mercury skills install ai-ml/prompt-engineering # install to ~/.mercury/skills/
-mercury skills list # show installed skills
-mercury skills update # refresh all installed skills
-mercury skills remove ai-ml/prompt-engineering
-mercury skills doctor # check install root + registry
+mercury
```
-Installed skills land at `~/.mercury/skills/<category>/<slug>/SKILL.md` and are
-picked up by the agent on the next boot — they're treated identically to
-built-in skills.
-
-> **Review before you ship.** Skills are community-contributed and unaudited.
-> Run `mercury skills view <id>` before installing.
-
-Overrides: `--registry <url>` (or `MERCURY_SKILLS_REGISTRY`) for self-hosted
-registries, `MERCURY_SKILLS_INSTALL_ROOT` for an alternate install path,
-`--json` for machine-readable output.
-
-**Also installable from:**
-
-- **Web dashboard** — `http://127.0.0.1:6174/skills` has a registry installer (paste `category/slug`) and a URL installer side by side.
-- **Telegram** — `/skills`, `/skills search <q>`, `/skills view <id>`, `/skills install <id>` (admin-only). Every result includes the registry URL so you can review before installing.
+The first run starts a short setup wizard: your name, the agent's name, Mercury Cloud or your own API keys, and optional channels such as Telegram. Mercury then starts its background service and opens the terminal UI.
-See the [Skills reference](https://mercuryagent.sh/docs/reference/skills) for the full command surface, frontmatter spec, and API endpoints.
-
-## Web Dashboard
-
-Mercury includes a built-in web UI at `http://127.0.0.1:6174` (port via `MERCURY_PORT` or `web.port`):
+**3. Use it every day.**
```bash
-mercury doctor # Enable web during setup
+mercury # open a chat (attaches to the running Mercury)
+mercury code . # open Mercury Code in the current repository
+mercury doctor # change providers, keys or channels; applies immediately
+mercury status # see what is running
```
-Or set in `~/.mercury/mercury.yaml`:
-
-```yaml
-web:
- enabled: true
- port: 6174
+Upgrades are one command: `mercury upgrade`. It does nothing if you are already on the latest version.
+
+## How it works
+
+```mermaid
+flowchart LR
+ subgraph You
+ T[Terminal UI]
+ TG[Telegram]
+ DC[Discord / Slack / Signal]
+ W[Web dashboard]
+ end
+ subgraph Runtime["Mercury runtime (one background process)"]
+ A[Agent loop]
+ P[Permissions]
+ M[(Second Brain<br/>SQLite)]
+ B[Mercury Bots]
+ S[Scheduler]
+ end
+ LLM[LLM providers<br/>with fallback]
+ T -- attach --> A
+ TG --> A
+ DC --> A
+ W --> A
+ A --> P
+ A <--> M
+ A --> LLM
+ B --> LLM
+ S --> A
+ S --> B
```
-Features: chat with SSE streaming, Kanban boards, Mercury Bots cockpit (fleet roster, onboarding wizard, deliverables inbox), Second Brain visualization, Workspace IDE, provider/skill/permission/schedule management, usage tracking, dark/light theme, WebSocket relay for Mercury Cloud.
-
-The first-run web password is **randomly generated** and displayed once so you can log in and change it (a hardcoded default from a public repo would be a known credential the moment the source ships). Reset later with `mercury web-reset-password`. Credentials are written `0600`, and the dashboard binds to localhost only.
-
-## Kanban Boards
-
-Persistent task boards with agent execution. Create boards, add cards, and let Mercury process them autonomously.
-
-- **Cards** — title, description, status (todo/doing/done/blocked), priority, labels, comments, attachments, dependencies
-- **Smart execution** — Mercury processes cards sequentially, updating status and leaving result comments
-- **Cascade execution** — process dependent cards in dependency order (web fleet step mirrors the TUI)
-- **Token budget** — per-card token tracking with auto-pause when exhausted
-- **Storage** — SQLite with per-board context, variables, and instructions
-
-Access via Web Dashboard or API (`/api/boards/*`).
-
-## Scheduler
-
-- **Recurring**: `schedule_task` with cron expressions (`0 9 * * *` for daily at 9am)
-- **One-shot**: `schedule_task` with `delay_seconds` (e.g. 15 seconds)
-- Tasks persist to `~/.mercury/schedules.yaml` and restore on restart
-- Responses route back to the channel where the task was created
+The runtime runs as a login service (LaunchAgent on macOS, systemd on Linux, Task Scheduler on Windows) and restarts itself after a crash. Every channel talks to the same agent, the same permissions and the same memory. The terminal is a client: `mercury` attaches to the runtime, and `mercury code` opens a coding session beside it.
-## Second Brain
+## Features
-Mercury builds a structured, persistent memory that grows with every conversation. Enabled by default, it automatically extracts, stores, and recalls facts about you.
+### Channels
-- **10 memory types** — identity, preference, goal, project, habit, decision, constraint, relationship, episode, reflection
-- **Automatic extraction** — after each conversation, Mercury pulls 0–3 facts with confidence, importance, and durability scores
-- **Relevant recall** — before each message, the top matching memories (bounded budget) are injected into context
-- **Auto-consolidation** — every 60 min, Mercury builds a profile summary, active-state summary, and generates reflections from patterns
-- **Conflict resolution** — opposing memories are resolved by confidence (higher wins) or recency (newer wins)
-- **Auto-pruning** — active-scope memories go stale after 21 days; inferred memories decay; low-confidence durable memories are dismissed after 120 days
-- **Graceful on constrained devices** — when native `better-sqlite3` isn't available (old Node, Termux), Mercury degrades cleanly instead of crashing
-- **User controls** — `/memory` for overview, search, pause, resume, and clear
-- **Disable** — `SECOND_BRAIN_ENABLED=false` env var or `memory.secondBrain.enabled: false` in config
-
-All data stays on your machine in `~/.mercury/memory/second-brain/second-brain.db` (SQLite + FTS5). No cloud.
-
-## Configuration
-
-All runtime data lives in `~/.mercury/` — not in your project directory.
+| Channel | Access model | Highlights |
+|---|---|---|
+| **Terminal** | Single user | Full-screen UI with live streaming, a command picker (`/menu`), approval prompts, background tasks |
+| **Telegram** | Admins and members, pairing codes | Streaming replies, file delivery, inline buttons for approvals and bot control |
+| **Discord** | Admin role, guild and channel scoping | Slash commands, streaming edits, DMs and channels |
+| **Slack** | Admins and members | Socket Mode (no public endpoint), streaming edits, `/mercury` command |
+| **Signal** | Pairing codes | End-to-end encrypted through `signal-cli`, groups and DMs |
+| **Web** | Local login | Chat, Kanban, bots cockpit, memory explorer, providers and skills |
-| Path | Purpose |
-|------|---------|
-| `~/.mercury/mercury.yaml` | Main config (providers, channels, budget) |
-| `~/.mercury/.env` | API keys and tokens (loaded alongside project .env) |
-| `~/.mercury/soul/*.md` | Agent personality (soul, persona, taste, heartbeat) |
-| `~/.mercury/permissions.yaml` | Capabilities and approval rules |
-| `~/.mercury/skills/` | Installed skills |
-| `~/.mercury/schedules.yaml` | Scheduled tasks |
-| `~/.mercury/token-usage.json` | Daily token usage tracking |
-| `~/.mercury/sessions/` | Canonical session store |
-| `~/.mercury/memory/short-term/` | Per-conversation JSON files |
-| `~/.mercury/memory/long-term/` | Auto-extracted facts (JSONL) |
-| `~/.mercury/memory/episodic/` | Timestamped event log (JSONL) |
-| `~/.mercury/memory/second-brain/` | Structured memory database (SQLite + FTS5) |
-| `~/.mercury/bots/` | Mercury Bots — personas, journals, queues, permissions per bot |
-| `~/.mercury/web-config.json` | Web dashboard credentials (0600) |
-| `~/.mercury/.crash-flag` | Crash recovery report (auto-cleared) |
-| `~/.mercury/daemon.pid` | Background process PID |
-| `~/.mercury/daemon.log` | Daemon mode logs |
-| `~/.mercury/boards.db` | Kanban boards database (SQLite) |
+When more than one channel is configured, notifications go to the first available one in order: Signal, Telegram, Discord, Slack, terminal.
-## Mercury Cloud
+### Mercury Code
-Mercury can pair with [Mercury Cloud](https://mercuryagent.sh) for hosted chat, cross-instance relay, and cloud models:
+A full-screen coding environment that works inside a repository.
```bash
-mercury cloud connect # terminal pairing
-mercury cloud status
-mercury cloud disconnect
+mercury code [dir] # from the shell
+/code # from a running chat
```
-Your local agent stays the source of truth — the cloud connection relays commands and bot activity; `mercury cloud disconnect` removes the pairing.
+- **AUTO mode:** plans and builds in one pass, and asks once before large or risky changes.
+- **Verified completion:** a task ends as done only when a build, test or typecheck ran and passed. Otherwise it stops and names the blocker.
+- **Live plan:** every step is shown as pending, active or done.
+- **Background work:** `/code agent <task>` hands a task to a sub-agent while you keep working.
+- **Workspace view:** `/ws` to browse, stage, commit and undo; `/code diff` for a colored diff.
-## Provider Fallback
+### Mercury Bots
-Configure multiple LLM providers. Mercury tries them in order and falls back automatically, remembering the last successful provider:
+Persistent specialist agents that run next to the main agent without blocking it.
-| Provider | Default Model | API Key | Notes |
-|----------|--------------|---------|-------|
-| **DeepSeek** | deepseek-chat | `DEEPSEEK_API_KEY` | Default, cost-effective |
-| **OpenAI** | gpt-4o-mini | `OPENAI_API_KEY` | Also covers OpenAI-compatible endpoints |
-| **Anthropic** | claude-sonnet-4 | `ANTHROPIC_API_KEY` | Claude Sonnet, Haiku, Opus |
-| **Grok (xAI)** | grok-4 | `GROK_API_KEY` | OpenAI-compatible endpoint |
-| **Atlas Cloud** | qwen/qwen3.5-flash | `ATLASCLOUD_API_KEY` | OpenAI-compatible |
-| **AI/ML API** | anthropic/claude-sonnet-4.6 | `AIMLAPI_API_KEY` | OpenAI-compatible aggregator |
-| **MiMo (Xiaomi)** | mimo-v2.5-pro | `MIMO_API_KEY` | + `MIMO_TOKEN_PLAN_*` subscription variant |
-| **Ollama Cloud** | gpt-oss:120b | `OLLAMA_CLOUD_API_KEY` | Remote Ollama via API |
-| **Ollama Local** | — | No key needed | Routed through OpenAI chat-compat for v1 spec stability |
-| **LM Studio** | — | No key needed | Local desktop app |
-| **OpenAI-compatible** | — | `OPENAI_COMPAT_API_KEY` | Self-hosted or third-party base URL |
-| **Mercury Cloud** | mercury-mini | `MERCURY_CLOUD_AGENT_API_KEY` | Cloud agent models via `mercury cloud` |
+- **Onboard** with `/bots create` from the terminal, Telegram or the web dashboard: persona, permission tier, solo or fleet, daily budget.
+- **Fleets:** a lead bot delegates typed tasks to its crew, runs pipelines defined in `bot.yaml`, and gets one summary when the work is done.
+- **Deliverables:** finished files land in `~/Documents/Mercury/<Bot name>/`, with work in progress under `work/`. On Telegram, results arrive as attached files.
+- **Governed:** per-turn limits, a daily token budget per bot and per fleet, outcomes judged from what the bot actually did, routines that cool down instead of burning tokens.
+- **Operate:** `/bots` roster with Stop, Start and Run buttons on Telegram; `/bots cost`, `/bots show`, `/bots doctor`, `/bots stop all`.
-Plus community-driven compat providers (LiteLLM, GitHub Copilot model endpoints) discoverable via `mercury doctor`.
+Design notes: [BOTS-ARCHITECTURE.md](BOTS-ARCHITECTURE.md).
-> **Custom endpoints** — anything OpenAI-compatible works via `OPENAI_COMPAT_BASE_URL` + a model name; no first-class provider needed.
+### Second Brain
-## Architecture
+- **10 memory types:** identity, preference, goal, project, habit, decision, constraint, relationship, episode, reflection.
+- **Automatic extraction** of up to three facts per conversation, with confidence, importance and durability scores.
+- **Recall** of the most relevant memories before each answer, within a fixed budget.
+- **Consolidation** every hour into a profile and an active-state summary; stale and low-confidence facts age out.
+- **Local only:** `~/.mercury/memory/second-brain/second-brain.db` (SQLite with FTS5). Turn it off with `memory.secondBrain.enabled: false`.
-- **TypeScript + Node.js 22+** — ESM, tsup build
-- **Vercel AI SDK v6** — `generateText` + `streamText`, agentic step loop, provider fallback, OpenAI-compat routing
-- **grammY** — Telegram bot with typing indicators, editable streaming, auto-retry, and file uploads
-- **discord.js / @slack/bolt / signal-cli** — Discord, Slack (Socket Mode), and E2E-encrypted Signal bridges
-- **Hono + @hono/node-server** — local web dashboard, REST API, SSE activity feeds, WS cloud relay
-- **SQLite + FTS5** — Second brain and Kanban boards with full-text search, conflict resolution, auto-consolidation
-- **JSONL** — Short-term, long-term, and episodic conversation memory
-- **Bot manager** — persona-scoped fleet with queues, journals, retention caps, and fail-closed permissions
-- **Daemon manager** — background spawn + PID file + watchdog crash recovery + crash flags
-- **System services** — macOS LaunchAgent, Linux systemd, Windows Task Scheduler (standalone-binary aware)
-- **ink + React** — terminal UI with static transcripts, live regions, mouse-scroll filtering
-- **pino** — structured logging with secret redaction
+### Permissions and safety
-## Build From Source
+- **Shell:** a blocklist that cannot be overridden (`sudo`, `rm -rf /` and its variants), plus approval for everything outside your allowed scopes.
+- **Files:** read and write scopes per folder, per channel and per role.
+- **Network:** `fetch_url` blocks private address ranges and caps response sizes.
+- **Modes:** *Ask Me* or *Allow All* per session, changeable with `/permissions`.
+- **Secrets:** API keys live in `~/.mercury/.env`, logs redact them, and the dashboard password is random on first run.
-You can build Mercury yourself from source — either the standard Node bundle (for `npm link` / local development) or a **standalone executable** that bundles the entire runtime, so end-users don't need Node.js installed at all.
+Report a vulnerability through [SECURITY.md](SECURITY.md).
-### Prerequisites
+### Skills
-- **Node.js ≥ 20** (for the build toolchain)
-- **[Bun](https://bun.sh) ≥ 1.3** (only required for standalone binaries; install with `curl -fsSL https://bun.sh/install | bash`)
+Install community skills from [skills.mercuryagent.sh](https://skills.mercuryagent.sh), based on the [Agent Skills](https://agentskills.io) specification.
-### Standard build (ESM bundle)
+```bash
+mercury skills search prompt
+mercury skills view ai-ml/prompt-engineering # read it before installing
+mercury skills install ai-ml/prompt-engineering
+```
+
+Skills are community contributed and not audited, so review them first. They can also be installed from the web dashboard or, by admins, from Telegram.
+
+### Web dashboard, Kanban and scheduler
+
+- **Dashboard** at `http://127.0.0.1:6174`, bound to localhost: chat, bots cockpit, memory explorer, providers, skills, permissions, schedules and usage.
+- **Kanban boards** that Mercury works through card by card, in dependency order, with per-card token tracking.
+- **Scheduler:** cron schedules and one-shot delays through `schedule_task`. Results go back to the channel that created them.
+
+### Providers
+
+Mercury tries your default provider first and falls back to the others if it fails. A provider whose key is rejected is skipped until you fix the key, and `mercury doctor` warns about keys that cannot be valid.
+
+<details>
+<summary><b>Supported providers and default models</b></summary>
+
+| Provider | Default model | Key |
+|---|---|---|
+| Mercury Cloud | `mercury-mini` | paired with `mercury cloud connect` |
+| DeepSeek | `deepseek-chat` | `DEEPSEEK_API_KEY` |
+| OpenAI | `gpt-4o-mini` | `OPENAI_API_KEY` |
+| Anthropic | `claude-sonnet-4` | `ANTHROPIC_API_KEY` |
+| Grok (xAI) | `grok-4` | `GROK_API_KEY` |
+| Atlas Cloud | `qwen/qwen3.5-flash` | `ATLASCLOUD_API_KEY` |
+| AI/ML API | `anthropic/claude-sonnet-4.6` | `AIMLAPI_API_KEY` |
+| MiMo (Xiaomi) | `mimo-v2.5-pro` | `MIMO_API_KEY` |
+| Ollama Cloud | `gpt-oss:120b` | `OLLAMA_CLOUD_API_KEY` |
+| Ollama Local | your local model | none |
+| LM Studio | your local model | none |
+| OpenAI-compatible | any | `OPENAI_COMPAT_API_KEY` and `OPENAI_COMPAT_BASE_URL` |
+
+LiteLLM and GitHub Copilot endpoints are also available through `mercury doctor`.
+
+</details>
+
+## Reference
+
+<details>
+<summary><b>CLI commands</b></summary>
+
+| Command | What it does |
+|---|---|
+| `mercury` | Start Mercury, or attach to it if it is already running |
+| `mercury up` | Install the login service and make sure Mercury is running |
+| `mercury attach` | Attach this terminal to the running runtime |
+| `mercury code [dir]` | Open Mercury Code in a directory |
+| `mercury start [-d]` / `stop` / `restart` | Control the runtime |
+| `mercury status` / `logs` | Show status and recent logs |
+| `mercury doctor [--platform]` | Reconfigure; `--platform` prints a compatibility report |
+| `mercury setup` | Run the setup wizard again |
+| `mercury upgrade [--force]` | Upgrade to the latest version |
+| `mercury telegram` / `discord` / `slack` / `signal` | Manage channel access |
+| `mercury bots` | `doctor`, `list`, `storage` |
+| `mercury skills` | `search`, `browse`, `view`, `install`, `remove`, `update`, `doctor` |
+| `mercury cloud` | `connect`, `disconnect`, `status`, `login`, `models` |
+| `mercury service` | `install`, `uninstall`, `status` |
+| `mercury web-reset-password` | Reset the dashboard password |
+| `mercury uninstall [--purge-data]` | Remove Mercury, optionally with all data |
+
+</details>
+
+<details>
+<summary><b>In-chat commands</b></summary>
+
+These run locally and do not use tokens. `/help` lists everything.
+
+| Command | What it does |
+|---|---|
+| `/menu` | Command picker |
+| `/status`, `/trace [id]` | Configuration and usage; what a turn did |
+| `/new`, `/sessions` | Fresh conversation; list and switch sessions |
+| `/models` | List providers; `/models use <provider>` to switch |
+| `/budget`, `/saver` | Token budget; Token Saver mode |
+| `/permissions` | Switch between Ask Me and Allow All |
+| `/memory` | Inspect and manage the Second Brain |
+| `/code`, `/ws` | Mercury Code; workspace view |
+| `/research [topic]` | Deep research mode |
+| `/bg`, `/agents` | Background tasks; sub-agents |
+| `/bots`, `/bot <id> <task>` | Bot fleet; give a bot a task |
+| `/tools`, `/skills` | Loaded tools; installed skills |
+| `/cloud`, `/spotify` | Mercury Cloud models; Spotify controls |
+| `/stop`, `/halt`, `/reset` | Stop work, stop everything, reset context |
+| `/whatsnew` | What changed in this version |
+
+</details>
+
+<details>
+<summary><b>Built-in tools</b></summary>
+
+| Area | Tools |
+|---|---|
+| Files | `read_file`, `write_file`, `create_file`, `edit_file`, `list_dir`, `delete_file`, `send_file`, `approve_scope` |
+| Shell | `run_command`, `cd`, `approve_command` |
+| Git | `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_push` |
+| GitHub | `create_pr`, `review_pr`, `list_issues`, `create_issue`, `github_api` (when `GITHUB_TOKEN` is set) |
+| Web | `fetch_url` |
+| Skills | `install_skill`, `list_skills`, `use_skill` |
+| Scheduler | `schedule_task`, `list_scheduled_tasks`, `cancel_scheduled_task` |
+| Memory | `save_memory`, `search_memory` |
+| Agents | `delegate_task`, `list_agents`, `stop_agent`, `dispatch_bot` |
+| Interaction | `ask_user`, `update_plan`, `send_message`, `budget_status` |
+| Spotify | search, playback, queue, devices, playlists and more (when connected) |
+
+</details>
+
+<details>
+<summary><b>Files and configuration</b></summary>
+
+Everything Mercury stores lives in `~/.mercury/`, never in your project.
+
+| Path | Contents |
+|---|---|
+| `mercury.yaml` | Main configuration: providers, channels, budget, web |
+| `.env` | API keys and tokens |
+| `soul/*.md` | Personality: soul, persona, taste, heartbeat |
+| `permissions.yaml` | Scopes and approval rules |
+| `skills/` | Installed skills |
+| `schedules.yaml` | Scheduled tasks |
+| `sessions/` | Conversations |
+| `memory/second-brain/` | Second Brain database |
+| `bots/` | Bot personas, journals, queues and permissions |
+| `boards.db` | Kanban boards |
+| `daemon.log`, `daemon.pid` | Runtime log and process id |
+
+</details>
+
+## Build from source
+
+Requirements: **Node.js 22+**, and [Bun](https://bun.sh) 1.3+ only if you want standalone binaries.
```bash
git clone https://github.com/cosmicstack-labs/mercury-agent.git
cd mercury-agent
npm install
-npm run build # builds dist/ via tsup + post-build (UI, static assets)
-npm start # node dist/index.js
+npm run build # dist/ plus the web UI
+npm test # vitest
+node dist/index.js # run your build
```
-### Standalone executable (no Node.js required for end users)
-
-Mercury can be compiled into a single self-contained binary using `bun build --compile`. The resulting file embeds the Bun runtime and the full Mercury bundle.
+Standalone binaries:
```bash
-npm run build:bin # host platform only
-npm run build:bin:all # clean release: all 5 targets plus web archive and checksums
-npm run build:bin:force # rebuild (overwrite existing binary for the same version)
-npm run build:bin:all:force # replace an existing release directory, then rebuild all targets
-node scripts/verify-standalone-release.cjs # verify an already-built publishable release
+npm run build:bin # this machine only (release/smoke/)
+npm run build:bin:all # all targets: macOS arm64/x64, Linux x64/arm64 (+ no-AVX2 build), Windows x64 (+ no-AVX2 build)
```
-Output is **versioned** so older builds are never overwritten:
-
-```
-release/
-├── latest → symlink to most-recent version
-├── v1.3.1/
-│ ├── mercury-macos-arm64
-│ ├── mercury-macos-x64
-│ ├── mercury-linux-x64
-│ ├── mercury-linux-arm64
-│ ├── mercury-win-x64.exe
-│ ├── web.tar.gz
-│ └── checksums.txt (SHA-256 for downloadable binaries and web.tar.gz)
-└── smoke/ (host-only local builds; never publish)
-```
+Release binaries are unsigned. On macOS, sign with `codesign` and notarize before distributing your own builds.
-The version is read from `package.json`. Host-only smoke builds are isolated from publishable releases. `build:bin:all` refuses to reuse a non-empty version directory; use `build:bin:all:force` to delete and recreate it so assets from different revisions cannot be mixed.
+## Documentation
-**Cross-compilation**: Bun produces the JavaScript binaries for every target from a single host. Native addons such as `better-sqlite3` still require target-compatible packaging. `sql.js` is used by a narrow web API fallback; it is not a general substitute for all `better-sqlite3`-backed features.
+| Resource | |
+|---|---|
+| [mercuryagent.sh/docs](https://mercuryagent.sh/docs) | Guides, platform setup, channel setup, reference |
+| [ARCHITECTURE.md](ARCHITECTURE.md) | How the runtime is put together |
+| [BOTS-ARCHITECTURE.md](BOTS-ARCHITECTURE.md) | Bots, fleets and their governance |
+| [DECISIONS.md](DECISIONS.md) | Architecture decision records |
+| [CHANGELOG.md](CHANGELOG.md) | Every release |
+| [SECURITY.md](SECURITY.md) | Reporting vulnerabilities |
-**macOS Gatekeeper**: unsigned binaries trigger a warning on first launch. For distribution, sign with `codesign --sign "Developer ID" release/v<version>/mercury-macos-arm64` and notarize.
+## Contributing
-## License
+Contributions are welcome, from bug reports to new tools. Mercury is an agent that runs unattended for days, so a few principles matter more here than in a typical library:
-MIT © [Cosmic Stack](https://github.com/cosmicstack-labs)
+- **Every external action goes through permissions.** Files, shell, network and git never bypass the permission system or the SSRF guard.
+- **Assume no human and no terminal.** Tools must behave the same on every channel.
+- **Spend tokens carefully.** Keep tool output small; it ends up in the model's context.
+- **Fail soft.** A provider outage or a missing file should produce an honest message, not a crash.
+- **Test the loop, not only the function.** A tool that works alone can still stall a multi-step turn.
----
+Getting started:
-## Disclaimer
+1. Fork and clone the repository, then `npm install`.
+2. Make your change with tests next to it.
+3. Run `npm run lint`, `npm run typecheck` and `npm test`.
+4. Open a pull request that explains what changed and why, one change per PR.
-**This is AI - it can break sometimes, please use this at your own risk.**
-
----
+Questions are welcome on [Discord](https://discord.gg/5emMpMJy5J) or at [[email protected]](mailto:[email protected]).
-## Contributing
+## Community
-We're open to contributions! Mercury is built to evolve, and we welcome help from the community. Whether it's fixing a bug, adding a tool, improving memory, or refining the soul — all quality contributions are appreciated.
-
-### 🎯 Agentic Expertise — Must-Have for Contributors
-
-Mercury isn't just another open-source project — it's a **soul-driven agent** that runs 24/7, manages permissions, remembers context, and interacts across channels. If you're contributing, you must think like an agent builder, not just a library contributor. These are non-negotiable principles every contributor should internalize:
-
-| Principle | What It Means |
-|-----------|---------------|
-| 🧠 **Think in loops** | Mercury operates in an agentic step loop. Your tool or feature will be called multiple times per conversation. Make it idempotent where possible. |
-| 🔐 **Permission-first** | Every action that touches the outside world (files, shell, network, git) must go through the permission system. Never assume approval. |
-| 💾 **Memory-aware** | If your feature generates facts about the user, consider hooking into the Second Brain. If it reads user data, check memory first. |
-| 📏 **Token-conscious** | Mercury has a daily token budget. Logging, verbose outputs, and large context dumps burn tokens fast. Keep it lean. |
-| 🔌 **Channel-agnostic** | Tools should work identically on every channel — CLI, Telegram, Discord, Slack, Signal. Don't assume a terminal, a keyboard, or even a human on the other end. |
-| 🔁 **Graceful degradation** | If a provider fails, a tool errors, or a file doesn't exist — Mercury should recover, not crash. Always handle edge cases. |
-| 📋 **Self-documenting** | Your tool's name and description are what Mercury reads to decide when to use it. Make them clear, specific, and action-oriented. |
-| 🧪 **Test the loop, not just the function** | A tool that works in isolation may fail in the agentic loop (e.g. returns too much data, blocks the next step). Test end-to-end. |
-
-### Code Quality — Dos
-
-| Do | Why |
-|----|-----|
-| ✅ Write clean, readable TypeScript with explicit types | Mercury's codebase is type-safe — keep it that way |
-| ✅ Add JSDoc comments on public functions and tools | Helps other contributors and the agent understand intent |
-| ✅ Keep functions small and single-purpose | Easier to test, review, and reason about |
-| ✅ Use async/await over raw promises | Consistent error handling and readability |
-| ✅ Write tests for new tools and memory features | Reliability matters for a 24/7 agent |
-| ✅ Follow the existing project structure (`src/capabilities/`, `src/memory/`, `src/channels/`) | Keeps the codebase navigable |
-| ✅ Use the Agent Skills spec for new skill-based features | Ensures compatibility with the skills ecosystem |
-| ✅ Document breaking changes in PR descriptions | Helps maintainers version properly |
-
-### Code Quality — Don'ts
-
-| Don't | Why |
-|-------|-----|
-| ❌ Don't add dependencies without discussion | Mercury is lean — every dep adds surface area |
-| ❌ Don't hardcode API keys, tokens, or paths | Use config/env vars like the rest of the codebase |
-| ❌ Don't bypass the permission system, including SSRF guards | Tools must ask before acting — that's Mercury's core promise |
-| ❌ Don't introduce sync/blocking I/O in hot paths | Mercury is async-first for a reason |
-| ❌ Don't commit large binary files or secrets | Use `.gitignore` and env files |
-| ❌ Don't change the soul/persona system without discussion | It's the heart of Mercury — changes need care |
-| ❌ Don't submit untested channel or daemon changes | These are hard to debug post-merge |
-| ❌ Don't ignore the token budget system | Every tool should be mindful of token consumption |
-
-### Getting Started
-
-1. Fork the repo
-2. Run `npm install`
-3. Make your changes
-4. Run `npm run lint && npm run build` to verify it compiles (tests: `npm test`)
-5. Test with `mercury` locally
-6. Open a PR with a clear description of what you changed and why
-
-### PR Guidelines
-
-- Keep PRs focused — one feature/fix per PR
-- Include before/after behavior in the description
-- Tag related issues if applicable
-- Be responsive to review feedback
-
-### Need Help?
-
-Open an issue or reach out at [[email protected]](mailto:[email protected]). We're friendly.
+- **Discord:** [discord.gg/5emMpMJy5J](https://discord.gg/5emMpMJy5J) for help, ideas and show-and-tell.
+- **Issues:** [GitHub Issues](https://github.com/cosmicstack-labs/mercury-agent/issues) for bugs and feature requests.
----
+## License
-## Community
+[MIT](LICENSE) © [Cosmic Stack](https://github.com/cosmicstack-labs)
-1. **Discord** — [Join the Mercury Agent Discord](https://discord.gg/5emMpMJy5J) for real-time chat, support, and community discussions.
\ No newline at end of file
+Mercury is an AI agent and can make mistakes. Review what it does, especially in *Allow All* mode.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index e82d4d27..43903e1a 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -1,368 +1,395 @@
-# Mercury — 以灵魂驱动的 AI Agent
-
<p align="center">
<picture>
- <source media="(prefers-color-scheme: dark)" srcset="docs/img/card-dark.png">
- <source media="(prefers-color-scheme: light)" srcset="docs/img/card-light.png">
- <img alt="Mercury — Soul-Driven AI Agent" src="docs/img/card-light.png" width="600">
+ <source media="(prefers-color-scheme: dark)" srcset="docs/img/readme-hero-dark.png">
+ <source media="(prefers-color-scheme: light)" srcset="docs/img/readme-hero-light.png">
+ <img alt="Mercury Agent" src="docs/img/readme-hero-light.png" width="520">
</picture>
</p>
-<p align="center">
- <strong>以灵魂驱动、内置权限加固工具、Token 预算和多渠道访问的 AI Agent。</strong>
-</p>
+<h3 align="center">运行在你自己机器上的个人 AI Agent:行动前先征求同意,记得真正重要的事。</h3>
<p align="center">
- 记住重要信息。行动前先请求确认。通过 CLI 或 Telegram 全天候运行。31 个内置工具、可扩展的 Skills、基于 SQLite 的第二大脑记忆。
+ <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/v/@cosmicstack/mercury-agent?color=0ea5e9&label=npm" alt="npm version"></a>
+ <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/dt/@cosmicstack/mercury-agent?color=0ea5e9&label=downloads" alt="npm 总下载量"></a>
+ <a href="https://github.com/cosmicstack-labs/mercury-agent/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/cosmicstack-labs/mercury-agent/ci.yml?branch=main&label=CI" alt="CI"></a>
+ <a href="https://github.com/cosmicstack-labs/mercury-agent/stargazers"><img src="https://img.shields.io/github/stars/cosmicstack-labs/mercury-agent?style=flat&color=f59e0b" alt="GitHub stars"></a>
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@cosmicstack/mercury-agent?color=16a34a" alt="node"></a>
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/cosmicstack-labs/mercury-agent?color=64748b" alt="MIT license"></a>
+ <a href="https://discord.gg/5emMpMJy5J"><img src="https://img.shields.io/badge/discord-join-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
</p>
<p align="center">
- <a href="https://www.npmjs.com/package/@cosmicstack/mercury-agent"><img src="https://img.shields.io/npm/v/@cosmicstack/mercury-agent" alt="npm"></a>
- <a href="https://github.com/cosmicstack-labs/mercury-agent"><img src="https://img.shields.io/github/license/cosmicstack-labs/mercury-agent" alt="license"></a>
- <a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@cosmicstack/mercury-agent" alt="node"></a>
+ <a href="https://mercuryagent.sh">官网</a> ·
+ <a href="https://mercuryagent.sh/docs">文档</a> ·
+ <a href="#快速开始">快速开始</a> ·
+ <a href="CHANGELOG.md">更新日志</a> ·
+ <a href="https://discord.gg/5emMpMJy5J">Discord</a> ·
+ <a href="README.md">English</a>
</p>
-<p align="center">
- <strong>🔖 当前稳定版:v1.2.3</strong>
-</p>
+---
-<p align="center">
- <a href="README.md">English</a> | 简体中文
-</p>
+Mercury 是一个由你自己运行的开源 AI Agent。你可以通过终端、Telegram、Discord、Slack、Signal 以及本地 Web 控制台与它对话,它们都连接到你机器上的同一个运行时。Mercury 可以读写文件、执行命令、使用 git 和 GitHub、浏览网页、安排定时任务,而每一个动作都要经过由你掌控的权限系统。它把结构化的长期记忆保存在本地 SQLite 数据库中,遵守每日 Token 预算,并且在你关闭终端之后继续在后台运行。
----
+除了与你对话的主 Agent,Mercury 还提供 **Mercury Code**(在代码仓库中工作的全屏编程环境)和 **Mercury Bots**(一组按自己的节奏工作、并交付可直接打开的文件的常驻专家 Agent)。
+
+## 一览
+
+| | |
+|---|---|
+| **安装** | 一行命令安装,无需 Node.js;或在 Node.js 22+ 上 `npm i -g @cosmicstack/mercury-agent` |
+| **平台** | macOS、Linux、Windows,以及通过 Termux 的 Android |
+| **对话入口** | 终端界面、Telegram、Discord、Slack、Signal、本地 Web 控制台 |
+| **模型** | DeepSeek、OpenAI、Anthropic、Grok、Ollama(云端与本地)、LM Studio、任何 OpenAI 兼容端点、Mercury Cloud 等,支持自动兜底 |
+| **安全** | Shell 黑名单、按文件夹的读写范围、审批提示、带 SSRF 防护的网络请求、日志中的密钥脱敏 |
+| **记忆** | 第二大脑:类型化、去重的事实,保存在带全文检索的 SQLite 中,全部在你的磁盘上 |
+| **工具** | 约 50 个内置工具(文件、Shell、git、GitHub、网页、调度、记忆、子 Agent),以及可安装的 Skills |
+| **常驻运行** | 带崩溃恢复的后台守护进程,各操作系统均有开机自启服务 |
+| **许可证** | MIT |
+
+## 为什么选择 Mercury
+
+大多数 Agent 都能读文件、跑命令、抓网页。真正的差别在于这些动作的周围发生了什么,而这正是 Mercury 投入精力的地方。
+
+**行动前先征求同意。** 文件访问按文件夹限定范围,Shell 命令先经过黑名单和审批,对外请求会拦截内网地址。你可以按会话选择每次都询问还是放手执行;共享的 Telegram 或 Discord 频道中的成员无法自行扩大权限。
+
+**不用你开口也能记住你。** 每次对话结束后,Mercury 会提取少量持久的事实(偏好、目标、项目、决定)并附带置信度,与已有记忆进行冲突消解,并在下一次回答前召回相关内容。所有数据都保存在 `~/.mercury` 下的 SQLite 文件里,可以用 `/memory` 查看、暂停或清空。
+
+**遵守预算。** 每一轮对话都执行每日 Token 预算。用量升高时,节省模式会裁剪上下文,并可以把日常任务交给更便宜的模型。`/budget` 显示当前用量。
+
+**一个运行时,而不是一堆脚本。** 由单一的后台进程负责所有渠道、Bots 和 Web 控制台。在终端中运行 `mercury` 会立即连接到这个进程,因此关闭终端不会中断正在执行的任务或 Bot。
+
+**像谨慎的工程师一样写代码。** Mercury Code 在同一流程中完成规划与实现,显示实时清单,在大型改动前询问一次,并且只有在构建、测试或类型检查真正通过后才报告完成。
+
+**你离开时它也在工作。** Mercury Bots 是常驻的专家 Agent,各自拥有人设、模型、记忆、权限和每日预算。它们按计划运行、相互交接任务,并把完成的文件交付到 `~/Documents/Mercury/<Bot 名称>/`。你可以在 Telegram 中通过按钮管理整个 Bot 团队。
+
+**人格由你掌控。** Mercury 的性格由你可以直接编辑的 Markdown 文件定义(`soul.md`、`persona.md`、`taste.md`、`heartbeat.md`)。
## 快速开始
+**1. 安装。** 安装脚本会为你的系统和 CPU 下载独立二进制文件并校验其哈希,无需 Node.js。
+
```bash
-npx @cosmicstack/mercury-agent
+# macOS / Linux
+curl -fsSL https://mercuryagent.sh/install.sh | sh
+```
+
+```powershell
+# Windows (PowerShell)
+irm https://mercuryagent.sh/install.ps1 | iex
```
-或全局安装:
+更喜欢 npm?这种方式需要 **Node.js 22 或更高版本**。
```bash
npm i -g @cosmicstack/mercury-agent
+```
+
+**2. 运行。**
+
+```bash
mercury
```
-首次运行会触发设置向导(姓名、Provider、可选 Telegram)。设置完成后,Mercury 打开 Ink TUI 启动画面,并在聊天开始前请求权限模式(`Ask Me` 或 `Allow All`)。
+首次运行会启动一个简短的设置向导:你的名字、Agent 的名字、使用 Mercury Cloud 还是自己的 API Key,以及可选的渠道(例如 Telegram)。之后 Mercury 会启动后台服务并打开终端界面。
-之后重新配置(更改 key、名称、设置):
+**3. 日常使用。**
```bash
-mercury doctor
-mercury doctor --platform
+mercury # 打开对话(连接到正在运行的 Mercury)
+mercury code . # 在当前仓库中打开 Mercury Code
+mercury doctor # 修改模型、密钥或渠道,立即生效
+mercury status # 查看运行状态
```
-## 为什么选择 Mercury?
+升级只需一条命令:`mercury upgrade`。如果已经是最新版本,它什么也不会做。
+
+## 工作原理
+
+```mermaid
+flowchart LR
+ subgraph You["你"]
+ T[终端界面]
+ TG[Telegram]
+ DC[Discord / Slack / Signal]
+ W[Web 控制台]
+ end
+ subgraph Runtime["Mercury 运行时(单一后台进程)"]
+ A[Agent 循环]
+ P[权限]
+ M[(第二大脑<br/>SQLite)]
+ B[Mercury Bots]
+ S[调度器]
+ end
+ LLM[LLM 提供方<br/>自动兜底]
+ T -- 连接 --> A
+ TG --> A
+ DC --> A
+ W --> A
+ A --> P
+ A <--> M
+ A --> LLM
+ B --> LLM
+ S --> A
+ S --> B
+```
+
+运行时以开机服务的形式运行(macOS 上为 LaunchAgent,Linux 上为 systemd,Windows 上为任务计划程序),崩溃后会自动重启。所有渠道共享同一个 Agent、同一套权限和同一份记忆。终端只是客户端:`mercury` 连接到运行时,`mercury code` 在它旁边打开一个编程会话。
+
+## 功能
-每个 AI Agent 都能读写文件、运行命令和获取 URL。大多数默默做这些事。**Mercury 先询问 — 并且记住重要的事。**
+### 渠道
-- **权限加固** — Shell 黑名单(`sudo`、`rm -rf /` 等永不执行)。目录级读/写作用域。待批准流程。会话级"问我"或"全部允许"。无意外。
-- **第二大脑** — 基于 SQLite + FTS5 全文搜索的持久化结构化记忆。10 种记忆类型、自动提取、冲突解决、自动整合。Mercury 无需手动输入即可学习你的偏好、目标和习惯。
-- **灵魂驱动** — 人格由你拥有的 Markdown 文件定义(`soul.md`、`persona.md`、`taste.md`、`heartbeat.md`)。无企业包装。
-- **Token 感知** — 每日预算强制执行。超过 70% 时自动简洁。`/budget` 命令查看、重置或覆盖。
-- **实时流式输出** — CLI 实时 Token 流式输出,带光标保存/恢复和 markdown 重渲染。Telegram 流式输出配合可编辑状态消息。
-- **全天候运行** — 在任何操作系统上作为后台守护进程运行。崩溃后自动重启。开机自启。Crontab 调度、心跳监控和主动通知。
-- **可扩展** — 一条命令安装社区 Skills。将 Skills 调度为循环任务。基于 [Agent Skills](https://agentskills.io) 规范。
+| 渠道 | 访问模型 | 亮点 |
+|---|---|---|
+| **终端** | 单用户 | 实时流式输出的全屏界面、命令选择器(`/menu`)、审批提示、后台任务 |
+| **Telegram** | 管理员与成员,配对码 | 流式回复、文件交付、用于审批和 Bot 控制的内联按钮 |
+| **Discord** | 管理员角色,按服务器和频道限定 | 斜杠命令、流式编辑、私信与频道 |
+| **Slack** | 管理员与成员 | Socket Mode(无需公网地址)、流式编辑、`/mercury` 命令 |
+| **Signal** | 配对码 | 通过 `signal-cli` 端到端加密,支持群组和私信 |
+| **Web** | 本地登录 | 对话、看板、Bots 控制台、记忆浏览、模型与 Skills 管理 |
-Mercury 现在在首次运行时在 `~/.mercury/skills/web-search/SKILL.md` 中植入默认 `web-search` Skill。
+配置了多个渠道时,通知按以下顺序发送到第一个可用渠道:Signal、Telegram、Discord、Slack、终端。
-## 守护进程模式
+### Mercury Code
-**一条命令让 Mercury 持久化:**
+在代码仓库中工作的全屏编程环境。
```bash
-mercury up
+mercury code [dir] # 在 Shell 中
+/code # 在对话中
```
-这会安装系统服务(如果未安装)、启动后台守护进程,并确保 Mercury 正在运行。将此作为你的常用命令。
+- **AUTO 模式:** 一次完成规划与实现,在大型或高风险改动前询问一次。
+- **经过验证的完成:** 只有构建、测试或类型检查真正运行并通过,任务才会标记为完成;否则会停下并说明阻碍。
+- **实时计划:** 每一步都显示为待办、进行中或已完成。
+- **后台工作:** `/code agent <任务>` 把任务交给子 Agent,你可以继续工作。
+- **工作区视图:** `/ws` 浏览、暂存、提交和撤销;`/code diff` 显示彩色差异。
-如果 Mercury 已在运行,`mercury up` 仅确认状态并显示 PID。
+### Mercury Bots
-### 其他守护进程命令
+与主 Agent 并行运行、互不阻塞的常驻专家 Agent。
+
+- **创建:** 在终端、Telegram 或 Web 控制台中使用 `/bots create`:人设、权限级别、单独工作或团队、每日预算。
+- **团队:** 主管 Bot 把类型化任务分派给成员,运行在 `bot.yaml` 中定义的流水线,并在工作完成时收到一份汇总。
+- **交付物:** 完成的文件放在 `~/Documents/Mercury/<Bot 名称>/`,进行中的工作在 `work/` 下。在 Telegram 中,结果以附件形式送达。
+- **受控运行:** 单轮上限、每个 Bot 和每个团队的每日 Token 预算、根据实际行为判定结果、例行任务会冷却而不是持续消耗 Token。
+- **运维:** Telegram 中带有停止、启动、运行按钮的 `/bots` 列表;`/bots cost`、`/bots show`、`/bots doctor`、`/bots stop all`。
+
+设计说明:[BOTS-ARCHITECTURE.md](BOTS-ARCHITECTURE.md)。
+
+### 第二大脑
+
+- **10 种记忆类型:** 身份、偏好、目标、项目、习惯、决定、约束、关系、事件、反思。
+- **自动提取:** 每次对话最多提取三条事实,附带置信度、重要性和持久度评分。
+- **召回:** 每次回答前在固定预算内召回最相关的记忆。
+- **整合:** 每小时生成个人画像和当前状态摘要;过期和低置信度的事实会逐步淘汰。
+- **仅限本地:** `~/.mercury/memory/second-brain/second-brain.db`(SQLite + FTS5)。可通过 `memory.secondBrain.enabled: false` 关闭。
+
+### 权限与安全
+
+- **Shell:** 不可覆盖的黑名单(`sudo`、`rm -rf /` 及其变体),以及对允许范围之外操作的审批。
+- **文件:** 按文件夹、渠道和角色设置读写范围。
+- **网络:** `fetch_url` 拦截内网地址并限制响应大小。
+- **模式:** 按会话选择 *Ask Me* 或 *Allow All*,可用 `/permissions` 切换。
+- **密钥:** API Key 保存在 `~/.mercury/.env`,日志会脱敏,Web 控制台首次运行时生成随机密码。
+
+漏洞报告请参阅 [SECURITY.md](SECURITY.md)。
+
+### Skills
+
+从 [skills.mercuryagent.sh](https://skills.mercuryagent.sh) 安装社区 Skills,遵循 [Agent Skills](https://agentskills.io) 规范。
```bash
-mercury restart # 重启后台进程
-mercury stop # 停止后台进程
-mercury start -d # 后台启动(不安装服务)
-mercury logs # 查看近期守护进程日志
-mercury status # 显示守护进程是否运行
+mercury skills search prompt
+mercury skills view ai-ml/prompt-engineering # 安装前先阅读
+mercury skills install ai-ml/prompt-engineering
```
-守护进程模式内置崩溃恢复 — 如果进程崩溃,它会自动重启并使用指数退避(最高每分钟 10 次重启)。
+Skills 由社区贡献且未经审计,请先审阅。也可以在 Web 控制台安装,管理员还可以在 Telegram 中安装。
+
+### Web 控制台、看板与调度
+
+- **控制台** 位于 `http://127.0.0.1:6174`,仅绑定本机:对话、Bots 控制台、记忆浏览、模型、Skills、权限、计划任务和用量。
+- **看板:** Mercury 按依赖顺序逐张处理卡片,并记录每张卡片的 Token 用量。
+- **调度器:** 通过 `schedule_task` 设置 cron 计划或一次性延时任务,结果发回创建任务的渠道。
+
+### 模型提供方
+
+Mercury 优先使用默认提供方,失败时自动切换到其他提供方。密钥被拒绝的提供方会被跳过,直到你修正密钥;`mercury doctor` 会提示明显无效的密钥。
+
+<details>
+<summary><b>支持的提供方与默认模型</b></summary>
+
+| 提供方 | 默认模型 | 密钥 |
+|---|---|---|
+| Mercury Cloud | `mercury-mini` | 通过 `mercury cloud connect` 配对 |
+| DeepSeek | `deepseek-chat` | `DEEPSEEK_API_KEY` |
+| OpenAI | `gpt-4o-mini` | `OPENAI_API_KEY` |
+| Anthropic | `claude-sonnet-4` | `ANTHROPIC_API_KEY` |
+| Grok (xAI) | `grok-4` | `GROK_API_KEY` |
+| Atlas Cloud | `qwen/qwen3.5-flash` | `ATLASCLOUD_API_KEY` |
+| AI/ML API | `anthropic/claude-sonnet-4.6` | `AIMLAPI_API_KEY` |
+| MiMo(小米) | `mimo-v2.5-pro` | `MIMO_API_KEY` |
+| Ollama Cloud | `gpt-oss:120b` | `OLLAMA_CLOUD_API_KEY` |
+| Ollama 本地 | 你的本地模型 | 无需 |
+| LM Studio | 你的本地模型 | 无需 |
+| OpenAI 兼容 | 任意 | `OPENAI_COMPAT_API_KEY` 与 `OPENAI_COMPAT_BASE_URL` |
-### 系统服务(开机自启)
+LiteLLM 和 GitHub Copilot 端点也可以通过 `mercury doctor` 配置。
-`mercury up` 自动安装此服务。你也可以直接管理它:
+</details>
+
+## 参考
+
+<details>
+<summary><b>CLI 命令</b></summary>
+
+| 命令 | 作用 |
+|---|---|
+| `mercury` | 启动 Mercury,若已在运行则连接到它 |
+| `mercury up` | 安装开机服务并确保 Mercury 正在运行 |
+| `mercury attach` | 将当前终端连接到运行时 |
+| `mercury code [dir]` | 在指定目录打开 Mercury Code |
+| `mercury start [-d]` / `stop` / `restart` | 控制运行时 |
+| `mercury status` / `logs` | 查看状态和最近日志 |
+| `mercury doctor [--platform]` | 重新配置;`--platform` 输出兼容性报告 |
+| `mercury setup` | 重新运行设置向导 |
+| `mercury upgrade [--force]` | 升级到最新版本 |
+| `mercury telegram` / `discord` / `slack` / `signal` | 管理渠道访问 |
+| `mercury bots` | `doctor`、`list`、`storage` |
+| `mercury skills` | `search`、`browse`、`view`、`install`、`remove`、`update`、`doctor` |
+| `mercury cloud` | `connect`、`disconnect`、`status`、`login`、`models` |
+| `mercury service` | `install`、`uninstall`、`status` |
+| `mercury web-reset-password` | 重置控制台密码 |
+| `mercury uninstall [--purge-data]` | 卸载 Mercury,可选同时删除全部数据 |
+
+</details>
+
+<details>
+<summary><b>对话内命令</b></summary>
+
+这些命令在本地执行,不消耗 Token。`/help` 列出全部命令。
+
+| 命令 | 作用 |
+|---|---|
+| `/menu` | 命令选择器 |
+| `/status`、`/trace [id]` | 配置与用量;某一轮做了什么 |
+| `/new`、`/sessions` | 新对话;列出并切换会话 |
+| `/models` | 列出提供方;`/models use <provider>` 切换 |
+| `/budget`、`/saver` | Token 预算;节省模式 |
+| `/permissions` | 在 Ask Me 和 Allow All 之间切换 |
+| `/memory` | 查看和管理第二大脑 |
+| `/code`、`/ws` | Mercury Code;工作区视图 |
+| `/research [topic]` | 深度研究模式 |
+| `/bg`、`/agents` | 后台任务;子 Agent |
+| `/bots`、`/bot <id> <task>` | Bot 团队;给某个 Bot 分派任务 |
+| `/tools`、`/skills` | 已加载工具;已安装 Skills |
+| `/cloud`、`/spotify` | Mercury Cloud 模型;Spotify 控制 |
+| `/stop`、`/halt`、`/reset` | 停止当前工作、停止全部、重置上下文 |
+| `/whatsnew` | 本版本的新内容 |
+
+</details>
+
+<details>
+<summary><b>内置工具</b></summary>
+
+| 类别 | 工具 |
+|---|---|
+| 文件 | `read_file`、`write_file`、`create_file`、`edit_file`、`list_dir`、`delete_file`、`send_file`、`approve_scope` |
+| Shell | `run_command`、`cd`、`approve_command` |
+| Git | `git_status`、`git_diff`、`git_log`、`git_add`、`git_commit`、`git_push` |
+| GitHub | `create_pr`、`review_pr`、`list_issues`、`create_issue`、`github_api`(设置 `GITHUB_TOKEN` 后可用) |
+| 网页 | `fetch_url` |
+| Skills | `install_skill`、`list_skills`、`use_skill` |
+| 调度 | `schedule_task`、`list_scheduled_tasks`、`cancel_scheduled_task` |
+| 记忆 | `save_memory`、`search_memory` |
+| Agent | `delegate_task`、`list_agents`、`stop_agent`、`dispatch_bot` |
+| 交互 | `ask_user`、`update_plan`、`send_message`、`budget_status` |
+| Spotify | 搜索、播放、队列、设备、歌单等(连接后可用) |
+
+</details>
+
+<details>
+<summary><b>文件与配置</b></summary>
+
+Mercury 存储的所有内容都在 `~/.mercury/` 下,不会写入你的项目目录。
+
+| 路径 | 内容 |
+|---|---|
+| `mercury.yaml` | 主配置:提供方、渠道、预算、Web |
+| `.env` | API Key 和令牌 |
+| `soul/*.md` | 人格:soul、persona、taste、heartbeat |
+| `permissions.yaml` | 访问范围和审批规则 |
+| `skills/` | 已安装的 Skills |
+| `schedules.yaml` | 计划任务 |
+| `sessions/` | 对话记录 |
+| `memory/second-brain/` | 第二大脑数据库 |
+| `bots/` | Bot 的人设、日志、队列和权限 |
+| `boards.db` | 看板数据 |
+| `daemon.log`、`daemon.pid` | 运行时日志和进程 ID |
+
+</details>
+
+## 从源码构建
+
+要求:**Node.js 22+**;如需构建独立二进制文件,还需要 [Bun](https://bun.sh) 1.3+。
```bash
-mercury service install
+git clone https://github.com/cosmicstack-labs/mercury-agent.git
+cd mercury-agent
+npm install
+npm run build # 生成 dist/ 和 Web 界面
+npm test # vitest
+node dist/index.js # 运行你的构建
```
-| 平台 | 方式 | 需要管理员 |
-|------|------|-----------|
-| **macOS** | LaunchAgent (`~/Library/LaunchAgents/`) | 否 |
-| **Linux** | systemd user unit (`~/.config/systemd/user/`) | 否(开机自启可能需要 linger) |
-| **Windows** | Task Scheduler (`schtasks`) | 否 |
+独立二进制文件:
```bash
-mercury service status # 检查服务是否运行
-mercury service uninstall # 移除系统服务
+npm run build:bin # 仅当前机器(release/smoke/)
+npm run build:bin:all # 所有目标:macOS arm64/x64、Linux x64/arm64(含无 AVX2 版本)、Windows x64(含无 AVX2 版本)
```
-在守护进程模式下,Telegram 成为主要渠道 — CLI 是纯日志,因为没有终端输入。
-
-## CLI 命令
-
-| 命令 | 描述 |
-|------|------|
-| `mercury up` | **推荐。** 安装服务 + 启动守护进程 + 确保运行 |
-| `mercury` | 启动 Agent(等同于 `mercury start`) |
-| `mercury start` | 前台启动 |
-| `mercury start -d` | 后台启动(守护进程模式) |
-| `mercury restart` | 重启后台进程 |
-| `mercury stop` | 停止后台进程 |
-| `mercury logs` | 查看近期守护进程日志 |
-| `mercury doctor` | 重新配置(姓名、Provider、渠道、权限默认项) |
-| `mercury doctor --platform` | 显示跨平台终端/守护进程兼容性诊断 |
-| `mercury setup` | 重新运行设置向导 |
-| `mercury status` | 显示配置和守护进程状态 |
-| `mercury help` | 显示完整手册 |
-| `mercury upgrade` | 升级到最新版本 |
-| `mercury telegram list` | 列出已批准和待处理的 Telegram 用户 |
-| `mercury telegram approve <code\|id>` | 批准配对码或待处理请求 |
-| `mercury telegram reject <id>` | 拒绝待处理的 Telegram 访问请求 |
-| `mercury telegram remove <id>` | 移除已批准的 Telegram 用户 |
-| `mercury telegram promote <id>` | 将 Telegram 成员晋升为管理员 |
-| `mercury telegram demote <id>` | 将 Telegram 管理员降级为成员 |
-| `mercury telegram reset` | 清除所有 Telegram 访问并重新开始 |
-| `mercury service install` | 安装为系统服务(开机自启) |
-| `mercury service uninstall` | 卸载系统服务 |
-| `mercury service status` | 显示系统服务状态 |
-| `mercury --verbose` | 使用调试日志启动 |
-
-## 对话内命令
-
-在对话中输入这些 — 它们不消耗 API Token。CLI 和 Telegram 都适用。
-
-| 命令 | 描述 |
-|------|------|
-| `/help` | 显示完整手册 |
-| `/status` | 显示 Agent 配置、预算和用量 |
-| `/tools` | 列出所有已加载的工具 |
-| `/skills` | 列出已安装的 Skills |
-| `/stream` | 切换 Telegram 文本流式输出 |
-| `/stream off` | 禁用流式输出(单条消息) |
-| `/budget` | 显示 Token 预算状态 |
-| `/budget override` | 单次请求覆盖预算 |
-| `/budget reset` | 将用量重置为零 |
-| `/budget set <n>` | 更改每日 Token 预算 |
-| `/permissions` | 更改权限模式(问我 / 全部允许) |
-| `/view` | 切换进度视图(平衡 / 详细) |
-| `/view balanced` | 设置精简进度视图 |
-| `/view detailed` | 设置完整进度视图 |
-| `/code agent <task>` | 将编码任务委托给后台子 Agent |
-| `/ws exit` | 退出工作区 IDE 模式回到常规聊天 |
-| `/tasks` | 列出调度任务 |
-| `/memory` | 查看和管理第二大脑记忆 |
-| `/unpair` | Telegram:重置所有访问 |
-
-## 内置工具
-
-| 分类 | 工具 |
-|------|------|
-| **文件系统** | `read_file`、`write_file`、`create_file`、`edit_file`、`list_dir`、`delete_file`、`send_file`、`approve_scope` |
-| **Shell** | `run_command`、`cd`、`approve_command` |
-| **消息** | `send_message` |
-| **Git** | `git_status`、`git_diff`、`git_log`、`git_add`、`git_commit`、`git_push` |
-| **Web** | `fetch_url` |
-| **Skills** | `install_skill`、`list_skills`、`use_skill` |
-| **调度器** | `schedule_task`、`list_scheduled_tasks`、`cancel_scheduled_task` |
-| **系统** | `budget_status` |
-
-## 渠道
-
-| 渠道 | 特性 |
-|------|------|
-| **CLI** | Ink TUI、启动权限模式选择器、交互式权限提示(方向键 + Enter;Y/N/A 快捷键)、进度视图(平衡/详细)、实时流式输出 |
-| **Telegram** | HTML 格式化、可编辑流式消息、文件上传、输入状态指示器、多用户访问与管理员/成员角色 |
-
-### 工作区/编码快捷键(CLI)
-
-- `Ctrl+P` → 切换到计划模式
-- `Ctrl+X` → 切换到执行模式
-- `Esc` 或 `Ctrl+Q` → 退出工作区回到常规聊天
-- `Ctrl+V` → 切换进度视图(当终端拦截 Ctrl+V 时 `/view` 作为后备)
-
-### Spotify UI 注意事项(CLI)
-
-- Spotify 面板支持键盘快捷键:`N` 下一曲、`P` 上一曲、`+/-` 音量、`Z` 正在播放。
-- 内联专辑封面是可选的且安全屏蔽:
- - 用 `MERCURY_SPOTIFY_ART=1` 启用
- - 目前仅在本地 iTerm 会话中渲染
- - 在 SSH/移动端/轻量终端中自动回退到纯文本 UI
-
-### Telegram 访问
-
-Mercury 使用**组织访问模型**,包含管理员和成员。
-
-- **首次设置:** 向你的 Bot 发送 `/start`,收到配对码,然后在 CLI 中输入 `mercury telegram approve <code>`。你成为首位管理员。
-- **其他用户:** 发送 `/start` 请求访问。管理员从 CLI 批准或拒绝。
-- **角色:** 管理员可以批准/拒绝请求、晋升/降级用户和重置访问。成员可以与 Mercury 聊天。
-- **重置:** 管理员可以在 Telegram 发送 `/unpair`,或在 CLI 中运行 `mercury telegram reset` 清除所有访问并重新开始。
-- 仅限私聊 — 群组消息始终被忽略。
-
-CLI 命令:`mercury telegram list|approve|reject|remove|promote|demote|reset`
-
-## 调度器
-
-- **循环**:使用 cron 表达式的 `schedule_task`(`0 9 * * *` 每天 9 点)
-- **一次性**:使用 `delay_seconds` 的 `schedule_task`(例如 15 秒)
-- 任务持久化到 `~/.mercury/schedules.yaml`,重启后恢复
-- 响应路由回创建任务的渠道
-
-## 第二大脑
-
-Mercury 构建一个结构化、持久化的记忆,随每次对话增长。默认启用,自动提取、存储和召回关于你的事实。
-
-- **10 种记忆类型** — identity、preference、goal、project、habit、decision、constraint、relationship、episode、reflection
-- **自动提取** — 每轮对话后,Mercury 提取 0–3 条带置信度、重要性和持久性分数的事实
-- **相关召回** — 每次消息前,将最匹配的 5 条记忆(900 字符预算)注入上下文
-- **自动整合** — 每 60 分钟,Mercury 构建个人资料摘要、活跃状态摘要,并从模式生成反思
-- **冲突解决** — 对立记忆按置信度(更高者胜出)或新旧(更新者胜出)解决
-- **自动修剪** — 活跃作用域记忆 21 天后过期;推断记忆会衰减;低置信度持久记忆 120 天后清除
-- **用户控制** — `/memory` 用于概览、搜索、暂停、恢复和清除
-- **禁用** — `SECOND_BRAIN_ENABLED=false` 环境变量或配置中的 `memory.secondBrain.enabled: false`
-
-所有数据保留在你机器的 `~/.mercury/memory/second-brain/second-brain.db`(SQLite + FTS5)。不上云。
-
-## 配置
-
-所有运行时数据位于 `~/.mercury/` — 不在你的项目目录中。
-
-| 路径 | 用途 |
-|------|------|
-| `~/.mercury/mercury.yaml` | 主配置(Provider、渠道、预算) |
-| `~/.mercury/.env` | API key 和 Token(与项目 .env 一起加载) |
-| `~/.mercury/soul/*.md` | Agent 人格(soul、persona、taste、heartbeat) |
-| `~/.mercury/permissions.yaml` | 能力和审批规则 |
-| `~/.mercury/skills/` | 已安装的 Skills |
-| `~/.mercury/schedules.yaml` | 调度任务 |
-| `~/.mercury/token-usage.json` | 每日 Token 用量跟踪 |
-| `~/.mercury/memory/short-term/` | 每段对话的 JSON 文件 |
-| `~/.mercury/memory/long-term/` | 自动提取的事实(JSONL) |
-| `~/.mercury/memory/episodic/` | 带时间戳的事件日志(JSONL) |
-| `~/.mercury/memory/second-brain/` | 结构化记忆数据库(SQLite + FTS5) |
-| `~/.mercury/daemon.pid` | 后台进程 PID |
-| `~/.mercury/daemon.log` | 守护进程模式日志 |
-
-## Provider 兜底
-
-配置多个 LLM Provider。Mercury 按顺序尝试并自动兜底:
-
-| Provider | 默认模型 | API Key | 备注 |
-|----------|----------|---------|------|
-| **DeepSeek** | deepseek-chat | `DEEPSEEK_API_KEY` | 默认,成本效益高 |
-| **OpenAI** | gpt-4o-mini | `OPENAI_API_KEY` | GPT-4o、o3 等 |
-| **Anthropic** | claude-sonnet-4 | `ANTHROPIC_API_KEY` | Claude Sonnet、Haiku、Opus |
-| **Grok (xAI)** | grok-4 | `GROK_API_KEY` | OpenAI 兼容端点 |
-| **Ollama Cloud** | gpt-oss:120b | `OLLAMA_CLOUD_API_KEY` | 通过 API 的远程 Ollama |
-| **Ollama Local** | gpt-oss:20b | 无需 Key | 本地 Ollama 实例 |
+发布的二进制文件未签名。在 macOS 上分发你自己的构建前,请使用 `codesign` 签名并进行公证。
-当 Provider 失败时,Mercury 自动尝试下一个。它记住最后一个成功的 Provider,并在下次请求时从那里开始。
-
-> **更多 Provider 即将到来** — Google Gemini、Mistral 等已在路线图上。Mercury 的 OpenAI 兼容架构也支持通过 base URL 配置自定义端点。
+## 文档
-## 架构
+| 资源 | |
+|---|---|
+| [mercuryagent.sh/docs](https://mercuryagent.sh/docs) | 指南、平台设置、渠道设置、参考 |
+| [ARCHITECTURE.zh-CN.md](ARCHITECTURE.zh-CN.md) | 运行时的整体结构 |
+| [BOTS-ARCHITECTURE.md](BOTS-ARCHITECTURE.md) | Bots、团队及其治理 |
+| [DECISIONS.md](DECISIONS.md) | 架构决策记录 |
+| [CHANGELOG.md](CHANGELOG.md) | 每个版本的变更 |
+| [SECURITY.md](SECURITY.md) | 漏洞报告 |
-- **TypeScript + Node.js 18+** — ESM,tsup 构建
-- **Vercel AI SDK v4** — `generateText` + `streamText`,10 步 Agent 循环,Provider 兜底
-- **grammY** — Telegram Bot,带输入指示器、可编辑流式输出和文件上传
-- **SQLite + FTS5** — 第二大脑,带全文搜索、冲突解决、自动整合
-- **JSONL** — 短期、长期和情景对话记忆
-- **守护进程管理器** — 后台生成 + PID 文件 + 看门狗崩溃恢复
-- **系统服务** — macOS LaunchAgent、Linux systemd、Windows Task Scheduler
+## 参与贡献
-## 许可证
+欢迎各种贡献,从问题报告到新工具。Mercury 是一个会无人值守连续运行多天的 Agent,因此以下原则比普通库更加重要:
-MIT © [Cosmic Stack](https://github.com/cosmicstack-labs)
+- **所有对外动作都经过权限系统。** 文件、Shell、网络和 git 绝不能绕过权限系统或 SSRF 防护。
+- **不要假设有人在场或有终端。** 工具在每个渠道上的行为都必须一致。
+- **节约 Token。** 保持工具输出精简,它们最终会进入模型上下文。
+- **温和失败。** 提供方故障或文件缺失应当给出诚实的提示,而不是崩溃。
+- **测试循环,而不只是函数。** 单独可用的工具仍可能卡住多步的一轮对话。
----
+开始贡献:
-## 免责声明
+1. Fork 并克隆仓库,然后执行 `npm install`。
+2. 修改代码,并在旁边补充测试。
+3. 运行 `npm run lint`、`npm run typecheck` 和 `npm test`。
+4. 提交 Pull Request,说明改了什么以及为什么,每个 PR 只做一件事。
-**这是 AI 软件 — 有时可能会出问题,请自行评估风险后使用。**
+欢迎在 [Discord](https://discord.gg/5emMpMJy5J) 或通过 [[email protected]](mailto:[email protected]) 提问。
----
-
-## 参与贡献
+## 社区
-我们欢迎贡献!Mercury 是为演进而构建的,我们欢迎社区的帮助。无论是修复 bug、添加工具、改善记忆还是改进 soul — 所有高质量的贡献都受欢迎。
-
-### 🎯 Agent 专业知识 — 贡献者必读
-
-Mercury 不只是一个开源项目 — 它是一个**以灵魂驱动的 Agent**,全天候运行,管理权限,记住上下文,并在多个渠道间交互。如果你正在贡献,你必须像 Agent 构建者一样思考,而不只是库贡献者。这些是每个贡献者都应该内化的不可协商的原则:
-
-| 原则 | 含义 |
-|------|------|
-| 🧠 **以循环思维** | Mercury 在 10 步 Agent 循环中运行。你的工具或功能每轮对话会被调用多次。尽可能保持幂等。 |
-| 🔐 **权限优先** | 每个触碰外部世界的行为(文件、shell、网络、git)必须经过权限系统。永远不要假设批准。 |
-| 💾 **记忆感知** | 如果你的功能生成关于用户的事实,考虑接入第二大脑。如果它读取用户数据,先检查记忆。 |
-| 📏 **Token 意识** | Mercury 有每日 Token 预算。日志、冗长输出和大上下文转储会快速消耗 Token。保持精简。 |
-| 🔌 **渠道无关** | 工具应该在 CLI 和 Telegram 上表现一致。不要假设终端、键盘,甚至另一端是人。 |
-| 🔁 **优雅降级** | 如果 Provider 失败、工具出错或文件不存在 — Mercury 应该恢复,而不是崩溃。始终处理边缘情况。 |
-| 📋 **自文档化** | 你的工具的名称和描述是 Mercury 决定何时使用它的依据。让它们清晰、具体和面向行动。 |
-| 🧪 **测试循环,不只是函数** | 在隔离中工作的工具在 Agent 循环中可能失败(例如,返回太多数据,阻塞下一步)。端到端测试。 |
-
-### 代码质量 — 做
-
-| 做 | 为什么 |
-|---|--------|
-| ✅ 写干净的、可读的带显式类型的 TypeScript | Mercury's codebase 是类型安全的 — 保持这样 |
-| ✅ 在公共函数和工具上添加 JSDoc 注释 | 帮助其他贡献者和 Agent 理解意图 |
-| ✅ 保持函数小而单一职责 | 更易于测试、审查和推理 |
-| ✅ 使用 async/await 而不是原始 Promise | 一致的错误处理和可读性 |
-| ✅ 为新工具和记忆功能写测试 | 对 24/7 Agent 来说可靠性很重要 |
-| ✅ 遵循现有项目结构(`src/tools/`、`src/memory/`、`src/channels/`) | 保持代码库可导航 |
-| ✅ 使用 Agent Skills 规范用于新的基于 skill 的功能 | 确保与 skills 生态系统的兼容性 |
-| ✅ 在 PR 描述中记录破坏性变更 | 帮助维护者正确版本管理 |
-
-### 代码质量 — 不做
-
-| 不做 | 为什么 |
-|------|--------|
-| ❌ 未经讨论不添加依赖 | Mercury 很精简 — 每个依赖增加表面积 |
-| ❌ 不硬编码 API key、Token 或路径 | 像代码库其他部分一样使用 config/env 变量 |
-| ❌ 不绕过权限系统 | 工具必须先请求再行动 — 这是 Mercury 的核心承诺 |
-| ❌ 不在热路径中引入同步/阻塞 I/O | Mercury 是异步优先的,有原因 |
-| ❌ 不提交大二进制文件或 secrets | 使用 `.gitignore` 和 env 文件 |
-| ❌ 未经讨论不更改 soul/persona 系统 | 它是 Mercury 的核心 — 更改需要谨慎 |
-| ❌ 不提交未测试的 Telegram 或守护进程更改 | 这些在合并后很难调试 |
-| ❌ 不忽略 Token 预算系统 | 每个工具都应该注意 Token 消耗 |
-
-### 开始
-
-1. Fork 仓库
-2. 运行 `npm install`
-3. 进行更改
-4. 运行 `npm run build` 验证编译
-5. 本地使用 `mercury` 测试
-6. 打开 PR,清晰描述你更改了什么和为什么
-
-### PR 指南
-
-- 保持 PR 聚焦 — 每个 PR 一个功能/修复
-- 在描述中包含前/后行为
-- 适当时标记相关 issues
-- 对审查反馈响应迅速
-
-### 需要帮助?
-
-打开 issue 或联系 [[email protected]](mailto:[email protected])。我们很友好。
+- **Discord:** [discord.gg/5emMpMJy5J](https://discord.gg/5emMpMJy5J),获取帮助、交流想法、展示作品。
+- **Issues:** [GitHub Issues](https://github.com/cosmicstack-labs/mercury-agent/issues),报告问题和提出功能需求。
----
+## 许可证
-## 社区
+[MIT](LICENSE) © [Cosmic Stack](https://github.com/cosmicstack-labs)
-1. **Discord** — [加入 Mercury Agent Discord](https://discord.gg/5emMpMJy5J) 获取实时聊天、支持和小社区讨论。
\ No newline at end of file
+Mercury 是一个 AI Agent,可能会出错。请检查它的操作,尤其是在 *Allow All* 模式下。
diff --git a/docs/img/readme-hero-dark.png b/docs/img/readme-hero-dark.png
new file mode 100644
index 00000000..215fab1d
Binary files /dev/null and b/docs/img/readme-hero-dark.png differ
diff --git a/docs/img/readme-hero-light.png b/docs/img/readme-hero-light.png
new file mode 100644
index 00000000..0ed78ec0
Binary files /dev/null and b/docs/img/readme-hero-light.png differ