@carllee1983/dbcli 0.1.0 → 0.3.0-beta
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/CHANGELOG.md +41 -5
- package/README.md +161 -8
- package/README.zh-TW.md +530 -0
- package/dist/cli.mjs +27630 -450
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,48 @@ All notable changes to dbcli are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.2.0-beta] - 2026-03-26
|
|
9
|
+
|
|
10
|
+
### Data Access Control — Blacklist System
|
|
11
|
+
|
|
12
|
+
Added table and column-level blacklisting to protect sensitive data from AI agent access.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`dbcli blacklist` command suite:** Manage blacklist rules via CLI
|
|
17
|
+
- `blacklist list` — display current blacklist configuration
|
|
18
|
+
- `blacklist table add/remove <table>` — manage table-level blacklist
|
|
19
|
+
- `blacklist column add/remove <table>.<column>` — manage column-level blacklist
|
|
20
|
+
- **Table-level blacklisting:** Reject all operations (query, insert, update, delete) on blacklisted tables
|
|
21
|
+
- **Column-level blacklisting:** Automatically omit blacklisted columns from SELECT results
|
|
22
|
+
- **Security notifications:** Footer in table/CSV/JSON output when columns are filtered (e.g., "Security: 2 column(s) were omitted based on your blacklist")
|
|
23
|
+
- **Context-aware override:** `DBCLI_OVERRIDE_BLACKLIST=true` environment variable for temporary bypass with warning
|
|
24
|
+
- **i18n support:** Blacklist messages in English and Traditional Chinese
|
|
25
|
+
- **Performance:** < 1ms overhead per query (O(1) Set/Map lookups)
|
|
26
|
+
- **103 new tests:** 83 core + 12 CLI wiring + 8 formatter security tests
|
|
27
|
+
- **`dbcli schema --reset`:** Clear all existing schema data and re-fetch from database — solves stale schema after switching DB connections
|
|
28
|
+
|
|
29
|
+
### Configuration
|
|
30
|
+
|
|
31
|
+
Blacklist rules stored in `.dbcli`:
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"blacklist": {
|
|
35
|
+
"tables": ["audit_logs", "secrets_vault"],
|
|
36
|
+
"columns": {
|
|
37
|
+
"users": ["password_hash", "ssn"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## [0.1.0-beta] - 2026-03-26
|
|
9
46
|
|
|
10
47
|
### Initial Release - AI-Ready Database CLI
|
|
11
48
|
|
|
12
|
-
dbcli
|
|
49
|
+
dbcli v0.1.0-beta is a complete, production-ready CLI tool enabling AI agents and developers to safely interact with PostgreSQL, MySQL, and MariaDB databases through a permission-controlled interface.
|
|
13
50
|
|
|
14
51
|
**Key Achievement:** Single command-line tool bridging AI agents (Claude Code, Gemini, Copilot, Cursor) to database access without requiring multiple MPC integrations.
|
|
15
52
|
|
|
@@ -176,9 +213,8 @@ dbcli v1.0.0 is a complete, production-ready CLI tool enabling AI agents and dev
|
|
|
176
213
|
|
|
177
214
|
## Known Limitations (V1)
|
|
178
215
|
|
|
179
|
-
- **Single database per project:** Multi-connection support deferred to
|
|
180
|
-
- **
|
|
181
|
-
- **No audit logging:** WHO/WHAT/WHEN tracking deferred to V1.1
|
|
216
|
+
- **Single database per project:** Multi-connection support deferred to a future version
|
|
217
|
+
- **No audit logging:** WHO/WHAT/WHEN tracking deferred to a future version
|
|
182
218
|
- **Read-only schema:** No schema modification commands (ALTER TABLE, etc.) in V1
|
|
183
219
|
- **CLI-only:** No visual schema designer, REPL, or interactive shell in V1
|
|
184
220
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
# dbcli — Database CLI for AI Agents
|
|
2
2
|
|
|
3
|
+
**Languages:** [English](./README.md) | [繁體中文](./README.zh-TW.md)
|
|
4
|
+
|
|
3
5
|
A unified database CLI tool that enables AI agents (Claude Code, Gemini, Copilot, Cursor) to safely query, discover, and operate on databases.
|
|
4
6
|
|
|
5
|
-
**Core Value:** AI agents can safely and intelligently access project databases through a single, permission-controlled CLI tool.
|
|
7
|
+
**Core Value:** AI agents can safely and intelligently access project databases through a single, permission-controlled CLI tool with sensitive data protection.
|
|
8
|
+
|
|
9
|
+
## Internationalization (i18n)
|
|
10
|
+
|
|
11
|
+
dbcli supports multiple languages via the `DBCLI_LANG` environment variable:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# English (default)
|
|
15
|
+
dbcli init
|
|
16
|
+
|
|
17
|
+
# Traditional Chinese
|
|
18
|
+
DBCLI_LANG=zh-TW dbcli init
|
|
19
|
+
|
|
20
|
+
# Or set in .env
|
|
21
|
+
export DBCLI_LANG=zh-TW
|
|
22
|
+
dbcli init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Supported languages:**
|
|
26
|
+
- `en` — English (default)
|
|
27
|
+
- `zh-TW` — Traditional Chinese (Taiwan)
|
|
28
|
+
|
|
29
|
+
All messages, help text, error messages, and command output respond to the language setting automatically.
|
|
30
|
+
|
|
6
31
|
|
|
7
32
|
## Quick Start
|
|
8
33
|
|
|
@@ -124,8 +149,9 @@ dbcli schema users # Show structure of 'users' table
|
|
|
124
149
|
|
|
125
150
|
**Options:**
|
|
126
151
|
- `--format json` — Output as JSON
|
|
127
|
-
- `--refresh` — Detect and update schema changes (requires --force for approval)
|
|
128
|
-
- `--
|
|
152
|
+
- `--refresh` — Detect and update schema changes incrementally (requires --force for approval)
|
|
153
|
+
- `--reset` — Clear all existing schema data and re-fetch from database (useful after switching DB connections)
|
|
154
|
+
- `--force` — Skip confirmation for schema refresh/overwrite/reset
|
|
129
155
|
|
|
130
156
|
**Examples:**
|
|
131
157
|
```bash
|
|
@@ -135,12 +161,12 @@ dbcli schema users
|
|
|
135
161
|
# JSON output with full metadata
|
|
136
162
|
dbcli schema users --format json
|
|
137
163
|
|
|
138
|
-
# Update schema with new tables
|
|
139
|
-
dbcli schema --refresh
|
|
140
|
-
|
|
141
|
-
# Auto-approve schema refresh
|
|
164
|
+
# Update schema with new tables (incremental)
|
|
142
165
|
dbcli schema --refresh --force
|
|
143
166
|
|
|
167
|
+
# Clear and re-fetch all schema (after switching DB)
|
|
168
|
+
dbcli schema --reset --force
|
|
169
|
+
|
|
144
170
|
# Scan entire database
|
|
145
171
|
dbcli schema
|
|
146
172
|
```
|
|
@@ -352,9 +378,63 @@ dbcli skill --install cursor
|
|
|
352
378
|
|
|
353
379
|
---
|
|
354
380
|
|
|
381
|
+
#### `dbcli blacklist`
|
|
382
|
+
|
|
383
|
+
Manage the data access blacklist to block AI agents from accessing sensitive tables or columns.
|
|
384
|
+
|
|
385
|
+
**Usage:**
|
|
386
|
+
```bash
|
|
387
|
+
dbcli blacklist list
|
|
388
|
+
dbcli blacklist table add <table>
|
|
389
|
+
dbcli blacklist table remove <table>
|
|
390
|
+
dbcli blacklist column add <table>.<column>
|
|
391
|
+
dbcli blacklist column remove <table>.<column>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Subcommands:**
|
|
395
|
+
|
|
396
|
+
| Subcommand | Description |
|
|
397
|
+
|------------|-------------|
|
|
398
|
+
| `dbcli blacklist list` | Show current blacklist (tables and columns) |
|
|
399
|
+
| `dbcli blacklist table add <table>` | Add table to blacklist (blocks all operations) |
|
|
400
|
+
| `dbcli blacklist table remove <table>` | Remove table from blacklist |
|
|
401
|
+
| `dbcli blacklist column add <table>.<column>` | Add column to blacklist (omitted from SELECT results) |
|
|
402
|
+
| `dbcli blacklist column remove <table>.<column>` | Remove column from blacklist |
|
|
403
|
+
|
|
404
|
+
**Behavior:**
|
|
405
|
+
- Table blacklist blocks all operations on that table (query, insert, update, delete)
|
|
406
|
+
- Column blacklist silently omits columns from SELECT results and shows a security notification
|
|
407
|
+
- Blacklist rules are stored in `.dbcli` and apply to all permission levels
|
|
408
|
+
- Override for admin use via `DBCLI_OVERRIDE_BLACKLIST=true` environment variable
|
|
409
|
+
|
|
410
|
+
**Examples:**
|
|
411
|
+
```bash
|
|
412
|
+
# View current blacklist
|
|
413
|
+
dbcli blacklist list
|
|
414
|
+
|
|
415
|
+
# Block all access to sensitive tables
|
|
416
|
+
dbcli blacklist table add audit_logs
|
|
417
|
+
dbcli blacklist table add secrets_vault
|
|
418
|
+
|
|
419
|
+
# Hide sensitive columns from query results
|
|
420
|
+
dbcli blacklist column add users.password_hash
|
|
421
|
+
dbcli blacklist column add users.ssn
|
|
422
|
+
|
|
423
|
+
# Remove a table from blacklist
|
|
424
|
+
dbcli blacklist table remove audit_logs
|
|
425
|
+
|
|
426
|
+
# Remove a column from blacklist
|
|
427
|
+
dbcli blacklist column remove users.ssn
|
|
428
|
+
|
|
429
|
+
# Override blacklist (admin use only)
|
|
430
|
+
DBCLI_OVERRIDE_BLACKLIST=true dbcli query "SELECT * FROM secrets_vault"
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
355
435
|
## Permission Model
|
|
356
436
|
|
|
357
|
-
dbcli implements a coarse-grained permission system with three levels. Permission level is set during `dbcli init` and stored in `.dbcli` config file.
|
|
437
|
+
dbcli implements a coarse-grained permission system with three levels. Permission level is set during `dbcli init` and stored in `.dbcli` config file. The blacklist system works alongside permissions to provide fine-grained protection for sensitive tables and columns (see [Data Access Control](#data-access-control)).
|
|
358
438
|
|
|
359
439
|
### Permission Levels
|
|
360
440
|
|
|
@@ -417,6 +497,79 @@ dbcli delete users --where "id=1" --force # Only Admin can delete
|
|
|
417
497
|
|
|
418
498
|
---
|
|
419
499
|
|
|
500
|
+
## Data Access Control
|
|
501
|
+
|
|
502
|
+
dbcli provides a blacklist system that works alongside the permission model to prevent AI agents from accessing sensitive tables or columns, regardless of their permission level.
|
|
503
|
+
|
|
504
|
+
### Table-Level Blacklist
|
|
505
|
+
|
|
506
|
+
Blocking a table prevents all operations on it — queries, inserts, updates, and deletes are all refused with a clear error message.
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
# Block a table
|
|
510
|
+
dbcli blacklist table add secrets_vault
|
|
511
|
+
|
|
512
|
+
# Attempting access is blocked at all permission levels
|
|
513
|
+
dbcli query "SELECT * FROM secrets_vault"
|
|
514
|
+
# ERROR: Table 'secrets_vault' is blacklisted
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Column-Level Blacklist
|
|
518
|
+
|
|
519
|
+
Blacklisted columns are silently omitted from SELECT results. A security notification is shown in the output so the agent is aware that the result set has been filtered.
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
# Blacklist sensitive columns
|
|
523
|
+
dbcli blacklist column add users.password_hash
|
|
524
|
+
dbcli blacklist column add users.ssn
|
|
525
|
+
|
|
526
|
+
# Query returns all other columns; notification shown
|
|
527
|
+
dbcli query "SELECT * FROM users"
|
|
528
|
+
# [Security] Columns omitted by blacklist: password_hash, ssn
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Security Notifications
|
|
532
|
+
|
|
533
|
+
Whenever a blacklist rule filters query output, dbcli appends a notification line to the result. This ensures AI agents do not silently operate on incomplete data without awareness.
|
|
534
|
+
|
|
535
|
+
### Override via Environment Variable
|
|
536
|
+
|
|
537
|
+
Administrators can bypass the blacklist for emergency or maintenance operations using the `DBCLI_OVERRIDE_BLACKLIST=true` environment variable:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
DBCLI_OVERRIDE_BLACKLIST=true dbcli query "SELECT * FROM secrets_vault"
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
This override is logged and should only be used by administrators when necessary.
|
|
544
|
+
|
|
545
|
+
### Blacklist Configuration
|
|
546
|
+
|
|
547
|
+
Blacklist rules are stored in the `.dbcli` config file and can also be set manually:
|
|
548
|
+
|
|
549
|
+
```json
|
|
550
|
+
{
|
|
551
|
+
"blacklist": {
|
|
552
|
+
"tables": ["audit_logs", "secrets_vault"],
|
|
553
|
+
"columns": {
|
|
554
|
+
"users": ["password_hash", "ssn"]
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### Blacklist vs. Permissions
|
|
561
|
+
|
|
562
|
+
The blacklist and permission model are complementary layers of access control:
|
|
563
|
+
|
|
564
|
+
| Layer | Controls | Applies To |
|
|
565
|
+
|-------|----------|------------|
|
|
566
|
+
| **Permission Model** | Operation type (read/write/delete) | All tables |
|
|
567
|
+
| **Blacklist** | Specific tables and columns | Targeted sensitive data |
|
|
568
|
+
|
|
569
|
+
A Query-only agent cannot write to any table, and also cannot read blacklisted tables or columns — both restrictions apply simultaneously.
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
420
573
|
## AI Integration Guide
|
|
421
574
|
|
|
422
575
|
dbcli generates AI-consumable skill documentation and can be integrated into your favorite AI development tools.
|