Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
**Command Structure**:

```typescript
import { Command } from "commander";
import { Command } from 'commander';

export const myCommand = new Command("name")
.description("Command description")
.option("-o, --option <value>", "Option description")
export const myCommand = new Command('name')
.description('Command description')
.option('-o, --option <value>', 'Option description')
.action(async (options) => {
// Implementation
});
Expand Down
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ updates:
all-actions:
patterns:
- '*'

5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache: 'npm'

- name: 📦 Install dependencies
run: npm ci
Expand All @@ -34,6 +34,9 @@ jobs:
- name: 🔍 Lint
run: npm run lint

- name: 💅 Format check
run: npm run format:check

- name: 🏗️ Build
run: npm run build

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
push:
branches: [master, main]
paths:
- "package.json"
- 'package.json'
workflow_dispatch:

permissions:
contents: write
id-token: write

env:
NODE_VERSION: "20"
NODE_VERSION: '20'

jobs:
detect-changes:
Expand All @@ -31,7 +31,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache: 'npm'

- name: 📦 Install dependencies
run: npm ci
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache: 'npm'

- name: 📦 Install dependencies
run: npm ci
Expand Down Expand Up @@ -110,8 +110,8 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: "https://registry.npmjs.org"
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: 📦 Install dependencies
run: npm ci
Expand Down
5 changes: 1 addition & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export default [
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/naming-convention': [
'error',
{
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"test:coverage": "jest --coverage",
"verify": "npm run type-check && npm run lint && npm run build && npm run test",
"clean": "rm -rf dist coverage",
"prepublishOnly": "npm run verify"
"prepublishOnly": "npm run verify",
"format:check": "prettier --check .",
"format": "prettier --write ."
},
"keywords": [
"cli",
Expand Down Expand Up @@ -62,6 +64,7 @@
"@typescript-eslint/parser": "^8.46.3",
"eslint": "^9.39.1",
"jest": "^30.2.0",
"prettier": "^3.8.1",
"ts-jest": "^29.4.5",
"tsx": "^4.20.6",
"typescript": "^5.9.3"
Expand Down
4 changes: 1 addition & 3 deletions src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ describe('CLI Commands', () => {
encoding: 'utf-8',
});
// Either shows no agents found or lists available agents (including global)
expect(
output.includes('No agents found') || output.includes('Available Agents')
).toBe(true);
expect(output.includes('No agents found') || output.includes('Available Agents')).toBe(true);
});
});
62 changes: 13 additions & 49 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ import { checkForUpdates } from './utils/version.js';

const displayBanner = (): void => {
console.log();
console.log(
chalk.cyan.bold(' ╔═══════════════════════════════════════════╗')
);
console.log(chalk.cyan.bold(' ╔═══════════════════════════════════════════╗'));
console.log(
chalk.cyan.bold(' ║') +
chalk.white.bold(' 🤖 AgentKit CLI ') +
chalk.cyan.bold('║')
);
console.log(
chalk.cyan.bold(' ╚═══════════════════════════════════════════╝')
);
console.log(chalk.cyan.bold(' ╚═══════════════════════════════════════════╝'));
console.log();
};

Expand All @@ -43,15 +39,9 @@ const displayVersionInfo = async (): Promise<void> => {
const user = await getMe();
const displayName = user.name || user.email;
const aliasDisplay = user.verifiedAlias
? chalk.gray(' (@') +
chalk.green.bold(user.verifiedAlias) +
chalk.gray(')')
? chalk.gray(' (@') + chalk.green.bold(user.verifiedAlias) + chalk.gray(')')
: '';
console.log(
chalk.gray(' Logged in as: ') +
chalk.green.bold(displayName) +
aliasDisplay
);
console.log(chalk.gray(' Logged in as: ') + chalk.green.bold(displayName) + aliasDisplay);
} else {
console.log(
chalk.gray(' Status: ') +
Expand Down Expand Up @@ -105,9 +95,7 @@ const displayVersionInfo = async (): Promise<void> => {

const displayCustomHelp = (): void => {
console.log(
chalk.white.bold(' Usage: ') +
chalk.cyan('agent') +
chalk.gray(' [command] [options]')
chalk.white.bold(' Usage: ') + chalk.cyan('agent') + chalk.gray(' [command] [options]')
);
console.log();
console.log(chalk.white.bold(' Commands:'));
Expand Down Expand Up @@ -170,24 +158,16 @@ const displayCustomHelp = (): void => {
console.log();
console.log(chalk.white.bold(' Options:'));
console.log();
console.log(` ${chalk.cyan.bold('-v, --version')} ${chalk.white('Display version number')}`);
console.log(
` ${chalk.cyan.bold('-v, --version')} ${chalk.white(
'Display version number'
)}`
);
console.log(
` ${chalk.cyan.bold('-h, --help')} ${chalk.white(
'Display this help message'
)}`
` ${chalk.cyan.bold('-h, --help')} ${chalk.white('Display this help message')}`
);
console.log();
console.log(chalk.white.bold(' Examples:'));
console.log();
console.log(chalk.white(' $ ') + chalk.cyan('agent init my-agent'));
console.log(
chalk.white(' $ ') +
chalk.cyan('agent run my-agent') +
chalk.white(' "Hello, how are you?"')
chalk.white(' $ ') + chalk.cyan('agent run my-agent') + chalk.white(' "Hello, how are you?"')
);
console.log(chalk.white(' $ ') + chalk.cyan('agent list'));
console.log();
Expand Down Expand Up @@ -232,11 +212,7 @@ program
.command('publish')
.description('Publish agent to registry')
.argument('[path]', 'Path to agent file')
.option(
'-v, --visibility <visibility>',
'Visibility (public or private)',
'public'
)
.option('-v, --visibility <visibility>', 'Visibility (public or private)', 'public')
.option('--version <version>', 'Override version')
.option('-t, --tag <tag...>', 'Add tags')
.option('-c, --changelog <message>', 'Changelog message')
Expand All @@ -262,25 +238,13 @@ program
.action(searchCommand);

// Auth commands
program
.command('login')
.description('Login to the Agentage registry')
.action(loginCommand);
program.command('login').description('Login to the Agentage registry').action(loginCommand);

program
.command('logout')
.description('Logout from the Agentage registry')
.action(logoutCommand);
program.command('logout').description('Logout from the Agentage registry').action(logoutCommand);

program
.command('whoami')
.description('Display the currently logged in user')
.action(whoamiCommand);
program.command('whoami').description('Display the currently logged in user').action(whoamiCommand);

program
.command('update')
.description('Update the CLI to the latest version')
.action(updateCommand);
program.command('update').description('Update the CLI to the latest version').action(updateCommand);

// Handle help flag explicitly
if (process.argv.includes('-h') || process.argv.includes('--help')) {
Expand Down
8 changes: 2 additions & 6 deletions src/commands/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ describe('initCommand', () => {
const consoleError = jest.spyOn(console, 'error').mockImplementation();

const originalWriteFile = require('fs/promises').writeFile;
jest
.spyOn(require('fs/promises'), 'writeFile')
.mockRejectedValue(new Error('Write failed'));
jest.spyOn(require('fs/promises'), 'writeFile').mockRejectedValue(new Error('Write failed'));

await expect(initCommand('test')).rejects.toThrow('process.exit called');
expect(consoleError).toHaveBeenCalledWith(
expect.stringContaining('❌ Failed: Write failed')
);
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('❌ Failed: Write failed'));
expect(mockExit).toHaveBeenCalledWith(1);

// Restore
Expand Down
11 changes: 2 additions & 9 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export interface InitOptions {
*/
const getGlobalDir = (): string => join(homedir(), '.agentage');

export const initCommand = async (
name?: string,
options?: InitOptions
): Promise<void> => {
export const initCommand = async (name?: string, options?: InitOptions): Promise<void> => {
const agentName = name || 'my-agent';
const isGlobal = options?.global ?? false;

Expand All @@ -55,11 +52,7 @@ export const initCommand = async (
console.log(`✅ Created ${agentFilePath}`);

// Create agent.json config file
await writeFile(
configFilePath,
JSON.stringify(agentConfig, null, 2),
'utf-8'
);
await writeFile(configFilePath, JSON.stringify(agentConfig, null, 2), 'utf-8');
console.log(`✅ Created ${configFilePath}`);
} catch (error) {
console.error(`❌ Failed: ${(error as Error).message}`);
Expand Down
Loading
Loading