Skip to content

CLI Scaffold: Create command for TypeScript agent projects #4

@larock22

Description

@larock22

Feature Request: CLI Scaffold Generator for TinyAgent Projects

Overview

Add a create command to the tinyagent CLI that generates TypeScript project scaffolds aligned with our current architecture and patterns.

Proposed Command

npx tinyagent create <project_name>
# or
ta create <project_name>

Generated Project Structure

my_project/
├── .gitignore
├── package.json
├── tsconfig.json
├── README.md
├── .env.example
└── src/
    ├── index.ts          # Entry point
    ├── agents/
    │   ├── main.agent.ts # Main agent configuration
    │   └── index.ts
    ├── tools/
    │   ├── example.tool.ts
    │   └── index.ts
    └── prompts/
        └── system.md     # System prompt (optional)

Key Features

  1. Aligned with Current Patterns:

    • Uses our unified Agent class with mode configuration
    • Programmatic configuration (no YAML initially)
    • TypeScript-first with proper types
    • Follows our tool interface patterns
  2. Generated Main Agent (src/agents/main.agent.ts):

import { Agent } from 'tinyagent-ts';
import { getDefaultTools } from 'tinyagent-ts/default-tools';
import { exampleTool } from '../tools';

export function createMainAgent() {
  const agent = new Agent({
    mode: 'react',
    model: {
      name: process.env.MODEL_NAME || 'gpt-4o-mini',
      provider: 'openrouter',
      apiKey: process.env.OPENROUTER_API_KEY\!
    },
    react: {
      maxSteps: 10,
      enableReflexion: true
    }
  });

  // Register default tools
  getDefaultTools().forEach(tool => agent.registerTool(tool));
  
  // Register custom tools
  agent.registerTool(exampleTool);

  return agent;
}
  1. Example Custom Tool (src/tools/example.tool.ts):
import { Tool } from 'tinyagent-ts';
import { z } from 'zod';

export const exampleTool: Tool = {
  name: 'example_tool',
  description: 'An example custom tool',
  schema: z.object({
    input: z.string().describe('The input to process')
  }),
  execute: async ({ input }) => {
    return `Processed: ${input}`;
  }
};
  1. Interactive Setup:

    • Ask for project type (simple chat, web scraper, data processor, custom)
    • Configure default tools based on type
    • Set up appropriate .env.example
  2. Templates for Common Patterns:

    • Web Scraper: Includes file & grep tools, example scraping logic
    • Data Processor: Python execution, file tools
    • Chat Agent: Simple mode, minimal tools
    • Multi-Agent: Example of composing multiple agents

Benefits

  • Quick start for new projects
  • Promotes best practices from our codebase
  • Maintains our philosophy of simplicity and explicit configuration
  • TypeScript-first approach
  • Easy to extend with more templates

Implementation Notes

  • Extend existing CLI in src/cli.ts
  • Use templates stored in src/templates/
  • Keep it simple - no complex configuration wizards
  • Focus on getting users to a working agent quickly

Future Enhancements

  • Add YAML/JSON configuration support (building on ConfigurableAgent work)
  • Support for multi-agent crews
  • More sophisticated templates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions