sqlew 2.1.4 → 3.0.2
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 +891 -605
- package/README.md +302 -690
- package/assets/kanban-style.png +0 -0
- package/assets/schema.sql +531 -402
- package/dist/database.d.ts +9 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +33 -34
- package/dist/database.js.map +1 -1
- package/dist/index.js +1024 -213
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-task-tables.d.ts +47 -0
- package/dist/migrations/add-task-tables.d.ts.map +1 -0
- package/dist/migrations/add-task-tables.js +285 -0
- package/dist/migrations/add-task-tables.js.map +1 -0
- package/dist/migrations/index.d.ts +96 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +239 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts +61 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.js +442 -0
- package/dist/migrations/migrate-decisions-to-tasks.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -3
- package/dist/schema.js.map +1 -1
- package/dist/tools/constraints.d.ts +4 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +6 -27
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +17 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +195 -190
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +113 -166
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +2 -9
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +67 -126
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +90 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +732 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/utils.d.ts +8 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +50 -21
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/batch.d.ts +69 -0
- package/dist/utils/batch.d.ts.map +1 -0
- package/dist/utils/batch.js +148 -0
- package/dist/utils/batch.js.map +1 -0
- package/dist/utils/query-builder.d.ts +68 -0
- package/dist/utils/query-builder.d.ts.map +1 -0
- package/dist/utils/query-builder.js +116 -0
- package/dist/utils/query-builder.js.map +1 -0
- package/dist/utils/task-stale-detection.d.ts +28 -0
- package/dist/utils/task-stale-detection.d.ts.map +1 -0
- package/dist/utils/task-stale-detection.js +92 -0
- package/dist/utils/task-stale-detection.js.map +1 -0
- package/dist/utils/validators.d.ts +57 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +117 -0
- package/dist/utils/validators.js.map +1 -0
- package/docs/AI_AGENT_GUIDE.md +1471 -648
- package/{ARCHITECTURE.md → docs/ARCHITECTURE.md} +636 -636
- package/docs/BEST_PRACTICES.md +481 -0
- package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +457 -0
- package/docs/MIGRATION_CHAIN.md +280 -0
- package/{MIGRATION_v2.md → docs/MIGRATION_v2.md} +538 -538
- package/docs/SHARED_CONCEPTS.md +339 -0
- package/docs/TASK_ACTIONS.md +854 -0
- package/docs/TASK_LINKING.md +729 -0
- package/docs/TASK_MIGRATION.md +701 -0
- package/docs/TASK_OVERVIEW.md +363 -0
- package/docs/TASK_SYSTEM.md +1244 -0
- package/docs/TOOL_REFERENCE.md +471 -0
- package/docs/TOOL_SELECTION.md +279 -0
- package/docs/WORKFLOWS.md +602 -0
- package/docs/refactoring-summary-2025-10-17.md +365 -0
- package/docs/requirement-2025-10-17.md +508 -0
- package/package.json +64 -64
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# Tool Selection Guide
|
|
2
|
+
|
|
3
|
+
**Quick reference for choosing the right sqlew tool for your task**
|
|
4
|
+
|
|
5
|
+
## Understanding Tool Purposes
|
|
6
|
+
|
|
7
|
+
Each tool serves a distinct purpose in the MCP sqlew ecosystem:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌──────────────────────────────────────────────────────────┐
|
|
11
|
+
│ What do you need to do? │
|
|
12
|
+
└────────────────┬─────────────────────────────────────────┘
|
|
13
|
+
│
|
|
14
|
+
├─ Record a CHOICE that was made?
|
|
15
|
+
│ └─> Use `decision` tool
|
|
16
|
+
│ • Examples: "We chose JWT auth", "Selected PostgreSQL"
|
|
17
|
+
│ • Key: Captures PAST decisions
|
|
18
|
+
│ • Supports: versioning, tags, layers, scopes
|
|
19
|
+
│
|
|
20
|
+
├─ Communicate with other agents?
|
|
21
|
+
│ └─> Use `message` tool
|
|
22
|
+
│ • Examples: Task updates, warnings, requests
|
|
23
|
+
│ • Key: Real-time communication
|
|
24
|
+
│ • Supports: priority, broadcast, read tracking
|
|
25
|
+
│
|
|
26
|
+
├─ Define a REQUIREMENT that must be followed?
|
|
27
|
+
│ └─> Use `constraint` tool
|
|
28
|
+
│ • Examples: "API must be <100ms", "Code coverage >80%"
|
|
29
|
+
│ • Key: Enforces RULES
|
|
30
|
+
│ • Supports: priority, categories, layers
|
|
31
|
+
│
|
|
32
|
+
├─ Track WORK to be done?
|
|
33
|
+
│ └─> Use `task` tool
|
|
34
|
+
│ • Examples: "Implement feature X", "Fix bug Y"
|
|
35
|
+
│ • Key: Tracks TODO items and progress
|
|
36
|
+
│ • Supports: status transitions, auto-stale, linking
|
|
37
|
+
│
|
|
38
|
+
├─ Record file modifications?
|
|
39
|
+
│ └─> Use `file` tool
|
|
40
|
+
│ • Examples: Track changes, check locks
|
|
41
|
+
│ • Key: File change history
|
|
42
|
+
│ • Supports: layers, change types, lock detection
|
|
43
|
+
│
|
|
44
|
+
└─ Get statistics or manage data?
|
|
45
|
+
└─> Use `stats` or `config` tools
|
|
46
|
+
• stats: Database metrics, cleanup, activity logs
|
|
47
|
+
• config: Retention settings, auto-deletion
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Tool Comparison Table
|
|
51
|
+
|
|
52
|
+
| Tool | Use For | Don't Use For | Key Feature |
|
|
53
|
+
|------|---------|---------------|-------------|
|
|
54
|
+
| **decision** | Recording choices made | Future work, requirements | Version history tracking |
|
|
55
|
+
| **message** | Agent communication | Permanent records, decisions | Priority-based delivery |
|
|
56
|
+
| **constraint** | Requirements & rules | Decisions, tasks | Category-based organization |
|
|
57
|
+
| **task** | Work tracking (TODO) | Decisions, history | Auto-stale detection |
|
|
58
|
+
| **file** | File change tracking | Code search, content | Layer-based organization |
|
|
59
|
+
| **stats** | Metrics & cleanup | Data storage | Aggregated views |
|
|
60
|
+
| **config** | Retention settings | Business logic | Auto-deletion control |
|
|
61
|
+
|
|
62
|
+
## Decision vs Constraint vs Task
|
|
63
|
+
|
|
64
|
+
This is the most common confusion. Here's the distinction:
|
|
65
|
+
|
|
66
|
+
| Concept | Definition | Example | Tool |
|
|
67
|
+
|---------|------------|---------|------|
|
|
68
|
+
| **Decision** | A choice that WAS made | "We chose JWT authentication" | `decision` |
|
|
69
|
+
| **Constraint** | A requirement that MUST be followed | "Response time must be <100ms" | `constraint` |
|
|
70
|
+
| **Task** | Work that NEEDS to be done | "Implement JWT authentication" | `task` |
|
|
71
|
+
|
|
72
|
+
## ⚠️ Decision vs Task: WHY vs WHAT
|
|
73
|
+
|
|
74
|
+
**Critical distinction**: `decision` stores WHY (reasoning), `task` stores WHAT (work status).
|
|
75
|
+
|
|
76
|
+
| Question | Answer | Tool |
|
|
77
|
+
|----------|--------|------|
|
|
78
|
+
| **WHY** did we choose this approach? | "Chose JWT because stateless auth scales horizontally" | **decision** |
|
|
79
|
+
| **WHAT** needs to be done? | "Implement JWT authentication (status: in_progress)" | **task** |
|
|
80
|
+
| **WHY** was this bug introduced? | "Nested transaction bug: setDecision wraps in transaction, batch also wraps" | **decision** |
|
|
81
|
+
| **WHAT** is the completion status? | "Fixed nested transaction bug (status: done)" | **task** |
|
|
82
|
+
|
|
83
|
+
### Common Mistakes
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// ❌ WRONG - Using decision for task completion
|
|
87
|
+
{
|
|
88
|
+
action: "set",
|
|
89
|
+
key: "jwt-implementation-complete",
|
|
90
|
+
value: "JWT authentication implemented. All tests passing."
|
|
91
|
+
}
|
|
92
|
+
// This is WHAT was done (completion status), not WHY decisions were made.
|
|
93
|
+
// FIX: Use task tool for tracking implementation progress.
|
|
94
|
+
|
|
95
|
+
// ✅ CORRECT - Using decision for architectural reasoning
|
|
96
|
+
{
|
|
97
|
+
action: "set",
|
|
98
|
+
key: "api/auth/jwt-choice",
|
|
99
|
+
value: "Chose JWT over sessions because: (1) Stateless design scales, (2) Mobile clients cache tokens, (3) Microservice auth requires distributed validation."
|
|
100
|
+
}
|
|
101
|
+
// This explains WHY JWT was chosen with architectural reasoning.
|
|
102
|
+
|
|
103
|
+
// ✅ CORRECT - Using task for work tracking
|
|
104
|
+
{
|
|
105
|
+
action: "create",
|
|
106
|
+
title: "Implement JWT authentication with refresh tokens",
|
|
107
|
+
status: "in_progress",
|
|
108
|
+
assigned_agent: "backend-agent"
|
|
109
|
+
}
|
|
110
|
+
// This tracks WHAT work is being done and its current status.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
💡 **See [BEST_PRACTICES.md](BEST_PRACTICES.md#critical-what-to-store-in-decisions) for detailed examples of WHY vs WHAT.**
|
|
114
|
+
|
|
115
|
+
## Scenario-Based Tool Selection
|
|
116
|
+
|
|
117
|
+
### Scenario 1: Breaking API Change
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// 1. Record the decision (WHY the change was necessary)
|
|
121
|
+
{
|
|
122
|
+
action: "set",
|
|
123
|
+
key: "api/v2/versioning-decision",
|
|
124
|
+
value: "Moved /users to /v2/users because: (1) Enables backward compatibility via versioning, (2) Allows gradual client migration without breaking production apps, (3) Future API changes won't force all clients to update simultaneously. Trade-off: More complex routing layer, but necessary for production stability with 50+ client apps.",
|
|
125
|
+
layer: "presentation",
|
|
126
|
+
tags: ["api", "versioning", "architecture-decision"]
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 2. Add a constraint (requirement going forward)
|
|
130
|
+
{
|
|
131
|
+
action: "add",
|
|
132
|
+
category: "architecture",
|
|
133
|
+
constraint_text: "All API endpoints must include version prefix",
|
|
134
|
+
layer: "presentation",
|
|
135
|
+
tags: ["api", "versioning"]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 3. Create migration task
|
|
139
|
+
{
|
|
140
|
+
action: "create",
|
|
141
|
+
title: "Migrate clients to /v2/users endpoint",
|
|
142
|
+
status: "todo",
|
|
143
|
+
layer: "presentation",
|
|
144
|
+
tags: ["migration", "v2.0.0"]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 4. Notify other agents
|
|
148
|
+
{
|
|
149
|
+
action: "send",
|
|
150
|
+
from_agent: "api-agent",
|
|
151
|
+
msg_type: "warning",
|
|
152
|
+
message: "Breaking change: /users moved to /v2/users",
|
|
153
|
+
priority: "critical"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Scenario 2: Performance Issue
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
// 1. Record the analysis and solution decision (WHY this approach)
|
|
161
|
+
{
|
|
162
|
+
action: "set",
|
|
163
|
+
key: "db/user_sessions/index-strategy",
|
|
164
|
+
value: "Adding composite index (user_id, created_at DESC) to user_sessions table because: (1) Query analysis shows 300% latency increase from full table scans on 10M+ rows, (2) 95% of queries filter by user_id + sort by timestamp, (3) Index reduces query time from 850ms to <50ms in staging tests. Trade-off: 15% slower inserts and 200MB additional storage, but read performance critical for user experience.",
|
|
165
|
+
layer: "data",
|
|
166
|
+
tags: ["performance", "database", "indexing-strategy"]
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 2. Add performance constraint
|
|
170
|
+
{
|
|
171
|
+
action: "add",
|
|
172
|
+
category: "performance",
|
|
173
|
+
constraint_text: "Database queries must complete within 50ms",
|
|
174
|
+
priority: "high",
|
|
175
|
+
layer: "data"
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 3. Create optimization task
|
|
179
|
+
{
|
|
180
|
+
action: "create",
|
|
181
|
+
title: "Add indexes to user_sessions table",
|
|
182
|
+
status: "in_progress",
|
|
183
|
+
priority: 4,
|
|
184
|
+
layer: "data",
|
|
185
|
+
tags: ["performance", "database"]
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Scenario 3: Security Vulnerability
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
// 1. Record the solution decision (WHY this mitigation approach)
|
|
193
|
+
{
|
|
194
|
+
action: "set",
|
|
195
|
+
key: "security/jwt/timing-attack-mitigation",
|
|
196
|
+
value: "Upgrading JWT library to v9.2.0+ and implementing constant-time comparison because: (1) CVE-2025-1234 timing attack allows token forgery via timing analysis, (2) Library v9.2.0+ includes constant-time string comparison preventing timing leaks, (3) Alternative approach (rewriting auth layer) would take 3 weeks vs 2-day upgrade. Trade-off: Breaking change requires updating all microservices, but security risk is critical and affects all user sessions.",
|
|
197
|
+
layer: "business",
|
|
198
|
+
tags: ["security", "authentication", "mitigation-strategy"]
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// 2. Add security constraint
|
|
202
|
+
{
|
|
203
|
+
action: "add",
|
|
204
|
+
category: "security",
|
|
205
|
+
constraint_text: "All auth tokens must use constant-time comparison",
|
|
206
|
+
priority: "critical",
|
|
207
|
+
layer: "business"
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 3. Create fix task
|
|
211
|
+
{
|
|
212
|
+
action: "create",
|
|
213
|
+
title: "Upgrade JWT library and implement constant-time comparison",
|
|
214
|
+
status: "in_progress",
|
|
215
|
+
priority: 4,
|
|
216
|
+
assigned_agent: "security-agent",
|
|
217
|
+
layer: "business"
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 4. Alert all agents
|
|
221
|
+
{
|
|
222
|
+
action: "send",
|
|
223
|
+
from_agent: "security-agent",
|
|
224
|
+
to_agent: null, // Broadcast
|
|
225
|
+
msg_type: "warning",
|
|
226
|
+
message: "URGENT: Auth vulnerability found, fix in progress",
|
|
227
|
+
priority: "critical"
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Search Actions Decision Tree
|
|
232
|
+
|
|
233
|
+
### When to use which search action?
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
┌─────────────────────────────────────┐
|
|
237
|
+
│ What do you want to search by? │
|
|
238
|
+
└──────────┬──────────────────────────┘
|
|
239
|
+
│
|
|
240
|
+
├─ Simple filters (status, layer, tags)?
|
|
241
|
+
│ └─> Use action: "list"
|
|
242
|
+
│
|
|
243
|
+
├─ Primarily by tags?
|
|
244
|
+
│ └─> Use action: "search_tags"
|
|
245
|
+
│ • match_mode: "AND" (all tags) or "OR" (any tag)
|
|
246
|
+
│
|
|
247
|
+
├─ Primarily by layer?
|
|
248
|
+
│ └─> Use action: "search_layer"
|
|
249
|
+
│
|
|
250
|
+
├─ Complex multi-filter query?
|
|
251
|
+
│ └─> Use action: "search_advanced"
|
|
252
|
+
│ • Multiple layers (OR)
|
|
253
|
+
│ • Tag combinations (AND/OR)
|
|
254
|
+
│ • Temporal filtering
|
|
255
|
+
│ • Full-text search
|
|
256
|
+
│ • Pagination
|
|
257
|
+
│
|
|
258
|
+
└─ Need version history?
|
|
259
|
+
└─> Use action: "versions"
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Detailed Search Comparison
|
|
263
|
+
|
|
264
|
+
| Action | Use When | Key Features |
|
|
265
|
+
|--------|----------|--------------|
|
|
266
|
+
| **list** | Basic filtering | Simple status/layer/tag filters, no pagination |
|
|
267
|
+
| **search_tags** | Tag-focused search | AND/OR logic for tags, optional status/layer |
|
|
268
|
+
| **search_layer** | Layer-focused search | Get all decisions in specific layer(s) |
|
|
269
|
+
| **search_advanced** | Complex queries | Full filtering, pagination, sorting, text search |
|
|
270
|
+
| **versions** | History tracking | Get all versions of a specific decision |
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Related Documentation
|
|
275
|
+
|
|
276
|
+
- **[TOOL_REFERENCE.md](TOOL_REFERENCE.md)** - Complete parameter reference for all tools
|
|
277
|
+
- **[WORKFLOWS.md](WORKFLOWS.md)** - Multi-step workflow examples
|
|
278
|
+
- **[BEST_PRACTICES.md](BEST_PRACTICES.md)** - Common errors and best practices
|
|
279
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Layer definitions and system architecture
|