sqlew 4.0.4 → 4.1.0

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 (203) hide show
  1. package/CHANGELOG.md +1805 -1762
  2. package/LICENSE +177 -39
  3. package/NOTICE +24 -0
  4. package/README.md +409 -390
  5. package/assets/claude-md-snippets/plan-mode-integration.md +17 -6
  6. package/assets/config.example.toml +282 -284
  7. package/assets/sample-agents/README.md +36 -40
  8. package/assets/sample-agents/sqlew-architect.md +321 -322
  9. package/assets/sample-agents/sqlew-researcher.md +292 -293
  10. package/assets/sample-agents/sqlew-scrum-master.md +286 -287
  11. package/assets/sample-commands/README.md +56 -57
  12. package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +33 -26
  13. package/dist/cli/hooks/check-completion.d.ts +19 -0
  14. package/dist/cli/hooks/check-completion.d.ts.map +1 -0
  15. package/dist/cli/hooks/check-completion.js +104 -0
  16. package/dist/cli/hooks/check-completion.js.map +1 -0
  17. package/dist/cli/hooks/init-hooks.d.ts +35 -0
  18. package/dist/cli/hooks/init-hooks.d.ts.map +1 -0
  19. package/dist/cli/hooks/init-hooks.js +425 -0
  20. package/dist/cli/hooks/init-hooks.js.map +1 -0
  21. package/dist/cli/hooks/mark-done.d.ts +25 -0
  22. package/dist/cli/hooks/mark-done.d.ts.map +1 -0
  23. package/dist/cli/hooks/mark-done.js +128 -0
  24. package/dist/cli/hooks/mark-done.js.map +1 -0
  25. package/dist/cli/hooks/plan-id-utils.d.ts +83 -0
  26. package/dist/cli/hooks/plan-id-utils.d.ts.map +1 -0
  27. package/dist/cli/hooks/plan-id-utils.js +183 -0
  28. package/dist/cli/hooks/plan-id-utils.js.map +1 -0
  29. package/dist/cli/hooks/save.d.ts +23 -0
  30. package/dist/cli/hooks/save.d.ts.map +1 -0
  31. package/dist/cli/hooks/save.js +90 -0
  32. package/dist/cli/hooks/save.js.map +1 -0
  33. package/dist/cli/hooks/stdin-parser.d.ts +139 -0
  34. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -0
  35. package/dist/cli/hooks/stdin-parser.js +127 -0
  36. package/dist/cli/hooks/stdin-parser.js.map +1 -0
  37. package/dist/cli/hooks/suggest.d.ts +19 -0
  38. package/dist/cli/hooks/suggest.d.ts.map +1 -0
  39. package/dist/cli/hooks/suggest.js +157 -0
  40. package/dist/cli/hooks/suggest.js.map +1 -0
  41. package/dist/cli/hooks/track-plan.d.ts +36 -0
  42. package/dist/cli/hooks/track-plan.d.ts.map +1 -0
  43. package/dist/cli/hooks/track-plan.js +152 -0
  44. package/dist/cli/hooks/track-plan.js.map +1 -0
  45. package/dist/cli.d.ts.map +1 -1
  46. package/dist/cli.js +56 -16
  47. package/dist/cli.js.map +1 -1
  48. package/dist/config/global-config.d.ts +187 -0
  49. package/dist/config/global-config.d.ts.map +1 -0
  50. package/dist/config/global-config.js +206 -0
  51. package/dist/config/global-config.js.map +1 -0
  52. package/dist/config/loader.d.ts +42 -0
  53. package/dist/config/loader.d.ts.map +1 -1
  54. package/dist/config/loader.js +96 -0
  55. package/dist/config/loader.js.map +1 -1
  56. package/dist/constants.d.ts +4 -0
  57. package/dist/constants.d.ts.map +1 -1
  58. package/dist/constants.js +10 -0
  59. package/dist/constants.js.map +1 -1
  60. package/dist/database/operations/queries.d.ts.map +1 -1
  61. package/dist/database/operations/queries.js +11 -2
  62. package/dist/database/operations/queries.js.map +1 -1
  63. package/dist/index.js +5 -2
  64. package/dist/index.js.map +1 -1
  65. package/dist/init-agents.js +0 -1
  66. package/dist/init-agents.js.map +1 -1
  67. package/dist/init-skills.d.ts +4 -3
  68. package/dist/init-skills.d.ts.map +1 -1
  69. package/dist/init-skills.js +10 -3
  70. package/dist/init-skills.js.map +1 -1
  71. package/dist/server/setup.d.ts +8 -0
  72. package/dist/server/setup.d.ts.map +1 -1
  73. package/dist/server/setup.js +141 -21
  74. package/dist/server/setup.js.map +1 -1
  75. package/dist/sync-agents.d.ts.map +1 -1
  76. package/dist/sync-agents.js +48 -3
  77. package/dist/sync-agents.js.map +1 -1
  78. package/dist/sync-commands.d.ts.map +1 -1
  79. package/dist/sync-commands.js +43 -3
  80. package/dist/sync-commands.js.map +1 -1
  81. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  82. package/dist/tools/constraints/actions/get.js +5 -8
  83. package/dist/tools/constraints/actions/get.js.map +1 -1
  84. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  85. package/dist/tools/constraints/help/help.js +1 -6
  86. package/dist/tools/constraints/help/help.js.map +1 -1
  87. package/dist/tools/context/actions/get.d.ts.map +1 -1
  88. package/dist/tools/context/actions/get.js.map +1 -1
  89. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  90. package/dist/tools/context/actions/search-layer.js +5 -3
  91. package/dist/tools/context/actions/search-layer.js.map +1 -1
  92. package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
  93. package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
  94. package/dist/tools/context/actions/set-from-policy.js.map +1 -1
  95. package/dist/tools/context/help/help.d.ts.map +1 -1
  96. package/dist/tools/context/help/help.js +1 -7
  97. package/dist/tools/context/help/help.js.map +1 -1
  98. package/dist/tools/context/internal/queries.d.ts.map +1 -1
  99. package/dist/tools/context/internal/queries.js +5 -2
  100. package/dist/tools/context/internal/queries.js.map +1 -1
  101. package/dist/tools/context/types.d.ts +1 -1
  102. package/dist/tools/context/types.d.ts.map +1 -1
  103. package/dist/tools/files/actions/get.d.ts.map +1 -1
  104. package/dist/tools/files/actions/get.js +4 -6
  105. package/dist/tools/files/actions/get.js.map +1 -1
  106. package/dist/tools/files/help/help.d.ts.map +1 -1
  107. package/dist/tools/files/help/help.js +1 -6
  108. package/dist/tools/files/help/help.js.map +1 -1
  109. package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
  110. package/dist/tools/suggest/help/constraint-help.js +0 -2
  111. package/dist/tools/suggest/help/constraint-help.js.map +1 -1
  112. package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
  113. package/dist/tools/suggest/internal/constraint-queries.js +12 -5
  114. package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
  115. package/dist/tools/suggest/internal/queries.js +2 -2
  116. package/dist/tools/suggest/internal/queries.js.map +1 -1
  117. package/dist/tools/tasks/help/help.d.ts.map +1 -1
  118. package/dist/tools/tasks/help/help.js +0 -6
  119. package/dist/tools/tasks/help/help.js.map +1 -1
  120. package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
  121. package/dist/tools/tasks/help/use-case.js +0 -1
  122. package/dist/tools/tasks/help/use-case.js.map +1 -1
  123. package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
  124. package/dist/tools/tasks/watcher/status.js +5 -1
  125. package/dist/tools/tasks/watcher/status.js.map +1 -1
  126. package/dist/types/decision/params.d.ts +7 -6
  127. package/dist/types/decision/params.d.ts.map +1 -1
  128. package/dist/types/decision/templates.d.ts +3 -2
  129. package/dist/types/decision/templates.d.ts.map +1 -1
  130. package/dist/types/view-entities.d.ts +2 -1
  131. package/dist/types/view-entities.d.ts.map +1 -1
  132. package/dist/types.d.ts +19 -11
  133. package/dist/types.d.ts.map +1 -1
  134. package/dist/types.js +4 -1
  135. package/dist/types.js.map +1 -1
  136. package/dist/utils/enum-converter.d.ts +72 -0
  137. package/dist/utils/enum-converter.d.ts.map +1 -0
  138. package/dist/utils/enum-converter.js +76 -0
  139. package/dist/utils/enum-converter.js.map +1 -0
  140. package/dist/utils/hook-queue.d.ts +81 -0
  141. package/dist/utils/hook-queue.d.ts.map +1 -0
  142. package/dist/utils/hook-queue.js +156 -0
  143. package/dist/utils/hook-queue.js.map +1 -0
  144. package/dist/utils/project-root.d.ts +9 -2
  145. package/dist/utils/project-root.d.ts.map +1 -1
  146. package/dist/utils/project-root.js +16 -2
  147. package/dist/utils/project-root.js.map +1 -1
  148. package/dist/utils/tag-parser.d.ts.map +1 -1
  149. package/dist/utils/tag-parser.js +6 -0
  150. package/dist/utils/tag-parser.js.map +1 -1
  151. package/dist/utils/validators.d.ts +1 -1
  152. package/dist/utils/validators.d.ts.map +1 -1
  153. package/dist/utils/validators.js +1 -1
  154. package/dist/utils/validators.js.map +1 -1
  155. package/dist/utils/vcs-adapter.d.ts +44 -0
  156. package/dist/utils/vcs-adapter.d.ts.map +1 -1
  157. package/dist/utils/vcs-adapter.js +88 -0
  158. package/dist/utils/vcs-adapter.js.map +1 -1
  159. package/dist/utils/view-queries.d.ts.map +1 -1
  160. package/dist/utils/view-queries.js +9 -19
  161. package/dist/utils/view-queries.js.map +1 -1
  162. package/dist/watcher/base-watcher.d.ts +69 -0
  163. package/dist/watcher/base-watcher.d.ts.map +1 -0
  164. package/dist/watcher/base-watcher.js +130 -0
  165. package/dist/watcher/base-watcher.js.map +1 -0
  166. package/dist/watcher/index.d.ts +3 -0
  167. package/dist/watcher/index.d.ts.map +1 -1
  168. package/dist/watcher/index.js +2 -0
  169. package/dist/watcher/index.js.map +1 -1
  170. package/dist/watcher/queue-watcher.d.ts +64 -0
  171. package/dist/watcher/queue-watcher.d.ts.map +1 -0
  172. package/dist/watcher/queue-watcher.js +187 -0
  173. package/dist/watcher/queue-watcher.js.map +1 -0
  174. package/docs/ADR_CONCEPTS.md +140 -0
  175. package/docs/CONFIGURATION.md +922 -925
  176. package/docs/CROSS_DATABASE.md +153 -0
  177. package/docs/DATABASE_AUTH.md +70 -356
  178. package/docs/HOOKS_GUIDE.md +159 -0
  179. package/docs/SLASH_COMMANDS.md +329 -337
  180. package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
  181. package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
  182. package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
  183. package/docs/cli/README.md +276 -277
  184. package/package.json +123 -119
  185. package/docs/ACCEPTANCE_CRITERIA.md +0 -625
  186. package/docs/AI_AGENT_GUIDE.md +0 -198
  187. package/docs/ARCHITECTURE.md +0 -167
  188. package/docs/AUTO_FILE_TRACKING.md +0 -841
  189. package/docs/BATCH_VALIDATION.md +0 -617
  190. package/docs/BEST_PRACTICES.md +0 -168
  191. package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
  192. package/docs/DECISION_CONTEXT.md +0 -675
  193. package/docs/DECISION_INTELLIGENCE.md +0 -605
  194. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
  195. package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
  196. package/docs/SHARED_CONCEPTS.md +0 -225
  197. package/docs/SPECIALIZED_AGENTS.md +0 -126
  198. package/docs/TASK_ACTIONS.md +0 -1177
  199. package/docs/TASK_OVERVIEW.md +0 -452
  200. package/docs/TASK_PRUNING.md +0 -594
  201. package/docs/TOOL_REFERENCE.md +0 -1077
  202. package/docs/TOOL_SELECTION.md +0 -83
  203. package/docs/WORKFLOWS.md +0 -941
