@kentwynn/kgraph 0.2.24 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/grammars/tree-sitter-bash.wasm +0 -0
- package/dist/grammars/tree-sitter-c.wasm +0 -0
- package/dist/grammars/tree-sitter-c_sharp.wasm +0 -0
- package/dist/grammars/tree-sitter-cpp.wasm +0 -0
- package/dist/grammars/tree-sitter-css.wasm +0 -0
- package/dist/grammars/tree-sitter-dart.wasm +0 -0
- package/dist/grammars/tree-sitter-elixir.wasm +0 -0
- package/dist/grammars/tree-sitter-go.wasm +0 -0
- package/dist/grammars/tree-sitter-html.wasm +0 -0
- package/dist/grammars/tree-sitter-java.wasm +0 -0
- package/dist/grammars/tree-sitter-json.wasm +0 -0
- package/dist/grammars/tree-sitter-kotlin.wasm +0 -0
- package/dist/grammars/tree-sitter-lua.wasm +0 -0
- package/dist/grammars/tree-sitter-php.wasm +0 -0
- package/dist/grammars/tree-sitter-python.wasm +0 -0
- package/dist/grammars/tree-sitter-ruby.wasm +0 -0
- package/dist/grammars/tree-sitter-rust.wasm +0 -0
- package/dist/grammars/tree-sitter-scala.wasm +0 -0
- package/dist/grammars/tree-sitter-yaml.wasm +0 -0
- package/dist/scanner/tree-sitter-parser.js +28 -2
- package/package.json +13 -12
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import { createRequire } from 'node:module';
|
|
2
3
|
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
3
5
|
import { Language, Parser } from 'web-tree-sitter';
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
4
7
|
const require = createRequire(import.meta.url);
|
|
5
8
|
let initPromise = null;
|
|
6
9
|
const languageCache = new Map();
|
|
@@ -42,8 +45,31 @@ async function ensureInit() {
|
|
|
42
45
|
}
|
|
43
46
|
function resolveWasmPath(grammarKey) {
|
|
44
47
|
const { pkg, wasm } = GRAMMAR_PACKAGES[grammarKey];
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
// Production: bundled in dist/grammars/
|
|
49
|
+
const bundled = path.join(__dirname, '..', 'grammars', wasm);
|
|
50
|
+
if (fs.existsSync(bundled))
|
|
51
|
+
return bundled;
|
|
52
|
+
// Development: resolve from node_modules
|
|
53
|
+
try {
|
|
54
|
+
const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
|
|
55
|
+
const fromPkg = path.join(pkgDir, wasm);
|
|
56
|
+
if (fs.existsSync(fromPkg))
|
|
57
|
+
return fromPkg;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// package not installed
|
|
61
|
+
}
|
|
62
|
+
// Fallback: tree-sitter-wasms package
|
|
63
|
+
try {
|
|
64
|
+
const wasmsDir = path.join(path.dirname(require.resolve('tree-sitter-wasms/package.json')), 'out');
|
|
65
|
+
const fromWasms = path.join(wasmsDir, wasm);
|
|
66
|
+
if (fs.existsSync(fromWasms))
|
|
67
|
+
return fromWasms;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// tree-sitter-wasms not installed
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`Cannot find ${wasm} for grammar "${grammarKey}". Run "npm run build" or install dev dependencies.`);
|
|
47
73
|
}
|
|
48
74
|
export async function loadLanguage(grammarKey) {
|
|
49
75
|
const cached = languageCache.get(grammarKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kentwynn/kgraph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.26",
|
|
4
4
|
"description": "Persistent repo intelligence for AI coding assistants.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"clean": "node scripts/clean-dist.mjs",
|
|
17
|
-
"build": "npm run clean && tsc -p tsconfig.json",
|
|
17
|
+
"build": "npm run clean && tsc -p tsconfig.json && node scripts/bundle-grammars.mjs",
|
|
18
18
|
"postbuild": "node -e \"try{require('child_process').execSync('chmod +x dist/cli/index.js')}catch{}\"",
|
|
19
19
|
"test": "vitest run",
|
|
20
20
|
"kgraph": "tsx src/cli/index.ts",
|
|
@@ -44,11 +44,19 @@
|
|
|
44
44
|
"homepage": "https://github.com/kentwynn/KGraph#readme",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@clack/prompts": "^1.3.0",
|
|
47
|
-
"@tree-sitter-grammars/tree-sitter-kotlin": "^1.1.0",
|
|
48
|
-
"@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
|
|
49
47
|
"chalk": "^5.6.2",
|
|
50
48
|
"commander": "^12.1.0",
|
|
51
49
|
"fast-glob": "^3.3.2",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"web-tree-sitter": "^0.26.8",
|
|
52
|
+
"yaml": "^2.5.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@release-it/conventional-changelog": "^11.0.0",
|
|
56
|
+
"@tree-sitter-grammars/tree-sitter-kotlin": "^1.1.0",
|
|
57
|
+
"@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
|
|
58
|
+
"@types/node": "^20.17.10",
|
|
59
|
+
"release-it": "^20.0.1",
|
|
52
60
|
"tree-sitter-bash": "^0.25.1",
|
|
53
61
|
"tree-sitter-c": "^0.24.1",
|
|
54
62
|
"tree-sitter-c-sharp": "^0.23.5",
|
|
@@ -66,14 +74,7 @@
|
|
|
66
74
|
"tree-sitter-ruby": "^0.23.1",
|
|
67
75
|
"tree-sitter-rust": "^0.24.0",
|
|
68
76
|
"tree-sitter-scala": "^0.24.0",
|
|
69
|
-
"
|
|
70
|
-
"web-tree-sitter": "^0.26.8",
|
|
71
|
-
"yaml": "^2.5.1"
|
|
72
|
-
},
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"@release-it/conventional-changelog": "^11.0.0",
|
|
75
|
-
"@types/node": "^20.17.10",
|
|
76
|
-
"release-it": "^20.0.1",
|
|
77
|
+
"tree-sitter-wasms": "^0.1.13",
|
|
77
78
|
"tsx": "^4.19.2",
|
|
78
79
|
"vitest": "^3.2.4"
|
|
79
80
|
},
|