Imported from raphaelsalaja/calligraph (
AGENTS.md). Install upstream withnpx skills add raphaelsalaja/calligraph. Copyright stays with the author.
Calligraph — Agent Guidelines
Rules for AI agents working on this package.
Architecture
Single-file package. One export: Calligraph. Keep it that way unless there's a strong reason to split.
src/
index.tsx # everything lives here
Key internals
computeLCS— standard LCS dynamic programming over two strings, returns[oldIndex, newIndex][]pairsCalligraph— the component. UsesuseState+ render-phase diffing (notuseEffect) to reconcile character keys whenchildrenchanges- Character identity is tracked via string keys (
c0,c1, ...) managed bynextIdRef - Entering characters get a drift offset based on position (left-side drifts left, right-side drifts right) via the
driftprop
Constraints
- Client component — the
"use client"directive is required. This component usesuseStateanduseRef. - Peer dependencies —
motion,react,react-dom. Do not add these todependencies. - Single export — consumers import
{ Calligraph }from"calligraph". Don't add default exports. - No internal state leaks —
computeLCS, key refs, and prev-text tracking are implementation details. Don't export them.
Build
- Uses
buncheefor bundling - Output:
dist/index.js+dist/index.d.ts - ESM only (
"type": "module")
Style
- Follow existing Biome config (spaces, double quotes, recommended rules)
- No comments explaining obvious code
- Keep JSDoc on the public export for IDE tooltips