import { rawSafe } from './safehtml.ts' import { ALLOWED_HOSTS, viewerHref } from './url.ts' import { atIndex, captureGroup, recordGet, textAt } from '../absent.ts' import { unwrapOr } from '../option.ts' import { VIEWER_CAPS } from './limits.ts' import { classifyHref, renderMarkdown, type MarkdownOptions } from './markdown.ts' import type { CommitInfo, RepoHeader, TraceModel, TreeEntry } from './model.ts' import type { PackObjectView } from './packmap.ts' import type { FileLoaded, PackLoaded, TreeLoaded, ViewerDocument } from './document.ts' import { commitProse, formatBytes, percentClass, portions, shortOid } from './format.ts' import { LAYOUT } from './layout.ts' import { KUMO_BUTTON_FOCUS, KUMO_BUTTON_SECONDARY, KUMO_BUTTON_SIZE_SM, KUMO_INPUT, KUMO_SURFACE } from './kumo-classes.ts' import { repoIdentity } from './identity.ts' import { Badge, Banner, Button, Card, Diagnostics, Document, Footer, Icon, PathCrumbs, PlyStrip, RepoIdentity, RepoTitle, Signed, Time } from './ui.tsx' import { PUBLIC_NAMESPACE, type PublicRepoList } from '../public.ts' import type { ViewerHint } from './hint.ts' // One per forge: the same client speaks to each one's git server (checked 2026-11-06, all 200). const EXAMPLES = [ ['curl/curl', '/view/github.com/curl/curl'], ['gitlab.com/gitlab-org/cli', '/view/gitlab.com/gitlab-org/cli'], ['codeberg.org/dnkl/foot', '/view/codeberg.org/dnkl/foot'], ['ply itself', '/r/ply'], ] as const const PACK_SWATCH: Record = { header: 'bg-kumo-fill', commit: 'bg-kumo-info', tree: 'bg-kumo-success', blob: 'bg-neutral-500', tag: 'bg-kumo-badge-purple', ofs_delta: 'bg-kumo-warning', ref_delta: 'bg-kumo-danger', trailer: 'bg-kumo-fill', } function PublicRepos(props: { list: PublicRepoList }) { const names = props.list.names return ( Public repositories{PUBLIC_NAMESPACE}}> {names.length ? : props.list.unavailable ?

The repository list is unavailable right now.

:

No repositories are published in this namespace yet.

}

