Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aae097e
feat!: code generation for Go, Rust, TypeScript
rvagg Jul 17, 2024
c20418d
fix: don't make annotations require a double-#
rvagg Jul 17, 2024
bb156f9
chore: add parser types
rvagg Aug 14, 2024
f21fde1
feat: tsdefs improvements & cli, expose & build schema-schema, fix ty…
rvagg Aug 31, 2024
9ab87bd
fix: allow KindInt to be bigint
rvagg Nov 20, 2024
2dd0e1c
chore: update deps
rvagg Jul 5, 2025
081ec73
feat(gen): enums
rvagg Jul 5, 2025
27e58e4
feat(gen): lists
rvagg Jul 5, 2025
f4cae0a
feat(gen): maps
rvagg Jul 5, 2025
272de77
feat(gen): keyed unions
rvagg Jul 5, 2025
eb43d35
fix(gen): kinded unions
rvagg Jul 5, 2025
c70c0a7
feat(gen): optionals
rvagg Jul 5, 2025
035a804
fix: windows crlf
rvagg Jul 5, 2025
055c139
feat(gen): implicits
rvagg Jul 7, 2025
955d882
fix(gen): properly handle nullables
rvagg Jul 7, 2025
e33e40f
feat(gen): renames
rvagg Jul 7, 2025
564ab12
feat(gen): copy types
rvagg Jul 7, 2025
b3db46d
feat(typed): custom transformers for typed converters/validators
rvagg Jul 8, 2025
86c657f
fix(gen): improve test coverage, improve using more Filecoin miner types
rvagg Jul 10, 2025
2233b38
fix(gen): minor parser & type improvements & fixes
rvagg Jul 11, 2025
d46b2e8
feat(typed): support copy types in typed validators/converters
rvagg Jul 11, 2025
b9eb9dc
chore(doc): README refresh
rvagg Jul 11, 2025
bfdd60d
feat!: breaking changes in TypeScript types and parser behavior
rvagg Jul 11, 2025
e59b231
chore(doc): add LLM context docs
rvagg Jul 11, 2025
8aa2597
chore(test): extend polendina timeout for slower systems
rvagg Jul 11, 2025
d798ab3
chore(deps): bump actions/setup-node from 4.3.0 to 4.4.0
dependabot[bot] Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4.2.2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4.3.0
uses: actions/setup-node@v4.4.0
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies
Expand All @@ -33,7 +33,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4.3.0
uses: actions/setup-node@v4.4.0
with:
node-version: lts/*
- name: Install dependencies
Expand Down
97 changes: 97 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# @ipld/schema AI Assistant Guide

## Overview
JavaScript implementation of IPLD Schema parser, validator, and code generator. IPLD Schemas define types for content-addressed data (like TypeScript for immutable data structures).

## Core Functionality
1. **Parse** `.ipldsch` DSL → JavaScript AST (DMT)
2. **Validate** data against schemas at runtime
3. **Generate** Go/Rust/TypeScript code from schemas
4. **Transform** between storage and application formats

## Project Structure
```
lib/
├── from-dsl.js # Parse DSL → AST
├── to-dsl.js # AST → DSL
├── typed.js # Runtime validators/transformers
├── parser.cjs # PEG.js generated parser
└── gen/ # Code generators
├── go.js
├── rust.js
└── typescript.js

bin/ # CLI commands
├── validate.js # Validate schemas
├── to-json.js # Schema → JSON
├── to-js.js # Generate JS validators
└── to-tsdefs.js # Generate TS types

test/
├── fixtures/ # Test schemas and expected outputs
└── test-*.js # Test files (mocha)
```

## Key Files
- `ipld-schema.pegjs` - PEG grammar (regenerate: `npm run peg`)
- `schema-schema.ts` - TypeScript types for schema AST
- `CHANGELOG.md` - Semantic release changelog

## Development
```bash
npm run lint:fix # Fix code style
npm run peg # Rebuild parser after grammar changes
npm run build # Build TypeScript declarations
npm test # Run full test suite
```

## Schema Language
```ipldsch
# Basic types: Bool, String, Int, Float, Bytes, Link, Any

type Person struct {
name String
age Int optional # Optional field
nickname String (implicit "") # Default value
userId String (rename "user_id") # JSON field rename
}

type Status enum {
| Active
| Inactive
} representation string

type UserID = String # Type alias (copy type)

# Annotations for code generation
# @gotype(big.Int)
# @rusttype(BigInt)
type Balance Int
```

## Important Patterns
1. **Type representations** - Separate logical structure from storage format (e.g., struct as tuple)
2. **Annotations** - Comments starting with `@` control code generation
3. **Copy types** - Type aliases using `=` syntax
4. **Custom transforms** - Handle wire format differences in `typed.js`

## Testing
- Add fixtures to `test/fixtures/` for parser tests
- Code generation tests use testmark format in `test/fixtures/gen/*.md`
- Run specific tests: `npm run test:node -- test/test-typed.js`

## Common Tasks
1. **Add schema feature**: Update grammar → `npm run peg` → add tests
2. **Fix code generation**: Edit `lib/gen/*.js` → add test fixtures
3. **Update types**: Edit `schema-schema.ts` → `npm run build`

## Git Workflow
- Conventional commits for semantic release (`feat:`, `fix:`, `chore:`)
- Breaking changes: use `feat!:` or `BREAKING CHANGE:` in commit body
- DO NOT perform git commits or modifications, leave that to the user, commit messages may be suggested

## Notes
- ES modules only (except parser.cjs)
- Functional style, avoid classes
- Parser errors handled in `transformError()`
- Schema validation happens during parsing, not in typed.js
1 change: 1 addition & 0 deletions CLAUDE.md
Loading
Loading