ai-hero-cli
v0.2.13
Published
The CLI used to run exercises for the AI Hero course
Downloads
1,918
Readme
AI Hero CLI
A command-line interface tool designed to help students navigate and run AI Hero exercises efficiently.
Overview
The AI Hero CLI is a specialized tool that makes it easy to:
- Browse and select exercises from the AI Hero course
- Run exercises with proper environment setup
- Navigate between exercises seamlessly
- Get exercise instructions and context
Installation
This CLI is typically pre-installed in AI Hero exercise repositories. If you need to install it manually:
pnpm add -D ai-hero-cliUsage
Basic Commands
Run an Exercise
# Run a specific exercise by lesson number
ai-hero exercise 1
# Browse and select an exercise interactively
ai-hero exerciseCommand Options
--root: Directory to look for lessons (default: current directory)--env-file: Path to environment file (default:.envin current directory)--cwd: Working directory to run the command in (default: current directory)--simple: Run the exercise in simple mode. This will disable the more advanced features of the CLI, such as shortcuts, to ensure maximum compatibility with some systems (default: false)
Interactive Features
When running an exercise, the CLI provides an interactive interface with several shortcuts:
- Enter: Choose a new exercise to run
- n: Go to the next exercise
- p: Go to the previous exercise
- q: Quit the current exercise
- h: Show all available shortcuts
Exercise Navigation
The CLI automatically detects the structure of your AI Hero exercises and provides seamless navigation:
- Exercise Selection: Use the interactive menu to browse and search through available exercises
- Subfolder Support: If an exercise has multiple subfolders, you'll be prompted to select one
- Progressive Navigation: Easily move to the next or previous exercise in the course
- Context Preservation: The CLI remembers your position and provides relevant navigation options
Exercise Execution
When you run an exercise:
- The CLI clears the terminal and displays the exercise information
- Shows the exercise instructions (if available in
readme.md) - Runs the exercise using
pnpm tsxwith your environment variables - Provides interactive controls while the exercise is running
- Offers options when the exercise completes or encounters an error
Post-Exercise Options
After an exercise completes, you can:
- Run Again: Retry the current exercise
- Next Exercise: Automatically move to the next exercise in the sequence
- Previous Exercise: Go back to the previous exercise
- Choose Exercise: Browse and select a different exercise
- Finish: Exit the CLI
Internal Commands
The CLI also includes internal commands for maintenance:
# Upgrade AI SDK packages
ai-hero internal upgrade
# Upgrade with verbose output
ai-hero internal upgrade --verboseFile Structure Expectations
The CLI expects your AI Hero exercises to follow this structure:
exercises/
├── 1-section-name/
│ ├── 1-exercise-name/
│ │ ├── main.ts
│ │ └── readme.md
│ └── 2-another-exercise/
│ ├── main.ts
│ └── readme.md- Each exercise should have a
main.tsfile as the entry point - Optional
readme.mdfiles provide exercise instructions - Exercise and section names should start with a number followed by a hyphen
Environment Setup
The CLI automatically loads environment variables from:
.envfile in the current directory (default)- Custom env file specified with
--env-fileoption
Make sure your .env file contains any necessary API keys or configuration for the exercises.
Troubleshooting
Getting Help
- Use
hduring exercise execution to see available shortcuts - Check the exercise's
readme.mdfile for specific instructions - Ensure all dependencies are installed with
pnpm install
Note: This CLI is specifically designed for AI Hero exercises and is not intended for general use outside of the AI Hero course context.
