Command-line interface for ITS Compiler - converts ITS templates to AI prompts
Project description
ITS Compiler CLI
Command-line interface for the ITS Compiler Python library. Converts Instruction Template Specification (ITS) templates into structured AI prompts.
Installation
pip install its-compiler-cli
This automatically installs the core its-compiler library as a dependency.
Quick Start
Basic Usage
# Compile template to stdout
its-compile template.json
# Save output to file
its-compile template.json --output prompt.txt
# Use custom variables
its-compile template.json --variables vars.json
# Validate template without compiling
its-compile template.json --validate-only
Example Template
Create example.json:
{
"version": "1.0.0",
"extends": ["https://alexanderparker.github.io/instruction-template-specification/schema/v1.0/its-standard-types-v1.json"],
"variables": {
"topic": "renewable energy"
},
"content": [
{
"type": "placeholder",
"instructionType": "paragraph",
"config": {
"description": "Write about ${topic}",
"tone": "informative"
}
}
]
}
Compile it:
its-compile example.json
Published type libraries
Templates import instruction types through extends. The specification publishes these libraries under https://alexanderparker.github.io/instruction-template-specification/schema/v1.0/:
| Library | File | Purpose |
|---|---|---|
| Standard Types | its-standard-types-v1.json |
Prose content: titles, lists, paragraphs, tables, dialogue and more |
| JSON Types | its-json-types-v1.json |
Value fills inside JSON structure authored in the template: json_string, json_number, json_value, json_array_items, json_object_fields |
| HTML Types | its-html-types-v1.json |
Fills inside literal markup: html_text, html_fragment, html_list_items, html_table_rows, html_form_fields |
| YAML Types | its-yaml-types-v1.json |
Fills inside literal YAML: yaml_value, yaml_list_items, yaml_block |
The structured-output libraries instruct the model to emit raw output with no markdown code fences and no commentary, for example:
# A template extending the JSON types library
its-compile api-response-template.json
# Developing an unpublished type library locally
its-compile template.json --allow-local-schemas
Command Reference
its-compile [OPTIONS] TEMPLATE_FILE
Arguments:
TEMPLATE_FILE Path to the ITS template JSON file
Options:
-o, --output FILE Output file (default: stdout)
-v, --variables FILE JSON file with variable values
-w, --watch Watch template file for changes
--validate-only Validate template without compiling
--verbose Show detailed output
--strict Enable strict validation mode
--no-cache Disable schema caching
--timeout INTEGER Network timeout in seconds (default: 30)
--allow-http Allow HTTP URLs (not recommended)
--allow-local-schemas Allow extends to resolve local file paths
relative to the template
--interactive-allowlist / --no-interactive-allowlist
Enable/disable interactive schema prompts
--security-report FILE Generate security analysis report to specified file
--supported-schema-version
Show the supported ITS specification version and exit
--allowlist-status Show schema allowlist status
--add-trusted-schema URL
Add a schema URL to the permanent allowlist and exit
--remove-schema URL Remove a schema URL from the allowlist and exit
--export-allowlist FILE
Export allowlist to specified file and exit
--import-allowlist FILE
Import allowlist from specified file and exit
--merge-allowlist Merge imported allowlist with existing
(use with --import-allowlist)
--cleanup-allowlist Remove old unused allowlist entries and exit
--older-than DAYS Days threshold for cleanup (default: 90)
--version Show version and exit
--help Show help and exit
Development Workflow
Watch Mode
Automatically recompile when the template changes:
its-compile template.json --watch --output prompt.txt
Validation
Check templates for errors without compiling:
its-compile template.json --validate-only --strict
Variables
Use external variable files:
# vars.json
{
"productName": "Widget Pro",
"features": ["fast", "reliable", "secure"]
}
its-compile template.json --variables vars.json
Schema Management
When templates reference external schemas, you may be prompted to allow them:
SCHEMA ALLOWLIST DECISION REQUIRED
URL: https://example.com/schema.json
1. Allow permanently (saved to allowlist)
2. Allow for this session only
3. Deny (compilation will fail)
Allowlist Commands
# Check current allowlist status
its-compile --allowlist-status
# Non-interactive mode (useful for CI/CD)
its-compile template.json --no-interactive-allowlist
Configuration
Set environment variables to configure default behaviour:
export ITS_INTERACTIVE_ALLOWLIST=false # Disable prompts
export ITS_REQUEST_TIMEOUT=60 # Increase timeout
export ITS_ALLOWLIST_FILE=/path/to/allowlist.json
The CLI honours the core library's full ITS_* environment surface. Alongside the three above:
ITS_ALLOW_HTTP- Allow HTTP URLsITS_ALLOW_LOCAL_SCHEMAS- Allow extends to resolve local file paths relative to the templateITS_BLOCK_LOCALHOST- Block localhost accessITS_DOMAIN_ALLOWLIST- Comma-separated allowed domainsITS_MAX_TEMPLATE_SIZE- Max template size in bytesITS_MAX_CONTENT_ELEMENTS- Max content elementsITS_MAX_NESTING_DEPTH- Max content/variable nesting depthITS_MAX_VARIABLE_COUNT- Max total variables including nested valuesITS_MAX_VARIABLE_ARRAY_ITEMS- Max items per variable arrayITS_MAX_TEXT_LENGTH- Max length of a text element or string valueITS_DISABLE_ALLOWLIST- Disable schema allowlistITS_DISABLE_INPUT_VALIDATION- Disable input validation
Error Examples
Missing Variable
✗ Variable Error: Undefined variable '${productName}'
Available variables: topic, features
Invalid Template
✗ Validation Error: Missing required field 'version'
At: root
Schema Issues
✗ Schema Error: Failed to load schema
URL: https://example.com/schema.json
Testing
Test your CLI installation:
# Basic functionality test
echo '{"version":"1.0.0","content":[{"type":"text","text":"Hello"}]}' | its-compile /dev/stdin
# Download test runner (optional)
curl -O https://raw.githubusercontent.com/AlexanderParker/its-compiler-cli-python/main/test_runner.py
python test_runner.py
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure all tests pass (
python test_runner.py) - Run linting (
black . && flake8) - Commit your changes
- Push to the branch and open a Pull Request
Development Setup
# Clone and setup
git clone https://github.com/AlexanderParker/its-compiler-cli-python.git
cd its-compiler-cli-python
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
python test_runner.py
For Maintainers
Publishing to PyPI:
This package is published to PyPI as its-compiler-cli. Releases are currently managed manually:
# Build the package
python -m build
# Test upload to TestPyPI first (recommended)
python -m twine upload --repository testpypi dist/*
# Upload to production PyPI (requires appropriate credentials)
python -m twine upload dist/*
TestPyPI Testing:
# Install from TestPyPI to verify the package
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ its-compiler-cli
ITS ecosystem
- Specification - the ITS spec, schemas and documentation (source)
- Template studio demo - build and compile templates in the browser (source)
- its-template-editor - the WYSIWYG React editor component behind the studio
- its-compiler-js - JavaScript/TypeScript reference compiler (npm)
- its-compiler-python - Python reference compiler library (PyPI)
- its-compiler-dotnet - .NET compiler with ASP.NET service and Azure Functions samples (NuGet publication pending)
- its-example-templates - example and test templates exercising the published schemas
License
MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file its_compiler_cli-1.1.0.tar.gz.
File metadata
- Download URL: its_compiler_cli-1.1.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75ded3f0865dffc5fb65cb4ccc9d39287b29463054f46128c298447bbc2db084
|
|
| MD5 |
09a47fdbec519893b3fabc62a90f82b7
|
|
| BLAKE2b-256 |
32373a29611bb5fa0a9a03f3b97e75456c7da85d0b883ff728849b833653d49e
|
Provenance
The following attestation bundles were made for its_compiler_cli-1.1.0.tar.gz:
Publisher:
publish.yml on AlexanderParker/its-compiler-cli-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
its_compiler_cli-1.1.0.tar.gz -
Subject digest:
75ded3f0865dffc5fb65cb4ccc9d39287b29463054f46128c298447bbc2db084 - Sigstore transparency entry: 2333135252
- Sigstore integration time:
-
Permalink:
AlexanderParker/its-compiler-cli-python@1b7060ec82ac6ddeb027bf2e41921eb5ee03121f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AlexanderParker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b7060ec82ac6ddeb027bf2e41921eb5ee03121f -
Trigger Event:
push
-
Statement type:
File details
Details for the file its_compiler_cli-1.1.0-py3-none-any.whl.
File metadata
- Download URL: its_compiler_cli-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67f8f795ea64203d642e015c54cfa965d54e6e2ac2644a8f99c99b07c7cd53d2
|
|
| MD5 |
266b44eb28141f7d86b2483ee01fcd37
|
|
| BLAKE2b-256 |
b24d62669348a605ef04239c9c4114c15ce68903e373d16a6d4b4c17ee206073
|
Provenance
The following attestation bundles were made for its_compiler_cli-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on AlexanderParker/its-compiler-cli-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
its_compiler_cli-1.1.0-py3-none-any.whl -
Subject digest:
67f8f795ea64203d642e015c54cfa965d54e6e2ac2644a8f99c99b07c7cd53d2 - Sigstore transparency entry: 2333135267
- Sigstore integration time:
-
Permalink:
AlexanderParker/its-compiler-cli-python@1b7060ec82ac6ddeb027bf2e41921eb5ee03121f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AlexanderParker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b7060ec82ac6ddeb027bf2e41921eb5ee03121f -
Trigger Event:
push
-
Statement type: