docs: add guide for using LanceDB in VS Code extensions - #371
Open
NishilRathod wants to merge 1 commit into
Open
NishilRathod wants to merge 1 commit into
NishilRathod wants to merge 1 commit into
Conversation
Adds an "AI Platforms & Frameworks" page that builds a small VS Code extension: it indexes workspace Markdown into an embedded LanceDB table and searches it with the local huggingface embedding function. The page covers the problems behind lancedb/lancedb#927 and #1713: relative database paths inside the extension host, esbuild and native .node binaries, the template's .vscodeignore dropping node_modules, per-platform VSIX packaging, and the Transformers.js model cache. The LanceDB code is tested in tests/ts/vscode_search.test.ts. The extension wiring in tests/ts/vscode_extension.ts was tested in a sample extension with @vscode/test-cli on VS Code 1.140 (Windows x64). Refs lancedb/lancedb#1849 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes lancedb/lancedb#1849
Why
lancedb/lancedb#1849 asks for an example of LanceDB in a VS Code extension, because people kept running into problems there (lancedb/lancedb#927, lancedb/lancedb#1713). An earlier attempt, lancedb/lancedb#3682, added a README link, and @prrao87 asked for something else instead: a quick guide in this repo, under Integrations › AI Platforms & Frameworks, showing how to use LanceDB in an extension and what results look like. The author of #3682 agreed and closed it. This PR is that guide.
What it adds
docs/integrations/ai/vscode.mdx: a new page, also added todocs.json. It builds a small extension with two commands. One indexes the workspace's Markdown into a LanceDB table using the built-inhuggingfaceembedding function, so no API key is needed. The other searches it by meaning. The page covers the parts that are specific to VS Code:context.storageUriinstead of a relative path, which is the cause of #927;@types/node≥ 22 andskipLibCheck, which covers #1713 and the DOM-type errors fromapache-arrow/onnxruntime typings;apache-arrowinside LanceDB's peer range;@lancedb/lancedband@huggingface/transformersas esbuild externals, and removingnode_modules/**from the template's.vscodeignore;vsce package --target, with a table mapping each target to LanceDB's native package;globalStorageUri, which only works if it's loaded withimport();tests/ts/vscode_search.tsandtests/ts/vscode_search.test.ts: the LanceDB code the page shows (connect, chunk, index, search), plus jest tests for it.tests/ts/vscode_extension.ts: the extension'ssrc/extension.ts. Jest can't run it because it needs the VS Code extension host, so it was tested in a real extension instead (see below). This follows the precedent oftests/ts/integrations.ts.docs/snippets/vscode_search.mdxanddocs/snippets/vscode_extension.mdx: generated withscripts/mdx_snippets_gen.py.How I tested it
vscode_search.test.tspasses (2 tests) with the repo's pinned@lancedb/lancedb0.31.0. On Windows thenpm testscript fails before it starts, because it runsnodeon the.bin/jestshell shim. I rannode --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment jest-environment-node-single-context vscode_searchinstead.biome ciis clean for the three new files.yo code(TypeScript + esbuild) and using@lancedb/lancedb0.39.0. I ran it with@vscode/test-cliin VS Code 1.140 on Windows x64. The integration test runs both commands against a six-file workspace and checks the top hits. The "Sample results" block on the page is copied from that run.vsce package --target win32-x64(200 MB, or 148 MB with the onnxruntime trimming in the Tip). Then I unpacked it outside the project and ran the same tests against the unpacked copy, so they couldn't pick up the project'snode_modules. They pass.node_modules/**left in.vscodeignore, activation fails withCannot find module '@lancedb/lancedb'and the commands reportcommand '…' not found.No loader is configured for ".node" files.apache-arrow21 fails withERESOLVE.require("@huggingface/transformers")returns a differentenvobject fromimport().mint devrenders the page, its 14 code blocks and the sidebar entry. Locally,mint broken-linksreports the same 81 entries with and without this change, none on the new page.Not tested:
Notes for reviewers
scripts/mdx_snippets_gen.py -s tests/tsalso rewritesdocs/snippets/storage.mdx. It dropsTsStorageGoosefsConnect, which exists only in the.mdxfile and not intests/ts/storage.test.ts, and it reorders the COS and GooseFS exports. I left that file out of this PR, but the next person who regenerates TS snippets will hit the same thing._distanceto.select(...), because LanceDB warns that it will stop adding the column automatically.AI disclosure
I used Claude Code to research the issue and its history, write the sample extension, the tests and this page, and draft this description. I ran every check listed above myself, and the outputs quoted on the page come from those runs.
🤖 Generated with Claude Code