aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: c611a0a013261101ef24f770336ce225fab9c435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# cheat

Local command-helper retrieval system using JSONL, SQLite, and sentence-transformers.

## Setup

```sh
export HF_HOME="$PWD/models/hf"
export SENTENCE_TRANSFORMERS_HOME="$PWD/models/hf"
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt
python init_db.py
python build_index.py
```

Then run a query like this:

```sh
python query_index.py "get free disk space"
```

Or install the wrapper script and use `cheat` from anywhere:

```sh
ln -sf "$PWD/bin/cheat" ~/.local/bin/cheat
cheat "get free disk space"
```

To add commands, add to `./cards.jsonl` and rebuild the index:

```sh
python build_index.py
```

For fast repeated queries, start the Unix-socket server once in another terminal:

```sh
python query_index.py --serve
```

Then keep using the same query command:

```sh
cheat "get free disk space"
```

To run the server in the background:

```sh
nohup cheat --serve >/tmp/cheat.log 2>&1 &
```

Useful controls:

```sh
cheat --status
cheat --reload
cheat --stop
```