Skip to content

Commit 798cf73

Browse files
authored
Merge pull request #1 from daniel-lxs/semantic-search-cleanup
Semantic search cleanup
2 parents e29ce27 + 2742439 commit 798cf73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4824
-1022
lines changed

.eslintrc.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33
"parser": "@typescript-eslint/parser",
44
"parserOptions": {
55
"ecmaVersion": 6,
6-
"sourceType": "module"
6+
"sourceType": "module",
7+
"project": "./tsconfig.json"
78
},
89
"plugins": ["@typescript-eslint"],
910
"rules": {
10-
"@typescript-eslint/naming-convention": [
11-
"warn",
12-
{
13-
"selector": "import",
14-
"format": ["camelCase", "PascalCase"]
15-
}
16-
],
11+
"no-var": "error",
12+
"no-unused-vars": "off",
13+
"@typescript-eslint/no-unused-vars": "warn",
14+
"@typescript-eslint/no-explicit-any": "warn",
15+
"@typescript-eslint/no-misused-promises": "error",
16+
"@typescript-eslint/await-thenable": "warn",
17+
"@typescript-eslint/return-await": "error",
18+
"@typescript-eslint/explicit-function-return-type": "warn",
1719
"@typescript-eslint/semi": "off",
1820
"eqeqeq": "warn",
1921
"no-throw-literal": "warn",
2022
"semi": "off"
2123
},
22-
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
24+
"ignorePatterns": ["out", "dist", "**/*.d.ts", "jest.*.js"],
25+
"overrides": [
26+
{
27+
"files": ["webview-ui/src/**/*.tsx"],
28+
"parserOptions": {
29+
"project": "./webview-ui/tsconfig.json"
30+
}
31+
}
32+
]
2333
}

.husky/pre-commit

Lines changed: 0 additions & 8 deletions
This file was deleted.

esbuild.js

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const esbuild = require("esbuild")
2+
const { copy } = require("esbuild-plugin-copy")
23
const fs = require("fs")
34
const path = require("path")
45

@@ -25,40 +26,14 @@ const esbuildProblemMatcherPlugin = {
2526
},
2627
}
2728

28-
const copyWasmFiles = {
29-
name: "copy-wasm-files",
29+
// Plugin to handle native .node files
30+
const nativeNodeModulesPlugin = {
31+
name: "native-node-modules",
3032
setup(build) {
31-
build.onEnd(() => {
32-
// tree sitter
33-
const sourceDir = path.join(__dirname, "node_modules", "web-tree-sitter")
34-
const targetDir = path.join(__dirname, "dist")
35-
36-
// Copy tree-sitter.wasm
37-
fs.copyFileSync(path.join(sourceDir, "tree-sitter.wasm"), path.join(targetDir, "tree-sitter.wasm"))
38-
39-
// Copy language-specific WASM files
40-
const languageWasmDir = path.join(__dirname, "node_modules", "tree-sitter-wasms", "out")
41-
const languages = [
42-
"typescript",
43-
"tsx",
44-
"python",
45-
"rust",
46-
"javascript",
47-
"go",
48-
"cpp",
49-
"c",
50-
"c_sharp",
51-
"ruby",
52-
"java",
53-
"php",
54-
"swift",
55-
]
56-
57-
languages.forEach((lang) => {
58-
const filename = `tree-sitter-${lang}.wasm`
59-
fs.copyFileSync(path.join(languageWasmDir, filename), path.join(targetDir, filename))
60-
})
61-
})
33+
build.onResolve({ filter: /\.node$/ }, (args) => ({
34+
path: args.path,
35+
external: true, // Already correctly marked as external
36+
}))
6237
},
6338
}
6439

@@ -67,9 +42,27 @@ const extensionConfig = {
6742
minify: production,
6843
sourcemap: !production,
6944
logLevel: "silent",
45+
assetNames: "[name]",
7046
plugins: [
71-
copyWasmFiles,
72-
/* add to the end of plugins array */
47+
copy({
48+
resolveFrom: "cwd",
49+
assets: [
50+
{
51+
from: "./node_modules/tree-sitter-wasms/out/**/*.wasm",
52+
to: "./dist/",
53+
},
54+
{
55+
from: "./node_modules/web-tree-sitter/tree-sitter.wasm",
56+
to: "./dist/",
57+
},
58+
{
59+
from: "./node_modules/@lancedb/**/*.node",
60+
to: "./dist/",
61+
},
62+
],
63+
watch: true,
64+
}),
65+
nativeNodeModulesPlugin,
7366
esbuildProblemMatcherPlugin,
7467
],
7568
entryPoints: ["src/extension.ts"],
@@ -78,6 +71,7 @@ const extensionConfig = {
7871
platform: "node",
7972
outfile: "dist/extension.js",
8073
external: ["vscode"],
74+
loader: { ".node": "file" },
8175
}
8276

8377
async function main() {

jest.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ module.exports = {
77
"^.+\\.tsx?$": [
88
"ts-jest",
99
{
10-
tsconfig: {
11-
module: "CommonJS",
12-
moduleResolution: "node",
13-
esModuleInterop: true,
14-
allowJs: true,
15-
},
16-
diagnostics: false,
17-
isolatedModules: true,
10+
tsconfig: "tsconfig.json",
1811
},
1912
],
2013
},
@@ -30,9 +23,11 @@ module.exports = {
3023
"^strip-ansi$": "<rootDir>/src/__mocks__/strip-ansi.js",
3124
"^default-shell$": "<rootDir>/src/__mocks__/default-shell.js",
3225
"^os-name$": "<rootDir>/src/__mocks__/os-name.js",
26+
"^(\\.{1,2}/.*)\\.js$": "$1",
27+
"^@xenova/transformers$": "<rootDir>/src/services/semantic-search/embeddings/__mocks__/transformers.ts",
3328
},
3429
transformIgnorePatterns: [
35-
"node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|globby|serialize-error|strip-ansi|default-shell|os-name)/)",
30+
"node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|globby|serialize-error|strip-ansi|default-shell|os-name|@xenova/transformers)/)",
3631
],
3732
roots: ["<rootDir>/src", "<rootDir>/webview-ui/src"],
3833
modulePathIgnorePatterns: [".vscode-test"],

0 commit comments

Comments
 (0)