@jcode.labs/ragmir 6.5.2 → 6.7.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.
package/README.md CHANGED
@@ -67,16 +67,24 @@ covers pnpm and guided setup.
67
67
 
68
68
  ## Connect your agent
69
69
 
70
- `rgr setup --agents claude,codex` prepares a project MCP server and a retrieval skill. The server
71
- exposes four read-only tools: `ragmir_search` (one question or up to five related ones sharing a
72
- budget, with named scopes), `ragmir_expand`, `ragmir_status`, and `ragmir_audit`. Passages
73
- already returned in a session come back as one-line stubs. Its instructions name the base it
74
- serves, and it warns or refuses agents working in unrelated projects. See
75
- [agent integration](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md)
76
- for connection steps and local or self-hosted model examples. Python agents built with the MCP
77
- SDK, LangChain, or LlamaIndex use the same server
78
- ([Python guide](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md)), and
79
- `ghcr.io/jcode-works/ragmir` runs it without Node.js.
70
+ [![Claude Code](https://img.shields.io/badge/Claude_Code-D97757?style=flat-square&logo=claude&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents) [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-111111?style=flat-square)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents) [![Cursor](https://img.shields.io/badge/Cursor-111111?style=flat-square&logo=cursor&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents) [![Gemini CLI](https://img.shields.io/badge/Gemini_CLI-8E75B2?style=flat-square&logo=googlegemini&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents) [![Qwen Code](https://img.shields.io/badge/Qwen_Code-6950EF?style=flat-square&logo=qwen&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents) [![LangChain.js](https://img.shields.io/badge/LangChain.js-1C3C3C?style=flat-square&logo=langchain&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/api-reference.md#langchainjs-retriever) [![LangChain](https://img.shields.io/badge/LangChain-1C3C3C?style=flat-square&logo=langchain&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md#langchain) [![LlamaIndex](https://img.shields.io/badge/LlamaIndex-6D28D9?style=flat-square)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md#llamaindex) [![MCP](https://img.shields.io/badge/MCP-111111?style=flat-square&logo=modelcontextprotocol&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#connect-an-agent-through-mcp) [![Python](https://img.shields.io/badge/Python-3776AB?style=flat-square&logo=python&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md) [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/api-reference.md) [![Ollama](https://img.shields.io/badge/Ollama-111111?style=flat-square&logo=ollama&logoColor=white)](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#confidential-chat-local-model-example)
71
+
72
+ Install Ragmir as a plugin for Claude Code (`/plugin install ragmir --marketplace
73
+ jcode-works/jcode-ragmir`), OpenAI Codex, or Cursor, or as an extension for Gemini CLI and Qwen
74
+ Code; the [plugin
75
+ guide](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md#plugins-and-extensions-for-coding-agents)
76
+ lists every install command. Without a plugin, `rgr setup --agents claude,codex` prepares a project
77
+ MCP server and a retrieval skill. The server exposes four read-only tools: `ragmir_search` (one
78
+ question or up to five related ones sharing a budget, with named scopes), `ragmir_expand`,
79
+ `ragmir_status`, and `ragmir_audit`. Passages already returned in a session come back as one-line
80
+ stubs. Its instructions name the base it serves, and it warns or refuses agents working in unrelated
81
+ projects. See [agent
82
+ integration](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/agent-integration.md) for
83
+ connection steps and local or self-hosted model examples. Python agents built with the MCP SDK,
84
+ LangChain, or LlamaIndex use the same server ([Python
85
+ guide](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md)), and
86
+ `ghcr.io/jcode-works/ragmir` runs it without Node.js. LangChain.js chains use `RagmirRetriever` from
87
+ `@jcode.labs/ragmir/langchain` with the optional peer `@langchain/core`.
80
88
 
81
89
  ## TypeScript API
82
90
 
@@ -0,0 +1,60 @@
1
+ import { Document } from "@langchain/core/documents";
2
+ import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
3
+ import { RagmirClient } from "./client.js";
4
+ import type { SearchOptions, SearchResult, SourceStatus } from "./types.js";
5
+ /** Search settings the retriever forwards to `RagmirClient.search` on every query. */
6
+ export type RagmirRetrieverSearchOptions = Omit<SearchOptions, "cwd" | "explain" | "signal">;
7
+ export interface RagmirRetrieverInput extends BaseRetrieverInput, RagmirRetrieverSearchOptions {
8
+ /**
9
+ * Client to query. The retriever never closes a client it did not open, so one client can serve
10
+ * several retrievers and the rest of the application.
11
+ */
12
+ client?: RagmirClient;
13
+ /**
14
+ * Project root, or a directory inside it, used to open a client on the first query when `client`
15
+ * is not given. Defaults to the current working directory. Call `close()` during shutdown.
16
+ */
17
+ projectRoot?: string;
18
+ }
19
+ /** Citation fields attached to every LangChain document the retriever returns. */
20
+ export interface RagmirDocumentMetadata extends Record<string, unknown> {
21
+ /** Project-relative path of the cited file. */
22
+ source: string;
23
+ /** Exact citation, such as `docs/runbook.md:L12-L18` or a PDF page, slide, or cell range. */
24
+ citation: string;
25
+ chunkIndex: number;
26
+ /** Heading or structural path of the passage inside its file. */
27
+ contextPath: string;
28
+ lineStart: number | null;
29
+ lineEnd: number | null;
30
+ pageStart: number | null;
31
+ pageEnd: number | null;
32
+ /** Vector distance when a semantic model scored the passage, otherwise null. */
33
+ distance: number | null;
34
+ /** The passage holds few of the question's distinctive words: verify it before relying on it. */
35
+ weakEvidence: boolean;
36
+ /** Set when the cited file changed or disappeared since it was indexed. */
37
+ sourceStatus?: SourceStatus;
38
+ knowledgeBaseId?: string;
39
+ }
40
+ /**
41
+ * LangChain.js retriever backed by a local Ragmir base. Each document carries its citation in
42
+ * `metadata`, and a query the indexed sources cannot answer returns an empty list instead of the
43
+ * least unrelated passages.
44
+ */
45
+ export declare class RagmirRetriever extends BaseRetriever<RagmirDocumentMetadata> {
46
+ static lc_name(): string;
47
+ lc_namespace: string[];
48
+ private readonly sharedClient;
49
+ private readonly projectRoot;
50
+ private readonly searchOptions;
51
+ private ownedClient;
52
+ constructor(input?: RagmirRetrieverInput);
53
+ _getRelevantDocuments(query: string): Promise<Document<RagmirDocumentMetadata>[]>;
54
+ /** Closes the client this retriever opened. A client passed in `client` stays open. */
55
+ close(): Promise<void>;
56
+ private client;
57
+ }
58
+ /** Converts one Ragmir search result into a LangChain document that keeps its citation. */
59
+ export declare function ragmirResultToDocument(result: SearchResult): Document<RagmirDocumentMetadata>;
60
+ //# sourceMappingURL=langchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../src/langchain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE3E,sFAAsF;AACtF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAA;AAE5F,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB,EAAE,4BAA4B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O,CAAC,MAAM;CAiBf;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAC,sBAAsB,CAAC,CAwB7F"}
@@ -0,0 +1,86 @@
1
+ import { Document } from "@langchain/core/documents";
2
+ import { BaseRetriever } from "@langchain/core/retrievers";
3
+ import { RagmirClient } from "./client.js";
4
+ /**
5
+ * LangChain.js retriever backed by a local Ragmir base. Each document carries its citation in
6
+ * `metadata`, and a query the indexed sources cannot answer returns an empty list instead of the
7
+ * least unrelated passages.
8
+ */
9
+ export class RagmirRetriever extends BaseRetriever {
10
+ static lc_name() {
11
+ return "RagmirRetriever";
12
+ }
13
+ lc_namespace = ["ragmir", "retrievers"];
14
+ sharedClient;
15
+ projectRoot;
16
+ searchOptions;
17
+ ownedClient;
18
+ constructor(input = {}) {
19
+ const { client, projectRoot, callbacks, tags, metadata, verbose, ...searchOptions } = input;
20
+ super({
21
+ ...(callbacks === undefined ? {} : { callbacks }),
22
+ ...(tags === undefined ? {} : { tags }),
23
+ ...(metadata === undefined ? {} : { metadata }),
24
+ ...(verbose === undefined ? {} : { verbose }),
25
+ });
26
+ this.sharedClient = client;
27
+ this.projectRoot = projectRoot;
28
+ this.searchOptions = searchOptions;
29
+ }
30
+ async _getRelevantDocuments(query) {
31
+ const client = await this.client();
32
+ const results = await client.search(query, this.searchOptions);
33
+ return results.map(ragmirResultToDocument);
34
+ }
35
+ /** Closes the client this retriever opened. A client passed in `client` stays open. */
36
+ async close() {
37
+ const owned = this.ownedClient;
38
+ if (!owned) {
39
+ return;
40
+ }
41
+ const client = await owned.catch(() => undefined);
42
+ await client?.close();
43
+ }
44
+ client() {
45
+ if (this.sharedClient) {
46
+ return Promise.resolve(this.sharedClient);
47
+ }
48
+ if (!this.ownedClient) {
49
+ const opening = RagmirClient.create(this.projectRoot === undefined ? {} : { cwd: this.projectRoot });
50
+ this.ownedClient = opening;
51
+ opening.catch(() => {
52
+ if (this.ownedClient === opening) {
53
+ this.ownedClient = undefined;
54
+ }
55
+ });
56
+ }
57
+ return this.ownedClient;
58
+ }
59
+ }
60
+ /** Converts one Ragmir search result into a LangChain document that keeps its citation. */
61
+ export function ragmirResultToDocument(result) {
62
+ const metadata = {
63
+ source: result.relativePath,
64
+ citation: result.citation,
65
+ chunkIndex: result.chunkIndex,
66
+ contextPath: result.contextPath,
67
+ lineStart: result.lineStart,
68
+ lineEnd: result.lineEnd,
69
+ pageStart: result.pageStart,
70
+ pageEnd: result.pageEnd,
71
+ distance: result.distance,
72
+ weakEvidence: result.weakEvidence === true,
73
+ };
74
+ if (result.sourceStatus) {
75
+ metadata.sourceStatus = result.sourceStatus;
76
+ }
77
+ if (result.evidence?.knowledgeBaseId) {
78
+ metadata.knowledgeBaseId = result.evidence.knowledgeBaseId;
79
+ }
80
+ return new Document({
81
+ pageContent: result.text,
82
+ metadata,
83
+ id: result.evidence?.id ?? result.citation,
84
+ });
85
+ }
86
+ //# sourceMappingURL=langchain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.js","sourceRoot":"","sources":["../src/langchain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAyC1C;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAqC;IACxE,MAAM,CAAC,OAAO;QACZ,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IAED,YAAY,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;IAEtB,YAAY,CAA0B;IACtC,WAAW,CAAoB;IAC/B,aAAa,CAA8B;IACpD,WAAW,CAAmC;IAEtD,YAAY,KAAK,GAAyB,EAAE;QAC1C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAA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Q,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAA;IAC5D,CAAC;IACD,OAAO,IAAI,QAAQ,CAAyB;QAC1C,WAAW,EAAE,MAAM,CAAC,IAAI;QACxB,QAAQ;QACR,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,MAAM,CAAC,QAAQ;KAC3C,CAAC,CAAA;AACJ,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "6.5.2";
1
+ export declare const VERSION = "6.7.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = "6.5.2";
1
+ export const VERSION = "6.7.0";
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jcode.labs/ragmir",
3
3
  "mcpName": "io.github.jcode-works/ragmir",
4
- "version": "6.5.2",
4
+ "version": "6.7.0",
5
5
  "description": "Open-source retrieval for agentic RAG: document search with exact citations on your laptop or servers, with OCR, CLI, MCP, and TypeScript.",
6
6
  "type": "module",
7
7
  "license": "AGPL-3.0-only",
@@ -49,6 +49,10 @@
49
49
  ".": {
50
50
  "types": "./dist/index.d.ts",
51
51
  "import": "./dist/index.js"
52
+ },
53
+ "./langchain": {
54
+ "types": "./dist/langchain.d.ts",
55
+ "import": "./dist/langchain.js"
52
56
  }
53
57
  },
54
58
  "bin": {
@@ -82,11 +86,15 @@
82
86
  "zod": "^4.6.7"
83
87
  },
84
88
  "peerDependencies": {
85
- "@huggingface/transformers": "^4.3.0"
89
+ "@huggingface/transformers": "^4.3.0",
90
+ "@langchain/core": "^1.0.0"
86
91
  },
87
92
  "peerDependenciesMeta": {
88
93
  "@huggingface/transformers": {
89
94
  "optional": true
95
+ },
96
+ "@langchain/core": {
97
+ "optional": true
90
98
  }
91
99
  },
92
100
  "devDependencies": {