Skip to content

Conversation

@marcusrein
Copy link

Add amp init command with extensible template system

Overview

Introduces amp init, a new CLI command that bootstraps Amp projects from templates. Provides a minimal and streamlined onboarding experience with an architecture designed to eventually support multiple templates.

Initial template is specific to local development. If this shape of amp init is approved, other templates that spin up various permutations of Amp may be built, for example evm-firehose-mulichain, evm-rpc-multichain-multicontract, etc.

Usage

Interactive Mode (Recommended)

npx @edgeandnode/amp init

Prompts for template selection, dataset name, version, and project name with validation.

Non-Interactive Mode

# Custom configuration
npx @edgeandnode/amp init --dataset-name my_data --project-name "My Project"

# Quick start with defaults
npx @edgeandnode/amp init -y

Template: local-evm-rpc

A complete learning environment for developers new to Amp. Generates 11 files including:

What's Generated

.
├── amp.config.ts              # TypeScript dataset config
├── amp.toml                   # Amp daemon config
├── manifests/anvil_rpc.json   # Raw dataset definition
├── providers/anvil.toml       # Anvil RPC endpoint config
├── contracts/
│   ├── src/EventEmitter.sol   # Sample contract (emits 500 events)
│   └── script/EventEmitter.s.sol
└── README.md                  # 495-line comprehensive guide

What Developers Get

  • 500 sample events ready to query immediately after setup
  • Step-by-step README: 5 steps, ~2 minutes to working setup
  • 6 categories of query examples: filtering, aggregations, joins, decoded events, UDFs, performance patterns
  • Foundry setup with deployment scripts
  • Troubleshooting guide for common issues

Key Features

Interactive & non-interactive modes - Follow prompts or use CLI flags
Template selection UI - Shows available templates with descriptions (extensible for future templates)
Input validation - Dataset names, versions validated with helpful error messages
Safety checks - Prevents overwriting existing amp.config.ts
Comprehensive testing - 9 unit tests covering template resolution, validation, and file generation

Architecture

  • Effect-TS patterns throughout (Effect, Schema, Match)
  • Extensible template system via Template interface
  • Type-safe error handling with TemplateError class
  • Clean separation of concerns (command logic, templates, file operations)

Testing

pnpm vitest run test/cli/init.test.ts
# ✓ 9/9 tests passing

Coverage includes:

  • Template file resolution (static & dynamic)
  • Config generation with custom values
  • Dataset name validation
  • Solidity contract validity

Next Steps

After this PR, the next template will be onchain-evm-rpc to guide developers to real blockchain usage (testnet/mainnet) with production best practices:

  • RPC endpoint configuration for public networks
  • start_block and finalized_blocks_only settings
  • Rate limiting and cost optimization
  • Real-world query patterns

Breaking Changes

None - purely additive feature.

@marcusrein
Copy link
Author

CI Notes

Two CI issues surfaced (not caused by this PR):

  1. TypeScript check fails: Root tsconfig.json has project
    reference configuration issues (TS2878). The amp init code
    itself compiles correctly.

  2. Integration test fails: it_typescript::typescript_basic
    needs git submodules in CI (missing submodules: recursive in
    checkout action).

Both are pre-existing infrastructure issues. Happy to address in
a follow-up if needed.

marcusrein and others added 14 commits November 16, 2025 09:23
…modes

Add new `amp init` command to scaffold Amp projects from templates.
Implements three modes of operation for maximum flexibility:

- Interactive mode: Prompts for dataset name, version, and project name
- Non-interactive mode: Uses flags (--dataset-name, --dataset-version, --project-name)
- Quick defaults mode: Uses -y/--yes flag for CI/automation

Features:
- Template system with dynamic file generation
- local-evm-rpc template with full Anvil setup
- Validation for dataset names (lowercase, alphanumeric, underscore only)
- Personalized README with configuration summary and doc links
- Complete Foundry project structure with sample Counter contract

Files added:
- typescript/amp/src/cli/commands/init.ts (239 lines)
- typescript/amp/src/cli/templates/Template.ts (60 lines)
- typescript/amp/src/cli/templates/local-evm-rpc.ts (377 lines)
- typescript/amp/test/cli/init.test.ts (141 lines)
- TESTING_AMP_INIT.md (manual testing guide)

Files modified:
- typescript/amp/src/cli/main.ts (added init to subcommands)

Testing:
- 9 unit tests (all passing)
- Manual testing guide with 10 test scenarios
- TypeScript compilation: clean
- ESLint formatting: clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Three small improvements for better user experience:

1. Validate project name is not empty in interactive mode
   - Prevents broken README with empty title
   - Trims whitespace from input

