Feat: add knowledge base, reranking, TXT/HTML support, and config merge#44
Feat: add knowledge base, reranking, TXT/HTML support, and config merge#44Helweg merged 22 commits intoHelweg:mainfrom
Conversation
- Add knowledge base tools (add/list/remove_knowledge_base) - Add SiliconFlow reranking with BAAI/bge-reranker-v2-m3 - Add TXT/HTML/HTM file format support - Add global/project config merging for embedding provider - Add additionalInclude config option - Exclude hidden files and build folders from indexing - Update SKILL.md and README.md documentation - Fix test assertion for exclude patterns count
|
Solid set of features — knowledge bases, reranking, config merging, and the file pattern improvements are well thought out. A couple things I noticed: Watcher doesn't account for The indexer merges const includePatterns = [...this.config.include, ...this.config.additionalInclude];But
When It doesn't actually trigger reindexing — the Nit:
|
- Fix watcher to account for additionalInclude patterns - Remove misleading reindex parameter from knowledge base tools - Remove dead code in shouldIncludeFile - Add error handling to plugin initialization to prevent opencode startup failure - Add error handling to native module loading to prevent crashes - Restore AVX-512 SIMD for production, disable only in tests via RUSTFLAGS
|
Thanks for the updates — the recursion depth limit in The three items from my earlier review still appear to be open in the current diff:
Are these on your radar, or intentionally deferred? |
- Add recursion depth detection (4096 limit) to prevent stack overflow in parser - Skip custom knowledge base folders from file watcher to reduce watch overhead - Optimize tool return formats by removing redundant prompt phrases - Fix test expectations to match new tool output formats - Add performance profiling for semantic node extraction - Limit leading comment traversal to 5 siblings for better performance This addresses issues reported by the repository author including: 1. File watcher intentionally excludes custom knowledge base folders 2. Iteration depth detection prevents segmentation faults 3. Other fixes for reported issues 4. Optimized tool call prompts for better LLM integration
|
I have updated this PR and have fixed and tested everything except "Watcher doesn't account for additionalInclude patterns." |
|
Some comments and commits are generated from OpenCode client. It created an unnecessary PR and I closed it manually. Now the current branch is latest. |
|
Thanks for the fixes on the On the So right now, if someone adds
The fix is just merging the patterns in If the intent is "index these file types but never watch them," that's a valid design choice — but it should be a separate config option rather than an accidental mismatch between the indexer and watcher. |
- Merge additionalInclude patterns with include patterns in handleChange - Ensures files matching additionalInclude patterns are watched for changes - Addresses PR review feedback from repository author
|
Thanks for the detailed review and clarification on the watcher issue. You're absolutely right — the const includePatterns = [...this.config.include, ...(this.config.additionalInclude ?? [])];This ensures files matching All three issues from your review are now addressed:
Tests pass (492/492). Let me know if you'd like any further adjustments. |
Helweg
left a comment
There was a problem hiding this comment.
All three review items addressed:
- Watcher now merges
additionalIncludepatterns inhandleChange - Misleading
reindexparameter cleaned up - Dead
rebuildexception removed
No supply-chain concerns — no new dependencies, all lockfile changes are routine semver bumps. LGTM.
|
CI is failing on typecheck: The |
|
fix CI typecheck |
|
These verified commits are from me instead of OpenCode client. |
|
Two more issues found during deeper review of the config merging: KB management tools only read project config, not merged config
function getConfigPath(): string {
return path.join(sharedProjectRoot, ".opencode", "codebase-index.json");
}If a user adds KBs in global config ( CLI/MCP entrypoint doesn't merge configs
This means the same project can behave differently depending on whether it's accessed via OpenCode plugin vs MCP client (Cursor, Claude Code, etc.). |
|
Oops, OpenCode closed my PR branch while working on my Git workflow. It mistakenly thought that the new "Resolve-conflict" branch should be deleted after committing! I urgently restored the branch and reopened the PR. I have reopened the branch via GitHub on the webpage and apologize for the OpenCode operation. I have tried to solve compile and test for the two issues you raised. |
|
These commits have fixed an OOM issue during my usage. |
|
I pulled the latest PR head, rebuilt locally, and re-tested this in a scratch workspace. I’m still seeing a blocking issue in the real parse/index path:
So |
|
Now I have fixed the TXT/MD chunking issue and commited into the PR branch. Branch |
Summary
This PR adds several new features to enhance the plugin's capabilities:
1. Knowledge Base Support
Add the ability to index external documentation folders alongside project code:
add_knowledge_base,list_knowledge_bases,remove_knowledge_baseknowledgeBasesarray in config to specify external directoriesExample config:
{ "knowledgeBases": [ "/home/user/docs/my-doc", "/home/user/docs/my-API-references" ] }2. Reranking API Integration
Add API-based reranking for improved search result quality:
rerankerconfig sectionBAAI/bge-reranker-v2-m3and other OpenAI-compatible endpointstopN,timeoutMsoptionsExample config:
{ "reranker": { "enabled": true, "baseUrl": "https://api.siliconflow.cn/v1", "model": "BAAI/bge-reranker-v2-m3", "apiKey": "{env:SILICONFLOW_API_KEY}", "topN": 20 } }3. Config Merging
Global and project configs are now merged:
~/.config/opencode/codebase-index.json) as base.opencode/codebase-index.json) overridesknowledgeBases,additionalInclude) are merged (union, deduplicated)4. File Pattern Improvements
additionalIncludeoption to extend defaults without replacing.)5. Token Efficiency
/indexcommand default toverbose=falseto reduce token consumptionFiles Changed
src/config/schema.ts- Add reranker, knowledgeBases, additionalIncludesrc/config/constants.ts- Update include/exclude patternssrc/index.ts- Config merging logicsrc/indexer/index.ts- Integrate reranker and knowledge basessrc/utils/files.ts- Knowledge base file collectionsrc/rerank/index.ts- New reranker modulesrc/tools/index.ts- New knowledge base toolsskill/SKILL.md- Updated with new featuresREADME.md- Documentation updatestests/config.test.ts- Updated testsTesting
All tests pass (492/492):