Skip to content

Commit dccb7d5

Browse files
committed
fix: resolve all TypeScript errors (JSON.parse casts, missing categoryLabels)
1 parent 40957f0 commit dccb7d5

3 files changed

Lines changed: 77 additions & 198 deletions

File tree

docs/data/census.data.ts

Lines changed: 47 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export interface CensusData {
7171
baselines: Record<string, string[]>
7272
/** backend name -> baseline -> { total, yes, pct } */
7373
baselineStats: Record<string, Record<string, { total: number; yes: number; pct: number }>>
74+
/** category slug -> display label */
75+
categoryLabels: Record<string, string>
7476
generated: string
7577
}
7678

@@ -86,7 +88,7 @@ interface FeatureMeta {
8688
}
8789

8890
function loadFeatureDescriptions(): Record<string, FeatureMeta> {
89-
const path = join(__dirname, "..", "..", "features.json")
91+
const path = join(__dirname, "..", "..", "content", "features.json")
9092
if (!existsSync(path)) {
9193
throw new Error(`features.json not found at ${path}`)
9294
}
@@ -116,7 +118,7 @@ function loadFeatureDescriptions(): Record<string, FeatureMeta> {
116118
}
117119

118120
function loadAnnotations(): Record<string, { note: string; url?: string; result?: string }> {
119-
const annotationsPath = join(__dirname, "..", "..", "annotations.json")
121+
const annotationsPath = join(__dirname, "..", "..", "content", "annotations.json")
120122
if (!existsSync(annotationsPath)) {
121123
throw new Error(`annotations.json not found at ${annotationsPath}`)
122124
}
@@ -126,6 +128,12 @@ function loadAnnotations(): Record<string, { note: string; url?: string; result?
126128
>
127129
}
128130

131+
function loadCategoryLabels(): Record<string, string> {
132+
const path = join(__dirname, "..", "..", "content", "categories.json")
133+
const raw = JSON.parse(readFileSync(path, "utf-8")) as Record<string, { label: string }>
134+
return Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, v.label]))
135+
}
136+
129137
function loadBackendMeta(): Record<string, BackendMeta> {
130138
const m = manifest()
131139
const meta: Record<string, BackendMeta> = {}
@@ -214,12 +222,11 @@ function mergeResults(app: CensusData, headless: CensusData): CensusData {
214222
}
215223

216224
function headlessToAppName(backend: string): string {
217-
const map: Record<string, string> = {
218-
xtermjs: "com.microsoft.VSCode",
219-
"ghostty-native": "ghostty",
220-
kitty: "kitty",
225+
const terms = loadTerminals()
226+
for (const [name, entry] of Object.entries(terms)) {
227+
if ((entry as any).headlessBackends?.includes(backend)) return name
221228
}
222-
return map[backend] ?? backend
229+
return backend
223230
}
224231

225232
/** Load community/app results from docs/data/results/app/ */
@@ -327,122 +334,50 @@ function loadAppResults(): CensusData {
327334
featureDescriptions: featureDescs,
328335
baselines: {},
329336
baselineStats: {},
337+
categoryLabels: loadCategoryLabels(),
330338
generated: new Date().toISOString(),
331339
}
332340
}
333341

342+
let _terminals: Record<string, any> | null = null
343+
function loadTerminals(): Record<string, any> {
344+
if (_terminals) return _terminals
345+
const path = join(__dirname, "..", "..", "content", "terminals.json")
346+
_terminals = JSON.parse(readFileSync(path, "utf-8")) as Record<string, any>
347+
return _terminals!
348+
}
349+
334350
function buildAppMeta(terminalName: string): BackendMeta {
335-
const labels: Record<string, string> = {
336-
ghostty: "Ghostty",
337-
kitty: "Kitty",
338-
iterm2: "iTerm2",
339-
"terminal-app": "Terminal.app",
340-
warp: "Warp",
341-
cmux: "cmux",
342-
cursor: "Cursor",
343-
"com.microsoft.VSCode": "VS Code",
344-
"com.todesktop.230313mzl4w4u92": "Cursor",
345-
}
346-
const slugs: Record<string, string> = {
347-
ghostty: "ghostty",
348-
kitty: "kitty",
349-
iterm2: "iterm2",
350-
"terminal-app": "terminal-app",
351-
warp: "warp",
352-
cmux: "cmux",
353-
cursor: "cursor",
354-
"com.microsoft.VSCode": "vscode",
355-
"com.todesktop.230313mzl4w4u92": "cursor",
356-
}
357-
const descriptions: Record<string, string> = {
358-
ghostty:
359-
"GPU-accelerated terminal by Mitchell Hashimoto. Written in Zig, Metal/OpenGL/Vulkan. Excellent standards compliance.",
360-
kitty:
361-
"GPU-accelerated terminal by Kovid Goyal. Pioneer of the Kitty keyboard and graphics protocols. Written in C/Python.",
362-
iterm2: "Feature-rich macOS terminal with split panes, profiles, and extensive customization. Native Cocoa app.",
363-
"terminal-app": "Apple's built-in macOS terminal. Ships with every Mac.",
364-
warp: "AI-powered terminal with blocks-based UI. Rust-based, GPU-accelerated.",
365-
cmux: "Terminal multiplexer built on libghostty (Ghostty's terminal emulation library). Inherits Ghostty's VT parser.",
366-
cursor: "AI code editor with integrated terminal. Based on VS Code, uses xterm.js for terminal emulation.",
367-
"com.microsoft.VSCode": "Microsoft's code editor with integrated terminal. Uses xterm.js for terminal emulation.",
368-
"com.todesktop.230313mzl4w4u92": "AI code editor with integrated terminal. Based on VS Code, uses xterm.js.",
369-
}
370-
371-
const bodies: Record<string, string> = {
372-
ghostty: `<p>Ghostty is a terminal emulator created by <strong>Mitchell Hashimoto</strong>, founder of HashiCorp (Terraform, Vagrant, Vault). Written in <strong>Zig</strong> with GPU-accelerated rendering via Metal (macOS), OpenGL, and Vulkan. First released in late 2024 after years of development, Ghostty quickly gained attention for its focus on correctness and performance.</p>
373-
<p>Ghostty's architecture separates the terminal emulation core into <strong>libghostty</strong>, a reusable library that other projects can embed. This is how <strong>cmux</strong> (the Ghostty multiplexer) gets its terminal emulation — it links against libghostty directly. The library handles VT parsing, grid management, and rendering, while the app adds window management and platform integration.</p>
374-
<p>Among modern terminals, Ghostty has some of the best standards compliance, supporting kitty keyboard protocol, kitty graphics, sixel, OSC 8 hyperlinks, semantic prompts, and full Unicode including grapheme clustering. It scores consistently near the top of terminfo.dev's feature matrix.</p>`,
375-
376-
kitty: `<p><strong>Kitty</strong> was created by <strong>Kovid Goyal</strong> and first released in 2017. Written in C and Python with <strong>OpenGL GPU rendering</strong>, it was one of the first terminals to use the GPU for text rendering, achieving smooth scrolling and low latency that traditional CPU-rendered terminals couldn't match.</p>
377-
<p>Kitty's most lasting contribution to the terminal ecosystem is the <strong>Kitty keyboard protocol</strong> (CSI u), which solves decades-old ambiguity in how terminals encode keypresses. The protocol has since been adopted by Ghostty, WezTerm, foot, and others. Kitty also pioneered the <strong>Kitty graphics protocol</strong> for inline image display and introduced extended underline styles (curly, dotted, dashed) with independent underline colors — features now standard in modern terminals.</p>
378-
<p>Kitty supports a rich extension ecosystem through "kittens" — small Python programs that run inside the terminal. Notable kittens include an image viewer, SSH integration, and a diff viewer. The terminal also features native tab and window management, remote control via IPC, and extensive Unicode support.</p>`,
379-
380-
iterm2: `<p><strong>iTerm2</strong> is the most popular third-party terminal for macOS, created by <strong>George Nachman</strong>. It's a successor to the original iTerm project, first released in 2010 as a native Cocoa application. iTerm2 has been the de facto "power user" terminal on macOS for over a decade.</p>
381-
<p>iTerm2 pioneered several features that became ecosystem standards: <strong>shell integration</strong> via OSC 133 semantic prompts (marking prompt, command, and output boundaries), the <strong>iTerm2 image protocol</strong> (OSC 1337) for inline image display, and sophisticated profile management. Its split pane system, tmux integration, and Instant Replay (scrubbing through terminal history) remain unmatched in many competitors.</p>
382-
<p>While iTerm2 supports truecolor and most modern escape sequences, it has been slower to adopt some newer protocols like the kitty keyboard protocol. It remains the most feature-complete terminal on macOS for users who don't need GPU acceleration, with features like triggers (automated actions on pattern matches), password manager integration, and extensive mouse reporting.</p>`,
383-
384-
"terminal-app": `<p><strong>Terminal.app</strong> is Apple's built-in terminal emulator, shipping with every Mac since <strong>Mac OS X 10.0</strong> (2001). It's the terminal most macOS users encounter first, and for many developers it's all they ever need.</p>
385-
<p>Terminal.app is deliberately conservative in its feature set. It was slow to adopt truecolor support and still lacks modern protocols like the kitty keyboard protocol. However, it provides solid basics: UTF-8 support, 256-color mode, mouse tracking, and integration with macOS services like Profiles and the Touch Bar. Its shell integration supports marks and bookmarks for navigating command output.</p>
386-
<p>Despite its limitations, Terminal.app is notable for its reliability and zero-setup experience. It's the baseline that macOS developers test against, and its VT100/VT220 compliance covers the vast majority of real-world terminal usage.</p>`,
387-
388-
warp: `<p><strong>Warp</strong> is a modern terminal built in <strong>Rust</strong> with GPU acceleration, backed by venture capital funding. It breaks from the traditional terminal paradigm with a <strong>blocks-based UI</strong> where each command and its output form a distinct visual block that can be selected, copied, and shared independently.</p>
389-
<p>Warp's most distinctive feature is its AI integration — it offers command suggestions, natural language to shell translation, and inline documentation. The terminal also features a modern text editor for command input (with selection, multi-cursor, and syntax highlighting) rather than the traditional readline-style input.</p>
390-
<p>Under the hood, Warp uses its own GPU-rendered terminal emulator with good standards compliance. It supports truecolor, mouse tracking, bracketed paste, and most modern escape sequences. The Rust codebase provides native performance while the GPU renderer handles smooth scrolling and high-DPI displays. Available on macOS and Linux.</p>`,
391-
392-
cmux: `<p><strong>cmux</strong> is a terminal multiplexer built by the <strong>Ghostty project</strong>, serving as a modern alternative to tmux and screen. Unlike traditional multiplexers that implement their own VT parser, cmux is built on <strong>libghostty</strong> — the same terminal emulation library that powers the Ghostty terminal.</p>
393-
<p>This architectural choice means cmux inherits Ghostty's complete VT parser and renderer, including support for the kitty keyboard protocol, graphics protocols, semantic prompts, and full Unicode with grapheme clustering. Where tmux has historically been a compatibility bottleneck (stripping or mishandling modern escape sequences), cmux passes them through with full fidelity.</p>
394-
<p>cmux aims to provide the session persistence and window management of tmux with the standards compliance of a modern terminal emulator. It scores identically to Ghostty on terminfo.dev because it uses the same underlying emulation library.</p>`,
395-
396-
cursor: `<p><strong>Cursor</strong> is an AI-focused code editor built on top of <strong>VS Code</strong>, with an integrated terminal powered by <strong>xterm.js</strong>. It adds AI pair programming features including chat, command generation, and code completion powered by large language models.</p>
397-
<p>Since Cursor's terminal is xterm.js (the same engine as VS Code), its terminal capabilities are identical — good basic support with truecolor, mouse tracking, and Unicode, but lacking some modern protocols like kitty keyboard and graphics protocols. The terminal is primarily a secondary interface; Cursor's focus is on the editor experience.</p>`,
398-
399-
"com.microsoft.VSCode": `<p><strong>Visual Studio Code</strong> is Microsoft's open-source code editor, the most widely used IDE in the world. Its integrated terminal is powered by <strong>xterm.js</strong>, the most widely deployed terminal emulator — used not just in VS Code but in countless web-based terminals, cloud IDEs, and development tools.</p>
400-
<p>VS Code pioneered <strong>shell integration</strong> via the OSC 633 protocol, which enables features like command decoration (success/failure markers), command navigation, and sticky scroll for terminal output. This protocol is now being adopted by other terminals.</p>
401-
<p>The xterm.js terminal provides solid basics — truecolor, Unicode, mouse tracking, bracketed paste, and link detection. It lacks some advanced features like kitty keyboard protocol and graphics protocols, but its ubiquity means it's the baseline that most CLI tools target for compatibility.</p>`,
402-
403-
"com.todesktop.230313mzl4w4u92": `<p><strong>Cursor</strong> is an AI-focused code editor built on <strong>VS Code</strong> with an <strong>xterm.js</strong> terminal. Terminal capabilities match VS Code — good basics, no advanced protocols.</p>`,
404-
}
405-
406-
const urls: Record<string, string> = {
407-
ghostty: "https://ghostty.org",
408-
kitty: "https://sw.kovidgoyal.net/kitty",
409-
iterm2: "https://iterm2.com",
410-
"terminal-app": "https://support.apple.com/guide/terminal/welcome/mac",
411-
warp: "https://www.warp.dev",
412-
cmux: "https://github.com/ghostty-org/ghostty",
413-
cursor: "https://cursor.com",
414-
"com.microsoft.VSCode": "https://code.visualstudio.com",
415-
"com.todesktop.230313mzl4w4u92": "https://cursor.com",
416-
}
417-
418-
// Look up terminal metadata from the @termless/core manifest
419-
// Map app terminal names to manifest backend names
420-
const appToManifest: Record<string, string> = {
421-
ghostty: "ghostty",
422-
kitty: "kitty",
423-
cmux: "ghostty", // cmux uses libghostty
424-
"com.microsoft.VSCode": "xtermjs",
425-
"com.todesktop.230313mzl4w4u92": "xtermjs",
426-
cursor: "xtermjs",
427-
}
428-
const manifestName = appToManifest[terminalName]
351+
const terminals = loadTerminals()
352+
const t = terminals[terminalName]
353+
354+
// Look up terminal metadata from @termless/core manifest
429355
let terminalMeta: TerminalMeta | undefined
356+
const manifestName = t?.manifestBackend
430357
if (manifestName) {
431358
try {
432359
const m = manifest()
433360
const entry = m.backends[manifestName]
434-
if (entry?.terminal) {
435-
terminalMeta = entry.terminal
436-
}
361+
if (entry?.terminal) terminalMeta = entry.terminal
437362
} catch {}
438363
}
439364

365+
if (!t) {
366+
// Unknown terminal — generate basic meta
367+
return {
368+
label: terminalName,
369+
slug: terminalName.toLowerCase().replace(/[^a-z0-9]+/g, "-"),
370+
description: `${terminalName} terminal emulator`,
371+
terminal: terminalMeta,
372+
}
373+
}
374+
440375
return {
441-
label: labels[terminalName] ?? terminalName,
442-
slug: slugs[terminalName] ?? terminalName.toLowerCase().replace(/[^a-z0-9]+/g, "-"),
443-
description: descriptions[terminalName] ?? `${labels[terminalName] ?? terminalName} terminal emulator`,
444-
body: bodies[terminalName],
445-
url: urls[terminalName],
376+
label: t.label ?? terminalName,
377+
slug: t.slug ?? terminalName.toLowerCase().replace(/[^a-z0-9]+/g, "-"),
378+
description: t.description ?? `${t.label ?? terminalName} terminal emulator`,
379+
body: t.body,
380+
url: t.url,
446381
terminal: terminalMeta,
447382
}
448383
}
@@ -526,6 +461,7 @@ function loadUnifiedCensus(path: string): CensusData {
526461
featureDescriptions: loadFeatureDescriptions(),
527462
baselines: {},
528463
baselineStats: {},
464+
categoryLabels: loadCategoryLabels(),
529465
generated: raw.generated ?? "",
530466
}
531467
}
@@ -635,6 +571,7 @@ function loadPerBackendResults(): CensusData {
635571
featureDescriptions: loadFeatureDescriptions(),
636572
baselines: {},
637573
baselineStats: {},
574+
categoryLabels: loadCategoryLabels(),
638575
generated,
639576
}
640577
}
@@ -652,6 +589,7 @@ function emptyData(): CensusData {
652589
featureDescriptions: loadFeatureDescriptions(),
653590
baselines: {},
654591
baselineStats: {},
592+
categoryLabels: {},
655593
generated: "",
656594
}
657595
}

0 commit comments

Comments
 (0)