From 8996f3609d3d13a62dd9943bfe2e846508a70336 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Wed, 12 Mar 2025 12:02:47 -0400 Subject: [PATCH 1/3] feat: add git and gh CLI tools availability check Implements a utility function to check if git and gh CLI tools are available and if gh is authenticated when GitHub mode is enabled. - Created gitCliCheck.ts utility with functions to check git/gh availability - Added warning messages when GitHub mode is enabled but tools are missing - Added unit tests for the new functionality Fixes #217 --- packages/cli/src/commands/$default.ts | 23 +++++ packages/cli/src/utils/gitCliCheck.test.ts | 110 +++++++++++++++++++++ packages/cli/src/utils/gitCliCheck.ts | 89 +++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 packages/cli/src/utils/gitCliCheck.test.ts create mode 100644 packages/cli/src/utils/gitCliCheck.ts diff --git a/packages/cli/src/commands/$default.ts b/packages/cli/src/commands/$default.ts index 8287ad7..f2ca110 100644 --- a/packages/cli/src/commands/$default.ts +++ b/packages/cli/src/commands/$default.ts @@ -20,8 +20,10 @@ import { TokenTracker } from 'mycoder-agent/dist/core/tokens.js'; import { SharedOptions } from '../options.js'; import { captureException } from '../sentry/index.js'; import { getConfigFromArgv, loadConfig } from '../settings/config.js'; +import { checkGitHubTools, getGitHubModeWarning } from '../utils/githubTools.js'; import { nameToLogIndex } from '../utils/nameToLogIndex.js'; import { checkForUpdates, getPackageInfo } from '../utils/versionCheck.js'; +import { checkGitCli } from '../utils/gitCliCheck.js'; import type { CommandModule, Argv } from 'yargs'; @@ -58,6 +60,27 @@ export const command: CommandModule = { if (config.upgradeCheck !== false) { await checkForUpdates(logger); } + + // Check for git and gh CLI tools if GitHub mode is enabled + if (config.githubMode) { + logger.debug('GitHub mode is enabled, checking for git and gh CLI tools...'); + const gitCliCheck = await checkGitCli(logger); + + if (gitCliCheck.errors.length > 0) { + logger.warn('GitHub mode is enabled but there are issues with git/gh CLI tools:'); + gitCliCheck.errors.forEach(error => logger.warn(`- ${error}`)); + + if (!gitCliCheck.gitAvailable || !gitCliCheck.ghAvailable) { + logger.warn('GitHub mode requires git and gh CLI tools to be installed.'); + logger.warn('Please install the missing tools or disable GitHub mode with --githubMode false'); + } else if (!gitCliCheck.ghAuthenticated) { + logger.warn('GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.'); + } + } else { + logger.info('GitHub mode is enabled and all required CLI tools are available.'); + } + } + const tokenTracker = new TokenTracker( 'Root', undefined, diff --git a/packages/cli/src/utils/gitCliCheck.test.ts b/packages/cli/src/utils/gitCliCheck.test.ts new file mode 100644 index 0000000..fb31fad --- /dev/null +++ b/packages/cli/src/utils/gitCliCheck.test.ts @@ -0,0 +1,110 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { checkGitCli, GitCliCheckResult } from './gitCliCheck'; + +// Mock the child_process module +vi.mock('child_process', () => ({ + exec: vi.fn(), +})); + +// Mock the util module +vi.mock('util', () => ({ + promisify: vi.fn((fn) => { + return (cmd: string) => { + return new Promise((resolve, reject) => { + fn(cmd, (error: Error | null, result: { stdout: string }) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); + }); + }; + }), +})); + +// Import the mocked modules +import { exec } from 'child_process'; + +describe('gitCliCheck', () => { + const mockExec = exec as unknown as vi.Mock; + + beforeEach(() => { + mockExec.mockReset(); + }); + + it('should return all true when git and gh are available and authenticated', async () => { + // Mock successful responses + mockExec.mockImplementation((cmd: string, callback: Function) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(null, { stdout: 'Logged in to github.com as username' }); + } + }); + + const result = await checkGitCli(); + + expect(result.gitAvailable).toBe(true); + expect(result.ghAvailable).toBe(true); + expect(result.ghAuthenticated).toBe(true); + expect(result.errors).toHaveLength(0); + }); + + it('should detect when git is not available', async () => { + mockExec.mockImplementation((cmd: string, callback: Function) => { + if (cmd === 'git --version') { + callback(new Error('Command not found')); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(null, { stdout: 'Logged in to github.com as username' }); + } + }); + + const result = await checkGitCli(); + + expect(result.gitAvailable).toBe(false); + expect(result.ghAvailable).toBe(true); + expect(result.ghAuthenticated).toBe(true); + expect(result.errors).toContain('Git CLI is not available. Please install git.'); + }); + + it('should detect when gh is not available', async () => { + mockExec.mockImplementation((cmd: string, callback: Function) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(new Error('Command not found')); + } + }); + + const result = await checkGitCli(); + + expect(result.gitAvailable).toBe(true); + expect(result.ghAvailable).toBe(false); + expect(result.ghAuthenticated).toBe(false); + expect(result.errors).toContain('GitHub CLI is not available. Please install gh CLI.'); + }); + + it('should detect when gh is not authenticated', async () => { + mockExec.mockImplementation((cmd: string, callback: Function) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(new Error('You are not logged into any GitHub hosts')); + } + }); + + const result = await checkGitCli(); + + expect(result.gitAvailable).toBe(true); + expect(result.ghAvailable).toBe(true); + expect(result.ghAuthenticated).toBe(false); + expect(result.errors).toContain('GitHub CLI is not authenticated. Please run "gh auth login".'); + }); +}); \ No newline at end of file diff --git a/packages/cli/src/utils/gitCliCheck.ts b/packages/cli/src/utils/gitCliCheck.ts new file mode 100644 index 0000000..163ca6f --- /dev/null +++ b/packages/cli/src/utils/gitCliCheck.ts @@ -0,0 +1,89 @@ +import { exec } from 'child_process'; +import { promisify } from 'util'; +import { Logger } from 'mycoder-agent'; + +const execAsync = promisify(exec); + +/** + * Result of CLI tool checks + */ +export interface GitCliCheckResult { + gitAvailable: boolean; + ghAvailable: boolean; + ghAuthenticated: boolean; + errors: string[]; +} + +/** + * Checks if git command is available + */ +async function checkGitAvailable(): Promise { + try { + await execAsync('git --version'); + return true; + } catch (error) { + return false; + } +} + +/** + * Checks if gh command is available + */ +async function checkGhAvailable(): Promise { + try { + await execAsync('gh --version'); + return true; + } catch (error) { + return false; + } +} + +/** + * Checks if gh is authenticated + */ +async function checkGhAuthenticated(): Promise { + try { + const { stdout } = await execAsync('gh auth status'); + return stdout.includes('Logged in to'); + } catch (error) { + return false; + } +} + +/** + * Checks if git and gh CLI tools are available and if gh is authenticated + * @param logger Optional logger for debug output + * @returns Object with check results + */ +export async function checkGitCli(logger?: Logger): Promise { + const result: GitCliCheckResult = { + gitAvailable: false, + ghAvailable: false, + ghAuthenticated: false, + errors: [], + }; + + logger?.debug('Checking for git CLI availability...'); + result.gitAvailable = await checkGitAvailable(); + + logger?.debug('Checking for gh CLI availability...'); + result.ghAvailable = await checkGhAvailable(); + + if (result.ghAvailable) { + logger?.debug('Checking for gh CLI authentication...'); + result.ghAuthenticated = await checkGhAuthenticated(); + } + + // Collect any errors + if (!result.gitAvailable) { + result.errors.push('Git CLI is not available. Please install git.'); + } + + if (!result.ghAvailable) { + result.errors.push('GitHub CLI is not available. Please install gh CLI.'); + } else if (!result.ghAuthenticated) { + result.errors.push('GitHub CLI is not authenticated. Please run "gh auth login".'); + } + + return result; +} \ No newline at end of file From 54431854e1e02de2a3c6bf993b114993739dcca1 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Wed, 12 Mar 2025 12:04:30 -0400 Subject: [PATCH 2/3] feat(cli): Add checking for git and gh CLI tools in GitHub mode Closes #217 - Enable GitHub mode by default - Add automatic checking for git and gh CLI tools when GitHub mode is enabled - Disable GitHub mode if required tools are not available or not authenticated - Update README.md with information about the new behavior - Update tsconfig.json to exclude test files from build --- packages/cli/README.md | 33 ++++++++++++--------------- packages/cli/src/commands/$default.ts | 9 ++++++-- packages/cli/src/options.ts | 3 ++- packages/cli/src/utils/gitCliCheck.ts | 6 ++--- packages/cli/tsconfig.json | 3 ++- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index fc5523e..b21374c 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -52,30 +52,22 @@ MyCoder includes a GitHub mode that enables the agent to work with GitHub issues - Create PRs when work is complete - Create additional GitHub issues for follow-up tasks or ideas -To enable GitHub mode: +GitHub mode is **enabled by default** but requires the Git and GitHub CLI tools to be installed and configured: -1. Via CLI option (overrides config file): - -```bash -mycoder --githubMode true -``` - -2. Via configuration file: +- Git CLI (`git`) must be installed +- GitHub CLI (`gh`) must be installed and authenticated -```js -// mycoder.config.js -export default { - githubMode: true, - // other configuration options... -}; -``` +MyCoder will automatically check for these requirements when GitHub mode is enabled and will: +- Warn you if any requirements are missing +- Automatically disable GitHub mode if the required tools are not available or not authenticated -To disable GitHub mode: +To manually enable/disable GitHub mode: -1. Via CLI option: +1. Via CLI option (overrides config file): ```bash -mycoder --githubMode false +mycoder --githubMode true # Enable GitHub mode +mycoder --githubMode false # Disable GitHub mode ``` 2. Via configuration file: @@ -83,16 +75,19 @@ mycoder --githubMode false ```js // mycoder.config.js export default { - githubMode: false, + githubMode: true, // Enable GitHub mode (default) // other configuration options... }; ``` Requirements for GitHub mode: +- Git CLI (`git`) needs to be installed - GitHub CLI (`gh`) needs to be installed and authenticated - User needs to have appropriate GitHub permissions for the target repository +If GitHub mode is enabled but the requirements are not met, MyCoder will provide instructions on how to install and configure the missing tools. + ## Configuration MyCoder is configured using a `mycoder.config.js` file in your project root, similar to ESLint and other modern JavaScript tools. This file exports a configuration object with your preferred settings. diff --git a/packages/cli/src/commands/$default.ts b/packages/cli/src/commands/$default.ts index f2ca110..05e0943 100644 --- a/packages/cli/src/commands/$default.ts +++ b/packages/cli/src/commands/$default.ts @@ -20,10 +20,9 @@ import { TokenTracker } from 'mycoder-agent/dist/core/tokens.js'; import { SharedOptions } from '../options.js'; import { captureException } from '../sentry/index.js'; import { getConfigFromArgv, loadConfig } from '../settings/config.js'; -import { checkGitHubTools, getGitHubModeWarning } from '../utils/githubTools.js'; +import { checkGitCli } from '../utils/gitCliCheck.js'; import { nameToLogIndex } from '../utils/nameToLogIndex.js'; import { checkForUpdates, getPackageInfo } from '../utils/versionCheck.js'; -import { checkGitCli } from '../utils/gitCliCheck.js'; import type { CommandModule, Argv } from 'yargs'; @@ -73,8 +72,14 @@ export const command: CommandModule = { if (!gitCliCheck.gitAvailable || !gitCliCheck.ghAvailable) { logger.warn('GitHub mode requires git and gh CLI tools to be installed.'); logger.warn('Please install the missing tools or disable GitHub mode with --githubMode false'); + // Disable GitHub mode if git or gh CLI is not available + logger.info('Disabling GitHub mode due to missing CLI tools.'); + config.githubMode = false; } else if (!gitCliCheck.ghAuthenticated) { logger.warn('GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.'); + // Disable GitHub mode if gh CLI is not authenticated + logger.info('Disabling GitHub mode due to unauthenticated GitHub CLI.'); + config.githubMode = false; } } else { logger.info('GitHub mode is enabled and all required CLI tools are available.'); diff --git a/packages/cli/src/options.ts b/packages/cli/src/options.ts index 99620dc..250f33b 100644 --- a/packages/cli/src/options.ts +++ b/packages/cli/src/options.ts @@ -88,7 +88,8 @@ export const sharedOptions = { } as const, githubMode: { type: 'boolean', - description: 'Enable GitHub mode for working with issues and PRs', + description: 'Enable GitHub mode for working with issues and PRs (requires git and gh CLI tools)', + default: true, } as const, upgradeCheck: { type: 'boolean', diff --git a/packages/cli/src/utils/gitCliCheck.ts b/packages/cli/src/utils/gitCliCheck.ts index 163ca6f..be29856 100644 --- a/packages/cli/src/utils/gitCliCheck.ts +++ b/packages/cli/src/utils/gitCliCheck.ts @@ -21,7 +21,7 @@ async function checkGitAvailable(): Promise { try { await execAsync('git --version'); return true; - } catch (error) { + } catch { return false; } } @@ -33,7 +33,7 @@ async function checkGhAvailable(): Promise { try { await execAsync('gh --version'); return true; - } catch (error) { + } catch { return false; } } @@ -45,7 +45,7 @@ async function checkGhAuthenticated(): Promise { try { const { stdout } = await execAsync('gh auth status'); return stdout.includes('Logged in to'); - } catch (error) { + } catch { return false; } } diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 204fe19..5954c75 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -44,5 +44,6 @@ "allowJs": false, "checkJs": false }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["src/**/*.test.ts", "src/**/*.spec.ts"] } From bec69e9f1d83e398c03ee1cae86c219c75642057 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Wed, 12 Mar 2025 12:20:30 -0400 Subject: [PATCH 3/3] style: Format code with Prettier --- mycoder.config.js | 4 +- packages/cli/src/commands/$default.ts | 36 ++++-- packages/cli/src/options.ts | 3 +- packages/cli/src/utils/gitCliCheck.test.ts | 138 +++++++++++++-------- packages/cli/src/utils/gitCliCheck.ts | 9 +- 5 files changed, 118 insertions(+), 72 deletions(-) diff --git a/mycoder.config.js b/mycoder.config.js index 04155d9..6c346a5 100644 --- a/mycoder.config.js +++ b/mycoder.config.js @@ -13,8 +13,8 @@ export default { //model: 'claude-3-7-sonnet-20250219', //provider: 'openai', //model: 'gpt-4o', - provider: 'ollama', - model: 'medragondot/Sky-T1-32B-Preview:latest', + //provider: 'ollama', + // model: 'medragondot/Sky-T1-32B-Preview:latest', maxTokens: 4096, temperature: 0.7, diff --git a/packages/cli/src/commands/$default.ts b/packages/cli/src/commands/$default.ts index 05e0943..87e3576 100644 --- a/packages/cli/src/commands/$default.ts +++ b/packages/cli/src/commands/$default.ts @@ -62,30 +62,44 @@ export const command: CommandModule = { // Check for git and gh CLI tools if GitHub mode is enabled if (config.githubMode) { - logger.debug('GitHub mode is enabled, checking for git and gh CLI tools...'); + logger.debug( + 'GitHub mode is enabled, checking for git and gh CLI tools...', + ); const gitCliCheck = await checkGitCli(logger); - + if (gitCliCheck.errors.length > 0) { - logger.warn('GitHub mode is enabled but there are issues with git/gh CLI tools:'); - gitCliCheck.errors.forEach(error => logger.warn(`- ${error}`)); - + logger.warn( + 'GitHub mode is enabled but there are issues with git/gh CLI tools:', + ); + gitCliCheck.errors.forEach((error) => logger.warn(`- ${error}`)); + if (!gitCliCheck.gitAvailable || !gitCliCheck.ghAvailable) { - logger.warn('GitHub mode requires git and gh CLI tools to be installed.'); - logger.warn('Please install the missing tools or disable GitHub mode with --githubMode false'); + logger.warn( + 'GitHub mode requires git and gh CLI tools to be installed.', + ); + logger.warn( + 'Please install the missing tools or disable GitHub mode with --githubMode false', + ); // Disable GitHub mode if git or gh CLI is not available logger.info('Disabling GitHub mode due to missing CLI tools.'); config.githubMode = false; } else if (!gitCliCheck.ghAuthenticated) { - logger.warn('GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.'); + logger.warn( + 'GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.', + ); // Disable GitHub mode if gh CLI is not authenticated - logger.info('Disabling GitHub mode due to unauthenticated GitHub CLI.'); + logger.info( + 'Disabling GitHub mode due to unauthenticated GitHub CLI.', + ); config.githubMode = false; } } else { - logger.info('GitHub mode is enabled and all required CLI tools are available.'); + logger.info( + 'GitHub mode is enabled and all required CLI tools are available.', + ); } } - + const tokenTracker = new TokenTracker( 'Root', undefined, diff --git a/packages/cli/src/options.ts b/packages/cli/src/options.ts index 250f33b..94d2994 100644 --- a/packages/cli/src/options.ts +++ b/packages/cli/src/options.ts @@ -88,7 +88,8 @@ export const sharedOptions = { } as const, githubMode: { type: 'boolean', - description: 'Enable GitHub mode for working with issues and PRs (requires git and gh CLI tools)', + description: + 'Enable GitHub mode for working with issues and PRs (requires git and gh CLI tools)', default: true, } as const, upgradeCheck: { diff --git a/packages/cli/src/utils/gitCliCheck.test.ts b/packages/cli/src/utils/gitCliCheck.test.ts index fb31fad..7ef16a4 100644 --- a/packages/cli/src/utils/gitCliCheck.test.ts +++ b/packages/cli/src/utils/gitCliCheck.test.ts @@ -1,5 +1,8 @@ +import { exec } from 'child_process'; + import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { checkGitCli, GitCliCheckResult } from './gitCliCheck'; + +import { checkGitCli } from './gitCliCheck'; // Mock the child_process module vi.mock('child_process', () => ({ @@ -23,88 +26,113 @@ vi.mock('util', () => ({ }), })); -// Import the mocked modules -import { exec } from 'child_process'; - describe('gitCliCheck', () => { const mockExec = exec as unknown as vi.Mock; - + beforeEach(() => { mockExec.mockReset(); }); - + it('should return all true when git and gh are available and authenticated', async () => { // Mock successful responses - mockExec.mockImplementation((cmd: string, callback: Function) => { - if (cmd === 'git --version') { - callback(null, { stdout: 'git version 2.30.1' }); - } else if (cmd === 'gh --version') { - callback(null, { stdout: 'gh version 2.0.0' }); - } else if (cmd === 'gh auth status') { - callback(null, { stdout: 'Logged in to github.com as username' }); - } - }); - + mockExec.mockImplementation( + ( + cmd: string, + callback: (error: Error | null, result: { stdout: string }) => void, + ) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(null, { stdout: 'Logged in to github.com as username' }); + } + }, + ); + const result = await checkGitCli(); - + expect(result.gitAvailable).toBe(true); expect(result.ghAvailable).toBe(true); expect(result.ghAuthenticated).toBe(true); expect(result.errors).toHaveLength(0); }); - + it('should detect when git is not available', async () => { - mockExec.mockImplementation((cmd: string, callback: Function) => { - if (cmd === 'git --version') { - callback(new Error('Command not found')); - } else if (cmd === 'gh --version') { - callback(null, { stdout: 'gh version 2.0.0' }); - } else if (cmd === 'gh auth status') { - callback(null, { stdout: 'Logged in to github.com as username' }); - } - }); - + mockExec.mockImplementation( + ( + cmd: string, + callback: (error: Error | null, result: { stdout: string }) => void, + ) => { + if (cmd === 'git --version') { + callback(new Error('Command not found'), { stdout: '' }); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(null, { stdout: 'Logged in to github.com as username' }); + } + }, + ); + const result = await checkGitCli(); - + expect(result.gitAvailable).toBe(false); expect(result.ghAvailable).toBe(true); expect(result.ghAuthenticated).toBe(true); - expect(result.errors).toContain('Git CLI is not available. Please install git.'); + expect(result.errors).toContain( + 'Git CLI is not available. Please install git.', + ); }); - + it('should detect when gh is not available', async () => { - mockExec.mockImplementation((cmd: string, callback: Function) => { - if (cmd === 'git --version') { - callback(null, { stdout: 'git version 2.30.1' }); - } else if (cmd === 'gh --version') { - callback(new Error('Command not found')); - } - }); - + mockExec.mockImplementation( + ( + cmd: string, + callback: (error: Error | null, result: { stdout: string }) => void, + ) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(new Error('Command not found'), { stdout: '' }); + } + }, + ); + const result = await checkGitCli(); - + expect(result.gitAvailable).toBe(true); expect(result.ghAvailable).toBe(false); expect(result.ghAuthenticated).toBe(false); - expect(result.errors).toContain('GitHub CLI is not available. Please install gh CLI.'); + expect(result.errors).toContain( + 'GitHub CLI is not available. Please install gh CLI.', + ); }); - + it('should detect when gh is not authenticated', async () => { - mockExec.mockImplementation((cmd: string, callback: Function) => { - if (cmd === 'git --version') { - callback(null, { stdout: 'git version 2.30.1' }); - } else if (cmd === 'gh --version') { - callback(null, { stdout: 'gh version 2.0.0' }); - } else if (cmd === 'gh auth status') { - callback(new Error('You are not logged into any GitHub hosts')); - } - }); - + mockExec.mockImplementation( + ( + cmd: string, + callback: (error: Error | null, result: { stdout: string }) => void, + ) => { + if (cmd === 'git --version') { + callback(null, { stdout: 'git version 2.30.1' }); + } else if (cmd === 'gh --version') { + callback(null, { stdout: 'gh version 2.0.0' }); + } else if (cmd === 'gh auth status') { + callback(new Error('You are not logged into any GitHub hosts'), { + stdout: '', + }); + } + }, + ); + const result = await checkGitCli(); - + expect(result.gitAvailable).toBe(true); expect(result.ghAvailable).toBe(true); expect(result.ghAuthenticated).toBe(false); - expect(result.errors).toContain('GitHub CLI is not authenticated. Please run "gh auth login".'); + expect(result.errors).toContain( + 'GitHub CLI is not authenticated. Please run "gh auth login".', + ); }); -}); \ No newline at end of file +}); diff --git a/packages/cli/src/utils/gitCliCheck.ts b/packages/cli/src/utils/gitCliCheck.ts index be29856..530b732 100644 --- a/packages/cli/src/utils/gitCliCheck.ts +++ b/packages/cli/src/utils/gitCliCheck.ts @@ -1,5 +1,6 @@ import { exec } from 'child_process'; import { promisify } from 'util'; + import { Logger } from 'mycoder-agent'; const execAsync = promisify(exec); @@ -78,12 +79,14 @@ export async function checkGitCli(logger?: Logger): Promise { if (!result.gitAvailable) { result.errors.push('Git CLI is not available. Please install git.'); } - + if (!result.ghAvailable) { result.errors.push('GitHub CLI is not available. Please install gh CLI.'); } else if (!result.ghAuthenticated) { - result.errors.push('GitHub CLI is not authenticated. Please run "gh auth login".'); + result.errors.push( + 'GitHub CLI is not authenticated. Please run "gh auth login".', + ); } return result; -} \ No newline at end of file +}