@vesviet/agent-skills 5.8.0 → 5.10.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 +8 -7
- package/README.md +3 -2
- package/VERSION +1 -1
- package/adapters/antigravity/ANTIGRAVITY.md +2 -2
- package/adapters/antigravity/INDEX_TIER1.json +68 -61
- package/adapters/antigravity/a2a-config.template.yaml +1 -1
- package/adapters/antigravity/role-skill-index.json +21 -12
- package/adapters/claude/CLAUDE_ADAPTER.md +1 -1
- package/adapters/claude/settings.template.json +7 -3
- package/adapters/cursor/hooks.template.json +3 -1
- package/core/policies/action-boundaries.yaml +10 -1
- package/core/policies/mcp-tool-map.yaml +28 -0
- package/core/roles/README.md +1 -1
- package/core/roles/frontend-developer.md +1 -0
- package/core/roles/references/vietnam-accounting-specialist-review-checklist.md +6 -6
- package/core/roles/role-standard.md +8 -0
- package/core/roles/technical-architect.md +1 -0
- package/core/roles/vietnam-accounting-specialist.md +20 -20
- package/core/rules/code.md +11 -6
- package/core/skills/README.md +3 -2
- package/core/skills/agent/agent-memory-compaction/SKILL.md +27 -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/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/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/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 +1 -1
- 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 +1 -0
- package/core/skills/commerce/handle-checkout-flow/SKILL.md +3 -1
- 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 +3 -1
- 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 +3 -1
- 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 +3 -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/pdf/SKILL.md +1 -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/documentation/configure-llms-txt/SKILL.md +2 -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 +3 -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/foundation/ai-risk-assessment/SKILL.md +3 -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/conduct-research/SKILL.md +1 -1
- package/core/skills/foundation/discernment-nudge/SKILL.md +1 -0
- package/core/skills/foundation/plan-technical-delivery/SKILL.md +2 -1
- package/core/skills/foundation/release-notes/SKILL.md +2 -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 +5 -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 +3 -1
- 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 +3 -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 +2 -1
- package/core/skills/frontend/component-composition/examples/headless-combobox-compound-component.tsx +207 -0
- package/core/skills/frontend/frontend-testing/SKILL.md +3 -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 +118 -0
- package/core/skills/frontend/implement-webmcp/SKILL.md +3 -1
- 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 +3 -1
- 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/setup-design-system/SKILL.md +3 -1
- 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 +3 -1
- 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/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 +2 -0
- 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 +56 -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 +2 -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 +2 -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/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/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/setup-deployment/SKILL.md +4 -0
- 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/supply-chain-security/SKILL.md +2 -0
- 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/product/build-story-map/SKILL.md +2 -0
- package/core/skills/repo-ops/review-code/SKILL.md +2 -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 +1 -1
- 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 +7 -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 +2 -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 +2 -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/package.json +2 -2
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: implement-ai-disclosure
|
|
3
|
+
description: Implement EU AI Act Article 50 transparency components - AIDisclosureBanner, data-ai-generated attributes, C2PA metadata embedding for AI media, and DOMPurify sanitization. Use when deploying user-facing AI features, chatbots, generative content requiring EU AI Act compliance (effective 2 August 2026).
|
|
4
|
+
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Implement AI Disclosure
|
|
8
|
+
|
|
9
|
+
Implement EU AI Act Article 50 transparency components for legal compliance in EU market.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- deploying chatbots, virtual assistants, conversational AI
|
|
14
|
+
- implementing generative AI content (text, image, audio, video)
|
|
15
|
+
- building AI-enhanced UIs requiring transparency disclosure
|
|
16
|
+
- adding AI disclosure to existing features
|
|
17
|
+
|
|
18
|
+
## Core Rules
|
|
19
|
+
|
|
20
|
+
### EU AI Act Article 50 - Four Obligations (effective 2 Aug 2026)
|
|
21
|
+
|
|
22
|
+
| Obligation | Article | Description |
|
|
23
|
+
|------------|---------|-------------|
|
|
24
|
+
| AI Interaction Disclosure | 50(1) | Inform users they interact with AI (unless obvious) |
|
|
25
|
+
| AI Content Marking | 50(2) | Mark AI content in machine-readable format |
|
|
26
|
+
| Biometric Notification | 50(3) | Notify individuals of emotion/biometric systems |
|
|
27
|
+
| Deepfake Disclosure | 50(4) | Disclose deepfakes depicting real persons/places |
|
|
28
|
+
|
|
29
|
+
### C2PA Metadata (deadline 2 Dec 2026)
|
|
30
|
+
|
|
31
|
+
- Apply to AI-generated image, audio, video content
|
|
32
|
+
- Requires cryptographic metadata embedding
|
|
33
|
+
- Enables machine-readable AI detection
|
|
34
|
+
|
|
35
|
+
### Disclosure Components
|
|
36
|
+
|
|
37
|
+
1. **AIDisclosureBanner**: Display before first meaningful interaction, accessible (ARIA, screen reader)
|
|
38
|
+
2. **data-ai-generated attribute**: Apply to AI-generated content elements
|
|
39
|
+
3. **DOMPurify + Trusted Types**: Sanitize AI content before DOM insertion
|
|
40
|
+
|
|
41
|
+
## Implementation Patterns
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
// AIDisclosureBanner component
|
|
45
|
+
function ChatInterface() {
|
|
46
|
+
const [hasInteracted, setHasInteracted] = useState(false);
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
{!hasInteracted && (
|
|
50
|
+
<AIDisclosureBanner
|
|
51
|
+
message="This is an AI-powered assistant"
|
|
52
|
+
onAcknowledge={() => setHasInteracted(true)}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// AI content marking
|
|
60
|
+
<article data-ai-generated="true" data-ai-model={version}>
|
|
61
|
+
{sanitizedContent}
|
|
62
|
+
</article>
|
|
63
|
+
|
|
64
|
+
// DOMPurify sanitization
|
|
65
|
+
import DOMPurify from 'dompurify';
|
|
66
|
+
const sanitized = DOMPurify.sanitize(aiOutput);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Compliance Matrix
|
|
70
|
+
|
|
71
|
+
| Feature | 50(1) | 50(2) | 50(3) | 50(4) |
|
|
72
|
+
|---------|-------|-------|-------|-------|
|
|
73
|
+
| Chatbot | Required | - | - | - |
|
|
74
|
+
| AI text | - | Required | - | - |
|
|
75
|
+
| AI image/video | - | Required | - | If deepfake |
|
|
76
|
+
| Emotion recognition | - | - | Required | - |
|
|
77
|
+
|
|
78
|
+
## Suggested Process
|
|
79
|
+
|
|
80
|
+
1. **Classify AI Feature**: Identify applicable Article 50 obligations
|
|
81
|
+
2. **Design Components**: Create AIDisclosureBanner, content marking strategy
|
|
82
|
+
3. **Implement**: Add banner before interaction, apply data attributes, sanitize
|
|
83
|
+
4. **Test**: Verify banner appears, marks present, accessibility works
|
|
84
|
+
5. **Document**: Record compliance for audit
|
|
85
|
+
|
|
86
|
+
## Checklist
|
|
87
|
+
|
|
88
|
+
- [ ] Article 50 obligations identified
|
|
89
|
+
- [ ] AIDisclosureBanner component created
|
|
90
|
+
- [ ] Banner appears before first interaction
|
|
91
|
+
- [ ] Banner is accessible (ARIA, screen reader)
|
|
92
|
+
- [ ] data-ai-generated attribute applied
|
|
93
|
+
- [ ] DOMPurify sanitization implemented
|
|
94
|
+
- [ ] C2PA planned for media (Dec 2026)
|
|
95
|
+
- [ ] Compliance documented
|
|
96
|
+
|
|
97
|
+
## Output Contracts
|
|
98
|
+
|
|
99
|
+
- **`contracts/schemas/implementation-result.json`** — Emit implementation summary, touched files, and verification evidence when delivering Article 50 disclosure components across roles.
|
|
100
|
+
|
|
101
|
+
## Failure Modes
|
|
102
|
+
|
|
103
|
+
- Missing disclosure: Add CI/CD gate, verify before release
|
|
104
|
+
- XSS from AI content: Always sanitize with DOMPurify
|
|
105
|
+
- C2PA deadline miss: Track as separate work item
|
|
106
|
+
|
|
107
|
+
## Security Guardrails (OWASP ASI)
|
|
108
|
+
|
|
109
|
+
- ASI05: AI content is untrusted, always sanitize before DOM insertion
|
|
110
|
+
- ASI07: AI outputs from external services require validation
|
|
111
|
+
|
|
112
|
+
## Related Skills
|
|
113
|
+
|
|
114
|
+
- **accessibility-review**: Verify banner accessibility
|
|
115
|
+
- **implement-schema-markup**: Structured metadata for SEO
|
|
116
|
+
- **design-ux-flow**: User experience around disclosure
|
|
117
|
+
|
|
118
|
+
Last updated: 2026-11-16
|
|
@@ -117,5 +117,7 @@ Skip emission for trivial local experiments that do not cross a role boundary.
|
|
|
117
117
|
- **integrate-api-client**: Wire frontend client state and API communication behind WebMCP actions
|
|
118
118
|
- **frontend-testing**: Test WebMCP context emission and client-side action execution
|
|
119
119
|
- **security-audit**: Audit client-side context exposure and verify PII/secret protection
|
|
120
|
+
- Companion reference: `references/webmcp-architecture-and-hitl-security.md`
|
|
121
|
+
- Companion example: `examples/webmcp-provider-and-hitl-modal.tsx`
|
|
120
122
|
|
|
121
|
-
Last updated: 2026-
|
|
123
|
+
Last updated: 2026-11-08
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebMCP Client Provider with Human-in-the-Loop (HITL) Consent Modal
|
|
3
|
+
*
|
|
4
|
+
* Implements:
|
|
5
|
+
* - SSR-safe feature detection ('modelContext' in document)
|
|
6
|
+
* - Sanitized state mapping stripping confidential fields
|
|
7
|
+
* - Default-deny tool registration with strict JSON schemas
|
|
8
|
+
* - Fail-safe HITL confirmation modal with 60s timeout
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';
|
|
12
|
+
|
|
13
|
+
export interface WebMcpToolDefinition {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
isHighRisk: boolean;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: 'object';
|
|
19
|
+
properties: Record<string, { type: string; description: string }>;
|
|
20
|
+
required: string[];
|
|
21
|
+
};
|
|
22
|
+
handler: (args: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface HitlRequest {
|
|
26
|
+
toolName: string;
|
|
27
|
+
args: Record<string, unknown>;
|
|
28
|
+
resolve: (approved: boolean) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface WebMcpContextValue {
|
|
32
|
+
isAvailable: boolean;
|
|
33
|
+
registerTool: (tool: WebMcpToolDefinition) => void;
|
|
34
|
+
pendingHitl: HitlRequest | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const WebMcpContext = createContext<WebMcpContextValue | null>(null);
|
|
38
|
+
|
|
39
|
+
export function WebMcpProvider({ children }: { children: ReactNode }) {
|
|
40
|
+
const [isAvailable, setIsAvailable] = useState(false);
|
|
41
|
+
const [tools, setTools] = useState<Map<string, WebMcpToolDefinition>>(new Map());
|
|
42
|
+
const [pendingHitl, setPendingHitl] = useState<HitlRequest | null>(null);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
// 1. SSR-safe check
|
|
46
|
+
if (typeof window !== 'undefined' && 'modelContext' in document) {
|
|
47
|
+
setIsAvailable(true);
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
const registerTool = (tool: WebMcpToolDefinition) => {
|
|
52
|
+
// Validate schema
|
|
53
|
+
if (!tool.inputSchema.properties || Object.keys(tool.inputSchema.properties).length === 0) {
|
|
54
|
+
throw new Error(`Tool ${tool.name} must declare explicit properties in inputSchema`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setTools((prev) => new Map(prev).set(tool.name, tool));
|
|
58
|
+
|
|
59
|
+
// Register with in-browser modelContext if supported
|
|
60
|
+
if (typeof window !== 'undefined' && 'modelContext' in document) {
|
|
61
|
+
// @ts-expect-error modelContext experimental API
|
|
62
|
+
document.modelContext?.registerTool({
|
|
63
|
+
name: tool.name,
|
|
64
|
+
description: tool.description,
|
|
65
|
+
inputSchema: tool.inputSchema,
|
|
66
|
+
execute: async (args: Record<string, unknown>) => {
|
|
67
|
+
if (tool.isHighRisk) {
|
|
68
|
+
const approved = await new Promise<boolean>((resolve) => {
|
|
69
|
+
setPendingHitl({ toolName: tool.name, args, resolve });
|
|
70
|
+
});
|
|
71
|
+
if (!approved) {
|
|
72
|
+
return { error: { code: 'USER_REJECTED', message: 'Action rejected by user' } };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return await tool.handler(args);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<WebMcpContext.Provider value={{ isAvailable, registerTool, pendingHitl }}>
|
|
83
|
+
{children}
|
|
84
|
+
{pendingHitl && (
|
|
85
|
+
<HitlApprovalModal
|
|
86
|
+
request={pendingHitl}
|
|
87
|
+
onDecision={(decision) => {
|
|
88
|
+
pendingHitl.resolve(decision);
|
|
89
|
+
setPendingHitl(null);
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
</WebMcpContext.Provider>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function HitlApprovalModal({
|
|
98
|
+
request,
|
|
99
|
+
onDecision,
|
|
100
|
+
}: {
|
|
101
|
+
request: HitlRequest;
|
|
102
|
+
onDecision: (approved: boolean) => void;
|
|
103
|
+
}) {
|
|
104
|
+
const [timeLeft, setTimeLeft] = useState(60);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const timer = setInterval(() => {
|
|
108
|
+
setTimeLeft((prev) => {
|
|
109
|
+
if (prev <= 1) {
|
|
110
|
+
clearInterval(timer);
|
|
111
|
+
onDecision(false); // Fail-safe on timeout
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
return prev - 1;
|
|
115
|
+
});
|
|
116
|
+
}, 1000);
|
|
117
|
+
|
|
118
|
+
return () => clearInterval(timer);
|
|
119
|
+
}, [onDecision]);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<div
|
|
123
|
+
role="alertdialog"
|
|
124
|
+
aria-modal="true"
|
|
125
|
+
aria-labelledby="hitl-title"
|
|
126
|
+
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm"
|
|
127
|
+
>
|
|
128
|
+
<div className="w-full max-w-md rounded-2xl border border-destructive/50 bg-card p-6 shadow-2xl">
|
|
129
|
+
<h3 id="hitl-title" className="text-lg font-bold text-foreground">
|
|
130
|
+
Confirm High-Risk Action
|
|
131
|
+
</h3>
|
|
132
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
133
|
+
An AI assistant has requested execution of <strong>{request.toolName}</strong>.
|
|
134
|
+
</p>
|
|
135
|
+
|
|
136
|
+
<div className="mt-4 rounded-lg bg-muted p-3 font-mono text-xs text-foreground overflow-x-auto">
|
|
137
|
+
<pre>{JSON.stringify(request.args, null, 2)}</pre>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div className="mt-3 flex items-center justify-between text-xs text-muted-foreground">
|
|
141
|
+
<span>Auto-rejecting in: {timeLeft}s</span>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div className="mt-6 flex justify-end space-x-3">
|
|
145
|
+
<button
|
|
146
|
+
type="button"
|
|
147
|
+
onClick={() => onDecision(false)}
|
|
148
|
+
className="px-4 py-2 font-medium text-sm rounded-lg border border-border bg-background hover:bg-muted active:scale-[0.98]"
|
|
149
|
+
>
|
|
150
|
+
Deny
|
|
151
|
+
</button>
|
|
152
|
+
<button
|
|
153
|
+
type="button"
|
|
154
|
+
onClick={() => onDecision(true)}
|
|
155
|
+
className="px-4 py-2 font-medium text-sm rounded-lg bg-destructive text-destructive-foreground hover:bg-destructive/90 active:scale-[0.98]"
|
|
156
|
+
>
|
|
157
|
+
Authorize Action
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
package/core/skills/frontend/implement-webmcp/references/webmcp-architecture-and-hitl-security.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# WebMCP Architecture & Human-in-the-Loop (HITL) Security Standards (2026)
|
|
2
|
+
|
|
3
|
+
## 1. WebMCP Runtime Architecture & SSR Safety
|
|
4
|
+
|
|
5
|
+
### 1.1 In-Browser Model Context Protocol (WebMCP)
|
|
6
|
+
WebMCP bridges in-browser AI assistants directly to the Document Object Model (DOM), client-side store state, and registered browser action tools:
|
|
7
|
+
- **Feature Detection Guard**: Never access `document.modelContext` directly during server-side rendering or before DOM hydration:
|
|
8
|
+
```typescript
|
|
9
|
+
export function isWebMcpAvailable(): boolean {
|
|
10
|
+
return typeof window !== 'undefined' && 'modelContext' in document;
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
- **Session Boundary Security**: WebMCP operates exclusively within the client execution sandbox. Secret tokens, refresh tokens, and authentication cookies must reside in `HttpOnly; Secure; SameSite=Strict` cookies, remaining completely inaccessible to client JavaScript.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 2. Sanitized State Mapping & Context Injection
|
|
18
|
+
|
|
19
|
+
### 2.1 PII & Secret Scrubbing
|
|
20
|
+
Before synchronizing client application stores (Zustand, Redux, React Context) to the agent context buffer, execute deterministic field stripping:
|
|
21
|
+
- **Forbidden Context Fields**: `password`, `ssn`, `accessToken`, `refreshToken`, `apiKey`, `creditCard`, `cvv`.
|
|
22
|
+
- **Sanitized Projection**:
|
|
23
|
+
```typescript
|
|
24
|
+
export function sanitizeStoreState(state: Record<string, unknown>): Record<string, unknown> {
|
|
25
|
+
const sanitized = { ...state };
|
|
26
|
+
const restrictedKeys = ['auth', 'session', 'tokens', 'billingSecret'];
|
|
27
|
+
restrictedKeys.forEach((key) => delete sanitized[key]);
|
|
28
|
+
return sanitized;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 3. Tool Registration & Default-Deny Allowlist
|
|
35
|
+
|
|
36
|
+
### 3.1 Strict Input Schema Declaration
|
|
37
|
+
Every registered client tool must declare concrete JSON Schema validation rules. Open `{ type: "object" }` declarations without explicit properties are rejected:
|
|
38
|
+
- Declare required fields, parameter ranges, and enum constraints.
|
|
39
|
+
- Tool handlers execute only after input parameters pass local validation.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 4. Human-in-the-Loop (HITL) Approval Gate
|
|
44
|
+
|
|
45
|
+
### 4.1 Non-Idempotent & High-Risk Actions
|
|
46
|
+
Any action mutating persistent backend state, modifying billing details, or deleting data requires explicit user confirmation:
|
|
47
|
+
- **Fail-Safe Timeout**: If the user dismisses the approval dialog or fails to respond within 60 seconds ($T_{timeout} = 60\text{s}$), the action is automatically rejected with error code `USER_CONSENT_TIMEOUT`.
|
|
48
|
+
- **Visual Activity Beacon**: Display a persistent visual badge when an AI agent is reading DOM context or executing allowlisted actions.
|
|
@@ -182,5 +182,7 @@ Skip emission for solo refactor work where no downstream handoff is expected.
|
|
|
182
182
|
- **review-code**: Review data flow, auth, and error handling risk
|
|
183
183
|
- **commit-code**: Prepare the integration for delivery
|
|
184
184
|
- **develop-mobile-app**: Connect mobile clients with offline-first persistence (MMKV, WatermelonDB) and NetInfo synchronization
|
|
185
|
+
- Companion reference: `references/orval-tanstack-query-and-streaming-specs.md`
|
|
186
|
+
- Companion example: `examples/orval-query-and-streaming-mutation.ts`
|
|
185
187
|
|
|
186
|
-
Last updated: 2026-
|
|
188
|
+
Last updated: 2026-11-08
|
package/core/skills/frontend/integrate-api-client/examples/orval-query-and-streaming-mutation.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production TanStack Query v5 Optimistic Mutation & Streaming Client
|
|
3
|
+
*
|
|
4
|
+
* Implements:
|
|
5
|
+
* - Centralized queryOptions factory (eliminating magic strings)
|
|
6
|
+
* - Three-phase optimistic mutation lifecycle (onMutate -> onError -> onSettled)
|
|
7
|
+
* - Functional updater syntax preventing stale closure captures
|
|
8
|
+
* - Streaming SSE reader with AbortController cancellation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { queryOptions, QueryClient, useMutation } from '@tanstack/react-query';
|
|
12
|
+
|
|
13
|
+
export interface UserTask {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
completed: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 1. Centralized queryOptions Factory
|
|
20
|
+
export const taskQueries = {
|
|
21
|
+
all: () => ['tasks'] as const,
|
|
22
|
+
list: (status: 'all' | 'pending' | 'completed') =>
|
|
23
|
+
queryOptions({
|
|
24
|
+
queryKey: [...taskQueries.all(), 'list', status],
|
|
25
|
+
queryFn: async (): Promise<UserTask[]> => {
|
|
26
|
+
const res = await fetch(`/api/v1/tasks?status=${status}`);
|
|
27
|
+
if (!res.ok) throw new Error(`Fetch failed: ${res.statusText}`);
|
|
28
|
+
return res.json();
|
|
29
|
+
},
|
|
30
|
+
staleTime: 1000 * 60 * 2,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 2. Optimistic Mutation Hook Lifecycle
|
|
35
|
+
export function useUpdateTaskOptimistic(queryClient: QueryClient) {
|
|
36
|
+
const queryKey = taskQueries.list('all').queryKey;
|
|
37
|
+
|
|
38
|
+
return useMutation({
|
|
39
|
+
mutationFn: async (updatedTask: UserTask) => {
|
|
40
|
+
const res = await fetch(`/api/v1/tasks/${updatedTask.id}`, {
|
|
41
|
+
method: 'PATCH',
|
|
42
|
+
headers: { 'Content-Type': 'application/json' },
|
|
43
|
+
body: JSON.stringify(updatedTask),
|
|
44
|
+
});
|
|
45
|
+
if (!res.ok) throw new Error('Task update failed on server');
|
|
46
|
+
return res.json();
|
|
47
|
+
},
|
|
48
|
+
// Step 1: Snapshot and Optimistically Mutate
|
|
49
|
+
onMutate: async (newTask) => {
|
|
50
|
+
await queryClient.cancelQueries({ queryKey });
|
|
51
|
+
const previousTasks = queryClient.getQueryData<UserTask[]>(queryKey) || [];
|
|
52
|
+
|
|
53
|
+
queryClient.setQueryData<UserTask[]>(queryKey, (old = []) =>
|
|
54
|
+
old.map((t) => (t.id === newTask.id ? { ...t, ...newTask } : t))
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return { previousTasks };
|
|
58
|
+
},
|
|
59
|
+
// Step 2: Rollback on Error
|
|
60
|
+
onError: (_err, _newTask, context) => {
|
|
61
|
+
if (context?.previousTasks) {
|
|
62
|
+
queryClient.setQueryData(queryKey, context.previousTasks);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
// Step 3: Reconcile with Server
|
|
66
|
+
onSettled: () => {
|
|
67
|
+
queryClient.invalidateQueries({ queryKey });
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 3. Streaming AI Token Consumer with AbortSignal
|
|
73
|
+
export async function consumeAiStream(
|
|
74
|
+
prompt: string,
|
|
75
|
+
onToken: (token: string) => void,
|
|
76
|
+
abortSignal: AbortSignal
|
|
77
|
+
): Promise<void> {
|
|
78
|
+
const response = await fetch('/api/v1/ai/stream', {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: { 'Content-Type': 'application/json' },
|
|
81
|
+
body: JSON.stringify({ prompt }),
|
|
82
|
+
signal: abortSignal,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (!response.ok || !response.body) {
|
|
86
|
+
throw new Error(`Streaming failed with status: ${response.status}`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
while (true) {
|
|
93
|
+
const { value, done } = await reader.read();
|
|
94
|
+
if (done) break;
|
|
95
|
+
if (value) {
|
|
96
|
+
onToken(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
reader.releaseLock();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Orval, TanStack Query v5, and Streaming API Specifications (2026)
|
|
2
|
+
|
|
3
|
+
## 1. OpenAPI Codegen Pipeline with Orval
|
|
4
|
+
|
|
5
|
+
### 1.1 Automated Type & Hook Generation
|
|
6
|
+
Manual API client writing introduces contract drift between backend protobuf/OpenAPI schemas and frontend client code:
|
|
7
|
+
- **Orval Automation**: Convert OpenAPI v3.1 / RFC 9727 specs into typed TanStack Query v5 hooks, MSW v2 mock handlers, and TypeScript types.
|
|
8
|
+
- **Drift Detection**: CI runs Orval verification to ensure committed client code strictly matches current API specifications:
|
|
9
|
+
```bash
|
|
10
|
+
orval --config orval.config.ts --mode check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 2. Centralized `queryOptions` Factories
|
|
16
|
+
|
|
17
|
+
### 2.1 Eliminating Magic String Query Keys
|
|
18
|
+
- All TanStack Query hooks must be configured using query option factories rather than scattered query key arrays:
|
|
19
|
+
```typescript
|
|
20
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
21
|
+
|
|
22
|
+
export const userQueries = {
|
|
23
|
+
all: () => ['users'] as const,
|
|
24
|
+
detail: (userId: string) =>
|
|
25
|
+
queryOptions({
|
|
26
|
+
queryKey: [...userQueries.all(), userId],
|
|
27
|
+
queryFn: () => fetchUser(userId),
|
|
28
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. Optimistic Mutation Lifecycle
|
|
36
|
+
|
|
37
|
+
### 3.1 Three-Phase Rollback Pattern
|
|
38
|
+
Optimistic UI updates must guarantee atomic recovery on backend failures:
|
|
39
|
+
1. **`onMutate`**:
|
|
40
|
+
- Cancel outstanding in-flight queries: `await queryClient.cancelQueries({ queryKey })`.
|
|
41
|
+
- Capture current cache snapshot: `const previous = queryClient.getQueryData(queryKey)`.
|
|
42
|
+
- Apply optimistic update using functional updater: `queryClient.setQueryData(queryKey, (old) => ...)`.
|
|
43
|
+
- Return context containing previous snapshot.
|
|
44
|
+
2. **`onError`**:
|
|
45
|
+
- Restore previous state from context: `queryClient.setQueryData(queryKey, context.previous)`.
|
|
46
|
+
3. **`onSettled`**:
|
|
47
|
+
- Invalidate cache to reconcile with authoritative server state: `queryClient.invalidateQueries({ queryKey })`.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 4. Streaming AI Responses (SSE & Chunked Fetch)
|
|
52
|
+
|
|
53
|
+
### 4.1 Token Chunking & State Batching
|
|
54
|
+
Streaming LLM completions must not trigger re-render storms:
|
|
55
|
+
- Pipe response body through `TextDecoderStream`.
|
|
56
|
+
- Process incoming Server-Sent Events (SSE) chunks via a `useReducer` action queue or batched `React.startTransition()` callbacks.
|
|
57
|
+
- Wire an `AbortController` signal to allow instantaneous user cancellation.
|
|
@@ -175,5 +175,7 @@ Documentation: [Storybook / none]
|
|
|
175
175
|
- **frontend-testing**: Add visual regression or interaction tests for the design system primitives.
|
|
176
176
|
- **accessibility-review**: Audit the foundational primitives to ensure they meet WCAG criteria.
|
|
177
177
|
- **design-review**: Validate design token choices against brand guidelines and user needs before implementation.
|
|
178
|
+
- Companion reference: `references/tailwind-v4-oklch-and-dtcg-tokens.md`
|
|
179
|
+
- Companion example: `examples/tailwind-v4-theme-and-dtcg-tokens.css`
|
|
178
180
|
|
|
179
|
-
Last updated: 2026-
|
|
181
|
+
Last updated: 2026-11-08
|
package/core/skills/frontend/setup-design-system/examples/tailwind-v4-theme-and-dtcg-tokens.css
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind v4 CSS-First Entrypoint with OKLCH Tokens
|
|
3
|
+
*
|
|
4
|
+
* Implements:
|
|
5
|
+
* - Native @theme directive (zero tailwind.config.js)
|
|
6
|
+
* - OKLCH perceptual color space ensuring WCAG AA 4.5:1 text / 3:1 UI contrast
|
|
7
|
+
* - Pure CSS variable dark mode without manual dark: utility overrides
|
|
8
|
+
* - Concentric border radii scale and 3-layer elevation shadows
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
@import "tailwindcss";
|
|
12
|
+
|
|
13
|
+
@theme {
|
|
14
|
+
/* Font Family Stacks */
|
|
15
|
+
--font-sans: 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
16
|
+
--font-mono: 'JetBrains Mono Variable', ui-monospace, SFMono-Regular, monospace;
|
|
17
|
+
|
|
18
|
+
/* Concentric Border Radii */
|
|
19
|
+
--radius-xs: 0.25rem;
|
|
20
|
+
--radius-sm: 0.375rem;
|
|
21
|
+
--radius-md: 0.5rem;
|
|
22
|
+
--radius-lg: 0.75rem;
|
|
23
|
+
--radius-xl: 1rem;
|
|
24
|
+
--radius-2xl: 1.5rem;
|
|
25
|
+
--radius-full: 9999px;
|
|
26
|
+
|
|
27
|
+
/* Semantic Color Aliases mapped to CSS variables */
|
|
28
|
+
--color-background: var(--background);
|
|
29
|
+
--color-foreground: var(--foreground);
|
|
30
|
+
--color-card: var(--card);
|
|
31
|
+
--color-card-foreground: var(--card-foreground);
|
|
32
|
+
--color-primary: var(--primary);
|
|
33
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
34
|
+
--color-muted: var(--muted);
|
|
35
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
36
|
+
--color-border: var(--border);
|
|
37
|
+
--color-ring: var(--ring);
|
|
38
|
+
|
|
39
|
+
/* 3-Layer Elevation Shadows */
|
|
40
|
+
--shadow-subtle: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
|
41
|
+
--shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
42
|
+
--shadow-overlay: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Light Mode Token Values (OKLCH) */
|
|
46
|
+
:root {
|
|
47
|
+
--background: oklch(0.985 0.002 247);
|
|
48
|
+
--foreground: oklch(0.145 0.005 247);
|
|
49
|
+
--card: oklch(1 0 0);
|
|
50
|
+
--card-foreground: oklch(0.145 0.005 247);
|
|
51
|
+
--primary: oklch(0.488 0.243 264.376);
|
|
52
|
+
--primary-foreground: oklch(0.985 0.002 247);
|
|
53
|
+
--muted: oklch(0.96 0.004 247);
|
|
54
|
+
--muted-foreground: oklch(0.45 0.015 247);
|
|
55
|
+
--border: oklch(0.88 0.006 247);
|
|
56
|
+
--ring: oklch(0.488 0.243 264.376);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Dark Mode Token Values (OKLCH) */
|
|
60
|
+
.dark {
|
|
61
|
+
--background: oklch(0.145 0.005 247);
|
|
62
|
+
--foreground: oklch(0.985 0.002 247);
|
|
63
|
+
--card: oklch(0.19 0.006 247);
|
|
64
|
+
--card-foreground: oklch(0.985 0.002 247);
|
|
65
|
+
--primary: oklch(0.627 0.265 264.376);
|
|
66
|
+
--primary-foreground: oklch(0.145 0.005 247);
|
|
67
|
+
--muted: oklch(0.24 0.008 247);
|
|
68
|
+
--muted-foreground: oklch(0.70 0.012 247);
|
|
69
|
+
--border: oklch(0.28 0.01 247);
|
|
70
|
+
--ring: oklch(0.627 0.265 264.376);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Base Accessibility Resets */
|
|
74
|
+
html {
|
|
75
|
+
font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
|
|
76
|
+
-webkit-font-smoothing: antialiased;
|
|
77
|
+
-moz-osx-font-smoothing: grayscale;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (prefers-reduced-motion: reduce) {
|
|
81
|
+
*, ::before, ::after {
|
|
82
|
+
animation-duration: 0.01ms !important;
|
|
83
|
+
animation-iteration-count: 1 !important;
|
|
84
|
+
transition-duration: 0.01ms !important;
|
|
85
|
+
scroll-behavior: auto !important;
|
|
86
|
+
}
|
|
87
|
+
}
|
package/core/skills/frontend/setup-design-system/references/tailwind-v4-oklch-and-dtcg-tokens.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Tailwind v4, OKLCH Perceptual Tokens, and W3C DTCG Standards (2026)
|
|
2
|
+
|
|
3
|
+
## 1. Tailwind v4 CSS-First Architecture (`@theme`)
|
|
4
|
+
|
|
5
|
+
### 1.1 Complete Elimination of `tailwind.config.js`
|
|
6
|
+
Tailwind CSS v4 replaces JavaScript configuration files with native CSS `@theme` directives located directly inside CSS entrypoints:
|
|
7
|
+
- All design tokens, breakpoints, font families, and container metrics are declared as CSS custom properties within `@theme`.
|
|
8
|
+
- Zero configuration overhead; instantaneous compilation via the Lightning CSS engine.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 2. OKLCH Perceptual Color Space
|
|
13
|
+
|
|
14
|
+
### 2.1 Perceptual Uniformity Across Themes
|
|
15
|
+
RGB and HSL color spaces exhibit severe non-linear perceived brightness shifts across different hues (e.g., pure yellow appears vastly brighter than pure blue at 50% lightness).
|
|
16
|
+
- **OKLCH Uniformity**: OKLCH separates perceived Lightness ($L$), Chroma ($C$), and Hue angle ($H$).
|
|
17
|
+
- Maintaining uniform $L$ across hues ensures identical contrast ratios against background surfaces:
|
|
18
|
+
$$\text{Contrast Ratio}(\text{Surface}, \text{Text}) \ge 4.5:1 \quad (\text{WCAG 2.2 AA})$$
|
|
19
|
+
|
|
20
|
+
### 2.2 Pure CSS Variable Dark Mode
|
|
21
|
+
- Never pollute component JSX with ad-hoc `dark:bg-slate-900` or `dark:text-white` utility classes.
|
|
22
|
+
- Dark mode must be achieved exclusively by swapping CSS variable values in `:root` and `.dark`:
|
|
23
|
+
```css
|
|
24
|
+
:root {
|
|
25
|
+
--background: oklch(0.985 0.002 247);
|
|
26
|
+
--foreground: oklch(0.145 0.005 247);
|
|
27
|
+
--primary: oklch(0.488 0.243 264.376);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dark {
|
|
31
|
+
--background: oklch(0.145 0.005 247);
|
|
32
|
+
--foreground: oklch(0.985 0.002 247);
|
|
33
|
+
--primary: oklch(0.627 0.265 264.376);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3. W3C Design Tokens Community Group (DTCG) Specification
|
|
40
|
+
|
|
41
|
+
### 3.1 Token Portability Contract
|
|
42
|
+
Design systems must export tokens in standardized W3C DTCG format for bidirectional synchronization with Figma Variables, Style Dictionary, and AI code generation tools:
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"color": {
|
|
46
|
+
"brand": {
|
|
47
|
+
"primary": {
|
|
48
|
+
"$type": "color",
|
|
49
|
+
"$value": "oklch(0.488 0.243 264.376)",
|
|
50
|
+
"$description": "Core interactive brand color meeting WCAG 2.2 AA contrast"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"spacing": {
|
|
55
|
+
"base": {
|
|
56
|
+
"$type": "dimension",
|
|
57
|
+
"$value": "0.25rem"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
@@ -111,5 +111,7 @@ When this skill is invoked as part of a coordinated multi-role delivery, emit:
|
|
|
111
111
|
- **add-ui-component**: Validate new or modified UI components against visual snapshot baselines
|
|
112
112
|
- **design-review**: Review visual snapshot diffs against design specifications and design tokens
|
|
113
113
|
- **review-code**: Audit visual test coverage and snapshot approval evidence during code review
|
|
114
|
+
- Companion reference: `references/visual-regression-docker-and-masking-specs.md`
|
|
115
|
+
- Companion example: `examples/visual-regression-playwright.config.ts`
|
|
114
116
|
|
|
115
|
-
Last updated: 2026-
|
|
117
|
+
Last updated: 2026-11-08
|