MCPcopy Index your code
hub / github.com/PTFOPlayer/TinyHarness

github.com/PTFOPlayer/TinyHarness @0.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.2 ↗ · + Follow
1,601 symbols 5,292 edges 95 files 580 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TinyHarness

Lightweight AI assistant framework in Rust with pluggable LLM providers (Ollama, llama.cpp, vLLM), built-in tool calling, agent skills, and customizable system prompts.

TinyHarness screenshot

Features

  • Pluggable Providers: Ollama, llama.cpp, vLLM, any OpenAI-compatible API gateway (OpenRouter, Together, etc.) with Bearer auth, and ⚠️ Sockudo AI Transport as a highly experimental backend requiring a running Sockudo server and a worker bridge (see docs/examples/sockudo-worker/). Ollama supports retries with backoff, configurable timeouts, and reasoning/think levels.
  • Tool System: 15 modular tools (ls, read, write, edit, grep, glob, run, web_search, web_fetch, auto_compact, invoke_skill, switch_mode, question, screenshot, plus the built-in read image loader for multimodal models).
  • Agent Modes: Four modes — casual (web-only), planning (read-only + signals), agent (full access), and research (web-focused) — to control what the AI can do. Modes are backed by customizable .md prompt files.
  • Skills: Pluggable SKILL.md modules discovered from ~/.config/tinyharness/skills/ and .tinyharness/skills/. Invokable by the AI via invoke_skill or by the user via /use <name>. Supports YAML frontmatter with name, description, compatibility, licensing, and model-invocation controls.
  • Context Management: Token estimation with per-model context window sizes (8K–256K), load warnings at 70%/90% thresholds, and cascading conversation compaction via /compact.
  • Session Persistence: JSONL-based sessions with UUIDs, saved in ~/.local/share/tinyharness/sessions/. Supports session listing, switching by prefix, renaming, deletion, and auto-save every 5 messages.
  • Async Streaming: Built on tokio for efficient streaming with all providers. Ctrl+C interrupts generation gracefully.
  • Experimental TUI: Split-pane terminal UI with conversation view, sidebar, input bar, and tool output panel. Built from scratch with no external TUI framework. Activate with --tui. ⚠️ Experimental — may have rendering issues or incomplete features.
  • Interactive CLI: Color-coded terminal interface with 24+ slash commands for session management, configuration, file pinning, image attachment, audit logging, debug diagnostics, and tool control.
  • Customizable Prompts: System prompts are seeded from hardcoded defaults on first launch to ~/.config/tinyharness/prompts/ and can be freely edited.
  • Command Safety: Smart auto-accept for safe shell commands with prefix matching, deny lists, redirection stripping, and audit logging.
  • Thinking Display: Optionally render the model's reasoning chain inline during streaming (toggle via /showthink).
  • Image Attachments: Multimodal support — attach images with /image and the read tool automatically loads image files for visual models.
  • Project Instructions: Auto-discovers TINYHARNESS.md, .tinyharness.md, AGENTS.md, or CLAUDE.md walking up from the current directory. Configurable via TINYHARNESS_MD_FILES env var or settings. Additional project-specific files (e.g. RULES.md, .cursorrules) can be loaded from .tinyharness/config.json.
  • Per-Project Settings: Layer .tinyharness/config.json over global settings. Override safe/denied commands, auto-accept behavior, context limits, preferred mode, and more per project. View merged settings with /project-settings.
  • Smart Language Detection: Auto-detects 17+ languages and build tools (Rust, Zig, Deno, Bun, Swift, Ruby, Elixir, Haskell, Kotlin, .NET, Dart/Flutter, Nix, Node.js, Python, Go, Java, C/C++). Detects monorepos (e.g. "Rust + Node.js").

Getting Started

Prerequisites

  • Rust (latest stable, edition 2024)
  • At least one LLM backend:
  • Ollama (default, local)
  • llama.cpp server (local, no auth)
  • vLLM (local, no auth)
  • Any OpenAI-compatible API gateway (OpenRouter, Together, custom proxies, etc.) — requires an API key and explicit URL
  • Sockudo (⚠️ highly experimental — requires a worker bridge, see docs/examples/sockudo-worker/)

Installation

git clone https://github.com/yourusername/TinyHarness.git
cd TinyHarness
make install

This builds in release mode and copies the binary to ~/.local/bin. Make sure ~/.local/bin is in your $PATH:

export PATH="$HOME/.local/bin:$PATH"

To uninstall:

make uninstall

Alternatively, install via Cargo:

cargo install --path .

Installation (Nix)

A Nix flake is provided for reproducible builds and dev environments.

