Skip to content

Commit bec69e9

Browse files
committed
style: Format code with Prettier
1 parent 5443185 commit bec69e9

File tree

5 files changed

+118
-72
lines changed

5 files changed

+118
-72
lines changed

mycoder.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export default {
1313
//model: 'claude-3-7-sonnet-20250219',
1414
//provider: 'openai',
1515
//model: 'gpt-4o',
16-
provider: 'ollama',
17-
model: 'medragondot/Sky-T1-32B-Preview:latest',
16+
//provider: 'ollama',
17+
// model: 'medragondot/Sky-T1-32B-Preview:latest',
1818
maxTokens: 4096,
1919
temperature: 0.7,
2020

packages/cli/src/commands/$default.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,44 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
6262

6363
// Check for git and gh CLI tools if GitHub mode is enabled
6464
if (config.githubMode) {
65-
logger.debug('GitHub mode is enabled, checking for git and gh CLI tools...');
65+
logger.debug(
66+
'GitHub mode is enabled, checking for git and gh CLI tools...',
67+
);
6668
const gitCliCheck = await checkGitCli(logger);
67-
69+
6870
if (gitCliCheck.errors.length > 0) {
69-
logger.warn('GitHub mode is enabled but there are issues with git/gh CLI tools:');
70-
gitCliCheck.errors.forEach(error => logger.warn(`- ${error}`));
71-
71+
logger.warn(
72+
'GitHub mode is enabled but there are issues with git/gh CLI tools:',
73+
);
74+
gitCliCheck.errors.forEach((error) => logger.warn(`- ${error}`));
75+
7276
if (!gitCliCheck.gitAvailable || !gitCliCheck.ghAvailable) {
73-
logger.warn('GitHub mode requires git and gh CLI tools to be installed.');
74-
logger.warn('Please install the missing tools or disable GitHub mode with --githubMode false');
77+
logger.warn(
78+
'GitHub mode requires git and gh CLI tools to be installed.',
79+
);
80+
logger.warn(
81+
'Please install the missing tools or disable GitHub mode with --githubMode false',
82+
);
7583
// Disable GitHub mode if git or gh CLI is not available
7684
logger.info('Disabling GitHub mode due to missing CLI tools.');
7785
config.githubMode = false;
7886
} else if (!gitCliCheck.ghAuthenticated) {
79-
logger.warn('GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.');
87+
logger.warn(
88+
'GitHub CLI is not authenticated. Please run "gh auth login" to authenticate.',
89+
);
8090
// Disable GitHub mode if gh CLI is not authenticated
81-
logger.info('Disabling GitHub mode due to unauthenticated GitHub CLI.');
91+
logger.info(
92+
'Disabling GitHub mode due to unauthenticated GitHub CLI.',
93+
);
8294
config.githubMode = false;
8395
}
8496
} else {
85-
logger.info('GitHub mode is enabled and all required CLI tools are available.');
97+
logger.info(
98+
'GitHub mode is enabled and all required CLI tools are available.',
99+
);
86100
}
87101
}
88-
102+
89103
const tokenTracker = new TokenTracker(
90104
'Root',
91105
undefined,

packages/cli/src/options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export const sharedOptions = {
8888
} as const,
8989
githubMode: {
9090
type: 'boolean',
91-
description: 'Enable GitHub mode for working with issues and PRs (requires git and gh CLI tools)',
91+
description:
92+
'Enable GitHub mode for working with issues and PRs (requires git and gh CLI tools)',
9293
default: true,
9394
} as const,
9495
upgradeCheck: {
Lines changed: 83 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import { exec } from 'child_process';
2+
13
import { describe, it, expect, vi, beforeEach } from 'vitest';
2-
import { checkGitCli, GitCliCheckResult } from './gitCliCheck';
4+
5+
import { checkGitCli } from './gitCliCheck';
36

47
// Mock the child_process module
58
vi.mock('child_process', () => ({
@@ -23,88 +26,113 @@ vi.mock('util', () => ({
2326
}),
2427
}));
2528

26-
// Import the mocked modules
27-
import { exec } from 'child_process';
28-
2929
describe('gitCliCheck', () => {
3030
const mockExec = exec as unknown as vi.Mock;
31-
31+
3232
beforeEach(() => {
3333
mockExec.mockReset();
3434
});
35-
35+
3636
it('should return all true when git and gh are available and authenticated', async () => {
3737
// Mock successful responses
38-
mockExec.mockImplementation((cmd: string, callback: Function) => {
39-
if (cmd === 'git --version') {
40-
callback(null, { stdout: 'git version 2.30.1' });
41-
} else if (cmd === 'gh --version') {
42-
callback(null, { stdout: 'gh version 2.0.0' });
43-
} else if (cmd === 'gh auth status') {
44-
callback(null, { stdout: 'Logged in to github.com as username' });
45-
}
46-
});
47-
38+
mockExec.mockImplementation(
39+
(
40+
cmd: string,
41+
callback: (error: Error | null, result: { stdout: string }) => void,
42+
) => {
43+
if (cmd === 'git --version') {
44+
callback(null, { stdout: 'git version 2.30.1' });
45+
} else if (cmd === 'gh --version') {
46+
callback(null, { stdout: 'gh version 2.0.0' });
47+
} else if (cmd === 'gh auth status') {
48+
callback(null, { stdout: 'Logged in to github.com as username' });
49+
}
50+
},
51+
);
52+
4853
const result = await checkGitCli();
49-
54+
5055
expect(result.gitAvailable).toBe(true);
5156
expect(result.ghAvailable).toBe(true);
5257
expect(result.ghAuthenticated).toBe(true);
5358
expect(result.errors).toHaveLength(0);
5459
});
55-
60+
5661
it('should detect when git is not available', async () => {
57-
mockExec.mockImplementation((cmd: string, callback: Function) => {
58-
if (cmd === 'git --version') {
59-
callback(new Error('Command not found'));
60-
} else if (cmd === 'gh --version') {
61-
callback(null, { stdout: 'gh version 2.0.0' });
62-
} else if (cmd === 'gh auth status') {
63-
callback(null, { stdout: 'Logged in to github.com as username' });
64-
}
65-
});
66-
62+
mockExec.mockImplementation(
63+
(
64+
cmd: string,
65+
callback: (error: Error | null, result: { stdout: string }) => void,
66+
) => {
67+
if (cmd === 'git --version') {
68+
callback(new Error('Command not found'), { stdout: '' });
69+
} else if (cmd === 'gh --version') {
70+
callback(null, { stdout: 'gh version 2.0.0' });
71+
} else if (cmd === 'gh auth status') {
72+
callback(null, { stdout: 'Logged in to github.com as username' });
73+
}
74+
},
75+
);
76+
6777
const result = await checkGitCli();
68-
78+
6979
expect(result.gitAvailable).toBe(false);
7080
expect(result.ghAvailable).toBe(true);
7181
expect(result.ghAuthenticated).toBe(true);
72-
expect(result.errors).toContain('Git CLI is not available. Please install git.');
82+
expect(result.errors).toContain(
83+
'Git CLI is not available. Please install git.',
84+
);
7385
});
74-
86+
7587
it('should detect when gh is not available', async () => {
76-
mockExec.mockImplementation((cmd: string, callback: Function) => {
77-
if (cmd === 'git --version') {
78-
callback(null, { stdout: 'git version 2.30.1' });
79-
} else if (cmd === 'gh --version') {
80-
callback(new Error('Command not found'));
81-
}
82-
});
83-
88+
mockExec.mockImplementation(
89+
(
90+
cmd: string,
91+
callback: (error: Error | null, result: { stdout: string }) => void,
92+
) => {
93+
if (cmd === 'git --version') {
94+
callback(null, { stdout: 'git version 2.30.1' });
95+
} else if (cmd === 'gh --version') {
96+
callback(new Error('Command not found'), { stdout: '' });
97+
}
98+
},
99+
);
100+
84101
const result = await checkGitCli();
85-
102+
86103
expect(result.gitAvailable).toBe(true);
87104
expect(result.ghAvailable).toBe(false);
88105
expect(result.ghAuthenticated).toBe(false);
89-
expect(result.errors).toContain('GitHub CLI is not available. Please install gh CLI.');
106+
expect(result.errors).toContain(
107+
'GitHub CLI is not available. Please install gh CLI.',
108+
);
90109
});
91-
110+
92111
it('should detect when gh is not authenticated', async () => {
93-
mockExec.mockImplementation((cmd: string, callback: Function) => {
94-
if (cmd === 'git --version') {
95-
callback(null, { stdout: 'git version 2.30.1' });
96-
} else if (cmd === 'gh --version') {
97-
callback(null, { stdout: 'gh version 2.0.0' });
98-
} else if (cmd === 'gh auth status') {
99-
callback(new Error('You are not logged into any GitHub hosts'));
100-
}
101-
});
102-
112+
mockExec.mockImplementation(
113+
(
114+
cmd: string,
115+
callback: (error: Error | null, result: { stdout: string }) => void,
116+
) => {
117+
if (cmd === 'git --version') {
118+
callback(null, { stdout: 'git version 2.30.1' });
119+
} else if (cmd === 'gh --version') {
120+
callback(null, { stdout: 'gh version 2.0.0' });
121+
} else if (cmd === 'gh auth status') {
122+
callback(new Error('You are not logged into any GitHub hosts'), {
123+
stdout: '',
124+
});
125+
}
126+
},
127+
);
128+
103129
const result = await checkGitCli();
104-
130+
105131
expect(result.gitAvailable).toBe(true);
106132
expect(result.ghAvailable).toBe(true);
107133
expect(result.ghAuthenticated).toBe(false);
108-
expect(result.errors).toContain('GitHub CLI is not authenticated. Please run "gh auth login".');
134+
expect(result.errors).toContain(
135+
'GitHub CLI is not authenticated. Please run "gh auth login".',
136+
);
109137
});
110-
});
138+
});

packages/cli/src/utils/gitCliCheck.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { exec } from 'child_process';
22
import { promisify } from 'util';
3+
34
import { Logger } from 'mycoder-agent';
45

56
const execAsync = promisify(exec);
@@ -78,12 +79,14 @@ export async function checkGitCli(logger?: Logger): Promise<GitCliCheckResult> {
7879
if (!result.gitAvailable) {
7980
result.errors.push('Git CLI is not available. Please install git.');
8081
}
81-
82+
8283
if (!result.ghAvailable) {
8384
result.errors.push('GitHub CLI is not available. Please install gh CLI.');
8485
} else if (!result.ghAuthenticated) {
85-
result.errors.push('GitHub CLI is not authenticated. Please run "gh auth login".');
86+
result.errors.push(
87+
'GitHub CLI is not authenticated. Please run "gh auth login".',
88+
);
8689
}
8790

8891
return result;
89-
}
92+
}

0 commit comments

Comments
 (0)