@imfusion/web-ui 0.5.1-dev.1.g3f7b7ce0 → 0.5.1-dev.15.g0b0aa0c5

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 (42) hide show
  1. package/README.md +175 -41
  2. package/bin/install.js +319 -0
  3. package/bin/install.test.ts +139 -0
  4. package/dist/components/logo/logo.d.ts +1 -1
  5. package/dist/index.js +3 -1
  6. package/dist/style.css +1 -1
  7. package/package.json +30 -25
  8. package/src/docgen/doc.gen.json +1 -1
  9. package/src/llms/skills/imf-web-ui/SKILL.md +15 -11
  10. package/src/llms/skills/imf-web-ui-agent-setup/SKILL.md +71 -0
  11. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/baseline-staleness.sh +17 -0
  12. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/post-tool-use.sh +21 -0
  13. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/session-start.sh +4 -0
  14. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/user-prompt-submit.sh +4 -0
  15. package/src/llms/skills/imf-web-ui-agent-setup/templates/settings.json +37 -0
  16. package/src/llms/skills/imf-web-ui-components/SKILL.md +1 -1
  17. package/src/llms/skills/imf-web-ui-frontend-conventions/SKILL.md +44 -0
  18. package/src/llms/skills/imf-web-ui-frontend-conventions/references/assets.md +23 -0
  19. package/src/llms/skills/imf-web-ui-frontend-conventions/references/components.md +63 -0
  20. package/src/llms/skills/imf-web-ui-frontend-conventions/references/data.md +130 -0
  21. package/src/llms/skills/imf-web-ui-frontend-conventions/references/docs-structure.md +44 -0
  22. package/src/llms/skills/imf-web-ui-frontend-conventions/references/git.md +33 -0
  23. package/src/llms/skills/imf-web-ui-frontend-conventions/references/library-boundary.md +37 -0
  24. package/src/llms/skills/imf-web-ui-frontend-conventions/references/npm-project.md +57 -0
  25. package/src/llms/skills/imf-web-ui-frontend-conventions/references/project-structure.md +21 -0
  26. package/src/llms/skills/{imf-web-ui-frontend-patterns/references/react-patterns.md → imf-web-ui-frontend-conventions/references/react.md} +26 -12
  27. package/src/llms/skills/imf-web-ui-frontend-conventions/references/stack.md +39 -0
  28. package/src/llms/skills/imf-web-ui-frontend-conventions/references/styling.md +91 -0
  29. package/src/llms/skills/imf-web-ui-frontend-conventions/references/testing.md +16 -0
  30. package/src/llms/skills/imf-web-ui-frontend-conventions/references/tooling.md +65 -0
  31. package/src/llms/skills/imf-web-ui-frontend-conventions/references/typescript.md +45 -0
  32. package/src/llms/skills/imf-web-ui-frontend-setup/SKILL.md +83 -0
  33. package/src/llms/skills/imf-web-ui-frontend-setup/templates/AGENTS.md +34 -0
  34. package/src/llms/skills/imf-web-ui-frontend-setup/templates/README.md +27 -0
  35. package/src/llms/skills/imf-web-ui-library-setup/SKILL.md +36 -0
  36. package/src/llms/skills/imf-web-ui-ux/SKILL.md +4 -4
  37. package/src/llms/skills/imf-web-ui-ux/references/forms.md +1 -1
  38. package/bin/install-skill.js +0 -180
  39. package/src/llms/skills/imf-web-ui-frontend-patterns/SKILL.md +0 -93
  40. package/src/llms/skills/imf-web-ui-frontend-patterns/references/code-conventions.md +0 -133
  41. package/src/llms/skills/imf-web-ui-imfusion-frontend-setup/SKILL.md +0 -202
  42. package/src/llms/skills/imf-web-ui-setup/SKILL.md +0 -57
