sqlew 3.6.5 → 3.6.6
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 +41 -0
- package/LICENSE +52 -52
- package/README.md +3 -2
- package/assets/sample-agents/sqlew-architect.md +89 -273
- package/assets/sample-agents/sqlew-researcher.md +87 -237
- package/assets/sample-agents/sqlew-scrum-master.md +105 -108
- package/dist/index.js +32 -71
- package/dist/index.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js +49 -34
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js +211 -175
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js.map +1 -1
- package/dist/tests/all-features.test.js +0 -71
- package/dist/tests/all-features.test.js.map +1 -1
- package/dist/tests/parameter-validation.test.d.ts +8 -0
- package/dist/tests/parameter-validation.test.d.ts.map +1 -0
- package/dist/tests/parameter-validation.test.js +461 -0
- package/dist/tests/parameter-validation.test.js.map +1 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +7 -8
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +68 -39
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +9 -7
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/help-queries.d.ts.map +1 -1
- package/dist/tools/help-queries.js +20 -14
- package/dist/tools/help-queries.js.map +1 -1
- package/dist/tools/messaging.d.ts +1 -1
- package/dist/tools/messaging.js +10 -10
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +13 -0
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +15 -12
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +93 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/action-specs.d.ts +46 -0
- package/dist/utils/action-specs.d.ts.map +1 -0
- package/dist/utils/action-specs.js +527 -0
- package/dist/utils/action-specs.js.map +1 -0
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +41 -24
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/parameter-validator.d.ts +53 -0
- package/dist/utils/parameter-validator.d.ts.map +1 -0
- package/dist/utils/parameter-validator.js +286 -0
- package/dist/utils/parameter-validator.js.map +1 -0
- package/docs/BEST_PRACTICES.md +69 -0
- package/docs/CONFIGURATION.md +35 -19
- package/docs/TOOL_REFERENCE.md +178 -0
- package/package.json +86 -86
- package/dist/tools/config.d.ts +0 -50
- package/dist/tools/config.d.ts.map +0 -1
- package/dist/tools/config.js +0 -170
- package/dist/tools/config.js.map +0 -1
package/docs/TOOL_REFERENCE.md
CHANGED
|
@@ -23,6 +23,63 @@
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
+
## Parameter Validation
|
|
27
|
+
|
|
28
|
+
**NEW in dev branch**: sqlew now provides comprehensive parameter validation with helpful error messages.
|
|
29
|
+
|
|
30
|
+
### Validation Features
|
|
31
|
+
|
|
32
|
+
1. **Required vs Optional Detection** - Clear indication of which parameters must be provided
|
|
33
|
+
2. **Typo Suggestions** - Levenshtein distance-based suggestions for mistyped parameter names
|
|
34
|
+
3. **Structured Error Messages** - JSON format with examples showing correct usage
|
|
35
|
+
4. **Visual Markers** - Help responses show 🔴 REQUIRED and ⚪ OPTIONAL parameter markers
|
|
36
|
+
|
|
37
|
+
### Example Error Message
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"error": "Missing required parameter for action 'set': value",
|
|
42
|
+
"action": "set",
|
|
43
|
+
"missing_params": ["value"],
|
|
44
|
+
"required_params": ["key", "value"],
|
|
45
|
+
"optional_params": ["agent", "layer", "tags", "status", "version", "scopes"],
|
|
46
|
+
"you_provided": ["key", "layer"],
|
|
47
|
+
"example": {
|
|
48
|
+
"action": "set",
|
|
49
|
+
"key": "database/postgresql-choice",
|
|
50
|
+
"value": "Selected PostgreSQL over MongoDB",
|
|
51
|
+
"layer": "data",
|
|
52
|
+
"tags": ["database", "architecture"]
|
|
53
|
+
},
|
|
54
|
+
"hint": "Use 'quick_set' for simpler usage with auto-inferred metadata"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Typo Detection Example
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"error": "Unknown parameter for action 'set': tgas",
|
|
63
|
+
"action": "set",
|
|
64
|
+
"invalid_params": ["tgas"],
|
|
65
|
+
"did_you_mean": {
|
|
66
|
+
"tgas": "tags"
|
|
67
|
+
},
|
|
68
|
+
"valid_params": ["action", "key", "value", "agent", "layer", "tags", "status", "version", "scopes"],
|
|
69
|
+
"hint": "Parameter names are case-sensitive"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Common Validation Errors
|
|
74
|
+
|
|
75
|
+
| Error Type | Cause | Solution |
|
|
76
|
+
|------------|-------|----------|
|
|
77
|
+
| Missing required parameter | Omitted required field | Check error message for required_params list |
|
|
78
|
+
| Unknown parameter | Typo or invalid field | Check did_you_mean suggestions |
|
|
79
|
+
| Wrong parameter for action | Using parameter from different action | Verify action name and consult example |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
26
83
|
## Quick Start
|
|
27
84
|
|
|
28
85
|
### Basic Decision Workflow
|
|
@@ -80,6 +137,123 @@
|
|
|
80
137
|
|
|
81
138
|
---
|
|
82
139
|
|
|
140
|
+
## Parameter Validation (v3.7.0)
|
|
141
|
+
|
|
142
|
+
sqlew provides structured error messages with examples and typo suggestions to help you fix parameter errors quickly.
|
|
143
|
+
|
|
144
|
+
### Structured Error Format
|
|
145
|
+
|
|
146
|
+
When required parameters are missing or incorrect, sqlew returns a detailed JSON error response:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"error": "Missing required parameters for 'set': key",
|
|
151
|
+
"action": "set",
|
|
152
|
+
"missing_params": ["key"],
|
|
153
|
+
"required_params": ["key", "value"],
|
|
154
|
+
"optional_params": ["agent", "layer", "tags", "status", "version", "scopes"],
|
|
155
|
+
"you_provided": ["action", "context_key", "value"],
|
|
156
|
+
"did_you_mean": {
|
|
157
|
+
"context_key": "key"
|
|
158
|
+
},
|
|
159
|
+
"example": {
|
|
160
|
+
"action": "set",
|
|
161
|
+
"key": "database/pre-existence-requirement",
|
|
162
|
+
"value": "Database must pre-exist before connection...",
|
|
163
|
+
"layer": "infrastructure",
|
|
164
|
+
"tags": ["database", "security"]
|
|
165
|
+
},
|
|
166
|
+
"hint": "💡 TIP: Use 'quick_set' action for simpler usage with smart defaults"
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Error Response Fields
|
|
171
|
+
|
|
172
|
+
| Field | Description |
|
|
173
|
+
|-------|-------------|
|
|
174
|
+
| **error** | Human-readable error message |
|
|
175
|
+
| **action** | The action that was attempted |
|
|
176
|
+
| **missing_params** | List of missing required parameters |
|
|
177
|
+
| **required_params** | All required parameters for this action |
|
|
178
|
+
| **optional_params** | All optional parameters for this action |
|
|
179
|
+
| **you_provided** | Parameters you actually provided |
|
|
180
|
+
| **did_you_mean** | Typo suggestions (parameter name → correct name) |
|
|
181
|
+
| **example** | Working example showing correct usage |
|
|
182
|
+
| **hint** | Optional helpful tip for this action |
|
|
183
|
+
|
|
184
|
+
### Example Error Scenarios
|
|
185
|
+
|
|
186
|
+
#### Scenario 1: Wrong Parameter Name
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
// ❌ Wrong
|
|
190
|
+
{ action: "set", context_key: "db/feature", value: "..." }
|
|
191
|
+
|
|
192
|
+
// Error Response:
|
|
193
|
+
{
|
|
194
|
+
"error": "Missing required parameter 'key' for action 'set'",
|
|
195
|
+
"did_you_mean": { "context_key": "key" },
|
|
196
|
+
"example": { action: "set", key: "db/feature", value: "..." }
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Scenario 2: Missing Required Parameter
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
// ❌ Wrong
|
|
204
|
+
{ action: "add", category: "architecture", constraint_text: "..." }
|
|
205
|
+
|
|
206
|
+
// Error Response:
|
|
207
|
+
{
|
|
208
|
+
"error": "Missing required parameter 'priority' for action 'add'",
|
|
209
|
+
"required_params": ["category", "constraint_text", "priority"],
|
|
210
|
+
"optional_params": ["layer", "tags", "created_by"],
|
|
211
|
+
"example": {
|
|
212
|
+
action: "add",
|
|
213
|
+
category: "architecture",
|
|
214
|
+
constraint_text: "...",
|
|
215
|
+
priority: "critical"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Scenario 3: Typo Detection
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
// ❌ Wrong
|
|
224
|
+
{ action: "add", cat: "architecture", constraint_text: "...", priority: "high" }
|
|
225
|
+
|
|
226
|
+
// Error Response:
|
|
227
|
+
{
|
|
228
|
+
"error": "Missing required parameter 'category' for action 'add'",
|
|
229
|
+
"did_you_mean": { "cat": "category" },
|
|
230
|
+
"example": { ... }
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Typo Detection
|
|
235
|
+
|
|
236
|
+
sqlew uses Levenshtein distance (≤2 edits) to detect common typos:
|
|
237
|
+
|
|
238
|
+
| Common Typo | Suggestion |
|
|
239
|
+
|-------------|------------|
|
|
240
|
+
| context_key | key |
|
|
241
|
+
| constraint | constraint_text |
|
|
242
|
+
| cat | category |
|
|
243
|
+
| prio | priority |
|
|
244
|
+
| msg | message |
|
|
245
|
+
| desc | description |
|
|
246
|
+
|
|
247
|
+
### Best Practices
|
|
248
|
+
|
|
249
|
+
1. **Read the error response** - It includes everything you need to fix the issue
|
|
250
|
+
2. **Check `did_you_mean`** - Often catches simple typos
|
|
251
|
+
3. **Copy the example** - Use it as a template for your call
|
|
252
|
+
4. **Verify required params** - Make sure you provide all items in `required_params`
|
|
253
|
+
5. **Use hints** - Look for simpler alternatives (e.g., `quick_set` vs `set`)
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
83
257
|
## Parameter Requirements by Tool
|
|
84
258
|
|
|
85
259
|
### `decision` Tool
|
|
@@ -140,6 +314,10 @@
|
|
|
140
314
|
|
|
141
315
|
### `config` Tool
|
|
142
316
|
|
|
317
|
+
> ⚠️ **DEPRECATED in v3.7.0** - This tool will be removed in a future version.
|
|
318
|
+
> Use `.sqlew/config.toml` file instead for configuration.
|
|
319
|
+
> See [CONFIGURATION.md](CONFIGURATION.md) for migration guide.
|
|
320
|
+
|
|
143
321
|
| Action | Required | Optional |
|
|
144
322
|
|--------|----------|----------|
|
|
145
323
|
| **get** | action | - |
|
package/package.json
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "sqlew",
|
|
3
|
+
"version": "3.6.6",
|
|
4
|
+
"description": "MCP server for efficient context sharing between Claude Code sub-agents (60-70% token reduction), Kanban Task Watcher, Decision or Constraint Context, and streamlined documentation",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sqlew": "dist/index.js",
|
|
9
|
+
"sqlew-cli": "dist/cli.js",
|
|
10
|
+
"sqlew-init-agents": "dist/init-agents.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"assets/",
|
|
15
|
+
"docs/",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"MIGRATION_v2.md",
|
|
20
|
+
"ARCHITECTURE.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"start": "node dist/index.js",
|
|
25
|
+
"cli": "node dist/cli.js",
|
|
26
|
+
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"rebuild": "npm run clean && npm run build",
|
|
30
|
+
"test": "npm run build && node --test dist/tests/tasks.dependencies.test.js",
|
|
31
|
+
"test:all-features": "npm run build && node dist/tests/all-features.test.js",
|
|
32
|
+
"test:migrations": "npm run build && node dist/tests/migrations/test-v3.2-migration.js",
|
|
33
|
+
"test:migrations:all": "npm run build && node dist/tests/migrations/test-all-versions-real.js",
|
|
34
|
+
"prepare": "husky",
|
|
35
|
+
"prepublishOnly": "npm run rebuild",
|
|
36
|
+
"knex": "tsx node_modules/.bin/knex --knexfile src/knexfile.ts",
|
|
37
|
+
"migrate:make": "npm run knex migrate:make",
|
|
38
|
+
"migrate:latest": "npm run knex migrate:latest",
|
|
39
|
+
"migrate:rollback": "npm run knex migrate:rollback",
|
|
40
|
+
"migrate:rollback:all": "npm run knex migrate:rollback --all",
|
|
41
|
+
"migrate:status": "npm run knex migrate:status",
|
|
42
|
+
"seed:make": "npm run knex seed:make",
|
|
43
|
+
"seed:run": "npm run knex seed:run"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/sin5ddd/mcp-sqlew.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/sin5ddd/mcp-sqlew/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/sin5ddd/mcp-sqlew#readme",
|
|
56
|
+
"keywords": [
|
|
57
|
+
"mcp",
|
|
58
|
+
"mcp-server",
|
|
59
|
+
"model-context-protocol",
|
|
60
|
+
"context-sharing",
|
|
61
|
+
"claude-code",
|
|
62
|
+
"sub-agents",
|
|
63
|
+
"sqlite",
|
|
64
|
+
"token-efficiency",
|
|
65
|
+
"shared-context"
|
|
66
|
+
],
|
|
67
|
+
"author": "sin5ddd",
|
|
68
|
+
"license": "AGPL-3.0",
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@modelcontextprotocol/sdk": "latest",
|
|
71
|
+
"better-sqlite3": "^11.0.0",
|
|
72
|
+
"chokidar": "^4.0.3",
|
|
73
|
+
"ignore": "^7.0.5",
|
|
74
|
+
"knex": "^3.1.0",
|
|
75
|
+
"smol-toml": "^1.4.2",
|
|
76
|
+
"sqlite3": "^5.1.7"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
80
|
+
"@types/knex": "^0.15.2",
|
|
81
|
+
"@types/node": "^20.0.0",
|
|
82
|
+
"husky": "^9.1.7",
|
|
83
|
+
"tsx": "^4.20.6",
|
|
84
|
+
"typescript": "^5.0.0"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/dist/tools/config.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration management tools for MCP Shared Context Server
|
|
3
|
-
* Provides tools to get and update auto-deletion configuration
|
|
4
|
-
*
|
|
5
|
-
* CONVERTED: Using Knex.js with DatabaseAdapter (async/await)
|
|
6
|
-
*/
|
|
7
|
-
import { DatabaseAdapter } from '../adapters/index.js';
|
|
8
|
-
/**
|
|
9
|
-
* Get current configuration settings
|
|
10
|
-
*
|
|
11
|
-
* @param adapter - Optional database adapter (for testing)
|
|
12
|
-
* @returns Current configuration values
|
|
13
|
-
*/
|
|
14
|
-
export declare function getConfig(adapter?: DatabaseAdapter): Promise<{
|
|
15
|
-
ignoreWeekend: boolean;
|
|
16
|
-
messageRetentionHours: number;
|
|
17
|
-
fileHistoryRetentionDays: number;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* Update configuration settings
|
|
21
|
-
* Validates values before updating
|
|
22
|
-
*
|
|
23
|
-
* @param params - Configuration parameters to update
|
|
24
|
-
* @param adapter - Optional database adapter (for testing)
|
|
25
|
-
* @returns Updated configuration
|
|
26
|
-
*/
|
|
27
|
-
export declare function updateConfig(params: {
|
|
28
|
-
ignoreWeekend?: boolean;
|
|
29
|
-
messageRetentionHours?: number;
|
|
30
|
-
fileHistoryRetentionDays?: number;
|
|
31
|
-
}, adapter?: DatabaseAdapter): Promise<{
|
|
32
|
-
success: boolean;
|
|
33
|
-
config: {
|
|
34
|
-
ignoreWeekend: boolean;
|
|
35
|
-
messageRetentionHours: number;
|
|
36
|
-
fileHistoryRetentionDays: number;
|
|
37
|
-
};
|
|
38
|
-
message: string;
|
|
39
|
-
}>;
|
|
40
|
-
/**
|
|
41
|
-
* Get help documentation for config tool
|
|
42
|
-
* @returns Help documentation object
|
|
43
|
-
*/
|
|
44
|
-
export declare function configHelp(): any;
|
|
45
|
-
/**
|
|
46
|
-
* Get comprehensive examples for config tool
|
|
47
|
-
* @returns Examples documentation object
|
|
48
|
-
*/
|
|
49
|
-
export declare function configExample(): any;
|
|
50
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IAClE,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC,CAYD;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,aAAa,EAAE,OAAO,CAAC;QACvB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,wBAAwB,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAqCD;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,GAAG,CAmBhC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,GAAG,CA4EnC"}
|
package/dist/tools/config.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration management tools for MCP Shared Context Server
|
|
3
|
-
* Provides tools to get and update auto-deletion configuration
|
|
4
|
-
*
|
|
5
|
-
* CONVERTED: Using Knex.js with DatabaseAdapter (async/await)
|
|
6
|
-
*/
|
|
7
|
-
import { getAdapter, getConfigBool, getConfigInt, setConfigValue } from '../database.js';
|
|
8
|
-
import { CONFIG_KEYS } from '../constants.js';
|
|
9
|
-
/**
|
|
10
|
-
* Get current configuration settings
|
|
11
|
-
*
|
|
12
|
-
* @param adapter - Optional database adapter (for testing)
|
|
13
|
-
* @returns Current configuration values
|
|
14
|
-
*/
|
|
15
|
-
export async function getConfig(adapter) {
|
|
16
|
-
const actualAdapter = adapter ?? getAdapter();
|
|
17
|
-
const ignoreWeekend = await getConfigBool(actualAdapter, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, false);
|
|
18
|
-
const messageRetentionHours = await getConfigInt(actualAdapter, CONFIG_KEYS.AUTODELETE_MESSAGE_HOURS, 24);
|
|
19
|
-
const fileHistoryRetentionDays = await getConfigInt(actualAdapter, CONFIG_KEYS.AUTODELETE_FILE_HISTORY_DAYS, 7);
|
|
20
|
-
return {
|
|
21
|
-
ignoreWeekend,
|
|
22
|
-
messageRetentionHours,
|
|
23
|
-
fileHistoryRetentionDays,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Update configuration settings
|
|
28
|
-
* Validates values before updating
|
|
29
|
-
*
|
|
30
|
-
* @param params - Configuration parameters to update
|
|
31
|
-
* @param adapter - Optional database adapter (for testing)
|
|
32
|
-
* @returns Updated configuration
|
|
33
|
-
*/
|
|
34
|
-
export async function updateConfig(params, adapter) {
|
|
35
|
-
const actualAdapter = adapter ?? getAdapter();
|
|
36
|
-
// Validate values
|
|
37
|
-
if (params.messageRetentionHours !== undefined) {
|
|
38
|
-
if (params.messageRetentionHours < 1 || params.messageRetentionHours > 168) {
|
|
39
|
-
throw new Error('messageRetentionHours must be between 1 and 168 (1 week)');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (params.fileHistoryRetentionDays !== undefined) {
|
|
43
|
-
if (params.fileHistoryRetentionDays < 1 || params.fileHistoryRetentionDays > 90) {
|
|
44
|
-
throw new Error('fileHistoryRetentionDays must be between 1 and 90 days');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Update values
|
|
48
|
-
if (params.ignoreWeekend !== undefined) {
|
|
49
|
-
await setConfigValue(actualAdapter, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, params.ignoreWeekend ? '1' : '0');
|
|
50
|
-
}
|
|
51
|
-
if (params.messageRetentionHours !== undefined) {
|
|
52
|
-
await setConfigValue(actualAdapter, CONFIG_KEYS.AUTODELETE_MESSAGE_HOURS, String(params.messageRetentionHours));
|
|
53
|
-
}
|
|
54
|
-
if (params.fileHistoryRetentionDays !== undefined) {
|
|
55
|
-
await setConfigValue(actualAdapter, CONFIG_KEYS.AUTODELETE_FILE_HISTORY_DAYS, String(params.fileHistoryRetentionDays));
|
|
56
|
-
}
|
|
57
|
-
// Get updated config
|
|
58
|
-
const updatedConfig = await getConfig(actualAdapter);
|
|
59
|
-
return {
|
|
60
|
-
success: true,
|
|
61
|
-
config: updatedConfig,
|
|
62
|
-
message: 'Configuration updated successfully',
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get help documentation for config tool
|
|
67
|
-
* @returns Help documentation object
|
|
68
|
-
*/
|
|
69
|
-
export function configHelp() {
|
|
70
|
-
return {
|
|
71
|
-
tool: 'config',
|
|
72
|
-
description: 'Manage auto-deletion configuration (weekend-aware retention)',
|
|
73
|
-
note: '💡 TIP: Use action: "example" to see comprehensive usage scenarios and real-world examples for all config actions.',
|
|
74
|
-
actions: {
|
|
75
|
-
get: 'Get current config. No params required',
|
|
76
|
-
update: 'Update config. Params: ignoreWeekend, messageRetentionHours (1-168), fileHistoryRetentionDays (1-90)'
|
|
77
|
-
},
|
|
78
|
-
examples: {
|
|
79
|
-
get: '{ action: "get" }',
|
|
80
|
-
update: '{ action: "update", ignoreWeekend: true, messageRetentionHours: 48 }'
|
|
81
|
-
},
|
|
82
|
-
documentation: {
|
|
83
|
-
shared_concepts: 'docs/SHARED_CONCEPTS.md - Weekend-aware retention behavior explained (339 lines, ~17k tokens)',
|
|
84
|
-
best_practices: 'docs/BEST_PRACTICES.md - Retention strategies, cleanup timing (345 lines, ~17k tokens)',
|
|
85
|
-
architecture: 'docs/ARCHITECTURE.md - Auto-cleanup architecture, configuration system'
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get comprehensive examples for config tool
|
|
91
|
-
* @returns Examples documentation object
|
|
92
|
-
*/
|
|
93
|
-
export function configExample() {
|
|
94
|
-
return {
|
|
95
|
-
tool: 'config',
|
|
96
|
-
description: 'Configuration management examples',
|
|
97
|
-
scenarios: {
|
|
98
|
-
view_config: {
|
|
99
|
-
title: 'Current Configuration',
|
|
100
|
-
example: {
|
|
101
|
-
request: '{ action: "get" }',
|
|
102
|
-
response: '{ ignoreWeekend: boolean, messageRetentionHours: number, fileHistoryRetentionDays: number }',
|
|
103
|
-
explanation: 'View current auto-deletion settings'
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
standard_retention: {
|
|
107
|
-
title: 'Standard Time-Based Retention',
|
|
108
|
-
example: {
|
|
109
|
-
request: '{ action: "update", ignoreWeekend: false, messageRetentionHours: 24, fileHistoryRetentionDays: 7 }',
|
|
110
|
-
explanation: 'Messages deleted after 24 hours, file history after 7 days (strict time-based)'
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
weekend_aware: {
|
|
114
|
-
title: 'Weekend-Aware Retention',
|
|
115
|
-
example: {
|
|
116
|
-
request: '{ action: "update", ignoreWeekend: true, messageRetentionHours: 24, fileHistoryRetentionDays: 7 }',
|
|
117
|
-
explanation: 'On Monday, 24h retention = Friday (skips weekend)',
|
|
118
|
-
scenario: 'Useful for business-hour contexts where weekend messages should persist'
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
extended_retention: {
|
|
122
|
-
title: 'Long-Term Project Retention',
|
|
123
|
-
example: {
|
|
124
|
-
request: '{ action: "update", messageRetentionHours: 168, fileHistoryRetentionDays: 90 }',
|
|
125
|
-
explanation: '1 week message retention, 90 days file history (max allowed)',
|
|
126
|
-
use_case: 'Long-running projects needing extended context'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
retention_behavior: {
|
|
131
|
-
ignoreWeekend_false: {
|
|
132
|
-
description: 'Standard time-based retention',
|
|
133
|
-
examples: [
|
|
134
|
-
'24h on Monday = 24 hours ago (Sunday)',
|
|
135
|
-
'24h on Friday = 24 hours ago (Thursday)',
|
|
136
|
-
'Straightforward chronological deletion'
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
ignoreWeekend_true: {
|
|
140
|
-
description: 'Business-hours retention (skips Sat/Sun)',
|
|
141
|
-
examples: [
|
|
142
|
-
'24h on Monday = Friday (skips Sat/Sun)',
|
|
143
|
-
'24h on Tuesday = Monday',
|
|
144
|
-
'24h on Friday = Thursday',
|
|
145
|
-
'24h on Saturday/Sunday = Friday',
|
|
146
|
-
'Preserves weekend messages until Monday cleanup'
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
best_practices: {
|
|
151
|
-
choosing_retention: [
|
|
152
|
-
'Short projects: 24h messages, 7d file history',
|
|
153
|
-
'Medium projects: 72h messages, 14d file history',
|
|
154
|
-
'Long projects: 168h (1 week) messages, 30-90d file history',
|
|
155
|
-
'Use ignoreWeekend=true for business-hour focused work'
|
|
156
|
-
],
|
|
157
|
-
limits: [
|
|
158
|
-
'messageRetentionHours: 1-168 (1 hour to 1 week)',
|
|
159
|
-
'fileHistoryRetentionDays: 1-90',
|
|
160
|
-
'Choose based on your projects needs and database size constraints'
|
|
161
|
-
],
|
|
162
|
-
cli_override: [
|
|
163
|
-
'Can override config at server startup via CLI args',
|
|
164
|
-
'--autodelete-ignore-weekend, --autodelete-message-hours, --autodelete-file-history-days',
|
|
165
|
-
'Runtime updates via config tool take precedence over CLI'
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
//# sourceMappingURL=config.js.map
|
package/dist/tools/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAyB;IAKvD,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAE9C,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,aAAa,EAAE,WAAW,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IACvG,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,WAAW,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;IAC1G,MAAM,wBAAwB,GA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