2026-05-11 20:55:04 -07:00
|
|
|
<h1 align="center">
|
2026-05-12 12:56:46 +02:00
|
|
|
<img src="assets/ktx-lockup.svg" alt="KTX" width="500" />
|
2026-05-11 20:55:04 -07:00
|
|
|
</h1>
|
2026-05-11 20:47:38 -07:00
|
|
|
|
2026-05-11 20:55:04 -07:00
|
|
|
<p align="center">
|
2026-05-11 23:32:10 -07:00
|
|
|
<strong>The context layer for analytics agents</strong>
|
2026-05-11 20:55:04 -07:00
|
|
|
</p>
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 20:55:04 -07:00
|
|
|
<p align="center">
|
|
|
|
|
<a href="https://www.npmjs.com/package/@kaelio/ktx"><img src="https://img.shields.io/npm/v/@kaelio/ktx?style=flat-square&color=f97316" alt="npm version" /></a>
|
2026-05-14 01:21:01 +02:00
|
|
|
<a href="https://codecov.io/gh/Kaelio/ktx"><img src="https://codecov.io/gh/Kaelio/ktx/branch/main/graph/badge.svg" alt="Codecov" /></a>
|
2026-05-11 20:55:04 -07:00
|
|
|
<a href="https://github.com/Kaelio/ktx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square" alt="License" /></a>
|
|
|
|
|
<a href="https://github.com/Kaelio/ktx"><img src="https://img.shields.io/github/stars/Kaelio/ktx?style=flat-square" alt="GitHub stars" /></a>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
KTX turns warehouse metadata, semantic definitions, and business knowledge into
|
|
|
|
|
reviewable project files that agents can use while planning, querying, and
|
|
|
|
|
updating analytics work.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-14 12:43:14 -04:00
|
|
|
A KTX project is a directory of plain files - YAML semantic sources, Markdown
|
|
|
|
|
wiki pages, and SQLite state - that you commit to git and review in PRs,
|
2026-05-11 23:32:10 -07:00
|
|
|
just like dbt models.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
## Who KTX is for
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
KTX is built for analytics engineers and data teams who want data agents to
|
2026-05-14 12:43:14 -04:00
|
|
|
work on real analytics systems - not just generate one-off SQL.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Use KTX when you want agents to:
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
- **Generate SQL** from approved measures and joins
|
|
|
|
|
- **Repair semantic definitions** through reviewable diffs
|
|
|
|
|
- **Explain metric provenance** with warehouse evidence
|
|
|
|
|
- **Work alongside** dbt, LookML, MetricFlow, Looker, Metabase, and modern BI
|
|
|
|
|
platforms
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Works with PostgreSQL, Snowflake, BigQuery, ClickHouse, MySQL, SQL Server, and
|
|
|
|
|
SQLite.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
## Quick start
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Install the CLI and run the setup wizard:
|
2026-05-11 15:50:34 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-12 12:26:19 +02:00
|
|
|
npm install @kaelio/ktx
|
2026-05-11 15:50:34 +02:00
|
|
|
npm install -g @kaelio/ktx
|
2026-05-11 23:32:10 -07:00
|
|
|
ktx setup
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
The wizard walks through six steps: configuring your LLM provider, setting up
|
|
|
|
|
embeddings, connecting your database, adding context sources (dbt, LookML,
|
|
|
|
|
Metabase, Looker, Notion), building context, and installing agent integration.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
If it exits before completion, rerun `ktx setup` to resume where you left off.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Check your project status:
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-11 23:32:10 -07:00
|
|
|
ktx status
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
2026-05-11 23:32:10 -07:00
|
|
|
KTX project: /home/user/analytics
|
|
|
|
|
Project ready: yes
|
|
|
|
|
LLM ready: yes (claude-sonnet-4-6)
|
|
|
|
|
Embeddings ready: yes (text-embedding-3-small)
|
2026-05-14 01:43:06 +02:00
|
|
|
Databases configured: yes (postgres-warehouse)
|
2026-05-11 23:32:10 -07:00
|
|
|
Context sources configured: yes (dbt-main)
|
|
|
|
|
KTX context built: yes
|
|
|
|
|
Agent integration ready: yes (claude-code:project)
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-12 12:26:19 +02:00
|
|
|
Generate SQL from a semantic-layer source:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
npx @kaelio/ktx sl query --project-dir "$PROJECT_DIR" \
|
|
|
|
|
--connection-id warehouse \
|
|
|
|
|
--measure accounts.account_count \
|
|
|
|
|
--dimension accounts.segment \
|
|
|
|
|
--format sql
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
List and test a configured warehouse connection:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
ktx connection list --project-dir "$PROJECT_DIR"
|
|
|
|
|
ktx connection test warehouse --project-dir "$PROJECT_DIR"
|
|
|
|
|
```
|
|
|
|
|
|
2026-05-14 12:53:55 -04:00
|
|
|
The connection test prints the configured driver and connector-specific status:
|
2026-05-12 12:26:19 +02:00
|
|
|
|
|
|
|
|
```text
|
2026-05-14 12:53:55 -04:00
|
|
|
Connection test passed: warehouse
|
2026-05-12 12:26:19 +02:00
|
|
|
Driver: sqlite
|
2026-05-14 12:53:55 -04:00
|
|
|
Status: ok
|
2026-05-12 12:26:19 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
## What's in a project
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
```
|
2026-05-11 23:32:10 -07:00
|
|
|
my-project/
|
|
|
|
|
├── ktx.yaml # Project configuration
|
|
|
|
|
├── semantic-layer/
|
|
|
|
|
│ └── warehouse/
|
|
|
|
|
│ ├── orders.yaml # Semantic source definitions
|
|
|
|
|
│ ├── customers.yaml
|
|
|
|
|
│ └── order_items.yaml
|
2026-05-13 16:05:58 +02:00
|
|
|
├── wiki/
|
2026-05-11 23:32:10 -07:00
|
|
|
│ ├── global/
|
|
|
|
|
│ │ ├── revenue.md # Business definitions and rules
|
|
|
|
|
│ │ └── segment-classification.md
|
|
|
|
|
│ └── user/
|
|
|
|
|
│ └── local/
|
|
|
|
|
├── raw-sources/
|
|
|
|
|
│ └── warehouse/
|
2026-05-14 01:43:06 +02:00
|
|
|
│ └── <syncId>/ # Database ingest artifacts and reports
|
2026-05-11 23:32:10 -07:00
|
|
|
└── .ktx/
|
|
|
|
|
└── db.sqlite # Local state (git-ignored)
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-13 16:05:58 +02:00
|
|
|
Semantic sources and wiki pages are committed to git. The `.ktx/` directory
|
2026-05-14 12:43:14 -04:00
|
|
|
holds ephemeral state and is git-ignored - delete it and KTX rebuilds on the
|
2026-05-11 23:32:10 -07:00
|
|
|
next run.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-14 01:43:06 +02:00
|
|
|
### Build demo warehouse context
|
2026-05-12 12:26:19 +02:00
|
|
|
|
2026-05-14 01:43:06 +02:00
|
|
|
Database ingest artifacts are written under `raw-sources/warehouse/<syncId>/`
|
|
|
|
|
in the project directory.
|
2026-05-12 12:26:19 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-14 01:43:06 +02:00
|
|
|
ktx ingest warehouse --project-dir "$PROJECT_DIR" --fast
|
2026-05-13 12:00:08 +02:00
|
|
|
ktx status --project-dir "$PROJECT_DIR"
|
2026-05-12 12:26:19 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
For non-SQLite drivers, prefer credential references such as `--url env:NAME`
|
|
|
|
|
or `--url file:PATH` over literal credential URLs.
|
|
|
|
|
|
|
|
|
|
## Managed Python runtime
|
|
|
|
|
|
|
|
|
|
KTX installs its Python runtime only when a Python-backed command needs it.
|
|
|
|
|
The runtime lives outside the npm cache, is versioned by the installed CLI
|
2026-05-12 23:51:46 +02:00
|
|
|
version, and is managed by `ktx dev runtime` commands.
|
2026-05-12 12:26:19 +02:00
|
|
|
|
|
|
|
|
KTX requires `uv` on `PATH` to create the managed runtime. Install `uv` with
|
|
|
|
|
your system package manager or the official installer before running Python-
|
|
|
|
|
backed KTX commands. KTX doesn't download `uv` automatically; run
|
2026-05-13 12:00:08 +02:00
|
|
|
`ktx dev runtime status` if runtime installation fails:
|
2026-05-12 12:26:19 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-12 23:51:46 +02:00
|
|
|
ktx dev runtime install --yes
|
|
|
|
|
ktx dev runtime status
|
|
|
|
|
ktx dev runtime start
|
|
|
|
|
ktx dev runtime stop
|
2026-05-12 12:26:19 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The release artifact manifest contains the public npm tarball and the bundled `kaelio-ktx`
|
|
|
|
|
runtime wheel. The `python/ktx-sl` and `python/ktx-daemon` directories remain
|
|
|
|
|
source packages for development, not public release artifacts.
|
|
|
|
|
|
2026-05-12 23:51:46 +02:00
|
|
|
## Use KTX with agents
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-12 23:51:46 +02:00
|
|
|
KTX integrates with coding agents through CLI skills. The setup wizard
|
|
|
|
|
configures this automatically.
|
2026-05-11 15:50:34 +02:00
|
|
|
|
2026-05-14 12:43:14 -04:00
|
|
|
**CLI skills** - the agent calls `ktx` commands directly through a skill file
|
2026-05-11 23:32:10 -07:00
|
|
|
installed in your agent's config (e.g., `.claude/skills/ktx/SKILL.md`):
|
2026-05-11 15:50:34 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-11 23:32:10 -07:00
|
|
|
ktx sl query --measure orders.revenue --dimension orders.status --format sql
|
|
|
|
|
ktx wiki search "revenue definition"
|
|
|
|
|
ktx sl validate orders
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Supported agents: Claude Code, Codex, Cursor, OpenCode, and any agent that
|
2026-05-12 23:51:46 +02:00
|
|
|
reads `.agents/` skills.
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
## Workspace packages
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
| Package | Purpose |
|
|
|
|
|
|---------|---------|
|
|
|
|
|
| `packages/cli` | CLI entry point |
|
|
|
|
|
| `packages/context` | Core context engine |
|
|
|
|
|
| `packages/llm` | LLM and embedding providers |
|
2026-05-12 12:26:19 +02:00
|
|
|
| `packages/connector-bigquery` | BigQuery scan connector |
|
|
|
|
|
| `packages/connector-clickhouse` | ClickHouse scan connector |
|
|
|
|
|
| `packages/connector-mysql` | MySQL scan connector |
|
|
|
|
|
| `packages/connector-postgres` | Postgres scan connector |
|
|
|
|
|
| `packages/connector-snowflake` | Snowflake scan connector |
|
|
|
|
|
| `packages/connector-sqlite` | SQLite scan connector |
|
|
|
|
|
| `packages/connector-sqlserver` | SQL Server scan connector |
|
2026-05-11 23:32:10 -07:00
|
|
|
| `python/ktx-sl` | Semantic-layer query planning |
|
|
|
|
|
| `python/ktx-daemon` | Portable compute service |
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-05-11 23:32:10 -07:00
|
|
|
git clone https://github.com/kaelio/ktx.git
|
|
|
|
|
cd ktx
|
2026-05-10 23:12:26 +02:00
|
|
|
pnpm install
|
2026-05-11 23:32:10 -07:00
|
|
|
uv sync --all-groups
|
|
|
|
|
pnpm run build
|
2026-05-10 23:12:26 +02:00
|
|
|
pnpm run check
|
|
|
|
|
```
|
|
|
|
|
|
2026-05-11 23:32:10 -07:00
|
|
|
Use the development CLI for local testing:
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-11 23:32:10 -07:00
|
|
|
pnpm run setup:dev
|
2026-05-10 23:12:26 +02:00
|
|
|
pnpm run link:dev
|
2026-05-10 23:51:24 +02:00
|
|
|
ktx-dev --help
|
2026-05-10 23:12:26 +02:00
|
|
|
```
|
|
|
|
|
|
2026-05-12 11:13:14 +02:00
|
|
|
### Debug LLM traces
|
|
|
|
|
|
|
|
|
|
KTX can capture local AI SDK DevTools traces for LLM calls that run through the
|
|
|
|
|
KTX provider. Enable it with an environment flag when running an LLM-backed
|
|
|
|
|
command:
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-05-14 01:43:06 +02:00
|
|
|
KTX_AI_DEVTOOLS_ENABLED=true ktx ingest warehouse --project-dir "$PROJECT_DIR" --deep
|
2026-05-12 11:13:14 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Traces are written to `.devtools/generations.json` under the current working
|
|
|
|
|
directory. To inspect them, run:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pnpm dlx @ai-sdk/devtools
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then open `http://localhost:4983`. These traces are local-development-only and
|
|
|
|
|
store prompts, model outputs, tool arguments/results, and raw provider payloads
|
|
|
|
|
in plain text. Do not enable this in production or for sensitive runs.
|
|
|
|
|
|
2026-05-10 23:12:26 +02:00
|
|
|
The repository uses `pnpm` for TypeScript packages and `uv` for Python
|
2026-05-11 23:32:10 -07:00
|
|
|
packages. See [Contributing](docs-site/content/docs/community/contributing.mdx)
|
|
|
|
|
for full development setup, testing, and PR guidelines.
|
2026-05-11 15:50:34 +02:00
|
|
|
|
2026-05-10 23:12:26 +02:00
|
|
|
## License
|
|
|
|
|
|
2026-05-10 23:51:24 +02:00
|
|
|
KTX is licensed under the Apache License, Version 2.0. See `LICENSE`.
|