Skip to content

Commit eea30a0

Browse files
committed
feat: added search bar in TUI
1 parent 0767972 commit eea30a0

5 files changed

Lines changed: 213 additions & 250 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dist/
2424
# local tooling
2525
.agents/
2626
.codex/
27-
27+
.cursor/
2828
# env/cache
2929
.env
3030
.cache

README.md

Lines changed: 6 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ No cloud. No accounts. No telemetry. No AI layer — just fast, offline search i
3939
</p>
4040

4141

42-
## Why devgrep
42+
## Documentations
4343

44-
You fix a hard problem once. The command lives in history for a week, then vanishes behind newer entries, log rotations, and half-written notes.
44+
Comprehensive documentation, including usage guides, is available at [Devgrep Docs](https://devgrep.vercel.app/)
4545

46-
devgrep keeps those breadcrumbs searchable:
46+
* [Getting Started](https://devgrep.vercel.app/docs/getting-started)
47+
* [Commands list](https://devgrep.vercel.app/docs/commands)
48+
* [Some examples](https://devgrep.vercel.app/docs/examples)
49+
* [Contributing](https://devgrep.vercel.app/docs/contributing)
4750

48-
- shell commands you already ran
49-
- deployment and Docker workflows
50-
- log lines with severity
51-
- markdown notes and runbooks
5251

53-
Everything stays on your machine in `~/.local/share/devgrep/devgrep.db`.
5452

5553
---
5654

@@ -79,147 +77,7 @@ make build
7977

8078
Platforms: Linux, macOS, and Windows (`amd64` / `arm64`) via manual method (docs/release.md).
8179

82-
---
83-
84-
## Quick start
85-
86-
```sh
87-
# Build your first index (shell history + default paths)
88-
devgrep index
89-
90-
# Search — opens the TUI when stdout is a terminal
91-
devgrep search "docker postgres"
92-
93-
# Shorthand (same as search)
94-
devgrep docker postgres
95-
```
96-
97-
**Plain output** for scripts and pipes:
98-
99-
```sh
100-
devgrep --plain search "kube auth failed" --source history,logs
101-
```
102-
103-
```text
104-
[history]
105-
docker compose up -d postgres
106-
107-
[last used]
108-
3 weeks ago
109-
110-
[directory]
111-
~/projects/auth-api
112-
113-
[score]
114-
92
115-
```
116-
117-
**Index a project** before searching its logs and notes:
118-
119-
```sh
120-
devgrep index .
121-
devgrep search "migration failed"
122-
```
123-
124-
---
125-
126-
## Example workflows
127-
128-
### Recover a shell command
12980

130-
```sh
131-
devgrep search "kubectl rollout undo"
132-
```
133-
134-
Results show the original command, when you last ran it, and the working directory inferred from history.
135-
136-
### Find a deployment step
137-
138-
```sh
139-
devgrep --plain search "terraform apply staging"
140-
```
141-
142-
### Search project logs
143-
144-
```sh
145-
devgrep index ~/projects/api
146-
devgrep search --source logs "connection refused"
147-
devgrep search --source logs --tail --regex "ERROR|WARN"
148-
```
149-
150-
### Search markdown notes
151-
152-
```sh
153-
devgrep search --source notes "postgres failover"
154-
```
155-
156-
### Inspect what is indexed
157-
158-
```sh
159-
devgrep sources
160-
devgrep sources --tree
161-
devgrep stats
162-
devgrep doctor
163-
```
164-
165-
---
166-
167-
## Features
168-
169-
| | |
170-
| --- | --- |
171-
| **Local-first** | SQLite storage, WAL mode, incremental indexing |
172-
| **Shell history** | Bash and zsh, duplicate suppression, cwd inference |
173-
| **Logs** | `.log` files with severity detection and tail mode |
174-
| **Notes** | Markdown fragments from configured paths |
175-
| **Search** | Fuzzy matching with typo-tolerant ranking fallback |
176-
| **TUI** | Full-screen Bubble Tea UI, vim-style navigation |
177-
| **Watch mode** | `fsnotify` re-indexing for explicit project paths |
178-
| **Unix-friendly** | `--plain` output, direct search shorthand, pipe-safe |
179-
| **Operational** | `sources`, `stats`, and `doctor` for visibility |
180-
181-
---
182-
183-
## How indexing works
184-
185-
```text
186-
~/.bash_history ──┐
187-
~/.zsh_history ──┼──► indexers ──► SQLite ──► search + ranking ──► TUI / plain output
188-
*.log, *.md ──┘ ▲
189-
190-
incremental offsets + watch
191-
```
192-
193-
1. **Indexers** parse history, logs, and notes into normalized documents.
194-
2. **Storage** persists documents, source offsets, and search stats.
195-
3. **Search** loads candidates from SQLite, applies fuzzy matching, and ranks results.
196-
4. **Commands** expose indexing, search, and maintenance through Cobra.
197-
198-
Shell history is indexed incrementally. Log and note indexers walk configured paths with shared ignore rules (`.git`, `node_modules`, large files, binaries, and more).
199-
200-
---
201-
202-
## Sources
203-
204-
| Source | Location | Label in results |
205-
| --- | --- | --- |
206-
| Shell history | `~/.bash_history`, `~/.zsh_history` | `[history]` |
207-
| Logs | `.log` under `indexed_paths` | `[log]` |
208-
| Notes | `.md` under `indexed_paths` | `[note]` |
209-
210-
Default note/log discovery paths (overridable in config):
211-
212-
```text
213-
.
214-
~/notes
215-
~/Documents
216-
```
217-
218-
Config: `~/.config/devgrep/config.yaml` · Database: `~/.local/share/devgrep/devgrep.db`
219-
220-
See [examples/config.yaml](examples/config.yaml) and [docs/config.md](docs/config.md).
221-
222-
---
22381

22482
## Commands
22583

@@ -245,65 +103,7 @@ See [examples/config.yaml](examples/config.yaml) and [docs/config.md](docs/confi
245103

246104
---
247105

248-
## Interactive TUI
249-
250-
When stdout is a TTY, search opens a full-screen interface:
251-
252-
<p align="center">
253-
<img src="assets/screenshot-doctor.svg" alt="devgrep doctor output" width="520">
254-
</p>
255-
256-
| Key | Action |
257-
| --- | --- |
258-
| `/` | Focus live search |
259-
| `j` / `k` | Move selection |
260-
| `gg` / `G` | Jump to top / bottom |
261-
| `enter` | Run selected history command |
262-
| `y` | Copy selected result |
263-
| `esc` / `q` | Quit |
264106

265-
Log and note previews include nearby context lines when the source file is still on disk.
266-
267-
---
268-
269-
## Watch mode
270-
271-
Indexing an explicit directory persists it as a watched path and, by default, keeps it synchronized:
272-
273-
```sh
274-
devgrep index ~/projects/api
275-
```
276-
277-
Watch mode uses `fsnotify` with debounced updates. New and modified files are re-indexed; deleted files are removed from the database.
278-
279-
```sh
280-
devgrep index ~/projects/api --no-watch # index once
281-
devgrep index --watch # restore saved watchers
282-
```
283-
284-
Risky paths (`/`, `~`) require confirmation unless you pass `--yes`. Use `--dry-run` to inspect a tree before indexing.
285-
286-
---
287-
288-
## Architecture
289-
290-
```text
291-
cmd/ Cobra commands and CLI wiring
292-
internal/history/ bash/zsh parsing and incremental history indexing
293-
internal/logs/ log indexing and tail mode
294-
internal/indexer/ pluggable indexer interface, markdown notes
295-
internal/storage/ SQLite migrations, documents, source state
296-
internal/search/ fuzzy search, formatting, result types
297-
internal/ranking/ scoring model (recency, frequency, fuzzy, cwd, …)
298-
internal/tui/ Bubble Tea interface
299-
internal/doctor/ health checks
300-
```
301-
302-
New sources implement the `Indexer` interface in `internal/indexer` without changing command wiring.
303-
304-
Deeper detail: [docs/architecture.md](docs/architecture.md)
305-
306-
---
307107

308108
## Configuration
309109

@@ -324,17 +124,10 @@ make lint # golangci-lint or go vet
324124
make bench # includes 100k-document search benchmark
325125
```
326126

327-
Contributions welcome. Good starting points: new local source indexers, ranking improvements, shell-specific history metadata, and benchmarks.
328-
329-
Please keep changes **offline-first**, **terminal-first**, and **dependency-conscious**.
330127

331128
---
332129

333-
## Privacy
334130

335-
devgrep does not phone home. It does not collect usage data, queries, commands, paths, or logs. Indexing and search happen entirely on local files you point it at.
336-
337-
---
338131

339132
## License
340133

0 commit comments

Comments
 (0)