Project Files
docs / 03_IMPLEMENTATION_STRATEGY.md
@lmstudio/sdk and @langchain/langgraph.obsidian_vault_path, zotero_db_path) in LM Studio's UI.obsidian.ts. Set up chokidar to scan the vault. Extract [[wikilinks]].zotero.ts. Set up better-sqlite3 to connect to Zotero, query attachments, and parse PDFs via pdf-parse.LanceDB (or a Pure-JS alternative if cross-OS compilation fails). Define the schema explicitly to include links_to and source metadata.State object to hold conversation history, intermediate documents, and routing status.Problem 1 (Connectivity): The plugin code is developed and served from WSL2 Linux, but needs to be loaded into LM Studio running on Windows.
Mitigation 1: This is actually straightforward! When you run npx lms dev inside WSL2, it spins up a local development server on localhost. Because WSL2 natively shares network ports with the Windows host, your Windows LM Studio application can connect directly to localhost to hot-reload the plugin without any manual IP routing.
Problem 2 (Native Binary Mismatch): This is the dangerous one. If you run npm install inside WSL2, npm will download Linux (linux-x64) binaries for native modules like better-sqlite3 and @lancedb/lancedb. When the Windows LM Studio runtime tries to execute this code, it will crash because it expects Windows (win32-x64) binaries.
Mitigation 2:
npm) to explicitly download and bundle the prebuilds for and , even though we are installing them from Linux.Problem: Zotero locks its zotero.sqlite database when the application is open.
Mitigation: Connect to the database using a strict read-only flag or periodically copy the database to a temporary location to query the copy safely.
Problem: Even ignoring WSL2, @lancedb/lancedb relies on native Rust/C++ bindings (Node-API). When running inside a sandboxed runtime like LM Studio extensions, native modules can sometimes fail to load.
Mitigation: We must ensure we pull the correct prebuilds. If LanceDB fails to load, pivot to a pure-JS vector store as mentioned above.
Problem: A LangGraph workflow runs in the background. If the model takes 30 seconds to retrieve, grade, and rewrite a query, the LM Studio UI will appear frozen, causing terrible user friction.
Mitigation: The LangGraph execution loop must be asynchronous. We will use LangGraph's streaming capabilities (graph.streamEvents()) to intercept node transitions and send intermediate status messages (e.g., "🔍 Searching Obsidian...", "⚖️ Evaluating relevance...") to the LM Studio chat UI.
Problem: Passing retrieved documents through a Grader node and then to a Synthesizer node can quickly blow up the token context window of smaller models (8k-16k tokens), causing OOM errors. Mitigation:
top_k = 3 limits on retrieval.Problem: Smaller models frequently fail to output clean JSON, which LangGraph nodes often require to make routing decisions (e.g., outputting {"relevant": true}).
Mitigation:
win32-x64better-sqlite3lancedbbetter-sqlite3 for sql.js (WebAssembly) and LanceDB for a pure-JS vector DB like voy or hnswlib-node (WASM). Pure JS/WASM modules are OS-agnostic and will run perfectly in both WSL2 and Windows.