Imported from stayhydated/gpui-form (
AGENTS.md). Install upstream withnpx skills add stayhydated/gpui-form. Copyright stays with the author.
AGENTS.md
This is the working guide for contributors and coding agents in the
gpui-form workspace.
Use it to decide:
- which crate or example owns a change,
- which docs, rustdocs, book pages, skills, examples, or generated outputs must change with it,
- which narrow validation command proves the edit.
For most application-facing form work, start in crates/gpui-form. Use
crates/gpui-form-prototyping-core for GPUI scaffolding from GpuiFormShape
inventory data. Check just --list before broad validation.
Use book/src/SUMMARY.md to route user-guide edits and web/src/lib.rs for
the public catalog.
Project Summary
gpui-form is a Rust form-generation ecosystem built on GPUI Kit, centered on
#[derive(GpuiForm)].
Its priorities are:
- type-safe generated form state, metadata, value holders, and helper APIs,
- concise derive attributes for normal application structs,
- inventory-driven prototyping, component shapes, MCP submit integration, and layered crates that can be used directly when needed.
Quick Decision Flow
Before editing:
- Find the owning surface in the workspace map.
- Treat README files,
book/src,examples/README.md, and in-repositoryskills/*guidance as user-facing. - Treat
//!and///rustdocs, source-adjacent comments, tests, snapshots, and examples as the internal behavior record. - Update every public surface that describes a changed derive attribute, component contract, feature flag, runtime import, prototyping workflow, MCP workflow, or supported example.
- Run the smallest command that proves the edited behavior or docs surface.
Route public documentation to the README, example, skill, and rustdoc surfaces named below. Keep implementation rationale next to the relevant module as rustdocs/source comments, in focused tests or snapshots, or in this guide when it affects agent routing.
Documentation Sync
When public usage changes, update the applicable set:
- root
README.md book/srcfor task-oriented guides and the published chapter structurecrates/gpui-form/README.md- affected crate
README.mdfiles examples/README.mdand showcased example cratesskills/use-gpui-formandskills/use-gpui-form-component-shapes- rustdocs on public traits, structs, macros, and helper functions
web/src/lib.rswhen the catalog description or published destinations change
Keep these specific surfaces aligned:
- root
README.mdandcrates/gpui-form/README.mdfor installation, quick-start, feature flags, runtime imports, MCP, prototyping, and examples - root
README.md, affected crate READMEs, and matchingbook/srcchapters for public workflows covered by the guide - root
README.md,crates/gpui-form-derive/README.md, andskills/use-gpui-form/references/api-map.mdfor supported component syntax and derive attributes - root
README.md,crates/gpui-form-prototyping-core/README.md,examples/README.md, andexamples/prototypingfor inventory/codegen workflows examples/README.mdas the canonical index for runnable workspace examples- package-local
i18n.toml,i18n/Fluent resources,src/i18n.rs, and matching README/example text for localization changes inexamples/some-lib,crates/gpui-form-component, orcrates/gpui-form-component-story
The checked-in sources are book/src, web/src, and
examples/some-lib-forms. Build web/public/book, web/public/llms*,
web/public/gpui-demo, and web/dist through cargo xtask; do not maintain
those generated publication artifacts by hand.
Workspace Map
Main User-Facing Entry Point
crates/gpui-formAudience: user-facing. Role: facade, default entry point, and home of public feature flags. It re-exportsGpuiForm,core,runtime,schema, andbon;mcpandmcp_submitare available behind the experimentalmcpfeature.
Public Integration Crates
-
crates/gpui-form-coreRole: non-GPUI helpers such as numeric validation and component suffix validation. -
crates/gpui-form-collectionRole: curated component shapes and value bindings for common GPUI Kit widgets. -
crates/gpui-form-collection-deriveRole: proc macros such asSelectItemthat pair withgpui-form-collection. -
crates/gpui-form-runtimeRole: GPUI-facing runtime contracts used by generated form code, including component-shape storage and value-binding helpers. -
crates/gpui-form-componentRole: runtime implementations for infinite select, date/date-range picker, and file picker, plus optional built-in component-shape impls. -
crates/gpui-form-component-deriveRole:InfiniteSelectderive macro for the runtime surface ingpui-form-component. -
crates/gpui-form-schemaRole: schema metadata, component behavior metadata, and inventory registry types used by derives, MCP, and prototyping. -
crates/gpui-form-deriveRole: proc macro for#[derive(GpuiForm)]and#[gpui_form::mcp_submit]. Most users should depend ongpui-formrather than this crate directly. -
crates/gpui-form-mcpRole: experimental MCP submit/edit integration for generated form value holders, including schema generation, typed handler registration, inventory registration, and stdio serving. -
crates/gpui-form-prototyping-coreRole: code-generation helpers that consumeGpuiFormShapeinventory data and generate scaffolded GPUI form code.
Internal Crates
-
crates/gpui-form-codegenRole: parse-time component parsing, crate-path resolution, metadata token lowering, and component field IR used by derive crates. -
crates/gpui-form-component-storyRole: Storybook-style GPUI app and story-only localization assets for reusable runtime components.
Examples
-
examples/some-libShared example domain types and structs that deriveGpuiForm, plus package-locales-fluentconfig and Fluent assets. -
examples/some-lib-formsShared native and WebAssembly Storybook gallery for generated forms. Thedemoexample target used by the public site also launches natively and runs the same registrations and gallery startup as the native binary. Run withcargo run -p some-lib-forms. -
examples/prototypingGenerator that readsGpuiFormShapeinventory data and emits form scaffolding intoexamples/some-lib-forms/src/formsandexamples/prototyping/output. Run withcargo run -p prototyping. -
examples/mcp-submitStdio MCP server that exposes generated form value holders as MCP tools. Run withcargo run -p mcp-submit. -
crates/gpui-form-component-storyStorybook-style GPUI app for reusable runtime components. Run withcargo run -p gpui-form-component-story.
Documentation, Demo, and Publishing
-
book/srcAudience: user-facing. Role: mdBook source for installation, field intent, validation, component shapes, MCP, and prototyping workflows. -
examples/some-lib-forms/examples/demo.rsAudience: user-facing. Role: native and nightly Trunk entry point for the fullsome-lib-formsStorybook gallery. -
webAudience: user-facing. Role: Dioxus catalog that links the book, GPUI demo, API docs, and source. -
xtaskAudience: internal. Role: reproducible book,llms.txt, GPUI demo, and Pages-site builds.
Editing Rules
When editing Rust crates:
- Use
cargofor focused build, test, and run tasks. Usejustfilerecipes for workspace-wide format, clippy, check, test, coverage, and dry-run publish tasks. - Treat
crates/gpui-formas the public facade boundary unless intentionally changing lower-level crate APIs.
When adding or changing a component shape:
- Keep
gpui-form-codegenparsing and metadata emission,gpui-form-schemametadata, andgpui-form-prototyping-corefield generation aligned. - Update supported-component docs in the root README,
crates/gpui-form/README.md,crates/gpui-form-derive/README.md, affected crate READMEs, and public skills. - Keep facade imports and lower-level runtime/type surfaces aligned when generated code paths change.
When editing prototyping or generated outputs:
- Prefer changing the generator or inventory metadata over hand-editing generated output.
- Keep
examples/prototyping,examples/prototyping/output, andexamples/some-lib-forms/src/formsaligned. - Keep
crates/gpui-form-prototyping-core/src/implementations/snapshotsaligned when generator token output changes.
When writing tests:
- Prefer focused crate-level tests near the changed subsystem.
- For macro or token-generation changes, test emitted behavior at the derive and codegen boundary rather than only the lowest-level helper.
Validation
Run the narrowest command that proves the edit. CI also runs fmt, clippy, workspace tests, docs, package-content listing, cargo-machete, and an es-fluent FTL check.
cargo check -p gpui-formfor facade compile checks, or the same-pform for the package that owns a focused editcargo test -p gpui-formfor facade behavior changes, or the same-pform for the package that owns a focused editcargo test -p gpui-form-derive --test uifor derive UI diagnosticscargo test -p gpui-form-prototyping-corefor prototyping generator or snapshot changescargo run -p prototypingafter generator/inventory output changescargo xtask build bookandcargo xtask build llms-txtfor book changescargo xtask build gpui-demofor the nightly Wasm GPUI examplecargo xtask build webafter the book, language-model docs, and demo assets exist, orjust web-buildfor the complete publication pipelinecargo doc --workspace --all-features --no-deps --lockedwhen matching the CI docs jobcargo package --workspace --listwhen matching the CI package jobjust covfor LLVM source coverage across publishable library crates; the recipe also exercises the headless example and MCP integration packages, while excluding GUI applications, prototyping, and publication toolingjust fmt,just clippy,just check,just test,just cov, or the matchingjustfilerecipe when a change spans each recipe's scope
CI generates a Cobertura report with cargo-llvm-cov and publishes it to
Codecov using the same crate scope as just cov.
If validation cannot be run, state why and what remains unvalidated. Do not claim a change works or was validated unless a proving command was run; for generated output, also state whether it was regenerated from source metadata.