Files
kid aa92d0e676 初始提交:terminalX 可运行态(M0/M1/M1.5 已真机验证)
- M0: libghostty SSH 终端(渲染/输入/连接)+ 白屏修复(OutputGate) + 会话状态机/自动重连
- M1: tsnet 用户态组网 + SSH-over-tsnet(fd 桥),shell 级真机验证;R5(Go+gvisor+C+++Swift 同进程) retire
- M1.5: tmux -CC 原生 tab(MVP)
- 结构: packages/(TXCore·TXTransport), apps/TerminalX, vendor/(libghostty-spm/libssh2/mbedtls/tsnet-bridge), artifacts/
- 文档: CLAUDE.md + docs/HANDOFF.md(新会话入口)
- 环境: 认证代理→依赖 vendor 本地化;Go 在 ~/.local/go;仅模拟器/未签名
- 待续: M2 mosh, tmux 多 pane, M4 安全(host key/SE)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 10:20:46 +08:00

71 lines
2.4 KiB
Swift

import Foundation
import GhosttyTerminal
public let defaultSandboxShell = ShellDefinition(
prompt: SandboxShellStyle.prompt,
welcomeMessage: SandboxShellStyle.welcomeMessage,
fallback: { command in
"\(SandboxShellStyle.error)\(command)\(SandboxShellStyle.reset): command not found"
}
) {
ShellCommand("echo", summary: "Echo text back") { context in
.output(context.arguments + "\r\n")
}
ShellCommand("date", summary: "Show current date/time") { _ in
let formatter = DateFormatter()
formatter.dateFormat = "EEE MMM dd HH:mm:ss zzz yyyy"
return .output(formatter.string(from: Date()) + "\r\n")
}
ShellCommand("uname", summary: "Show system information") { _ in
.output("Darwin ghostty-sandbox host-managed\r\n")
}
ShellCommand("whoami", summary: "Show current user") { context in
.output(context.username + "\r\n")
}
ShellCommand("env", summary: "Show environment variables") { context in
.output("""
TERM=xterm-ghostty\r
SHELL=/bin/zsh\r
USER=\(context.username)\r
HOME=/Users/\(context.username)\r
LANG=en_US.UTF-8\r
TERM_PROGRAM=GhosttyKit\r\n
""")
}
ShellCommand("size", summary: "Show terminal size") { context in
let size = context.terminalSize
return .output(
"columns: \(size.columns), rows: \(size.rows), " +
"pixels: \(size.widthPixels)x\(size.heightPixels)\r\n"
)
}
ShellCommand("clear", summary: "Clear the screen") { _ in
.clear
}
ShellCommand("exit", summary: "Exit the terminal") { _ in
.exit
}
ShellCommand("logout", summary: "Exit the terminal") { _ in
.exit
}
}
public let sandboxShell = defaultSandboxShell
private enum SandboxShellStyle {
static let reset = "\u{1B}[0m"
static let accent = "\u{1B}[38;5;110m"
static let highlight = "\u{1B}[38;5;221m"
static let error = "\u{1B}[38;5;203m"
static let emphasis = "\u{1B}[1m"
static let prompt = "\(accent)sandbox\(reset)@\(highlight)ghostty\(reset) % "
static let welcomeMessage = """
\r\n \(emphasis)\(accent)GhosttyKit Sandbox Demo\(reset)\r
\r\n This terminal runs inside App Sandbox.\r
\(accent)No subprocesses are spawned.\(reset)\r
Type '\(highlight)help\(reset)' for available commands.\r\n\r\n
"""
}