Skip to content

Commit 7e1b475

Browse files
authored
feat: improve ingestion reporting and agent setup
- expand ingestion inventory and skipped-file reporting - add Markdown report skill and Claude/Codex MCP snippets - bump packages to 0.4.7 and regenerate dist
1 parent f45e11f commit 7e1b475

66 files changed

Lines changed: 1391 additions & 125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
Transformers.js WAV path for offline/confidential rendering, use the Edge MP3 path for global
3333
Voice Forge quality only when online TTS is explicitly acceptable, and keep generated audio under
3434
ignored local Mimir state.
35+
- Keep report generation separate from core retrieval. The `mimir-markdown-report` skill writes cited
36+
Markdown reports under ignored `.mimir/reports/` by default and must distinguish evidence,
37+
inference, uncertainty, missing documents, and professional-review items.
38+
- Ingestion must be explicit about files it did not index. Preserve `kb audit --unsupported`,
39+
unsupported-extension summaries, secret-like file skipping, max file size limits, and checksum-based
40+
stale detection.
3541
- Keep the repository as a simple pnpm workspace monorepo. Add Turbo only if multiple packages or
3642
apps start needing task caching/orchestration beyond `pnpm --filter`.
3743
- Keep Mimir core free of Ollama. `embeddingProvider: "local-hash"` supports ingestion, search, MCP,
@@ -95,6 +101,11 @@ General principles (KISS, DRY, YAGNI, SOLID) as applied in this codebase. Match
95101
privacy and confidentiality hardening layer.
96102
- `packages/mimir/skills/mimir/SKILL.md` is the bundled portable agent skill.
97103
- `packages/mimir/skills/mimir-audio-summary/SKILL.md` is the optional bundled audio-summary skill.
104+
- `packages/mimir/skills/mimir-markdown-report/SKILL.md` is the optional bundled Markdown-report
105+
skill.
106+
- `kb setup` must keep generating agent-specific MCP helpers for easy local use:
107+
`.mimir/claude-mcp-server.json` for `claude mcp add-json` and `.mimir/codex-mcp.toml` for Codex
108+
config layers.
98109
- `packages/mimir/examples/sovereign-rag-demo` is the tracked synthetic test workspace for manual
99110
and package validation.
100111
- `.kb/`, `.mimir/`, and project `private/` folders are local user data or generated agent

README.md

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ Early public package. APIs may evolve before `1.0.0`.
6464
- Give Claude, Codex, Cursor, internal assistants, or other MCP-compatible tools the same private
6565
retrieval layer.
6666
- Retrieve grounded local evidence through CLI, library calls, MCP tools, or bundled agent skills.
67-
- Optionally create listenable MP3 or WAV summaries with `kb audio`, `@jcode.labs/mimir-tts`, and
68-
the bundled `mimir-audio-summary` skill.
67+
- Optionally create listenable MP3/WAV summaries or cited Markdown reports with bundled skills.
6968

7069
Mimir is not a hosted SaaS, not a remote vector database, and not a certified high-assurance system.
7170
For regulated or state-grade environments, pair it with encrypted disks, controlled machines,
@@ -88,6 +87,7 @@ context.
8887
| Prepare meetings or decisions | "Give me a one-page briefing.", "What is missing before deciding?", "List action items and evidence." |
8988
| Ask questions over offline documents | "Which files mention local-only operation?", "What evidence supports this claim?" |
9089
| Generate audio briefings | "Create a listenable high-quality or offline summary of the current dossier." |
90+
| Generate Markdown reports | "Write a cited local report with findings, risks, next actions, and sources." |
9191

9292
## Requirements
9393

@@ -103,6 +103,8 @@ context.
103103
external `edge-tts` CLI and render with `--engine edge`. For confidential or air-gapped content,
104104
use the Transformers.js WAV path with `--engine transformers --offline`; it does not require
105105
Python, ffmpeg, Piper, XTTS, or a local server.
106+
- Optional Markdown reports use the bundled `mimir-markdown-report` skill and should stay under
107+
ignored `.mimir/reports/` unless explicitly sanitized for sharing.
106108

107109
## Install
108110

