raggrep 0.12.1 → 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 +39 -14
- package/dist/cli/main.js.map +3 -3
- package/package.json +1 -1
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.
|
|
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,6 +14778,34 @@ 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
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.",
|
|
@@ -14808,6 +14836,13 @@ export default tool({
|
|
|
14808
14836
|
),
|
|
14809
14837
|
},
|
|
14810
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
|
+
|
|
14811
14846
|
const cmdArgs = [args.query];
|
|
14812
14847
|
|
|
14813
14848
|
if (args.top !== undefined) {
|
|
@@ -14825,7 +14860,7 @@ export default tool({
|
|
|
14825
14860
|
}
|
|
14826
14861
|
}
|
|
14827
14862
|
|
|
14828
|
-
const proc = Bun.spawn(['raggrep', 'query', ...cmdArgs], { stdout: 'pipe' });
|
|
14863
|
+
const proc = Bun.spawn([executor, 'raggrep', 'query', ...cmdArgs], { stdout: 'pipe' });
|
|
14829
14864
|
const result = await new Response(proc.stdout).text();
|
|
14830
14865
|
return result.trim();
|
|
14831
14866
|
},
|
|
@@ -14833,19 +14868,9 @@ export default tool({
|
|
|
14833
14868
|
`;
|
|
14834
14869
|
try {
|
|
14835
14870
|
await fs10.mkdir(toolDir, { recursive: true });
|
|
14836
|
-
let action = "Installed";
|
|
14837
|
-
const backupPath = toolPath + ".backup";
|
|
14838
|
-
try {
|
|
14839
|
-
await fs10.access(toolPath);
|
|
14840
|
-
await fs10.copyFile(toolPath, backupPath);
|
|
14841
|
-
action = "Updated";
|
|
14842
|
-
} catch {}
|
|
14843
14871
|
await fs10.writeFile(toolPath, toolContent, "utf-8");
|
|
14844
|
-
console.log(
|
|
14872
|
+
console.log(`Installed raggrep tool for opencode.`);
|
|
14845
14873
|
console.log(` Location: ${toolPath}`);
|
|
14846
|
-
if (action === "Updated") {
|
|
14847
|
-
console.log(` Backup: ${backupPath}`);
|
|
14848
|
-
}
|
|
14849
14874
|
console.log(`
|
|
14850
14875
|
The raggrep tool is now available in opencode.`);
|
|
14851
14876
|
} catch (error) {
|
|
@@ -14894,4 +14919,4 @@ Run 'raggrep <command> --help' for more information.
|
|
|
14894
14919
|
}
|
|
14895
14920
|
main();
|
|
14896
14921
|
|
|
14897
|
-
//# debugId=
|
|
14922
|
+
//# debugId=049DF49BCF57EE1664756E2164756E21
|