Skip to content

Beautifully crafted agentic AI engine in Ruby πŸ’Ž

License

Notifications You must be signed in to change notification settings

0x7466/botiasloop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

69 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– BotiasLoop

Ruby Gem Version License StandardRB Tests

Think. Act. Repeat.

A minimal agentic AI application built on the ReAct (Reasoning + Acting) loop pattern.

BotiasLoop gives your AI agent full shell access and web search capabilities via multiple LLM providers. Designed for dedicated infrastructure following the Rails Doctrine β€” beautiful code, sensible defaults, sharp knives.


πŸš€ Installation

Prerequisites

  • Ruby 3.4 or higher
  • API key from your preferred LLM provider (see supported providers below)
  • (Optional) SearXNG instance for web search

Via RubyGems

gem install botiasloop

From Source

git clone https://github.com/0x7466/botiasloop.git
cd botiasloop
bundle install
bundle exec rake install

Using mise (Recommended)

# Install mise if not already installed
curl https://mise.run | sh

# Install Ruby and dependencies
mise install

# Run with mise-managed Ruby
mise exec ruby -- bundle install

⚑ Quick Start

# 1. Configure your API key
export BOTIASLOOP_API_KEY="your-api-key"

# 2. Start chatting
botiasloop cli

# 3. Ask anything!
You: What's the weather in Tokyo?

Agent: I'll search for the current weather in Tokyo for you.

[Tool] Executing web_search with arguments: {"query"=>"current weather Tokyo Japan"}

The weather in Tokyo is currently...

✨ Features

🧠 Core Capabilities

  • ReAct Loop β€” AI reasons, acts using tools, observes results, and repeats
  • 12+ LLM Providers β€” OpenRouter, OpenAI, Anthropic, Gemini, DeepSeek, Mistral, Perplexity, Ollama, and more
  • Shell Access β€” Execute any shell command (full system access)
  • Web Search β€” Search the web via SearXNG integration
  • Token Tracking β€” Monitor input/output tokens per conversation

πŸ’¬ Channels & Interfaces

  • CLI Mode β€” Interactive REPL for local usage
  • Telegram Bot β€” Chat with your agent anywhere
  • Multi-Channel β€” Run CLI + Telegram simultaneously
  • One-Shot Mode β€” Single command execution

πŸ—„οΈ Conversation Management

  • Persistent Storage β€” JSONL-backed conversation history
  • UUID Tracking β€” Every conversation has a unique ID
  • Auto-Labeling β€” Conversations get human-readable names
  • Conversation Switching β€” Jump between active chats
  • Archiving β€” Keep your workspace clean

πŸ› οΈ Built-in Tools

Tool Description
πŸ”§ shell Execute any shell command
πŸ” web_search Search the web via SearXNG

πŸ“š Skills System

Skills follow the agentskills.io specification:

  • Load default skills from data/skills/
  • Load custom skills from ~/skills/
  • Progressive disclosure: name/description in system prompt, full content on demand
  • Includes skill-creator skill for creating new skills

⌨️ Slash Commands

Manage conversations with intuitive commands:

Command Description
/new Start a new conversation
/switch <label|uuid> Switch to a different conversation
/label <name> Label the current conversation
/conversations List all conversations
/reset Clear current conversation history
/compact Summarize and archive old messages
/status Show current model, token usage
/archive Archive old conversations
/system_prompt Show current system prompt
/verbose Toggle verbose mode (show tool calls)
/help Show available commands

🎨 Philosophy

Sharp Knives πŸ”ͺ

BotiasLoop intentionally provides full shell access without restrictions. This is a feature, not a bug. It's designed for dedicated infrastructure where raw power is needed, not personal devices.

The agent can:

  • Execute any shell command
  • Read, write, and delete any file
  • Install software
  • Modify system configuration
  • Access network resources

Rails Doctrine πŸš‚

Following the Rails Doctrine:

  • Optimize for programmer happiness β€” Beautiful, readable Ruby code
  • Convention over Configuration β€” Sensible defaults, minimal setup required
  • The menu is omakase β€” Curated stack (ruby_llm, StandardRB, RSpec)
  • No one paradigm β€” Practical over pure - use what works

