@anygap/anycode
v0.4.1
Published
AnyCode — a coding-agent CLI for Anygap (anygap.ir): an agentic tool-use REPL with plan mode, approval-with-diff, MCP, themes, and a chalk-rendered terminal UI.
Downloads
664
Maintainers
Readme
AnyCode CLI
A small, agentic coding CLI for Anygap (آنیگپ · anygap.ir).
Run anycode in any project and it streams from a compatible endpoint at https://anygap.ir/v1,
then reads, writes, edits (with diffs), searches, and runs your code — with your approval —
right in the terminal, like Codex or Claude Code.
The terminal UI renders streaming Markdown, syntax-highlighted code, colored unified
diffs with real @@ hunk headers, a persistent status/footer line (model · mode · cwd ·
token budget · estimated Toman cost), framed tool-call cards, and a gradient AnyCode
wordmark in your chosen color theme. Color auto-degrades truecolor → 256 → 16 → none, and all
rich output no-ops cleanly when piped or under NO_COLOR. The core (config, network, sandbox, agent
loop, MCP client, raw-mode widgets) stays on Node.js built-ins (readline, fs, child_process,
fetch); a thin bin/render/ layer adds the presentation. Requires Node 18+.
New in this wave: a read-only Plan Mode (/plan → propose, /approve → execute), a
3-way approval prompt (y / n / always) with the diff shown first, MCP support
(connect stdio servers from ~/.anycode/mcp.json and use their tools), selectable themes,
an estimated Toman cost in the status line, and a friendly first-run setup wizard.
Meet Andy — AnyCode's little purple coding robot, who waves hello every time you start.
Install
# Global install from npm (the package is scoped; the command stays `anycode`)
npm i -g @anygap/anycodeThe package name is @anygap/anycode, but it still installs an anycode command on your PATH.
Install from source (for development)
cd tools/anycode-cli
npm linkThis links this folder and gives you the same anycode command for local development.
Authenticate
The first time you run anycode with no config, a friendly setup wizard walks you through it:
paste your API key, pick a default model, and choose a theme. Create an API key first at
https://anygap.ir/dashboard/keys (it looks like agp-...). You can re-run setup any time with:
anycode loginThis stores your key and a default model slug at ~/.anycode/config.json (chmod 600).
You can also override values per-session with environment variables:
export ANYCODE_API_KEY=agp-xxxxxxxx
export ANYCODE_MODEL=nex-n2-pro
export ANYCODE_THEME=oceanPricing is a flat per-request charge in Toman, debited from your wallet — top up at https://anygap.ir/dashboard/wallet. There is no per-token billing.
Usage
anycode # start the agentic REPL (default)
anycode --plan # start the REPL in read-only plan mode
anycode agent "<task>" # start the REPL seeded with a task
anycode exec "<task>" # run a task non-interactively, print result, exit
anycode --continue # resume your most recent session (alias: -c)
anycode --resume # pick a past session to resume (↑/↓), or --resume=<id>
anycode models # list models and pick a default (↑/↓)
anycode login # store/refresh your API key + default model
anycode --help # full helpThe agentic REPL
anycode drops you into a conversational agent. Ask it to build, fix, or run something and it
uses real tools to do it — creating files, editing them (shown as diffs), searching the
project, and running commands — instead of just printing code at you.
In-REPL commands and inline shortcuts:
| Command / input | Effect |
| ------------------ | ------------------------------------------------------- |
| /plan [goal] | Read-only: investigate and propose a step plan |
| /approve | Lift plan mode and execute the proposed plan |
| /model /models | Pick the active model with ↑/↓ |
| /mode | Switch approval mode (suggest · auto-edit · full-auto) |
| /theme | Switch the color theme (↑/↓) |
| /config | Show the active config and where it lives |
| /mcp | List connected MCP servers and their tools |
| /skills | List saved skills (reusable playbooks) |
| /skill <name> | Apply a saved skill to the next task |
| /sessions /resume | Resume a past session (↑/↓), or /resume <id> |
| /compress | Summarize older turns to free up context |
| /diff | Show the git diff of your working tree |
| /init | Scaffold an AGENTS.md project-context file |
| /status | Model, mode, cwd, tokens, estimated cost, turn count |
| /tools | List the tools the agent can call |
| /clear /cwd /help /exit | Reset · print cwd · help · quit |
| @path | Attach a file's contents as context (Tab completes) |
| !command | Run a shell command directly |
Open the slash-command palette by pressing Enter on a bare / (or an unknown command): it's a
filterable ↑/↓ menu of every command. The line prompt also has Tab-completion — a leading /
completes slash commands, and @ completes file paths from the current directory.
Plan Mode
/plan (or starting with --plan) puts AnyCode into a read-only state: it can read, search,
and list to investigate, but every edit and command is refused. It produces a concise, numbered
plan of what it would change and which commands it would run, then waits. Review it, and when
you're happy run /approve — plan mode lifts (back to auto-edit by default) and the agent
executes the plan step by step. Nothing touches your files until you approve.
Approval modes
AnyCode won't touch your files or run commands behind your back unless you let it:
| Mode | Behavior |
| ----------- | ---------------------------------------------- |
| plan | Read-only — propose a plan, make no changes |
| suggest | Ask before every edit and command (default) |
| auto-edit | Auto-apply file edits, ask before commands |
| full-auto | Apply edits and run commands automatically |
Switch any time with /mode, or start with --plan / --auto-edit / --full-auto. Before each
edit AnyCode shows the colored diff and then a 3-way prompt — press y to apply once, n
to skip, or a to apply this and auto-approve the rest of this session's edits. A built-in
deny-list refuses obviously catastrophic commands (rm -rf /, fork bombs, writing to raw devices,
…) in every mode. anycode exec runs in full-auto since nothing can answer prompts.
Tools
The agent is given a small toolset and loops until the task is done:
read_file/list_dir— read a file / list a directorysearch/glob— grep across files / find files by patternwrite_file— create or overwrite a file (diff shown, gated by approval)edit_file— replace a unique snippet in a file (diff shown, gated by approval)multi_edit— apply several edits to one file atomically (one diff, one round-trip)run_command— run a shell command (gated by approval; destructive commands blocked)save_skill— save a reusable playbook the agent can recall later (see Skills below)
All paths are sandboxed to the current working directory. Tool results are classified
(done · empty · error · refused · skipped) so the agent reacts deliberately — e.g. it
won't keep retrying a command you declined. The system prompt also includes a compact, depth-limited
file-tree hint of the project so the agent orients itself without a first list_dir call.
Sessions — persistence & resume
Every REPL session is saved under ~/.anycode/sessions/<id>.json (the full transcript, model, cwd,
and an auto-generated title) after each turn. Pick up where you left off with anycode --continue
(most recent) or anycode --resume (a picker), and switch between past sessions mid-REPL with
/sessions / /resume. When the conversation approaches the model's context budget AnyCode
auto-compacts older turns into a summary (or run /compress yourself) so long sessions keep going.
Skills — reusable playbooks
A skill is a short Markdown playbook the agent can recall on demand. Drop *.md files in
~/.anycode/skills/ (global) or ./.anycode/skills/ (per-repo, project wins on a name clash), with
an optional front-matter description:. List them with /skills, apply one with /skill <name>,
and the agent can write new ones for itself via the save_skill tool after it works out a
repeatable procedure.
Project context — AGENTS.md
If a ./AGENTS.md (or ~/.anycode/AGENTS.md) exists, AnyCode loads it into its system prompt so
it knows your conventions, commands, and layout. Run /init to scaffold one.
MCP — connect external tools
AnyCode speaks the Model Context Protocol (stdio transport). Configure servers in
~/.anycode/mcp.json and AnyCode spawns each one at startup, runs the handshake, and exposes its
tools to the agent under namespaced names (mcp__<server>__<tool>) alongside the built-ins:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
},
"git": { "command": "uvx", "args": ["mcp-server-git"] }
}
}Each server entry takes command, optional args, optional env, and optional disabled: true.
A server that fails to start is reported but never blocks the REPL or the other servers. List what's
connected with /mcp. MCP tool calls are gated like commands, so plan/suggest mode still asks
before a server with side effects runs.
Themes
Pick a color theme with /theme (or set theme in your config / ANYCODE_THEME=). Built-in
themes: anygap (default), ocean, sunset, slate, and mono. The theme repaints the
wordmark, accents, spinners, and status line on the next launch.
Coding models
| Display name | Slug | Context | Notes |
| ----------------------- | ------------------------ | ------- | --------------------------------------- |
| Laguna M.1 | laguna-m1 | 256K | Poolside's code-tuned model. (default) |
| Nemotron 3 Super 120B | nemotron-3-super-120b | 1M | NVIDIA, strong long-context reasoning. |
| Nex N2 Pro | nex-n2-pro | 256K | Agentic coding & tool use. |
| GPT-OSS 120B | gpt-oss-120b | 131K | OpenAI open-weight, general + code. |
| Nemotron 3 Ultra 550B | nemotron-3-ultra-550b | 1M | NVIDIA flagship, deepest reasoning. |
| Hermes 3 405B | hermes-3-405b | 128K | Nous Research, steerable agentic coding. |
| North Mini Code | north-mini-code | 256K | Cohere, fast code edits & tool use. |
API
AnyCode talks to a compatible endpoint:
- Base URL:
https://anygap.ir/v1 POST /chat/completions— SSE streaming and tool/function calling are forwardedGET /models- Auth header:
Authorization: Bearer agp-...
Configuration
~/.anycode/config.json:
{
"apiKey": "agp-xxxxxxxx",
"model": "laguna-m1",
"approvalMode": "suggest",
"theme": "anygap"
}The file is written with 600 permissions. Environment variables
(ANYCODE_API_KEY, ANYCODE_MODEL, ANYCODE_THEME) take precedence over the stored values.
MCP servers live in a separate file, ~/.anycode/mcp.json (see MCP above).
The status line shows an approximate Toman cost for the session, derived from token usage and a per-model rate — a convenience estimate only. Your wallet at https://anygap.ir/dashboard/wallet is the source of truth for actual charges.
Notice
AnyCode's session persistence/resume, context compaction, skills, tool-result classification, and file-tree hints are original implementations inspired by the public feature set of NousResearch/hermes-agent (MIT, © 2025 Nous Research). Its plan mode, 3-way approval-with-diff, tool-call cards, slash-command palette, usage line, MCP client, themes, and onboarding are original implementations written from scratch, inspired only by the public feature sets and terminal-UX patterns of tools like Claude Code and the OpenAI Codex CLI. No source was copied — the file formats, schemas, protocol code, and designs here are our own.
License
MIT
