8000 GitHub - amenski/nib: Open-source, bring-your-own-key coding agent for the terminal. Built for cheap models: run all day on DeepSeek for a few dollars, or use OpenAI, OpenRouter, Groq, local Ollama. Explicit permissions, no telemetry. · GitHub
[go: up one dir, main page]

Skip to content
amenskiPublic

About

Open-source, bring-your-own-key coding agent for the terminal. Built for cheap models: run all day on DeepSeek for a few dollars, or use OpenAI, OpenRouter, Groq, local Ollama. Explicit permissions, no telemetry.

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Nib

Build License: Apache 2.0 npm npm downloads Node.js 20+

An open-source, bring-your-own-key coding agent for the terminal, built for cheap models: run it all day on DeepSeek for a few dollars, or point it at OpenAI, OpenRouter, Groq, or local Ollama. Explicit permissions, rewindable checkpoints, resumable sessions, skills, and MCP — one process on your machine, no hosted service, no telemetry.

Nib in Code mode, running DeepSeek V4 Flash

Why Nib

Nib Claude Code
Models Any key: DeepSeek, OpenAI, OpenRouter, Groq, local Ollama One vendor's models
Where the agent runs One inspectable process on your machine Local CLI, closed source
Telemetry None Vendor-controlled
Permissions Explicit allow/ask/deny rules, sandbox profiles, audit trail Prompt-based approvals
Code Apache 2.0, every subsystem documented in docs/ Not available

Already using Claude Code? Hooks, skills, MCP, sub-agents, custom slash commands and -p headless mode work the way you expect; see the parity table for what is and is not there yet.

Measured

Nib keeps the prompt prefix byte-stable (system prompt, tools, history only appended), so the provider's prefix cache does the work. This is the /usage panel from the author's own DeepSeek key on 2026-10-18:

Nib /usage panel: deepseek-flash 504,190,080 cached of 506,372,034 input tokens

  • deepseek-flash: 504,190,080 cached / 506,372,034 input = 99.57% cache hit rate (1,207,287 output tokens).
  • deepseek-v4-pro: 201,984 / 279,485 = 72.3%, on a small sample.
  • Cached tokens are what the provider reports; providers that do not report them show 0. Check yours with /usage inside Nib.
  • Under the auto posture, most Bash calls in an ordinary session are read-only and never reach the judge; a judged call costs one short model round trip (about 1 s on Flash). Measure yours with the jq recipes in docs/auto-mode.md.

Quick start

Requires Node.js 20+ and Git.

Distribution: npm and Homebrew carry every release from v0.5.1. The Homebrew formula can trail a new npm release briefly; install from source if you need a version it does not have yet.

Install with npm:

npm install -g @amenski/nib
nib doctor

Or run it without a global install:

npx @amenski/nib doctor

Install from Homebrew:

brew install amenski/tap/nib

Install from source when a package-manager artifact is unavailable:

git clone https://github.com/amenski/nib.git
cd nib
npm install
npm run build && npm link

Add a provider key, then check the installation:

nib auth                         # stores keys in ~/.nib/credentials.yaml
nib doctor                       # shows config and credential sources

You can use an environment variable instead, such as DEEPSEEK_API_KEY or OPENAI_API_KEY. If both are set, the environment variable wins over the stored key (order).

Start a session:

nib                              # interactive
nib "explain src/foo.ts"         # start with a prompt
nib -c                           # continue the most recent session
nib -p "..."                     # one-shot, no TUI (for scripts)

Upgrading from Heirloom? Nib intentionally does not read ~/.heirloom. Run nib auth again or copy credentials.yaml into ~/.nib with mode 0600. See the v0.5.0 migration notes before moving sessions, settings, or trust stores; do not symlink the two state directories.

How Nib works

nib [code]    > fix the failing test             implementation tools by default
nib [code]    > Shift+Tab                        cycle normal / auto / plan
nib [code]    > /mode general                    switch to read-only chat

