bit-cli-ai 1.0.4 → 1.0.6

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/package.json +1 -1
  2. package/src/index.js +79 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bit-cli-ai",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Git with a brain - intelligent Git wrapper with AI-powered commits, ghost branches, and predictive merge",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -1,99 +1,119 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { Command } from 'commander';
4
- import { execSync } from 'child_process';
5
- import chalk from 'chalk';
3
+ import { Command } from "commander";
4
+ import { execSync } from "child_process";
5
+ import chalk from "chalk";
6
+ import { readFileSync } from "fs";
7
+ import path from "path";
8
+ import { fileURLToPath } from "url";
6
9
 
7
- import { smartInit } from './commands/init.js';
8
- import { aiCommit } from './commands/commit.js';
9
- import { ghostBranch, checkoutGhost } from './commands/branch.js';
10
- import { mergePreview } from './commands/merge.js';
11
- import { checkHotZones } from './commands/hotzone.js';
12
- import { analyzeSymbols } from './commands/analyze.js';
10
+ // ===== Resolve __dirname (ESM-safe) =====
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
13
 
14
+ // ===== Read version from package.json =====
15
+ const pkg = JSON.parse(
16
+ readFileSync(path.join(__dirname, "../package.json"), "utf-8")
17
+ );
18
+
19
+ // ===== Import Bit commands =====
20
+ import { smartInit } from "./commands/init.js";
21
+ import { aiCommit } from "./commands/commit.js";
22
+ import { ghostBranch, checkoutGhost } from "./commands/branch.js";
23
+ import { mergePreview } from "./commands/merge.js";
24
+ import { checkHotZones } from "./commands/hotzone.js";
25
+ import { analyzeSymbols } from "./commands/analyze.js";
26
+
27
+ // ===== Setup CLI =====
14
28
  const program = new Command();
15
29
 
16
30
  program
17
- .name('bit')
18
- .description(chalk.cyan('Bit — Git with a brain'))
19
- .version('1.0.0');
31
+ .name("bit")
32
+ .description(chalk.cyan("Bit — Git with a brain"))
33
+ .version(pkg.version);
20
34
 
21
- // ============ SMART INIT ============
35
+ // ================= INIT =================
22
36
  program
23
- .command('init')
24
- .description('Initialize repo with smart .gitignore and .bit directory')
37
+ .command("init")
38
+ .description("Initialize repo with smart .gitignore and .bit directory")
25
39
  .action(smartInit);
26
40
 
27
- // ============ AI COMMIT ============
41
+ // ================= COMMIT =================
28
42
  program
29
- .command('commit')
30
- .description('AI-powered commit message generation')
31
- .option('-m, --message <msg>', 'Manual commit message (skip AI)')
43
+ .command("commit")
44
+ .description("AI-powered commit message generation")
45
+ .option("-m, --message <msg>", "Manual commit message (skip AI)")
32
46
  .action(aiCommit);
33
47
 
34
- // ============ GHOST BRANCHES ============
48
+ // ================= BRANCH =================
35
49
  program
36
- .command('branch')
37
- .description('List all branches including ghost branches')
38
- .option('--ghost <name>', 'Create a ghost branch')
39
- .option('--list-ghost', 'List only ghost branches')
50
+ .command("branch")
51
+ .description("List all branches including ghost branches")
52
+ .option("--ghost <name>", "Create a ghost branch")
53
+ .option("--list-ghost", "List only ghost branches")
40
54
  .action(ghostBranch);
41
55
 
56
+ // ================= CHECKOUT =================
42
57
  program
43
- .command('checkout')
44
- .description('Checkout a branch')
45
- .argument('<branch>', 'Branch name to checkout')
46
- .option('--ghost', 'Checkout a ghost branch')
58
+ .command("checkout")
59
+ .description("Checkout a branch")
60
+ .argument("<branch>", "Branch name to checkout")
61
+ .option("--ghost", "Checkout a ghost branch")
47
62
  .action(checkoutGhost);
48
63
 
49
- // ============ MERGE PREVIEW ============
64
+ // ================= MERGE =================
50
65
  program
51
- .command('merge')
52
- .description('Merge branches with optional preview')
53
- .argument('<branch>', 'Branch to merge')
54
- .option('--preview', 'Preview merge conflicts without merging')
66
+ .command("merge")
67
+ .description("Merge branches with optional preview")
68
+ .argument("<branch>", "Branch to merge")
69
+ .option("--preview", "Preview merge conflicts without merging")
55
70
  .action(mergePreview);
56
71
 
57
- // ============ HOT ZONE DETECTION ============
72
+ // ================= HOTZONE =================
58
73
  program
59
- .command('hotzone')
60
- .description('Detect overlapping work with other developers')
74
+ .command("hotzone")
75
+ .description("Detect overlapping work with other developers")
61
76
  .action(checkHotZones);
62
77
 
63
- // ============ SYMBOL ANALYSIS ============
78
+ // ================= ANALYZE =================
64
79
  program
65
- .command('analyze')
66
- .description('Analyze code changes at function/symbol level')
80
+ .command("analyze")
81
+ .description("Analyze code changes at function/symbol level")
67
82
  .action(analyzeSymbols);
68
83
 
69
- // ============ STATUS ============
84
+ // ================= STATUS =================
70
85
  program
71
- .command('status')
72
- .description('Enhanced git status with Bit intelligence')
86
+ .command("status")
87
+ .description("Enhanced git status with Bit intelligence")
73
88
  .action(() => {
74
89
  try {
75
- console.log(chalk.cyan('\n--- Bit Status ---\n'));
76
- execSync('git status', { stdio: 'inherit' });
90
+ console.log(chalk.cyan("\n--- Bit Status ---\n"));
91
+ execSync("git status", { stdio: "inherit" });
77
92
  checkHotZones(true); // silent mode
78
93
  } catch {
79
- console.error(chalk.red('Not a git repository'));
94
+ console.error(chalk.red("Not a git repository"));
95
+ process.exit(1);
80
96
  }
81
97
  });
82
98
 
83
- // ============ GIT PASSTHROUGH ============
84
- program
85
- .arguments('[command] [args...]')
86
- .action((command, args) => {
87
- if (!command) {
88
- program.outputHelp();
89
- return;
90
- }
99
+ // ================= GIT PASSTHROUGH =================
100
+ // Forward ANY unknown command directly to git
101
+ program.allowUnknownOption(true);
91
102
 
92
- try {
93
- execSync(`git ${command} ${args.join(' ')}`, { stdio: 'inherit' });
94
- } catch {
95
- process.exit(1);
96
- }
97
- });
103
+ program.action(() => {
104
+ const args = process.argv.slice(2);
105
+
106
+ if (args.length === 0) {
107
+ program.outputHelp();
108
+ return;
109
+ }
110
+
111
+ try {
112
+ execSync(`git ${args.join(" ")}`, { stdio: "inherit" });
113
+ } catch {
114
+ process.exit(1);
115
+ }
116
+ });
98
117
 
118
+ // ================= RUN =================
99
119
  program.parse(process.argv);