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.
Files changed (217) hide show
  1. package/CHANGELOG.md +1817 -1782
  2. package/README.md +409 -468
  3. package/assets/claude-md-snippets/plan-mode-integration.md +17 -6
  4. package/assets/config.example.toml +282 -284
  5. package/assets/sample-agents/README.md +36 -40
  6. package/assets/sample-agents/sqlew-architect.md +321 -322
  7. package/assets/sample-agents/sqlew-researcher.md +292 -293
  8. package/assets/sample-agents/sqlew-scrum-master.md +286 -287
  9. package/assets/sample-commands/README.md +56 -57
  10. package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +33 -26
  11. package/dist/cli/hooks/check-completion.d.ts +19 -0
  12. package/dist/cli/hooks/check-completion.d.ts.map +1 -0
  13. package/dist/cli/hooks/check-completion.js +104 -0
  14. package/dist/cli/hooks/check-completion.js.map +1 -0
  15. package/dist/cli/hooks/init-hooks.d.ts +35 -0
  16. package/dist/cli/hooks/init-hooks.d.ts.map +1 -0
  17. package/dist/cli/hooks/init-hooks.js +425 -0
  18. package/dist/cli/hooks/init-hooks.js.map +1 -0
  19. package/dist/cli/hooks/mark-done.d.ts +25 -0
  20. package/dist/cli/hooks/mark-done.d.ts.map +1 -0
  21. package/dist/cli/hooks/mark-done.js +128 -0
  22. package/dist/cli/hooks/mark-done.js.map +1 -0
  23. package/dist/cli/hooks/plan-id-utils.d.ts +83 -0
  24. package/dist/cli/hooks/plan-id-utils.d.ts.map +1 -0
  25. package/dist/cli/hooks/plan-id-utils.js +183 -0
  26. package/dist/cli/hooks/plan-id-utils.js.map +1 -0
  27. package/dist/cli/hooks/save.d.ts +23 -0
  28. package/dist/cli/hooks/save.d.ts.map +1 -0
  29. package/dist/cli/hooks/save.js +90 -0
  30. package/dist/cli/hooks/save.js.map +1 -0
  31. package/dist/cli/hooks/stdin-parser.d.ts +139 -0
  32. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -0
  33. package/dist/cli/hooks/stdin-parser.js +127 -0
  34. package/dist/cli/hooks/stdin-parser.js.map +1 -0
  35. package/dist/cli/hooks/suggest.d.ts +19 -0
  36. package/dist/cli/hooks/suggest.d.ts.map +1 -0
  37. package/dist/cli/hooks/suggest.js +157 -0
  38. package/dist/cli/hooks/suggest.js.map +1 -0
  39. package/dist/cli/hooks/track-plan.d.ts +36 -0
  40. package/dist/cli/hooks/track-plan.d.ts.map +1 -0
  41. package/dist/cli/hooks/track-plan.js +152 -0
  42. package/dist/cli/hooks/track-plan.js.map +1 -0
  43. package/dist/cli.d.ts.map +1 -1
  44. package/dist/cli.js +56 -16
  45. package/dist/cli.js.map +1 -1
  46. package/dist/config/global-config.d.ts +187 -0
  47. package/dist/config/global-config.d.ts.map +1 -0
  48. package/dist/config/global-config.js +206 -0
  49. package/dist/config/global-config.js.map +1 -0
  50. package/dist/config/loader.d.ts +42 -0
  51. package/dist/config/loader.d.ts.map +1 -1
  52. package/dist/config/loader.js +96 -0
  53. package/dist/config/loader.js.map +1 -1
  54. package/dist/constants.d.ts +4 -0
  55. package/dist/constants.d.ts.map +1 -1
  56. package/dist/constants.js +10 -0
  57. package/dist/constants.js.map +1 -1
  58. package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +59 -59
  59. package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js.map +1 -1
  60. package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js +33 -33
  61. package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js.map +1 -1
  62. package/dist/database/migrations/v4/20251127000000_add_rejected_status.js +7 -7
  63. package/dist/database/migrations/v4/20251127000000_add_rejected_status.js.map +1 -1
  64. package/dist/database/migrations/v4/20251127000001_update_task_move_help.js +11 -11
  65. package/dist/database/migrations/v4/20251127000001_update_task_move_help.js.map +1 -1
  66. package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js +10 -10
  67. package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js.map +1 -1
  68. package/dist/database/migrations/v4/20251127000003_add_task_notes_column.js +7 -7
  69. package/dist/database/migrations/v4/20251127000003_add_task_notes_column.js.map +1 -1
  70. package/dist/database/migrations/v4/20251128000000_drop_all_views.js +8 -8
  71. package/dist/database/migrations/v4/20251128000000_drop_all_views.js.map +1 -1
  72. package/dist/database/operations/queries.d.ts.map +1 -1
  73. package/dist/database/operations/queries.js +11 -2
  74. package/dist/database/operations/queries.js.map +1 -1
  75. package/dist/index.js +4 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/init-agents.js +0 -1
  78. package/dist/init-agents.js.map +1 -1
  79. package/dist/init-skills.d.ts +4 -3
  80. package/dist/init-skills.d.ts.map +1 -1
  81. package/dist/init-skills.js +10 -3
  82. package/dist/init-skills.js.map +1 -1
  83. package/dist/server/setup.d.ts +8 -0
  84. package/dist/server/setup.d.ts.map +1 -1
  85. package/dist/server/setup.js +141 -21
  86. package/dist/server/setup.js.map +1 -1
  87. package/dist/sync-agents.d.ts.map +1 -1
  88. package/dist/sync-agents.js +48 -3
  89. package/dist/sync-agents.js.map +1 -1
  90. package/dist/sync-commands.d.ts.map +1 -1
  91. package/dist/sync-commands.js +43 -3
  92. package/dist/sync-commands.js.map +1 -1
  93. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  94. package/dist/tools/constraints/actions/get.js +5 -8
  95. package/dist/tools/constraints/actions/get.js.map +1 -1
  96. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  97. package/dist/tools/constraints/help/help.js +1 -6
  98. package/dist/tools/constraints/help/help.js.map +1 -1
  99. package/dist/tools/context/actions/get.d.ts.map +1 -1
  100. package/dist/tools/context/actions/get.js.map +1 -1
  101. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  102. package/dist/tools/context/actions/search-layer.js +5 -3
  103. package/dist/tools/context/actions/search-layer.js.map +1 -1
  104. package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
  105. package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
  106. package/dist/tools/context/actions/set-from-policy.js.map +1 -1
  107. package/dist/tools/context/help/help.d.ts.map +1 -1
  108. package/dist/tools/context/help/help.js +1 -7
  109. package/dist/tools/context/help/help.js.map +1 -1
  110. package/dist/tools/context/internal/queries.d.ts.map +1 -1
  111. package/dist/tools/context/internal/queries.js +5 -2
  112. package/dist/tools/context/internal/queries.js.map +1 -1
  113. package/dist/tools/context/types.d.ts +1 -1
  114. package/dist/tools/context/types.d.ts.map +1 -1
  115. package/dist/tools/files/actions/get.d.ts.map +1 -1
  116. package/dist/tools/files/actions/get.js +4 -6
  117. package/dist/tools/files/actions/get.js.map +1 -1
  118. package/dist/tools/files/help/help.d.ts.map +1 -1
  119. package/dist/tools/files/help/help.js +1 -6
  120. package/dist/tools/files/help/help.js.map +1 -1
  121. package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
  122. package/dist/tools/suggest/help/constraint-help.js +0 -2
  123. package/dist/tools/suggest/help/constraint-help.js.map +1 -1
  124. package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
  125. package/dist/tools/suggest/internal/constraint-queries.js +12 -5
  126. package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
  127. package/dist/tools/suggest/internal/queries.js +2 -2
  128. package/dist/tools/suggest/internal/queries.js.map +1 -1
  129. package/dist/tools/tasks/help/help.d.ts.map +1 -1
  130. package/dist/tools/tasks/help/help.js +0 -6
  131. package/dist/tools/tasks/help/help.js.map +1 -1
  132. package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
  133. package/dist/tools/tasks/help/use-case.js +0 -1
  134. package/dist/tools/tasks/help/use-case.js.map +1 -1
  135. package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
  136. package/dist/tools/tasks/watcher/status.js +5 -1
  137. package/dist/tools/tasks/watcher/status.js.map +1 -1
  138. package/dist/types/decision/params.d.ts +7 -6
  139. package/dist/types/decision/params.d.ts.map +1 -1
  140. package/dist/types/decision/templates.d.ts +3 -2
  141. package/dist/types/decision/templates.d.ts.map +1 -1
  142. package/dist/types/view-entities.d.ts +2 -1
  143. package/dist/types/view-entities.d.ts.map +1 -1
  144. package/dist/types.d.ts +19 -11
  145. package/dist/types.d.ts.map +1 -1
  146. package/dist/types.js +4 -1
  147. package/dist/types.js.map +1 -1
  148. package/dist/utils/enum-converter.d.ts +72 -0
  149. package/dist/utils/enum-converter.d.ts.map +1 -0
  150. package/dist/utils/enum-converter.js +76 -0
  151. package/dist/utils/enum-converter.js.map +1 -0
  152. package/dist/utils/hook-queue.d.ts +81 -0
  153. package/dist/utils/hook-queue.d.ts.map +1 -0
  154. package/dist/utils/hook-queue.js +156 -0
  155. package/dist/utils/hook-queue.js.map +1 -0
  156. package/dist/utils/project-root.d.ts +9 -2
  157. package/dist/utils/project-root.d.ts.map +1 -1
  158. package/dist/utils/project-root.js +16 -2
  159. package/dist/utils/project-root.js.map +1 -1
  160. package/dist/utils/tag-parser.d.ts.map +1 -1
  161. package/dist/utils/tag-parser.js +6 -0
  162. package/dist/utils/tag-parser.js.map +1 -1
  163. package/dist/utils/universal-knex.js +3 -3
  164. package/dist/utils/universal-knex.js.map +1 -1
  165. package/dist/utils/validators.d.ts +1 -1
  166. package/dist/utils/validators.d.ts.map +1 -1
  167. package/dist/utils/validators.js +1 -1
  168. package/dist/utils/validators.js.map +1 -1
  169. package/dist/utils/vcs-adapter.d.ts +44 -0
  170. package/dist/utils/vcs-adapter.d.ts.map +1 -1
  171. package/dist/utils/vcs-adapter.js +88 -0
  172. package/dist/utils/vcs-adapter.js.map +1 -1
  173. package/dist/utils/view-queries.d.ts.map +1 -1
  174. package/dist/utils/view-queries.js +9 -19
  175. package/dist/utils/view-queries.js.map +1 -1
  176. package/dist/watcher/base-watcher.d.ts +69 -0
  177. package/dist/watcher/base-watcher.d.ts.map +1 -0
  178. package/dist/watcher/base-watcher.js +130 -0
  179. package/dist/watcher/base-watcher.js.map +1 -0
  180. package/dist/watcher/index.d.ts +3 -0
  181. package/dist/watcher/index.d.ts.map +1 -1
  182. package/dist/watcher/index.js +2 -0
  183. package/dist/watcher/index.js.map +1 -1
  184. package/dist/watcher/queue-watcher.d.ts +64 -0
  185. package/dist/watcher/queue-watcher.d.ts.map +1 -0
  186. package/dist/watcher/queue-watcher.js +187 -0
  187. package/dist/watcher/queue-watcher.js.map +1 -0
  188. package/docs/ADR_CONCEPTS.md +140 -0
  189. package/docs/CONFIGURATION.md +922 -925
  190. package/docs/CROSS_DATABASE.md +153 -0
  191. package/docs/DATABASE_AUTH.md +70 -356
  192. package/docs/HOOKS_GUIDE.md +159 -0
  193. package/docs/SLASH_COMMANDS.md +329 -337
  194. package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
  195. package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
  196. package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
  197. package/docs/cli/README.md +276 -277
  198. package/package.json +123 -124
  199. package/docs/ACCEPTANCE_CRITERIA.md +0 -625
  200. package/docs/AI_AGENT_GUIDE.md +0 -299
  201. package/docs/ARCHITECTURE.md +0 -167
  202. package/docs/AUTO_FILE_TRACKING.md +0 -841
  203. package/docs/BATCH_VALIDATION.md +0 -617
  204. package/docs/BEST_PRACTICES.md +0 -168
  205. package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
  206. package/docs/DECISION_CONTEXT.md +0 -697
  207. package/docs/DECISION_INTELLIGENCE.md +0 -605
  208. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
  209. package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
  210. package/docs/SHARED_CONCEPTS.md +0 -225
  211. package/docs/SPECIALIZED_AGENTS.md +0 -126
  212. package/docs/TASK_ACTIONS.md +0 -1177
  213. package/docs/TASK_OVERVIEW.md +0 -452
  214. package/docs/TASK_PRUNING.md +0 -594
  215. package/docs/TOOL_REFERENCE.md +0 -1077
  216. package/docs/TOOL_SELECTION.md +0 -83
  217. 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
