diff --git a/AGENTS.md b/AGENTS.md index ef0a03ad..526e5417 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -102,6 +102,8 @@ See `agent-docs/framework-dev.md` for monorepo commands, workspace layout, refer An **AI-first, web-components-first** framework inspired by NextJs, Lit, and Rails. +**Why lit-style web components specifically?** AI coding agents have substantial training data on lit. Aligning webjs's component runtime API (reactive properties via `static properties`, lifecycle hooks like `shouldUpdate` / `willUpdate` / `updated` / `firstUpdated` / `updateComplete`, ReactiveController hooks `hostConnected` / `hostDisconnected` / `hostUpdate` / `hostUpdated`, the full `lit-html` directive set, `html` / `css` tagged templates) lets agents emit idiomatic webjs code without framework-specific translation. Webjs ships its own implementation under `packages/core/src/` (clean JSDoc-typed JS, no-build), but the public API surface matches lit so the ecosystem's collective lit knowledge transfers directly. Decorators are the one exception (banned by invariant 10, non-erasable TS); the `declare` + `static properties` pattern replaces them. + - **Sensible defaults, overridable.** Memory store in dev, Redis when configured. HTTP caching via standard `Cache-Control`. - **Built-in essentials.** Auth, sessions, caching, cache store, rate limiting, all with pluggable adapters. - **No build step.** Source files are served as native ES modules. @@ -206,17 +208,22 @@ import { html, css, WebComponent, render, renderToString } from '@webjskit/core' ### Directives, from `import { … } from '@webjskit/core/directives'` -**"Less is more":** only directives that solve problems with no native alternative. +lit-html parity. AI agents writing lit-shaped directive code land on familiar names. | Directive | Purpose | Example | |---|---|---| -| `repeat(items, keyFn, templateFn)` | Keyed reconciliation | `${repeat(items, i => i.id, i => html\`…\`)}` | +| `repeat(items, keyFn, templateFn)` | Keyed list reconciliation | `${repeat(items, i => i.id, i => html\`…\`)}` | | `unsafeHTML(str)` | Render trusted raw HTML. **NEVER use with user input.** | `${unsafeHTML(markdownToHtml(md))}` | | `live(value)` | Input value sync against live DOM | `.value=${live(inputVal)}` | +| `keyed(key, template)` | Force remount on key change | `${keyed(this.userId, html\`
\`)}` | +| `guard(deps, fn)` | Memoize sub-template; client skips re-eval when deps unchanged | `${guard([this.title], () => html\`

\${this.title}

\`)}` | +| `templateContent(tpl)` | Render content of a `