AGENTS.md
libs/@hashintel/ds-components/AGENTS.mdAGENTS.md
Quality
97/100
Scores the file, not the repository.Length
856 words
21 headings · 13 code blocksRepository
1.6k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# @hashintel/ds-components - Agent Context23## Purpose45`@hashintel/ds-components` is now the source-owning design-system package.67It owns:89- the Panda preset source in `src/preset/**`10- token/codegen scripts in `scripts/**`11- the component library in `src/components/**`12- the token/demo surface in `src/tokens/**`, `src/stories/Intro.mdx`, `.ladle/`, and `tests/**`1314It still consumes the generated runtime styling utilities from `@hashintel/ds-helpers`.1516## Architecture1718```19┌─────────────────────────────────────┐20│ ds-components │21│ preset source + scripts + demos │22└──────────────────────┬──────────────┘23 │24 │ panda codegen25 ▼26 ┌─────────────────┐27 │ ds-helpers │28 │ generated only │29 │ styled-system │30 └────────┬────────┘31 ▼32 css(), cva(), jsx runtime33```3435Boundary rules:3637- `ds-components` generates `../ds-helpers/styled-system` via Panda `outdir`.38- `ds-helpers` must not depend on `ds-components`.39- `@hashintel/ds-components/preset` is the canonical public styling entrypoint.40- `@hashintel/ds-components/tokens` is the public package-owned token export for `tokens` and `semanticTokens`.4142## Panda CSS Configuration4344### panda.config.ts4546```ts47import { defineConfig } from "@pandacss/dev";4849import { preset } from "./src/preset";5051export default defineConfig({52 importMap: "@hashintel/ds-helpers",53 outdir: "../ds-helpers/styled-system",54 include: ["./src/components/**/*.{ts,tsx}"],55 jsxFramework: "react",56 outExtension: "mjs",57 preflight: false,58 presets: [preset],59 strictPropertyValues: true,60 strictTokens: true,61 validation: "error",62});63```6465Key points:6667- `src/preset.ts` is the local source of truth for the preset.68- publish codegen writes to `../ds-helpers/styled-system`69- `panda.local.config.ts` also writes to `../ds-helpers/styled-system`; it only broadens the scanned demo/story globs.70- `panda.local.config.ts` exists separately for local demo surfaces such as Ladle7172### Token Naming Patterns (Strict Mode)7374With `strictTokens: true`, you must use the exact token names:7576| Token Type | ❌ Invalid | ✅ Valid |77| ---------------- | --------------------- | ------------------------------------------------ |78| Spacing | `spacing.4`, `"4"` | `default.4`, `compact.4`, `comfortable.4` |79| Radii | `radius.2`, `md` | `md.2`, `sm.3`, `lg.full`, `component.button.sm` |80| FontSize | `size.textsm` | `sm`, `xs`, `base`, `lg`, `xl`, `2xl` |81| LineHeight | `leading.none.textsm` | `none.text-sm`, `normal.text-base` |82| Arbitrary values | `64px` | `[64px]` |8384Token types for stories and public token access should come from `@hashintel/ds-helpers/tokens`.8586### Import Patterns8788Component implementation continues to use the generated styling runtime from `@hashintel/ds-helpers`:8990```tsx91import { css, cva, cx } from "@hashintel/ds-helpers/css";92import { Box, Flex, Stack } from "@hashintel/ds-helpers/jsx";93```9495When you need token lookup helpers or token types, use:9697```ts98import { token, type Token } from "@hashintel/ds-helpers/tokens";99```100101## Color Token Naming102103### Core Colors104105Direct color scales with numeric shades:106107```108gray.{00,10,20,30,35,40,50,60,70,80,90,95}109red.{00,10,20,...,90}110blue.{00,10,20,...,90}111accent.{00,10,20,...,90}112neutral.{white,black}113```114115### Semantic Colors116117Semantic tokens reference core colors:118119**Backgrounds (`bg.*`):**120121```122bg.accent.subtle.{default,hover,active}123bg.accent.bold.{default,hover,pressed,active}124bg.neutral.subtle.{default,hover,active,pressed}125bg.neutral.bold.{default,hover,active,pressed}126bg.status.{info,success,caution,warning}.subtle.{default,hover,active}127bg.status.critical.subtle.{default,hover,active}128bg.status.critical.strong.{default,hover,active}129```130131**Text (`text.*`):**132133```134text.{primary,secondary,tertiary,disabled,inverted}135text.{link,linkHover}136text.status.{info,success,warning,critical}137```138139**Borders (`border.*`):**140141```142border.neutral.{muted,subtle,default,emphasis,hover,active}143border.status.{info,success,caution,warning,critical}144```145146**Surfaces (`surface.*`):**147148```149surface.{default,subtle,muted,emphasis,alt,inverted}150```151152### Token Mapping from Legacy Names153154When updating components, use this mapping:155156| Old (incorrect) | New (correct) |157| ------------------------ | ---------------------- |158| `bg.brand.*` | `bg.accent.*` |159| `core.gray.20` | `gray.20` |160| `core.red.50` | `red.50` |161| `core.custom.30` | `accent.30` |162| `text.linkhover` | `text.linkHover` |163| `text.semantic.critical` | `text.status.critical` |164165## Component Patterns166167### Recipe Definition168169Components use `cva()` for variant-based styling:170171```tsx172import { cva } from "@hashintel/ds-helpers/css";173174const buttonRecipe = cva({175 base: {176 display: "inline-flex",177 alignItems: "center",178 // ...base styles179 },180 variants: {181 variant: {182 primary: {},183 secondary: {},184 ghost: {},185 },186 size: {187 sm: { height: "[28px]", px: "spacing.5" },188 md: { height: "[32px]", px: "spacing.6" },189 lg: { height: "[40px]", px: "spacing.8" },190 },191 },192 compoundVariants: [193 {194 variant: "primary",195 colorScheme: "brand",196 css: {197 backgroundColor: "bg.accent.bold.default",198 color: "text.inverted",199 _hover: { backgroundColor: "bg.accent.bold.hover" },200 },201 },202 ],203});204```205206### Ark UI Integration207208Components wrap Ark UI primitives with Panda styling:209210```tsx211import { Checkbox as ArkCheckbox } from "@ark-ui/react/checkbox";212import { css } from "@hashintel/ds-helpers/css";213214export const Checkbox = (props) => (215 <ArkCheckbox.Root216 className={css({217 /* styles */218 })}219 {...props}220 >221 <ArkCheckbox.Control222 className={css({223 /* styles */224 })}225 >226 <ArkCheckbox.Indicator>{/* check icon */}</ArkCheckbox.Indicator>227 </ArkCheckbox.Control>228 <ArkCheckbox.Label>{props.children}</ArkCheckbox.Label>229 </ArkCheckbox.Root>230);231```232233## Scripts234235| Script | Description |236| --------------------- | ------------------------------------------------------------------ |237| `yarn dev` | Start the primary Ladle-based demo loop |238| `yarn dev:lib` | Watch the publishable component library build |239| `yarn codegen` | Generate token source files and `../ds-helpers/styled-system` |240| `yarn build` | Build the component library entrypoints |241| `yarn build:ladle` | Build the Ladle demo surface |242| `yarn lint:eslint` | Lint the publishable package surface |243| `yarn lint:tsc` | TypeScript type checking |244| `yarn test:unit` | Run the Vitest unit suites without the Playwright snapshot harness |245| `yarn test:snapshots` | Build Ladle and run the Playwright snapshot suite |246247## File Structure248249```250libs/@hashintel/ds-components/251├── .ladle/ # Ladle/demo harness252├── src/253│ ├── components/254│ ├── preset/ # Panda preset source of truth255│ ├── stories/ # Shared docs such as Intro.mdx256│ ├── tokens/ # Token stories and fixtures257│ ├── tokens.ts # Public `./tokens` facade258├── scripts/ # Token/codegen scripts259├── tests/ # Snapshot/demo tests260├── panda.config.ts261├── panda.local.config.ts262├── package.json263└── tsconfig.json264```265266## Regenerating Tokens267268When tokens or preset inputs change:269270```bash271# 1. Regenerate token source files inside ds-components272cd libs/@hashintel/ds-components273yarn codegen:colors274yarn codegen:tokens275276# 2. Regenerate the styled-system artifact in ds-helpers277yarn codegen278279# 3. Verify the package surface still compiles280yarn lint:tsc281```282283## Related Packages284285- **ds-helpers**: generated Panda styled-system artifact (`libs/@hashintel/ds-helpers`)286
Also in hashintel/hash
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hashintel/hash.cursor/rules/ai-assistant-guidelines.mdc · 1.6k | Cursor rules | do-not | 51/100 | 3 days ago | |
| hashintel/hash.cursor/rules/git-commit-conventions.mdc · 1.6k | Cursor rules | lint-formatstylegitdo-not | 51/100 | 3 days ago | |
| hashintel/hash.cursor/rules/meaningful-identifiers.mdc · 1.6k | Cursor rules | do-not | 32/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-coding-style.mdc · 1.6k | Cursor rules | lint-formatstyletypesdependencies+2 | 69/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-documentation.mdc · 1.6k | Cursor rules | docs | 33/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-error-handling.mdc · 1.6k | Cursor rules | no sections | 31/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-testing-strategy.mdc · 1.6k | Cursor rules | testlint-formatstyletesting-strategy | 81/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-tracing-practices.mdc · 1.6k | Cursor rules | no sections | 45/100 | 3 days ago | |
| hashintel/hash.cursor/rules/update-rules.mdc · 1.6k | Cursor rules | no sections | 4/100 | 3 days ago | |
| hashintel/hash.github/instructions/code-review.instructions.md · 1.6k | Copilot instructions | lint-formatstylegitdo-not+1 | 78/100 | 3 days ago | |
| hashintel/hash.github/instructions/rust-review.instructions.md · 1.6k | Copilot instructions | lint-formatstylegitdo-not | 73/100 | 3 days ago | |
| hashintel/hash.github/instructions/typescript-review.instructions.md · 1.6k | Copilot instructions | testlint-formatstyletypes+2 | 66/100 | 3 days ago | |
| hashintel/hashAGENTS.md · 1.6k | AGENTS.md | testlint-formatarchtypes+4 | 93/100 | 3 days ago | |
| hashintel/hashlibs/@hashintel/ds-helpers/AGENTS.md · 1.6k | AGENTS.md | archdependenciesagent-behaviour | 62/100 | 3 days ago | |
| hashintel/hashlibs/@hashintel/petrinaut/AGENTS.md · 1.6k | AGENTS.md | buildtestlint-formatstyle | 80/100 | 3 days ago | |
| hashintel/hash.cursor/rules/typescript-coding-guidelines.mdc · 1.6k | Cursor rules | styletypesdo-not | 65/100 | 3 days ago |
Diff against .cursor/rules/ai-assistant-guidelines.mdc Diff against .cursor/rules/git-commit-conventions.mdc Diff against .cursor/rules/meaningful-identifiers.mdc Diff against .cursor/rules/rust-coding-style.mdc Diff against .cursor/rules/rust-documentation.mdc Diff against .cursor/rules/rust-error-handling.mdc Diff against .cursor/rules/rust-testing-strategy.mdc Diff against .cursor/rules/rust-tracing-practices.mdc Diff against .cursor/rules/update-rules.mdc Diff against .github/instructions/code-review.instructions.md Diff against .github/instructions/rust-review.instructions.md Diff against .github/instructions/typescript-review.instructions.md Diff against AGENTS.md Diff against libs/@hashintel/ds-helpers/AGENTS.md Diff against libs/@hashintel/petrinaut/AGENTS.md Diff against .cursor/rules/typescript-coding-guidelines.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago |
