agentleFS
zalando-incubatorzalando-incubator/agentic-identity-broker/web/AGENTS.md

agentic-identity-broker / web

AGENTS.md68 starsChanged 10 days agoMITView on GitHub

Read the relevant source before you change components, hooks, API types, or design tokens. All file paths are repository-root-relative. Indented tree entries extend their parent path. Browser routes are URL paths. This React SPA manages agent permissions and tool approvals. The Go backend serves web/dist at /. The browser redirects / to /delegations with history replacement. For feature work, read the governing feature's specification, plan, and tasks before changing behavior.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

14 rules. About 0 are common, 5 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the relevant source before you change components, hooks, API types, or design tokens.

    line 3
  2. Distinctive:

    All file paths are repository-root-relative.

    line 4
  3. Very specific:

    Use these aliases in imports.

    line 138
  4. Distinctive:

    Before component work, read these guides:

    line 143
  5. Very specific:

    Add generally reusable components to web/src/design-system/components/.

    line 153
  6. Distinctive:

    Do not reference raw palette utilities from components.

    line 155
  7. Very specific:

    Use Tailwind CSS v4 @theme tokens and CVA for component variants.

    line 156
  8. Very specific:

    Read web/src/design-system/docs/TOKEN_GUIDE.md and web/src/design-system/docs/MOTION_GUIDE.md before changing these details.

    line 176
  9. Distinctive:

    Use semantic roles instead of copying hex values or raw palette scales into components.

    line 181
  10. Very specific:

    After mutations, invalidate relevant cache entries.

    line 202
  11. Very specific:

    Run these commands from the repository root.

    line 230
  12. Very specific:

    Testing approach: Test user-visible behavior.

    line 258
  13. Very specific:

    Harness guidance: Read tests/e2e/AGENTS.md and tests/e2e/README.md before browser test work.

    line 263
  14. Very specific:

    Keep web/src/types/consent.ts, web/src/types/approval.ts, and session types in web/src/services/api/sessions.ts aligned with the contract.

    line 269

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Consent Frontend — React SPA (web/)

Read the relevant source before you change components, hooks, API types, or design tokens. All file paths are repository-root-relative. Indented tree entries extend their parent path. Browser routes are URL paths.

Overview

This React SPA manages agent permissions and tool approvals. The Go backend serves web/dist at /. The browser redirects / to /delegations with history replacement.

Governing References

SourceUse
.specify/memory/constitution.md, Principles XI and XIIIDesign-system requirements and frontend acceptance tests
ARCHITECTURE.md, section 3.1.2Frontend architecture and backend boundary
adrs/005-spa-serving-pattern.mdSame-origin SPA deployment decision
adrs/035-root-mounted-spa.mdCurrent routes, filesystem serving, and superseded portions of ADR 005
adrs/006-frontend-stack.mdStack decisions. Use web/package.json for current dependency versions
adrs/016-authorization-session-anti-spoofing.mdTrusted consent metadata and opaque authorization redirects
api/enduser/openapi.yamlHTTP request and response contracts
specs/024-approval-api-ui/spec.md, specs/024-approval-api-ui/plan.md, specs/024-approval-api-ui/tasks.mdApproval UI requirements, design, and implementation tasks
specs/024-approval-api-ui/glob-approval-matching.mdApproval parameter scopes and previews

For feature work, read the governing feature's specification, plan, and tasks before changing behavior.

Tech Stack

TechnologyVersionRole
React19UI framework (StrictMode)
TypeScript5.3+Type safety
Vite7Build tool + dev server
Tailwind CSS4Utility-first styling via semantic tokens
Headless UI2Accessible unstyled component primitives
React Router7Client-side routing (basename /)
Axios1HTTP client with interceptors
Framer Motion12Page transitions and animations
Vitest4Unit/integration testing
React Testing Library16Component testing
Storybook10Design system documentation and visual testing

Source Structure

