@bahulam/code 2.6.2 → 2.6.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bahulam/code",
3
- "version": "2.6.2",
4
- "description": "Bahulam Code abundance, in your terminal. CLI-first, reliability-first, sub-agents, 65.6% SWE-bench Verified.",
3
+ "version": "2.6.3",
4
+ "description": "Bahulam Code \u2014 abundance, in your terminal. CLI-first, reliability-first, sub-agents, 65.6% SWE-bench Verified.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "bahulam": "src/terminal/main.mjs",
@@ -47,5 +47,8 @@
47
47
  "pdf-parse": "^1.1.1",
48
48
  "tree-sitter-wasms": "^0.1.13",
49
49
  "web-tree-sitter": "^0.26.9"
50
+ },
51
+ "optionalDependencies": {
52
+ "@bahulam/runtime-darwin-arm64": "2.6.3"
50
53
  }
51
54
  }
@@ -41,7 +41,7 @@ import { randomBytes } from 'node:crypto';
41
41
  import * as net from 'node:net';
42
42
  import * as http from 'node:http';
43
43
 
44
- const DEFAULT_RUNTIME_ROOT = path.join(os.homedir(), '.bahulam', 'runtime', 'current');
44
+ const DEV_RUNTIME_ROOT = path.join(os.homedir(), '.bahulam', 'runtime', 'current');
45
45
  const READY_TIMEOUT_MS = 30_000;
46
46
  const READY_POLL_MS = 100;
47
47
  const IS_WINDOWS = process.platform === 'win32';
@@ -54,8 +54,39 @@ const USE_UNIX_SOCKET = process.env.BAHULAM_RUNTIME_TRANSPORT === 'socket';
54
54
 
55
55
  let _daemon = null; // { proc, socketPath, port, ready }
56
56
 
57
+ // Runtime resolution order (see RUNBOOK in codekepler-bahulam-runtime):
58
+ // 1. BAHULAM_RUNTIME_ROOT env — explicit override for dev/testing
59
+ // 2. Sibling optional dep — @bahulam/runtime-<platform>-<arch> installed
60
+ // alongside @bahulam/code via npm's optionalDependencies. This is the
61
+ // shipped path for end users. `os`/`cpu` fields in each runtime package
62
+ // ensure npm only installs the matching one.
63
+ // 3. Legacy dev tarball — ~/.bahulam/runtime/current/ — used by developers
64
+ // who built the runtime by hand before the npm packaging existed.
57
65
  function _runtimeRoot() {
58
- return process.env.BAHULAM_RUNTIME_ROOT || DEFAULT_RUNTIME_ROOT;
66
+ if (process.env.BAHULAM_RUNTIME_ROOT) return process.env.BAHULAM_RUNTIME_ROOT;
67
+
68
+ // Sibling optional dep: same package.json's node_modules/@bahulam/runtime-<plat>-<arch>.
69
+ // import.meta.url points at this file inside @bahulam/code, so its
70
+ // node_modules is two dirs up (@bahulam/code/src/core/ → @bahulam/code/ → @bahulam/).
71
+ const plat = process.platform; // 'darwin' | 'linux' | 'win32'
72
+ const arch = process.arch; // 'arm64' | 'x64' | ...
73
+ const siblingName = `@bahulam/runtime-${plat}-${arch}`;
74
+ try {
75
+ const here = path.dirname(new URL(import.meta.url).pathname);
76
+ // Walk up looking for node_modules containing @bahulam/runtime-<plat>-<arch>
77
+ let dir = here;
78
+ for (let i = 0; i < 6; i++) {
79
+ const candidate = path.join(dir, 'node_modules', siblingName);
80
+ if (fs.existsSync(path.join(candidate, 'bin'))) {
81
+ return candidate;
82
+ }
83
+ const parent = path.dirname(dir);
84
+ if (parent === dir) break;
85
+ dir = parent;
86
+ }
87
+ } catch { /* fall through */ }
88
+
89
+ return DEV_RUNTIME_ROOT;
59
90
  }
60
91
 
61
92
  function _runtimeBin() {