Served read-only from the {PUBLIC_NAMESPACE} Artifacts namespace. No token needed.

) } function Home(props: { error: string | null; publicRepos: PublicRepoList }) { const caps = VIEWER_CAPS return ( <>

ply · git over the wire, in a Worker

Read a public git repository

Every page here is rendered by ply, a zero-dependency TypeScript git client, speaking git's smart-HTTP protocol from a Cloudflare Worker: no clone, no git binary. Each page shows every round trip it made: the call, bytes, cache tier and time.

Paste a URL, github.com/owner/repo, or owner/repo.

{props.error ?
{props.error}
: null}
PasteA public https URL on an allowlisted host. A username or password in the URL is rejected and never forwarded.
BrowseBranches, trees, files and READMEs, rendered on the server.
InspectEvery page shows its git round trips as a waterfall; the pack map shows how the server deltified objects.
Supported hosts}>
    {ALLOWED_HOSTS.map(host =>
  • {host}
  • )}

https, no username or password, port 443. A trailing dot or a lookalike host is rejected.

Limits}>
Upstream
{formatBytes(caps.maxUpstreamBytes)} / page
Pack
{formatBytes(caps.maxPackBytes)} · {caps.maxPackObjects} objects
File
{formatBytes(caps.maxFileDisplayBytes)}
Calls
{caps.maxSubrequests} · {caps.requestTimeoutMs / LAYOUT.msPerSecond}s each
Page
{caps.pageTimeoutMs / LAYOUT.msPerSecond}s
Rate
{caps.ratePerMinute}/min · packs {caps.packRatePerMinute}/min
) } function initials(name: string): string { const parts = name.trim().split(/\s+/).filter(part => part.length > 0) const firstPart = atIndex(parts, 0) const first = firstPart.tag === 'some' ? unwrapOr(textAt(firstPart.value, 0), '?') : '?' const lastPart = atIndex(parts, parts.length - 1) const last = parts.length > 1 && lastPart.tag === 'some' ? unwrapOr(textAt(lastPart.value, 0), '') : '' return (first + last).toUpperCase() } function Avatar(props: { name: string }) { return } function TrailerValue(props: { value: string }) { const email = captureGroup(/^(.*?)\s*<[^>]+>$/.exec(props.value), 1) if (email.tag === 'some' && email.value) return {email.value} const href = /^https:\/\/\S+$/.test(props.value) ? classifyHref(props.value) : null return href ? {props.value} : {props.value} } function CommitMessage(props: { message: string }) { const prose = commitProse(props.message) if (!prose.paragraphs.length && !prose.trailers.length) return null return (
{prose.paragraphs.map(paragraph =>

{paragraph}

)} {prose.trailers.length ? (
{prose.trailers.map(trailer =>
{trailer.key}
)}
) : null}
) } /** The card header: who, when, which commit; the subject, and the full message one tap away. */ function CommitHead(props: { commit: CommitInfo; header: RepoHeader; now: number }) { const prose = commitProse(props.commit.message) const subject = prose.subject || '(no message)' const hasBody = prose.paragraphs.length > 0 || prose.trailers.length > 0 return (
{props.commit.authorName || 'unknown'}
{hasBody ? (
{subject}···
) :

{subject}

}
) } function EntryIcon(props: { entry: TreeEntry }) { if (props.entry.type === 'tree') return if (props.entry.mode === '160000') return if (props.entry.mode === '120000') return return } function EntryNote(props: { entry: TreeEntry }) { if (props.entry.mode === '160000') return submodule if (props.entry.mode === '120000') return symlink if (props.entry.mode === '100755') return exec return null } function parentPath(path: string): string { const at = path.lastIndexOf('/') return at === -1 ? '' : path.slice(0, at) } function TreePage(props: { loaded: TreeLoaded; trace: TraceModel; now: number }) { const { header } = props.loaded const id = repoIdentity(header.host, header.repoPath) const path = props.loaded.path const count = props.loaded.entries.length + props.loaded.entriesTruncated return ( } class="tree-card"> {props.loaded.entries.length === 0 && !path ?

This directory is empty.

: ( // Stable scraping contract (README "Machine-readable markup"): one li[data-oid] per entry shown. )} {props.loaded.entriesTruncated ?

Showing {props.loaded.entries.length} of {count} entries.

: null}
) } function markdownOptions(header: RepoHeader, docPath: string): MarkdownOptions { return { base: parentPath(docPath), resolve: (path, kind) => viewerHref(header.host, header.repoPath, { ref: header.ref, path, raw: kind === 'image' ? '1' : '' }), } } function Readme(props: { loaded: TreeLoaded }) { const readme = props.loaded.readme if (!readme) return null const header = props.loaded.header const docPath = props.loaded.path ? `${props.loaded.path}/${readme.name}` : readme.name const head = ( <> {readme.name} ) if ('tooBig' in readme) { return (
This README is binary or larger than {formatBytes(VIEWER_CAPS.maxFileDisplayBytes)}, so it is not rendered. Open the file to see the size.
) } return (
{rawSafe(renderMarkdown(readme.text, markdownOptions(header, docPath)))}
) } function subjectOf(message: string): string { return unwrapOr(atIndex(message.split('\n'), 0), '').slice(0, LAYOUT.logSubjectChars) || '(no message)' } function Log(props: { loaded: TreeLoaded; now: number }) { const log = props.loaded.log if (!log.length) return null const header = props.loaded.header return ( Recent commits{log.length}}>
    {log.map(commit => (
  1. {subjectOf(commit.message)} {shortOid(commit.oid)} {commit.authorName}
  2. ))}
{props.loaded.logStopped ?

Older history is not loaded on this page. Open the oldest commit above to keep going.

: null}
) } function isMarkdown(path: string): boolean { return /\.(md|markdown|mdown|mkd)$/i.test(path) } function FilePage(props: { loaded: FileLoaded; trace: TraceModel; now: number }) { const { header } = props.loaded const id = repoIdentity(header.host, header.repoPath) const rawHref = viewerHref(header.host, header.repoPath, { ref: header.ref, path: props.loaded.path, raw: '1' }) const pathParts = props.loaded.path.split('/') const name = unwrapOr(atIndex(pathParts, pathParts.length - 1), props.loaded.path) const text = props.loaded.note !== 'text' ? null : props.loaded.text === null ? '' : props.loaded.text const lineCount = text === null ? 0 : text.split('\n').length - (text.endsWith('\n') ? 1 : 0) const md = text !== null && isMarkdown(props.loaded.path) const head = ( <> {text !== null ? {lineCount} {lineCount === 1 ? 'line' : 'lines'} : null} {formatBytes(props.loaded.size)} {props.loaded.mode !== '100644' ? {props.loaded.mode === '100755' ? 'executable' : props.loaded.mode} : null} {md ? ( ) : null} Raw ) return ( {md ? : null} {md ?
{rawSafe(renderMarkdown(text === null ? '' : text, markdownOptions(header, props.loaded.path)))}
: null} {md ? : null}
) } function FileBody(props: { loaded: FileLoaded; rawHref: string }) { const loaded = props.loaded if (loaded.note === 'submodule') return
This is a submodule (gitlink) {loaded.blob}. The blob is not in this repository.
if (loaded.note === 'too-big') return
This file is {formatBytes(loaded.size)}, over the {formatBytes(VIEWER_CAPS.maxFileDisplayBytes)} display cap. It was not buffered. Open a smaller file, or fetch it with git.
if (loaded.note === 'binary') return
Binary file, {formatBytes(loaded.size)}. Not shown as text. Download raw bytes (not HTML).
const text = loaded.text === null ? '' : loaded.text const lines = text.split('\n') if (text.endsWith('\n')) lines.pop() const shown = lines.slice(0, VIEWER_CAPS.maxLineRows) return (
{lines.length > shown.length ?

Showing {shown.length} of {lines.length} lines.

: null}
{shown.map((line, index) => { const n = index + 1 return (
{n} {line}
) })}
) } function PackPage(props: { loaded: PackLoaded; trace: TraceModel; now: number }) { const map = props.loaded.map const header = props.loaded.header const selected = props.loaded.offset === null ? null : packObjectAt(map.objects, props.loaded.offset) const lengths = [map.headerLength, ...map.objects.map(obj => obj.length), map.trailerLength] const widths = portions(lengths) const choice = map.ofsDelta === 0 && map.refDelta === 0 ? 'The server sent full objects only — no ofs-delta and no ref-delta.' : `The server used ${map.ofsDelta} ofs-delta and ${map.refDelta} ref-delta object${map.refDelta === 1 ? '' : 's'}.` const legend = ['header', 'commit', 'tree', 'blob', 'tag', 'ofs_delta', 'ref_delta', 'trailer'] as const return (

Pack map

{map.count} {map.count === 1 ? 'object' : 'objects'} {formatBytes(map.bytes)} version {map.version} max chain {map.maxChain} {map.thin ? 'thin pack' : 'not thin'}

want {shortOid(props.loaded.want)} · asked {props.loaded.filterRequested} · honoured {props.loaded.filterHonoured} · client asked for ofs-delta and did not ask for a thin pack

{choice} Choose a segment to jump to its row.

{legend.map(name => {name.replace('_', ' ')})}
{selected ? :

Select a region to inspect that object.

}
{map.objects.map(obj => { const wire = obj.wireType.replaceAll('_', ' ') const resolved = obj.resolvedType && obj.resolvedType !== obj.wireType ? obj.resolvedType : '' const object = obj.oid ? shortOid(obj.oid) : obj.baseOid ? `base ${shortOid(obj.baseOid)}` : obj.baseOffset !== null ? `@${obj.baseOffset}` : '' return (
offset{obj.offset} {wire}{resolved ? ` · ${resolved}` : ''} {object} {formatBytes(obj.compressed)} compressed · {formatBytes(obj.inflated)} inflated · chain {obj.chain}
) })}
) } function swatch(name: string): string { return unwrapOr(recordGet(PACK_SWATCH, name), '') } function widthAt(widths: readonly number[], index: number): number { return unwrapOr(atIndex(widths, index), 0) } function packObjectAt(objects: readonly PackObjectView[], offset: number): PackObjectView | null { for (const obj of objects) if (obj.offset === offset) return obj return null } function PackSegment(props: { cls: string; width: number; offset: number | null; tip: string; on: boolean }) { if (!props.width) return null const klass = `${props.cls} ${percentClass('w', props.width)}${props.on ? ' on' : ''}` if (props.offset === null) return return } function ObjectDetail(props: { obj: PackObjectView }) { const obj = props.obj const preview = obj.preview return (

Object at {obj.offset}

wire {obj.wireType.replace('_', ' ')} · resolved {obj.resolvedType === null ? 'unresolved' : obj.resolvedType} · oid {obj.oid === null ? 'n/a' : obj.oid}

header {formatBytes(obj.headerBytes)} · compressed {formatBytes(obj.compressed)} · inflated {formatBytes(obj.inflated)} · chain {obj.chain}{obj.baseOffset !== null ? ` · base @${obj.baseOffset}` : ''}{obj.baseOid ? ` · base ${shortOid(obj.baseOid)}` : ''}

{preview !== null && preview.kind === 'commit' ?

{preview.summary} tree {shortOid(preview.tree)} · parents {preview.parents.map(shortOid).join(' ') || 'none'}

: null} {preview !== null && preview.kind === 'tree' ?

{preview.names.join(', ') || '(empty tree)'}

: null} {preview !== null && preview.kind === 'blob' ? (preview.text !== null ?
{preview.text}
:

Binary or large blob, {formatBytes(obj.inflated)} inflated.

) : null} {preview !== null && preview.kind === 'tag' ?
{preview.text}
: null} {preview !== null && preview.kind === 'unresolved' ?

The delta base is not in this pack.

: null}
) } function errorTitle(code: string, status: number): string { if (code === 'rate_limited' || status === 429) return 'Too many requests' if (code === 'not_found' || status === 404) return 'Not found' if (code === 'auth' || status === 401 || status === 403) return 'Repository not found, or private' if (code === 'limit_exceeded' || status === 413) return 'Too big for this viewer' if (code === 'timeout' || status === 504) return 'The git host timed out' if (code === 'unavailable' || status === 503) return 'Viewer unavailable' if (code === 'bad_request' || status === 400) return 'That URL is not supported' return 'Something went wrong' } function errorHint(code: string, status: number, message: string): string { if (code === 'rate_limited' || status === 429) return 'Wait for the retry window, then open the repository again. The limit is per client.' if (code === 'unavailable' || status === 503) return 'The rate limiter is not available, so the viewer stops rather than fetching without a limit.' if (code === 'limit_exceeded' || status === 413) return 'Open a smaller path or a single file. Huge repositories and packs are refused on purpose.' if (code === 'timeout' || status === 504) return 'The git host did not answer in time. Try the same URL again.' if (/credentials/.test(message)) return 'Remove the username and password from the URL and paste it again. Credentials are never forwarded.' if (/allowlisted|Supported hosts/.test(message)) return 'Use one of the supported hosts. owner/repo by itself means github.com.' return 'Go back to the viewer and paste a public repository URL.' } const PRIVATE_HINT = 'Private repositories are not visible here. GitHub answers 401 for a missing repository and a private one.' function RefHint(props: { host: string; repoPath: string; hint: ViewerHint }) { const links = props.hint.nearby const intro = 'That name is not a branch or tag. Open the ref picker on the repository root' if (!links.length) return <>{intro}. return ( <> {intro}, or try{' '} {links.map((item, index) => ( <> {index > 0 ? ', ' : null} {item.label} ))} . ) } function PathHint(props: { host: string; repoPath: string; ref: string | null; hint: ViewerHint }) { const cue = props.hint.path const missing = cue === null ? 'that entry' : cue.missing const existing = cue === null ? '' : cue.existingPath const where = existing.length > 0 ? existing : 'the repository root' const href = viewerHref(props.host, props.repoPath, { ref: props.ref === null ? '' : props.ref, path: existing }) if (cue !== null && cue.notDirectory) return <>{missing} is a file, not a directory. Open {where}. return <>No entry named {missing}. The deepest directory that exists is {where}. } function FailureBanner(props: Extract) { const tone = errorTone(props.code, props.status) // The banner is a flex row (Kumo's icon + text). One span keeps the sentence and its links on the same line. if (props.code === 'auth') return {PRIVATE_HINT} if (props.part === 'ref') return if (props.part === 'path') return if (notInNamespace(props)) return That name is not in this namespace. Open the repository index. if (props.part === 'repo') return This repository could not be opened. return {errorHint(props.code, props.status, props.message)} } /** A /r/ that the public namespace does not have. */ function notInNamespace(props: { part: string; message: string }): boolean { return props.part === 'repo' && /no repository |not a repository/.test(props.message) } /** * The way back up from an error. A missing repository has no root to go back to: a public-namespace name links to the * namespace index, any other missing repo gets only "Back to the viewer". */ function UpLink(props: Extract) { if (notInNamespace(props)) return <>Repository index · if (props.part === 'repo' || props.host.length === 0 || props.repoPath.length === 0) return null return <>Repository root · } function errorTone(code: string, status: number): 'alert' | 'info' { if (code === 'not_found' || status === 404 || code === 'auth' || status === 401 || status === 403) return 'info' return 'alert' } function supportedHosts(message: string): readonly string[] { const marker = 'Supported hosts:' const at = message.indexOf(marker) if (at < 0) return [] return message.slice(at + marker.length).replace(/\.$/, '').split(',').map(host => host.trim()).filter(host => host.length > 0) } function ErrorPage(props: Extract) { const title = errorTitle(props.code, props.status) const hosts = supportedHosts(props.message) const specific = props.part === 'repo' || props.part === 'ref' || props.part === 'path' const headline = specific ? props.summary : title const knownRepo = props.host.length > 0 && props.repoPath.length > 0 return ( {knownRepo ? (
) : null} {knownRepo && props.part !== 'ref' && props.ref ? : null}

HTTP {props.status} · {props.part}

{headline}

{hosts.length ?
    {hosts.map(host =>
  • {host}
  • )}
: null}

Back to the viewer

Why this was refused

{props.message}