Metadata-Version: 2.4
Name: aimancli
Version: 0.2.0
Summary: Tiny on-device models that turn plain-English intent into Linux commands
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/experimente-oo-r/aiman
Project-URL: Source, https://github.com/experimente-oo-r/aiman
Project-URL: Issues, https://github.com/experimente-oo-r/aiman/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scikit-learn>=1.2
Requires-Dist: joblib
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# aiman

Tiny on-device models that turn plain-English intent into Linux commands, one command at a time.

```console
$ aiman find "delete .log files older than 30 days in /var/log"
find /var/log -type f -name '*.log' -mtime +30 -delete
destructive -- would affect 3 item(s):
    /var/log/app.log
    ...
type 'yes' to run:
```

No LLM and no GPU: each tool is a slot-filling model (a token tagger plus a few sentence
classifiers, about 5 MB) and a deterministic rule engine that writes the command.
Destructive commands are previewed and need an explicit `yes`.

## Benchmark: aiman find vs Qwen2.5-Coder-0.5B (Q4_K_M, llama.cpp)

Same intents, same machine (x86_64, 8 CPUs). Latency is per intent.

| Metric | aiman | Qwen 0.5B Q4 |
|---|---|---|
| Size on disk | 5.3 MB | 491.4 MB |
| Cold start + answer, median | 1722 ms | 1208 ms |
| Warm answer, median | 22.1 ms | 528.0 ms |
| Warm answer, p95 | 24.7 ms | 907.3 ms |
| Accuracy, val (templated), in-schema | 97.1% (202/208) | 17.3% (36/208) |
| Accuracy, val (templated), all items | 86.7% (202/233) | 15.5% (36/233) |

**Caveat:** the validation set comes from the same template generator aiman is trained on,
so these accuracy numbers favour aiman and overstate how it does on real phrasing. Qwen gets
a 2-shot prompt with greedy decoding and no fine-tuning. Reproduce with `pytest -m bench -s`
(see `tests/test_llm_baseline.py`); full output in `results/baseline.md`.

## Per-tool accuracy

| Tool | Status | In-schema accuracy (val) | Model size |
|------|--------|--------------------------|-----------|
| find | v0.1   | 97.1%                    | 5.2 MB    |
| ls   | v0.2   | 99.2%                    | 3.6 MB    |

## Quick start

```bash
pip install -e .                 # needs scikit-learn, joblib
aiman all find                   # build dataset -> train -> evaluate (~35 s on a laptop CPU)
aiman find -n "count jpg files in my home folder"
```

## Layout

```
aiman/
  cli.py                 aiman <tool> "intent" | build | train | eval | all | list
  core/                  shared by every tool
    tool.py              plugin contract (Tool base class)
    tagger.py            span tagger (BIO)
    classifiers.py       sentence classifiers
    pipeline.py          dataset -> labels -> train -> evaluate -> Predictor
    safety.py            show / preview / confirm / run
    registry.py          discovers aiman/tools/*
  tools/
    find/                one folder per command
      schema.json        slots the tool understands
      templates.py       intent -> command data generator
      slots.py           parse / build / tag / targets
      rules.py           lexicons, normalisers, assemble()
      fixture.py         sandbox for validation and equivalence
tests/
data/, models/           generated, git-ignored
```

## Adding a command

1. Copy `aiman/tools/find/` to `aiman/tools/<cmd>/`.
2. Write `schema.json`: the slots the command needs.
3. Write `templates.py`: intent/command pairs covering its options.
4. Implement the `Tool` methods (see `aiman/core/tool.py`).
5. Add `tests/test_<cmd>.py`, run `aiman all <cmd>` and `pytest`.

See [ROADMAP.md](ROADMAP.md) for the order commands are added.
