DeveloperTemplate Packs System

Template Packs System

Template Packs are versioned bundles of entity templates, AI generation rules, and example entities. They are the distribution unit for sharing reusable entity type definitions — both within a team and on the public StudioBrain Marketplace.

What Are Template Packs?

A Template Pack is a directory containing:

my-pack/
  pack.json          # Pack metadata (required)
  templates/         # Template files for each entity type
    CHARACTER_TEMPLATE.md
    LOCATION_TEMPLATE.md
  examples/          # Sample entity markdown files
    example_character.md
  rules/             # AI generation rules for these types
    character_style.yaml
  README.md          # Human-readable documentation (recommended)
  icon.png           # 128x128 icon for the Marketplace card (optional)

Where a pack is loaded from depends on the runtime. Neither path restarts a Docker backend.

  • Cloud (api.studiobrain.ai): the Worker has no content filesystem. It reads the catalog from GitHub (BiloxiStudios/studiobrain-templates, directory templates/Packs, overridable with TEMPLATE_PACKS_REPO and TEMPLATE_PACKS_BRANCH) and caches it in R2 (_system/template-packs/catalog.json) for 15 minutes. A git push updates the catalog. The Worker is not rebuilt.
  • Self-hosted core (sb-server): each GET /api/template-packs scans {content_base}/_Templates/Packs/ for directories that contain pack.json. Discovery runs on that request, not once at startup.

Pack Structure

pack.json

The pack.json file is required and must be valid JSON:

{
  "id": "game-dev-essentials",
  "name": "Game Dev Essentials",
  "description": "Core entity types for game projects: factions, creatures, quests, and items.",
  "author": "Biloxi Studios",
  "version": "1.2.0",
  "entity_types": ["faction", "creature", "item"],
  "categories": ["entity"],
  "tags": ["game", "rpg", "narrative"],
  "icon": "icon.png",
  "includes": []
}

Fields:

FieldTypeRequiredDescription
idstringYesUnique pack identifier (kebab-case, alphanumeric + hyphens)
namestringYesHuman-readable display name
descriptionstringYesWhat the pack provides
authorstringYesPack author name or organization
versionstringYesSemantic version: major.minor.patch
entity_typesarrayYesList of entity type slugs included in the pack
categoriesarrayNoCategory tags for marketplace filtering
tagsarrayNoFreeform tags for search
iconstringNoRelative path to icon file inside pack directory
includesarrayNoPack IDs to include (for meta-packs only)

Template Files

Template files in templates/ follow the standard YAML frontmatter format. The filename must match the pattern {UPPERCASE_TYPE}_TEMPLATE.md. The entity type slug in the entity_type frontmatter field must match the lowercase filename stem:

templates/FACTION_TEMPLATE.md  →  entity_type: "faction"
templates/CREATURE_TEMPLATE.md →  entity_type: "creature"

Example Files

Example files in examples/ are valid entity markdown files that demonstrate the template in use. They are used during pack testing and shown in the Marketplace preview:

---
entity_type: faction
id: "iron_fist_guild"
name: "Iron Fist Guild"
faction_type: "mercenary"
alignment: "neutral"
size: "medium"
...
---
 
## Overview
 
The Iron Fist Guild is a mercenary organization operating out of Port Arkon...

Rule Files

Rule files in rules/ are AI generation rule YAML files that are imported when the pack is installed. Rules are scoped to the pack’s entity types and appear in Settings > Rules alongside the built-in rules.

Pack Development

