@minato-aqukin/autodl-cli 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -49,10 +49,10 @@ being saved, and you land on the dashboard. Once configured, `autodl` goes strai
49
49
 
50
50
  A live table of your instances: status, GPU, region, **how long each has been powered on
51
51
  and roughly what that has cost**, and how much TTL is left. Keys: `↑↓` move, `Enter`
52
- detail, `s` start, `x` stop, `c` copy the SSH command to the clipboard, `ctrl+d` release, `g` GPU stock,
53
- `n` new instance, `r` refresh, `ctrl+l` log out, `q` quit. The two that change or destroy
54
- something take ctrl rather than a bare key; shift makes no difference to either, and the
55
- hints are printed all-lowercase so they do not read as bindings you hold shift for.
52
+ detail, `s` start, `x` stop, `ctrl+d` release, `g` stock,
53
+ `r` refresh, `ctrl+l` log out, `?` help, `q` quit. Release and logout require confirmation.
54
+ The detail screen (`Enter`) owns the per-instance keys: `h` automatically authenticated
55
+ SSH, `f` files, `t` transfers, `c` copy the SSH command, `n` new instance.
56
56
 
57
57
  `ctrl+d` release wipes the instance permanently, which is why it is not a bare `d`.
58
58
 
@@ -91,6 +91,60 @@ The TUI never runs in a pipe, in CI, or under `--json`: it exits with code 2 and
91
91
  explanation instead of taking over a terminal that isn't there. A bare `autodl` outside
92
92
  an interactive terminal still prints help exactly as before.
93
93
 
94
+ ### SSH and file management
95
+
96
+ Open the detail screen (`Enter`) and press `h`: it hands the entire terminal to a
97
+ password-authenticated SSH session and restores the dashboard on exit or disconnect;
98
+ this is not an embedded terminal. Credentials are
99
+ fetched live and never placed in command arguments, logs, or transfer records.
100
+ The CLI equivalent is `autodl ssh <id> --auto-auth`. This mode uses ssh2, not OpenSSH
101
+ configuration. Keep using ordinary `autodl ssh <id>` for `~/.ssh/config`, agents and
102
+ forwarding such as `-L`. The implementation uses cross-platform Node.js terminal and
103
+ filesystem interfaces for Linux, macOS and native Windows; sshpass is not required.
104
+
105
+ On the detail screen, `f` opens local/remote panes; narrow terminals show the active pane. `Tab` switches
106
+ sides, arrows and Enter navigate, Space selects multiple entries, and `a` selects all.
107
+ `g` accepts a directory path; `p` accepts source/destination paths directly.
108
+ `u` transfers the selection to the opposite pane after confirming direction.
109
+ `m` creates directories, `r` renames or moves within one side, and `x` permanently
110
+ deletes after confirmation. `Q` opens the queue; Esc returns.
111
+
112
+ Relative paths resolve against their corresponding pane. Selected source basenames
113
+ are preserved: copying `project` into `/root/work` produces `/root/work/project`.
114
+ The browser transfers explicitly selected directory contents, without the legacy
115
+ `push` command's ignore rules. Symlinks and special files are skipped; queue details
116
+ offer `v` to browse every skipped entry.
117
+
118
+ Ordinary conflicts pause for `o` overwrite, `s` skip, or `b` keep both; `a` applies the
119
+ choice to remaining conflicts in this task. Toggle `s` in the browser to synchronize
120
+ one way: skip unchanged files, replace changed files in full, and **never delete
121
+ destination-only files**. Size/mtime comparison is the default; `c` enables SHA-256
122
+ comparison. Checksumming reads both files; remote contents are streamed over SFTP,
123
+ so strict checking can cost as much bandwidth as downloading the files.
124
+
125
+ The session queue is serial, with byte progress, speed, cancellation (`c`), details
126
+ (Enter), and manual resume (`r`). Recoverable transport failures have bounded retries;
127
+ authentication failures and powered-off instances pause instead. Starting a stopped
128
+ instance to open SSH/files or resume a task always requires a billing confirmation.
129
+ Automatic reconnect never powers an instance on.
130
+ The file view holds one browsing connection for list/mkdir/rename/remove; directory
131
+ contents are always read live, a dead connection reconnects on the next operation,
132
+ and leaving the view releases it.
133
+ The CLI `files` and `queue` commands share the same queue records: a task added via
134
+ `queue add` can be confirmed and resumed from the dashboard, and vice versa.
135
+
136
+ Transfers write same-directory `.autodl-*.part` files and commit only after completion,
137
+ preserving existing destinations on interruption. Resume validates the source version
138
+ and partial prefix, restarting changed/corrupt files. Remote replacement requires the
139
+ OpenSSH atomic-rename extension; unsupported servers fail without deleting the old file.
140
+ Credential-free records live under the config directory's `transfers/`, scoped by
141
+ account and API endpoint. Exit/logout pauses unfinished work. Restored tasks require
142
+ manual resume: **nothing runs in the background after exit**. Only one process may
143
+ mutate an account's queue; dead-process ownership claims are recoverable.
144
+ Cancelled tasks retain partial data; remove their `.part` files and local checkpoints
145
+ only when you no longer need to resume them.
146
+
147
+
94
148
  ## Setup
