@imfusion/web-ui 0.5.1-dev.48.g27701f90 → 0.5.1-dev.5.gb4de52d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +55 -156
  2. package/bin/install-skill.js +180 -0
  3. package/dist/index.d.ts +0 -2
  4. package/dist/index.js +4317 -4956
  5. package/dist/integrations/code-highlight/highlighter.d.ts +3 -32
  6. package/dist/integrations/code-highlight.js +48 -188
  7. package/dist/integrations/image-display-options.js +1 -1
  8. package/dist/style.css +1 -1
  9. package/dist/{tabs-CVp_SgBl.js → tabs-DqBFSqq6.js} +1 -1
  10. package/package.json +25 -39
  11. package/src/docgen/doc.gen.json +0 -327
  12. package/src/llms/llms.gen.txt +0 -12
  13. package/src/llms/skills/imf-web-ui/SKILL.md +12 -13
  14. package/src/llms/skills/imf-web-ui-components/SKILL.md +1 -2
  15. package/src/llms/skills/imf-web-ui-frontend-patterns/SKILL.md +93 -0
  16. package/src/llms/skills/imf-web-ui-frontend-patterns/references/code-conventions.md +133 -0
  17. package/src/llms/skills/imf-web-ui-frontend-patterns/references/react-patterns.md +94 -0
  18. package/src/llms/skills/imf-web-ui-imfusion-frontend-setup/SKILL.md +201 -0
  19. package/src/llms/skills/imf-web-ui-setup/SKILL.md +37 -67
  20. package/src/llms/skills/imf-web-ui-ux/SKILL.md +4 -4
  21. package/src/llms/skills/imf-web-ui-ux/references/forms.md +2 -2
  22. package/bin/install.js +0 -428
  23. package/bin/install.test.ts +0 -329
  24. package/dist/build/vite-css-module-names/index.d.ts +0 -20
  25. package/dist/build/vite-css-module-names.js +0 -17
  26. package/dist/components/field/field.d.ts +0 -104
  27. package/dist/components/field/field.meta.d.ts +0 -2
  28. package/dist/components/field/index.d.ts +0 -2
  29. package/dist/components/fieldset/fieldset.d.ts +0 -29
  30. package/dist/components/fieldset/fieldset.meta.d.ts +0 -2
  31. package/dist/components/fieldset/index.d.ts +0 -2
  32. package/dist/integrations/code-highlight/language-patterns.d.ts +0 -7
  33. package/dist/integrations/code-highlight/languages/cmake.d.ts +0 -1
  34. package/dist/integrations/code-highlight/languages/cpp.d.ts +0 -1
  35. package/dist/integrations/code-highlight/languages/python.d.ts +0 -1
  36. package/dist/llms/gen-tokens.d.ts +0 -7
  37. package/src/llms/install-templates/AGENTS.md +0 -34
  38. package/src/llms/install-templates/codex-hooks.json +0 -44
  39. package/src/llms/install-templates/hooks/baseline-staleness.sh +0 -17
  40. package/src/llms/install-templates/hooks/session-start.sh +0 -5
  41. package/src/llms/install-templates/hooks/stop.sh +0 -18
  42. package/src/llms/install-templates/hooks/subagent-start.sh +0 -5
  43. package/src/llms/install-templates/hooks/user-prompt-submit.sh +0 -5
  44. package/src/llms/install-templates/settings.json +0 -45
  45. package/src/llms/skills/imf-web-ui-audit/SKILL.md +0 -119
  46. package/src/llms/skills/imf-web-ui-conventions/SKILL.md +0 -57
  47. package/src/llms/skills/imf-web-ui-conventions/templates/AUDIT_CHECKLIST.md +0 -141
  48. package/src/llms/skills/imf-web-ui-conventions/templates/REPORT.md +0 -45
  49. package/src/llms/skills/imf-web-ui-conventions/topics/agent-tooling.md +0 -82
  50. package/src/llms/skills/imf-web-ui-conventions/topics/assets.md +0 -27
  51. package/src/llms/skills/imf-web-ui-conventions/topics/authentication.md +0 -65
  52. package/src/llms/skills/imf-web-ui-conventions/topics/class-names.md +0 -50
  53. package/src/llms/skills/imf-web-ui-conventions/topics/components.md +0 -101
  54. package/src/llms/skills/imf-web-ui-conventions/topics/data.md +0 -221
  55. package/src/llms/skills/imf-web-ui-conventions/topics/docs-structure.md +0 -40
  56. package/src/llms/skills/imf-web-ui-conventions/topics/git.md +0 -34
  57. package/src/llms/skills/imf-web-ui-conventions/topics/library-boundary.md +0 -33
  58. package/src/llms/skills/imf-web-ui-conventions/topics/library-setup.md +0 -26
  59. package/src/llms/skills/imf-web-ui-conventions/topics/npm-project.md +0 -53
  60. package/src/llms/skills/imf-web-ui-conventions/topics/project-structure.md +0 -44
  61. package/src/llms/skills/imf-web-ui-conventions/topics/react.md +0 -109
  62. package/src/llms/skills/imf-web-ui-conventions/topics/styling.md +0 -88
  63. package/src/llms/skills/imf-web-ui-conventions/topics/testing.md +0 -25
  64. package/src/llms/skills/imf-web-ui-conventions/topics/tokens.md +0 -7
  65. package/src/llms/skills/imf-web-ui-conventions/topics/tooling.md +0 -116
  66. package/src/llms/skills/imf-web-ui-conventions/topics/typescript.md +0 -73
  67. package/src/llms/skills/imf-web-ui-conventions/topics/validation.md +0 -62
  68. package/src/llms/skills/imf-web-ui-update/SKILL.md +0 -157
  69. package/src/llms/tokens.gen.json +0 -887