Creating a Pack

  1. Create a directory in _Templates/Packs/:

    mkdir -p _Templates/Packs/my-pack/templates
    mkdir -p _Templates/Packs/my-pack/examples
    mkdir -p _Templates/Packs/my-pack/rules
  2. Create pack.json with your pack metadata.

  3. Add template files to templates/. Use _Templates/Standard/CHARACTER_TEMPLATE.md as a reference for the expected frontmatter fields.

  4. Add at least one example entity to examples/.

  5. Load the pack. Do not restart LXC 138. That container was removed (SBAI-11868). There is no Proxmox CT 138, and pct exec 138 does not reach a backend. App, API, and auth run on Cloudflare Workers.

    Cloud. Add the pack under templates/Packs/<id>/ in BiloxiStudios/studiobrain-templates (or the repo TEMPLATE_PACKS_REPO names) and add an entry to templates/Packs/index.json:

    { "id": "my-pack", "path": "templates/Packs/my-pack" }

    Push to the catalog branch (main unless TEMPLATE_PACKS_BRANCH is set). The Worker reads that index, not a directory listing, so a pack directory with no index entry is invisible. The cached catalog refreshes within 15 minutes. To load it immediately, call refresh with a tenant access token:

    curl -sS -X POST https://api.studiobrain.ai/api/template-packs/refresh \
      -H "Authorization: Bearer $TOKEN"

    Settings > Templates Sync posts POST /api/plugins/marketplace/sync, which runs the same refresh. A local _Templates/Packs/ directory is not visible to the Worker.

    Self-hosted core. Leave the directory at {content_base}/_Templates/Packs/my-pack/. The next GET /api/template-packs scans it. No process restart is required. From studiobrain-core, the local server is:

    cargo run -p sb-server --features sqlite
  6. Verify the pack loads. GET /api/template-packs includes the pack id, and the pack appears in Settings > Templates. On self-hosted core the server logs discover_packs: found N packs under .... The old Docker line Discovered pack: my-pack is not what this scanner emits.

Pack Metadata

Self-hosted core parses pack.json into PackManifest (crates/sb-server/src/services/template_packs.rs in studiobrain-core). Fields: id (falls back to the directory name), name, description, author, version (defaults to 1.0.0), entity_types, categories, tags, icon, is_meta_pack, includes, is_default, auto_install. The Cloud catalog (packages/cloudflare-worker/worker/src/template-packs.ts) lists the same fields plus a template_count.

Meta-Packs

A meta-pack does not define its own templates — it is a named bundle of other packs. Set "is_meta_pack": true in pack.json and list pack IDs in includes to make it a shortcut installer:

{
  "id": "game-studio-bundle",
  "name": "Game Studio Bundle",
  "description": "All game development packs in one install",
  "author": "Biloxi Studios",
  "version": "1.0.0",
  "entity_types": [],
  "is_meta_pack": true,
  "includes": ["game-dev-essentials", "narrative-packs", "world-building"]
}

Installing a meta-pack installs all included packs.

Dependencies

pack.json has no dependency field. Declare required packs in README.md, or bundle them with a meta-pack.

Pack Distribution

Cloud packs are distributed through the studiobrain-templates catalog repo (see Creating a Pack). Self-hosted packs are plain directories under _Templates/Packs/. There is no pack-submission API.

Version Management

Follow semantic versioning when releasing pack updates:

  • Patch (1.0.0 → 1.0.1): Fix typos, correct field defaults, adjust rule weights
  • Minor (1.0.0 → 1.1.0): Add new fields (backward compatible), add new rule files, add example entities
  • Major (1.0.0 → 2.0.0): Rename or remove fields, change entity type slugs, restructure frontmatter hierarchy

For major version updates, include a MIGRATION.md in the pack root describing the changes and how to update existing entities.

Local Distribution

For self-hosted team packs, include _Templates/Packs/ in your project’s git repository, or place it on shared storage that every instance mounts under the content directory. The next GET /api/template-packs scan finds it.

API Reference

The Template Packs API exposes pack discovery and install operations:

MethodPathDescription
GET/api/template-packsList all discovered packs
GET/api/template-packs/{pack_id}Get pack details (self-hosted core only; not served by the Cloud Worker)
GET/api/template-packs/installedList installed packs for current project
POST/api/template-packs/applyApply pack(s) to a project (Cloud Worker)
POST/api/template-packs/refreshRefresh the template pack catalog cache (Cloud Worker)
POST/api/template-packs/{pack_id}/installInstall a pack (activate its types)
DELETE/api/template-packs/{pack_id}/uninstallUninstall a pack (deactivate types, do not delete files)

See REST API Reference for full endpoint documentation and authentication details.

See Also