genbox 1.0.157 → 1.0.158

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.
@@ -98,31 +98,47 @@ function cleanPath(text) {
98
98
  // Remove escape characters from terminal drag-drop (backslash before spaces)
99
99
  return text.replace(/\\ /g, ' ').trim();
100
100
  }
101
+ function stripAnsi(text) {
102
+ // Remove ANSI escape codes
103
+ return text.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, '');
104
+ }
101
105
  function extractLocalImagePath(text) {
102
- const cleaned = cleanPath(text);
106
+ // Strip ANSI codes and clean path
107
+ const cleaned = cleanPath(stripAnsi(text));
103
108
  // Patterns for local paths
104
109
  const patterns = [
105
- /\/var\/folders\/[^\n\r]+/,
106
- /\/private\/var\/folders\/[^\n\r]+/,
107
- /\/tmp\/[^\n\r]+/,
108
- /\/Users\/[^\n\r]+/,
110
+ /\/var\/folders\/[^\n\r\t]+/,
111
+ /\/private\/var\/folders\/[^\n\r\t]+/,
112
+ /\/tmp\/[^\n\r\t]+/,
113
+ /\/Users\/[^\n\r\t]+/,
109
114
  ];
110
115
  for (const pattern of patterns) {
111
116
  const match = cleaned.match(pattern);
112
117
  if (match) {
113
118
  let potentialPath = match[0].trim();
114
- // Remove trailing quotes or special chars
115
- potentialPath = potentialPath.replace(/['"]+$/, '');
116
- if (fs.existsSync(potentialPath) && isImageFile(potentialPath)) {
117
- return potentialPath;
119
+ // Remove trailing quotes, special chars, prompt artifacts
120
+ potentialPath = potentialPath.replace(/['">\s]+$/, '');
121
+ if (isImageFile(potentialPath)) {
122
+ if (fs.existsSync(potentialPath)) {
123
+ return { path: potentialPath };
124
+ }
125
+ else {
126
+ // File doesn't exist - might have been cleaned up
127
+ return { path: null, notFound: potentialPath };
128
+ }
118
129
  }
119
130
  }
120
131
  }
121
132
  // Check if the whole cleaned text is a valid image path
122
- if (fs.existsSync(cleaned) && isImageFile(cleaned)) {
123
- return cleaned;
133
+ if (isImageFile(cleaned)) {
134
+ if (fs.existsSync(cleaned)) {
135
+ return { path: cleaned };
136
+ }
137
+ else {
138
+ return { path: null, notFound: cleaned };
139
+ }
124
140
  }
125
- return null;
141
+ return { path: null };
126
142
  }
127
143
  function uploadFileSync(localPath, ipAddress, keyPath) {
128
144
  const fileName = path.basename(localPath);
@@ -442,10 +458,18 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
442
458
  }
443
459
  lastClipboard = currentClipboard;
444
460
  // Try to extract a local image path
445
- const localPath = extractLocalImagePath(currentClipboard);
446
- if (!localPath) {
461
+ const extractResult = extractLocalImagePath(currentClipboard);
462
+ // If file path was detected but file doesn't exist (e.g., macOS temp file was cleaned up)
463
+ if (extractResult.notFound) {
464
+ const fileName = path.basename(extractResult.notFound);
465
+ process.stderr.write(`\n${chalk_1.default.yellow('!')} Screenshot file was already deleted: ${chalk_1.default.dim(fileName)}\n`);
466
+ process.stderr.write(chalk_1.default.dim(' Tip: Save screenshot to Desktop first, then drag into terminal.\n'));
467
+ return;
468
+ }
469
+ if (!extractResult.path) {
447
470
  return; // Not a local image path
448
471
  }
472
+ const localPath = extractResult.path;
449
473
  // Check if we already uploaded this
450
474
  if (uploadedPaths.has(localPath)) {
451
475
  return;
@@ -459,6 +483,9 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
459
483
  // Use stderr to not interfere with terminal
460
484
  process.stderr.write(`\n${chalk_1.default.green('✓')} Uploaded ${chalk_1.default.dim(path.basename(localPath))} → clipboard has remote path. Just Cmd+V!\n`);
461
485
  }
486
+ else {
487
+ process.stderr.write(`\n${chalk_1.default.red('x')} Failed to upload: ${chalk_1.default.dim(result.error || 'unknown error')}\n`);
488
+ }
462
489
  }
463
490
  catch {
464
491
  // Ignore clipboard errors during SSH session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.157",
3
+ "version": "1.0.158",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {