@zweer/dev 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export interface AgentConfig {
3
+ name: string;
4
+ projectName: string;
5
+ projectPath: string;
6
+ techStack: string;
7
+ projectStructure: string;
8
+ template: string;
9
+ }
10
+ export declare function createAgent(config: AgentConfig): Promise<{
11
+ agentPath: string;
12
+ }>;
13
+ export declare function getDefaultConfig(cwd: string, name?: string, template?: string): AgentConfig;
14
+ export declare const createCommand: Command<[string | undefined], {
15
+ template: string;
16
+ yes?: true | undefined;
17
+ }>;
@@ -0,0 +1,89 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { basename, join } from 'node:path';
3
+ import { Command } from '@commander-js/extra-typings';
4
+ import chalk from 'chalk';
5
+ import inquirer from 'inquirer';
6
+ import { paths } from '../../../utils/paths.js';
7
+ export async function createAgent(config) {
8
+ // Read template
9
+ const templatePath = join(paths.templates, `${config.template}.md`);
10
+ let template = await readFile(templatePath, 'utf-8');
11
+ // Replace placeholders
12
+ template = template
13
+ .replace(/\{\{PROJECT_NAME\}\}/g, config.projectName)
14
+ .replace(/\{\{PROJECT_PATH\}\}/g, config.projectPath)
15
+ .replace(/\{\{TECH_STACK\}\}/g, config.techStack)
16
+ .replace(/\{\{PROJECT_STRUCTURE\}\}/g, config.projectStructure);
17
+ // Create .cao/agents directory
18
+ const caoDir = join(config.projectPath, '.cao', 'agents');
19
+ await mkdir(caoDir, { recursive: true });
20
+ // Write agent file
21
+ const agentPath = join(caoDir, `${config.name}.md`);
22
+ await writeFile(agentPath, template);
23
+ return { agentPath };
24
+ }
25
+ export function getDefaultConfig(cwd, name, template) {
26
+ const projectName = basename(cwd);
27
+ return {
28
+ name: name || `${projectName}_orchestrator`,
29
+ projectName,
30
+ projectPath: cwd,
31
+ techStack: 'Next.js, TypeScript, PostgreSQL',
32
+ projectStructure: 'app/, components/, lib/',
33
+ template: template || 'orchestrator',
34
+ };
35
+ }
36
+ export const createCommand = new Command()
37
+ .name('create')
38
+ .description('Create a new agent in current project')
39
+ .argument('[name]', 'Agent name')
40
+ .option('-t, --template <template>', 'Template to use (orchestrator, specialist)', 'orchestrator')
41
+ .option('-y, --yes', 'Skip prompts and use defaults')
42
+ .action(async (name, options) => {
43
+ const cwd = process.cwd();
44
+ let config = getDefaultConfig(cwd, name, options.template);
45
+ if (!options.yes) {
46
+ const answers = await inquirer.prompt([
47
+ {
48
+ type: 'input',
49
+ name: 'name',
50
+ message: 'Agent name:',
51
+ default: config.name,
52
+ },
53
+ {
54
+ type: 'input',
55
+ name: 'projectName',
56
+ message: 'Project name:',
57
+ default: config.projectName,
58
+ },
59
+ {
60
+ type: 'input',
61
+ name: 'techStack',
62
+ message: 'Tech stack:',
63
+ default: config.techStack,
64
+ },
65
+ {
66
+ type: 'input',
67
+ name: 'projectStructure',
68
+ message: 'Main folders:',
69
+ default: config.projectStructure,
70
+ },
71
+ ]);
72
+ config = { ...config, ...answers };
73
+ }
74
+ console.log(chalk.cyan(`\nšŸŽÆ Creating agent: ${config.name}\n`));
75
+ try {
76
+ const { agentPath } = await createAgent(config);
77
+ console.log(chalk.green(`āœ” Agent created: ${agentPath}\n`));
78
+ console.log(chalk.dim('Next steps:'));
79
+ console.log(chalk.dim(' 1. Edit the agent to add project-specific details'));
80
+ console.log(chalk.dim(' 2. Run: dev cao sync'));
81
+ console.log(chalk.dim(` 3. Run: dev cao launch ${config.name}`));
82
+ console.log();
83
+ }
84
+ catch (error) {
85
+ console.error(chalk.red('āœ– Failed to create agent'));
86
+ console.error(error);
87
+ process.exit(1);
88
+ }
89
+ });
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const agentCommand: Command<[], {}>;
@@ -0,0 +1,8 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ import { createCommand } from './create.js';
3
+ import { listCommand } from './list.js';
4
+ import { removeCommand } from './remove.js';
5
+ export const agentCommand = new Command().name('agent').description('Manage local project agents');
6
+ agentCommand.addCommand(createCommand);
7
+ agentCommand.addCommand(listCommand);
8
+ agentCommand.addCommand(removeCommand);
@@ -0,0 +1,3 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare function getLocalAgents(): Promise<string[]>;
3
+ export declare const listCommand: Command<[], {}>;
@@ -0,0 +1,29 @@
1
+ import { readdir } from 'node:fs/promises';
2
+ import { Command } from '@commander-js/extra-typings';
3
+ import chalk from 'chalk';
4
+ export async function getLocalAgents() {
5
+ const caoAgentsDir = '.cao/agents';
6
+ try {
7
+ const files = await readdir(caoAgentsDir);
8
+ return files.filter((f) => f.endsWith('.md')).map((f) => f.replace('.md', ''));
9
+ }
10
+ catch {
11
+ return [];
12
+ }
13
+ }
14
+ export const listCommand = new Command()
15
+ .name('list')
16
+ .description('List all local agents in .cao/agents/')
17
+ .action(async () => {
18
+ const agents = await getLocalAgents();
19
+ if (agents.length === 0) {
20
+ console.log(chalk.yellow('No local agents found in .cao/agents/'));
21
+ console.log(chalk.dim('\nCreate one with: dev cao agent create <name>'));
22
+ return;
23
+ }
24
+ console.log(chalk.bold(`\nLocal Agents (${agents.length}):\n`));
25
+ for (const agent of agents) {
26
+ console.log(chalk.cyan(` • ${agent}`));
27
+ }
28
+ console.log();
29
+ });
@@ -0,0 +1,5 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare function removeAgent(name: string): Promise<void>;
3
+ export declare const removeCommand: Command<[string], {
4
+ yes?: true | undefined;
5
+ }>;
@@ -0,0 +1,39 @@
1
+ import { unlink } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { Command } from '@commander-js/extra-typings';
4
+ import chalk from 'chalk';
5
+ import inquirer from 'inquirer';
6
+ export async function removeAgent(name) {
7
+ const agentPath = join('.cao/agents', `${name}.md`);
8
+ await unlink(agentPath);
9
+ }
10
+ export const removeCommand = new Command()
11
+ .name('remove')
12
+ .description('Remove a local agent')
13
+ .argument('<name>', 'Agent name to remove')
14
+ .option('-y, --yes', 'Skip confirmation')
15
+ .action(async (name, options) => {
16
+ if (!options.yes) {
17
+ const { confirm } = await inquirer.prompt([
18
+ {
19
+ type: 'confirm',
20
+ name: 'confirm',
21
+ message: `Are you sure you want to remove ${name}?`,
22
+ default: false,
23
+ },
24
+ ]);
25
+ if (!confirm) {
26
+ console.log(chalk.yellow('Cancelled'));
27
+ return;
28
+ }
29
+ }
30
+ try {
31
+ await removeAgent(name);
32
+ console.log(chalk.green(`āœ” Agent ${name} removed`));
33
+ }
34
+ catch (error) {
35
+ console.error(chalk.red(`āœ– Failed to remove agent ${name}`));
36
+ console.error(error);
37
+ process.exit(1);
38
+ }
39
+ });
@@ -1,14 +1,18 @@
1
1
  import { Command } from '@commander-js/extra-typings';
