2026-05-11 00:45:43 -07:00
---
title: "ktx wiki"
2026-05-14 01:43:06 +02:00
description: "List or search wiki pages."
2026-05-11 00:45:43 -07:00
---
2026-05-20 17:33:38 +02:00
List and search wiki pages in your **ktx** project. Wiki pages are Markdown
2026-05-14 12:53:55 -04:00
documents that capture business definitions, rules, and gotchas. Agents search
them for context when answering questions about your data.
2026-05-11 00:45:43 -07:00
2026-05-11 16:43:08 -07:00
## Command signature
2026-05-11 00:45:43 -07:00
```bash
2026-05-20 01:52:37 +02:00
ktx wiki [options] [query...]
2026-05-11 00:45:43 -07:00
```
2026-05-20 01:52:37 +02:00
- Bare `ktx wiki` lists local wiki pages.
- `ktx wiki <query...>` searches local wiki pages (multi-word queries are
joined with a space).
2026-05-11 00:45:43 -07:00
2026-05-20 01:52:37 +02:00
Edit the Markdown files under `wiki/` directly, or ingest source content with
`ktx ingest`, when you need to add or update wiki knowledge.
2026-05-14 12:53:55 -04:00
2026-05-11 00:45:43 -07:00
## Options
| Flag | Description | Default |
|------|-------------|---------|
| `--user-id <id>` | Local user id | `local` |
2026-05-20 01:52:37 +02:00
| `--limit <number>` | Maximum search results (search mode only) | - |
2026-05-14 12:53:55 -04:00
| `--output <mode>` | Output mode: `pretty` (default in TTY), `plain` (TSV), or `json` | `pretty` |
| `--json` | Shortcut for `--output=json` (overrides `--output`) | `false` |
2026-05-11 00:45:43 -07:00
2026-05-20 01:52:37 +02:00
`ktx wiki <query>` uses hybrid search when `storage.search` is `sqlite-fts5`.
2026-05-20 17:33:38 +02:00
**ktx** combines lexical SQLite FTS5 matches, token matches, and semantic matches
2026-05-20 01:52:37 +02:00
from wiki page embeddings stored in `.ktx/db.sqlite`. If embeddings are not
2026-05-20 17:33:38 +02:00
configured or the embedding backend is unavailable, **ktx** skips the semantic lane
2026-05-17 02:32:41 +02:00
and keeps lexical and token results.
2026-05-11 00:45:43 -07:00
## Examples
```bash
# List all wiki pages
2026-05-20 01:52:37 +02:00
ktx wiki
2026-05-11 00:45:43 -07:00
2026-05-13 13:01:56 +02:00
# List all wiki pages as JSON
2026-05-20 01:52:37 +02:00
ktx wiki --json
2026-05-13 13:01:56 +02:00
2026-05-11 00:45:43 -07:00
# Search wiki pages
2026-05-20 01:52:37 +02:00
ktx wiki "monthly recurring revenue"
2026-05-11 00:45:43 -07:00
2026-05-13 13:01:56 +02:00
# Search wiki pages as JSON
2026-05-20 01:52:37 +02:00
ktx wiki "monthly recurring revenue" --json --limit 10
2026-05-14 12:53:55 -04:00
# Print search results as TSV
2026-05-20 01:52:37 +02:00
ktx wiki "monthly recurring revenue" --output plain
2026-05-17 02:32:41 +02:00
# Inspect which search lanes were used
2026-05-20 01:52:37 +02:00
ktx --debug wiki "monthly recurring revenue" --json
2026-05-11 00:45:43 -07:00
```
2026-05-11 16:43:08 -07:00
## Output
2026-05-14 12:53:55 -04:00
Wiki commands print clack-style pretty output in a TTY and TSV-style plain
output when requested. JSON output wraps the items with a command metadata
2026-05-17 02:32:41 +02:00
envelope. Search results include `matchReasons` and `lanes` metadata so you can
see whether lexical, token, or semantic search contributed to the ranking. Open
the matching Markdown files directly when you need the full page contents.
Pretty search output shows `#1`, `#2`, and later rank badges for the displayed
results. Plain and JSON output keep the raw `score` value, which is a ranking
score rather than a percentage.
2026-05-11 16:43:08 -07:00
```json
{
2026-05-13 13:01:56 +02:00
"kind": "list",
"data": {
"items": [
{
"key": "revenue-definitions",
"summary": "Canonical revenue metric definitions",
2026-05-17 02:32:41 +02:00
"score": 0.92,
"matchReasons": ["lexical", "semantic"],
"lanes": [
{
"lane": "lexical",
"status": "available",
"requestedCandidatePoolLimit": 25,
"effectiveCandidatePoolLimit": 25,
"returnedCandidateCount": 3,
"weight": 1.5
},
{
"lane": "semantic",
"status": "available",
"requestedCandidatePoolLimit": 25,
"effectiveCandidatePoolLimit": 25,
"returnedCandidateCount": 8,
"weight": 3
}
]
2026-05-13 13:01:56 +02:00
}
]
2026-05-17 02:32:41 +02:00
},
"meta": {
"command": "wiki search"
2026-05-13 13:01:56 +02:00
}
2026-05-11 16:43:08 -07:00
}
```
2026-05-20 17:33:38 +02:00
When you pass the global `--debug` flag, **ktx** writes search diagnostics to
2026-05-17 02:32:41 +02:00
stderr and leaves stdout unchanged. This is useful with `--json` because stdout
stays machine-readable:
```text
[debug] wiki search mode=sqlite-fts5 embedding=configured results=2
[debug] wiki search lane=lexical status=available returned=1 weight=1.5
[debug] wiki search lane=token status=available returned=1 weight=0.75
[debug] wiki search lane=semantic status=available returned=2 weight=3
```
2026-05-11 16:43:08 -07:00
## Common errors
| Error | Cause | Recovery |
|-------|-------|----------|
2026-05-17 02:32:41 +02:00
| Search returns no results | The query terms do not match summaries, tags, or content, and the semantic lane is unavailable or has no positive matches | Run with `--debug`, check the semantic lane status, retry with business synonyms, then create a page if the knowledge is missing |
2026-05-14 01:43:06 +02:00
| A page is missing | No Markdown file exists for that business context | Add a file under `wiki/` or run `ktx ingest <connectionId>` |