@khivi/opencode-codebase-index 0.5.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/LICENSE +21 -0
- package/README.md +658 -0
- package/commands/call-graph.md +24 -0
- package/commands/find.md +25 -0
- package/commands/index.md +21 -0
- package/commands/search.md +24 -0
- package/commands/status.md +15 -0
- package/dist/cli.cjs +6208 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +6213 -0
- package/dist/cli.js.map +1 -0
- package/dist/git-cli.cjs +6006 -0
- package/dist/git-cli.cjs.map +1 -0
- package/dist/git-cli.js +6011 -0
- package/dist/git-cli.js.map +1 -0
- package/dist/index.cjs +8224 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +8221 -0
- package/dist/index.js.map +1 -0
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/package.json +103 -0
- package/skill/SKILL.md +78 -0
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@khivi/opencode-codebase-index",
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "Semantic codebase indexing and search for OpenCode - find code by meaning, not just keywords",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"opencode-codebase-index-mcp": "dist/cli.js",
|
|
17
|
+
"codebase-index": "dist/git-cli.js"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Kenneth",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/khivi/opencode-codebase-index"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"opencode",
|
|
27
|
+
"semantic-search",
|
|
28
|
+
"codebase-indexing",
|
|
29
|
+
"vector-search",
|
|
30
|
+
"embeddings",
|
|
31
|
+
"tree-sitter",
|
|
32
|
+
"ai-coding"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "npm run build:ts && npm run build:native",
|
|
39
|
+
"build:ts": "tsup",
|
|
40
|
+
"build:native": "cd native && cargo build --release && napi build --release --platform",
|
|
41
|
+
"build:native:all": "cd native && napi build --release --platform --target x86_64-apple-darwin --target aarch64-apple-darwin --target x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu --target x86_64-pc-windows-msvc",
|
|
42
|
+
"dev": "tsup --watch",
|
|
43
|
+
"test": "vitest",
|
|
44
|
+
"test:run": "vitest run",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"lint": "eslint src/",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"prepublishOnly": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"native/*.node",
|
|
53
|
+
"skill",
|
|
54
|
+
"commands"
|
|
55
|
+
],
|
|
56
|
+
"napi": {
|
|
57
|
+
"binaryName": "codebase-index-native",
|
|
58
|
+
"targets": [
|
|
59
|
+
"x86_64-apple-darwin",
|
|
60
|
+
"aarch64-apple-darwin",
|
|
61
|
+
"x86_64-unknown-linux-gnu",
|
|
62
|
+
"aarch64-unknown-linux-gnu",
|
|
63
|
+
"x86_64-pc-windows-msvc"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"chokidar": "^5.0.0",
|
|
68
|
+
"ignore": "^7.0.5",
|
|
69
|
+
"p-queue": "^9.1.0",
|
|
70
|
+
"p-retry": "^7.1.1",
|
|
71
|
+
"tiktoken": "^1.0.15"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@eslint/js": "^9.39.2",
|
|
75
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
76
|
+
"@napi-rs/cli": "^3.5.1",
|
|
77
|
+
"@opencode-ai/plugin": "^1.1.21",
|
|
78
|
+
"@types/node": "^25.0.8",
|
|
79
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
80
|
+
"eslint": "^9.0.0",
|
|
81
|
+
"tsup": "^8.1.0",
|
|
82
|
+
"typescript": "^5.5.0",
|
|
83
|
+
"typescript-eslint": "^8.53.0",
|
|
84
|
+
"vitest": "^4.0.17",
|
|
85
|
+
"zod": "^3.25.67"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
89
|
+
"@opencode-ai/plugin": "^1.0.0",
|
|
90
|
+
"zod": "^3.0.0"
|
|
91
|
+
},
|
|
92
|
+
"peerDependenciesMeta": {
|
|
93
|
+
"@modelcontextprotocol/sdk": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@opencode-ai/plugin": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"zod": {
|
|
100
|
+
"optional": true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-search
|
|
3
|
+
description: Semantic code search by meaning. Use codebase_peek to find WHERE code is (saves tokens), codebase_search to see actual code. For exact identifiers, use grep instead.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codebase Search Skill
|
|
7
|
+
|
|
8
|
+
## When to Use What
|
|
9
|
+
|
|
10
|
+
| Scenario | Tool | Why |
|
|
11
|
+
|----------|------|-----|
|
|
12
|
+
| Just need file locations | `codebase_peek` | Metadata only, saves ~90% tokens |
|
|
13
|
+
| Need to see actual code | `codebase_search` | Returns full code content |
|
|
14
|
+
| Find duplicates/patterns | `find_similar` | Given code snippet → similar code |
|
|
15
|
+
| Understand code flow | `call_graph` | Find callers/callees of any function |
|
|
16
|
+
| Don't know function/class names | `codebase_peek` or `codebase_search` | Natural language → code |
|
|
17
|
+
| Know exact identifier names | `grep` | Faster, more precise |
|
|
18
|
+
| Need ALL occurrences | `grep` | Semantic returns top N only |
|
|
19
|
+
|
|
20
|
+
## Recommended Workflow
|
|
21
|
+
|
|
22
|
+
1. **Locate with peek**: `codebase_peek("authentication flow")` → get file locations
|
|
23
|
+
2. **Read what matters**: `Read` the specific files you need
|
|
24
|
+
3. **Drill down with grep**: `grep "validateToken"` for exact matches
|
|
25
|
+
|
|
26
|
+
## Tools
|
|
27
|
+
|
|
28
|
+
### `codebase_peek`
|
|
29
|
+
Find WHERE code is. Returns metadata only (file, line, name, type).
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
codebase_peek(query="validation logic", chunkType="function", directory="src/utils")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `codebase_search`
|
|
36
|
+
Find code with full content. Use when you need to see implementation.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
codebase_search(query="error handling middleware", fileType="ts", contextLines=2)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### `find_similar`
|
|
43
|
+
Find code similar to a given snippet. Use for duplicate detection, pattern discovery, refactoring.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
find_similar(code="function validate(input) { return input.length > 0; }", excludeFile="src/current.ts")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `call_graph`
|
|
50
|
+
Query callers or callees of a function/method. Built automatically during indexing for TypeScript, JavaScript, Python, Go, and Rust.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
call_graph(name="validateToken", direction="callers")
|
|
54
|
+
call_graph(name="validateToken", direction="callees", symbolId="src/auth.ts::validateToken")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `direction="callers"`: Who calls this function?
|
|
58
|
+
- `direction="callees"`: What does this function call? (requires `symbolId` from a prior callers query)
|
|
59
|
+
|
|
60
|
+
### `index_codebase`
|
|
61
|
+
Manually trigger indexing. Required before first search. Incremental (~50ms when unchanged).
|
|
62
|
+
|
|
63
|
+
### `index_status`
|
|
64
|
+
Check if indexed and ready.
|
|
65
|
+
|
|
66
|
+
## Query Tips
|
|
67
|
+
|
|
68
|
+
**Describe behavior, not syntax:**
|
|
69
|
+
- Good: `"function that hashes passwords securely"`
|
|
70
|
+
- Bad: `"hashPassword"` (use grep for exact names)
|
|
71
|
+
|
|
72
|
+
## Filters
|
|
73
|
+
|
|
74
|
+
| Filter | Example |
|
|
75
|
+
|--------|---------|
|
|
76
|
+
| `chunkType` | `function`, `class`, `interface`, `type`, `method` |
|
|
77
|
+
| `directory` | `"src/api"`, `"tests"` |
|
|
78
|
+
| `fileType` | `"ts"`, `"py"`, `"rs"` |
|