@cliphijack/santaclaude 1.0.16 → 1.0.17
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/package.json +1 -1
- package/santaclaude.js +13 -6
package/package.json
CHANGED
package/santaclaude.js
CHANGED
|
@@ -392,27 +392,34 @@ async function run(conf) {
|
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
if (cmd.action === 'image') {
|
|
395
|
-
// 웹이 올린
|
|
395
|
+
// 웹이 올린 파일을 받아 로컬에 저장하고 claude에 경로 주입 (이미지·txt·mp3·mp4 등 전부)
|
|
396
396
|
const dir = path.join(os.homedir(), '.santaclaude', 'img');
|
|
397
397
|
try { fs.mkdirSync(dir, { recursive: true }); } catch (e) {}
|
|
398
|
-
const
|
|
398
|
+
const MIME_EXT = {}; for (const k in EXT_MIME) if (!(EXT_MIME[k] in MIME_EXT)) MIME_EXT[EXT_MIME[k]] = k; // mime→ext 역매핑
|
|
399
|
+
const paths = []; let allImg = true;
|
|
399
400
|
for (const im of (cmd.imgs || [])) {
|
|
400
401
|
try {
|
|
401
402
|
const r = await fetch(api + '/api/img?token=' + encodeURIComponent(token) + '&id=' + encodeURIComponent(im.id));
|
|
402
403
|
if (!r.ok) continue;
|
|
403
404
|
const j = await r.json();
|
|
404
|
-
const
|
|
405
|
-
|
|
405
|
+
const mime = String(j.mime || '');
|
|
406
|
+
if (!mime.startsWith('image/')) allImg = false;
|
|
407
|
+
const safe = String(im.name || j.name || '').replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80);
|
|
408
|
+
let fname;
|
|
409
|
+
if (safe && /\.[A-Za-z0-9]+$/.test(safe)) fname = Date.now() + '_' + paths.length + '_' + safe; // 원본 파일명·확장자 보존
|
|
410
|
+
else { const ext = MIME_EXT[mime] || (mime.includes('png') ? 'png' : mime.includes('webp') ? 'webp' : mime.startsWith('image/') ? 'jpg' : 'bin'); fname = Date.now() + '_' + paths.length + '.' + ext; }
|
|
411
|
+
const fp = path.join(dir, fname);
|
|
406
412
|
fs.writeFileSync(fp, Buffer.from(j.data, 'base64'));
|
|
407
413
|
paths.push(fp);
|
|
408
414
|
} catch (e) {}
|
|
409
415
|
}
|
|
410
416
|
if (paths.length) {
|
|
411
417
|
const w = (cmd.name && windowExists(session, cmd.name)) ? (session + ':' + cmd.name) : pane;
|
|
412
|
-
const
|
|
418
|
+
const label = allImg ? ('첨부 이미지 ' + paths.length + '장') : ('첨부 파일 ' + paths.length + '개');
|
|
419
|
+
const msg = (cmd.note ? cmd.note + ' ' : '') + label + ' 봐줘: ' + paths.join(' ');
|
|
413
420
|
execFileSync('tmux', ['send-keys', '-t', w, '-l', msg]);
|
|
414
421
|
setTimeout(() => { try { execFileSync('tmux', ['send-keys', '-t', w, 'Enter']); } catch (e) {} }, 300);
|
|
415
|
-
console.log(`
|
|
422
|
+
console.log(` 📎 ${label} → ${w}`);
|
|
416
423
|
}
|
|
417
424
|
return;
|
|
418
425
|
}
|