From 32ca410f4edbff578d71781d943c41573912f476 Mon Sep 17 00:00:00 2001 From: amrkmn Date: Fri, 26 Dec 2025 22:39:23 +0800 Subject: Initial commit --- AGENTS.md | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 AGENTS.md (limited to 'AGENTS.md') diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..005c5b0 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,184 @@ +# Agent Instructions for Mihon/Aniyomi Extensions Aggregator + +This repository is a SvelteKit project managed with **Bun**. It aggregates extensions for Mihon and Aniyomi, serving them as a static site with an API-like structure in `static/`. + +## 1. Environment & Toolchain + +- **Runtime**: `bun` (Do not use `npm` or `yarn` or `pnpm`). +- **Framework**: SvelteKit (Svelte 5). +- **Language**: TypeScript (Strict mode). +- **Search**: Meilisearch (client-side integration). + +## 2. Development Commands + +### Build & Run + +- **Install dependencies**: + ```bash + bun install + ``` +- **Start dev server**: + ```bash + bun run dev + ``` +- **Build production output**: + ```bash + bun run build + ``` + _Note: This runs `bun run update --generate-only` first to regenerate `static/data.json` before Vite builds._ + +### Linting & Verification + +- **Type Check**: + ```bash + bun run check + ``` + _Always run this after making TypeScript or Svelte changes. There are no unit tests, so strict type checking is your primary safety net._ +- **Format Code**: + ```bash + bun run format + ``` +- **Verify Formatting**: + ```bash + bun run lint + ``` + +### Data Management + +- **Update Extensions**: + ```bash + bun run update + ``` + _Fetches upstream data. Use `--generate-only` to just rebuild `data.json` locally._ + +### Testing + +- **Run all tests**: + ```bash + bun test + ``` +- **Run a single test file**: + ```bash + bun test tests/debounce.test.ts + ``` +- **Run tests with watch mode**: + ```bash + bun test --watch + ``` + +## 3. Testing Strategy + +**Test Framework**: Uses `bun:test` built-in test runner with TypeScript support. + +**Test Coverage**: + +- Utility functions in `src/lib/search/` (debouncing, source name formatting) +- Logger utilities in `scripts/cache/` (transfer stats formatting) +- Cache manifest operations in `scripts/cache/` (finding caches by key/prefix) +- File operations in `scripts/cache/` (checksums, directory management) +- Cache lock utilities (instance ID generation, staleness detection) +- Cache metadata key generation +- Cache utility functions (key generation, byte formatting) + +**Agent Protocol for Verification**: + +1. **Run Tests**: Execute `bun test` to verify existing functionality. +2. **Write Tests**: When adding utility functions, add corresponding test files in `tests/`. +3. **Type Check**: Always run `bun run check` after making changes. +4. **Build Verification**: Run `bun run build` to ensure static adapter and prerendering complete successfully. + +## 4. Code Style & Conventions + +### Formatting (Enforced by Prettier) + +- **Indentation**: 4 spaces. +- **Quotes**: Single quotes (`'`). +- **Trailing Commas**: `none`. +- **Line Width**: 100 characters. +- **Line Endings**: LF (`\n`). + +### TypeScript + +- **Strict Mode**: Enabled. No `any` types unless absolutely necessary. +- **Imports**: Use standard ESM imports. + - SvelteKit aliases: `$lib/` is mapped to `src/lib/`. +- **Interfaces**: Define specific interfaces for data structures (see `src/lib/types.ts` or `src/lib/search/types.ts`). + +### Svelte Components (Svelte 5) + +- Use `