@samuelfaj/distill 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ # @samuelfaj/distill
2
+
3
+ Install with:
4
+
5
+ ```bash
6
+ npm i -g @samuelfaj/distill
7
+ ```
package/bin/distill.js ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const path = require("node:path");
5
+ const { createRequire } = require("node:module");
6
+
7
+ const requireFromHere = createRequire(__filename);
8
+
9
+ const PACKAGE_BY_TARGET = {
10
+ "darwin-arm64": "@samuelfaj/distill-darwin-arm64",
11
+ "darwin-x64": "@samuelfaj/distill-darwin-x64",
12
+ "linux-arm64": "@samuelfaj/distill-linux-arm64",
13
+ "linux-x64": "@samuelfaj/distill-linux-x64"
14
+ };
15
+
16
+ function resolveBinaryPath() {
17
+ const target = `${process.platform}-${process.arch}`;
18
+ const packageName = PACKAGE_BY_TARGET[target];
19
+
20
+ if (!packageName) {
21
+ console.error(
22
+ `[distill] Unsupported platform: ${process.platform}/${process.arch}.`
23
+ );
24
+ process.exit(1);
25
+ }
26
+
27
+ try {
28
+ const packageJsonPath = requireFromHere.resolve(`${packageName}/package.json`);
29
+ return path.join(path.dirname(packageJsonPath), "bin", "distill");
30
+ } catch (error) {
31
+ console.error(
32
+ `[distill] Missing platform package ${packageName}. Reinstall @samuelfaj/distill for this platform.`
33
+ );
34
+ process.exit(1);
35
+ }
36
+ }
37
+
38
+ const binPath = resolveBinaryPath();
39
+ const child = spawn(binPath, process.argv.slice(2), {
40
+ stdio: "inherit"
41
+ });
42
+
43
+ const forwardSignal = (signal) => {
44
+ if (!child.killed) {
45
+ child.kill(signal);
46
+ }
47
+ };
48
+
49
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((signal) => {
50
+ process.on(signal, () => forwardSignal(signal));
51
+ });
52
+
53
+ child.on("error", (error) => {
54
+ console.error(`[distill] Failed to launch native binary: ${error.message}`);
55
+ process.exit(1);
56
+ });
57
+
58
+ child.on("exit", (code, signal) => {
59
+ if (signal) {
60
+ process.removeAllListeners(signal);
61
+ process.kill(process.pid, signal);
62
+ return;
63
+ }
64
+
65
+ process.exit(code ?? 1);
66
+ });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@samuelfaj/distill",
3
+ "version": "0.1.0",
4
+ "description": "Compress command output for downstream LLMs.",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "distill": "bin/distill.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "optionalDependencies": {
17
+ "@samuelfaj/distill-darwin-arm64": "0.1.0",
18
+ "@samuelfaj/distill-darwin-x64": "0.1.0",
19
+ "@samuelfaj/distill-linux-arm64": "0.1.0",
20
+ "@samuelfaj/distill-linux-x64": "0.1.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ }
25
+ }