@jcode.labs/ragmir 2.8.0 → 2.9.0

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.
@@ -1,253 +1,88 @@
1
1
  ---
2
2
  name: ragmir
3
- description: Use this skill whenever a repository uses or should use Ragmir, local-first RAG, private project knowledge, document ingestion, knowledge-base audit, or MCP access to project documents. Use it before answering from memory when the user asks about facts that may be present in private files, asks to ingest/query/audit documents, or wants Claude Code, Codex, Kimi, OpenCode, Cline, or another AI agent to use the same local knowledge base.
3
+ description: Use Ragmir for local-first retrieval from private project documents, document ingestion, knowledge-base audits, or MCP access to a repository corpus. Prefer it to memory when the answer may be in local documents.
4
4
  ---
5
5
 
6
6
  # Ragmir
7
7
 
8
- Ragmir is a sovereign local RAG knowledge base for confidential project documents and datasets. It
9
- indexes files from the current repository, stores vectors locally, and exposes both a CLI and an MCP
10
- server.
8
+ Ragmir indexes a repository's documents locally and returns cited passages through a CLI and MCP
9
+ server. Treat the target repository and its index as the source of truth.
11
10
 
12
- Use this skill to help an AI agent work with a Ragmir-enabled repository without leaking private documents or relying on stale memory.
11
+ ## Safety
13
12
 
14
- ## Core Rule
13
+ - Do not commit `.ragmir/`, raw documents, generated vectors, or access logs.
14
+ - Treat retrieval output as sensitive. Summarize it with citations instead of pasting long passages.
15
+ - Separate document-backed facts from inference. Ask for missing documents when the index is weak.
15
16
 
16
- Treat the repository where the user is working as the source of truth. Ragmir data belongs to that repository, not to the installed npm package.
17
+ ## Start here
17
18
 
18
- Default project layout:
19
+ From the target repository root:
19
20
 
20
- ```plain text
21
- .ragmir/config.json # local Ragmir config
22
- .ragmir/raw/ # raw documents to ingest
23
- .ragmir/storage/ # generated local index
24
- .ragmir/access.log # metadata-only access log
25
- .ragmir/reports/ # generated local Markdown reports
26
- ```
27
-
28
- ## Data Safety
29
-
30
- - Do not commit raw documents, secrets, tax IDs, scans, bank documents, tokens, or generated vector stores.
31
- - Keep `.ragmir/` ignored by Git.
32
- - Treat `rgr search`, `rgr ask`, `rgr research`, and MCP results as sensitive because they can
33
- contain private source passages even when redaction is enabled.
34
- - Prefer summaries and citations over dumping long private passages into the chat.
35
- - If the user asks for a high-stakes answer, identify which facts came from Ragmir and which still require professional or official verification.
36
-
37
- ## First Checks
38
-
39
- From the repository root:
40
-
41
- ```bash
21
+ ```sh
42
22
  pnpm exec rgr doctor
43
23
  ```
44
24
 
45
- If Ragmir is installed but setup is incomplete or the index is stale:
25
+ If setup or indexing is incomplete:
46
26
 
47
- ```bash
27
+ ```sh
48
28
  pnpm exec rgr doctor --fix
49
29
  ```
50
30
 
51
- If Ragmir is not installed:
31
+ For a new installation:
52
32
 
53
- ```bash
33
+ ```sh
54
34
  pnpm add -D @jcode.labs/ragmir
55
35
  pnpm exec rgr setup
