vibes-plug 1.0.0 → 2.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/.claude/rules/vibes-plug-core.md +32 -0
- package/.cursor/rules/vibes-plug-core.mdc +51 -0
- package/.cursorrules +42 -0
- package/AGENTS.md +96 -0
- package/BLUEPRINT.md +309 -125
- package/CHANGELOG.md +183 -1
- package/CLAUDE.md +70 -0
- package/LICENSE +1 -1
- package/README.md +641 -263
- package/index.js +19 -0
- package/package.json +61 -25
- package/plugin.json +24 -7
- package/scripts/generate_swarm_gif.py +295 -0
- package/scripts/install.js +201 -0
- package/skills/accessibility-testing-expert/SKILL.md +116 -0
- package/skills/ai-cost-token-optimizer/SKILL.md +82 -0
- package/skills/ai-evals-benchmark-expert/SKILL.md +188 -0
- package/skills/ai-llm-integration-expert/SKILL.md +147 -122
- package/skills/ai-media-generation-expert/SKILL.md +172 -0
- package/skills/ai-prompt-engineering-expert/SKILL.md +84 -0
- package/skills/angular-expert/SKILL.md +148 -0
- package/skills/api-design-expert/SKILL.md +316 -309
- package/skills/api-gateway-proxy-expert/SKILL.md +81 -0
- package/skills/app-analyzer-optimizer/SKILL.md +195 -188
- package/skills/apple-ecosystem-expert/SKILL.md +145 -0
- package/skills/{asisten_ramah → asisten-ramah}/SKILL.md +7 -1
- package/skills/astro-framework-expert/SKILL.md +200 -0
- package/skills/async-queue-temporal-expert/SKILL.md +240 -0
- package/skills/authentication-identity-expert/SKILL.md +279 -45
- package/skills/auto-doc-updater/SKILL.md +219 -203
- package/skills/autonomous-chaos-monkey/SKILL.md +63 -0
- package/skills/autonomous-red-teamer/SKILL.md +203 -0
- package/skills/autonomous-tdd-debugger/SKILL.md +71 -0
- package/skills/background-jobs-queue-expert/SKILL.md +235 -0
- package/skills/biome-linter-formatter-expert/SKILL.md +89 -0
- package/skills/blockchain-web3-expert/SKILL.md +115 -0
- package/skills/bootstrap-to-modern/SKILL.md +93 -86
- package/skills/brainstorming/SKILL.md +381 -353
- package/skills/browser-automation-expert/SKILL.md +222 -0
- package/skills/bun-runtime-expert/SKILL.md +7 -1
- package/skills/chatbot-messaging-expert/SKILL.md +114 -0
- package/skills/ci-cd-devops-architect/SKILL.md +81 -45
- package/skills/cloud-hosting-expert/SKILL.md +249 -243
- package/skills/coderabbit/SKILL.md +197 -191
- package/skills/compliance-gdpr-privacy-expert/SKILL.md +85 -0
- package/skills/cron-scheduler-expert/SKILL.md +304 -0
- package/skills/data-pipeline-etl-expert/SKILL.md +84 -0
- package/skills/data-telemetry-expert/SKILL.md +218 -212
- package/skills/data-visualization-expert/SKILL.md +154 -0
- package/skills/database-migration-versioning-expert/SKILL.md +90 -0
- package/skills/database-orm-expert/SKILL.md +303 -293
- package/skills/dependency-upgrade-migrator/SKILL.md +301 -0
- package/skills/design-system-architect/SKILL.md +278 -242
- package/skills/desktop-electron-expert/SKILL.md +128 -0
- package/skills/documentation-site-expert/SKILL.md +59 -0
- package/skills/doku-mcp-server/SKILL.md +257 -0
- package/skills/doku-payment-gateway/SKILL.md +233 -0
- package/skills/domain-driven-design-expert/SKILL.md +82 -0
- package/skills/e2e-testing-expert/SKILL.md +320 -314
- package/skills/ecommerce-expert/SKILL.md +87 -0
- package/skills/edge-serverless-db-expert/SKILL.md +99 -0
- package/skills/email-notification-expert/SKILL.md +368 -0
- package/skills/error-resilience-expert/SKILL.md +486 -0
- package/skills/event-driven-architect/SKILL.md +86 -80
- package/skills/feature-flag-analytics-expert/SKILL.md +66 -0
- package/skills/file-upload-media-expert/SKILL.md +437 -0
- package/skills/firebase-security-expert/SKILL.md +7 -1
- package/skills/form-validation-expert/SKILL.md +407 -0
- package/skills/fullstack-expert/SKILL.md +260 -201
- package/skills/fullstack-expert/references/api_design_guide.md +466 -466
- package/skills/fullstack-expert/references/multi_language_backend.md +528 -528
- package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -253
- package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -326
- package/skills/gemini-agent-booster/SKILL.md +142 -104
- package/skills/geospatial-maps-expert/SKILL.md +80 -0
- package/skills/global-a11y-i18n-expert/SKILL.md +86 -80
- package/skills/glsl-shader-expert/SKILL.md +107 -0
- package/skills/go-programming-expert/SKILL.md +300 -294
- package/skills/graph-rag-knowledge-expert/SKILL.md +159 -0
- package/skills/graphql-apollo-expert/SKILL.md +114 -0
- package/skills/headless-cms-expert/SKILL.md +181 -0
- package/skills/hig/SKILL.md +193 -187
- package/skills/js-backend-expert/SKILL.md +218 -191
- package/skills/legacy-code-translator/SKILL.md +71 -0
- package/skills/local-slm-edge-ai-expert/SKILL.md +167 -0
- package/skills/logging-error-tracking-expert/SKILL.md +344 -0
- package/skills/mcp-client-orchestrator/SKILL.md +76 -0
- package/skills/mcp-server-architect/SKILL.md +226 -126
- package/skills/micro-frontend-architect/SKILL.md +112 -0
- package/skills/mobile-expo-expert/SKILL.md +191 -185
- package/skills/mobile-push-notification-expert/SKILL.md +71 -0
- package/skills/modern-css-native-expert/SKILL.md +189 -0
- package/skills/monday-design-aesthetic/SKILL.md +72 -66
- package/skills/monorepo-architect/SKILL.md +232 -226
- package/skills/mpa-orchestrator/SKILL.md +120 -101
- package/skills/multi-agent-orchestration/SKILL.md +173 -153
- package/skills/multiple-entry-points/SKILL.md +91 -55
- package/skills/mvc-expert/SKILL.md +237 -231
- package/skills/n8n-automation-expert/SKILL.md +89 -0
- package/skills/nextjs-app-router-expert/SKILL.md +148 -0
- package/skills/openapi-swagger-codegen-expert/SKILL.md +67 -0
- package/skills/payment-gateway-expert/SKILL.md +129 -45
- package/skills/pdf-document-generation-expert/SKILL.md +91 -0
- package/skills/performance-web-vitals/SKILL.md +337 -331
- package/skills/post-quantum-crypto-migrator/SKILL.md +57 -0
- package/skills/prd-architect/SKILL.md +206 -190
- package/skills/proactive-background-watcher/SKILL.md +68 -0
- package/skills/production-ready-hardener/PRODUCTION_READINESS_REPORT.md +67 -0
- package/skills/production-ready-hardener/SKILL.md +461 -468
- package/skills/production-ready-hardener/references/production_checklist.md +161 -161
- package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +881 -875
- package/skills/project-context-mapper/SKILL.md +85 -0
- package/skills/pwa-offline-first-expert/SKILL.md +185 -0
- package/skills/python-programming-expert/SKILL.md +407 -270
- package/skills/rate-limit-abuse-prevention/SKILL.md +377 -0
- package/skills/realtime-collaboration-expert/SKILL.md +99 -45
- package/skills/rich-text-editor-expert/SKILL.md +177 -0
- package/skills/rust-programming-expert/SKILL.md +240 -234
- package/skills/saas-billing/SKILL.md +382 -376
- package/skills/saas-multi-tenant/SKILL.md +256 -236
- package/skills/saas-mvp-launcher/SKILL.md +30 -1
- package/skills/saas-transformer/SKILL.md +499 -445
- package/skills/saas-transformer/references/billing_integration_guide.md +401 -401
- package/skills/saas-transformer/references/feature_gating_patterns.md +137 -137
- package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -121
- package/skills/saas-transformer/scripts/saas_transformation_scanner.py +39 -29
- package/skills/scalability-clean-code/SKILL.md +234 -228
- package/skills/search-engine-expert/SKILL.md +89 -0
- package/skills/secure-fuzz-testing/SKILL.md +7 -1
- package/skills/self-evolving-memory-graph/SKILL.md +91 -0
- package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -0
- package/skills/senior-frontend/SKILL.md +85 -105
- package/skills/seo/SKILL.md +258 -224
- package/skills/session-context-loader/SKILL.md +83 -0
- package/skills/session-handoff-resume/SKILL.md +163 -157
- package/skills/{skill_baru → skill-baru}/SKILL.md +177 -146
- package/skills/solidjs-expert/SKILL.md +80 -0
- package/skills/spa-orchestrator/SKILL.md +306 -287
- package/skills/sse-websocket-streaming-expert/SKILL.md +93 -0
- package/skills/state-management-expert/SKILL.md +277 -271
- package/skills/supabase-migration/SKILL.md +47 -1
- package/skills/supabase-security-expert/SKILL.md +248 -242
- package/skills/svelte-sveltekit-expert/SKILL.md +91 -0
- package/skills/svg-animation-motion-expert/SKILL.md +115 -0
- package/skills/tailwind-expert/SKILL.md +139 -187
- package/skills/tanstack-query-expert/SKILL.md +204 -198
- package/skills/tauri-expert/SKILL.md +7 -1
- package/skills/token-saver/SKILL.md +118 -110
- package/skills/typescript-expert/SKILL.md +329 -278
- package/skills/ui-components-expert/SKILL.md +166 -63
- package/skills/ui-ux-pro-max/SKILL.md +221 -200
- package/skills/vector-db-rag-expert/SKILL.md +208 -0
- package/skills/vibe-code-gardener/SKILL.md +180 -172
- package/skills/visual-qa-vision-agent/SKILL.md +71 -0
- package/skills/voice-ai-realtime-agent/SKILL.md +202 -0
- package/skills/vue-frontend-expert/SKILL.md +132 -0
- package/skills/wasm-edge-computing-expert/SKILL.md +97 -0
- package/skills/web-3d-graphics-expert/SKILL.md +137 -0
- package/skills/web-game-engine-expert/SKILL.md +102 -0
- package/skills/web-scraper/SKILL.md +98 -146
- package/skills/website-design-cloner/SKILL.md +180 -0
- package/skills/webxr-ar-vr-expert/SKILL.md +123 -0
- package/skills/wordpress-headless-expert/SKILL.md +144 -0
- package/skills/zero-to-prod-orchestrator/SKILL.md +231 -180
- package/skills/zero-trust-secret-vault/SKILL.md +88 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/CONTRIBUTING.md +0 -199
- package/SECURITY.md +0 -21
- package/banner.png +0 -0
- package/skills/senior-fullstack/SKILL.md +0 -167
- package/skills/senior-fullstack/references/architecture_patterns.md +0 -160
- package/skills/senior-fullstack/references/development_workflows.md +0 -222
- package/skills/senior-fullstack/references/tech_stack_guide.md +0 -190
- package/skills/senior-fullstack/scripts/code_quality_analyzer.py +0 -114
- package/skills/senior-fullstack/scripts/fullstack_scaffolder.py +0 -114
- package/skills/senior-fullstack/scripts/project_scaffolder.py +0 -114
- package/skills/seo-aeo-landing-page-writer/SKILL.md +0 -97
- package/skills/seo-geo/SKILL.md +0 -188
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
- package/skills/ui_ux_expert/SKILL.md +0 -114
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: voice-ai-realtime-agent
|
|
3
|
+
description: "Expert guide for Ultra-Low Latency Conversational Voice AI (<300ms), WebRTC bidirectional streaming, OpenAI Realtime API, Gemini Multimodal Live Audio, LiveKit Agents, and Semantic VAD / Panduan ahli AI suara percakapan real-time berlatensi ultra-rendah."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Voice AI Realtime Agent (2026 Edition)
|
|
8
|
+
|
|
9
|
+
Expert guide for building ultra-low-latency (<300ms), bi-directional conversational voice AI applications. Covers WebRTC, full-duplex WebSocket audio streaming (PCM 24kHz), OpenAI Realtime API, Gemini Multimodal Live API, LiveKit Agents SDK, and smart interruption (barge-in) handling.
|
|
10
|
+
|
|
11
|
+
*Panduan ahli untuk membangun aplikasi AI suara percakapan dua arah berlatensi ultra-rendah (<300ms) menggunakan WebRTC, WebSocket full-duplex, OpenAI Realtime API, Gemini Multimodal Live API, LiveKit Agents SDK, dan penanganan interupsi (barge-in).*
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Core Architecture: Full-Duplex Speech-to-Speech
|
|
16
|
+
|
|
17
|
+
Traditional voice pipelines chain STT ➔ LLM ➔ TTS with cumulative latency exceeding 1,200ms–2,500ms. Modern 2026 voice agents use **native speech-to-speech** or **streamable full-duplex WebRTC pipelines** achieving natural, human-like reaction times (~250–350ms).
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
User Mic ──► [WebRTC / WebSocket] ──► [VAD: Silero / WebRTC VAD]
|
|
21
|
+
│
|
|
22
|
+
▼
|
|
23
|
+
User Speaks <── [Audio Output] ◄── [Native Audio Stream / Cartesia] ◄── [OpenAI Realtime / Gemini Live]
|
|
24
|
+
│
|
|
25
|
+
└── User Interrupts (Barge-in) ──► Instant Buffer Flush & Cancel Audio Frame Emission
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. Production Recipe: LiveKit Agents + OpenAI Realtime (Python)
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
# agent.py - Production Voice Agent Worker with LiveKit & OpenAI Realtime
|
|
34
|
+
import asyncio
|
|
35
|
+
import os
|
|
36
|
+
from livekit import rtc
|
|
37
|
+
from livekit.agents import (
|
|
38
|
+
AutoSubscribe,
|
|
39
|
+
JobContext,
|
|
40
|
+
JobProcess,
|
|
41
|
+
WorkerOptions,
|
|
42
|
+
cli,
|
|
43
|
+
llm,
|
|
44
|
+
)
|
|
45
|
+
from livekit.agents.pipeline import VoicePipelineAgent
|
|
46
|
+
from livekit.plugins import deepgram, openai, silero
|
|
47
|
+
|
|
48
|
+
async def entrypoint(ctx: JobContext):
|
|
49
|
+
# Connect to room with audio only to minimize bandwidth & latency
|
|
50
|
+
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
|
|
51
|
+
|
|
52
|
+
# Wait for the user participant to join
|
|
53
|
+
participant = await ctx.wait_for_participant()
|
|
54
|
+
|
|
55
|
+
# Define agent instructions and tools
|
|
56
|
+
initial_ctx = llm.ChatContext().append(
|
|
57
|
+
role="system",
|
|
58
|
+
text=(
|
|
59
|
+
"You are a helpful, concise voice assistant. "
|
|
60
|
+
"Respond naturally in 1-2 short sentences. Never output markdown, bullet points, or emojis."
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Realtime Voice Pipeline: Deepgram (STT) + OpenAI (LLM) + Cartesia/OpenAI (TTS)
|
|
65
|
+
# Or use native OpenAI Realtime Model: gpt-4o-realtime-preview
|
|
66
|
+
agent = VoicePipelineAgent(
|
|
67
|
+
vad=silero.VAD.load(
|
|
68
|
+
min_speech_duration=0.1,
|
|
69
|
+
min_silence_duration=0.3, # Snappy turn-taking
|
|
70
|
+
prefix_padding_duration=0.2,
|
|
71
|
+
),
|
|
72
|
+
stt=deepgram.STT(model="nova-2", language="id"), # Multi-language support
|
|
73
|
+
llm=openai.LLM(model="gpt-4o-mini"),
|
|
74
|
+
tts=openai.TTS(voice="alloy"),
|
|
75
|
+
chat_ctx=initial_ctx,
|
|
76
|
+
allow_interruptions=True, # Barge-in capability
|
|
77
|
+
interrupt_speech_duration=0.3, # Immediate cutoff when user talks
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
agent.start(ctx.room, participant)
|
|
81
|
+
|
|
82
|
+
# Greet user immediately
|
|
83
|
+
await agent.say("Halo! Ada yang bisa saya bantu hari ini?", now=True)
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 3. Production Recipe: Gemini Multimodal Live Audio (TypeScript / Node.js)
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// gemini-live-audio.ts - Bidirectional WebSocket PCM 24kHz
|
|
95
|
+
import WebSocket from 'ws';
|
|
96
|
+
|
|
97
|
+
interface GeminiAudioConfig {
|
|
98
|
+
apiKey: string;
|
|
99
|
+
model?: string;
|
|
100
|
+
systemInstruction?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class GeminiVoiceAgent {
|
|
104
|
+
private ws: WebSocket | null = null;
|
|
105
|
+
private isConnected = false;
|
|
106
|
+
|
|
107
|
+
constructor(private config: GeminiAudioConfig) {}
|
|
108
|
+
|
|
109
|
+
public async connect(): Promise<void> {
|
|
110
|
+
const url = `wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1alpha.GenerativeService.BidiGenerateContent?key=${this.config.apiKey}`;
|
|
111
|
+
|
|
112
|
+
this.ws = new WebSocket(url);
|
|
113
|
+
|
|
114
|
+
this.ws.on('open', () => {
|
|
115
|
+
this.isConnected = true;
|
|
116
|
+
this.sendInitialHandshake();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
this.ws.on('message', (data: WebSocket.Data) => {
|
|
120
|
+
this.handleIncomingAudio(data);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private sendInitialHandshake(): void {
|
|
125
|
+
const setupMessage = {
|
|
126
|
+
setup: {
|
|
127
|
+
model: `models/${this.config.model || 'gemini-2.0-flash-exp'}`,
|
|
128
|
+
generationConfig: {
|
|
129
|
+
responseModalities: ["AUDIO"],
|
|
130
|
+
speechConfig: {
|
|
131
|
+
voiceConfig: {
|
|
132
|
+
prebuiltVoiceConfig: { voiceName: "Puck" }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
systemInstruction: {
|
|
137
|
+
parts: [{ text: this.config.systemInstruction || "You are a conversational voice agent. Keep answers brief." }]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
this.ws?.send(JSON.stringify(setupMessage));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Stream raw PCM 16-bit 24kHz mono audio from mic
|
|
145
|
+
public sendAudioChunk(pcm16Chunk: Buffer): void {
|
|
146
|
+
if (!this.isConnected || !this.ws) return;
|
|
147
|
+
|
|
148
|
+
const base64Audio = pcm16Chunk.toString('base64');
|
|
149
|
+
const msg = {
|
|
150
|
+
realtimeInput: {
|
|
151
|
+
mediaChunks: [
|
|
152
|
+
{
|
|
153
|
+
mimeType: "audio/pcm;rate=24000",
|
|
154
|
+
data: base64Audio
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
this.ws.send(JSON.stringify(msg));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private handleIncomingAudio(data: WebSocket.Data): void {
|
|
163
|
+
try {
|
|
164
|
+
const response = JSON.parse(data.toString());
|
|
165
|
+
const parts = response.serverContent?.modelTurn?.parts;
|
|
166
|
+
if (parts) {
|
|
167
|
+
for (const part of parts) {
|
|
168
|
+
if (part.inlineData?.data) {
|
|
169
|
+
const pcmBuffer = Buffer.from(part.inlineData.data, 'base64');
|
|
170
|
+
this.playAudioSpeaker(pcmBuffer);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
// Binary PCM frame handler
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private playAudioSpeaker(pcmChunk: Buffer): void {
|
|
180
|
+
// Send to WebRTC audio track or audio output device
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 4. Key 2026 Performance Guardrails
|
|
188
|
+
|
|
189
|
+
1. **Barge-in Latency Budget (<150ms)**: When the user speaks while the bot is talking, cancel outgoing audio immediately. Do not wait for the LLM to finish streaming its chunk.
|
|
190
|
+
2. **Audio Sample Rates**:
|
|
191
|
+
- Mic Input: 16kHz or 24kHz 16-bit Linear PCM Mono.
|
|
192
|
+
- Bot Output: 24kHz PCM for crystal-clear natural prosody.
|
|
193
|
+
3. **Turn-Taking Jitter Prevention**: Use minimum silence thresholds between `300ms` and `450ms`. Lower thresholds cause the bot to interrupt users when they pause to think; higher thresholds make the conversation feel robotic.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Orchestration & Integration
|
|
198
|
+
|
|
199
|
+
- **`ai-llm-integration-expert`**: For base LLM prompt routing and function calling during conversation.
|
|
200
|
+
- **`realtime-collaboration-expert`**: For syncing WebRTC tracks and room states with client applications.
|
|
201
|
+
- **`gemini-agent-booster`**: Connects Gemini 3.x / 2.0 Flash thinking models to live voice agents.
|
|
202
|
+
- **`mobile-expo-expert`**: Audio streaming implementation in React Native with `expo-av` and WebRTC shim.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vue-frontend-expert
|
|
3
|
+
description: "Expert guide for Vue 3 (Composition API), Nuxt 3, and Pinia. Covers advanced reactive state management, `<script setup>` syntax, Vue Router, VueUse, and SPA/SSR architectural patterns in English and Indonesian."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Vue Frontend Expert (Vue 3 / Nuxt 3)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Orchestration & Integration
|
|
17
|
+
Connects and orchestrates with relevant domain skills like `brainstorming`, `zero-to-prod-orchestrator`, and `project-context-mapper` to ensure cohesive execution.
|
|
18
|
+
|
|
19
|
+
### Description
|
|
20
|
+
Production-grade guidance for building highly reactive and scalable frontend applications using **Vue 3 (Composition API)** and **Nuxt 3**. Covers the latest ecosystem tools including **Pinia** for state management, **VueUse** for composables, and **Tailwind CSS v4** integration.
|
|
21
|
+
|
|
22
|
+
### Trigger Conditions
|
|
23
|
+
Activate this skill when the user is:
|
|
24
|
+
- Scaffolding a new Vue 3 or Nuxt 3 project.
|
|
25
|
+
- Writing or refactoring Vue components using `<script setup>` and Composition API.
|
|
26
|
+
- Managing global state with Pinia.
|
|
27
|
+
- Handling client-side routing with Vue Router or Nuxt's file-based routing.
|
|
28
|
+
- Implementing SSR (Server-Side Rendering) or SSG (Static Site Generation) using Nuxt 3.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Core Concepts
|
|
33
|
+
|
|
34
|
+
#### 1. Vue 3 Composition API & `<script setup>`
|
|
35
|
+
Use the `<script setup>` syntax by default. It provides better type inference, less boilerplate, and superior performance compared to the Options API.
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import { ref, computed, onMounted } from 'vue'
|
|
40
|
+
|
|
41
|
+
const count = ref(0)
|
|
42
|
+
const doubleCount = computed(() => count.value * 2)
|
|
43
|
+
|
|
44
|
+
function increment() {
|
|
45
|
+
count.value++
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
console.log('Component is mounted!')
|
|
50
|
+
})
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<button @click="increment">Count is: {{ count }} (Double: {{ doubleCount }})</button>
|
|
55
|
+
</template>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### 2. Global State Management (Pinia)
|
|
59
|
+
Pinia is the official state management library for Vue. Avoid Vuex in modern applications.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// stores/counter.ts
|
|
63
|
+
import { defineStore } from 'pinia'
|
|
64
|
+
import { ref, computed } from 'vue'
|
|
65
|
+
|
|
66
|
+
export const useCounterStore = defineStore('counter', () => {
|
|
67
|
+
const count = ref(0)
|
|
68
|
+
const doubleCount = computed(() => count.value * 2)
|
|
69
|
+
function increment() {
|
|
70
|
+
count.value++
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { count, doubleCount, increment }
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### 3. Nuxt 3 Architecture
|
|
78
|
+
For SSR, SEO optimization, and file-based routing, use Nuxt 3.
|
|
79
|
+
- Data fetching: Use `useAsyncData` or `useFetch` to prevent hydration mismatches.
|
|
80
|
+
- Server API: Utilize the `server/api/` directory for Nitro API routes.
|
|
81
|
+
|
|
82
|
+
#### 4. The VueUse Collection
|
|
83
|
+
Always leverage [VueUse](https://vueuse.org/) for common composables (e.g., `useWindowSize`, `onClickOutside`, `useStorage`) instead of writing custom composables from scratch.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Best Practices
|
|
88
|
+
1. **Ref vs Reactive:** Prefer `ref` for primitive values and `reactive` for deeply nested objects. When in doubt, default to `ref`.
|
|
89
|
+
2. **Define Macros:** Use `defineProps` and `defineEmits` in `<script setup>` for typed props and events.
|
|
90
|
+
3. **Avoid Watchers when possible:** Rely on `computed` properties instead of `watch` to derive state. Use `watch` only for side-effects (e.g., API calls, DOM manipulation).
|
|
91
|
+
4. **V-Model:** Use the updated `v-model` binding in Vue 3.4+ with `defineModel()` for cleaner two-way data binding between components.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### Integration with Other Skills (MANDATORY)
|
|
96
|
+
|
|
97
|
+
This skill works best when combined with:
|
|
98
|
+
- `design-system-architect` — To build headless UI components using Radix Vue or VueUse components.
|
|
99
|
+
- `tailwind-expert` — For styling Vue/Nuxt components with Tailwind CSS v4.
|
|
100
|
+
- `performance-web-vitals` — To optimize Nuxt 3 SSR metrics (LCP, INP).
|
|
101
|
+
|
|
102
|
+
### Referenced By Orchestrators (MANDATORY)
|
|
103
|
+
|
|
104
|
+
This skill should be referenced by the following orchestrators:
|
|
105
|
+
- `brainstorming` — Add to "Frontend Frameworks" row in the Matrix.
|
|
106
|
+
- `zero-to-prod-orchestrator` — Phase 5 (Frontend Implementation).
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
<a name="bahasa-indonesia"></a>
|
|
111
|
+
## Bahasa Indonesia
|
|
112
|
+
|
|
113
|
+
### Integrasi Orkestrasi
|
|
114
|
+
Terhubung dan mengorkestrasi skill domain yang relevan seperti `brainstorming`, `zero-to-prod-orchestrator`, dan `project-context-mapper` untuk memastikan eksekusi yang kohesif.
|
|
115
|
+
|
|
116
|
+
### Deskripsi
|
|
117
|
+
Panduan tingkat produksi untuk membangun aplikasi frontend reaktif dan terukur menggunakan **Vue 3 (Composition API)** dan **Nuxt 3**. Mencakup pengelolaan state dengan **Pinia**, utilitas **VueUse**, dan integrasi **Tailwind CSS v4**.
|
|
118
|
+
|
|
119
|
+
### Kondisi Pemicu
|
|
120
|
+
Aktifkan skill ini ketika pengguna sedang:
|
|
121
|
+
- Memulai proyek Vue 3 atau Nuxt 3 baru.
|
|
122
|
+
- Menulis ulang (refactoring) komponen ke `<script setup>` dan Composition API.
|
|
123
|
+
- Mengelola state global dengan Pinia (bukan Vuex).
|
|
124
|
+
- Menerapkan SSR (Server-Side Rendering) dengan Nuxt 3.
|
|
125
|
+
|
|
126
|
+
### Panduan Singkat
|
|
127
|
+
|
|
128
|
+
- **Composition API Default:** Selalu gunakan sintaks `<script setup lang="ts">`. Lebih ringkas, type-safe, dan efisien.
|
|
129
|
+
- **Pinia:** Gunakan Pinia dengan pola *Setup Store* (mirip Composition API) alih-alih pola Options (state, getters, actions).
|
|
130
|
+
- **Nuxt 3 Fetching:** Gunakan `useFetch` atau `useAsyncData` di dalam komponen Nuxt untuk pengambilan data saat SSR, bukan `onMounted` dengan `fetch` biasa.
|
|
131
|
+
- **Reaktivitas:** Gunakan `ref` untuk nilai primitif (string, number) dan `reactive` untuk objek bersarang yang kompleks. Utamakan `computed` daripada `watch` untuk state turunan.
|
|
132
|
+
- **VueUse:** Jangan menulis fungsi utilitas dari nol jika sudah ada di *library* VueUse (contoh: `useIntersectionObserver`, `useLocalStorage`).
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wasm-edge-computing-expert
|
|
3
|
+
description: "Expert guide for WebAssembly (WASM) and Edge Computing. Covers WASI preview 2, Spin/Fermyon, Cloudflare Workers WASM, and high-performance browser computing / Panduan ahli untuk WebAssembly (WASM) dan Edge Computing. Mencakup WASI preview 2, Spin/Fermyon, Cloudflare Workers WASM, dan komputasi performa tinggi di browser."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# WASM & Edge Computing Expert
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
A specialized guide for writing, compiling, and deploying WebAssembly (WASM) modules both on the Edge and in the browser. Covers the new WebAssembly System Interface (WASI) Preview 2, serverless execution environments (Spin, Cloudflare Workers, Fastly Compute), and bidirectional JavaScript-to-WASM interop.
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
- When porting heavy computational tasks (image processing, video encoding, cryptography) from JavaScript to Rust/Go via WASM.
|
|
21
|
+
- When deploying ultra-fast, cold-start-free serverless functions on Cloudflare Workers or Fermyon Spin.
|
|
22
|
+
- When the user asks about "WASI", "WebAssembly", or "Edge computing performance".
|
|
23
|
+
- When bridging legacy C/C++ libraries to run in the browser using Emscripten.
|
|
24
|
+
|
|
25
|
+
### Core Architectural Guidelines
|
|
26
|
+
|
|
27
|
+
#### 1. Language Choice & Toolchain
|
|
28
|
+
- **Rust (Recommended)**: Use `wasm-pack` for browser modules and `cargo component` for WASI Preview 2. Rust offers the smallest binary sizes and no garbage collector overhead.
|
|
29
|
+
- **Go**: Go 1.21+ has native WASI support (`GOOS=wasip1 GOARCH=wasm`), but binaries are larger due to the included runtime. Use TinyGo for smaller binaries.
|
|
30
|
+
- **AssemblyScript**: Use when the team only knows TypeScript, though performance is slightly less than Rust.
|
|
31
|
+
|
|
32
|
+
#### 2. Browser Integration (`wasm-bindgen`)
|
|
33
|
+
When writing Rust for the browser, minimize crossings between JS and WASM, as serialization is expensive.
|
|
34
|
+
```rust
|
|
35
|
+
use wasm_bindgen::prelude::*;
|
|
36
|
+
|
|
37
|
+
#[wasm_bindgen]
|
|
38
|
+
pub fn compute_heavy_task(input: &[u8]) -> Vec<u8> {
|
|
39
|
+
// Process data entirely in WASM before returning
|
|
40
|
+
input.iter().map(|&b| b.wrapping_add(1)).collect()
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### 3. Edge & WASI Preview 2
|
|
45
|
+
WASI Preview 2 introduces the Component Model, allowing WASM modules to securely access system resources (HTTP, Filesystem) without being tied to a specific language.
|
|
46
|
+
- Deploying to Cloudflare Workers:
|
|
47
|
+
```toml
|
|
48
|
+
# wrangler.toml
|
|
49
|
+
main = "./build/worker.js"
|
|
50
|
+
[wasm_modules]
|
|
51
|
+
MODULE = "./build/module.wasm"
|
|
52
|
+
```
|
|
53
|
+
- Deploying to Fermyon Spin: Use the `spin` CLI to build microservices entirely in WASM that start in under 1 millisecond.
|
|
54
|
+
|
|
55
|
+
#### 4. Shared Memory & Atomics
|
|
56
|
+
For multi-threaded browser WASM, use `SharedArrayBuffer` and Web Workers. Ensure your server sends the correct headers:
|
|
57
|
+
- `Cross-Origin-Opener-Policy: same-origin`
|
|
58
|
+
- `Cross-Origin-Embedder-Policy: require-corp`
|
|
59
|
+
|
|
60
|
+
## Orchestration & Integration
|
|
61
|
+
- Enhances `api-gateway-proxy-expert` for running custom logic at the edge (Cloudflare/Kong).
|
|
62
|
+
- Integrates with `rust-programming-expert` or `go-programming-expert` for module compilation.
|
|
63
|
+
- Pairs with `performance-web-vitals` to offload main-thread blocking tasks.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
<a name="bahasa-indonesia"></a>
|
|
68
|
+
## Bahasa Indonesia
|
|
69
|
+
|
|
70
|
+
### Deskripsi
|
|
71
|
+
Panduan khusus untuk menulis, mengompilasi, dan mendeploy modul WebAssembly (WASM) baik di Edge maupun di browser. Mencakup WebAssembly System Interface (WASI) Preview 2, lingkungan serverless (Spin, Cloudflare Workers), dan interoperabilitas JavaScript-ke-WASM dua arah.
|
|
72
|
+
|
|
73
|
+
### Kondisi Pemicu
|
|
74
|
+
- Saat memindahkan tugas komputasi berat (pemrosesan gambar, kriptografi) dari JavaScript ke Rust/Go melalui WASM.
|
|
75
|
+
- Saat mendeploy fungsi serverless ultra-cepat tanpa *cold start* di Cloudflare Workers atau Fermyon Spin.
|
|
76
|
+
- Saat menjembatani library C/C++ lama untuk dijalankan di browser menggunakan Emscripten.
|
|
77
|
+
|
|
78
|
+
### Panduan Arsitektur Inti
|
|
79
|
+
|
|
80
|
+
#### 1. Pilihan Bahasa & Toolchain
|
|
81
|
+
- **Rust (Direkomendasikan)**: Menghasilkan ukuran biner terkecil. Gunakan `wasm-pack` untuk web dan `cargo component` untuk WASI.
|
|
82
|
+
- **Go**: Gunakan TinyGo untuk ukuran modul yang lebih kecil, atau Go native `GOOS=wasip1` untuk dukungan WASI penuh (namun biner akan lebih besar).
|
|
83
|
+
- **AssemblyScript**: Jika tim hanya menguasai TypeScript.
|
|
84
|
+
|
|
85
|
+
#### 2. Integrasi Browser
|
|
86
|
+
Minimalkan pertukaran data (crossing) antara JavaScript dan WASM karena biaya serialisasinya tinggi. Kirim array besar (seperti `Uint8Array`) sekali, proses seluruhnya di WASM, lalu kembalikan hasilnya.
|
|
87
|
+
|
|
88
|
+
#### 3. Edge & WASI Preview 2 (Component Model)
|
|
89
|
+
WASI Preview 2 memungkinkan modul WASM mengakses resource sistem (HTTP, File) secara aman. Anda dapat mendeploy service WASM murni ke infrastruktur edge seperti Fermyon Spin atau Fastly dengan waktu mulai (startup time) di bawah 1 milidetik, jauh lebih cepat daripada container Docker tradisional.
|
|
90
|
+
|
|
91
|
+
#### 4. Shared Memory & Web Workers
|
|
92
|
+
Untuk performa multi-threading sejati di browser menggunakan WASM, gunakan `SharedArrayBuffer`. Pastikan server Anda mengirimkan header keamanan COOP dan COEP yang diwajibkan oleh browser modern.
|
|
93
|
+
|
|
94
|
+
## Integrasi Orkestrasi
|
|
95
|
+
- Memperkuat `api-gateway-proxy-expert` untuk logika kustom di edge.
|
|
96
|
+
- Terintegrasi dengan `rust-programming-expert` untuk kompilasi modul.
|
|
97
|
+
- Melengkapi `performance-web-vitals` dengan memindahkan komputasi berat dari *main thread* JavaScript.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: web-3d-graphics-expert
|
|
3
|
+
description: "Expert guide for WebGL and 3D graphics in the browser using Three.js, Babylon.js, React Three Fiber (R3F), and TresJS. Covers scene optimization, shaders, lighting, 3D model loading (GLTF/GLB), and performance tuning."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web 3D Graphics Expert (Three.js & Babylon.js)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Orchestration & Integration
|
|
17
|
+
Connects and orchestrates with relevant domain skills like `brainstorming`, `zero-to-prod-orchestrator`, and `project-context-mapper` to ensure cohesive execution.
|
|
18
|
+
|
|
19
|
+
### Description
|
|
20
|
+
Production-level guidance for developing high-performance 3D graphics in the browser. Covers the raw APIs of **Three.js** and **Babylon.js**, as well as framework-specific wrappers like **React Three Fiber (R3F)** for React and **TresJS** for Vue. Focuses on rendering performance, efficient memory management, and realistic lighting/material setups.
|
|
21
|
+
|
|
22
|
+
### Trigger Conditions
|
|
23
|
+
Activate this skill when the user is:
|
|
24
|
+
- Initializing a WebGL/WebGPU 3D scene.
|
|
25
|
+
- Using `three`, `@react-three/fiber`, `@babylonjs/core`, or `@tresjs/core`.
|
|
26
|
+
- Loading 3D models (`.glb`, `.gltf`, `.obj`).
|
|
27
|
+
- Adding advanced lighting, shadows, or Post-Processing effects (Bloom, Depth of Field).
|
|
28
|
+
- Asking about framerate drops, memory leaks, or rendering performance in 3D apps.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Core Concepts & Framework Selection
|
|
33
|
+
|
|
34
|
+
#### 1. React Three Fiber (R3F) vs Vanilla Three.js
|
|
35
|
+
When building with React, always use **React Three Fiber**. It manages the scene graph, object lifecycles, and `requestAnimationFrame` natively within the React component tree.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { Canvas } from '@react-three/fiber'
|
|
39
|
+
import { OrbitControls, Environment, useGLTF } from '@react-three/drei'
|
|
40
|
+
|
|
41
|
+
export default function App() {
|
|
42
|
+
const { scene } = useGLTF('/model.glb')
|
|
43
|
+
return (
|
|
44
|
+
<Canvas camera={{ position: [0, 2, 5] }}>
|
|
45
|
+
<ambientLight intensity={0.5} />
|
|
46
|
+
<directionalLight position={[10, 10, 5]} castShadow />
|
|
47
|
+
<primitive object={scene} />
|
|
48
|
+
<Environment preset="city" />
|
|
49
|
+
<OrbitControls />
|
|
50
|
+
</Canvas>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
*Note: Always use `@react-three/drei` for common helpers (OrbitControls, Text, Environment).*
|
|
55
|
+
|
|
56
|
+
#### 2. Babylon.js vs Three.js
|
|
57
|
+
- **Three.js**: Lighter, more flexible, vast community, excellent for creative coding, landing page animations, and React/Vue integrations.
|
|
58
|
+
- **Babylon.js**: Robust, game-engine-like architecture, built-in physics, excellent for web-based games, AR/VR (WebXR), and complex interactive simulations. Fully written in TypeScript.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Basic Babylon.js Setup
|
|
62
|
+
import { Engine, Scene, FreeCamera, Vector3, MeshBuilder, HemisphericLight } from '@babylonjs/core'
|
|
63
|
+
|
|
64
|
+
const canvas = document.getElementById('renderCanvas') as HTMLCanvasElement
|
|
65
|
+
const engine = new Engine(canvas, true)
|
|
66
|
+
const scene = new Scene(engine)
|
|
67
|
+
|
|
68
|
+
const camera = new FreeCamera('camera1', new Vector3(0, 5, -10), scene)
|
|
69
|
+
camera.setTarget(Vector3.Zero())
|
|
70
|
+
camera.attachControl(canvas, true)
|
|
71
|
+
|
|
72
|
+
const light = new HemisphericLight('light', new Vector3(0, 1, 0), scene)
|
|
73
|
+
const sphere = MeshBuilder.CreateSphere('sphere', { diameter: 2 }, scene)
|
|
74
|
+
|
|
75
|
+
engine.runRenderLoop(() => {
|
|
76
|
+
scene.render()
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### 3. Asset Loading & Optimization
|
|
81
|
+
- **Format:** ALWAYS use `.glb` or `.gltf`. Avoid `.obj` or `.fbx` in the browser as they are unoptimized.
|
|
82
|
+
- **Compression:** Use Draco compression (`glTF-Transform` or `gltf-pipeline`) to dramatically reduce file sizes.
|
|
83
|
+
- **Loading:** Preload models if they are critical to the first paint.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Best Practices for Performance
|
|
88
|
+
|
|
89
|
+
1. **Geometry and Material Reuse:**
|
|
90
|
+
Never create new Geometries or Materials inside the render loop. Instantiate them once and reuse them. Use `InstancedMesh` (Three.js) or `Thin Instances` (Babylon.js) when rendering hundreds of identical objects.
|
|
91
|
+
2. **Memory Management (Disposing):**
|
|
92
|
+
WebGL does not automatically garbage collect textures and geometries. When an object is removed from the scene, you MUST call `.dispose()` on its geometry and material.
|
|
93
|
+
*(Note: R3F handles this automatically when components unmount).*
|
|
94
|
+
3. **Shadows & Lighting:**
|
|
95
|
+
Limit the number of shadow-casting lights to 1 or 2. Use baked shadows (lightmaps) for static scenes. Use `Environment` maps (HDRI) instead of multiple lights for realistic reflections.
|
|
96
|
+
4. **Post-Processing:**
|
|
97
|
+
Post-processing requires rendering the scene multiple times. Use it sparingly. Group passes together when possible.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### Integration with Other Skills (MANDATORY)
|
|
102
|
+
|
|
103
|
+
This skill works best when combined with:
|
|
104
|
+
- `senior-frontend` — When integrating React Three Fiber into Next.js/React applications.
|
|
105
|
+
- `vue-frontend-expert` — When integrating TresJS into Vue 3/Nuxt 3 applications.
|
|
106
|
+
- `performance-web-vitals` — To optimize the bundle size of 3D libraries and reduce Total Blocking Time (TBT).
|
|
107
|
+
|
|
108
|
+
### Referenced By Orchestrators (MANDATORY)
|
|
109
|
+
|
|
110
|
+
This skill should be referenced by the following orchestrators:
|
|
111
|
+
- `brainstorming` — Add to "UI/UX & Design Systems" or create a "3D & Graphics" category.
|
|
112
|
+
- `zero-to-prod-orchestrator` — Phase 5 (Frontend Implementation).
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
<a name="bahasa-indonesia"></a>
|
|
117
|
+
## Bahasa Indonesia
|
|
118
|
+
|
|
119
|
+
### Integrasi Orkestrasi
|
|
120
|
+
Terhubung dan mengorkestrasi skill domain yang relevan seperti `brainstorming`, `zero-to-prod-orchestrator`, dan `project-context-mapper` untuk memastikan eksekusi yang kohesif.
|
|
121
|
+
|
|
122
|
+
### Deskripsi
|
|
123
|
+
Panduan produksi untuk pengembangan grafis 3D performa tinggi di browser. Mencakup **Three.js** dan **Babylon.js**, serta integrasi framework seperti **React Three Fiber (R3F)** untuk React dan **TresJS** untuk Vue. Fokus pada performa render, manajemen memori, dan pencahayaan realistis.
|
|
124
|
+
|
|
125
|
+
### Kondisi Pemicu
|
|
126
|
+
Aktifkan skill ini ketika pengguna sedang:
|
|
127
|
+
- Menginisialisasi *scene* WebGL 3D.
|
|
128
|
+
- Menggunakan library `three`, `@react-three/fiber`, atau `@babylonjs/core`.
|
|
129
|
+
- Memuat model 3D (terutama format `.glb`/`.gltf`).
|
|
130
|
+
- Mengoptimalkan FPS (frame-rate) atau menangani masalah *memory leak* pada aplikasi 3D.
|
|
131
|
+
|
|
132
|
+
### Panduan Singkat
|
|
133
|
+
- **Pemilihan Alat:** Gunakan **React Three Fiber** jika menggunakan React. Gunakan **TresJS** jika menggunakan Vue. Gunakan **Babylon.js** jika membuat game berbasis web yang membutuhkan mesin fisika kuat (physics engine).
|
|
134
|
+
- **Format Aset:** Selalu gunakan format `.glb` dengan kompresi Draco.
|
|
135
|
+
- **Performa:** Jangan membuat *Geometry* atau *Material* baru di dalam *render loop* (`requestAnimationFrame`).
|
|
136
|
+
- **Manajemen Memori:** Panggil method `.dispose()` pada geometry, material, dan texture yang sudah tidak digunakan di vanilla Three.js/Babylon.js untuk mencegah kebocoran memori.
|
|
137
|
+
- **Pencahayaan:** Gunakan *Environment map* (HDRI) untuk pencahayaan realistis yang lebih ringan diproses daripada banyak lampu *directional/point*. Batasi lampu yang memancarkan bayangan maksimal 1-2 saja.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: web-game-engine-expert
|
|
3
|
+
description: "Expert guide for web-based game development. Covers Entity Component System (ECS) architectures, physics engines (Rapier, Havok, Cannon-es), collision detection, and game loop optimization."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web Game Engine Expert (Physics & ECS)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Orchestration & Integration
|
|
17
|
+
Connects and orchestrates with relevant domain skills like `brainstorming`, `zero-to-prod-orchestrator`, and `project-context-mapper` to ensure cohesive execution.
|
|
18
|
+
|
|
19
|
+
### Description
|
|
20
|
+
Production-grade guidance for building highly interactive 3D simulations and web games. Focuses on integrating modern WebAssembly-based **Physics Engines** (Havok, Rapier, Cannon-es) and structuring application state using the **Entity Component System (ECS)** pattern (e.g., bitECS, Miniplex).
|
|
21
|
+
|
|
22
|
+
### Trigger Conditions
|
|
23
|
+
Activate this skill when the user is:
|
|
24
|
+
- Adding physics (gravity, collisions, rigid bodies) to a 3D scene (Three.js/Babylon.js).
|
|
25
|
+
- Dealing with performance issues in web games with thousands of objects.
|
|
26
|
+
- Structuring a complex game or simulation architecture.
|
|
27
|
+
- Using `@dimforge/rapier3d`, `havok`, or `cannon-es`.
|
|
28
|
+
|
|
29
|
+
### Core Concepts
|
|
30
|
+
|
|
31
|
+
#### 1. Physics Engine Integration
|
|
32
|
+
Avoid calculating collisions manually in JavaScript. Use a dedicated physics engine.
|
|
33
|
+
- **Babylon.js + Havok:** Babylon.js natively supports Havok Physics (the same engine used in AAA titles like Zelda BotW).
|
|
34
|
+
- **Three.js / React Three Fiber + Rapier:** Use `@react-three/rapier` for seamless integration in R3F. It is written in Rust and compiled to WebAssembly.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
// React Three Fiber + Rapier Example
|
|
38
|
+
import { Physics, RigidBody } from '@react-three/rapier';
|
|
39
|
+
|
|
40
|
+
function GameScene() {
|
|
41
|
+
return (
|
|
42
|
+
<Physics gravity={[0, -9.81, 0]}>
|
|
43
|
+
{/* Falling Object */}
|
|
44
|
+
<RigidBody colliders="box" position={[0, 10, 0]}>
|
|
45
|
+
<mesh>
|
|
46
|
+
<boxGeometry />
|
|
47
|
+
<meshStandardMaterial color="hotpink" />
|
|
48
|
+
</mesh>
|
|
49
|
+
</RigidBody>
|
|
50
|
+
|
|
51
|
+
{/* Static Floor */}
|
|
52
|
+
<RigidBody type="fixed" colliders="cuboid">
|
|
53
|
+
<mesh position={[0, -1, 0]}>
|
|
54
|
+
<boxGeometry args={[10, 1, 10]} />
|
|
55
|
+
<meshStandardMaterial color="gray" />
|
|
56
|
+
</mesh>
|
|
57
|
+
</RigidBody>
|
|
58
|
+
</Physics>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### 2. Entity Component System (ECS)
|
|
64
|
+
Traditional Object-Oriented Programming (OOP) can cause performance bottlenecks in games due to poor cache locality. ECS stores data in contiguous memory arrays (Components) and processes them in tight loops (Systems).
|
|
65
|
+
- Use **bitECS** for extreme performance (uses TypedArrays).
|
|
66
|
+
- Use **Miniplex** for an easier, developer-friendly React integration.
|
|
67
|
+
|
|
68
|
+
### Best Practices
|
|
69
|
+
- **Decouple Logic from Rendering:** The physics engine should update at a fixed timestep (e.g., 60Hz), while rendering should happen at the screen's refresh rate (e.g., 144Hz) using interpolation to prevent stuttering.
|
|
70
|
+
- **Use Simple Colliders:** Never use complex mesh colliders (Convex/Trimesh) for moving objects unless absolutely necessary. Use primitives (Spheres, Boxes, Capsules).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### Integration with Other Skills (MANDATORY)
|
|
75
|
+
This skill works best when combined with:
|
|
76
|
+
- `web-3d-graphics-expert` — For the visual rendering of the physics world.
|
|
77
|
+
- `webxr-ar-vr-expert` — For adding grabbable physics objects in VR space.
|
|
78
|
+
- `realtime-collaboration-expert` — For synchronizing physics state across multiple players using WebRTC.
|
|
79
|
+
|
|
80
|
+
### Referenced By Orchestrators (MANDATORY)
|
|
81
|
+
- `brainstorming` — Add to "3D & Graphics" or "Game Development".
|
|
82
|
+
- `zero-to-prod-orchestrator` — Phase 5 (Frontend / Simulation).
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
<a name="bahasa-indonesia"></a>
|
|
87
|
+
## Bahasa Indonesia
|
|
88
|
+
|
|
89
|
+
### Integrasi Orkestrasi
|
|
90
|
+
Terhubung dan mengorkestrasi skill domain yang relevan seperti `brainstorming`, `zero-to-prod-orchestrator`, dan `project-context-mapper` untuk memastikan eksekusi yang kohesif.
|
|
91
|
+
|
|
92
|
+
### Deskripsi
|
|
93
|
+
Panduan pengembangan *game* dan simulasi 3D di web. Mencakup integrasi *Physics Engine* berbasis WebAssembly (Rapier, Havok, Cannon) dan arsitektur *Entity Component System* (ECS).
|
|
94
|
+
|
|
95
|
+
### Kondisi Pemicu
|
|
96
|
+
- Saat menambahkan gravitasi, tabrakan (collision), atau benda padat (rigid body) ke dalam aplikasi 3D.
|
|
97
|
+
- Saat membuat game web yang membutuhkan performa tinggi dengan ribuan entitas.
|
|
98
|
+
|
|
99
|
+
### Panduan Singkat
|
|
100
|
+
- **Pilih Mesin Fisika:** Gunakan **Havok** jika menggunakan Babylon.js. Gunakan **Rapier** (`@react-three/rapier`) jika menggunakan Three.js/R3F.
|
|
101
|
+
- **Gunakan Collider Sederhana:** Untuk objek bergerak, selalu gunakan *primitive colliders* (Kotak, Bola, Kapsul) alih-alih *mesh collider* agar perhitungan CPU/WASM tetap ringan.
|
|
102
|
+
- **Pola ECS (Entity Component System):** Untuk game kompleks, pisahkan logika dan data menggunakan arsitektur ECS (seperti `miniplex` atau `bitECS`) untuk memaksimalkan performa *cache* memori.
|