Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 3.64 KB

AGENTS.md

File metadata and controls

75 lines (51 loc) · 3.64 KB

Agent Guide — webtyp/user

Constraints for agents working on user UI modules. Read this before any change.


Construction Harness — typed & explicit (the WebTyp approach)

This library is part of WebTyp's construction harness: the typed, explicit API is what keeps an agent that doesn't know the library from building wrong code. The compiler must reject mistakes; what it can't catch becomes a devMode warning — never a silent failure.

  • Typed over any — no generic slots; typed builder methods (like webtyp/json), reusing fmt types. Anything reactive goes only through a signal binding (BindText/Bind*), which requires a signal.
  • Explicit names — Text (static) vs BindText (reactive); reading the call states intent.
  • Illegal states unrepresentable — dynamic content has ONE path, typed to require a signal.
  • Minimal public surface — export only what the author types; engine plumbing stays unexported.
  • Docs are minimal "how" instructions, not long skills — if a rule must be remembered, close it with types, not prose.

(Ecosystem rationale: skill api-design — the construction harness, in webtyp/devskills/skills/api-design/SKILL.md.)


Component Contract — ONE way (signals)

Modules and views implement only Render() *dom.Element (+ optional Init(ctx dom.Ctx)). There is NO OnMount/OnUpdate/OnUnmount and NO manual Update() (unexported in dom).

  • Do not delegate form.OnMount() — webtyp/form self-manages via signal bindings. A module that embeds a form just includes it in its render tree (expose sub-components via Children() []dom.Component so their Init runs).
  • Dynamic lists (e.g. lan.go IP rows) are a dom.SignalNodes bound with container.BindChildren(s); add/remove rebuilds []*dom.Element (each .Key(id)) and only the changed row patches.

State the UI shows lives in typed signals; changing one patches only the bound node — never re-render a whole element, never a Virtual DOM.

No Generics

Zero generic functions (follow webtyp/fmt codec rule "cero any, cero map"). Use concrete typed signals: SignalString/SignalBool/SignalNodes, DeriveString/DeriveBool, Bind*, Show. Never Signal[T].

Minimal Public Surface

Export only what other packages consume (module entry types). Unexport view helpers, field models, and anything only this package uses. Struct fields stay unexported.

WASM / TinyGo

  • UI lifecycle/reactive code in //go:build wasm files; !wasm stubs where called from tag-less code.
  • No Go stdlib: use webtyp.com/fmt. DOM only via webtyp.com/dom, never syscall/js. switch not map. No defer/recover. Embed dom.Element by value.

Testing

go install webtyp.com/devflow/cmd/gotest@latest
gotest
  • gotest, never go test. Stdlib assertions only. Dual WASM/stdlib; real DOM in WASM tests.
  • Cover frequent use cases: login/register/profile forms work after construction with no lifecycle hook; lan add/remove patches single IP rows (others keep identity). Publish with gopush 'message'.

Security Policy

This library provides the mechanism (hashing, sessions, routes, permission checking). The policy—what roles exist, who receives what, if there's a wildcard—is declared by the consumer via Bootstrap(Seed). No role or resource constants live here.

Documentation First

Update docs before code and before gopush: docs/ARCHITECTURE.md (remove OnMount delegation from the module-lifecycle description), update docs/diagrams/ (flowchart TD, no subgraph, <br/> for breaks), and re-index README.md so every docs/ file is linked.