@glyphlang/glyph

中文文档
0.1.134发布于 2026/11/12MIT OR Apache-2.0零依赖构建来源已验证近 30 天下载 3095

TypeScript your AI agents can't quietly break: a statically typed language that transpiles to TypeScript, with no any, exhaustive matching, and runtime-checked types.

原始使用文档
文档目录10 节
  1. Try it without installing anything
  2. The problem it solves
  3. See it
  4. What's different
  5. The commands
  6. Built for agents
  7. Where to go next
  8. Status
  9. Verifying your download
  10. License

Glyph

TypeScript your AI agents can't quietly break.

npm downloads CI install size license Socket Badge OpenSSF Scorecard

Glyph is a statically typed language that transpiles to TypeScript, built so AI agents can read, write, and modify code safely. It looks almost like TypeScript, so you read it on day one with no tutorial. Where it differs, each difference closes a hole an agent falls through and tsc --strict waves past.

Try it without installing anything

npx @glyphlang/glyph init my-app
cd my-app
npm install
npx glyph run
# hello from glyph

That scaffolds six files, pins the compiler in devDependencies, and runs the program. Anyone who clones the project builds it with npm install and nothing global. Two of the six are for coding agents rather than for you: an AGENTS.md pointing at the offline language reference, and an .mcp.json registering the analysis server below.

Prefer it on your PATH:

npm install -g @glyphlang/glyph
glyph init my-app && cd my-app && glyph run

Website: glyphlang.io  ·  Try it in the browser: playground  ·  Pointing an agent at it? glyphlang.io/llms.txt


The problem it solves

An AI agent will happily write TypeScript that compiles clean and breaks at runtime. It reaches for any at a boundary, casts an unknown, forgets a switch case, drops a Promise on the floor, and tsc --strict stays green the whole time. On a large codebase it cannot even reliably find where something is defined, because overloads, decorators, namespace merging, and barrel re-exports scatter one symbol across many places.

Glyph removes those hazards at the language level. The bugs an agent ships do not compile here.

See it

Glyph reads like TypeScript, but there is no any, match must cover every case, and a type you declare is actually checked at runtime:

type User = {
  id: number,
  name: string,
}

// A boundary value is `unknown` until you prove its shape.
// `User.parse` exists because every type carries a runtime descriptor.
fn handle(body: unknown) -> string {
  return match User.parse(body) {
    Ok(user) => string.upper(user.name),
    Err(_) => "invalid",
  }
}

That compiles to clean, readable TypeScript you can commit, run anywhere TS runs, and mix with any npm package.

What's different

  • No any, no erasure. What the types say is true when the code runs. Every record type generates a runtime validator (User.parse(x)), so untrusted input is typed only after it has been checked, and a failure names the field and its path.
  • Exhaustive by default. match over a union, or over number/string, must handle every case or it does not compile. Add a variant and every unhandled site lights up.
  • Errors are values. Result and the ? operator instead of thrown exceptions. Drop a Result and you get a warning, because a discarded error is a swallowed failure.
  • Greppable. One name, one declaration form. grep "fn parseUser" finds the definition every time. No overloads, decorators, or barrel files.
  • Stable diffs. One canonical format, one element per line, trailing commas, no reflow. A one-line change is a one-line diff, so agent edits stay reviewable.
  • Generate, don't hand-write. glyph gen openapi spec.yaml --client emits a typed HTTP client and server stubs. glyph gen zod and gen dts turn existing schemas into checked Glyph types.
  • Talks to real databases. Import any npm client by name. Class-based clients (new Pool, new MongoClient) construct with new, and SQLite is built in via std/sqlite. A row comes back untrusted, so you Row.parse it into a typed record and the schema-versus-code mismatch a cast would hide is caught at the boundary. See the databases guide.

The commands

glyph init my-app          # scaffold a project
glyph run                  # build + type-check + execute
glyph build --check        # emit TypeScript, verified with tsc --strict
glyph fmt                  # one canonical layout
glyph --explain E0200      # long-form help for any diagnostic

Glyph ships as a single prebuilt binary per platform (macOS, Linux, and Windows, on Intel and ARM). No postinstall download and no toolchain to set up. Running or type-checking uses your local tsx/tsc.