@@ -145,12 +147,15 @@ private/ # raw documents to ingest
145147
.kb/sources.txt # optional extra source paths
146148
.mimir/skills/mimir/SKILL.md # portable agent skill
147149
.mimir/skills/mimir-audio-summary/SKILL.md
148-
.mimir/mcp.json # MCP server config snippet
150+
.mimir/skills/mimir-markdown-report/SKILL.md
151+
.mimir/mcp.json # generic MCP server config snippet
152+
.mimir/claude-mcp-server.json # Claude Code add-json payload
153+
.mimir/codex-mcp.toml # Codex config.toml snippet
149154
.gitignore # ignores private/**, .kb/, and .mimir/
150155
```
151156

152-
It detects the repository package manager and writes `.mimir/mcp.json` with the right command, such
153-
as `pnpm exec kb serve-mcp`, `npx kb serve-mcp`, `yarn exec kb serve-mcp`, or `bunx kb serve-mcp`.
157+
It detects the repository package manager and writes the MCP helper files with the right command:
158+
`pnpm exec kb serve-mcp`, `npx kb serve-mcp`, `yarn exec kb serve-mcp`, or `bunx kb serve-mcp`.
154159

155160
Check readiness at any time:
156161

@@ -192,7 +197,15 @@ pnpm exec kb ingest
192197
pnpm exec kb doctor
193198
```
194199

195-
When the index is ready, `kb doctor` prints `ready=true`.
200+
When the index is ready, `kb doctor` prints `ready=true`. `kb ingest` and `kb audit` also report
201+
files that were discovered but not indexed because the type is unsupported, the file is too large,
202+
or the file name looks like a secret/private key.
203+
204+
List skipped paths explicitly:
205+
206+
```bash
207+
pnpm exec kb audit --unsupported
208+
```
196209

197210
Retrieve exact passages:
198211

@@ -286,13 +299,18 @@ This creates:
286299
```plain text
287300
.mimir/skills/mimir/SKILL.md
288301
.mimir/skills/mimir-audio-summary/SKILL.md
302+
.mimir/skills/mimir-markdown-report/SKILL.md
289303
.mimir/mcp.json
304+
.mimir/claude-mcp-server.json
305+
.mimir/codex-mcp.toml
290306
.mimir/README.md
291307
```
292308

293309
Agents that support skill folders can load `.mimir/skills/mimir/` for deep local RAG usage. Load
294-
`.mimir/skills/mimir-audio-summary/` only when an optional spoken summary is needed. Other agents can
295-
read the generated `.mimir/README.md` and use the MCP config snippet.
310+
`.mimir/skills/mimir-audio-summary/` only when an optional spoken summary is needed. Load
311+
`.mimir/skills/mimir-markdown-report/` when the user asks for a cited Markdown report, dossier,
312+
audit memo, or planning note. Other agents can read the generated `.mimir/README.md` and use the MCP
313+
config snippet.
296314

297315
Start the MCP server from the repository root:
298316

@@ -312,6 +330,55 @@ This MCP layer is the recommended way to let any compatible LLM or agent query t
312330
knowledge base. The LLM does not need to know about LanceDB or the raw file layout; it asks Mimir for
313331
ranked passages or cited context and uses the returned citations.
314332

333+
### Claude Code
334+
335+
From the target repository root:
336+
337+
```bash
338+
pnpm exec kb setup
339+
claude mcp add-json --scope local mimir "$(cat .mimir/claude-mcp-server.json)"
340+
```
341+
342+
Claude Code provides the active project path to MCP servers through `CLAUDE_PROJECT_DIR`; Mimir uses
343+
that value when serving MCP, so the same installed npm package can work inside each repository where
344+
`kb setup` was run. Keep the MCP scope local unless you intentionally want to share the server
345+
config.
346+
347+
### Codex
348+
349+
From the target repository root:
350+
351+
```bash
352+
pnpm exec kb setup
353+
cat .mimir/codex-mcp.toml
354+
```
355+
356+
Copy the printed TOML into `~/.codex/config.toml` or another trusted Codex config layer. The snippet
357+
contains the repository `cwd`, so Codex can launch the Mimir MCP server from the right project.
358+
359+
For other MCP clients that cannot set `cwd`, set `MIMIR_PROJECT_ROOT=/absolute/path/to/repository`
360+
when launching `kb serve-mcp`.
361+
362+
### Agent Demo
363+
364+
From a repository that already ran `kb setup` and has Mimir wired into the current agent, ask:
365+
366+
```plain text
367+
Use Mimir to audit the local evidence. First run mimir_status and mimir_audit. Then search for
368+
"offline retrieval approval" and produce a cited Markdown report. Do not rely on memory if Mimir
369+
does not contain enough evidence.
370+
```
371+
372+
Agents that support skill folders should also load:
373+
374+
```plain text
375+
.mimir/skills/mimir/
376+
.mimir/skills/mimir-markdown-report/
377+
```
378+
379+
The Markdown report skill writes reports under `.mimir/reports/` by default, which stays ignored by
380+
Git.
381+
315382
Print the bundled skill path from the installed package:
316383