web/src/
  App.tsx              Router setup for consent, sessions, approvals, and tool authorizations
  main.tsx             Entry point — React.StrictMode mount

  components/
    consent/           DelegationCard, ServiceCard, ScopeList, GrantValidityControl,
                       ServiceRequirementCard, GrantStatusBadge
    approvals/         Tool-approval review components
    layout/            AppLayout, Header — page chrome
    sessions/          SessionCard, TerminationDialog — OAuth2 session management
    ui/                Reusable UI primitives (Button, Toast, ErrorBoundary, Skeleton,
                       EmptyState, Switch, InlineError, PageTransition, DatePicker)

  design-system/       Shared components and tokens — governed by Constitution XI
    components/        Design system component library (8 categories):
      primitives/        Button, Badge, Avatar, Spinner, Divider
      inputs/            TextInput, TextArea, Select, Checkbox, Radio, Switch, DatePicker
      data-display/      Card, Table, ScopeList, StatusIndicator
      layout/            AppLayout, Container, Stack, Grid, PageTransition
      navigation/        Tabs, Pagination, Breadcrumb
      overlays/          Modal, Tooltip, Dropdown, Popover
      feedback/          EmptyState, InlineError, Skeleton, Alert
      advanced/          Accordion, Progress
    tokens/            Colors, typography, spacing, shadows, radius, animation, z-index, and breakpoints
    utils/             cn() (clsx + tailwind-merge), a11y helpers, focus utilities
    docs/              Detailed design guides:
      INDEX.md                Complete documentation index
      DESIGN_PRINCIPLES.md    Visual philosophy — "Refined Trust Architecture"
      COLOR_GUIDE.md          Full color palette with hex values + WCAG ratios
      TOKEN_GUIDE.md          All design tokens with usage examples
      COMPONENT_ARCHETYPES.md Foundational component specifications
      COMMON_MISTAKES.md      Anti-patterns with correct solutions
      MOTION_GUIDE.md         Animation timing and easing specifications
      COMPONENT_PAIRING_GUIDE.md  Component composition patterns
      COMPOSITION_PATTERNS.md     Complex layout recipes
      DECISION_TREES.md           Which component to use when
      ACCESSIBILITY_GUIDE.md      WCAG 2.1 AA compliance requirements

  hooks/               Custom React hooks
    useConsent          Consent overview data fetching + state
    useAgentGrants      Agent detail + grant management
    useSessions         OAuth2 session listing + operations
    useToggleGrant      Grant enable/disable toggle logic
    useUpdateValidity   Grant expiration date management
    useApproval         Tool-approval data and actions

  pages/               Route components (lazy-loaded with React.lazy)
    ConsentOverviewPage     /delegations — agent delegation list
    AgentGrantDetailPage    /agents/:agentId — per-agent grants
    ThirdPartySessionsPage  /sessions — session management
    ApprovalPage            /approvals/:id — tool-approval review
    ToolAuthorizationsPage  /approvals — permanent approvals
    ErrorPage               * — fallback

  services/
    api/
      client.ts        Axios instance — baseURL: /api, 30s timeout, error interceptors
      consent.ts       Consent data and grant requests
      sessions.ts      Session list, detail, termination, and refresh requests
      approvals.ts     Tool-approval review, scope preview, decisions, lists, and revocation
      cache.ts         In-memory cache for GET responses
      index.ts         Barrel export

  styles/
    index.css          Global styles + Tailwind directives
    fonts.css          Self-hosted Crimson Pro, Manrope, and JetBrains Mono declarations

  types/
    consent.ts         Consent API types: user, agent, service, grant, scope, and permission set
    approval.ts         Tool-approval request and response types

  utils/
    validation.ts      Input validation and redirect URL safety
    scrollToError.ts   Scroll-to-first-error UX helper

Path Aliases

web/vite.config.ts, web/vitest.config.ts, and web/tsconfig.app.json define application aliases. web/.storybook/main.ts defines the subset that Storybook uses.

AliasPath
@design-systemweb/src/design-system
@componentsweb/src/components
@hooksweb/src/hooks
@servicesweb/src/services
@typesweb/src/types
@utilsweb/src/utils
@assetsweb/src/assets
@stylesweb/src/styles

Use these aliases in imports. Do not use relative imports across alias boundaries. The configured @assets target does not exist. Current font assets are in web/public/fonts/.

Design System Rules

Before component work, read these guides:

  • web/src/design-system/docs/INDEX.md for the documentation map
  • web/src/design-system/docs/DECISION_TREES.md for component variants
  • web/src/design-system/docs/COMPONENT_PAIRING_GUIDE.md for composition
  • web/src/design-system/docs/COMMON_MISTAKES.md for known mistakes.

Required Process

  1. Build application components from web/src/design-system/ primitives.
  2. Add generally reusable components to web/src/design-system/components/.
  3. Define color, type, spacing, radius, motion, and theme decisions as semantic tokens in web/src/design-system/tokens/.
  4. Do not reference raw palette utilities from components.
  5. Use Tailwind CSS v4 @theme tokens and CVA for component variants.
  6. Support light and dark themes. Add stories and visual regression tests for new design-system components.
  7. Make every story pass the accessibility addon in both themes.
  8. Meet WCAG 2.1 AA. Use semantic HTML, correct ARIA attributes, visible focus, keyboard support, and reduced-motion behavior.
  9. Self-host brand assets. Do not load fonts, scripts, or images from third-party origins.

Constitution XI governs these requirements. Existing code or guide examples do not prove compliance. For conflicting examples, apply the constitution and report the source conflict.

Current Visual Direction

web/src/design-system/docs/DESIGN_PRINCIPLES.md defines Refined Trust Architecture. A change to that direction requires an ADR. The constitution does not prescribe that aesthetic.

DetailCurrent design guide
Typographyfont-display for headings, font-sans for body text, font-mono for code
ElevationCard shadows, with borders for containment
Motion150ms hover, 200ms state changes, 300ms modals, 500ms pages, with reduced-motion support

