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.
Files changed (183) hide show
  1. package/.claude/rules/vibes-plug-core.md +32 -0
  2. package/.cursor/rules/vibes-plug-core.mdc +51 -0
  3. package/.cursorrules +42 -0
  4. package/AGENTS.md +96 -0
  5. package/BLUEPRINT.md +309 -125
  6. package/CHANGELOG.md +183 -1
  7. package/CLAUDE.md +70 -0
  8. package/LICENSE +1 -1
  9. package/README.md +641 -263
  10. package/index.js +19 -0
  11. package/package.json +61 -25
  12. package/plugin.json +24 -7
  13. package/scripts/generate_swarm_gif.py +295 -0
  14. package/scripts/install.js +201 -0
  15. package/skills/accessibility-testing-expert/SKILL.md +116 -0
  16. package/skills/ai-cost-token-optimizer/SKILL.md +82 -0
  17. package/skills/ai-evals-benchmark-expert/SKILL.md +188 -0
  18. package/skills/ai-llm-integration-expert/SKILL.md +147 -122
  19. package/skills/ai-media-generation-expert/SKILL.md +172 -0
  20. package/skills/ai-prompt-engineering-expert/SKILL.md +84 -0
  21. package/skills/angular-expert/SKILL.md +148 -0
  22. package/skills/api-design-expert/SKILL.md +316 -309
  23. package/skills/api-gateway-proxy-expert/SKILL.md +81 -0
  24. package/skills/app-analyzer-optimizer/SKILL.md +195 -188
  25. package/skills/apple-ecosystem-expert/SKILL.md +145 -0
  26. package/skills/{asisten_ramah → asisten-ramah}/SKILL.md +7 -1
  27. package/skills/astro-framework-expert/SKILL.md +200 -0
  28. package/skills/async-queue-temporal-expert/SKILL.md +240 -0
  29. package/skills/authentication-identity-expert/SKILL.md +279 -45
  30. package/skills/auto-doc-updater/SKILL.md +219 -203
  31. package/skills/autonomous-chaos-monkey/SKILL.md +63 -0
  32. package/skills/autonomous-red-teamer/SKILL.md +203 -0
  33. package/skills/autonomous-tdd-debugger/SKILL.md +71 -0
  34. package/skills/background-jobs-queue-expert/SKILL.md +235 -0
  35. package/skills/biome-linter-formatter-expert/SKILL.md +89 -0
  36. package/skills/blockchain-web3-expert/SKILL.md +115 -0
  37. package/skills/bootstrap-to-modern/SKILL.md +93 -86
  38. package/skills/brainstorming/SKILL.md +381 -353
  39. package/skills/browser-automation-expert/SKILL.md +222 -0
  40. package/skills/bun-runtime-expert/SKILL.md +7 -1
  41. package/skills/chatbot-messaging-expert/SKILL.md +114 -0
  42. package/skills/ci-cd-devops-architect/SKILL.md +81 -45
  43. package/skills/cloud-hosting-expert/SKILL.md +249 -243
  44. package/skills/coderabbit/SKILL.md +197 -191
  45. package/skills/compliance-gdpr-privacy-expert/SKILL.md +85 -0
  46. package/skills/cron-scheduler-expert/SKILL.md +304 -0
  47. package/skills/data-pipeline-etl-expert/SKILL.md +84 -0
  48. package/skills/data-telemetry-expert/SKILL.md +218 -212
  49. package/skills/data-visualization-expert/SKILL.md +154 -0
  50. package/skills/database-migration-versioning-expert/SKILL.md +90 -0
  51. package/skills/database-orm-expert/SKILL.md +303 -293
  52. package/skills/dependency-upgrade-migrator/SKILL.md +301 -0
  53. package/skills/design-system-architect/SKILL.md +278 -242
  54. package/skills/desktop-electron-expert/SKILL.md +128 -0
  55. package/skills/documentation-site-expert/SKILL.md +59 -0
  56. package/skills/doku-mcp-server/SKILL.md +257 -0
  57. package/skills/doku-payment-gateway/SKILL.md +233 -0
  58. package/skills/domain-driven-design-expert/SKILL.md +82 -0
  59. package/skills/e2e-testing-expert/SKILL.md +320 -314
  60. package/skills/ecommerce-expert/SKILL.md +87 -0
  61. package/skills/edge-serverless-db-expert/SKILL.md +99 -0
  62. package/skills/email-notification-expert/SKILL.md +368 -0
  63. package/skills/error-resilience-expert/SKILL.md +486 -0
  64. package/skills/event-driven-architect/SKILL.md +86 -80
  65. package/skills/feature-flag-analytics-expert/SKILL.md +66 -0
  66. package/skills/file-upload-media-expert/SKILL.md +437 -0
  67. package/skills/firebase-security-expert/SKILL.md +7 -1
  68. package/skills/form-validation-expert/SKILL.md +407 -0
  69. package/skills/fullstack-expert/SKILL.md +260 -201
  70. package/skills/fullstack-expert/references/api_design_guide.md +466 -466
  71. package/skills/fullstack-expert/references/multi_language_backend.md +528 -528
  72. package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -253
  73. package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -326
  74. package/skills/gemini-agent-booster/SKILL.md +142 -104
  75. package/skills/geospatial-maps-expert/SKILL.md +80 -0
  76. package/skills/global-a11y-i18n-expert/SKILL.md +86 -80
  77. package/skills/glsl-shader-expert/SKILL.md +107 -0
  78. package/skills/go-programming-expert/SKILL.md +300 -294
  79. package/skills/graph-rag-knowledge-expert/SKILL.md +159 -0
  80. package/skills/graphql-apollo-expert/SKILL.md +114 -0
  81. package/skills/headless-cms-expert/SKILL.md +181 -0
  82. package/skills/hig/SKILL.md +193 -187
  83. package/skills/js-backend-expert/SKILL.md +218 -191
  84. package/skills/legacy-code-translator/SKILL.md +71 -0
  85. package/skills/local-slm-edge-ai-expert/SKILL.md +167 -0
  86. package/skills/logging-error-tracking-expert/SKILL.md +344 -0
  87. package/skills/mcp-client-orchestrator/SKILL.md +76 -0
  88. package/skills/mcp-server-architect/SKILL.md +226 -126
  89. package/skills/micro-frontend-architect/SKILL.md +112 -0
  90. package/skills/mobile-expo-expert/SKILL.md +191 -185
  91. package/skills/mobile-push-notification-expert/SKILL.md +71 -0
  92. package/skills/modern-css-native-expert/SKILL.md +189 -0
  93. package/skills/monday-design-aesthetic/SKILL.md +72 -66
  94. package/skills/monorepo-architect/SKILL.md +232 -226
  95. package/skills/mpa-orchestrator/SKILL.md +120 -101
  96. package/skills/multi-agent-orchestration/SKILL.md +173 -153
  97. package/skills/multiple-entry-points/SKILL.md +91 -55
  98. package/skills/mvc-expert/SKILL.md +237 -231
  99. package/skills/n8n-automation-expert/SKILL.md +89 -0
  100. package/skills/nextjs-app-router-expert/SKILL.md +148 -0
  101. package/skills/openapi-swagger-codegen-expert/SKILL.md +67 -0
  102. package/skills/payment-gateway-expert/SKILL.md +129 -45
  103. package/skills/pdf-document-generation-expert/SKILL.md +91 -0
  104. package/skills/performance-web-vitals/SKILL.md +337 -331
  105. package/skills/post-quantum-crypto-migrator/SKILL.md +57 -0
  106. package/skills/prd-architect/SKILL.md +206 -190
  107. package/skills/proactive-background-watcher/SKILL.md +68 -0
  108. package/skills/production-ready-hardener/PRODUCTION_READINESS_REPORT.md +67 -0
  109. package/skills/production-ready-hardener/SKILL.md +461 -468
  110. package/skills/production-ready-hardener/references/production_checklist.md +161 -161
  111. package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +881 -875
  112. package/skills/project-context-mapper/SKILL.md +85 -0
  113. package/skills/pwa-offline-first-expert/SKILL.md +185 -0
  114. package/skills/python-programming-expert/SKILL.md +407 -270
  115. package/skills/rate-limit-abuse-prevention/SKILL.md +377 -0
  116. package/skills/realtime-collaboration-expert/SKILL.md +99 -45
  117. package/skills/rich-text-editor-expert/SKILL.md +177 -0
  118. package/skills/rust-programming-expert/SKILL.md +240 -234
  119. package/skills/saas-billing/SKILL.md +382 -376
  120. package/skills/saas-multi-tenant/SKILL.md +256 -236
  121. package/skills/saas-mvp-launcher/SKILL.md +30 -1
  122. package/skills/saas-transformer/SKILL.md +499 -445
  123. package/skills/saas-transformer/references/billing_integration_guide.md +401 -401
  124. package/skills/saas-transformer/references/feature_gating_patterns.md +137 -137
  125. package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -121
  126. package/skills/saas-transformer/scripts/saas_transformation_scanner.py +39 -29
  127. package/skills/scalability-clean-code/SKILL.md +234 -228
  128. package/skills/search-engine-expert/SKILL.md +89 -0
  129. package/skills/secure-fuzz-testing/SKILL.md +7 -1
  130. package/skills/self-evolving-memory-graph/SKILL.md +91 -0
  131. package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -0
  132. package/skills/senior-frontend/SKILL.md +85 -105
  133. package/skills/seo/SKILL.md +258 -224
  134. package/skills/session-context-loader/SKILL.md +83 -0
  135. package/skills/session-handoff-resume/SKILL.md +163 -157
  136. package/skills/{skill_baru → skill-baru}/SKILL.md +177 -146
  137. package/skills/solidjs-expert/SKILL.md +80 -0
  138. package/skills/spa-orchestrator/SKILL.md +306 -287
  139. package/skills/sse-websocket-streaming-expert/SKILL.md +93 -0
  140. package/skills/state-management-expert/SKILL.md +277 -271
  141. package/skills/supabase-migration/SKILL.md +47 -1
  142. package/skills/supabase-security-expert/SKILL.md +248 -242
  143. package/skills/svelte-sveltekit-expert/SKILL.md +91 -0
  144. package/skills/svg-animation-motion-expert/SKILL.md +115 -0
  145. package/skills/tailwind-expert/SKILL.md +139 -187
  146. package/skills/tanstack-query-expert/SKILL.md +204 -198
  147. package/skills/tauri-expert/SKILL.md +7 -1
  148. package/skills/token-saver/SKILL.md +118 -110
  149. package/skills/typescript-expert/SKILL.md +329 -278
  150. package/skills/ui-components-expert/SKILL.md +166 -63
  151. package/skills/ui-ux-pro-max/SKILL.md +221 -200
  152. package/skills/vector-db-rag-expert/SKILL.md +208 -0
  153. package/skills/vibe-code-gardener/SKILL.md +180 -172
  154. package/skills/visual-qa-vision-agent/SKILL.md +71 -0
  155. package/skills/voice-ai-realtime-agent/SKILL.md +202 -0
  156. package/skills/vue-frontend-expert/SKILL.md +132 -0
  157. package/skills/wasm-edge-computing-expert/SKILL.md +97 -0
  158. package/skills/web-3d-graphics-expert/SKILL.md +137 -0
  159. package/skills/web-game-engine-expert/SKILL.md +102 -0
  160. package/skills/web-scraper/SKILL.md +98 -146
  161. package/skills/website-design-cloner/SKILL.md +180 -0
  162. package/skills/webxr-ar-vr-expert/SKILL.md +123 -0
  163. package/skills/wordpress-headless-expert/SKILL.md +144 -0
  164. package/skills/zero-to-prod-orchestrator/SKILL.md +231 -180
  165. package/skills/zero-trust-secret-vault/SKILL.md +88 -0
  166. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  167. package/CONTRIBUTING.md +0 -199
  168. package/SECURITY.md +0 -21
  169. package/banner.png +0 -0
  170. package/skills/senior-fullstack/SKILL.md +0 -167
  171. package/skills/senior-fullstack/references/architecture_patterns.md +0 -160
  172. package/skills/senior-fullstack/references/development_workflows.md +0 -222
  173. package/skills/senior-fullstack/references/tech_stack_guide.md +0 -190
  174. package/skills/senior-fullstack/scripts/code_quality_analyzer.py +0 -114
  175. package/skills/senior-fullstack/scripts/fullstack_scaffolder.py +0 -114
  176. package/skills/senior-fullstack/scripts/project_scaffolder.py +0 -114
  177. package/skills/seo-aeo-landing-page-writer/SKILL.md +0 -97
  178. package/skills/seo-geo/SKILL.md +0 -188
  179. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
  180. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
  181. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
  182. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
  183. package/skills/ui_ux_expert/SKILL.md +0 -114
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: astro-framework-expert
3
+ description: "Expert guide for Astro 5+ framework — Content Collections, Islands Architecture, View Transitions, partial hydration, and MDX integration / Panduan ahli framework Astro 5+ — Content Collections, Islands Architecture, View Transitions, partial hydration, dan integrasi MDX."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # Astro Framework Expert (2026 Edition)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Orchestration & Integration
17
+ - **`seo`**: Astro's built-in SEO capabilities, sitemaps, and structured data.
18
+ - **`performance-web-vitals`**: Astro's zero-JS-by-default performance optimization.
19
+ - **`tailwind-expert`**: Tailwind CSS v4 integration with Astro.
20
+ - **`headless-cms-expert`**: Content fetching from Sanity/Payload/Strapi in Astro.
21
+ - **`ci-cd-devops-architect`**: Deploying Astro to Vercel, Cloudflare Pages, or Netlify.
22
+
23
+ ### Description
24
+ Expert guide for building high-performance, content-first websites with Astro 5+. Covers Content Collections (type-safe content), Islands Architecture (partial hydration), View Transitions, server-side rendering, hybrid rendering, MDX integration, Astro DB, and multi-framework component support (React, Vue, Svelte in one project).
25
+
26
+ ### Trigger Conditions
27
+ - Building content-heavy websites (blogs, docs, marketing pages, portfolios).
28
+ - Choosing between Astro and Next.js for a content-first project.
29
+ - Implementing partial hydration or Islands Architecture.
30
+ - Creating documentation sites or landing pages optimized for performance.
31
+ - Using multiple UI frameworks (React + Vue + Svelte) in one project.
32
+
33
+ ---
34
+
35
+ ### Core Concepts
36
+
37
+ #### Astro vs Next.js Decision Guide
38
+
39
+ | Criteria | Astro 5 | Next.js 15 |
40
+ |----------|---------|------------|
41
+ | Primary Focus | Content sites | Full-stack apps |
42
+ | Default JS Shipped | 0 KB | React runtime |
43
+ | Rendering | Static-first, opt-in SSR | SSR-first, opt-in static |
44
+ | Multi-framework | ✅ React, Vue, Svelte, Solid | React only |
45
+ | Content Collections | ✅ Built-in, type-safe | Manual with MDX |
46
+ | Server Islands | ✅ Deferred rendering | PPR (similar) |
47
+ | **Choose When** | Content, SEO, speed critical | Complex interactivity |
48
+
49
+ **Recommendation:** Choose **Astro** for content-driven sites where performance and SEO are top priorities. Choose **Next.js** for interactive web applications with complex state.
50
+
51
+ #### 1. Project Setup
52
+
53
+ ```bash
54
+ # Create new Astro project
55
+ npm create astro@latest ./my-site -- --template blog --typescript strict
56
+
57
+ # Add integrations
58
+ npx astro add tailwind react mdx sitemap
59
+ ```
60
+
61
+ #### 2. Content Collections (Type-Safe Content)
62
+
63
+ ```typescript
64
+ // src/content/config.ts
65
+ import { defineCollection, z } from 'astro:content';
66
+
67
+ const blog = defineCollection({
68
+ type: 'content', // Markdown/MDX files
69
+ schema: z.object({
70
+ title: z.string(),
71
+ description: z.string(),
72
+ pubDate: z.coerce.date(),
73
+ heroImage: z.string().optional(),
74
+ tags: z.array(z.string()).default([]),
75
+ draft: z.boolean().default(false),
76
+ }),
77
+ });
78
+
79
+ const authors = defineCollection({
80
+ type: 'data', // JSON/YAML files
81
+ schema: z.object({
82
+ name: z.string(),
83
+ avatar: z.string(),
84
+ bio: z.string(),
85
+ }),
86
+ });
87
+
88
+ export const collections = { blog, authors };
89
+ ```
90
+
91
+ ```astro
92
+ ---
93
+ // src/pages/blog/[...slug].astro
94
+ import { getCollection } from 'astro:content';
95
+
96
+ export async function getStaticPaths() {
97
+ const posts = await getCollection('blog', ({ data }) => !data.draft);
98
+ return posts.map((post) => ({
99
+ params: { slug: post.slug },
100
+ props: { post },
101
+ }));
102
+ }
103
+
104
+ const { post } = Astro.props;
105
+ const { Content } = await post.render();
106
+ ---
107
+
108
+ <article>
109
+ <h1>{post.data.title}</h1>
110
+ <time>{post.data.pubDate.toLocaleDateString()}</time>
111
+ <Content />
112
+ </article>
113
+ ```
114
+
115
+ #### 3. Islands Architecture (Partial Hydration)
116
+
117
+ ```astro
118
+ ---
119
+ // Only hydrate interactive components — rest ships as 0 JS
120
+ import Newsletter from '../components/Newsletter.tsx';
121
+ import Counter from '../components/Counter.vue';
122
+ import Chart from '../components/Chart.svelte';
123
+ ---
124
+
125
+ <!-- Static by default — no JS shipped -->
126
+ <h1>My Blog Post</h1>
127
+ <p>This is static HTML with zero JavaScript.</p>
128
+
129
+ <!-- Hydrate only when visible (lazy loading) -->
130
+ <Newsletter client:visible />
131
+
132
+ <!-- Hydrate on page load -->
133
+ <Counter client:load />
134
+
135
+ <!-- Hydrate only on interaction (click, hover) -->
136
+ <Chart client:idle />
137
+
138
+ <!-- Hydrate only on specific media query -->
139
+ <MobileMenu client:media="(max-width: 768px)" />
140
+ ```
141
+
142
+ #### 4. View Transitions
143
+
144
+ ```astro
145
+ ---
146
+ // src/layouts/BaseLayout.astro
147
+ import { ViewTransitions } from 'astro:transitions';
148
+ ---
149
+ <html>
150
+ <head>
151
+ <ViewTransitions />
152
+ </head>
153
+ <body>
154
+ <nav transition:persist><!-- Persists across pages --></nav>
155
+ <main transition:animate="slide">
156
+ <slot />
157
+ </main>
158
+ </body>
159
+ </html>
160
+ ```
161
+
162
+ #### 5. Server Islands (Deferred Rendering)
163
+
164
+ ```astro
165
+ ---
166
+ // Renders on the server, deferred from the initial page load
167
+ // Great for personalized content in otherwise static pages
168
+ ---
169
+ <UserGreeting server:defer>
170
+ <p slot="fallback">Loading...</p>
171
+ </UserGreeting>
172
+ ```
173
+
174
+ ### Production Checklist
175
+ - [ ] Content Collections with strict Zod schemas.
176
+ - [ ] Sitemap integration enabled (`@astrojs/sitemap`).
177
+ - [ ] Image optimization with `astro:assets`.
178
+ - [ ] View Transitions for smooth page navigation.
179
+ - [ ] Hybrid rendering (static + SSR where needed).
180
+ - [ ] Deploy adapter configured (Vercel, Cloudflare, Node).
181
+
182
+ ---
183
+
184
+ <a name="bahasa-indonesia"></a>
185
+ ## Bahasa Indonesia
186
+
187
+ ### Integrasi Orkestrasi
188
+ - **`seo`**: Kemampuan SEO bawaan Astro, sitemap, dan data terstruktur.
189
+ - **`performance-web-vitals`**: Optimasi performa zero-JS-by-default Astro.
190
+ - **`tailwind-expert`**: Integrasi Tailwind CSS v4 dengan Astro.
191
+ - **`headless-cms-expert`**: Pengambilan konten dari Sanity/Payload/Strapi di Astro.
192
+
193
+ ### Deskripsi
194
+ Panduan ahli untuk membangun website berperforma tinggi dan berfokus konten dengan Astro 5+. Mencakup Content Collections, Islands Architecture (partial hydration), View Transitions, rendering hybrid, integrasi MDX, Astro DB, dan dukungan multi-framework (React, Vue, Svelte dalam satu proyek).
195
+
196
+ ### Kondisi Pemicu
197
+ - Membangun website berat konten (blog, docs, halaman marketing, portfolio).
198
+ - Memilih antara Astro dan Next.js untuk proyek konten.
199
+ - Mengimplementasikan partial hydration atau Islands Architecture.
200
+ - Membuat situs dokumentasi atau landing page yang dioptimalkan untuk performa.
@@ -0,0 +1,240 @@
1
+ ---
2
+ name: async-queue-temporal-expert
3
+ description: "Expert guide for Durable Workflow Engines (Temporal.io, Trigger.dev v3, Inngest, BullMQ v5) and fault-tolerant background sagas / Panduan ahli workflow engine tahan-gagal (Temporal, Trigger.dev, Inngest, BullMQ)."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # Async Queue & Durable Workflow Expert (Temporal & Sagas 2026)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Purpose & Overview
17
+ Production-grade architectural guide for designing durable, fault-tolerant background execution pipelines, asynchronous job queues, and distributed state machines using **Temporal.io**, **Trigger.dev v3**, **Inngest**, and **BullMQ v5**. Guarantees eventual completion across long-running sagas, API rate limits, worker crashes, and network partitions.
18
+
19
+ ### Key Capabilities
20
+ 1. **Durable State Machines**: Workflows survive process restarts, deployments, and database blips without losing state or re-executing completed side-effects.
21
+ 2. **Distributed Saga Pattern**: Multi-step transactions paired with automated compensating activities (rollbacks) whenever a downstream service permanently fails.
22
+ 3. **Idempotency & Deduplication**: Ensuring unique idempotency keys per transaction to prevent double billing or duplicate emails.
23
+ 4. **Queue Concurrency & Rate Limiting**: Token-bucket throttles, exponential backoff with jitter, and dead-letter queues (DLQ) for poison-pill isolation.
24
+
25
+ ---
26
+
27
+ ### Production Implementation Recipes
28
+
29
+ #### Recipe 1: Temporal.io Saga Pattern with Compensations (TypeScript SDK)
30
+ ```typescript
31
+ import { proxyActivities, ApplicationFailure } from '@temporalio/workflow';
32
+ import type * as activities from './activities';
33
+
34
+ // Proxy activities with aggressive retry policies
35
+ const { chargeCustomer, provisionLicense, sendWelcomeEmail, refundCustomer, revokeLicense } =
36
+ proxyActivities<typeof activities>({
37
+ startToCloseTimeout: '1 minute',
38
+ retry: {
39
+ initialInterval: '1s',
40
+ backoffCoefficient: 2,
41
+ maximumAttempts: 5,
42
+ nonRetryableErrorTypes: ['InvalidCardError', 'AccountSuspendedError'],
43
+ },
44
+ });
45
+
46
+ export interface SubscriptionWorkflowInput {
47
+ customerId: string;
48
+ planId: string;
49
+ amountCents: number;
50
+ }
51
+
52
+ /**
53
+ * Distributed Subscription Saga with Compensating Rollbacks
54
+ */
55
+ export async function subscriptionSagaWorkflow(input: SubscriptionWorkflowInput): Promise<{ status: string }> {
56
+ const compensations: Array<() => Promise<void>> = [];
57
+
58
+ try {
59
+ // Step 1: Charge Customer
60
+ const chargeResult = await chargeCustomer(input.customerId, input.amountCents);
61
+ compensations.unshift(() => refundCustomer(chargeResult.chargeId));
62
+
63
+ // Step 2: Provision License
64
+ const licenseResult = await provisionLicense(input.customerId, input.planId);
65
+ compensations.unshift(() => revokeLicense(licenseResult.licenseId));
66
+
67
+ // Step 3: Send Welcome Notification
68
+ await sendWelcomeEmail(input.customerId, licenseResult.licenseKey);
69
+
70
+ return { status: 'COMPLETED' };
71
+ } catch (error) {
72
+ // Execute compensating activities in reverse order
73
+ for (const compensate of compensations) {
74
+ try {
75
+ await compensate();
76
+ } catch (compError) {
77
+ console.error('Compensation failed, alerting on-call engineer:', compError);
78
+ }
79
+ }
80
+ throw ApplicationFailure.create({
81
+ message: `Subscription saga failed and rolled back: ${(error as Error).message}`,
82
+ nonRetryable: true,
83
+ });
84
+ }
85
+ }
86
+ ```
87
+
88
+ #### Recipe 2: Trigger.dev v3 Durable Task with Idempotency
89
+ ```typescript
90
+ import { task } from '@trigger.dev/sdk/v3';
91
+
92
+ export const generateEnterpriseAnalyticsReport = task({
93
+ id: 'generate-enterprise-report',
94
+ retry: {
95
+ maxAttempts: 4,
96
+ minTimeoutInMs: 2000,
97
+ factor: 2,
98
+ randomize: true, // Jitter
99
+ },
100
+ run: async (payload: { tenantId: string; month: string }, { ctx }) => {
101
+ // Automatic checkpointing: each step runs durably
102
+ const data = await ctx.run('fetch-telemetry', async () => {
103
+ return await fetchTelemetryFromWarehouse(payload.tenantId, payload.month);
104
+ });
105
+
106
+ const pdfUrl = await ctx.run('render-pdf', async () => {
107
+ return await generateReportPdf(data);
108
+ });
109
+
110
+ await ctx.run('dispatch-webhook', async () => {
111
+ return await sendWebhookNotification(payload.tenantId, pdfUrl);
112
+ });
113
+
114
+ return { success: true, pdfUrl };
115
+ },
116
+ });
117
+ ```
118
+
119
+ ---
120
+
121
+ ### Implementation Checklist
122
+ - [ ] Implement Saga rollback handlers for multi-step distributed payments and user provisioning.
123
+ - [ ] Enforce deterministic code inside Temporal workflows (never use `Math.random()`, `Date.now()`, or direct DB calls in workflow files; run them inside activities).
124
+ - [ ] Store large payloads in object storage (S3/R2); pass only IDs and signed URLs through queues.
125
+ - [ ] Configure DLQ (Dead Letter Queue) and alert thresholds for persistent failures.
126
+
127
+ ## Orchestration & Integration
128
+ - Integrates with: `js-backend-expert`, `background-jobs-queue-expert`, `error-resilience-expert`, `saas-billing`, `doku-payment-gateway`.
129
+
130
+ ---
131
+
132
+ <a name="bahasa-indonesia"></a>
133
+ ## Bahasa Indonesia
134
+
135
+ ### Tujuan & Gambaran Umum
136
+ Panduan arsitektur tingkat produksi untuk merancang pipeline eksekusi background yang tahan-gagal (durable execution), antrean tugas asinkron, dan state machine terdistribusi menggunakan **Temporal.io**, **Trigger.dev v3**, **Inngest**, dan **BullMQ v5**. Menjamin penyelesaian mutlak tugas berdurasi panjang terhadap pembatasan rate limit API, kegagalan worker, dan partisi jaringan.
137
+
138
+ ### Kemampuan Utama
139
+ 1. **State Machine Tahan-Gagal (Durable Execution)**: Alur kerja (workflow) tetap bertahan saat restart server, deployment, atau gangguan database tanpa kehilangan progres state.
140
+ 2. **Pola Transaksi Terdistribusi (Saga Pattern)**: Transaksi multi-langkah yang dilengkapi dengan aktivitas kompensasi (rollback otomatis) jika langkah lanjutan gagal permanen.
141
+ 3. **Idempotensi & Anti-Duplikasi**: Menjamin kunci idempotensi unik pada setiap transaksi guna mencegah duplikasi penagihan atau email berulang.
142
+ 4. **Pembatasan Rate Limit & DLQ**: Throttling berbasis token bucket, exponential backoff dengan jitter acak, dan dead-letter queue (DLQ) untuk mengisolasi tugas beracun (*poison pills*).
143
+
144
+ ---
145
+
146
+ ### Resep Implementasi Produksi
147
+
148
+ #### Resep 1: Pola Saga Temporal.io dengan Logika Kompensasi (TypeScript)
149
+ ```typescript
150
+ import { proxyActivities, ApplicationFailure } from '@temporalio/workflow';
151
+ import type * as activities from './activities';
152
+
153
+ const { tagihPelanggan, aktifkanLisensi, kirimEmailSambutan, kembalikanDana, cabutLisensi } =
154
+ proxyActivities<typeof activities>({
155
+ startToCloseTimeout: '1 minute',
156
+ retry: {
157
+ initialInterval: '1s',
158
+ backoffCoefficient: 2,
159
+ maximumAttempts: 5,
160
+ },
161
+ });
162
+
163
+ export interface InputWorkflowLangganan {
164
+ customerId: string;
165
+ planId: string;
166
+ amountCents: number;
167
+ }
168
+
169
+ export async function workflowSagaLangganan(input: InputWorkflowLangganan) {
170
+ const kompensasi: Array<() => Promise<void>> = [];
171
+
172
+ try {
173
+ // Langkah 1: Tagih Pembayaran
174
+ const hasilTagihan = await tagihPelanggan(input.customerId, input.amountCents);
175
+ kompensasi.unshift(() => kembalikanDana(hasilTagihan.chargeId));
176
+
177
+ // Langkah 2: Aktifkan Lisensi
178
+ const hasilLisensi = await aktifkanLisensi(input.customerId, input.planId);
179
+ kompensasi.unshift(() => cabutLisensi(hasilLisensi.licenseId));
180
+
181
+ // Langkah 3: Kirim Notifikasi
182
+ await kirimEmailSambutan(input.customerId, hasilLisensi.licenseKey);
183
+
184
+ return { status: 'SELESAI' };
185
+ } catch (error) {
186
+ // Eksekusi kompensasi rollback secara berurutan mundur
187
+ for (const compensate of kompensasi) {
188
+ try {
189
+ await compensate();
190
+ } catch (err) {
191
+ console.error('Kompensasi gagal:', err);
192
+ }
193
+ }
194
+ throw ApplicationFailure.create({
195
+ message: `Saga gagal dan dilakukan rollback: ${(error as Error).message}`,
196
+ nonRetryable: true,
197
+ });
198
+ }
199
+ }
200
+ ```
201
+
202
+ #### Resep 2: Tugas Background Tahan-Gagal Trigger.dev v3
203
+ ```typescript
204
+ import { task } from '@trigger.dev/sdk/v3';
205
+
206
+ export const buatLaporanAnalitik = task({
207
+ id: 'buat-laporan-analitik',
208
+ retry: {
209
+ maxAttempts: 4,
210
+ factor: 2,
211
+ randomize: true, // Jitter
212
+ },
213
+ run: async (payload: { tenantId: string; bulan: string }, { ctx }) => {
214
+ const data = await ctx.run('ambil-data', async () => {
215
+ return await ambilDataWarehouse(payload.tenantId, payload.bulan);
216
+ });
217
+
218
+ const urlPdf = await ctx.run('buat-pdf', async () => {
219
+ return await renderDokumenPdf(data);
220
+ });
221
+
222
+ await ctx.run('kirim-webhook', async () => {
223
+ return await notifikasiWebhook(payload.tenantId, urlPdf);
224
+ });
225
+
226
+ return { sukses: true, urlPdf };
227
+ },
228
+ });
229
+ ```
230
+
231
+ ---
232
+
233
+ ### Checklist Implementasi
234
+ - [ ] Terapkan penanganan rollback (Saga) untuk alur transaksi pembayaran dan provisi akun bertahap.
235
+ - [ ] Pastikan kode di dalam alur Temporal selalu deterministik (jangan gunakan `Math.random()` atau kueri DB langsung di dalam workflow, tempatkan di dalam activities).
236
+ - [ ] Pindahkan berkas besar ke S3/R2 dan hanya teruskan referensi ID melalui queue.
237
+ - [ ] Pasang konfigurasi DLQ (Dead Letter Queue) dan notifikasi peringatan jika ada job yang macet.
238
+
239
+ ## Integrasi Orkestrasi
240
+ - Terintegrasi dengan: `js-backend-expert`, `background-jobs-queue-expert`, `error-resilience-expert`, `saas-billing`, `doku-payment-gateway`.