πŸ“– Usage

CLI Mode

Start interactive REPL:

botiasloop cli

Exit with: exit, quit, \q, or Ctrl+C

One-Shot Mode

Send a single message:

botiasloop "What's the weather in Tokyo?"

Gateway Mode (Telegram Bot)

Start the gateway to enable Telegram and other channels:

# Run in foreground
botiasloop gateway

# Systemd service management (boot auto-start)
botiasloop gateway enable   # Install and enable boot auto-start
botiasloop gateway start    # Start the service now
botiasloop gateway status   # Check service status
botiasloop gateway stop     # Stop the service
botiasloop gateway logs     # View service logs
botiasloop gateway disable  # Disable boot auto-start and uninstall

Example Session

$ botiasloop cli

botiasloop v0.0.1 - Interactive Mode
Type 'exit', 'quit', or '\q' to exit

You: What files are in this directory?

Agent: I'll check what files are in the current directory for you.

[Tool] Executing shell with arguments: {"command"=>"ls -la"}

Exit: 0
Stdout:
total 128
drwxr-xr-x  10 user  staff   320 Feb 22 14:00 .
drwxr-xr-x   5 user  staff   160 Feb 22 13:00 ..
-rw-r--r--   1 user  staff  2345 Feb 22 14:00 README.md
...

Here are the files in your current directory...

You: /label my-project

Agent: **Conversation labeled as `my-project`**

You: /verbose

Agent: **Verbose mode enabled** β€” You will now see reasoning and tool execution details.

You: exit

Goodbye!

βš™οΈ Configuration

Create ~/.config/botiasloop/config.yml:

OpenRouter (Recommended)

providers:
  openrouter:
    api_key: "your-openrouter-api-key"
    model: "moonshotai/kimi-k2.5"

OpenAI

providers:
  openai:
    api_key: "your-openai-api-key"
    model: "gpt-4o"

Anthropic

providers:
  anthropic:
    api_key: "your-anthropic-api-key"
    model: "claude-3-5-sonnet-20241022"

Ollama (Local)

providers:
  ollama:
    api_base: "http://localhost:11434/v1"
    model: "llama3.2"

Full Configuration Example

# Required: Provider configuration
providers:
  openrouter:
    api_key: "your-api-key"
    model: "moonshotai/kimi-k2.5"

# Optional: Web search configuration
tools:
  web_search:
    searxng_url: "http://localhost:8080"

# Optional: Maximum ReAct iterations (default: 20)
max_iterations: 20

# Optional: Telegram channel
channels:
  telegram:
    bot_token: "your-telegram-bot-token"
    allowed_users: []  # Empty = allow all, or list specific user IDs

# Optional: Logging
logger:
  level: "info"  # debug, info, warn, error
  destination: "stdout"  # stdout, stderr, or path to log file

Environment Variables

Environment variables override config file values:

Variable Description
BOTIASLOOP_API_KEY API key for the active provider
BOTIASLOOP_SEARXNG_URL SearXNG URL for web search
BOTIASLOOP_LOG_LEVEL Log level (debug, info, warn, error)

πŸ”’ Security

⚠️ IMPORTANT: BotiasLoop provides full shell access. The AI agent can:

  • Execute any shell command
  • Read, write, and delete any file
  • Install software
  • Modify system configuration
  • Access network resources

Use only on dedicated infrastructure, never on personal devices or production systems containing sensitive data.

Future Security Features (Roadmap)

  • Sandboxed execution (Docker/Firejail)
  • Command whitelist/blacklist
  • Confirmation for destructive operations
  • Read-only mode option
  • Secret management integration

πŸ› οΈ Development

Setup

# Clone repository
git clone https://github.com/0x7466/botiasloop.git
cd botiasloop

# Install dependencies
bundle install

Testing

Test-first development is required:

# Run all tests
bundle exec rspec

# Run specific test file
bundle exec rspec spec/unit/agent_spec.rb