56
- # Optional: one-time model download for higher-quality semantic retrieval.
57
- pnpm exec rgr setup --semantic
58
- ```
59
-
60
- When the repository should expose only specific agent helpers or must launch MCP through a local
61
- wrapper, generate the agent kit explicitly:
62
-
63
- ```bash
64
- pnpm exec rgr setup --agents claude,codex --mcp-command ./scripts/serve-mcp.sh
65
- ```
66
-
67
- If the package manager is npm:
68
-
69
- ```bash
70
- npm install --save-dev @jcode.labs/ragmir
71
- npx rgr setup
72
- # Optional: one-time model download for higher-quality semantic retrieval.
73
- npx rgr setup --semantic
36
+ pnpm exec rgr ingest
74
37
  ```
75
38
 
76
- Use `status`, `audit`, and `security-audit` for deeper checks after `doctor` explains the current
77
- state. Use `audit --unsupported` when files exist but may not have been indexed.
39
+ Use `pnpm exec rgr setup --semantic` only when a one-time local embedding-model download is
40
+ acceptable. Normal confidential indexing keeps remote model loading disabled.
78
41
 
79
- ## Agent Operating Loop
42
+ ## Choose the smallest operation
80
43
 
81
- Prefer the smallest command that answers the user's task:
82
-
83
- | Task | Preferred command or tool |
44
+ | Need | Command or MCP tool |
84
45
  | --- | --- |
85
- | Check whether Ragmir is usable | `rgr doctor` or MCP `ragmir_status` |
86
- | Decide whether a prompt needs Ragmir | `rgr route-prompt "..." --json` or MCP `ragmir_route_prompt` |
87
- | Repair missing setup or stale index | `rgr doctor --fix` |
88
- | Inspect skipped, duplicate, archive-like, or mirror-like sources | `rgr audit --unsupported` |
89
- | Find exact source passages | `rgr search "<query>" --compact` or MCP `ragmir_search` with `compact: true` |
90
- | Prepare a broad implementation, review, or planning answer | `rgr research "<topic>" --compact` or MCP `ragmir_research` |
91
- | Return deterministic cited context for a trusted model | `rgr ask "<question>"` or MCP `ragmir_ask` |
92
- | Check local privacy posture | `rgr security-audit` or MCP `ragmir_security_audit` |
93
- | Validate recall against known expected files | `rgr evaluate --golden <file>` or MCP `ragmir_evaluate` |
94
-
95
- ## Provider Modes
46
+ | Readiness | `rgr doctor` or `ragmir_status` |
47
+ | Repair setup or stale data | `rgr doctor --fix` |
48
+ | Check unindexed or unsupported files | `rgr audit --unsupported` |
49
+ | Check privacy posture | `rgr security-audit` |
50
+ | Retrieve exact passages | `rgr search "query" --compact` or `ragmir_search` |
51
+ | Gather broad cited evidence | `rgr research "topic" --compact` or `ragmir_research` |
52
+ | Return deterministic context | `rgr ask "question"` or `ragmir_ask` |
53
+ | Measure retrieval recall | `rgr evaluate --golden <file>` or `ragmir_evaluate` |
96
54
 
97
- Default retrieval mode:
55
+ Use `rgr route-prompt "..." --json` or `ragmir_route_prompt` only when it is unclear whether the
56
+ current request needs the local corpus. The router is deterministic and does not retrieve or store
57
+ the prompt.
98
58
 
99
- ```json
100
- {
101
- "embeddingProvider": "local-hash"
102
- }
103
- ```
104
-
105
- This supports ingestion, search, MCP retrieval, and `rgr ask` with cited passages without a model
106
- server. It is lexical/hash retrieval, not model-semantic search. Do not present it as equivalent to
107
- semantic embeddings.
108
-
109
- Optional semantic embedding mode:
110
-
111
- ```json
112
- {
113
- "embeddingProvider": "transformers",
114
- "embeddingModel": "intfloat/multilingual-e5-small",
115
- "embeddingModelRevision": "main",
116
- "embeddingModelPath": ".ragmir/models",
117
- "transformersAllowRemoteModels": false
118
- }
119
- ```
59
+ ## Indexing
120
60
 
121
- This uses Transformers.js for embeddings only. Keep `transformersAllowRemoteModels` false for
122
- air-gapped or confidential work and preload model files under `embeddingModelPath`. Use the
123
- first-run shortcut when a one-time download is acceptable:
61
+ Use `.ragmir/config.json` for sources, with paths, globs, and `!` exclusions:
124
62
 
125
- ```bash
126
- pnpm exec rgr setup --semantic
127
- pnpm exec rgr ingest --rebuild
63
+ ```sh
64
+ pnpm exec rgr sources add "docs/**/*.md" "specs/**/*.md"
65
+ pnpm exec rgr sources add "!**/node_modules/**"
66
+ pnpm exec rgr ingest
128
67
  ```
129
68
 
130
- Or enable it later:
69
+ Normal ingestion is incremental. Rebuild only after changing the embedding provider, embedding
70
+ model, or chunking settings:
131
71
 
132
- ```bash
133
- pnpm exec rgr models pull --enable
72
+ ```sh
134
73
  pnpm exec rgr ingest --rebuild