@@ -1,302 +1,107 @@
1
1
  # Database Authentication Configuration
2
2
 
3
- This document describes the authentication configuration system for multi-database support in mcp-sqlew v4.0.0+.
3
+ This document describes the authentication configuration for multi-database support in sqlew v4.0.0+.
4
4
 
5
- ## Overview
5
+ ## Supported Authentication
6
6
 
7
- The configuration system supports multiple database backends with various authentication methods:
8
-
9
- - **SQLite**: Local file-based database (default, no authentication)
10
- - **PostgreSQL**: Remote PostgreSQL with direct authentication or IAM authentication (planned)
11
- - **MySQL**: Remote MySQL with direct authentication or IAM authentication (planned)
12
-
13
- **Note**: SSH tunneling is NOT supported by this software. Users must set up SSH tunnels manually using the `ssh` command and connect to localhost.
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` under the `[database]` section.
18
-
19
- ### SQLite Configuration (Default)
17
+ All configuration is defined in `.sqlew/config.toml`.
20
18
 
21
- The simplest configuration for local development:
19
+ ### SQLite (Default)
22
20
 
23
21
  ```toml
24
22
  [database]
25
23
  path = ".sqlew/sqlew.db"
26
24
  ```
27
25
 
28
- ### PostgreSQL/MySQL Configuration
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 = "db.example.com"
33
+ host = "localhost"
151
34
  port = 5432
152
- database = "sqlew_production"
35
+ database = "sqlew_db"
153
36
 
154
37
  [database.auth]
155
38
  type = "direct"
156
39
  user = "postgres"
157
- password = "secure-password"
40
+ password = "your-password"
158
41
  ```
