c64-debug-mcp 1.0.1 → 1.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/dist/http.cjs CHANGED
@@ -1370,6 +1370,8 @@ var DEFAULT_INPUT_TAP_MS = 75;
1370
1370
  var DEFAULT_KEYBOARD_REPEAT_MS = 100;
1371
1371
  var VICE_PROCESS_LOG_PATH = import_node_path.default.join(import_node_os.default.tmpdir(), "c64-debug-mcp-x64sc.log");
1372
1372
  var DISPLAY_CAPTURE_DIR = import_node_path.default.resolve(process.cwd(), ".vice-debug-mcp-artifacts");
1373
+ var CLEANUP_ENABLED = !/^(0|false|no|off)$/i.test(process.env.C64_CLEANUP_SCREENSHOTS ?? "");
1374
+ var CLEANUP_MAX_AGE_MINUTES = Number.parseInt(process.env.C64_CLEANUP_MAX_AGE_MINUTES ?? "20", 10);
1373
1375
  var MIRROR_EMULATOR_LOGS_TO_STDERR = /^(1|true|yes|on)$/i.test(process.env.C64_DEBUG_CONSOLE_LOGS ?? "");
1374
1376
  var EXECUTION_EVENT_WAIT_MS = 1e3;
1375
1377
  var EXECUTION_SETTLE_DELAY_MS = 2e3;
@@ -1518,6 +1520,7 @@ var ViceSession = class {
1518
1520
  #displayOperationLock = null;
1519
1521
  constructor(portAllocator = new PortAllocator()) {
1520
1522
  this.#portAllocator = portAllocator;
1523
+ void this.#cleanupOldScreenshots();
1521
1524
  this.#client.on("response", (response) => {
1522
1525
  this.#lastResponseAt = nowIso();
1523
1526
  this.#writeProcessLogLine(`[monitor-response] type=${response.type} requestId=${response.requestId} errorCode=${response.errorCode}`);
@@ -3160,6 +3163,45 @@ var ViceSession = class {
3160
3163
  }
3161
3164
  this.#syncMonitorRuntimeState();
3162
3165
  }
3166
+ async #cleanupOldScreenshots() {
3167
+ if (!CLEANUP_ENABLED) {
3168
+ return;
3169
+ }
3170
+ try {
3171
+ const maxAgeMinutes = Math.max(1, Math.min(525600, CLEANUP_MAX_AGE_MINUTES));
3172
+ const maxAgeMs = maxAgeMinutes * 60 * 1e3;
3173
+ const cutoffTime = Date.now() - maxAgeMs;
3174
+ this.#writeProcessLogLine(`[cleanup] scanning ${DISPLAY_CAPTURE_DIR} for screenshots older than ${maxAgeMinutes}m`);
3175
+ let entries;
3176
+ try {
3177
+ entries = await import_promises.default.readdir(DISPLAY_CAPTURE_DIR);
3178
+ } catch (error) {
3179
+ if (error.code === "ENOENT") {
3180
+ return;
3181
+ }
3182
+ throw error;
3183
+ }
3184
+ const pngFiles = entries.filter((name) => name.endsWith(".png") && name.startsWith("capture-"));
3185
+ let deletedCount = 0;
3186
+ let errorCount = 0;
3187
+ for (const filename of pngFiles) {
3188
+ try {
3189
+ const filePath = import_node_path.default.join(DISPLAY_CAPTURE_DIR, filename);
3190
+ const stats = await import_promises.default.stat(filePath);
3191
+ if (stats.mtime.getTime() < cutoffTime) {
3192
+ await import_promises.default.unlink(filePath);
3193
+ deletedCount++;
3194
+ }
3195
+ } catch (error) {
3196
+ errorCount++;
3197
+ this.#writeProcessLogLine(`[cleanup] failed to delete ${filename}: ${error instanceof Error ? error.message : String(error)}`);
3198
+ }
3199
+ }
3200
+ this.#writeProcessLogLine(`[cleanup] completed: ${deletedCount} deleted, ${errorCount} errors, ${pngFiles.length - deletedCount - errorCount} retained`);
3201
+ } catch (error) {
3202
+ this.#writeProcessLogLine(`[cleanup] failed: ${error instanceof Error ? error.message : String(error)}`);
3203
+ }
3204
+ }
3163
3205
  };
