# Where Is the Parser Registry Located in the Distilly Codebase?

> Find the Distilly parser registry at tools/skill_presets.py. Learn how CHARACTER_PRESETS maps character families to prompts and parsing behavior.

- Repository: [Tianyi Zhou/distilly](https://github.com/titanwings/distilly)
- Tags: internals
- Published: 2026-09-10

---

**The Distilly parser registry is located in [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py), where the `CHARACTER_PRESETS` dictionary defines how each character family maps to its prompt bundle and parsing behavior.**

Distilly uses a centralized parser registry to determine how different character families are interpreted and processed. This registry governs everything from prompt template selection to storage path resolution according to the `titanwings/distilly` source code. Understanding where this registry lives and how to interact with it is essential for extending Distilly's character-based skills or customizing parsing behavior.

## Location of the Parser Registry in Distilly

The parser registry resides in **[`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py)** on the `dot-skill` branch. This module contains the **`CHARACTER_PRESETS`** constant—a dictionary that registers every supported character preset including *colleague*, *relationship*, and *celebrity*.

### The CHARACTER_PRESETS Dictionary

The `CHARACTER_PRESETS` dictionary serves as the single source of truth for character family definitions. Each entry maps a character key to metadata including display names and prompt bundle paths.

### Registry Helper Functions

Several utility functions interact with this registry to resolve parsing behavior:

- **`get_character_preset`** – Retrieves preset configuration for a given character name
- **`normalize_character`** – Resolves user-provided aliases to canonical character names  
- **`resolve_storage_root`** – Determines storage paths based on character family
- **`canonical_storage_root`** – Returns the standard storage location for a character type

## How to Access and Use the Parser Registry

Developers interact with the Distilly parser registry through the helper functions exported from [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py).

### Retrieving Character Presets

To fetch configuration for a specific character family:

```python
from tools.skill_presets import get_character_preset

preset = get_character_preset("celebrity")
print(preset["display_name"])   # → Celebrity

print(preset["prompt_bundle"])  # contains paths to the prompt templates

```

### Resolving Storage Paths

The registry determines where skill artifacts are stored on the filesystem:

```python
from tools.skill_presets import resolve_storage_root

storage_root = resolve_storage_root("relationship")
print(storage_root)   # → Path('skills/relationship')

```

### Normalizing Character Aliases

User input often requires normalization against the registry to ensure consistent parsing:

```python
from tools.skill_presets import normalize_character

print(normalize_character("ex"))          # → relationship

print(normalize_character("nuwa"))       # → celebrity

print(normalize_character(None))         # → colleague (default)

```

## Related Files That Depend on the Parser Registry

The parser registry in [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py) supports several downstream modules that implement Distilly's skill management pipeline:

- **[`tools/skill_writer.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_writer.py)** – Uses the registry to create or update skill artifacts based on the selected character preset
- **[`tools/version_manager.py`](https://github.com/titanwings/distilly/blob/main/tools/version_manager.py)** – References the registry when handling versioned skill data via the `--character` argument

## Summary

- The parser registry is located in **[`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py)** on the `dot-skill` branch
- The **`CHARACTER_PRESETS`** dictionary contains all character family definitions and prompt bundle mappings
- Helper functions including `get_character_preset`, `normalize_character`, and `resolve_storage_root` provide the primary API for registry access
- Downstream tools [`skill_writer.py`](https://github.com/titanwings/distilly/blob/main/skill_writer.py) and [`version_manager.py`](https://github.com/titanwings/distilly/blob/main/version_manager.py) depend on this registry for character-aware skill operations

## Frequently Asked Questions

### In which file is the Distilly parser registry defined?

The parser registry is defined in **[`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py)**, specifically within the `CHARACTER_PRESETS` dictionary constant. This file contains the complete mapping of character families to their parsing configurations, display names, and prompt bundle paths.

### How do I retrieve a character preset from the Distilly registry?

Import the **`get_character_preset`** function from [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py) and pass the character name as a string argument. This function queries the `CHARACTER_PRESETS` registry and returns a dictionary containing the `display_name`, `prompt_bundle`, and other configuration metadata for that character family.

### What functions interact with the parser registry in Distilly?

The primary functions include **`get_character_preset`** for retrieving configurations, **`normalize_character`** for resolving aliases to canonical names, **`resolve_storage_root`** for determining skill storage paths, and **`canonical_storage_root`** for standard storage locations. All are exported from [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py) and operate against the central `CHARACTER_PRESETS` registry.

### Which other modules reference the parser registry?

**[`tools/skill_writer.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_writer.py)** uses the registry when creating or updating skill artifacts to ensure correct prompt bundle selection, while **[`tools/version_manager.py`](https://github.com/titanwings/distilly/blob/main/tools/version_manager.py)** references it when processing versioned skill data with the `--character` argument. Both modules import utilities from [`tools/skill_presets.py`](https://github.com/titanwings/distilly/blob/main/tools/skill_presets.py) to maintain consistent parsing behavior across the codebase.