@icyfenix-dmla/cli 2026.5.2-1959 → 2026.5.2-2025

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icyfenix-dmla/cli",
3
- "version": "2026.5.2-1959",
3
+ "version": "2026.5.2-2025",
4
4
  "description": "DMLA 沙箱服务命令行工具",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -208,9 +208,8 @@ async function showMainMenu(dataPath) {
208
208
  { name: '2', message: '下载数据集' },
209
209
  { name: '3', message: '查看数据集列表' },
210
210
  { name: '4', message: '清空数据内容' },
211
- { name: '5', message: '显示实际路径' },
212
- { name: '6', message: '删除数据卷' },
213
- { name: '7', message: '退出' }
211
+ { name: '5', message: '删除数据卷' },
212
+ { name: '6', message: '退出' }
214
213
  ]
215
214
 
216
215
  const { action } = await prompt({
@@ -277,35 +276,6 @@ async function mountPath() {
277
276
  console.log(chalk.yellow('提示: 需要重启沙箱服务才能生效 (dmla stop && dmla start)'))
278
277
  }
279
278
 
280
- /**
281
- * 显示实际路径
282
- */
283
- function showPath() {
284
- const dataPath = getDataVolumePath()
285
- const stats = getDirectoryStats(dataPath)
286
-
287
- console.log()
288
- console.log(chalk.bold('数据卷信息'))
289
- console.log()
290
- console.log(chalk.gray(`挂载路径: ${dataPath}`))
291
- console.log(chalk.gray(`存在状态: ${fs.existsSync(dataPath) ? '已创建' : '未创建'}`))
292
- console.log(chalk.gray(`数据集数量: ${stats.datasets}`))
293
- console.log(chalk.gray(`模型数量: ${stats.models}`))
294
- console.log()
295
-
296
- // 显示子目录
297
- if (fs.existsSync(dataPath)) {
298
- console.log(chalk.bold('目录结构:'))
299
- const subDirs = ['datasets', 'models', 'outputs', 'cache']
300
- for (const dir of subDirs) {
301
- const fullPath = path.join(dataPath, dir)
302
- const exists = fs.existsSync(fullPath)
303
- console.log(chalk.gray(` ${dir}/ ${exists ? '(已存在)' : '(不存在)'}`))
304
- }
305
- }
306
- console.log()
307
- }
308
-
309
279
  /**
310
280
  * 清空数据内容
311
281
  */
@@ -431,45 +401,45 @@ async function downloadDatasets() {
431
401
  // 构建选项列表
432
402
  const choices = DATASETS.map((dataset, index) => {
433
403
  const downloaded = isDatasetDownloaded(dataPath, dataset.id)
404
+
405
+ let message = `${dataset.name} (${dataset.size})`
406
+ if (downloaded) {
407
+ message += ' [已下载]'
408
+ }
409
+
434
410
  return {
435
411
  name: index.toString(),
436
- message: `${dataset.name} (${dataset.size})${downloaded ? ' [已下载]' : ''}`,
437
- disabled: downloaded || dataset.id === 'mnist'
412
+ message,
413
+ disabled: downloaded
438
414
  }
439
415
  })
440
416
 
441
- // MNIST 特殊提示
442
- console.log(chalk.gray('提示: MNIST 数据集将在训练时通过 torchvision 自动下载'))
443
- console.log(chalk.gray('操作: 上下键选择,空格勾选/取消,回车确认下载'))
417
+ // 操作提示
418
+ console.log(chalk.gray('操作: 上下键移动,空格勾选/取消,回车确认,ESC 返回'))
444
419
  console.log()
445
420
 
446
- const { selected } = await prompt({
447
- type: 'multiselect',
448
- name: 'selected',
449
- message: '选择要下载的数据集',
450
- choices,
451
- hint: '空格选择,回车确认',
452
- warn: '已下载或不可选'
453
- })
454
-
455
- if (!selected || selected.length === 0) {
456
- console.log(chalk.yellow('未选择任何数据集'))
457
- return
458
- }
421
+ try {
422
+ const { selected } = await prompt({
423
+ type: 'multiselect',
424
+ name: 'selected',
425
+ message: '选择要下载的数据集',
426
+ choices,
427
+ hint: '空格选择,回车确认下载',
428
+ warn: '已下载'
429
+ })
459
430
 
460
- // 下载选中的数据集
461
- for (const indexStr of selected) {
462
- const index = parseInt(indexStr)
463
- const dataset = DATASETS[index]
431
+ if (!selected || selected.length === 0) {
432
+ console.log(chalk.yellow('未选择任何数据集'))
433
+ return
434
+ }
464
435
 
465
- console.log()
466
- console.log(chalk.cyan(`────────────────────────────────────`))
436
+ // 下载选中的数据集
437
+ for (const indexStr of selected) {
438
+ const index = parseInt(indexStr)
439
+ const dataset = DATASETS[index]
467
440
 
468
- // MNIST 特殊处理
469
- if (dataset.id === 'mnist') {
470
- console.log(chalk.yellow('MNIST 数据集将在训练时通过 torchvision 自动下载'))
471
- continue
472
- }
441
+ console.log()
442
+ console.log(chalk.cyan(`────────────────────────────────────`))
473
443
 
474
444
  // 检查是否已下载
475
445
  if (isDatasetDownloaded(dataPath, dataset.id)) {
@@ -483,6 +453,14 @@ async function downloadDatasets() {
483
453
  console.log()
484
454
  console.log(chalk.cyan(`────────────────────────────────────`))
485
455
  console.log(chalk.green('所有选中的数据集已处理完成'))
456
+ } catch (error) {
457
+ // 用户按 ESC 或 Ctrl+C 取消
458
+ if (error.message && error.message.includes('cancel')) {
459
+ console.log(chalk.gray('返回上一级'))
460
+ return
461
+ }
462
+ throw error
463
+ }
486
464
  }
487
465
 
488
466
  /**
@@ -669,12 +647,9 @@ export async function runDataTUI() {
669
647
  await clearData()
670
648
  break
671
649
  case 5:
672
- showPath()
673
- break
674
- case 6:
675
650
  await removeData()
676
651
  break
677
- case 7:
652
+ case 6:
678
653
  console.log()
679
654
  console.log(chalk.gray('已退出数据管理'))
680
655
  console.log()