own-rag-cli 0.0.3-snapshot → 0.0.4-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 +90 -23
- package/README.pt-br.md +88 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# own-rag
|
|
2
2
|
|
|
3
|
-
Local RAG for codebases with ChromaDB + MCP, focused on
|
|
3
|
+
Local RAG for codebases with ChromaDB + MCP, focused on practical setup and lower LLM token waste.
|
|
4
4
|
|
|
5
5
|
Language: English (default) | Portuguese: `README.pt-br.md`
|
|
6
6
|
|
|
7
7
|
## Why use own-rag
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
9
|
+
Without local retrieval, an AI assistant often scans many files or asks you to paste large chunks of code, which increases token usage and slows iteration. With `own-rag`, your repository is indexed once and exposed via MCP tools, so the assistant can fetch only the most relevant files/chunks.
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
- Without RAG: asking "where is `MedicationController` used?" may trigger broad project reads.
|
|
13
|
+
- With MCP + own-rag: retrieval points directly to likely files first, so the assistant reads less and answers faster.
|
|
14
|
+
|
|
15
|
+
Immediate MCP targets are Claude Code and Cursor, but the server can be used by any MCP-capable client.
|
|
13
16
|
|
|
14
17
|
## What gets installed
|
|
15
18
|
|
|
@@ -63,8 +66,8 @@ rag remove --force # uninstall without confirmation prompts
|
|
|
63
66
|
Path: `~/.own-rag-cli.json`
|
|
64
67
|
|
|
65
68
|
Purpose:
|
|
66
|
-
- Stores Chroma endpoint
|
|
67
|
-
-
|
|
69
|
+
- Stores Chroma endpoint and last known indexing batch values.
|
|
70
|
+
- Used as the simplest user-facing config to move between machines or switch endpoint.
|
|
68
71
|
|
|
69
72
|
Example:
|
|
70
73
|
|
|
@@ -82,6 +85,18 @@ Example:
|
|
|
82
85
|
}
|
|
83
86
|
```
|
|
84
87
|
|
|
88
|
+
Field meaning:
|
|
89
|
+
- `chroma.scheme`: `http` or `https`.
|
|
90
|
+
- `chroma.host`: Chroma host (`localhost`, IP, or DNS).
|
|
91
|
+
- `chroma.port`: Chroma TCP port.
|
|
92
|
+
- `indexing.embedding_batch_size`: batch size used by embedding encode.
|
|
93
|
+
- `indexing.batch_count`: mirrored batch value for explicit readability.
|
|
94
|
+
|
|
95
|
+
If you edit this file manually:
|
|
96
|
+
1. Save the file.
|
|
97
|
+
2. Restart tools that consume MCP (Claude/Cursor).
|
|
98
|
+
3. If you changed model/chunk/batch strategy, run reindex (`rag run <project>` or `--only-index`) so stored vectors match new settings.
|
|
99
|
+
|
|
85
100
|
### 2) Indexer tuning config
|
|
86
101
|
|
|
87
102
|
Path: `~/.cache/own-rag-cli/indexer_tuning.json`
|
|
@@ -100,11 +115,11 @@ Purpose:
|
|
|
100
115
|
|
|
101
116
|
- Claude Code: `~/.claude.json`
|
|
102
117
|
- Cursor: `~/.cursor/mcp.json`
|
|
103
|
-
- Cursor (alt
|
|
118
|
+
- Cursor (alt paths): `~/.config/Cursor/User/mcp.json` or `~/Library/Application Support/Cursor/User/mcp.json`
|
|
104
119
|
|
|
105
120
|
## Choosing the embedding model (practical guidance)
|
|
106
121
|
|
|
107
|
-
These are practical memory guidelines
|
|
122
|
+
These are practical CPU-memory guidelines. Real usage depends on project size and concurrent processes.
|
|
108
123
|
|
|
109
124
|
| Choice | Use case | Approx RAM target |
|
|
110
125
|
|---|---|---|
|
|
@@ -113,70 +128,122 @@ These are practical memory guidelines for CPU usage. Real usage depends on proje
|
|
|
113
128
|
| `hybrid` (`jina v2 + bge`) | two collections, broader retrieval strategy | 24-48 GiB |
|
|
114
129
|
|
|
115
130
|
Notes:
|
|
116
|
-
- Jina on CPU is heavy; with low free RAM/swap,
|
|
117
|
-
- If your machine
|
|
131
|
+
- Jina on CPU is heavy; with low free RAM/swap, slowdowns or OOM (`exit 137`) can happen.
|
|
132
|
+
- If your machine is memory-limited, start with `bge`.
|
|
118
133
|
|
|
119
134
|
## Performance profile
|
|
120
135
|
|
|
121
|
-
During setup/indexing
|
|
136
|
+
During setup/indexing:
|
|
122
137
|
|
|
123
138
|
- `autotune` (recommended):
|
|
124
139
|
- Runs a short local benchmark (`model.encode`) with `psutil` metrics.
|
|
125
|
-
-
|
|
140
|
+
- Targets cost-benefit (not too aggressive, not too conservative).
|
|
126
141
|
- Automatically adjusts `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
|
|
127
142
|
|
|
128
143
|
- `max-performance`:
|
|
129
144
|
- Uses more aggressive throughput-oriented parameters.
|
|
130
|
-
-
|
|
145
|
+
- Shows explicit memory-risk warning.
|
|
131
146
|
|
|
132
147
|
## Chroma endpoint behavior
|
|
133
148
|
|
|
134
149
|
- Default local endpoint is `http://localhost:8000`.
|
|
135
|
-
- Setup checks if
|
|
136
|
-
- If
|
|
150
|
+
- Setup checks if selected port is already in use.
|
|
151
|
+
- If `~/.own-rag-cli.json` points to a remote host, local Docker startup is skipped.
|
|
152
|
+
|
|
153
|
+
## Backup/snapshot before reinstall or machine migration
|
|
154
|
+
|
|
155
|
+
Before running `rag remove`, formatting your machine, or moving to another machine, snapshot these files:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
mkdir -p "$HOME/own-rag-backup"
|
|
159
|
+
cp "$HOME/.own-rag-cli.json" "$HOME/own-rag-backup/" 2>/dev/null || true
|
|
160
|
+
cp "$HOME/.cache/own-rag-cli/indexer_tuning.json" "$HOME/own-rag-backup/" 2>/dev/null || true
|
|
161
|
+
|
|
162
|
+
tar -czf "$HOME/own-rag-backup/chromadb-ragdb-$(date +%Y%m%d-%H%M%S).tgz" -C "$HOME" .rag_db
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Restore on a new machine:
|
|
166
|
+
1. Install `own-rag-cli`.
|
|
167
|
+
2. Restore `~/.own-rag-cli.json` and optional tuning file.
|
|
168
|
+
3. Extract `.rag_db` backup into `$HOME`.
|
|
169
|
+
4. Start with `rag run /path/to/project --skip-index` and validate search.
|
|
170
|
+
5. If model/chunk settings changed, reindex.
|
|
137
171
|
|
|
138
172
|
## Common flows
|
|
139
173
|
|
|
140
|
-
### Reindex only
|
|
174
|
+
### Reindex only (`--only-index`)
|
|
141
175
|
|
|
142
176
|
```bash
|
|
143
177
|
./rag-setup.run /path/to/project --only-index
|
|
144
178
|
```
|
|
145
179
|
|
|
146
|
-
|
|
180
|
+
Use when environment is already installed and you only changed project code/docs.
|
|
181
|
+
|
|
182
|
+
### Skip index step (`--skip-index`)
|
|
147
183
|
|
|
148
184
|
```bash
|
|
149
185
|
./rag-setup.run /path/to/project --skip-index
|
|
150
186
|
```
|
|
151
187
|
|
|
152
|
-
|
|
188
|
+
Use when you want to refresh infra/config first (venv, Docker, MCP wiring), and index later.
|
|
189
|
+
|
|
190
|
+
### Change model (`--change-model`)
|
|
153
191
|
|
|
154
192
|
```bash
|
|
155
193
|
./rag-setup.run --change-model /path/to/project
|
|
156
194
|
```
|
|
157
195
|
|
|
158
|
-
|
|
196
|
+
Use when switching embedding strategy (`jina`, `bge`, `hybrid`). This may reset collections and requires full reindex so embeddings remain consistent.
|
|
159
197
|
|
|
160
198
|
## Environment overrides
|
|
161
199
|
|
|
162
|
-
|
|
200
|
+
Where to override:
|
|
201
|
+
- Temporary for one shell/session: `export VAR=value` before `rag run`.
|
|
202
|
+
- Persistent for MCP runtime: set env in your MCP client config (`~/.claude.json`, Cursor `mcp.json`).
|
|
203
|
+
- Chroma endpoint can also be persisted in `~/.own-rag-cli.json`.
|
|
204
|
+
|
|
205
|
+
What each variable does:
|
|
163
206
|
|
|
164
207
|
- `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
|
|
208
|
+
- Selects embedding strategy.
|
|
209
|
+
- After changing: reindex required.
|
|
210
|
+
|
|
165
211
|
- `MCP_JINA_QUANTIZATION=default|dynamic-int8`
|
|
212
|
+
- Jina CPU quantization mode.
|
|
213
|
+
- After changing: reindex recommended.
|
|
214
|
+
|
|
166
215
|
- `MCP_PERF_PROFILE=autotune|max-performance`
|
|
216
|
+
- Chooses tuning strategy for chunk and batch decisions.
|
|
217
|
+
- After changing: rerun index setup to apply new tuning.
|
|
218
|
+
|
|
167
219
|
- `MCP_EMBEDDING_BATCH_SIZE=<int>`
|
|
220
|
+
- Forces fixed embedding batch size (overrides autotune batch).
|
|
221
|
+
- After changing: restart MCP; reindex recommended for consistent throughput assumptions.
|
|
222
|
+
|
|
168
223
|
- `MCP_CHUNK_SIZE=<int>`
|
|
224
|
+
- Sets chunk length for indexing.
|
|
225
|
+
- After changing: full reindex required.
|
|
226
|
+
|
|
169
227
|
- `MCP_CHUNK_OVERLAP=<int>`
|
|
228
|
+
- Sets overlap between chunks.
|
|
229
|
+
- After changing: full reindex required.
|
|
230
|
+
|
|
170
231
|
- `OWN_RAG_CLI_CONFIG_FILE=<path>`
|
|
232
|
+
- Moves runtime config location from default `~/.own-rag-cli.json`.
|
|
233
|
+
- After changing: restart setup/MCP tools.
|
|
234
|
+
|
|
171
235
|
- `MCP_INDEXER_CONFIG_FILE=<path>`
|
|
236
|
+
- Moves tuning config location from default `~/.cache/own-rag-cli/indexer_tuning.json`.
|
|
237
|
+
- After changing: restart setup/MCP tools.
|
|
238
|
+
|
|
172
239
|
- `MCP_CHROMA_SCHEME=http|https`
|
|
173
240
|
- `MCP_CHROMA_HOST=<host>`
|
|
174
241
|
- `MCP_CHROMA_PORT=<port>`
|
|
242
|
+
- Overrides Chroma endpoint.
|
|
243
|
+
- After changing: restart MCP clients; reindex only if switching to a fresh/empty database.
|
|
175
244
|
|
|
176
245
|
## Checksum verification (`.run`)
|
|
177
246
|
|
|
178
|
-
Current checksum (documented in this repo) refers to payload hash.
|
|
179
|
-
|
|
180
247
|
Manual verification (Linux/macOS):
|
|
181
248
|
|
|
182
249
|
```bash
|
package/README.pt-br.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# own-rag
|
|
2
2
|
|
|
3
|
-
RAG local para codebases com ChromaDB + MCP, focado em
|
|
3
|
+
RAG local para codebases com ChromaDB + MCP, focado em setup prático e menor desperdício de tokens no uso de IA.
|
|
4
4
|
|
|
5
5
|
Idioma: Português (PT-BR) | English: `README.md`
|
|
6
6
|
|
|
7
7
|
## Por que usar o own-rag
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
9
|
+
Sem recuperação local, a IA costuma ler muitos arquivos ou pedir grandes trechos de código, aumentando custo de tokens e tempo de resposta. Com `own-rag`, o repositório é indexado uma vez e exposto por ferramentas MCP, então a IA consulta primeiro os trechos mais relevantes.
|
|
10
|
+
|
|
11
|
+
Exemplo:
|
|
12
|
+
- Sem RAG: ao perguntar "onde `MedicationController` é usado?", a IA pode varrer boa parte do projeto.
|
|
13
|
+
- Com MCP + own-rag: a recuperação aponta rapidamente para os arquivos com maior probabilidade, reduzindo leitura desnecessária.
|
|
14
|
+
|
|
15
|
+
Os alvos imediatos por padrão são Claude Code e Cursor, mas o servidor pode ser usado por qualquer cliente compatível com MCP.
|
|
13
16
|
|
|
14
17
|
## O que é instalado
|
|
15
18
|
|
|
@@ -63,8 +66,8 @@ rag remove --force # desinstala sem prompts de confirmação
|
|
|
63
66
|
Caminho: `~/.own-rag-cli.json`
|
|
64
67
|
|
|
65
68
|
Finalidade:
|
|
66
|
-
-
|
|
67
|
-
-
|
|
69
|
+
- Guarda endpoint do Chroma e os últimos valores de batch de indexação.
|
|
70
|
+
- É o arquivo mais simples para portar configuração entre máquinas.
|
|
68
71
|
|
|
69
72
|
Exemplo:
|
|
70
73
|
|
|
@@ -82,6 +85,18 @@ Exemplo:
|
|
|
82
85
|
}
|
|
83
86
|
```
|
|
84
87
|
|
|
88
|
+
Significado de cada variável:
|
|
89
|
+
- `chroma.scheme`: protocolo (`http` ou `https`).
|
|
90
|
+
- `chroma.host`: host do Chroma (`localhost`, IP ou DNS).
|
|
91
|
+
- `chroma.port`: porta TCP do Chroma.
|
|
92
|
+
- `indexing.embedding_batch_size`: tamanho do batch usado no encode de embeddings.
|
|
93
|
+
- `indexing.batch_count`: espelho explícito do valor de batch para leitura humana.
|
|
94
|
+
|
|
95
|
+
Se você editar esse arquivo manualmente:
|
|
96
|
+
1. Salve o arquivo.
|
|
97
|
+
2. Reinicie as ferramentas que usam MCP (Claude/Cursor).
|
|
98
|
+
3. Se mudou estratégia de modelo/chunk/batch, rode reindexação (`rag run <projeto>` ou `--only-index`) para manter consistência dos vetores.
|
|
99
|
+
|
|
85
100
|
### 2) Configuração de tuning do indexador
|
|
86
101
|
|
|
87
102
|
Caminho: `~/.cache/own-rag-cli/indexer_tuning.json`
|
|
@@ -100,11 +115,11 @@ Finalidade:
|
|
|
100
115
|
|
|
101
116
|
- Claude Code: `~/.claude.json`
|
|
102
117
|
- Cursor: `~/.cursor/mcp.json`
|
|
103
|
-
- Cursor (
|
|
118
|
+
- Cursor (caminhos alternativos): `~/.config/Cursor/User/mcp.json` ou `~/Library/Application Support/Cursor/User/mcp.json`
|
|
104
119
|
|
|
105
120
|
## Escolha do modelo de embeddings (guia prático)
|
|
106
121
|
|
|
107
|
-
Valores abaixo são referência prática para CPU. O consumo real depende do tamanho do projeto
|
|
122
|
+
Valores abaixo são referência prática para CPU. O consumo real depende do tamanho do projeto e de processos concorrentes.
|
|
108
123
|
|
|
109
124
|
| Opção | Quando usar | RAM desejada (aprox.) |
|
|
110
125
|
|---|---|---|
|
|
@@ -118,60 +133,114 @@ Notas:
|
|
|
118
133
|
|
|
119
134
|
## Perfil de performance
|
|
120
135
|
|
|
121
|
-
Durante setup/indexação
|
|
136
|
+
Durante setup/indexação:
|
|
122
137
|
|
|
123
138
|
- `autotune` (recomendado):
|
|
124
139
|
- Executa micro-benchmark local (`model.encode`) com métricas `psutil`.
|
|
125
|
-
- Busca
|
|
140
|
+
- Busca custo-benefício (nem agressivo, nem conservador).
|
|
126
141
|
- Ajusta automaticamente `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
|
|
127
142
|
|
|
128
143
|
- `max-performance`:
|
|
129
144
|
- Usa parâmetros mais agressivos para throughput.
|
|
130
|
-
- Exibe aviso explícito de
|
|
145
|
+
- Exibe aviso explícito de risco de memória.
|
|
131
146
|
|
|
132
147
|
## Comportamento do endpoint Chroma
|
|
133
148
|
|
|
134
149
|
- Endpoint local padrão: `http://localhost:8000`.
|
|
135
150
|
- O setup verifica se a porta escolhida já está em uso.
|
|
136
|
-
- Se
|
|
151
|
+
- Se `~/.own-rag-cli.json` apontar para host remoto, o setup não sobe Docker local.
|
|
152
|
+
|
|
153
|
+
## Backup/snapshot antes de remover, formatar ou migrar máquina
|
|
154
|
+
|
|
155
|
+
Antes de executar `rag remove`, formatar o computador, ou migrar para outra máquina, faça snapshot:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
mkdir -p "$HOME/own-rag-backup"
|
|
159
|
+
cp "$HOME/.own-rag-cli.json" "$HOME/own-rag-backup/" 2>/dev/null || true
|
|
160
|
+
cp "$HOME/.cache/own-rag-cli/indexer_tuning.json" "$HOME/own-rag-backup/" 2>/dev/null || true
|
|
161
|
+
|
|
162
|
+
tar -czf "$HOME/own-rag-backup/chromadb-ragdb-$(date +%Y%m%d-%H%M%S).tgz" -C "$HOME" .rag_db
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Restauração em nova máquina:
|
|
166
|
+
1. Instale `own-rag-cli`.
|
|
167
|
+
2. Restaure `~/.own-rag-cli.json` e, opcionalmente, o tuning.
|
|
168
|
+
3. Extraia o backup de `.rag_db` em `$HOME`.
|
|
169
|
+
4. Execute `rag run /caminho/do/projeto --skip-index` e valide a busca.
|
|
170
|
+
5. Se mudou modelo/chunks, reindexe.
|
|
137
171
|
|
|
138
172
|
## Fluxos comuns
|
|
139
173
|
|
|
140
|
-
### Reindexar somente
|
|
174
|
+
### Reindexar somente (`--only-index`)
|
|
141
175
|
|
|
142
176
|
```bash
|
|
143
177
|
./rag-setup.run /caminho/do/projeto --only-index
|
|
144
178
|
```
|
|
145
179
|
|
|
146
|
-
|
|
180
|
+
Use quando o ambiente já está instalado e você só alterou código/documentação do projeto.
|
|
181
|
+
|
|
182
|
+
### Pular indexação (`--skip-index`)
|
|
147
183
|
|
|
148
184
|
```bash
|
|
149
185
|
./rag-setup.run /caminho/do/projeto --skip-index
|
|
150
186
|
```
|
|
151
187
|
|
|
152
|
-
|
|
188
|
+
Use para atualizar infraestrutura/configuração primeiro (venv, Docker, MCP), deixando a indexação para depois.
|
|
189
|
+
|
|
190
|
+
### Trocar modelo (`--change-model`)
|
|
153
191
|
|
|
154
192
|
```bash
|
|
155
193
|
./rag-setup.run --change-model /caminho/do/projeto
|
|
156
194
|
```
|
|
157
195
|
|
|
158
|
-
Esse fluxo
|
|
196
|
+
Use ao mudar estratégia de embeddings (`jina`, `bge`, `hybrid`). Esse fluxo pode resetar coleções e exige reindexação completa para consistência.
|
|
197
|
+
|
|
198
|
+
## Environment overrides
|
|
159
199
|
|
|
160
|
-
|
|
200
|
+
Onde sobrescrever:
|
|
201
|
+
- Temporário por sessão: `export VAR=valor` antes do `rag run`.
|
|
202
|
+
- Persistente no runtime MCP: definir `env` no arquivo de configuração do MCP (`~/.claude.json`, `mcp.json` do Cursor).
|
|
203
|
+
- Endpoint Chroma também pode ser persistido em `~/.own-rag-cli.json`.
|
|
161
204
|
|
|
162
|
-
|
|
205
|
+
Para que serve cada variável:
|
|
163
206
|
|
|
164
207
|
- `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
|
|
208
|
+
- Seleciona estratégia de embedding.
|
|
209
|
+
- Ao alterar: reindexação obrigatória.
|
|
210
|
+
|
|
165
211
|
- `MCP_JINA_QUANTIZATION=default|dynamic-int8`
|
|
212
|
+
- Define quantização do Jina em CPU.
|
|
213
|
+
- Ao alterar: reindexação recomendada.
|
|
214
|
+
|
|
166
215
|
- `MCP_PERF_PROFILE=autotune|max-performance`
|
|
216
|
+
- Define estratégia de tuning para chunks e batch.
|
|
217
|
+
- Ao alterar: rode setup/indexador novamente para aplicar novo tuning.
|
|
218
|
+
|
|
167
219
|
- `MCP_EMBEDDING_BATCH_SIZE=<int>`
|
|
220
|
+
- Força batch fixo (sobrescreve batch autotunado).
|
|
221
|
+
- Ao alterar: reinicie MCP; reindexação recomendada para consistência operacional.
|
|
222
|
+
|
|
168
223
|
- `MCP_CHUNK_SIZE=<int>`
|
|
224
|
+
- Define tamanho dos chunks na indexação.
|
|
225
|
+
- Ao alterar: reindexação completa obrigatória.
|
|
226
|
+
|
|
169
227
|
- `MCP_CHUNK_OVERLAP=<int>`
|
|
228
|
+
- Define sobreposição entre chunks.
|
|
229
|
+
- Ao alterar: reindexação completa obrigatória.
|
|
230
|
+
|
|
170
231
|
- `OWN_RAG_CLI_CONFIG_FILE=<path>`
|
|
232
|
+
- Muda localização do arquivo runtime (padrão `~/.own-rag-cli.json`).
|
|
233
|
+
- Ao alterar: reinicie setup/ferramentas MCP.
|
|
234
|
+
|
|
171
235
|
- `MCP_INDEXER_CONFIG_FILE=<path>`
|
|
236
|
+
- Muda localização do arquivo de tuning (padrão `~/.cache/own-rag-cli/indexer_tuning.json`).
|
|
237
|
+
- Ao alterar: reinicie setup/ferramentas MCP.
|
|
238
|
+
|
|
172
239
|
- `MCP_CHROMA_SCHEME=http|https`
|
|
173
240
|
- `MCP_CHROMA_HOST=<host>`
|
|
174
241
|
- `MCP_CHROMA_PORT=<port>`
|
|
242
|
+
- Sobrescrevem endpoint do Chroma.
|
|
243
|
+
- Ao alterar: reinicie clientes MCP; reindexe somente se trocar para base vazia/nova.
|
|
175
244
|
|
|
176
245
|
## Verificação de checksum (`.run`)
|
|
177
246
|
|