opencode-codebase-index 0.1.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/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "opencode-codebase-index",
3
+ "version": "0.1.0",
4
+ "description": "Semantic codebase indexing and search for OpenCode - find code by meaning, not just keywords",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
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
+ "license": "MIT",
16
+ "author": "Kenneth",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/Helweg/opencode-codebase-index"
20
+ },
21
+ "keywords": [
22
+ "opencode",
23
+ "semantic-search",
24
+ "codebase-indexing",
25
+ "vector-search",
26
+ "embeddings",
27
+ "tree-sitter",
28
+ "ai-coding"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18.0.0"
32
+ },
33
+ "scripts": {
34
+ "build": "npm run build:ts && npm run build:native",
35
+ "build:ts": "tsup",
36
+ "build:native": "cd native && cargo build --release && napi build --release --platform",
37
+ "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",
38
+ "dev": "tsup --watch",
39
+ "test": "vitest",
40
+ "test:run": "vitest run",
41
+ "lint": "eslint src/",
42
+ "typecheck": "tsc --noEmit",
43
+ "prepublishOnly": "npm run build"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "native/*.node",
48
+ "skill",
49
+ "commands"
50
+ ],
51
+ "napi": {
52
+ "binaryName": "codebase-index-native",
53
+ "targets": [
54
+ "x86_64-apple-darwin",
55
+ "aarch64-apple-darwin",
56
+ "x86_64-unknown-linux-gnu",
57
+ "aarch64-unknown-linux-gnu",
58
+ "x86_64-pc-windows-msvc"
59
+ ]
60
+ },
61
+ "dependencies": {
62
+ "chokidar": "^5.0.0",
63
+ "ignore": "^7.0.5",
64
+ "p-queue": "^9.1.0",
65
+ "p-retry": "^7.1.1",
66
+ "tiktoken": "^1.0.15",
67
+ "zod": "^4.3.5"
68
+ },
69
+ "devDependencies": {
70
+ "@eslint/js": "^9.39.2",
71
+ "@napi-rs/cli": "^3.5.1",
72
+ "@opencode-ai/plugin": "^1.1.20",
73
+ "@types/node": "^25.0.8",
74
+ "eslint": "^9.0.0",
75
+ "tsup": "^8.1.0",
76
+ "typescript": "^5.5.0",
77
+ "typescript-eslint": "^8.53.0",
78
+ "vitest": "^4.0.17"
79
+ },
80
+ "peerDependencies": {
81
+ "@opencode-ai/plugin": "^1.0.0"
82
+ }
83
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,91 @@
1
+ # Codebase Search Skill
2
+
3
+ Semantic search for finding code by meaning, not just keywords.
4
+
5
+ ## When to Use Semantic Search vs Grep
6
+
7
+ | Scenario | Use | Why |
8
+ |----------|-----|-----|
9
+ | Don't know function/class names | `codebase_search` | Natural language → code |
10
+ | Concept discovery ("what handles auth?") | `codebase_search` | Finds related code by meaning |
11
+ | Know exact identifier names | `grep` | Faster, more precise |
12
+ | Need ALL occurrences | `grep` | Semantic returns top N only |
13
+ | Unfamiliar codebase exploration | `codebase_search` | Broader conceptual matches |
14
+
15
+ ## Hybrid Strategy (Recommended)
16
+
17
+ 1. **Discover with semantic**: `codebase_search("authentication flow")` → get candidate files
18
+ 2. **Drill down with grep**: `grep "validateToken"` in those files for exact matches
19
+ 3. **Use LSP**: For definitions and references once you have the identifier
20
+
21
+ ## Available Tools
22
+
23
+ ### `codebase_search`
24
+ Find code by describing what it does in natural language.
25
+
26
+ **Best for:**
27
+ - "find the user authentication logic"
28
+ - "code that handles database connections"
29
+ - "error handling middleware for HTTP requests"
30
+ - "where is the payment processing"
31
+
32
+ **Parameters:**
33
+ - `query` (required): Natural language description
34
+ - `limit` (optional): Maximum results (default: 10)
35
+
36
+ **Returns:** Focused list of 5-10 most relevant files/chunks with scores.
37
+
38
+ ### `index_codebase`
39
+ Create or update the semantic index. Required before first search.
40
+
41
+ **Parameters:**
42
+ - `force` (optional): Reindex from scratch (default: false)
43
+ - `estimateOnly` (optional): Show cost estimate without indexing
44
+
45
+ **Note:** Incremental indexing is fast (~50ms) when files haven't changed.
46
+
47
+ ### `index_status`
48
+ Check if the codebase is indexed and ready for search.
49
+
50
+ ### `index_health_check`
51
+ Remove stale entries from deleted files.
52
+
53
+ ## Query Writing Tips
54
+
55
+ **Describe behavior, not syntax:**
56
+ ```
57
+ Good: "function that hashes passwords securely"
58
+ Bad: "hashPassword" (use grep for exact names)
59
+
60
+ Good: "middleware that checks JWT tokens"
61
+ Bad: "jwt" (too vague, use grep for keyword)
62
+
63
+ Good: "error handling for unauthorized requests"
64
+ Bad: "401" (literal keyword, use grep)
65
+ ```
66
+
67
+ ## Workflow Examples
68
+
69
+ ### Exploring unfamiliar codebase
70
+ ```
71
+ 1. index_status → check if indexed
72
+ 2. index_codebase → if needed
73
+ 3. codebase_search("how does authentication work") → get overview
74
+ 4. codebase_search("session management") → drill into specifics
75
+ 5. grep "SessionStore" → once you know the class name
76
+ ```
77
+
78
+ ### Finding implementation for a feature
79
+ ```
80
+ 1. codebase_search("image upload and processing") → find relevant files
81
+ 2. Read top results to understand structure
82
+ 3. grep "uploadImage" → find exact function
83
+ 4. LSP goto_definition → navigate to implementation
84
+ ```
85
+
86
+ ### Debugging unknown code path
87
+ ```
88
+ 1. codebase_search("error handling for payment failures") → find error handlers
89
+ 2. codebase_search("retry logic for API calls") → find retry mechanisms
90
+ 3. grep "PaymentError" → find specific error class
91
+ ```