claudish 13.0.0 → 13.0.1

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,104 @@
1
+ // Which environment names Bun's env-file autoload sets in a directory — asked of Bun.
2
+ //
3
+ // Bun loads `.env`, `.env.local`, `.env.<NODE_ENV>` and `.env.<NODE_ENV>.local` (plus
4
+ // any `--env-file`) into `process.env` before a script runs, and marks nothing as
5
+ // coming from a file. Every claudish launch path turns that off with `--no-env-file`.
6
+ // When a process was started without it anyway (`bun <path>/claudish.cjs`,
7
+ // `bun <path>/index.ts`), claudish cannot recover the real environment, but it can
8
+ // learn which NAMES the files set, and drop those. Bun is asked rather than imitated:
9
+ // its file list and its parser differ from dotenv's and change between releases, and a
10
+ // re-implementation of either is how an earlier check was bypassed.
11
+ //
12
+ // The probe runs Bun in the same directory with an empty environment and prints the
13
+ // names it ends up with. It runs once with NODE_ENV unset and once with the current
14
+ // value, because NODE_ENV picks the file list and a `.env` may itself have set it.
15
+ // `--config=<null device>` keeps the directory's `bunfig.toml` out, so the probe runs
16
+ // no `preload` from the checkout; a bunfig can only turn the autoload off, which makes
17
+ // this answer a superset of what was loaded, the safe direction.
18
+ //
19
+ // Shared on purpose: the npm launcher requires it, and so does `src/launch-env.ts`
20
+ // (lazily, from the package's `bin/`), so there is one implementation.
21
+
22
+ const { spawnSync } = require("node:child_process");
23
+ const { devNull } = require("node:os");
24
+
25
+ const PROBE_TIMEOUT_MS = 15_000;
26
+ const PRINT_NAMES = "JSON.stringify(Object.keys(process.env))";
27
+
28
+ /** Bun's flag that turns its env-file autoload off. */
29
+ const NO_ENV_FILE_FLAG = "--no-env-file";
30
+
31
+ /** The `--env-file` arguments in Bun's own argv, so the probe loads the same files. */
32
+ function envFileArgs(execArgv) {
33
+ const out = [];
34
+ for (let i = 0; i < execArgv.length; i++) {
35
+ const arg = execArgv[i];
36
+ if (arg.startsWith("--env-file=")) out.push(arg);
37
+ else if (arg === "--env-file" && i + 1 < execArgv.length) out.push(arg, execArgv[++i]);
38
+ }
39
+ return out;
40
+ }
41
+
42
+ /** The minimal environment a probe needs to start on this platform. */
43
+ function probeBaseEnv(platform, env) {
44
+ if (platform !== "win32") return {};
45
+ const base = {};
46
+ for (const key of ["SystemRoot", "SYSTEMROOT"]) if (env[key]) base[key] = env[key];
47
+ return base;
48
+ }
49
+
50
+ /** One probe run: the names Bun's process has under `runEnv`, or null on any failure. */
51
+ function probeNames(bunPath, args, cwd, runEnv) {
52
+ const r = spawnSync(bunPath, args, {
53
+ cwd,
54
+ env: runEnv,
55
+ encoding: "utf-8",
56
+ stdio: ["ignore", "pipe", "ignore"],
57
+ timeout: PROBE_TIMEOUT_MS,
58
+ windowsHide: true,
59
+ });
60
+ if (r.status !== 0 || typeof r.stdout !== "string") return null;
61
+ try {
62
+ const parsed = JSON.parse(r.stdout.trim().split("\n").pop() || "");
63
+ return Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : null;
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * The names Bun's env-file loading sets in `cwd` for a Bun started with `execArgv`.
71
+ * Returns null when Bun could not answer: the caller must then fail closed.
72
+ */
73
+ function envFileKeys({ bunPath, execArgv, cwd, env, platform = process.platform }) {
74
+ const base = probeBaseEnv(platform, env);
75
+ const runs = [base];
76
+ if (env.NODE_ENV !== undefined) runs.push({ ...base, NODE_ENV: env.NODE_ENV });
77
+ const args = [...envFileArgs(execArgv), `--config=${devNull}`, "--print", PRINT_NAMES];
78
+ const names = new Set();
79
+ for (const runEnv of runs) {
80
+ const found = probeNames(bunPath, args, cwd, runEnv);
81
+ if (found === null) return null;
82
+ for (const name of found) if (!Object.hasOwn(runEnv, name)) names.add(name);
83
+ }
84
+ return [...names];
85
+ }
86
+
87
+ /** The one stderr line for names dropped because Bun's env-file autoload was on. */
88
+ function droppedByAutoloadNotice(names) {
89
+ const them = names.length === 1 ? "it" : "them";
90
+ return `[claudish] ignoring ${names.join(", ")}: Bun loaded this directory's env files before claudish started, so a repository may have set ${them}. claudish reads provider API keys and model settings from .env itself. Run the installed claudish command, or start Bun with ${NO_ENV_FILE_FLAG}.`;
91
+ }
92
+
93
+ /** The one stderr line when Bun could not say which names its env files set. */
94
+ function probeFailedNotice() {
95
+ return `[claudish] Bun loaded this directory's env files before claudish started, and claudish could not tell which values came from them, so it will not start. Run the installed claudish command, or start Bun with ${NO_ENV_FILE_FLAG}.`;
96
+ }
97
+
98
+ module.exports = {
99
+ NO_ENV_FILE_FLAG,
100
+ envFileArgs,
101
+ envFileKeys,
102
+ droppedByAutoloadNotice,
103
+ probeFailedNotice,
104
+ };
package/dist/index.js CHANGED
@@ -575,7 +575,7 @@ var init_onepassword_config = __esm(() => {
575
575
  });
576
576
 
577
577
  // src/version.ts
578
- var VERSION = "13.0.0";
578
+ var VERSION = "13.0.1";
579
579
 
580
580
  // src/logger.ts
581
581
  import { appendFile, existsSync as existsSync2, mkdirSync, readdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "13.0.0",
3
+ "version": "13.0.1",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,6 +49,7 @@
49
49
  },
50
50
  "files": [
51
51
  "dist/",
52
+ "bin/",
52
53
  "AI_AGENT_GUIDE.md",
53
54
  "skills/"
54
55
  ],
@@ -68,10 +69,10 @@
68
69
  "ai"
69
70
  ],
70
71
  "optionalDependencies": {
71
- "@claudish/magmux-darwin-arm64": "13.0.0",
72
- "@claudish/magmux-darwin-x64": "13.0.0",
73
- "@claudish/magmux-linux-arm64": "13.0.0",
74
- "@claudish/magmux-linux-x64": "13.0.0"
72
+ "@claudish/magmux-darwin-arm64": "13.0.1",
73
+ "@claudish/magmux-darwin-x64": "13.0.1",
74
+ "@claudish/magmux-linux-arm64": "13.0.1",
75
+ "@claudish/magmux-linux-x64": "13.0.1"
75
76
  },
76
77
  "author": "Jack Rudenko <i@madappgang.com>",
77
78
  "license": "MIT",