Built for agents

Point your coding agent at glyphlang.io/llms.txt, a single file that takes it from zero to correct, runnable Glyph: the canonical program shape, the full stdlib surface, the common gotchas, and the complete diagnostic catalogue with one-line fixes. Agents writing Glyph get compile-time feedback precise enough to self-correct.

Model Context Protocol. glyph init writes an .mcp.json that registers this automatically, and glyph agents adds it to a project you already have. glyph mcp runs a server over stdio that answers five queries: type-check a file for coded diagnostics, the inferred type at a cursor, where a name is defined (following imports), every reference to a symbol across the project, and symbol search. It runs the same analysis the editor uses, so the agent's answers match the compiler. Point any MCP client at glyph mcp <project>; details at glyphlang.io/mcp.

Editors. glyph lsp is a full language server (diagnostics, hover, go-to-definition, completion, symbols, workspace-wide find-references and rename, formatting) that any LSP client can drive over stdio.

Where to go next

Your first program in 10 minutesStart Here
The whole language in five minutesthe tour
Try it without installingplayground
Straight answers to engineer questionsglyphlang.io/answers
The four pillars, in depthglyphlang.io/pillars/verifiability
Source, issues, roadmapgithub.com/chadetov/glyph

Status

Glyph is an early preview and moves fast. The compiler toolchain (build, run, fmt, gen, regen, --explain) works end to end, and every release is type-checked against tsc --strict. It is not ready for production yet. It is ready for you to try and to tell us where it breaks. Every version's changes are at glyphlang.io/versions.

Stability while pre-1.0: the language can still change between 0.1.x releases. Two lines hold. Your code stays runnable, because it always compiles to plain TypeScript you own, which is a permanent escape hatch. And when syntax does change we aim to make glyph fmt migrate it for you. Full policy: docs/stability.md.

Verifying your download

Releases are built in GitHub Actions and published with provenance, so you can confirm an artifact came from this repo's workflow rather than a tampered copy:

# npm packages: published with npm provenance (OIDC-signed)
npm audit signatures

# GitHub Release archives: SLSA build-provenance attestation
gh attestation verify glyph-<version>-<platform>.tar.gz --repo chadetov/glyph

# ...or against the provenance bundle attached to the release, with no network
gh attestation verify glyph-<version>-<platform>.tar.gz \
  --bundle v<version>.intoto.jsonl --repo chadetov/glyph

# ...and a SHA-256 for each archive
sha256sum -c SHA256SUMS

License

Dual-licensed under Apache-2.0 or MIT, at your option.

版本与发布记录

@glyphlang/glyph 共发布 133 个版本,首次发布于 2026/06/15;过去 12 个月发布了 133 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.134latest2026/11/124 天前
0.1.1332026/11/115 天前
0.1.1322026/11/106 天前
0.1.1312026/11/0610 天前
0.1.1302026/11/0610 天前
0.1.1292026/11/0214 天前

关于 @glyphlang/glyph 的常见问题

@glyphlang/glyph 是什么?

TypeScript your AI agents can't quietly break: a statically typed language that transpiles to TypeScript, with no any, exhaustive matching, and runtime-checked types.

如何安装 @glyphlang/glyph?

在项目目录运行 npm install @glyphlang/glyph,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 glyph,可以用 npx glyph 直接运行。

@glyphlang/glyph 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/glyphlang__glyph 是否存在。

@glyphlang/glyph 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@glyphlang/glyph 可以商用吗?

@glyphlang/glyph 使用 MIT OR Apache-2.0 许可。可在 MIT、Apache-2.0 中任选其一遵守。选择 MIT 时,宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@glyphlang/glyph 的下载量有多少?

根据 npm 官方下载统计,@glyphlang/glyph 在 2026/10/17 – 2026/11/15 这 30 天内被下载 3,095 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@glyphlang/glyph 还在维护吗?

最新版本 0.1.134 发布于 2026/11/12(4 天前);至今共发布 133 个版本,其中过去 12 个月发布了 133 个;首次发布于 2026/06/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。