slopcannon 0.1.0 → 0.1.2

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 +80 -19
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -1384,27 +1384,38 @@ function detectDefaultBranch(root) {
1384
1384
  }
1385
1385
  function listBranches(root, defaultBranch) {
1386
1386
  const raw = exec(["branch", "-a", "--format=%(refname:short)"], root);
1387
- const seen = new Set;
1388
- const branches = [];
1387
+ const localBranches = new Set;
1388
+ const entries = new Map;
1389
+ for (const line of raw.split(`
1390
+ `)) {
1391
+ const name = line.trim();
1392
+ if (!name || name.startsWith("origin/"))
1393
+ continue;
1394
+ localBranches.add(name);
1395
+ }
1389
1396
  for (const line of raw.split(`
1390
1397
  `)) {
1391
1398
  const name = line.trim();
1392
1399
  if (!name)
1393
1400
  continue;
1394
- const short = name.startsWith("origin/") ? name.replace("origin/", "") : name;
1401
+ const isRemote = name.startsWith("origin/");
1402
+ const short = isRemote ? name.replace("origin/", "") : name;
1395
1403
  if (short === "HEAD")
1396
1404
  continue;
1397
- if (seen.has(short))
1405
+ if (entries.has(short))
1398
1406
  continue;
1399
- seen.add(short);
1400
- branches.push(short);
1407
+ entries.set(short, {
1408
+ name: short,
1409
+ ref: localBranches.has(short) ? short : name
1410
+ });
1401
1411
  }
1412
+ const branches = Array.from(entries.values());
1402
1413
  branches.sort((a, b) => {
1403
- if (a === defaultBranch)
1414
+ if (a.name === defaultBranch)
1404
1415
  return -1;
1405
- if (b === defaultBranch)
1416
+ if (b.name === defaultBranch)
1406
1417
  return 1;
1407
- return a.localeCompare(b);
1418
+ return a.name.localeCompare(b.name);
1408
1419
  });
1409
1420
  return branches;
1410
1421
  }
@@ -1602,7 +1613,29 @@ var ADJECTIVES = [
1602
1613
  "haunted",
1603
1614
  "bootleg",
1604
1615
  "squishy",
1605
- "untested"
1616
+ "untested",
1617
+ "turbo",
1618
+ "mega",
1619
+ "bigly",
1620
+ "massive",
1621
+ "humongous",
1622
+ "truculent",
1623
+ "cackling",
1624
+ "unruly",
1625
+ "blistering",
1626
+ "preposterous",
1627
+ "ludicrous",
1628
+ "rotund",
1629
+ "swole",
1630
+ "thicc",
1631
+ "chunky",
1632
+ "maximum",
1633
+ "supreme",
1634
+ "bonkers",
1635
+ "absolute",
1636
+ "industrial",
1637
+ "weaponized",
1638
+ "premium"
1606
1639
  ];
1607
1640
  var NOUNS = [
1608
1641
  "goose",
@@ -1629,7 +1662,26 @@ var NOUNS = [
1629
1662
  "gopher",
1630
1663
  "waffle",
1631
1664
  "blunderbuss",
1632
- "hotdog"
1665
+ "hotdog",
1666
+ "jester",
1667
+ "slop",
1668
+ "gumption",
1669
+ "maxx",
1670
+ "chungus",
1671
+ "honk",
1672
+ "donkey",
1673
+ "biscuit",
1674
+ "rascal",
1675
+ "torpedo",
1676
+ "avalanche",
1677
+ "stampede",
1678
+ "ruckus",
1679
+ "shenanigan",
1680
+ "juggernaut",
1681
+ "unit",
1682
+ "whopper",
1683
+ "caboose",
1684
+ "hooligan"
1633
1685
  ];
1634
1686
  function randomBranchName() {
1635
1687
  const adj = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)];
@@ -1690,21 +1742,23 @@ async function runTui() {
1690
1742
  return null;
1691
1743
  }