317384
```bash
@@ -419,14 +486,20 @@ Mimir supports common text, document, data, config, log, and source-code files o
419486
- YAML: `.yaml`, `.yml`
420487
- CSV/TSV: `.csv`, `.tsv`
421488
- HTML: `.html`, `.htm`
489+
- EPUB: `.epub`
422490
- PDF: `.pdf`
423491
- Office/OpenDocument: `.docx`, `.pptx`, `.xlsx`, `.odt`, `.ods`, `.odp`
424492
- Rich text: `.rtf`
493+
- Notebook: `.ipynb`
494+
- Subtitles/calendars/mail: `.vtt`, `.srt`, `.ics`, `.eml`
425495
- Line data and logs: `.jsonl`, `.ndjson`, `.log`
426-
- XML feeds and documents: `.xml`, `.rss`, `.atom`
496+
- XML feeds and documents: `.xml`, `.rss`, `.atom`, `.svg`
427497
- Config and data files: `.toml`, `.ini`, `.conf`, `.cfg`, `.properties`, `.sql`
428-
- Source code: `.ts`, `.tsx`, `.js`, `.jsx`, `.py`, `.go`, `.rs`, `.java`, `.rb`, `.php`, `.cs`,
429-
`.c`, `.cpp`, `.h`, `.css`
498+
- Source code: `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.py`, `.go`, `.rs`,
499+
`.java`, `.rb`, `.php`, `.cs`, `.c`, `.cpp`, `.h`, `.hpp`, `.css`, `.scss`, `.vue`, `.svelte`,
500+
`.astro`, `.sh`, `.bash`, `.ps1`
501+
- Documentation/code review text: `.rst`, `.adoc`, `.tex`, `.diff`, `.patch`, `.markdown`,
502+
`.mdown`
430503

431504
Custom UTF-8 text extensions can be enabled without changing code:
432505

@@ -447,6 +520,13 @@ that are not listed should be OCRed, transcribed, converted, or exported to text
447520
Mimir intentionally avoids pretending that every binary format can be indexed safely without
448521
extraction logic.
449522

523+
Secret-like files such as `.env`, `.npmrc`, private keys, and certificates are skipped by default.
524+
Convert safe examples to a normal text format before ingestion.
525+
526+
Sensitive key/certificate-like files such as `.pem`, `.key`, `.p12`, `.pfx`, `.jks`, `.gpg`, and
527+
common secret filenames such as `.env`, `.npmrc`, `.netrc`, and `.pgpass` are skipped by default even
528+
if they sit under a source directory.
529+
450530
## Configuration Reference
451531

452532
Default `.kb/config.json`:
@@ -472,6 +552,9 @@ Default `.kb/config.json`:
472552
"topK": 5,
473553
"chunkSize": 1200,
474554
"chunkOverlap": 150,
555+
"maxFileBytes": 50000000,
556+
"ingestConcurrency": 4,
557+
"embeddingBatchSize": 32,
475558
"includeExtensions": []
476559
}
477560
```
@@ -493,6 +576,9 @@ Environment overrides:
493576
- `KB_TOP_K`
494577
- `KB_CHUNK_SIZE`
495578
- `KB_CHUNK_OVERLAP`
579+
- `KB_MAX_FILE_BYTES`
580+
- `KB_INGEST_CONCURRENCY`
581+
- `KB_EMBEDDING_BATCH_SIZE`
496582
- `KB_INCLUDE_EXTENSIONS`
497583

498584
## CLI Reference
@@ -512,6 +598,7 @@ Mimir ships two CLIs:
512598
| `kb doctor --fix` | Create missing scaffolding, install skills/MCP config, and rebuild stale indexes when safe. |
513599
| `kb ingest` | Parse source files, redact, chunk, embed, and rebuild the local LanceDB index. |
514600
| `kb audit` | Check whether supported source files are missing from or stale in the index. |
601+
| `kb audit --unsupported` | List files skipped because they are unsupported, too large, or secret-like. |
515602
| `kb search "<query>"` | Retrieve ranked passages without asking an LLM to write an answer. |
516603
| `kb ask "<question>"` | Return cited retrieval context for an agent or trusted model runtime. |
517604
| `kb security-audit` | Inspect privacy posture: telemetry, providers, redaction, Git ignore, MCP. |
@@ -547,7 +634,8 @@ Mimir ships two CLIs:
547634
| Option | Applies to | Meaning |
548635
| --- | --- | --- |
549636
| `--top-k <number>` | `search`, `ask` | Number of passages to return. |
550-
| `--json` | `doctor`, `security-audit`, `audio --doctor`, `mimir-tts doctor` | Print machine-readable JSON. |
637+
| `--json` | `doctor`, `audit`, `security-audit`, `audio --doctor`, `mimir-tts doctor` | Print machine-readable JSON. |
638+
| `--unsupported` | `audit` | List skipped file paths and reasons. |
551639
| `--strict` | `security-audit` | Exit non-zero when warnings exist. |
552640
| `--offline` | `audio`, `mimir-tts render` | Disable remote model downloads and force the local Transformers.js path. |
553641
| `--allow-remote-models` | `audio`, `mimir-tts render` | Explicitly allow model downloads for Transformers.js. |
@@ -602,6 +690,15 @@ pnpm exec kb doctor
602690
If documents live elsewhere, add one path per line to `.kb/sources.txt`. Relative paths resolve from
603691
the project root.
604692

