sqlew 4.0.5 → 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 (201) hide show
  1. package/CHANGELOG.md +1805 -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/operations/queries.d.ts.map +1 -1
  59. package/dist/database/operations/queries.js +11 -2
  60. package/dist/database/operations/queries.js.map +1 -1
  61. package/dist/index.js +4 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/init-agents.js +0 -1
  64. package/dist/init-agents.js.map +1 -1
  65. package/dist/init-skills.d.ts +4 -3
  66. package/dist/init-skills.d.ts.map +1 -1
  67. package/dist/init-skills.js +10 -3
  68. package/dist/init-skills.js.map +1 -1
  69. package/dist/server/setup.d.ts +8 -0
  70. package/dist/server/setup.d.ts.map +1 -1
  71. package/dist/server/setup.js +141 -21
  72. package/dist/server/setup.js.map +1 -1
  73. package/dist/sync-agents.d.ts.map +1 -1
  74. package/dist/sync-agents.js +48 -3
  75. package/dist/sync-agents.js.map +1 -1
  76. package/dist/sync-commands.d.ts.map +1 -1
  77. package/dist/sync-commands.js +43 -3
  78. package/dist/sync-commands.js.map +1 -1
  79. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  80. package/dist/tools/constraints/actions/get.js +5 -8
  81. package/dist/tools/constraints/actions/get.js.map +1 -1
  82. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  83. package/dist/tools/constraints/help/help.js +1 -6
  84. package/dist/tools/constraints/help/help.js.map +1 -1
  85. package/dist/tools/context/actions/get.d.ts.map +1 -1
  86. package/dist/tools/context/actions/get.js.map +1 -1
  87. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  88. package/dist/tools/context/actions/search-layer.js +5 -3
  89. package/dist/tools/context/actions/search-layer.js.map +1 -1
  90. package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
  91. package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
  92. package/dist/tools/context/actions/set-from-policy.js.map +1 -1
  93. package/dist/tools/context/help/help.d.ts.map +1 -1
  94. package/dist/tools/context/help/help.js +1 -7
  95. package/dist/tools/context/help/help.js.map +1 -1
  96. package/dist/tools/context/internal/queries.d.ts.map +1 -1
  97. package/dist/tools/context/internal/queries.js +5 -2
  98. package/dist/tools/context/internal/queries.js.map +1 -1
  99. package/dist/tools/context/types.d.ts +1 -1
  100. package/dist/tools/context/types.d.ts.map +1 -1
  101. package/dist/tools/files/actions/get.d.ts.map +1 -1
  102. package/dist/tools/files/actions/get.js +4 -6
  103. package/dist/tools/files/actions/get.js.map +1 -1
  104. package/dist/tools/files/help/help.d.ts.map +1 -1
  105. package/dist/tools/files/help/help.js +1 -6
  106. package/dist/tools/files/help/help.js.map +1 -1
  107. package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
  108. package/dist/tools/suggest/help/constraint-help.js +0 -2
  109. package/dist/tools/suggest/help/constraint-help.js.map +1 -1
  110. package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
  111. package/dist/tools/suggest/internal/constraint-queries.js +12 -5
  112. package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
  113. package/dist/tools/suggest/internal/queries.js +2 -2
  114. package/dist/tools/suggest/internal/queries.js.map +1 -1
  115. package/dist/tools/tasks/help/help.d.ts.map +1 -1
  116. package/dist/tools/tasks/help/help.js +0 -6
  117. package/dist/tools/tasks/help/help.js.map +1 -1
  118. package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
  119. package/dist/tools/tasks/help/use-case.js +0 -1
  120. package/dist/tools/tasks/help/use-case.js.map +1 -1
  121. package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
  122. package/dist/tools/tasks/watcher/status.js +5 -1
  123. package/dist/tools/tasks/watcher/status.js.map +1 -1
  124. package/dist/types/decision/params.d.ts +7 -6
  125. package/dist/types/decision/params.d.ts.map +1 -1
  126. package/dist/types/decision/templates.d.ts +3 -2
  127. package/dist/types/decision/templates.d.ts.map +1 -1
  128. package/dist/types/view-entities.d.ts +2 -1
  129. package/dist/types/view-entities.d.ts.map +1 -1
  130. package/dist/types.d.ts +19 -11
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/types.js +4 -1
  133. package/dist/types.js.map +1 -1
  134. package/dist/utils/enum-converter.d.ts +72 -0
  135. package/dist/utils/enum-converter.d.ts.map +1 -0
  136. package/dist/utils/enum-converter.js +76 -0
  137. package/dist/utils/enum-converter.js.map +1 -0
  138. package/dist/utils/hook-queue.d.ts +81 -0
  139. package/dist/utils/hook-queue.d.ts.map +1 -0
  140. package/dist/utils/hook-queue.js +156 -0
  141. package/dist/utils/hook-queue.js.map +1 -0
  142. package/dist/utils/project-root.d.ts +9 -2
  143. package/dist/utils/project-root.d.ts.map +1 -1
  144. package/dist/utils/project-root.js +16 -2
  145. package/dist/utils/project-root.js.map +1 -1
  146. package/dist/utils/tag-parser.d.ts.map +1 -1
  147. package/dist/utils/tag-parser.js +6 -0
  148. package/dist/utils/tag-parser.js.map +1 -1
  149. package/dist/utils/validators.d.ts +1 -1
  150. package/dist/utils/validators.d.ts.map +1 -1
  151. package/dist/utils/validators.js +1 -1
  152. package/dist/utils/validators.js.map +1 -1
  153. package/dist/utils/vcs-adapter.d.ts +44 -0
  154. package/dist/utils/vcs-adapter.d.ts.map +1 -1
  155. package/dist/utils/vcs-adapter.js +88 -0
  156. package/dist/utils/vcs-adapter.js.map +1 -1
  157. package/dist/utils/view-queries.d.ts.map +1 -1
  158. package/dist/utils/view-queries.js +9 -19
  159. package/dist/utils/view-queries.js.map +1 -1
  160. package/dist/watcher/base-watcher.d.ts +69 -0
  161. package/dist/watcher/base-watcher.d.ts.map +1 -0
  162. package/dist/watcher/base-watcher.js +130 -0
  163. package/dist/watcher/base-watcher.js.map +1 -0
  164. package/dist/watcher/index.d.ts +3 -0
  165. package/dist/watcher/index.d.ts.map +1 -1
  166. package/dist/watcher/index.js +2 -0
  167. package/dist/watcher/index.js.map +1 -1
  168. package/dist/watcher/queue-watcher.d.ts +64 -0
  169. package/dist/watcher/queue-watcher.d.ts.map +1 -0
  170. package/dist/watcher/queue-watcher.js +187 -0
  171. package/dist/watcher/queue-watcher.js.map +1 -0
  172. package/docs/ADR_CONCEPTS.md +140 -0
  173. package/docs/CONFIGURATION.md +922 -925
  174. package/docs/CROSS_DATABASE.md +153 -0
  175. package/docs/DATABASE_AUTH.md +70 -356
  176. package/docs/HOOKS_GUIDE.md +159 -0
  177. package/docs/SLASH_COMMANDS.md +329 -337
  178. package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
  179. package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
  180. package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
  181. package/docs/cli/README.md +276 -277
  182. package/package.json +123 -124
  183. package/docs/ACCEPTANCE_CRITERIA.md +0 -625
  184. package/docs/AI_AGENT_GUIDE.md +0 -299
  185. package/docs/ARCHITECTURE.md +0 -167
  186. package/docs/AUTO_FILE_TRACKING.md +0 -841
  187. package/docs/BATCH_VALIDATION.md +0 -617
  188. package/docs/BEST_PRACTICES.md +0 -168
  189. package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
  190. package/docs/DECISION_CONTEXT.md +0 -697
  191. package/docs/DECISION_INTELLIGENCE.md +0 -605
  192. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
  193. package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
  194. package/docs/SHARED_CONCEPTS.md +0 -225
  195. package/docs/SPECIALIZED_AGENTS.md +0 -126
  196. package/docs/TASK_ACTIONS.md +0 -1177
  197. package/docs/TASK_OVERVIEW.md +0 -452
  198. package/docs/TASK_PRUNING.md +0 -594
  199. package/docs/TOOL_REFERENCE.md +0 -1077
  200. package/docs/TOOL_SELECTION.md +0 -83
  201. package/docs/WORKFLOWS.md +0 -941
