Skip to content

Commit 654ac6f

Browse files
committed
CLI setup
1 parent d0c4980 commit 654ac6f

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

core/cli/agentCommands.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Command } from 'commander';
2+
import chalk from 'chalk';
3+
import Table from 'cli-table3';
4+
5+
interface AgentConfig {
6+
name: string;
7+
model?: string;
8+
description?: string;
9+
systemPrompt?: string;
10+
}
11+
12+
interface ModifyAgentConfig {
13+
agentId: string;
14+
name?: string;
15+
model?: string;
16+
description?: string;
17+
systemPrompt?: string;
18+
}
19+
20+
export const createAgent = async (config: AgentConfig): Promise<void> => {
21+
try {
22+
// Add agent creation logic here
23+
console.log(chalk.green('✓'), `Created agent '${config.name}' with model ${config.model || 'gpt-3.5-turbo'}`);
24+
} catch (error) {
25+
console.error(chalk.red('✗'), `Failed to create agent: ${error.message}`);
26+
process.exit(1);
27+
}
28+
};
29+
30+
export const modifyAgent = async (config: ModifyAgentConfig): Promise<void> => {
31+
try {
32+
// Add agent modification logic here
33+
console.log(chalk.green('✓'), `Modified agent '${config.agentId}'`);
34+
} catch (error) {
35+
console.error(chalk.red('✗'), `Failed to modify agent: ${error.message}`);
36+
process.exit(1);
37+
}
38+
};
39+
40+
export const listAgents = async (): Promise<void> => {
41+
try {
42+
const table = new Table({
43+
head: ['ID', 'Name', 'Model', 'Description'].map(header => chalk.magenta(header)),
44+
});
45+
46+
// Add logic to fetch and display agents
47+
// table.push([...]);
48+
49+
console.log(table.toString());
50+
} catch (error) {
51+
console.error(chalk.red('✗'), `Failed to list agents: ${error.message}`);
52+
process.exit(1);
53+
}
54+
};
55+
56+
export const setupEnvironment = async (envName: string, configFile?: string): Promise<void> => {
57+
try {
58+
// Add environment setup logic here
59+
console.log(chalk.green('✓'), `Environment '${envName}' setup complete`);
60+
} catch (error) {
61+
console.error(chalk.red('✗'), `Failed to setup environment: ${error.message}`);
62+
process.exit(1);
63+
}
64+
};

core/cli/main.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env node
2+
import { Command } from 'commander';
3+
import { createAgent, modifyAgent, listAgents, setupEnvironment } from './agentCommands';
4+
5+
const program = new Command();
6+
7+
program
8+
.name('ai-cli')
9+
.description('CLI tool for managing AI agents')
10+
.version('1.0.0');
11+
12+
program
13+
.command('agent')
14+
.description('Agent management commands');
15+
16+
program
17+
.command('agent create')
18+
.description('Create a new agent with specified configuration')
19+
.requiredOption('-n, --name <name>', 'name of the agent')
20+
.option('-m, --model <model>', 'model to use', 'gpt-3.5-turbo')
21+
.option('-d, --description <description>', 'agent description')
22+
.option('-s, --system-prompt <prompt>', 'system prompt for the agent')
23+
.action(async (options) => {
24+
await createAgent(options);
25+
});
26+
27+
program
28+
.command('agent modify')
29+
.description('Modify an existing agent\'s configuration')
30+
.requiredOption('-i, --agent-id <id>', 'ID of the agent to modify')
31+
.option('-n, --name <name>', 'new name for the agent')
32+
.option('-m, --model <model>', 'new model to use')
33+
.option('-d, --description <description>', 'new agent description')
34+
.option('-s, --system-prompt <prompt>', 'new system prompt')
35+
.action(async (options) => {
36+
await modifyAgent(options);
37+
});
38+
39+
program
40+
.command('agent list')
41+
.description('List all available agents')
42+
.action(async () => {
43+
await listAgents();
44+
});
45+
46+
program
47+
.command('agent setup-env')
48+
.description('Setup the environment for agents')
49+
.argument('<env-name>', 'name of the environment')
50+
.option('-c, --config-file <path>', 'path to config file')
51+
.action(async (envName, options) => {
52+
await setupEnvironment(envName, options.configFile);
53+
});
54+
55+
program.parse();

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"@google-cloud/scheduler": "^3.0.0",
2525
"@google-cloud/storage": "^6.0.0",
2626
"@google-cloud/run": "^1.0.0",
27-
"@google-cloud/compute": "^3.0.0"
27+
"@google-cloud/compute": "^3.0.0",
28+
"commander": "^11.0.0",
29+
"chalk": "^5.3.0",
30+
"cli-table3": "^0.6.3"
2831
},
2932
"devDependencies": {
3033
"@types/node": "^20.0.0",

0 commit comments

Comments
 (0)