@rasmusengelbrecht/pi-semantic-query
Compile and inspect governed semantic metrics from pi coding agent
Package details
Install @rasmusengelbrecht/pi-semantic-query from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@rasmusengelbrecht/pi-semantic-query- Package
@rasmusengelbrecht/pi-semantic-query- Version
0.1.4- Published
- Jun 13, 2026
- Downloads
- not available
- Author
- engelbrechtrasmus
- License
- MIT
- Types
- extension, skill
- Size
- 19.6 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions"
],
"skills": [
"./skills"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-semantic-query
Pi extension for working with governed semantic metrics from semantic-query-compiler.
It gives pi tools to discover metrics, inspect definitions, validate a model, and compile metric requests to SQL. It does not execute warehouse queries.
Requirements
- pi coding agent
- Node/npm for installing the pi package
semantic-query-compiler >= 0.1.2installed so thesemanticCLI is onPATH- a semantic model in the project, usually
semantic.yml
Install the Python compiler first:
uv tool install 'semantic-query-compiler>=0.1.2'
semantic --version
Install in pi
From npm, after publishing:
pi install npm:@rasmusengelbrecht/pi-semantic-query
For local development:
pi install /absolute/path/to/pi-semantic-query
Or try without installing:
pi -e /absolute/path/to/pi-semantic-query
Tools
The package registers a bundled semantic-query skill plus these pi tools:
semantic_metrics— list metrics with discovery metadatasemantic_search_metrics— search metrics by id, name, description, synonyms, and teamssemantic_describe— describe one metric definitionsemantic_validate— validate a semantic modelsemantic_compile— compile a metric request to SQL
The skill teaches pi the default workflow: search before guessing metric IDs, describe ambiguous metrics, validate model changes, prefer period, and never present compiled SQL as executed results.
All tools shell out to the local semantic CLI. If target relation flags fail with unrecognized arguments, upgrade the Python CLI:
uv tool install 'semantic-query-compiler>=0.1.2' --force
By default tools look for one of:
semantic.ymlsemantic.yamlmodel.ymlmodel.yamlsemantic_layer.ymlsemantic_layer.yaml
Pass model explicitly when your file lives somewhere else.
Example prompt
List available semantic metrics in this repo, find the revenue metric, then compile revenue by country for the last 12 complete months.
The agent should:
- call
semantic_search_metrics - call
semantic_describefor the chosen metric - call
semantic_compilewith an inline request shape andperiod
Example request shape for semantic_compile:
{
"metricId": "revenue",
"period": "last 12 complete months",
"dialect": "bigquery",
"request": {
"timeGrain": "monthly",
"breakdownDimensionIds": ["country"]
}
}
For target series, pass targetTable. Use targetProject and targetSchema when the warehouse needs a qualified target relation but you want to keep the table name generic:
{
"metricId": "revenue",
"period": "current year",
"dialect": "bigquery",
"targetProject": "warehouse-project",
"targetSchema": "analytics",
"targetTable": "metric_targets",
"request": {
"timeGrain": "monthly",
"targetSeries": "budget_current"
}
}
Safety boundary
This package is compile-only by design. semantic_compile returns SQL; it does not run the SQL. Query execution touches credentials, cost, and data access, so execution should stay in the caller's existing warehouse tooling or a separate explicitly configured integration.
Publishing
npm pack --dry-run
npm publish --access public
The pi-package keyword makes the package discoverable by pi package indexes.