A unified command-line tool for managing AT Protocol lexicons across TypeScript and Rust codegen in the Teal monorepo.
- Unified Generation: Generate both TypeScript and Rust types from lexicons with a single command
- Auto-installation: Automatically installs required dependencies (jacquard-lexicon) when needed
- File Watching: Watch lexicon files for changes and auto-regenerate types
- Cross-language Validation: Validate consistency between TypeScript and Rust generated types
- Diff Analysis: Show impact of lexicon changes on generated code
The tool is automatically available in the workspace. Install dependencies:
pnpm installGenerate both TypeScript and Rust types from lexicons:
# Generate all types
pnpm lex:gen
# Generate only TypeScript types
lex gen --ts-only
# Generate only Rust types
lex gen --rust-only
# Force regeneration even if no changes detected
lex gen --forceAutomatically regenerate types when lexicon files change:
# Watch all lexicon files
pnpm lex:watch
# Watch only for TypeScript generation
lex watch --ts-only
# Watch only for Rust generation
lex watch --rust-onlyValidate that generated types are consistent and up-to-date:
pnpm lex:validateDisplay lexicon and generated type changes:
# Show changes since last commit
pnpm lex:diff
# Show changes since specific commit
lex diff HEAD~3- Uses
@atproto/lex-clito generate TypeScript types - Sources lexicons from
packages/lexicons/real/ - Outputs to
packages/lexicons/src/types/
- Uses
jacquard-codegenfor Rust code generation - Sources lexicons from
services/types/lexicons/ - Outputs to
services/types/src/ - Auto-installs jacquard-lexicon if not present (tries cargo-binstall first for speed)
- Monitors both lexicon source directories
- Debounces changes to avoid multiple regenerations
- Shows clear feedback about what changed
The tool integrates with the existing Turbo build pipeline:
lex:gen-server- Legacy TypeScript-only generation (kept for compatibility)lex:gen- New unified generation commandlex:watch- File watching for developmentlex:validate- Type validation
- Actor: Profile management, status tracking, search
- Feed: Music play tracking, artist/track data
- Stats: Top artists, releases, user statistics
- Bluesky (
app.bsky.*): Full AT Protocol compatibility - Statusphere (
xyz.statusphere.*): Status sharing - AT Protocol Core (
com.atproto.*): Authentication, repositories, admin
- Making Lexicon Changes: Edit files in
packages/lexicons/real/orservices/types/lexicons/ - Regenerate Types: Run
pnpm lex:genor usepnpm lex:watchduring development - Validate Changes: Run
pnpm lex:validateto check consistency - Review Impact: Use
pnpm lex:diffto see what changed
If automatic installation fails:
cargo install jacquard-lexiconFor faster installation, consider using cargo-binstall:
cargo install cargo-binstall
cargo binstall jacquard-lexicon- Ensure lexicon JSON files are valid
- Check that both TypeScript and Rust lexicon directories exist
- Verify file permissions for output directories
- File watching uses
chokidarfor cross-platform compatibility - If changes aren't detected, try restarting the watcher
- Large numbers of files may cause performance issues
The tool automatically detects the workspace structure using:
pnpm-workspace.yamlfor workspace root detection- Package structure for TypeScript and Rust paths
- Git for diff operations
No additional configuration is required.