2
+ import { agentCommand } from './agent/index.js';
2
3
  import { initCommand } from './init.js';
3
4
  import { installCommand } from './install.js';
4
5
  import { launchCommand } from './launch.js';
5
6
  import { listCommand } from './list.js';
6
7
  import { serverCommand } from './server.js';
8
+ import { syncCommand } from './sync.js';
7
9
  export const caoCommand = new Command()
8
10
  .name('cao')
9
11
  .description('Manage CAO (CLI Agent Orchestrator) and agents')
10
12
  .addCommand(initCommand)
13
+ .addCommand(agentCommand)
11
14
  .addCommand(installCommand)
15
+ .addCommand(syncCommand)
12
16
  .addCommand(serverCommand)
13
17
  .addCommand(launchCommand)
14
18
  .addCommand(listCommand);
@@ -0,0 +1,6 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare function executeSync(): Promise<{
3
+ installed: number;
4
+ failed: number;
5
+ }>;
6
+ export declare const syncCommand: Command<[], {}>;
@@ -0,0 +1,52 @@
1
+ import { readdir } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { Command } from '@commander-js/extra-typings';
4
+ import chalk from 'chalk';
5
+ import { installAgent } from '../../utils/cao.js';
6
+ export async function executeSync() {
7
+ const caoAgentsDir = '.cao/agents';
8
+ let installed = 0;
9
+ let failed = 0;
10
+ try {
11
+ const files = await readdir(caoAgentsDir);
12
+ const agentFiles = files.filter((f) => f.endsWith('.md'));
13
+ for (const file of agentFiles) {
14
+ const agentPath = join(caoAgentsDir, file);
15
+ try {
16
+ await installAgent(agentPath);
17
+ console.log(chalk.green(` āœ” ${file}`));
18
+ installed++;
19
+ }
20
+ catch (error) {
21
+ console.log(chalk.red(` āœ– ${file}`));
22
+ console.error(chalk.dim(` ${error}`));
23
+ failed++;
24
+ }
25
+ }
26
+ }
27
+ catch (error) {
28
+ throw new Error(`Failed to read .cao/agents directory: ${error}`);
29
+ }
30
+ return { installed, failed };
31
+ }
32
+ export const syncCommand = new Command()
33
+ .name('sync')
34
+ .description('Sync all local agents from .cao/agents/')
35
+ .action(async () => {
36
+ console.log(chalk.cyan('Syncing local agents...\n'));
37
+ try {
38
+ const { installed, failed } = await executeSync();
39
+ console.log();
40
+ if (failed === 0) {
41
+ console.log(chalk.green(`āœ” All ${installed} agents synced successfully`));
42
+ }
43
+ else {
44
+ console.log(chalk.yellow(`⚠ Synced ${installed} agents, ${failed} failed`));
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(chalk.red('āœ– Failed to sync agents'));
49
+ console.error(error);
50
+ process.exit(1);
51
+ }
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zweer/dev",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Shared configurations & AI agents for software projects",
5
5
  "keywords": [
6
6
  "ai",