agentleFS
viu-mediaviu-media/viu/.github/copilot-instructions.md

viu

Copilot instructions1.1k starsChanged 15 months agoUnlicenseArchived repositoryView on GitHub

Hello, Copilot! This document provides instructions and context to help you understand the viu codebase. Following these guidelines will help you generate code that is consistent, maintainable, and aligned with the project's architecture. viu is a command-line tool that brings the anime browsing, streaming, and management experience to the terminal. It integrates with metadata providers like AniList and scrapes streaming links from various anime provider websites. The core goals are efficiency, extensibility, and providing a powerful, scriptable user experience. The…

  • Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.

    Of the Copilot instructions files we read, the 2,336 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

14 rules. About 0 are common, 2 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Guideline: When adding new functionality (e.g., a new way to manage downloads), it should likely be implemented in a service or an existing …

    line 22
  2. Distinctive:

    Follow these patterns to ensure your contributions fit the existing architecture.

    line 48
  3. Very specific:

    Create Directory: Add a new folder in viu/libs/provider/anime/newprovider/.

    line 51
  4. Very specific:

    Add the provider's name to the ProviderName enum in viu/libs/provider/anime/types.py.

    line 55
  5. Very specific:

    Add it to the PROVIDERS_AVAILABLE dictionary in viu/libs/provider/anime/provider.py.

    line 56
  6. Very specific:

    Add Configuration: If the player has settings, add a NewPlayerConfig Pydantic model in viu/core/config/model.py, and add it to the main …

    line 61
  7. Very specific:

    Register Player: Add the player's name to the PLAYERS list and the factory logic in viu/libs/player/player.py.

    line 62
  8. Very specific:

    Add Configuration: If needed, add a NewSelectorConfig to viu/core/config/model.py.

    line 67
  9. Very specific:

    Register Selector: Add the selector's name to the SELECTORS list and the factory logic in viu/libs/selectors/selector.py.

    line 68
  10. Very specific:

    Create viu/cli/commands/my_command.py with your click.command().

    line 72
  11. Very specific:

    Add to Model: Add the field to the appropriate Pydantic model in viu/core/config/model.py.

    line 79
  12. Very specific:

    Add Default: Add a default value in viu/core/config/defaults.py.

    line 80
  13. Very specific:

    Add Description: Add a user-friendly description in viu/core/config/descriptions.py.

    line 81
  14. Very specific:

    Logging: Use Python's logging module.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 3,779 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

GitHub Copilot Instructions for the viu Repository

Hello, Copilot! This document provides instructions and context to help you understand the viu codebase. Following these guidelines will help you generate code that is consistent, maintainable, and aligned with the project's architecture.

1. High-Level Project Goal

viu is a command-line tool that brings the anime browsing, streaming, and management experience to the terminal. It integrates with metadata providers like AniList and scrapes streaming links from various anime provider websites. The core goals are efficiency, extensibility, and providing a powerful, scriptable user experience.

2. Core Architectural Concepts

The project follows a clean, layered architecture. When generating code, please adhere to this structure.

Layer 1: CLI (viu/cli)

  • Purpose: Handles user interaction, command parsing, and displaying output.
  • Key Libraries: click for command structure, rich for styled output.
  • Interactive Mode: The interactive TUI is managed by the Session object in viu/cli/interactive/session.py. It's a state machine where each menu is a function that returns the next State or an InternalDirective (like BACK or EXIT).
  • Guideline: CLI files should not contain complex business logic. They should parse arguments and delegate tasks to the Service Layer.

Layer 2: Service (viu/cli/service)

  • Purpose: Contains the core application logic. Services act as orchestrators, connecting the CLI layer with the various library components.
  • Examples: DownloadService, PlayerService, MediaRegistryService, WatchHistoryService.
  • Guideline: When adding new functionality (e.g., a new way to manage downloads), it should likely be implemented in a service or an existing service should be extended. Services are the "brains" of the application.

Layer 3: Libraries (viu/libs)

  • Purpose: A collection of independent, reusable modules with well-defined contracts (Abstract Base Classes).
  • media_api: Interfaces with metadata services like AniList. All new metadata clients must inherit from BaseApiClient.
  • provider: Interfaces with anime streaming websites. All new providers must inherit from BaseAnimeProvider.
  • player: Wrappers around external media players like MPV. All new players must inherit from BasePlayer.
  • selectors: Wrappers for interactive UI tools like FZF or Rofi. All new selectors must inherit from BaseSelector.
  • Guideline: Libraries should be self-contained and not depend on the CLI or Service layers. They receive configuration and perform their specific task.

