@winci/local-rag 0.2.5 → 0.2.6

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/.mcp.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "local-rag": {
4
+ "command": "bunx",
5
+ "args": ["@winci/local-rag@latest", "serve"]
6
+ }
7
+ }
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winci/local-rag",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Semantic search for your codebase — local-first RAG MCP server with hybrid search, AST-aware chunking, and usage analytics",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -2,11 +2,12 @@ import { resolve } from "path";
2
2
  import { RagDB } from "../../db";
3
3
  import { loadConfig } from "../../config";
4
4
  import { indexDirectory } from "../../indexing/indexer";
5
- import { runSetup, mcpConfigSnippet, detectAgentHints, confirm } from "../setup";
5
+ import { runSetup, confirm } from "../setup";
6
6
  import { cliProgress } from "../progress";
7
7
 
8
8
  export async function initCommand(args: string[], getFlag: (flag: string) => string | undefined) {
9
9
  const dir = resolve(args[1] && !args[1].startsWith("--") ? args[1] : ".");
10
+ const autoYes = args.includes("--yes") || args.includes("-y");
10
11
  const { actions } = await runSetup(dir);
11
12
  if (actions.length === 0) {
12
13
  console.log("Already set up — nothing to do.");
@@ -14,14 +15,8 @@ export async function initCommand(args: string[], getFlag: (flag: string) => str
14
15
  for (const action of actions) console.log(action);
15
16
  }
16
17
 
17
- console.log("\nAdd this to your agent's MCP config (mcpServers):\n");
18
- console.log(mcpConfigSnippet(dir));
19
- const hints = detectAgentHints(dir);
20
18
  console.log();
21
- for (const hint of hints) console.log(` ${hint}`);
22
-
23
- console.log();
24
- const shouldIndex = await confirm("Index project now? [Y/n] ");
19
+ const shouldIndex = autoYes || await confirm("Index project now? [Y/n] ");
25
20
  if (shouldIndex) {
26
21
  const db = new RagDB(dir);
27
22
  const config = await loadConfig(dir);
package/src/cli/setup.ts CHANGED
@@ -154,6 +154,79 @@ export function mcpConfigSnippet(projectDir: string): string {
154
154
  }, null, 2);
155
155
  }
156
156
 
157
+ function mcpServerEntry(projectDir: string) {
158
+ return {
159
+ command: "bunx",
160
+ args: ["@winci/local-rag@latest"],
161
+ env: { RAG_PROJECT_DIR: resolve(projectDir) },
162
+ };
163
+ }
164
+
165
+ export async function ensureMcpJson(projectDir: string): Promise<string[]> {
166
+ const actions: string[] = [];
167
+ const entry = mcpServerEntry(projectDir);
168
+
169
+ // Claude Code — .mcp.json
170
+ const claudeMcpPath = join(projectDir, ".mcp.json");
171
+ if (existsSync(claudeMcpPath)) {
172
+ const raw = JSON.parse(await readFile(claudeMcpPath, "utf-8"));
173
+ if (!raw.mcpServers?.["local-rag"]) {
174
+ raw.mcpServers = raw.mcpServers || {};
175
+ raw.mcpServers["local-rag"] = entry;
176
+ await writeFile(claudeMcpPath, JSON.stringify(raw, null, 2) + "\n");
177
+ actions.push("Added local-rag to .mcp.json");
178
+ }
179
+ } else {
180
+ await writeFile(
181
+ claudeMcpPath,
182
+ JSON.stringify({ mcpServers: { "local-rag": entry } }, null, 2) + "\n"
183
+ );
184
+ actions.push("Created .mcp.json with local-rag");
185
+ }
186
+
187
+ // Cursor — .cursor/mcp.json
188
+ if (existsSync(join(projectDir, ".cursor"))) {
189
+ const cursorMcpPath = join(projectDir, ".cursor", "mcp.json");
190
+ if (existsSync(cursorMcpPath)) {
191
+ const raw = JSON.parse(await readFile(cursorMcpPath, "utf-8"));
192
+ if (!raw.mcpServers?.["local-rag"]) {
193
+ raw.mcpServers = raw.mcpServers || {};
194
+ raw.mcpServers["local-rag"] = entry;
195
+ await writeFile(cursorMcpPath, JSON.stringify(raw, null, 2) + "\n");
196
+ actions.push("Added local-rag to .cursor/mcp.json");
197
+ }
198
+ } else {
199
+ await writeFile(
200
+ cursorMcpPath,
201
+ JSON.stringify({ mcpServers: { "local-rag": entry } }, null, 2) + "\n"
202
+ );
203
+ actions.push("Created .cursor/mcp.json with local-rag");
204
+ }
205
+ }
206
+
207
+ // Windsurf — .windsurf/mcp.json
208
+ if (existsSync(join(projectDir, ".windsurf"))) {
209
+ const windsurfMcpPath = join(projectDir, ".windsurf", "mcp.json");
210
+ if (existsSync(windsurfMcpPath)) {
211
+ const raw = JSON.parse(await readFile(windsurfMcpPath, "utf-8"));
212
+ if (!raw.mcpServers?.["local-rag"]) {
213
+ raw.mcpServers = raw.mcpServers || {};
214
+ raw.mcpServers["local-rag"] = entry;
215
+ await writeFile(windsurfMcpPath, JSON.stringify(raw, null, 2) + "\n");
216
+ actions.push("Added local-rag to .windsurf/mcp.json");
217
+ }
218
+ } else {
219
+ await writeFile(
220
+ windsurfMcpPath,
221
+ JSON.stringify({ mcpServers: { "local-rag": entry } }, null, 2) + "\n"
222
+ );
223
+ actions.push("Created .windsurf/mcp.json with local-rag");
224
+ }
225
+ }
226
+
227
+ return actions;
228
+ }
229
+
157
230
  export function detectAgentHints(projectDir: string): string[] {
158
231
  const hints: string[] = [];
159
232
  if (existsSync(join(projectDir, ".mcp.json")))
@@ -186,6 +259,9 @@ export async function runSetup(projectDir: string): Promise<SetupResult> {
186
259
  const instructionActions = await ensureAgentInstructions(projectDir);
187
260
  actions.push(...instructionActions);
188
261
 
262
+ const mcpActions = await ensureMcpJson(projectDir);
263
+ actions.push(...mcpActions);
264
+
189
265
  const gitignoreAction = await ensureGitignore(projectDir);
190
266
  if (gitignoreAction) actions.push(gitignoreAction);
191
267