migueldeicaza/SwiftTerm
59.2
Adequate · 1 October 2026
69.8k
lines of production code
Swift
primary language
2
measurements over time
What this system is
SwiftTerm is a cross-platform terminal emulator library written in Swift, providing core rendering, text processing, and protocol support for macOS, iOS, and WebAssembly environments. It handles complex terminal features including bidirectional text, Kitty graphics and clipboard protocols, and off-main-thread Metal rendering to ensure performance and responsiveness. The system includes comprehensive tooling for benchmarking, fuzzing, and visual validation, alongside sample applications that demonstrate SSH connectivity and web-based terminal integration.
How it got here
2019–2020 — BiDi support and platform modernization
14 changes.
This period focused on adding bidirectional text rendering and restructuring the terminal buffer internals for performance. It also involved modernizing the Apple platform front-ends with advanced protocol support, SwiftUI wrappers, and dedicated sample applications.
2025–2026 — WebAssembly, Web Terminal, and Performance Tooling
14 changes.
This period focused on expanding SwiftTerm's reach and reliability by introducing a WebAssembly ABI for browser-based terminal rendering and a complete client-side Web Terminal infrastructure. Significant effort was also dedicated to performance optimization and validation, including off-main-thread Metal rendering, comprehensive benchmarking suites, and the development of specialized testing tools for bidirectional text and graphics parity.
Features
Add Termcast tool for recording and replaying terminal sessions
Introduces the Termcast command-line application, which allows users to record terminal sessions and replay them in a format compatible with asciinema. The implementation includes a recorder that captures input, output, and resize events, and a player that replays these events with timing fidelity, exposing 'record' and 'playback' subcommands via ArgumentParser.
Sources/Termcast · high confidence
Initial project scaffolding and documentation
The repository is initialized with core project files including a MIT license, a Code of Conduct, and a Security policy. Documentation is added for performance benchmarking and a migration guide from version 1.x to 2.x. A Makefile is introduced to manage build tasks such as fuzzing and benchmarking, and a terminfo entry is provided to define terminal capabilities for the SwiftTerm emulator.
(repo-wide) · high confidence
Introduce MacTerminal sample app with Kitty protocol support and clipboard integration
The MacTerminal sample application is introduced to demonstrate the SwiftTerm library on macOS. It features a native AppKit interface with menu items for exporting buffer and selection content, and integrates the Kitty keyboard and graphics protocols. The app implements the Kitty clipboard protocol (OSC 5522), allowing terminal programs to request clipboard access with user permission prompts, and supports Base16 color themes. It also includes an IO baseline harness for measuring main-thread stall times and performance under load.
TerminalApp/MacTerminal · high confidence
Introduce off-main-thread Metal rendering via CAMetalLayer
SwiftTerm now supports rendering the terminal via Metal on a background thread by introducing a new \CAMetalLayer\-backed surface (\TerminalMetalLayerView\) alongside the existing \MTKView\ path. This change decouples the GPU render loop from the main thread's display cycle, allowing the terminal to maintain responsiveness during heavy main-thread workloads. The update includes the necessary infrastructure for this dual-surface architecture, such as the \MetalRenderTarget\ protocol, \MetalBufferingMode\ for controlling buffer strategies, and a \CoreTextGlyphRasterizer\ with configurable font smoothing, ensuring that the new off-main-thread path produces pixel-identical output to the legacy main-thread renderer.
Sources/SwiftTerm/Apple/Metal · high confidence
Introduces WebAssembly ABI for terminal rendering, graphics, and clipboard operations
This change adds a new WebAssembly (WASM) interface layer to SwiftTerm, exposing a stable ABI (version 1) for host applications to control the terminal. It introduces new modules in \Sources/SwiftTermWebWasm\ that handle memory management, handle registries, and specific exports for terminal lifecycle (create, destroy, reset, resize), input/output, and graphics updates. The implementation includes support for Kitty graphics protocol (inline images, placeholders, and raster images) and Kitty clipboard operations, allowing web-based hosts to render terminal content and manage graphics state via a portable, lock-free snapshot mechanism.
Sources/SwiftTerm/Portable, Sources/SwiftTermWebWasm · high confidence
Introduces bidirectional text (BiDi) support and restructures terminal buffer internals
SwiftTerm now supports bidirectional text rendering for Arabic and Hebrew via the terminal-wg protocol, exposing configuration options like \BidiSupportMode\, \BidiDirection\, and \BidiPresentationState\ to control how logical text is processed and displayed. This change is accompanied by a significant internal restructuring of the terminal buffer system, including the introduction of \PackedCell\ for efficient 64-bit cell storage, a new \BufferRef\ mechanism to optimize reference counting, and the inlining of \BufferSet\ into the \Terminal\ class to improve performance and reduce memory overhead.
Sources/SwiftTerm · high confidence
Major rendering overhaul and new protocol support on Apple platforms
The Apple terminal view has been significantly reworked to support advanced rendering and new terminal protocols. Bidirectional text (Arabic/Hebrew) is now fully supported with Unicode 17.0 data, and block elements are rendered with correct geometry. The view now supports the Kitty graphics protocol (including images and Unicode placeholders) and the Kitty clipboard protocol (OSC 5522). Performance is improved by moving Metal rendering off the main thread, coalescing output, and optimizing color handling. New features include configurable bell styles, bracketed paste, and improved cursor styles.
Sources/SwiftTerm/Apple · high confidence
New RenderBench performance harness for SwiftTerm
A new benchmarking tool, RenderBench, has been added to the Tools directory to measure the combined parser, buffer, invalidation, and UI render performance of SwiftTerm. It drives a real, on-screen TerminalView without requiring a PTY or shell, using deterministic synthetic workloads to ensure reproducible results. Users can run built-in scenarios (such as dense coloring, scrolling, and Arabic text shaping) or import shared VTEBench workloads, choosing between Core Graphics and Metal renderers via command-line flags. The tool provides detailed metrics including input throughput, render rates, and frame presentation status, and includes a specific debug scenario to reproduce and verify fixes for stalled Metal renderer frames.
Tools/RenderBench · high confidence
New SwiftTerm performance benchmarking suite
A new benchmarking tool has been added to the \Tools/SwiftTermBenchmarks\ directory, enabling developers to measure \HeadlessTerminal\ throughput using 12 vtebench-derived workloads and dedicated Kitty graphics snapshot tests. The suite includes a Swift Package harness for automated benchmarking and a standalone profiling executable (\SwiftTermProfile\) for detailed Instruments tracing and CPU counter analysis, along with the necessary license attributions for the imported vtebench resources.
Tools/SwiftTermBenchmarks · high confidence
New SwiftUI wrapper and dedicated iOS accessory keyboard
SwiftTerm now includes a SwiftUI-compatible \SwiftUITerminalView\ for easier embedding in SwiftUI apps, alongside a new \TerminalAccessory\ input view that provides a dedicated on-screen keyboard with keys for F1–F10, navigation, and modifiers like Control. This accessory view also supports auto-repeat for cursor keys and allows toggling between the on-screen keyboard and mouse reporting.
Sources/SwiftTerm/iOS · high confidence
New SwiftUI-based SSH login interface for iOS Terminal
The iOS Terminal app now features a redesigned login experience built with SwiftUI. A new SSHLoginView presents a styled card for entering local SSH credentials (username and password), which triggers the connection to localhost:22. This SwiftUI view is hosted within the existing UIKit ViewController, replacing the previous setup flow. The underlying terminal connection logic remains handled by the existing UIKit-based terminal views.
TerminalApp/iOSTerminal · high confidence
New developer tooling for Kitty graphics parity, fuzz corpus import, and PTY benchmarking
Added three new scripts in the Tools directory to support development and testing workflows: \generate\_kitty\_parity\_matrix.py\ generates a documentation matrix mapping Ghostty's Kitty graphics tests to iiSwiftTerm test coverage; \import-ghostty-fuzz-corpus.swift\ imports Ghostty fuzzing corpus data into SwiftTerm test fixtures; and \run-pty-benchmark.py\ provides a framework for building and comparing MacTerminal PTY performance metrics across different code versions.
Tools · high confidence
New macOS terminal view components and caret rendering
The macOS AppKit front-end now includes a dedicated MacCaretView for rendering the terminal cursor with support for focus tracking, blinking styles, and transparency, alongside a TerminalFindBarView for search functionality. The MacTerminalView has been updated to use an overlay scroller indicator and manages mouse-move events via a window-scoped fallback for macOS 26+, while MacLocalTerminalView provides a convenient interface for launching local processes with a dedicated delegate protocol for process lifecycle and clipboard events.
Sources/SwiftTerm/Mac · high confidence
New visual BidiHarness tool for testing bidirectional terminal rendering
A new macOS application, BidiHarness, has been added to the Tools directory to visually test and validate bidirectional (BiDi) terminal text rendering. The harness provides a split-view interface displaying both a SwiftTerm-based terminal and a WebKit reference view, allowing users to load predefined scenarios (stored as JSON) that exercise complex text layouts, CJK scrolling, box-drawing, and selection behaviors. It supports switching between Core Graphics and Metal renderers, captures visual artifacts for regression comparison, and exposes a socket-based control interface for automated testing.
Tools/BidiHarness · high confidence
Web Terminal client-side rendering and testing infrastructure
The Web Terminal now includes a client-side rendering engine and a comprehensive suite of browser-based tests. The \app.js\ module introduces a \ShellClient\ that manages WebSocket connections, handles terminal resizing, and processes server control frames (ready, exit, error). A new \ClipboardController\ in \clipboard.js\ manages clipboard permissions and data exchange. To ensure reliability, the \BrowserTests\ directory now contains smoke tests (\server-smoke.mjs\, \backend-live.mjs\) that verify WebSocket connectivity and shell interaction, unit tests (\client.test.mjs\, \clipboard.test.mjs\) for the client logic, and live UI/performance tests (\ui-live.mjs\, \performance-live.mjs\) using Playwright to measure rendering speed and input latency.
TerminalApp/WebTerminal, Web · high confidence
Architecture
MacTerminal project reorganized into TerminalApp directory
The MacTerminal Xcode project has been moved into the TerminalApp directory and is now referenced from the SwiftTerm.xcworkspace. This restructuring updates the project file paths and workspace references to reflect the new location, ensuring the build system correctly locates the MacTerminal.app target and its dependencies (SwiftTerm and VTEBenchWorkloads).
TerminalApp/MacTerminal.xcodeproj · high confidence
Behavioural changes
Added iOSTerminal workspace configuration
The iOSTerminal project is now included in the Xcode workspace, enabling it to be built and run alongside the main TerminalApp. This change introduces the necessary workspace data files and updates the IDE workspace checks configuration to reflect the new project structure.
TerminalApp/iOSTerminal.xcodeproj/project.xcworkspace · high confidence
Build-time generation of terminal capability and version metadata
A new build plugin now generates Swift source files at compile time to embed Git repository information (branch, tag, commit, and dirty status) and a static table of terminfo capabilities. The generated version metadata is exposed via \SwiftTermBuildInfo.version\ for diagnostic purposes, while the terminfo data is compiled into \SwiftTermTerminfo.xtgettcapReplies\ to support XTGETTCAP queries. This approach ensures build stability by only writing output files when content changes and excludes the generated code from embedded builds via \\#if !SWIFTTERM\_EMBEDDED\.
Sources/SwiftTermBuildInfoGenerator · high confidence
Pin Swift WASM builds to version 6.4 and add build automation scripts
The build process for WebAssembly targets is now pinned to the Swift 6.4.0 release toolchain (via \scripts/wasm-toolchain.env\), ensuring consistent compiler and SDK versions for both browser and smoke-test builds. A new \scripts/build-wasm.sh\ script automates the build, export verification, and artifact generation, supported by \scripts/wasm-artifact.mjs\ for WASM inspection and stripping, and \scripts/check-wasm-exports.sh\ for ABI validation. Additionally, \scripts/regen\_unicode\_width\_data.py\ has been added to regenerate terminal-width lookup data based on Unicode 17.0.0 specifications.
scripts · high confidence
Stable build-time generation of SwiftTerm version and terminfo data
The SwiftTerm build plugin now generates SwiftTermBuildInfo.swift and SwiftTermTerminfo.swift files at build time, incorporating source-control metadata (branch, tag, commit, dirty state) and terminfo capabilities. By carefully selecting stable input files (such as Package.swift, swifterm-terminfo, and specific .git state files) rather than the entire source tree, the plugin ensures that generated outputs remain consistent across builds, preventing unnecessary rebuilds of SwiftTerm when unrelated files change.
Plugins/SwiftTermBuildInfoPlugin · high confidence
iOS sample app renamed to iOSTerminal with modern SSH stack
The iOS sample application has been renamed from SwiftTerm to iOSTerminal, and the project structure has been updated to replace the legacy SSH implementation with a modern stack using NIOSSH and NIOPosix. This change introduces new source files (SSHLoginView.swift, TerminalHostViewController.swift, UIKitSshTerminalView.swift) and updates the build configuration to embed these frameworks, resulting in a rebuilt app bundle named iOSTerminal.app.
TerminalApp/iOSTerminal.xcodeproj · high confidence
Test coverage
Added Ghostty-style fuzzer entry point for SwiftTerm; Added Unicode column-width benchmark; Added performance test baseline for SwiftTermTests; Added unit tests for HeadlessTerminal behavior; Expanded test coverage for embedded core, BiDi, and rendering internals; Removal of default SwiftTerm test file.
Dependencies
Update Swift and Web dependencies to Swift 6.2 toolchain and Playwright 1.55.1
The project updates its Swift Package Manager manifests to use the Swift 6.2 toolchain, introducing support for Embedded and WebAssembly (Wasm) build traits, conditional platform exclusions, and new executable targets like Termcast and SwiftTermFuzz. It also bumps the Web directory's Playwright dependency to version 1.55.1 and updates various Swift packages (such as swift-argument-parser, swift-nio, and hummingbird) across the root, WebTerminal, and benchmark tool packages to ensure compatibility with the new toolchain and platform targets.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 63 → 59 (-3.5)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 68 → 69 (+0.4)
- Architecture 97 → 94 (-2.7)
- Maturity 91 → 90 (-1.1)
- Readiness 48 → 40 (-7.9)
- Security 72 → 75 (+3.1)
- Domain Modelling 100 → 100 (+0.0)
- Accessibility 82 → 82 (+0.0)
- Performance 81 (new)
Resolved (20)
- Dependency hygiene PARTLY measured — npm pinning read, dependency currency not (no pnpm-resolved versions to grade)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Documentation: written for insiders (Docs/semantic-prompt-design.md)
- Duplicated block (6 lines × 2) (Sources/SwiftTerm/Mac/MacTerminalView.swift)
- Duplicated block (9–10 lines × 2) (Sources/SwiftTerm/Terminal.swift)
- Edited copy of a member (10 corresponding lines) (Sources/SwiftTerm/Apple/AppleTerminalView.swift)
- High: security finding (details withheld)
- Hotspot: Sources/SwiftTerm/Apple/AppleTerminalView.swift (Sources/SwiftTerm/Apple/AppleTerminalView.swift)
- Hotspot: Sources/SwiftTerm/Apple/Metal/GlyphAtlas.swift (Sources/SwiftTerm/Apple/Metal/GlyphAtlas.swift)
- Hotspot: Sources/SwiftTerm/CharData.swift (Sources/SwiftTerm/CharData.swift)
- Hotspot: Sources/SwiftTerm/Colors.swift (Sources/SwiftTerm/Colors.swift)
- Hotspot: Sources/SwiftTerm/HangulInput.swift (Sources/SwiftTerm/HangulInput.swift)
- Hotspot: Sources/SwiftTerm/KittyClipboardProtocol.swift (Sources/SwiftTerm/KittyClipboardProtocol.swift)
- Hotspot: Sources/SwiftTerm/KittyPlaceholder.swift (Sources/SwiftTerm/KittyPlaceholder.swift)
- Hotspot: Sources/SwiftTerm/SearchEngine.swift (Sources/SwiftTerm/SearchEngine.swift)
- Hotspot: Sources/SwiftTerm/iOS/iOSAccessoryView.swift (Sources/SwiftTerm/iOS/iOSAccessoryView.swift)
- Hotspot: Sources/SwiftTermWebWasm/SnapshotEncoder.swift (Sources/SwiftTermWebWasm/SnapshotEncoder.swift)
- Hotspot: Tools/BidiHarness/BidiHarness/ArtifactCapture.swift (Tools/BidiHarness/BidiHarness/ArtifactCapture.swift)
- MethodTooLong: TerminalView.mapColor (Sources/SwiftTerm/Mac/MacTerminalView.swift)
New (44)
- BoxDrawingRenderer.swift.linesChar (cognitive 64) (Sources/SwiftTerm/Apple/BoxDrawingRenderer.swift)
- BoxDrawingRenderer.swift.linesChar (cyclomatic 57) (Sources/SwiftTerm/Apple/BoxDrawingRenderer.swift)
- Coverage not measured — Swift suite
- Duplicated block (10 lines × 2) (Sources/SwiftTerm/Apple/SnapshotTextBuilder.swift)
- Duplicated block (12 lines × 2) (Sources/SwiftTerm/Apple/BoxDrawingRenderer.swift)
- Duplicated block (12 lines × 2) (scripts/regen_unicode_width_data.py)
- Duplicated block (12 lines × 2) (scripts/regen_unicode_width_data.py)
- Duplicated block (17 lines × 2) (Sources/SwiftTerm/Profiling.swift)
- Duplicated block (5 lines × 2) (Sources/SwiftTerm/Apple/BoxDrawingRenderer.swift)
- Duplicated block (5 lines × 2) (Tools/SwiftTermBenchmarks/analyze-time-profile.py)
- Duplicated block (6 lines × 3) (scripts/regen_unicode_width_data.py)
- Duplicated block (8 lines × 2) (Docs/prototypes/futex-ticket-lock/main.swift)
- Duplicated block (8 lines × 3) (scripts/regen_unicode_width_data.py)
- Duplicated block (9–10 lines × 2) (scripts/regen_unicode_width_data.py)
- Edited copy of a member (10 corresponding lines) (Sources/SwiftTerm/Apple/AppleTerminalView.swift)
- FunctionTooLong: BoxDrawingRenderer.swift.linesChar (Sources/SwiftTerm/Apple/BoxDrawingRenderer.swift)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- Hotspot: Sources/SwiftTerm/Profiling.swift (Sources/SwiftTerm/Profiling.swift)
- …and 24 more
Changes since last survey
- 16 commits — 12 feature/other, 4 fixes
By area
- Sources/SwiftTerm — 9 commits
- (root) — 2 commits
- .github/workflows — 2 commits
- TerminalApp/MacTerminal — 2 commits
- Tests/SwiftTermTests — 1 commit
Notable commits
- fix: Fix CI: DocC does not work for Embedded mode, avoid it
- fix: Fix Insert/Delete Line corrupting the screen in margin mode (#707)
- fix: Fix NUL characters in getBufferAsData output (#718)
- fix: Fix the clicking event notifications being slowed down. (#714)
- change: Add tests
- change: CI: add WASI smoke build with released Swift 6.3.3
- change: Mac: Allow users to control whether certain accelerators are sent to the remote end when Kitty keyboard input is enabled
- change: Make TerminalView.currentMouseMode public on macOS (#715)
- change: Prevents flashing when creating new windows with the Metal backend.
- change: Stop implicit path links from absorbing the next path (#702)
- change: Update sample
- change: Use UITraitCollection for getting scale factor (#713)
- change: avoid SwiftPM 6.2 embedded link mode for normal builds (#720)
- change: exclude profiling helpers from WASI builds (#721)
- change: macOS: report focus on window activation; keep Control in Meta chords on iOS (#700)
- change: pin browser wasm builds to Swift 6.4 release (#722)
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
migueldeicaza/SwiftTerm was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit b6eb17c96c4667f8391d6cf5dfba270f1da1f8ae — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.