3164
3206
  function splitCommandLine(input) {
3165
3207
  const result = [];
package/dist/http.js CHANGED
@@ -1347,6 +1347,8 @@ var DEFAULT_INPUT_TAP_MS = 75;
1347
1347
  var DEFAULT_KEYBOARD_REPEAT_MS = 100;
1348
1348
  var VICE_PROCESS_LOG_PATH = path.join(os.tmpdir(), "c64-debug-mcp-x64sc.log");
1349
1349
  var DISPLAY_CAPTURE_DIR = path.resolve(process.cwd(), ".vice-debug-mcp-artifacts");
1350
+ var CLEANUP_ENABLED = !/^(0|false|no|off)$/i.test(process.env.C64_CLEANUP_SCREENSHOTS ?? "");
1351
+ var CLEANUP_MAX_AGE_MINUTES = Number.parseInt(process.env.C64_CLEANUP_MAX_AGE_MINUTES ?? "20", 10);
1350
1352
  var MIRROR_EMULATOR_LOGS_TO_STDERR = /^(1|true|yes|on)$/i.test(process.env.C64_DEBUG_CONSOLE_LOGS ?? "");
1351
1353
  var EXECUTION_EVENT_WAIT_MS = 1e3;
1352
1354
  var EXECUTION_SETTLE_DELAY_MS = 2e3;
@@ -1495,6 +1497,7 @@ var ViceSession = class {
1495
1497
  #displayOperationLock = null;
1496
1498
  constructor(portAllocator = new PortAllocator()) {
1497
1499
  this.#portAllocator = portAllocator;
1500
+ void this.#cleanupOldScreenshots();
1498
1501
  this.#client.on("response", (response) => {
1499
1502
  this.#lastResponseAt = nowIso();
1500
1503
  this.#writeProcessLogLine(`[monitor-response] type=${response.type} requestId=${response.requestId} errorCode=${response.errorCode}`);
@@ -3137,6 +3140,45 @@ var ViceSession = class {
3137
3140
  }
3138
3141
  this.#syncMonitorRuntimeState();
3139
3142
  }
3143
+ async #cleanupOldScreenshots() {
3144
+ if (!CLEANUP_ENABLED) {
3145
+ return;
3146
+ }
3147
+ try {
3148
+ const maxAgeMinutes = Math.max(1, Math.min(525600, CLEANUP_MAX_AGE_MINUTES));
3149
+ const maxAgeMs = maxAgeMinutes * 60 * 1e3;
3150
+ const cutoffTime = Date.now() - maxAgeMs;
3151
+ this.#writeProcessLogLine(`[cleanup] scanning ${DISPLAY_CAPTURE_DIR} for screenshots older than ${maxAgeMinutes}m`);
3152
+ let entries;
3153
+ try {
3154
+ entries = await fs.readdir(DISPLAY_CAPTURE_DIR);
3155
+ } catch (error) {
3156
+ if (error.code === "ENOENT") {
3157
+ return;
3158
+ }
3159
+ throw error;
3160
+ }
3161
+ const pngFiles = entries.filter((name) => name.endsWith(".png") && name.startsWith("capture-"));
3162
+ let deletedCount = 0;
3163
+ let errorCount = 0;
3164
+ for (const filename of pngFiles) {
3165
+ try {
3166
+ const filePath = path.join(DISPLAY_CAPTURE_DIR, filename);
3167
+ const stats = await fs.stat(filePath);
3168
+ if (stats.mtime.getTime() < cutoffTime) {
3169
+ await fs.unlink(filePath);
3170
+ deletedCount++;
3171
+ }
3172
+ } catch (error) {
3173
+ errorCount++;
3174
+ this.#writeProcessLogLine(`[cleanup] failed to delete ${filename}: ${error instanceof Error ? error.message : String(error)}`);
3175
+ }
3176
+ }
3177
+ this.#writeProcessLogLine(`[cleanup] completed: ${deletedCount} deleted, ${errorCount} errors, ${pngFiles.length - deletedCount - errorCount} retained`);
3178
+ } catch (error) {
3179
+ this.#writeProcessLogLine(`[cleanup] failed: ${error instanceof Error ? error.message : String(error)}`);
3180
+ }
3181
+ }
3140
3182
  };
