CLI Reference â
Complete command-line interface reference for the CAL Runtime.
Installation â
Install globally for command-line use:
npm install -g @stratiqx/cal-runtime
# Verify installation
cal versionOr use locally:
npm install @stratiqx/cal-runtime
# Run via npx
npx cal run script.calCommands â
run â
Execute a CAL script with data.
cal run <script> [options]Arguments:
<script>- Path to CAL script file (.calextension)
Options:
--inline, -i <code>- Inline CAL code instead of file--data, -d <file>- Data file (JSON)--data-path <dir>- Directory with data files--output, -o <file>- Output file for results (JSON)--alert, -a <type>- Alert type:console,file,json--alert-file <file>- Alert log file (for file alerts)--verbose, -v- Verbose output--quiet, -q- Minimal output
Examples:
# Basic execution
cal run analysis.cal --data entities.json
# With data directory
cal run analysis.cal --data-path ./data
# Save output
cal run analysis.cal --data entities.json --output results.json
# Verbose mode
cal run analysis.cal --data entities.json --verbose
# File alerts
cal run analysis.cal --data entities.json --alert file --alert-file ./logs/alerts.log
# Quiet mode
cal run analysis.cal --data entities.json --quiet
# Inline script
cal run --inline "FORAGE entities WHERE sound > 7 SURFACE results" --data entities.jsonOutput:
ðŠķ âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Cormorant Agentic Language (CAL) v0.1.0
Sound à Space à Time â 6D Analysis â Action
ðŠķ âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
ð Script: analysis.cal
ð§ Parsing CAL...
â
Parsing successful
ð Loading data: entities.json
ð Executing action plan...
âââ EXECUTION RESULTS âââ
â
Execution completed
Actions executed: 3
Outputs: 2
Watchers: 0
âââ OUTPUTS âââ
ðĶ results:
Type: Array
Count: 2
ðŠķ Done.analyze â
Parse and analyze a script without execution.
cal analyze <script> [options]Arguments:
<script>- Path to CAL script file
Options:
--inline, -i <code>- Inline CAL code--output, -o <file>- Save analysis to file--verbose, -v- Show detailed action plan--quiet, -q- Minimal output
Examples:
# Analyze script structure
cal analyze analysis.cal
# Detailed analysis
cal analyze analysis.cal --verbose
# Save to file
cal analyze analysis.cal --output analysis.jsonOutput:
ðŠķ âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Cormorant Agentic Language (CAL) v0.1.0
Sound à Space à Time â 6D Analysis â Action
ðŠķ âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
ð Analyzing: analysis.cal
ð§ Parsing CAL...
â
Parsing successful
âââ ANALYSIS âââ
Actions: 5
Action breakdown:
query: 2
drift: 1
fetch: 1
output: 1
ðŠķ Analysis complete.validate â
Validate script syntax without execution or analysis.
cal validate <script>Arguments:
<script>- Path to CAL script file
Options:
--inline, -i <code>- Inline CAL code
Examples:
# Validate script
cal validate analysis.cal
# Validate inline
cal validate --inline "FORAGE entities SURFACE results"Output:
â
analysis.cal is validOr if invalid:
â Validation failed: Expected keyword but found "INVALID"
at line 5, column 3help â
Show help information.
cal helpShows complete usage information, available commands, options, and examples.
version â
Show version information.
cal versionOutput:
CAL (Cormorant Agentic Language) v0.1.0
Runtime: Node.js v20.10.0Global Options â
Options that work with all commands:
--verbose, -v â
Show detailed output including:
- Source code
- Parsed action plan (JSON)
- Full result objects
- Stack traces on errors
cal run script.cal --verbose--quiet, -q â
Minimal output, only errors:
cal run script.cal --quietGood for scripting and automation.
Data Options â
--data, -d â
Specify a single data file:
cal run script.cal --data entities.jsonFile must contain JSON with an entities array:
{
"entities": [
{ "id": "1", "name": "Entity 1", "sound": 8, "space": 7, "time": 9 }
]
}--data-path â
Specify a directory containing data files:
cal run script.cal --data-path ./dataScripts reference files by name (without extension):
FORAGE entities -- Loads ./data/entities.json
FORAGE customers -- Loads ./data/customers.jsonOutput Options â
--output, -o â
Save execution results to file (JSON format):
cal run script.cal --data entities.json --output results.jsonOutput includes:
- Execution metadata (timestamps, methodology)
- All action results
- Output variables
- Watchers and scheduled tasks
- Success status
Example output file:
{
"type": "ExecutionResult",
"started": "2026-01-14T10:30:00.000Z",
"completed": "2026-01-14T10:30:05.123Z",
"methodology": "6D Foraging",
"actions": [...],
"outputs": {
"results": {...}
},
"watchers": [],
"scheduledTasks": [],
"success": true
}Alert Options â
--alert, -a â
Specify alert channel type:
# Console alerts (default)
cal run script.cal --alert console
# File alerts
cal run script.cal --alert file --alert-file ./logs/alerts.log
# JSON accumulation
cal run script.cal --alert jsonAlert Types:
console- Pretty-printed terminal output (default)file- JSON Lines log filejson- In-memory (testing)
--alert-file â
Log file path for file alerts:
cal run script.cal --alert file --alert-file ./logs/cal-alerts.logCreates JSON Lines format log:
{"timestamp":"2026-01-14T10:30:00.000Z","type":"warning","message":"High risk detected"}
{"timestamp":"2026-01-14T10:31:00.000Z","type":"critical","message":"Immediate action"}Inline Execution â
--inline, -i â
Execute CAL code directly without a file:
# Simple query
cal run --inline "FORAGE entities WHERE sound > 7 SURFACE results" --data entities.json
# Multi-line (use quotes)
cal run --inline "
FORAGE entities WHERE sound > 7 SURFACE targets
DRIFT targets METHODOLOGY 85 PERFORMANCE 40
CHIRP warning 'Gap detected'
" --data entities.jsonGood for:
- Quick tests
- Shell scripts
- One-off analysis
Exit Codes â
The CLI uses standard exit codes:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (parse, execution, validation) |
Example usage in scripts:
#!/bin/bash
if cal run analysis.cal --data entities.json --quiet; then
echo "Analysis passed"
else
echo "Analysis failed"
exit 1
fiConfiguration Files â
The CLI automatically loads configuration from:
cal.config.json.calrc.json.calrcpackage.json(in"cal"field)
See Configuration for details.
Command-line options override configuration file settings.
Environment Variables â
CAL_DATA_PATH â
Default data directory:
export CAL_DATA_PATH=./production-data
cal run script.calCAL_ALERT_FILE â
Default alert log file:
export CAL_ALERT_FILE=/var/log/cal/alerts.log
cal run script.cal --alert fileNODE_ENV â
Affects default settings:
# Development: verbose, console alerts
NODE_ENV=development cal run script.cal
# Production: quiet, file alerts
NODE_ENV=production cal run script.calExamples â
Basic Analysis â
cal run examples/simple-query.cal --data examples/data/entities.jsonCascade Analysis â
cal run examples/tailwind-cascade.cal \
--data examples/data/entities.json \
--verbose \
--output results.jsonDRIFT Analysis â
cal run examples/drift-analysis.cal \
--data examples/data/entities.json \
--alert file \
--alert-file ./logs/drift-alerts.logClosed-Loop Pipeline â
cal run examples/closed-loop-pipeline.cal \
--data examples/data/entities.json \
--output pipeline-results.jsonValidation Only â
# Validate all scripts
for script in *.cal; do
echo "Validating $script..."
cal validate "$script"
doneBatch Processing â
#!/bin/bash
# Process multiple data files
for datafile in data/*.json; do
basename=$(basename "$datafile" .json)
echo "Processing $basename..."
cal run analysis.cal \
--data "$datafile" \
--output "results/$basename-results.json" \
--quiet
if [ $? -eq 0 ]; then
echo "â
$basename complete"
else
echo "â $basename failed"
exit 1
fi
doneMonitoring Script â
#!/bin/bash
# Run analysis every hour
while true; do
timestamp=$(date +%Y%m%d-%H%M%S)
cal run monitoring.cal \
--data-path ./live-data \
--output "./reports/monitor-$timestamp.json" \
--alert file \
--alert-file "./logs/alerts-$timestamp.log" \
--quiet
echo "$(date): Analysis complete"
sleep 3600
doneTroubleshooting â
"Cannot find module" â
# Install globally
npm install -g @stratiqx/cal-runtime
# Or use npx
npx @stratiqx/cal-runtime run script.cal"Unexpected token" / Parse Error â
# Validate syntax first
cal validate script.cal
# Check for syntax errors in CAL script"No data provided" â
# Must specify data source
cal run script.cal --data entities.json
# OR
cal run script.cal --data-path ./data"Data file not found" â
# Check file exists
ls entities.json
# Use absolute path
cal run script.cal --data /full/path/to/entities.json
# Or use data-path for directory
cal run script.cal --data-path $(pwd)/dataVerbose debugging â
# See everything
cal run script.cal --verbose
# Shows:
# - Source code
# - Parsed action plan
# - Full execution results
# - Stack traces on errorsShell Completion â
Bash â
# Add to ~/.bashrc
eval "$(cal --completion bash)"Zsh â
# Add to ~/.zshrc
eval "$(cal --completion zsh)"Fish â
# Add to ~/.config/fish/config.fish
cal --completion fish | sourceScripting Tips â
Check for errors â
#!/bin/bash
set -e # Exit on any error
cal validate analysis.cal
cal run analysis.cal --data entities.json --output results.json
echo "Analysis successful"Capture output â
#!/bin/bash
# Run and capture output
output=$(cal run script.cal --data entities.json 2>&1)
exitcode=$?
if [ $exitcode -eq 0 ]; then
echo "Success: $output"
else
echo "Failed: $output"
exit 1
fiConditional execution â
#!/bin/bash
# Only run if validation passes
if cal validate analysis.cal --quiet; then
cal run analysis.cal --data entities.json
else
echo "Script validation failed"
exit 1
fiBest Practices â
1. Validate Before Running â
# Good: Validate first
cal validate script.cal && cal run script.cal --data entities.json
# Less safe: Run directly
cal run script.cal --data entities.json2. Use Quiet Mode in Scripts â
# Good for automation
cal run script.cal --quiet
# Verbose for debugging
cal run script.cal --verbose3. Save Results for Auditing â
timestamp=$(date +%Y%m%d-%H%M%S)
cal run analysis.cal \
--data entities.json \
--output "results-$timestamp.json" \
--alert file \
--alert-file "alerts-$timestamp.log"4. Use Data Paths for Organization â
# Better: Organized structure
data/
entities.json
customers.json
employees.json
cal run script.cal --data-path ./data
# Less organized: Scattered files
cal run script.cal --data ./entities.json5. Version Control Scripts â
# Track scripts in git
git add *.cal
git commit -m "Add cascade analysis scripts"
# Document usage in README
echo "cal run analysis.cal --data entities.json" >> README.mdNext Steps â
- Examples - See CLI in action
- Configuration - Configure defaults
- Getting Started - Learn CAL basics
- API Reference - TypeScript API