bitfab-cli 0.2.277 → 0.2.279

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 +77 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10440,6 +10440,10 @@ function readPid(pidPath) {
10440
10440
  return null;
10441
10441
  }
10442
10442
  }
10443
+ var systemWaitClock = {
10444
+ now: Date.now,
10445
+ sleep: (delayMs) => new Promise((resolve4) => setTimeout(resolve4, delayMs))
10446
+ };
10443
10447
  async function pingSocket(socketPath) {
10444
10448
  return new Promise((resolve4) => {
10445
10449
  const timeout = setTimeout(() => {
@@ -10480,14 +10484,14 @@ async function waitForSocket(socketPath, timeoutMs) {
10480
10484
  }
10481
10485
  throw new Error(`daemon did not become ready within ${timeoutMs}ms`);
10482
10486
  }
10483
- async function waitForLockHolderDaemon(socketPath, timeoutMs, localBuild = localBuildFingerprint()) {
10484
- const deadline = Date.now() + timeoutMs;
10485
- while (Date.now() < deadline) {
10487
+ async function waitForLockHolderDaemon(socketPath, timeoutMs, localBuild = localBuildFingerprint(), clock = systemWaitClock) {
10488
+ const deadline = clock.now() + timeoutMs;
10489
+ while (clock.now() < deadline) {
10486
10490
  const ping = await pingSocket(socketPath);
10487
10491
  if (ping.alive && buildMatches(localBuild, ping.build)) {
10488
10492
  return;
10489
10493
  }
10490
- await new Promise((r) => setTimeout(r, ENSURE_POLL_INTERVAL_MS));
10494
+ await clock.sleep(ENSURE_POLL_INTERVAL_MS);
10491
10495
  }
10492
10496
  const finalPing = await pingSocket(socketPath);
10493
10497
  if (finalPing.alive) {
@@ -28847,6 +28851,7 @@ var SKIP_FLAG = "--dangerously-skip-permissions";
28847
28851
  var REPO = "Project-White-Rabbit/bitfab-claude-plugin";
28848
28852
  var MARKETPLACE = "bitfab";
28849
28853
  var PLUGIN_KEY = "bitfab@bitfab";
28854
+ var MCP_SERVER_NAME = `plugin:${MARKETPLACE}:Bitfab`;
28850
28855
  var SETUP_COMMAND = "/bitfab:setup";
28851
28856
  var ANALYZE_REPO_COMMAND = "/bitfab:setup analyze-repo";
28852
28857
  var ASSISTANT_COMMAND = "/bitfab:assistant";
@@ -28878,6 +28883,13 @@ var checkClaudeAuth = makeCliAuthCheck({
28878
28883
  });
28879
28884
  function runClaudeInstall() {
28880
28885
  const s = p3.spinner();
28886
+ const repaired = enableBitfabMcpServer(
28887
+ path17.join(os15.homedir(), ".claude.json"),
28888
+ process.cwd()
28889
+ );
28890
+ if (repaired) {
28891
+ p3.log.step("Re-enabled the Bitfab MCP server for this project");
28892
+ }
28881
28893
  const localPluginKey = activeLocalClaudeBitfabPlugin();
28882
28894
  if (localPluginKey !== null) {
28883
28895
  p3.log.step(`Local Bitfab plugin already enabled (${localPluginKey})`);
@@ -29783,6 +29795,67 @@ function pluginStateFromText(listOut) {
29783
29795
  }
29784
29796
  return new RegExp(`${key}\\s*\\n.*\\n.*\\n.*disabled`).test(listOut) ? "disabled" : "enabled";
29785
29797
  }
29798
+ function claudeProjectKeys(projectPath) {
29799
+ const shape = (value) => {
29800
+ const normalized = path17.normalize(value.normalize("NFC"));
29801
+ return process.platform === "win32" ? normalized.replaceAll("\\", "/") : normalized;
29802
+ };
29803
+ const candidates = [projectPath, shape(projectPath)];
29804
+ const root = runCliResult("git", [
29805
+ "-C",
29806
+ projectPath,
29807
+ "rev-parse",
29808
+ "--show-toplevel"
29809
+ ]);
29810
+ const toplevel = root.status === 0 ? root.output.trim() : "";
29811
+ if (toplevel !== "") {
29812
+ candidates.unshift(shape(toplevel));
29813
+ }
29814
+ return Array.from(new Set(candidates));
29815
+ }
29816
+ function enableBitfabMcpServer(configPath, projectPath) {
29817
+ let staging;
29818
+ try {
29819
+ if (!fs20.existsSync(configPath)) {
29820
+ return false;
29821
+ }
29822
+ const raw = fs20.readFileSync(configPath, "utf-8");
29823
+ if (raw.trim() === "") {
29824
+ return false;
29825
+ }
29826
+ const config4 = JSON.parse(raw);
29827
+ const projects = config4.projects ?? {};
29828
+ const hit = claudeProjectKeys(projectPath).map((key) => projects[key]).find(
29829
+ (entry) => entry !== null && typeof entry === "object" && Array.isArray(entry.disabledMcpServers) && entry.disabledMcpServers.includes(MCP_SERVER_NAME)
29830
+ );
29831
+ if (hit === void 0) {
29832
+ return false;
29833
+ }
29834
+ const project = hit;
29835
+ const disabled = project.disabledMcpServers;
29836
+ project.disabledMcpServers = disabled.filter(
29837
+ (name) => name !== MCP_SERVER_NAME
29838
+ );
29839
+ const target = fs20.realpathSync(configPath);
29840
+ const mode = fs20.statSync(target).mode & 511;
29841
+ const stagingPath = `${target}.bitfab-${process.pid}.tmp`;
29842
+ fs20.writeFileSync(stagingPath, JSON.stringify(config4, null, 2), {
29843
+ mode,
29844
+ flag: "wx"
29845
+ });
29846
+ staging = stagingPath;
29847
+ fs20.renameSync(staging, target);
29848
+ return true;
29849
+ } catch {
29850
+ if (staging !== void 0) {
29851
+ try {
29852
+ fs20.rmSync(staging, { force: true });
29853
+ } catch {
29854
+ }
29855
+ }
29856
+ return false;
29857
+ }
29858
+ }
29786
29859
  function enableAutoUpdate(settingsPath) {
29787
29860
  let settings = {};
29788
29861
  if (fs20.existsSync(settingsPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitfab-cli",
3
- "version": "0.2.277",
3
+ "version": "0.2.279",
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",