@@ -1,202 +0,0 @@
1
- ---
2
- name: imf-web-ui-imfusion-frontend-setup
3
- description:
4
- "Set up or audit an ImFusion frontend's project tooling: the stack, package.json scripts, formatting, linting, typecheck,
5
- staged-file and pre-commit hooks, verification scopes, dependency pinning, tsconfig, folder structure. House conventions,
6
- not industry standards. Load when starting a new ImFusion frontend, or when asked what an existing one's setup is missing.
7
- Not for adding one config file on request — that's just the edit. Not for wiring the library itself (imf-web-ui-setup)."
8
- ---
9
-
10
- # imf-web-ui-imfusion-frontend-setup
11
-
12
- ImFusion house conventions, **not** industry standards. Report as "missing against the ImFusion baseline", never "against
13
- best practice". Only apply to an ImFusion frontend.
14
-
15
- Two modes, same list:
16
-
17
- - **New project** — work down the list and set each piece up.
18
- - **Existing project** — audit. Read the repo (don't ask what it has), report present / missing / broken, change nothing
19
- until the human picks. An established repo is where a forgotten piece hides.
20
-
21
- **The project wins.** Where the repo already decided, that stands. Report what's _absent_; a working convention you'd have
22
- chosen differently is not a finding.
23
-
24
- ## The stack
25
-
26
- | Concern | Tool | Notes |
27
- | ------------ | --------------------------------------------------------- | ----------------------------------------------------------------------------------- |
28
- | Format | [Prettier](https://prettier.io) | Values below are shared across repos |
29
- | Lint | [ESLint](https://eslint.org) flat config | `--cache --max-warnings=0` |
30
- | Types | `tsc --noEmit` | Own script, own CI step |
31
- | Staged files | [lint-staged](https://github.com/lint-staged/lint-staged) | [nano-staged](https://github.com/usmanyunusov/nano-staged) is a drop-in alternative |
32
- | Routing | [TanStack Router](https://tanstack.com/router) | File-based, `src/routes/` |
33
- | Server state | [TanStack Query](https://tanstack.com/query) | Query keys colocated per API topic |
34
- | Client state | [TanStack Store](https://tanstack.com/store) | Only for state that isn't URL- or server-owned |
35
- | Styling | CSS Modules | Colocated `<component>.module.css` |
36
- | Dead code | [knip](https://knipjs.dev) | Needs per-repo config |
37
- | Build | [Vite](https://vite.dev) | |
38
- | Test | [Vitest](https://vitest.dev) | |
39
-
40
- Either staged-file runner is fine; lint-staged is the larger project and the safer default when one misbehaves.
41
-
42
- ### Devtools come with the library
43
-
44
- Every TanStack library that ships a devtools package gets it as a dev dependency alongside the library itself, mounted in
45
- development only. Router is a given in any ImFusion frontend, so `@tanstack/react-router-devtools` is a given too; Query's
46
- goes in when Query does, and so on. Look for a `-devtools` sibling whenever you add a TanStack dependency rather than working
47
- from a fixed list — the set grows, and not every library has one yet (Store doesn't). Once a project has several,
48
- `@tanstack/devtools` hosts them in one panel.
49
-
50
- ## package.json
51
-
52
- `"type": "module"`, `"private": true`. Scripts — these names, in every repo:
53
-
54
- | Script | Runs |
55
- | ------------------ | -------------------------------------------------------- |
56
- | `dev` | dev server |
57
- | `build` | production build |
58
- | `verify:lint` | `eslint . --cache --max-warnings=0` |
59
- | `verify:format` | `prettier --check .` |
60
- | `verify:typecheck` | `tsc --noEmit` |
61
- | `verify:tests` | `vitest run` |
62
- | `verify:staged` | staged-file subset, called by the pre-commit hook |
63
- | `verify:full` | every check above plus the build; what CI runs |
64
- | `format` | `prettier --write .` |
65
- | `lint:fix` | `eslint . --cache --fix` |
66
- | `git:config` | `git config core.hooksPath …` + `pull.rebase`/`merge.ff` |
67
- | `prepare` | `npm run git:config` |
68
-
69
- **Every check is `verify:*`.** One namespace, so "what can I run to check this?" is answered by tab-completion. Write-mode
70
- scripts keep tool names — `format` and `lint:fix` change files, which isn't verifying. Same name, same meaning, every repo.
71
-
72
- **Git config gets its own script.** `git:config` holds the real command so it's greppable and runnable by hand; `prepare` is
73
- a one-line delegator to it. `prepare` can't be renamed away — npm reserves it and runs it after install — but it shouldn't be
74
- where the logic lives either, since lifecycle scripts get disabled and an invisible setup step then silently stops happening.
75
-
76
- **Dependencies pinned exactly.** No `^`, `~`, or `latest`, in `dependencies` and `devDependencies` alike. A check script in
77
- the verify chain enforces it, but that only catches drift after it lands — `save-exact=true` in `.npmrc` stops `npm install`
78
- reintroducing ranges in the first place.
79
-
80
- ## Config
81
-
82
- **Prettier** — config file shape is free (`.prettierrc`, `prettier.config.ts`); the values are not:
83
-
84
- ```
85
- printWidth: 125 tabWidth: 2 useTabs: false trailingComma: "none"
86
- arrowParens: "avoid" semi: true singleQuote: false proseWrap: "always"
87
- ```
88
-
89
- No config file at all means Prettier runs on defaults — flag it, the values silently differ.
90
-
91
- **ESLint** — flat config (`eslint.config.ts`), `strictTypeChecked` + `stylisticTypeChecked` with `projectService: true`, `as`
92
- and `!` banned outside tests, and `.gitignore` as the ignore source (`includeIgnoreFile` from `@eslint/compat`) so ignores
93
- aren't maintained twice.
94
-
95
- **tsconfig** — defaults:
96
-
97
- ```jsonc
98
- {
99
- "compilerOptions": {
100
- "strict": true,
101
- "moduleResolution": "bundler",
102
- "verbatimModuleSyntax": true, // import type stays import type
103
- "noUnusedLocals": true,
104
- "noUnusedParameters": true,
105
- "noFallthroughCasesInSwitch": true,
106
- "noUncheckedSideEffectImports": true,
107
- "skipLibCheck": true,
108
- "paths": { "#/*": ["./src/*"] }
109
- }
110
- }
111
- ```
112
-
113
- The alias is always `#/` → `src/`. `#` is Node's own subpath-import prefix, so it resolves without a bundler-specific
114
- convention, and it can't collide with an npm scope the way `@/` does.
115
-
116
- **Staged files** — runner config applying eslint `--fix` and prettier `--write` to staged files only.
117
-
118
- **Pre-commit** — the hook installs itself via `prepare` → `git:config`, which sets `core.hooksPath` to a tracked directory
119
- plus `pull.rebase true` and `merge.ff only`, so history strategy doesn't depend on personal git config. Two silent failure
120
- modes: no `prepare` at all (hooks exist only on the machine that ran `git config` by hand), and `core.hooksPath` pointing at
121
- a directory that doesn't exist. Check config **and** directory.
122
-
123
- **Verify scopes** — two blocking, one advisory:
124
-
125
- - **staged** — `verify:staged`, called by the pre-commit hook: lint, format, restage. Fast. A passing commit is not CI green.
126
- - **full** — `verify:full`: the build plus every `verify:*` check. What CI runs.
127
- - **files** — optional post-edit agent hook. Advisory, never exits non-zero, so a mid-flight refactor can't trap the agent.
128
-
129
- One script owns each scope's step list; npm scripts and hooks only launch them. Name by depth, not by occasion — a name like
130
- `preflight` needs explaining and invites a second, near-identical script beside it. Two of those drift, and the drift reads
131
- as "passes locally, fails in CI".
132
-
133
- **Node pinning** — `.nvmrc` or `engines.node`. Not a personal version manager's config; that pins it for you alone.
134
-
135
- ## Folder structure
136
-
137
- ```
138
- src/
139
- routes/ # TanStack Router file-based routes; nothing but routing
140
- api/<topic>/ # one folder per API topic
141
- <topic>.ts # queries/mutations
142
- query-key.ts # key factory
143
- types.ts # request/response types
144
- components/ # see below
145
- http/ # client, error normalisation — the only transport-aware place
146
- lib/ # framework-free helpers
147
- ```
148
-
149
- Everything is kebab-case, folders and files alike.
150
-
151
- **Inside `components/`, group by what kind of component it is** — `layouts/`, `primitives/`, `forms/`, or a domain name. Not
152
- a hard rule: a handful of components reads fine flat, and the grouping should follow what the project actually has rather
153
- than a structure imposed up front. But most codebases grow past flat, and a clear layout component belongs under `layouts/`
154
- rather than beside a domain widget.
155
-
156
- ```
157
- components/
158
- page-header/ # flat is fine
159
- layouts/
160
- page-shell/
161
- data-table/ # a component with sub-component files
162
- data-table.tsx
163
- data-table-row.tsx
164
- data-table.module.css
165
- index.ts
166
- ```
167
-
168
- A component gets a folder when it has more than one file — sub-components, styles, tests. Single-file components can stay
169
- single files. The folder's `index.ts` only re-exports, so imports read `#/components/data-table` and the inside can be
170
- restructured without touching call sites.
171
-
172
- Routes stay thin: they compose, they don't fetch inline. `api/<topic>/` holds the query and its key factory together so a key
173
- is never spelled out at a call site. Anything transport-level (base client, error normalisation) lives in `http/` and nowhere
174
- else.
175
-
176
- ## Styling
177
-
178
- CSS Modules by default, colocated as `<component>.module.css` next to the component. No CSS-in-JS, no utility-class
179
- framework.
180
-
181
- On a project using `@imfusion/web-ui`, style through the sanctioned seams — `--imf-ui-*` tokens and `data-imf-ui-component`
182
- attributes, never the library's generated class names. `imf-web-ui-frontend-patterns` covers that contract.
183
-
184
- If more than one tool compiles the CSS (app build plus Storybook), the generated class-name pattern must be defined **once**
185
- and imported by both, or the same source file gets different class names in each and styles silently don't apply.
186
- `build/css-modules-config.ts` in web-ui is the reference shape; pick your own prefix.
187
-
188
- ## Optional
189
-
190
- Recommend when the shape calls for it; absence is not a finding.
191
-
192
- - **knip** — once several people delete things independently.
193
- - **`ignore-scripts=true` in `.npmrc`** — blocks most supply-chain worm payloads; costs an explicit `npm rebuild` for native
194
- deps.
195
- - **`eslint-plugin-jsx-a11y`** — anything user-facing.
196
-
197
- Out of scope, project-specific: CI, env and secrets, error tracking, deploy, dependency updates.
198
-
199
- ## Not this skill
200
-
201
- - Library wiring (styles import, provider) → `imf-web-ui-setup`
202
- - Code conventions (TypeScript, naming, testing) → `imf-web-ui-frontend-patterns`, `references/code-conventions.md`
@@ -1,57 +0,0 @@
1
- ---
2
- name: imf-web-ui-setup
3
- description:
4
- "One-time wiring of a consumer project: the @imfusion/web-ui styles import and WebUIProvider wrapper. Also covers what to
5
- say about the Agent Skills a dependency ships. Load when installing the library for the first time, or when components
6
- render unstyled or without theme context."
7
- ---
8
-
9
- # imf-web-ui-setup
10
-
11
- This is library wiring: the styles import and the provider. It applies to anyone using `@imfusion/web-ui`.
12
-
13
- If the project is an **ImFusion** frontend and this is first-time setup, mention once that
14
- `imf-web-ui-imfusion-frontend-setup` sets up or audits the repo's tooling (formatting, linting, hooks, scripts) against the
15
- ImFusion baseline, and let the human decide. Offer it; never run it uninvited, and don't raise it again if they pass — the
16
- library works fine without any of it.
17
-
18
- Every consumer entry point needs exactly two lines, in this order:
19
-
20
- ```tsx
21
- import "@imfusion/web-ui/styles.css";
22
- import { WebUIProvider, Button } from "@imfusion/web-ui";
23
- ```
24
-
25
- Wrap the app root in `<WebUIProvider>` once. Components rendered outside it won't have the theme/CSS-variable context they
26
- expect.
27
-
28
- Never import a Base UI (or other upstream) stylesheet or component directly — everything a web-ui component needs is already
29
- inside `styles.css` and the package's own exports; reaching around web-ui to the upstream library is always wrong, even if
30
- the upstream docs show it that way.
31
-
32
- ## Dependency-shipped skills
33
-
34
- Some libraries ship Agent Skills inside their npm package; TanStack does across much of the suite.
35
- [`@tanstack/intent`](https://github.com/TanStack/intent) is the CLI that surfaces them — an agent holding a dependency but
36
- not its guidance writes plausible code against a half-remembered API.
37
-
38
- Setting it up is the project's own call, not something web-ui does on its behalf. Point it out:
39
-
40
- > This project has TanStack dependencies that ship their own Agent Skills. `@tanstack/intent` can make them reachable — worth
41
- > a look if you want your agent working from the library's own guidance.
42
-
43
- Intent offers two things: a fenced instructions block in `AGENTS.md`, and a `PreToolUse` hook that blocks an edit until a
44
- matching skill has been read. The house preference is both — the block alone is advice an agent can walk past. The hook
45
- refuses every edit while no matching skill is loadable, so a project adopting it wants the current docs open; that sequencing
46
- belongs to whoever runs it.
47
-
48
- Whatever the project decides, guidance you didn't read is not guidance you have: use `npx @tanstack/cli` for TanStack docs,
49
- and never guess at a skill name.
50
-
51
- ## Symptoms of a broken setup
52
-
53
- - **Components render but look unstyled** — the `styles.css` import is missing from the entry point.
54
- - **Components render but ignore the theme (wrong colors, no CSS variables resolving)** — they're mounted outside
55
- `<WebUIProvider>`.
56
- - **An integration component throws on import** — its optional peer dependency isn't installed; check the component's
57
- description in the docgen index (`imf-web-ui-components`) for which peer to add to your `package.json`.