Skip to content

Development Guide

This guide provides an overview of the development process for extending and enhancing AI Scaffolding.

Whether you're adding new packages, improving existing ones, or contributing to the core codebase, this document will help you get started.

Development Workflow

The development workflow for AI Scaffolding follows these general steps:

  1. Set up your development environment
  2. Understand the codebase structure
  3. Make your changes (add packages, enhance features, fix bugs)
  4. Test your changes
  5. Submit a pull request

Setting Up Your Environment

To get started with AI Scaffolding development:

# Clone the repository
git clone https://github.com/appliedblockchain/ai-scaffolding.git
cd ai-scaffolding
 
# Install dependencies
pnpm install
 
# Build the project
pnpm build
 
# Run the CLI in development mode
pnpm dev tmp/test-project

Understanding Key Concepts

Before diving into development, it's important to understand some key concepts:

Project Structure

AI Scaffolding follows a modular architecture with clear separation of concerns:

  • CLI Layer: Handles command-line arguments and routes to appropriate actions
  • Prompt Layer: Collects user input through interactive prompts
  • Builder Layer: Generates project files based on collected configuration
  • Package System: Modular components that can be added to projects

See the Project Structure document for a detailed breakdown.

Configuration Model

The configuration model is the heart of AI Scaffolding. It's a hierarchical object that:

  1. Stores all user selections from the prompt phase
  2. Gets passed to builders during the execution phase
  3. Is available to templates as Handlebars variables
const config = {
  projectName: "my-project",
  packageManager: "pnpm",
  packages: {
    hardhat: { /* Hardhat-specific config */ },
    vite: { /* Vite-specific config */ }
  },
  global: {
    // Global flags and settings
  }
};

Templating System

AI Scaffolding uses Handlebars for templating. You can create dynamic template files with conditional sections and loops:

// Example of Handlebars syntax in a template file
/*#{{#if global.shouldAddHardhat}}*/
import { ethers } from 'ethers';
/*#{{/if}}*/

Adding New Packages

One of the most common development tasks is adding new packages to AI Scaffolding. This involves:

  1. Creating a package directory in src/packages/<your-package>
  2. Implementing prompt.ts to collect user configuration
  3. Implementing builder.ts to generate files
  4. Adding template files in the files/ directory
  5. Registering your package in src/packages/index.ts

For detailed instructions on package architecture and implementation, see the Package Architecture guide.

See the Create First Package guide for a step-by-step example.

Testing Your Changes

To test your changes during development:

# Build the project
pnpm build
 
# Run the CLI with your changes
pnpm dev tmp/test-project

When testing packages, make sure to:

  1. Test all prompt paths and options
  2. Verify that generated files are correct
  3. Check integration with other packages
  4. Test with different package managers (npm, yarn, pnpm)

References