Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"timeout": 10
}
]
},
{
"matcher": "Read|Bash|Edit|Write|MultiEdit|NotebookEdit",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/scripts/hooks/design-guide-first.sh",
"timeout": 10
}
]
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/design-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v7
with:
node-version: 22
- name: Check public tokens, contrast and bundled agent marks
- name: Check public tokens, contrast, bundled agent marks and raw controls
run: |
node scripts/check-design-contract.mjs
node --test scripts/tests/token-contrast.test.mjs
node --test scripts/tests/token-contrast.test.mjs scripts/tests/ui-parts.test.mjs
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ Conventions:
## Design Reference

Read [docs/UI_BEHAVIOR.md](docs/UI_BEHAVIOR.md) before changing any surface a user looks at; it owns what the UI does.
Read [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md) before making a design change; it owns how a change moves from scratch to a shipped PR, including the token/System-part/Component procedures and the screen transplant procedure.
Read [docs/DESIGN_GUIDE.md](docs/DESIGN_GUIDE.md) before changing a screen or a token; it says which part to build from and the rules that keep screens alike, and a `PreToolUse` hook (`scripts/hooks/design-guide-first.sh`, registered for Claude Code in `.claude/settings.json` and for Codex in `~/.codex/hooks.json`) refuses the first such edit of a session until it has been read.
Read [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md) before making a design change; it owns how a change moves from proposal to a shipped PR and how it is visually reviewed.
Numeric authority is `design/tokens.json`, and code authority is `web/src/components/ui` and `web/src/components`.
`scripts/gen-tokens.mjs` writes `web/src/tokens.css` and `web/src/generated/accents.ts` from the tokens.
Run `node scripts/check-design-contract.mjs` before delivery; it is the entrypoint `design-contract.yml` runs.