package/README.md CHANGED
@@ -1,390 +1,409 @@
1
- # sqlew
2
- ![sqlew_logo](assets/sqlew-logo.png)
3
-
4
- [![npm version](https://img.shields.io/npm/v/sqlew.svg)](https://www.npmjs.com/package/sqlew)
5
- [![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
6
-
7
- > **Never Start From Zero Context Again** – An MCP server that gives AI agents a shared SQL-backed context repository
8
-
9
- ## What is sqlew?
10
-
11
- **sqlew** is a Model Context Protocol (MCP) server that provides AI agents with a shared SQL-backed context repository across sessions.
12
-
13
- ### Concerns About AI Coding
14
- Every Claude session starts with zero context. You must re-explain decisions, agents can reintroduce bugs, and there's no way to track WHY decisions were made.
15
-
16
- It is possible to keep records using Markdown files.
17
- However, maintaining records for large-scale projects and long-term maintenance generates an enormous volume of documentation.
18
-
19
- This has become problematic because it causes context rotting in AI systems, leading to performance deterioration.
20
-
21
- ### *sqlew* provides the solution for this problem
22
- sqlew builds an efficient external context repository for AI by using relational databases.
23
- - Records the reasoning behind decisions
24
- - Enables querying past context
25
- - Prevents anti-patterns through constraints
26
- - Eliminates duplicate work via task management
27
-
28
- > *This software does not send any data to external networks. We NEVER collect any data or usage statistics. Please use it with complete security.*
29
-
30
- ## Concept: Decision & Constraint Repository Layer
31
-
32
- sqlew originally started as a way to reduce duplicated work and inconsistent behavior across multiple AI agents. Instead of letting every new session re-read the same documents and reinvent similar code, sqlew centralizes context in a shared SQL database.
33
-
34
- With recent LLMs, the most valuable part of this shared context has proved to be the **history of Decisions and Constraints**:
35
-
36
- - **Decisions** capture *why* a change or design choice was made (trade-offs, rejected options, rationale).
37
- - **Constraints** capture *how* things should be done (coding rules, architecture boundaries, performance requirements).
38
-
39
- Modern versions of sqlew treat this decision & constraint history as **first-class data**:
40
-
41
- - The database schema is optimized around Decisions and Constraints instead of generic notes.
42
- - A three-tier **duplicate detection and suggestion system** helps you reuse existing Decisions/Constraints instead of creating nearly identical ones.
43
- - Legacy, unused features have been removed or simplified to keep the focus on long-term context and consistency.
44
-
45
- In practice, sqlew acts as a **Decision & Constraint repository layer** for your AI tools: agents can query what was decided before, which rules already exist, and how similar situations were handled previously.
46
-
47
- ## Why Use sqlew?
48
-
49
- ### 🧠 Organizational Memory
50
- Traditional code analysis like git tells you **WHAT** is done, sqlew adds **WHY** and **HOW** on it:
51
- - **Decisions** → WHY it was changed
52
- - **Constraints** → HOW should it be written
53
- - **Tasks** WHAT needs to be done
54
-
55
- ### ⚡ Token Efficiency
56
- **60-75% token reduction** in multi-session projects through structured data storage and selective querying.
57
-
58
- ### 🎯 Key Benefits for Your Development Workflow
59
-
60
- #### 🧠 **Context Persistence Across Sessions**
61
- - **No More Re-Explaining**: AI remembers decisions from weeks ago - no need to re-explain "why we chose PostgreSQL over MongoDB"
62
- - **Session Continuity**: Pick up exactly where you left off, even after days or weeks
63
- - **Team Knowledge Sharing**: New team members (or new AI sessions) instantly understand past decisions
64
-
65
- #### 🛡️ **Prevents Context Rotting & Inconsistency**
66
- - **Architectural Constraints**: Define rules once ("always use async/await, never callbacks"), AI follows them forever
67
- - **Version History**: Track how decisions evolved - see what changed and when
68
-
69
- #### 🎯 **Enables Consistent, High-Quality Code**
70
- - **Bug Prevention**: AI won't reintroduce bugs you already fixed (decisions document "what didn't work")
71
- - **Pattern Enforcement**: Constraints ensure AI writes code matching your team's style
72
- - **Context-Aware Suggestions**: AI sees related decisions before creating new ones ("Did you know we already solved this?")
73
- - **Rationale Documentation**: Every decision includes WHY it was made, preventing cargo-cult programming
74
-
75
- #### 📊 **Transparent AI Work Tracking**
76
- - **Task Dependencies**: AI knows Task B needs Task A completed first
77
- - **Auto File Watching**: Tasks auto-update when AI edits tracked files (zero manual updates)
78
- - **Progress Visibility**: See exactly what AI is working on, what's blocked, what's done
79
-
80
- #### ⚡ **Efficiency & Reliability**
81
- - **60-75% Token Reduction**: Structured data beats dumping entire context into prompts
82
- - **Reduce Context Rot**: No more "this README is 50 pages and AI ignores half of it"
83
- - **Production-Ready**: 495/495 tests passing (100%), battle-tested on real projects
84
-
85
- ---
86
-
87
- **Technical Features**: 6 specialized MCP tools (decisions, tasks, files, constraints, stats, suggest), smart similarity scoring (0-100 point algorithm), runtime reconnection, parameter validation, metadata-driven organization
88
-
89
- See [docs/TASK_OVERVIEW.md](docs/TASK_OVERVIEW.md) and [docs/DECISION_CONTEXT.md](docs/DECISION_CONTEXT.md) for details.
90
-
91
- ### 🔖Kanban-style AI Scrum
92
- ![kanban-style task management](assets/kanban-visualizer.png)
93
-
94
- (This visualizer is not included in this package)
95
-
96
- ## Installation
97
-
98
- ### Requirements
99
- - Node.js 20.0.0 or higher
100
- - npm or npx
101
-
102
- ### Quick Install
103
-
104
- on `.mcp.json` in your project's root, add these lines:
105
-
106
- ```json
107
- {
108
- "mcpServers": {
109
- "sqlew": {
110
- "command": "npx",
111
- "args": ["sqlew"]
112
- }
113
- }
114
- }
115
- ```
116
- **Recommend to restart claude after initialize**
117
-
118
- The first time, sqlew initializes database, installs custom agents and slash commands. But agents and commands are not loaded in this time. So, please exit claude once, and restart claude again.
119
-
120
- It's Ready!
121
-
122
- ## 🚀 Quick Start: /sqlew Command
123
-
124
- **The `/sqlew` command is the easiest way to use sqlew!** Just type `/sqlew` in Claude Code with natural language input.
125
-
126
- ### Most Common Uses
127
-
128
- ```bash
129
- # Show status and get suggestions
130
- /sqlew
131
-
132
- # Record a decision
133
- /sqlew record we use PostgreSQL 15 for production database
134
-
135
- # Search past decisions
136
- /sqlew search why we chose Knex for migrations
137
-
138
- # List remaining tasks
139
- /sqlew show remaining tasks
140
-
141
- # Plan a new feature (breakdown into tasks)
142
- /sqlew plan implementing user authentication
143
- ```
144
-
145
- The `/sqlew` command automatically detects your intent (search, record, list, execute, task creation) and invokes the appropriate MCP tools.
146
-
147
- ---
148
-
149
- **⚠️Note**: Global install (`npm install -g`) is **not recommended** because sqlew requires an independent settings per project. Each project should maintain its own context database in `.sqlew/sqlew.db`.
150
-
151
- **Custom database path:** Add path as argument: `"args": ["sqlew", "/path/to/db.db"]`
152
- **Default location:** `.sqlew/sqlew.db`
153
-
154
- **⚠️ Not Supported:** Junie AI cannot use relative paths in MCP server configurations, which makes it incompatible with sqlew's project-based database model. Each project requires its own isolated database at `.sqlew/sqlew.db`, but Junie AI's global MCP configuration cannot handle per-project database paths.
155
-
156
- ## Configuration
157
-
158
- ### Database Support
159
-
160
- sqlew supports multiple database backends for different deployment scenarios:
161
-
162
- | Database | Use Case | Status |
163
- |----------|----------------------------------------------|-------------|
164
- | **SQLite** | Personal or small projects | ✅ Default |
165
- | **MySQL 8.0 / MariaDB 10+** | Production, shared environments, remote work | Supported |
166
- | **PostgreSQL 12+** | Production, shared environments, remote work | ✅ Supported |
167
-
168
- Of course, it also works with Docker RDB instances.
169
-
170
- ### Optional Config File
171
-
172
- On first run, `.sqlew/config.toml` will be created for persistent settings:
173
-
174
- **SQLite (Default):**
175
- ```toml
176
- [database]
177
- path = ".sqlew/custom.db"
178
-
179
- [autodelete]
180
- ignore_weekend = true
181
- message_hours = 48
182
- ```
183
-
184
- **PostgreSQL:**
185
- ```toml
186
- [database]
187
- type = "postgres"
188
-
189
- [database.connection]
190
- host = "localhost"
191
- port = 5432
192
- database = "sqlew_db"
193
-
194
- [database.auth]
195
- type = "direct"
196
- user = "sqlew_user"
197
- password = "secret"
198
- ```
199
-
200
- **MySQL/MariaDB:**
201
- ```toml
202
- [database]
203
- type = "mysql"
204
-
205
- [database.connection]
206
- host = "localhost"
207
- port = 3306
208
- database = "sqlew_db"
209
-
210
- [database.auth]
211
- type = "direct"
212
- user = "sqlew_user"
213
- password = "secret"
214
- ```
215
-
216
- Also `.sqlew/config.example.toml` is created for reference.
217
-
218
- **Settings Priority:** CLI args > config.toml > database defaults
219
-
220
- See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for all options and validation rules.
221
-
222
- ### CLI Configuration (Recommended)
223
-
224
- Configuration is managed via **`.sqlew/config.toml`** file and **CLI arguments only**. The MCP `config` tool has been removed for simplicity.
225
-
226
- **Why CLI-only configuration?**
227
- - **No drift:** Single source of truth (config file)
228
- - **Version control:** Commit config to git, share with team
229
- - **Clear documentation:** Config file documents project requirements
230
- - **Type safety:** TOML validation catches errors at startup
231
-
232
- **Common CLI arguments:**
233
- ```bash
234
- # Custom database path
235
- npx sqlew /path/to/database.db
236
-
237
- # Auto-deletion settings
238
- npx sqlew --autodelete-message-hours=48
239
- npx sqlew --autodelete-file-history-days=30
240
- npx sqlew --autodelete-ignore-weekend
241
-
242
- # Custom config file
243
- npx sqlew --config-path=.sqlew/custom.toml
244
- ```
245
-
246
- For persistent settings, edit `.sqlew/config.toml` instead of using CLI arguments.
247
-
248
- ## Quick Start
249
-
250
- install it, launch claude, exit claude and launch Claude again.
251
-
252
- ### Basic Usage
253
-
254
- You'll never need to call it manually, I recommend to call this tool via prompt.
255
-
256
- ```
257
- read sqlew usecases, and plan implementation of feature X using sqlew.
258
- ```
259
-
260
- or invoke Specialized Agent
261
-
262
- ```
263
- /sqw-plan implementation of feature X .
264
- ```
265
-
266
- Specialized Agents use sqlew more efficiently.
267
-
268
- ---
269
-
270
- **Note**: The `/sqlew` command supersedes the previous multi-command system (`/sqw-plan`, `/sqw-scrum`, etc.). All functionality is now available through the unified `/sqlew` interface with automatic intent detection.
271
-
272
- ### Advanced: Direct MCP Tool Access
273
-
274
- Power users can still call MCP tools directly. See [Available Tools](#available-tools) section below.
275
-
276
- ### Available Tools
277
-
278
- | Tool | Purpose | Example Use |
279
- |------|---------|------------|
280
- | **decision** | Record choices and reasons | "We chose PostgreSQL" |
281
- | **constraint** | Define rules | "DO NOT use raw SQL, use ORM" |
282
- | **task** | Track work | "Implement feature X" |
283
- | **file** | Track changes | "Modified auth.ts" |
284
- | **stats** | Database metrics | Get layer summary |
285
- | **suggest** | Find similar decisions (v3.9.0) | Duplicate detection, pattern search |
286
-
287
-
288
- ## Documentation
289
-
290
- Each tool supports `action: "help"` for full documentation and `action: "example"` for comprehensive usage examples.
291
-
292
- And `action: "use_case"` shows how to use the tool in a real-world scenario.
293
-
294
- ### On-Demand Documentation
295
-
296
- All tools support:
297
- - `action: "help"` - Parameter reference and descriptions
298
- - `action: "example"` - Usage scenarios and examples
299
- - `action: "use_case"` - Real-world usage examples
300
-
301
- ### For AI Agents
302
-
303
- **Essential Guides:**
304
- - [Tool Selection](docs/TOOL_SELECTION.md) - Decision tree, when to use each tool
305
- - [Workflows](docs/WORKFLOWS.md) - Multi-step examples, multi-agent coordination
306
- - [Tool Reference](docs/TOOL_REFERENCE.md) - Parameters, batch operations, templates
307
- - [Best Practices](docs/BEST_PRACTICES.md) - Common errors, troubleshooting
308
-
309
- **Task System:**
310
- - [Task Overview](docs/TASK_OVERVIEW.md) - Lifecycle, status transitions
311
- - [Task Actions](docs/TASK_ACTIONS.md) - All actions with examples
312
- - [Task Dependencies](docs/TASK_DEPENDENCIES.md) - Blocking relationships
313
- - [Task Linking](docs/TASK_LINKING.md) - Link to decisions/constraints/files
314
- - [Task Migration](docs/TASK_MIGRATION.md) - Migrate from decision-based tracking
315
-
316
- **Advanced Features:**
317
- - [Decision Intelligence](docs/DECISION_INTELLIGENCE.md) - Three-tier duplicate detection (v3.9.0)
318
- - [Decision Context](docs/DECISION_CONTEXT.md) - Rich decision documentation
319
- - [Auto File Tracking](docs/AUTO_FILE_TRACKING.md) - Zero-token task management
320
- - [Acceptance Criteria](docs/ACCEPTANCE_CRITERIA.md) - All check types
321
-
322
- **Reference:**
323
- - [Shared Concepts](docs/SHARED_CONCEPTS.md) - Layer definitions, enum values
324
- - [Configuration](docs/CONFIGURATION.md) - Config file setup, all options
325
- - [Architecture](docs/ARCHITECTURE.md) - Technical architecture
326
-
327
- ### Advanced Usage
328
-
329
- - [Configuration Guide](docs/CONFIGURATION.md) - TOML config file setup
330
- - [CLI Mode Overview](docs/cli/README.md) - Database migration, export/import commands
331
- - [Building from Source](docs/ARCHITECTURE.md#development) - Setup instructions
332
- - [Migration Guides](docs/MIGRATION_v2.md) - Version upgrade guides
333
-
334
- ## Use Cases
335
-
336
- - **Multi-Agent Coordination**: Orchestrators create tasks, agents send status updates
337
- - **Breaking Change Management**: Record deprecations and add architectural constraints
338
- - **Decision Context**: Document rationale, alternatives considered, and trade-offs
339
- - **Session Continuity**: Save progress in Session 1, resume in Session 2
340
-
341
- See [docs/WORKFLOWS.md](docs/WORKFLOWS.md) for detailed multi-step examples.
342
-
343
- ## Performance
344
-
345
- - **Query speed**: 2-50ms
346
- - **Concurrent agents**: 5+ simultaneous
347
- - **Storage efficiency**: ~140 bytes per decision
348
- - **Token savings**: 60-75% in typical projects
349
-
350
- ## Support
351
-
352
- Support development via [GitHub Sponsors](https://github.com/sponsors/sin5ddd) - One-time or monthly options available.
353
-
354
- ## Version
355
-
356
- Current version: **4.0.2**
357
- See [CHANGELOG.md](CHANGELOG.md) for release history.
358
-
359
- **What's New in v4.0.2:**
360
- - **Unified CLI Entry Point** - `npx sqlew db:export` works directly (no `npm install` required)
361
- - **Cross-DB Migration via JSON Only** - SQL dump no longer supports cross-database conversion
362
- - **Node.js 20+ Required** - Updated minimum version requirement
363
-
364
- **What's New in v4.0.0:**
365
- - **Schema Refactoring** - Unified v4_ table prefix, agent system completely removed
366
- - **Clean Schema** - No legacy columns, optimized for Decision & Constraint repository
367
- - **Improved Migration System** - Reorganized v3/v4 directories
368
-
369
- See [docs/DECISION_INTELLIGENCE.md](docs/DECISION_INTELLIGENCE.md) for details on the suggest tool.
370
-
371
- ## License
372
-
373
- AGPLv3 - Free to use. Open-source required when embedding or modifying. See [LICENSE](LICENSE) for details.
374
-
375
- ## Links
376
-
377
- - [npm package](https://www.npmjs.com/package/sqlew)
378
- - [GitHub repository](https://github.com/sin5ddd/mcp-sqlew)
379
- - [Model Context Protocol](https://modelcontextprotocol.io/)
380
-
381
- ## Support & Documentation
382
-
383
- - Issues: [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
384
- - Docs: [docs/](docs/) directory
385
-
386
- ## Acknowledgments
387
-
388
- Built with [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk), [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), and TypeScript.
389
-
390
- **Author**: sin5ddd
1
+ # sqlew
2
+ ![sqlew_logo](assets/sqlew-logo.png)
3
+
4
+ [![npm version](https://img.shields.io/npm/v/sqlew.svg)](https://www.npmjs.com/package/sqlew)
5
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+
7
+ > **ADR (Architecture Decision Record) for AI Agents** – An MCP server that enables AI agents to create, query, and maintain architecture decision records in a structured SQL database
8
+
9
+ ## 🚀 Quick Start
10
+
11
+ ### 1. Install globally (Recommended)
12
+
13
+ ```bash
14
+ npm install -g sqlew
15
+ ```
16
+
17
+ ### 2. Add to your MCP config
18
+
19
+ Add to `.mcp.json` in your project root:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "sqlew": {
25
+ "command": "sqlew"
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### 3. Initialize hooks
32
+
33
+ ```bash
34
+ sqlew init --hooks
35
+ ```
36
+
37
+ ### 4. Just use Plan Mode!
38
+
39
+ **That's it!** Now every time you:
40
+ 1. Create a plan in Claude Code
41
+ 2. Get user approval (ExitPlanMode)
42
+
43
+ Your architectural decisions are **automatically recorded** as ADR knowledge.
44
+
45
+ No special commands needed. Just plan your work normally, and sqlew captures the decisions in the background.
46
+
47
+ ### Optional: /sqlew command
48
+
49
+ For manual queries and explicit decision recording:
50
+
51
+ ```bash
52
+ /sqlew # Show status
53
+ /sqlew search auth # Search past decisions
54
+ /sqlew record use Redis # Record a decision manually
55
+ ```
56
+
57
+ ---
58
+
59
+ ## What is sqlew?
60
+
61
+ **sqlew** is a Model Context Protocol (MCP) server that brings ADR (Architecture Decision Record) capabilities to AI agents through a shared SQL-backed repository.
62
+
63
+ ### The Problem: AI Agents Lack Decision Memory
64
+ Every AI session starts with zero context. Agents must re-learn architectural decisions, can reintroduce previously rejected patterns, and have no systematic way to understand WHY past choices were made.
65
+
66
+ Traditional ADR approaches use Markdown files scattered across repositories. While human-readable, this format creates challenges for AI agents:
67
+ - **No structured querying** AI must read entire files to find relevant decisions
68
+ - **Context explosion** – Token costs grow linearly with decision history
69
+ - **No duplicate detection** AI cannot easily identify similar or conflicting decisions
70
+ - **Poor discoverability** Finding related decisions requires full-text search across many files
71
+
72
+ ### *sqlew* brings structured ADR to AI agents
73
+ sqlew transforms ADR from static documentation into a **queryable, AI-native decision database**:
74
+
75
+ - **Structured records** Decisions stored as relational data with metadata, tags, and relationships
76
+ - **Efficient querying** AI agents retrieve only relevant decisions via SQL queries
77
+ - **Smart suggestions** Three-tier similarity system detects duplicate or related decisions
78
+ - **Constraint tracking** Architectural rules and principles as first-class entities
79
+ - **Auto-capture** – Claude Code Hooks automatically record decisions from Plan Mode
80
+
81
+ > *This software does not send any data to external networks. We NEVER collect any data or usage statistics. Please use it with complete security.*
82
+
83
+ ## Why sqlew?
84
+
85
+ AI agents automatically accumulate project knowledge through Plan Mode. Decisions are stored in SQL for efficient querying.
86
+
87
+ **Perfect for:**
88
+ - 🏢 Large-scale projects with many architectural decisions
89
+ - 🔧 Long-term maintenance where context must persist across sessions
90
+ - 👥 Team environments where multiple AI agents share knowledge
91
+
92
+ **Key benefits:**
93
+ - ⚡ **60-75% token reduction** vs reading Markdown ADRs
94
+ - 🔍 **Millisecond queries** (2-50ms) even with thousands of decisions
95
+ - 🛡️ **Duplicate prevention** via similarity detection
96
+ - 📚 **Persistent memory** across all AI sessions
97
+
98
+ See [ADR Concepts](docs/ADR_CONCEPTS.md) for detailed architecture.
99
+
100
+ ---
101
+
102
+ **Technical Features**: 7 MCP tools (4 core: decision, constraint, file, suggest + 3 utility: help, example, use_case), three-tier similarity detection (0-100 point scoring), ACID transaction support, multi-database backend (SQLite/PostgreSQL/MySQL), metadata-driven organization with layers and tags
103
+
104
+
105
+ ## Installation
106
+
107
+ ### Requirements
108
+ - Node.js 20.0.0 or higher
109
+ - npm or npx
110
+
111
+ ### Recommended: Global Install
112
+
113
+ ```bash
114
+ npm install -g sqlew
115
+ ```
116
+
117
+ > **Why global install?** Claude Code Hooks call `sqlew` directly from shell. Global install ensures hooks work correctly without npx overhead.
118
+
119
+ Then add to `.mcp.json` in your project root:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "sqlew": {
125
+ "command": "sqlew"
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Alternative: npx (No Install)
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "sqlew": {
137
+ "command": "npx",
138
+ "args": ["sqlew"]
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ **Note**: First run initializes the database. Restart Claude Code to load the MCP server.
145
+
146
+ Each project maintains its own context database in `.sqlew/sqlew.db`.
147
+
148
+ **Custom database path:** Add path as argument: `"args": ["sqlew", "/path/to/db.db"]`
149
+ **Default location:** `.sqlew/sqlew.db`
150
+
151
+ **⚠️ Not Supported:** Junie AI cannot use relative paths in MCP server configurations, which makes it incompatible with sqlew's project-based database model. Each project requires its own isolated database at `.sqlew/sqlew.db`, but Junie AI's global MCP configuration cannot handle per-project database paths.
152
+
153
+ ## Configuration
154
+
155
+ ### Database Support
156
+
157
+ sqlew supports multiple database backends for different deployment scenarios:
158
+
159
+ | Database | Use Case | Status |
160
+ |----------|----------------------------------------------|-------------|
161
+ | **SQLite** | Personal or small projects | ✅ Default |
162
+ | **MySQL 8.0 / MariaDB 10+** | Production, shared environments, remote work | ✅ Supported |
163
+ | **PostgreSQL 12+** | Production, shared environments, remote work | ✅ Supported |
164
+
165
+ Of course, it also works with Docker RDB instances.
166
+
167
+ ### Optional Config File
168
+
169
+ On first run, `.sqlew/config.toml` will be created for persistent settings:
170
+
171
+ **SQLite (Default):**
172
+ ```toml
173
+ [database]
174
+ path = ".sqlew/custom.db"
175
+
176
+ [autodelete]
177
+ ignore_weekend = true
178
+ message_hours = 48
179
+ ```
180
+
181
+ **PostgreSQL:**
182
+ ```toml
183
+ [database]
184
+ type = "postgres"
185
+
186
+ [database.connection]
187
+ host = "localhost"
188
+ port = 5432
189
+ database = "sqlew_db"
190
+
191
+ [database.auth]
192
+ type = "direct"
193
+ user = "sqlew_user"
194
+ password = "secret"
195
+ ```
196
+
197
+ **MySQL/MariaDB:**
198
+ ```toml
199
+ [database]
200
+ type = "mysql"
201
+
202
+ [database.connection]
203
+ host = "localhost"
204
+ port = 3306
205
+ database = "sqlew_db"
206
+
207
+ [database.auth]
208
+ type = "direct"
209
+ user = "sqlew_user"
210
+ password = "secret"
211
+ ```
212
+
213
+ Also `.sqlew/config.example.toml` is created for reference.
214
+
215
+ **Settings Priority:** CLI args > config.toml > database defaults
216
+
217
+ See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for all options and validation rules.
218
+
219
+ ### CLI Configuration (Recommended)
220
+
221
+ Configuration is managed via **`.sqlew/config.toml`** file and **CLI arguments only**. The MCP `config` tool has been removed for simplicity.
222
+
223
+ **Why CLI-only configuration?**
224
+ - **No drift:** Single source of truth (config file)
225
+ - **Version control:** Commit config to git, share with team
226
+ - **Clear documentation:** Config file documents project requirements
227
+ - **Type safety:** TOML validation catches errors at startup
228
+
229
+ **Common CLI arguments:**
230
+ ```bash
231
+ # Custom database path
232
+ npx sqlew /path/to/database.db
233
+
234
+ # Auto-deletion settings
235
+ npx sqlew --autodelete-message-hours=48
236
+ npx sqlew --autodelete-file-history-days=30
237
+ npx sqlew --autodelete-ignore-weekend
238
+
239
+ # Custom config file
240
+ npx sqlew --config-path=.sqlew/custom.toml
241
+ ```
242
+
243
+ For persistent settings, edit `.sqlew/config.toml` instead of using CLI arguments.
244
+
245
+ ## Quick Start
246
+
247
+ install it, launch claude, exit claude and launch Claude again.
248
+
249
+ ### Basic Usage
250
+
251
+ You'll never need to call it manually, I recommend to call this tool via prompt.
252
+
253
+ ```
254
+ read sqlew usecases, and plan implementation of feature X using sqlew.
255
+ ```
256
+
257
+ or invoke Specialized Agent
258
+
259
+ ```
260
+ /sqw-plan implementation of feature X .
261
+ ```
262
+
263
+ Specialized Agents use sqlew more efficiently.
264
+
265
+ ---
266
+
267
+ **Note**: The `/sqlew` command supersedes the previous multi-command system (`/sqw-plan`, `/sqw-scrum`, etc.). All functionality is now available through the unified `/sqlew` interface with automatic intent detection.
268
+
269
+ ### Advanced: Direct MCP Tool Access
270
+
271
+ Power users can still call MCP tools directly. See [Available Tools](#available-tools) section below.
272
+
273
+ ### Available Tools
274
+
275
+ #### Core ADR Tools
276
+
277
+ | Tool | Purpose | Example Use |
278
+ |------|---------|------------|
279
+ | **decision** | Record architectural decisions with context | "We chose PostgreSQL over MongoDB (ACID requirement)" |
280
+ | **constraint** | Define architectural rules and principles | "All API endpoints must use /v2/ prefix" |
281
+ | **file** | Track code changes linked to decisions | "Modified auth.ts per security ADR" |
282
+ | **suggest** | Find similar decisions, prevent duplicates | Duplicate detection, similarity search |
283
+
284
+ #### Utility Tools
285
+
286
+ | Tool | Purpose | Example Use |
287
+ |------|---------|------------|
288
+ | **help** | Query action documentation and parameters | Get decision.set parameters |
289
+ | **example** | Browse code examples by tool/action | Find task.create examples |
290
+ | **use_case** | Complete workflow scenarios | Multi-step ADR workflows |
291
+
292
+
293
+ ## Documentation
294
+
295
+ Each tool supports `action: "help"` for full documentation and `action: "example"` for comprehensive usage examples.
296
+
297
+ And `action: "use_case"` shows how to use the tool in a real-world scenario.
298
+
299
+ ### On-Demand Documentation
300
+
301
+ All tools support:
302
+ - `action: "help"` - Parameter reference and descriptions
303
+ - `action: "example"` - Usage scenarios and examples
304
+ - `action: "use_case"` - Real-world usage examples
305
+
306
+ ### For AI Agents
307
+
308
+ **Essential Guides:**
309
+
310
+ **Advanced Features:**
311
+ - [Hooks Guide](docs/HOOKS_GUIDE.md) - Claude Code Hooks integration
312
+ - [Cross Database](docs/CROSS_DATABASE.md) - Multi-database support
313
+
314
+ **Reference:**
315
+ - [Configuration](docs/CONFIGURATION.md) - Config file setup, all options
316
+
317
+ ### Advanced Usage
318
+
319
+ - [Configuration Guide](docs/CONFIGURATION.md) - TOML config file setup
320
+ - [CLI Mode Overview](docs/cli/README.md) - Database migration, export/import commands
321
+ - [Migration Guides](docs/MIGRATION_v2.md) - Version upgrade guides
322
+
323
+ ## Use Cases
324
+
325
+ ### ADR-Driven Development with AI
326
+ - **Architecture Evolution** – Document major architectural decisions with full context and alternatives
327
+ - **Pattern Standardization** – Establish coding patterns as constraints, enforce via AI code generation
328
+ - **Technical Debt Tracking** – Record temporary decisions with deprecation paths and future plans
329
+ - **Onboarding Acceleration** New AI sessions instantly understand architectural history
330
+
331
+ ### Cross-Session AI Workflows
332
+ - **Multi-Session Projects** – AI maintains context across days/weeks without re-reading documentation
333
+ - **Multi-Agent Coordination** – Multiple AI agents share architectural understanding through ADR database
334
+ - **Breaking Change Management** – Document API changes, deprecations, and migration paths systematically
335
+ - **Refactoring Guidance** – AI references past decisions to maintain architectural consistency during refactors
336
+
337
+ ### Real-World Examples
338
+ ```bash
339
+ # Document an architectural decision with alternatives
340
+ /sqlew record we use PostgreSQL over MongoDB. MongoDB was rejected due to lack of ACID transactions for our financial data requirements.
341
+
342
+ # Search for past decisions before making new ones
343
+ /sqlew search why did we choose JWT authentication
344
+
345
+ # Create constraint to guide AI code generation
346
+ /sqlew add constraint all API endpoints must use /v2/ prefix for versioning
347
+
348
+ # Plan implementation of a decision
349
+ /sqlew plan implementing the PostgreSQL connection pool with pgBouncer
350
+ ```
351
+
352
+
353
+ ## Performance
354
+
355
+ - **Query speed**: 2-50ms
356
+ - **Concurrent agents**: 5+ simultaneous
357
+ - **Storage efficiency**: ~140 bytes per decision
358
+ - **Token savings**: 60-75% in typical projects
359
+
360
+ ## Support
361
+
362
+ Support development via [GitHub Sponsors](https://github.com/sponsors/sin5ddd) - One-time or monthly options available.
363
+
364
+ ## Version
365
+
366
+ Current version: **4.1.0**
367
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
368
+
369
+ **What's New in v4.1.0:**
370
+ - **Claude Code Hooks Integration** - File Queue Architecture for async decision operations
371
+ - **Hook Commands** - `suggest`, `track-plan`, `save`, `check-completion`, `mark-done`
372
+ - **QueueWatcher** - Monitors `.sqlew/queue/pending.json` for hook operations
373
+ - **PostgreSQL Compatibility** - GROUP_CONCAT string_agg, GROUP BY strictness fixes
374
+ - **Cross-DB Verified** - SQLite, MySQL, MariaDB, PostgreSQL all tested
375
+
376
+ **What's New in v4.0.5:**
377
+ - **License Change** - Apache License 2.0 (from AGPL-3.0)
378
+
379
+ **What's New in v4.0.2:**
380
+ - **Unified CLI Entry Point** - `npx sqlew db:export` works directly (no `npm install` required)
381
+ - **Cross-DB Migration via JSON Only** - SQL dump no longer supports cross-database conversion
382
+ - **Node.js 20+ Required** - Updated minimum version requirement
383
+
384
+ See [docs/HOOKS_GUIDE.md](docs/HOOKS_GUIDE.md) for Claude Code Hooks details.
385
+
386
+ ## License
387
+
388
+ Apache License 2.0 - Free for commercial and personal use. See [LICENSE](LICENSE) for details.
389
+
390
+ ## Links
391
+
392
+ - [npm package](https://www.npmjs.com/package/sqlew)
393
+ - [GitHub repository](https://github.com/sin5ddd/mcp-sqlew)
394
+ - [Model Context Protocol](https://modelcontextprotocol.io/)
395
+
396
+ ## Support & Documentation
397
+
398
+ - Issues: [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
399
+ - Docs: [docs/](docs/) directory
400
+
401
+ ## Acknowledgments
402
+
403
+ Built with [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk), [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), and TypeScript.
404
+
405
+ **Author**: sin5ddd
406
+
407
+ ---
408
+
409
+ <!-- Git Hooks Integration Test: 2025-12-22 - This line tests post-merge hook triggering mark-done --auto -->