sqlew 4.1.2 → 4.3.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 (232) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +268 -409
  3. package/assets/claude-md-snippets/plan-mode-integration.md +36 -10
  4. package/assets/config.example.toml +120 -282
  5. package/assets/sample-skills/sqlew-decision-format/SKILL.md +73 -0
  6. package/dist/cli/hooks/check-completion.d.ts.map +1 -1
  7. package/dist/cli/hooks/check-completion.js +90 -2
  8. package/dist/cli/hooks/check-completion.js.map +1 -1
  9. package/dist/cli/hooks/init-hooks.d.ts.map +1 -1
  10. package/dist/cli/hooks/init-hooks.js +97 -5
  11. package/dist/cli/hooks/init-hooks.js.map +1 -1
  12. package/dist/cli/hooks/on-enter-plan.d.ts +22 -0
  13. package/dist/cli/hooks/on-enter-plan.d.ts.map +1 -0
  14. package/dist/cli/hooks/on-enter-plan.js +51 -0
  15. package/dist/cli/hooks/on-enter-plan.js.map +1 -0
  16. package/dist/cli/hooks/on-exit-plan.d.ts +20 -0
  17. package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -0
  18. package/dist/cli/hooks/on-exit-plan.js +66 -0
  19. package/dist/cli/hooks/on-exit-plan.js.map +1 -0
  20. package/dist/cli/hooks/on-stop.d.ts +19 -0
  21. package/dist/cli/hooks/on-stop.d.ts.map +1 -0
  22. package/dist/cli/hooks/on-stop.js +152 -0
  23. package/dist/cli/hooks/on-stop.js.map +1 -0
  24. package/dist/cli/hooks/on-subagent-stop.d.ts +20 -0
  25. package/dist/cli/hooks/on-subagent-stop.d.ts.map +1 -0
  26. package/dist/cli/hooks/on-subagent-stop.js +94 -0
  27. package/dist/cli/hooks/on-subagent-stop.js.map +1 -0
  28. package/dist/cli/hooks/plan-pattern-extractor.d.ts +87 -0
  29. package/dist/cli/hooks/plan-pattern-extractor.d.ts.map +1 -0
  30. package/dist/cli/hooks/plan-pattern-extractor.js +218 -0
  31. package/dist/cli/hooks/plan-pattern-extractor.js.map +1 -0
  32. package/dist/cli/hooks/plan-processor.d.ts +43 -0
  33. package/dist/cli/hooks/plan-processor.d.ts.map +1 -0
  34. package/dist/cli/hooks/plan-processor.js +115 -0
  35. package/dist/cli/hooks/plan-processor.js.map +1 -0
  36. package/dist/cli/hooks/plan-toml-parser.d.ts +42 -0
  37. package/dist/cli/hooks/plan-toml-parser.d.ts.map +1 -0
  38. package/dist/cli/hooks/plan-toml-parser.js +178 -0
  39. package/dist/cli/hooks/plan-toml-parser.js.map +1 -0
  40. package/dist/cli/hooks/save.d.ts +7 -9
  41. package/dist/cli/hooks/save.d.ts.map +1 -1
  42. package/dist/cli/hooks/save.js +50 -25
  43. package/dist/cli/hooks/save.js.map +1 -1
  44. package/dist/cli/hooks/stdin-parser.d.ts +66 -2
  45. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
  46. package/dist/cli/hooks/stdin-parser.js +57 -2
  47. package/dist/cli/hooks/stdin-parser.js.map +1 -1
  48. package/dist/cli/hooks/suggest.d.ts +8 -4
  49. package/dist/cli/hooks/suggest.d.ts.map +1 -1
  50. package/dist/cli/hooks/suggest.js +21 -123
  51. package/dist/cli/hooks/suggest.js.map +1 -1
  52. package/dist/cli/hooks/track-plan.d.ts +8 -1
  53. package/dist/cli/hooks/track-plan.d.ts.map +1 -1
  54. package/dist/cli/hooks/track-plan.js +64 -66
  55. package/dist/cli/hooks/track-plan.js.map +1 -1
  56. package/dist/cli.d.ts.map +1 -1
  57. package/dist/cli.js +107 -6
  58. package/dist/cli.js.map +1 -1
  59. package/dist/config/global-config.d.ts +90 -0
  60. package/dist/config/global-config.d.ts.map +1 -1
  61. package/dist/config/global-config.js +86 -1
  62. package/dist/config/global-config.js.map +1 -1
  63. package/dist/database/initialization/init.js +3 -3
  64. package/dist/database/initialization/init.js.map +1 -1
  65. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts +15 -0
  66. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts.map +1 -0
  67. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +74 -0
  68. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js.map +1 -0
  69. package/dist/index.js +8 -4
  70. package/dist/index.js.map +1 -1
  71. package/dist/init-skills.d.ts +12 -3
  72. package/dist/init-skills.d.ts.map +1 -1
  73. package/dist/init-skills.js +96 -24
  74. package/dist/init-skills.js.map +1 -1
  75. package/dist/knexfile.d.ts.map +1 -1
  76. package/dist/knexfile.js +16 -12
  77. package/dist/knexfile.js.map +1 -1
  78. package/dist/server/setup.js +5 -5
  79. package/dist/server/setup.js.map +1 -1
  80. package/dist/server/tool-handlers.d.ts.map +1 -1
  81. package/dist/server/tool-handlers.js +7 -1
  82. package/dist/server/tool-handlers.js.map +1 -1
  83. package/dist/server/tool-registry.js +1 -1
  84. package/dist/server/tool-registry.js.map +1 -1
  85. package/dist/tests/feature/decision/truncate.test.d.ts +8 -0
  86. package/dist/tests/feature/decision/truncate.test.d.ts.map +1 -0
  87. package/dist/tests/feature/decision/truncate.test.js +192 -0
  88. package/dist/tests/feature/decision/truncate.test.js.map +1 -0
  89. package/dist/tests/unit/config/plan-toml-cache.test.d.ts +9 -0
  90. package/dist/tests/unit/config/plan-toml-cache.test.d.ts.map +1 -0
  91. package/dist/tests/unit/config/plan-toml-cache.test.js +230 -0
  92. package/dist/tests/unit/config/plan-toml-cache.test.js.map +1 -0
  93. package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts +10 -0
  94. package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts.map +1 -0
  95. package/dist/tests/unit/hooks/plan-toml-parser.test.js +316 -0
  96. package/dist/tests/unit/hooks/plan-toml-parser.test.js.map +1 -0
  97. package/dist/tools/constraints/actions/activate.d.ts +46 -0
  98. package/dist/tools/constraints/actions/activate.d.ts.map +1 -0
  99. package/dist/tools/constraints/actions/activate.js +105 -0
  100. package/dist/tools/constraints/actions/activate.js.map +1 -0
  101. package/dist/tools/constraints/actions/add.d.ts.map +1 -1
  102. package/dist/tools/constraints/actions/add.js +30 -13
  103. package/dist/tools/constraints/actions/add.js.map +1 -1
  104. package/dist/tools/constraints/actions/deactivate.d.ts.map +1 -1
  105. package/dist/tools/constraints/actions/deactivate.js +7 -4
  106. package/dist/tools/constraints/actions/deactivate.js.map +1 -1
  107. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  108. package/dist/tools/constraints/actions/get.js +10 -7
  109. package/dist/tools/constraints/actions/get.js.map +1 -1
  110. package/dist/tools/constraints/actions/suggest-pending.d.ts +41 -0
  111. package/dist/tools/constraints/actions/suggest-pending.d.ts.map +1 -0
  112. package/dist/tools/constraints/actions/suggest-pending.js +71 -0
  113. package/dist/tools/constraints/actions/suggest-pending.js.map +1 -0
  114. package/dist/tools/constraints/help/example.d.ts.map +1 -1
  115. package/dist/tools/constraints/help/example.js +65 -1
  116. package/dist/tools/constraints/help/example.js.map +1 -1
  117. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  118. package/dist/tools/constraints/help/help.js +10 -5
  119. package/dist/tools/constraints/help/help.js.map +1 -1
  120. package/dist/tools/constraints/index.d.ts +2 -0
  121. package/dist/tools/constraints/index.d.ts.map +1 -1
  122. package/dist/tools/constraints/index.js +2 -0
  123. package/dist/tools/constraints/index.js.map +1 -1
  124. package/dist/tools/context/actions/add-context.d.ts.map +1 -1
  125. package/dist/tools/context/actions/add-context.js +13 -6
  126. package/dist/tools/context/actions/add-context.js.map +1 -1
  127. package/dist/tools/context/actions/has-updates.d.ts.map +1 -1
  128. package/dist/tools/context/actions/has-updates.js +0 -4
  129. package/dist/tools/context/actions/has-updates.js.map +1 -1
  130. package/dist/tools/context/actions/list-contexts.d.ts.map +1 -1
  131. package/dist/tools/context/actions/list-contexts.js +12 -7
  132. package/dist/tools/context/actions/list-contexts.js.map +1 -1
  133. package/dist/tools/context/actions/list.d.ts.map +1 -1
  134. package/dist/tools/context/actions/list.js +8 -0
  135. package/dist/tools/context/actions/list.js.map +1 -1
  136. package/dist/tools/context/actions/search-advanced.d.ts.map +1 -1
  137. package/dist/tools/context/actions/search-advanced.js +41 -27
  138. package/dist/tools/context/actions/search-advanced.js.map +1 -1
  139. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  140. package/dist/tools/context/actions/search-layer.js +8 -0
  141. package/dist/tools/context/actions/search-layer.js.map +1 -1
  142. package/dist/tools/context/actions/search-tags.d.ts.map +1 -1
  143. package/dist/tools/context/actions/search-tags.js +8 -0
  144. package/dist/tools/context/actions/search-tags.js.map +1 -1
  145. package/dist/tools/files/actions/check-lock.d.ts.map +1 -1
  146. package/dist/tools/files/actions/check-lock.js +9 -3
  147. package/dist/tools/files/actions/check-lock.js.map +1 -1
  148. package/dist/tools/files/actions/get.d.ts.map +1 -1
  149. package/dist/tools/files/actions/get.js +18 -13
  150. package/dist/tools/files/actions/get.js.map +1 -1
  151. package/dist/tools/files/actions/record-batch.d.ts.map +1 -1
  152. package/dist/tools/files/actions/record-batch.js +11 -6
  153. package/dist/tools/files/actions/record-batch.js.map +1 -1
  154. package/dist/tools/files/actions/record.d.ts.map +1 -1
  155. package/dist/tools/files/actions/record.js +8 -2
  156. package/dist/tools/files/actions/record.js.map +1 -1
  157. package/dist/tools/files/help/example.d.ts.map +1 -1
  158. package/dist/tools/files/help/example.js +11 -0
  159. package/dist/tools/files/help/example.js.map +1 -1
  160. package/dist/tools/files/help/help.d.ts.map +1 -1
  161. package/dist/tools/files/help/help.js +11 -0
  162. package/dist/tools/files/help/help.js.map +1 -1
  163. package/dist/tools/suggest/actions/by-context.d.ts.map +1 -1
  164. package/dist/tools/suggest/actions/by-context.js +5 -15
  165. package/dist/tools/suggest/actions/by-context.js.map +1 -1
  166. package/dist/tools/suggest/actions/by-key.d.ts.map +1 -1
  167. package/dist/tools/suggest/actions/by-key.js +5 -15
  168. package/dist/tools/suggest/actions/by-key.js.map +1 -1
  169. package/dist/tools/suggest/actions/by-tags.d.ts.map +1 -1
  170. package/dist/tools/suggest/actions/by-tags.js +5 -15
  171. package/dist/tools/suggest/actions/by-tags.js.map +1 -1
  172. package/dist/tools/suggest/actions/constraint-by-context.d.ts +1 -1
  173. package/dist/tools/suggest/actions/constraint-by-context.d.ts.map +1 -1
  174. package/dist/tools/suggest/actions/constraint-by-context.js +9 -16
  175. package/dist/tools/suggest/actions/constraint-by-context.js.map +1 -1
  176. package/dist/tools/suggest/actions/constraint-by-tags.d.ts +1 -1
  177. package/dist/tools/suggest/actions/constraint-by-tags.d.ts.map +1 -1
  178. package/dist/tools/suggest/actions/constraint-by-tags.js +11 -17
  179. package/dist/tools/suggest/actions/constraint-by-tags.js.map +1 -1
  180. package/dist/tools/suggest/actions/constraint-by-text.d.ts +1 -1
  181. package/dist/tools/suggest/actions/constraint-by-text.d.ts.map +1 -1
  182. package/dist/tools/suggest/actions/constraint-by-text.js +6 -15
  183. package/dist/tools/suggest/actions/constraint-by-text.js.map +1 -1
  184. package/dist/types/actions.d.ts +1 -1
  185. package/dist/types/actions.d.ts.map +1 -1
  186. package/dist/types.d.ts +9 -230
  187. package/dist/types.d.ts.map +1 -1
  188. package/dist/utils/action-specs/constraint-specs.d.ts +1 -1
  189. package/dist/utils/action-specs/constraint-specs.d.ts.map +1 -1
  190. package/dist/utils/action-specs/constraint-specs.js +22 -5
  191. package/dist/utils/action-specs/constraint-specs.js.map +1 -1
  192. package/dist/utils/action-specs/decision-specs.d.ts.map +1 -1
  193. package/dist/utils/action-specs/decision-specs.js +11 -10
  194. package/dist/utils/action-specs/decision-specs.js.map +1 -1
  195. package/dist/utils/action-specs/file-specs.js +4 -4
  196. package/dist/utils/action-specs/file-specs.js.map +1 -1
  197. package/dist/utils/hook-queue.d.ts +43 -3
  198. package/dist/utils/hook-queue.d.ts.map +1 -1
  199. package/dist/utils/hook-queue.js +326 -32
  200. package/dist/utils/hook-queue.js.map +1 -1
  201. package/dist/utils/param-normalizer.d.ts +52 -0
  202. package/dist/utils/param-normalizer.d.ts.map +1 -0
  203. package/dist/utils/param-normalizer.js +70 -0
  204. package/dist/utils/param-normalizer.js.map +1 -0
  205. package/dist/utils/parameter-validator.d.ts.map +1 -1
  206. package/dist/utils/parameter-validator.js +2 -0
  207. package/dist/utils/parameter-validator.js.map +1 -1
  208. package/dist/utils/suggest-helpers.d.ts +82 -0
  209. package/dist/utils/suggest-helpers.d.ts.map +1 -0
  210. package/dist/utils/suggest-helpers.js +93 -0
  211. package/dist/utils/suggest-helpers.js.map +1 -0
  212. package/dist/utils/text-truncate.d.ts +13 -0
  213. package/dist/utils/text-truncate.d.ts.map +1 -0
  214. package/dist/utils/text-truncate.js +18 -0
  215. package/dist/utils/text-truncate.js.map +1 -0
  216. package/dist/utils/validators.d.ts +1 -1
  217. package/dist/utils/validators.d.ts.map +1 -1
  218. package/dist/utils/validators.js +1 -1
  219. package/dist/utils/validators.js.map +1 -1
  220. package/dist/watcher/base-watcher.d.ts.map +1 -1
  221. package/dist/watcher/base-watcher.js +4 -3
  222. package/dist/watcher/base-watcher.js.map +1 -1
  223. package/dist/watcher/file-watcher.d.ts.map +1 -1
  224. package/dist/watcher/file-watcher.js +5 -1
  225. package/dist/watcher/file-watcher.js.map +1 -1
  226. package/dist/watcher/queue-watcher.d.ts +12 -1
  227. package/dist/watcher/queue-watcher.d.ts.map +1 -1
  228. package/dist/watcher/queue-watcher.js +92 -12
  229. package/dist/watcher/queue-watcher.js.map +1 -1
  230. package/docs/ADR_CONCEPTS.md +4 -0
  231. package/docs/HOOKS_GUIDE.md +1 -1
  232. package/package.json +1 -1