New sessions start in Code, which can edit files, run commands, and delegate work. Switch to General, a fast, read-only chat mode, with /mode general or --mode general. Independently, Shift+Tab cycles the permission posture through normal → auto → plan. The active mode controls which tools exist; the posture controls how Nib may use them.

Two personas

A persona changes three things together: the role at the top of the system prompt, the tool groups offered to the model, and—when configured—the files it may edit. These are hard runtime boundaries, not requests for the model to behave differently.

Persona Capabilities Best used for
General Read-only; DeepSeek V4 Flash at low effort Questions, exploration, and everyday conversation
Code (default) Read, edit, shell commands, background jobs, and sub-agent delegation; DeepSeek V4 Flash at low effort Building, fixing, refactoring, and verification

Nib deliberately keeps the current built-in surface to General and Code. Code handles planning, architecture, debugging, implementation, and delegation without making you choose a different persona for each phase. Project and global YAML files can still define custom personas with their own role, tool groups, file restrictions, model, and reasoning effort. Select a custom persona explicitly by slug with --mode or /mode; the picker lists the two current built-ins. See the mode specification.

Keys / commands
Enter send · Shift+Enter newline
Esc interrupt; keep complete exchanges, discard partial streamed text
Shift+Tab cycle the approval posture
/ open the command menu
/help full command list
/model, /effort pick model · set reasoning effort
/new, /resume, /continue session management
/clear, /compact clear the conversation and screen · summarize older turns to free context
/undo rewind code and/or conversation
/permissions this session's permission history
/skills, /mcp, /tasks list skills · inspect MCP servers · inspect/stop sub-agent tasks
Ctrl+D twice quit

Common CLI flags

Flag Meaning
[prompt] positional prompt to submit on launch
-p, --print print the response and exit, non-interactive (needs a prompt)
-r, --resume [id] resume a session by ID, or open the picker
-c, --continue continue the most recent session for this directory
--model <provider/model> override the configured model
--mode <name> start in a given mode
--add-dir <path> add a trusted writable directory (repeatable)
--max-turns <n> cap agentic turns in print mode
--plan print mode only: plan posture — read-only tools, reply ends with a <proposed_plan>
-d, --debug opt in to diagnostic request/response JSONL (includes conversation and tool payloads, with secret redaction)
cat error.log | nib -p "Explain this error"

Run nib --help for the complete command-line reference.


Configuration

Create ~/.nib/settings.json (or ./.nib/settings.json per project; project wins when both exist):

{
  "permissions": {
    "defaultMode": "askAll",
    "rules": [
      { "tool": "read_file",     "pattern": "./**", "action": "allow" },
      { "tool": "write_to_file", "pattern": "./**", "action": "allow" },
      { "tool": "run_bash",      "pattern": "*",    "action": "ask"   }
    ]
  },
  "mcpServers": {
    "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] }
  }
}

With the default DeepSeek setup, --mode general uses DeepSeek Flash with low reasoning effort to keep everyday chat fast and inexpensive. An explicit provider or model selection in settings, flags, or slash commands takes precedence; use model and provider here, --model, or /model to choose.

  • Store API keys in ~/.nib/credentials.yaml (via nib auth) or env vars — not in settings.json.
  • Project instructions: .nib/instructions.md (or AGENTS.md).
  • Custom modes: drop a YAML file into ~/.nib/modes/.

Full schema: docs/config-spec.md.

Recommended settings

Default (macOS, sandbox on): sandboxed Bash runs on the session grant, and auto judges the rest.

{ "classifier": { "defaultPosture": "auto" } }

Your own projects (sandbox off): no OS containment, so use it on code you trust.

{
  "sandbox": { "enabled": false },
  "classifier": { "defaultPosture": "auto", "model": { "id": "deepseek/deepseek-flash" } }
}

Both go in ~/.nib/settings.json (these keys are global-only). code is the default persona, on DeepSeek Flash at low effort; /model and /effort change that per session. If context grows, cap it with compaction.maxTokens. See auto mode and the config spec.