135
74
  ```
136
75
 
137
- ## Ingestion Workflow
138
-
139
- After documents are added or changed:
140
-
141
- ```bash
142
- pnpm exec rgr doctor --fix
143
- pnpm exec rgr audit
144
- pnpm exec rgr audit --unsupported
145
- pnpm exec rgr security-audit
146
- pnpm exec rgr status
147
- ```
148
-
149
- `rgr doctor --fix` updates the index only when supported files are present and the privacy posture
150
- has no warnings. Normal `rgr ingest` reuses unchanged rows; use `rgr ingest --rebuild` after changing
151
- embedding provider/model or chunking settings. `rgr ingest --json` reports `emptyTextFiles` when
152
- supported files, typically scanned PDFs, produce no indexable text. `rgr doctor` should show
153
- `ready=true` before relying on the index. Empty-text, oversized, missing, or stale coverage keeps it
154
- false. Run `rgr limits` to inspect the active per-file and parser bounds. There is no fixed file-count
155
- or total-corpus-byte ceiling, so benchmark large corpora on their target machine. The audit must show
156
- no missing or stale supported files, and the security audit should not show warnings before relying
157
- on Ragmir for sensitive work.
158
-
159
- Default retrieval is tuned for broader recall (`topK: 8`, `chunkOverlap: 200`). Keep MCP retrieval
160
- bounded by `mcpMaxTopK`, and raise `--top-k` only when the first results are too narrow.
161
-
162
- For monorepos, keep raw confidential files local and list useful repo docs through the `sources`
163
- array in `.ragmir/config.json`. Entries can be paths or glob patterns relative to the Ragmir project
164
- root, with `!` exclusions:
165
-
166
- ```plain text
167
- ../apps/*/README.md
168
- ../apps/*/docs/**/*.md
169
- !../apps/**/node_modules/**
170
- ```
171
-
172
- Use the CLI when you want agents or setup scripts to update the file without manual editing:
173
-
174
- ```bash
175
- pnpm exec rgr sources add "../apps/*/README.md" "../apps/*/docs/**/*.md"
176
- pnpm exec rgr sources add "!../apps/**/node_modules/**"
177
- pnpm exec rgr sources list
178
- ```
76
+ For scanned PDFs, first run `rgr ocr doctor`, then configure a local OCR tool with `rgr ocr setup`.
77
+ OCR stays opt-in and never calls a remote service by default.
179
78
 
180
- ## Query Workflow
181
-
182
- Use search when you need exact source passages:
183
-
184
- ```bash
185
- pnpm exec rgr search "your query"
186
- ```
187
-
188
- Use repeatable `--include-path` and `--exclude-path` filters when primary evidence, research notes,
189
- or mirror/archive directories must be evaluated separately. The same `includePaths` and
190
- `excludePaths` arrays are available through MCP and per query in golden evaluation files.
191
-
192
- Use research when the user asks for broad context, implementation planning, review preparation, or a
193
- cross-document audit:
194
-
195
- ```bash
196
- pnpm exec rgr research "your topic" --compact
197
- ```
198
-
199
- `rgr research` runs audit and security checks, generates several related retrieval queries, merges
200
- cited evidence, reports source diagnostics, and performs a lightweight repository code scan unless
201
- `--no-code` is used.
202
-
203
- Use ask when you need cited context for the current agent or an external LLM:
204
-
205
- ```bash
206
- pnpm exec rgr ask "your question"
207
- ```
79
+ `local-hash` is the default retrieval provider. It supports cited local retrieval but is not
80
+ semantic embeddings. Use the Transformers provider only after an explicit model preload.
208
81
 
209
- Ground answers in returned sources. If search results are weak, say that the current index does not
210
- prove the point and ask for the missing document. `rgr ask` returns cited passages rather than LLM
211
- synthesis. Use those passages as context for the current agent, or tell the user that generative
212
- synthesis needs a trusted external LLM or model runtime.
82
+ ## MCP
213
83
 
214
- ## Prompt Routing
215
-
216
- When the user did not explicitly mention Ragmir, use local judgment first. If the prompt asks about
217
- the current repository, local documents, private specs, architecture, previous decisions, citations,
218
- release readiness, audits, or implementation planning, prefer Ragmir before answering from memory.
219
-
220
- When the runtime supports MCP and you are unsure, call `ragmir_route_prompt` with the prompt text. If
221
- MCP is unavailable, use:
222
-
223
- ```bash
224
- pnpm exec rgr route-prompt "the user prompt" --json
225
- ```
226
-
227
- If the decision returns `shouldUseRagmir: true`, call the suggested `tool` with the returned `query`.
228
- If it returns `false`, answer normally. The router is deterministic and local: it does not store
229
- prompt text, call an LLM, read the vector index, or retrieve passages.
230
-
231
- ## Deep Research Workflow
232
-
233
- For broad summaries, audits, planning, or institutional dossiers, do not rely on one query. Build a
234
- small retrieval plan first:
235
-
236
- - use `rgr research` as the first pass when available;
237
- - check `rgr audit` and `rgr security-audit`;
238
- - query the main topic;
239
- - query names, dates, amounts, obligations, risks, decisions, and missing evidence separately;
240
- - compare the strongest passages across files;
241
- - ask a synthesis question only after search has found enough grounded context;
242
- - cite source paths and chunk numbers in the answer when useful;
243
- - explicitly say when the index does not prove a claim.
244
-
245
- For sensitive work, prefer the smallest useful `topK`; raise it only when the first results are too
246
- thin. Do not dump large raw passages into the chat unless the user explicitly asks for extracts.
247
-
248
- ## MCP Usage
249
-
250
- If the agent supports MCP, configure a server for the repository:
84
+ `rgr setup` writes local MCP helpers under `.ragmir/` for Claude Code, Codex, Kimi, OpenCode, and
85
+ Cline. A generic server configuration is:
251
86
 
252
87
  ```json
