@jcode.labs/ragmir 2.0.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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -0
  3. package/dist/access-log.d.ts +11 -0
  4. package/dist/access-log.d.ts.map +1 -0
  5. package/dist/access-log.js +145 -0
  6. package/dist/access-log.js.map +1 -0
  7. package/dist/chunking.d.ts +3 -0
  8. package/dist/chunking.d.ts.map +1 -0
  9. package/dist/chunking.js +58 -0
  10. package/dist/chunking.js.map +1 -0
  11. package/dist/cli.d.ts +3 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +944 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/config.d.ts +11 -0
  16. package/dist/config.d.ts.map +1 -0
  17. package/dist/config.js +224 -0
  18. package/dist/config.js.map +1 -0
  19. package/dist/defaults.d.ts +17 -0
  20. package/dist/defaults.d.ts.map +1 -0
  21. package/dist/defaults.js +59 -0
  22. package/dist/defaults.js.map +1 -0
  23. package/dist/destroy.d.ts +3 -0
  24. package/dist/destroy.d.ts.map +1 -0
  25. package/dist/destroy.js +16 -0
  26. package/dist/destroy.js.map +1 -0
  27. package/dist/doctor.d.ts +3 -0
  28. package/dist/doctor.d.ts.map +1 -0
  29. package/dist/doctor.js +117 -0
  30. package/dist/doctor.js.map +1 -0
  31. package/dist/embeddings.d.ts +9 -0
  32. package/dist/embeddings.d.ts.map +1 -0
  33. package/dist/embeddings.js +110 -0
  34. package/dist/embeddings.js.map +1 -0
  35. package/dist/evaluate.d.ts +3 -0
  36. package/dist/evaluate.d.ts.map +1 -0
  37. package/dist/evaluate.js +97 -0
  38. package/dist/evaluate.js.map +1 -0
  39. package/dist/files.d.ts +16 -0
  40. package/dist/files.d.ts.map +1 -0
  41. package/dist/files.js +388 -0
  42. package/dist/files.js.map +1 -0
  43. package/dist/gitignore.d.ts +3 -0
  44. package/dist/gitignore.d.ts.map +1 -0
  45. package/dist/gitignore.js +27 -0
  46. package/dist/gitignore.js.map +1 -0
  47. package/dist/guards.d.ts +2 -0
  48. package/dist/guards.d.ts.map +1 -0
  49. package/dist/guards.js +4 -0
  50. package/dist/guards.js.map +1 -0
  51. package/dist/index.d.ts +25 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +20 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/ingest.d.ts +4 -0
  56. package/dist/ingest.d.ts.map +1 -0
  57. package/dist/ingest.js +268 -0
  58. package/dist/ingest.js.map +1 -0
  59. package/dist/init.d.ts +2 -0
  60. package/dist/init.d.ts.map +1 -0
  61. package/dist/init.js +33 -0
  62. package/dist/init.js.map +1 -0
  63. package/dist/mcp.d.ts +8 -0
  64. package/dist/mcp.d.ts.map +1 -0
  65. package/dist/mcp.js +189 -0
  66. package/dist/mcp.js.map +1 -0
  67. package/dist/package-manager.d.ts +11 -0
  68. package/dist/package-manager.d.ts.map +1 -0
  69. package/dist/package-manager.js +93 -0
  70. package/dist/package-manager.js.map +1 -0
  71. package/dist/parsing.d.ts +12 -0
  72. package/dist/parsing.d.ts.map +1 -0
  73. package/dist/parsing.js +307 -0
  74. package/dist/parsing.js.map +1 -0
  75. package/dist/query.d.ts +5 -0
  76. package/dist/query.d.ts.map +1 -0
  77. package/dist/query.js +180 -0
  78. package/dist/query.js.map +1 -0
  79. package/dist/redaction.d.ts +7 -0
  80. package/dist/redaction.d.ts.map +1 -0
  81. package/dist/redaction.js +93 -0
  82. package/dist/redaction.js.map +1 -0
  83. package/dist/research.d.ts +9 -0
  84. package/dist/research.d.ts.map +1 -0
  85. package/dist/research.js +335 -0
  86. package/dist/research.js.map +1 -0
  87. package/dist/security.d.ts +3 -0
  88. package/dist/security.d.ts.map +1 -0
  89. package/dist/security.js +106 -0
  90. package/dist/security.js.map +1 -0
  91. package/dist/semantic-config.d.ts +9 -0
  92. package/dist/semantic-config.d.ts.map +1 -0
  93. package/dist/semantic-config.js +35 -0
  94. package/dist/semantic-config.js.map +1 -0
  95. package/dist/setup.d.ts +32 -0
  96. package/dist/setup.d.ts.map +1 -0
  97. package/dist/setup.js +74 -0
  98. package/dist/setup.js.map +1 -0
  99. package/dist/skill.d.ts +66 -0
  100. package/dist/skill.d.ts.map +1 -0
  101. package/dist/skill.js +652 -0
  102. package/dist/skill.js.map +1 -0
  103. package/dist/sources.d.ts +16 -0
  104. package/dist/sources.d.ts.map +1 -0
  105. package/dist/sources.js +71 -0
  106. package/dist/sources.js.map +1 -0
  107. package/dist/store.d.ts +13 -0
  108. package/dist/store.d.ts.map +1 -0
  109. package/dist/store.js +94 -0
  110. package/dist/store.js.map +1 -0
  111. package/dist/text.d.ts +3 -0
  112. package/dist/text.d.ts.map +1 -0
  113. package/dist/text.js +10 -0
  114. package/dist/text.js.map +1 -0
  115. package/dist/types.d.ts +322 -0
  116. package/dist/types.d.ts.map +1 -0
  117. package/dist/types.js +2 -0
  118. package/dist/types.js.map +1 -0
  119. package/dist/version.d.ts +2 -0
  120. package/dist/version.d.ts.map +1 -0
  121. package/dist/version.js +2 -0
  122. package/dist/version.js.map +1 -0
  123. package/examples/library-api-demo/README.md +42 -0
  124. package/examples/library-api-demo/run.mjs +61 -0
  125. package/examples/sovereign-rag-demo/.ragmir/config.json +22 -0
  126. package/examples/sovereign-rag-demo/.ragmir/sources.txt +2 -0
  127. package/examples/sovereign-rag-demo/README.md +95 -0
  128. package/examples/sovereign-rag-demo/golden-queries.json +29 -0
  129. package/examples/sovereign-rag-demo/raw/dataset-inventory.csv +5 -0
  130. package/examples/sovereign-rag-demo/raw/facility-scan.heic +3 -0
  131. package/examples/sovereign-rag-demo/raw/incident-timeline.jsonl +4 -0
  132. package/examples/sovereign-rag-demo/raw/operations-brief.md +16 -0
  133. package/examples/sovereign-rag-demo/raw/review-notes.evidence +11 -0
  134. package/examples/sovereign-rag-demo/raw/security-policy.yaml +14 -0
  135. package/package.json +87 -0
  136. package/skills/ragmir/SKILL.md +366 -0
  137. package/skills/ragmir-audio-summary/SKILL.md +150 -0
  138. package/skills/ragmir-audio-summary/forge-voice.sh +150 -0
  139. package/skills/ragmir-audio-summary/split-lines.py +13 -0
  140. package/skills/ragmir-audio-summary/xtts-voice.py +46 -0
  141. package/skills/ragmir-legal-dossier/SKILL.md +143 -0
  142. package/skills/ragmir-markdown-report/SKILL.md +110 -0
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ // Local library smoke for @jcode.labs/ragmir.
3
+ //
4
+ // This exercises the public TypeScript API (ingest -> search -> ask -> audit) the
5
+ // exact way an external consumer would `import` it, but Node self-referencing
6
+ // resolves "@jcode.labs/ragmir" to THIS repo's local build (packages/ragmir-core/dist),
7
+ // never the npm-published version. That is the point of the demo: while developing
8
+ // core you can validate the library surface end to end against your own changes,
9
+ // without `npx` silently pulling a released package.
10
+ //
11
+ // Run it from the repository root with `pnpm example`.
12
+
13
+ import path from "node:path"
14
+ import { fileURLToPath } from "node:url"
15
+
16
+ import { ask, audit, ingest, search } from "@jcode.labs/ragmir"
17
+
18
+ const here = path.dirname(fileURLToPath(import.meta.url))
19
+
20
+ // Reuse the committed synthetic corpus so the demo needs no private documents and
21
+ // writes only to the sibling example's gitignored .ragmir/storage.
22
+ const corpus = path.resolve(here, "..", "sovereign-rag-demo")
23
+
24
+ function heading(title) {
25
+ console.log(`\n=== ${title} ===`)
26
+ }
27
+
28
+ async function main() {
29
+ console.log("Running @jcode.labs/ragmir from the local build against the synthetic corpus.")
30
+ console.log(`corpus: ${corpus}`)
31
+
32
+ heading("ingest")
33
+ const ingested = await ingest({ cwd: corpus, rebuild: true })
34
+ console.log(
35
+ `indexed ${ingested.indexedFiles}/${ingested.supportedFiles} supported files, ` +
36
+ `${ingested.chunks} chunks, ${ingested.redactions} redactions`,
37
+ )
38
+
39
+ heading('search "offline retrieval approval"')
40
+ const passages = await search("offline retrieval approval", { cwd: corpus, topK: 3 })
41
+ for (const passage of passages) {
42
+ console.log(`- ${passage.relativePath}#${passage.chunkIndex} (distance ${passage.distance ?? "n/a"})`)
43
+ }
44
+
45
+ heading('ask "What evidence supports offline operation?"')
46
+ const answer = await ask("What evidence supports offline operation?", { cwd: corpus, topK: 3 })
47
+ console.log(`${answer.sources.length} cited sources`)
48
+ console.log(answer.answer)
49
+
50
+ heading("audit")
51
+ const report = await audit(corpus)
52
+ console.log(
53
+ `${report.supportedFiles.length} supported, ${report.skippedFiles.length} skipped, ` +
54
+ `${report.totalChunks} chunks indexed`,
55
+ )
56
+ }
57
+
58
+ main().catch((error) => {
59
+ console.error(error)
60
+ process.exitCode = 1
61
+ })
@@ -0,0 +1,22 @@
1
+ {
2
+ "rawDir": "raw",
3
+ "storageDir": ".ragmir/storage",
4
+ "sourcesFile": ".ragmir/sources.txt",
5
+ "accessLogPath": ".ragmir/access.log",
6
+ "embeddingModelPath": ".ragmir/models",
7
+ "tableName": "chunks",
8
+ "embeddingProvider": "local-hash",
9
+ "embeddingModel": "mixedbread-ai/mxbai-embed-xsmall-v1",
10
+ "transformersAllowRemoteModels": false,
11
+ "redaction": {
12
+ "enabled": true,
13
+ "builtIn": true,
14
+ "patterns": []
15
+ },
16
+ "accessLog": true,
17
+ "mcpMaxTopK": 10,
18
+ "topK": 5,
19
+ "chunkSize": 900,
20
+ "chunkOverlap": 120,
21
+ "includeExtensions": [".evidence"]
22
+ }
@@ -0,0 +1,2 @@
1
+ # Optional extra source paths, one per line.
2
+ # This demo keeps all indexed files under ./raw.
@@ -0,0 +1,95 @@
1
+ # Sovereign RAG Demo
2
+
3
+ Synthetic test workspace for Ragmir. It is intentionally safe to commit: every document is fictional,
4
+ generic, and designed only to exercise local ingestion, retrieval, redaction, custom extensions, and
5
+ security-audit flows.
6
+
7
+ This folder must never contain real-world sensitive, regulated, or production documents.
8
+
9
+ ## What It Covers
10
+
11
+ - Markdown operational briefs.
12
+ - CSV dataset inventories.
13
+ - JSONL incident timelines.
14
+ - YAML policy metadata.
15
+ - A custom `.evidence` text extension enabled through `.ragmir/config.json`.
16
+ - Unsupported/skipped-file reporting with recommendations through `audit --unsupported`.
17
+
18
+ ## Run From This Repository Checkout
19
+
20
+ Build Ragmir once from the repository root:
21
+
22
+ ```bash
23
+ pnpm build
24
+ ```
25
+
26
+ Then run the CLI from this folder:
27
+
28
+ ```bash
29
+ cd packages/ragmir-core/examples/sovereign-rag-demo
30
+ node ../../dist/cli.js security-audit
31
+ node ../../dist/cli.js ingest
32
+ node ../../dist/cli.js search "offline retrieval approval"
33
+ node ../../dist/cli.js search "dataset residency"
34
+ node ../../dist/cli.js ask "What evidence supports offline operation?"
35
+ node ../../dist/cli.js evaluate --golden golden-queries.json
36
+ node ../../dist/cli.js evaluate --golden golden-queries.json --fail-under 1
37
+ node ../../dist/cli.js audit
38
+ node ../../dist/cli.js audit --unsupported
39
+ node ../../dist/cli.js status
40
+ ```
41
+
42
+ This example uses `embeddingProvider: "local-hash"`, so it does not require a model runtime.
43
+ Retrieval is lexical/hash-based rather than model-semantic.
44
+
45
+ ## Useful Test Queries
46
+
47
+ - `offline retrieval approval`
48
+ - `dataset residency`
49
+ - `incident containment evidence`
50
+ - `who owns the usage review`
51
+ - `what documents support sovereign deployment`
52
+
53
+ ## Agent Report Prompt
54
+
55
+ After running `ragmir setup` in a real project, an MCP-compatible agent can use the generated
56
+ `.ragmir/mcp.json`. For this synthetic demo, ask an agent:
57
+
58
+ ```plain text
59
+ Use Ragmir to inspect the local knowledge base, search for "offline retrieval approval", and write a
60
+ cited Markdown report under .ragmir/reports/demo-sovereign-rag.md. Mention any unsupported or stale
61
+ files reported by the audit.
62
+ ```
63
+
64
+ ## Switch To Transformers Semantic Mode
65
+
66
+ To compare no-model retrieval with semantic local retrieval, change `.ragmir/config.json`:
67
+
68
+ ```json
69
+ {
70
+ "embeddingProvider": "transformers",
71
+ "embeddingModel": "mixedbread-ai/mxbai-embed-xsmall-v1",
72
+ "embeddingModelPath": ".ragmir/models",
73
+ "transformersAllowRemoteModels": false
74
+ }
75
+ ```
76
+
77
+ Preload the model files under `.ragmir/models` for offline work, then rebuild the index:
78
+
79
+ ```bash
80
+ node ../../dist/cli.js ingest
81
+ node ../../dist/cli.js ask "What documents support sovereign deployment?"
82
+ node ../../dist/cli.js evaluate --golden golden-queries.json --json
83
+ node ../../dist/cli.js evaluate --golden golden-queries.json --fail-under 0.8 --json
84
+ ```
85
+
86
+ ## Generated State
87
+
88
+ Generated state stays local and ignored:
89
+
90
+ ```plain text
91
+ .ragmir/
92
+ ```
93
+
94
+ Do not replace these synthetic documents with real confidential files inside the Ragmir package
95
+ repository.
@@ -0,0 +1,29 @@
1
+ {
2
+ "topK": 3,
3
+ "queries": [
4
+ {
5
+ "id": "dataset-rejection",
6
+ "query": "Which dataset was rejected for confidential tests?",
7
+ "expectedPaths": ["raw/dataset-inventory.csv"]
8
+ },
9
+ {
10
+ "id": "offline-tts",
11
+ "query": "What proves offline text-to-speech is required?",
12
+ "expectedPaths": ["raw/incident-timeline.jsonl", "raw/review-notes.evidence"]
13
+ },
14
+ {
15
+ "id": "usage-review-owner",
16
+ "query": "Who owns the usage review?",
17
+ "expectedPaths": [
18
+ "raw/operations-brief.md",
19
+ "raw/security-policy.yaml",
20
+ "raw/review-notes.evidence"
21
+ ]
22
+ },
23
+ {
24
+ "id": "model-loading-disabled",
25
+ "query": "Which document says remote model loading is disabled?",
26
+ "expectedPaths": ["raw/incident-timeline.jsonl", "raw/security-policy.yaml"]
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,5 @@
1
+ dataset,source_type,data_residency,network_access,review_status
2
+ Example Notes,markdown notes,local only,none,approved
3
+ Example Model Card,model metadata,local repository,none,approved
4
+ Example Audio Draft,generated summary,local only,none,approved with offline TTS
5
+ Example Remote Transcript,transcription sample,remote processing,internet,rejected for confidential tests
@@ -0,0 +1,3 @@
1
+ Synthetic placeholder for an unsupported scanned document format.
2
+
3
+ Convert scans to OCR text or PDF before expecting Ragmir to index their content.
@@ -0,0 +1,4 @@
1
+ {"date":"2026-02-12","event":"synthetic dataset imported","owner":"example knowledge team","impact":"none","evidence":"fictional files only"}
2
+ {"date":"2026-02-13","event":"remote model loading disabled","owner":"example review team","impact":"offline policy enforced","evidence":"transformersAllowRemoteModels false"}
3
+ {"date":"2026-02-14","event":"offline retrieval approval completed","owner":"example platform team","impact":"local cited retrieval allowed","evidence":"local-hash provider"}
4
+ {"date":"2026-02-15","event":"audio summary test requested","owner":"example operations role","impact":"offline TTS required","evidence":"ragmir-audio-summary skill"}
@@ -0,0 +1,16 @@
1
+ # Offline Analytics Brief
2
+
3
+ Example Workspace is a synthetic local knowledge-base deployment used to test Ragmir.
4
+
5
+ The demo goal is to let a test team summarize fictional operational notes without shipping source
6
+ files to a hosted RAG service. The approved runtime is a local Linux workstation with an encrypted
7
+ disk, local retrieval, and no telemetry.
8
+
9
+ The initial approval covers three workflows:
10
+
11
+ - summarize daily operational briefs;
12
+ - compare dataset handling notes against internal policy;
13
+ - prepare audio briefings only with an offline text-to-speech engine.
14
+
15
+ The usage review is owned by the Example Review Team. Any remote model endpoint requires a written
16
+ exception before use.
@@ -0,0 +1,11 @@
1
+ Evidence memo for the synthetic usage review.
2
+
3
+ The Example Review Team approved local-only retrieval because the source documents remain under the
4
+ repository raw folder and the generated vector store remains under .ragmir/storage.
5
+
6
+ The review rejected remote transcription and online text-to-speech for fictional confidential test
7
+ datasets. The approved audio path is a generated briefing under .ragmir/audio created with an offline
8
+ engine.
9
+
10
+ The test is considered complete when Ragmir can retrieve the offline retrieval approval, dataset
11
+ residency requirements, and incident containment evidence from separate file formats.
@@ -0,0 +1,14 @@
1
+ classification: synthetic
2
+ purpose: local-rag-test
3
+ controls:
4
+ remote_model_loading: disabled
5
+ storage: encrypted-volume-recommended
6
+ telemetry: none
7
+ access_log: metadata-only
8
+ mcp:
9
+ destructive_tools: false
10
+ max_top_k: 10
11
+ review:
12
+ owner: Example Review Team
13
+ required_before_remote_model_loading: true
14
+ required_before_online_tts: true
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@jcode.labs/ragmir",
3
+ "version": "2.0.0",
4
+ "description": "Ragmir Core: open-source sovereign local RAG for confidential datasets and AI agents.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Jean-Baptiste Thery",
9
+ "url": "https://github.com/jb-thery"
10
+ },
11
+ "keywords": [
12
+ "jcode",
13
+ "ragmir",
14
+ "open-source",
15
+ "rag",
16
+ "sovereign-rag",
17
+ "knowledge-base",
18
+ "confidential-data",
19
+ "private-ai",
20
+ "local-first",
21
+ "mcp",
22
+ "transformers",
23
+ "semantic-search",
24
+ "lancedb"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/jcode-works/jcode-ragmir.git",
29
+ "directory": "packages/ragmir-core"
30
+ },
31
+ "homepage": "https://github.com/jcode-works/jcode-ragmir#readme",
32
+ "bugs": {
33
+ "url": "https://github.com/jcode-works/jcode-ragmir/issues"
34
+ },
35
+ "engines": {
36
+ "node": ">=20"
37
+ },
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.js"
42
+ }
43
+ },
44
+ "bin": {
45
+ "ragmir": "dist/cli.js",
46
+ "kb": "dist/cli.js"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "skills",
51
+ "examples",
52
+ "README.md"
53
+ ],
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "dependencies": {
58
+ "@huggingface/transformers": "^4.2.0",
59
+ "@lancedb/lancedb": "^0.30.0",
60
+ "@modelcontextprotocol/sdk": "^1.29.0",
61
+ "commander": "^14.0.2",
62
+ "fast-glob": "^3.3.3",
63
+ "fflate": "^0.8.3",
64
+ "html-to-text": "^9.0.5",
65
+ "mammoth": "^1.12.0",
66
+ "picocolors": "^1.1.1",
67
+ "read-excel-file": "^9.2.0",
68
+ "unpdf": "^1.4.0",
69
+ "yaml": "^2.9.0",
70
+ "zod": "^4.1.13",
71
+ "@jcode.labs/ragmir-tts": "2.0.0"
72
+ },
73
+ "devDependencies": {
74
+ "@types/html-to-text": "^9.0.4",
75
+ "@types/node": "^24.10.1",
76
+ "publint": "^0.3.21",
77
+ "typescript": "^5.9.3",
78
+ "vitest": "^4.0.15"
79
+ },
80
+ "scripts": {
81
+ "build": "tsc -p tsconfig.json",
82
+ "check": "tsc -p tsconfig.json --noEmit",
83
+ "mcp:smoke": "pnpm build && node scripts/mcp-smoke.mjs",
84
+ "package:check": "publint",
85
+ "test": "vitest run"
86
+ }
87
+ }