初始提交: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>
This commit is contained in:
kid
2026-07-24 10:20:46 +08:00
commit aa92d0e676
2761 changed files with 803505 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
diff --git a/build.zig.zon b/build.zig.zon
index f80cd53b3..e6141add7 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -26,10 +26,7 @@
.lazy = true,
},
.zig_objc = .{
- // mitchellh/zig-objc
- .url = "https://deps.files.ghostty.org/zig_objc-f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz",
- .hash = "zig_objc-0.0.0-Ir_Sp5gTAQCvxxR7oVIrPXxXwsfKgVP7_wqoOQrZjFeK",
- .lazy = true,
+ .path = ".libghostty-spm/zig_objc",
},
.zig_js = .{
// mitchellh/zig-js
diff --git a/pkg/macos/video/display_link.zig b/pkg/macos/video/display_link.zig
index 4866531f2..18e9e40ec 100644
--- a/pkg/macos/video/display_link.zig
+++ b/pkg/macos/video/display_link.zig
@@ -2,6 +2,8 @@ const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
+extern "c" fn ghostty_arm64e_sign_function(*const anyopaque) *const anyopaque;
+
pub const DisplayLink = opaque {
pub const Error = error{
@@ -58,7 +60,7 @@ pub const DisplayLink = opaque {
) Error!void {
if (c.CVDisplayLinkSetOutputCallback(
@ptrCast(self),
- @ptrCast(&(struct {
+ @ptrCast(@alignCast(ghostty_arm64e_sign_function(@ptrCast(&(struct {
fn callback(
displayLink: *DisplayLink,
inNow: *const c.CVTimeStamp,
@@ -78,7 +80,7 @@ pub const DisplayLink = opaque {
);
return c.kCVReturnSuccess;
}
- }).callback),
+ }).callback)))),
userinfo,
) != c.kCVReturnSuccess)
return error.InvalidOperation;

View File

@@ -0,0 +1,64 @@
diff --git a/src/block.zig b/src/block.zig
index bd4b17d..4d43262 100644
--- a/src/block.zig
+++ b/src/block.zig
@@ -4,6 +4,7 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const objc = @import("main.zig");
+extern "c" fn ghostty_arm64e_prepare_block(*anyopaque) void;
// We have to use the raw C allocator for all heap allocation in here
// because the objc runtime expects `malloc` to be used. If you don't use
// malloc you'll get segfaults because the objc runtime will try to free
@@ -42,7 +43,7 @@ pub fn Block(
const Self = @This();
const captures_info = @typeInfo(Captures).@"struct";
const InvokeFn = FnType(anyopaque);
- const descriptor: Descriptor = .{
+ var descriptor: Descriptor = .{
.reserved = 0,
.size = @sizeOf(Context),
.copy_helper = &descCopyHelper,
@@ -90,6 +91,7 @@ pub fn Block(
@field(ctx, field.name) = @field(captures, field.name);
}
+ ghostty_arm64e_prepare_block(@ptrCast(&ctx));
return ctx;
}
diff --git a/src/class.zig b/src/class.zig
index e0c989c..697fe31 100644
--- a/src/class.zig
+++ b/src/class.zig
@@ -7,5 +7,7 @@ const objc = @import("main.zig");
const MsgSend = @import("msg_send.zig").MsgSend;
+extern "c" fn ghostty_arm64e_sign_function(*const anyopaque) *const anyopaque;
+
pub const Class = struct {
value: c.Class,
@@ -65,7 +67,12 @@ pub const Class = struct {
assert(fn_info.params.len >= 2);
assert(fn_info.params[0].type == c.id);
assert(fn_info.params[1].type == c.SEL);
- _ = c.class_replaceMethod(self.value, objc.sel(name).value, @ptrCast(&imp), null);
+ _ = c.class_replaceMethod(
+ self.value,
+ objc.sel(name).value,
+ @ptrCast(@alignCast(ghostty_arm64e_sign_function(@ptrCast(&imp)))),
+ null,
+ );
}
// allows adding new methods; returns true on success.
@@ -81,7 +88,7 @@ pub const Class = struct {
return boolResult(c.class_addMethod(
self.value,
objc.sel(name).value,
- @ptrCast(&imp),
+ @ptrCast(@alignCast(ghostty_arm64e_sign_function(@ptrCast(&imp)))),
&encoding,
));
}