raggrep 0.12.0 → 0.12.2

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/dist/cli/main.js CHANGED
@@ -14276,7 +14276,7 @@ init_logger();
14276
14276
  // package.json
14277
14277
  var package_default = {
14278
14278
  name: "raggrep",
14279
- version: "0.12.0",
14279
+ version: "0.12.2",
14280
14280
  description: "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
14281
14281
  type: "module",
14282
14282
  main: "./dist/index.js",
@@ -14778,14 +14778,47 @@ Examples:
14778
14778
  const toolPath = path25.join(toolDir, "raggrep.ts");
14779
14779
  const toolContent = `import { tool } from "@opencode-ai/plugin";
14780
14780
 
14781
+ /**
14782
+ * Get the package executor command (pnpx if available, otherwise npx)
14783
+ */
14784
+ async function getExecutor(): Promise<string> {
14785
+ try {
14786
+ // Try to find pnpm first (faster)
14787
+ await Bun.spawn(['pnpm', '--version'], { stdout: 'pipe', stderr: 'pipe' }).exited;
14788
+ return 'pnpx';
14789
+ } catch {
14790
+ // Fall back to npx
14791
+ return 'npx';
14792
+ }
14793
+ }
14794
+
14795
+ /**
14796
+ * Get the installed raggrep version
14797
+ */
14798
+ async function getRagrepVersion(executor: string): Promise<string | null> {
14799
+ try {
14800
+ const proc = Bun.spawn([executor, 'raggrep', '--version'], { stdout: 'pipe', stderr: 'pipe' });
14801
+ const output = await new Response(proc.stdout).text();
14802
+ const match = output.match(/v([\\d.]+)/);
14803
+ return match ? match[1] : null;
14804
+ } catch {
14805
+ return null;
14806
+ }
14807
+ }
14808
+
14781
14809
  export default tool({
14782
14810
  description:
14783
- "Search the codebase using semantic RAG (Retrieval-Augmented Generation). Uses raggrep to find relevant code snippets based on natural language queries. The index is managed automatically - first query creates it, changed files are re-indexed, and unchanged files use cached index.",
14811
+ "Semantic code search powered by RAG - understands INTENT, not just literal text. Parses code using AST to extract functions, classes, and symbols with full context. Finds relevant code even when exact keywords don't match. Superior to grep for exploratory searches like 'authentication logic', 'error handling patterns', or 'configuration loading'.\\n\\n\uD83C\uDFAF USE THIS TOOL FIRST when you need to:\\n• Find WHERE code is located (functions, components, services)\\n• Understand HOW code is structured\\n• Discover RELATED code across multiple files\\n• Get a QUICK overview of a topic\\n\\n❌ DON'T read multiple files manually when you can:\\n raggrep(\\"user authentication\\", { filter: [\\"src/\\"] })\\n\\n✅ INSTEAD of reading files one-by-one, search semantically:\\n • \\"Find the auth middleware\\" vs read: auth.ts, middleware.ts, index.ts...\\n • \\"Where are React components?\\" vs read: App.tsx, components/*, pages/*...\\n • \\"Database connection logic?\\" vs read: db.ts, config.ts, models/*...\\n • \\"Error handling patterns\\" vs read: error.ts, middleware.ts, handlers/*...\\n\\nThis saves ~10x tool calls and provides BETTER context by showing related code across the entire codebase.",
14784
14812
  args: {
14785
14813
  query: tool.schema
14786
14814
  .string()
14787
14815
  .describe(
14788
- "Natural language search query (e.g., 'user authentication', 'handle errors')"
14816
+ "Natural language search query describing what you want to find. Be specific: 'auth middleware that checks JWT', 'React hooks for data fetching', 'database connection pool config'. This is MUCH faster than reading files manually."
14817
+ ),
14818
+ filter: tool.schema
14819
+ .array(tool.schema.string())
14820
+ .describe(
14821
+ "Array of path prefixes or glob patterns to narrow search scope (OR logic). If user mentions a directory, use it. Otherwise infer from context. Common patterns: ['src/auth'], ['*.tsx', 'components/'], ['api/', 'routes/'], ['docs/', '*.md'], ['*.test.ts']. For broad search use ['src/'] or ['**/*']."
14789
14822
  ),
14790
14823
  top: tool.schema
14791
14824
  .number()
@@ -14798,15 +14831,18 @@ export default tool({
14798
14831
  type: tool.schema
14799
14832
  .string()
14800
14833
  .optional()
14801
- .describe("Filter by file extension (e.g., ts, tsx, js)"),
14802
- filter: tool.schema
14803
- .array(tool.schema.string())
14804
- .optional()
14805
14834
  .describe(
14806
- "Filter by path prefix or glob pattern. Multiple filters use OR logic. Examples: 'src/auth', '*.ts', '*.md', 'src/**/*.test.ts'"
14835
+ "Filter by single file extension without dot (e.g., 'ts', 'tsx', 'js', 'md'). Prefer using 'filter' with glob patterns like '*.ts' for more flexibility."
14807
14836
  ),
14808
14837
  },
14809
14838
  async execute(args) {
14839
+ const executor = await getExecutor();
14840
+ const version = await getRagrepVersion(executor);
14841
+
14842
+ if (!version) {
14843
+ return \`Error: raggrep not found. Install it with: \${executor} install -g raggrep\`;
14844
+ }
14845
+
14810
14846
  const cmdArgs = [args.query];
14811
14847
 
14812
14848
  if (args.top !== undefined) {
@@ -14824,26 +14860,17 @@ export default tool({
14824
14860
  }
14825
14861
  }
14826
14862
 
14827
- const result = await Bun.$\`raggrep query \${cmdArgs}\`.text();
14863
+ const proc = Bun.spawn([executor, 'raggrep', 'query', ...cmdArgs], { stdout: 'pipe' });
14864
+ const result = await new Response(proc.stdout).text();
14828
14865
  return result.trim();
14829
14866
  },
14830
14867
  });
14831
14868
  `;
14832
14869
  try {
14833
14870
  await fs10.mkdir(toolDir, { recursive: true });
14834
- let action = "Installed";
14835
- const backupPath = toolPath + ".backup";
14836
- try {
14837
- await fs10.access(toolPath);
14838
- await fs10.copyFile(toolPath, backupPath);
14839
- action = "Updated";
14840
- } catch {}
14841
14871
  await fs10.writeFile(toolPath, toolContent, "utf-8");
14842
- console.log(`${action} raggrep tool for opencode.`);
14872
+ console.log(`Installed raggrep tool for opencode.`);
14843
14873
  console.log(` Location: ${toolPath}`);
14844
- if (action === "Updated") {
14845
- console.log(` Backup: ${backupPath}`);
14846
- }
14847
14874
  console.log(`
14848
14875
  The raggrep tool is now available in opencode.`);
14849
14876
  } catch (error) {
@@ -14892,4 +14919,4 @@ Run 'raggrep <command> --help' for more information.
14892
14919
  }
14893
14920
  main();
14894
14921
 
14895
- //# debugId=E6A5C2A479D4470864756E2164756E21
14922
+ //# debugId=049DF49BCF57EE1664756E2164756E21