3141
3183
  function splitCommandLine(input) {
3142
3184
  const result = [];
package/dist/stdio.cjs CHANGED
@@ -1367,6 +1367,8 @@ var DEFAULT_INPUT_TAP_MS = 75;
1367
1367
  var DEFAULT_KEYBOARD_REPEAT_MS = 100;
1368
1368
  var VICE_PROCESS_LOG_PATH = import_node_path.default.join(import_node_os.default.tmpdir(), "c64-debug-mcp-x64sc.log");
1369
1369
  var DISPLAY_CAPTURE_DIR = import_node_path.default.resolve(process.cwd(), ".vice-debug-mcp-artifacts");
1370
+ var CLEANUP_ENABLED = !/^(0|false|no|off)$/i.test(process.env.C64_CLEANUP_SCREENSHOTS ?? "");
1371
+ var CLEANUP_MAX_AGE_MINUTES = Number.parseInt(process.env.C64_CLEANUP_MAX_AGE_MINUTES ?? "20", 10);
1370
1372
  var MIRROR_EMULATOR_LOGS_TO_STDERR = /^(1|true|yes|on)$/i.test(process.env.C64_DEBUG_CONSOLE_LOGS ?? "");
1371
1373
  var EXECUTION_EVENT_WAIT_MS = 1e3;
1372
1374
  var EXECUTION_SETTLE_DELAY_MS = 2e3;
@@ -1515,6 +1517,7 @@ var ViceSession = class {
1515
1517
  #displayOperationLock = null;
1516
1518
  constructor(portAllocator = new PortAllocator()) {
1517
1519
  this.#portAllocator = portAllocator;
1520
+ void this.#cleanupOldScreenshots();
1518
1521
  this.#client.on("response", (response) => {
1519
1522
  this.#lastResponseAt = nowIso();
1520
1523
  this.#writeProcessLogLine(`[monitor-response] type=${response.type} requestId=${response.requestId} errorCode=${response.errorCode}`);
@@ -3157,6 +3160,45 @@ var ViceSession = class {
3157
3160
  }
3158
3161
  this.#syncMonitorRuntimeState();
3159
3162
  }
3163
+ async #cleanupOldScreenshots() {
3164
+ if (!CLEANUP_ENABLED) {
3165
+ return;
3166
+ }
3167
+ try {
3168
+ const maxAgeMinutes = Math.max(1, Math.min(525600, CLEANUP_MAX_AGE_MINUTES));
3169
+ const maxAgeMs = maxAgeMinutes * 60 * 1e3;
3170
+ const cutoffTime = Date.now() - maxAgeMs;
3171
+ this.#writeProcessLogLine(`[cleanup] scanning ${DISPLAY_CAPTURE_DIR} for screenshots older than ${maxAgeMinutes}m`);
3172
+ let entries;
3173
+ try {
3174
+ entries = await import_promises.default.readdir(DISPLAY_CAPTURE_DIR);
3175
+ } catch (error) {
3176
+ if (error.code === "ENOENT") {
3177
+ return;
3178
+ }
3179
+ throw error;
3180
+ }
3181
+ const pngFiles = entries.filter((name) => name.endsWith(".png") && name.startsWith("capture-"));
3182
+ let deletedCount = 0;
3183
+ let errorCount = 0;
3184
+ for (const filename of pngFiles) {
3185
+ try {
3186
+ const filePath = import_node_path.default.join(DISPLAY_CAPTURE_DIR, filename);
3187
+ const stats = await import_promises.default.stat(filePath);
3188
+ if (stats.mtime.getTime() < cutoffTime) {
3189
+ await import_promises.default.unlink(filePath);
3190
+ deletedCount++;
3191
+ }
3192
+ } catch (error) {
3193
+ errorCount++;
3194
+ this.#writeProcessLogLine(`[cleanup] failed to delete ${filename}: ${error instanceof Error ? error.message : String(error)}`);
3195
+ }
3196
+ }
3197
+ this.#writeProcessLogLine(`[cleanup] completed: ${deletedCount} deleted, ${errorCount} errors, ${pngFiles.length - deletedCount - errorCount} retained`);
3198
+ } catch (error) {
3199
+ this.#writeProcessLogLine(`[cleanup] failed: ${error instanceof Error ? error.message : String(error)}`);
3200
+ }
3201
+ }
3160
3202
  };
