@wonderwhy-er/desktop-commander 0.2.48 → 0.2.50

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.
@@ -44,16 +44,6 @@ class UsageTracker {
44
44
  const stats = await configManager.getValue('usageStats');
45
45
  return stats || this.getDefaultStats();
46
46
  }
47
- /**
48
- * Save usage stats to config.
49
- * Non-blocking: the tool-call return path must not wait on a disk write. The
50
- * in-memory stats are already updated by the caller (getStats returns the live
51
- * config object), so persistence is coalesced in the background. This is what
52
- * keeps a saturated libuv threadpool from gating tool responses on every call.
53
- */
54
- async saveStats(stats) {
55
- await configManager.setValueNonBlocking('usageStats', stats);
56
- }
57
47
  /**
58
48
  * Determine which category a tool belongs to
59
49
  */
@@ -104,51 +94,53 @@ class UsageTracker {
104
94
  * Track a successful tool call
105
95
  */
106
96
  async trackSuccess(toolName) {
107
- const stats = await this.getStats();
108
- // Update session
109
97
  this.updateSession();
110
- // Update counters
111
- stats.totalToolCalls++;
112
- stats.successfulCalls++;
113
- stats.lastUsed = Date.now();
114
- // Update tool-specific counter
115
- stats.toolCounts[toolName] = (stats.toolCounts[toolName] || 0) + 1;
116
- // Update category counter
98
+ const now = Date.now();
117
99
  const category = this.getToolCategory(toolName);
118
- if (category) {
119
- stats[category]++;
120
- }
121
- // Update session count if this is a new session
122
- if (this.currentSession?.commandsInSession === 1) {
123
- stats.totalSessions++;
124
- }
125
- await this.saveStats(stats);
126
- return stats;
100
+ const newSession = this.currentSession?.commandsInSession === 1;
101
+ return await configManager.updateValueNonBlocking('usageStats', (stored) => {
102
+ const defaults = { ...this.getDefaultStats(), firstUsed: now, lastUsed: now };
103
+ const stats = {
104
+ ...defaults,
105
+ ...(stored || {}),
106
+ toolCounts: { ...(stored?.toolCounts || {}) },
107
+ };
108
+ stats.totalToolCalls++;
109
+ stats.successfulCalls++;
110
+ stats.lastUsed = Math.max(stats.lastUsed || 0, now);
111
+ stats.toolCounts[toolName] = (stats.toolCounts[toolName] || 0) + 1;
112
+ if (category)
113
+ stats[category]++;
114
+ if (newSession)
115
+ stats.totalSessions++;
116
+ return stats;
117
+ });
127
118
  }
128
119
  /**
129
120
  * Track a failed tool call
130
121
  */
131
122
  async trackFailure(toolName) {
132
- const stats = await this.getStats();
133
- // Update session
134
123
  this.updateSession();
135
- // Update counters
136
- stats.totalToolCalls++;
137
- stats.failedCalls++;
138
- stats.lastUsed = Date.now();
139
- // Update tool-specific counter (we count failures too)
140
- stats.toolCounts[toolName] = (stats.toolCounts[toolName] || 0) + 1;
141
- // Update category counter
124
+ const now = Date.now();
142
125
  const category = this.getToolCategory(toolName);
143
- if (category) {
144
- stats[category]++;
145
- }
146
- // Update session count if this is a new session
147
- if (this.currentSession?.commandsInSession === 1) {
148
- stats.totalSessions++;
149
- }
150
- await this.saveStats(stats);
151
- return stats;
126
+ const newSession = this.currentSession?.commandsInSession === 1;
127
+ return await configManager.updateValueNonBlocking('usageStats', (stored) => {
128
+ const defaults = { ...this.getDefaultStats(), firstUsed: now, lastUsed: now };
129
+ const stats = {
130
+ ...defaults,
131
+ ...(stored || {}),
132
+ toolCounts: { ...(stored?.toolCounts || {}) },
133
+ };
134
+ stats.totalToolCalls++;
135
+ stats.failedCalls++;
136
+ stats.lastUsed = Math.max(stats.lastUsed || 0, now);
137
+ stats.toolCounts[toolName] = (stats.toolCounts[toolName] || 0) + 1;
138
+ if (category)
139
+ stats[category]++;
140
+ if (newSession)
141
+ stats.totalSessions++;
142
+ return stats;
143
+ });
152
144
  }
153
145
  /**
154
146
  * Check if user should be prompted for feedback based on usage patterns
@@ -258,16 +250,23 @@ class UsageTracker {
258
250
  * Mark that user was prompted for feedback
259
251
  */
260
252
  async markFeedbackPrompted() {
261
- const stats = await this.getStats();
262
- const today = new Date().toISOString().split('T')[0]; // '2025-10-20'
263
- stats.lastFeedbackPrompt = Date.now();
264
- stats.lastFeedbackPromptDate = today;
265
- stats.feedbackAttempts = (stats.feedbackAttempts || 0) + 1;
266
- // Mark session so we don't prompt again this session
253
+ const now = Date.now();
254
+ const today = new Date(now).toISOString().split('T')[0];
267
255
  if (this.currentSession) {
268
256
  this.currentSession.promptedThisSession = true;
269
257
  }
270
- await this.saveStats(stats);
258
+ await configManager.updateValueNonBlocking('usageStats', (stored) => {
259
+ const defaults = { ...this.getDefaultStats(), firstUsed: now, lastUsed: now };
260
+ const stats = {
261
+ ...defaults,
262
+ ...(stored || {}),
263
+ toolCounts: { ...(stored?.toolCounts || {}) },
264
+ };
265
+ stats.lastFeedbackPrompt = Math.max(stats.lastFeedbackPrompt || 0, now);
266
+ stats.lastFeedbackPromptDate = today;
267
+ stats.feedbackAttempts = (stats.feedbackAttempts || 0) + 1;
268
+ return stats;
269
+ });
271
270
  }
272
271
  /**
273
272
  * Mark that user has given feedback
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.48";
1
+ export declare const VERSION = "0.2.50";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.48';
1
+ export const VERSION = '0.2.50';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderwhy-er/desktop-commander",
3
- "version": "0.2.48",
3
+ "version": "0.2.50",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "mcpName": "io.github.wonderwhy-er/desktop-commander",
6
6
  "license": "MIT",
@@ -112,6 +112,7 @@
112
112
  "open": "^10.2.0",
113
113
  "pdf-lib": "^1.17.1",
114
114
  "pizzip": "^3.2.0",
115
+ "proper-lockfile": "^4.1.2",
115
116
  "remark": "^15.0.1",
116
117
  "remark-gfm": "^4.0.1",
117
118
  "remark-parse": "^11.0.0",
@@ -129,6 +130,7 @@
129
130
  "@anthropic-ai/mcpb": "^1.2.0",
130
131
  "@modelcontextprotocol/ext-apps": "^1.0.1",
131
132
  "@types/node": "^20.17.24",
133
+ "@types/proper-lockfile": "^4.1.4",
132
134
  "commander": "^13.1.0",
133
135
  "esbuild": "^0.27.2",
134
136
  "js-tiktoken": "^1.0.21",