AI-Native TypeScript (Discipline v0.2) — boot snippet
01TypeScript code in this
project follows the AI-Native TypeScript guide
(spec/typescript/GUIDE-AI-NATIVE-TYPESCRIPT.xml in this package).
02Read the guide when authoring or reviewing structure; per-edit work needs only the card whose trigger fires.
03Card registry for TypeScript: spec/cards/INDEX.xml in this package (trigger →
card; the nine executable scaffolds A–I in their TypeScript shape).
04This
stack ships its own spec/cards/ projection — the weak-reader runtime surface
for .ts edits is a TypeScript card's Band-3 ops block, never the Rust
one.
05(The core cards/ are the Rust pilot's reference set; a future
symmetry pass may unify both languages' Band-3 in the core — see the
guide's tooling note.)
06Standing rules at the surface level:
- 07Ordinary idiomatic TypeScript at the token level — no invented dialect,
no type-level wizardry in domain code (deep conditional/recursive types
are the OOD tail, treated like
unsafe). Strictness lives in the envelope: the maxedtsconfig, branded types at seams, runtime validators at the erasure boundary,spec://metadata, per-cell fast verification (tsc --noEmit -p <cell>+vitest run <cell>, < ~60s). - The compiler is a configurable verifier: the project
tsconfigis a versioned discipline artifact at the strictest practical floor (strict+noUncheckedIndexedAccess+exactOptionalPropertyTypes+erasableSyntaxOnly); loosening a mandatory flag needsdeviates+ reason. - Cells: one cell = one file-set with a single public entry (
index.tsas the seam); cells import seams + core only, never sibling cells' internals. No barrel-file ambient re-export sprawl; ambient coupling (module-level mutable singletons,declare global) is forbidden. - Types are erased and can be lied to. The
unsafeset —any/ uncheckedas/!/@ts-ignore— is forbidden in domain code; escape hatches areunknown+ a runtime validator,asonly after a check, anassertsfunction, and@ts-expect-error -- reason(never@ts-ignore). Each deviation carries a recorded reason. - Structural typing is recovered to nominal by branding: a meaning-bearing
primitive crossing a seam is a branded type, so the wrong same-shaped
value fails
tsc. - Failure on a seam is a typed value (
Result<T, E>/ discriminated union), never an untypedthrow; theEunion citesspec://REQs and its exhaustiveswitchis compiler-checked. - Untyped external data (network, JSON,
process.env, user input) enters asunknownand is narrowed only through a single-source schema (Zod/Valibot) that is both the static type and the runtime check. - Every public seam carries one type-checked example (Twoslash) of
canonical use, and public generic/branded/union surfaces carry a
type-level test (
expectTypeOf/tsd). Replacing a non-trivial cell requires a differential oracle (fast-check). - Uniformity is load-bearing: one idiom per operation; exceptions are marked, or they propagate as false training signal.
08The shipped toolchain (this stack materialises it; no dev tree needed):
- 09
typescript-ai-native—init(bootstrap policies + registries),floor(prettier→tsc→tests→eslint→conform→specmap→test-gate, one exit code),health(the sweep's fact collector),test-gate(xfail-strict over node's TAP) /tripwire/trace/fast-loop/codemod; - plus
the narrow
typescript-ai-native-conformandtypescript-ai-native-specmapengines, - and
the agentic type oracle
typescript-ai-native-tcg(also served over MCP bymcp:org.vibevm.ai-native/typescript-ai-native-mcp— PROP-027; persistent enrichingserverelay + one-shotvalidate/scope/complete/type/bench: check an edit against in-memory overlays BEFORE writing it, with the SAME conform rules as the gate — GUIDE §14, §15 move 5).
10The
structural gate parses through the PROJECT's own typescript install
(node ≥ 22.6; the same devDependency the tsc floor step needs).
11Run
vibe-natively (vibe bin exec typescript-ai-native -- <args> —
PROP-025 lockfile dispatch; vibe bin build pre-builds), from PATH
(cargo install --path
vibedeps/<stack-slot>/crates/typescript-ai-native-cli), or in place via
cargo run --manifest-path vibedeps/<stack-slot>/Cargo.toml -p
typescript-ai-native-cli --bin typescript-ai-native -- <args>.
12Procedures as agent skills: /typescript-ai-native-sweep (recurring),
/typescript-ai-native-terraform (brownfield adoption) — vibe skill install
projects them.