2. Check for existing amp.config.ts before initializing
   - Prevents accidental data loss
   - Clear error message with guidance

3. Add blank line after interactive prompts complete
   - Better visual separation between input and output phases
   - Improves readability

All changes are defensive and low-risk.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit introduces the following changes to enhance the `amp init` command:

1. Updated the project name prompt to simplify the message from "Project name (for README):" to "Project name:" for clarity.
2. Changed the generated README file name from `README.md` to `README-local-evm-rpc.md` to better reflect its content and purpose.
3. Adjusted the README content to provide a more concise overview of the template's features and configuration, including a clearer description of the dataset and network.

These modifications aim to improve user experience and documentation clarity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ontracts and build artifacts

This commit enhances the .gitignore file by adding entries for various directories related to contracts and build outputs, including:
- `contracts/out/`
- `contracts/cache/`
- `contracts/broadcast/`
- `contracts/lib/`
- `target/` for Rust builds
- Nested workspace directories for Node.js, including `**/node_modules/`, `**/dist/`, and TypeScript build info files.

These changes aim to prevent unnecessary files from being tracked in the repository, improving project cleanliness and maintainability.
… local-evm-rpc template headings

This commit includes the following changes:

1. Updated the `amp init` command to use `return yield*` for error handling, enhancing clarity in the code.
2. Simplified console log messages for project initialization, removing emojis for a cleaner output.
3. Revised headings in the `local-evm-rpc` template documentation to remove emojis and improve consistency, making it more straightforward for users.

These modifications aim to enhance code readability and improve user experience during project initialization.
… clarity

This commit simplifies the output messages in the `amp init` command by consolidating next steps into a single line directing users to the README.md for further instructions. Additionally, the README template has been updated to reflect this change, ensuring consistency in documentation. These modifications aim to enhance user experience and streamline project setup.
… template

This commit introduces a new `postInstall` function in the `local-evm-rpc` template, which automates the installation of Foundry dependencies and the building of contracts. The script utilizes the `Effect` library for error handling and provides clear console log messages to guide users through the setup process. These enhancements aim to streamline the development workflow for users working with Anvil-based projects.
… options for deployment

This commit updates the deployment instructions in the `local-evm-rpc` template to include additional parameters for specifying the sender address and private key. This enhancement allows users to customize their deployment process more effectively, facilitating easier contract deployment on local EVM setups.
This commit modifies the Foundry installation command in the `local-evm-rpc` template to include the `--no-commit` and `--no-git` flags. This change aims to prevent automatic commits and Git operations during the installation process, providing users with more control over their setup. The error message has also been updated to reflect these changes, ensuring clarity in case of installation failure.
This commit updates the `local-evm-rpc` template to ensure the `lib` directory is created before cloning the `forge-std` repository. It adds error handling for directory creation and modifies the installation command to clone the repository directly, improving the reliability of the Foundry setup process. These changes aim to streamline the installation workflow and provide clearer error messages for users.
This commit deletes the following files as part of a cleanup process:
- `tsconfig.build.json` and `tsconfig.json`: TypeScript configuration files that are no longer needed.
- `VERSIONING.md`: Documentation on the versioning system, which has been removed for simplification.
- `vitest.config.ts`: Configuration for Vitest testing framework, now obsolete.
- Unused submodules and fixtures related to `forge-std` and `solady` have also been removed to streamline the project structure.

These changes aim to reduce clutter and improve maintainability of the codebase.
…proved clarity and functionality

This commit makes several enhancements to the `local-evm-rpc` template, including:
- Updated the template description to reflect a focus on learning Amp with sample data.
- Changed the event structure to emit 500 events for immediate querying, enhancing the educational aspect.
- Revised the README to provide clearer instructions and highlight the new features, including the quick start guide and sample queries.
- Modified the deployment script to deploy the new `EventEmitter` contract, which generates varied event data.
- Updated tests to ensure they align with the new template structure and content.

These changes aim to improve the user experience and streamline the onboarding process for new users learning Amp.
@marcusrein marcusrein force-pushed the marcus/amp-init-command branch from 67815a5 to 8ad996b Compare November 16, 2025 12:25
@CLAassistant
Copy link

CLAassistant commented Nov 21, 2025

CLA assistant check
All committers have signed the CLA.

@leoyvens
Copy link
Collaborator

@marcusrein are you still working on this?

@marcusrein
Copy link
Author

marcusrein commented Dec 15, 2025

@leoyvens I would like to continue working on it once I receive feedback. I submitted prior to DevConnect and have not heard if I should continue on this or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants