@zhachory1/mewrite-code
v0.65.10
Published
Me Write Code — a terminal coding agent
Maintainers
Readme
Me Write Code is the mewrite CLI package in Zhachory1/mewritecode.
Me Write Code is a minimal terminal coding harness that stays provider-agnostic, terminal-native, and deeply extensible. Use it interactively, run it in print or JSON mode, embed it through the SDK, or extend it with TypeScript modules, skills, prompt templates, themes, and CaveKit workflows.
Install
npm (current package)
npm install -g @zhachory1/mewrite-code
mewriteHomebrew (macOS, Linux)
brew tap Zhachory1/mewritecode https://github.com/Zhachory1/mewritecode
brew install mewrite
mewriteDebian / Ubuntu
echo "deb [trusted=yes] https://raw.githubusercontent.com/Zhachory1/mewritecode/gh-pages/apt ./" | sudo tee /etc/apt/sources.list.d/mewrite.list
sudo apt update
sudo apt install mewrite-code
mewriteThe package supports amd64 and arm64 systems. It installs mewrite plus mewrite-code and mewritecode aliases.
Fedora / RHEL / CentOS
sudo curl -fsSL https://raw.githubusercontent.com/Zhachory1/mewritecode/gh-pages/yum/mewrite.repo -o /etc/yum.repos.d/mewrite.repo
sudo dnf install mewrite-code # or yum
mewriteThe package supports x86_64 and aarch64 systems. It installs mewrite plus mewrite-code and mewritecode aliases.
Snap (tracked, not yet published)
Snap packaging metadata is tracked in snap/snapcraft.yaml. Once published:
sudo snap install mewrite-code --classic
mewrite-codeRequirements:
- Node.js 20+ (npm install path only)
- API key or active subscription for at least one supported provider
Quick Start
Authenticate
# API key
export ANTHROPIC_API_KEY=sk-ant-...
mewrite
# Or sign in with an existing subscription
mewrite
/loginUse
mewrite # interactive mode
mewrite "explain this codebase" # start with prompt
mewrite -p "summarize this file" # print mode
cat README.md | mewrite -p "review" # pipe stdin
mewrite -c # continue last session
mewrite -r # browse sessions
mewrite goal start "<text>" # autonomous goal loopSuccess looks like this:
- interactive TUI opens with active model + status footer
/loginor API key auth succeeds- model can call built-in tools like
read,bash,edit, andwrite
Platform notes: Windows · Termux · tmux · Terminal setup · Shell aliases
What Me Write Code Adds
Me Write Code keeps upstream extensibility goals, then adds fork-specific workflows and compression features on top.
| Area | Me Write Code | |------|------| | Multi-provider coding agent | Built in | | Caveman Mode | 3-layer token compression | | RTK integration | Optional bash command rewriting + output reduction | | CaveKit | Draft → Architect → Build → Inspect workflow | | Package ecosystem | Install prompts, skills, themes, and extensions via npm or git | | SDK + RPC | Embed in apps or automate from other runtimes |
Supported Providers
OAuth subscriptions
Claude Pro/Max · ChatGPT Plus/Pro · GitHub Copilot · Google Gemini · Google Antigravity
API keys
Anthropic · OpenAI · Azure OpenAI · Google Gemini · Google Vertex · Amazon Bedrock · Mistral · Groq · Cerebras · xAI · OpenRouter · Vercel AI Gateway · Hugging Face · Kimi · MiniMax · ZAI · OpenCode
Custom providers
Add any OpenAI-, Anthropic-, or Google-compatible endpoint via ~/.mewrite/agent/models.json, or build a custom provider with Extensions and Custom Provider docs.
Provider setup details: docs/providers.md
Modes
| Mode | Command | Use case |
|------|---------|----------|
| Interactive | mewrite | Full TUI with history, editor, tool calls, and status UI |
| Print | mewrite -p "..." | One-shot scripting |
| JSON | mewrite --mode json "..." | Structured automation |
| RPC | mewrite --mode rpc | Stdin/stdout process integration |
| SDK | createAgentSession() | Embed Me Write Code in Node.js apps |
Interactive Mode
Main UI regions:
- Startup header — version, shortcuts, loaded context, skills, prompts, extensions
- Messages — prompts, assistant output, tool calls/results, notifications, extension UI
- Editor — input area, file picker, slash commands, shell dispatch
- Footer — cwd, session name, token/cache usage, cost, context usage, model
Editor Features
| Feature | How |
|---------|-----|
| File reference | @ fuzzy-searches project files |
| Path completion | Tab |
| Multi-line input | Shift+Enter |
| Paste images | Ctrl+V |
| Shell commands | !cmd sends output to model · !!cmd runs silently |
| Thinking level | Shift+Tab cycles levels |
| Model switcher | Ctrl+L |
| Collapse tool output | Ctrl+O |
| Collapse thinking | Ctrl+T |
Slash Commands
| Command | Description |
|---------|-------------|
| /login, /logout | OAuth auth |
| /model | Switch models |
| /settings | Theme, thinking, delivery, transport, compaction |
| /resume | Pick prior session |
| /new | New session |
| /tree | Browse + branch session history |
| /fork | Create session from branch point |
| /compact [prompt] | Manual compaction |
| /copy | Copy last assistant message |
| /export [file] | Export session to HTML |
| /share | Upload session as private gist |
| /reload | Reload extensions, prompts, skills, keybindings, context |
| /hotkeys | Show shortcuts |
| /changelog | Show version history |
Keyboard shortcut details: docs/keybindings.md
Sessions
Sessions auto-save to ~/.mewrite/agent/sessions/ and keep full tree history in JSONL format.
mewrite -c # continue most recent session
mewrite -r # browse sessions
mewrite --session <path|id> # open specific session
mewrite --fork <path|id> # fork into new session
mewrite --no-session # ephemeral modeBranching
Use /tree to search, branch, label bookmarks, and revisit earlier points without overwriting history.
Compaction
Compaction summarizes older context while keeping recent turns active:
- automatic on overflow or near-limit conditions
- manual via
/compact - full history always remains in session file
Session format details: docs/session.md · Compaction details: docs/compaction.md
Caveman Mode
Caveman Mode is enabled by default and reduces token waste without changing workflow.
Layer 1: prompt compression
lite— brief responsesfull— default terse modeultra— maximum brevity
Layer 2: tool output compression
- strips ANSI noise
- applies per-tool budgets
- truncates with head/tail slices instead of hard cuts
- compresses structured bash output where possible
Layer 3: read deduplication
- fingerprints reads within session
- returns stub when unchanged file is re-read
- reduces repeated context injection during refactors
Change level with /mewrite [lite|full|ultra|off].
Settings reference: docs/settings.md
Benchmark Results
Run npm run bench:offline to reproduce. Results on 10 real-world tool output fixtures:
Tool Output Compression
0% 25% 50% 75% 100%
| | | | |
git diff (901 lines) [##################################################] -94.0%
npm ls (701 lines) [################################################ ] -91.6%
ls recursive (601 ln) [############################################### ] -90.3%
grep results (801 ln) [############################################## ] -89.3%
test output (501 ln) [############################################ ] -87.6%
XML/pom.xml (382 ln) [######################################## ] -78.7%
docker inspect (258) [################################## ] -67.9%
ANSI colored (97 ln) [######################### ] -50.0%
read file (429 lines) [################ ] -32.0%
build output (19 ln) [######### ] -18.0%
| | | | |
AGGREGATE [########################################### ] -85.9%~72,400 tokens saved across 337K chars of tool output. Larger outputs compress more aggressively.
Compression Pipeline Layers
| Layer | What it does | Biggest impact on | |-------|-------------|-------------------| | Flint Chipper | Per-tool line budgets (bash: 80, read: 300, grep: 120) | Large outputs (-67% to -92%) | | ANSI Strip | Removes escape codes from colored output | Terminal output (-20% to -40%) | | Stone Tablet | Semantic JSON/XML key extraction | Structured bash output | | Blank Collapse | Collapses 3+ blank lines | Sparse output | | General Truncation | 500-line cap with head+tail preservation | Very long outputs |
Read Deduplication
First read (429-line file) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~2,966 tokens
Second read (unchanged) ~ ~22 tokens
99.3% savingsSystem Prompt Overhead vs Savings
| Intensity | Prompt Cost | Break-even | Net per 15-turn session | |-----------|------------|------------|------------------------| | lite | +120 tokens | 1 tool call | +567K tokens saved | | full | +175 tokens | 1 tool call | +567K tokens saved | | ultra | +195 tokens | 1 tool call | +566K tokens saved |
Caveman Mode pays for itself on the first tool call of every session.
Cost Impact (Sonnet pricing, $3/M input)
15-turn session: ~$1.70 saved per session
30-turn session: ~$6.92 saved per session (91% tool compression)Session Replay (real sessions)
4 sessions analyzed from ~/.mewrite/agent/sessions/:
| Metric | Value | |--------|-------| | Total tool calls | 78 | | Actual API input tokens | 105,105 | | Cache read tokens | 1,314,699 | | Tool types | bash (19), read (31), write (28) |
Note: These sessions had small tool outputs (all under budget thresholds). Compression savings scale with output size -- the offline benchmarks above show the full range on realistic large outputs.
Run benchmarks yourself:
npm run bench:offline # Compression analysis (free, <1s)
npm run bench:replay # Analyze your real sessions (free)
npm run bench:live # A/B comparison with LLM calls (needs API key, ~$1-2)
npm run bench # All tiersRTK Integration
RTK (Rust Token Killer) is an optional external binary. When installed, Me Write Code can rewrite bash commands through rtk rewrite before execution, then still apply Caveman Mode compression afterward.
Install check
rtk --versionDisable globally
// ~/.mewrite/agent/settings.json
{
"rtk": { "enabled": false }
}More: docs/settings.md
Customization
Prompt Templates
Reusable Markdown prompts in:
~/.mewrite/agent/prompts/.mewrite/prompts/
Docs: docs/prompt-templates.md
Skills
On-demand capability packs in:
~/.mewrite/agent/skills/~/.agents/skills/.mewrite/skills/.agents/skills/
Docs: docs/skills.md
Extensions
TypeScript modules can register tools, commands, event handlers, keybindings, UI, sub-agents, permission gates, MCP integrations, and more.
export default function (api: ExtensionAPI) {
api.registerTool({ name: "deploy", ... });
api.registerCommand("stats", { ... });
api.on("tool_call", async (event, ctx) => { ... });
}Extension docs: docs/extensions.md · Examples: examples/extensions/
Themes
Built-in: dark, light. Custom themes live in:
~/.mewrite/agent/themes/.mewrite/themes/
Docs: docs/themes.md
Me Write Code Packages
Bundle and share extensions, skills, prompts, and themes via npm or git.
mewrite install npm:@foo/mewrite-tools
mewrite install git:github.com/user/repo
mewrite remove npm:@foo/mewrite-tools
mewrite list
mewrite update
mewrite configPackage docs: docs/packages.md
Programmatic Usage
SDK
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@zhachory1/mewrite-code";
const authStorage = AuthStorage.create();
const modelRegistry = ModelRegistry.create(authStorage);
const { session } = await createAgentSession({
sessionManager: SessionManager.inMemory(),
authStorage,
modelRegistry,
});
await session.prompt("What files are in the current directory?");Advanced API docs: docs/sdk.md · Examples: examples/sdk/
RPC Mode
mewrite --mode rpcProtocol details: docs/rpc.md
CLI Reference
mewrite [options] [@files...] [messages...]Subcommands
| Command | Description |
|---------|-------------|
| mewrite goal start "<text>" [flags] | Autonomous goal loop (Ralph-style) |
| mewrite goal resume [id] [--force] | Resume a paused/completed goal |
| mewrite goal status [id] | Show goal state, ledger, transcript |
| mewrite goal cancel [id] | Mark goal as cancelled |
| mewrite goal list | List all goals in project |
Subcommands
| Command | Description |
|---------|-------------|
| mewrite goal start "<text>" [flags] | Autonomous Ralph-style goal loop |
| mewrite goal resume [id] [--force] | Resume a paused goal |
| mewrite goal status [id] | Show goal state and ledger |
| mewrite goal cancel [id] | Cancel a running goal |
| mewrite goal list | List all goals |
| mewrite mcp <subcmd> | Manage MCP servers |
| mewrite watch [paths] | File watcher for // mewrite! triggers |
| mewrite exec [flags] "<prompt>" | Non-interactive CI mode |
| mewrite plugin <subcmd> | Plugin marketplace |
| mewrite run-recipe <name> | Run YAML workflows |
| mewrite rollback N | Revert to checkpoint N |
| mewrite models <subcmd> | Manage model registry |
| mewrite serve / attach | Daemon mode |
Core options
| Option | Description |
|--------|-------------|
| -c, --continue | Continue most recent session |
| -r, --resume | Browse and select session |
| -p, --print | Print response and exit |
| --mode json\|rpc | Structured output modes |
| --provider <name> | Provider (anthropic, openai, google, ... ) |
| --model <pattern> | Model ID or pattern |
| --thinking <level> | off · minimal · low · medium · high · xhigh |
| --tools <list> | Enable specific built-in tools |
| --no-tools | Disable built-in tools |
| --no-extensions | Disable extension discovery |
| -e, --extension <src> | Load explicit extension |
| --api-key <key> | Override env var auth |
| -v, --version | Show version |
| -h, --help | Show help |
Slash commands (in TUI)
| Command | Description |
|---------|-------------|
| /plan | Toggle plan mode (read-only exploration) |
| /act | Execute a saved plan |
| /mewrite [level] | Adjust token compression |
| /login, /logout | OAuth authentication |
| /model | Switch models |
| /settings | Configure settings |
| /resume | Browse sessions |
| /tree | Navigate session history |
Built-in tools: read, bash, edit, write, grep, find, ls
Environment variables
| Variable | Description |
|----------|-------------|
| ANTHROPIC_API_KEY | Anthropic API key |
| OPENAI_API_KEY | OpenAI API key |
| MEWRITE_CODING_AGENT_DIR | Override config directory (default: ~/.mewrite/agent) |
| MEWRITE_PACKAGE_DIR | Override package directory |
| MEWRITE_SKIP_VERSION_CHECK | Skip version check at startup |
| MEWRITE_CACHE_RETENTION | Set to long for extended prompt cache |
| VISUAL, EDITOR | External editor for Ctrl+G |
Contributing
Contribution guide: ../../CONTRIBUTING.md
Development docs:
Plugin Marketplace
Me Write Code supports a plugin ecosystem. Plugins bundle commands, skills, agents, themes, hooks, and MCP server configs.
mewrite plugin search [query] # Search all configured marketplaces
mewrite plugin install <owner/name> # Install a plugin from GitHub or a URL
mewrite plugin list # Show installed plugins
mewrite plugin upgrade # Upgrade all installed plugins
mewrite plugin marketplace add <url> # Register a remote marketplace
mewrite plugin marketplace list # Show configured marketplace sourcesMarketplaces are resolved in order: repo (.mewrite/plugins/marketplace.json), personal (~/.mewrite/plugins/marketplace.json), and remote URLs. Plugins install into ~/.mewrite/plugins/<owner>/<name>/. To scaffold a new plugin, use /plugin create in interactive mode (invokes the plugin-creator skill).
License
MIT