Run once without installing:

nix run github:PTFOPlayer/TinyHarness

Build the package:

cd TinyHarness
nix build
./result/bin/tinyharness

Enter a development shell (with Rust toolchain, rustfmt, and clippy pre-configured):

nix develop

Usage

Ollama (default):

tinyharness

Connects to http://127.0.0.1:11434. Supports configurable timeout, retries, and think/reasoning level.

llama.cpp:

tinyharness --llama-cpp

Connects to http://127.0.0.1:8080 by default.

vLLM:

tinyharness --vllm

Connects to http://127.0.0.1:8000 by default.

OpenAI-compatible gateway (OpenRouter, Together, custom proxies, etc.):

tinyharness --openai-compat --url https://openrouter.ai/api/v1 --api-key <YOUR_KEY>

Requires --url (no default URL) and an API key. You can also set the OPENAI_API_KEY environment variable instead of --api-key. Bearer auth is sent on every request. Use --skip-health-check if the gateway doesn't expose a /health endpoint.

Sockudo (⚠️ highly experimental):

tinyharness --sockudo

Connects to http://127.0.0.1:6001 by default. Requires a running Sockudo server with AI Transport enabled and a worker bridge process (see docs/examples/sockudo-worker/). This backend is not recommended for production use.

A health check runs on startup to verify the provider is reachable. If the saved model is unavailable, the first available model is auto-selected with a warning.

Custom URL (works with any provider):

tinyharness --llama-cpp --url http://localhost:2832
tinyharness --ollama --url http://192.168.1.50:11434
tinyharness --vllm --url http://gpu-server:8000
tinyharness --openai-compat --url https://api.example.com/v1 --api-key sk-xxx

Continue last session:

tinyharness --continue

Resumes the most recent session in the current working directory.

Non-interactive prompt:

tinyharness -p "What does this project do?"
tinyharness --prompt "Explain the architecture"

Sends an initial prompt and then drops into the interactive loop for follow-up turns.

Terminal UI (experimental):

tinyharness --tui

Launches a split-pane TUI with conversation view, sidebar, input bar, and tool output panel. Built from scratch using raw ANSI escape sequences — no external TUI framework. This is experimental and may have rendering issues or incomplete features.

Interactive setup:

tinyharness --config

Runs a guided setup: pick a provider, enter a URL, save to settings. Exits when done.

CLI Arguments

Flag Description
-o, --ollama Use the Ollama provider (default)
-l, --llama-cpp Use the llama.cpp provider
-v, --vllm Use the vLLM provider
--openai-compat Use a generic OpenAI-compatible gateway (requires --api-key and --url)
--sockudo Use the Sockudo AI Transport provider (⚠️ highly experimental)
-u, --url <url> Custom base URL for the provider
--api-key <key> Bearer token for --openai-compat (use - to clear saved key)
--skip-health-check Skip provider health check at startup
-c, --continue Continue the most recent session in the current directory
--config Run interactive provider setup, then exit
-p, --prompt <text> Start with this message, then drop into interactive mode
--tui Launch the experimental terminal UI (split-pane TUI)

Agent Modes

Mode Tools Available Purpose
casual web_search, web_fetch Pure chat with web access, no filesystem access
planning All read-only tools + signal tools Analyze & plan, then escalate to agent
agent All 15 tools Full development access — code, commands, web
research All read-only tools + signal tools Web research, then escalate for execution

Switch modes with /mode <name>, use shortcut aliases (/plan, /agent, /research, /casual), or let the AI request escalation via switch_mode.

Tools

Tool Category Description
ls ReadOnly List directory contents
read ReadOnly Read file content (also loads images for multimodal models)
grep ReadOnly Search with regex across files
glob ReadOnly Find files by glob pattern
web_search ReadOnly Search the web (requires Ollama API key)
web_fetch ReadOnly Fetch a web page by URL
write Destructive Write content to a file
edit Destructive Edit a file by find-and-replace
run Destructive Execute shell commands with timeout & working directory
switch_mode Signal Request a mode switch
question Signal Ask the user a question with options
auto_compact Signal Request conversation compaction
invoke_skill Signal Activate a skill by name
screenshot Signal Request a screenshot from the user

Slash Commands

Session Management

Command Description
/sessions List all saved sessions (most recent first)
/session <id> Switch to an existing session by ID prefix
/session delete <id\|name> Delete a session with confirmation
/rename <name> Rename the current session

Mode & Model

Command Description
/mode [casual\|planning\|agent\|research] Show or switch agent mode
/plan, /agent, /research, /casual Quick mode switch aliases
/model [name] List available models or switch to one

