compile
Compile all prompts from an arena.yaml configuration into a single pack file.
Synopsis
Section titled “Synopsis”packc compile --config <arena.yaml> --output <pack-file> --id <pack-id>Description
Section titled “Description”The compile command reads an Arena configuration file (arena.yaml) that references multiple prompt YAML files and compiles them all into a single optimized .pack.json file.
This is the primary command for building production packs that contain multiple prompts for your application.
Options
Section titled “Options”Required
Section titled “Required”--config <path>
- Path to the arena.yaml configuration file
- This file lists all prompts to include in the pack
- Default:
config.arena.yaml
--output <path>
- Path where the compiled pack file will be written
- Should end in
.pack.json - Example:
packs/customer-support.pack.json
--id <string>
- Unique identifier for this pack
- Used by the SDK to reference the pack
- Should be kebab-case (e.g.,
customer-support) - Example:
--id customer-support
Examples
Section titled “Examples”Basic Compilation
Section titled “Basic Compilation”packc compile \ --config arena.yaml \ --output packs/app.pack.json \ --id my-appProduction Pack
Section titled “Production Pack”packc compile \ --config configs/production/arena.yaml \ --output dist/production.pack.json \ --id prod-assistantMultiple Environments
Section titled “Multiple Environments”# Development packpackc compile \ --config arena.dev.yaml \ --output packs/app.dev.pack.json \ --id app-dev
# Production packpackc compile \ --config arena.prod.yaml \ --output packs/app.prod.pack.json \ --id app-prodInput: arena.yaml Structure
Section titled “Input: arena.yaml Structure”The arena.yaml file references prompt configurations:
version: "1.0"
prompts: - id: customer-support path: prompts/support.yaml
- id: sales-assistant path: prompts/sales.yaml
- id: technical-expert path: prompts/technical.yaml
tools_dir: tools/Output: Pack File
Section titled “Output: Pack File”The command produces a .pack.json file:
{ "id": "customer-support", "name": "Customer Support Pack", "version": "1.0.0", "template_engine": "go", "prompts": { "customer-support": { "system": "You are a customer support agent...", "parameters": { "temperature": 0.7, "max_tokens": 1000 } }, "sales-assistant": { "system": "You are a sales assistant...", "parameters": { "temperature": 0.8 } } }, "compilation": { "compiled_with": "packc-v0.1.0", "created_at": "2024-01-15T10:30:00Z", "schema": "1.0" }}Compilation Process
Section titled “Compilation Process”The compile command performs these steps:
- Load Configuration - Read arena.yaml
- Parse Prompts - Load all referenced YAML files
- Validate - Check for errors and warnings
- Compile - Transform to pack format
- Optimize - Remove unused data
- Write - Save to output file
Exit Codes
Section titled “Exit Codes”0- Success1- Error (invalid config, compilation failure, etc.)
Common Errors
Section titled “Common Errors”Missing Required Options
Section titled “Missing Required Options”$ packc compile --config arena.yamlError: --output and --id are requiredSolution: Provide both --output and --id:
packc compile --config arena.yaml --output app.pack.json --id my-appConfig File Not Found
Section titled “Config File Not Found”Error loading arena config: open arena.yaml: no such file or directorySolution: Check that the config file exists:
ls -la arena.yamlInvalid YAML Syntax
Section titled “Invalid YAML Syntax”Error loading arena config: yaml: line 5: mapping values are not allowedSolution: Fix YAML syntax errors in arena.yaml or prompt files.
Missing Prompt Files
Section titled “Missing Prompt Files”Error: prompt file not found: prompts/support.yamlSolution: Ensure all referenced prompt files exist.
Validation Warnings
Section titled “Validation Warnings”The compiler may emit warnings for non-fatal issues:
⚠ Media validation warnings for customer-support: - Referenced image not found: images/logo.png - Template variable 'user_name' not definedThese warnings don’t stop compilation but should be addressed.
Performance
Section titled “Performance”Compilation is fast:
- Small packs (1-5 prompts): <100ms
- Medium packs (10-20 prompts): <500ms
- Large packs (50+ prompts): <2s
Best Practices
Section titled “Best Practices”1. Organize by Environment
Section titled “1. Organize by Environment”configs/├── arena.dev.yaml├── arena.staging.yaml└── arena.prod.yaml
packs/├── app.dev.pack.json├── app.staging.pack.json└── app.prod.pack.json2. Use Descriptive Pack IDs
Section titled “2. Use Descriptive Pack IDs”# Good--id customer-support-v2--id sales-assistant-prod--id technical-docs-staging
# Bad--id pack1--id app--id test3. Version Your Packs
Section titled “3. Version Your Packs”Include version in pack metadata:
# arena.yamlversion: "1.0"metadata: pack_version: "2.1.0"4. Validate After Compilation
Section titled “4. Validate After Compilation”Always validate after compiling:
packc compile --config arena.yaml --output app.pack.json --id my-apppackc validate app.pack.json5. Store Packs in Version Control
Section titled “5. Store Packs in Version Control”Commit compiled packs to track changes:
git add packs/app.pack.jsongit commit -m "chore: update customer support pack"Integration with CI/CD
Section titled “Integration with CI/CD”GitHub Actions
Section titled “GitHub Actions”name: Compile Packs
on: [push]
jobs: compile: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Install packc run: go install github.com/AltairaLabs/PromptKit/tools/packc@latest
- name: Compile packs run: | packc compile --config arena.yaml --output packs/app.pack.json --id my-app packc validate packs/app.pack.json
- name: Upload packs uses: actions/upload-artifact@v3 with: name: compiled-packs path: packs/Makefile
Section titled “Makefile”.PHONY: compile-packscompile-packs: packc compile --config arena.yaml --output packs/app.pack.json --id my-app packc validate packs/app.pack.json
.PHONY: compile-allcompile-all: packc compile --config arena.dev.yaml --output packs/app.dev.pack.json --id app-dev packc compile --config arena.prod.yaml --output packs/app.prod.pack.json --id app-prodSee Also
Section titled “See Also”- compile-prompt - Compile single prompt
- validate - Validate pack file
- inspect - Inspect pack contents
- How to Compile Packs