159
42
 
160
- ### Example 2: PostgreSQL with SSL/TLS
43
+ ### MySQL/MariaDB
161
44
 
162
45
  ```toml
163
46
  [database]
164
- type = "postgres"
47
+ type = "mysql"
165
48
 
166
49
  [database.connection]
167
- host = "db.example.com"
168
- port = 5432
169
- database = "sqlew_production"
50
+ host = "localhost"
51
+ port = 3306
52
+ database = "sqlew_db"
170
53
 
171
54
  [database.auth]
172
55
  type = "direct"
173
- user = "postgres"
174
- password = "secure-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
- **Step 2**: Configure sqlew to use localhost:
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
- ### Example 4: MySQL via Manual SSH Tunnel with SSL
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
- ssh -f -N -L 53306:mysql.internal.example.com:3306 deploy@jump.example.com
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
- ### Example 5: MySQL with Inline SSL Certificate
69
+ Then configure sqlew to connect to localhost:
232
70
 
233
71
  ```toml
234
72
  [database]
235
- type = "mysql"
73
+ type = "postgres"
236
74
 
237
75
  [database.connection]
238
- host = "db.example.com"
239
- port = 3306
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 = "mysql_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
- ## Validation Rules
256
-
257
- The configuration loader validates all settings and provides clear error messages:
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
- ### Connection Validation
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
- ### Authentication Validation
93
+ ### Connection
94
+ - `host`: Required for PostgreSQL/MySQL
95
+ - `port`: 1-65535
96
+ - `database`: Required for PostgreSQL/MySQL
269
97
 