693+
If files exist but are not supported yet, inspect the skipped inventory:
694+
695+
```bash
696+
pnpm exec kb audit --unsupported
697+
```
698+
699+
Then either convert them to a supported format, OCR/transcribe them, or add a safe custom UTF-8 text
700+
extension with `includeExtensions` / `KB_INCLUDE_EXTENSIONS`.
701+
605702
### Search Returns Weak Results
606703

607704
The default `local-hash` provider is dependency-light and offline, but it is lexical/hash retrieval,

SECURITY-HARDENING.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ built to minimize data movement, but it is not a certified high-assurance system
1313
remote model loading disabled by default through `transformersAllowRemoteModels: false`.
1414
- Redaction before indexing: built-in DLP patterns redact common secrets and identifiers before
1515
chunks are embedded and stored.
16+
- Secret-like files are skipped by default: common private-key, certificate, and credential
17+
filenames/extensions are not indexed even when they appear under a source directory.
18+
- Ingestion has a default per-file size cap through `maxFileBytes` and reports unsupported,
19+
oversized, and secret-like skipped files.
1620
- Metadata-only access logs: access logs contain action metadata and query hashes, not raw
1721
queries or retrieved text.
1822
- Generated local state is ignored by Git: `.kb/`, `.mimir/`, and `private/**` are ignored by
@@ -22,6 +26,8 @@ built to minimize data movement, but it is not a certified high-assurance system
2226
- Optional audio summaries use `kb audio` / `@jcode.labs/mimir-tts`. Transformers.js WAV is the
2327
default offline/confidential path and does not require Python, ffmpeg, Piper, XTTS, or a local TTS
2428
server. Edge MP3 gives the highest quality only when online TTS is explicitly acceptable.
29+
- Optional Markdown reports use the bundled `mimir-markdown-report` skill and should be written
30+
under `.mimir/reports/` by default.
2531
- npm releases are published with provenance from the protected GitHub Actions workflow.
2632
- Release artifacts include a package tarball, SHA256 checksums, SBOM, and manifest.
2733

@@ -61,8 +67,9 @@ Move the generated tarballs from `release-artifacts/` into the offline environme
6167

6268
```bash
6369
pnpm add -D ./jcode.labs-mimir-tts-<version>.tgz ./jcode.labs-mimir-<version>.tgz
64-
pnpm exec kb init
65-
pnpm exec kb ingest
70+
pnpm exec kb setup
71+
pnpm exec kb doctor --fix
72+
pnpm exec kb audit --unsupported
6673
```
6774

