opencode-codebase-index 0.2.5 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codebase-index",
3
- "version": "0.2.5",
3
+ "version": "0.3.2",
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",
@@ -38,6 +38,7 @@
38
38
  "dev": "tsup --watch",
39
39
  "test": "vitest",
40
40
  "test:run": "vitest run",
41
+ "test:coverage": "vitest run --coverage",
41
42
  "lint": "eslint src/",
42
43
  "typecheck": "tsc --noEmit",
43
44
  "prepublishOnly": "npm run build"
@@ -70,6 +71,7 @@
70
71
  "@napi-rs/cli": "^3.5.1",
71
72
  "@opencode-ai/plugin": "^1.1.21",
72
73
  "@types/node": "^25.0.8",
74
+ "@vitest/coverage-v8": "^4.0.17",
73
75
  "eslint": "^9.0.0",
74
76
  "tsup": "^8.1.0",
75
77
  "typescript": "^5.5.0",
package/skill/SKILL.md CHANGED
@@ -32,6 +32,10 @@ Find code by describing what it does in natural language.
32
32
  **Parameters:**
33
33
  - `query` (required): Natural language description
34
34
  - `limit` (optional): Maximum results (default: 10)
35
+ - `chunkType` (optional): Filter by code type
36
+ - `directory` (optional): Filter by directory path
37
+ - `fileType` (optional): Filter by file extension
38
+ - `contextLines` (optional): Extra lines before/after each match
35
39
 
36
40
  **Returns:** Focused list of 5-10 most relevant files/chunks with scores.
37
41
 
@@ -41,6 +45,7 @@ Create or update the semantic index. Required before first search.
41
45
  **Parameters:**
42
46
  - `force` (optional): Reindex from scratch (default: false)
43
47
  - `estimateOnly` (optional): Show cost estimate without indexing
48
+ - `verbose` (optional): Show skipped files and parse failures
44
49
 
45
50
  **Note:** Incremental indexing is fast (~50ms) when files haven't changed.
46
51
 
@@ -48,7 +53,104 @@ Create or update the semantic index. Required before first search.
48
53
  Check if the codebase is indexed and ready for search.
49
54
 
50
55
  ### `index_health_check`
51
- Remove stale entries from deleted files.
56
+ Remove stale entries from deleted files and orphaned embeddings.
57
+
58
+ ### `index_metrics`
59
+ Get performance statistics for indexing and search operations.
60
+ Requires `debug.enabled` and `debug.metrics` to be `true` in config.
61
+
62
+ **Shows:** Files indexed, chunks created, cache hit rate, search timing breakdown, GC stats, embedding API call stats.
63
+
64
+ ### `index_logs`
65
+ Get recent debug logs with optional filtering.
66
+ Requires `debug.enabled` to be `true` in config.
67
+
68
+ **Parameters:**
69
+ - `limit` (optional): Maximum log entries (default: 20)
70
+ - `category` (optional): Filter by `search`, `embedding`, `cache`, `gc`, `branch`, `general`
71
+ - `level` (optional): Filter by `error`, `warn`, `info`, `debug`
72
+
73
+ ## Search Filters
74
+
75
+ ### Filter by Chunk Type (`chunkType`)
76
+
77
+ Narrow results to specific code constructs:
78
+
79
+ | Value | Finds |
80
+ |-------|-------|
81
+ | `function` | Functions, arrow functions |
82
+ | `class` | Class definitions |
83
+ | `method` | Class methods |
84
+ | `interface` | TypeScript interfaces |
85
+ | `type` | Type aliases |
86
+ | `enum` | Enumerations |
87
+ | `struct` | Rust/Go structs |
88
+ | `impl` | Rust impl blocks |
89
+ | `trait` | Rust traits |
90
+ | `module` | Module definitions |
91
+
92
+ **Examples:**
93
+ ```
94
+ codebase_search(query="validation logic", chunkType="function")
95
+ codebase_search(query="data models", chunkType="interface")
96
+ codebase_search(query="user entity", chunkType="class")
97
+ ```
98
+
99
+ ### Filter by Directory (`directory`)
100
+
101
+ Scope search to specific paths:
102
+
103
+ ```
104
+ codebase_search(query="API routes", directory="src/api")
105
+ codebase_search(query="test helpers", directory="tests")
106
+ codebase_search(query="database queries", directory="src/db")
107
+ ```
108
+
109
+ ### Filter by File Type (`fileType`)
110
+
111
+ Limit to specific languages:
112
+
113
+ ```
114
+ codebase_search(query="config parsing", fileType="ts")
115
+ codebase_search(query="build scripts", fileType="py")
116
+ codebase_search(query="data structures", fileType="rs")
117
+ ```
118
+
119
+ ### Combining Filters
120
+
121
+ Filters can be combined for precise results:
122
+
123
+ ```
124
+ codebase_search(
125
+ query="validation",
126
+ chunkType="function",
127
+ directory="src/utils",
128
+ fileType="ts"
129
+ )
130
+ ```
131
+
132
+ ## Hybrid Weight Tuning
133
+
134
+ The `hybridWeight` config option (0.0-1.0) balances semantic vs keyword search:
135
+
136
+ | Value | Behavior | Best For |
137
+ |-------|----------|----------|
138
+ | `0.0` | Pure semantic | Conceptual queries, unfamiliar code |
139
+ | `0.5` | Balanced (default) | General use |
140
+ | `1.0` | Pure keyword (BM25) | When you know specific terms |
141
+
142
+ Configure in `.opencode/codebase-index.json`:
143
+ ```json
144
+ {
145
+ "search": {
146
+ "hybridWeight": 0.3
147
+ }
148
+ }
149
+ ```
150
+
151
+ **When to adjust:**
152
+ - Lower (0.2-0.4): Exploratory queries, finding related code
153
+ - Higher (0.6-0.8): When query contains specific identifiers
52
154
 
53
155
  ## Query Writing Tips
54
156
 
@@ -75,6 +177,13 @@ Bad: "401" (literal keyword, use grep)
75
177
  5. grep "SessionStore" → once you know the class name
76
178
  ```
77
179
 
180
+ ### Finding all functions in a module
181
+ ```
182
+ 1. codebase_search(query="utility helpers", directory="src/utils", chunkType="function")
183
+ 2. Review results to understand available utilities
184
+ 3. grep specific function name for all usages
185
+ ```
186
+
78
187
  ### Finding implementation for a feature
79
188
  ```
80
189
  1. codebase_search("image upload and processing") → find relevant files
@@ -89,3 +198,9 @@ Bad: "401" (literal keyword, use grep)
89
198
  2. codebase_search("retry logic for API calls") → find retry mechanisms
90
199
  3. grep "PaymentError" → find specific error class
91
200
  ```
201
+
202
+ ### Finding TypeScript interfaces
203
+ ```
204
+ 1. codebase_search(query="user data", chunkType="interface") → find User interfaces
205
+ 2. codebase_search(query="API response", chunkType="type") → find response types
206
+ ```