3161
3203
  function splitCommandLine(input) {
3162
3204
  const result = [];
package/dist/stdio.js CHANGED
@@ -1344,6 +1344,8 @@ var DEFAULT_INPUT_TAP_MS = 75;
1344
1344
  var DEFAULT_KEYBOARD_REPEAT_MS = 100;
1345
1345
  var VICE_PROCESS_LOG_PATH = path.join(os.tmpdir(), "c64-debug-mcp-x64sc.log");
1346
1346
  var DISPLAY_CAPTURE_DIR = path.resolve(process.cwd(), ".vice-debug-mcp-artifacts");
1347
+ var CLEANUP_ENABLED = !/^(0|false|no|off)$/i.test(process.env.C64_CLEANUP_SCREENSHOTS ?? "");
1348
+ var CLEANUP_MAX_AGE_MINUTES = Number.parseInt(process.env.C64_CLEANUP_MAX_AGE_MINUTES ?? "20", 10);
1347
1349
  var MIRROR_EMULATOR_LOGS_TO_STDERR = /^(1|true|yes|on)$/i.test(process.env.C64_DEBUG_CONSOLE_LOGS ?? "");
1348
1350
  var EXECUTION_EVENT_WAIT_MS = 1e3;
1349
1351
  var EXECUTION_SETTLE_DELAY_MS = 2e3;
@@ -1492,6 +1494,7 @@ var ViceSession = class {
1492
1494
  #displayOperationLock = null;
1493
1495
  constructor(portAllocator = new PortAllocator()) {
1494
1496
  this.#portAllocator = portAllocator;
1497
+ void this.#cleanupOldScreenshots();
1495
1498
  this.#client.on("response", (response) => {
1496
1499
  this.#lastResponseAt = nowIso();
1497
1500
  this.#writeProcessLogLine(`[monitor-response] type=${response.type} requestId=${response.requestId} errorCode=${response.errorCode}`);
@@ -3134,6 +3137,45 @@ var ViceSession = class {
3134
3137
  }
3135
3138
  this.#syncMonitorRuntimeState();
3136
3139
  }
3140
+ async #cleanupOldScreenshots() {
3141
+ if (!CLEANUP_ENABLED) {
3142
+ return;
3143
+ }
3144
+ try {
3145
+ const maxAgeMinutes = Math.max(1, Math.min(525600, CLEANUP_MAX_AGE_MINUTES));
3146
+ const maxAgeMs = maxAgeMinutes * 60 * 1e3;
3147
+ const cutoffTime = Date.now() - maxAgeMs;
3148
+ this.#writeProcessLogLine(`[cleanup] scanning ${DISPLAY_CAPTURE_DIR} for screenshots older than ${maxAgeMinutes}m`);
3149
+ let entries;
3150
+ try {
3151
+ entries = await fs.readdir(DISPLAY_CAPTURE_DIR);
3152
+ } catch (error) {
3153
+ if (error.code === "ENOENT") {
3154
+ return;
3155
+ }
3156
+ throw error;
3157
+ }
3158
+ const pngFiles = entries.filter((name) => name.endsWith(".png") && name.startsWith("capture-"));
3159
+ let deletedCount = 0;
3160
+ let errorCount = 0;
3161
+ for (const filename of pngFiles) {
3162
+ try {
3163
+ const filePath = path.join(DISPLAY_CAPTURE_DIR, filename);
3164
+ const stats = await fs.stat(filePath);
3165
+ if (stats.mtime.getTime() < cutoffTime) {
3166
+ await fs.unlink(filePath);
3167
+ deletedCount++;
3168
+ }
3169
+ } catch (error) {
3170
+ errorCount++;
3171
+ this.#writeProcessLogLine(`[cleanup] failed to delete ${filename}: ${error instanceof Error ? error.message : String(error)}`);
3172
+ }
3173
+ }
3174
+ this.#writeProcessLogLine(`[cleanup] completed: ${deletedCount} deleted, ${errorCount} errors, ${pngFiles.length - deletedCount - errorCount} retained`);
3175
+ } catch (error) {
3176
+ this.#writeProcessLogLine(`[cleanup] failed: ${error instanceof Error ? error.message : String(error)}`);
3177
+ }
3178
+ }
3137
3179
  };
3138
3180
  function splitCommandLine(input) {
3139
3181
  const result = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c64-debug-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Model Context Protocol server for C64 debugging via VICE emulator",
5
5
  "type": "module",
6
6
  "keywords": [