Skip to content

Commit 9261b28

Browse files
committed
fix bundled paths for wasm
1 parent fc7ac8d commit 9261b28

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

packages/code-map/src/init-node.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,33 @@ export async function initTreeSitterForNode(): Promise<void> {
3434
const dir = hereDir()
3535

3636
// Try shared WASM directory first (new approach to avoid duplication)
37-
const sharedWasm = path.join(dir, '..', 'wasm', 'tree-sitter.wasm')
37+
const sharedWasms = [
38+
path.join(dir, '..', 'wasm', 'tree-sitter.wasm'),
39+
path.join(dir, 'wasm', 'tree-sitter.wasm'),
40+
]
3841

3942
// Use locateFile to override where the runtime looks for tree-sitter.wasm
4043
await Parser.init({
4144
locateFile: (name: string, scriptDir: string) => {
4245
if (name === 'tree-sitter.wasm') {
43-
// First try shared WASM directory (new approach)
44-
if (fs.existsSync(sharedWasm)) {
45-
return sharedWasm
46+
for (const sharedWasm of sharedWasms) {
47+
// First try shared WASM directory (new approach)
48+
if (fs.existsSync(sharedWasm)) {
49+
return sharedWasm
50+
}
4651
}
4752
// Fallback to script directory
4853
const fallback = path.join(scriptDir, name)
4954
if (fs.existsSync(fallback)) {
5055
return fallback
5156
}
57+
for (const sharedWasm of sharedWasms) {
58+
if (fs.existsSync(path.dirname(sharedWasm))) {
59+
return sharedWasm
60+
}
61+
}
5262
// Return our preferred path and let web-tree-sitter handle the error
53-
return sharedWasm
63+
return sharedWasms[0]
5464
}
5565
// For other files, use default behavior
5666
return path.join(scriptDir, name)

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codebuff/sdk",
33
"private": false,
4-
"version": "0.3.10",
4+
"version": "0.3.11",
55
"description": "Official SDK for Codebuff — AI coding agent & framework",
66
"license": "Apache-2.0",
77
"type": "module",

sdk/src/native/ripgrep.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ export function getBundledRgPath(importMetaUrl?: string): string {
7777
if (existsSync(cjsPath)) {
7878
vendorPath = cjsPath
7979
}
80+
const cjsPath2 = join(
81+
dirname,
82+
'vendor',
83+
'ripgrep',
84+
platformDir,
85+
binaryName,
86+
)
87+
if (existsSync(cjsPath2)) {
88+
vendorPath = cjsPath2
89+
}
8090
}
8191
}
8292

0 commit comments

Comments
 (0)