sandal-db 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/dist/cli.js +1091 -107
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -121,6 +121,7 @@ npx sandal-db@latest config --path
|
|
|
121
121
|
```text
|
|
122
122
|
npx sandal-db@latest [options] [dbUrl]
|
|
123
123
|
npx sandal-db@latest config [options]
|
|
124
|
+
npx sandal-db@latest md [options] [fileOrText]
|
|
124
125
|
```
|
|
125
126
|
|
|
126
127
|
### Global Options
|
|
@@ -135,6 +136,8 @@ npx sandal-db@latest config [options]
|
|
|
135
136
|
| `--no-strict` | `flag` | Disables strict safety mode. | `false` |
|
|
136
137
|
| `--allow-full-wipe` | `flag` | Explicitly permits database-level drops after interactive phrase confirmation. | `false` |
|
|
137
138
|
| `--threshold <number>` | `integer` | Row count threshold above which updates are classified as dangerous operations. | `50` |
|
|
139
|
+
| `--markdown` | `boolean` | Formats and renders LLM responses as rich terminal markdown. | `true` |
|
|
140
|
+
| `--no-markdown` | `flag` | Disables terminal markdown rendering and outputs raw text. | `false` |
|
|
138
141
|
| `-V, --version` | `flag` | Output the version number. | |
|
|
139
142
|
| `-h, --help` | `flag` | Display command help and exit. | |
|
|
140
143
|
|
|
@@ -164,6 +167,16 @@ Dot commands provide direct utility functions without issuing requests to the LL
|
|
|
164
167
|
| --------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
165
168
|
| `.tables` or `.collections` | Lists all discovered database tables or MongoDB collections with current row counts. |
|
|
166
169
|
| `.schema [name]` | Displays column names, data types, nullability constraints, and primary keys for the specified table. |
|
|
170
|
+
| `.connect` or `.switch` | Shows saved database connections; select by number or enter a new URL (preserves chat memory). |
|
|
171
|
+
| `.model [name]` | Displays current model or switches to a new model on the fly. |
|
|
172
|
+
| `.provider [name]` | Switches active LLM provider (`google`, `openai`, or `anthropic`). |
|
|
173
|
+
| `.key [remove \| set]` | Displays active API key, removes it from config, or updates it live. |
|
|
174
|
+
| `.chats` | Lists all saved chat sessions with message counts and last active times. |
|
|
175
|
+
| `.chat <id \| number>` | Switches to a specific chat session and restores its conversation memory. |
|
|
176
|
+
| `.new` | Starts a fresh chat session with clean memory. |
|
|
177
|
+
| `.history` | Displays full conversation turn history for the active chat session. |
|
|
178
|
+
| `.clear-chat` | Clears message history for the current chat session. |
|
|
179
|
+
| `.md [file\|text]` | Renders markdown file or inline markdown text with syntax highlighting directly in the terminal. |
|
|
167
180
|
| `.refresh` | Invalidates cached schema metadata and re-introspects the live database. |
|
|
168
181
|
| `.clear` | Clears the terminal screen. |
|
|
169
182
|
| `.help` | Prints the interactive command reference and sample queries. |
|
|
@@ -200,6 +213,102 @@ sandal [postgres]> Update users set status = 'dormant' where last_active_at < '2
|
|
|
200
213
|
sandal [mongodb]> Delete error log documents created more than 90 days ago.
|
|
201
214
|
```
|
|
202
215
|
|
|
216
|
+
#### Terminal Markdown Rendering
|
|
217
|
+
|
|
218
|
+
SANDAL automatically parses and renders LLM answers with syntax-highlighted code blocks, formatted Unicode tables, bullet points, headers, and styled text directly inside your terminal:
|
|
219
|
+
|
|
220
|
+
```text
|
|
221
|
+
sandal [postgres]> Show top customers and give me an analysis.
|
|
222
|
+
🤖 Answer:
|
|
223
|
+
# Customer Insights
|
|
224
|
+
|
|
225
|
+
Here is the breakdown of top revenue generators:
|
|
226
|
+
|
|
227
|
+
┌─────────────────┬──────────┬──────────────┐
|
|
228
|
+
│ Customer Name │ Orders │ Total Spent │
|
|
229
|
+
├─────────────────┼──────────┼──────────────┤
|
|
230
|
+
│ Acme Corp │ 34 │ $48,250.00 │
|
|
231
|
+
│ Initech LLC │ 28 │ $36,120.00 │
|
|
232
|
+
└─────────────────┴──────────┴──────────────┘
|
|
233
|
+
|
|
234
|
+
Key Findings:
|
|
235
|
+
* **Acme Corp** is the highest-value account with 34 completed orders.
|
|
236
|
+
* Recommended index for faster queries:
|
|
237
|
+
CREATE INDEX CONCURRENTLY idx_orders_customer ON orders(customer_id);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
You can also view or render any markdown file or snippet directly from the command line:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Render a markdown file in the terminal
|
|
244
|
+
npx sandal-db md README.md
|
|
245
|
+
|
|
246
|
+
# Pipe markdown from standard input
|
|
247
|
+
echo "# Hello Terminal" | npx sandal-db md
|
|
248
|
+
|
|
249
|
+
# Disable markdown rendering if plain text is desired
|
|
250
|
+
npx sandal-db --no-markdown postgresql://...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Connection History and Database Switching
|
|
254
|
+
|
|
255
|
+
SANDAL tracks your previous database connections automatically in `~/.sandal/config.json`. Inside the interactive REPL, switch databases at any time without restarting your session:
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
sandal [postgres]> .connect
|
|
259
|
+
|
|
260
|
+
Database Connections:
|
|
261
|
+
[1] postgresql://postgres:***@localhost:5432/analytics (Current)
|
|
262
|
+
[2] mongodb://app_user:***@cluster0.mongodb.net/production
|
|
263
|
+
[N] Enter a new connection URL
|
|
264
|
+
[C] Cancel
|
|
265
|
+
|
|
266
|
+
Select a connection [number, N, C]: 2
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
When you switch databases, your **conversation history and chat memory are preserved**, allowing you to continue querying or comparing insights across databases.
|
|
270
|
+
|
|
271
|
+
From the command line:
|
|
272
|
+
```bash
|
|
273
|
+
# List all saved database connections
|
|
274
|
+
npx sandal-db config --connections
|
|
275
|
+
|
|
276
|
+
# Remove a connection from saved history
|
|
277
|
+
npx sandal-db config --remove-connection 2
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Changing Models, Providers, and API Keys Live
|
|
281
|
+
|
|
282
|
+
Modify your AI configuration during an active session:
|
|
283
|
+
|
|
284
|
+
- `.model` — View recommended models for your provider (e.g. `gemini-2.5-flash`, `gpt-4o`, `claude-3-5-sonnet-latest`) or type a custom model name.
|
|
285
|
+
- `.provider` — Switch between Google Gemini, OpenAI, and Anthropic Claude.
|
|
286
|
+
- `.key` — View masked key information.
|
|
287
|
+
- `.key remove` — Remove the stored API key for the current provider from `~/.sandal/config.json`.
|
|
288
|
+
- `.key set <new-key>` — Update your API key dynamically.
|
|
289
|
+
|
|
290
|
+
From the command line:
|
|
291
|
+
```bash
|
|
292
|
+
# Remove stored API key for a specific provider
|
|
293
|
+
npx sandal-db config --remove-key google
|
|
294
|
+
|
|
295
|
+
# Remove all stored API keys
|
|
296
|
+
npx sandal-db config --remove-key all
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### Per-Chat Memory and Multi-Turn Sessions
|
|
300
|
+
|
|
301
|
+
SANDAL provides persistent multi-turn chat memory stored per chat session in `~/.sandal/chats/`:
|
|
302
|
+
|
|
303
|
+
- **Multi-Turn Context**: Resolves follow-up queries and pronouns (e.g., `"Show top customers"` followed by `"Now count how many of them are active"`).
|
|
304
|
+
- **Query Memory**: Remembers previous queries and schema references within the chat session.
|
|
305
|
+
- **Session Management**:
|
|
306
|
+
- `.chats` — Displays all saved chat sessions with message counts, titles, and dates.
|
|
307
|
+
- `.chat <id|num>` — Switches to an existing chat session and reloads its memory.
|
|
308
|
+
- `.new` — Starts a brand new chat session with clean memory.
|
|
309
|
+
- `.history` — Reviews the conversation history of the current chat.
|
|
310
|
+
- `.clear-chat` — Clears message memory for the current session.
|
|
311
|
+
|
|
203
312
|
---
|
|
204
313
|
|
|
205
314
|
## Safety and Guardrail Architecture
|