shuiyuan1223

add-page

0
0
# Install this skill:
npx skills add shuiyuan1223/skillfix_xuetang --skill "add-page"

Install specific skill from multi-skill repository

# Description

Use when adding a new page/view to the PHA web UI. Covers A2UI page generation, routing, sidebar nav, and i18n.

# SKILL.md


name: add-page
description: Use when adding a new page/view to the PHA web UI. Covers A2UI page generation, routing, sidebar nav, and i18n.


Add New Page to PHA

Checklist

Follow these steps in order. Do NOT skip any step.

1. i18n Types & Translations

  • [ ] src/locales/types.ts โ€” Add nav.xxx to nav section, add new section if needed
  • [ ] src/locales/zh-CN.ts โ€” Add Chinese translations
  • [ ] src/locales/en.ts โ€” Add English translations

2. Page Generator

  • [ ] src/gateway/pages.ts โ€” Create generateXxxPage(data) function
  • [ ] Use A2UIGenerator to build component tree
  • [ ] Use t("xxx.yyy") for all user-facing text (NO hardcoded strings)
  • [ ] Use icon NAMES (e.g. "heart", "brain"), NEVER emoji for icon properties
  • [ ] Available icons listed in CLAUDE.md. Need new icon? Add SVG to ui/src/lib/icons.tsx ICONS object
  • [ ] Complex pages can have their own file (e.g. src/gateway/evolution-lab.ts) instead of adding to pages.ts

3. Sidebar Navigation

  • [ ] src/gateway/pages.ts โ€” In generateSidebar(), add nav item:
    typescript { id: "xxx", label: t("nav.xxx"), icon: "icon-name" }
  • [ ] Main pages go in first ui.nav(), settings pages go in second ui.nav()

4. Route Handler

  • [ ] src/gateway/server.ts โ€” In handleNavigate(), add case "xxx": before default:
  • [ ] Fetch data, call generateXxxPage(data), assign to mainPage
  • [ ] Add import for generateXxxPage at top of file

5. Action Handlers (if page has interactive elements)

  • [ ] src/gateway/server.ts โ€” In handleAction(), add handlers for buttons/forms
  • [ ] Add any session state fields to GatewaySession class
  • [ ] Pattern: else if (action === "xxx_action" && payload?.field) { ... }

6. Verify

bun run check   # Types pass
bun test         # Tests pass
bun run build    # Build succeeds

Architecture Rules

  • Frontend is a pure renderer โ€” All UI generated server-side via A2UI
  • No frontend changes needed if existing A2UI components suffice
  • Available components: text, card, column, row, grid, chart, stat_card, data_table, table, button, form, form_input, badge, progress, collapsible, code_editor, tabs, score_gauge, modal, git_timeline, step_indicator, file_tree
  • Complex pages can have their own file (e.g. evolution-lab.ts) instead of adding to pages.ts
  • New A2UI component types require renderers in both A2UIRenderer.tsx (Web) and tui-renderer.ts (TUI)

All registered view IDs in handleNavigate():

Main Views:
  chat              โ€” ่Šๅคฉ้กต้ข (default)
  system-agent      โ€” ็ณป็ปŸ Agent ่Šๅคฉ
  dashboard         โ€” ๅฅๅบทไปช่กจ็›˜ (aliases: health, sleep, activity)
  memory            โ€” ่ฎฐๅฟ†็ณป็ปŸ
  evolution         โ€” ่ฟ›ๅŒ–ๅฎž้ชŒๅฎค

Settings Views:
  settings/prompts       โ€” ๆ็คบ่ฏ็ฎก็†
  settings/skills        โ€” ๆŠ€่ƒฝ็ฎก็†
  settings/integrations  โ€” ๆ•ฐๆฎๆบ้›†ๆˆ
  settings/logs          โ€” ๆ—ฅๅฟ—ๆŸฅ็œ‹
  settings/general       โ€” ้€š็”จ่ฎพ็ฝฎ
  settings/system-agent  โ€” (redirects โ†’ settings/prompts)
  settings/evolution     โ€” (redirects โ†’ evolution)
  settings/evolution-legacy โ€” (redirects โ†’ evolution)
Main Nav (top-level):
  chat, dashboard, memory, evolution, system-agent

Settings Nav (below divider):
  settings/prompts, settings/skills, settings/integrations, settings/logs, settings/general

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.