@@ -1,299 +0,0 @@
1
- # AI Agent Guide for sqlew ADR System
2
-
3
- **Quick Reference for Claude Code and other AI agents using sqlew (v4.0.0+)**
4
-
5
- ## What is sqlew?
6
-
7
- sqlew is an **ADR (Architecture Decision Record) system designed for AI agents**. It enables you to create, query, and maintain structured architectural decisions in a SQL database, providing persistent context across sessions.
8
-
9
- ### Core Concept: ADR for AI
10
-
11
- Traditional ADR uses Markdown files. sqlew brings ADR to AI agents through **RDBMS + MCP**:
12
-
13
- **RDBMS (Relational Database)** enables efficient operations:
14
- - **Indexed queries** – Find decisions by tags/layers in milliseconds
15
- - **JOIN operations** – Query related decisions, constraints, and tasks together
16
- - **Transaction safety** – ACID guarantees prevent data corruption
17
- - **Scalability** – Handle thousands of ADRs without slowdown
18
-
19
- **MCP (Model Context Protocol)** provides AI-native access:
20
- - **Native tool calls** – AI agents use ADR as built-in functions
21
- - **Structured parameters** – Type-safe, validated inputs prevent errors
22
- - **Token efficiency** – Retrieve only required data (60-75% reduction)
23
- - **Session persistence** – ADRs survive beyond individual conversations
24
-
25
- **Result**: AI agents query ADRs like database operations, not file reads.
26
-
27
- ---
28
-
29
- ## Most Important Rule
30
-
31
- **ALWAYS include the `action` parameter in EVERY tool call.** This is the #1 cause of errors.
32
-
33
- ```javascript
34
- // WRONG - Missing action
35
- {
36
- key: "auth_method",
37
- value: "jwt"
38
- }
39
-
40
- // CORRECT - action parameter present
41
- {
42
- action: "set",
43
- key: "auth_method",
44
- value: "jwt"
45
- }
46
- ```
47
-
48
- ---
49
-
50
- ## Quick Start: Creating Your First ADR
51
-
52
- ### Basic ADR Workflow
53
-
54
- ```javascript
55
- // 1. Record an architectural decision
56
- {
57
- action: "set",
58
- key: "auth_method",
59
- value: "We chose JWT authentication over session-based auth. JWT enables stateless API design and better horizontal scaling. Session-based auth was rejected due to scaling concerns with shared session stores.",
60
- layer: "business",
61
- tags: ["security", "authentication", "api"]
62
- }
63
-
64
- // 2. Retrieve the decision
65
- {
66
- action: "get",
67
- key: "auth_method"
68
- }
69
-
70
- // 3. Search for related decisions
71
- {
72
- action: "list",
73
- tags: ["authentication"],
74
- status: "active"
75
- }
76
-
77
- // 4. Add architectural constraint
78
- {
79
- action: "add",
80
- category: "security",
81
- constraint_text: "All authentication must use JWT with RS256 signing algorithm",
82
- layer: "business"
83
- }
84
- ```
85
-
86
- ---
87
-
88
- ## When to Use Each Tool
89
-
90
- ### Core ADR Tools
91
-
92
- | Tool | ADR Purpose | Key Feature |
93
- |------|-------------|-------------|
94
- | **decision** | Record architectural decisions | Full version history, alternatives tracking |
95
- | **constraint** | Define architectural principles | Category-based rules, validation support |
96
- | **task** | Track decision implementation | Links to decisions, status tracking |
97
- | **file** | Document impacted code | Shows which files implement decisions |
98
- | **suggest** | Find similar decisions | Prevent duplicate ADRs, detect conflicts |
99
-
100
- ### Utility Tools
101
-
102
- | Tool | Purpose | When to Use |
103
- |------|---------|-------------|
104
- | **help** | Query action parameters | Need to check available parameters for an action |
105
- | **example** | Browse code examples | Want to see working code snippets |
106
- | **use_case** | Learn complete workflows | Need end-to-end multi-step scenarios |
107
-
108
- > **Note**: Utility tools provide documentation and examples without affecting your ADR data.
109
-
110
- ### Understanding the ADR Data Model
111
-
112
- | Concept | ADR Equivalent | Example |
113
- |---------|----------------|---------|
114
- | **Decision** | Architecture Decision Record | "We chose PostgreSQL over MongoDB for ACID compliance" |
115
- | **Constraint** | Architectural Principle/Rule | "All database queries must use prepared statements" |
116
- | **Task** | Implementation Action | "Migrate user authentication to JWT" |
117
- | **File** | Impacted Component | "Modified auth.ts to implement JWT" |
118
-
119
- ### Complete ADR Workflow Example
120
-
121
- ```javascript
122
- // 1. Record decision with full context
123
- {
124
- action: "set",
125
- key: "database_choice",
126
- value: "PostgreSQL selected for production database. Alternatives considered: MongoDB (rejected: no ACID), MySQL (rejected: weaker JSON support). PostgreSQL chosen for ACID compliance, mature ecosystem, and superior JSON handling.",
127
- layer: "data",
128
- tags: ["database", "postgresql", "architecture"]
129
- }
130
-
131
- // 2. Define constraints based on decision
132
- {
133
- action: "add",
134
- category: "database",
135
- constraint_text: "All database operations must use connection pooling with max 20 connections",
136
- layer: "data"
137
- }
138
-
139
- // 3. Create implementation task
140
- {
141
- action: "create",
142
- title: "Set up PostgreSQL connection pool",
143
- description: "Implement connection pooling as per database_choice ADR",
144
- layer: "data",
145
- tags: ["database", "postgresql"]
146
- }
147
-
148
- // 4. Track file changes
149
- {
150
- action: "set",
151
- path: "src/db/connection.ts",
152
- description: "PostgreSQL connection pool implementation",
153
- layer: "data"
154
- }
155
- ```
156
-
157
- ---
158
-
159
- ## Common Errors & Solutions
160
-
161
- ### Error: "Unknown action: undefined"
162
-
163
- **Cause**: Missing `action` parameter
164
-
165
- ```javascript
166
- // WRONG
167
- { key: "some_key", value: "some value" }
168
-
169
- // CORRECT
170
- { action: "set", key: "some_key", value: "some value" }
171
- ```
172
-
173
- ### Error: "Invalid layer"
174
-
175
- **Valid layers** (9 total):
176
- - `presentation`, `business`, `data`, `infrastructure`, `cross-cutting`
177
- - `documentation`, `planning`, `coordination`, `review`
178
-
179
- ### Error: "Invalid status"
180
-
181
- **Valid decision statuses**: `active`, `deprecated`, `draft`
182
-
183
- **Valid task statuses**: `pending`, `in_progress`, `blocked`, `on_hold`, `completed`
184
-
185
- ### Error: "Batch operations are limited to 50 items maximum"
186
-
187
- **Solution**: Split into multiple batches of ≤50 items each
188
-
189
- ---
190
-
191
- ## Key Parameters Quick Reference
192
-
193
- ### decision tool
194
-
195
- | Action | Required | Optional |
196
- |--------|----------|----------|
197
- | **set** | action, key, value, layer | version, status, tags, scopes |
198
- | **get** | action, key | version |
199
- | **list** | action | status, layer, tags, limit |
200
-
201
- ### task tool
202
-
203
- | Action | Required | Optional |
204
- |--------|----------|----------|
205
- | **create** | action, title | description, priority, layer, tags, status |
206
- | **move** | action, task_id, status | - |
207
- | **list** | action | status, layer, tags, limit |
208
-
209
- ### constraint tool
210
-
211
- | Action | Required | Optional |
212
- |--------|----------|----------|
213
- | **add** | action, category, constraint_text | priority, layer, tags |
214
- | **get** | action | category, layer, active_only |
215
-
216
- > **Full parameter reference**: See [TOOL_REFERENCE.md](TOOL_REFERENCE.md)
217
-
218
- ---
219
-
220
- ## ADR Best Practices for AI Agents
221
-
222
- ### Writing Good ADRs
223
-
224
- 1. **Include rationale** - Explain WHY, not just WHAT
225
- ```javascript
226
- // BAD: "Use PostgreSQL"
227
- // GOOD: "Use PostgreSQL for ACID compliance (rejected MongoDB for lack of transactions)"
228
- ```
229
-
230
- 2. **Document alternatives** - Show what was considered and rejected
231
- ```javascript
232
- value: "JWT chosen. Alternatives: session-based (rejected: scaling), OAuth (overkill for internal API)"
233
- ```
234
-
235
- 3. **Use descriptive keys** - Make decisions discoverable
236
- ```javascript
237
- // BAD: key: "db"
238
- // GOOD: key: "database_postgresql_production"
239
- ```
240
-
241
- 4. **Tag comprehensively** - Enable efficient searching
242
- ```javascript
243
- tags: ["database", "postgresql", "production", "acid", "scalability"]
244
- ```
245
-
246
- 5. **Link related entities** - Connect decisions to implementation
247
- ```javascript
248
- // Record decision → Create constraint → Make task → Track files
249
- ```
250
-
251
- ### Technical Best Practices
252
-
253
- 1. **Always include `action` parameter** - #1 error source
254
- 2. **Always specify `layer`** - Required for architectural organization
255
- 3. **Use `atomic: false` for batch operations** - Avoid all-or-nothing failures
256
- 4. **Check for duplicates first** - Use `suggest` tool before creating decisions
257
- 5. **Version important changes** - Increment version for significant updates
258
-
259
- > **Detailed best practices**: See [BEST_PRACTICES.md](BEST_PRACTICES.md)
260
-
261
- ---
262
-
263
- ## Built-In Documentation
264
-
265
- All tools provide built-in help with zero token cost:
266
-
267
- ```javascript
268
- // Get detailed help for any tool
269
- { action: "help" }
270
-
271
- // Get comprehensive examples
272
- { action: "example" }
273
- ```
274
-
275
- ---
276
-
277
- ## Related Documentation
278
-
279
- | Document | Content |
280
- |----------|---------|
281
- | [TOOL_REFERENCE.md](TOOL_REFERENCE.md) | Complete parameter reference |
282
- | [WORKFLOWS.md](WORKFLOWS.md) | Multi-step workflow examples |
283
- | [BEST_PRACTICES.md](BEST_PRACTICES.md) | Detailed best practices |
284
- | [DECISION_INTELLIGENCE.md](DECISION_INTELLIGENCE.md) | Decision duplicate detection |
285
- | [CONSTRAINT_INTELLIGENCE.md](CONSTRAINT_INTELLIGENCE.md) | Constraint duplicate detection |
286
- | [BATCH_VALIDATION.md](BATCH_VALIDATION.md) | Batch operations guide |
287
- | [ARCHITECTURE.md](ARCHITECTURE.md) | System architecture |
288
-
289
- ---
290
-
291
- ## Most Common Mistakes
292
-
293
- 1. **Missing `action` parameter** ← #1 error!
294
- 2. Invalid layer/status values
295
- 3. Forgetting to specify `layer` when setting decisions
296
- 4. Using `atomic: true` by default in batch operations
297
- 5. Using `new_status` instead of `status` for task.move
298
-
299
- **When in doubt**: Call `{action: "help"}` or `{action: "example"}`!
@@ -1,167 +0,0 @@
1
- # sqlew Architecture Documentation
2
-
3
- ## Overview
4
-
5
- sqlew (SQL Efficient Workflow) is an MCP server designed to achieve **72% token reduction** in context sharing between Claude Code agents through intelligent database design and metadata-driven architecture. **Version 4.0.0** introduces a major schema refactoring with unified v4_ table prefix and action-based MCP tool architecture.
6
-
7
- ## Core Design Principles
8
-
9
- ### 1. Token Efficiency Strategy
10
-
11
- The 72% token reduction is achieved through five key strategies:
12
-
13
- | Strategy | Description | Savings |
14
- |----------|-------------|---------|
15
- | **ID-Based Normalization** | Store strings once in master tables, reference by integer IDs | ~50% |
16
- | **Integer Enums** | Replace string values with integers (status, priority, etc.) | 70-75% |
17
- | **Pre-Aggregated Views** | Eliminate need for multiple joins in client code | ~85% |
18
- | **Type-Based Separation** | Separate tables for numeric vs string values | ~50% |
19
- | **Automatic Cleanup** | Prevent database bloat via triggers | N/A |
20
-
21
- ### 2. Metadata-Driven Classification
22
-
23
- sqlew organizes data through five metadata dimensions:
24
-
25
- | Dimension | Purpose | Example |
26
- |-----------|---------|---------|
27
- | **Tags** | Flexible cross-cutting categorization | authentication, security, api |
28
- | **Layers** | Architecture layer organization (9 layers) | business, data, infrastructure |
29
- | **Scopes** | Module/component-level organization | user-service, api-gateway |
30
- | **Versions** | Automatic version history tracking | 1.0.0, 1.1.0 |
31
- | **Priority** | Importance levels (1-4) | low, medium, high, critical |
32
-
33
- ### 3. Layer System (v4.0)
34
-
35
- 9 layers organized by file requirement:
36
-
37
- **FILE_REQUIRED (6 layers):**
38
- - presentation, business, data, infrastructure, cross-cutting, documentation
39
-
40
- **FILE_OPTIONAL (3 layers):**
41
- - planning, coordination, review
42
-
43
- ### 4. Data Integrity
44
-
45
- - **Foreign Key Constraints**: All relationships enforced via SQLite
46
- - **Transaction Guarantees**: ACID properties, WAL mode for concurrency
47
- - **Auto-Registration Pattern**: Master records auto-created on first use
48
-
49
- ## Database Schema (v4.0)
50
-
51
- All tables use unified `v4_` prefix. For detailed schema, see `src/database/migrations/v4/`.
52
-
53
- ### Master Tables (Normalization)
54
-
55
- | Table | Purpose |
56
- |-------|---------|
57
- | `v4_files` | Normalize file paths |
58
- | `v4_context_keys` | Normalize decision keys |
59
- | `v4_layers` | Architecture layers (9 seeded) |
60
- | `v4_tags` | Categorization tags (10 seeded, auto-expandable) |
61
- | `v4_scopes` | Module/component scopes |
62
- | `v4_constraint_categories` | Constraint types (performance, architecture, security) |
63
- | `v4_task_statuses` | Task status types (pending, in_progress, completed, blocked, on_hold) |
64
- | `v4_config` | Configuration storage |
65
-
66
- ### Transaction Tables (Core Data)
67
-
68
- | Table | Purpose |
69
- |-------|---------|
70
- | `v4_decisions` | Store decisions with layer, status, version |
71
- | `v4_decision_history` | Version history for all decision changes |
72
- | `v4_decision_context` | Decision context (rationale, alternatives, tradeoffs) |
73
- | `v4_file_changes` | Track file modifications with layer |
74
- | `v4_constraints` | Project constraints with priority |
75
- | `v4_tasks` | Task management with kanban-style status |
76
-
77
- ### Relationship Tables
78
-
79
- | Table | Purpose |
80
- |-------|---------|
81
- | `v4_decision_tags` | Decision ↔ Tags (many-to-many) |
82
- | `v4_decision_scopes` | Decision ↔ Scopes (many-to-many) |
83
- | `v4_task_file_links` | Task ↔ Files with action types |
84
- | `v4_task_dependencies` | Task dependencies with circular detection |
85
-
86
- ### Pre-Aggregated Views
87
-
88
- | View | Purpose |
89
- |------|---------|
90
- | `v4_tagged_decisions` | Decisions with all metadata (tags, layers, scopes) |
91
- | `v4_layer_summary` | Per-layer aggregated statistics |
92
- | `v4_recent_file_changes` | Recent file changes with metadata |
93
- | `v4_tagged_constraints` | Constraints with category and layer |
94
- | `v4_task_board` | Kanban-style task view with dependencies |
95
-
96
- ## MCP Tool Architecture
97
-
98
- ### Action-Based Tool System (v4.0)
99
-
100
- 6 consolidated action-based MCP tools:
101
-
102
- | Tool | Purpose | Key Actions |
103
- |------|---------|-------------|
104
- | **decision** | Decision context management | set, get, list, search, versions |
105
- | **file** | File change tracking | record, get, check_lock |
106
- | **constraint** | Constraint management | add, get, deactivate |
107
- | **task** | Task management with dependencies | create, update, move, link, list |
108
- | **help** | Documentation queries | query_action, query_tool, workflow_hints |
109
- | **suggest** | Decision intelligence | by_key, by_tags, check_duplicate |
110
-
111
- All tools support `action: "help"` for in-tool documentation.
112
-
113
- ## Performance Characteristics
114
-
115
- ### Query Performance
116
-
117
- | Operation | Avg Time |
118
- |-----------|----------|
119
- | decision.set | 2-5 ms |
120
- | decision.get | 5-15 ms |
121
- | file.record | 2-4 ms |
122
- | task.create | 3-7 ms |
123
-
124
- ### Database Size
125
-
126
- - **Empty:** ~28 KB (schema + seed data)
127
- - **Growth Rate:** ~140 bytes/decision (linear)
128
-
129
- ### Concurrent Access
130
-
131
- - **WAL Mode:** Enabled for read/write concurrency
132
- - **Busy Timeout:** 5000ms
133
-
134
- ## File Structure
135
-
136
- | Component | Location |
137
- |-----------|----------|
138
- | MCP Server | `src/index.ts` |
139
- | Database Init | `src/database/initialization/` |
140
- | Migrations | `src/database/migrations/v4/` |
141
- | Tool Implementations | `src/tools/` |
142
- | Types | `src/types.ts` |
143
- | Constants | `src/constants.ts` |
144
-
145
- ## Known Limitations
146
-
147
- 1. **No Semantic Search:** Delegated to specialized tools like Serena
148
- 2. **Single Project Scope:** Not multi-tenant
149
- 3. **No Authentication:** Trust-based (local MCP server)
150
- 4. **No Network Access:** Offline-only operation
151
-
152
- ## Version History
153
-
154
- | Version | Key Changes |
155
- |---------|-------------|
156
- | **v4.0.0** | Unified v4_ prefix, agent system removed, 6 action-based tools, 9 layers |
157
- | v3.9.0 | Decision Intelligence System, suggestion policies |
158
- | v3.8.0 | Layer expansion (5→9), file_actions parameter |
159
- | v3.0.0 | Kanban task system, 7-tool consolidation |
160
- | v2.0 | Action-based API, 96% token reduction |
161
-
162
- ## Related Documentation
163
-
164
- - [SHARED_CONCEPTS.md](SHARED_CONCEPTS.md) - Common concepts across tools
165
- - [TOOL_REFERENCE.md](TOOL_REFERENCE.md) - Complete tool parameter reference
166
- - [CONFIGURATION.md](CONFIGURATION.md) - Configuration options
167
- - [TASK_OVERVIEW.md](TASK_OVERVIEW.md) - Task management overview