{%- set exts = extensions.get('extensions', {}) -%}
# Appendix: Domain Extensions

{% for ext_domain, ext in exts.items() -%}
## {{ ext_domain.upper() }} Domain Extension

{% if ext.hooks -%}
### Workflow Hooks

The following hooks are automatically triggered at specific workflow points:

| Trigger Point | Action | Condition | Description |
|--------------|--------|-----------|-------------|
{% for hook in ext.hooks -%}
{%- set condition = ('`' ~ hook.condition ~ '`') if hook.condition else '-' -%}
{%- set ctx = ext.contexts.get(hook.context_id, None) -%}
{%- set desc = ctx.description if ctx else (hook.context_id or '-') -%}
| `{{ hook.trigger }}` | {{ hook.action }} | {{ condition }} | {{ desc }} |
{% endfor %}
{% endif -%}

{% if ext.contexts -%}
### Injectable Contexts

{% for ctx_id, ctx in ext.contexts.items() -%}
**{{ ctx_id }}** ({{ ctx.type }})
{% if ctx.description -%}
: {{ ctx.description }}
{% endif -%}
{% if ctx.source -%}
- Source: `{{ ctx.source }}`
{% endif -%}
{% if ctx.pattern -%}
- Pattern: `{{ ctx.pattern }}`
{% endif %}
{% endfor -%}
{% endif -%}

{% if ext.additional_files -%}
### Domain Files

| File | Purpose |
|------|---------|
{% for af in ext.additional_files -%}
| `{{ af.get('path', '') }}` | {{ af.get('purpose', '') }} |
{% endfor %}
{% endif -%}

---

{% endfor -%}
