sharkbait 1.0.26 → 1.0.27

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/cli.js +82 -46
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1428,7 +1428,20 @@ async function isBeadsFunctional() {
1428
1428
  return { functional: true, useNoDb: false };
1429
1429
  }
1430
1430
  } catch {}
1431
- if (bdSupportsNoDb()) {
1431
+ try {
1432
+ const result = await exec([BD_PATH, "list", "--json", "--no-db"], { cwd: process.cwd() });
1433
+ if (result.exitCode === 0) {
1434
+ forceNoDb = true;
1435
+ return { functional: true, useNoDb: true };
1436
+ }
1437
+ } catch {}
1438
+ if (tryFixMetadataBackend()) {
1439
+ try {
1440
+ const result = await exec([BD_PATH, "list", "--json"], { cwd: process.cwd() });
1441
+ if (result.exitCode === 0) {
1442
+ return { functional: true, useNoDb: true };
1443
+ }
1444
+ } catch {}
1432
1445
  try {
1433
1446
  const result = await exec([BD_PATH, "list", "--json", "--no-db"], { cwd: process.cwd() });
1434
1447
  if (result.exitCode === 0) {
@@ -1437,7 +1450,7 @@ async function isBeadsFunctional() {
1437
1450
  }
1438
1451
  } catch {}
1439
1452
  }
1440
- return { functional: false, error: "bd list failed (dolt unreachable and --no-db fallback failed)" };
1453
+ return { functional: false, error: "bd list failed (dolt unreachable, --no-db failed, metadata fix failed)" };
1441
1454
  }
1442
1455
  async function isBdInstalled() {
1443
1456
  try {
@@ -1447,13 +1460,25 @@ async function isBdInstalled() {
1447
1460
  return false;
1448
1461
  }
1449
1462
  }
1450
- function bdSupportsNoDb() {
1463
+ function tryFixMetadataBackend(cwd) {
1464
+ const dir = cwd || process.cwd();
1465
+ const metadataPath = join3(dir, ".beads", "metadata.json");
1451
1466
  try {
1452
- const help = execSync(`${BD_PATH} init --help 2>&1`, { encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] });
1453
- return help.includes("--no-db");
1454
- } catch {
1455
- return false;
1456
- }
1467
+ if (!existsSync3(metadataPath))
1468
+ return false;
1469
+ const { readFileSync, writeFileSync } = __require("fs");
1470
+ const raw = readFileSync(metadataPath, "utf-8");
1471
+ const meta = JSON.parse(raw);
1472
+ if (meta.backend === "dolt" || meta.database === "dolt") {
1473
+ meta.backend = "no-db";
1474
+ meta.database = "no-db";
1475
+ delete meta.dolt_mode;
1476
+ delete meta.dolt_database;
1477
+ writeFileSync(metadataPath, JSON.stringify(meta, null, 2));
1478
+ return true;
1479
+ }
1480
+ } catch {}
1481
+ return false;
1457
1482
  }
1458
1483
  var beadsTools = [
1459
1484
  {
@@ -1590,18 +1615,27 @@ var beadsTools = [
1590
1615
  alreadyInitialized: true
1591
1616
  };
1592
1617
  }
1593
- if (bdSupportsNoDb()) {
1594
- try {
1595
- const result = await exec([BD_PATH, "init", "--no-db"], { cwd: process.cwd() });
1596
- if (result.exitCode === 0) {
1597
- return {
1598
- success: true,
1599
- message: "Beads reinitialized in no-db mode (dolt was not reachable).",
1600
- output: result.stdout.trim(),
1601
- mode: "no-db"
1602
- };
1603
- }
1604
- } catch {}
1618
+ try {
1619
+ const result = await exec([BD_PATH, "init", "--no-db"], { cwd: process.cwd() });
1620
+ if (result.exitCode === 0) {
1621
+ tryFixMetadataBackend();
1622
+ return {
1623
+ success: true,
1624
+ message: "Beads reinitialized in no-db mode (dolt was not reachable).",
1625
+ output: result.stdout.trim(),
1626
+ mode: "no-db"
1627
+ };
1628
+ }
1629
+ } catch {}
1630
+ if (tryFixMetadataBackend()) {
1631
+ const { functional: nowFunctional } = await isBeadsFunctional();
1632
+ if (nowFunctional) {
1633
+ return {
1634
+ success: true,
1635
+ message: "Beads metadata fixed — switched from dolt to no-db mode.",
1636
+ mode: "no-db"
1637
+ };
1638
+ }
1605
1639
  }
1606
1640
  return {
1607
1641
  success: false,
@@ -1609,34 +1643,28 @@ var beadsTools = [
1609
1643
  proceedWithoutBeads: true
1610
1644
  };
1611
1645
  }
1612
- const args = [BD_PATH, "init"];
1613
- if (noDb && bdSupportsNoDb()) {
1614
- args.push("--no-db");
1615
- }
1616
1646
  try {
1617
- const result = await exec(args, { cwd: process.cwd() });
1618
- if (result.exitCode !== 0) {
1619
- if (!noDb && bdSupportsNoDb()) {
1620
- const fallback = await exec([BD_PATH, "init", "--no-db"], { cwd: process.cwd() });
1621
- if (fallback.exitCode === 0) {
1622
- return {
1623
- success: true,
1624
- message: "Beads initialized in no-db mode (dolt not available, using JSONL).",
1625
- output: fallback.stdout.trim(),
1626
- mode: "no-db"
1627
- };
1628
- }
1629
- }
1647
+ const result = await exec([BD_PATH, "init", "--no-db"], { cwd: process.cwd() });
1648
+ if (result.exitCode === 0) {
1630
1649
  return {
1631
- success: false,
1632
- message: `Failed to initialize beads: ${result.stderr || result.stdout}. Proceed with the task without beads.`,
1633
- proceedWithoutBeads: true
1650
+ success: true,
1651
+ message: "Beads initialized in no-db mode (JSONL-backed, no dolt dependency).",
1652
+ output: result.stdout.trim(),
1653
+ mode: "no-db"
1654
+ };
1655
+ }
1656
+ const fallback = await exec([BD_PATH, "init"], { cwd: process.cwd() });
1657
+ if (fallback.exitCode === 0) {
1658
+ return {
1659
+ success: true,
1660
+ message: "Beads initialized successfully.",
1661
+ output: fallback.stdout.trim()
1634
1662
  };
1635
1663
  }
1636
1664
  return {
1637
- success: true,
1638
- message: "Beads initialized successfully.",
1639
- output: result.stdout.trim()
1665
+ success: false,
1666
+ message: `Failed to initialize beads: ${fallback.stderr || fallback.stdout}. Proceed with the task without beads.`,
1667
+ proceedWithoutBeads: true
1640
1668
  };
1641
1669
  } catch (error) {
1642
1670
  return {
@@ -1822,7 +1850,7 @@ var beadsTools = [
1822
1850
  return JSON.parse(result.stdout);
1823
1851
  }
1824
1852
  } catch {}
1825
- if (!forceNoDb && bdSupportsNoDb()) {
1853
+ if (!forceNoDb) {
1826
1854
  try {
1827
1855
  const noDbArgs = [...args, "--no-db"];
1828
1856
  const result = await exec(noDbArgs);
@@ -1832,6 +1860,14 @@ var beadsTools = [
1832
1860
  }
1833
1861
  } catch {}
1834
1862
  }
1863
+ if (tryFixMetadataBackend()) {
1864
+ try {
1865
+ const result = await exec(bdArgs("list", "--json"));
1866
+ if (result.exitCode === 0) {
1867
+ return JSON.parse(result.stdout);
1868
+ }
1869
+ } catch {}
1870
+ }
1835
1871
  try {
1836
1872
  const { readFileSync, readdirSync: readdirSync2 } = await import("fs");
1837
1873
  const beadsDir = join3(process.cwd(), ".beads");
@@ -9089,7 +9125,7 @@ ${event.consolidated}`,
9089
9125
  }
9090
9126
 
9091
9127
  // src/version.ts
9092
- var VERSION = "1.0.26";
9128
+ var VERSION = "1.0.27";
9093
9129
 
9094
9130
  // src/agent/start-chat.ts
9095
9131
  async function startChat(options = {}) {
@@ -10373,7 +10409,7 @@ ${"━".repeat(60)}`);
10373
10409
  }
10374
10410
 
10375
10411
  // src/version.ts
10376
- var VERSION2 = "1.0.26";
10412
+ var VERSION2 = "1.0.27";
10377
10413
 
10378
10414
  // src/ui/logo.tsx
10379
10415
  import { Box as Box14, Text as Text14 } from "ink";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sharkbait",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "AI-powered coding assistant for the command line. Uses OpenAI Responses API (not Chat). Autonomous agents, parallel code reviews, 36 tools.",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",