Command Line Usage
Query Command Overview
Mantis provides two powerful approaches to querying your infrastructure configurations:
- Natural language queries for intuitive exploration
- CUE query configurations for precise, repeatable queries
Basic Query Syntax
Natural Language Queries
mantis query \
-S ./prompts/cquery.txt \
-C ./config \
-q "Show me all services with more than 3 replicas" \
-i ~/.mantis/index/mantis-index.json
CUE Configuration Queries
mantis query \
-S ./prompts/cquery.txt \
-C ./config \
-c ./queries/replicas.cue
Required Parameters
Parameter | Flag | Description |
---|---|---|
System Prompt | -S, --system-prompt | Path to system prompt file |
Code Directory | -C, --code-dir | Directory containing CUE configurations |
Query String | -q, --query | Natural language query (when using NL mode) |
Index Path | -i, --index | Path to query index file (required with -q) |
Query Config | -c, --query-config | Path to CUE query configuration file |
Query Configuration Files
When using CUE configuration files (-c
option), create structured queries:
// queries/replicas.cue
{
from: "service[string]"
select: [
"name",
"replicas"
]
where: {
"replicas": "^[4-9]|[1-9][0-9]+$" // Match 4 or more replicas
}
}
Natural Language Query Examples
# Resource Analysis
mantis query -q "What is the total number of replicas across services"
# Service Discovery
mantis query -q "Show me all frontend services"
# Resource Optimization
mantis query -q "Find services with high CPU limits"
Index Management
Building the Index
# Basic indexing
mantis index --code-dir ./configs
# Custom index location
mantis index --code-dir ./configs --index-dir /path/to/index
# With custom system prompt
mantis index --code-dir ./configs --system-prompt ./prompts/index.txt
Index Parameters
Parameter | Flag | Description | Default |
---|---|---|---|
Code Directory | -C, --code-dir | Source directory for CUE files | Required |
System Prompt | -S, --system-prompt | AI prompt file path | Optional |
Index Directory | -i, --index-dir | Index storage location | ~/.mantis/index |
Index Features
The generated index provides:
- Query Templates: Pre-built queries for common scenarios
- Path Optimization: Pre-computed paths for faster queries
- AI Suggestions: Context-aware query recommendations
Best Practices
-
Index Management
- Regularly update your index as configurations change
- Use custom system prompts for specialized queries
- Store indexes in version control for team sharing
-
Query Organization
- Create reusable query configurations for common tasks
- Document complex queries with comments
- Use natural language for exploratory queries