Skip to main content

A terminal assistant that runs shell commands from natural language using a local LLM

Project description

unix-tutor

A terminal assistant that runs shell commands from natural language using a local LLM (Ollama). Works as a hybrid shell: type real commands and they run directly; prefix with llm-exec to translate natural language into a command first.

Install

pip install unix-tutor

Requires Ollama running locally with a model pulled:

ollama pull qwen2.5:7b
ollama serve

Usage

Terminal CLI

unix-tutor
Input Behavior
ls -la Runs directly as a shell command
llm-exec show all python files LLM translates → shows command → [y/N] → runs
add-constraint Prompts to add a blocked path or soft constraint rule
exit Quit

Desktop UI

unix-tutor-ui

Full agent-based chat interface with guardrails manager, command history, and file operations.

Guardrails

Add constraints without restarting — type add-constraint at the prompt:

You> add-constraint

Which constraint type would you like to add?
  1. Blocked path   — prevent access to a specific file or directory
  2. Soft constraint — a rule added to the agent's behavior
Enter 1 or 2:

Blocked paths are enforced at the tool layer — no command (direct or LLM-generated) can touch them, even if the path casing differs (macOS case-insensitive filesystem handled).

Soft constraints are injected into the agent's guidance in the desktop UI.

Constraints persist across sessions in ~/Library/Application Support/UnixAgent/guardrails.json.

Hard-blocked commands (always enforced, not configurable)

The following commands are always rejected regardless of input:

  • Privilege escalation: sudo, su
  • Network/remote: ssh, scp, curl, wget, nc, telnet
  • Process/service control: kill, killall, shutdown, reboot, launchctl, systemctl
  • Disk operations: mount, diskutil, fdisk, dd
  • Shell spawns: bash, sh, zsh, fish

Destructive commands (rm, rmdir) require [y/N] confirmation before running.

Configuration

Settings are loaded from ~/Library/Application Support/UnixAgent/.env (auto-created on first run). Override by placing a .env in the directory where you run unix-tutor:

LLM_API_KEY=ollama
LLM_BASE_URL=http://localhost:11434
LLM_MODEL=qwen2.5:7b

Project Structure

src/unix_tutor_agent/
  cli.py          — hybrid terminal CLI (llm-exec prefix + direct shell)
  ui.py           — Tkinter desktop UI and agent backend
  agent.py        — agent construction and turn execution
  tools.py        — agent tools (run commands, file ops, history, guardrails)
  guardrails.py   — blocked paths and soft constraints (persisted to JSON)
  config.py       — settings loading from env
  session.py      — workspace-scoped shell session (cd state)
  db.py           — SQLite command history schema and logging
run_ui.py         — dev launcher for the desktop UI

Evaluation

The evaluation harness and dataset:

  • Dataset: eval/scenarios.json
  • Runner: eval/run_eval.py
  • LLM candidate generator: eval/generate_llm_candidates.py
  • Judge spot-check tool: eval/spot_check_judge.py

Run deterministic eval

python eval/run_eval.py --k 5

Run two configurations for comparison:

python eval/run_eval.py --k 5 --models "claude-haiku-4-5,claude-opus-4-6-v1"

Run one specific scenario:

python eval/run_eval.py --k 1 --scenario-id create_notes_dir

Pass@k Results

Model: claude-sonnet-4-6

  • pass@1: 0.714 (10/14)
  • pass@5: 0.786 (11/14)
  • hard_safety_breach_rate: 0.000

Model: api-gpt-oss-120b

  • pass@1: 0.500 (7/14)
  • pass@5: 0.571 (8/14)
  • hard_safety_breach_rate: 0.000

Hard-block guardrails are enforced at the tool layer regardless of model output — blocked commands are never executed.

Optional LLM-as-judge

python eval/run_eval.py --k 5 --use-llm-judge --judge-model "claude-opus-4-6-v1"

Spot-check judge verdicts

python eval/spot_check_judge.py --results eval/results/eval_results_<timestamp>.json --samples 5

Demo

https://youtu.be/cUaGNh2H8Jc

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unix_tutor-0.3.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unix_tutor-0.3.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file unix_tutor-0.3.0.tar.gz.

File metadata

  • Download URL: unix_tutor-0.3.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for unix_tutor-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c8f22e52a9e52a5fa760ce77bb4d127a30bd870b59efc3035926be41836499b6
MD5 eab6b69ccf5bbbd6423bbfc125bb8a92
BLAKE2b-256 592423269544c13b01c874d562332b3af94b5a332577fa8c773d780d280e34d5

See more details on using hashes here.

File details

Details for the file unix_tutor-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: unix_tutor-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for unix_tutor-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a9a0eb022b0924cc7e3ef78f9664e469e3e4c4c6d946823e70f9dda12f93186
MD5 461b86dafbe1f6051c836b60938a8c8b
BLAKE2b-256 8cad61d93ef0c5cfa44e2a0a73cafbcc69d6cc185b6ab0507a9bd40510527e2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page