Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "tinyharness-lib", "tinyharness-ui"]

[package]
name = "TinyHarness"
version = "0.1.2"
version = "0.2.0"
license = "MIT"
description = "tinyharness - ai coding harness"
edition = "2024"
Expand All @@ -13,8 +13,8 @@ name = "tinyharness"
path = "src/main.rs"

[dependencies]
tinyharness-lib = { version = "0.1.2", path = "tinyharness-lib" }
tinyharness-ui = { version = "0.1.2", path = "tinyharness-ui" }
tinyharness-lib = { version = "0.2.0", path = "tinyharness-lib" }
tinyharness-ui = { version = "0.2.0", path = "tinyharness-ui" }
clap = { version = "4.6.1", features = ["derive"] }
tokio = { version = "1.52.1", features = ["full"] }
serde = { version = "1.0.228", features = ["derive"] }
Expand Down
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Lightweight AI assistant framework in Rust with pluggable LLM providers (Ollama,
- **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 22+ slash commands for session management, configuration, file pinning, image attachment, audit logging, 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.
Expand Down Expand Up @@ -100,6 +101,12 @@ tinyharness --prompt "Explain the architecture"
```
Sends an initial prompt and then drops into the interactive loop for follow-up turns.

**Terminal UI (experimental)**:
```bash
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**:
```bash
tinyharness --config
Expand All @@ -117,6 +124,7 @@ Runs a guided setup: pick a provider, enter a URL, save to settings. Exits when
| `-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

Expand Down Expand Up @@ -327,19 +335,36 @@ tinyharness-lib/src/

### UI library (`tinyharness-ui/`)

Terminal UI abstractions — reusable output formatting, diff display, confirmation prompts.
Terminal UI abstractions — reusable output formatting, diff display, confirmation prompts, and the experimental TUI.

```
tinyharness-ui/src/
├── lib.rs Module declarations
├── output.rs Structured output writer (stdout/stderr abstraction)
├── style.rs ANSI color constants (BOLD, CYAN, RED, BG_TOOL, SPINNER_FRAMES, etc.)
└── ui/
├── mod.rs Module declarations
├── confirm.rs Tool call confirmation prompts (Yes/No/Auto-accept)
├── diff.rs Unified diff display
├── input.rs CommandHelper for rustyline tab-completion
└── wrap.rs Word-wrapped output with ANSI-aware line filling
├── ui/
│ ├── mod.rs Module declarations
│ ├── confirm.rs Tool call confirmation prompts (Yes/No/Auto-accept)
│ ├── diff.rs Unified diff display
│ ├── input.rs CommandHelper for rustyline tab-completion
│ └── wrap.rs Word-wrapped output with ANSI-aware line filling
└── tui/ ⚠️ Experimental TUI subsystem
├── mod.rs TUI module declarations + agent integration types (TuiAgentEvent, TuiUserAction)
├── app.rs Main TUI application loop, widget layout, event dispatch
├── backend.rs Backend trait (StdioBackend + TestBackend for testing)
├── cell.rs Color/style representation for the screen buffer (raw ANSI, no framework)
├── event.rs Event system (keyboard, mouse, paste)
├── layout.rs Rect/constraint-based layout (inspired by ratatui, from scratch)
├── screen.rs Screen buffer with differential rendering (only changed cells written)
├── terminal.rs Raw terminal control, alternate screen, signal handling
├── widget.rs Widget trait, Action enum, shared style helpers
└── widgets/
├── conversation.rs Conversation pane (streaming text, thinking, tool calls)
├── input_bar.rs Multi-line input with history, word-wrap, paste
├── sidebar.rs Context panel (files, tools, mode, model info)
├── spinner.rs Streaming indicator
├── status_bar.rs Top bar (mode, model, token count)
└── tool_output.rs Tool result viewer
```

### Binary crate (`src/`)
Expand All @@ -348,9 +373,10 @@ CLI application — argument parsing, agent loop, slash commands, tool dispatch,

```
src/
├── main.rs Entry point, CLI parsing (clap), provider creation, session init
├── main.rs Entry point, CLI parsing (clap), provider creation, session init, TUI launch
├── agent/
│ ├── mod.rs Main interaction loop, streaming response display, spinner, thinking chain
│ ├── tui_loop.rs Background agent loop for TUI mode (communicates via channels)
│ ├── tools.rs Tool call dispatch, confirmation, generic execution, signal handlers
│ ├── safety.rs Shell command safety checker (prefix + deny list + redirection stripping)
│ ├── setup.rs Interactive provider setup (--config), URL prompting
Expand Down
6 changes: 4 additions & 2 deletions TINYHARNESS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TinyHarness

Lightweight AI assistant framework in Rust with pluggable LLM providers (Ollama, llama.cpp, vLLM) and built-in tool calling.
Lightweight AI assistant framework in Rust with pluggable LLM providers (Ollama, llama.cpp, vLLM), built-in tool calling, and an experimental terminal UI (TUI).

## Commands

Expand All @@ -11,13 +11,14 @@ Lightweight AI assistant framework in Rust with pluggable LLM providers (Ollama,
- Formatting: `cargo fmt --all`
- Install: `make install` (builds release + copies to `~/.local/bin`)
- Run: `cargo run` (Ollama default) or `cargo run -- --llama-cpp` / `--vllm`
- TUI (experimental): `cargo run -- --tui`

## Workspace Structure

Three crates in a Cargo workspace:

- **`tinyharness-lib`** — Core library: providers, tools, sessions, context, skills, tokens. No terminal I/O.
- **`tinyharness-ui`** — UI library: ANSI output, confirmation prompts, diff display, command input.
- **`tinyharness-ui`** — UI library: ANSI output, confirmation prompts, diff display, command input, experimental TUI subsystem.
- **`TinyHarness`** — Binary CLI: agent loop, slash commands, tool dispatch, setup.

### Key `tinyharness-lib` modules
Expand All @@ -33,6 +34,7 @@ Three crates in a Cargo workspace:
### Binary crate structure

- `src/agent/` — Agent loop, tool execution, safety checks, display, multi-line input, provider setup
- `src/agent/tui_loop.rs` — Background agent loop for TUI mode (communicates with TUI via mpsc channels)
- `src/commands/` — 22+ slash commands (mode, model, sessions, compact, init, context, files, image, skill, settings, help, etc.), `CommandRegistry` and `async_command!` macro

## Code Conventions
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ All CLI flags override settings:
| `-c`, `--continue` | Loads most recent session (doesn't modify settings) |
| `--config` | Runs interactive setup, saves, exits |
| `-p`, `--prompt <text>` | Sends initial prompt then enters interactive mode |
| `--tui` | Launch the experimental terminal UI (split-pane TUI) |

---

Expand Down
17 changes: 14 additions & 3 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,23 @@ tinyharness-lib/ Core library — no terminal I/O, no ANSI, no rust
│ ├── mode.rs AgentMode enum, prompt assembly
│ └── prompts/ Hardcoded default system prompts (.md files)
tinyharness-ui/ UI library — terminal output abstractions
tinyharness-ui/ UI library — terminal output abstractions + experimental TUI
├── src/
│ ├── lib.rs Module declarations
│ ├── output.rs Structured output writer
│ ├── style.rs ANSI color constants, spinner frames
│ └── ui/ confirm.rs, diff.rs, input.rs, wrap.rs
│ ├── ui/ confirm.rs, diff.rs, input.rs, wrap.rs
│ └── tui/ ⚠️ Experimental TUI subsystem
│ ├── mod.rs Agent integration types (TuiAgentEvent, TuiUserAction)
│ ├── app.rs Main TUI application loop
│ ├── backend.rs Backend trait (StdioBackend + TestBackend)
│ ├── cell.rs Color/style for screen buffer (raw ANSI, no framework)
│ ├── event.rs Keyboard/mouse/paste events
│ ├── layout.rs Constraint-based layout
│ ├── screen.rs Differential rendering screen buffer
│ ├── terminal.rs Raw terminal control, alternate screen
│ ├── widget.rs Widget trait, Action enum
│ └── widgets/ conversation, input_bar, sidebar, spinner, status_bar, tool_output
docs/ User-facing documentation
└── todo/ Enhancement tracking (local only, not committed)
Expand All @@ -64,7 +75,7 @@ docs/ User-facing documentation
### Crate Rules

- **`tinyharness-lib`**: Must not use terminal I/O, ANSI escape codes, or `rustyline`. Uses `tracing` for logging.
- **`tinyharness-ui`**: Terminal UI abstractions — ANSI colors, confirmation prompts, diff display, word wrapping.
- **`tinyharness-ui`**: Terminal UI abstractions — ANSI colors, confirmation prompts, diff display, word wrapping. Includes an experimental TUI subsystem (`tui/` module) built from scratch with raw ANSI escape sequences (no ratatui/crossterm). The TUI is feature-gated behind the `tui` Cargo feature.
- **`src/` (binary)**: Wires everything together. Handles I/O, user interaction, and the agent loop.

---
Expand Down
Loading
Loading