95
149
 
96
150
  The official API needs a developer token from an **identity-verified** account
@@ -303,9 +357,10 @@ same error contract; explicit help and version requests still print their normal
303
357
  | `info <id> [--show-password]` | Details, live SSH info, resource usage |
304
358
  | `create --gpu <spec>` | Create a pay-as-you-go Pro instance |
305
359
  | `start` / `stop` / `rm <id>` | Power on / off / release |
306
- | `ssh <id>` | Interactive login (extra flags pass through to `ssh`) |
360
+ | `ssh <id> [--auto-auth]` | System OpenSSH with extra flags, or automatic instance-password authentication |
307
361
  | `exec <id> <cmd…>` | Run a command, stream output, propagate exit code |
308
- | `push` / `pull <id>` | SFTP transfer, recursive, respects ignore files |
362
+ | `files ls/mkdir/mv/rm <id>` | Browse and manage instance files (SFTP, reused connection) |
363
+ | `queue add/ls/resume/cancel/resolve` | Serial transfer queue, shared with the dashboard |
309
364
  | `run <cmd…>` | Create → sync → run → fetch → power off |
310
365
  | `deploy <repo>` | Create → clone → install deps → start → **stop, keeping data** |
311
366
  | `stock [--gpu] [--region]` | Live GPU stock per region |
package/README.zh-CN.md CHANGED
@@ -43,9 +43,10 @@ autodl tui # 交互式终端里直接敲 autodl 也进
43
43
  粘贴 Token 后会先向 API 验证再保存,然后直接进看板。已经配置过的,敲 `autodl` 直接进。
44
44
 
45
45
  一张会自己刷新的实例表:状态、GPU、地区、**已开机多久、大概花了多少钱**、TTL 还剩多少。
46
- 快捷键:`↑↓` 移动、`Enter` 详情、`s` 开机、`x` 关机、`c` 复制 SSH 命令到剪贴板、`ctrl+d` 释放、
47
- `g` 看 GPU 库存、`n` 新建、`r` 刷新、`ctrl+l` 退出登录、`q` 退出。会改变或销毁东西的两个
48
- 都带 ctrl 而不是单键;按不按 shift 都认,提示也统一小写显示,免得看起来像要按 shift。
46
+ 快捷键:`↑↓` 移动、`Enter` 详情、`s` 开机、`x` 关机、`ctrl+d` 释放、`g` 库存、
47
+ `r` 刷新、`ctrl+l` 退出登录、`?` 帮助、`q` 退出。释放和退出登录需要确认。
48
+ 详情页(`Enter` 进入)里还有实例级操作:`h` 自动认证 SSH、`f` 文件管理、
49
+ `t` 传输队列、`c` 复制 SSH 命令、`n` 新建实例。
49
50
 
50
51
  `ctrl+d` 释放会永久清空实例,所以它不是单个 `d`。
51
52
 
@@ -77,6 +78,54 @@ autodl tui # 交互式终端里直接敲 autodl 也进
77
78
  TUI 不会在管道、CI 或 `--json` 下启动:它会以退出码 2 退出并说明原因,
78
79
  而不是去接管一个并不存在的终端。非交互环境下裸 `autodl` 仍然和以前一样打印帮助。
79
80
 
