own-rag-cli 0.0.1-snapshot → 0.0.3-snapshot

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,133 +1,220 @@
1
- # MCP binary checksum (SHA-256, payload without shebang): `3246eeb57f901742d915e0bce37fa96f059e149a57bbce73095ff4e5ea51d8d4`
2
-
3
1
  # own-rag
4
2
 
5
- Local RAG for codebases with:
6
- - ChromaDB (Docker)
7
- - MCP server (`mcp-rag-server`)
8
- - CPU embeddings (`jina`, `bge`, `hybrid`)
9
- - Cross-platform setup (`Linux` and `macOS`)
3
+ Local RAG for codebases with ChromaDB + MCP, focused on simple setup and local control.
4
+
5
+ Language: English (default) | Portuguese: `README.pt-br.md`
10
6
 
11
- ## Why this repo
7
+ ## Why use own-rag
12
8
 
13
- `own-rag` lets you index local projects and query them from MCP-compatible tools (Claude/Cursor).
9
+ - Search your codebase semantically from MCP clients (Claude/Cursor).
10
+ - Keep data local by default.
11
+ - Run on CPU (no GPU required).
12
+ - Choose between safer memory usage (`autotune`) or higher throughput (`max-performance`).
14
13
 
15
- It includes:
16
- - installers: `rag-setup.run`, `rag-setup-macos.run`
17
- - MCP server source: `bin/mcp_server.py`
18
- - indexer source: `bin/indexer_full.py`
19
- - monitor and wrapper scripts
14
+ ## What gets installed
20
15
 
21
- ## Source vs Artifact
16
+ - ChromaDB container (Docker)
17
+ - Python virtual environment (`~/.rag_venv`)
18
+ - MCP server binary (`~/.local/bin/mcp-rag-server`)
19
+ - Setup runners (`rag-setup.run`, `rag-setup-macos.run`)
20
+ - CLI wrapper command: `rag`
22
21
 
23
- This repo is fully auditable:
24
- - source of logic: `bin/*.py` and `bin/*.sh`
25
- - generated artifacts: `rag-setup.run`, `rag-setup-macos.run`
22
+ ## Install and run
26
23
 
27
- To refresh embedded payloads from source files:
24
+ ### Option A: npm (recommended)
28
25
 
29
26
  ```bash
30
- ./bin/build_run.sh
31
- ./bin/build_run_macos.sh
27
+ npm install -g own-rag-cli
28
+ rag run /path/to/your/project
32
29
  ```
33
30
 
34
- ## Quick Start
31
+ If you run `rag run` without a path, it asks whether to use the current directory.
35
32
 
36
- ### Linux
33
+ ### Option B: direct `.run`
34
+
35
+ Linux:
37
36
 
38
37
  ```bash
39
38
  chmod +x rag-setup.run
40
- ./rag-setup.run /path/to/project
39
+ ./rag-setup.run /path/to/your/project
41
40
  ```
42
41
 
43
- ### macOS
42
+ macOS:
44
43
 
45
44
  ```bash
46
45
  chmod +x rag-setup-macos.run
47
- ./rag-setup-macos.run /path/to/project
46
+ ./rag-setup-macos.run /path/to/your/project
48
47
  ```
49
48
 
50
- ### NPM wrapper
49
+ ## Main commands
51
50
 
52
51
  ```bash
53
- rag run /path/to/project
54
- rag monitor
55
- rag remove
52
+ rag run /path/to/project # full setup + indexing
53
+ rag monitor # interactive Chroma monitor
54
+ rag monitor full # full monitor dashboard
55
+ rag remove # full local uninstall (double confirmation)
56
+ rag remove --force # uninstall without confirmation prompts
56
57
  ```
57
58
 
58
- ## What setup does
59
+ ## Configuration files and paths
59
60
 
60
- 1. Creates `~/.rag_venv` and installs dependencies.
61
- 2. Starts ChromaDB in Docker with persistent volume (`~/.rag_db`).
62
- 3. Installs `mcp-rag-server` in `~/.local/bin`.
63
- 4. Optionally updates MCP config files (`.claude.json`, Cursor config).
64
- 5. Indexes the project.
61
+ ### 1) Runtime config (CLI-level)
65
62
 
