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

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-2022",
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,39 +401,48 @@ async function downloadDatasets() {
431
401
  // 构建选项列表
432
402
  const choices = DATASETS.map((dataset, index) => {
433
403
  const downloaded = isDatasetDownloaded(dataPath, dataset.id)
404
+ const isMnist = dataset.id === 'mnist'
405
+
406
+ let message = `${dataset.name} (${dataset.size})`
407
+ if (downloaded) {
408
+ message += ' [已下载]'
409
+ } else if (isMnist) {
410
+ message += ' [训练时自动下载]'
411
+ }
412
+
434
413
  return {
435
414
  name: index.toString(),
436
- message: `${dataset.name} (${dataset.size})${downloaded ? ' [已下载]' : ''}`,
437
- disabled: downloaded || dataset.id === 'mnist'
415
+ message,
416
+ disabled: downloaded || isMnist
438
417
  }
439
418
  })
440
419
 
441
- // MNIST 特殊提示
442
- console.log(chalk.gray('提示: MNIST 数据集将在训练时通过 torchvision 自动下载'))
443
- console.log(chalk.gray('操作: 上下键选择,空格勾选/取消,回车确认下载'))
420
+ // 操作提示
421
+ console.log(chalk.gray('操作: 上下键移动,空格勾选/取消,回车确认,ESC 返回'))
444
422
  console.log()
445
423
 
446
- const { selected } = await prompt({
447
- type: 'multiselect',
448
- name: 'selected',
449
- message: '选择要下载的数据集',
450
- choices,
451
- hint: '空格选择,回车确认',
452
- warn: '已下载或不可选'
453
- })
424
+ try {
425
+ const { selected } = await prompt({
426
+ type: 'multiselect',
427
+ name: 'selected',
428
+ message: '选择要下载的数据集',
429
+ choices,
430
+ hint: '空格选择,回车确认下载',
431
+ warn: '已下载或自动下载类型'
432
+ })
454
433
 
455
- if (!selected || selected.length === 0) {
456
- console.log(chalk.yellow('未选择任何数据集'))
457
- return
458
- }
434
+ if (!selected || selected.length === 0) {
435
+ console.log(chalk.yellow('未选择任何数据集'))
436
+ return
437
+ }
459
438
 
460
- // 下载选中的数据集
461
- for (const indexStr of selected) {
462
- const index = parseInt(indexStr)
463
- const dataset = DATASETS[index]
439
+ // 下载选中的数据集
440
+ for (const indexStr of selected) {
441
+ const index = parseInt(indexStr)
442
+ const dataset = DATASETS[index]
464
443
 
465
- console.log()
466
- console.log(chalk.cyan(`────────────────────────────────────`))
444
+ console.log()
445
+ console.log(chalk.cyan(`────────────────────────────────────`))
467
446
 
468
447
  // MNIST 特殊处理
469
448
  if (dataset.id === 'mnist') {
@@ -483,6 +462,14 @@ async function downloadDatasets() {
483
462
  console.log()
484
463
  console.log(chalk.cyan(`────────────────────────────────────`))
485
464
  console.log(chalk.green('所有选中的数据集已处理完成'))
465
+ } catch (error) {
466
+ // 用户按 ESC 或 Ctrl+C 取消
467
+ if (error.message && error.message.includes('cancel')) {
468
+ console.log(chalk.gray('返回上一级'))
469
+ return
470
+ }
471
+ throw error
472
+ }
486
473
  }
487
474
 
488
475
  /**
@@ -669,12 +656,9 @@ export async function runDataTUI() {
669
656
  await clearData()
670
657
  break
671
658
  case 5:
672
- showPath()
673
- break
674
- case 6:
675
659
  await removeData()
676
660
  break
677
- case 7:
661
+ case 6:
678
662
  console.log()
679
663
  console.log(chalk.gray('已退出数据管理'))
680
664
  console.log()