6875
For semantic embeddings, preload the Transformers.js-compatible embedding model files inside the
@@ -104,6 +111,16 @@ Run:
104111
pnpm exec kb security-audit --strict
105112
```
106113

114+
Also run:
115+
116+
```bash
117+
pnpm exec kb audit --unsupported
118+
```
119+
120+
This exposes local relative paths for files that were skipped because the extension is unsupported,
121+
the file exceeds `maxFileBytes`, or the filename looks like a secret/key artifact. Use it before
122+
assuming a dossier was fully indexed.
123+
107124
## DLP Redaction
108125

109126
Built-in redaction is enabled by default for common secret and identifier shapes: private keys,
@@ -129,6 +146,23 @@ Custom patterns can be added in `.kb/config.json`:
129146

130147
Redaction changes the indexed text, not the raw files under `private/`.
131148

149+
## Ingestion Boundaries
150+
151+
Mimir indexes many text, document, Office/OpenDocument, PDF, EPUB, subtitle, notebook, mail, config,
152+
and source-code formats. It does not silently ingest every binary file. Unsupported images, scans,
153+
audio/video, old proprietary Office binaries, and unknown formats must be converted, OCRed, or
154+
transcribed first.
155+
156+
Default ingestion guardrails:
157+
158+
- `maxFileBytes`: 50 MB per file by default;
159+
- `ingestConcurrency`: four parse/chunk workers by default;
160+
- `embeddingBatchSize`: 32 chunks per embedding batch by default;
161+
- checksum-based stale detection for supported files;
162+
- unsupported/skipped file reporting through `kb ingest`, `kb audit`, and `kb audit --unsupported`.
163+
164+
These are configurable, but raising limits increases local memory and parsing risk.
165+
132166
## Optional Audio Summaries
133167

134168
`kb install-skill` installs an optional `mimir-audio-summary` skill. It is designed for listenable
@@ -151,6 +185,12 @@ Confidentiality defaults:
151185
Generated audio can still contain sensitive information. Treat it like a derived confidential
152186
document.
153187

188+
## Optional Markdown Reports
189+
190+
`kb install-skill` also installs `mimir-markdown-report`. Reports generated from private evidence are
191+
derived confidential documents. Keep them under `.mimir/reports/` by default, cite source paths and
192+
chunk numbers, and do not commit them unless the user explicitly asks for a sanitized tracked report.
193+
154194
## MCP Hardening
155195

156196
MCP gives an agent access to retrieved private context. Use it only for agents running under the

docs/ux-dx-audit.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ developer and agent workflow around installation, indexing, querying, safety, au
2323
| Generated helper files | `private/README.md` was indexed and could pollute retrieval results. | Fixed: generated private README is skipped by source discovery. |
2424
| Audio confidentiality | `auto` could select online Edge TTS when installed. | Fixed: default path is Transformers.js WAV; Edge MP3 requires `--engine edge`. |
2525
| Documentation shape | The package README had too much tutorial, reference, and explanation mixed together. | Fixed: the root README is canonical; package README files are minimal npm entrypoints. |
26-
| Agent onboarding | `install-skill` installed files but gave limited operational guidance. | Fixed: command output now prints agent next steps. |
26+
| Agent onboarding | `install-skill` installed files but gave limited operational guidance. | Fixed: command output now prints agent next steps and Claude Code/Codex MCP snippets. |
27+
| Ingestion visibility | Unsupported files were ignored silently, which made users overestimate coverage. | Fixed: `ingest`, `audit`, and `audit --unsupported` report skipped files by reason. |
28+
| Report generation | Users had audio summaries but no dedicated Markdown-report workflow. | Fixed: `mimir-markdown-report` skill writes cited reports under ignored local state. |
29+
| Stale detection | Audit compared paths but did not detect changed file content. | Fixed: audit now uses stored checksums to flag stale indexed content. |
2730

2831
## DX Findings
2932

@@ -32,7 +35,7 @@ developer and agent workflow around installation, indexing, querying, safety, au
3235
| Local validation | `pnpm validate` already covers lint, typecheck, tests, build, smoke, package checks, and artifacts. | Good. |
3336
| Release safety | npm publish is protected by CI, environment approval, provenance, and explicit version input. | Good. |
3437
| API clarity | Core exports are small and named, but the README only shows a minimal API snippet. | Partially improved by CLI docs; deeper API docs remain future work. |
35-
| MCP reference | Tool names are documented, but tool schemas are not deeply documented. | Future work. |
38+
| MCP reference | Tool names and an agent demo prompt are documented, but tool schemas are not deeply documented. | Partially improved. |
3639
| Error guidance | Common setup and audio errors were not centralized. | Fixed in the root README troubleshooting section. |
3740
| Dist workflow | `dist/` is committed and documented in `CLAUDE.md`; this is unusual but CI-enforced. | Good for this repo, but keep documenting it. |
3841

@@ -44,11 +47,13 @@ developer and agent workflow around installation, indexing, querying, safety, au
4447
fully air-gapped operation requires a documented model-preload workflow.
4548
- MCP access is read-focused but still exposes private retrieved passages to the connected agent.
4649
Team/RBAC support remains out of scope.
50+
- `audit --unsupported` intentionally lists relative paths only; users still need to avoid pasting
51+
sensitive path names into public issue reports.
4752
- The library API is usable, but a dedicated API reference page would help external developers.
4853

4954
## Recommended Next Pass
5055

5156
1. Add API reference docs for exported functions and result types.
5257
2. Add MCP tool schema examples for agent developers.
5358
3. Add a model-preload guide for semantic embeddings and offline TTS.
54-
4. Add a recorded or scripted demo workspace flow for release QA.
59+
4. Add deeper API reference docs for external library consumers once the public API grows.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jcode-mimir",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"private": true,
55
"description": "Monorepo for the Mimir open-source local RAG packages.",
66
"type": "module",

0 commit comments

Comments
 (0)