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
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)
--interactive-allowlist / --no-interactive-allowlist
Enable/disable interactive schema prompts
--allowlist-status Show schema allowlist status
--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
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
Related Projects
- ITS Compiler Python - Core library
- Instruction Template Specification - Official specification
- ITS Example Templates - Example templates
License
MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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.0.0.tar.gz.
File metadata
- Download URL: its_compiler_cli-1.0.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46a3bc8f381ebd24f03d1dedfc19223aed243dadcebf9551def11ce13abe3939
|
|
| MD5 |
68d97270f96f95ec6d8b047abd568990
|
|
| BLAKE2b-256 |
2a9a19320247b5b98193a637a28afe0a5e5204a2a94ce5fdbc3d12dc62d1e8cd
|
File details
Details for the file its_compiler_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: its_compiler_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83aa809dc06ef755121a0527dfb66168c997429279983369ce3113244b445cc7
|
|
| MD5 |
64dda1ce9ff891ecffa430a8ea046aa2
|
|
| BLAKE2b-256 |
cfd921f4750d12dc278644d488f93e895d711c110c6c61cd5ab469b874667ada
|