Original design boards, proposal tools and maintainer skills are maintained separately.
The public checkout must build and pass its gates without access to them.
Use the production gallery and isolated app captures for public visual review, following [DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md).
The public checkout builds and passes its gates without any design tool or private repository.
The production gallery and isolated app captures are the visual reference and the review evidence, following [DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md).
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The rest of this file is for the people who open pull requests.
hide is a macOS app over the [Herdr](https://herdr.dev) runtime.
The Rust core in `herdr-core/` owns every piece of state; the `hided` daemon serves a snapshot of it to the web shell in `web/`, which the Electron host in `desktop/` shows in its own window and dispatches typed events back from.
`AGENTS.md` keeps the rules; [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) owns the architecture and the Herdr wire boundary with their reasons, [docs/BUILD.md](docs/BUILD.md) the build output and worktree rules, and [docs/PERFORMANCE_TESTING.md](docs/PERFORMANCE_TESTING.md) the performance rules that came out of real incidents.
Read `AGENTS.md` and the architecture guide before changing anything under `herdr-core/`, `hided/` or `desktop/`; [docs/UI_BEHAVIOR.md](docs/UI_BEHAVIOR.md) before changing anything a user looks at, and [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md) before making a design change.
Read `AGENTS.md` and the architecture guide before changing anything under `herdr-core/`, `hided/` or `desktop/`; [docs/UI_BEHAVIOR.md](docs/UI_BEHAVIOR.md) before changing anything a user looks at, [docs/DESIGN_GUIDE.md](docs/DESIGN_GUIDE.md) before changing a screen or a token, and [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md) before making a design change.
Use [docs/README.md](docs/README.md) to find current guides and distinguish historical/reference-only material.

## Before you open a pull request
Expand Down Expand Up @@ -280,9 +280,8 @@ It starts only private Herdr servers and a loopback SSH account, with no externa

The additional gates that read an existing Herdr server, drive an installed app, or reach an external device are local steps and are not required in CI.
They are listed under "Local gates" below; every script in `scripts/` is either a required gate above, a local gate there, or a generator named in [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md).
The separate `design-contract.yml` workflow runs `node scripts/check-design-contract.mjs` and `node --test scripts/tests/token-contrast.test.mjs`.
The shared entrypoint checks public web token usage, token contrast and bundled agent marks through `check-web-tokens.mjs`, `check-token-contrast.mjs` and `check-agent-logos.mjs`.
Original design boards and their authoring tools are maintained separately with their own checks.
The separate `design-contract.yml` workflow runs `node scripts/check-design-contract.mjs` and `node --test scripts/tests/token-contrast.test.mjs scripts/tests/ui-parts.test.mjs`.
The shared entrypoint checks public web token usage, token contrast, bundled agent marks and raw controls outside the parts through `check-web-tokens.mjs`, `check-token-contrast.mjs`, `check-agent-logos.mjs` and `check-ui-parts.mjs`.
Public builds and contribution checks require no private repository or design-tool login.
These are static checks; [docs/DESIGN_WORKFLOW.md](docs/DESIGN_WORKFLOW.md) owns visual review with the production gallery and isolated app captures.

Expand Down
86 changes: 86 additions & 0 deletions docs/DESIGN_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Design guide

Read this before changing anything a user looks at in `web/src` or a value in `design/tokens.json`.
It says which part to build a screen from and the few rules that keep screens alike.
[UI_BEHAVIOR.md](UI_BEHAVIOR.md) owns what each screen does; [DESIGN_WORKFLOW.md](DESIGN_WORKFLOW.md) owns how a change is proposed, reviewed and delivered.
A project hook refuses the first edit of a web source or the tokens in an agent session until this file has been read in that session (`scripts/hooks/design-guide-first.sh`).

## Three rules

1. Build from a part in `web/src/components/ui`, and from a product composite in `web/src/components` when one already draws the thing.
When no part fits, extend the part (a variant, a size, a slot) with its gallery states in the same pull request; never restyle a raw `<button>`, `<input>` or layer inside a screen.
2. Reach every color, size, radius and text size through a token (`check-web-tokens.mjs` refuses the rest).
Use a general token (`--size-control`, `--size-icon`, the spacing scale) before adding a feature-specific `--size-*`; a new token needs a reason the existing ones cannot carry.
3. Open every layer (menu, dialog, popover, sheet, select) through its part.
The parts register with the shell's one Escape owner and hand keyboard focus back when they close (`components/ui/layer.ts`); a hand-made layer leaves Escape to the terminal under it or loses focus.

`check-ui-parts.mjs` counts raw `<button>`, `<input>`, `<select>`, `<textarea>` and `role="dialog"`/`role="menu"` outside `components/ui` against `scripts/ui-parts-baseline.json`.
A file may only go down: a new raw control fails, and a file with fewer than its baseline asks you to lock the lower number in with `node scripts/check-ui-parts.mjs --update`.

## Which part

| You need | Use | Notes |
| --- | --- | --- |
| An action | `Button` | `variant`: `default` (the one primary action), `secondary`, `outline`, `ghost` (toolbar and row actions), `destructive`, `link`; `size`: `default`, `sm`, `lg`, `icon`, `icon-sm`. |
| An icon-only control | `Button size="icon"` or `"icon-sm"` inside `Hint` | The hint's label is the control's accessible name. |
| One of a few options, all visible | `ToggleGroup type="single"` + `ToggleGroupItem` | Roving focus and arrow keys come with it; `size="sm"` for caption text. |
| Panels switched by a strip | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` | |
| An on/off setting | `Switch` | |
| Several independent choices | `Checkbox` | |
| One of a short list, shown as rows | `RadioGroup`, `RadioGroupItem` | |
| One of a long list | `Select` | |
| A text field | `Input` | No multi-line part exists yet; add one to `components/ui` instead of styling a `<textarea>` in a screen. |
| A range | `Slider` | |
| A menu from a button | `DropdownMenu` | Hide's action menus are `EntryDropdown`, `EntryContextMenu` and `EntryPointMenu` in `components/entry-menu.tsx`. |
| A menu on right-click | `ContextMenu` | |
| A floating panel with controls | `Popover` | |
| A modal task | `Dialog` | `DialogHeader`, `DialogBody`, `DialogFooter`. |
| Confirming an irreversible effect | `AlertDialog` | Prefer an undo (design principle 6); confirm only what cannot be undone. |
| A side or large panel | `Sheet` | |
| A searchable command or item list | `Command` | `CommandDialog` for the palette form. |
| A short label or count | `Badge` | `secondary` by default; `outline`, `default`, `destructive`. |
| A shortcut | `Kbd`, `KbdGroup` | `Keycap` is the number a modifier hold reveals on a row or tile. |
| A hint on hover or focus | `Hint` (or `Tooltip` parts) | A hint holds nothing to click. |
| A divider | `Separator` | Spacing first (design principle 8). |

## Product composites

These already draw a thing Hide shows in several places; use them instead of drawing it again.

| Thing | Composite |
| --- | --- |
| An agent's status | `StatusMark` (`status-mark.tsx`); a project's mark counts are `StatusBadge` |
| An agent's runtime logo | `agent-logo.tsx` |
| Time since something | `Elapsed`, `useElapsed` (`elapsed.tsx`) |
| A row's second line that must keep its leading word | `RowLineText` |
| A settings form | `Group`, `Row`, `Disclosure`, `Value`, `Status`, `Note` (`settings-rows.tsx`) |
| A pull request's mark or card | `pr-mark.tsx`, `pr-card.tsx` |
| A file or folder mark | `FileMark` |
| A device | `DeviceChip`, `device-rail.tsx` |
| What a close would take with it | `SubtreeList` |
| A state that stands in a box | `StateBox` |

## Tokens at a glance

`design/tokens.json` is the authority; `web/src/tokens.css` is generated from it.

- Text, small to large: `text-micro`, `text-caption`, `text-body`, `text-subhead`, `text-title`, `text-headline`, `text-display`.
- Spacing: `xxs`, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, `xxxl` (`gap-sm`, `px-xs`, ...).
- Radius: `rounded-xs` to `rounded-xl`.
- Text color by weight: `text-foreground`, then `text-subtle-foreground`, then `text-muted-foreground`.
- Surfaces: `bg-background`, `bg-card`, `bg-secondary`, `bg-accent` (hover), `bg-popover`.
- Dimming and disabled use the opacity tokens (`opacity-(--opacity-disabled)`, `--opacity-dimmed`), never a raw number.

## Screen rules

- A state reaches the screen only where the operator would act on it; a failure they cannot act on goes to the log (design principle 13).
- Encode state with marks, color and position before sentences; a box or border has to carry information spacing cannot.
- Draw every state the screen can be in (empty, loading, failed, stale) in its smallest form, a mark or a dimmed row before a banner.
- Check long Korean text, a narrow width, Light and Dark, and the largest text size.
- Copy uses plain words the operator already knows, in Korean and English (`web/src/i18n`).

## Before delivery

1. Add or update the gallery state of any part you changed (`web/src/gallery`, served at `/gallery` by `pnpm --dir web dev`).
2. Run `node scripts/check-design-contract.mjs`; it runs the token, contrast, logo and part-count checks.
3. Put a capture of the changed screen in the pull request, following [DESIGN_WORKFLOW.md](DESIGN_WORKFLOW.md#visual-review).
10 changes: 5 additions & 5 deletions docs/DESIGN_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

This guide owns changes to the public interface, tokens and component library.
[UI_BEHAVIOR.md](UI_BEHAVIOR.md) owns shipped behavior.
Original design boards, proposals, authoring tools and maintainer skills are maintained separately.
When using a Pen canvas, keep distinct areas for the design system, components, screens, review proposals and temporary feature designs.
[DESIGN_GUIDE.md](DESIGN_GUIDE.md) owns which part a screen is built from and the rules that keep screens alike.
The production gallery is the visual reference; no design board is an input to a change or its review.
A public checkout requires no private repository or design-tool login to build, test or contribute.

## Authorities
Expand All @@ -16,7 +16,6 @@ A public checkout requires no private repository or design-tool login to build,
The token generator remains public and is the only implementation of token parsing and web generation.
Run `node scripts/gen-tokens.mjs` after changing tokens.
It generates `web/src/tokens.css` and `web/src/generated/accents.ts`; do not edit those generated files by hand.
Original boards are not an input to the public build or CI.

## Make a change

Expand Down Expand Up @@ -50,7 +49,7 @@ A screenshot exemption names its concrete reason in the pull request for the rev
Add a token with both Dark (`value`) and Light (`light`) colors when it is a color.
Use `hide` only when the Hide palette differs, and use aliases instead of restating an existing value.
Regenerate the web outputs and use the token through Tailwind classes or CSS custom properties.
Remove a token only after no public consumer needs it and maintainers have checked their separately maintained boards.
Remove a token once no consumer needs it.
For a reusable component, extend the existing part and its gallery states before introducing a sibling implementation.
Keep product composites in `web/src/components` and smaller reusable parts in `web/src/components/ui`.

Expand All @@ -62,8 +61,9 @@ The public `design-contract.yml` workflow runs this same entrypoint and the cont
- `check-web-tokens.mjs` refuses literal colors, sizes, radii and unchosen Tailwind values in web source.
- `check-token-contrast.mjs` checks terminal text and secondary text against their backgrounds in both palettes and modes.
- `check-agent-logos.mjs` checks bundled agent marks against their public registries and asset manifest.
- `check-ui-parts.mjs` refuses a raw control or layer outside `web/src/components/ui` beyond each file's count in `scripts/ui-parts-baseline.json`, and asks for `--update` when a count went down ([DESIGN_GUIDE.md](DESIGN_GUIDE.md#three-rules)).

`node --test scripts/tests/token-contrast.test.mjs scripts/tests/design-contract.test.mjs` checks contrast policy and staged-source isolation.
`node --test scripts/tests/token-contrast.test.mjs scripts/tests/design-contract.test.mjs scripts/tests/ui-parts.test.mjs` checks contrast policy, staged-source isolation and the part-count ratchet.
The opt-in `.githooks/pre-commit` invokes `node scripts/check-design-contract.mjs --staged`.
That mode reads staged checker modules, tokens, web sources and agent registries into a temporary directory without changing the index or working tree.
Stage the checker and inputs together; an unstaged repair must never make a broken staged candidate pass.
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Product usage statistics: [wire, ownership and privacy](ARCHITECTURE.md#product-
| Explorer context menu, inline naming, drag move, Git decorations, and the core-owned file events | [UI_BEHAVIOR.md: Explorer file management](UI_BEHAVIOR.md#explorer-file-management), [agent workflow contract](../design/agent-workflow-review.md), [bounded projection cost](PERFORMANCE_TESTING.md#projects-and-overview-cost-contract) | `changes.rs`, `hide-host/src/git.rs` (Git changes), `files.rs` explorer operations, runtime explorer tests, `web/src/ExplorerTree.tsx`, `web/src/explorer.ts`, `web/src/revealExternal.ts` (the OS file manager reveal every menu shares) |
| Terminal links: plain-text URL and path detection, wrapped joins, the existence check, click and ⌘-click routes, OSC 8, paths outside every checkout | [UI_BEHAVIOR.md: Terminal links](UI_BEHAVIOR.md#terminal-links), [ARCHITECTURE.md: The desktop host](ARCHITECTURE.md#the-desktop-host) | `web/src/{terminalLinks,terminalLinkProvider}.ts`, `web/src/actions.ts`, `web/src/editor/lineRequest.ts`, `desktop/src/main/localPath.ts`, `desktop/e2e/terminal-links.spec.ts` |
| Terminal file and clipboard image ingress | [ARCHITECTURE.md: Explicit terminal attachments](ARCHITECTURE.md#explicit-terminal-attachments), [UI_BEHAVIOR.md: Terminal image attachment boundary](UI_BEHAVIOR.md#terminal-image-attachment-boundary) | `runtime/attachments.rs`, `hide-host/src/attachments.rs`, `hided/src/attachments.rs`, `web/src/attachments.ts` |
| Which part a screen is built from, the token quick reference and the screen rules | [DESIGN_GUIDE.md](DESIGN_GUIDE.md) | `web/src/components/ui`, `web/src/components`, `scripts/check-ui-parts.mjs`, `scripts/ui-parts-baseline.json`, `scripts/hooks/design-guide-first.sh` |
| Public tokens, component library and human design approval | [DESIGN_WORKFLOW.md](DESIGN_WORKFLOW.md) | `design/tokens.json`, `scripts/gen-tokens.mjs`, `scripts/check-design-contract.mjs`, `web/src/components/ui`, `web/src/gallery` |
| Brand position, approved owl mark, the owl character, palette and voice | [BRAND.md](BRAND.md) | `design/brand/hide-mark.png`, `design/brand/hide-icon-blinking.svg`, `desktop/resources/hide-icon-1024.png`, `web/public/m/`, `site/assets/owls/` |
| Keyboard shortcuts on each system: the rule that makes ⌘ Ctrl+Shift and ⇧⌘ or ⌥⌘ Alt+Shift on Windows and Linux, its exceptions and their reasons, the terminal copy, paste and interrupt keys, and every command's chord in both hosts on both systems | [UI_BEHAVIOR.md: Keyboard shortcuts per system](UI_BEHAVIOR.md#keyboard-shortcuts-per-system) | `web/src/shortcuts.ts` (`modChord`, `PC_KEYS`, `systemRegistry`), `web/src/keys.ts`, `web/src/shortcutLabels.ts`, `desktop/src/main/menu.ts`, `web/src/{shortcuts,keys}.test.ts`, `web/src/shortcutsDoc.test.ts` (holds the every-command table to the registry), `desktop/src/main/menu.test.ts`, `web/e2e/chords.ts`, `web/e2e/korean-input.spec.ts` |
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-design-contract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os from 'node:os';
import path from 'node:path';
import {execFileSync, spawnSync} from 'node:child_process';

const commands = ['check-web-tokens.mjs', 'check-token-contrast.mjs', 'check-agent-logos.mjs'];
const commands = ['check-web-tokens.mjs', 'check-token-contrast.mjs', 'check-agent-logos.mjs', 'check-ui-parts.mjs'];
function run(root) {
for (const command of commands) {
const result = spawnSync(process.execPath, [path.join(root, 'scripts', command)], {cwd: root, stdio: 'inherit'});
Expand Down
Loading
Loading