sqlew 4.0.5 → 4.1.1
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 +1817 -1782
- package/README.md +409 -468
- package/assets/claude-md-snippets/plan-mode-integration.md +17 -6
- package/assets/config.example.toml +282 -284
- package/assets/sample-agents/README.md +36 -40
- package/assets/sample-agents/sqlew-architect.md +321 -322
- package/assets/sample-agents/sqlew-researcher.md +292 -293
- package/assets/sample-agents/sqlew-scrum-master.md +286 -287
- package/assets/sample-commands/README.md +56 -57
- package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +33 -26
- package/dist/cli/hooks/check-completion.d.ts +19 -0
- package/dist/cli/hooks/check-completion.d.ts.map +1 -0
- package/dist/cli/hooks/check-completion.js +104 -0
- package/dist/cli/hooks/check-completion.js.map +1 -0
- package/dist/cli/hooks/init-hooks.d.ts +35 -0
- package/dist/cli/hooks/init-hooks.d.ts.map +1 -0
- package/dist/cli/hooks/init-hooks.js +425 -0
- package/dist/cli/hooks/init-hooks.js.map +1 -0
- package/dist/cli/hooks/mark-done.d.ts +25 -0
- package/dist/cli/hooks/mark-done.d.ts.map +1 -0
- package/dist/cli/hooks/mark-done.js +128 -0
- package/dist/cli/hooks/mark-done.js.map +1 -0
- package/dist/cli/hooks/plan-id-utils.d.ts +83 -0
- package/dist/cli/hooks/plan-id-utils.d.ts.map +1 -0
- package/dist/cli/hooks/plan-id-utils.js +183 -0
- package/dist/cli/hooks/plan-id-utils.js.map +1 -0
- package/dist/cli/hooks/save.d.ts +23 -0
- package/dist/cli/hooks/save.d.ts.map +1 -0
- package/dist/cli/hooks/save.js +90 -0
- package/dist/cli/hooks/save.js.map +1 -0
- package/dist/cli/hooks/stdin-parser.d.ts +139 -0
- package/dist/cli/hooks/stdin-parser.d.ts.map +1 -0
- package/dist/cli/hooks/stdin-parser.js +127 -0
- package/dist/cli/hooks/stdin-parser.js.map +1 -0
- package/dist/cli/hooks/suggest.d.ts +19 -0
- package/dist/cli/hooks/suggest.d.ts.map +1 -0
- package/dist/cli/hooks/suggest.js +157 -0
- package/dist/cli/hooks/suggest.js.map +1 -0
- package/dist/cli/hooks/track-plan.d.ts +36 -0
- package/dist/cli/hooks/track-plan.d.ts.map +1 -0
- package/dist/cli/hooks/track-plan.js +152 -0
- package/dist/cli/hooks/track-plan.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -16
- package/dist/cli.js.map +1 -1
- package/dist/config/global-config.d.ts +187 -0
- package/dist/config/global-config.d.ts.map +1 -0
- package/dist/config/global-config.js +206 -0
- package/dist/config/global-config.js.map +1 -0
- package/dist/config/loader.d.ts +42 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +96 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -1
- package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +59 -59
- package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js.map +1 -1
- package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js +33 -33
- package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js.map +1 -1
- package/dist/database/migrations/v4/20251127000000_add_rejected_status.js +7 -7
- package/dist/database/migrations/v4/20251127000000_add_rejected_status.js.map +1 -1
- package/dist/database/migrations/v4/20251127000001_update_task_move_help.js +11 -11
- package/dist/database/migrations/v4/20251127000001_update_task_move_help.js.map +1 -1
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js +10 -10
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js.map +1 -1
- package/dist/database/migrations/v4/20251127000003_add_task_notes_column.js +7 -7
- package/dist/database/migrations/v4/20251127000003_add_task_notes_column.js.map +1 -1
- package/dist/database/migrations/v4/20251128000000_drop_all_views.js +8 -8
- package/dist/database/migrations/v4/20251128000000_drop_all_views.js.map +1 -1
- package/dist/database/operations/queries.d.ts.map +1 -1
- package/dist/database/operations/queries.js +11 -2
- package/dist/database/operations/queries.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/init-agents.js +0 -1
- package/dist/init-agents.js.map +1 -1
- package/dist/init-skills.d.ts +4 -3
- package/dist/init-skills.d.ts.map +1 -1
- package/dist/init-skills.js +10 -3
- package/dist/init-skills.js.map +1 -1
- package/dist/server/setup.d.ts +8 -0
- package/dist/server/setup.d.ts.map +1 -1
- package/dist/server/setup.js +141 -21
- package/dist/server/setup.js.map +1 -1
- package/dist/sync-agents.d.ts.map +1 -1
- package/dist/sync-agents.js +48 -3
- package/dist/sync-agents.js.map +1 -1
- package/dist/sync-commands.d.ts.map +1 -1
- package/dist/sync-commands.js +43 -3
- package/dist/sync-commands.js.map +1 -1
- package/dist/tools/constraints/actions/get.d.ts.map +1 -1
- package/dist/tools/constraints/actions/get.js +5 -8
- package/dist/tools/constraints/actions/get.js.map +1 -1
- package/dist/tools/constraints/help/help.d.ts.map +1 -1
- package/dist/tools/constraints/help/help.js +1 -6
- package/dist/tools/constraints/help/help.js.map +1 -1
- package/dist/tools/context/actions/get.d.ts.map +1 -1
- package/dist/tools/context/actions/get.js.map +1 -1
- package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
- package/dist/tools/context/actions/search-layer.js +5 -3
- package/dist/tools/context/actions/search-layer.js.map +1 -1
- package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
- package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
- package/dist/tools/context/actions/set-from-policy.js.map +1 -1
- package/dist/tools/context/help/help.d.ts.map +1 -1
- package/dist/tools/context/help/help.js +1 -7
- package/dist/tools/context/help/help.js.map +1 -1
- package/dist/tools/context/internal/queries.d.ts.map +1 -1
- package/dist/tools/context/internal/queries.js +5 -2
- package/dist/tools/context/internal/queries.js.map +1 -1
- package/dist/tools/context/types.d.ts +1 -1
- package/dist/tools/context/types.d.ts.map +1 -1
- package/dist/tools/files/actions/get.d.ts.map +1 -1
- package/dist/tools/files/actions/get.js +4 -6
- package/dist/tools/files/actions/get.js.map +1 -1
- package/dist/tools/files/help/help.d.ts.map +1 -1
- package/dist/tools/files/help/help.js +1 -6
- package/dist/tools/files/help/help.js.map +1 -1
- package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
- package/dist/tools/suggest/help/constraint-help.js +0 -2
- package/dist/tools/suggest/help/constraint-help.js.map +1 -1
- package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
- package/dist/tools/suggest/internal/constraint-queries.js +12 -5
- package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
- package/dist/tools/suggest/internal/queries.js +2 -2
- package/dist/tools/suggest/internal/queries.js.map +1 -1
- package/dist/tools/tasks/help/help.d.ts.map +1 -1
- package/dist/tools/tasks/help/help.js +0 -6
- package/dist/tools/tasks/help/help.js.map +1 -1
- package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
- package/dist/tools/tasks/help/use-case.js +0 -1
- package/dist/tools/tasks/help/use-case.js.map +1 -1
- package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
- package/dist/tools/tasks/watcher/status.js +5 -1
- package/dist/tools/tasks/watcher/status.js.map +1 -1
- package/dist/types/decision/params.d.ts +7 -6
- package/dist/types/decision/params.d.ts.map +1 -1
- package/dist/types/decision/templates.d.ts +3 -2
- package/dist/types/decision/templates.d.ts.map +1 -1
- package/dist/types/view-entities.d.ts +2 -1
- package/dist/types/view-entities.d.ts.map +1 -1
- package/dist/types.d.ts +19 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/enum-converter.d.ts +72 -0
- package/dist/utils/enum-converter.d.ts.map +1 -0
- package/dist/utils/enum-converter.js +76 -0
- package/dist/utils/enum-converter.js.map +1 -0
- package/dist/utils/hook-queue.d.ts +81 -0
- package/dist/utils/hook-queue.d.ts.map +1 -0
- package/dist/utils/hook-queue.js +156 -0
- package/dist/utils/hook-queue.js.map +1 -0
- package/dist/utils/project-root.d.ts +9 -2
- package/dist/utils/project-root.d.ts.map +1 -1
- package/dist/utils/project-root.js +16 -2
- package/dist/utils/project-root.js.map +1 -1
- package/dist/utils/tag-parser.d.ts.map +1 -1
- package/dist/utils/tag-parser.js +6 -0
- package/dist/utils/tag-parser.js.map +1 -1
- package/dist/utils/universal-knex.js +3 -3
- package/dist/utils/universal-knex.js.map +1 -1
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.d.ts.map +1 -1
- package/dist/utils/validators.js +1 -1
- package/dist/utils/validators.js.map +1 -1
- package/dist/utils/vcs-adapter.d.ts +44 -0
- package/dist/utils/vcs-adapter.d.ts.map +1 -1
- package/dist/utils/vcs-adapter.js +88 -0
- package/dist/utils/vcs-adapter.js.map +1 -1
- package/dist/utils/view-queries.d.ts.map +1 -1
- package/dist/utils/view-queries.js +9 -19
- package/dist/utils/view-queries.js.map +1 -1
- package/dist/watcher/base-watcher.d.ts +69 -0
- package/dist/watcher/base-watcher.d.ts.map +1 -0
- package/dist/watcher/base-watcher.js +130 -0
- package/dist/watcher/base-watcher.js.map +1 -0
- package/dist/watcher/index.d.ts +3 -0
- package/dist/watcher/index.d.ts.map +1 -1
- package/dist/watcher/index.js +2 -0
- package/dist/watcher/index.js.map +1 -1
- package/dist/watcher/queue-watcher.d.ts +64 -0
- package/dist/watcher/queue-watcher.d.ts.map +1 -0
- package/dist/watcher/queue-watcher.js +187 -0
- package/dist/watcher/queue-watcher.js.map +1 -0
- package/docs/ADR_CONCEPTS.md +140 -0
- package/docs/CONFIGURATION.md +922 -925
- package/docs/CROSS_DATABASE.md +153 -0
- package/docs/DATABASE_AUTH.md +70 -356
- package/docs/HOOKS_GUIDE.md +159 -0
- package/docs/SLASH_COMMANDS.md +329 -337
- package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
- package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
- package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
- package/docs/cli/README.md +276 -277
- package/package.json +123 -124
- package/docs/ACCEPTANCE_CRITERIA.md +0 -625
- package/docs/AI_AGENT_GUIDE.md +0 -299
- package/docs/ARCHITECTURE.md +0 -167
- package/docs/AUTO_FILE_TRACKING.md +0 -841
- package/docs/BATCH_VALIDATION.md +0 -617
- package/docs/BEST_PRACTICES.md +0 -168
- package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
- package/docs/DECISION_CONTEXT.md +0 -697
- package/docs/DECISION_INTELLIGENCE.md +0 -605
- package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
- package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
- package/docs/SHARED_CONCEPTS.md +0 -225
- package/docs/SPECIALIZED_AGENTS.md +0 -126
- package/docs/TASK_ACTIONS.md +0 -1177
- package/docs/TASK_OVERVIEW.md +0 -452
- package/docs/TASK_PRUNING.md +0 -594
- package/docs/TOOL_REFERENCE.md +0 -1077
- package/docs/TOOL_SELECTION.md +0 -83
- package/docs/WORKFLOWS.md +0 -941
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Cross-Database Compatibility
|
|
2
|
+
|
|
3
|
+
sqlew supports multiple database backends with unified query behavior.
|
|
4
|
+
|
|
5
|
+
## Supported Databases
|
|
6
|
+
|
|
7
|
+
| Database | Version | Status |
|
|
8
|
+
|----------|---------|--------|
|
|
9
|
+
| SQLite | 3.x | Primary (default) |
|
|
10
|
+
| MySQL | 8.0+ | Supported |
|
|
11
|
+
| MariaDB | 10.5+ | Supported |
|
|
12
|
+
| PostgreSQL | 12+ | Supported |
|
|
13
|
+
|
|
14
|
+
## Configuration
|
|
15
|
+
|
|
16
|
+
### SQLite (Default)
|
|
17
|
+
|
|
18
|
+
```toml
|
|
19
|
+
[database]
|
|
20
|
+
type = "sqlite"
|
|
21
|
+
path = ".sqlew/sqlew.db"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### MySQL / MariaDB
|
|
25
|
+
|
|
26
|
+
```toml
|
|
27
|
+
[database]
|
|
28
|
+
type = "mysql" # or "mariadb"
|
|
29
|
+
|
|
30
|
+
[database.connection]
|
|
31
|
+
host = "localhost"
|
|
32
|
+
port = 3306
|
|
33
|
+
database = "sqlew"
|
|
34
|
+
|
|
35
|
+
[database.auth]
|
|
36
|
+
type = "direct"
|
|
37
|
+
user = "sqlew_user"
|
|
38
|
+
password = "your_password"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### PostgreSQL
|
|
42
|
+
|
|
43
|
+
```toml
|
|
44
|
+
[database]
|
|
45
|
+
type = "postgres"
|
|
46
|
+
|
|
47
|
+
[database.connection]
|
|
48
|
+
host = "localhost"
|
|
49
|
+
port = 5432
|
|
50
|
+
database = "sqlew"
|
|
51
|
+
|
|
52
|
+
[database.auth]
|
|
53
|
+
type = "direct"
|
|
54
|
+
user = "sqlew_user"
|
|
55
|
+
password = "your_password"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Database-Specific Differences
|
|
59
|
+
|
|
60
|
+
### String Aggregation
|
|
61
|
+
|
|
62
|
+
| Database | Function |
|
|
63
|
+
|----------|----------|
|
|
64
|
+
| SQLite | `GROUP_CONCAT(column)` |
|
|
65
|
+
| MySQL | `GROUP_CONCAT(column)` |
|
|
66
|
+
| MariaDB | `GROUP_CONCAT(column)` |
|
|
67
|
+
| PostgreSQL | `string_agg(column, ',')` |
|
|
68
|
+
|
|
69
|
+
sqlew automatically detects the database type and uses the appropriate function.
|
|
70
|
+
|
|
71
|
+
### GROUP BY Strictness
|
|
72
|
+
|
|
73
|
+
PostgreSQL enforces strict GROUP BY rules:
|
|
74
|
+
- All non-aggregated SELECT columns must appear in GROUP BY
|
|
75
|
+
- MySQL/MariaDB/SQLite are more lenient
|
|
76
|
+
|
|
77
|
+
sqlew includes all necessary columns in GROUP BY for cross-database compatibility.
|
|
78
|
+
|
|
79
|
+
### Example Query Difference
|
|
80
|
+
|
|
81
|
+
**MySQL/SQLite:**
|
|
82
|
+
```sql
|
|
83
|
+
SELECT d.key_id, ck.key_name, GROUP_CONCAT(t.name) as tags
|
|
84
|
+
FROM v4_decisions d
|
|
85
|
+
JOIN v4_context_keys ck ON d.key_id = ck.id
|
|
86
|
+
GROUP BY d.key_id
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**PostgreSQL:**
|
|
90
|
+
```sql
|
|
91
|
+
SELECT d.key_id, ck.key_name, string_agg(t.name, ',') as tags
|
|
92
|
+
FROM v4_decisions d
|
|
93
|
+
JOIN v4_context_keys ck ON d.key_id = ck.id
|
|
94
|
+
GROUP BY d.key_id, ck.key_name
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Data Migration
|
|
98
|
+
|
|
99
|
+
### Cross-Database Migration
|
|
100
|
+
|
|
101
|
+
Use JSON export/import for migrating between database types:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Export from source database
|
|
105
|
+
sqlew db:export backup.json
|
|
106
|
+
|
|
107
|
+
# Import to target database (after changing config)
|
|
108
|
+
sqlew db:import backup.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Note:** SQL dump (`db:dump`) is for same-database-type operations only.
|
|
112
|
+
|
|
113
|
+
### Export Options
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Export all data
|
|
117
|
+
sqlew db:export full-backup.json
|
|
118
|
+
|
|
119
|
+
# Export with version tracking
|
|
120
|
+
sqlew db:export --version 4.1.0 backup.json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Adapter Implementation
|
|
124
|
+
|
|
125
|
+
Database adapters are located in `src/adapters/`:
|
|
126
|
+
|
|
127
|
+
| File | Purpose |
|
|
128
|
+
|------|---------|
|
|
129
|
+
| `sqlite-adapter.ts` | SQLite (better-sqlite3) |
|
|
130
|
+
| `mysql-adapter.ts` | MySQL/MariaDB (mysql2) |
|
|
131
|
+
| `postgresql-adapter.ts` | PostgreSQL (pg) |
|
|
132
|
+
|
|
133
|
+
Each adapter implements the `DatabaseAdapter` interface with database-specific:
|
|
134
|
+
- Connection handling
|
|
135
|
+
- Transaction management
|
|
136
|
+
- String aggregation
|
|
137
|
+
- Type conversions
|
|
138
|
+
|
|
139
|
+
## Testing Cross-Database Compatibility
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Run tests on all configured databases
|
|
143
|
+
npm run test:cross-db
|
|
144
|
+
|
|
145
|
+
# Run tests on specific database
|
|
146
|
+
DB_TYPE=postgres npm test
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Version History
|
|
150
|
+
|
|
151
|
+
- **v4.1.0**: PostgreSQL compatibility fixes (string_agg, GROUP BY)
|
|
152
|
+
- **v4.0.2**: JSON-only cross-database migration
|
|
153
|
+
- **v3.7.0**: Multi-database adapter architecture
|
package/docs/DATABASE_AUTH.md
CHANGED
|
@@ -1,302 +1,107 @@
|
|
|
1
1
|
# Database Authentication Configuration
|
|
2
2
|
|
|
3
|
-
This document describes the authentication configuration
|
|
3
|
+
This document describes the authentication configuration for multi-database support in sqlew v4.0.0+.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Supported Authentication
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
| Method | Status | Description |
|
|
8
|
+
|--------|--------|-------------|
|
|
9
|
+
| **Direct (Password)** | ✅ Supported | Standard username/password authentication |
|
|
10
|
+
| **SSH Tunnel** | ✅ Manual | User-managed SSH port forwarding |
|
|
11
|
+
| SSL/TLS Certificates | 🔮 Planned | Client certificate authentication |
|
|
12
|
+
| AWS RDS IAM | 🔮 Planned | Token-based authentication for AWS RDS |
|
|
13
|
+
| GCP Cloud SQL IAM | 🔮 Planned | Token-based authentication for GCP Cloud SQL |
|
|
14
14
|
|
|
15
15
|
## Configuration Structure
|
|
16
16
|
|
|
17
|
-
All configuration is defined in `.sqlew/config.toml
|
|
18
|
-
|
|
19
|
-
### SQLite Configuration (Default)
|
|
17
|
+
All configuration is defined in `.sqlew/config.toml`.
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
### SQLite (Default)
|
|
22
20
|
|
|
23
21
|
```toml
|
|
24
22
|
[database]
|
|
25
23
|
path = ".sqlew/sqlew.db"
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
### PostgreSQL
|
|
29
|
-
|
|
30
|
-
Remote databases require three main sections:
|
|
31
|
-
|
|
32
|
-
1. **Database Type**: Specifies the database system
|
|
33
|
-
2. **Connection**: Server address and database name
|
|
34
|
-
3. **Authentication**: Credentials and authentication method
|
|
35
|
-
|
|
36
|
-
## Configuration Sections
|
|
37
|
-
|
|
38
|
-
### 1. Database Type
|
|
39
|
-
|
|
40
|
-
```toml
|
|
41
|
-
[database]
|
|
42
|
-
type = "postgres" # or "mysql" or "sqlite"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Valid values: `sqlite`, `postgres`, `mysql`
|
|
46
|
-
|
|
47
|
-
### 2. Connection Configuration
|
|
48
|
-
|
|
49
|
-
Required for PostgreSQL and MySQL:
|
|
50
|
-
|
|
51
|
-
```toml
|
|
52
|
-
[database.connection]
|
|
53
|
-
host = "localhost" # Database server hostname or IP
|
|
54
|
-
port = 5432 # PostgreSQL: 5432, MySQL: 3306
|
|
55
|
-
database = "sqlew" # Database name
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Fields**:
|
|
59
|
-
- `host` (required): Database server hostname or IP address
|
|
60
|
-
- `port` (required): Database server port (1-65535)
|
|
61
|
-
- `database` (required): Target database name
|
|
62
|
-
|
|
63
|
-
### 3. Authentication Configuration
|
|
64
|
-
|
|
65
|
-
```toml
|
|
66
|
-
[database.auth]
|
|
67
|
-
type = "direct" # Authentication method
|
|
68
|
-
user = "postgres" # Database username
|
|
69
|
-
password = "your-password" # Database password
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Fields**:
|
|
73
|
-
- `type` (required): Authentication method
|
|
74
|
-
- `direct`: Standard username/password (or localhost connection through manual SSH tunnel)
|
|
75
|
-
- `aws-iam`: AWS RDS IAM authentication (planned)
|
|
76
|
-
- `gcp-iam`: GCP Cloud SQL IAM authentication (planned)
|
|
77
|
-
- `user` (optional): Database username
|
|
78
|
-
- `password` (optional): Database password
|
|
79
|
-
|
|
80
|
-
**Note**: For databases behind bastion hosts, users must set up SSH tunnels manually using the `ssh -L` command, then connect to localhost.
|
|
81
|
-
|
|
82
|
-
### 4. SSL/TLS Configuration (Optional)
|
|
83
|
-
|
|
84
|
-
For encrypted database connections:
|
|
85
|
-
|
|
86
|
-
```toml
|
|
87
|
-
[database.auth.ssl]
|
|
88
|
-
ca = "/path/to/ca-cert.pem" # CA certificate
|
|
89
|
-
cert = "/path/to/client-cert.pem" # Client certificate (mutual TLS)
|
|
90
|
-
key = "/path/to/client-key.pem" # Client private key (mutual TLS)
|
|
91
|
-
rejectUnauthorized = true # Reject self-signed certificates
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Fields**:
|
|
95
|
-
- `ca` (optional): Certificate Authority certificate (file path or content)
|
|
96
|
-
- `cert` (optional): Client certificate for mutual TLS (file path or content)
|
|
97
|
-
- `key` (optional): Client private key for mutual TLS (file path or content)
|
|
98
|
-
- `rejectUnauthorized` (optional): Whether to reject unauthorized certificates (default: `true`)
|
|
99
|
-
|
|
100
|
-
**Security Note**: Setting `rejectUnauthorized = false` is not recommended for production.
|
|
101
|
-
|
|
102
|
-
### 5. Manual SSH Tunnel Setup (For Databases Behind Bastion Hosts)
|
|
103
|
-
|
|
104
|
-
**SSH tunneling is NOT supported by this software.** Users must set up SSH tunnels manually before connecting.
|
|
105
|
-
|
|
106
|
-
**Manual Tunnel Setup:**
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Example: Connect to database behind bastion host
|
|
110
|
-
ssh -L 3307:db.internal.example.com:3306 user@bastion.example.com
|
|
111
|
-
|
|
112
|
-
# Then configure sqlew to connect to localhost:
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
```toml
|
|
116
|
-
[database]
|
|
117
|
-
type = "mysql"
|
|
118
|
-
|
|
119
|
-
[database.connection]
|
|
120
|
-
host = "localhost" # Connect to tunnel endpoint
|
|
121
|
-
port = 3307 # Forwarded port (not 3306!)
|
|
122
|
-
database = "sqlew_db"
|
|
123
|
-
|
|
124
|
-
[database.auth]
|
|
125
|
-
type = "direct"
|
|
126
|
-
user = "mysql_user"
|
|
127
|
-
password = "db-password"
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**SSH Tunnel Command Options:**
|
|
131
|
-
- `-L localport:remotehost:remoteport`: Port forwarding specification
|
|
132
|
-
- `-N`: Don't execute remote command (tunnel only)
|
|
133
|
-
- `-f`: Run in background
|
|
134
|
-
- `-o ServerAliveInterval=60`: Keep connection alive
|
|
135
|
-
|
|
136
|
-
**Example with background tunnel:**
|
|
137
|
-
```bash
|
|
138
|
-
ssh -f -N -L 3307:db.internal:3306 user@bastion.example.com
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Complete Examples
|
|
142
|
-
|
|
143
|
-
### Example 1: PostgreSQL with Direct Authentication
|
|
26
|
+
### PostgreSQL
|
|
144
27
|
|
|
145
28
|
```toml
|
|
146
29
|
[database]
|
|
147
30
|
type = "postgres"
|
|
148
31
|
|
|
149
32
|
[database.connection]
|
|
150
|
-
host = "
|
|
33
|
+
host = "localhost"
|
|
151
34
|
port = 5432
|
|
152
|
-
database = "
|
|
35
|
+
database = "sqlew_db"
|
|
153
36
|
|
|
154
37
|
[database.auth]
|
|
155
38
|
type = "direct"
|
|
156
39
|
user = "postgres"
|
|
157
|
-
password = "
|
|
40
|
+
password = "your-password"
|
|
158
41
|
```
|
|
159
42
|
|
|
160
|
-
###
|
|
43
|
+
### MySQL/MariaDB
|
|
161
44
|
|
|
162
45
|
```toml
|
|
163
46
|
[database]
|
|
164
|
-
type = "
|
|
47
|
+
type = "mysql"
|
|
165
48
|
|
|
166
49
|
[database.connection]
|
|
167
|
-
host = "
|
|
168
|
-
port =
|
|
169
|
-
database = "
|
|
50
|
+
host = "localhost"
|
|
51
|
+
port = 3306
|
|
52
|
+
database = "sqlew_db"
|
|
170
53
|
|
|
171
54
|
[database.auth]
|
|
172
55
|
type = "direct"
|
|
173
|
-
user = "
|
|
174
|
-
password = "
|
|
175
|
-
|
|
176
|
-
[database.auth.ssl]
|
|
177
|
-
ca = "/path/to/ca-cert.pem"
|
|
178
|
-
rejectUnauthorized = true
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Example 3: PostgreSQL via Manual SSH Tunnel
|
|
182
|
-
|
|
183
|
-
**Step 1**: Set up SSH tunnel manually:
|
|
184
|
-
```bash
|
|
185
|
-
ssh -L 5433:db.internal.example.com:5432 deploy@bastion.example.com
|
|
56
|
+
user = "mysql_user"
|
|
57
|
+
password = "your-password"
|
|
186
58
|
```
|
|
187
59
|
|
|
188
|
-
|
|
189
|
-
```toml
|
|
190
|
-
[database]
|
|
191
|
-
type = "postgres"
|
|
192
|
-
|
|
193
|
-
[database.connection]
|
|
194
|
-
host = "localhost" # Tunnel endpoint
|
|
195
|
-
port = 5433 # Forwarded port (not 5432!)
|
|
196
|
-
database = "sqlew_production"
|
|
197
|
-
|
|
198
|
-
[database.auth]
|
|
199
|
-
type = "direct"
|
|
200
|
-
user = "postgres"
|
|
201
|
-
password = "db-password"
|
|
202
|
-
```
|
|
60
|
+
## SSH Tunnel (Manual Setup)
|
|
203
61
|
|
|
204
|
-
|
|
62
|
+
**SSH tunneling is NOT built into sqlew.** Set up tunnels manually before connecting.
|
|
205
63
|
|
|
206
|
-
**Step 1**: Set up SSH tunnel manually:
|
|
207
64
|
```bash
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
**Step 2**: Configure sqlew with SSL:
|
|
212
|
-
```toml
|
|
213
|
-
[database]
|
|
214
|
-
type = "mysql"
|
|
215
|
-
|
|
216
|
-
[database.connection]
|
|
217
|
-
host = "localhost" # Tunnel endpoint
|
|
218
|
-
port = 53306 # Forwarded port
|
|
219
|
-
database = "sqlew_db"
|
|
220
|
-
|
|
221
|
-
[database.auth]
|
|
222
|
-
type = "direct"
|
|
223
|
-
user = "mysql_user"
|
|
224
|
-
password = "db-password"
|
|
225
|
-
|
|
226
|
-
[database.auth.ssl]
|
|
227
|
-
ca = "/path/to/ca.pem"
|
|
228
|
-
rejectUnauthorized = true
|
|
65
|
+
# Example: Forward local port 5433 to remote database
|
|
66
|
+
ssh -L 5433:db.internal.example.com:5432 user@bastion.example.com
|
|
229
67
|
```
|
|
230
68
|
|
|
231
|
-
|
|
69
|
+
Then configure sqlew to connect to localhost:
|
|
232
70
|
|
|
233
71
|
```toml
|
|
234
72
|
[database]
|
|
235
|
-
type = "
|
|
73
|
+
type = "postgres"
|
|
236
74
|
|
|
237
75
|
[database.connection]
|
|
238
|
-
host = "
|
|
239
|
-
port =
|
|
76
|
+
host = "localhost" # Tunnel endpoint
|
|
77
|
+
port = 5433 # Forwarded port
|
|
240
78
|
database = "sqlew_db"
|
|
241
79
|
|
|
242
80
|
[database.auth]
|
|
243
81
|
type = "direct"
|
|
244
|
-
user = "
|
|
82
|
+
user = "postgres"
|
|
245
83
|
password = "db-password"
|
|
246
|
-
|
|
247
|
-
[database.auth.ssl]
|
|
248
|
-
ca = """-----BEGIN CERTIFICATE-----
|
|
249
|
-
MIIEGzCCAwOgAwIBAgIQDKU...
|
|
250
|
-
...certificate content...
|
|
251
|
-
-----END CERTIFICATE-----"""
|
|
252
|
-
rejectUnauthorized = true
|
|
253
84
|
```
|
|
254
85
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
### Database Type Validation
|
|
260
|
-
- Must be one of: `sqlite`, `postgres`, `mysql`
|
|
86
|
+
**Useful SSH options:**
|
|
87
|
+
- `-N`: Don't execute remote command (tunnel only)
|
|
88
|
+
- `-f`: Run in background
|
|
89
|
+
- `-o ServerAliveInterval=60`: Keep connection alive
|
|
261
90
|
|
|
262
|
-
|
|
263
|
-
- Required for PostgreSQL and MySQL
|
|
264
|
-
- `host`: Must be specified
|
|
265
|
-
- `port`: Must be between 1 and 65535
|
|
266
|
-
- `database`: Must be specified
|
|
91
|
+
## Validation Rules
|
|
267
92
|
|
|
268
|
-
###
|
|
93
|
+
### Connection
|
|
94
|
+
- `host`: Required for PostgreSQL/MySQL
|
|
95
|
+
- `port`: 1-65535
|
|
96
|
+
- `database`: Required for PostgreSQL/MySQL
|
|
269
97
|
|
|
270
|
-
|
|
98
|
+
### Authentication
|
|
99
|
+
- `type`: Must be `direct`
|
|
271
100
|
- `user`: Required
|
|
272
101
|
- `password`: Required
|
|
273
102
|
|
|
274
|
-
### SSL Validation
|
|
275
|
-
- `rejectUnauthorized`: Must be a boolean (if specified)
|
|
276
|
-
|
|
277
|
-
## Default Values
|
|
278
|
-
|
|
279
|
-
The configuration loader applies sensible defaults:
|
|
280
|
-
|
|
281
|
-
### SSL Defaults
|
|
282
|
-
- `rejectUnauthorized`: true
|
|
283
|
-
|
|
284
103
|
## Error Handling
|
|
285
104
|
|
|
286
|
-
### Configuration Parsing Errors
|
|
287
|
-
|
|
288
|
-
If the TOML file is malformed:
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
⚠️ Failed to load config file: .sqlew/config.toml
|
|
292
|
-
Error: Unexpected character at line 5
|
|
293
|
-
Using default configuration
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### Validation Errors
|
|
297
|
-
|
|
298
|
-
If configuration is invalid:
|
|
299
|
-
|
|
300
105
|
```
|
|
301
106
|
⚠️ Configuration validation failed: .sqlew/config.toml
|
|
302
107
|
- database.connection.host is required
|
|
@@ -304,141 +109,50 @@ If configuration is invalid:
|
|
|
304
109
|
Using default configuration
|
|
305
110
|
```
|
|
306
111
|
|
|
307
|
-
## Loading Configuration
|
|
308
|
-
|
|
309
|
-
The configuration is loaded automatically when the MCP server starts. You can also load it programmatically:
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
import { loadConfigFile, validateDatabaseConfig } from './config/loader.js';
|
|
313
|
-
|
|
314
|
-
// Load and validate
|
|
315
|
-
const config = loadConfigFile('.sqlew/config.toml');
|
|
316
|
-
const validation = validateDatabaseConfig(config.database);
|
|
317
|
-
|
|
318
|
-
if (!validation.valid) {
|
|
319
|
-
console.error('Invalid configuration:', validation.errors);
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
## Backward Compatibility
|
|
324
|
-
|
|
325
|
-
The new authentication system is fully backward compatible:
|
|
326
|
-
|
|
327
|
-
- Existing SQLite configurations continue to work
|
|
328
|
-
- The `path` field in `[database]` is still supported
|
|
329
|
-
- If no configuration is provided, SQLite with default path is used
|
|
330
|
-
|
|
331
112
|
## Security Best Practices
|
|
332
113
|
|
|
333
|
-
1. **
|
|
334
|
-
2. **
|
|
335
|
-
3. **
|
|
336
|
-
4. **Secure Credentials**: Never commit config.toml with passwords to version control
|
|
337
|
-
5. **Restrict Permissions**: Set appropriate file permissions on private keys (chmod 600)
|
|
338
|
-
6. **Environment Variables**: Consider using environment variables for sensitive data (future enhancement)
|
|
339
|
-
|
|
340
|
-
## Troubleshooting
|
|
341
|
-
|
|
342
|
-
### Connection Failures
|
|
343
|
-
|
|
344
|
-
**PostgreSQL connection refused**:
|
|
345
|
-
- Check that PostgreSQL is running
|
|
346
|
-
- Verify host and port are correct
|
|
347
|
-
- Ensure firewall allows connections
|
|
348
|
-
- Check pg_hba.conf for authentication settings
|
|
349
|
-
|
|
350
|
-
**Manual SSH tunnel issues**:
|
|
351
|
-
- Run `ssh -v -L ...` for verbose debugging
|
|
352
|
-
- Check SSH key permissions (`chmod 600 ~/.ssh/id_rsa`)
|
|
353
|
-
- Verify bastion host is reachable
|
|
354
|
-
- Ensure SSH port (usually 22) is open
|
|
355
|
-
- Check if local port is already in use (`netstat -an | grep <port>`)
|
|
356
|
-
|
|
357
|
-
**SSL certificate errors**:
|
|
358
|
-
- Verify CA certificate path is correct
|
|
359
|
-
- Check certificate is not expired
|
|
360
|
-
- Ensure certificate chain is complete
|
|
361
|
-
- For development, temporarily set `rejectUnauthorized = false` (not for production)
|
|
362
|
-
|
|
363
|
-
### Configuration Validation
|
|
364
|
-
|
|
365
|
-
Use the test suite to validate your configuration:
|
|
114
|
+
1. **Never commit passwords** - Don't commit config.toml with passwords to git
|
|
115
|
+
2. **Use SSH tunnels** - For databases behind firewalls
|
|
116
|
+
3. **Restrict access** - Limit database user permissions
|
|
366
117
|
|
|
367
|
-
|
|
368
|
-
npx tsc
|
|
369
|
-
node dist/tests/config-loader.test.js
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
## API Reference
|
|
118
|
+
---
|
|
373
119
|
|
|
374
|
-
|
|
120
|
+
## Future Authentication Methods
|
|
375
121
|
|
|
376
|
-
|
|
122
|
+
> **Status**: Planned for future releases. If you need these features, please [open an issue](https://github.com/sin5ddd/mcp-sqlew/issues) - we'll prioritize based on demand!
|
|
377
123
|
|
|
378
|
-
|
|
124
|
+
### SSL/TLS Client Certificates
|
|
379
125
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const config = loadConfigFile('.sqlew/config.toml');
|
|
126
|
+
```toml
|
|
127
|
+
# PLANNED - Not yet implemented
|
|
128
|
+
[database.auth.ssl]
|
|
129
|
+
ca = "/path/to/ca-cert.pem"
|
|
130
|
+
cert = "/path/to/client-cert.pem"
|
|
131
|
+
key = "/path/to/client-key.pem"
|
|
132
|
+
rejectUnauthorized = true
|
|
388
133
|
```
|
|
389
134
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
Validates database configuration.
|
|
393
|
-
|
|
394
|
-
**Parameters**:
|
|
395
|
-
- `config`: Database configuration object
|
|
135
|
+
### AWS RDS IAM Authentication
|
|
396
136
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (!validation.valid) {
|
|
403
|
-
console.error('Validation errors:', validation.errors);
|
|
404
|
-
}
|
|
137
|
+
```toml
|
|
138
|
+
# PLANNED - Not yet implemented
|
|
139
|
+
[database.auth]
|
|
140
|
+
type = "aws-iam"
|
|
141
|
+
region = "us-east-1"
|
|
405
142
|
```
|
|
406
143
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
Normalizes database configuration by applying defaults.
|
|
410
|
-
|
|
411
|
-
**Parameters**:
|
|
412
|
-
- `config`: Partial database configuration
|
|
144
|
+
### GCP Cloud SQL IAM Authentication
|
|
413
145
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
type: 'postgres',
|
|
420
|
-
connection: { host: 'localhost', port: 5432, database: 'test' },
|
|
421
|
-
auth: {
|
|
422
|
-
type: 'direct',
|
|
423
|
-
user: 'postgres',
|
|
424
|
-
password: 'pass',
|
|
425
|
-
ssl: { ca: '/path/to/ca.pem' }
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
// normalized.auth.ssl.rejectUnauthorized === true (default applied)
|
|
146
|
+
```toml
|
|
147
|
+
# PLANNED - Not yet implemented
|
|
148
|
+
[database.auth]
|
|
149
|
+
type = "gcp-iam"
|
|
150
|
+
project = "my-project"
|
|
429
151
|
```
|
|
430
152
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
Planned authentication methods:
|
|
434
|
-
|
|
435
|
-
- **AWS RDS IAM Authentication**: Token-based authentication for AWS RDS
|
|
436
|
-
- **GCP Cloud SQL IAM Authentication**: Token-based authentication for GCP Cloud SQL
|
|
437
|
-
- **Environment Variable Substitution**: Reference environment variables in config
|
|
438
|
-
- **Credential Encryption**: Encrypt sensitive fields in config file
|
|
153
|
+
---
|
|
439
154
|
|
|
440
155
|
## Related Documentation
|
|
441
156
|
|
|
442
157
|
- [Configuration Guide](./CONFIGURATION.md)
|
|
443
|
-
- [
|
|
444
|
-
- [Type Definitions](../src/config/types.ts)
|
|
158
|
+
- [Cross Database Guide](./CROSS_DATABASE.md)
|