253
88
  {
@@ -255,138 +90,28 @@ If the agent supports MCP, configure a server for the repository:
255
90
  "ragmir": {
256
91
  "command": "pnpm",
257
92
  "args": ["exec", "rgr", "serve-mcp"],
258
- "cwd": "/absolute/path/to/the/repository"
93
+ "cwd": "/absolute/path/to/repository"
259
94
  }
260
95
  }
261
96
  }
262
97
  ```
263
98
 
264
- Generated MCP helpers use the `ragmir` server name by default. Use `rgr setup --mcp-name <name>`
265
- or `rgr install-skill --mcp-name <name>` only when the repository needs a different stable MCP
266
- key.
99
+ When a client cannot set `cwd`, set `RAGMIR_PROJECT_ROOT` for the server process. Prefer MCP tools
100
+ when available. Use CLI commands when they are not.
267
101
 
268
- For Claude Code, run this from the target repository root after `pnpm exec rgr setup`:
102
+ MCP is read-focused. Only remove an index with the explicit shell command:
269
103
 
270
- ```bash
271
- claude mcp add-json --scope local ragmir "$(cat .ragmir/claude-mcp-server.json)"
104
+ ```sh
105
+ pnpm exec rgr destroy-index --yes
272
106
  ```
273
107
 
274
- For Codex, copy `.ragmir/codex-mcp.toml` into `~/.codex/config.toml` or another trusted Codex config
275
- layer. It includes both the Ragmir MCP server and `skills.config` entries.
276
-
277
- For Kimi Code CLI, run from the target repository root:
278
-
279
- ```bash
280
- kimi --mcp-config-file .ragmir/kimi-mcp.json
281
- ```
282
-
283
- For OpenCode, merge `.ragmir/opencode.jsonc` into the OpenCode config layer used by the project.
284
-
285
- For Cline, add `.ragmir/cline-mcp.json` under `mcpServers` in Cline's MCP configuration.
286
-
287
- For other MCP clients that cannot set `cwd`, set `RAGMIR_PROJECT_ROOT=/absolute/path/to/repository`
288
- when launching `rgr serve-mcp`. `RAGMIR_PROJECT_ROOT` is the strongest signal; otherwise a
289
- configured current working directory wins before agent-provided project environment variables.
290
-
291
- Available MCP tools:
292
-
293
- - `ragmir_status`: show config and chunk count.
294
- - `ragmir_route_prompt`: classify a prompt and suggest whether local Ragmir context is needed.
295
- - `ragmir_search`: retrieve source passages; set `compact: true` when the agent context is tight.
296
- - `ragmir_ask`: return cited retrieval context.
297
- - `ragmir_research`: run audit-backed multi-query retrieval with source diagnostics and optional code matches.
298
- - `ragmir_audit`: compare source files with the current index.
299
- - `ragmir_evaluate`: measure retrieval recall against a local golden query file.
300
- - `ragmir_usage_report`: summarize metadata-only local access-log activity without query text or local paths.
301
- - `ragmir_security_audit`: inspect local privacy, provider, redaction, MCP, and gitignore posture.
302
-
303
- Prefer MCP tools over shell commands when the agent runtime provides them. Use shell commands when MCP is unavailable.
304
-
305
- MCP is read-focused and intentionally does not expose index deletion. Use `pnpm exec rgr
306
- destroy-index --yes` from the shell when the user explicitly wants to remove the generated index.
307
-
308
- ## Optional Audio Summaries
309
-
310
- If the user asks for a listenable or TTS summary, load the optional
311
- `.ragmir/skills/ragmir-audio-summary/` skill installed by `pnpm exec rgr setup`.
312
-
313
- The audio skill should:
314
-
315
- - gather evidence through Ragmir first;
316
- - write narration text only to a temp file outside the repository;
317
- - render generated audio under `.ragmir/audio/` by default;
318
- - prefer offline TTS engines for confidential content.
319
-
320
- ## Optional Markdown Reports
321
-
322
- If the user asks for a Markdown report, dossier, audit memo, planning note, or decision brief, load
323
- the optional `.ragmir/skills/ragmir-markdown-report/` skill installed by `pnpm exec rgr setup`.
324
-
325
- The report skill should:
326
-
327
- - gather evidence through multiple Ragmir searches first;
328
- - cite source paths and chunk numbers;
329
- - separate facts, inference, uncertainty, and missing evidence;
330
- - write reports under `.ragmir/reports/` by default;
331
- - keep generated reports uncommitted unless the user explicitly wants a sanitized tracked report.
332
-
333
- ## Installing This Skill Into A Repository
334
-
335
- Most repositories should run the full setup command:
336
-
337
- ```bash
338
- pnpm exec rgr setup
339
- ```
340
-
341
- Use the lower-level skill installer only when Ragmir is already initialized and you want to refresh
342
- the local agent kit:
343
-
344
- ```bash
345
- pnpm exec rgr install-skill
346
- pnpm exec rgr install-skill --agents claude,codex --mcp-command ./scripts/serve-mcp.sh
347
- ```
348
-
349
- This creates:
350
-
351
- ```plain text
352
- .ragmir/skills/ragmir/SKILL.md
353
- .ragmir/skills/ragmir-audio-summary/SKILL.md
354
- .ragmir/skills/ragmir-markdown-report/SKILL.md
355
- .ragmir/skills/ragmir-legal-dossier/SKILL.md
356
- .ragmir/mcp.json
357
- .ragmir/claude-mcp-server.json
358
- .ragmir/codex-mcp.toml
359
- .ragmir/kimi-mcp.json
360
- .ragmir/opencode.jsonc
361
- .ragmir/cline-mcp.json
362
- .ragmir/agent-setup.md
363
- .ragmir/README.md
364
- ```
365
-
366
- When `--agents` is used, only the selected agent-specific MCP helpers are written, and stale
367
- unselected helpers in `.ragmir/` are removed.
368
-
369
- For native discovery, install only the agent the user uses:
370
-
371
- ```bash
372
- pnpm exec rgr install-agent --agents claude
373
- pnpm exec rgr install-agent --agents kimi
374
- pnpm exec rgr install-agent --agents claude,codex,kimi,opencode,cline
375
- ```
376
-
377
- By default this writes project-scope skill folders such as `.claude/skills/`, `.kimi/skills/`,
378
- `.opencode/skills/`, or `.cline/skills/` as links back to `.ragmir/skills/`. That keeps one original
379
- skill source. Add `--scope user` for global installs, or `--mode copy` only when an agent/runtime
380
- cannot follow symlinked skill directories.
381
-
382
- Agents that understand skill folders can load `.ragmir/skills/ragmir/` directly when native discovery
383
- is not installed. Other agents can read `.ragmir/README.md` and `.ragmir/mcp.json`.
108
+ ## Optional outputs
384
109
 
385
- ## Answer Style
110
+ For audio narration, load the installed `ragmir-audio-summary` skill. For a cited Markdown memo,
111
+ load `ragmir-markdown-report`. Both should write generated output under ignored `.ragmir/` state.
386
112
 
387
- When answering from Ragmir:
113
+ ## Answer standard
388
114
 
389
- - mention the source file paths and chunk/source labels when useful;
390
- - distinguish facts found in documents from inference;
391
- - keep operational/legal/financial claims conservative;
392
- - recommend ingesting or providing missing documents when the index is incomplete.
115
+ - Cite file paths and source labels when useful.
116
+ - State uncertainty when retrieval does not prove a claim.
117
+ - Keep legal, security, and financial conclusions conservative and recommend appropriate review.