Layer 4: Core (viu/core)

  • Purpose: Foundational code shared across the entire application.
  • config: Pydantic models defining the application's configuration structure. This is the single source of truth for all settings.
  • downloader: The underlying logic for downloading files (using yt-dlp or httpx).
  • exceptions: Custom exception classes used throughout the project.
  • utils: Common, low-level utility functions.
  • Guideline: Code in core should be generic and have no dependencies on other layers except for other core modules.

3. Key Technologies

  • Dependency Management: uv is used for all package management and task running. Refer to pyproject.toml for dependencies.
  • Configuration: Pydantic is used exclusively. The entire configuration is defined in viu/core/config/model.py.
  • CLI Framework: click. We use a custom LazyGroup to load commands on demand for faster startup.
  • HTTP Client: httpx is the standard for all network requests.

4. How to Add New Features

Follow these patterns to ensure your contributions fit the existing architecture.

How to Add a New Provider

  1. Create Directory: Add a new folder in viu/libs/provider/anime/newprovider/.
  2. Implement BaseAnimeProvider: In provider.py, create a class NewProvider that inherits from BaseAnimeProvider and implement the search, get, and episode_streams methods.
  3. Create Mappers: In mappers.py, write functions to convert the provider's API/HTML data into the generic Pydantic models from viu/libs/provider/anime/types.py (e.g., SearchResult, Anime, Server).
  4. Register Provider:
    • Add the provider's name to the ProviderName enum in viu/libs/provider/anime/types.py.
    • Add it to the PROVIDERS_AVAILABLE dictionary in viu/libs/provider/anime/provider.py.

How to Add a New Player

  1. Create Directory: Add a new folder in viu/libs/player/newplayer/.
  2. Implement BasePlayer: In player.py, create a class NewPlayer that inherits from BasePlayer and implement the play method. It should call the player's executable via subprocess.
  3. Add Configuration: If the player has settings, add a NewPlayerConfig Pydantic model in viu/core/config/model.py, and add it to the main AppConfig. Also add defaults and descriptions.
  4. Register Player: Add the player's name to the PLAYERS list and the factory logic in viu/libs/player/player.py.

How to Add a New Selector

  1. Create Directory: Add a new folder in viu/libs/selectors/newselector/.
  2. Implement BaseSelector: In selector.py, create a class NewSelector that inherits from BaseSelector and implement choose, confirm, and ask.
  3. Add Configuration: If needed, add a NewSelectorConfig to viu/core/config/model.py.
  4. Register Selector: Add the selector's name to the SELECTORS list and the factory logic in viu/libs/selectors/selector.py. Update the Literal type hint for selector in GeneralConfig.

How to Add a New CLI Command

  • Top-Level Command (viu my-command):
    1. Create viu/cli/commands/my_command.py with your click.command().
    2. Register it in the commands dictionary in viu/cli/cli.py.
  • Subcommand (viu anilist my-subcommand):
    1. Create viu/cli/commands/anilist/commands/my_subcommand.py.
    2. Register it in the lazy_subcommands dictionary of the parent click.group() (e.g., in viu/cli/commands/anilist/cmd.py).

How to Add a New Configuration Option

  1. Add to Model: Add the field to the appropriate Pydantic model in viu/core/config/model.py.
  2. Add Default: Add a default value in viu/core/config/defaults.py.
  3. Add Description: Add a user-friendly description in viu/core/config/descriptions.py.
  4. The config loader and CLI option generation will handle the rest automatically.

5. Code Style and Conventions

  • Style: ruff for formatting, ruff for linting. The pre-commit hooks handle this.
  • Types: Full type hinting is mandatory. All code must pass pyright.
  • Commits: Adhere to the Conventional Commits standard.
  • Logging: Use Python's logging module. Do not use print() for debugging or informational messages in library or service code.

6. Do's and Don'ts

  • ✅ DO use the abstract base classes (BaseProvider, BasePlayer, etc.) as contracts.
  • ✅ DO place business logic in the service layer.
  • ✅ DO use the Pydantic models in viu/core/config/model.py as the single source of truth for configuration.
  • ✅ DO use the Context object in interactive menus to access services and configuration.
  • ❌ DON'T hardcode configuration values. Access them via the config object.
  • ❌ DON'T put complex logic directly into click command functions. Delegate to a service.
  • ❌ DON'T make direct httpx calls outside of a provider or media_api library.
  • ❌ DON'T introduce new dependencies without updating pyproject.toml and discussing it first.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.