@sma1lboy/kobe 0.8.189 → 0.8.190

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/dist/cli/kobe.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import{join as l}from"node:path";import{createInterface as s}from"node:readline/promises";import{pathToFileURL as o}from"node:url";import{spawnSync as U}from"node:child_process";import{constants as f,accessSync as A}from"node:fs";import{homedir as y}from"node:os";import{basename as S,delimiter as _,dirname as p,join as $}from"node:path";import{fileURLToPath as w}from"node:url";var W="rove",Y="kobe";var N="ROVE_INVOKED_AS";function K(z=process.env){return z[N]===W?W:Y}var x="ROVE_BUN",v="ROVE_NO_BUN_BOOTSTRAP",E=(z)=>{try{return A(z,f.X_OK),!0}catch{return!1}},d=(z)=>z==="win32"?"bun.exe":"bun";function m(z={}){let H=z.env??process.env,J=z.platform??process.platform,Z=z.home??H.HOME??H.USERPROFILE??y(),Q=d(J),X=[],G=H[x]?.trim();if(G)X.push(G);for(let L of(H.PATH??H.Path??"").split(_))if(L)X.push($(L,Q));let V=H.BUN_INSTALL?.trim();if(V)X.push($(V,"bin",Q));if(Z)X.push($(Z,".bun","bin",Q));let q=z.launcherDir;if(q)X.push($(q,"..","..","node_modules","bun","bin",Q)),X.push($(q,"..","..","..","bun","bin",Q));return X}function F(z={}){let H=z.isExecutable??E;return m(z).find((J)=>H(J))??null}function b(z){return p(w(z))}function B(z){return S(w(z)).replace(/\.[cm]?[jt]s$/,"")}function c(z=process.platform){return z==="win32"?["powershell","-NoProfile","-Command","irm bun.sh/install.ps1 | iex"]:["bash","-c","curl -fsSL https://bun.sh/install | bash"]}function D(z=K(),H=process.platform){let J=H==="win32"?'powershell -c "irm bun.sh/install.ps1 | iex"':"curl -fsSL https://bun.sh/install | bash";return[`${z}: Rove runs on the Bun runtime, and no Bun was found on this machine.`,"","Install Bun, then run this command again:",` ${J}`," npm install -g bun # any platform, if you already have npm","","Or install Bun and Rove together in one step:"," curl -fsSL https://rove.sma1lboy.me/install.sh | sh","",`Already have Bun somewhere unusual? Point Rove at it: ${x}=/path/to/bun`,""].join(`
3
- `)}function k(z=process.env,H=process.stdin,J=process.stdout){if(z[v]==="1")return!1;if(z.CI==="true"||z.CI==="1")return!1;return Boolean(H.isTTY&&J.isTTY)}function C(z={},H=U){let J=z.platform??process.platform,[Z,...Q]=c(J);if(!Z)return null;let X=H(Z,Q,{stdio:"inherit"});if(X.error||X.status!==0)return null;return F(z)}function u(z){if(typeof z.status==="number")return z.status;if(z.signal)return 128+(Object.hasOwn(j,z.signal)?j[z.signal]:0);return 1}var j={SIGINT:2,SIGQUIT:3,SIGKILL:9,SIGTERM:15};function M(z,H,J,Z=U){let Q=Z(z,[H,...J],{stdio:"inherit"});if(Q.error)return process.stderr.write(`rove: could not start Bun at ${z}: ${Q.error.message}
4
- `),1;return u(Q)}var O=b(import.meta.url),P=B(import.meta.url),T=l(O,`${P}-run.js`);async function i(z){let H=s({input:process.stdin,output:process.stdout});try{let J=(await H.question(z)).trim().toLowerCase();return J===""||J==="y"||J==="yes"}finally{H.close()}}async function a(){let z={launcherDir:O},H=F(z);if(H)return H;if(!k())return null;let J=`${P}: Rove runs on the Bun runtime, and none is installed. Install Bun now? [Y/n] `;if(!await i(J))return null;return C(z)}if(typeof globalThis.Bun<"u")await import(o(T).href);else{let z=await a();if(!z)process.stderr.write(D(P)),process.exit(1);process.exit(M(z,T,process.argv.slice(2)))}
3
+ `)}function C(z=process.env,H=process.stdin,J=process.stdout){if(z[v]==="1")return!1;if(z.CI==="true"||z.CI==="1")return!1;return Boolean(H.isTTY&&J.isTTY)}function M(z={},H=U){let J=z.platform??process.platform,[Z,...Q]=c(J);if(!Z)return null;let X=H(Z,Q,{stdio:"inherit"});if(X.error||X.status!==0)return null;return F(z)}function u(z){if(typeof z.status==="number")return z.status;if(z.signal)return 128+(Object.hasOwn(j,z.signal)?j[z.signal]:0);return 1}var j={SIGINT:2,SIGQUIT:3,SIGKILL:9,SIGTERM:15};function k(z,H,J,Z=U){let Q=Z(z,[H,...J],{stdio:"inherit"});if(Q.error)return process.stderr.write(`rove: could not start Bun at ${z}: ${Q.error.message}
4
+ `),1;return u(Q)}var O=b(import.meta.url),P=B(import.meta.url),T=l(O,`${P}-run.js`);async function i(z){let H=s({input:process.stdin,output:process.stdout});try{let J=(await H.question(z)).trim().toLowerCase();return J===""||J==="y"||J==="yes"}finally{H.close()}}async function a(){let z={launcherDir:O},H=F(z);if(H)return H;if(!C())return null;let J=`${P}: Rove runs on the Bun runtime, and none is installed. Install Bun now? [Y/n] `;if(!await i(J))return null;return M(z)}if(typeof globalThis.Bun<"u")await import(o(T).href);else{let z=await a();if(!z)process.stderr.write(D(P)),process.exit(1);process.exit(k(z,T,process.argv.slice(2)))}
@@ -55,9 +55,9 @@ async function nodePtyDriver(spawn) {
55
55
  }
56
56
 
57
57
  // ../kobe-daemon/src/daemon/pty-server.ts
58
- import { mkdir, unlink, writeFile } from "node:fs/promises";
58
+ import { mkdir as mkdir2, unlink as unlink2, writeFile } from "node:fs/promises";
59
59
  import { createServer } from "node:net";
60
- import { dirname as dirname2 } from "node:path";
60
+ import { dirname as dirname3 } from "node:path";
61
61
  import { StringDecoder as StringDecoder3 } from "node:string_decoder";
62
62
 
63
63
  // ../kobe-daemon/src/daemon/client-writer.ts
@@ -155,6 +155,26 @@ class ClientWriter {
155
155
  }
156
156
  }
157
157
 
158
+ // ../kobe-daemon/src/daemon/compat-link.ts
159
+ import { lstat, mkdir, symlink, unlink } from "node:fs/promises";
160
+ import { dirname } from "node:path";
161
+ async function linkLegacyRuntimePath(canonical, legacy) {
162
+ if (canonical === legacy)
163
+ return false;
164
+ try {
165
+ const existing = await lstat(legacy).catch(() => null);
166
+ if (existing && !existing.isSymbolicLink())
167
+ return false;
168
+ if (existing)
169
+ await unlink(legacy).catch(() => {});
170
+ await mkdir(dirname(legacy), { recursive: true });
171
+ await symlink(canonical, legacy);
172
+ return true;
173
+ } catch {
174
+ return false;
175
+ }
176
+ }
177
+
158
178
  // ../kobe-daemon/src/daemon/crash-log.ts
159
179
  function toError(err) {
160
180
  if (err instanceof Error)
@@ -229,6 +249,15 @@ function runtimePath(homeDir, name, pidName) {
229
249
  return legacyPath;
230
250
  return canonicalPath;
231
251
  }
252
+ function legacyRuntimePath(homeDir, name) {
253
+ return join(homeDir, COMPAT_STATE_DIR_BASENAME, name);
254
+ }
255
+ function legacyPtyHostSocketPath(homeDir) {
256
+ return legacyRuntimePath(homeDir, "pty.sock");
257
+ }
258
+ function legacyPtyHostPidPath(homeDir) {
259
+ return legacyRuntimePath(homeDir, "pty.pid");
260
+ }
232
261
  function runtimeDataPath(homeDir, name) {
233
262
  const { canonical, legacy } = stateDirs(homeDir);
234
263
  const canonicalPath = join(canonical, name);
@@ -251,6 +280,10 @@ function fitSocketPath(naturalPath, homeDir, role, pidTag) {
251
280
  return fallback;
252
281
  throw new Error(`daemon socket path exceeds ${SOCKET_PATH_SAFETY_LIMIT} bytes even after fallback: ${fallback}`);
253
282
  }
283
+ function resolveDaemonHomeDir(homeDir) {
284
+ const explicit = homeDir ?? readRoveEnv("HOME_DIR");
285
+ return explicit && explicit.length > 0 ? explicit : homedir();
286
+ }
254
287
  function isWindowsPipePath(path) {
255
288
  return path.startsWith("\\\\.\\pipe\\") || path.startsWith("//./pipe/");
256
289
  }
@@ -321,7 +354,7 @@ function frameToLine(frame) {
321
354
 
322
355
  // ../kobe-daemon/src/daemon/pty-exit-store.ts
323
356
  import { mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
324
- import { dirname } from "node:path";
357
+ import { dirname as dirname2 } from "node:path";
325
358
  var MAX_RECORDS = 50;
326
359
  var TAIL_LINES = 40;
327
360
  var TAIL_LINE_CHARS = 500;
@@ -360,7 +393,7 @@ function recordPtyExit(info, path = defaultPtyExitsPath()) {
360
393
  tail: plainTail(info.tail)
361
394
  };
362
395
  const newest = Object.values(records).sort((a, b) => a.at < b.at ? 1 : -1).slice(0, MAX_RECORDS);
363
- mkdirSync(dirname(path), { recursive: true });
396
+ mkdirSync(dirname2(path), { recursive: true });
364
397
  writeFileSync(path, JSON.stringify(Object.fromEntries(newest.map((r) => [r.key, r])), null, 2), "utf8");
365
398
  }
366
399
 
@@ -1148,8 +1181,8 @@ async function startPtyHostServer(options = {}) {
1148
1181
  ptys.restoreFrozen(loadFrozenSessions(freezeDir));
1149
1182
  const pipeSocket = isWindowsPipePath(socketPath);
1150
1183
  if (!pipeSocket)
1151
- await mkdir(dirname2(socketPath), { recursive: true });
1152
- await mkdir(dirname2(pidPath), { recursive: true });
1184
+ await mkdir2(dirname3(socketPath), { recursive: true });
1185
+ await mkdir2(dirname3(pidPath), { recursive: true });
1153
1186
  const server = createServer((socket) => {
1154
1187
  const client = {
1155
1188
  socket,
@@ -1188,8 +1221,8 @@ async function startPtyHostServer(options = {}) {
1188
1221
  client.socket.destroy();
1189
1222
  await new Promise((resolve) => server.close(() => resolve()));
1190
1223
  if (!pipeSocket)
1191
- await unlink(socketPath).catch(() => {});
1192
- await unlink(pidPath).catch(() => {});
1224
+ await unlink2(socketPath).catch(() => {});
1225
+ await unlink2(pidPath).catch(() => {});
1193
1226
  }
1194
1227
  };
1195
1228
  async function stop() {
@@ -1298,6 +1331,11 @@ async function startPtyHostServer(options = {}) {
1298
1331
  });
1299
1332
  await writeFile(pidPath, `${process.pid}
1300
1333
  `, "utf8");
1334
+ if (!pipeSocket) {
1335
+ const home = resolveDaemonHomeDir();
1336
+ await linkLegacyRuntimePath(socketPath, legacyPtyHostSocketPath(home));
1337
+ await linkLegacyRuntimePath(pidPath, legacyPtyHostPidPath(home));
1338
+ }
1301
1339
  armIdle();
1302
1340
  log("boot", `pty host listening on ${socketPath}`);
1303
1341
  return api;