@sylphx/flow 2.4.2 → 2.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sylphx/flow
2
2
 
3
+ ## 2.6.0 (2025-12-17)
4
+
5
+ ### ✨ Features
6
+
7
+ - **commands:** add Vercel Blob upload governance to saas-review ([aabcd25](https://github.com/SylphxAI/flow/commit/aabcd25eb7d19725173db0b08018626b91b95daa))
8
+
9
+ ## 2.5.0 (2025-12-17)
10
+
11
+ ### ✨ Features
12
+
13
+ - **commands:** add /saas-review for full-stack SaaS product review ([bcd004c](https://github.com/SylphxAI/flow/commit/bcd004cf4e34a34a4325652088c54882fa0c327d))
14
+
3
15
  ## 2.4.2 (2025-12-10)
4
16
 
5
17
  ### 🐛 Bug Fixes
@@ -0,0 +1,275 @@
1
+ ---
2
+ name: saas-review
3
+ description: Full-stack SaaS product review - architecture, billing, security, compliance, growth
4
+ agent: coder
5
+ ---
6
+
7
+ # Global Subscription Web Product — Master Specification and Review Mandate
8
+
9
+ ## 1) Mandate and Work Model
10
+
11
+ * Perform a complete end-to-end review across product, engineering, security, compliance, growth, operations, and UX.
12
+ * **Delegate work to multiple workers; you act as the final gate to improve quality.**
13
+ * Deliverables must be stated as **standards, constraints, and acceptance criteria**; avoid low-level implementation prescriptions unless required for correctness or compliance.
14
+ * **Single-pass delivery**: no roadmap, no phasing, no deferrals; deliver an integrated outcome that satisfies all requirements simultaneously.
15
+ * **Exploration required**: the review must not be limited to this document; identify additional improvements for competitiveness, completeness, usability, reliability, and monetization within fixed constraints.
16
+
17
+ ## 2) Non-Negotiable Engineering Principles
18
+
19
+ * No workarounds, hacks, or TODOs.
20
+ * Feature-first with clean architecture; designed for easy extension; no "god files".
21
+ * Type-first, strict end-to-end correctness (**DB → API → UI**).
22
+ * Serverless-first and server-first; edge-compatible where feasible without sacrificing correctness, security, or observability.
23
+ * Mobile-first responsive design; desktop-second.
24
+ * Precise naming; remove dead/unused code.
25
+ * Upgrade all packages to latest stable; avoid deprecated patterns.
26
+
27
+ ## 3) Fixed Platform, Stack, and Tooling (Locked)
28
+
29
+ * Platform: **Vercel**
30
+ * Framework: **Next.js** (SSR-first for indexable/discovery)
31
+ * API: **tRPC** for all internal application APIs
32
+ * i18n: **next-intl**
33
+ * DB: **Neon (Postgres)**
34
+ * ORM: **Drizzle**
35
+ * Auth: **better-auth**
36
+ * Payments: **Stripe**
37
+ * Email: **Resend**
38
+ * Observability: **Sentry**
39
+ * Analytics: **PostHog**
40
+ * Cache / rate limiting / workflows: **Upstash Redis + Upstash Workflows + QStash**
41
+ * Tooling baseline: **Bun**, **Biome**, **Bun test**
42
+ * Tag management: **GTM (marketing tags only)**
43
+
44
+ ## 4) Architecture and Data Foundations
45
+
46
+ ### 4.1 Boundaries, Server Enforcement, and Consistency Model (Hard Requirement)
47
+
48
+ * Define clear boundaries: domain rules, use-cases, integrations, UI.
49
+ * All authorization/entitlements are **server-enforced**; no client-trust.
50
+ * Runtime constraints (serverless/edge) must be explicit and validated.
51
+ * **Consistency model is mandatory for high-value state**: for billing, entitlements, ledger, admin privilege grants, and security posture, the system must define and enforce an explicit consistency model (source-of-truth, allowed delay windows, retry/out-of-order handling, and acceptable eventual consistency bounds).
52
+ * **Billing and access state machine is mandatory**: define and validate the mapping **Stripe state → internal subscription state → entitlements**, including trial, past_due, unpaid, canceled, refund, and dispute outcomes. UI must only present interpretable, non-ambiguous states derived from server-truth.
53
+ * **No dual-write (hard requirement)**: subscription/payment truth must be derived from Stripe-driven events; internal systems must not directly rewrite billing truth or authorize entitlements based on non-Stripe truth, except for explicitly defined admin remediation flows that are fully server-enforced and fully audited.
54
+ * **Server-truth is authoritative**: UI state must never contradict server-truth. Where asynchronous confirmation exists, UI must represent that state unambiguously and remain explainable.
55
+ * **Auditability chain is mandatory** for any high-value mutation: who/when/why, before/after state, and correlation to the triggering request/job/webhook must be recorded and queryable.
56
+
57
+ ### 4.2 Drizzle Migrations (Non-Negotiable)
58
+
59
+ * Migration files must exist, be complete, and be committed.
60
+ * Deterministic, reproducible, environment-safe; linear/auditable history; no drift.
61
+ * CI must fail if schema changes are not represented by migrations.
62
+
63
+ ### 4.3 Financial-Grade Balance System (Only if "balance/credits/wallet" exists)
64
+
65
+ * Any balance concept must be implemented as an **immutable ledger** (append-only source of truth), not a mutable balance field.
66
+ * Deterministic precision (no floats), idempotent posting, concurrency safety, transactional integrity, and auditability are required.
67
+ * Monetary flows must be currency-based and reconcilable with Stripe; credits (if used) must be governed as non-cash entitlements.
68
+
69
+ ### 4.4 Vercel Blob Upload Governance (Hard Requirement)
70
+
71
+ * All uploads must be **intent-based and server-verified**.
72
+ * The client must upload to Vercel Blob first using short-lived, server-issued authorization (e.g., signed upload URL / token), then call a server finalize endpoint to persist the resulting Blob URL/key.
73
+ * The server must validate the Blob URL/key ownership and namespace, and must match it against the originating upload intent (who/what/where/expiry/constraints) before attaching it to any resource.
74
+ * The system must support safe retries and idempotent finalize; expired/abandoned intents must be cleanable and auditable.
75
+
76
+ ## 5) Internationalization, Routing, and Canonicalization (Keep Precise)
77
+
78
+ ### 5.1 Supported Locales
79
+
80
+ `en`, `zh-Hans`, `zh-Hant`, `es`, `ja`, `ko`, `de`, `fr`, `pt-BR`, `it`, `nl`, `pl`, `tr`, `id`, `th`, `vi`
81
+
82
+ ### 5.2 URL Strategy: Prefix Except Default
83
+
84
+ * English is default and non-prefixed.
85
+ * `/en/*` must not exist; permanently redirect to non-prefixed equivalent.
86
+ * All non-default locales are `/<locale>/...`.
87
+
88
+ ### 5.3 Globalization Rules
89
+
90
+ * Intl formatting; explicit fallback rules.
91
+ * Missing translation keys must fail build.
92
+ * No hardcoded user-facing strings outside localization.
93
+
94
+ ### 5.4 UGC Canonicalization
95
+
96
+ * Separate UI language from content language.
97
+ * Exactly one canonical URL per UGC resource determined by content language.
98
+ * No indexable locale-prefixed duplicates unless primary content is truly localized; otherwise redirect to canonical.
99
+ * Canonical/hreflang/sitemap must reflect only true localized variants.
100
+
101
+ ## 6) Product Systems (Capabilities + Governance)
102
+
103
+ ### 6.1 Membership and Account Security
104
+
105
+ * Membership is entitlement-driven and server-enforced.
106
+ * Provide a dedicated **Account Security** surface.
107
+ * **Account Security minimum acceptance**: session/device visibility and revocation; MFA/passkey management; linked identity provider management; key security event visibility (and export where applicable). All server-enforced and auditable.
108
+
109
+ ### 6.2 Identity, Verification, and Sign-in
110
+
111
+ * SSO providers (minimum): **Google, Apple, Facebook, Microsoft, GitHub** (prioritize by audience).
112
+ * If provider env/secrets are missing, **hide** the login option (no broken/disabled UI).
113
+ * Allow linking multiple providers and safe unlinking; server-enforced and abuse-protected.
114
+ * Passkeys (WebAuthn) are first-class with secure enrollment/usage/recovery.
115
+ * Verification:
116
+
117
+ * **Email verification is mandatory** baseline for high-impact capabilities.
118
+ * **Phone verification is optional** and used as risk-based step-up (anti-abuse, higher-trust flows, recovery); consent-aware and data-minimizing.
119
+
120
+ ### 6.3 Billing and Payments (Stripe)
121
+
122
+ * Support subscriptions and one-time payments as product needs require.
123
+ * **Billing state machine follows §4.1 mapping requirements**; UI must only surface explainable, non-ambiguous states aligned to server-truth.
124
+ * Webhooks must be idempotent, retry-safe, out-of-order safe, auditable; billing UI reflects server-truth state without ambiguity.
125
+ * **Webhook trust is mandatory (high-risk)**: webhook origin must be verified (signature verification and replay resistance). The Stripe **event id** must be used as the idempotency and audit correlation key; unverifiable events must be rejected and must trigger alerting.
126
+ * **Out-of-order behavior must be explicit**: all webhook handlers must define and enforce a clear out-of-order strategy (event ordering is not guaranteed even for the same subscription), and must use the §4.1 consistency model to define final-state decision rules.
127
+ * Tax/invoicing and refund/dispute handling must be behaviorally consistent with product UX and entitlement state.
128
+ * **Stripe pricing governance is mandatory (Stripe-first, not Dashboard-first)**:
129
+
130
+ * Stripe is the system-of-record for products, prices, subscriptions, invoices, and disputes; internal systems must not contradict Stripe truth.
131
+ * Pricing changes must be performed by creating new Stripe Prices and updating the "active sellable price" policy; historical prices must remain immutable for existing subscriptions unless an approved migration is executed.
132
+ * Default pricing change policy is **grandfathering**: existing subscribers keep their current price; new customers use the currently active sellable price.
133
+ * An operational-grade Pricing Admin must exist to manage creation of new Stripe Prices, activation/deactivation of sellable prices, and (optionally) controlled bulk subscription migrations; all actions must be governed by RBAC, step-up controls, and audit logs.
134
+ * Stripe Dashboard is treated as monitoring/emergency access; non-admin Stripe changes must be detectable (drift), alertable, and remediable.
135
+
136
+ ### 6.4 Admin Platform (Operational-Grade)
137
+
138
+ * Baseline: RBAC (least privilege), audit logs, feature flags governance, optional impersonation with safeguards and auditing.
139
+ * Admin bootstrap must not rely on file seeding:
140
+
141
+ * Use a secure, auditable **first-login allowlist** for the initial SUPER_ADMIN.
142
+ * Permanently disable bootstrap after completion.
143
+ * All privilege grants must be server-enforced and recorded in the audit log.
144
+ * The allowlist must be managed via secure configuration (environment/secret store), not code or DB seeding.
145
+ * **Configuration management is mandatory**:
146
+
147
+ * All **non-secret** product-level configuration must be manageable via admin (server-enforced), with validation and change history.
148
+ * Secrets/credentials are environment-managed only; admin may expose safe readiness/health visibility, not raw secrets.
149
+ * **Admin analytics and reporting are mandatory**:
150
+
151
+ * Provide comprehensive dashboards/reports for business, growth, billing, referral, support, and security/abuse signals, governed by RBAC.
152
+ * Reporting must be consistent with system-of-record truth (billing/webhooks, ledger, entitlements) and auditable when derived from privileged actions.
153
+ * **Admin operational management is mandatory**:
154
+
155
+ * Tools for user/account management, entitlements/access management, lifecycle actions, and issue resolution workflows.
156
+ * Actions affecting access, money/credits, or security posture require appropriate step-up controls and must be fully auditable; reversibility must follow domain rules.
157
+
158
+ ### 6.5 Support and Communications
159
+
160
+ * Support/Contact surface must be discoverable, localized, WCAG AA, SEO-complete, privacy-safe, and auditable where relevant.
161
+ * Newsletter subscription/preferences must be consent-aware; unsubscribe enforcement must be reliable.
162
+
163
+ ### 6.6 Referral (Anti-Abuse Baseline Required)
164
+
165
+ * Referral must be measurable, abuse-resistant, and governed:
166
+
167
+ * attribution semantics, reward lifecycle governance (including revocation/clawbacks), anti-fraud, admin reporting/audit,
168
+ * localized and instrumented.
169
+ * **Referral anti-fraud minimum baseline is mandatory**:
170
+
171
+ * define a minimum set of risk signals and enforcement measures, including velocity controls, account/device linkage posture, risk-tiered enforcement, reward delay/hold/freeze, clawback conditions, and an auditable manual review/appeal posture where applicable.
172
+
173
+ ## 7) UX, Design System, and Guidance
174
+
175
+ * Design-system driven UI (tokens), dark/light theme, WCAG AA, CLS-safe, responsive.
176
+ * Iconify; no emoji in UI content.
177
+ * Guidance is mandatory for all user-facing features and monetization flows: discoverable, clear, dismissible with re-entry, localized and measurable, governed by eligibility and frequency controls.
178
+
179
+ ## 8) Web Platform: SEO, PWA, Performance
180
+
181
+ * SEO-first + SSR-first for indexable/discovery.
182
+ * Required: metadata + Open Graph + favicon; canonical; hreflang + x-default; schema.org; sitemap.xml; robots.txt.
183
+ * PWA: manifest, service worker with explicit cache correctness; push notifications using VAPID where applicable.
184
+ * **Service Worker caching boundary is mandatory**: service worker must not cache personalized/sensitive/authorized content. Authenticated and entitlement-sensitive routes must have explicit cache-control and SW rules, and must be validated by tests to prevent stale or unauthorized state exposure.
185
+ * Performance must be **measurable and regression-resistant**:
186
+
187
+ * define and enforce performance budgets for key journeys,
188
+ * define caching boundaries and correctness requirements across SSR/ISR/static and service worker behavior,
189
+ * monitor Core Web Vitals and server latency; alert on regressions.
190
+
191
+ ## 9) Growth System (Onboarding, Share/Viral, Retention)
192
+
193
+ * The review must produce a coherent, measurable growth system for activation, sharing/virality, and retention, aligned with compliance and anti-abuse constraints.
194
+ * Onboarding must be outcome-oriented, localized, accessible, and instrumented.
195
+ * Sharing/virality must be consent-aware, abuse-resistant, and measurable end-to-end.
196
+ * Retention must be intentionally engineered, monitored, and protected against regressions.
197
+
198
+ ## 10) Trust, Safety, Security, Privacy, Compliance, and Operability
199
+
200
+ * **Behavioral consistency is required**: policy and disclosures must match actual behavior across UI, data handling, logging/observability, analytics, support operations, and marketing tags; mismatches are release-blocking.
201
+ * **Consent governance is mandatory (release-blocking)**:
202
+
203
+ * Analytics (PostHog) and marketing/newsletter communications (Resend) must be governed by consent and user preferences.
204
+ * Marketing tags (including GTM and Google Ads) must not load or fire without the appropriate consent.
205
+ * Without consent, tracking and marketing sends must not occur, except for strictly necessary service communications.
206
+ * Event schemas and attributes must follow data minimization, with explicit PII classification and handling rules.
207
+ * **Marketing attribution and conversions are governed (hard requirement)**:
208
+
209
+ * GTM may be used **only** for marketing tags and attribution; it must not become the primary product analytics system (PostHog remains the product analytics source).
210
+ * Conversions representing monetary value or entitlement changes must be **server-truth aligned**, **idempotent**, and **deduplicated**; client-side tags may exist for attribution but must not become the authoritative source of billing/entitlement truth.
211
+ * **PII and sensitive data controls apply everywhere (hard requirement)**:
212
+
213
+ * PII rules apply to logs, Sentry, PostHog, support tooling, email systems, and marketing tags/conversion payloads.
214
+ * A consistent scrubbing/redaction standard must exist, and must be covered by automated tests to prevent leakage to third parties.
215
+ * Data lifecycle must be explicit and enforceable:
216
+
217
+ * define deletion/deactivation semantics, deletion propagation, export where applicable, DR/backup posture aligned with retention,
218
+ * **define data classification, retention periods, deletion propagation to third-party processors, and explicit exceptions** (legal/tax/anti-fraud), and ensure external disclosures match behavior.
219
+ * Abuse/fraud posture (especially referral/UGC/support): define prevention and enforcement measures; risk signals trigger protective actions and step-up verification where appropriate.
220
+ * Account/session security management: session/device visibility + revocation, security event visibility, recovery governance (including support-assisted recovery) with strict audit logging; step-up for sensitive actions.
221
+ * **Async/workflows are governed (hard requirement)**:
222
+
223
+ * define idempotency and deduplication posture,
224
+ * define controlled retries/backoff,
225
+ * **dead-letter handling must exist and be observable and operable**,
226
+ * **safe replay must be supported**,
227
+ * side-effects (email/billing/ledger/entitlements) must be governed such that they are either proven effectively-once or safely re-entrant without duplicated economic/security consequences.
228
+ * Release safety: define safe rollout posture with backward compatibility and rollback expectations for billing/ledger/auth changes.
229
+ * **Observability and alerting are mandatory (hard requirement)**:
230
+
231
+ * structured logs and correlation IDs must exist end-to-end (request/job/webhook) with consistent traceability,
232
+ * define critical-path SLO/SLI posture,
233
+ * define actionable alerts for webhook failures, ledger/entitlement drift, authentication attacks, abuse spikes, and drift detection.
234
+ * **Configuration and secrets governance is mandatory**:
235
+
236
+ * required configuration must fail-fast at build/startup,
237
+ * strict environment isolation (dev/stage/prod),
238
+ * rotation and incident remediation posture must be auditable and exercisable.
239
+ * **Drift detection must be remediable (hard requirement)**:
240
+
241
+ * drift alerts must have a defined remediation playbook (automated fix or operator workflow),
242
+ * each remediation must be auditable and support post-incident traceability.
243
+ * Security baseline:
244
+
245
+ * OWASP Top 10:2025 taxonomy; OWASP ASVS (L2/L3) verification baseline.
246
+ * Password UX masked + temporary reveal; no plaintext passwords in logs/returns/storage/telemetry.
247
+ * MFA for Admin/SUPER_ADMIN; step-up for high-risk.
248
+ * Risk-based anti-bot for auth and high-cost endpoints; integrate rate limits + consent gating.
249
+ * Baseline controls: CSP/HSTS/headers, CSRF where applicable, Upstash-backed rate limiting, PII scrubbing, supply-chain hygiene, measurable security.
250
+ * **Security controls must be verifiable**: CSP/HSTS/security headers and CSRF (where applicable) must be covered by automated checks or security tests and included in release gates.
251
+
252
+ ## 11) Review Requirements: Explore Beyond the Spec
253
+
254
+ * Feature design review: define success criteria, journeys, state model, auth/entitlements, instrumentation; propose competitiveness improvements within constraints.
255
+ * Pricing/monetization review: packaging/entitlements, lifecycle semantics, legal/tax/invoice implications; propose conversion/churn improvements within constraints.
256
+ * Competitive research: features, extensibility, guidance patterns, pricing/packaging norms; convert insights into testable acceptance criteria.
257
+
258
+ ## 12) Delivery Gates and Completion
259
+
260
+ * CI must block merges/deploys when failing:
261
+
262
+ * Biome lint/format, strict TS typecheck, unit + E2E (**Bun test**), build,
263
+ * migration integrity checks,
264
+ * i18n missing-key checks,
265
+ * **SEO/i18n/canonicalization verification** covering `/en/*` non-existence, hreflang/x-default, sitemap containing only true variants, UGC canonical redirects, and locale routing invariants,
266
+ * **performance budget verification** for key journeys (including Core Web Vitals-related thresholds) with release-blocking regression detection,
267
+ * **security verification** for CSP/HSTS/security headers and CSRF (where applicable),
268
+ * **consent gating verification** for analytics/marketing tags/newsletter eligibility and firing rules.
269
+ * **All gates above must be enforced by automated tests or mechanized checks (non-manual); manual verification does not satisfy release gates.**
270
+ * Build/startup must fail-fast when required configuration/secrets are missing or invalid for the target environment.
271
+ * Operability gates must be met for release:
272
+
273
+ * observability and alerting are configured for critical anomalies,
274
+ * workflow dead-letter handling is operable, visible, and supports controlled replay.
275
+ * Complete only when all sections are satisfied without deferral, system is integrated/buildable/testable/deployable, and there are no TODOs/hacks/workarounds/dead/unused code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/flow",
3
- "version": "2.4.2",
3
+ "version": "2.6.0",
4
4
  "description": "One CLI to rule them all. Unified orchestration layer for Claude Code, OpenCode, Cursor and all AI development tools. Auto-detection, auto-installation, auto-upgrade.",
5
5
  "type": "module",
6
6
  "bin": {