own-rag-cli 0.0.2-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 +212 -97
- package/README.pt-br.md +287 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,84 +1,75 @@
|
|
|
1
|
-
# MCP binary checksum (SHA-256, payload without shebang): `74bb1de161e5ebeef6691397fc1403bc58c221b9302f67fd770b1097f8ff76d8`
|
|
2
|
-
|
|
3
1
|
# own-rag
|
|
4
2
|
|
|
5
|
-
Local RAG for codebases with
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Local RAG for codebases with ChromaDB + MCP, focused on practical setup and lower LLM token waste.
|
|
4
|
+
|
|
5
|
+
Language: English (default) | Portuguese: `README.pt-br.md`
|
|
6
|
+
|
|
7
|
+
## Why use own-rag
|
|
10
8
|
|
|
11
|
-
|
|
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.
|
|
12
10
|
|
|
13
|
-
|
|
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
14
|
|
|
15
|
-
|
|
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
|
|
15
|
+
Immediate MCP targets are Claude Code and Cursor, but the server can be used by any MCP-capable client.
|
|
20
16
|
|
|
21
|
-
##
|
|
17
|
+
## What gets installed
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
19
|
+
- ChromaDB container (Docker)
|
|
20
|
+
- Python virtual environment (`~/.rag_venv`)
|
|
21
|
+
- MCP server binary (`~/.local/bin/mcp-rag-server`)
|
|
22
|
+
- Setup runners (`rag-setup.run`, `rag-setup-macos.run`)
|
|
23
|
+
- CLI wrapper command: `rag`
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
## Install and run
|
|
26
|
+
|
|
27
|
+
### Option A: npm (recommended)
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
npm install -g own-rag-cli
|
|
31
|
+
rag run /path/to/your/project
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
If you run `rag run` without a path, it asks whether to use the current directory.
|
|
35
|
+
|
|
36
|
+
### Option B: direct `.run`
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
Linux:
|
|
37
39
|
|
|
38
40
|
```bash
|
|
39
41
|
chmod +x rag-setup.run
|
|
40
|
-
./rag-setup.run /path/to/project
|
|
42
|
+
./rag-setup.run /path/to/your/project
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
macOS:
|
|
44
46
|
|
|
45
47
|
```bash
|
|
46
48
|
chmod +x rag-setup-macos.run
|
|
47
|
-
./rag-setup-macos.run /path/to/project
|
|
49
|
+
./rag-setup-macos.run /path/to/your/project
|
|
48
50
|
```
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
## Main commands
|
|
51
53
|
|
|
52
54
|
```bash
|
|
53
|
-
rag run /path/to/project
|
|
54
|
-
rag monitor
|
|
55
|
-
rag
|
|
55
|
+
rag run /path/to/project # full setup + indexing
|
|
56
|
+
rag monitor # interactive Chroma monitor
|
|
57
|
+
rag monitor full # full monitor dashboard
|
|
58
|
+
rag remove # full local uninstall (double confirmation)
|
|
59
|
+
rag remove --force # uninstall without confirmation prompts
|
|
56
60
|
```
|
|
57
61
|
|
|
58
|
-
##
|
|
59
|
-
|
|
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.
|
|
62
|
+
## Configuration files and paths
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
### 1) Runtime config (CLI-level)
|
|
67
65
|
|
|
68
|
-
-
|
|
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:
|
|
66
|
+
Path: `~/.own-rag-cli.json`
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
68
|
+
Purpose:
|
|
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.
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
- Runtime config file: `~/.own-rag-cli.json`
|
|
81
|
-
- Default generated content:
|
|
72
|
+
Example:
|
|
82
73
|
|
|
83
74
|
```json
|
|
84
75
|
{
|
|
@@ -94,79 +85,203 @@ export MCP_INDEXER_CONFIG_FILE="$HOME/.rag_db/indexer_tuning.json"
|
|
|
94
85
|
}
|
|
95
86
|
```
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
- `
|
|
99
|
-
- `
|
|
100
|
-
-
|
|
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
|
+
|
|
100
|
+
### 2) Indexer tuning config
|
|
101
|
+
|
|
102
|
+
Path: `~/.cache/own-rag-cli/indexer_tuning.json`
|
|
103
|
+
|
|
104
|
+
Purpose:
|
|
105
|
+
- Persists model/profile/tuning decisions (`chunk_size`, `chunk_overlap`, `embedding_batch_size`, etc.).
|
|
106
|
+
- Loaded by both indexer and MCP server to keep behavior consistent across re-runs.
|
|
107
|
+
|
|
108
|
+
### 3) Database and runtime directories
|
|
109
|
+
|
|
110
|
+
- Chroma data: `~/.rag_db`
|
|
111
|
+
- Python venv: `~/.rag_venv`
|
|
112
|
+
- Installed binaries/scripts: `~/.local/bin/`
|
|
113
|
+
|
|
114
|
+
### 4) MCP client config files (optional auto-update)
|
|
115
|
+
|
|
116
|
+
- Claude Code: `~/.claude.json`
|
|
117
|
+
- Cursor: `~/.cursor/mcp.json`
|
|
118
|
+
- Cursor (alt paths): `~/.config/Cursor/User/mcp.json` or `~/Library/Application Support/Cursor/User/mcp.json`
|
|
101
119
|
|
|
102
|
-
##
|
|
120
|
+
## Choosing the embedding model (practical guidance)
|
|
103
121
|
|
|
104
|
-
-
|
|
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`)
|
|
122
|
+
These are practical CPU-memory guidelines. Real usage depends on project size and concurrent processes.
|
|
116
123
|
|
|
117
|
-
|
|
124
|
+
| Choice | Use case | Approx RAM target |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| `bge` (`BAAI/bge-m3`) | mixed docs + code, safer memory | 8-16 GiB |
|
|
127
|
+
| `jina` (`jinaai/jina-embeddings-v3`, default) | code-focused quality | 32-64 GiB (48+ GiB preferred) |
|
|
128
|
+
| `hybrid` (`jina v2 + bge`) | two collections, broader retrieval strategy | 24-48 GiB |
|
|
118
129
|
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
130
|
+
Notes:
|
|
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`.
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
## Performance profile
|
|
124
135
|
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
During setup/indexing:
|
|
137
|
+
|
|
138
|
+
- `autotune` (recommended):
|
|
139
|
+
- Runs a short local benchmark (`model.encode`) with `psutil` metrics.
|
|
140
|
+
- Targets cost-benefit (not too aggressive, not too conservative).
|
|
141
|
+
- Automatically adjusts `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
|
|
142
|
+
|
|
143
|
+
- `max-performance`:
|
|
144
|
+
- Uses more aggressive throughput-oriented parameters.
|
|
145
|
+
- Shows explicit memory-risk warning.
|
|
146
|
+
|
|
147
|
+
## Chroma endpoint behavior
|
|
148
|
+
|
|
149
|
+
- Default local endpoint is `http://localhost:8000`.
|
|
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
|
|
127
163
|
```
|
|
128
164
|
|
|
129
|
-
|
|
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.
|
|
130
171
|
|
|
131
|
-
|
|
132
|
-
- `MCP_JINA_QUANTIZATION=default|dynamic-int8`
|
|
133
|
-
- `MCP_PERF_PROFILE=autotune|max-performance`
|
|
134
|
-
- `OWN_RAG_CLI_CONFIG_FILE=~/.own-rag-cli.json`
|
|
135
|
-
- `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`
|
|
172
|
+
## Common flows
|
|
141
173
|
|
|
142
|
-
|
|
174
|
+
### Reindex only (`--only-index`)
|
|
143
175
|
|
|
144
176
|
```bash
|
|
145
|
-
# only index (infra already installed)
|
|
146
177
|
./rag-setup.run /path/to/project --only-index
|
|
178
|
+
```
|
|
147
179
|
|
|
148
|
-
|
|
180
|
+
Use when environment is already installed and you only changed project code/docs.
|
|
181
|
+
|
|
182
|
+
### Skip index step (`--skip-index`)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
149
185
|
./rag-setup.run /path/to/project --skip-index
|
|
186
|
+
```
|
|
150
187
|
|
|
151
|
-
|
|
152
|
-
./rag-setup.run /path/to/project --reinstall
|
|
188
|
+
Use when you want to refresh infra/config first (venv, Docker, MCP wiring), and index later.
|
|
153
189
|
|
|
154
|
-
|
|
190
|
+
### Change model (`--change-model`)
|
|
191
|
+
|
|
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.
|
|
197
|
+
|
|
198
|
+
## Environment overrides
|
|
199
|
+
|
|
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:
|
|
206
|
+
|
|
207
|
+
- `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
|
|
208
|
+
- Selects embedding strategy.
|
|
209
|
+
- After changing: reindex required.
|
|
210
|
+
|
|
211
|
+
- `MCP_JINA_QUANTIZATION=default|dynamic-int8`
|
|
212
|
+
- Jina CPU quantization mode.
|
|
213
|
+
- After changing: reindex recommended.
|
|
214
|
+
|
|
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
|
+
|
|
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
|
+
|
|
223
|
+
- `MCP_CHUNK_SIZE=<int>`
|
|
224
|
+
- Sets chunk length for indexing.
|
|
225
|
+
- After changing: full reindex required.
|
|
226
|
+
|
|
227
|
+
- `MCP_CHUNK_OVERLAP=<int>`
|
|
228
|
+
- Sets overlap between chunks.
|
|
229
|
+
- After changing: full reindex required.
|
|
230
|
+
|
|
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
|
+
|
|
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
|
+
|
|
239
|
+
- `MCP_CHROMA_SCHEME=http|https`
|
|
240
|
+
- `MCP_CHROMA_HOST=<host>`
|
|
241
|
+
- `MCP_CHROMA_PORT=<port>`
|
|
242
|
+
- Overrides Chroma endpoint.
|
|
243
|
+
- After changing: restart MCP clients; reindex only if switching to a fresh/empty database.
|
|
244
|
+
|
|
245
|
+
## Checksum verification (`.run`)
|
|
246
|
+
|
|
247
|
+
Manual verification (Linux/macOS):
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
sha256sum rag-setup.run
|
|
251
|
+
sha256sum rag-setup-macos.run
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
On macOS without `sha256sum`:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
shasum -a 256 rag-setup.run
|
|
258
|
+
shasum -a 256 rag-setup-macos.run
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Source transparency
|
|
262
|
+
|
|
263
|
+
Project logic is in source files (`bin/*.py`, `bin/*.sh`).
|
|
264
|
+
Generated artifacts:
|
|
265
|
+
|
|
266
|
+
- `rag-setup.run`
|
|
267
|
+
- `rag-setup-macos.run`
|
|
268
|
+
|
|
269
|
+
Rebuild artifacts after source changes:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
./bin/build_run.sh
|
|
273
|
+
./bin/build_run_macos.sh
|
|
274
|
+
```
|
|
159
275
|
|
|
160
|
-
|
|
161
|
-
- Rebuild payloads with `./bin/build_run.sh` and `./bin/build_run_macos.sh`.
|
|
162
|
-
- Validate before commit:
|
|
276
|
+
## Validation before release
|
|
163
277
|
|
|
164
278
|
```bash
|
|
165
279
|
bash -n rag-setup.run
|
|
166
280
|
bash -n rag-setup-macos.run
|
|
167
|
-
python3 -m py_compile bin/indexer_full.py
|
|
281
|
+
python3 -m py_compile bin/indexer_full.py bin/mcp_server.py
|
|
282
|
+
npm pack --dry-run
|
|
168
283
|
```
|
|
169
284
|
|
|
170
285
|
## License
|
|
171
286
|
|
|
172
|
-
MIT
|
|
287
|
+
MIT
|
package/README.pt-br.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# own-rag
|
|
2
|
+
|
|
3
|
+
RAG local para codebases com ChromaDB + MCP, focado em setup prático e menor desperdício de tokens no uso de IA.
|
|
4
|
+
|
|
5
|
+
Idioma: Português (PT-BR) | English: `README.md`
|
|
6
|
+
|
|
7
|
+
## Por que usar o own-rag
|
|
8
|
+
|
|
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.
|
|
16
|
+
|
|
17
|
+
## O que é instalado
|
|
18
|
+
|
|
19
|
+
- Container ChromaDB (Docker)
|
|
20
|
+
- Ambiente virtual Python (`~/.rag_venv`)
|
|
21
|
+
- Binário MCP (`~/.local/bin/mcp-rag-server`)
|
|
22
|
+
- Instaladores (`rag-setup.run`, `rag-setup-macos.run`)
|
|
23
|
+
- Comando wrapper: `rag`
|
|
24
|
+
|
|
25
|
+
## Instalação e execução
|
|
26
|
+
|
|
27
|
+
### Opção A: npm (recomendado)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g own-rag-cli
|
|
31
|
+
rag run /caminho/do/projeto
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Se executar `rag run` sem caminho, o CLI pergunta se deve usar o diretório atual.
|
|
35
|
+
|
|
36
|
+
### Opção B: `.run` direto
|
|
37
|
+
|
|
38
|
+
Linux:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
chmod +x rag-setup.run
|
|
42
|
+
./rag-setup.run /caminho/do/projeto
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
macOS:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
chmod +x rag-setup-macos.run
|
|
49
|
+
./rag-setup-macos.run /caminho/do/projeto
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Comandos principais
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
rag run /caminho/do/projeto # setup completo + indexação
|
|
56
|
+
rag monitor # monitor interativo do Chroma
|
|
57
|
+
rag monitor full # painel completo do monitor
|
|
58
|
+
rag remove # desinstalação completa local (dupla confirmação)
|
|
59
|
+
rag remove --force # desinstala sem prompts de confirmação
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Arquivos e caminhos de configuração
|
|
63
|
+
|
|
64
|
+
### 1) Configuração de runtime (nível CLI)
|
|
65
|
+
|
|
66
|
+
Caminho: `~/.own-rag-cli.json`
|
|
67
|
+
|
|
68
|
+
Finalidade:
|
|
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.
|
|
71
|
+
|
|
72
|
+
Exemplo:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"chroma": {
|
|
77
|
+
"scheme": "http",
|
|
78
|
+
"host": "localhost",
|
|
79
|
+
"port": 8000
|
|
80
|
+
},
|
|
81
|
+
"indexing": {
|
|
82
|
+
"embedding_batch_size": 4,
|
|
83
|
+
"batch_count": 4
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
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
|
+
|
|
100
|
+
### 2) Configuração de tuning do indexador
|
|
101
|
+
|
|
102
|
+
Caminho: `~/.cache/own-rag-cli/indexer_tuning.json`
|
|
103
|
+
|
|
104
|
+
Finalidade:
|
|
105
|
+
- Persiste decisões de modelo/perfil/tuning (`chunk_size`, `chunk_overlap`, `embedding_batch_size`, etc.).
|
|
106
|
+
- É lido por indexador e MCP server para manter consistência entre execuções.
|
|
107
|
+
|
|
108
|
+
### 3) Diretórios de dados e runtime
|
|
109
|
+
|
|
110
|
+
- Dados do Chroma: `~/.rag_db`
|
|
111
|
+
- Venv Python: `~/.rag_venv`
|
|
112
|
+
- Binários/scripts instalados: `~/.local/bin/`
|
|
113
|
+
|
|
114
|
+
### 4) Arquivos de configuração MCP (auto-update opcional)
|
|
115
|
+
|
|
116
|
+
- Claude Code: `~/.claude.json`
|
|
117
|
+
- Cursor: `~/.cursor/mcp.json`
|
|
118
|
+
- Cursor (caminhos alternativos): `~/.config/Cursor/User/mcp.json` ou `~/Library/Application Support/Cursor/User/mcp.json`
|
|
119
|
+
|
|
120
|
+
## Escolha do modelo de embeddings (guia prático)
|
|
121
|
+
|
|
122
|
+
Valores abaixo são referência prática para CPU. O consumo real depende do tamanho do projeto e de processos concorrentes.
|
|
123
|
+
|
|
124
|
+
| Opção | Quando usar | RAM desejada (aprox.) |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| `bge` (`BAAI/bge-m3`) | docs + código, menor risco de memória | 8-16 GiB |
|
|
127
|
+
| `jina` (`jinaai/jina-embeddings-v3`, padrão) | foco em qualidade para código | 32-64 GiB (ideal 48+ GiB) |
|
|
128
|
+
| `hybrid` (`jina v2 + bge`) | duas coleções, recuperação mais ampla | 24-48 GiB |
|
|
129
|
+
|
|
130
|
+
Notas:
|
|
131
|
+
- Jina em CPU é pesado; com pouca RAM/swap livre pode ocorrer lentidão ou OOM (`exit 137`).
|
|
132
|
+
- Se a máquina for limitada, comece com `bge`.
|
|
133
|
+
|
|
134
|
+
## Perfil de performance
|
|
135
|
+
|
|
136
|
+
Durante setup/indexação:
|
|
137
|
+
|
|
138
|
+
- `autotune` (recomendado):
|
|
139
|
+
- Executa micro-benchmark local (`model.encode`) com métricas `psutil`.
|
|
140
|
+
- Busca custo-benefício (nem agressivo, nem conservador).
|
|
141
|
+
- Ajusta automaticamente `MCP_EMBEDDING_BATCH_SIZE`, `MCP_CHUNK_SIZE`, `MCP_CHUNK_OVERLAP`.
|
|
142
|
+
|
|
143
|
+
- `max-performance`:
|
|
144
|
+
- Usa parâmetros mais agressivos para throughput.
|
|
145
|
+
- Exibe aviso explícito de risco de memória.
|
|
146
|
+
|
|
147
|
+
## Comportamento do endpoint Chroma
|
|
148
|
+
|
|
149
|
+
- Endpoint local padrão: `http://localhost:8000`.
|
|
150
|
+
- O setup verifica se a porta escolhida já está em uso.
|
|
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.
|
|
171
|
+
|
|
172
|
+
## Fluxos comuns
|
|
173
|
+
|
|
174
|
+
### Reindexar somente (`--only-index`)
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
./rag-setup.run /caminho/do/projeto --only-index
|
|
178
|
+
```
|
|
179
|
+
|
|
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`)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
./rag-setup.run /caminho/do/projeto --skip-index
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Use para atualizar infraestrutura/configuração primeiro (venv, Docker, MCP), deixando a indexação para depois.
|
|
189
|
+
|
|
190
|
+
### Trocar modelo (`--change-model`)
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
./rag-setup.run --change-model /caminho/do/projeto
|
|
194
|
+
```
|
|
195
|
+
|
|
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
|
|
199
|
+
|
|
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`.
|
|
204
|
+
|
|
205
|
+
Para que serve cada variável:
|
|
206
|
+
|
|
207
|
+
- `MCP_EMBEDDING_MODEL=jina|bge|hybrid`
|
|
208
|
+
- Seleciona estratégia de embedding.
|
|
209
|
+
- Ao alterar: reindexação obrigatória.
|
|
210
|
+
|
|
211
|
+
- `MCP_JINA_QUANTIZATION=default|dynamic-int8`
|
|
212
|
+
- Define quantização do Jina em CPU.
|
|
213
|
+
- Ao alterar: reindexação recomendada.
|
|
214
|
+
|
|
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
|
+
|
|
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
|
+
|
|
223
|
+
- `MCP_CHUNK_SIZE=<int>`
|
|
224
|
+
- Define tamanho dos chunks na indexação.
|
|
225
|
+
- Ao alterar: reindexação completa obrigatória.
|
|
226
|
+
|
|
227
|
+
- `MCP_CHUNK_OVERLAP=<int>`
|
|
228
|
+
- Define sobreposição entre chunks.
|
|
229
|
+
- Ao alterar: reindexação completa obrigatória.
|
|
230
|
+
|
|
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
|
+
|
|
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
|
+
|
|
239
|
+
- `MCP_CHROMA_SCHEME=http|https`
|
|
240
|
+
- `MCP_CHROMA_HOST=<host>`
|
|
241
|
+
- `MCP_CHROMA_PORT=<port>`
|
|
242
|
+
- Sobrescrevem endpoint do Chroma.
|
|
243
|
+
- Ao alterar: reinicie clientes MCP; reindexe somente se trocar para base vazia/nova.
|
|
244
|
+
|
|
245
|
+
## Verificação de checksum (`.run`)
|
|
246
|
+
|
|
247
|
+
Verificação manual (Linux/macOS):
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
sha256sum rag-setup.run
|
|
251
|
+
sha256sum rag-setup-macos.run
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
No macOS sem `sha256sum`:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
shasum -a 256 rag-setup.run
|
|
258
|
+
shasum -a 256 rag-setup-macos.run
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Transparência de código
|
|
262
|
+
|
|
263
|
+
Lógica principal em arquivos-fonte (`bin/*.py`, `bin/*.sh`).
|
|
264
|
+
Artefatos gerados:
|
|
265
|
+
|
|
266
|
+
- `rag-setup.run`
|
|
267
|
+
- `rag-setup-macos.run`
|
|
268
|
+
|
|
269
|
+
Para regenerar artefatos após mudanças no fonte:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
./bin/build_run.sh
|
|
273
|
+
./bin/build_run_macos.sh
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Validação antes de publicar
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
bash -n rag-setup.run
|
|
280
|
+
bash -n rag-setup-macos.run
|
|
281
|
+
python3 -m py_compile bin/indexer_full.py bin/mcp_server.py
|
|
282
|
+
npm pack --dry-run
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Licença
|
|
286
|
+
|
|
287
|
+
MIT
|