This file contains guidelines and commands for agentic coding agents working in this repository.
This is a Bun-based TypeScript project called apo2cdsp-parametriceq that parses EqualizerAPO parametric EQ filter data from text files and converts it to JSON format for use with cDSP (CamillaDSP).
The project is structured with a main entry point in index.ts and supporting logic in the lib/ directory.
- Install dependencies:
bun install - Add dependency:
bun add <package> - Remove dependency:
bun remove <package>
- Lint and format check:
bun run check(runs Biome check) - Fix issues:
bun run check:fix(runs Biome check --fix) - Fix issues unsafely:
bun run check:fix-unsafe(runs Biome check --fix --unsafe) - Type check:
bun run typecheck
- Run in development:
bun run dev <input-file>orbun index.ts <input-file> - Build production executable:
bun run build(outputs todist/apo2cdsp)
- Input file: The first positional argument is the input file path.
- Output file:
-o <path>or--output <path>to specify output JSON path. - Validation only:
--validateto check input without writing output. - Quiet mode:
--quietto suppress success messages. - Help/Version:
-h,--helpor-v,--version.
- Run tests:
bun test
- Target:
ESNext - Module:
Preserve(for bundler compatibility) - Strict mode enabled
- No implicit any, no unchecked indexed access
- Use ESNext lib features
- Indentation: 2 spaces (no tabs)
- Line width: 80 characters
- Quotes: Double quotes for strings/JSX
- Semicolons: Always
- Trailing commas: All (consistent)
- Line endings: LF
- Bracket spacing: Enabled
- Arrow parentheses: Always
- Use
import * as fs from "node:fs";for Node.js built-in modules - Prefer named imports over default imports when possible
- Group imports: built-in modules first, then external packages, then local modules
- Use type-only imports (
import type) when only types are needed
- Variables/Functions: camelCase
- Classes/Interfaces: PascalCase
- Constants: UPPER_SNAKE_CASE for truly constant values
- Files: kebab-case for utility files,
index.tsfor entry point
- Main logic resides in
index.ts(CLI handling) andlib/(core logic) lib/fileUtils.ts: Optimized file I/O operations (sync for small files, streams for large files)lib/parseFilters.ts: Core parsing and validation logic- Use
Math.fround()for 32-bit float precision consistency where required - Frequencies are rounded to integers in output
- Use custom error classes (e.g.,
ParseError) for domain-specific errors - Use
try/catchblocks in the CLI entry point to provide user-friendly error messages - Use
chalkfor colorized console output (Red for errors, Green for success, Yellow/Blue for info)
- Always run
bun run check:fixbefore committing - Test the main script with sample data before changes
- Check that output JSON format matches expected structure
- Verify file paths and error handling
- Ensure exactly 10 filters are present in the input as required by the parser
- The parser expects filter data in format:
"Filter <id>: <state> <type> Fc <freq> Hz Gain <gain> dB Q <q>" - Preamp lines are automatically stripped before parsing.
- Output maps to specific index ranges:
0-9: Gain (32-bit float, usingMath.fround)10-19: Frequency (integer, usingMath.round)20-29: Q factor (high precision float, rounded to 14 decimal places usingPRECISION_MULTIPLIER = 100000000000000)30-49: Static configuration values (indices 30-49 and 1024)
- Maximum supported file size: 10MB
- Stream threshold for file I/O: 1MB