@trouve-ai/search-core 2.0.0
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/README.md +14 -0
- package/bin/trouve-search.js +21 -0
- package/package.json +51 -0
- package/src/platform.d.ts +5 -0
- package/src/platform.js +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @trouve-ai/search-core
|
|
2
|
+
|
|
3
|
+
Native `trouve-search` binary distribution and MCP launcher for Node.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @trouve-ai/search-core
|
|
7
|
+
trouve-search search "auth flow" ./repo
|
|
8
|
+
npx -y @trouve-ai/search-core # MCP stdio server
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Platform-specific binaries (`@trouve-ai/search-linux-x64-gnu`, etc.) install
|
|
12
|
+
automatically via optional dependencies. Requires Node 18+ (Bun also works).
|
|
13
|
+
|
|
14
|
+
Exports `resolveBinaryPath()` for other packages (e.g. the harness plugin).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Launch the native trouve-search binary (MCP stdio server by default).
|
|
3
|
+
import { spawnSync } from "node:child_process"
|
|
4
|
+
import { resolveBinaryPath } from "../src/platform.js"
|
|
5
|
+
|
|
6
|
+
const bin = resolveBinaryPath()
|
|
7
|
+
const result = spawnSync(bin, process.argv.slice(2), {
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
env: process.env,
|
|
10
|
+
})
|
|
11
|
+
if (result.error) {
|
|
12
|
+
const msg = result.error.message
|
|
13
|
+
console.error(
|
|
14
|
+
/ENOENT|executable|not.*found/i.test(msg)
|
|
15
|
+
? "trouve-search: binary not found. Reinstall @trouve-ai/search-core or install " +
|
|
16
|
+
"trouve-search with `cargo install trouve-search`."
|
|
17
|
+
: `trouve-search: ${msg}`,
|
|
18
|
+
)
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
process.exit(result.status ?? 1)
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@trouve-ai/search-core",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "trouve-search native binary and MCP launcher for Node. Platform-specific binaries install via optional dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/platform.d.ts",
|
|
9
|
+
"default": "./src/platform.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"trouve-search": "./bin/trouve-search.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"code-search",
|
|
24
|
+
"semantic-search",
|
|
25
|
+
"mcp",
|
|
26
|
+
"trouve"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/jimsimon/trouve.git",
|
|
32
|
+
"directory": "npm/search-core"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"typecheck": "tsc --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"optionalDependencies": {
|
|
38
|
+
"@trouve-ai/search-darwin-arm64": "2.0.0",
|
|
39
|
+
"@trouve-ai/search-darwin-x64": "2.0.0",
|
|
40
|
+
"@trouve-ai/search-linux-arm64-gnu": "2.0.0",
|
|
41
|
+
"@trouve-ai/search-linux-arm64-musl": "2.0.0",
|
|
42
|
+
"@trouve-ai/search-linux-x64-gnu": "2.0.0",
|
|
43
|
+
"@trouve-ai/search-linux-x64-musl": "2.0.0",
|
|
44
|
+
"@trouve-ai/search-win32-arm64": "2.0.0",
|
|
45
|
+
"@trouve-ai/search-win32-x64": "2.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^22.0.0",
|
|
49
|
+
"typescript": "^6.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/platform.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Resolve the native trouve-search binary shipped in a platform package.
|
|
2
|
+
// Plain ESM JavaScript so it runs under Node (npx) and Bun alike.
|
|
3
|
+
import { execSync } from "node:child_process"
|
|
4
|
+
import { existsSync } from "node:fs"
|
|
5
|
+
import { createRequire } from "node:module"
|
|
6
|
+
import { arch, platform } from "node:os"
|
|
7
|
+
import { dirname, join } from "node:path"
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url)
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* npm package name for the current OS/arch/libc.
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function platformPackageName() {
|
|
16
|
+
const os = platform()
|
|
17
|
+
const cpu = arch()
|
|
18
|
+
if (cpu !== "x64" && cpu !== "arm64") {
|
|
19
|
+
throw new Error(`Unsupported platform: ${os}-${cpu}`)
|
|
20
|
+
}
|
|
21
|
+
if (os === "linux") {
|
|
22
|
+
const libc = isMusl() ? "musl" : "gnu"
|
|
23
|
+
return `@trouve-ai/search-linux-${cpu}-${libc}`
|
|
24
|
+
}
|
|
25
|
+
if (os === "darwin") {
|
|
26
|
+
return `@trouve-ai/search-darwin-${cpu}`
|
|
27
|
+
}
|
|
28
|
+
if (os === "win32") {
|
|
29
|
+
return `@trouve-ai/search-win32-${cpu}`
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Unsupported platform: ${os}-${cpu}`)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @returns {boolean} */
|
|
35
|
+
function isMusl() {
|
|
36
|
+
try {
|
|
37
|
+
const out = execSync("ldd /bin/sh 2>/dev/null || true", {
|
|
38
|
+
encoding: "utf8",
|
|
39
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
40
|
+
})
|
|
41
|
+
return out.includes("musl")
|
|
42
|
+
} catch {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @returns {string} */
|
|
48
|
+
function binaryFileName() {
|
|
49
|
+
return platform() === "win32" ? "trouve-search.exe" : "trouve-search"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Absolute path to the bundled binary, or the bare binary name for PATH fallback.
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
export function resolveBinaryPath() {
|
|
57
|
+
const pkg = platformPackageName()
|
|
58
|
+
try {
|
|
59
|
+
const pkgJson = require.resolve(`${pkg}/package.json`)
|
|
60
|
+
const bin = join(dirname(pkgJson), "bin", binaryFileName())
|
|
61
|
+
if (existsSync(bin)) return bin
|
|
62
|
+
} catch {
|
|
63
|
+
// Platform package not installed (e.g. dev checkout without optional deps).
|
|
64
|
+
}
|
|
65
|
+
return binaryFileName()
|
|
66
|
+
}
|