@agentuity/cli 0.0.85 → 0.0.86

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.
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Git helper utilities for detecting and using git safely.
3
+ *
4
+ * On macOS, git may be a stub that triggers Xcode Command Line Tools installation popup.
5
+ * This helper detects the real git binary and provides safe wrappers.
6
+ */
7
+
8
+ /**
9
+ * Check if git is available and is the real git binary (not the macOS stub).
10
+ *
11
+ * On macOS without Xcode CLT installed, /usr/bin/git exists but it's a stub that
12
+ * triggers a popup asking to install developer tools. We detect this by checking
13
+ * if Xcode Command Line Tools are installed using `xcode-select -p`.
14
+ *
15
+ * @returns true if git is available and functional, false otherwise
16
+ */
17
+ export async function isGitAvailable(): Promise<boolean> {
18
+ const gitPath = Bun.which('git');
19
+ if (!gitPath) {
20
+ return false;
21
+ }
22
+
23
+ // On macOS, check if Xcode Command Line Tools are installed
24
+ // xcode-select -p returns 0 if tools are installed, non-zero otherwise
25
+ if (process.platform === 'darwin') {
26
+ try {
27
+ const result = Bun.spawnSync(['xcode-select', '-p'], {
28
+ stdout: 'pipe',
29
+ stderr: 'pipe',
30
+ });
31
+
32
+ // If xcode-select -p fails, CLT are not installed, git is just a stub
33
+ if (result.exitCode !== 0) {
34
+ return false;
35
+ }
36
+ } catch {
37
+ // xcode-select not found or error - assume git is not available
38
+ return false;
39
+ }
40
+ }
41
+
42
+ // On other platforms, just verify git works
43
+ try {
44
+ const result = Bun.spawnSync(['git', '--version'], {
45
+ stdout: 'pipe',
46
+ stderr: 'pipe',
47
+ });
48
+ return result.exitCode === 0;
49
+ } catch {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Get the default branch name from git config, or 'main' as fallback.
56
+ * Returns null if git is not available.
57
+ */
58
+ export async function getDefaultBranch(): Promise<string | null> {
59
+ if (!(await isGitAvailable())) {
60
+ return null;
61
+ }
62
+
63
+ try {
64
+ const result = Bun.spawnSync(['git', 'config', '--global', 'init.defaultBranch']);
65
+ if (result.exitCode === 0) {
66
+ const branch = result.stdout.toString().trim();
67
+ return branch || 'main';
68
+ }
69
+ } catch {
70
+ // Ignore errors
71
+ }
72
+
73
+ return 'main';
74
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { createCLI, registerCommands } from './cli';
2
2
  export { validateRuntime, isBun } from './runtime';
3
+ export { ensureBunOnPath } from './bun-path';
4
+ export { isGitAvailable, getDefaultBranch } from './git-helper';
3
5
  export {
4
6
  generateCLISchema,
5
7
  type CLISchema,