66
- ## ChromaDB Port Behavior
63
+ Path: `~/.own-rag-cli.json`
67
64
 
68
- - Default host port is `8000`.
69
- - During ChromaDB install/reinstall, setup asks for the port.
70
- - The installer checks if the chosen port is already in use using native tools:
71
- - Linux: `ss` (fallback: `lsof` / `netstat`)
72
- - macOS: `lsof` (fallback: `netstat`)
73
- - If the port is busy, it asks for another one.
74
- - In non-interactive runs, it auto-selects the next free port.
75
- - Selected port is propagated to:
76
- - Docker Compose mapping
77
- - health checks
78
- - MCP config (`CHROMA_PORT`)
79
- - indexer runtime (`MCP_CHROMA_PORT`)
65
+ Purpose:
66
+ - Stores Chroma endpoint (`scheme`, `host`, `port`).
67
+ - Stores latest indexing batch fields (`indexing.embedding_batch_size`, `indexing.batch_count`).
80
68
 
81
- ## Performance Profiles
69
+ Example:
82
70
 
83
- Available in indexer/setup:
84
- - `autotune` (recommended): uses local machine metrics and short benchmark.
85
- - `max-performance`: higher throughput and higher memory usage risk.
71
+ ```json
72
+ {
73
+ "chroma": {
74
+ "scheme": "http",
75
+ "host": "localhost",
76
+ "port": 8000
77
+ },
78
+ "indexing": {
79
+ "embedding_batch_size": 4,
80
+ "batch_count": 4
81
+ }
82
+ }
83
+ ```
86
84
 
87
- `max-performance` warning shown by setup:
85
+ ### 2) Indexer tuning config
88
86
 
89
- ```text
90
- Este modo pode elevar consideravelmente o consumo de memória e causar encerramento por OOM (exit 137).
91
- ```
87
+ Path: `~/.cache/own-rag-cli/indexer_tuning.json`
92
88
 
93
- ## Key Environment Variables
89
+ Purpose:
90
+ - Persists model/profile/tuning decisions (`chunk_size`, `chunk_overlap`, `embedding_batch_size`, etc.).
91
+ - Loaded by both indexer and MCP server to keep behavior consistent across re-runs.
94
92
 
95
- - `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
96
- - `MCP_JINA_QUANTIZATION=default|dynamic-int8`
97
- - `MCP_PERF_PROFILE=autotune|max-performance`
98
- - `MCP_CHROMA_PORT=8000`
99
- - `MCP_CHUNK_SIZE`
100
- - `MCP_CHUNK_OVERLAP`
101
- - `MCP_EMBEDDING_BATCH_SIZE`
93
+ ### 3) Database and runtime directories
94
+
95
+ - Chroma data: `~/.rag_db`
96
+ - Python venv: `~/.rag_venv`
97
+ - Installed binaries/scripts: `~/.local/bin/`
98
+
99
+ ### 4) MCP client config files (optional auto-update)
100
+
101
+ - Claude Code: `~/.claude.json`
102
+ - Cursor: `~/.cursor/mcp.json`
103
+ - Cursor (alt, Linux/macOS variants): `~/.config/Cursor/User/mcp.json` or `~/Library/Application Support/Cursor/User/mcp.json`
104
+
105
+ ## Choosing the embedding model (practical guidance)
102
106
 
103
- ## Useful Commands
107
+ These are practical memory guidelines for CPU usage. Real usage depends on project size, file size, and other running processes.
108
+
109
+ | Choice | Use case | Approx RAM target |
110
+ |---|---|---|
111
+ | `bge` (`BAAI/bge-m3`) | mixed docs + code, safer memory | 8-16 GiB |
112
+ | `jina` (`jinaai/jina-embeddings-v3`, default) | code-focused quality | 32-64 GiB (48+ GiB preferred) |
113
+ | `hybrid` (`jina v2 + bge`) | two collections, broader retrieval strategy | 24-48 GiB |
114
+
115
+ Notes:
116
+ - Jina on CPU is heavy; with low free RAM/swap, you can see slowdowns or OOM (`exit 137`).
117
+ - If your machine has limited memory, start with `bge`.
118
+
119
+ ## Performance profile
120
+
121
+ During setup/indexing, choose one profile:
122
+
123
+ - `autotune` (recommended):
124
+ - Runs a short local benchmark (`model.encode`) with `psutil` metrics.
125
+ - Tries to keep memory in a safer range (roughly cost-benefit target).
126
+ - Automatically adjusts `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
127
+
128
+ - `max-performance`:
129
+ - Uses more aggressive throughput-oriented parameters.
130
+ - Explicit warning is shown because memory can increase considerably.
131
+
132
+ ## Chroma endpoint behavior
133
+
134
+ - Default local endpoint is `http://localhost:8000`.
135
+ - Setup checks if the selected port is already in use.
136
+ - If `host` in `~/.own-rag-cli.json` is remote (not localhost/127.0.0.1/::1), local Docker startup is skipped.
137
+
138
+ ## Common flows
139
+
140
+ ### Reindex only
104
141
 