270
- **Direct Authentication**:
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. **Use Private Keys**: Prefer SSH private key authentication over passwords
334
- 2. **Enable SSL**: Use SSL/TLS for all production database connections
335
- 3. **Validate Certificates**: Keep `rejectUnauthorized = true` in production
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
- ```bash
368
- npx tsc
369
- node dist/tests/config-loader.test.js
370
- ```
371
-
372
- ## API Reference
118
+ ---
373
119
 
374
- ### Functions
120
+ ## Future Authentication Methods
375
121
 
376
- #### `loadConfigFile(configPath?: string): SqlewConfig`
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
- Loads and parses configuration from TOML file.
124
+ ### SSL/TLS Client Certificates
379
125
 
380
- **Parameters**:
381
- - `configPath` (optional): Path to config file (default: `.sqlew/config.toml`)
382
-
383
- **Returns**: Parsed and validated configuration
384
-
385
- **Example**:
386
- ```typescript
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
- #### `validateDatabaseConfig(config: DatabaseConfig): { valid: boolean; errors: string[] }`
391
-
392
- Validates database configuration.
393
-
394
- **Parameters**:
395
- - `config`: Database configuration object
135
+ ### AWS RDS IAM Authentication
396
136
 
397
- **Returns**: Validation result with errors if any
398
-
399
- **Example**:
400
- ```typescript
401
- const validation = validateDatabaseConfig(config.database);
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
- #### `normalizeDatabaseConfig(config: DatabaseConfig): DatabaseConfig`
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
- **Returns**: Complete database configuration with defaults
415
-
416
- **Example**:
417
- ```typescript
418
- const normalized = normalizeDatabaseConfig({
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
- ## Future Enhancements
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
- - [Architecture Overview](./ARCHITECTURE.md)
444
- - [Type Definitions](../src/config/types.ts)
158
+ - [Cross Database Guide](./CROSS_DATABASE.md)