@mathew-cf/rag-cli 0.0.0-bootstrap.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 +24 -0
- package/bin/rag.js +71 -0
- package/package.json +35 -0
- package/src/platform.js +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @mathew-cf/rag-cli
|
|
2
|
+
|
|
3
|
+
Local-first RAG CLI — semantic search over your files using local embeddings. All inference runs on your machine; no external API calls.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @mathew-cf/rag-cli
|
|
7
|
+
|
|
8
|
+
rag index ./my-project
|
|
9
|
+
rag search "how does authentication work"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
On install, npm fetches the prebuilt binary for your platform via `optionalDependencies`. Supported platforms: macOS ARM64, macOS x86_64, Linux x86_64, Linux ARM64.
|
|
13
|
+
|
|
14
|
+
On any other platform, install from source instead:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cargo install rag-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For the full command reference, see the [project README](https://github.com/mathew-cf/rag-cli#readme).
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
Apache-2.0
|
package/bin/rag.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Meta-package shim for @mathew-cf/rag-cli.
|
|
4
|
+
*
|
|
5
|
+
* Resolves the platform-specific subpackage at runtime and execs its
|
|
6
|
+
* `rag` binary. Signals are forwarded so Ctrl-C works; exit codes are
|
|
7
|
+
* propagated so shell scripts can branch on success/failure.
|
|
8
|
+
*
|
|
9
|
+
* The platform detection logic lives in ../src/platform.js so it's
|
|
10
|
+
* testable without spawning a process.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
const { spawn } = require("node:child_process");
|
|
16
|
+
const {
|
|
17
|
+
binaryFilename,
|
|
18
|
+
isSupported,
|
|
19
|
+
platformKey,
|
|
20
|
+
subpackageName,
|
|
21
|
+
unsupportedMessage,
|
|
22
|
+
} = require("../src/platform");
|
|
23
|
+
|
|
24
|
+
const key = platformKey(process.platform, process.arch);
|
|
25
|
+
|
|
26
|
+
if (!isSupported(key)) {
|
|
27
|
+
process.stderr.write(`${unsupportedMessage(key)}\n`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let binaryPath;
|
|
32
|
+
try {
|
|
33
|
+
binaryPath = require.resolve(
|
|
34
|
+
`${subpackageName(key)}/bin/${binaryFilename(process.platform)}`,
|
|
35
|
+
);
|
|
36
|
+
} catch {
|
|
37
|
+
process.stderr.write(
|
|
38
|
+
`@mathew-cf/rag-cli: platform package ${subpackageName(key)} is not installed.\n` +
|
|
39
|
+
`This usually means npm skipped optionalDependencies. Try:\n` +
|
|
40
|
+
` npm install @mathew-cf/rag-cli --force\n`,
|
|
41
|
+
);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
46
|
+
stdio: "inherit",
|
|
47
|
+
windowsHide: false,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Forward terminal signals to the child. Without this, ^C gets eaten by
|
|
51
|
+
// the Node wrapper and the spawned binary keeps running.
|
|
52
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"];
|
|
53
|
+
for (const sig of forwardedSignals) {
|
|
54
|
+
process.on(sig, () => {
|
|
55
|
+
if (!child.killed) child.kill(sig);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
child.on("error", (err) => {
|
|
60
|
+
process.stderr.write(`@mathew-cf/rag-cli: failed to exec binary: ${err.message}\n`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
child.on("exit", (code, signal) => {
|
|
65
|
+
if (signal) {
|
|
66
|
+
// Re-raise so the shell sees the canonical exit-via-signal (128+n).
|
|
67
|
+
process.kill(process.pid, signal);
|
|
68
|
+
} else {
|
|
69
|
+
process.exit(code ?? 1);
|
|
70
|
+
}
|
|
71
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mathew-cf/rag-cli",
|
|
3
|
+
"version": "0.0.0-bootstrap.0",
|
|
4
|
+
"description": "Local-first RAG CLI — semantic search over your files using local embeddings",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "mathew-cf",
|
|
7
|
+
"homepage": "https://github.com/mathew-cf/rag-cli",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/mathew-cf/rag-cli"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"rag",
|
|
14
|
+
"semantic-search",
|
|
15
|
+
"embeddings",
|
|
16
|
+
"cli",
|
|
17
|
+
"local-first"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"rag": "bin/rag.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin",
|
|
24
|
+
"src"
|
|
25
|
+
],
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@mathew-cf/rag-cli-darwin-arm64": "0.0.0-bootstrap.0",
|
|
28
|
+
"@mathew-cf/rag-cli-darwin-x64": "0.0.0-bootstrap.0",
|
|
29
|
+
"@mathew-cf/rag-cli-linux-x64": "0.0.0-bootstrap.0",
|
|
30
|
+
"@mathew-cf/rag-cli-linux-arm64": "0.0.0-bootstrap.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/platform.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform → subpackage mapping.
|
|
3
|
+
*
|
|
4
|
+
* Kept in its own module (and written as plain CommonJS) so:
|
|
5
|
+
* - the shim at `bin/rag.js` can `require()` it at runtime
|
|
6
|
+
* - unit tests can import it and call `platformKey()` with mocked
|
|
7
|
+
* values without spawning a shell or a child process.
|
|
8
|
+
*
|
|
9
|
+
* Update SUPPORTED_PLATFORMS in lockstep with `npm/rag-cli/package.json`
|
|
10
|
+
* `optionalDependencies` and the release workflow's build matrix.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Compose the platform key used in subpackage names.
|
|
17
|
+
* Mirrors Node's `process.platform` + `process.arch` convention.
|
|
18
|
+
* Exported so tests can feed synthetic platform/arch values without
|
|
19
|
+
* mutating process globals.
|
|
20
|
+
*/
|
|
21
|
+
function platformKey(platform, arch) {
|
|
22
|
+
return `${platform}-${arch}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The set of platforms we publish prebuilt binaries for. Anything
|
|
27
|
+
* outside this set falls back to `cargo install rag-cli`.
|
|
28
|
+
*/
|
|
29
|
+
const SUPPORTED_PLATFORMS = Object.freeze([
|
|
30
|
+
"darwin-arm64",
|
|
31
|
+
"darwin-x64",
|
|
32
|
+
"linux-x64",
|
|
33
|
+
"linux-arm64",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} key — result of platformKey(platform, arch)
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
function isSupported(key) {
|
|
41
|
+
return SUPPORTED_PLATFORMS.includes(key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* npm package name for a given platform key.
|
|
46
|
+
* The scope matches the meta package.
|
|
47
|
+
*/
|
|
48
|
+
function subpackageName(key) {
|
|
49
|
+
return `@mathew-cf/rag-cli-${key}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Name of the binary file inside a subpackage's `bin/` directory.
|
|
54
|
+
* Windows binaries would be `rag.exe`; Unix platforms use `rag`.
|
|
55
|
+
* Currently all supported platforms are Unix — this helper is the
|
|
56
|
+
* single place to update when/if win32 support lands.
|
|
57
|
+
*/
|
|
58
|
+
function binaryFilename(platform) {
|
|
59
|
+
return platform === "win32" ? "rag.exe" : "rag";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Build a human-readable diagnostic for unsupported platforms.
|
|
64
|
+
* Kept as a pure function so tests can snapshot the message.
|
|
65
|
+
*/
|
|
66
|
+
function unsupportedMessage(key) {
|
|
67
|
+
return [
|
|
68
|
+
`@mathew-cf/rag-cli: no prebuilt binary for ${key}.`,
|
|
69
|
+
`Supported platforms: ${SUPPORTED_PLATFORMS.join(", ")}.`,
|
|
70
|
+
``,
|
|
71
|
+
`Fallback: install from source via Rust:`,
|
|
72
|
+
` cargo install rag-cli`,
|
|
73
|
+
].join("\n");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
platformKey,
|
|
78
|
+
isSupported,
|
|
79
|
+
subpackageName,
|
|
80
|
+
binaryFilename,
|
|
81
|
+
unsupportedMessage,
|
|
82
|
+
SUPPORTED_PLATFORMS,
|
|
83
|
+
};
|