sqlew 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +222 -0
- package/README.md +314 -209
- package/assets/schema.sql +122 -36
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +312 -0
- package/dist/cli.js.map +1 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +18 -0
- package/dist/database.js.map +1 -1
- package/dist/index.js +136 -42
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-v2.1.0-features.d.ts +29 -0
- package/dist/migrations/add-v2.1.0-features.d.ts.map +1 -0
- package/dist/migrations/add-v2.1.0-features.js +198 -0
- package/dist/migrations/add-v2.1.0-features.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -0
- package/dist/schema.js.map +1 -1
- package/dist/tools/context.d.ts +91 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +695 -70
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts +10 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +98 -1
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +10 -1
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +107 -1
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/utils.d.ts +9 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +115 -0
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +196 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cleanup.d.ts +12 -1
- package/dist/utils/cleanup.d.ts.map +1 -1
- package/dist/utils/cleanup.js +20 -3
- package/dist/utils/cleanup.js.map +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,226 @@ All notable changes to sqlew will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.1.1] - 2025-10-15
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Bin Command Configuration:** Fixed `npx sqlew` to launch MCP server by default instead of CLI
|
|
12
|
+
- Changed `package.json` bin mapping: `sqlew` now points to MCP server (`dist/index.js`)
|
|
13
|
+
- CLI mode moved to `sqlew-cli` command (`dist/cli.js`)
|
|
14
|
+
- **Before:** `npx sqlew` → CLI mode, `npx sqlew-server` → MCP server
|
|
15
|
+
- **After:** `npx sqlew` → MCP server (default), `npx sqlew-cli` → CLI mode (optional)
|
|
16
|
+
- Fixes user experience issue where MCP server launch required non-intuitive command
|
|
17
|
+
|
|
18
|
+
- **Batch Operations Nested Transaction Bug:** Fixed `set_batch` failing with "cannot start a transaction within a transaction" error
|
|
19
|
+
- Root cause: `setDecision()` wraps logic in `transaction()`, but `setDecisionBatch()` also wraps calls in `transaction()` for atomic mode
|
|
20
|
+
- Solution: Created `setDecisionInternal()` helper function with core logic but no transaction wrapper
|
|
21
|
+
- `setDecision()` now calls `setDecisionInternal()` wrapped in transaction
|
|
22
|
+
- `setDecisionBatch()` now calls `setDecisionInternal()` directly (batch manages its own transaction)
|
|
23
|
+
- All batch operations verified working: `set_batch`, `send_batch`, `record_batch`
|
|
24
|
+
- Location: `src/tools/context.ts:40-152` (setDecisionInternal), `context.ts:154-174` (setDecision), `context.ts:883` (setDecisionBatch)
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- **Documentation Improvements:**
|
|
28
|
+
- **README Benefits Section:** Rewrote to emphasize organizational memory for AI agents as the core value proposition
|
|
29
|
+
- Added comparison table: Git history (WHAT) vs Code comments (HOW) vs sqlew decisions (WHY)
|
|
30
|
+
- Added real-world example showing cross-session context survival
|
|
31
|
+
- Highlighted 4 key LLM benefits: context survival, prevents regression, historical reasoning, knowledge discovery
|
|
32
|
+
- **README Token Savings:** Replaced internal architecture metrics with honest real-world token reduction analysis
|
|
33
|
+
- Shows concrete scenario: 5 agents, 10 sessions, 20,000 → 7,400 tokens (63% reduction)
|
|
34
|
+
- Explains 4 savings mechanisms: selective retrieval, structured vs unstructured, cross-session persistence, search vs scan
|
|
35
|
+
- Provides realistic ranges: Conservative (50-65%), Realistic (60-75%), Optimal (70-85%)
|
|
36
|
+
- Clarified that 96%/67% metrics are internal v1.0→v2.0 improvements, not usage benefits
|
|
37
|
+
|
|
38
|
+
### Migration Notes
|
|
39
|
+
- No breaking changes for MCP tool API
|
|
40
|
+
- Users who relied on `npx sqlew` for CLI should update to `npx sqlew-cli`
|
|
41
|
+
- MCP server configuration unchanged (still uses stdio transport)
|
|
42
|
+
|
|
43
|
+
## [2.1.0] - 2025-10-14
|
|
44
|
+
|
|
45
|
+
### 🎉 Feature Release
|
|
46
|
+
|
|
47
|
+
**Major enhancement release implementing 7 feature requests from real-world usage in the Trackne Server project. Adds activity logging, smart defaults, subscriptions, advanced querying, batch operations, templates, and a standalone CLI tool.**
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
#### FR-001: Activity Log System
|
|
52
|
+
- **Automatic Activity Logging:** All decision changes, messages, and file modifications are now automatically logged
|
|
53
|
+
- New `t_activity_log` table with 3 optimized indexes
|
|
54
|
+
- 4 triggers for automatic logging:
|
|
55
|
+
- `trg_log_decision_insert` - Logs decision creation
|
|
56
|
+
- `trg_log_decision_update` - Logs decision modifications
|
|
57
|
+
- `trg_log_message_insert` - Logs message sending
|
|
58
|
+
- `trg_log_file_change_insert` - Logs file changes
|
|
59
|
+
- `getActivityLog` action in `stats` tool for retrieving filtered logs
|
|
60
|
+
- Filter by agent, entity type, action type, and time range
|
|
61
|
+
- Token-efficient logging (~50 bytes per log entry)
|
|
62
|
+
|
|
63
|
+
#### FR-002: Smart Defaults
|
|
64
|
+
- **quickSetDecision:** Streamlined decision setting with automatic layer inference
|
|
65
|
+
- Infers layer from key patterns (e.g., "auth_*" → infrastructure)
|
|
66
|
+
- Auto-extracts tags from key and value (e.g., "jwt_config" → ["jwt", "config"])
|
|
67
|
+
- Reduces token usage by ~60% for simple decisions
|
|
68
|
+
- Falls back to manual tagging when inference is ambiguous
|
|
69
|
+
- New `quick_set` action in `decision` tool
|
|
70
|
+
|
|
71
|
+
#### FR-003: Lightweight Subscriptions
|
|
72
|
+
- **hasUpdates Polling:** Efficient change detection for agents
|
|
73
|
+
- Check for updates since last check (~5-10 tokens per call)
|
|
74
|
+
- Filter by entity type (decisions, messages, files)
|
|
75
|
+
- Filter by scope, layer, or agent
|
|
76
|
+
- Returns boolean + count + latest timestamp
|
|
77
|
+
- New `has_updates` action in `decision` tool
|
|
78
|
+
- 95% token reduction vs full list queries
|
|
79
|
+
|
|
80
|
+
#### FR-004: Advanced Query System
|
|
81
|
+
- **searchAdvanced:** Comprehensive search across all decision metadata
|
|
82
|
+
- 13 query parameters: keys, tags, scopes, layers, status, versions, full-text search
|
|
83
|
+
- Pagination support (limit, offset)
|
|
84
|
+
- Sort by multiple fields with direction control
|
|
85
|
+
- Full-text search in keys and values
|
|
86
|
+
- Scope inheritance (search within parent scopes)
|
|
87
|
+
- New `search_advanced` action in `decision` tool
|
|
88
|
+
- Replaces multiple sequential queries with single call
|
|
89
|
+
|
|
90
|
+
#### FR-005: Batch Operations
|
|
91
|
+
- **Atomic Batch Processing:** Process multiple operations in a single transaction
|
|
92
|
+
- `setDecisionBatch` - Set up to 50 decisions atomically
|
|
93
|
+
- `sendMessageBatch` - Send multiple messages in one transaction
|
|
94
|
+
- `recordFileChangeBatch` - Record multiple file changes atomically
|
|
95
|
+
- All-or-nothing guarantee (rollback on any failure)
|
|
96
|
+
- ~70% token reduction vs sequential calls
|
|
97
|
+
- New actions: `set_batch` (decision), `send_batch` (message), `record_batch` (file)
|
|
98
|
+
|
|
99
|
+
#### FR-006: Template System
|
|
100
|
+
- **Decision Templates:** Reusable decision patterns with validation
|
|
101
|
+
- 5 built-in templates: auth_config, api_endpoint, db_schema, ui_component, feature_flag
|
|
102
|
+
- `createTemplate` - Define custom templates with field schemas
|
|
103
|
+
- `setFromTemplate` - Create decisions from templates with validation
|
|
104
|
+
- `listTemplates` - Browse available templates
|
|
105
|
+
- Template inheritance and composition support
|
|
106
|
+
- New `t_decision_templates` table
|
|
107
|
+
- New actions: `set_from_template`, `create_template`, `list_templates` (decision tool)
|
|
108
|
+
|
|
109
|
+
#### FR-007: Standalone CLI Query Tool
|
|
110
|
+
- **Command-Line Interface:** Query MCP database without starting MCP server
|
|
111
|
+
- 4 commands: `decisions`, `messages`, `files`, `activity`
|
|
112
|
+
- JSON and table output formats
|
|
113
|
+
- Filter options match MCP tool parameters
|
|
114
|
+
- Supports all query patterns from MCP tools
|
|
115
|
+
- Zero MCP token impact (standalone binary)
|
|
116
|
+
- New script: `src/cli.ts`
|
|
117
|
+
- Usage: `node dist/cli.js decisions --scope=auth --format=table`
|
|
118
|
+
|
|
119
|
+
### Changed
|
|
120
|
+
|
|
121
|
+
- **Tool Definitions:** Added 11 new actions across 3 tools
|
|
122
|
+
- `decision` tool: 7 → 11 actions (+4: quick_set, has_updates, search_advanced, set_batch, set_from_template, create_template, list_templates)
|
|
123
|
+
- `message` tool: 4 → 5 actions (+1: send_batch)
|
|
124
|
+
- `file` tool: 4 → 5 actions (+1: record_batch)
|
|
125
|
+
- `stats` tool: 4 → 5 actions (+1: getActivityLog)
|
|
126
|
+
- **Database Schema:** v2.1.0 migration adds 2 tables and 4 triggers
|
|
127
|
+
- **Token Efficiency:** Maintains 92% efficiency vs v1.0.0 original design
|
|
128
|
+
- Tool definitions: 481 → 1,031 tokens (+550 tokens for 11 new actions)
|
|
129
|
+
- CLI has zero MCP token impact (standalone)
|
|
130
|
+
- Batch operations save ~70% tokens vs sequential calls
|
|
131
|
+
- hasUpdates saves ~95% tokens vs full list queries
|
|
132
|
+
|
|
133
|
+
### Technical Details
|
|
134
|
+
|
|
135
|
+
#### Database Changes
|
|
136
|
+
- **New Tables:**
|
|
137
|
+
- `t_activity_log` - Automatic logging of all changes (agent_id, entity_type, entity_id, action_type, details, ts)
|
|
138
|
+
- `t_decision_templates` - Template definitions (name, description, schema, layer, tags, created_by, created_at)
|
|
139
|
+
- **New Indexes:**
|
|
140
|
+
- `idx_activity_log_agent_ts` - Agent-based log queries
|
|
141
|
+
- `idx_activity_log_entity_ts` - Entity-based log queries
|
|
142
|
+
- `idx_activity_log_ts` - Time-based log queries
|
|
143
|
+
- **New Triggers:**
|
|
144
|
+
- `trg_log_decision_insert`, `trg_log_decision_update` - Decision logging
|
|
145
|
+
- `trg_log_message_insert` - Message logging
|
|
146
|
+
- `trg_log_file_change_insert` - File change logging
|
|
147
|
+
|
|
148
|
+
#### Migration
|
|
149
|
+
- **Migration Script:** `src/migrations/add-v2.1.0-features.ts`
|
|
150
|
+
- Creates `t_activity_log` and `t_decision_templates` tables
|
|
151
|
+
- Creates 3 indexes for activity log queries
|
|
152
|
+
- Creates 4 triggers for automatic logging
|
|
153
|
+
- Seeds 5 built-in templates
|
|
154
|
+
- Transaction-based with rollback on failure
|
|
155
|
+
- Automatic execution on startup
|
|
156
|
+
- Backward compatible with v2.0.0 databases
|
|
157
|
+
|
|
158
|
+
#### Performance
|
|
159
|
+
- **Token Efficiency:**
|
|
160
|
+
- Batch operations: ~70% reduction vs sequential (3 operations: 1,200 → 360 tokens)
|
|
161
|
+
- hasUpdates polling: ~95% reduction vs full list (500 → 25 tokens)
|
|
162
|
+
- quickSetDecision: ~60% reduction vs manual (250 → 100 tokens)
|
|
163
|
+
- Templates: ~50% reduction for repeated patterns
|
|
164
|
+
- **Query Performance:**
|
|
165
|
+
- Activity log queries: 5-15ms (with indexes)
|
|
166
|
+
- Advanced search: 10-30ms (with full-text)
|
|
167
|
+
- Batch operations: 20-50ms (atomic transaction)
|
|
168
|
+
- Template operations: 5-10ms
|
|
169
|
+
|
|
170
|
+
#### Code Statistics
|
|
171
|
+
- **Source Changes:**
|
|
172
|
+
- New files: `src/cli.ts`, `src/migrations/add-v2.1.0-features.ts`
|
|
173
|
+
- Modified: `src/tools/context.ts`, `src/tools/messaging.ts`, `src/tools/files.ts`, `src/tools/utils.ts`
|
|
174
|
+
- Total lines added: ~1,500 lines
|
|
175
|
+
- **CLI Tool:**
|
|
176
|
+
- Standalone binary (~300 lines)
|
|
177
|
+
- Zero dependencies on MCP server
|
|
178
|
+
- Supports all common query patterns
|
|
179
|
+
|
|
180
|
+
### Real-World Impact
|
|
181
|
+
|
|
182
|
+
These features were requested during development of the **Trackne Server** project:
|
|
183
|
+
- **Activity Log:** Essential for debugging multi-agent coordination
|
|
184
|
+
- **Smart Defaults:** Reduced boilerplate by 60% for common decisions
|
|
185
|
+
- **Subscriptions:** Enabled efficient polling without full list queries
|
|
186
|
+
- **Advanced Query:** Replaced 5-10 sequential queries with single calls
|
|
187
|
+
- **Batch Operations:** Critical for atomic state updates across agents
|
|
188
|
+
- **Templates:** Standardized patterns across 15+ API endpoints
|
|
189
|
+
- **CLI Tool:** Enabled quick debugging without starting MCP server
|
|
190
|
+
|
|
191
|
+
### Migration from v2.0.0
|
|
192
|
+
|
|
193
|
+
No breaking changes. All v2.0.0 tool calls work unchanged. New features are opt-in:
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
// NEW: Quick decision setting with smart defaults
|
|
197
|
+
await callTool('decision', { action: 'quick_set', key: 'jwt_config', value: 'HS256' });
|
|
198
|
+
// Auto-infers layer=infrastructure, tags=["jwt", "config"]
|
|
199
|
+
|
|
200
|
+
// NEW: Check for updates efficiently
|
|
201
|
+
await callTool('decision', { action: 'has_updates', since: '2025-10-14T10:00:00Z' });
|
|
202
|
+
// Returns: { hasUpdates: true, count: 5, latestTimestamp: '...' }
|
|
203
|
+
|
|
204
|
+
// NEW: Batch operations (atomic)
|
|
205
|
+
await callTool('decision', {
|
|
206
|
+
action: 'set_batch',
|
|
207
|
+
decisions: [
|
|
208
|
+
{ key: 'auth', value: 'jwt' },
|
|
209
|
+
{ key: 'db', value: 'postgres' }
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// NEW: Use templates
|
|
214
|
+
await callTool('decision', {
|
|
215
|
+
action: 'set_from_template',
|
|
216
|
+
template_name: 'api_endpoint',
|
|
217
|
+
key: 'users_api',
|
|
218
|
+
values: { path: '/api/users', method: 'GET' }
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// NEW: CLI queries (no MCP server needed)
|
|
222
|
+
// $ node dist/cli.js decisions --scope=auth --format=table
|
|
223
|
+
// $ node dist/cli.js activity --agent=agent1 --limit=20
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Database migration runs automatically on first startup with v2.1.0.
|
|
227
|
+
|
|
8
228
|
## [2.0.0] - 2025-10-11
|
|
9
229
|
|
|
10
230
|
### 🚨 BREAKING CHANGES
|
|
@@ -252,6 +472,8 @@ First production release of sqlew - MCP server for efficient context sharing bet
|
|
|
252
472
|
- Full type safety
|
|
253
473
|
- Comprehensive error handling
|
|
254
474
|
|
|
475
|
+
[2.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.1
|
|
476
|
+
[2.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.0
|
|
255
477
|
[2.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.0.0
|
|
256
478
|
[1.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.2
|
|
257
479
|
[1.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.1
|