fix(cli): 收敛逐级披露与输入错误

This commit is contained in:
Codex
2026-07-12 02:01:47 +02:00
parent e4b7fb9fbc
commit 80edc6c08b
12 changed files with 2044 additions and 1195 deletions
+27
View File
@@ -330,6 +330,33 @@ export function sshHelp(scope: SshHelpScope | undefined = undefined): unknown {
};
}
export function renderSshHelpText(scope: SshHelpScope | undefined = undefined): string {
const entrypoint = sshEntrypoint();
if (scope === undefined) {
return [
"TRANS remote route executor",
`usage: ${entrypoint} <route> <operation> [operation-args...]`,
"routes: <provider>:/workspace | <provider>:k3s[:namespace:workload[:container]] | <provider>:win[/drive/path] | gh:/owner/repo/...",
`process: ${SSH_OPERATION_GROUPS.process.join(" | ")}`,
`shell: ${SSH_OPERATION_GROUPS.shell.join(" | ")}`,
`filesystem: ${SSH_OPERATION_GROUPS.filesystem.join(" | ")}`,
`patch: ${SSH_OPERATION_GROUPS.patch.join(" | ")}`,
`transfer: ${SSH_OPERATION_GROUPS.transfer.join(" | ")}`,
`scoped help: ${entrypoint} --help <operation>`,
"boundary: route only selects the target; use sh/bash/ps/cmd explicitly for shell syntax.",
].join("\n");
}
const detail = SSH_OPERATION_HELP[scope];
return [
`TRANS HELP ${scope}`,
`group: ${detail.group}`,
`description: ${detail.description}`,
...detail.usage.slice(0, 3).map((usage) => `usage: ${usage.replace(/^trans\b/u, entrypoint)}`),
...(detail.notes ?? []).slice(0, 2).map((note) => `note: ${note}`),
`back: ${entrypoint} --help`,
].join("\n");
}
function sshOperationHelp(scope: Exclude<SshHelpScope, "download">): unknown {
const entrypoint = sshEntrypoint();
const detail = SSH_OPERATION_HELP[scope];