Guidance for coding agents working in this repository.
Before making any change, read in this order:
formspec.cmlβ the formal bounded-context model. Authoritative.BOUNDED_CONTEXTS.mdβ prose reader companion to the CML.GLOSSARY.mdβ project vocabulary; pin the right term before writing code or commits.docs/000-principles.mdβ the architectural invariants the system upholds.
When in doubt about which package owns a concept, search GLOSSARY.md and formspec.cml. When in doubt about a cross-package change, the relationships in formspec.cml are the contract.
FormSpec is a TypeScript monorepo for defining type-safe forms that compile to JSON Schema 2020-12 and JSON Forms UI Schema.
Primary packages:
formspecβ umbrella package re-exporting common runtime-facing APIs@formspec/coreβ shared form types, canonical IR types, extension APIs@formspec/dslβ chain DSL authoring surface@formspec/buildβ schema generation and static TypeScript analysis@formspec/runtimeβ resolver helpers for dynamic enum/schema sources@formspec/analysisβ shared semantic-analysis protocol types and helpers@formspec/configβformspec.config.tsloading and DSL capability validation@formspec/eslint-pluginβ lint rules for tags and DSL usage@formspec/ts-pluginβ TypeScript language-service plugin and semantic service@formspec/language-serverβ reference LSP implementation over shared helpers@formspec/cliβ CLI for schema and IR generation@formspec/validatorβ runtime JSON Schema validation@formspec/e2eβ end-to-end and benchmark workspace (/e2e)
pnpm install
pnpm run build
pnpm run test
pnpm run test:e2e
pnpm run typecheck
pnpm run lint
pnpm run lint:fix
pnpm run format:check
pnpm run format
pnpm run api-extractor
pnpm run api-extractor:local
pnpm run api-documenterPackage-scoped examples:
pnpm --filter @formspec/build run test
pnpm --filter @formspec/dsl run test:types
pnpm --filter @formspec/eslint-plugin run fix:eslint-docs
pnpm --filter @formspec/eslint-plugin run check:eslint-docs- Use
pnpm. - The workspace
engines.nodeis>=24. - Prefer
rgfor file and text search. - API surface changes usually require updated
api-report/files. - This repo uses Changesets. User-facing package changes may need a
.changeset/*.mdentry. - Do not assume generated docs are authoritative if source exports disagree. Check the source first.
group()is layout-only and does not change the data shape.field.object()andfield.array()create nested schema structure.when(is(...), ...)controls UI visibility; conditional fields are still present in schema inference as optional fields.- Static analysis uses TSDoc-style comments on classes, interfaces, and type aliases.
- Use lowercase tag examples such as
@minimum,@maximum, and@displayName. @descriptionis intentionally unsupported. Summary text becomes JSON Schemadescription;@remarksis separate metadata.@formspec/buildpublic entry points are:@formspec/build@formspec/build/browser@formspec/build/internals
@formspec/buildexports includegenerateSchemas,generateSchemasFromClass,generateSchemasFromProgram, andbuildMixedAuthoringSchemas.@formspec/language-serveris built on top of plugin-backed diagnostics from@formspec/ts-plugin.
- Vitest is the main test runner.
tsdis used for type-level tests in packages that exposetest:types.@formspec/buildtest script builds the package before running tests.e2e/contains integration fixtures for chain DSL, TSDoc analysis, CLI flows, and benchmark coverage.