smart-context-mcp 1.3.0 → 1.3.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/README.md +9 -14
- package/package.json +1 -1
- package/src/decision-explainer.js +26 -5
- package/src/missed-opportunities.js +35 -7
- package/src/usage-feedback.js +10 -32
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ Restart your AI client. Done.
|
|
|
62
62
|
- ✅ Token savings: 85-90% on complex tasks
|
|
63
63
|
|
|
64
64
|
Check actual usage:
|
|
65
|
-
- **Real-time feedback** -
|
|
65
|
+
- **Real-time feedback** - Enabled by default (disable with `export DEVCTX_SHOW_USAGE=false`)
|
|
66
66
|
- `npm run report:metrics` - Tool-level savings + adoption analysis
|
|
67
67
|
- `npm run report:workflows` - Workflow-level savings (requires `DEVCTX_WORKFLOW_TRACKING=true`)
|
|
68
68
|
|
|
@@ -105,16 +105,11 @@ Production usage: **14.5M tokens → 1.6M tokens** (89.87% reduction)
|
|
|
105
105
|
|
|
106
106
|
## Verify It's Working
|
|
107
107
|
|
|
108
|
-
### Real-Time Feedback (
|
|
108
|
+
### Real-Time Feedback (Enabled by Default)
|
|
109
109
|
|
|
110
|
-
Feedback is **
|
|
110
|
+
Feedback is **enabled by default** and shows after every devctx tool call.
|
|
111
111
|
|
|
112
|
-
**To
|
|
113
|
-
```bash
|
|
114
|
-
export DEVCTX_SHOW_USAGE=true
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**To disable immediately:**
|
|
112
|
+
**To disable:**
|
|
118
113
|
```bash
|
|
119
114
|
export DEVCTX_SHOW_USAGE=false
|
|
120
115
|
```
|
|
@@ -130,7 +125,7 @@ You'll see at the end of agent responses:
|
|
|
130
125
|
|
|
131
126
|
**Total saved:** ~57.0K tokens
|
|
132
127
|
|
|
133
|
-
*
|
|
128
|
+
*To disable this message: `export DEVCTX_SHOW_USAGE=false`*
|
|
134
129
|
```
|
|
135
130
|
|
|
136
131
|
**Why this is useful:**
|
|
@@ -203,12 +198,12 @@ You'll see warnings like:
|
|
|
203
198
|
- Low adoption (<30%)
|
|
204
199
|
- Usage dropped mid-session
|
|
205
200
|
|
|
206
|
-
**
|
|
201
|
+
**All features enabled by default.** To disable:
|
|
207
202
|
|
|
208
203
|
```bash
|
|
209
|
-
export DEVCTX_SHOW_USAGE=
|
|
210
|
-
export DEVCTX_EXPLAIN=
|
|
211
|
-
export DEVCTX_DETECT_MISSED=
|
|
204
|
+
export DEVCTX_SHOW_USAGE=false
|
|
205
|
+
export DEVCTX_EXPLAIN=false
|
|
206
|
+
export DEVCTX_DETECT_MISSED=false
|
|
212
207
|
```
|
|
213
208
|
|
|
214
209
|
## MCP Prompts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-context-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "MCP server that reduces agent token usage by 90% with intelligent context compression, task checkpoint persistence, and workflow-aware agent guidance.",
|
|
5
5
|
"author": "Francisco Caballero Portero <fcp1978@hotmail.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Decision explainer - tracks and explains why devctx tools were used or not used
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* ENABLED BY DEFAULT - disable with: DEVCTX_EXPLAIN=false
|
|
5
5
|
*
|
|
6
6
|
* Provides transparency into agent decision-making:
|
|
7
7
|
* - Why was smart_read used instead of Read?
|
|
@@ -11,17 +11,37 @@
|
|
|
11
11
|
|
|
12
12
|
const sessionDecisions = {
|
|
13
13
|
decisions: [],
|
|
14
|
-
enabled:
|
|
14
|
+
enabled: true, // Changed: enabled by default
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Check if explanations are enabled
|
|
19
19
|
*/
|
|
20
|
+
/**
|
|
21
|
+
* Check if decision explanations are enabled
|
|
22
|
+
*
|
|
23
|
+
* Priority:
|
|
24
|
+
* 1. Explicit env var (DEVCTX_EXPLAIN=true/false)
|
|
25
|
+
* 2. Default: ENABLED (changed from disabled)
|
|
26
|
+
*/
|
|
20
27
|
export const isExplainEnabled = () => {
|
|
21
28
|
const envValue = process.env.DEVCTX_EXPLAIN?.toLowerCase();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
|
|
30
|
+
// Explicit enable
|
|
31
|
+
if (envValue === 'true' || envValue === '1' || envValue === 'yes') {
|
|
32
|
+
sessionDecisions.enabled = true;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Explicit disable
|
|
37
|
+
if (envValue === 'false' || envValue === '0' || envValue === 'no') {
|
|
38
|
+
sessionDecisions.enabled = false;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Default: ENABLED (changed)
|
|
43
|
+
sessionDecisions.enabled = true;
|
|
44
|
+
return true;
|
|
25
45
|
};
|
|
26
46
|
|
|
27
47
|
/**
|
|
@@ -100,6 +120,7 @@ export const formatDecisionExplanations = () => {
|
|
|
100
120
|
*/
|
|
101
121
|
export const resetSessionDecisions = () => {
|
|
102
122
|
sessionDecisions.decisions = [];
|
|
123
|
+
sessionDecisions.enabled = true; // Reset to default (enabled)
|
|
103
124
|
};
|
|
104
125
|
|
|
105
126
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Analyzes session metrics to detect patterns where devctx would have helped.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* ENABLED BY DEFAULT - disable with: DEVCTX_DETECT_MISSED=false
|
|
7
7
|
*
|
|
8
8
|
* Detection heuristics (based on session metrics):
|
|
9
9
|
* - Low devctx adoption in complex sessions (many operations, few devctx calls)
|
|
@@ -19,7 +19,7 @@ const sessionActivity = {
|
|
|
19
19
|
totalOperations: 0, // Estimated from devctx calls + time-based heuristic
|
|
20
20
|
lastDevctxCall: 0,
|
|
21
21
|
sessionStart: Date.now(),
|
|
22
|
-
enabled:
|
|
22
|
+
enabled: true, // Changed: enabled by default
|
|
23
23
|
warnings: [],
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -36,12 +36,29 @@ const DEVCTX_TOOLS = new Set([
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Check if missed opportunity detection is enabled
|
|
39
|
+
*
|
|
40
|
+
* Priority:
|
|
41
|
+
* 1. Explicit env var (DEVCTX_DETECT_MISSED=true/false)
|
|
42
|
+
* 2. Default: ENABLED (changed from disabled)
|
|
39
43
|
*/
|
|
40
44
|
export const isMissedDetectionEnabled = () => {
|
|
41
45
|
const envValue = process.env.DEVCTX_DETECT_MISSED?.toLowerCase();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
// Explicit enable
|
|
48
|
+
if (envValue === 'true' || envValue === '1' || envValue === 'yes') {
|
|
49
|
+
sessionActivity.enabled = true;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Explicit disable
|
|
54
|
+
if (envValue === 'false' || envValue === '0' || envValue === 'no') {
|
|
55
|
+
sessionActivity.enabled = false;
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Default: ENABLED (changed)
|
|
60
|
+
sessionActivity.enabled = true;
|
|
61
|
+
return true;
|
|
45
62
|
};
|
|
46
63
|
|
|
47
64
|
/**
|
|
@@ -152,8 +169,18 @@ export const formatMissedOpportunities = () => {
|
|
|
152
169
|
const analysis = analyzeMissedOpportunities();
|
|
153
170
|
if (!analysis) return '';
|
|
154
171
|
|
|
155
|
-
//
|
|
156
|
-
if (analysis.message
|
|
172
|
+
// Show session too short message (but don't show full warning)
|
|
173
|
+
if (analysis.message) {
|
|
174
|
+
return '';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// If no opportunities but session is active, show positive feedback
|
|
178
|
+
if (analysis.opportunities.length === 0 && analysis.devctxOperations > 0) {
|
|
179
|
+
return `\n\n✅ **devctx adoption: ${analysis.devctxRatio}%** (${analysis.devctxOperations}/${analysis.estimatedTotal} operations)\n`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// No opportunities and no devctx usage - don't show yet (wait for longer session)
|
|
183
|
+
if (analysis.opportunities.length === 0) {
|
|
157
184
|
return '';
|
|
158
185
|
}
|
|
159
186
|
|
|
@@ -222,6 +249,7 @@ export const resetSessionActivity = () => {
|
|
|
222
249
|
sessionActivity.lastDevctxCall = 0;
|
|
223
250
|
sessionActivity.sessionStart = Date.now();
|
|
224
251
|
sessionActivity.warnings = [];
|
|
252
|
+
sessionActivity.enabled = true; // Reset to default (enabled)
|
|
225
253
|
};
|
|
226
254
|
|
|
227
255
|
/**
|
package/src/usage-feedback.js
CHANGED
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
* Usage feedback system - tracks devctx tool usage in current session
|
|
3
3
|
* and provides visible feedback to users about what tools were used and tokens saved.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* ENABLED BY DEFAULT - disable with: DEVCTX_SHOW_USAGE=false
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* User can explicitly
|
|
7
|
+
* Shows feedback after every devctx tool call to ensure visibility.
|
|
8
|
+
* User can explicitly disable if they find it too verbose.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
const sessionUsage = {
|
|
12
12
|
tools: new Map(), // toolName -> { count, savedTokens }
|
|
13
13
|
totalSavedTokens: 0,
|
|
14
|
-
enabled:
|
|
14
|
+
enabled: true, // Changed: enabled by default
|
|
15
15
|
totalToolCalls: 0,
|
|
16
|
-
onboardingMode: true,
|
|
17
|
-
ONBOARDING_THRESHOLD: 10, // Auto-disable after 10 tool calls
|
|
18
16
|
};
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -22,8 +20,7 @@ const sessionUsage = {
|
|
|
22
20
|
*
|
|
23
21
|
* Priority:
|
|
24
22
|
* 1. Explicit env var (DEVCTX_SHOW_USAGE=true/false)
|
|
25
|
-
* 2.
|
|
26
|
-
* 3. Default: disabled
|
|
23
|
+
* 2. Default: ENABLED (changed from disabled)
|
|
27
24
|
*/
|
|
28
25
|
export const isFeedbackEnabled = () => {
|
|
29
26
|
const envValue = process.env.DEVCTX_SHOW_USAGE?.toLowerCase();
|
|
@@ -31,30 +28,18 @@ export const isFeedbackEnabled = () => {
|
|
|
31
28
|
// Explicit enable
|
|
32
29
|
if (envValue === 'true' || envValue === '1' || envValue === 'yes') {
|
|
33
30
|
sessionUsage.enabled = true;
|
|
34
|
-
sessionUsage.onboardingMode = false;
|
|
35
31
|
return true;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
// Explicit disable
|
|
39
35
|
if (envValue === 'false' || envValue === '0' || envValue === 'no') {
|
|
40
36
|
sessionUsage.enabled = false;
|
|
41
|
-
sessionUsage.onboardingMode = false;
|
|
42
37
|
return false;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// After onboarding threshold, auto-disable
|
|
52
|
-
if (sessionUsage.onboardingMode && sessionUsage.totalToolCalls >= sessionUsage.ONBOARDING_THRESHOLD) {
|
|
53
|
-
sessionUsage.enabled = false;
|
|
54
|
-
sessionUsage.onboardingMode = false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return sessionUsage.enabled;
|
|
40
|
+
// Default: ENABLED (changed)
|
|
41
|
+
sessionUsage.enabled = true;
|
|
42
|
+
return true;
|
|
58
43
|
};
|
|
59
44
|
|
|
60
45
|
/**
|
|
@@ -128,14 +113,7 @@ export const formatUsageFeedback = () => {
|
|
|
128
113
|
}
|
|
129
114
|
|
|
130
115
|
lines.push('');
|
|
131
|
-
|
|
132
|
-
// Show onboarding message if in onboarding mode
|
|
133
|
-
if (sessionUsage.onboardingMode && sessionUsage.totalToolCalls < sessionUsage.ONBOARDING_THRESHOLD) {
|
|
134
|
-
const remaining = sessionUsage.ONBOARDING_THRESHOLD - sessionUsage.totalToolCalls;
|
|
135
|
-
lines.push(`*Onboarding mode: showing for ${remaining} more tool calls. To keep: \`export DEVCTX_SHOW_USAGE=true\`*`);
|
|
136
|
-
} else {
|
|
137
|
-
lines.push('*To disable this message: `export DEVCTX_SHOW_USAGE=false`*');
|
|
138
|
-
}
|
|
116
|
+
lines.push('*To disable this message: `export DEVCTX_SHOW_USAGE=false`*');
|
|
139
117
|
|
|
140
118
|
return lines.join('\n');
|
|
141
119
|
};
|
|
@@ -147,7 +125,7 @@ export const resetSessionUsage = () => {
|
|
|
147
125
|
sessionUsage.tools.clear();
|
|
148
126
|
sessionUsage.totalSavedTokens = 0;
|
|
149
127
|
sessionUsage.totalToolCalls = 0;
|
|
150
|
-
sessionUsage.
|
|
128
|
+
sessionUsage.enabled = true; // Reset to default (enabled)
|
|
151
129
|
};
|
|
152
130
|
|
|
153
131
|
/**
|