sqlew 1.1.2 → 2.0.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.
- package/CHANGELOG.md +73 -0
- package/MIGRATION_v2.md +538 -0
- package/README.md +136 -75
- package/dist/index.js +265 -693
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/sqlew)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
**sqlew** (SQL Efficient Workflow) is a Model Context Protocol (MCP) server for efficient context sharing between Claude Code sub-agents. Achieve **
|
|
6
|
+
**sqlew** (SQL Efficient Workflow) is a Model Context Protocol (MCP) server for efficient context sharing between Claude Code sub-agents. Achieve **96% token reduction** through action-based tools while managing structured data through a metadata-driven SQLite database.
|
|
7
|
+
|
|
8
|
+
## ⚠️ Version 2.0.0 - Breaking Changes
|
|
9
|
+
|
|
10
|
+
**v2.0.0 introduces action-based tools that consolidate the API from 20 tools to 6 tools.** This is a breaking change in the MCP tool API only.
|
|
11
|
+
|
|
12
|
+
**Database Compatibility:** ✅ **100% compatible** - v2.0 uses the same database schema as v1.x. No data migration needed.
|
|
13
|
+
|
|
14
|
+
**Migration Required:** Only for code that calls MCP tools - see [MIGRATION_v2.md](MIGRATION_v2.md) for upgrade guide.
|
|
7
15
|
|
|
8
16
|
## Why sqlew?
|
|
9
17
|
|
|
10
18
|
When coordinating multiple Claude Code agents on a complex project, context sharing becomes critical. Traditional JSON-based approaches consume massive amounts of tokens. sqlew solves this with:
|
|
11
19
|
|
|
12
|
-
- **
|
|
20
|
+
- **96% Token Reduction:** Action-based API eliminates tool duplication (12,848 → 481 tokens)
|
|
21
|
+
- **67% MCP Context Reduction:** From ~13,730 to ~4,482 tokens in MCP server definitions
|
|
13
22
|
- **Structured Metadata:** Tags, layers, scopes, versions, and priorities for intelligent organization
|
|
14
23
|
- **Fast & Reliable:** SQLite-backed with ACID guarantees and automatic cleanup
|
|
15
|
-
- **
|
|
24
|
+
- **6 Action-Based Tools:** Comprehensive API for decisions, messaging, file tracking, constraints, config, and stats
|
|
25
|
+
- **Help Actions:** On-demand documentation with zero token cost until called
|
|
16
26
|
|
|
17
27
|
## Features
|
|
18
28
|
|
|
@@ -92,15 +102,20 @@ npx @modelcontextprotocol/inspector npx sqlew
|
|
|
92
102
|
|
|
93
103
|
Default: `.sqlew/sqlew.db` (created in current directory)
|
|
94
104
|
|
|
95
|
-
## Available Tools
|
|
105
|
+
## Available Tools (v2.0.0)
|
|
96
106
|
|
|
97
|
-
|
|
107
|
+
All tools now use action-based routing. Call any tool with `action: "help"` for comprehensive documentation.
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
### `decision` - Context Management
|
|
110
|
+
|
|
111
|
+
Manage decisions with metadata (tags, layers, versions, scopes).
|
|
112
|
+
|
|
113
|
+
**Actions:** `set`, `get`, `list`, `search_tags`, `search_layer`, `versions`, `help`
|
|
101
114
|
|
|
102
115
|
```typescript
|
|
116
|
+
// Set a decision
|
|
103
117
|
{
|
|
118
|
+
action: "set",
|
|
104
119
|
key: "auth_method",
|
|
105
120
|
value: "JWT",
|
|
106
121
|
agent: "auth-agent",
|
|
@@ -110,39 +125,47 @@ Set or update a decision with metadata support.
|
|
|
110
125
|
version: "1.0.0",
|
|
111
126
|
status: "active"
|
|
112
127
|
}
|
|
113
|
-
```
|
|
114
128
|
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
// Get decision by key
|
|
130
|
+
{
|
|
131
|
+
action: "get",
|
|
132
|
+
key: "auth_method"
|
|
133
|
+
}
|
|
117
134
|
|
|
118
|
-
|
|
135
|
+
// List with filtering
|
|
119
136
|
{
|
|
137
|
+
action: "list",
|
|
120
138
|
status: "active",
|
|
121
|
-
layer: "business"
|
|
122
|
-
tags: ["authentication"],
|
|
123
|
-
tag_match: "AND"
|
|
139
|
+
layer: "business"
|
|
124
140
|
}
|
|
125
|
-
```
|
|
126
141
|
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
// Search by tags
|
|
143
|
+
{
|
|
144
|
+
action: "search_tags",
|
|
145
|
+
tags: ["authentication", "security"],
|
|
146
|
+
tag_match: "AND"
|
|
147
|
+
}
|
|
129
148
|
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
// Get version history
|
|
150
|
+
{
|
|
151
|
+
action: "versions",
|
|
152
|
+
key: "auth_method"
|
|
153
|
+
}
|
|
132
154
|
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
// Get help
|
|
156
|
+
{ action: "help" }
|
|
157
|
+
```
|
|
135
158
|
|
|
136
|
-
|
|
137
|
-
Search decisions within an architecture layer.
|
|
159
|
+
### `message` - Agent Messaging
|
|
138
160
|
|
|
139
|
-
|
|
161
|
+
Send and retrieve messages between agents with priority levels.
|
|
140
162
|
|
|
141
|
-
|
|
142
|
-
Send messages between agents with priority levels.
|
|
163
|
+
**Actions:** `send`, `get`, `mark_read`, `help`
|
|
143
164
|
|
|
144
165
|
```typescript
|
|
166
|
+
// Send message
|
|
145
167
|
{
|
|
168
|
+
action: "send",
|
|
146
169
|
from_agent: "agent1",
|
|
147
170
|
to_agent: "agent2",
|
|
148
171
|
msg_type: "warning",
|
|
@@ -150,86 +173,118 @@ Send messages between agents with priority levels.
|
|
|
150
173
|
priority: "high",
|
|
151
174
|
payload: { file: "/src/auth.ts" }
|
|
152
175
|
}
|
|
153
|
-
```
|
|
154
176
|
|
|
155
|
-
|
|
156
|
-
|
|
177
|
+
// Get messages
|
|
178
|
+
{
|
|
179
|
+
action: "get",
|
|
180
|
+
unread_only: true,
|
|
181
|
+
priority_filter: "high"
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Mark as read
|
|
185
|
+
{
|
|
186
|
+
action: "mark_read",
|
|
187
|
+
message_ids: [1, 2, 3]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
157
190
|
|
|
158
|
-
|
|
159
|
-
Mark messages as read.
|
|
191
|
+
### `file` - File Change Tracking
|
|
160
192
|
|
|
161
|
-
|
|
193
|
+
Track file modifications with layer assignment and lock detection.
|
|
162
194
|
|
|
163
|
-
|
|
164
|
-
Record file changes with layer assignment.
|
|
195
|
+
**Actions:** `record`, `get`, `check_lock`, `help`
|
|
165
196
|
|
|
166
197
|
```typescript
|
|
198
|
+
// Record file change
|
|
167
199
|
{
|
|
200
|
+
action: "record",
|
|
168
201
|
file_path: "/src/auth.ts",
|
|
169
202
|
agent_name: "auth-agent",
|
|
170
203
|
change_type: "modified",
|
|
171
204
|
layer: "business",
|
|
172
205
|
description: "Updated JWT validation"
|
|
173
206
|
}
|
|
174
|
-
```
|
|
175
207
|
|
|
176
|
-
|
|
177
|
-
|
|
208
|
+
// Get file changes
|
|
209
|
+
{
|
|
210
|
+
action: "get",
|
|
211
|
+
since: "2025-01-10T10:00:00Z",
|
|
212
|
+
layer: "business"
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Check file lock
|
|
216
|
+
{
|
|
217
|
+
action: "check_lock",
|
|
218
|
+
file_path: "/src/auth.ts",
|
|
219
|
+
lock_duration: 300
|
|
220
|
+
}
|
|
221
|
+
```
|
|
178
222
|
|
|
179
|
-
|
|
180
|
-
Check if a file is recently modified (prevents concurrent edits).
|
|
223
|
+
### `constraint` - Constraint Management
|
|
181
224
|
|
|
182
|
-
|
|
225
|
+
Manage architectural, performance, and security constraints.
|
|
183
226
|
|
|
184
|
-
|
|
185
|
-
Add constraints with priority and metadata.
|
|
227
|
+
**Actions:** `add`, `get`, `deactivate`, `help`
|
|
186
228
|
|
|
187
229
|
```typescript
|
|
230
|
+
// Add constraint
|
|
188
231
|
{
|
|
232
|
+
action: "add",
|
|
189
233
|
category: "performance",
|
|
190
234
|
constraint_text: "Response time < 200ms",
|
|
191
235
|
priority: "high",
|
|
192
236
|
layer: "business",
|
|
193
237
|
tags: ["api", "performance"]
|
|
194
238
|
}
|
|
195
|
-
```
|
|
196
239
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
240
|
+
// Get constraints
|
|
241
|
+
{
|
|
242
|
+
action: "get",
|
|
243
|
+
category: "performance",
|
|
244
|
+
active_only: true
|
|
245
|
+
}
|
|
202
246
|
|
|
203
|
-
|
|
247
|
+
// Deactivate constraint
|
|
248
|
+
{
|
|
249
|
+
action: "deactivate",
|
|
250
|
+
constraint_id: 42
|
|
251
|
+
}
|
|
252
|
+
```
|
|
204
253
|
|
|
205
|
-
|
|
206
|
-
Get aggregated statistics per architecture layer.
|
|
254
|
+
### `stats` - Statistics & Utilities
|
|
207
255
|
|
|
208
|
-
|
|
209
|
-
Manually clear old messages and file changes (uses weekend-aware config when no params provided).
|
|
256
|
+
Get database statistics and manage data cleanup.
|
|
210
257
|
|
|
211
|
-
|
|
212
|
-
Get comprehensive database statistics.
|
|
258
|
+
**Actions:** `layer_summary`, `db_stats`, `clear`, `help`
|
|
213
259
|
|
|
214
|
-
|
|
260
|
+
```typescript
|
|
261
|
+
// Layer summary
|
|
262
|
+
{ action: "layer_summary" }
|
|
215
263
|
|
|
216
|
-
|
|
217
|
-
|
|
264
|
+
// Database stats
|
|
265
|
+
{ action: "db_stats" }
|
|
218
266
|
|
|
219
|
-
|
|
220
|
-
// Returns:
|
|
267
|
+
// Clear old data (weekend-aware)
|
|
221
268
|
{
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
269
|
+
action: "clear",
|
|
270
|
+
messages_older_than_hours: 48,
|
|
271
|
+
file_changes_older_than_days: 14
|
|
225
272
|
}
|
|
226
273
|
```
|
|
227
274
|
|
|
228
|
-
|
|
229
|
-
|
|
275
|
+
### `config` - Configuration
|
|
276
|
+
|
|
277
|
+
Manage auto-deletion and retention settings.
|
|
278
|
+
|
|
279
|
+
**Actions:** `get`, `update`, `help`
|
|
230
280
|
|
|
231
281
|
```typescript
|
|
282
|
+
// Get config
|
|
283
|
+
{ action: "get" }
|
|
284
|
+
|
|
285
|
+
// Update config
|
|
232
286
|
{
|
|
287
|
+
action: "update",
|
|
233
288
|
ignoreWeekend: true,
|
|
234
289
|
messageRetentionHours: 48,
|
|
235
290
|
fileHistoryRetentionDays: 10
|
|
@@ -254,13 +309,19 @@ When upgrading from v1.2.0 to v1.3.0, the server automatically migrates your dat
|
|
|
254
309
|
|
|
255
310
|
## Token Efficiency
|
|
256
311
|
|
|
257
|
-
sqlew achieves **
|
|
312
|
+
sqlew achieves **96% token reduction** through:
|
|
313
|
+
|
|
314
|
+
1. **Action-Based Tools (v2.0):** Consolidates 20 tools → 6 tools, eliminating duplication
|
|
315
|
+
2. **ID-Based Normalization:** Strings stored once, referenced by integer IDs
|
|
316
|
+
3. **Integer Enums:** Status, priority, message types use integers (1-4) instead of strings
|
|
317
|
+
4. **Pre-Aggregated Views:** Common queries use pre-computed results
|
|
318
|
+
5. **Type-Based Tables:** Separate storage for numeric vs string values
|
|
319
|
+
6. **Automatic Cleanup:** Prevents database bloat
|
|
320
|
+
|
|
321
|
+
### v2.0.0 Token Savings
|
|
258
322
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
3. **Pre-Aggregated Views:** Common queries use pre-computed results
|
|
262
|
-
4. **Type-Based Tables:** Separate storage for numeric vs string values
|
|
263
|
-
5. **Automatic Cleanup:** Prevents database bloat
|
|
323
|
+
- **Tool Definitions:** 12,848 → 481 tokens (96.3% reduction)
|
|
324
|
+
- **MCP Context Usage:** ~13,730 → ~4,482 tokens (67% reduction)
|
|
264
325
|
|
|
265
326
|
### Example Comparison
|
|
266
327
|
|
|
@@ -324,11 +385,11 @@ npm start
|
|
|
324
385
|
### Testing
|
|
325
386
|
|
|
326
387
|
```bash
|
|
327
|
-
#
|
|
328
|
-
node verify-all-tools.mjs
|
|
329
|
-
|
|
330
|
-
# Or use MCP Inspector
|
|
388
|
+
# Use MCP Inspector to test all tools
|
|
331
389
|
npm run inspector
|
|
390
|
+
|
|
391
|
+
# Or test individual tools via CLI
|
|
392
|
+
npx @modelcontextprotocol/inspector npx sqlew
|
|
332
393
|
```
|
|
333
394
|
|
|
334
395
|
### Project Structure
|