feat: add semantic/RAG vault indexing with automatic background sync

- Add VaultVectorStore backed by ChromaDB for vector-based vault search
- Integrate existing ContentVectorizer/IndexingPipeline for embeddings
- Update VaultIndexer to prefer semantic search with keyword fallback
- Background indexing on plugin load + incremental sync via vault events
- Add vault index settings, commands, and UI controls
- Add tests for VaultVectorStore
- Update README with RAG setup instructions
This commit is contained in:
2026-05-19 23:00:04 +02:00
parent 4f3472a49c
commit fae74ade95
11 changed files with 1528 additions and 27 deletions
+9 -2
View File
@@ -1,6 +1,7 @@
import { ItemView, Notice, WorkspaceLeaf } from 'obsidian';
import { OllamaClient } from './ollama-client';
import { VaultIndexer } from './vault-indexer';
import { VaultVectorStore } from './vault-vector-store';
import { ToolExecutor } from './tool-executor';
import { PluginSettings, OllamaMessage, OllamaTool, OllamaToolCall, ChatMessage } from './types';
import { ConversationStateManager } from './conversation-state';
@@ -22,7 +23,7 @@ export class ChatView extends ItemView {
return this.newChatButtonClickHandler;
}
constructor(leaf: WorkspaceLeaf, settings: PluginSettings) {
constructor(leaf: WorkspaceLeaf, settings: PluginSettings, vectorStore?: VaultVectorStore) {
super(leaf);
this.messages = [];
this.lastMessageEl = null;
@@ -44,7 +45,7 @@ export class ChatView extends ItemView {
undefined,
settings.cacheConfig
);
this.vaultIndexer = new VaultIndexer(this.app.vault);
this.vaultIndexer = new VaultIndexer(this.app.vault, undefined, vectorStore);
this.toolExecutor = new ToolExecutor(this.app.vault, this.app);
this.conversationStateManager = new ConversationStateManager();
}
@@ -64,6 +65,11 @@ export class ChatView extends ItemView {
});
}
setVectorStore(vectorStore: VaultVectorStore | undefined) {
this.vectorStore = vectorStore;
this.vaultIndexer.setVectorStore(vectorStore);
}
async clearCache(): Promise<void> {
await this.ollamaClient.clearCache();
}
@@ -567,6 +573,7 @@ export class ChatView extends ItemView {
private vaultIndexer: VaultIndexer;
private toolExecutor: ToolExecutor;
private conversationStateManager: ConversationStateManager;
private vectorStore?: VaultVectorStore;
}
const MAX_TOOL_CALLS = 5;