opencode-codebase-index 0.6.0 → 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.
- package/README.md +298 -28
- package/commands/index.md +6 -4
- package/dist/cli.cjs +950 -150
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +950 -150
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +8024 -6826
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7942 -6744
- package/dist/index.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.linux-arm64-gnu.node +0 -0
- package/native/codebase-index-native.linux-x64-gnu.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +21 -16
- package/skill/SKILL.md +63 -10
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-codebase-index",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Semantic codebase indexing and search for OpenCode - find code by meaning, not just keywords",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"eval:ci:ollama": "npx tsx src/cli.ts eval run --config .github/eval-ollama-config.json --reindex --ci --budget benchmarks/budgets/default.json --against benchmarks/baselines/eval-baseline-summary.json",
|
|
46
46
|
"eval:compare": "npx tsx src/cli.ts eval compare",
|
|
47
47
|
"test": "vitest",
|
|
48
|
-
"pretest:run": "npm run build:native",
|
|
48
|
+
"pretest:run": "RUSTFLAGS=\"-C target-cpu=generic\" npm run build:native",
|
|
49
49
|
"test:run": "vitest run",
|
|
50
|
-
"pretest:coverage": "npm run build:native",
|
|
50
|
+
"pretest:coverage": "RUSTFLAGS=\"-C target-cpu=generic\" npm run build:native",
|
|
51
51
|
"test:coverage": "vitest run --coverage",
|
|
52
52
|
"lint": "eslint src/",
|
|
53
53
|
"typecheck": "tsc --noEmit",
|
|
@@ -70,28 +70,33 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
+
"@opencode-ai/plugin": "~1.3.13",
|
|
73
74
|
"chokidar": "^5.0.0",
|
|
74
75
|
"ignore": "^7.0.5",
|
|
75
|
-
"p-queue": "^9.1.
|
|
76
|
+
"p-queue": "^9.1.1",
|
|
76
77
|
"p-retry": "^7.1.1",
|
|
77
78
|
"tiktoken": "^1.0.15"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@eslint/js": "^9.39.
|
|
81
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
82
|
-
"@napi-rs/cli": "^3.
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"
|
|
86
|
-
"eslint": "^9.0.0",
|
|
81
|
+
"@eslint/js": "^9.39.4",
|
|
82
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
83
|
+
"@napi-rs/cli": "^3.6.0",
|
|
84
|
+
"@types/node": "^25.5.2",
|
|
85
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
86
|
+
"eslint": "^9.39.4",
|
|
87
87
|
"tsup": "^8.1.0",
|
|
88
|
-
"typescript": "^5.
|
|
89
|
-
"typescript-eslint": "^8.
|
|
90
|
-
"vitest": "^4.
|
|
91
|
-
"zod": "^3.25.
|
|
88
|
+
"typescript": "^5.9.3",
|
|
89
|
+
"typescript-eslint": "^8.58.0",
|
|
90
|
+
"vitest": "^4.1.2",
|
|
91
|
+
"zod": "^3.25.76"
|
|
92
|
+
},
|
|
93
|
+
"overrides": {
|
|
94
|
+
"@hono/node-server": "1.19.14",
|
|
95
|
+
"hono": "4.12.12",
|
|
96
|
+
"vite": "8.0.8"
|
|
92
97
|
},
|
|
93
98
|
"peerDependencies": {
|
|
94
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
99
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
95
100
|
"@opencode-ai/plugin": "^1.0.0",
|
|
96
101
|
"zod": "^3.0.0"
|
|
97
102
|
},
|
package/skill/SKILL.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
---
|
|
2
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.
|
|
3
|
+
description: Semantic code and documentation 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. Search local codebase before using websearch for code/library/API/example questions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Codebase Search Skill
|
|
7
7
|
|
|
8
|
+
## Important: Indexed Content
|
|
9
|
+
|
|
10
|
+
The indexed codebase contains **two types of content**:
|
|
11
|
+
|
|
12
|
+
1. **Project Source Code** — all code files in the current workspace
|
|
13
|
+
2. **Knowledge Base Documentation** — external documentation, usage guides, API references, and example programs added via `add_knowledge_base`
|
|
14
|
+
|
|
8
15
|
## When to Use What
|
|
9
16
|
|
|
10
17
|
| Scenario | Tool | Why |
|
|
11
18
|
|----------|------|-----|
|
|
19
|
+
| Code/library/API question | `codebase_search` | Search local knowledge first |
|
|
12
20
|
| Just need file locations | `codebase_peek` | Metadata only, saves ~90% tokens |
|
|
13
21
|
| Need to see actual code | `codebase_search` | Returns full code content |
|
|
14
22
|
| Find duplicates/patterns | `find_similar` | Given code snippet → similar code |
|
|
@@ -16,12 +24,40 @@ description: Semantic code search by meaning. Use codebase_peek to find WHERE co
|
|
|
16
24
|
| Don't know function/class names | `codebase_peek` or `codebase_search` | Natural language → code |
|
|
17
25
|
| Know exact identifier names | `grep` | Faster, more precise |
|
|
18
26
|
| Need ALL occurrences | `grep` | Semantic returns top N only |
|
|
27
|
+
| Access specific URL | `webfetch` | Direct URL access, no codebase search needed |
|
|
28
|
+
| Local search fails | `websearch` | Fallback when codebase has no results |
|
|
29
|
+
| Local and web search fails | suggest adding knowledge base | Notify user to add related folder |
|
|
30
|
+
|
|
31
|
+
## Search Rule
|
|
32
|
+
|
|
33
|
+
**Search local codebase first, then web search if needed.**
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Question received
|
|
37
|
+
↓
|
|
38
|
+
Is this about code/library/API/framework?
|
|
39
|
+
↓ YES
|
|
40
|
+
codebase_search(query)
|
|
41
|
+
↓
|
|
42
|
+
Found relevant results? → YES → Return answer
|
|
43
|
+
↓ NO
|
|
44
|
+
websearch(query)
|
|
45
|
+
↓
|
|
46
|
+
Found relevant results? → YES → Return answer
|
|
47
|
+
↓ NO
|
|
48
|
+
Suggest: "知识库中未找到相关信息,是否添加相关文档文件夹?"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
1. Use `codebase_search` for code/library/API questions
|
|
52
|
+
2. If no relevant results → use `websearch`
|
|
53
|
+
3. If web search also fails → suggest adding a knowledge base folder
|
|
19
54
|
|
|
20
55
|
## Recommended Workflow
|
|
21
56
|
|
|
22
|
-
1. **
|
|
23
|
-
2. **
|
|
24
|
-
3. **
|
|
57
|
+
1. **Search first**: `codebase_search("ADC channels ESP32")` → check local knowledge
|
|
58
|
+
2. **Locate with peek**: `codebase_peek("authentication flow")` → get file locations
|
|
59
|
+
3. **Read what matters**: `Read` the specific files you need
|
|
60
|
+
4. **Drill down with grep**: `grep "validateToken"` for exact matches
|
|
25
61
|
|
|
26
62
|
## Tools
|
|
27
63
|
|
|
@@ -47,28 +83,45 @@ find_similar(code="function validate(input) { return input.length > 0; }", exclu
|
|
|
47
83
|
```
|
|
48
84
|
|
|
49
85
|
### `call_graph`
|
|
50
|
-
Query callers or callees of a function/method.
|
|
86
|
+
Query callers or callees of a function/method.
|
|
51
87
|
|
|
52
88
|
```
|
|
53
89
|
call_graph(name="validateToken", direction="callers")
|
|
54
|
-
call_graph(name="validateToken", direction="callees", symbolId="src/auth.ts::validateToken")
|
|
55
90
|
```
|
|
56
91
|
|
|
57
|
-
- `direction="callers"`: Who calls this function?
|
|
58
|
-
- `direction="callees"`: What does this function call? (requires `symbolId` from a prior callers query)
|
|
59
|
-
|
|
60
92
|
### `index_codebase`
|
|
61
|
-
Manually trigger indexing. Required before first search.
|
|
93
|
+
Manually trigger indexing. Required before first search.
|
|
62
94
|
|
|
63
95
|
### `index_status`
|
|
64
96
|
Check if indexed and ready.
|
|
65
97
|
|
|
98
|
+
### `add_knowledge_base`
|
|
99
|
+
Add a folder as a knowledge base. The folder will be indexed alongside project code.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
add_knowledge_base(path="/path/to/docs")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `list_knowledge_bases`
|
|
106
|
+
List all configured knowledge base folders.
|
|
107
|
+
|
|
108
|
+
### `remove_knowledge_base`
|
|
109
|
+
Remove a knowledge base folder from the index.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
remove_knowledge_base(path="/path/to/docs")
|
|
113
|
+
```
|
|
114
|
+
|
|
66
115
|
## Query Tips
|
|
67
116
|
|
|
68
117
|
**Describe behavior, not syntax:**
|
|
69
118
|
- Good: `"function that hashes passwords securely"`
|
|
70
119
|
- Bad: `"hashPassword"` (use grep for exact names)
|
|
71
120
|
|
|
121
|
+
**Search across documentation:**
|
|
122
|
+
- Good: `"how to configure WiFi in ESP-IDF"`
|
|
123
|
+
- Good: `"GPIO initialization example"`
|
|
124
|
+
|
|
72
125
|
## Filters
|
|
73
126
|
|
|
74
127
|
| Filter | Example |
|