1692
1744
  R2.info(`${info.repoName}${info.remoteUrl ? ` (${info.remoteUrl})` : ""}`);
1693
- const baseBranch = await Xt({
1745
+ const defaultEntry = info.branches.find((b) => b.name === info.defaultBranch);
1746
+ const baseBranchEntry = await Xt({
1694
1747
  message: "Base branch",
1695
1748
  options: info.branches.map((b) => ({
1696
1749
  value: b,
1697
- label: b,
1698
- hint: b === info.defaultBranch ? "default" : undefined
1750
+ label: b.name,
1751
+ hint: b.name === info.defaultBranch ? "default" : undefined
1699
1752
  })),
1700
1753
  maxItems: 10,
1701
- initialValue: info.defaultBranch,
1754
+ initialValue: defaultEntry,
1702
1755
  placeholder: "Type to filter..."
1703
1756
  });
1704
- if (Ct(baseBranch)) {
1757
+ if (Ct(baseBranchEntry)) {
1705
1758
  Le("Cancelled.");
1706
1759
  return null;
1707
1760
  }
1761
+ const baseBranch = baseBranchEntry;
1708
1762
  const defaultName = randomBranchName();
1709
1763
  const newBranch = await Ze({
1710
1764
  message: "New branch name",
@@ -1721,7 +1775,7 @@ async function runTui() {
1721
1775
  }
1722
1776
  const branchName = (newBranch || defaultName).trim();
1723
1777
  const worktreePath = computeWorktreePath(info.parentDir, info.repoName, branchName);
1724
- R2.step(`git worktree add -b ${branchName} ${worktreePath} ${baseBranch}`);
1778
+ R2.step(`git worktree add -b ${branchName} ${worktreePath} ${baseBranch.ref}`);
1725
1779
  const confirmed = await Re({
1726
1780
  message: "Create worktree?"
1727
1781
  });
@@ -1732,7 +1786,7 @@ async function runTui() {
1732
1786
  const s = bt2();
1733
1787
  s.start("Creating worktree...");
1734
1788
  try {
1735
- createWorktree(info.root, worktreePath, baseBranch, branchName);
1789
+ createWorktree(info.root, worktreePath, baseBranch.ref, branchName);
1736
1790
  s.stop("Worktree created.");
1737
1791
  } catch (err) {
1738
1792
  s.stop("Failed.");
@@ -1899,10 +1953,12 @@ What it does:
1899
1953
  `.trim();
1900
1954
  function parseArgs() {
1901
1955
  const args = process.argv.slice(2);
1902
- const result = { help: false, config: false, cleanup: false };
1956
+ const result = { help: false, version: false, config: false, cleanup: false };
1903
1957
  for (let i = 0;i < args.length; i++) {
1904
1958
  if (args[i] === "--help" || args[i] === "-h") {
1905
1959
  result.help = true;
1960
+ } else if (args[i] === "--version" || args[i] === "-v" || args[i] === "-V") {
1961
+ result.version = true;
1906
1962
  } else if (args[i] === "--path-file" && i + 1 < args.length) {
1907
1963
  result.pathFile = args[++i];
1908
1964
  } else if (args[i] === "config") {
@@ -1929,6 +1985,11 @@ function requireGit(deps) {
1929
1985
  }
1930
1986
  async function main() {
1931
1987
  const args = parseArgs();
1988
+ if (args.version) {
1989
+ const pkg = await Bun.file(new URL("../package.json", import.meta.url)).json();
1990
+ console.log(pkg.version);
1991
+ process.exit(0);
1992
+ }
1932
1993
  if (args.help) {
1933
1994
  console.log(HELP);
1934
1995
  process.exit(0);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "slopcannon",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Create a git worktree. Launch Claude Code. Ship slop.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "slopcannon": "./dist/cli.js"
7
+ "slopcannon": "dist/cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "bun build ./src/cli.ts --outdir ./dist --target bun",