# Run specific test by line number
bundle exec rspec spec/unit/agent_spec.rb:42

# Check coverage (after running tests)
open coverage/index.html

Linting

Code must pass StandardRB with zero offenses:

# Check for offenses
bundle exec standardrb

# Auto-fix offenses
bundle exec standardrb --fix

Default Rake Task

# Run tests + linting
bundle exec rake

πŸ“ Architecture

botiasloop/
β”œβ”€β”€ bin/
β”‚   └── botiasloop              # CLI executable
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ botiasloop.rb           # Main entry point
β”‚   └── botiasloop/
β”‚       β”œβ”€β”€ agent.rb            # Main orchestrator
β”‚       β”œβ”€β”€ loop.rb             # ReAct cycle implementation
β”‚       β”œβ”€β”€ config.rb           # Configuration management
β”‚       β”œβ”€β”€ conversation.rb     # Conversation persistence
β”‚       β”œβ”€β”€ conversation_manager.rb  # Multi-conversation management
β”‚       β”œβ”€β”€ auto_label.rb       # Auto-labeling conversations
β”‚       β”œβ”€β”€ tool.rb             # Base tool class
β”‚       β”œβ”€β”€ tools/
β”‚       β”‚   β”œβ”€β”€ registry.rb     # Tool registration
β”‚       β”‚   β”œβ”€β”€ shell.rb        # Shell execution
β”‚       β”‚   └── web_search.rb   # SearXNG search
β”‚       β”œβ”€β”€ skills/
β”‚       β”‚   β”œβ”€β”€ skill.rb        # Skill model
β”‚       β”‚   β”œβ”€β”€ loader.rb       # Skill loading
β”‚       β”‚   └── registry.rb     # Skill registry
β”‚       β”œβ”€β”€ commands/
β”‚       β”‚   β”œβ”€β”€ registry.rb     # Command registry
β”‚       β”‚   β”œβ”€β”€ context.rb      # Execution context
β”‚       β”‚   └── *.rb            # Individual commands
β”‚       β”œβ”€β”€ channels/
β”‚       β”‚   β”œβ”€β”€ base.rb         # Channel base class
β”‚       β”‚   β”œβ”€β”€ cli.rb          # CLI channel
β”‚       β”‚   └── telegram.rb     # Telegram bot
β”‚       β”œβ”€β”€ channels_manager.rb # Multi-channel orchestration
β”‚       └── systemd_service.rb  # Service management
β”œβ”€β”€ data/
β”‚   └── skills/                 # Default skills
β”œβ”€β”€ spec/                       # Test suite
└── README.md                   # This file

πŸ—ΊοΈ Roadmap

See ROADMAP.md for detailed planned features:

  • Persistent Memory β€” Vector database for semantic search
  • Custom Tools β€” Load tools from ~/tools/
  • Conversation Compaction β€” Automatic summarization
  • Subagents β€” Specialized agent instances
  • Streaming Responses β€” Real-time token display
  • Multi-Modal β€” Image analysis, audio transcription
  • Web Dashboard β€” Browser-based management UI
  • Plugin System β€” Load plugins from gems

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Write tests first (TDD required)
  4. Implement the feature
  5. Ensure all tests pass: bundle exec rspec
  6. Ensure zero linting offenses: bundle exec standardrb
  7. Commit with descriptive message
  8. Push to your fork
  9. Create a Pull Request

Development Principles

  • Test-First β€” All features built using TDD
  • Sharp Knives β€” Keep raw power, minimal restrictions
  • Rails Doctrine β€” Optimize for programmer happiness
  • Privacy First β€” Local-first, user-controlled data
  • Unix Philosophy β€” Do one thing well, compose with other tools

πŸ“œ License

MIT License β€” see LICENSE file for details.


πŸ™ Credits

Built by Tobias Feistmantl with inspiration from nanobot and the Ruby on Rails doctrine.

Powered by:


⚑ Built with sharp knives. Use responsibly.

About

Beautifully crafted agentic AI engine in Ruby πŸ’Ž

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages