OF-DL/AGENTS.md

124 lines
3.7 KiB
Markdown

# AGENTS.md
## Purpose
OF DL (OF-DL) is a C# (`net10.0`) app suite with:
- A modern Avalonia GUI
- A classic CLI
- Shared core services for auth, API calls, downloads, DRM handling, and metadata storage
## Architecture at a glance
1. `AuthService` loads `auth.json` or runs browser login and saves auth.
2. `ApiService` signs OnlyFans API requests with dynamic rules.
3. `DownloadOrchestrationService` selects creators/lists and coordinates download jobs.
4. `DownloadService` downloads/decrypts media and records metadata via `DBService`.
## Key directories
- `OF DL.Cli/`: CLI-specific UI/helpers
- `OF DL.Gui/`: Avalonia UI, view models, windows
- `OF DL.Core/Services/`: business logic (auth/api/download/config/startup/db/logging)
- `OF DL.Core/Models/`: DTOs, entities, config/auth/download/startup models, mappers
- `OF DL.Core/Widevine/`: Widevine CDM logic
- `docs/`: MkDocs source
- `docker/`: container entrypoint/runtime config
## Files and entry points to check first
- `OF DL.Gui/ViewModels/MainWindowViewModel.cs`
- `OF DL.Gui/Views/MainWindow.axaml`
- `OF DL.Core/Services/ApiService.cs`
- `OF DL.Core/Services/AuthService.cs`
- `OF DL.Core/Services/ConfigService.cs`
- `OF DL.Core/Services/DownloadOrchestrationService.cs`
- `OF DL.Core/Services/DownloadService.cs`
- `OF DL.Core/Services/StartupService.cs`
- `OF DL.Core/Services/DBService.cs`
- `OF DL.Core/Helpers/EnvironmentHelper.cs`
## Runtime files (relative to working directory)
- `config.conf` (primary config)
- `auth.json` (saved auth)
- `rules.json` (dynamic rules fallback)
- `users.db` (global user index)
- `chromium-data/` (browser profile for auth)
- `cdm/` (Widevine device files)
Default download root when `DownloadPath` is blank:
- `__user_data__/sites/OnlyFans/{username}`
## Commands
Build GUI:
```bash
dotnet build "OF DL.Gui/OF DL.Gui.csproj"
```
Build CLI:
```bash
dotnet build "OF DL.Cli/OF DL.Cli.csproj"
```
Tests:
```bash
dotnet test "OF DL.Tests/OF DL.Tests.csproj"
```
Coverage (optional):
```bash
dotnet test "OF DL.Tests/OF DL.Tests.csproj" --collect:"XPlat Code Coverage"
```
## High-impact technical details
Dynamic rules and request signing (`ApiService.GetDynamicHeaders`):
- Remote rules URL: `https://git.ofdl.tools/sim0n00ps/dynamic-rules/raw/branch/main/rules.json`
- Falls back to local `rules.json`
- Signed headers include `app-token`, `sign`, `time`, `user-id`, `user-agent`, `x-bc`, `cookie`
DRM decryption:
- Preferred: local CDM device files under `cdm/devices/chrome_1610/`
- Fallback path exists when CDM files are missing (`ofdl.tools/WV`)
- Primary flow is in `DownloadService` + DRM helpers in `ApiService`
## Documentation update rules
Update docs whenever user-facing behavior changes.
- Config shape/options changed: update
- `docs/config/configuration.md`
- `docs/config/all-configuration-options.md`
- `docs/config/custom-filename-formats.md` (if filename tokens/formats changed)
- Auth/login behavior changed: update `docs/config/auth.md`
- GUI/CLI workflow changed: update
- `docs/operation/modern-version.md`
- `docs/operation/classic-version.md` (if applicable)
- Docker runtime/paths changed: update `docs/installation/docker.md`
## Coding style essentials
Follow `.editorconfig`. Most important rules:
- 4 spaces (2 for XML/YAML/project files), no tabs
- C# braces on new lines
- Prefer predefined types (`int`, `string`)
- `using` directives outside namespace, `System` first
- Private fields `_camelCase`; private static `s_` prefix
## Agent guardrails
- Prefer small, targeted changes in the service/viewmodel responsible for the behavior.
- Keep GUI and CLI behavior aligned when changes affect both.
- Do not manually edit generated docs in `site/`.
- If you add new significant workflow/service structure, update this file.