@@ -1,109 +0,0 @@
1
- # React
2
-
3
- House defaults for React around `@imfusion/web-ui`. Links are for you, the agent — authoritative when a case here is
4
- ambiguous; hand them to the human only if asked.
5
-
6
- ## Composition: pages (smart containers), partials, dumb components
7
-
8
- The architecture principle, top-down — rooted in Dan Abramov's
9
- [Presentational and Container Components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0) and
10
- [Thinking in React](https://react.dev/learn/thinking-in-react). Styling lives exclusively in dumb and layout components,
11
- nowhere else:
12
-
13
- - **Pages are the smart containers.** The route component in `routes/` is the container — don't go looking for `*Container`
14
- files. It owns how things _work_: loaders prefetch, the component fetches data, orchestrates, composes partials and passes
15
- data down. Zero styling — a page wanting CSS (two panels side by side) means a layout component, not an inline style. A
16
- standalone container earns its place only off-route (a modal fetching its own data).
17
- - **Partials** are pure composition: reusable units of dumb and layout components with light logic and zero styling of their
18
- own, extracted because they read as a unit. A partial with a CSS file is a red flag — the styled element wants to be its
19
- own dumb component, or the wrapper wants to be a layout component.
20
- - **Layout components** own _arrangement_ and nothing else: `Stack`-/`Row`-based wrappers with token gaps, a page grid, a
21
- section frame.
22
- - **Dumb components** own how things _look_: style and compose library primitives, take plain data and callbacks as props; no
23
- fetching, routing, or business logic. All non-layout styling lives here and only here — logic-free dumb components (the
24
- `@imfusion/web-ui` layer) keep screens restylable, testable with plain props, resilient to library updates.
25
- - Wrapping library primitives in app-level dumb components: [library-boundary.md](library-boundary.md).
26
-
27
- ```tsx
28
- // Dumb — renders what it's given
29
- function UserCard({ name, role, onEdit }: { name: string; role: string; onEdit: () => void }) {
30
- return (
31
- <Card.Root>
32
- <Card.Content>
33
- <Typo>{name}</Typo>
34
- <Chip>{role}</Chip>
35
- </Card.Content>
36
- <Card.Footer>
37
- <Button onClick={onEdit}>Edit</Button>
38
- </Card.Footer>
39
- </Card.Root>
40
- );
41
- }
42
- ```
43
-
44
- ```tsx
45
- // Smart — knows where data comes from, renders the dumb component
46
- function UserCardContainer({ userId }: { userId: string }) {
47
- const user = useUserQuery(userId);
48
- const openEditor = useEditorNavigation(userId);
49
- return <UserCard name={user.data.name} role={user.data.role} onEdit={openEditor} />;
50
- }
51
- ```
52
-
53
- ## Compose, don't configure
54
-
55
- - Build screen-level pieces by composing primitives (`Stack`, `Row`, `Card`, dumb components), not one component with a dozen
56
- boolean props — a prop list that reads like a settings page wanted to be two or three components.
57
- - Lift state shared between siblings to the nearest common parent
58
- ([Sharing State Between Components](https://react.dev/learn/sharing-state-between-components)); never sync copies.
59
-
60
- ## Put state where its truth lives
61
-
62
- Work down this list; stop at the first match:
63
-
64
- 1. **URL state** — shareable via the address bar (filters, sort, pagination, active tab) → TanStack Router search params;
65
- back button and copied links come free. These cross an external boundary — parse per [validation.md](validation.md).
66
- 2. **Server state** — from an API → TanStack Query's cache ([data.md](data.md)); never copy it into `useState` — that's how
67
- stale-UI bugs are born.
68
- 3. **Subtree state** — resets on leave (wizard progress) → React context.
69
- 4. **Client state** — app-wide and persistent → TanStack Store, and only now: tiers 1–2 usually dissolve the "we need a
70
- store" instinct.
71
- 5. **Local state** — one component's own (input value, open/closed, a draft, a hover flag) → `useState`. Most state is local;
72
- keep it in the component, no library.
73
-
74
- - A form turning drafts into a submitted domain value validates that boundary per [validation.md](validation.md).
75
- - Shape the state itself per [Choosing the State Structure](https://react.dev/learn/choosing-the-state-structure) —
76
- especially its rules on redundant and duplicated state.
77
-
78
- ## Effects: last resort, and named
79
-
80
- - No `useEffect` for: derived values (render or `useMemo`), responses to user actions (the event handler), server sync (the
81
- data-fetching layer). Effects only synchronize with systems _outside_ React.
82
- - Read [You Might Not Need an Effect](https://react.dev/learn/you-might-not-need-an-effect) — the definitive misuse catalog —
83
- before every effect you're tempted to write.
84
- - Extract a genuine effect into a custom hook named for its purpose (`useSyncedScroll`, `useDocumentTitle`, `useHotkey`),
85
- never an anonymous inline `useEffect`: the name documents intent, the hook isolates the dependency array. Pattern:
86
- [Reusing Logic with Custom Hooks](https://react.dev/learn/reusing-logic-with-custom-hooks).
87
- - The rare effect that stays inline still names its callback, so intent survives without a comment:
88
-
89
- ```tsx
90
- useEffect(
91
- function syncDocumentTitle() {
92
- document.title = title;
93
- },
94
- [title]
95
- );
96
- ```
97
-
98
- - A dependency sourced from a hook or query return: destructure the primitive first — [typescript.md](typescript.md#naming).
99
-
100
- ## Reading list
101
-
102
- Consult while building; each is the authority for its topic:
103
-
104
- - [Thinking in React](https://react.dev/learn/thinking-in-react) — decomposition and one-way data flow
105
- - [Keeping Components Pure](https://react.dev/learn/keeping-components-pure) — why dumb components stay dumb
106
- - [Choosing the State Structure](https://react.dev/learn/choosing-the-state-structure) — shaping state without duplication
107
- - [Sharing State Between Components](https://react.dev/learn/sharing-state-between-components) — lifting state
108
- - [You Might Not Need an Effect](https://react.dev/learn/you-might-not-need-an-effect) — the effect misuse catalog
109
- - [Reusing Logic with Custom Hooks](https://react.dev/learn/reusing-logic-with-custom-hooks) — named effects live here
@@ -1,88 +0,0 @@
1
- # Styling
2
-
3
- How app CSS is written and how it meets `@imfusion/web-ui`.
4
-
5
- ## CSS authoring
6
-
7
- - **CSS Modules with native CSS only** — no Sass, no CSS-in-JS, no utility-class framework: nesting and custom properties
8
- already cover DRY. Stylesheet location and ownership: [components.md](components.md).
9
- - Nest pseudo-elements, states, and child selectors under the root so the prefix is written once:
10
-
11
- ```css
12
- .root {
13
- transition: clip-path var(--ease);
14
-
15
- &:focus-visible {
16
- outline: var(--imf-ui-border-size-2) solid var(--imf-ui-color-fg-support);
17
- }
18
-
19
- &[data-disabled] {
20
- opacity: 0.5;
21
- }
22
- }
23
- ```
24
-
25
- - Lift a repeated literal (an easing, a colour-math result) into a custom property; custom properties also carry
26
- per-state/per-variant values down the tree — native parameterisation, no mixin needed.
27
- - Don't merge rules that only look similar — structurally different output (three distinct `clip-path` polygons) isn't
28
- repetition; keep it explicit.
29
-
30
- ## Build custom UI from tokens
31
-
32
- - Custom UI the library doesn't cover (a stat widget, a custom panel) uses names from the shipped token index
33
- ([tokens.md](tokens.md)) for color, size, radius, and type — that's what makes it look native and survive theme changes.
34
- - A hex code or a magic `px` next to a concept the tokens already name is a defect.
35
- - Geometry that can't be a token (a clip-path percentage, a hairline `1px`) → named custom property at the top of the
36
- stylesheet, invariant written next to it. Don't silently approximate to the nearest token.
37
-
38
- ## Override through the sanctioned seams
39
-
40
- - All library styles live in the `imf-ui.components` CSS layer, so any plain selector you write wins — that's the whole
41
- override contract.
42
- - Target the stable hooks: `data-imf-ui-component` attributes and your own classes/wrappers.
43
- - Never target the library's internal class names — they are generated and change without notice.
44
- - Never `!important` — needing it means you're targeting the wrong thing.
45
- - Style against state via data attributes (`[data-checked]`, `[data-disabled]`, `[data-popup-open]`) — components expose
46
- state there, so never maintain your own state classes. `className` is purely a styling surface:
47
-
48
- ```css
49
- [data-imf-ui-component="Switch"][data-checked] {
50
- outline: 2px solid var(--imf-ui-color-bg-positive);
51
- }
52
- ```
53
-
54
- ## The color system
55
-
56
- - Roles: **surfaces** (`main` canvas, `support` panels, `minor` popovers); **brand** (identity, full saturation) vs
57
- **primary** (contrast-tuned, CTAs) — distinct roles on purpose; **status** (`negative`, `warning`, `positive`, `info`);
58
- three **accent** slots.
59
- - **Controls** are the 80/20 customization surface — override one and every derived token shifts:
60
-
61
- ```css
62
- :root {
63
- --imf-ui-color-primary-hue: 30; /* every primary semantic token follows */
64
- }
65
- ```
66
-
67
- - **Semantic tokens** are what you consume: `--imf-ui-color-bg-{name}` per role, a flat
68
- `--imf-ui-color-fg-{main|support|minor|oncolor|…}` ladder for text. Borders and rings draw from `fg-*`.
69
- - Push a hue control into a pale corner → you own overriding the matching `fg-*` token.
70
- - Color scheme is `<html data-imf-ui-color-scheme="light|dark">`, set by the provider; scheme-specific styling selects via
71
- that attribute.
72
-
73
- ## Responsive styling
74
-
75
- - Tune components per breakpoint by overriding their `--imf-ui-*` variables inside your own media queries — custom properties
76
- cross the `@media` boundary, props don't (why sizing is variables, not a `width` prop):
77
-
78
- ```css
79
- @media (min-width: 768px) {
80
- .my-shell {
81
- --imf-ui-appshell-navbar-width: 22rem;
82
- }
83
- }
84
- ```
85
-
86
- - Write literal breakpoint values — the library's `@custom-media` aliases are build-internal and don't ship.
87
- - JS only for behaviour (render a burger menu on mobile): `useMediaQuery(minWidth("md"))`. Never for styling CSS can do.
88
- - No responsive props — `size={{ sm: … }}` objects are deliberately not offered; write the media query.
@@ -1,25 +0,0 @@
1
- # Testing
2
-
3
- Test the **decisions**, not the rendering.
4
-
5
- ## Naming
6
-
7
- - Colocated tests use `.test.ts` / `.test.tsx` (e.g. `login-url.test.ts`) — not `.spec.*` or plural `.tests.*`.
8
-
9
- ## What gets a test
10
-
11
- - **Pure logic gets unit tests** — pricing, permissions, date math, parsing, reducers: cheap, fast, and where bugs actually
12
- hide.
13
- - **Presentational components generally don't**: a component mapping props onto web-ui primitives has no logic of its own —
14
- asserting a `<Button>` rendered tests React, not your code.
15
- - **Behaviour a user performs gets an interaction test** — a validating form, a stepped flow — through the interface the user
16
- has (roles, labels, visible text), not through internals.
17
- - **Extract the decision out of a hook and test it as a plain function** — easier than a render harness; a hook that only
18
- wraps a browser API has no decision to extract.
19
- - The measure isn't coverage percentage — it's whether a failing test tells you something you didn't already know.
20
-
21
- ## Layer-specific recipes
22
-
23
- - Data layer: stub `fetch`, run the real query client — the recipe is in [data.md](data.md).
24
- - A schema whose constraints or transforms encode product behavior gets focused accepted, rejected, and transformed cases:
25
- [validation.md](validation.md).
@@ -1,7 +0,0 @@
1
- # Tokens
2
-
3
- ## Token index
4
-
5
- - `@imfusion/web-ui` ships the generated token index at `node_modules/@imfusion/web-ui/src/llms/tokens.gen.json` — the only
6
- source for consumer token names and authored default values.
7
- - Look up the exact entry there; never invent, recall, or duplicate a plausible `--imf-ui-*` name.
@@ -1,116 +0,0 @@
1
- # Tooling
2
-
3
- Dependency and configuration baseline for an ImFusion frontend; check before adding a dependency and before writing its
4
- config.
5
-
6
- ## Topic-to-tool map
7
-
8
- - Use the mapped tool for each topic; prefer typed config (`.ts` over `.json`) where the tool supports it.
9
-
10
- | Topic | Tool |
11
- | --------------------- | ----------------------------------------------------------------------------------------------------- |
12
- | Build | [Vite](https://vite.dev) |
13
- | Routing, URL state | [TanStack Router](https://tanstack.com/router) — file-based, type-safe search params |
14
- | Server state | [TanStack Query](https://tanstack.com/query) — the pattern around it is [data.md](data.md) |
15
- | Forms | [TanStack Form](https://tanstack.com/form) |
16
- | Data grids | [TanStack Table](https://tanstack.com/table) + web-ui's styled `Table` parts |
17
- | App-wide client state | [TanStack Store](https://tanstack.com/store) — last resort in the state ladder ([react.md](react.md)) |
18
- | Schema validation | [Zod](https://zod.dev) — at the network boundary ([data.md](data.md)) |
19
- | Styling | CSS Modules ([styling.md](styling.md)) |
20
- | Test | [Vitest](https://vitest.dev) |
21
- | Format | [Prettier](https://prettier.io) |
22
- | Lint | [ESLint](https://eslint.org) flat config |
23
- | Types | `tsc --noEmit` — own script, own CI step |
24
- | Staged files | [lint-staged](https://github.com/lint-staged/lint-staged) (or nano-staged, drop-in) |
25
- | Dead code | [Knip](https://knipjs.dev) via `verify:knip` — needs per-repo config |
26
-
27
- ## When a library owns a layer
28
-
29
- - Adopt the library once you're rebuilding what it does — validation timing and cross-field rules (Form), caching and
30
- refetching (Query), URL as source of truth (Router), sorting/pagination over rows (Table): adding it mid-project is cheap,
31
- unpicking a hand-rolled version later is not.
32
-
33
- ## Devtools
34
-
35
- - Every TanStack library with a devtools package gets it as a dev dependency, mounted in development only — Router's
36
- `@tanstack/react-router-devtools` is a given; Query's goes in when Query does.
37
- - Check for a `-devtools` sibling on every new TanStack dependency — not every library has one yet.
38
- - Once several are in, host them in one panel via `@tanstack/devtools`.
39
-
40
- ## Docs over memory
41
-
42
- - `npx @tanstack/cli` for TanStack docs — never work from memory.
43
- - Where `@tanstack/intent` is wired up, use it to reach and read the Agent Skills the TanStack dependencies ship.
44
-
45
- ## Prettier
46
-
47
- - Config file shape is free (`.prettierrc`, `prettier.config.ts`); the values are not:
48
-
49
- ```ts
50
- import type { Config } from "prettier";
51
-
52
- const config: Config = {
53
- printWidth: 125,
54
- tabWidth: 2,
55
- useTabs: false,
56
- trailingComma: "none",
57
- arrowParens: "avoid",
58
- semi: true,
59
- singleQuote: false,
60
- proseWrap: "always"
61
- };
62
- ```
63
-
64
- - Never omit the config file — no file means defaults, and the values silently differ.
65
-
66
- ## ESLint
67
-
68
- Flat config (`eslint.config.ts`):
69
-
70
- - `strictTypeChecked` + `stylisticTypeChecked`, `projectService: true`
71
- - `as` and `!` banned outside tests (`consistent-type-assertions`)
72
- - `.gitignore` as the ignore source (`includeIgnoreFile` from `@eslint/compat`)
73
- - `#/` alias enforced via `no-restricted-imports` banning `../*` — parent-relative paths error, siblings (`./`) stay relative
74
- ([project-structure.md](project-structure.md))
75
-
76
- ## tsconfig
77
-
78
- ```jsonc
79
- {
80
- "compilerOptions": {
81
- "strict": true,
82
- "moduleResolution": "bundler",
83
- "verbatimModuleSyntax": true, // import type stays import type
84
- "noUnusedLocals": true,
85
- "noUnusedParameters": true,
86
- "noFallthroughCasesInSwitch": true,
87
- "noUncheckedSideEffectImports": true,
88
- "skipLibCheck": true,
89
- "paths": { "#/*": ["./src/*"] }
90
- }
91
- }
92
- ```
93
-
94
- - `#/` → `src/` alias rationale: [project-structure.md](project-structure.md).
95
-
96
- ## Staged files
97
-
98
- - Runner config (lint-staged or nano-staged) applies eslint `--fix` and prettier `--write` to staged files only.
99
- - The pre-commit runner also invokes `verify:knip` when staged source or project config can change the reachability graph.
100
-
101
- ## CSS class names
102
-
103
- - Generated CSS Module class names are readable in the DOM, `{prefix}-{file}-{local}`, never the default hash: a legible DOM
104
- is what makes devtools and browser automation usable.
105
- - The library ships the plugin; pass a short, app-scoped prefix:
106
-
107
- ```ts
108
- import { readableCssModuleNames } from "@imfusion/web-ui/build/vite-css-module-names";
109
-
110
- export default defineConfig({
111
- plugins: [react(), readableCssModuleNames({ prefix: "acme" })]
112
- });
113
- ```
114
-
115
- - One pattern for dev, Storybook, and production: register the plugin in **every** tool that compiles the CSS — a compiler
116
- left out generates different names for the same source, and its styles silently don't apply.
@@ -1,73 +0,0 @@
1
- # TypeScript & code style
2
-
3
- Functional by default: pure functions over stateful classes, immutable data over in-place mutation, expressions over
4
- statements, side effects at the edges (network, DOM, store).
5
-
6
- ## Types
7
-
8
- - No `any`. `unknown` at a boundary you can't type, narrowed before use.
9
- - Infer locals; annotate contracts. Exported functions get an explicit return type.
10
- - No temporal coupling — model the states instead of initialising `null` and filling in later.
11
- - Avoid `as`. Fix the type. The honest exception: an untyped third-party boundary, kept at the boundary.
12
- - Derive, don't duplicate:
13
-
14
- ```ts
15
- const sizes = ["sm", "md", "lg"] as const;
16
- type Size = (typeof sizes)[number];
17
-
18
- const labels: Record<Size, string> = { sm: "S", md: "M", lg: "L" }; // compiler breaks if `sizes` changes
19
- ```
20
-
21
- - Same rule across boundaries: library props via `React.ComponentProps<typeof Button>`
22
- ([library-boundary.md](library-boundary.md)), untrusted data via a runtime schema and `z.infer`
23
- ([validation.md](validation.md)).
24
- - Function signatures: 1–2 positional arguments; at 3+, one destructured object.
25
-
26
- ## Immutability & expressions
27
-
28
- - Array methods before loops — `map`, `filter`, `find`, `some`, `flatMap` name what they do:
29
-
30
- ```ts
31
- const activeNames = users.filter(u => u.isActive).map(u => u.name);
32
- ```
33
-
34
- - Produce new values: spreads and `structuredClone` over in-place edits, `toSorted`/`toReversed` over `sort`/`reverse` (which
35
- mutate their receiver).
36
- - Allowed exceptions: a genuine early exit (`for` + `break`), a measured hot loop.
37
- - Keep chains flat: 3–4 steps read well; longer wants named intermediates, and a `reduce` doing four things wants to be a
38
- loop.
39
-
40
- ## Naming
41
-
42
- - Say what it is, not what it's made of: `useUserQuery`, not `useUserHook`; `retryDelay`, not `num`.
43
- - Booleans read as assertions: `isOpen`, `hasAccess`, `canSubmit`.
44
- - Handlers: `onX` as props, `handleX` as implementations.
45
- - Match the vocabulary the product and the API already use — no synonyms for terms the backend named.
46
- - Keep the object a hook or query returns as a namespace instead of destructuring it, and drop the `Query`/`Mutation` suffix
47
- from the local binding — the binding reads as the domain name, and every field access shows where it came from:
48
-
49
- ```tsx
50
- const search = Route.useSearch(); // not const { page, filter } = ...
51
- const user = useSuspenseQuery(context.api.user.getDetails()); // not const { data } = ...
52
- const updateUser = useMutation(context.api.user.update());
53
-
54
- search.page;
55
- user.data.name;
56
- updateUser.mutate(values);
57
- updateUser.isPending;
58
- ```
59
-
60
- - Exception: a `useEffect` dependency array needs a stable primitive, since deps compare by identity — destructure the
61
- primitive out first rather than listing the object or a deep path into it:
62
-
63
- ```tsx
64
- const user = useSuspenseQuery(context.api.auth.getUser());
65
- const { name } = user.data; // destructure for the dep array
66
-
67
- useEffect(
68
- function syncDocumentTitle() {
69
- document.title = name;
70
- },
71
- [name]
72
- );
73
- ```
@@ -1,62 +0,0 @@
1
- # Validation
2
-
3
- Validate where data crosses from untrusted representation into frontend-owned values; the schema is the single source of
4
- truth for runtime check and TypeScript type.
5
-
6
- ## Boundaries
7
-
8
- - Validate once, at the edge: network responses on entry; URL path and search params before business logic; persisted browser
9
- data on read; user input becoming a submitted domain or request value.
10
- - Inside the boundary: parsed values only, no repeated defensive shape checks.
11
- - Outgoing requests built from already parsed domain values are serialized, not re-validated.
12
- - A typed client's handwritten generic is not validation — it only asserts a type onto an untrusted response.
13
-
14
- ## Schema first, type derived
15
-
16
- - Zod schema, type via `z.infer`; never a handwritten type beside its schema.
17
- - Same rule for request and response shapes the frontend owns or consumes at runtime.
18
-
19
- ```ts
20
- import { z } from "zod";
21
-
22
- export const userSchema = z.object({
23
- id: z.string(),
24
- email: z.email()
25
- });
26
-
27
- export type User = z.infer<typeof userSchema>;
28
- ```
29
-
30
- ## TanStack Router search params
31
-
32
- - `validateSearch` takes a Zod v4 schema directly (TanStack Router v1) — no adapter or parsing wrapper.
33
- - `Route.useSearch()` infers its type from `validateSearch`.
34
- - `.catch()`: malformed URL input falls back without interrupting navigation.
35
- - `.default()`: only for missing values; malformed values still follow the route's validation error path.
36
-
37
- ```tsx
38
- import { createFileRoute } from "@tanstack/react-router";
39
- import { z } from "zod";
40
-
41
- const searchSchema = z.object({
42
- page: z.number().int().positive().catch(1),
43
- filter: z.string().catch("")
44
- });
45
-
46
- export const Route = createFileRoute("/users")({
47
- validateSearch: searchSchema,
48
- component: Users
49
- });
50
-
51
- function Users() {
52
- const search = Route.useSearch(); // inferred: z.infer<typeof searchSchema>
53
- return <UserList page={search.page} filter={search.filter} />;
54
- }
55
- ```
56
-
57
- ## Failure handling
58
-
59
- - `schema.parse`: invalid data is a contract failure on the normal error path (malformed backend response → route error
60
- boundary).
61
- - `schema.safeParse`: failure is expected and the caller handles the issues (submitted user input).
62
- - Transforms and coercion live in the boundary schema — never scatter trimming, number conversion, or defaulting downstream.
@@ -1,157 +0,0 @@
1
- ---
2
- name: imf-web-ui-update
3
- description:
4
- "Update @imfusion/web-ui in a consumer repository: refresh the package, vendored skills, and lifecycle hooks, verify the
5
- base update, then audit and optionally migrate affected or custom consumer components in a separate approved commit."
6
- argument-hint: "[--dry-run] [optional version or reason]"
7
- allowed-tools: Bash Read Grep
8
- ---
9
-
10
- # imf-web-ui-update
11
-
12
- Update a repository that consumes `@imfusion/web-ui`. Preserve existing project choices and user work. The workflow has two
13
- commits: the dependency/tooling update first, then an optional consumer migration. Never commit without a fresh explicit
14
- approval.
15
-
16
- ## Rules
17
-
18
- - Work from the frontend package root. In a monorepo, inspect package manifests and `git worktree list` first, then choose
19
- the frontend package in the active worktree that uses web-ui. Read repository and component instructions before changing
20
- files.
21
- - This workflow uses npm. `package-lock.json` is the expected lockfile. Another lockfile is a conflict: stop and ask.
22
- - A dry run is read-only. Do not install, run the installer, format, stage, commit, reset, or clean. Report what would run.
23
- - Record the initial `git status --short`. Existing changes are held back, never staged or overwritten.
24
- - A dirty file that the workflow needs to modify is a conflict. Stop and report it. This includes package files, installed
25
- skill directories, the `AGENTS.md` installer fence, hook files, and hook settings.
26
- - Do not hand-edit installer-owned skills, the `AGENTS.md` fenced block, or installer-owned hook files.
27
- - Keep the base update and consumer migration in separate commits. Do not begin the migration audit until the base update
28
- commit is complete.
29
- - Treat the installed package version before the update as the comparison baseline. There is no assumed changelog.
30
- - A migration candidate is a custom consumer implementation whose behavior overlaps with a current web-ui component, or an
31
- existing web-ui usage affected by changed types or documented API. Do not infer a replacement from a name alone; inspect
32
- the implementation and the current component documentation/types.
33
-
34
- ## Preflight
35
-
36
- 1. Select the frontend package in the active worktree and read its instructions, `package.json`, and `package-lock.json`.
37
- 2. Check whether `@imfusion/web-ui` is already declared and record its installed/version-marker version.
38
- 3. Record the worktree status and identify files the update would touch.
39
- 4. Inspect `.agents/skills/`, `.claude/skills/`, the `AGENTS.md` fence, `.claude/settings.json`, and `.agents/hooks/`.
40
- 5. Check for another npm process. Stop on any conflict or ambiguous target.
41
-
42
- ## Base update
43
-
44
- In a non-dry run, update the dependency:
45
-
46
- ```sh
47
- npm install @imfusion/web-ui
48
- ```
49
-
50
- Pass an explicit version only when the user supplied one. Do not use `--force` or `--legacy-peer-deps` to make installation
51
- pass. Stop on install failure.
52
-
53
- Then refresh the existing web-ui skill target and lifecycle hooks:
54
-
55
- ```sh
56
- npx web-ui-install
57
- npx web-ui-install --hooks
58
- ```
59
-
60
- Run these from the consumer package root, the directory holding the `node_modules` that the dependency install just wrote.
61
- `npx` resolves `web-ui-install` from the installed `@imfusion/web-ui` there; from any other directory it cannot find the
62
- binary. Preserve the existing target (`.agents`, `.claude`, or both); do not silently choose a new one.
63
-
64
- Always run both installer commands after the package update. Skills and installer-owned hook scripts may have changed even
65
- when their existing registrations already cover session start, subagent start, prompt submit, and the stop gate. The hook
66
- installer refreshes those scripts wholesale, prunes retired scripts and their registrations, and merges registrations
67
- idempotently into both host files (`.claude/settings.json` and `.codex/hooks.json`). Stop on malformed settings or installer
68
- conflicts.
69
-
70
- ## Verification
71
-
72
- After each mutating command, compare `git status --short` with the preflight snapshot.
73
-
74
- Classify paths as:
75
-
76
- - **Update-owned:** package files and installer-owned files changed by this workflow.
77
- - **Held back:** pre-existing user changes, excluded from the commit.
78
- - **Conflict:** an overlapping pre-existing change, ambiguous target, or unexpected changed path.
79
-
80
- On conflict, stop. Never use `git restore`, `git reset`, `git clean`, or broad staging to hide it.
81
-
82
- Run the frontend package's documented full verification after the base update. Read its `package.json` scripts and choose
83
- commands that cover typechecking, linting, tests, and building. Prefer one documented aggregate `verify`/`check` script when
84
- it covers those responsibilities; otherwise run the documented non-watch scripts for the responsibilities that exist. Do not
85
- invent script names or run watch/dev scripts. A type or build failure is a base-update conflict to resolve before the base
86
- commit, not a migration finding to defer.
87
-
88
- Verify the dependency/lockfile, current skill markers, the `AGENTS.md` fence, hook coverage, and the final path list. In
89
- dry-run mode, say that mutation-dependent checks were skipped.
90
-
91
- ## Base update report and approval
92
-
93
- Before the base commit, show this concise report:
94
-
95
- ```text
96
- @imfusion/web-ui update report
97
- Package : <old> -> <new> / would update
98
- Skills : <status>
99
- Hooks : <status>
100
- Verification : <status>
101
- Update files : <paths>
102
- Held back : <paths or none>
103
- Conflicts : <paths or none>
104
- Commit : <imperative message or not proposed>
105
- ```
106
-
107
- Normal mode: ask exactly, **“Approve these update-owned changes and commit them?”** Do not commit without an affirmative
108
- answer. If denied, leave the changes uncommitted.
109
-
110
- Dry-run mode: state **“Dry run complete; no changes or commit were made.”** Do not mutate or ask for commit approval.
111
-
112
- ## Consumer migration audit
113
-
114
- Begin this phase only after the approved base update has been committed. Record the old and new package versions from the
115
- pre-update and current manifests/lockfile. Use the current package's exported types, generated documentation, and component
116
- examples as the source of truth. Use the old version's package metadata or repository history when available to identify what
117
- changed; do not pretend a changelog exists.
118
-
119
- Run the same documented full verification again after the base commit. Separate findings into:
120
-
121
- - **Compatibility fixes:** existing web-ui imports, props, or usage patterns that no longer typecheck, build, lint, or pass
122
- tests.
123
- - **Changed component usages:** existing components whose current API, behavior, or documented contract changed between the
124
- two versions and may need a consumer update, even when the typecheck passes.
125
- - **Replacement candidates:** custom consumer components, wrappers, or field implementations that overlap with a component
126
- now exported by `@imfusion/web-ui`. Inspect their code, styles, and call sites before suggesting a replacement. Include the
127
- current custom implementation, the proposed web-ui component, the relevant API/type evidence, and any behavior or styling
128
- that still needs to be preserved.
129
-
130
- Report these findings separately from the base update. Ask whether to apply the proposed migration. If the user declines,
131
- leave the consumer code unchanged. If accepted, make only the approved migration changes, run the documented full
132
- verification again, and show a second report with the migration paths, held-back paths, conflicts, and verification result.
133
-
134
- If no findings exist, report that the installed update has no detected compatibility fixes, changed usages, or replacement
135
- candidates. Do not create an empty migration commit.
136
-
137
- Whatever the migration outcome, close the phase by asking whether to run `imf-web-ui-audit full`: an update can shift the
138
- baseline (new components, hooks, conventions), and the audit shows where the project now stands against it. Run it only on an
139
- explicit yes.
140
-
141
- ## Migration approval
142
-
143
- Ask exactly, **“Approve these consumer migration changes and commit them separately?”** Do not commit without an affirmative
144
- answer. The migration approval is not implied by approval of the base update.
145
-
146
- ## Commit
147
-
148
- For the base update, after approval:
149
-
150
- 1. Recheck status and exclude held-back paths.
151
- 2. Stage base update-owned paths selectively. Never use `git add .` or `git add -A`.
152
- 3. Run the repository's commit workflow if it has one, including its required verification and documentation audit. Otherwise
153
- run documented verification and follow the repository's commit convention.
154
- 4. Commit with a concise imperative message and confirm the commit and final status.
155
-
156
- For an approved migration, repeat the same selective staging and documented commit workflow with a separate imperative
157
- message. Never bypass hooks or amend an unrelated commit after a hook failure.