grepmax 0.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.
Potentially problematic release.
This version of grepmax might be problematic. Click here for more details.
- package/LICENSE +202 -0
- package/NOTICE +33 -0
- package/README.md +375 -0
- package/dist/commands/claude-code.js +60 -0
- package/dist/commands/codex.js +98 -0
- package/dist/commands/doctor.js +92 -0
- package/dist/commands/droid.js +189 -0
- package/dist/commands/index.js +125 -0
- package/dist/commands/list.js +120 -0
- package/dist/commands/mcp.js +572 -0
- package/dist/commands/opencode.js +199 -0
- package/dist/commands/search.js +539 -0
- package/dist/commands/serve.js +512 -0
- package/dist/commands/setup.js +162 -0
- package/dist/commands/skeleton.js +288 -0
- package/dist/commands/symbols.js +129 -0
- package/dist/commands/trace.js +50 -0
- package/dist/commands/verify.js +174 -0
- package/dist/config.js +120 -0
- package/dist/eval.js +618 -0
- package/dist/index.js +82 -0
- package/dist/lib/core/languages.js +237 -0
- package/dist/lib/graph/graph-builder.js +105 -0
- package/dist/lib/index/chunker.js +663 -0
- package/dist/lib/index/grammar-loader.js +110 -0
- package/dist/lib/index/ignore-patterns.js +63 -0
- package/dist/lib/index/index-config.js +86 -0
- package/dist/lib/index/sync-helpers.js +97 -0
- package/dist/lib/index/syncer.js +396 -0
- package/dist/lib/index/walker.js +164 -0
- package/dist/lib/index/watcher.js +245 -0
- package/dist/lib/output/formatter.js +161 -0
- package/dist/lib/output/json-formatter.js +6 -0
- package/dist/lib/search/intent.js +23 -0
- package/dist/lib/search/searcher.js +475 -0
- package/dist/lib/setup/model-loader.js +107 -0
- package/dist/lib/setup/setup-helpers.js +106 -0
- package/dist/lib/skeleton/body-fields.js +175 -0
- package/dist/lib/skeleton/index.js +24 -0
- package/dist/lib/skeleton/retriever.js +36 -0
- package/dist/lib/skeleton/skeletonizer.js +483 -0
- package/dist/lib/skeleton/summary-formatter.js +90 -0
- package/dist/lib/store/meta-cache.js +143 -0
- package/dist/lib/store/types.js +2 -0
- package/dist/lib/store/vector-db.js +340 -0
- package/dist/lib/utils/cleanup.js +33 -0
- package/dist/lib/utils/exit.js +38 -0
- package/dist/lib/utils/file-utils.js +131 -0
- package/dist/lib/utils/filter-builder.js +17 -0
- package/dist/lib/utils/formatter.js +230 -0
- package/dist/lib/utils/git.js +83 -0
- package/dist/lib/utils/lock.js +157 -0
- package/dist/lib/utils/project-root.js +107 -0
- package/dist/lib/utils/server-registry.js +97 -0
- package/dist/lib/workers/colbert-math.js +107 -0
- package/dist/lib/workers/colbert-tokenizer.js +113 -0
- package/dist/lib/workers/download-worker.js +169 -0
- package/dist/lib/workers/embeddings/colbert.js +213 -0
- package/dist/lib/workers/embeddings/granite.js +180 -0
- package/dist/lib/workers/embeddings/mlx-client.js +144 -0
- package/dist/lib/workers/orchestrator.js +350 -0
- package/dist/lib/workers/pool.js +373 -0
- package/dist/lib/workers/process-child.js +92 -0
- package/dist/lib/workers/worker.js +31 -0
- package/package.json +80 -0
- package/plugins/osgrep/.claude-plugin/plugin.json +20 -0
- package/plugins/osgrep/hooks/start.js +92 -0
- package/plugins/osgrep/hooks/stop.js +3 -0
- package/plugins/osgrep/hooks.json +26 -0
- package/plugins/osgrep/skills/osgrep/SKILL.md +82 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.uninstallOpencode = exports.installOpencode = void 0;
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
const commander_1 = require("commander");
|
|
20
|
+
const TOOL_PATH = node_path_1.default.join(node_os_1.default.homedir(), ".config", "opencode", "tool", "osgrep.ts");
|
|
21
|
+
const PLUGIN_PATH = node_path_1.default.join(node_os_1.default.homedir(), ".config", "opencode", "plugin", "osgrep.ts");
|
|
22
|
+
const CONFIG_PATH = node_path_1.default.join(node_os_1.default.homedir(), ".config", "opencode", "opencode.json");
|
|
23
|
+
const SHIM_CONTENT = `
|
|
24
|
+
import { tool } from "@opencode-ai/plugin";
|
|
25
|
+
|
|
26
|
+
const SKILL = \`
|
|
27
|
+
---
|
|
28
|
+
name: osgrep
|
|
29
|
+
description: Semantic code search. Use alongside grep - grep for exact strings, osgrep for concepts.
|
|
30
|
+
allowed-tools: "Bash(osgrep:*), Read"
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## What osgrep does
|
|
34
|
+
|
|
35
|
+
Finds code by meaning. When you'd ask a colleague "where do we handle auth?", use osgrep.
|
|
36
|
+
|
|
37
|
+
- grep/ripgrep: exact string match, fast
|
|
38
|
+
- osgrep: concept match, finds code you couldn't grep for
|
|
39
|
+
|
|
40
|
+
## Primary command
|
|
41
|
+
|
|
42
|
+
osgrep "where do we validate user permissions"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Returns ~10 results with code snippets (15+ lines each). Usually enough to understand what's happening.
|
|
46
|
+
|
|
47
|
+
## Output explained
|
|
48
|
+
|
|
49
|
+
ORCHESTRATION src/auth/handler.ts:45
|
|
50
|
+
Defines: handleAuth | Calls: validate, checkRole, respond | Score: .94
|
|
51
|
+
|
|
52
|
+
export async function handleAuth(req: Request) {
|
|
53
|
+
const token = req.headers.get("Authorization");
|
|
54
|
+
const claims = await validateToken(token);
|
|
55
|
+
if (!claims) return unauthorized();
|
|
56
|
+
const allowed = await checkRole(claims.role, req.path);
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
- **ORCHESTRATION** = contains logic, coordinates other code
|
|
60
|
+
- **DEFINITION** = types, interfaces, classes
|
|
61
|
+
- **Score** = relevance (1 = best match)
|
|
62
|
+
- **Calls** = what this code calls (helps you trace flow)
|
|
63
|
+
|
|
64
|
+
## When to Read more
|
|
65
|
+
|
|
66
|
+
The snippet often has enough context. But if you need more:
|
|
67
|
+
|
|
68
|
+
# osgrep found src/auth/handler.ts:45-90 as ORCH
|
|
69
|
+
Read src/auth/handler.ts:45-120
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Read the specific line range, not the whole file.
|
|
73
|
+
|
|
74
|
+
## Other commands
|
|
75
|
+
|
|
76
|
+
# Trace call graph (who calls X, what X calls)
|
|
77
|
+
osgrep trace handleAuth
|
|
78
|
+
|
|
79
|
+
# Skeleton of a huge file (to find which ranges to read)
|
|
80
|
+
osgrep skeleton src/giant-2000-line-file.ts
|
|
81
|
+
|
|
82
|
+
# Just file paths when you only need locations
|
|
83
|
+
osgrep "authentication" --compact
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Workflow: architecture questions
|
|
87
|
+
|
|
88
|
+
# 1. Find entry points
|
|
89
|
+
osgrep "where do requests enter the server"
|
|
90
|
+
# Review the ORCH results - code is shown
|
|
91
|
+
|
|
92
|
+
# 2. If you need deeper context on a specific function
|
|
93
|
+
Read src/server/handler.ts:45-120
|
|
94
|
+
|
|
95
|
+
# 3. Trace to understand call flow
|
|
96
|
+
osgrep trace handleRequest
|
|
97
|
+
|
|
98
|
+
## Tips
|
|
99
|
+
|
|
100
|
+
- More words = better results. "auth" is vague. "where does the server validate JWT tokens" is specific.
|
|
101
|
+
- ORCH results contain the logic - prioritize these
|
|
102
|
+
- Don't read entire files. Use the line ranges osgrep gives you.
|
|
103
|
+
- If results seem off, rephrase your query like you'd ask a teammate
|
|
104
|
+
|
|
105
|
+
\`;
|
|
106
|
+
|
|
107
|
+
export default tool({
|
|
108
|
+
description: SKILL,
|
|
109
|
+
args: {
|
|
110
|
+
argv: tool.schema.array(tool.schema.string())
|
|
111
|
+
.describe("Arguments for osgrep, e.g. ['search', 'user auth']")
|
|
112
|
+
},
|
|
113
|
+
async execute({ argv }) {
|
|
114
|
+
try {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
const out = await Bun.spawn(["osgrep", ...argv], { stdout: "pipe" }).stdout;
|
|
117
|
+
const text = await new Response(out).text();
|
|
118
|
+
return text.trim();
|
|
119
|
+
} catch (err) {
|
|
120
|
+
return \`Error running osgrep: \${err}\`;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
})`;
|
|
124
|
+
function install() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
try {
|
|
127
|
+
// 1. Delete legacy plugin
|
|
128
|
+
if (node_fs_1.default.existsSync(PLUGIN_PATH)) {
|
|
129
|
+
try {
|
|
130
|
+
node_fs_1.default.unlinkSync(PLUGIN_PATH);
|
|
131
|
+
console.log("Deleted legacy plugin at", PLUGIN_PATH);
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
console.warn("mnt: Failed to delete legacy plugin:", e);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// 2. Create tool shim
|
|
138
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(TOOL_PATH), { recursive: true });
|
|
139
|
+
node_fs_1.default.writeFileSync(TOOL_PATH, SHIM_CONTENT);
|
|
140
|
+
console.log("✅ Created tool shim at", TOOL_PATH);
|
|
141
|
+
// 3. Register MCP
|
|
142
|
+
if (!node_fs_1.default.existsSync(CONFIG_PATH)) {
|
|
143
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(CONFIG_PATH), { recursive: true });
|
|
144
|
+
node_fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify({}, null, 2));
|
|
145
|
+
}
|
|
146
|
+
const config = JSON.parse(node_fs_1.default.readFileSync(CONFIG_PATH, "utf-8") || "{}");
|
|
147
|
+
if (!config.$schema)
|
|
148
|
+
config.$schema = "https://opencode.ai/config.json";
|
|
149
|
+
if (!config.mcp)
|
|
150
|
+
config.mcp = {};
|
|
151
|
+
config.mcp.osgrep = {
|
|
152
|
+
type: "local",
|
|
153
|
+
command: ["osgrep", "mcp"],
|
|
154
|
+
enabled: true,
|
|
155
|
+
};
|
|
156
|
+
node_fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
157
|
+
console.log("✅ Registered MCP server in", CONFIG_PATH);
|
|
158
|
+
console.log(" Command: check proper path if 'osgrep' is not in PATH of OpenCode.");
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
console.error("❌ Installation failed:", err);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function uninstall() {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
var _a;
|
|
168
|
+
try {
|
|
169
|
+
// 1. Remove shim
|
|
170
|
+
if (node_fs_1.default.existsSync(TOOL_PATH)) {
|
|
171
|
+
node_fs_1.default.unlinkSync(TOOL_PATH);
|
|
172
|
+
console.log("✅ Removed tool shim.");
|
|
173
|
+
}
|
|
174
|
+
// 2. Unregister MCP
|
|
175
|
+
if (node_fs_1.default.existsSync(CONFIG_PATH)) {
|
|
176
|
+
const config = JSON.parse(node_fs_1.default.readFileSync(CONFIG_PATH, "utf-8") || "{}");
|
|
177
|
+
if ((_a = config.mcp) === null || _a === void 0 ? void 0 : _a.osgrep) {
|
|
178
|
+
delete config.mcp.osgrep;
|
|
179
|
+
node_fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
180
|
+
console.log("✅ Unregistered MCP server.");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Cleanup plugin just in case
|
|
184
|
+
if (node_fs_1.default.existsSync(PLUGIN_PATH)) {
|
|
185
|
+
node_fs_1.default.unlinkSync(PLUGIN_PATH);
|
|
186
|
+
console.log("✅ Cleaned up plugin file.");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
console.error("❌ Uninstall failed:", err);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
exports.installOpencode = new commander_1.Command("install-opencode")
|
|
195
|
+
.description("Install osgrep as an OpenCode plugin (Daemon + Tool)")
|
|
196
|
+
.action(install);
|
|
197
|
+
exports.uninstallOpencode = new commander_1.Command("uninstall-opencode")
|
|
198
|
+
.description("Remove the osgrep OpenCode plugin")
|
|
199
|
+
.action(uninstall);
|