own-rag-cli 0.0.2-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.
Files changed (3) hide show
  1. package/README.md +145 -97
  2. package/README.pt-br.md +218 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,84 +1,72 @@
1
- # MCP binary checksum (SHA-256, payload without shebang): `74bb1de161e5ebeef6691397fc1403bc58c221b9302f67fd770b1097f8ff76d8`
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
- ## Permissions and Tuning Config
63
+ Path: `~/.own-rag-cli.json`
67
64
 
68
- - Autotune/indexer tuning is persisted by default in:
69
- - `~/.cache/own-rag-cli/indexer_tuning.json`
70
- - This avoids permission issues when `~/.rag_db` is owned by `root`.
71
- - If you want to store tuning inside `~/.rag_db`, grant permissions and set:
65
+ Purpose:
66
+ - Stores Chroma endpoint (`scheme`, `host`, `port`).
67
+ - Stores latest indexing batch fields (`indexing.embedding_batch_size`, `indexing.batch_count`).
72
68
 
73
- ```bash
74
- sudo chown -R "$USER":"$USER" ~/.rag_db
75
- export MCP_INDEXER_CONFIG_FILE="$HOME/.rag_db/indexer_tuning.json"
76
- ```
77
-
78
- ## Chroma Endpoint Config
79
-
80
- - Runtime config file: `~/.own-rag-cli.json`
81
- - Default generated content:
69
+ Example:
82
70
 
83
71
  ```json
84
72
  {
@@ -94,79 +82,139 @@ export MCP_INDEXER_CONFIG_FILE="$HOME/.rag_db/indexer_tuning.json"
94
82
  }
95
83
  ```
96
84
 
97
- - You can point to remote ChromaDB by changing `scheme`, `host`, and `port`.
98
- - `indexing.embedding_batch_size` / `indexing.batch_count` are updated after indexing/autotune.
99
- - `rag-setup.run` / `rag-setup-macos.run` persist chosen values into this file.
100
- - If `host` is not local (`localhost`, `127.0.0.1`, `::1`), setup skips local Docker startup.
85
+ ### 2) Indexer tuning config
86
+
87
+ Path: `~/.cache/own-rag-cli/indexer_tuning.json`
88
+
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.
92
+
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)
106
+
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
101
139
 
102
- ## ChromaDB Port Behavior (Local)
140
+ ### Reindex only
103
141
 
104
- - Default host port is `8000`.
105
- - During ChromaDB install/reinstall, setup asks for the port.
106
- - The installer checks if the chosen port is already in use using native tools:
107
- - Linux: `ss` (fallback: `lsof` / `netstat`)
108
- - macOS: `lsof` (fallback: `netstat`)
109
- - If the port is busy, it asks for another one.
110
- - In non-interactive runs, it auto-selects the next free port.
111
- - Selected port is propagated to:
112
- - Docker Compose mapping
113
- - health checks
114
- - `~/.own-rag-cli.json`
115
- - indexer runtime (`MCP_CHROMA_PORT`)
142
+ ```bash
143
+ ./rag-setup.run /path/to/project --only-index
144
+ ```
116
145
 
117
- ## Performance Profiles
146
+ ### Skip index step
118
147
 
119
- Available in indexer/setup:
120
- - `autotune` (recommended): uses local machine metrics and short benchmark.
121
- - `max-performance`: higher throughput and higher memory usage risk.
148
+ ```bash
149
+ ./rag-setup.run /path/to/project --skip-index
150
+ ```
122
151
 
123
- `max-performance` warning shown by setup:
152
+ ### Change model later
124
153
 
125
- ```text
126
- Este modo pode elevar consideravelmente o consumo de memória e causar encerramento por OOM (exit 137).
154
+ ```bash
155
+ ./rag-setup.run --change-model /path/to/project
127
156
  ```
128
157
 
129
- ## Key Environment Variables
158
+ This flow warns about resetting Chroma collections and requiring full reindex.
159
+
160
+ ## Environment overrides
161
+
162
+ Main overrides:
130
163
 
131
164
  - `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
132
165
  - `MCP_JINA_QUANTIZATION=default|dynamic-int8`
133
166
  - `MCP_PERF_PROFILE=autotune|max-performance`
134
- - `OWN_RAG_CLI_CONFIG_FILE=~/.own-rag-cli.json`
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>`
135
172
  - `MCP_CHROMA_SCHEME=http|https`
136
- - `MCP_CHROMA_HOST=localhost|<host>`
137
- - `MCP_CHROMA_PORT=8000`
138
- - `MCP_CHUNK_SIZE`
139
- - `MCP_CHUNK_OVERLAP`
140
- - `MCP_EMBEDDING_BATCH_SIZE`
173
+ - `MCP_CHROMA_HOST=<host>`
174
+ - `MCP_CHROMA_PORT=<port>`
141
175
 
142
- ## Useful Commands
176
+ ## Checksum verification (`.run`)
143
177
 
144
- ```bash
145
- # only index (infra already installed)
146
- ./rag-setup.run /path/to/project --only-index
178
+ Current checksum (documented in this repo) refers to payload hash.
147
179
 
148
- # skip indexing
149
- ./rag-setup.run /path/to/project --skip-index
180
+ Manual verification (Linux/macOS):
150
181
 
151
- # force reinstall
152
- ./rag-setup.run /path/to/project --reinstall
182
+ ```bash
183
+ sha256sum rag-setup.run
184
+ sha256sum rag-setup-macos.run
185
+ ```
153
186
 
154
- # force model change flow
155
- ./rag-setup.run --change-model /path/to/project
187
+ On macOS without `sha256sum`:
188
+
189
+ ```bash
190
+ shasum -a 256 rag-setup.run
191
+ shasum -a 256 rag-setup-macos.run
156
192
  ```
157
193
 
158
- ## Development
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
+ ```
159
208
 
160
- - Edit source files in `bin/`.
161
- - Rebuild payloads with `./bin/build_run.sh` and `./bin/build_run_macos.sh`.
162
- - Validate before commit:
209
+ ## Validation before release
163
210
 
164
211
  ```bash
165
212
  bash -n rag-setup.run
166
213
  bash -n rag-setup-macos.run
167
- 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
168
216
  ```
169
217
 
170
218
  ## License
171
219
 
172
- 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "own-rag-cli",
3
- "version": "0.0.2-snapshot",
3
+ "version": "0.0.3-snapshot",
4
4
  "description": "Local RAG setup with ChromaDB + MCP server (Jina/BGE hybrid support).",
5
5
  "license": "MIT",
6
6
  "private": false,