Skip to main content

Command-line interface for ITS Compiler - converts ITS templates to AI prompts

Project description

ITS Compiler CLI

PyPI version Python License

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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and add tests
  4. Ensure all tests pass (python test_runner.py)
  5. Run linting (black . && flake8)
  6. Commit your changes
  7. 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

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

its_compiler_cli-1.0.4.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

its_compiler_cli-1.0.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file its_compiler_cli-1.0.4.tar.gz.

File metadata

  • Download URL: its_compiler_cli-1.0.4.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

Hashes for its_compiler_cli-1.0.4.tar.gz
Algorithm Hash digest
SHA256 0bf45368a2793f282a576e51920ab51dd5f903257880bcb387083765c32f5fda
MD5 8ed5194a140e29a5927f4beb8f77b4b4
BLAKE2b-256 b7c5a3c2d60c0112baa42c0ed420d002b0984c7f03c42d1e3887ea1f3da81100

See more details on using hashes here.

File details

Details for the file its_compiler_cli-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for its_compiler_cli-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe62e5313fef96295916497f93cea5eb70a6d441a378fd2db512497e00045e5
MD5 ac47788fb838f1eebeb8dd6cf8f8cb54
BLAKE2b-256 4177daf0e2a5af5a440c90d7553410810af047a875c43d095b76d69364d606e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page