Skip to content

Commit ec38b49

Browse files
committed
docs: enhance repository guidelines and documentation structure
1 parent f1c3b08 commit ec38b49

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Repository Guidelines
22

33
## Project Structure & Module Organization
4+
45
- **src/** – Strict TypeScript sources: `state.ts` (Zod schemas), `graph/auralyze-graph.ts` (LangGraph), `tools/` (client contracts), `config/llm.ts`, `prompts/`, and `dev.ts`.
56
- **test/** – Vitest suites mirroring feature areas (`state`, `tools`, `config`, `graph/unit`, `graph/integration`) plus coverage helpers.
67
- **docs/** – VitePress site (`docs/.vitepress/config.ts`) with guides for onboarding, architecture, testing, and releases.
78
- **dist/** – tsup output (ESM/CJS bundles + `.d.ts`). Regenerated via `npm run build` or the `prepare` script.
89

910
## Build, Test, and Development Commands
11+
1012
- `npm run lint` – ESLint (strict TS config, Prettier formatting on demand via `npm run format`).
1113
- `npm run typecheck``tsc --noEmit` to verify contracts without emitting JS.
1214
- `npm test -- --run` / `--coverage` – Vitest suites with optional coverage (target 100% over `src/`).
@@ -15,27 +17,32 @@
1517
- `npm run docs:dev` / `docs:build` – VitePress documentation preview/build.
1618

1719
## Coding Style & Naming Conventions
20+
1821
- TypeScript, strict + `noImplicitAny`. Use `import type` for type-only dependencies.
1922
- ESM modules with explicit `.ts` specifiers; kebab-case filenames (`audio-metadata-tool.ts`).
2023
- Formatting: Prettier (2-space indent, single quotes). Linting: ESLint (`npm run lint`).
2124

2225
## Testing Guidelines
26+
2327
- Framework: Vitest with globals enabled. Stub injected clients using `vi.fn()` for deterministic runs.
2428
- Suites live alongside the feature under test; file names follow `area/file.kind.test.ts`.
2529
- Coverage: run `npm run test -- --coverage --run`; CI expects full coverage across `src/`.
2630

2731
## Architecture Overview
32+
2833
- `runAuralyzeSession(input, deps)` builds a LangGraph pipeline (`validateInput → metadataStep → analysisStep → feedbackStep → finalize`).
2934
- Dependencies are injected clients (`audioMetadataClient`, `audioAnalysisClient`, `feedbackClient`); the engine never touches ffmpeg or HTTP endpoints directly.
3035
- `OpenAIFeedbackClient` (in `src/config/llm.ts`) wraps the OpenAI SDK; other LLM providers can implement the `FeedbackClient` interface.
3136

3237
## Commit & Pull Request Guidelines
38+
3339
- Use descriptive commits (e.g., `graph: add crest-factor reducer`). Squash only when keeping history readable.
3440
- Run `npm run ci` locally before opening a PR; CI mirrors the same commands.
3541
- PRs should link the tracking ticket, summarize behavior changes, and include test results or coverage output. Attach screenshots/logs if the change impacts tooling or docs.
3642
- Never commit secrets. Configure credentials via env vars or GitHub secrets (`DOCS_PUBLISH_TOKEN`, `GITHUB_TOKEN`, etc.).
3743

3844
## Security & Configuration Tips
45+
3946
- Install from GitHub Packages by mapping `@auralyze:registry=https://npm.pkg.github.com` and authenticating with `${GITHUB_TOKEN}`.
4047
- The docs workflow (`.github/workflows/docs.yml`) pushes to a separate repo/branch; configure `DOCS_PUBLISH_TOKEN`, and optionally `DOCS_REPOSITORY` / `DOCS_BRANCH`.
4148
- `src/dev.ts` is a playground only—do not ship it in production; rely on the published bundle from `dist/`.

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
This repository contains the Auralyze Engine, a LangGraph-powered workflow engine for AI-driven audio mix analysis. The actual project code lives in the `engine/` subdirectory.
88

99
**Key directories (all under `engine/`):**
10+
1011
- `src/` - TypeScript source code with strict typing
1112
- `state.ts` - Zod schemas for engine state and analysis data
1213
- `graph/auralyze-graph.ts` - LangGraph workflow orchestration
@@ -23,6 +24,7 @@ This repository contains the Auralyze Engine, a LangGraph-powered workflow engin
2324
**All commands must be run from the `engine/` directory.**
2425

2526
### Essential Commands
27+
2628
```bash
2729
cd engine
2830
npm install # Install dependencies
@@ -31,6 +33,7 @@ npm run dev # Run ts-node playground (src/dev.ts) with mock clients
3133
```
3234

3335
### Individual Tasks
36+
3437
```bash
3538
npm run lint # ESLint over src/**/*.ts
3639
npm run typecheck # TypeScript contract verification (tsc --noEmit)
@@ -41,13 +44,15 @@ npm run format # Prettier formatting
4144
```
4245

4346
### Documentation
47+
4448
```bash
4549
npm run docs:dev # Start VitePress dev server (localhost:5173)
4650
npm run docs:build # Build static documentation
4751
npm run docs:preview # Preview built docs
4852
```
4953

5054
### Running Single Tests
55+
5156
```bash
5257
npm test -- path/to/file.test.ts # Run specific test file
5358
npm test -- --run # Run once without watch mode
@@ -57,6 +62,7 @@ npm test -- --coverage --run # Coverage report without watch
5762
## Architecture
5863