81
+ ### SSH 和文件管理
82
+
83
+ 先 `Enter` 进详情页再按 `h`,它会临时交出整个终端,用实时实例密码建立 SSH 会话;
84
+ 退出或断线后返回看板,不是看板内嵌入终端。
85
+ 也可运行 `autodl ssh <id> --auto-auth`。自动认证模式使用 ssh2,不读取 OpenSSH 配置;
86
+ 需要 `~/.ssh/config`、agent 或 `-L` 转发时,继续使用普通 `autodl ssh <id>`。
87
+ 实现使用 Node.js 的跨平台终端和文件接口,无需安装 sshpass;支持 Linux、macOS 和原生 Windows。
88
+
89
+ 详情页按 `f` 打开本地/远端双栏,窄屏显示活动侧,`Tab` 切换。文件操作:
90
+
91
+ | 按键 | 操作 |
92
+ |---|---|
93
+ | `↑↓`、`Enter`、`←` | 选择、进入目录、返回父目录 |
94
+ | `Space` / `a` | 多选 / 全选或清空 |
95
+ | `g` / `p` | 跳转路径 / 直接输入传输来源和目标目录 |
96
+ | `u` | 把选中项传到对侧目录,确认方向后加入队列 |
97
+ | `s` / `c` | 切换单向增量同步 / 内容校验 |
98
+ | `m` / `r` / `x` | 新建目录 / 改名或同端移动 / 确认后永久删除 |
99
+ | `Q` / `Esc` | 查看队列 / 返回 |
100
+
101
+ 相对路径以对应侧当前目录为基准。每个选中来源的文件名或目录名保留在目标目录下:
102
+ 例如把本地 `project` 传到远端 `/root/work`,结果是 `/root/work/project`。
103
+ 文件管理器传输明确选中的目录内容,不套用旧 `push` 命令的忽略规则;
104
+ 符号链接及特殊文件跳过,队列详情按 `v` 可逐项查看全部跳过记录。
105
+
106
+ 普通传输遇到同名文件会暂停询问:`o` 覆盖、`s` 跳过、`b` 保留两份,
107
+ `a` 切换对本任务其余冲突应用同一选择。同步则以所选方向的来源为准:
108
+ 跳过未变化文件,整份替换变化文件,**不删除目标端独有文件**。
109
+ 默认比较大小和修改时间;可开启 SHA-256 内容校验,但需要读取两端文件内容,
110
+ 远端校验会通过 SFTP 读取数据,因此严格校验可能消耗与下载相当的带宽。
111
+
112
+ 队列按顺序执行,显示字节进度、速度和状态。可返回看板继续操作;
113
+ 在队列按 `Enter` 看详情、`c` 取消、`r` 恢复已暂停或已取消任务。
114
+ 网络中断有界重试;实例关机或认证失败会暂停,不自动开机。
115
+ 文件页打开后只建立一条浏览连接,切目录、建目录、改名、删除都复用它;
116
+ 目录内容每次实时读取,连接断了下次操作自动重连,离开文件页即释放。
117
+ CLI 的 `files` 和 `queue` 命令与看板共用同一队列记录:
118
+ `queue add` 进去的任务能在看板 `t` 里确认冲突和恢复,反之亦然。
119
+
120
+ 未完成文件写入目标目录里的 `.autodl-*.part`,完成后才替换目标,取消不会截断原文件。
121
+ 续传会验证来源版本及已传前缀;来源变化或临时文件损坏时重新传输。
122
+ 覆盖远端文件需要服务器的 OpenSSH 原子重命名扩展;不支持时保留原文件并报错。
123
+ 任务记录位于配置目录的 `transfers/`,按账号和 API 地址隔离,不保存凭证。
124
+ 退出/退出登录会暂停任务;下次进入队列后手动恢复,**退出后不后台传输**。
125
+ 同一账号队列只允许一个进程写入,崩溃遗留的所有权记录可自动回收。
126
+ 取消会保留续传文件;确定不再恢复时可删除对应任务的 `.part` 和本地续传记录。
127
+
128
+
80
129
  ## 配置
81
130
 
82
131
  官方 API 需要**已完成实名认证**(个人或企业)账号的开发者 Token。
@@ -280,9 +329,10 @@ autodl guard idle pro-xxx --threshold 5 --samples 6 --interval 1m
280
329
  | `info <id> [--show-password]` | 详情、实时 SSH 信息、资源占用 |
281
330
  | `create --gpu <spec>` | 创建按量计费 Pro 实例 |
282
331
  | `start` / `stop` / `rm <id>` | 开机 / 关机 / 释放 |
283
- | `ssh <id>` | 交互式登录(多余参数原样透传给 `ssh`) |
332
+ | `ssh <id> [--auto-auth]` | 系统 SSH 登录,或使用实例密码自动认证;系统模式支持额外 OpenSSH 参数 |
284
333
  | `exec <id> <cmd…>` | 远程执行,流式输出,透传退出码 |
285
- | `push` / `pull <id>` | SFTP 传输,支持递归目录与忽略规则 |
334
+ | `files ls/mkdir/mv/rm <id>` | 实例文件浏览与管理(SFTP,连接复用) |
335
+ | `queue add/ls/resume/cancel/resolve` | 串行传输队列,与看板共用同一队列 |
286
336
  | `run <cmd…>` | 建实例 → 同步 → 执行 → 回传 → 关机 |
287
337
  | `deploy <仓库>` | 建实例 → 拉代码 → 装依赖 → 启动 → **关机保留数据** |
288
338
  | `stock [--gpu] [--region]` | 各地区 GPU 实时库存 |