Context & Files

Command Description
/add <path> Pin a file into context
/drop <path> Remove a pinned file from context
/files List all pinned files
/dropall Remove all pinned files
/refresh Re-read pinned files from disk
/context Show auto-detected project context
/init Generate or update TINYHARNESS.md
/project-settings [init] Show or initialize per-project settings

Conversation

Command Description
/compact [focus] Summarize conversation history (with cascading for long sessions)
/image [<path>\|clear\|drop <n>] Attach an image to the next message

Skills

Command Description
/skills List all available skills
/skill <name> Show a skill's details and content
/use <name> Activate a skill, injecting its instructions
/unload <name> Deactivate a previously loaded skill

Configuration

Command Description
/settings [all] Show current configuration
/command [list\|add\|rm\|deny\|undeny\|reset\|resetdeny] Manage auto-accepted and denied commands
/apikey [key\|clear] Set, show, or clear the Ollama API key (needed for web_search)
/contextlimit [tokens] Show or set the context warning threshold
/autoaccept [all\|safe\|off] Show or set auto-accept mode (off, safe = read-only, all = all tools except run)
/autocompact [on\|off] Toggle the auto_compact tool (when off, the model cannot request compaction)
/showthink [on\|off] Toggle display of the model's thinking/reasoning chain
/timeout <seconds> Set Ollama request timeout (default: 5s)
/retries <count> Set Ollama max retries (default: 3)
/think [off\|low\|medium\|high] Set Ollama reasoning/think level
/audit [last\|session\|clear] View command execution audit log

General

Command Description
/help Show available commands
/clear Clear terminal screen
/debug [path] Dump full conversation context to a log file (for diagnostics)
/exit or /quit Exit TinyHarness

Command Management

The /command system controls which shell commands are auto-accepted:

/command list          # Show safe and denied commands
/command add <cmd>     # Add a command to auto-accept list
/command rm <cmd>      # Remove from auto-accept list
/command deny <cmd>    # Add to deny list (always requires confirmation)
/command undeny <cmd>  # Remove from deny list
/command reset         # Reset safe commands to defaults
/command resetdeny     # Clear the deny list

Safe commands include cd, ls, grep, cat, git status, git diff, git log, cargo tree, and ~40 more. Shell redirections (2>&1, 2>/dev/null) are stripped before matching. The deny list takes priority — if a command matches both lists, it is denied. The run tool can never be auto-accepted even in auto-ac

Extension points exported contracts — how you extend this code

Widget (Interface)
A UI widget that can render itself to a screen buffer and handle events. Widgets are the building blocks of the TUI. Ea [6 …
tinyharness-ui/src/tui/widget.rs
Provider (Interface)
(no doc) [5 implementers]
tinyharness-lib/src/provider/mod.rs
Command (Interface)
A self-contained command definition. Each command implements this trait to provide its name, description, usage string, [1 …
src/commands/registry.rs
Backend (Interface)
Abstraction over terminal I/O. The TUI writes all output through a `Backend` implementation. In production, `StdioBacke [2 …
tinyharness-ui/src/tui/backend.rs

Core symbols most depended-on inside this repo

clone
called by 250
tinyharness-ui/src/tui/screen.rs
push
called by 168
tinyharness-ui/src/tui/widgets/tool_output.rs
len
called by 156
tinyharness-ui/src/tui/widgets/tool_output.rs
collect
called by 132
tinyharness-lib/src/context.rs
is_empty
called by 113
src/commands/files.rs
get
called by 98
tinyharness-lib/src/skill.rs
write_str
called by 97
tinyharness-ui/src/tui/screen.rs
path
called by 95
tinyharness-lib/src/config/mod.rs

Shape

Function 967
Method 475
Class 117
Enum 38
Interface 4

Languages

Rust100%

Modules by API surface

tinyharness-ui/src/tui/app.rs93 symbols
tinyharness-ui/src/tui/widgets/conversation.rs87 symbols
tinyharness-ui/src/tui/widgets/input_bar.rs70 symbols
tinyharness-lib/src/provider/sockudo.rs65 symbols
tinyharness-lib/src/config/mod.rs63 symbols
tinyharness-ui/src/tui/screen.rs61 symbols
tinyharness-ui/src/tui/widgets/sidebar.rs48 symbols
tinyharness-ui/src/tui/terminal.rs48 symbols
tinyharness-ui/src/output.rs47 symbols
tinyharness-ui/src/tui/event.rs46 symbols
src/commands/registry.rs39 symbols
tinyharness-ui/src/tui/layout.rs35 symbols

For agents

$ claude mcp add TinyHarness \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact