@optima-chat/browser-cli 0.20.0 → 0.21.0

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1422,8 +1422,8 @@ function registerFeikuaCommands(program2) {
1422
1422
  function formatVideoList(videos) {
1423
1423
  if (videos.length === 0) {
1424
1424
  return `No videos found. Videos are listed from your OptimaConnect folder:
1425
- macOS/Linux: ~/Downloads/OptimaConnect/<\u5E73\u53F0>/<\u8D27\u54C1>/\u89C6\u9891/ (older files: ~/Downloads/OptimaConnect/videos)
1426
- Windows: C:\\Users\\<\u7528\u6237\u540D>\\Downloads\\OptimaConnect\\<\u5E73\u53F0>\\<\u8D27\u54C1>\\\u89C6\u9891\\ (older files: ...\\OptimaConnect\\videos)
1425
+ macOS/Linux: ~/Downloads/OptimaConnect/<\u5E73\u53F0>/<\u8D27\u54C1>/videos/ (older files: ~/Downloads/OptimaConnect/videos)
1426
+ Windows: C:\\Users\\<\u7528\u6237\u540D>\\Downloads\\OptimaConnect\\<\u5E73\u53F0>\\<\u8D27\u54C1>\\videos\\ (older files: ...\\OptimaConnect\\videos)
1427
1427
  Then try again.`;
1428
1428
  }
1429
1429
  return videos.map((v) => {
@@ -1433,12 +1433,26 @@ Then try again.`;
1433
1433
  }).join("\n");
1434
1434
  }
1435
1435
  function mediaRefLine(result) {
1436
- return result.media_ref ? `media_ref: ${result.media_ref} (\u4E0A\u4F20\u53C2\u6570\u586B\u8FD9\u4E2A)` : null;
1436
+ if (!result.media_ref) return null;
1437
+ return `\u4E0A\u4F20\u53C2\u6570\u586B\u4E0B\u4E00\u884C\u5F15\u53F7\u91CC\u7684\u5B8C\u6574\u503C(\u53EF\u80FD\u542B\u7A7A\u683C,\u522B\u81EA\u5DF1\u62FC\u6216\u8865\u6269\u5C55\u540D):
1438
+ media_ref=${JSON.stringify(result.media_ref)}`;
1439
+ }
1440
+ function collisionWarning(dest, localPath) {
1441
+ const wanted = dest.split(/[\\/]/).pop();
1442
+ const landed = localPath.split(/[\\/]/).pop();
1443
+ if (wanted === landed) return null;
1444
+ return `\u6CE8\u610F:\u672C\u673A\u5DF2\u6709\u540C\u540D\u6587\u4EF6 ${wanted}(\u65E7\u6587\u4EF6,\u4E0D\u662F\u8FD9\u6B21\u9001\u7684),\u8FD9\u6B21\u843D\u4E3A ${landed}\u3002\u5F15\u7528\u8FD9\u6B21\u7684\u6587\u4EF6\u522B\u7528 ${wanted}\u3002`;
1437
1445
  }
1438
1446
  function registerFileCommands(program2) {
1439
- program2.command("send-file").description("Send a file from your workspace to your local download folder").requiredOption("--src <path>", "Source path in your workspace (e.g. ~/output/report.pdf)").requiredOption("--dest <path>", "Destination path relative to the download folder").action(async (opts) => {
1447
+ program2.command("send-file").description("Send a file from your workspace to your local download folder").requiredOption("--src <path>", "Source path in your workspace (e.g. ~/output/report.pdf)").requiredOption("--dest <path>", "Destination path relative to the download folder").option("--json", "Print {local_path, media_ref} as JSON \u2014 read media_ref from here instead of parsing text").action(async (opts) => {
1440
1448
  try {
1441
1449
  const result = await api.sendFile(opts.src, opts.dest);
1450
+ const warning = collisionWarning(opts.dest, result.local_path);
1451
+ if (warning) console.error(warning);
1452
+ if (opts.json) {
1453
+ console.log(JSON.stringify(result));
1454
+ return;
1455
+ }
1442
1456
  console.log(result.local_path);
1443
1457
  const hint = mediaRefLine(result);
1444
1458
  if (hint) console.error(hint);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/browser-cli",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {