Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions content/wiki/ai-assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ A common failure of generic AI tools (like ChatGPT) is hallucinating column name

When you ask the AI to "Find users who ordered in the last 30 days", Tabularis intercepts the request and builds a condensed, token-optimized snapshot of your current database structure.

The snapshot is loaded through the driver of the editor's active connection and schema. Tabularis waits for that metadata before sending the request, so a fast click on **Generate SQL** cannot race ahead with an empty schema. Up to 20 tables are included with their columns, primary-key markers, nullability, defaults, and available foreign-key relationships; the prompt notes when additional tables were omitted.

**Example Snapshot injected into the system prompt:**
```text
=== DATABASE SCHEMA ===
Expand All @@ -29,6 +31,12 @@ FK: orders.user_id -> users.id
```
By feeding this exact structural context to the LLM alongside your natural language prompt, the AI knows exactly which `JOIN` clauses to write and which data types it is dealing with.

### Plugin drivers

AI Query Assist uses the same driver registry as the rest of Tabularis, so it also works with external database plugins. Existing plugins receive automatic support through their standard `get_tables`, `get_columns`, and `get_foreign_keys` metadata methods. A plugin can optionally implement the batched `get_ai_schema_context` JSON-RPC method when its database offers a more efficient metadata query; if that method is absent, Tabularis falls back automatically.

Plugins return structured metadata only. Tabularis keeps ownership of truncation safeguards, prompt formatting, and provider dispatch, which gives built-in and external drivers the same behavior.

## Supported Providers & Local Privacy

Tabularis is provider-agnostic. Configure your preferred engine in Settings:
Expand Down
2 changes: 2 additions & 0 deletions content/wiki/building-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Handlers you fill in first → features that light up:
5. `insert_record` / `update_record` / `delete_record` — inline row editing in the data grid.
6. `get_create_table_sql` and friends — SQL preview for DDL operations.

Once `get_tables` and `get_columns` work, the driver also supplies schema context to **AI Query Assist** automatically. For databases that can fetch the first tables, columns, and foreign keys more efficiently in one operation, optionally add `get_ai_schema_context`; returning `-32601` keeps the host's standard metadata fallback. The plugin returns structured metadata, while Tabularis formats and sends the AI prompt.

Every step is independently shippable. A plugin with only the first three is already useful as a read-only viewer.

## UI extensions
Expand Down
21 changes: 21 additions & 0 deletions content/wiki/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,27 @@ Your plugin runs a continuous read loop on `stdin`. For each line received, pars

The `params.params` object (a `ConnectionParams`) contains the values the user entered in the connection form. Additional fields at the top level of `params` are method-specific (e.g. `schema`, `table`, `query`).

### Optional AI schema context

External drivers automatically participate in **AI Query Assist** when they implement the standard `get_tables`, `get_columns`, and `get_foreign_keys` metadata methods. The host limits the selected tables and builds the final system prompt, so plugins do not need to know which AI provider the user configured.

Drivers with an efficient batch metadata API can additionally implement `get_ai_schema_context`:

```json
{
"jsonrpc": "2.0",
"id": 12,
"method": "get_ai_schema_context",
"params": {
"params": { "driver": "my-driver", "database": "app" },
"schema": "public",
"max_tables": 20
}
}
```

Return a result shaped as `{ "tables": [{ "name", "columns", "foreign_keys" }], "total_table_count": 42 }`. Respect `max_tables` while reporting the pre-limit count in `total_table_count`. If the method is not implemented, return `-32601`; Tabularis automatically falls back to the standard metadata calls, keeping existing plugins compatible.

### Successful response

```json
Expand Down