@vesviet/agent-skills 5.8.0 → 5.11.0
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.
- package/INDEX.md +35 -22
- package/README.md +7 -18
- package/VERSION +1 -1
- package/adapters/antigravity/ANTIGRAVITY.md +40 -142
- package/adapters/antigravity/INDEX_TIER1.json +174 -146
- package/adapters/antigravity/a2a-config.template.yaml +1 -1
- package/adapters/antigravity/antigravity-tools.md +25 -0
- package/adapters/antigravity/role-skill-index.json +175 -58
- package/adapters/claude/CLAUDE_ADAPTER.md +3 -7
- package/adapters/claude/settings.template.json +18 -3
- package/adapters/cursor/README.md +1 -5
- package/adapters/cursor/hooks.template.json +4 -2
- package/core/contracts/README.md +0 -20
- package/core/contracts/schemas/compact-working-state.json +42 -1
- package/core/contracts/schemas/ui-component-spec.json +28 -2
- package/core/policies/README.md +0 -20
- package/core/policies/action-boundaries.yaml +10 -1
- package/core/policies/execution-sandbox.md +0 -12
- package/core/policies/mcp-tool-map.yaml +28 -0
- package/core/roles/3d-graphics-engineer.md +144 -208
- package/core/roles/README.md +1 -23
- package/core/roles/agent-coordinator.md +28 -147
- package/core/roles/agent-discovery-engineer.md +46 -39
- package/core/roles/ai-systems-engineer.md +2 -0
- package/core/roles/backend-developer.md +22 -117
- package/core/roles/cloudflare-engineer.md +1 -1
- package/core/roles/data-engineer.md +3 -1
- package/core/roles/devops-engineer.md +4 -3
- package/core/roles/ecommerce-engineer.md +18 -6
- package/core/roles/frontend-developer.md +146 -317
- package/core/roles/game-developer.md +2 -1
- package/core/roles/mobile-engineer.md +18 -204
- package/core/roles/product-manager.md +3 -3
- package/core/roles/project-manager.md +5 -5
- package/core/roles/references/3d-graphics-engineer-review-checklist.md +109 -109
- package/core/roles/references/agent-coordinator-responsibilities.md +120 -0
- package/core/roles/references/agent-coordinator-review-checklist.md +22 -4
- package/core/roles/references/agent-discovery-engineer-review-checklist.md +29 -20
- package/core/roles/references/backend-developer-responsibilities.md +47 -0
- package/core/roles/references/backend-developer-review-checklist.md +15 -0
- package/core/roles/references/business-analyst-responsibilities.md +2 -2
- package/core/roles/references/frontend-developer-responsibilities.md +14 -6
- package/core/roles/references/frontend-developer-review-checklist.md +13 -6
- package/core/roles/references/mobile-engineer-responsibilities.md +137 -0
- package/core/roles/references/mobile-engineer-review-checklist.md +63 -0
- package/core/roles/references/reviewer-review-checklist.md +54 -0
- package/core/roles/references/sdet-review-checklist.md +53 -0
- package/core/roles/references/solution-architect-responsibilities.md +134 -0
- package/core/roles/references/sre-review-checklist.md +81 -0
- package/core/roles/references/system-engineer-responsibilities.md +124 -0
- package/core/roles/references/technical-architect-responsibilities.md +192 -0
- package/core/roles/references/technical-architect-review-checklist.md +58 -0
- package/core/roles/references/technical-lead-review-checklist.md +65 -0
- package/core/roles/references/ui-ux-designer-anti-slop-standards.md +61 -35
- package/core/roles/references/ui-ux-designer-responsibilities.md +79 -226
- package/core/roles/references/ui-ux-designer-review-checklist.md +102 -116
- package/core/roles/references/vietnam-accounting-specialist-review-checklist.md +6 -6
- package/core/roles/researcher.md +3 -3
- package/core/roles/reviewer.md +2 -2
- package/core/roles/role-standard.md +79 -205
- package/core/roles/sdet.md +5 -6
- package/core/roles/security-engineer.md +4 -3
- package/core/roles/solution-architect.md +9 -130
- package/core/roles/sre.md +1 -0
- package/core/roles/system-engineer.md +15 -155
- package/core/roles/task-planner.md +1 -1
- package/core/roles/technical-architect.md +15 -244
- package/core/roles/technical-lead.md +1 -0
- package/core/roles/technical-writer.md +3 -3
- package/core/roles/ui-ux-designer.md +158 -303
- package/core/roles/vietnam-accounting-specialist.md +20 -20
- package/core/rules/README.md +0 -22
- package/core/rules/code.md +11 -6
- package/core/skills/README.md +12 -25
- package/core/skills/agent/agent-delegation/SKILL.md +11 -0
- package/core/skills/agent/agent-graph-orchestration/SKILL.md +5 -0
- package/core/skills/agent/agent-memory-compaction/SKILL.md +79 -82
- package/core/skills/agent/agent-memory-compaction/references/anchored-schema-and-compaction-algorithms.md +74 -115
- package/core/skills/agent/agent-model-routing/SKILL.md +2 -0
- package/core/skills/agent/agent-observability/SKILL.md +12 -6
- package/core/skills/agent/agent-observability/references/session-forensics-7-dimensions.md +41 -0
- package/core/skills/agent/agent-panel-meeting/SKILL.md +3 -3
- package/core/skills/agent/agent-quality-gate/SKILL.md +9 -0
- package/core/skills/agent/configure-agent-commerce/SKILL.md +2 -0
- package/core/skills/agent/configure-agent-commerce/examples/ucp-commerce-manifest-and-endpoints.json +55 -0
- package/core/skills/agent/configure-agent-commerce/references/acp-ucp-agent-commerce-manifest-specs.md +66 -0
- package/core/skills/agent/configure-agent-headers/SKILL.md +3 -0
- package/core/skills/agent/configure-agent-skills/SKILL.md +4 -4
- package/core/skills/agent/configure-oauth-metadata/SKILL.md +10 -7
- package/core/skills/agent/manage-agent-identity/SKILL.md +2 -0
- package/core/skills/agent/manage-agent-identity/examples/agent-identity-spire-workload.yaml +72 -0
- package/core/skills/agent/manage-agent-identity/references/nhi-lifecycle-and-token-rotation.md +45 -0
- package/core/skills/ai/deploy-vllm-inference/SKILL.md +2 -0
- package/core/skills/ai/deploy-vllm-inference/examples/vllm-production-serve-config.yaml +22 -0
- package/core/skills/ai/deploy-vllm-inference/references/vllm-v1-paged-attention-and-kv-tiering.md +20 -0
- package/core/skills/ai/openrouter-task/SKILL.md +5 -5
- package/core/skills/ai-agent/context-optimization/SKILL.md +2 -0
- package/core/skills/ai-agent/context-optimization/examples/context-pruner-and-reorderer.py +85 -0
- package/core/skills/ai-agent/context-optimization/references/token-budgeting-and-attention-allocation.md +47 -0
- package/core/skills/ai-agent/memory-hygiene/SKILL.md +13 -0
- package/core/skills/ai-agent/memory-hygiene/examples/memory-audit-and-compaction-routine.py +90 -0
- package/core/skills/ai-agent/memory-hygiene/references/agent-memory-vault-spec.md +137 -0
- package/core/skills/ai-agent/memory-hygiene/references/owasp-asi06-and-memory-poisoning-defense.md +38 -0
- package/core/skills/backend/add-api-endpoint/SKILL.md +9 -0
- package/core/skills/backend/add-api-endpoint/examples/express-zod-rfc9457-endpoint.md +329 -0
- package/core/skills/backend/add-api-endpoint/examples/kratos-go-clean-architecture-endpoint.md +405 -0
- package/core/skills/backend/add-api-endpoint/references/idempotency-and-rate-limiting.md +116 -0
- package/core/skills/backend/add-event-handler/SKILL.md +12 -1
- package/core/skills/backend/add-event-handler/examples/go-outbox-skip-locked-relay.go +97 -0
- package/core/skills/backend/add-event-handler/references/transactional-outbox-and-cloudevents.md +42 -0
- package/core/skills/backend/add-service-client/SKILL.md +2 -0
- package/core/skills/backend/add-service-client/examples/ts-circuit-breaker-full-jitter-client.ts +71 -0
- package/core/skills/backend/add-service-client/references/resilient-client-circuit-breaker-specs.md +25 -0
- package/core/skills/backend/build-mcp-server/SKILL.md +2 -0
- package/core/skills/backend/build-mcp-server/examples/ts-stateless-mcp-server-zod.ts +52 -0
- package/core/skills/backend/build-mcp-server/references/mcp-2026-stateless-contract-specs.md +21 -0
- package/core/skills/backend/design-caching-and-locking/SKILL.md +83 -0
- package/core/skills/backend/design-caching-and-locking/examples/redis-lua-atomic-reservation-fencing.lua +30 -0
- package/core/skills/backend/design-caching-and-locking/references/redis-lua-fencing-and-stampede-specs.md +25 -0
- package/core/skills/backend/design-caching-and-locking/scripts/verify_lua_atomicity.py +68 -0
- package/core/skills/backend/implement-auth/SKILL.md +9 -0
- package/core/skills/backend/implement-structured-outputs/SKILL.md +2 -0
- package/core/skills/backend/implement-structured-outputs/examples/python-pydantic-structured-output.py +65 -0
- package/core/skills/backend/implement-structured-outputs/references/constrained-decoding-and-double-validation.md +18 -0
- package/core/skills/backend/optimize-postgres/SKILL.md +9 -0
- package/core/skills/backend/scaffold-new-service/SKILL.md +2 -1
- package/core/skills/backend/scaffold-new-service/references/deep-modules-and-seams.md +43 -0
- package/core/skills/business/elicit-requirements/SKILL.md +2 -0
- package/core/skills/business/trace-requirements-impact/SKILL.md +1 -0
- package/core/skills/business/write-use-cases/SKILL.md +1 -0
- package/core/skills/commerce/handle-checkout-flow/SKILL.md +18 -66
- package/core/skills/commerce/handle-checkout-flow/examples/production-checkout-orchestrator.ts +185 -0
- package/core/skills/commerce/handle-checkout-flow/references/pci-dss-v4-and-agentic-checkout-specs.md +72 -0
- package/core/skills/commerce/integrate-payment-gateway/SKILL.md +22 -58
- package/core/skills/commerce/integrate-payment-gateway/examples/resilient-webhook-and-mpp-handler.ts +164 -0
- package/core/skills/commerce/integrate-payment-gateway/references/mpp-x402-and-webhook-security-specs.md +47 -0
- package/core/skills/commerce/manage-order-fulfillment/SKILL.md +17 -50
- package/core/skills/commerce/manage-order-fulfillment/examples/temporal-fulfillment-saga.ts +104 -0
- package/core/skills/commerce/manage-order-fulfillment/references/event-sourced-fulfillment-and-carrier-webhooks.md +58 -0
- package/core/skills/commerce/manage-product-catalog/SKILL.md +5 -1
- package/core/skills/commerce/manage-product-catalog/examples/hybrid-search-and-governance-pipeline.ts +120 -0
- package/core/skills/commerce/manage-product-catalog/references/semantic-vector-catalog-and-graphrag.md +54 -0
- package/core/skills/content/write-article/SKILL.md +1 -1
- package/core/skills/document/docx/SKILL.md +1 -0
- package/core/skills/document/pdf/SKILL.md +2 -0
- package/core/skills/document/pdf/references/pdf-acroforms-and-pdfplumber-specs.md +54 -0
- package/core/skills/document/pdf/scripts/check_fillable_fields.py +144 -0
- package/core/skills/document/pdf/scripts/fill_fillable_fields.py +145 -0
- package/core/skills/document/xlsx/SKILL.md +1 -0
- package/core/skills/documentation/configure-llms-txt/SKILL.md +3 -0
- package/core/skills/documentation/configure-llms-txt/examples/canonical-llms-txt-and-full-txt.md +45 -0
- package/core/skills/documentation/configure-llms-txt/references/llms-txt-and-llms-full-txt-standard.md +37 -0
- package/core/skills/documentation/write-documentation/SKILL.md +4 -1
- package/core/skills/documentation/write-documentation/examples/microservice-production-readme-and-api-docs.md +70 -0
- package/core/skills/documentation/write-documentation/references/diataxis-framework-and-doc-standards.md +62 -0
- package/core/skills/documentation/write-tech-radar/SKILL.md +1 -0
- package/core/skills/education/create-exercises/SKILL.md +1 -0
- package/core/skills/education/design-learning-plan/SKILL.md +1 -0
- package/core/skills/education/grade-and-review/SKILL.md +1 -0
- package/core/skills/foundation/accessibility-review/SKILL.md +1 -0
- package/core/skills/foundation/ai-risk-assessment/SKILL.md +4 -5
- package/core/skills/foundation/ai-risk-assessment/examples/genai-system-risk-register.md +67 -0
- package/core/skills/foundation/ai-risk-assessment/references/nist-ai-rmf-and-eu-ai-act-taxonomy.md +49 -0
- package/core/skills/foundation/combinatorial-testing/SKILL.md +1 -0
- package/core/skills/foundation/conduct-research/SKILL.md +2 -2
- package/core/skills/foundation/conduct-research/references/ai-era-source-discipline.md +1 -1
- package/core/skills/foundation/create-migration/SKILL.md +10 -0
- package/core/skills/foundation/design-review/SKILL.md +9 -10
- package/core/skills/foundation/design-ux-flow/SKILL.md +9 -7
- package/core/skills/foundation/discernment-nudge/SKILL.md +2 -0
- package/core/skills/foundation/hostile-component-stress-testing/SKILL.md +1 -0
- package/core/skills/foundation/incident-report/SKILL.md +1 -0
- package/core/skills/foundation/plan-technical-delivery/SKILL.md +3 -1
- package/core/skills/foundation/playwright-evidence-qa/SKILL.md +1 -0
- package/core/skills/foundation/refactor-legacy-code/SKILL.md +84 -0
- package/core/skills/foundation/refactor-legacy-code/examples/characterization-test-seam-extraction.py +34 -0
- package/core/skills/foundation/refactor-legacy-code/references/strangler-fig-seams-and-characterization-tests.md +17 -0
- package/core/skills/foundation/refactor-legacy-code/scripts/check_refactor_blast_radius.py +63 -0
- package/core/skills/foundation/release-notes/SKILL.md +3 -3
- package/core/skills/foundation/release-notes/examples/enterprise-platform-release-notes.md +42 -0
- package/core/skills/foundation/release-notes/references/keep-a-changelog-and-semver-governance.md +43 -0
- package/core/skills/foundation/systematic-debugging/SKILL.md +15 -0
- package/core/skills/foundation/webapp-server-runner/SKILL.md +1 -0
- package/core/skills/foundation/write-product-brief/SKILL.md +1 -0
- package/core/skills/foundation/write-tests/SKILL.md +9 -0
- package/core/skills/foundation/write-tests/examples/anti-tautological-tdd-walkthrough.md +204 -0
- package/core/skills/foundation/write-tests/examples/testcontainers-kratos-integration-test.md +186 -0
- package/core/skills/foundation/write-tests/references/contract-and-chaos-testing.md +187 -0
- package/core/skills/frontend/INDEX.json +16 -0
- package/core/skills/frontend/add-page-route/SKILL.md +10 -8
- package/core/skills/frontend/add-page-route/examples/streaming-rsc-page-with-view-transition.tsx +133 -0
- package/core/skills/frontend/add-page-route/references/rsc-routing-and-view-transitions.md +72 -0
- package/core/skills/frontend/add-ui-component/SKILL.md +4 -1
- package/core/skills/frontend/add-ui-component/examples/compound-dialog-and-form-actions.tsx +193 -0
- package/core/skills/frontend/add-ui-component/references/react19-component-standards-and-anti-slop.md +55 -0
- package/core/skills/frontend/component-composition/SKILL.md +12 -1
- package/core/skills/frontend/component-composition/examples/headless-combobox-compound-component.tsx +207 -0
- package/core/skills/frontend/design-md-specification/SKILL.md +5 -0
- package/core/skills/frontend/design-system-engineering/SKILL.md +4 -2
- package/core/skills/frontend/frontend-micro-polish/SKILL.md +1 -0
- package/core/skills/frontend/frontend-testing/SKILL.md +4 -1
- package/core/skills/frontend/frontend-testing/examples/playwright-e2e-with-msw-and-axe.spec.ts +87 -0
- package/core/skills/frontend/frontend-testing/references/playwright-msw-and-a11y-testing-standards.md +78 -0
- package/core/skills/frontend/implement-ai-disclosure/SKILL.md +119 -0
- package/core/skills/frontend/implement-view-transitions/SKILL.md +1 -0
- package/core/skills/frontend/implement-webmcp/SKILL.md +7 -4
- package/core/skills/frontend/implement-webmcp/examples/webmcp-provider-and-hitl-modal.tsx +163 -0
- package/core/skills/frontend/implement-webmcp/references/webmcp-architecture-and-hitl-security.md +48 -0
- package/core/skills/frontend/integrate-api-client/SKILL.md +12 -12
- package/core/skills/frontend/integrate-api-client/examples/orval-query-and-streaming-mutation.ts +102 -0
- package/core/skills/frontend/integrate-api-client/references/orval-tanstack-query-and-streaming-specs.md +57 -0
- package/core/skills/frontend/interactive-component-workbench/SKILL.md +1 -0
- package/core/skills/frontend/motion-performance-engineering/SKILL.md +1 -0
- package/core/skills/frontend/setup-design-system/SKILL.md +6 -3
- package/core/skills/frontend/setup-design-system/examples/tailwind-v4-theme-and-dtcg-tokens.css +87 -0
- package/core/skills/frontend/setup-design-system/references/tailwind-v4-oklch-and-dtcg-tokens.md +61 -0
- package/core/skills/frontend/setup-visual-regression/SKILL.md +8 -5
- package/core/skills/frontend/setup-visual-regression/examples/visual-regression-playwright.config.ts +83 -0
- package/core/skills/frontend/setup-visual-regression/references/visual-regression-docker-and-masking-specs.md +46 -0
- package/core/skills/frontend/ui-ux-designer-anti-slop-standards.md +64 -42
- package/core/skills/frontend/web-quality-audit/SKILL.md +1 -0
- package/core/skills/gamedev/abstract-input-actions/SKILL.md +2 -0
- package/core/skills/gamedev/abstract-input-actions/examples/input-action-manager.ts +85 -0
- package/core/skills/gamedev/abstract-input-actions/references/action-mapping-and-analog-deadzones.md +54 -0
- package/core/skills/gamedev/architect-ecs-systems/SKILL.md +2 -0
- package/core/skills/gamedev/architect-ecs-systems/examples/bevy-flecs-combat-system.rs +73 -0
- package/core/skills/gamedev/architect-ecs-systems/references/data-oriented-design-and-archetype-ecs.md +39 -0
- package/core/skills/gamedev/author-game-ai/SKILL.md +2 -0
- package/core/skills/gamedev/author-game-ai/examples/modular-behavior-tree-ai.ts +98 -0
- package/core/skills/gamedev/author-game-ai/references/behavior-trees-and-utility-ai-curves.md +47 -0
- package/core/skills/gamedev/configure-physics-collision/SKILL.md +2 -0
- package/core/skills/gamedev/configure-physics-collision/examples/kinematic-physics-substepping.cpp +100 -0
- package/core/skills/gamedev/configure-physics-collision/references/continuous-collision-detection-and-substepping.md +50 -0
- package/core/skills/gamedev/develop-gameplay-systems/SKILL.md +2 -0
- package/core/skills/gamedev/develop-gameplay-systems/examples/kinematic-character-controller.gd +86 -0
- package/core/skills/gamedev/develop-gameplay-systems/references/deterministic-gameplay-state-machines.md +42 -0
- package/core/skills/gamedev/implement-save-persistence/SKILL.md +2 -0
- package/core/skills/gamedev/implement-save-persistence/examples/versioned-save-manager.ts +127 -0
- package/core/skills/gamedev/implement-save-persistence/references/versioned-save-schemas-and-checksums.md +44 -0
- package/core/skills/gamedev/render-webgl-threejs/SKILL.md +14 -10
- package/core/skills/gamedev/render-webgl-threejs/examples/production-threejs-webgpu-scene.ts +116 -0
- package/core/skills/gamedev/render-webgl-threejs/references/webgpu-threejs-pbr-pipeline.md +72 -0
- package/core/skills/legal-compliance/audit-ai-compliance/SKILL.md +1 -0
- package/core/skills/legal-compliance/draft-legal-opinion/SKILL.md +1 -0
- package/core/skills/legal-compliance/manage-vietnam-legal/SKILL.md +1 -0
- package/core/skills/meetings-analysis/analyze-business-requirements/SKILL.md +1 -0
- package/core/skills/meetings-analysis/analyze-data/SKILL.md +1 -0
- package/core/skills/meetings-analysis/meeting-review/SKILL.md +1 -0
- package/core/skills/mmo/analyze-campaign-roi/SKILL.md +2 -0
- package/core/skills/mmo/analyze-campaign-roi/examples/campaign-roi-and-roas-dashboard.py +80 -0
- package/core/skills/mmo/analyze-campaign-roi/references/multi-touch-attribution-and-cpa-analytics.md +33 -0
- package/core/skills/mmo/create-automation-script/SKILL.md +2 -0
- package/core/skills/mmo/create-automation-script/examples/stealth-browser-automation-flow.ts +65 -0
- package/core/skills/mmo/create-automation-script/references/stealth-cdp-and-behavioral-mimicry.md +37 -0
- package/core/skills/mmo/deploy-mmo-infrastructure/SKILL.md +3 -0
- package/core/skills/mmo/deploy-mmo-infrastructure/examples/proxy-health-probe-and-rotation-daemon.py +75 -0
- package/core/skills/mmo/deploy-mmo-infrastructure/references/proxy-pool-rotation-and-anti-detect-specs.md +45 -0
- package/core/skills/mmo/deploy-proxyware-fleet/SKILL.md +3 -0
- package/core/skills/mmo/deploy-proxyware-fleet/examples/docker-compose-depin-light-node-fleet.yaml +52 -0
- package/core/skills/mmo/deploy-proxyware-fleet/references/depin-bandwidth-monetization-node-specs.md +43 -0
- package/core/skills/mmo/generate-mmo-content/SKILL.md +2 -0
- package/core/skills/mmo/generate-mmo-content/examples/pseo-programmatic-page-generator.ts +76 -0
- package/core/skills/mmo/generate-mmo-content/references/pseo-landing-pages-and-social-video-hooks.md +39 -0
- package/core/skills/mmo/manage-mmo-assets/SKILL.md +2 -0
- package/core/skills/mmo/manage-mmo-assets/examples/mmo-asset-vault-manager.py +63 -0
- package/core/skills/mmo/manage-mmo-assets/references/mmo-asset-rbac-and-vault-isolation.md +38 -0
- package/core/skills/mmo/setup-tracking-system/SKILL.md +2 -0
- package/core/skills/mmo/setup-tracking-system/examples/meta-capi-s2s-event-dispatcher.ts +79 -0
- package/core/skills/mmo/setup-tracking-system/references/server-to-server-postback-and-capi-specs.md +45 -0
- package/core/skills/mobile/deploy-mobile-app/SKILL.md +1 -0
- package/core/skills/mobile/develop-mobile-app/SKILL.md +1 -0
- package/core/skills/platform/add-telemetry-instrumentation/SKILL.md +2 -0
- package/core/skills/platform/add-telemetry-instrumentation/examples/kratos-otel-middleware-instrumentation.go +87 -0
- package/core/skills/platform/add-telemetry-instrumentation/references/opentelemetry-semantic-conventions-2026.md +37 -0
- package/core/skills/platform/agents-sdk/SKILL.md +1 -0
- package/core/skills/platform/aws-infrastructure/SKILL.md +2 -0
- package/core/skills/platform/aws-infrastructure/examples/opentofu-eks-pod-identity-vpc.tf +101 -0
- package/core/skills/platform/aws-infrastructure/references/opentofu-aws-zero-trust-and-irsa.md +40 -0
- package/core/skills/platform/cloudflare-email-service/SKILL.md +2 -2
- package/core/skills/platform/configure-ci-cd-pipeline/SKILL.md +83 -0
- package/core/skills/platform/configure-ci-cd-pipeline/examples/hardened-ci-matrix-workflow.yml +33 -0
- package/core/skills/platform/configure-ci-cd-pipeline/references/github-actions-sha-pinning-and-slsa-specs.md +22 -0
- package/core/skills/platform/configure-ci-cd-pipeline/scripts/audit_workflow_pinning.py +74 -0
- package/core/skills/platform/debug-runtime-platform/SKILL.md +1 -2
- package/core/skills/platform/debug-workers-edge/SKILL.md +2 -2
- package/core/skills/platform/durable-objects/SKILL.md +1 -0
- package/core/skills/platform/orchestrate-chaos-experiment/SKILL.md +1 -0
- package/core/skills/platform/sandbox-sdk/SKILL.md +1 -0
- package/core/skills/platform/setup-deployment/SKILL.md +6 -2
- package/core/skills/platform/setup-deployment/examples/kustomize-production-service-manifests.yaml +123 -0
- package/core/skills/platform/setup-deployment/references/interactive-hitl-wizard.md +55 -0
- package/core/skills/platform/setup-deployment/references/k8s-gitops-and-kustomize-invariants.md +40 -0
- package/core/skills/platform/setup-gpu-finops/SKILL.md +2 -0
- package/core/skills/platform/setup-gpu-finops/examples/gpu-finops-prometheus-rules.yaml +23 -0
- package/core/skills/platform/setup-gpu-finops/references/dcgm-kubecost-gpu-attribution-specs.md +16 -0
- package/core/skills/platform/setup-llm-gateway/SKILL.md +2 -0
- package/core/skills/platform/setup-llm-gateway/examples/litellm-gateway-config.yaml +28 -0
- package/core/skills/platform/setup-llm-gateway/references/litellm-routing-budget-failover-specs.md +16 -0
- package/core/skills/platform/supply-chain-security/SKILL.md +3 -2
- package/core/skills/platform/supply-chain-security/examples/github-actions-sbom-cosign.yaml +57 -0
- package/core/skills/platform/supply-chain-security/references/slsa-provenance-and-sbom-sigstore.md +60 -0
- package/core/skills/platform/turnstile-spin/SKILL.md +2 -2
- package/core/skills/platform/web-perf/SKILL.md +2 -2
- package/core/skills/platform/workers-best-practices/SKILL.md +1 -0
- package/core/skills/platform/wrangler/SKILL.md +1 -0
- package/core/skills/product/build-story-map/SKILL.md +3 -0
- package/core/skills/product/define-product-strategy/SKILL.md +1 -0
- package/core/skills/product/model-saas-metrics/SKILL.md +1 -0
- package/core/skills/product/prioritize-roadmap/SKILL.md +1 -0
- package/core/skills/repo-ops/commit-code/SKILL.md +1 -0
- package/core/skills/repo-ops/navigate-service/SKILL.md +28 -132
- package/core/skills/repo-ops/navigate-service/examples/service-boundary-map-example.md +14 -0
- package/core/skills/repo-ops/navigate-service/references/service-topology-mapping-guide.md +18 -0
- package/core/skills/repo-ops/review-code/SKILL.md +12 -2
- package/core/skills/repo-ops/review-code/examples/adversarial-two-axis-pr-review.md +167 -0
- package/core/skills/repo-ops/review-code/examples/ai-vibe-slop-remediation.md +220 -0
- package/core/skills/repo-ops/review-code/references/supply-chain-and-migration-safety.md +103 -0
- package/core/skills/repo-ops/review-service/SKILL.md +4 -1
- package/core/skills/repo-ops/review-service/examples/service-release-audit-report.md +21 -0
- package/core/skills/repo-ops/review-service/references/release-readiness-audit-rubric.md +21 -0
- package/core/skills/repo-ops/troubleshoot-service/SKILL.md +1 -0
- package/core/skills/security-data/database-maintenance/SKILL.md +1 -1
- package/core/skills/security-data/manage-secrets/SKILL.md +2 -0
- package/core/skills/security-data/manage-secrets/examples/external-secrets-vault-crds.yaml +53 -0
- package/core/skills/security-data/manage-secrets/references/zero-trust-secret-rotation-and-eso.md +30 -0
- package/core/skills/security-data/manage-vietnam-accounting/SKILL.md +8 -7
- package/core/skills/security-data/prompt-injection-defense/SKILL.md +2 -0
- package/core/skills/security-data/prompt-injection-defense/examples/bounded-tool-execution-wrapper.py +78 -0
- package/core/skills/security-data/prompt-injection-defense/references/prompt-injection-taxonomy-and-delimiters.md +37 -0
- package/core/skills/security-data/reverse-engineer-binary/SKILL.md +3 -0
- package/core/skills/security-data/reverse-engineer-binary/examples/binary-triage-and-vulnerability-dossier.md +58 -0
- package/core/skills/security-data/reverse-engineer-binary/references/ghidra-radare2-and-rea-evidence-ledgers.md +43 -0
- package/core/skills/security-data/security-audit/SKILL.md +3 -1
- package/core/skills/security-data/security-audit/examples/enterprise-service-security-audit-report.md +54 -0
- package/core/skills/security-data/security-audit/references/owasp-asi-and-cvss4-threat-modeling.md +39 -0
- package/core/skills/security-data/skill-preflight-ast-check/SKILL.md +3 -0
- package/core/skills/security-data/skill-preflight-ast-check/references/ast-lethal-trifecta-and-static-vetting.md +38 -0
- package/core/skills/security-data/skill-preflight-ast-check/scripts/scan-skill-ast.py +127 -0
- package/core/skills/seo/audit-technical-seo/SKILL.md +1 -0
- package/core/skills/seo/implement-schema-markup/SKILL.md +1 -0
- package/core/workflows/README.md +0 -20
- package/overlays/README.md +2 -22
- package/overlays/astro-cloudflare/README.md +0 -20
- package/overlays/astro-cloudflare/rules/astro-cloudflare-conventions.md +0 -31
- package/overlays/b2b-catalog-golf/README.md +0 -20
- package/overlays/b2b-catalog-golf/rules/golf-project-rules.md +0 -31
- package/overlays/b2b-catalog-golf/skills/develop-b2b-golf-feature/SKILL.md +1 -0
- package/overlays/b2b-factory-catalog/README.md +0 -20
- package/overlays/b2b-factory-catalog/rules/icm-project-rules.md +0 -31
- package/overlays/b2b-factory-catalog/skills/develop-b2b-catalog-feature/SKILL.md +1 -0
- package/overlays/b2b-sport-catalog/README.md +0 -20
- package/overlays/b2b-sport-catalog/rules/sport-project-rules.md +0 -31
- package/overlays/cad-projection/README.md +0 -20
- package/overlays/cad-projection/rules/cad-conventions.md +0 -20
- package/overlays/cad-projection/skills/isometric-svg-projection/SKILL.md +1 -0
- package/overlays/data-analyst-stack/README.md +0 -20
- package/overlays/data-analyst-stack/rules/metric-dashboard-templates.md +0 -31
- package/overlays/data-analyst-stack/rules/stack-conventions.md +0 -31
- package/overlays/data-warehouse/README.md +0 -22
- package/overlays/data-warehouse/learning/learning-conventions.md +0 -31
- package/overlays/data-warehouse/learning/phase-roadmap.md +0 -31
- package/overlays/data-warehouse/rules/amis-accounting-standards.md +0 -33
- package/overlays/data-warehouse/rules/duckdb-concurrency.md +0 -37
- package/overlays/data-warehouse/rules/pii-scrubbing.md +0 -37
- package/overlays/data-warehouse/rules/stocktake-tolerance.md +0 -33
- package/overlays/ecommerce-microservices/README.md +22 -35
- package/overlays/ecommerce-microservices/config/README.md +3 -1
- package/overlays/ecommerce-microservices/rules/README.md +2 -1
- package/overlays/ecommerce-microservices/rules/microservices-conventions.md +30 -0
- package/overlays/ecommerce-microservices/skills/README.md +1 -1
- package/overlays/ecommerce-microservices/workflows/README.md +3 -1
- package/overlays/fintech-compliance/README.md +0 -20
- package/overlays/fintech-compliance/rules/credit-scorecard-rules.md +0 -20
- package/overlays/fintech-compliance/skills/build-credit-scorecard/SKILL.md +1 -0
- package/overlays/go-microservices/README.md +1 -21
- package/overlays/go-microservices/rules/go-conventions.md +0 -31
- package/overlays/hugo-authority-content/README.md +0 -20
- package/overlays/hugo-authority-content/roles/README.md +0 -20
- package/overlays/hugo-authority-content/rules/content-brand.md +0 -30
- package/overlays/hugo-authority-content/rules/link-topology.md +0 -30
- package/overlays/hugo-authority-content/rules/seo-authority.md +0 -30
- package/overlays/hugo-authority-content/rules/technical-article-2027.md +0 -30
- package/overlays/hugo-authority-content/skills/audit-technical-article/SKILL.md +1 -0
- package/overlays/hugo-authority-content/skills/write-hugo-twin-content/SKILL.md +1 -0
- package/overlays/hugo-authority-content/workflows/README.md +0 -20
- package/overlays/hvac-authority-content/README.md +0 -20
- package/overlays/hvac-authority-content/config/collections.md +0 -22
- package/overlays/hvac-authority-content/rules/content-schema.md +0 -30
- package/overlays/hvac-authority-content/rules/hvac-engineering-standards.md +0 -30
- package/overlays/hvac-authority-content/rules/silo-linking.md +0 -30
- package/overlays/hvac-authority-content/skills/write-hvac-authority-content/SKILL.md +1 -0
- package/overlays/hvac-authority-content/workflows/publish-hvac-content.md +0 -22
- package/overlays/laravel-ecommerce/README.md +0 -20
- package/overlays/laravel-ecommerce/rules/elomus-design-system.md +0 -31
- package/overlays/laravel-ecommerce/rules/laravel-ecommerce-rules.md +0 -31
- package/overlays/laravel-ecommerce/skills/develop-laravel-ecommerce-feature/SKILL.md +1 -0
- package/overlays/laravel-filament/README.md +0 -20
- package/overlays/laravel-filament/rules/laravel-conventions.md +0 -31
- package/overlays/laravel-filament/skills/develop-laravel-feature/SKILL.md +1 -0
- package/overlays/livestream-web/README.md +0 -20
- package/overlays/livestream-web/rules/livestream-web-ux-conventions.md +0 -31
- package/overlays/obj-configurator/README.md +0 -20
- package/overlays/obj-configurator/rules/obj-project-rules.md +0 -31
- package/overlays/obj-configurator/skills/develop-obj-feature/SKILL.md +1 -0
- package/overlays/r3f-stack/README.md +0 -20
- package/overlays/r3f-stack/rules/stub.md +0 -31
- package/overlays/r3f-stack/skills/debug-3d-scene/SKILL.md +4 -2
- package/overlays/r3f-stack/skills/integrate-r3f-three-legacy/SKILL.md +6 -5
- package/overlays/r3f-stack/skills/optimize-3d-assets/SKILL.md +4 -3
- package/overlays/real-estate-content/README.md +0 -20
- package/overlays/real-estate-content/roles/README.md +0 -20
- package/overlays/real-estate-content/rules/affiliate-links.md +0 -31
- package/overlays/real-estate-content/rules/content-schema.md +0 -31
- package/overlays/real-estate-content/rules/seo-baseline.md +0 -31
- package/overlays/real-estate-content/skills/write-real-estate-astro-data/SKILL.md +1 -0
- package/overlays/real-estate-content/workflows/README.md +0 -20
- package/overlays/security-research/README.md +0 -20
- package/overlays/security-research/rules/reverse-engineering-rules.md +0 -20
- package/overlays/seo-publishing/README.md +1 -21
- package/overlays/seo-publishing/rules/publish-log-conventions.md +0 -31
- package/overlays/seo-publishing/rules/publishing-cadence.md +0 -31
- package/overlays/seo-publishing/rules/site-mix-and-cannibalization.md +0 -31
- package/overlays/seo-publishing/rules/topic-board-template.md +0 -31
- package/overlays/ui-design-system/README.md +0 -20
- package/overlays/ui-design-system/rules/handoff-conventions.md +0 -31
- package/package.json +2 -2
- package/packs/README.md +3 -9
- package/packs/ecommerce-team/manifest.yaml +1 -1
- package/core/skills/commerce/2026_STANDARDS_SUMMARY.md +0 -316
- package/core/skills/commerce/handle-checkout-flow/UPGRADE_PLAN_2026.md +0 -99
- package/core/skills/commerce/integrate-payment-gateway/UPGRADE_PLAN_2026.md +0 -128
- package/core/skills/commerce/manage-order-fulfillment/UPGRADE_PLAN_2026.md +0 -136
- package/core/skills/commerce/manage-product-catalog/UPGRADE_PLAN_2026.md +0 -130
- package/core/skills/education/2026_STANDARDS_SUMMARY.md +0 -290
- package/core/skills/education/create-exercises/UPGRADE_PLAN_2026.md +0 -115
- package/core/skills/education/design-learning-plan/UPGRADE_PLAN_2026.md +0 -140
- package/core/skills/education/grade-and-review/UPGRADE_PLAN_2026.md +0 -141
- package/core/skills/frontend/2026_STANDARDS_SUMMARY.md +0 -345
- package/core/skills/frontend/add-page-route/UPGRADE_PLAN_2026.md +0 -102
- package/core/skills/frontend/add-ui-component/UPGRADE_PLAN_2026.md +0 -114
- package/core/skills/frontend/component-composition/UPGRADE_PLAN_2026.md +0 -103
- package/core/skills/frontend/frontend-testing/UPGRADE_PLAN_2026.md +0 -137
- package/core/skills/frontend/implement-view-transitions/UPGRADE_PLAN_2026.md +0 -118
- package/core/skills/frontend/implement-webmcp/UPGRADE_PLAN_2026.md +0 -108
- package/core/skills/frontend/integrate-api-client/UPGRADE_PLAN_2026.md +0 -118
- package/core/skills/frontend/setup-design-system/UPGRADE_PLAN_2026.md +0 -123
- package/core/skills/frontend/setup-visual-regression/UPGRADE_PLAN_2026.md +0 -121
- package/core/skills/meetings-analysis/2026_STANDARDS_SUMMARY.md +0 -236
- package/core/skills/meetings-analysis/analyze-business-requirements/UPGRADE_PLAN_2026.md +0 -97
- package/core/skills/meetings-analysis/analyze-data/UPGRADE_PLAN_2026.md +0 -143
- package/core/skills/meetings-analysis/meeting-review/UPGRADE_PLAN_2026.md +0 -125
- package/core/skills/mobile/2026_STANDARDS_SUMMARY.md +0 -209
- package/core/skills/mobile/deploy-mobile-app/UPGRADE_PLAN_2026.md +0 -122
- package/core/skills/mobile/develop-mobile-app/UPGRADE_PLAN_2026.md +0 -141
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Contract Testing, Chaos Injection & Concurrency Verification — Reference
|
|
2
|
+
|
|
3
|
+
This reference documents 2027 testing standards for resilient distributed systems: Consumer-Driven Contract Testing (PactV3), in-test network chaos injection (Toxiproxy), Circuit Breaker state verification, and strict goroutine leak detection (`goleak`).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Consumer-Driven Contract Testing (PactV3)
|
|
8
|
+
|
|
9
|
+
Consumer-Driven Contract Testing eliminates breaking API changes between microservices without requiring brittle end-to-end multi-service test environments.
|
|
10
|
+
|
|
11
|
+
### 1.1 Core Principles
|
|
12
|
+
1. **Consumer-Driven**: The client (consumer) defines expectations for endpoints, query params, headers, and payload structures.
|
|
13
|
+
2. **Flexible Structural Matching**: Contracts assert data types and shape using PactV3 matchers (`like`, `eachLike`, `regex`) rather than hardcoded mock values.
|
|
14
|
+
3. **Provider State Isolation**: Providers set up isolated test fixtures based on a declared `providerState` before verifying interactions.
|
|
15
|
+
|
|
16
|
+
### 1.2 TypeScript PactV3 Consumer Contract Specification
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { PactV3, MatchersV3 } from "@pact-foundation/pact";
|
|
20
|
+
import { PaymentClient } from "../clients/payment";
|
|
21
|
+
|
|
22
|
+
const { like, eachLike, regex } = MatchersV3;
|
|
23
|
+
|
|
24
|
+
const provider = new PactV3({
|
|
25
|
+
consumer: "order-service",
|
|
26
|
+
provider: "payment-service",
|
|
27
|
+
dir: "./pacts"
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("fetches payment transaction details by transaction ID", async () => {
|
|
31
|
+
await provider
|
|
32
|
+
.given("payment txn_12345 exists and is settled")
|
|
33
|
+
.uponReceiving("a request for payment txn_12345")
|
|
34
|
+
.withRequest({
|
|
35
|
+
method: "GET",
|
|
36
|
+
path: "/v1/payments/txn_12345",
|
|
37
|
+
headers: { Accept: "application/json" }
|
|
38
|
+
})
|
|
39
|
+
.willRespondWith({
|
|
40
|
+
status: 200,
|
|
41
|
+
headers: { "Content-Type": "application/json" },
|
|
42
|
+
body: {
|
|
43
|
+
paymentId: like("txn_12345"),
|
|
44
|
+
status: regex("SETTLED|AUTHORIZED", "SETTLED"),
|
|
45
|
+
amountCents: like(10000),
|
|
46
|
+
currency: regex("^[A-Z]{3}$", "USD"),
|
|
47
|
+
lineItems: eachLike({
|
|
48
|
+
itemId: like("item_abc"),
|
|
49
|
+
quantity: like(1)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.executeTest(async (mockServer) => {
|
|
54
|
+
const client = new PaymentClient(mockServer.url);
|
|
55
|
+
const res = await client.getPayment("txn_12345");
|
|
56
|
+
expect(res.paymentId).toBe("txn_12345");
|
|
57
|
+
expect(res.status).toBe("SETTLED");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. In-Test Chaos Injection via Toxiproxy
|
|
65
|
+
|
|
66
|
+
Unit tests with in-memory mocks fail to verify real-world transport failure handling. Toxiproxy simulates production network faults deterministically in local integration tests.
|
|
67
|
+
|
|
68
|
+
### 2.1 Toxic Types & Failure Modes
|
|
69
|
+
- **`latency`**: Adds simulated latency and jitter (e.g., 2000ms ± 500ms) to trigger timeouts and race conditions.
|
|
70
|
+
- **`reset_peer`**: Simulates TCP RST packets or abrupt network disconnects mid-stream.
|
|
71
|
+
- **`bandwidth`**: Limits downstream or upstream throughput (e.g., 10 KB/s) to simulate mobile packet loss or network degradation.
|
|
72
|
+
- **`slicer`**: Slices TCP packets into small chunks with delays to test socket streaming parsers.
|
|
73
|
+
|
|
74
|
+
### 2.2 Go In-Test Toxiproxy Walkthrough
|
|
75
|
+
|
|
76
|
+
```go
|
|
77
|
+
package chaos_test
|
|
78
|
+
|
|
79
|
+
import (
|
|
80
|
+
"context"
|
|
81
|
+
"testing"
|
|
82
|
+
"time"
|
|
83
|
+
|
|
84
|
+
toxiproxy "github.com/Shopify/toxiproxy/v2/client"
|
|
85
|
+
"github.com/stretchr/testify/assert"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
func TestClientCircuitBreakerUnderNetworkChaos(t *testing.T) {
|
|
89
|
+
toxiClient := toxiproxy.NewClient("localhost:8474")
|
|
90
|
+
|
|
91
|
+
// Create proxy between payment client and downstream mock server
|
|
92
|
+
proxy, err := toxiClient.CreateProxy("payment_proxy", "localhost:28080", "localhost:18080")
|
|
93
|
+
assert.NoError(t, err)
|
|
94
|
+
defer proxy.Delete()
|
|
95
|
+
|
|
96
|
+
// 1. Inject high latency toxic (simulate 3000ms delay)
|
|
97
|
+
toxic, err := proxy.AddToxic("slow_network", "latency", "downstream", 1.0, toxiproxy.Attributes{
|
|
98
|
+
"latency": 3000,
|
|
99
|
+
"jitter": 200,
|
|
100
|
+
})
|
|
101
|
+
assert.NoError(t, err)
|
|
102
|
+
|
|
103
|
+
client := NewResilientClient("http://localhost:28080", 500*time.Millisecond)
|
|
104
|
+
|
|
105
|
+
// 2. Client timeout triggers
|
|
106
|
+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
|
107
|
+
defer cancel()
|
|
108
|
+
|
|
109
|
+
_, err = client.ExecuteRequest(ctx)
|
|
110
|
+
assert.ErrorIs(t, err, context.DeadlineExceeded)
|
|
111
|
+
|
|
112
|
+
// 3. Remove toxic and verify automatic recovery
|
|
113
|
+
assert.NoError(t, proxy.RemoveToxic(toxic.Name))
|
|
114
|
+
resp, err := client.ExecuteRequest(context.Background())
|
|
115
|
+
assert.NoError(t, err)
|
|
116
|
+
assert.Equal(t, 200, resp.StatusCode)
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 3. Circuit Breaker State Transition Testing
|
|
123
|
+
|
|
124
|
+
A circuit breaker prevents cascading microservice failures by failing fast when a dependency degrades.
|
|
125
|
+
|
|
126
|
+
### 3.1 State Machine Specification
|
|
127
|
+
```
|
|
128
|
+
┌──────────────────────────────────────┐
|
|
129
|
+
│ │ Success count >= threshold
|
|
130
|
+
▼ │
|
|
131
|
+
┌───────────┐ Failure threshold reached ┌───────────┐
|
|
132
|
+
│ CLOSED ├───────────────────────────────►│ OPEN │
|
|
133
|
+
│ (Normal) │ │(Fast-Fail)│
|
|
134
|
+
└─────▲─────┘ └─────┬─────┘
|
|
135
|
+
│ │
|
|
136
|
+
│ Success Timeout expires│
|
|
137
|
+
│ │
|
|
138
|
+
│ ┌───────────┐ │
|
|
139
|
+
└──────────────┤ HALF-OPEN │◄────────────────┘
|
|
140
|
+
│ (Probing) │
|
|
141
|
+
└─────┬─────┘
|
|
142
|
+
│ Failure
|
|
143
|
+
▼
|
|
144
|
+
(Back to OPEN)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 3.2 Verification Protocol
|
|
148
|
+
1. **Transition to OPEN**: Fire $N$ consecutive simulated failure requests (e.g. 5 failures within 10 seconds). Assert that subsequent requests fail immediately without invoking the network (`ErrCircuitOpen`).
|
|
149
|
+
2. **Transition to HALF-OPEN**: Advance virtual or real clock past the sleep window (e.g. 5 seconds). Assert the breaker permits a single probe request.
|
|
150
|
+
3. **Transition to CLOSED**: Assert that successful probe resets failure counters and restores normal traffic.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 4. Concurrency & Goroutine Leak Assertions
|
|
155
|
+
|
|
156
|
+
Data races and goroutine leaks in asynchronous services cause memory starvation and mysterious production deadlocks.
|
|
157
|
+
|
|
158
|
+
### 4.1 Race Detection
|
|
159
|
+
Run all test suites with the race detector enabled:
|
|
160
|
+
```bash
|
|
161
|
+
go test -v -race -count=1 ./...
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 4.2 Leak Detection with `uber-go/goleak`
|
|
165
|
+
Enforce that no background goroutines linger after test teardown:
|
|
166
|
+
|
|
167
|
+
```go
|
|
168
|
+
package integration_test
|
|
169
|
+
|
|
170
|
+
import (
|
|
171
|
+
"testing"
|
|
172
|
+
"go.uber.org/goleak"
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
func TestMain(m *testing.M) {
|
|
176
|
+
// Verify zero leaked goroutines across all package tests
|
|
177
|
+
goleak.VerifyTestMain(m)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
func TestWorkerPoolShutdown(t *testing.T) {
|
|
181
|
+
defer goleak.VerifyNone(t)
|
|
182
|
+
|
|
183
|
+
pool := NewWorkerPool(4)
|
|
184
|
+
pool.Submit(func() { /* task */ })
|
|
185
|
+
pool.Shutdown() // Must cancel all internal worker loops
|
|
186
|
+
}
|
|
187
|
+
```
|
|
@@ -126,6 +126,22 @@
|
|
|
126
126
|
],
|
|
127
127
|
"version": "1.0.0"
|
|
128
128
|
},
|
|
129
|
+
{
|
|
130
|
+
"name": "implement-ai-disclosure",
|
|
131
|
+
"description": "Implement EU AI Act Article 50 transparency components — <AIDisclosureBanner>, data-ai-generated attributes, C2PA metadata embedding for AI media, and DOMPurify sanitization for AI-generated content. Use when deploying user-facing AI features, chatbots, generative content, or any system requiring AI disclosure per EU AI Act (effective 2 August 2026, C2PA deadline 2 December 2026).",
|
|
132
|
+
"allowed-tools": [
|
|
133
|
+
"read_file",
|
|
134
|
+
"write_file",
|
|
135
|
+
"edit_file",
|
|
136
|
+
"create_file",
|
|
137
|
+
"search_code",
|
|
138
|
+
"run_tests",
|
|
139
|
+
"run_linter",
|
|
140
|
+
"run_build",
|
|
141
|
+
"execute_command"
|
|
142
|
+
],
|
|
143
|
+
"version": "1.0.0"
|
|
144
|
+
},
|
|
129
145
|
{
|
|
130
146
|
"name": "implement-view-transitions",
|
|
131
147
|
"description": "Implement fluid, native-feeling page and state transitions using CSS View Transitions API, React 19 ViewTransition, Next.js App Router transitions, and shared element morphing without degrading Core Web Vitals. Use when adding route animations, shared element transitions, or layout morphs.",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: add-page-route
|
|
3
3
|
description: Add or modify a page, screen, or route by following the repo's navigation, data-loading, layout, and auth patterns. Use when frontend work requires new route-level behavior or page wiring.
|
|
4
|
+
version: "1.0.0"
|
|
4
5
|
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, run_dev_server, execute_command]
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -26,12 +27,11 @@ Use this skill when a frontend change needs a new page, screen, or route-level f
|
|
|
26
27
|
- preserve navigation and deep-link behavior
|
|
27
28
|
- update route-aware tests when the page contract changes
|
|
28
29
|
- if any code in this change was AI-generated, validate it per the risk tier defined in the frontend-developer role before accepting
|
|
29
|
-
-
|
|
30
|
-
- **hoist route data loading to
|
|
31
|
-
- **RSC leaf pattern
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
- for AI-generated routes: verify auth guard completeness (AI frequently omits auth wrappers), data loading pattern match, cache invalidation on mutations, and URL parameter validation before merging
|
|
30
|
+
- validate all URL search parameters with Zod `.catch()` fallbacks at the route boundary (`validateSearch` in TanStack Router, `searchParams` parser in Next.js/React Router/Astro) — raw URL parameters are untrusted input
|
|
31
|
+
- **hoist route data loading to server/route loaders** — do not trigger primary data fetches in `useEffect` after mount (causes layout shift waterfalls); use RSC/Next.js Server Components, TanStack Start `createServerFn`, or Astro SSR endpoints matching the repo stack
|
|
32
|
+
- **RSC leaf pattern** (when using React Server Components): push `"use client"` as deep as possible and verify only JSON-serializable props cross the boundary
|
|
33
|
+
- use type-safe navigation primitives matching the router (`<Link>`, `navigate({ to })`); never use untyped string concatenation
|
|
34
|
+
- for AI-generated routes: verify auth guard completeness inside both route loaders and Server Actions, cache invalidation on mutations, and URL parameter validation before merging
|
|
35
35
|
- for route animations and page morphs, leverage skill: `implement-view-transitions` using native CSS View Transitions or React 19 ViewTransition; ensure navigation transitions do not block the main thread or degrade INP (< 200ms)
|
|
36
36
|
|
|
37
37
|
## Suggested Process
|
|
@@ -105,7 +105,7 @@ Cover:
|
|
|
105
105
|
- [ ] RSC leaf pattern enforced: `"use client"` pushed to leaves
|
|
106
106
|
- [ ] data loading hoisted to loaders / Server Functions (no `useEffect` primary fetches)
|
|
107
107
|
- [ ] type-safe navigation: `<Link to="..." />`, `navigate({ to: '...' })` only
|
|
108
|
-
- [ ] URL search params validated with Zod `.catch()` fallbacks
|
|
108
|
+
- [ ] URL search params validated with Zod `.catch()` fallbacks (via `validateSearch` or `searchParams` parser)
|
|
109
109
|
- [ ] CSS View Transitions: composited properties only, INP < 200ms, reduced motion
|
|
110
110
|
- [ ] React 19 `ViewTransition` boundaries: `default="none"`, wrap before DOM nodes, unique dynamic names
|
|
111
111
|
- [ ] AI-generated route audit: auth guards complete, loader pattern matched, cache invalidation on mutations, URL params validated
|
|
@@ -150,5 +150,7 @@ Skip emission for solo refactor work where no downstream handoff is expected.
|
|
|
150
150
|
- **accessibility-review**: Check route-level a11y (focus management, navigation announcements)
|
|
151
151
|
- **navigate-service**: Understand existing frontend structure before wiring routes
|
|
152
152
|
- **commit-code**: Prepare the route change for delivery
|
|
153
|
+
- Companion reference: `references/rsc-routing-and-view-transitions.md`
|
|
154
|
+
- Companion example: `examples/streaming-rsc-page-with-view-transition.tsx`
|
|
153
155
|
|
|
154
|
-
Last updated: 2026-
|
|
156
|
+
Last updated: 2026-11-08
|
package/core/skills/frontend/add-page-route/examples/streaming-rsc-page-with-view-transition.tsx
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming RSC Page with View Transitions (Next.js 15 / React 19)
|
|
3
|
+
*
|
|
4
|
+
* Implements:
|
|
5
|
+
* - Server Component data hoisting with React Suspense streaming
|
|
6
|
+
* - Zod search parameter validation with resilient .catch() fallbacks
|
|
7
|
+
* - Leaf Client Component with CSS View Transition trigger
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React, { Suspense, startTransition } from 'react';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
// 1. Zod URL Search Parameter Schema
|
|
14
|
+
export const searchParamsSchema = z.object({
|
|
15
|
+
tab: z.enum(['overview', 'analytics', 'audit']).catch('overview'),
|
|
16
|
+
page: z.coerce.number().int().min(1).catch(1),
|
|
17
|
+
q: z.string().trim().max(100).catch(''),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type ValidatedSearchParams = z.infer<typeof searchParamsSchema>;
|
|
21
|
+
|
|
22
|
+
// Mock data fetcher running server-side
|
|
23
|
+
async function fetchMetricData(tab: string, page: number) {
|
|
24
|
+
// Simulate database latency
|
|
25
|
+
await new Promise((resolve) => setTimeout(resolve, 80));
|
|
26
|
+
return [
|
|
27
|
+
{ id: '1', title: `Metric A (${tab})`, value: page * 1420 },
|
|
28
|
+
{ id: '2', title: `Metric B (${tab})`, value: page * 890 },
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 2. Client Leaf Component: View Transition Tab Navigation
|
|
33
|
+
export function ViewTransitionNavLeaf({ currentTab }: { currentTab: string }) {
|
|
34
|
+
const tabs = ['overview', 'analytics', 'audit'];
|
|
35
|
+
|
|
36
|
+
const handleTabChange = (nextTab: string) => {
|
|
37
|
+
if (!document.startViewTransition) {
|
|
38
|
+
window.location.search = `?tab=${nextTab}`;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
document.startViewTransition(() => {
|
|
43
|
+
startTransition(() => {
|
|
44
|
+
const url = new URL(window.location.href);
|
|
45
|
+
url.searchParams.set('tab', nextTab);
|
|
46
|
+
window.history.pushState({}, '', url.toString());
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<nav className="flex space-x-2 border-b border-border pb-2" aria-label="Route Tabs">
|
|
53
|
+
{tabs.map((tab) => {
|
|
54
|
+
const isActive = tab === currentTab;
|
|
55
|
+
return (
|
|
56
|
+
<button
|
|
57
|
+
key={tab}
|
|
58
|
+
type="button"
|
|
59
|
+
onClick={() => handleTabChange(tab)}
|
|
60
|
+
style={{ viewTransitionName: isActive ? 'active-tab-indicator' : undefined }}
|
|
61
|
+
className={`px-4 py-2 text-sm font-medium rounded-md transition-transform active:scale-[0.98] ${
|
|
62
|
+
isActive
|
|
63
|
+
? 'bg-primary text-primary-foreground shadow-sm'
|
|
64
|
+
: 'text-muted-foreground hover:bg-muted hover:text-foreground'
|
|
65
|
+
}`}
|
|
66
|
+
>
|
|
67
|
+
{tab.charAt(0).toUpperCase() + tab.slice(1)}
|
|
68
|
+
</button>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</nav>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 3. Streaming Server Data Component
|
|
76
|
+
async function MetricDataList({ tab, page }: { tab: string; page: number }) {
|
|
77
|
+
const metrics = await fetchMetricData(tab, page);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<ul className="mt-4 grid gap-4 sm:grid-cols-2" role="list">
|
|
81
|
+
{metrics.map((m) => (
|
|
82
|
+
<li
|
|
83
|
+
key={m.id}
|
|
84
|
+
className="p-4 rounded-xl border border-border bg-card shadow-sm hover:border-primary/50 transition-colors"
|
|
85
|
+
>
|
|
86
|
+
<h3 className="text-sm font-medium text-muted-foreground">{m.title}</h3>
|
|
87
|
+
<p className="mt-2 text-2xl font-bold tracking-tight text-foreground">
|
|
88
|
+
{m.value.toLocaleString()}
|
|
89
|
+
</p>
|
|
90
|
+
</li>
|
|
91
|
+
))}
|
|
92
|
+
</ul>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 4. Root React Server Component Page
|
|
97
|
+
export default async function AnalyticsRoutePage({
|
|
98
|
+
searchParams,
|
|
99
|
+
}: {
|
|
100
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
101
|
+
}) {
|
|
102
|
+
const rawParams = await searchParams;
|
|
103
|
+
const validated = searchParamsSchema.parse({
|
|
104
|
+
tab: typeof rawParams.tab === 'string' ? rawParams.tab : undefined,
|
|
105
|
+
page: typeof rawParams.page === 'string' ? rawParams.page : undefined,
|
|
106
|
+
q: typeof rawParams.q === 'string' ? rawParams.q : undefined,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<main className="container mx-auto px-4 py-8 min-h-[100dvh]">
|
|
111
|
+
<header className="mb-6">
|
|
112
|
+
<h1 className="text-3xl font-extrabold tracking-tight">System Performance Metrics</h1>
|
|
113
|
+
<p className="text-muted-foreground text-sm mt-1">
|
|
114
|
+
Real-time telemetry with React 19 RSC streaming and off-thread View Transitions.
|
|
115
|
+
</p>
|
|
116
|
+
</header>
|
|
117
|
+
|
|
118
|
+
{/* Interactive Client Leaf */}
|
|
119
|
+
<ViewTransitionNavLeaf currentTab={validated.tab} />
|
|
120
|
+
|
|
121
|
+
{/* Streaming Asynchronous Server Component */}
|
|
122
|
+
<Suspense
|
|
123
|
+
fallback={
|
|
124
|
+
<div className="mt-6 flex items-center justify-center p-8 text-muted-foreground">
|
|
125
|
+
<span className="animate-pulse">Streaming metric data...</span>
|
|
126
|
+
</div>
|
|
127
|
+
}
|
|
128
|
+
>
|
|
129
|
+
<MetricDataList tab={validated.tab} page={validated.page} />
|
|
130
|
+
</Suspense>
|
|
131
|
+
</main>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# React 19 RSC Routing & View Transitions Architecture (2026)
|
|
2
|
+
|
|
3
|
+
## 1. React Server Component (RSC) Leaf Architecture
|
|
4
|
+
|
|
5
|
+
### 1.1 Data Hoisting & Boundary Isolation
|
|
6
|
+
In React 19 and Next.js 15+ App Router, routes enforce strict separation between data fetching and interactive presentation:
|
|
7
|
+
- **Server Component Root**: All data fetching, auth verification, and database reads occur in async Server Components at the route root.
|
|
8
|
+
- **Client Leaf Boundary**: The `"use client"` directive must be pushed down to terminal UI leaves (buttons, interactive filter inputs, modals).
|
|
9
|
+
- **Waterfall Elimination**: Avoid fetching primary page data inside client-side `useEffect` hooks, which causes layout shift waterfalls and Cumulative Layout Shift (CLS) regressions.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 2. Type-Safe Route Validation (TanStack Router & Next.js)
|
|
14
|
+
|
|
15
|
+
### 2.1 Untrusted Query Parameters
|
|
16
|
+
URL search parameters are user-controlled inputs subject to tampering:
|
|
17
|
+
- Every query parameter must be validated with Zod schemas.
|
|
18
|
+
- Use `.catch()` fallbacks to supply safe defaults instead of failing hard on malformed inputs:
|
|
19
|
+
```typescript
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
|
|
22
|
+
export const searchSchema = z.object({
|
|
23
|
+
page: z.coerce.number().int().positive().catch(1),
|
|
24
|
+
filter: z.enum(['all', 'active', 'archived']).catch('all'),
|
|
25
|
+
query: z.string().trim().max(100).catch(''),
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 3. CSS View Transitions & React 19 `ViewTransition`
|
|
32
|
+
|
|
33
|
+
### 3.1 Off-Thread Composited Motion
|
|
34
|
+
Route animations must never trigger layout recalculation during transitions:
|
|
35
|
+
- Restrict animated CSS properties to `transform` and `opacity`.
|
|
36
|
+
- Target Interaction to Next Paint (INP) budget of `< 200ms` with DOM mutation callbacks `< 50ms`.
|
|
37
|
+
- Wrap route mutations in `React.startTransition()`:
|
|
38
|
+
```tsx
|
|
39
|
+
import { startTransition } from 'react';
|
|
40
|
+
|
|
41
|
+
function onNavigate(nextUrl: string) {
|
|
42
|
+
if (!document.startViewTransition) {
|
|
43
|
+
router.push(nextUrl);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
document.startViewTransition(() => {
|
|
47
|
+
startTransition(() => {
|
|
48
|
+
router.push(nextUrl);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
- **Accessibility Invariant**:
|
|
54
|
+
```css
|
|
55
|
+
@media (prefers-reduced-motion: reduce) {
|
|
56
|
+
::view-transition-group(*),
|
|
57
|
+
::view-transition-old(*),
|
|
58
|
+
::view-transition-new(*) {
|
|
59
|
+
animation: none !important;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 4. AI Route Audit Checklist
|
|
67
|
+
|
|
68
|
+
Before accepting AI-generated route code, verify:
|
|
69
|
+
- [ ] Auth guard completeness: Route wraps access control or verifies session before server reads.
|
|
70
|
+
- [ ] Loader hoisting: Data loading occurs at server root, not in client hooks.
|
|
71
|
+
- [ ] Cache revalidation: Mutating actions call `revalidatePath` or `router.invalidate()`.
|
|
72
|
+
- [ ] Safe parameters: Query/path parameters validated against Zod schemas with fallbacks.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: add-ui-component
|
|
3
3
|
description: Add or evolve a reusable UI component by following the repo's design system, composition patterns, accessibility rules, and state boundaries. Use when building frontend components or shared presentation elements.
|
|
4
|
+
version: "1.0.0"
|
|
4
5
|
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, run_dev_server, execute_command]
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -158,5 +159,7 @@ Skip emission for solo exploratory UI work with no planned handoff.
|
|
|
158
159
|
- **design-ux-flow**: Upstream ux-flow-spec and ui-component-spec from UI/UX Designer
|
|
159
160
|
- **commit-code**: Prepare the component change for delivery
|
|
160
161
|
- **develop-mobile-app**: Build high-performance React Native / Expo UI components with FlashList virtualization and Reanimated motion
|
|
162
|
+
- Companion reference: `references/react19-component-standards-and-anti-slop.md`
|
|
163
|
+
- Companion example: `examples/compound-dialog-and-form-actions.tsx`
|
|
161
164
|
|
|
162
|
-
Last updated: 2026-
|
|
165
|
+
Last updated: 2026-11-08
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compound Accessible Dialog with React 19 Form Actions
|
|
3
|
+
*
|
|
4
|
+
* Implements:
|
|
5
|
+
* - Compound component architecture with Radix-style asChild slot delegation
|
|
6
|
+
* - React 19 useActionState form mutation with optimistic UI updates
|
|
7
|
+
* - Anti-slop finish mechanics: tactile scale-[0.98], whitespace-nowrap CTA
|
|
8
|
+
* - WCAG 2.2 keyboard trap, Escape dismissal, and focus restoration
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, {
|
|
12
|
+
createContext,
|
|
13
|
+
useContext,
|
|
14
|
+
useState,
|
|
15
|
+
useActionState,
|
|
16
|
+
useOptimistic,
|
|
17
|
+
ReactNode,
|
|
18
|
+
} from 'react';
|
|
19
|
+
|
|
20
|
+
// --- Context & Compound Primitives ---
|
|
21
|
+
|
|
22
|
+
interface DialogContextValue {
|
|
23
|
+
isOpen: boolean;
|
|
24
|
+
setIsOpen: (open: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DialogContext = createContext<DialogContextValue | null>(null);
|
|
28
|
+
|
|
29
|
+
function useDialogContext() {
|
|
30
|
+
const ctx = useContext(DialogContext);
|
|
31
|
+
if (!ctx) throw new Error('Dialog components must be rendered within Dialog.Root');
|
|
32
|
+
return ctx;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function DialogRoot({ children }: { children: ReactNode }) {
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
return (
|
|
38
|
+
<DialogContext.Provider value={{ isOpen, setIsOpen }}>
|
|
39
|
+
{children}
|
|
40
|
+
</DialogContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function DialogTrigger({
|
|
45
|
+
asChild,
|
|
46
|
+
children,
|
|
47
|
+
}: {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
children: React.ReactElement<{ onClick?: () => void }>;
|
|
50
|
+
}) {
|
|
51
|
+
const { setIsOpen } = useDialogContext();
|
|
52
|
+
if (asChild && React.isValidElement(children)) {
|
|
53
|
+
return React.cloneElement(children, {
|
|
54
|
+
onClick: () => {
|
|
55
|
+
children.props.onClick?.();
|
|
56
|
+
setIsOpen(true);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
onClick={() => setIsOpen(true)}
|
|
64
|
+
className="px-4 py-2 font-medium text-sm rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 active:scale-[0.98] transition-transform whitespace-nowrap"
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</button>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function DialogContent({
|
|
72
|
+
title,
|
|
73
|
+
children,
|
|
74
|
+
}: {
|
|
75
|
+
title: string;
|
|
76
|
+
children: ReactNode;
|
|
77
|
+
}) {
|
|
78
|
+
const { isOpen, setIsOpen } = useDialogContext();
|
|
79
|
+
if (!isOpen) return null;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
role="dialog"
|
|
84
|
+
aria-modal="true"
|
|
85
|
+
aria-labelledby="dialog-title"
|
|
86
|
+
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm"
|
|
87
|
+
onKeyDown={(e) => {
|
|
88
|
+
if (e.key === 'Escape') setIsOpen(false);
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<div className="w-full max-w-lg rounded-2xl border border-border bg-card p-6 shadow-xl animate-in fade-in zoom-in-95 duration-150">
|
|
92
|
+
<div className="flex items-center justify-between pb-4 border-b border-border">
|
|
93
|
+
<h2 id="dialog-title" className="text-lg font-semibold text-foreground">
|
|
94
|
+
{title}
|
|
95
|
+
</h2>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
onClick={() => setIsOpen(false)}
|
|
99
|
+
aria-label="Close dialog"
|
|
100
|
+
className="rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted active:scale-[0.98]"
|
|
101
|
+
>
|
|
102
|
+
✕
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
<div className="mt-4">{children}</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// --- React 19 Form Action Component Example ---
|
|
112
|
+
|
|
113
|
+
async function updateProfileServerAction(
|
|
114
|
+
prevState: { success: boolean; message: string },
|
|
115
|
+
formData: FormData
|
|
116
|
+
) {
|
|
117
|
+
const displayName = formData.get('displayName') as string;
|
|
118
|
+
// Simulate network mutation
|
|
119
|
+
await new Promise((r) => setTimeout(r, 120));
|
|
120
|
+
return { success: true, message: `Profile updated to: ${displayName}` };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function ProfileEditDialog() {
|
|
124
|
+
const [state, formAction, isPending] = useActionState(updateProfileServerAction, {
|
|
125
|
+
success: false,
|
|
126
|
+
message: '',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const [optimisticName, setOptimisticName] = useOptimistic(
|
|
130
|
+
'Alex Developer',
|
|
131
|
+
(_current, newName: string) => newName
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<DialogRoot>
|
|
136
|
+
<DialogTrigger asChild>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
className="px-4 py-2 font-medium text-sm rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 active:scale-[0.98] transition-transform whitespace-nowrap"
|
|
140
|
+
>
|
|
141
|
+
Edit Profile ({optimisticName})
|
|
142
|
+
</button>
|
|
143
|
+
</DialogTrigger>
|
|
144
|
+
|
|
145
|
+
<DialogContent title="Edit Public Profile">
|
|
146
|
+
<form
|
|
147
|
+
action={async (formData: FormData) => {
|
|
148
|
+
const nextName = formData.get('displayName') as string;
|
|
149
|
+
setOptimisticName(nextName);
|
|
150
|
+
await formAction(formData);
|
|
151
|
+
}}
|
|
152
|
+
className="space-y-4"
|
|
153
|
+
>
|
|
154
|
+
<div>
|
|
155
|
+
<label htmlFor="displayName" className="block text-sm font-medium text-foreground">
|
|
156
|
+
Display Name
|
|
157
|
+
</label>
|
|
158
|
+
<input
|
|
159
|
+
id="displayName"
|
|
160
|
+
name="displayName"
|
|
161
|
+
type="text"
|
|
162
|
+
defaultValue={optimisticName}
|
|
163
|
+
required
|
|
164
|
+
className="mt-1 block w-full rounded-lg border border-input bg-background px-3 py-2 text-sm text-foreground shadow-sm focus:border-primary focus:ring-2 focus:ring-primary/20"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
{state.message && (
|
|
169
|
+
<p className="text-sm font-medium text-emerald-600 dark:text-emerald-400">
|
|
170
|
+
{state.message}
|
|
171
|
+
</p>
|
|
172
|
+
)}
|
|
173
|
+
|
|
174
|
+
<div className="flex justify-end space-x-3 pt-2">
|
|
175
|
+
<button
|
|
176
|
+
type="submit"
|
|
177
|
+
disabled={isPending}
|
|
178
|
+
className="px-4 py-2 font-medium text-sm rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 active:scale-[0.98] transition-transform whitespace-nowrap disabled:opacity-50"
|
|
179
|
+
>
|
|
180
|
+
{isPending ? 'Saving...' : 'Save Profile'}
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
|
+
</form>
|
|
184
|
+
</DialogContent>
|
|
185
|
+
</DialogRoot>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const Dialog = {
|
|
190
|
+
Root: DialogRoot,
|
|
191
|
+
Trigger: DialogTrigger,
|
|
192
|
+
Content: DialogContent,
|
|
193
|
+
};
|