Read web/src/design-system/docs/TOKEN_GUIDE.md and web/src/design-system/docs/MOTION_GUIDE.md before changing these details.

Semantic Color Palette

These values describe web/src/design-system/tokens/colors.css, not permanent visual requirements. Use semantic roles instead of copying hex values or raw palette scales into components.

Token FamilyHex (primary)Use
trust-*#0A2540 (deep), #1E4D6B, #E8F1F5 (light)Primary brand, headings, actions
cta-*#D97706Call-to-action buttons and links
success-*#059669Granted permissions, success states
error-*#DC2626Error states, destructive actions
warning-*#D97706Warnings, attention signals
neutral-*#faf9f7 → #1a1511 (50–900 scale)Palette behind semantic background, text, and border roles

API Client Pattern

  • web/src/services/api/client.ts exports apiClient, with base URL /api and a 30-second timeout.
  • The browser uses same-origin endpoints. Vite forwards backend namespaces in development. The Go backend serves production APIs.
  • The Vite proxy adds X-Remote-User in development. An upstream proxy handles production authentication.
  • ConsentApiService, SessionsApiService, and approvalApi provide typed apiClient methods.
  • Consent GETs use a five-minute cache. Session GETs use a two-minute cache. Approval GETs do not use apiCache.
  • Consent detail requests with session_token do not populate the cache.
  • The response interceptor normalizes errors to ApiError.

After mutations, invalidate relevant cache entries. For authorization resumption, treat the server's redirect_url as opaque. Preserve redirect URL validation and full-page navigation, as required by ADR 016 and the OpenAPI contract.

Key API Endpoints

MethodEndpointService method
GET/api/meconsentApi.getUserInfo()
GET/api/consent/agentsconsentApi.getAgentDelegations()
GET/api/consent/agents/:idconsentApi.getAgentDetail(id)
GET/api/consent/agents/:id/grantsconsentApi.getAgentGrants(id)
POST/api/consent/agents/:id/grantsconsentApi.createOrUpdateGrant(id, request)
DELETE/api/consent/agents/:id/grantsconsentApi.deleteGrant(id)
GET/api/third-party/sessionssessionsApi.listSessions()
GET/api/third-party/:id/sessionsessionsApi.getSessionDetails(id)
DELETE/api/third-party/:id/sessionsessionsApi.terminateSession(id)
POST/api/third-party/:id/session/refreshsessionsApi.refreshSession(id)
GET/api/approvals/pendingapprovalApi.listPendingApprovals()
GET/api/approvals/permanentapprovalApi.listPermanentApprovals()
GET/api/approvals/:idapprovalApi.getApproval(id)
POST/api/approvals/:id/approveapprovalApi.approveApproval(id, request)
POST/api/approvals/:id/scope-previewapprovalApi.previewApprovalScope(id, request)
POST/api/approvals/:id/denyapprovalApi.denyApproval(id, request)
POST/api/approvals/:id/revokeapprovalApi.revokePermanentApproval(id)

Development Setup

Run these commands from the repository root. web/package.json requires Node.js 24 or later.

just web-install          # Install npm dependencies
just web-dev              # Start Vite on :3000
just web-build            # Build the production frontend
just web-test             # Run frontend tests
just web-test-coverage    # Run frontend tests with coverage

Vite defaults to port 3000. It proxies /api, /oauth2, /.well-known, and /health to Go. VITE_API_URL overrides the default backend target, http://localhost:8000. Set VITE_USE_POLLING=true for Docker.

Storybook

cd web && npm run storybook     # Port 6006

Storybook loads stories and MDX from web/src/design-system/. Keep application-specific components outside that catalog. web/.storybook/main.ts and web/.storybook/preview.ts control the catalog and accessibility configuration.

Testing Conventions

  • Framework: Vitest, React Testing Library, and jsdom.
  • Setup: web/vitest.setup.ts installs jest-dom matchers and calls cleanup() after each test.
  • File names: *.test.ts, *.test.tsx, *.interactive.test.tsx, and *.integration.test.tsx.
  • Testing approach: Test user-visible behavior. Use role, text, or label queries. If no semantic query exists, use getByTestId.
  • Mocking: Mock API services at the module level. Do not mock React hooks. Mock their data sources.
  • Accessibility: The linter enforces jsx-a11y. Components must support keyboard use and correct ARIA attributes.
  • Browser acceptance tests: For UI changes, add or amend Playwright tests in tests/e2e/frontend/.
  • Screenshots: Capture each meaningful UI state in tests/e2e/screenshots/, as required by Constitution XIII.
  • Harness guidance: Read tests/e2e/AGENTS.md and tests/e2e/README.md before browser test work.

Architecture Boundary

The frontend uses only HTTP endpoints in api/enduser/openapi.yaml. It has no Go imports or shared backend types. Keep web/src/types/consent.ts, web/src/types/approval.ts, and session types in web/src/services/api/sessions.ts aligned with the contract.

Code Splitting

Page components load with React.lazy() inside <Suspense>. Load route bundles during navigation.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.