# AGENTS.md `image-meta`: detect image type and dimensions from a `Uint8Array`, in pure JS. It has no runtime dependencies and uses no Node APIs in `src/`. `src/` runs directly under Node's built-in type stripping (`node src/index.ts`): relative imports use explicit `.ts` extensions, and only erasable TS syntax is allowed (no `enum`, `namespace`, or parameter properties). `tsconfig.json` enforces both. ## Layout - `src/index.ts`: `imageMeta(input)` is the public API. It detects the type, calls the handler's `calculate`, and throws `TypeError` for unsupported input. - `src/detector.ts`: fast path that uses a `firstBytes` lookup, then falls back to calling each handler's `validate` in order. - `src/types/.ts`: one `IImage` handler (`validate` + `calculate`) per format. - `src/types/index.ts`: `typeHandlers` registry. Its keys define `ImageType`. - `src/types/utils.ts`: byte readers (`readUInt32BE`, `toUTF8String`, …). Use these, not `Buffer`. - `src/types/interface.ts`: `ImageMeta` / `IImage` types. ## Adding or fixing a format 1. Add or edit `src/types/.ts`, then register it in `src/types/index.ts`. If it has a unique leading byte, also add it to `firstBytes` in `detector.ts`. 2. Add fixtures to `test/fixtures/valid//`. The folder name must equal the type key. Snapshots (`.meta`) are generated by vitest (`vitest run -u`). 3. Put inputs that must throw in `test/fixtures/invalid//`. ## Commands (pnpm) - `pnpm vitest run`: run tests only - `pnpm test`: lint + typecheck + tests with coverage - `pnpm lint:fix`: eslint (`eslint-config-unjs`) + prettier - `pnpm build`: obuild to `dist/` (ESM only)