105
142
  ```bash
106
- # only index (infra already installed)
107
143
  ./rag-setup.run /path/to/project --only-index
144
+ ```
145
+
146
+ ### Skip index step
108
147
 
109
- # skip indexing
148
+ ```bash
110
149
  ./rag-setup.run /path/to/project --skip-index
150
+ ```
111
151
 
112
- # force reinstall
113
- ./rag-setup.run /path/to/project --reinstall
152
+ ### Change model later
114
153
 
115
- # force model change flow
154
+ ```bash
116
155
  ./rag-setup.run --change-model /path/to/project
117
156
  ```
118
157
 
119
- ## Development
158
+ This flow warns about resetting Chroma collections and requiring full reindex.
159
+
160
+ ## Environment overrides
161
+
162
+ Main overrides:
163
+
164
+ - `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
165
+ - `MCP_JINA_QUANTIZATION=default|dynamic-int8`
166
+ - `MCP_PERF_PROFILE=autotune|max-performance`
167
+ - `MCP_EMBEDDING_BATCH_SIZE=<int>`
168
+ - `MCP_CHUNK_SIZE=<int>`
169
+ - `MCP_CHUNK_OVERLAP=<int>`
170
+ - `OWN_RAG_CLI_CONFIG_FILE=<path>`
171
+ - `MCP_INDEXER_CONFIG_FILE=<path>`
172
+ - `MCP_CHROMA_SCHEME=http|https`
173
+ - `MCP_CHROMA_HOST=<host>`
174
+ - `MCP_CHROMA_PORT=<port>`
175
+
176
+ ## Checksum verification (`.run`)
177
+
178
+ Current checksum (documented in this repo) refers to payload hash.
179
+
180
+ Manual verification (Linux/macOS):
181
+
182
+ ```bash
183
+ sha256sum rag-setup.run
184
+ sha256sum rag-setup-macos.run
185
+ ```
186
+
187
+ On macOS without `sha256sum`:
188
+
189
+ ```bash
190
+ shasum -a 256 rag-setup.run
191
+ shasum -a 256 rag-setup-macos.run
192
+ ```
193
+
194
+ ## Source transparency
195
+
196
+ Project logic is in source files (`bin/*.py`, `bin/*.sh`).
197
+ Generated artifacts:
198
+
199
+ - `rag-setup.run`
200
+ - `rag-setup-macos.run`
201
+
202
+ Rebuild artifacts after source changes:
203
+
204
+ ```bash
205
+ ./bin/build_run.sh
206
+ ./bin/build_run_macos.sh
207
+ ```
120
208
 
121
- - Edit source files in `bin/`.
122
- - Rebuild payloads with `./bin/build_run.sh` and `./bin/build_run_macos.sh`.
123
- - Validate before commit:
209
+ ## Validation before release
124
210
 
125
211
  ```bash
126
212
  bash -n rag-setup.run
127
213
  bash -n rag-setup-macos.run
128
- python3 -m py_compile bin/indexer_full.py
214
+ python3 -m py_compile bin/indexer_full.py bin/mcp_server.py
215
+ npm pack --dry-run
129
216
  ```
130
217
 
131
218
  ## License
132
219
 
133
- MIT (or your preferred OSS license file in this repo).
220
+ MIT
@@ -0,0 +1,218 @@
1
+ # own-rag
2
+
3
+ RAG local para codebases com ChromaDB + MCP, focado em instalação simples e controle local.
4
+
5
+ Idioma: Português (PT-BR) | English: `README.md`
6
+
7
+ ## Por que usar o own-rag
8
+
9
+ - Busca semântica no seu código via clientes MCP (Claude/Cursor).
10
+ - Dados locais por padrão.
11
+ - Execução em CPU (sem GPU obrigatória).
12
+ - Escolha entre perfil mais seguro de memória (`autotune`) ou maior throughput (`max-performance`).
13
+
14
+ ## O que é instalado
15
+
16
+ - Container ChromaDB (Docker)
17
+ - Ambiente virtual Python (`~/.rag_venv`)
18
+ - Binário MCP (`~/.local/bin/mcp-rag-server`)
19
+ - Instaladores (`rag-setup.run`, `rag-setup-macos.run`)
20
+ - Comando wrapper: `rag`
21
+
22
+ ## Instalação e execução
23
+
24
+ ### Opção A: npm (recomendado)
25
+
26
+ ```bash
27
+ npm install -g own-rag-cli
28
+ rag run /caminho/do/projeto
29
+ ```
30
+
31
+ Se executar `rag run` sem caminho, o CLI pergunta se deve usar o diretório atual.
32
+
33
+ ### Opção B: `.run` direto
34
+
35
+ Linux:
36
+
37
+ ```bash
38
+ chmod +x rag-setup.run
39
+ ./rag-setup.run /caminho/do/projeto
40
+ ```
41
+
42
+ macOS:
43
+
44
+ ```bash
45
+ chmod +x rag-setup-macos.run
46
+ ./rag-setup-macos.run /caminho/do/projeto
47
+ ```
48
+
49
+ ## Comandos principais
50
+
51
+ ```bash
52
+ rag run /caminho/do/projeto # setup completo + indexação
53
+ rag monitor # monitor interativo do Chroma
54
+ rag monitor full # painel completo do monitor
55
+ rag remove # desinstalação completa local (dupla confirmação)
56
+ rag remove --force # desinstala sem prompts de confirmação
57
+ ```
58
+
59
+ ## Arquivos e caminhos de configuração
60
+
61
+ ### 1) Configuração de runtime (nível CLI)
62
+
63
+ Caminho: `~/.own-rag-cli.json`
64
+
65
+ Finalidade:
66
+ - Armazena endpoint do Chroma (`scheme`, `host`, `port`).
67
+ - Armazena campos de batch da indexação (`indexing.embedding_batch_size`, `indexing.batch_count`).
68
+
69
+ Exemplo:
70
+
71
+ ```json
72
+ {
73
+ "chroma": {
74
+ "scheme": "http",
75
+ "host": "localhost",
76
+ "port": 8000
77
+ },
78
+ "indexing": {
79
+ "embedding_batch_size": 4,
80
+ "batch_count": 4
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### 2) Configuração de tuning do indexador
86
+
87
+ Caminho: `~/.cache/own-rag-cli/indexer_tuning.json`
88
+
89
+ Finalidade:
90
+ - Persiste decisões de modelo/perfil/tuning (`chunk_size`, `chunk_overlap`, `embedding_batch_size`, etc.).
91
+ - É lido por indexador e MCP server para manter consistência entre execuções.
92
+
93
+ ### 3) Diretórios de dados e runtime
94
+
95
+ - Dados do Chroma: `~/.rag_db`
96
+ - Venv Python: `~/.rag_venv`
97
+ - Binários/scripts instalados: `~/.local/bin/`
98
+
99
+ ### 4) Arquivos de configuração MCP (auto-update opcional)
100
+
101
+ - Claude Code: `~/.claude.json`
102
+ - Cursor: `~/.cursor/mcp.json`
103
+ - Cursor (variações Linux/macOS): `~/.config/Cursor/User/mcp.json` ou `~/Library/Application Support/Cursor/User/mcp.json`
104
+
105
+ ## Escolha do modelo de embeddings (guia prático)
106
+
107
+ Valores abaixo são referência prática para CPU. O consumo real depende do tamanho do projeto, arquivos e processos concorrentes.
108
+
109
+ | Opção | Quando usar | RAM desejada (aprox.) |
110
+ |---|---|---|
111
+ | `bge` (`BAAI/bge-m3`) | docs + código, menor risco de memória | 8-16 GiB |
112
+ | `jina` (`jinaai/jina-embeddings-v3`, padrão) | foco em qualidade para código | 32-64 GiB (ideal 48+ GiB) |
113
+ | `hybrid` (`jina v2 + bge`) | duas coleções, recuperação mais ampla | 24-48 GiB |
114
+
115
+ Notas:
116
+ - Jina em CPU é pesado; com pouca RAM/swap livre pode ocorrer lentidão ou OOM (`exit 137`).
117
+ - Se a máquina for limitada, comece com `bge`.
118
+
119
+ ## Perfil de performance
120
+
121
+ Durante setup/indexação, escolha:
122
+
123
+ - `autotune` (recomendado):
124
+ - Executa micro-benchmark local (`model.encode`) com métricas `psutil`.
125
+ - Busca faixa mais estável de memória (custo-benefício).
126
+ - Ajusta automaticamente `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
127
+
128
+ - `max-performance`:
129
+ - Usa parâmetros mais agressivos para throughput.
130
+ - Exibe aviso explícito de maior consumo de memória.
131
+
132
+ ## Comportamento do endpoint Chroma
133
+
134
+ - Endpoint local padrão: `http://localhost:8000`.
135
+ - O setup verifica se a porta escolhida já está em uso.
136
+ - Se `host` em `~/.own-rag-cli.json` for remoto (não localhost/127.0.0.1/::1), o setup não sobe Docker local.
137
+
138
+ ## Fluxos comuns
139
+
140
+ ### Reindexar somente
141
+
142
+ ```bash
143
+ ./rag-setup.run /caminho/do/projeto --only-index
144
+ ```
145
+
146
+ ### Pular indexação
147
+
148
+ ```bash
149
+ ./rag-setup.run /caminho/do/projeto --skip-index
150
+ ```
151
+
152
+ ### Trocar modelo depois
153
+
154
+ ```bash
155
+ ./rag-setup.run --change-model /caminho/do/projeto
156
+ ```
157
+
158
+ Esse fluxo alerta sobre reset das coleções Chroma e reindexação completa.
159
+
160
+ ## Variáveis de ambiente (override)
161
+
162
+ Principais variáveis:
163
+
164
+ - `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
165
+ - `MCP_JINA_QUANTIZATION=default|dynamic-int8`
166
+ - `MCP_PERF_PROFILE=autotune|max-performance`
167
+ - `MCP_EMBEDDING_BATCH_SIZE=<int>`
168
+ - `MCP_CHUNK_SIZE=<int>`
169
+ - `MCP_CHUNK_OVERLAP=<int>`
170
+ - `OWN_RAG_CLI_CONFIG_FILE=<path>`
171
+ - `MCP_INDEXER_CONFIG_FILE=<path>`
172
+ - `MCP_CHROMA_SCHEME=http|https`
173
+ - `MCP_CHROMA_HOST=<host>`
174
+ - `MCP_CHROMA_PORT=<port>`
175
+
176
+ ## Verificação de checksum (`.run`)
177
+
178
+ Verificação manual (Linux/macOS):
179
+
180
+ ```bash
181
+ sha256sum rag-setup.run
182
+ sha256sum rag-setup-macos.run
183
+ ```
184
+
185
+ No macOS sem `sha256sum`:
186
+
187
+ ```bash
188
+ shasum -a 256 rag-setup.run
189
+ shasum -a 256 rag-setup-macos.run
190
+ ```
191
+
192
+ ## Transparência de código
193
+
194
+ Lógica principal em arquivos-fonte (`bin/*.py`, `bin/*.sh`).
195
+ Artefatos gerados:
196
+
197
+ - `rag-setup.run`
198
+ - `rag-setup-macos.run`
199
+
200
+ Para regenerar artefatos após mudanças no fonte:
201
+
202
+ ```bash
203
+ ./bin/build_run.sh
204
+ ./bin/build_run_macos.sh
205
+ ```
206
+
207
+ ## Validação antes de publicar
208
+
209
+ ```bash
210
+ bash -n rag-setup.run
211
+ bash -n rag-setup-macos.run
212
+ python3 -m py_compile bin/indexer_full.py bin/mcp_server.py
213
+ npm pack --dry-run
214
+ ```
215
+
216
+ ## Licença
217
+
218
+ MIT