package/README.md CHANGED
@@ -1,409 +1,268 @@
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 -->
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 project
32
+
33
+ ```bash
34
+ sqlew --init
35
+ ```
36
+
37
+ This one-shot command sets up:
38
+ - Claude Code Skills
39
+ - CLAUDE.md integration hints
40
+ - Plan-to-ADR hooks
41
+ - .gitignore entries
42
+
43
+ ### 4. Just use Plan Mode!
44
+
45
+ **That's it!** Now every time you:
46
+ 1. Create a plan in Claude Code
47
+ 2. Get user approval (ExitPlanMode)
48
+
49
+ Your architectural decisions are **automatically recorded** as ADR knowledge.
50
+
51
+ No special commands needed. Just plan your work normally, and sqlew captures the decisions in the background.
52
+
53
+ ### Optional: /sqlew command
54
+
55
+ For manual queries and explicit decision recording:
56
+
57
+ ```bash
58
+ /sqlew # Show status
59
+ /sqlew search auth # Search past decisions
60
+ /sqlew record use Redis # Record a decision manually
61
+ ```
62
+
63
+ ---
64
+
65
+ ## What is sqlew?
66
+
67
+ **sqlew** is a Model Context Protocol (MCP) server that brings ADR (Architecture Decision Record) capabilities to AI agents through a shared SQL-backed repository.
68
+
69
+ ### The Problem: AI Agents Lack Decision Memory
70
+ 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.
71
+
72
+ Traditional ADR approaches use Markdown files scattered across repositories. While human-readable, this format creates challenges for AI agents:
73
+ - **No structured querying** AI must read entire files to find relevant decisions
74
+ - **Context explosion** – Token costs grow linearly with decision history
75
+ - **No duplicate detection** – AI cannot easily identify similar or conflicting decisions
76
+ - **Poor discoverability** – Finding related decisions requires full-text search across many files
77
+
78
+ ### *sqlew* brings structured ADR to AI agents
79
+ sqlew transforms ADR from static documentation into a **queryable, AI-native decision database**:
80
+
81
+ - **Structured records** Decisions stored as relational data with metadata, tags, and relationships
82
+ - **Efficient querying** – AI agents retrieve only relevant decisions via SQL queries
83
+ - **Smart suggestions** – Three-tier similarity system detects duplicate or related decisions
84
+ - **Constraint tracking** – Architectural rules and principles as first-class entities
85
+ - **Auto-capture** Claude Code Hooks automatically record decisions from Plan Mode
86
+
87
+ > *This software does not send any data to external networks. We NEVER collect any data or usage statistics. Please use it with complete security.*
88
+
89
+ ## Why sqlew?
90
+
91
+ AI agents automatically accumulate project knowledge through Plan Mode. Decisions are stored in SQL for efficient querying.
92
+
93
+ **Perfect for:**
94
+ - 🏢 Large-scale projects with many architectural decisions
95
+ - 🔧 Long-term maintenance where context must persist across sessions
96
+ - 👥 Team environments where multiple AI agents share knowledge
97
+
98
+ **Key benefits:**
99
+ - ⚡ **60-75% token reduction** vs reading Markdown ADRs
100
+ - 🔍 **Millisecond queries** (2-50ms) even with thousands of decisions
101
+ - 🛡️ **Duplicate prevention** via similarity detection
102
+ - 📚 **Persistent memory** across all AI sessions
103
+
104
+ → See [ADR Concepts](docs/ADR_CONCEPTS.md) for detailed architecture.
105
+
106
+ ---
107
+
108
+ **Technical Features**: 6 MCP tools (3 core: decision, constraint, 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
109
+
110
+
111
+ ## Installation
112
+
113
+ ### Requirements
114
+ - Node.js 20.0.0 or higher
115
+ - npm or npx
116
+
117
+ ### Recommended: Global Install
118
+
119
+ ```bash
120
+ npm install -g sqlew
121
+ ```
122
+
123
+ > **Why global install?** Claude Code Hooks call `sqlew` directly from shell. Global install ensures hooks work correctly without npx overhead.
124
+
125
+ Then add to `.mcp.json` in your project root:
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "sqlew": {
131
+ "command": "sqlew"
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### Alternative: npx (Not Recommended)
138
+
139
+ **⚠️ Not recommended**: npx usage prevents Claude Code Hooks from working, disabling Plan-to-ADR automatic decision capture. Use global install instead.
140
+
141
+ **Note**: First run initializes the database. Restart Claude Code to load the MCP server.
142
+
143
+ Each project maintains its own context database in `.sqlew/sqlew.db`.
144
+
145
+ **Custom database path:** Add path as argument: `"args": ["sqlew", "/path/to/db.db"]`
146
+ **Default location:** `.sqlew/sqlew.db`
147
+
148
+ ## Configuration
149
+
150
+ sqlew supports multiple database backends:
151
+
152
+ | Database | Use Case | Status |
153
+ |----------|----------|--------|
154
+ | **SQLite** | Personal/small projects | ✅ Default |
155
+ | **MySQL 8.0+ / MariaDB 10+** | Production, team sharing | ✅ Supported |
156
+ | **PostgreSQL 12+** | Production, team sharing | ✅ Supported |
157
+
158
+ Configuration is managed via `.sqlew/config.toml` file and CLI arguments.
159
+
160
+ → **[Full Configuration Guide](docs/CONFIGURATION.md)** - All options, database setup, validation rules
161
+
162
+ ## Documentation
163
+
164
+ Each tool supports `action: "help"` for full documentation and `action: "example"` for comprehensive usage examples.
165
+
166
+ And `action: "use_case"` shows how to use the tool in a real-world scenario.
167
+
168
+ ### On-Demand Documentation
169
+
170
+ All tools support:
171
+ - `action: "help"` - Parameter reference and descriptions
172
+ - `action: "example"` - Usage scenarios and examples
173
+ - `action: "use_case"` - Real-world usage examples
174
+
175
+ ### For AI Agents
176
+
177
+ **Essential Guides:**
178
+
179
+ **Advanced Features:**
180
+ - [Hooks Guide](docs/HOOKS_GUIDE.md) - Claude Code Hooks integration
181
+ - [Cross Database](docs/CROSS_DATABASE.md) - Multi-database support
182
+
183
+ **Reference:**
184
+ - [Configuration](docs/CONFIGURATION.md) - Config file setup, all options
185
+
186
+ ### Advanced Usage
187
+
188
+ - [Configuration Guide](docs/CONFIGURATION.md) - TOML config file setup
189
+ - [CLI Mode Overview](docs/cli/README.md) - Database migration, export/import commands
190
+ - [Migration Guides](docs/MIGRATION_v2.md) - Version upgrade guides
191
+
192
+ ## Use Cases
193
+
194
+ ### ADR-Driven Development with AI
195
+ - **Architecture Evolution** – Document major architectural decisions with full context and alternatives
196
+ - **Pattern Standardization** – Establish coding patterns as constraints, enforce via AI code generation
197
+ - **Technical Debt Tracking** – Record temporary decisions with deprecation paths and future plans
198
+ - **Onboarding Acceleration** – New AI sessions instantly understand architectural history
199
+
200
+ ### Cross-Session AI Workflows
201
+ - **Multi-Session Projects** – AI maintains context across days/weeks without re-reading documentation
202
+ - **Multi-Agent Coordination** – Multiple AI agents share architectural understanding through ADR database
203
+ - **Breaking Change Management** – Document API changes, deprecations, and migration paths systematically
204
+ - **Refactoring Guidance** – AI references past decisions to maintain architectural consistency during refactors
205
+
206
+ ### Real-World Examples
207
+ ```bash
208
+ # Document an architectural decision with alternatives
209
+ /sqlew record we use PostgreSQL over MongoDB. MongoDB was rejected due to lack of ACID transactions for our financial data requirements.
210
+
211
+ # Search for past decisions before making new ones
212
+ /sqlew search why did we choose JWT authentication
213
+
214
+ # Create constraint to guide AI code generation
215
+ /sqlew add constraint all API endpoints must use /v2/ prefix for versioning
216
+
217
+ # Plan implementation of a decision
218
+ /sqlew plan implementing the PostgreSQL connection pool with pgBouncer
219
+ ```
220
+
221
+
222
+ ## Performance
223
+
224
+ - **Query speed**: 2-50ms
225
+ - **Concurrent agents**: 5+ simultaneous
226
+ - **Storage efficiency**: ~140 bytes per decision
227
+ - **Token savings**: 60-75% in typical projects
228
+
229
+ ## Support
230
+
231
+ Support development via [GitHub Sponsors](https://github.com/sponsors/sin5ddd) - One-time or monthly options available.
232
+
233
+ ## Version
234
+
235
+ Current version: **4.3.1**
236
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
237
+
238
+ **What's New in v4.3.1:**
239
+ - **`.claude/rules/` Integration** - Safer installation without modifying CLAUDE.md
240
+ - **Incremental gitignore** - Missing entries added even if sqlew section exists
241
+ - **Code Quality** - DRY improvements, obsolete code cleanup
242
+
243
+ See [docs/HOOKS_GUIDE.md](docs/HOOKS_GUIDE.md) for Claude Code Hooks details.
244
+
245
+ ## License
246
+
247
+ Apache License 2.0 - Free for commercial and personal use. See [LICENSE](LICENSE) for details.
248
+
249
+ ## Links
250
+
251
+ - [npm package](https://www.npmjs.com/package/sqlew)
252
+ - [GitHub repository](https://github.com/sin5ddd/mcp-sqlew)
253
+ - [Model Context Protocol](https://modelcontextprotocol.io/)
254
+
255
+ ## Support & Documentation
256
+
257
+ - Issues: [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
258
+ - Docs: [docs/](docs/) directory
259
+
260
+ ## Acknowledgments
261
+
262
+ Built with [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk), [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), and TypeScript.
263
+
264
+ **Author**: sin5ddd
265
+
266
+ ---
267
+
268
+ <!-- Git Hooks Integration Test: 2025-12-22 - This line tests post-merge hook triggering mark-done --auto -->