bitfab-cli 0.2.16 → 0.2.18

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7308,11 +7308,21 @@ import crypto3 from "crypto";
7308
7308
  import fs6 from "fs";
7309
7309
  import os6 from "os";
7310
7310
  import path5 from "path";
7311
- function cwdHash() {
7312
- return crypto3.createHash("sha256").update(process.cwd()).digest("hex").slice(0, 16);
7311
+
7312
+ // ../bitfab-plugin-lib/dist/getAgentSessionId.js
7313
+ function getAgentSessionId() {
7314
+ return process.env.CLAUDE_CODE_SESSION_ID ?? process.env.CODEX_THREAD_ID ?? null;
7315
+ }
7316
+
7317
+ // ../bitfab-plugin-lib/dist/activeStudioSession.js
7318
+ function shortHash(input) {
7319
+ return crypto3.createHash("sha256").update(input).digest("hex").slice(0, 16);
7320
+ }
7321
+ function sessionScope() {
7322
+ return shortHash(getAgentSessionId() ?? process.cwd());
7313
7323
  }
7314
7324
  function filePath() {
7315
- return path5.join(os6.homedir(), ".config", "bitfab", `active-studio-session.${cwdHash()}.json`);
7325
+ return path5.join(os6.homedir(), ".config", "bitfab", `active-studio-session.${sessionScope()}.json`);
7316
7326
  }
7317
7327
  function writeActiveStudioSession(session) {
7318
7328
  const target = filePath();
@@ -7878,7 +7888,7 @@ async function openStudioTo(path14, opts) {
7878
7888
  const targetWithSession = `${path14}${path14.includes("?") ? "&" : "?"}session=${encodeURIComponent(sessionId)}`;
7879
7889
  const signInUrl = `${opts.serviceUrl}/studio/sign-in?redirect_url=${encodeURIComponent(targetWithSession)}`;
7880
7890
  openChromelessWindow(signInUrl);
7881
- opts.onLoginRequired?.(sessionId);
7891
+ opts.onLoginRequired?.(sessionId, signInUrl);
7882
7892
  const abortController = new AbortController();
7883
7893
  const timer = setTimeout(() => abortController.abort(), LOGIN_TIMEOUT_MS2);
7884
7894
  const keepalive = setInterval(() => process.stderr.write(""), 3e4);
@@ -7925,7 +7935,7 @@ async function openStudioTo(path14, opts) {
7925
7935
  if (opts.forceNew) {
7926
7936
  clearActiveStudioSession();
7927
7937
  }
7928
- const existing = opts.forceNew ? null : readActiveStudioSession();
7938
+ const existing = opts.forceNew || opts.sessionId ? null : readActiveStudioSession();
7929
7939
  if (existing) {
7930
7940
  const client = {
7931
7941
  serviceUrl: existing.serviceUrl,
@@ -8046,11 +8056,15 @@ async function runLogin(platform2, pluginVersion, options) {
8046
8056
  const exitOnComplete = options?.exitOnComplete ?? true;
8047
8057
  const config2 = getConfig();
8048
8058
  console.log("\nOpening Studio to sign in...");
8049
- console.log("(If the browser didn't open, visit the Studio URL manually.)");
8050
8059
  const closePath = `/studio/close?pluginLogin=true&autoClose=true&message=${encodeURIComponent("Login complete")}`;
8051
8060
  try {
8052
8061
  const result = await openStudioTo(closePath, {
8053
- serviceUrl: config2.serviceUrl
8062
+ serviceUrl: config2.serviceUrl,
8063
+ onLoginRequired: (_sessionId, signInUrl) => {
8064
+ console.log(`
8065
+ If the browser didn't open, visit this URL manually:
8066
+ ${signInUrl}`);
8067
+ }
8054
8068
  });
8055
8069
  result.abort();
8056
8070
  const apiKey = getConfig().apiKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitfab-cli",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Install and configure the Bitfab plugin in Claude Code, Codex, or Cursor.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",