|
| 1 | +# Agent Guidelines for Ecto |
| 2 | + |
| 3 | +Ecto is a modern template consolidation engine that provides a unified interface for working with multiple popular template engines (EJS, Markdown, Pug, Nunjucks, Mustache, Handlebars, and Liquid). |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +- **Purpose**: Simplify template rendering by providing a single API for multiple template engines with automatic engine selection based on file extensions |
| 8 | +- **Architecture**: TypeScript library with a plugin architecture - `Ecto` coordinates engines, `BaseEngine` provides common functionality, individual engine classes handle specific template formats |
| 9 | +- **Key Dependencies**: `ejs`, `pug`, `nunjucks`, `liquidjs`, `@jaredwray/fumanchu` (Handlebars/Mustache), `writr` (Markdown), `cacheable` (caching), `hookified` (events/hooks) |
| 10 | + |
| 11 | +## Development Commands |
| 12 | + |
| 13 | +- Use `pnpm` instead of `npm` for all package management commands |
| 14 | +- `pnpm build` - Build TypeScript to ESM with type declarations |
| 15 | +- `pnpm test` - Run linting and tests with coverage |
| 16 | +- `pnpm lint` - Run Biome linter with auto-fix |
| 17 | +- `pnpm clean` - Remove dist, coverage, node_modules, and lock files |
| 18 | + |
| 19 | +## Code Quality Requirements |
| 20 | + |
| 21 | +- Always run `pnpm test` to verify tests pass before completing changes |
| 22 | +- All new code must have corresponding tests |
| 23 | +- Follow existing code patterns in `src/ecto.ts` for the main class |
| 24 | +- Use Biome for linting and formatting (configured in the project) |
| 25 | +- TypeScript strict mode is enabled |
| 26 | + |
| 27 | +## Project Structure |
| 28 | + |
| 29 | +- `src/ecto.ts` - Main Ecto class (core engine coordinator) |
| 30 | +- `src/base-engine.ts` - Base class for all engines |
| 31 | +- `src/engine-interface.ts` - TypeScript interface for engine implementations |
| 32 | +- `src/engine-map.ts` - Manages file extension to engine mappings |
| 33 | +- `src/engines/` - Individual engine implementations (ejs, handlebars, liquid, markdown, nunjucks, pug) |
| 34 | +- `test/` - Vitest test files |
| 35 | + |
| 36 | +## Engine Mapping |
| 37 | + |
| 38 | +- `.ejs` → EJS |
| 39 | +- `.md`, `.markdown` → Markdown |
| 40 | +- `.pug`, `.jade` → Pug |
| 41 | +- `.njk` → Nunjucks |
| 42 | +- `.mustache` → Mustache |
| 43 | +- `.handlebars`, `.hbs`, `.hjs` → Handlebars |
| 44 | +- `.liquid` → Liquid |
| 45 | + |
| 46 | +## Key Considerations |
| 47 | + |
| 48 | +- Async and sync rendering methods are available (`render`/`renderSync`, `renderFromFile`/`renderFromFileSync`) |
| 49 | +- FrontMatter support is built-in for Markdown files |
| 50 | +- Caching is available via the `cacheable` library for performance optimization |
| 51 | +- Hooks system allows intercepting and modifying data during rendering |
| 52 | +- Custom engines can be created by implementing the `EngineInterface` |
0 commit comments