Imported from laxamentumtech/audnexus (
AGENTS.md). Install upstream withnpx skills add laxamentumtech/audnexus. Copyright stays with the author.
Repository Standards for AI Agents
This document establishes comprehensive standards for AI agents working on the audnexus project. All agents must follow these guidelines to ensure consistency, quality, and maintainability.
1. Testing Standards
1.1 Unit Test Requirements
All code changes must include appropriate unit tests. Tests are located in the tests/ directory and follow the naming patterns:
- Test file pattern:
**/*.+(spec|test).+(ts|tsx|js) - Location:
tests/**/*.+(ts|tsx|js) - Live tests excluded:
tests/live/(see Section 6)
Run unit tests:
bun run test
This command executes Bun's test runner with the following options:
--timeout 30000: Sets per-test timeout to 30 seconds- Runs only Bun-compatible tests (subset of total test suite during migration)
Note: Some legacy tests use Jest-specific APIs (jest.mock(), jest-mock-extended) and are not included in the default test command. These tests are being converted to use Bun's native testing APIs. New tests should use Bun's native mocking capabilities.
1.2 Coverage
Coverage reports are generated automatically by Bun test. Coverage configuration is defined in bunfig.toml.
Coverage reports are generated in: coverage/ directory
1.3 Mock Guidelines
Recommended approach: Use Bun's native mocking capabilities or simple function stubs.
Example of Bun-compatible mock:
import { mock } from 'bun:test'
// Example: Mocking a simple function
const mockFetch = mock(() => Promise.resolve({ data: 'test' }))
1.4 Test Execution Commands
| Command | Purpose |
|---|---|
bun run test |
Run Bun-compatible unit tests with coverage |
bun run test:live |
Run live integration tests (see Section 6) |
2. Code Quality Standards
2.1 TypeScript Configuration
The project uses TypeScript 5.9.3 with strict mode enabled. See tsconfig.json.
Build command:
bun run build-ts # or bun run build (includes build-ts)
2.2 ESLint Rules
The project uses ESLint 10.0.0 with the following configuration (eslint.config.mjs):
Extended configs:
eslint:recommendedplugin:@typescript-eslint/recommendedprettier
Custom rules:
| Rule | Level | Description |
|---|---|---|
simple-import-sort/imports |
error | Enforces import sorting order |
simple-import-sort/exports |
error | Enforces export sorting order |
Import sort order: Use simple-import-sort/imports rule via bun run lint.
Run linting:
bun run lint
This runs:
- Prettier check:
prettier --config .prettierrc --check 'src/**/*.ts' - TypeScript check:
tsc --noEmit - ESLint:
eslint "**/*.{js,ts}" --quiet --fix
2.3 Prettier Configuration
Format code:
bun run format
2.4 Module Aliases
The project uses module aliases (#helpers/*, #config/*, #static/*, etc., defined in package.json).
3. Dependency Management
3.1 Update Process
Standard update workflow:
# 1. Check for outdated packages
bun outdated
# 2. Update dependencies
bun update
# 3. Install new dependencies
bun install
# 4. Run full verification
bun run lint && bun run test && bun run build
3.2 Major Version Handling
Major version updates require special attention.
Breaking change detection checklist:
- Review the package's CHANGELOG or release notes
- Check for peer dependency warnings
- Look for deprecated API usage warnings
- Run
bun run testto verify all tests pass - Check
bun run buildcompiles without errors
3.3 Security Patch SLA
Priority levels:
| Severity | SLA | Action |
|---|---|---|
| Critical (RCE, data breach) | 24 hours | Immediate patch or rollback |
| High (privilege escalation) | 72 hours | Apply patch within SLA |
| Medium (information disclosure) | 7 days | Include in next update cycle |
| Low (best practice) | Next release | Document and plan fix |
Check for vulnerabilities:
bun audit
3.4 Rollback Procedures
If a dependency update causes issues:
# 1. Revert package.json and bun.lock changes
git checkout package.json bun.lock
# 2. Reinstall previous versions
bun install
# 3. Verify restoration
bun run lint && bun run test && bun run build
4. CI/CD Standards
4.1 What Runs in CI
Bun CI Workflow (.github/workflows/bun.yml):
Triggers:
- Push to
main,develop,renovate/*branches - Pull requests to
main,develop - Scheduled: Every Monday at 13:00 UTC
Steps:
bun install
bun run lint
bun run test
bun run build
4.2 Required Checks
All pull requests must pass:
| Check | Command | Status |
|---|---|---|
| Linting | bun run lint |
Required |
| Tests | bun run test |
Required |
| Build | bun run build |
Required |
| Conventional Commits | CI validation | Required |
4.3 Failure Handling
On CI failure:
-
Check the workflow logs in GitHub Actions
-
Identify the failing step (lint, test, or build)
-
Fix locally:
bun run lint # Check for issues bun run test # Run tests bun run build # Verify build -
Push fixes to the PR branch
-
Re-run CI by pushing new commits
Common failures:
| Failure | Solution |
|---|---|
| Lint errors | Run bun run lint and fix issues |
| Test failures | Check test logic and fix issues |
| Build errors | Check TypeScript compilation errors |
| Type errors | Run tsc --noEmit to see all errors |
4.4 Live Tests CI
Live Tests Workflow (.github/workflows/live-tests.yml):
Triggers:
- Scheduled: Daily at 09:00 UTC
- Manual:
workflow_dispatchwith optional chapter tests
Environment:
RUN_LIVE_TESTS=true bun run test:live
Failure handling:
- Creates automatic issue with
[AUDIBLE API CHANGE]or[AUDIBLE HTML CHANGE]label - Requires human review and code updates
4.5 Deployment Workflows
See .github/workflows/ for deployment workflows (deploy-coolify.yml, docker-publish.yml).
5. Commit Standards
5.1 Conventional Commit Format
All commits must follow the Conventional Commits specification:
<type>(<scope>): <description>
Types:
| Type | Description | Example |
|---|---|---|
feat |
A new feature | feat(api): add book search endpoint |
fix |
A bug fix | fix(auth): resolve token expiration issue |
chore |
Maintenance tasks | chore(deps): update axios version |
docs |
Documentation changes | docs(config): update API documentation |
style |
Code style changes | style(code): format code with prettier |
refactor |
Code refactoring | refactor(helper): simplify book parsing |
perf |
Performance improvements | perf(db): optimize query performance |
test |
Adding or modifying tests | test(helper): add unit tests for ApiHelper |
deps |
Dependency updates | deps: update mongodb to 7.1.0 |
ci |
CI/CD changes | ci(workflows): add new GitHub workflow |
api- API-related changesdb- Database-related changesauth- Authentication changesscraper- Web scraping changeshelper- Helper function changesconfig- Configuration changes Invalid: missing type, non-conventional format, or vague description.
5.2 CI Validation
The repository uses webiny/action-conventional-commits to validate commit messages on PRs to main.
Enforcement:
- All PRs to
mainmust have conventional commit messages - PRs with invalid commit messages will fail the
Conventional Commitscheck
6. Live Test Standards
6.1 When to Run Live Tests
Environment variable required:
RUN_LIVE_TESTS=true bun run test:live
Live tests are located in: tests/live/
Use cases:
- Testing against real Audible API responses
- Detecting changes in Audible's HTML structure
- Verifying API endpoint changes
- Integration testing with real data
6.3 Warning vs Failure Interpretation
Warnings (non-blocking):
[AUDIBLE API CHANGE] - Minor structure change detected
[AUDIBLE HTML CHANGE] - HTML parsing warning
Warnings indicate potential issues that should be reviewed but don't fail the build.
Failures (blocking):
[AUDIBLE API CHANGE] - Breaking API change detected
[AUDIBLE HTML CHANGE] - Critical HTML structure change
Failures indicate breaking changes that require immediate attention and code updates.
6.4 Handling Audible Changes
When live tests detect changes:
-
Review the test output for specific change details
-
Identify the affected helper in
src/helpers/audible/ -
Update the helper to handle the new structure
-
Update tests in
tests/audible/if needed -
Re-run live tests to confirm fixes
-
Commit changes with appropriate message:
fix(audible): update book scraper for new HTML structure
Quick Reference Commands
# Development
bun install # Install dependencies
bun run watch # Watch mode for development
bun run debug # Build and watch with debug
# Testing
bun run test # Run unit tests with coverage
bun run test:live # Run live integration tests
# Quality
bun run lint # Check linting and formatting
bun run format # Format code with Prettier
bun run build # Build TypeScript
# Documentation
bun run build-docs # Build API documentation
# Release
# Releases are handled by the annalist GitHub App with fill_after mode on main branch
File References
| File | Purpose |
|---|---|
bunfig.toml |
Bun configuration and test coverage settings |
eslint.config.mjs |
ESLint rules and configuration |
package.json |
Dependencies and scripts |
tsconfig.json |
TypeScript configuration |
.github/workflows/bun.yml |
CI/CD pipeline |
.github/workflows/live-tests.yml |
Live test workflow |
.github/workflows/conventional-commits.yml |
Commit validation |
.github/workflows/deploy-coolify.yml |
Coolify deployment integration |
.github/workflows/docker-publish.yml |
Docker image publishing |
Last updated: 2026-02-19 Maintained by: Repository maintainers