Features

  • Modes with real tool boundaries. general is read-only; code adds editing, commands, debugging, and delegation. Custom modes can define their own instructions and tool groups.
  • Explicit permissions. Allow, ask, or deny by tool and pattern. Every decision is inspectable through /permissions.
  • OS sandbox for commands (macOS). Bash, background jobs, MCP servers and hooks run under a Seatbelt profile: writes stay in the workspace, the session temp dir and toolchain caches; reads under $HOME are limited to the workspace; outbound network is allowed (Unix sockets such as Docker's are not). Because of that boundary, ordinary sandboxed Bash runs without a prompt (sandbox.autoAllowBash); background jobs and guarded commands still ask.
  • Auto mode. Press Shift+Tab to auto, or start there with "classifier": { "defaultPosture": "auto" } in ~/.nib/settings.json (global-only). Read-only calls and ordinary edits inside the workspace run silently, and a model judge allows or blocks everything else instead of prompting. It works with the sandbox off, which is the case it is for. It still asks you about credential files (including cat .env and edits of .env or .husky/*), git config changes, anything that would run outside the sandbox and any call matched by an ask rule you wrote, and falls back to a prompt when the judge cannot decide or has blocked 3 calls in a row (20 in total). The judge is classifier.model.id if set, otherwise your current model. It reads your messages and the agent's tool calls, never tool output. Not available with nib -p. See docs/auto-mode.md for the full guide and docs/permission-spec.md §9 for the spec.
  • Recoverable edits. Interactive edits are checkpointed in a shadow Git repo; /undo can rewind code, conversation, or both.
  • Durable sessions. Conversations are append-only JSONL with automatic compaction and resumable todo state. Continue by directory or resume by ID.
  • Lean long sessions. Nib caps oversized tool output, clears older tool results from large model requests, and compacts earlier conversation. Recent results stay available to the model; the complete transcript remains in the local session log.
  • Skills, MCP, and sub-agents. Load Agent Skills, add stdio MCP servers with nib mcp add, and delegate bounded work through new_task.
  • Safe file coordination. Nib tracks when it last read a file and refuses to overwrite changes made outside the agent.
  • Optional web access. Keyless Bing RSS search and HTTPS fetch are permission-gated and marked as untrusted input; arbitrary fetch targets are also SSRF-checked. A local SearXNG instance can provide richer results.
  • Terminal-native visibility. A streaming, Claude Code-style transcript (readable tool headers, collapsed results, a live todo list), token/cost reporting, diagnostics, task status, and opt-in redacted debug logs are all available without leaving the TUI.

Inside the core

Nib's core agent runtime is intentionally one inspectable process. Neither the TUI nor the headless CLI hides a remote agent service. Providers receive tool schemas, but never direct access to tool execution or local files:

TUI / headless CLI → prompt assembly → agent loop ↔ model provider
                                           │
                                           ├─ permission engine → tool registry → files, shell, MCP, sub-agents
                                           │                         │
                                           │                         └─ edit checkpoints (interactive)
                                           │
                                           └─ session log → context editing and compaction
Core Responsibility
Provider boundary Adapts each model through one canonical message and streaming contract.
Agent loop Streams replies, batches tool calls, reflects on failures, guards loops, and stops deterministically.
Prompt assembly Combines a stable cacheable preamble with live project state, rules, research, skills, and todo context.
Personas Change identity and remove unavailable tool groups before a request reaches the model.
Permission engine Resolves allow/ask/deny rules before execution and records every decision. Diagram
Tool registry Keeps tool schemas, mode groups, and handlers behind one dispatch boundary.
Sessions and context Preserve the complete append-only transcript while compacting or editing only provider-bound context.
Checkpoints Snapshot edits in per-session shadow Git repositories so code and conversation can rewind together.
TUI Presents streaming output, approvals, plans, jobs, tasks, models, sessions, and diagnostics.

Start with the architecture overview, then follow the core-system reading path into the normative specs and subsystem deep dives.

Supported models

Nib features DeepSeek, OpenAI, OpenRouter, Groq, and local Ollama, and its bundled Models.dev catalog adds ~190 other OpenAI-compatible providers (run nib auth to connect one). The catalog supplies the selectable models for each provider; switch with /model or --model <provider/model>. DeepSeek V4 Pro is the primary tested model, while the opt-in general mode uses DeepSeek V4 Flash at low reasoning effort.


Better search (optional)

web_search works out of the box via keyless Bing RSS — thin, snippet-only results. For richer results (and inline content excerpts), run your own SearXNG instance locally and point nib at it:

# 1. Start it (localhost-only, port 8888). The compose file renders a fresh
#    random secret_key container-side on every start — the shipped
#    searxng/settings.yml stays a read-only template.
docker compose up -d

# 2. Verify
curl -s http://localhost:8888/healthz    # → OK
curl -s "http://localhost:8888/search?q=test&format=json" | head -c 120

Then add one line to ~/.nib/settings.json:

"webSearch": { "searxngUrl": "http://localhost:8888" }

SearXNG becomes the primary backend, Bing stays as the automatic fallback when the instance is down, and the top results come back with inline content excerpts (enrich defaults on). http:// is accepted only for localhost; a remote instance must use https://. See docs/web-search-spec.md.

If you already run a SearXNG container named searxng on port 8888, remove it (docker rm -f searxng) before docker compose up — the compose file manages the same name and port.

FAQ

Why another AI coding agent?

Nib started as a fix for an agent that broke inside IntelliJ's embedded terminal. It grew into a full tool by combining the best ideas from opencode, RooCode, Aider, and SWE-agent — modes, checkpoints, permission rules — with zero telemetry and no vendor lock-in. Every design decision is documented in docs/.

Does it send my data anywhere?

Nib has no telemetry or analytics. It sends prompts and tool results to the model provider you select, and may contact integrations you explicitly configure or invoke, such as web search, MCP servers, hooks, or notifications.

Is it safe to use on production code?

Nib executes model-chosen commands on your machine. The permission system is the safety net — read docs/security-spec.md before enabling auto mode on code you didn't write.

How do I configure MCP?

Add a server from the command line, restart Nib, then run /mcp to check it connected:

nib mcp add github --env GITHUB_TOKEN=... -- npx -y @modelcontextprotocol/server-github
nib mcp list
nib mcp remove github

Servers run inside Nib's sandbox. Browser servers cannot: the sandbox blocks the macOS services a browser needs. Add those with --no-sandbox, which runs only that server outside it:

nib mcp add playwright --no-sandbox -- npx @playwright/mcp@latest

nib mcp writes mcpServers in ~/.nib/settings.json; you can also edit it by hand. See docs/config-spec.md.

How do I get notified when a task completes?

Set notify in settings.json to the path of a notification script. See docs/notify-spec.md.

Does it support images?

Yes — three routes:

  • Paste — Ctrl+V attaches an image from the clipboard.
  • Mention — @path/to/shot.png in the prompt attaches that file (permission-gated like read_file).
  • Tool — the model calls view_image for an https image URL or a local file path.

Images must be PNG, JPEG, GIF, or WebP and at most 5 MB. The active model must accept image input. read_file refuses binary files rather than returning garbled text.

Does it support Thinking mode?

Yes. Thinking is enabled by default. Models with effort metadata support reasoning effort control through /effort, and ctrl+t cycles the levels. Models that can turn thinking off list none: /effort none (or reasoningEffort: "none" in settings.json; thinkingEnabled: false is an alias).


Docs

Start at docs/README.md — the canonical index of specs, deep dives, and troubleshooting, with reading paths for new contributors, maintainers, and users.

Having trouble? See docs/troubleshooting.md.


Contributing

git clone https://github.com/amenski/nib.git
cd nib
npm install
npm test              # run the test suite
npx tsc --noEmit      # type gate
npm run build         # bundle with tsup

See CONTRIBUTING.md for the PR checklist, code map, and good first contributions. Code of Conduct applies.


License

Apache 2.0

About

Open-source, bring-your-own-key coding agent for the terminal. Built for cheap models: run all day on DeepSeek for a few dollars, or use OpenAI, OpenRouter, Groq, local Ollama. Explicit permissions, no telemetry.

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0