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
11 changes: 9 additions & 2 deletions src/agents/commands/push-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface AgentsConfig {
agents: AgentDefinition[];
}

export async function pushAgents(dryRun: boolean = false): Promise<void> {
export async function pushAgents(dryRun: boolean = false, agentId?: string): Promise<void> {
// Load agents configuration
const agentsConfigPath = path.resolve(AGENTS_CONFIG_FILE);
if (!(await fs.pathExists(agentsConfigPath))) {
Expand All @@ -24,7 +24,14 @@ export async function pushAgents(dryRun: boolean = false): Promise<void> {

const agentsConfig = await readConfig<AgentsConfig>(agentsConfigPath);

const agentsToProcess = agentsConfig.agents;
let agentsToProcess = agentsConfig.agents;
// Filter to specific agent if agentId is provided
if (agentId) {
agentsToProcess = agentsToProcess.filter(agent => agent.id === agentId);
if (agentsToProcess.length === 0) {
throw new Error(`Agent with ID ${agentId} not found in agents.json`);
}
}

console.log(`Pushing ${agentsToProcess.length} agent(s) to ElevenLabs...`);

Expand Down
13 changes: 11 additions & 2 deletions src/agents/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ interface AgentsConfig {
}

interface PushOptions {
agent?: string;
dryRun: boolean;
}

export function createPushCommand(): Command {
return new Command('push')
.description('Push agents to ElevenLabs API when configs change')
.option('--agent <agent_id>', 'Specific agent ID to push')
.option('--dry-run', 'Show what would be done without making changes', false)
.option('--no-ui', 'Disable interactive UI')
.action(async (options: PushOptions & { ui: boolean }) => {
Expand All @@ -37,7 +39,14 @@ export function createPushCommand(): Command {

const agentsConfig = await readConfig<AgentsConfig>(agentsConfigPath);

const agentsToProcess = agentsConfig.agents;
let agentsToProcess = agentsConfig.agents;
// Filter to specific agent if --agent is provided
if (options.agent) {
agentsToProcess = agentsToProcess.filter(agent => agent.id === options.agent);
if (agentsToProcess.length === 0) {
throw new Error(`Agent with ID ${options.agent} not found in agents.json`);
}
}

// Prepare agents for UI
const pushAgentsData = await Promise.all(
Expand All @@ -58,7 +67,7 @@ export function createPushCommand(): Command {
await waitUntilExit();
} else {
// Use existing non-UI push
await pushAgents(options.dryRun);
await pushAgents(options.dryRun, options.agent);
}
} catch (error) {
console.error(`Error during push: ${error}`);
Expand Down
2 changes: 2 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createAgentsCommand } from './agents/commands/index.js';
import { createToolsCommand } from './tools/commands/index.js';
import { createTestsCommand } from './tests/commands/index.js';
import { createComponentsCommand } from './components/commands/index.js';
import { createCompletionCommand } from './completion/commands/index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down Expand Up @@ -47,6 +48,7 @@ program.addCommand(createAgentsCommand());
program.addCommand(createToolsCommand());
program.addCommand(createTestsCommand());
program.addCommand(createComponentsCommand());
program.addCommand(createCompletionCommand());

// Show help if no arguments provided or if only help flag is provided
const args = process.argv.slice(2);
Expand Down
23 changes: 23 additions & 0 deletions src/completion/commands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Command } from 'commander';
import { bashCompletion, zshCompletion } from '../scripts.js';

export function createCompletionCommand(): Command {
const cmd = new Command('completion')
.description('Generate shell completion script')
.argument('<shell>', 'Shell type: bash or zsh')
.action((shell: string) => {
const shellLower = shell.toLowerCase();

if (shellLower === 'bash') {
console.log(bashCompletion);
} else if (shellLower === 'zsh') {
console.log(zshCompletion);
} else {
console.error(`Unsupported shell: ${shell}`);
console.error('Supported shells: bash, zsh');
process.exit(1);
}
});

return cmd;
}
Loading
Loading