Skip to content

Commit 2b5f0c8

Browse files
authored
Merge pull request #46 from agentage/chore/add-prettier-ci
chore: add prettier format:check to CI
2 parents 34675ce + b35928e commit 2b5f0c8

35 files changed

Lines changed: 208 additions & 557 deletions

.github/copilot-instructions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070
**Command Structure**:
7171

7272
```typescript
73-
import { Command } from "commander";
73+
import { Command } from 'commander';
7474

75-
export const myCommand = new Command("name")
76-
.description("Command description")
77-
.option("-o, --option <value>", "Option description")
75+
export const myCommand = new Command('name')
76+
.description('Command description')
77+
.option('-o, --option <value>', 'Option description')
7878
.action(async (options) => {
7979
// Implementation
8080
});

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ updates:
3232
all-actions:
3333
patterns:
3434
- '*'
35-

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-node@v6
2424
with:
2525
node-version: ${{ matrix.node-version }}
26-
cache: "npm"
26+
cache: 'npm'
2727

2828
- name: 📦 Install dependencies
2929
run: npm ci
@@ -34,6 +34,9 @@ jobs:
3434
- name: 🔍 Lint
3535
run: npm run lint
3636

37+
- name: 💅 Format check
38+
run: npm run format:check
39+
3740
- name: 🏗️ Build
3841
run: npm run build
3942

.github/workflows/publish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ on:
44
push:
55
branches: [master, main]
66
paths:
7-
- "package.json"
7+
- 'package.json'
88
workflow_dispatch:
99

1010
permissions:
1111
contents: write
1212
id-token: write
1313

1414
env:
15-
NODE_VERSION: "20"
15+
NODE_VERSION: '20'
1616

1717
jobs:
1818
detect-changes:
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/setup-node@v6
3232
with:
3333
node-version: ${{ env.NODE_VERSION }}
34-
cache: "npm"
34+
cache: 'npm'
3535

3636
- name: 📦 Install dependencies
3737
run: npm ci
@@ -78,7 +78,7 @@ jobs:
7878
uses: actions/setup-node@v6
7979
with:
8080
node-version: ${{ env.NODE_VERSION }}
81-
cache: "npm"
81+
cache: 'npm'
8282

8383
- name: 📦 Install dependencies
8484
run: npm ci
@@ -110,8 +110,8 @@ jobs:
110110
uses: actions/setup-node@v6
111111
with:
112112
node-version: ${{ env.NODE_VERSION }}
113-
cache: "npm"
114-
registry-url: "https://registry.npmjs.org"
113+
cache: 'npm'
114+
registry-url: 'https://registry.npmjs.org'
115115

116116
- name: 📦 Install dependencies
117117
run: npm ci

eslint.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ export default [
2121
rules: {
2222
'@typescript-eslint/no-explicit-any': 'error',
2323
'@typescript-eslint/explicit-function-return-type': 'warn',
24-
'@typescript-eslint/no-unused-vars': [
25-
'error',
26-
{ argsIgnorePattern: '^_' },
27-
],
24+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
2825
'@typescript-eslint/naming-convention': [
2926
'error',
3027
{

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"test:coverage": "jest --coverage",
2020
"verify": "npm run type-check && npm run lint && npm run build && npm run test",
2121
"clean": "rm -rf dist coverage",
22-
"prepublishOnly": "npm run verify"
22+
"prepublishOnly": "npm run verify",
23+
"format:check": "prettier --check .",
24+
"format": "prettier --write ."
2325
},
2426
"keywords": [
2527
"cli",
@@ -62,6 +64,7 @@
6264
"@typescript-eslint/parser": "^8.46.3",
6365
"eslint": "^9.39.1",
6466
"jest": "^30.2.0",
67+
"prettier": "^3.8.1",
6568
"ts-jest": "^29.4.5",
6669
"tsx": "^4.20.6",
6770
"typescript": "^5.9.3"

src/cli.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ describe('CLI Commands', () => {
7474
encoding: 'utf-8',
7575
});
7676
// Either shows no agents found or lists available agents (including global)
77-
expect(
78-
output.includes('No agents found') || output.includes('Available Agents')
79-
).toBe(true);
77+
expect(output.includes('No agents found') || output.includes('Available Agents')).toBe(true);
8078
});
8179
});

src/cli.ts

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ import { checkForUpdates } from './utils/version.js';
1919

2020
const displayBanner = (): void => {
2121
console.log();
22-
console.log(
23-
chalk.cyan.bold(' ╔═══════════════════════════════════════════╗')
24-
);
22+
console.log(chalk.cyan.bold(' ╔═══════════════════════════════════════════╗'));
2523
console.log(
2624
chalk.cyan.bold(' ║') +
2725
chalk.white.bold(' 🤖 AgentKit CLI ') +
2826
chalk.cyan.bold('║')
2927
);
30-
console.log(
31-
chalk.cyan.bold(' ╚═══════════════════════════════════════════╝')
32-
);
28+
console.log(chalk.cyan.bold(' ╚═══════════════════════════════════════════╝'));
3329
console.log();
3430
};
3531

@@ -43,15 +39,9 @@ const displayVersionInfo = async (): Promise<void> => {
4339
const user = await getMe();
4440
const displayName = user.name || user.email;
4541
const aliasDisplay = user.verifiedAlias
46-
? chalk.gray(' (@') +
47-
chalk.green.bold(user.verifiedAlias) +
48-
chalk.gray(')')
42+
? chalk.gray(' (@') + chalk.green.bold(user.verifiedAlias) + chalk.gray(')')
4943
: '';
50-
console.log(
51-
chalk.gray(' Logged in as: ') +
52-
chalk.green.bold(displayName) +
53-
aliasDisplay
54-
);
44+
console.log(chalk.gray(' Logged in as: ') + chalk.green.bold(displayName) + aliasDisplay);
5545
} else {
5646
console.log(
5747
chalk.gray(' Status: ') +
@@ -105,9 +95,7 @@ const displayVersionInfo = async (): Promise<void> => {
10595

10696
const displayCustomHelp = (): void => {
10797
console.log(
108-
chalk.white.bold(' Usage: ') +
109-
chalk.cyan('agent') +
110-
chalk.gray(' [command] [options]')
98+
chalk.white.bold(' Usage: ') + chalk.cyan('agent') + chalk.gray(' [command] [options]')
11199
);
112100
console.log();
113101
console.log(chalk.white.bold(' Commands:'));
@@ -170,24 +158,16 @@ const displayCustomHelp = (): void => {
170158
console.log();
171159
console.log(chalk.white.bold(' Options:'));
172160
console.log();
161+
console.log(` ${chalk.cyan.bold('-v, --version')} ${chalk.white('Display version number')}`);
173162
console.log(
174-
` ${chalk.cyan.bold('-v, --version')} ${chalk.white(
175-
'Display version number'
176-
)}`
177-
);
178-
console.log(
179-
` ${chalk.cyan.bold('-h, --help')} ${chalk.white(
180-
'Display this help message'
181-
)}`
163+
` ${chalk.cyan.bold('-h, --help')} ${chalk.white('Display this help message')}`
182164
);
183165
console.log();
184166
console.log(chalk.white.bold(' Examples:'));
185167
console.log();
186168
console.log(chalk.white(' $ ') + chalk.cyan('agent init my-agent'));
187169
console.log(
188-
chalk.white(' $ ') +
189-
chalk.cyan('agent run my-agent') +
190-
chalk.white(' "Hello, how are you?"')
170+
chalk.white(' $ ') + chalk.cyan('agent run my-agent') + chalk.white(' "Hello, how are you?"')
191171
);
192172
console.log(chalk.white(' $ ') + chalk.cyan('agent list'));
193173
console.log();
@@ -232,11 +212,7 @@ program
232212
.command('publish')
233213
.description('Publish agent to registry')
234214
.argument('[path]', 'Path to agent file')
235-
.option(
236-
'-v, --visibility <visibility>',
237-
'Visibility (public or private)',
238-
'public'
239-
)
215+
.option('-v, --visibility <visibility>', 'Visibility (public or private)', 'public')
240216
.option('--version <version>', 'Override version')
241217
.option('-t, --tag <tag...>', 'Add tags')
242218
.option('-c, --changelog <message>', 'Changelog message')
@@ -262,25 +238,13 @@ program
262238
.action(searchCommand);
263239

264240
// Auth commands
265-
program
266-
.command('login')
267-
.description('Login to the Agentage registry')
268-
.action(loginCommand);
241+
program.command('login').description('Login to the Agentage registry').action(loginCommand);
269242

270-
program
271-
.command('logout')
272-
.description('Logout from the Agentage registry')
273-
.action(logoutCommand);
243+
program.command('logout').description('Logout from the Agentage registry').action(logoutCommand);
274244

275-
program
276-
.command('whoami')
277-
.description('Display the currently logged in user')
278-
.action(whoamiCommand);
245+
program.command('whoami').description('Display the currently logged in user').action(whoamiCommand);
279246

280-
program
281-
.command('update')
282-
.description('Update the CLI to the latest version')
283-
.action(updateCommand);
247+
program.command('update').description('Update the CLI to the latest version').action(updateCommand);
284248

285249
// Handle help flag explicitly
286250
if (process.argv.includes('-h') || process.argv.includes('--help')) {

src/commands/init.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ describe('initCommand', () => {
7171
const consoleError = jest.spyOn(console, 'error').mockImplementation();
7272

7373
const originalWriteFile = require('fs/promises').writeFile;
74-
jest
75-
.spyOn(require('fs/promises'), 'writeFile')
76-
.mockRejectedValue(new Error('Write failed'));
74+
jest.spyOn(require('fs/promises'), 'writeFile').mockRejectedValue(new Error('Write failed'));
7775

7876
await expect(initCommand('test')).rejects.toThrow('process.exit called');
79-
expect(consoleError).toHaveBeenCalledWith(
80-
expect.stringContaining('❌ Failed: Write failed')
81-
);
77+
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('❌ Failed: Write failed'));
8278
expect(mockExit).toHaveBeenCalledWith(1);
8379

8480
// Restore

0 commit comments

Comments
 (0)