5964
### LangGraph Workflow Pipeline
65+
6066
The engine uses a linear LangGraph state machine defined in `src/graph/auralyze-graph.ts`:
6167

6268
```
@@ -66,6 +72,7 @@ START → validateInput → metadataStep → analysisStep → feedbackStep → f
6672
Each node processes the shared `EngineState` and returns partial updates. If any node encounters an error, it sets `state.error` and subsequent nodes skip processing.
6773

6874
### Dependency Injection Pattern
75+
6976
The engine uses **dependency injection** exclusively - it never makes HTTP requests or runs ffmpeg directly. Instead, host applications inject three client implementations:
7077

7178
1. `audioMetadataClient: AudioMetadataClient` - Retrieves file metadata (duration, format, sample rate, etc.)
@@ -75,25 +82,30 @@ The engine uses **dependency injection** exclusively - it never makes HTTP reque
7582
The built-in `OpenAIFeedbackClient` (in `src/config/llm.ts`) implements `FeedbackClient` using the OpenAI SDK. Custom implementations can support other LLM providers.
7683

7784
### State Management
85+
7886
State is defined using Zod schemas in `src/state.ts`. The `EngineState` type includes:
87+
7988
- Session metadata (`sessionId`, `uploadUrl`, `userContext`)
8089
- File information (`fileInfo: FileInfo`)
8190
- Analysis results (`analysis: Analysis` with loudness, dynamics, spectrum, stereo sub-schemas)
8291
- LLM feedback (`feedbackText`, `suggestions`)
8392
- Error tracking (`error`)
8493

8594
### Entry Point
95+
8696
The main API is `runAuralyzeSession(input, deps)` exported from `src/index.ts`. It builds the LangGraph workflow, initializes state, and invokes the compiled graph.
8797

8898
## Testing Strategy
8999

90100
Tests use Vitest with mocked dependencies:
101+
91102
- **Unit tests**: Individual node functions with `vi.fn()` mocks
92103
- **Integration tests**: Full graph execution with fake clients
93104
- **Schema tests**: Zod validation edge cases
94105
- **Prompt tests**: Feedback prompt builder output
95106

96107
Test files follow the pattern: `test/<area>/<file>.<kind>.test.ts`
108+
97109
- Example: `test/graph/auralyzeGraph.unit.test.ts`
98110
- Example: `test/graph/auralyzeGraph.integration.test.ts`
99111

@@ -136,6 +148,7 @@ Only `dist/`, `README.md`, and `LICENSE` are included in the published package (
136148
## Documentation Deployment
137149

138150
The VitePress docs are automatically deployed via `.github/workflows/docs.yml` on pushes to `main`. The workflow:
151+
139152
1. Builds the docs site
140153
2. Force-pushes to a companion repository (default: `auralyze/engine-docs` on `gh-pages` branch)
141154
3. Requires `DOCS_PUBLISH_TOKEN` secret with appropriate permissions

0 commit comments

Comments
 (0)