mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-30 17:14:40 +08:00
138 lines
4.5 KiB
Diff
138 lines
4.5 KiB
Diff
diff --git a/src/download.ts b/src/download.ts
|
|
index 3454256..6dca25a 100644
|
|
--- a/src/download.ts
|
|
+++ b/src/download.ts
|
|
@@ -7,7 +7,7 @@
|
|
*/
|
|
|
|
+declare const FFF_LIBC: "gnu" | "musl";
|
|
import { existsSync } from "node:fs";
|
|
-import { createRequire } from "node:module";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { getLibFilename, getNpmPackageName } from "./platform";
|
|
@@ -54,14 +54,10 @@ export function binaryExists(): boolean {
|
|
* in the same directory.
|
|
*/
|
|
function resolveFromNpmPackage(): string | null {
|
|
- const packageName = getNpmPackageName();
|
|
-
|
|
try {
|
|
- // Use createRequire to resolve the platform package's location
|
|
- const require = createRequire(join(getPackageDir(), "package.json"));
|
|
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
- const packageDir = dirname(packageJsonPath);
|
|
- const binaryPath = join(packageDir, getLibFilename());
|
|
+ const binaryPath = require(
|
|
+ `@ff-labs/fff-bin-${process.platform === "linux" ? `linux-${process.arch}-${typeof FFF_LIBC === "string" ? FFF_LIBC : getNpmPackageName().endsWith("musl") ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`}/${process.platform === "win32" ? "fff_c.dll" : process.platform === "darwin" ? "libfff_c.dylib" : "libfff_c.so"}`,
|
|
+ );
|
|
|
|
if (existsSync(binaryPath)) {
|
|
return binaryPath;
|
|
diff --git a/src/ffi.ts b/src/ffi.ts
|
|
--- a/src/ffi.ts
|
|
+++ b/src/ffi.ts
|
|
@@ -328,6 +328,10 @@
|
|
return new TextEncoder().encode(`${s}\0`);
|
|
}
|
|
-
|
|
+
|
|
+function asResult(value: Pointer | bigint | null): Pointer | null {
|
|
+ return value as unknown as Pointer | null;
|
|
+}
|
|
+
|
|
/**
|
|
* Convert snake_case keys to camelCase recursively
|
|
*/
|
|
@@ -1121,4 +1126,4 @@
|
|
minComboCount,
|
|
);
|
|
- return parseSearchResult(resultPtr);
|
|
+ return parseSearchResult(asResult(resultPtr));
|
|
}
|
|
@@ -1145,4 +1150,4 @@
|
|
pageSize,
|
|
);
|
|
- return parseSearchResult(resultPtr);
|
|
+ return parseSearchResult(asResult(resultPtr));
|
|
}
|
|
@@ -1168,4 +1173,4 @@
|
|
pageSize,
|
|
);
|
|
- return parseDirSearchResult(resultPtr);
|
|
+ return parseDirSearchResult(asResult(resultPtr));
|
|
}
|
|
@@ -1195,4 +1200,4 @@
|
|
minComboCount,
|
|
);
|
|
- return parseMixedSearchResult(resultPtr);
|
|
+ return parseMixedSearchResult(asResult(resultPtr));
|
|
}
|
|
@@ -1230,4 +1235,4 @@
|
|
classifyDefinitions,
|
|
);
|
|
- return parseGrepResult(resultPtr);
|
|
+ return parseGrepResult(asResult(resultPtr));
|
|
}
|
|
@@ -1265,4 +1270,4 @@
|
|
classifyDefinitions,
|
|
);
|
|
- return parseGrepResult(resultPtr);
|
|
+ return parseGrepResult(asResult(resultPtr));
|
|
}
|
|
@@ -1274,4 +1279,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_scan_files(handle);
|
|
- return parseVoidResult(resultPtr);
|
|
+ return parseVoidResult(asResult(resultPtr));
|
|
}
|
|
@@ -1291,4 +1296,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_get_base_path(handle);
|
|
- return parseStringResult(resultPtr);
|
|
+ return parseStringResult(asResult(resultPtr));
|
|
}
|
|
@@ -1336,4 +1341,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_wait_for_scan(handle, BigInt(timeoutMs));
|
|
- return parseBoolResult(resultPtr);
|
|
+ return parseBoolResult(asResult(resultPtr));
|
|
}
|
|
@@ -1351,4 +1356,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_restart_index(handle, ptr(encodeString(newPath)));
|
|
- return parseVoidResult(resultPtr);
|
|
+ return parseVoidResult(asResult(resultPtr));
|
|
}
|
|
@@ -1360,4 +1365,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_refresh_git_status(handle);
|
|
- return parseIntResult(resultPtr);
|
|
+ return parseIntResult(asResult(resultPtr));
|
|
}
|
|
@@ -1377,4 +1382,4 @@
|
|
ptr(encodeString(filePath)),
|
|
);
|
|
- return parseBoolResult(resultPtr);
|
|
+ return parseBoolResult(asResult(resultPtr));
|
|
}
|
|
@@ -1392,4 +1397,4 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_get_historical_query(handle, BigInt(offset));
|
|
- return parseStringResult(resultPtr);
|
|
+ return parseStringResult(asResult(resultPtr));
|
|
}
|
|
@@ -1306,3 +1311,3 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_get_scan_progress(handle);
|
|
- const envelope = readResultEnvelope(resultPtr);
|
|
+ const envelope = readResultEnvelope(asResult(resultPtr));
|
|
@@ -1406,6 +1411,6 @@
|
|
const library = loadLibrary();
|
|
const resultPtr = library.symbols.fff_health_check(
|
|
handle ?? (0 as unknown as Pointer),
|
|
ptr(encodeString(testPath)),
|
|
);
|
|
- return parseJsonResult<unknown>(resultPtr);
|
|
+ return parseJsonResult<unknown>(asResult(resultPtr));
|