Skip to content

kamilmac/unibear

Repository files navigation

Unibear

License: MIT Version

Unibear

A lean TUI AI assistant: run your tools, stay in control, no magic tricks.

Unibear Screenshot Unibear Demo gif

Table of Contents


Installation

curl -fsSL \
  https://raw.githubusercontent.com/kamilmac/unibear/main/install.sh \
  | bash

Ensure OPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY are set in your environment, depending on the provider you intend to use. (OpenAI, Anthropic, Gemini, and Ollama (for local LLMs) are supported). For Ollama, you might also need to set OPENAI_API_URL (see "Using a local LLM" section).

Launch Unibear in your git repository:

unibear

Getting Started

Follow these steps to begin using Unibear:

  1. Launch Unibear
    Run the following command in your workspace root so that all files
    in this directory are accessible:

    unibear
  2. Configure your editor
    Map a key to send the current buffer or file to Unibear:

    • Neovim

      nnoremap <leader>ua :silent !unibear add_file %:p<CR>
    • Helix

      [keys.normal]
      C-a = [":sh unibear add_file %{buffer_name}"]

    (Unibear can also search for files and list directories)

  3. Brainstorm and iterate

    • Press i to enter Prompt Mode, type your prompt, and hit ↵ to
      get AI suggestions. Continue iterating until you're satisfied.
    • Press Esc to switch to Visual Mode. Navigate with j/k,
      scroll fast with J/K, jump to top (gg) or bottom (G/ge),
      select (v), yank (y), paste (p), or delete chat items with (d).
      You probably noticed that these keybindings are inspired by Helix
      and Neovim.
  4. Apply edits
    Press your + to toggle modify mode,
    which enables file-editing tools. In this mode, you can instruct the AI
    to apply changes to your files and commit them. (Read-only tools are
    available in default mode).


Features

  • 🚀 Work in Prompt or Visual (Vim/Helix-like) modes
  • 🔍 Inject arbitrary file context
  • 🔧 Built-in Git, filesystem, and web-search tools
  • 🤝 Plan & pair-program with your AI buddy before applying edits
  • 🖥️ Responsive TUI with improved visual feedback
  • 📁 Ability to use a local LLM server that supports the OpenAI chat completions API (eg. Ollama)

Editor Integrations

Only one Unibear instance at a time (it runs a local server).

Helix

Add a buffer to Unibear’s context:

unibear add_file <path/to/file>

Example Helix mapping:

# ~/.config/helix/config.toml
[keys.normal]
C-a = [":sh unibear add_file %{buffer_name}"]

Neovim

Bind a key to send the current buffer path to Unibear:

init.vim

nnoremap <leader>ua :silent !unibear add_file %:p<CR>

init.lua

vim.keymap.set("n", "<leader>ua", function()
  vim.cmd("silent !unibear add_file " .. vim.fn.expand("%:p"))
end, { noremap = true, silent = true })

Configuration

Create ~/.config/unibear/config.json:

Note: Supported providers are openai, anthropic, gemini, and ollama.

{
  "provider": "openai", // or "anthropic", "gemini", "ollama"
  "model": "o4-mini",
  "reasoning_effort": "medium", // controls depth of reasoning: low, medium, or high
  "web_search_model": "gpt-4.1-mini",
  "temperature": 0.7,
  "port": 12496,
  "system": <SYSTEM_MESSAGE> // It will replace the Unibear default message
  "theme": "dark",
  "user_name": "Alice",
  "key_bindings": {
    "useModifyTools": "+"
  }
}

Note on Gemini Accounts: Free Gemini accounts are often subject to strict rate limiting by Google, which can lead to frequent 400 errors. This is due to Google's policies on LLM requests for free tier users. If you encounter persistent 400 errors, consider upgrading your Gemini account or exploring alternative API access methods.


Using a local LLM (eg. Ollama)

Unibear supports using local LLMs via the OpenAI chat completions API by providing OPENAI_API_URL environment variable.

# Example using Ollama:
OPENAI_API_URL=http://localhost:11434/v1 unibear

Modes

Prompt Mode

  • Press i
  • Type your prompt and hit ↵
  • Invoke tools like file operations, git commands, or web search

Visual Mode

  • Press Esc
  • Press + to enable write access (modify mode)
  • Navigate output with j/k (or J/K for big scroll)
  • Select (v), yank (y), paste (p), delete (d)
  • Jump to top (gg) or end (G/ge)

Tools

Tool Mode Key Commands
Normal read_multiple_files, search_files, search_content, list_directory, git_get_diff_to_base, git_get_working_diff, git_generate_commit_message, git_review, git_create_pr_description, git_list_local_modified_files, web_search, help
Modify + edit_file, write_file, create_directory, git_commit

Key Bindings

{
  "visual": {
    "quit": ["ctrl-q"],
    "clearChat": ["ctrl-d"],
    "promptMode": ["i"],
    "moveUp": ["k"],
    "moveDown": ["j"],
    "bigMoveUp": ["K"],
    "bigMoveDown": ["J"],
    "select": ["v"],
    "yank": ["y"],
    "paste": ["p"],
    "delete": ["d"],
    "goToTop": ["gg"],
    "goToEnd": ["G", "ge"],
    "useModifyTools": ["+"]
  }
}

Development

Clone the repo and get going locally:

git clone https://github.com/kamilmac/unibear.git
cd unibear

Leverage the built-in Deno tasks:

# watch & run in dev mode
deno task dev

# compile a standalone binary
deno task compile

# faster compile skipping type checks
deno task compile-no-check

Contributing

Contributions welcome! Please open issues or pull requests with clear descriptions. Follow DWYL style guide and run deno fmt & deno lint.

Roadmap

  • Better Windows build support
  • Enhanced LLM model options
  • Support for images
  • Tools as plugins architecture

FAQ

Q: Port already in use?
A: Run lsof -i :<port> and kill the process or change port in config.

Q: Invalid API key?
A: Ensure OPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY is set correctly in your environment, corresponding to the selected provider in your configuration. For Ollama, an API key is typically not required if using the default "ollama" value.

License

MIT

About

A lean TUI AI assistant.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •