@pentoshi/clai 3.11.15 → 3.11.16

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.
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Postinstall script for @pentoshi/clai.
4
+ * Automatically checks for Bun (required by OpenTUI) and installs it into
5
+ * ~/.clai/bin/bun across Linux, macOS, and Windows if missing.
6
+ */
7
+ import { spawnSync } from "node:child_process";
8
+ import { accessSync, chmodSync, constants, existsSync, mkdirSync } from "node:fs";
9
+ import { homedir } from "node:os";
10
+ import { delimiter, join } from "node:path";
11
+
12
+ function findBun() {
13
+ const binName = process.platform === "win32" ? "bun.exe" : "bun";
14
+ const fromEnv = process.env.BUN_INSTALL
15
+ ? join(process.env.BUN_INSTALL, "bin", binName)
16
+ : undefined;
17
+ const targetDir = join(homedir(), ".clai");
18
+ const candidates = [
19
+ fromEnv,
20
+ join(targetDir, "bin", binName),
21
+ join(homedir(), ".bun", "bin", binName),
22
+ ...(process.env.PATH ?? "")
23
+ .split(delimiter)
24
+ .filter(Boolean)
25
+ .map((dir) => join(dir, binName)),
26
+ ].filter(Boolean);
27
+
28
+ const checkMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
29
+
30
+ for (const path of candidates) {
31
+ try {
32
+ accessSync(path, checkMode);
33
+ return path;
34
+ } catch {
35
+ // try next
36
+ }
37
+ }
38
+ return undefined;
39
+ }
40
+
41
+ if (!findBun() && process.env.CLAI_NO_BUN_AUTO_INSTALL !== "1") {
42
+ const targetDir = join(homedir(), ".clai");
43
+ const binName = process.platform === "win32" ? "bun.exe" : "bun";
44
+ const targetBin = join(targetDir, "bin", binName);
45
+
46
+ mkdirSync(join(targetDir, "bin"), { recursive: true });
47
+
48
+ const env = {
49
+ ...process.env,
50
+ BUN_INSTALL: targetDir,
51
+ };
52
+
53
+ console.log("Setting up Bun runtime for OpenTUI (~/.clai/bin)...");
54
+ try {
55
+ if (process.platform === "win32") {
56
+ spawnSync(
57
+ "powershell",
58
+ [
59
+ "-NoProfile",
60
+ "-ExecutionPolicy",
61
+ "Bypass",
62
+ "-Command",
63
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; irm https://bun.sh/install.ps1 | iex",
64
+ ],
65
+ { env, stdio: "inherit", windowsHide: true },
66
+ );
67
+ } else {
68
+ const res = spawnSync(
69
+ "sh",
70
+ ["-c", "curl -fsSL https://bun.sh/install | bash"],
71
+ { env, stdio: "inherit" },
72
+ );
73
+
74
+ if (res.status !== 0) {
75
+ spawnSync(
76
+ "sh",
77
+ ["-c", "wget -qO- https://bun.sh/install | bash"],
78
+ { env, stdio: "inherit" },
79
+ );
80
+ }
81
+ }
82
+
83
+ if (existsSync(targetBin) && process.platform !== "win32") {
84
+ try {
85
+ chmodSync(targetBin, 0o755);
86
+ } catch {
87
+ // ignore
88
+ }
89
+ }
90
+ } catch (err) {
91
+ console.warn("Notice: Automatic Bun setup skipped or failed:", err?.message || err);
92
+ }
93
+ }
@@ -2,5 +2,5 @@
2
2
  * AUTO-GENERATED by scripts/sync-version.mjs — do not edit by hand.
3
3
  * Source of truth: package.json "version".
4
4
  */
5
- export declare const VERSION: "3.11.15";
6
- export declare const VERSION_TAG: "v3.11.15";
5
+ export declare const VERSION: "3.11.16";
6
+ export declare const VERSION_TAG: "v3.11.16";
@@ -2,6 +2,6 @@
2
2
  * AUTO-GENERATED by scripts/sync-version.mjs — do not edit by hand.
3
3
  * Source of truth: package.json "version".
4
4
  */
5
- export const VERSION = "3.11.15";
6
- export const VERSION_TAG = "v3.11.15";
5
+ export const VERSION = "3.11.16";
6
+ export const VERSION_TAG = "v3.11.16";
7
7
  //# sourceMappingURL=version.generated.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pentoshi/clai",
3
- "version": "3.11.15",
3
+ "version": "3.11.16",
4
4
  "description": "A fast, cross-platform AI CLI assistant with ask and agent modes for shell tasks, file operations, and cybersecurity workflows.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "prepublishOnly": "npm run build",
47
47
  "precompile": "node scripts/sync-version.mjs",
48
48
  "compile": "node scripts/embed-prompts.mjs && bun run scripts/build.ts",
49
- "postinstall": "node scripts/postinstall.mjs",
49
+ "postinstall": "node bin/postinstall.mjs",
50
50
  "install:opentui-platforms": "node scripts/install-opentui-platforms.mjs",
51
51
  "typecheck": "tsc -p tsconfig.json --noEmit",
52
52
  "pretest": "node scripts/sync-version.mjs",