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:
- Set up your development environment
- Understand the codebase structure
- Make your changes (add packages, enhance features, fix bugs)
- Test your changes
- 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-projectUnderstanding 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:
- Stores all user selections from the prompt phase
- Gets passed to builders during the execution phase
- 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:
- Creating a package directory in
src/packages/<your-package> - Implementing prompt.ts to collect user configuration
- Implementing builder.ts to generate files
- Adding template files in the
files/directory - 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-projectWhen testing packages, make sure to:
- Test all prompt paths and options
- Verify that generated files are correct
- Check integration with other packages
- Test with different package managers (npm, yarn, pnpm)
References
- Project Structure - Detailed overview of the codebase architecture
- Handlebars - Documentation for Handlebars templates
- Package Architecture - Guide to creating new packages
- Create First Package - Step-by-step guide to creating your first package