Skip to content

Commit 0e3ddc6

Browse files
author
Sailor Template Bot
committed
chore: sync from Nebutra-Sailor@2631ec097be5ec08389d33a79b695e75e5e96c7f
0 parents  commit 0e3ddc6

7,209 files changed

Lines changed: 1032359 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets).
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
3+
"changelog": ["@changesets/changelog-github", { "repo": "Nebutra/Nebutra-Sailor" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.cursor/rules/nebutra.mdc

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
---
2+
description: Nebutra-Sailor monorepo project rules for Cursor AI
3+
globs: ["**/*.ts", "**/*.tsx", "**/*.mdx"]
4+
alwaysApply: true
5+
---
6+
7+
# Nebutra-Sailor — Cursor Rules
8+
9+
## Stack
10+
11+
- Node.js 22+, pnpm 10.32+
12+
- Next.js 16 (App Router, React 19, Turbopack) — frontends
13+
- Hono — TypeScript backends; FastAPI — Python (only when justified)
14+
- Tailwind CSS v4 + CSS variables from `@nebutra/tokens` (SSOT)
15+
- TypeScript 5.9 strict, Biome (NOT ESLint), Vitest + Playwright
16+
- License: AGPL-3.0
17+
18+
## Repository Layout (categorized monorepo)
19+
20+
```
21+
apps/ # User-facing apps
22+
landing/ web/ storybook/ design-docs/ studio/ docs/
23+
sleptons/ idp/ mail-preview/ sailor-docs/ tsekaluk-dev/
24+
25+
backends/ # No-UI backends, split by language
26+
gateway/ # TS / Hono — BFF, auth, tenancy, rate-limit
27+
# DEFAULT for new backend work
28+
python/ # FastAPI — only when batch/ML/libs justify (ADR 2026-05-10)
29+
active: _shared, ai, ecommerce, event-ingest, recsys
30+
stub: content, third-party, web3
31+
32+
packages/ # categorized: <category>/<name>
33+
design/ ui tokens design-tokens brand theme icons design-sync
34+
iam/ auth audit vault tenant permissions identity
35+
commerce/ billing contracts license marketing metering waitlist
36+
integrations/ queue search notifications webhooks uploads storage email saga
37+
platform/ db logger config
38+
ops/ cli create-sailor sanity preset
39+
ai/ mcp ai-providers
40+
41+
infra/ iac/ + runtime/ + data/ + ops/
42+
workflows/ inngest/ + n8n/ + pusher/
43+
e2e/ smoke/ + golden/ + sleptons/
44+
tests/ architecture/ + load/
45+
```
46+
47+
Notes:
48+
- `@nebutra/design-system` was merged into `@nebutra/ui` (layout at `@nebutra/ui/layout`).
49+
- `apps/api-gateway` was relocated to `backends/gateway`.
50+
51+
## CRITICAL Import Rules
52+
53+
```tsx
54+
// UI components (low-level primitives + composed patterns)
55+
import { Button, Input, Card } from "@nebutra/ui/components";
56+
import { Browser, Safari } from "@nebutra/ui/primitives";
57+
import { PageHeader, EmptyState, LoadingState, ErrorState } from "@nebutra/ui/layout";
58+
59+
// Icons — Geist preferred, Lucide for generic
60+
import { Search, Settings } from "@nebutra/icons";
61+
import { ChevronRight } from "lucide-react";
62+
63+
// Theme switching
64+
import { ThemeProvider, useTheme } from "@nebutra/tokens";
65+
import { NebutraThemeProvider } from "@nebutra/ui"; // Lobe UI bridge
66+
67+
// Utilities
68+
import { cn } from "@nebutra/ui/utils";
69+
```
70+
71+
- ❌ NEVER import from `@primer/react` (removed)
72+
- ❌ NEVER add new HeroUI imports unless Radix has NO equivalent
73+
- ❌ NEVER import JS color tokens from `@nebutra/ui/theme` (deprecated, internal only)
74+
75+
## Component Discipline (手搓禁止)
76+
77+
Priority order — DO NOT hand-craft when something exists:
78+
79+
1. **Geist source** — direct reference for Geist-aligned components
80+
2. **21st.dev** — community-vetted implementations
81+
3. **HeroUI / Radix** — existing wheels
82+
4. **Hand-craft** — absolute last resort
83+
84+
Also:
85+
- NO inline SVG icons — always use `lucide-react` or `@nebutra/icons`
86+
- SVG math for data viz (e.g. Gauge) is OK; only icon SVGs are forbidden
87+
- HeroUI visual style often mismatches Geist — prefer Geist-native when restyling
88+
- Every new component MUST have a Storybook story
89+
90+
## Styling Rules
91+
92+
```tsx
93+
// ✅ Semantic 12-step scales (registered in @theme)
94+
<div className="bg-neutral-1 text-neutral-12 border-neutral-7" />
95+
<div className="bg-blue-9 text-cyan-11" />
96+
97+
// ✅ Semantic shadcn classes
98+
<div className="bg-primary text-foreground border-border" />
99+
100+
// ✅ Brand aliases via Tailwind
101+
<div className="bg-brand-primary text-brand-accent" />
102+
103+
// ✅ Brand gradient
104+
<h1 style={{
105+
background: "var(--brand-gradient)",
106+
WebkitBackgroundClip: "text",
107+
WebkitTextFillColor: "transparent",
108+
}}>...</h1>
109+
110+
// ✅ CSS variables in inline styles (SVG, recharts, dynamic)
111+
<Cell fill="var(--brand-accent)" />
112+
113+
// ❌ NEVER hardcode brand hex
114+
<stop stopColor="#0033FE" /> // → var(--brand-primary)
115+
<Cell fill="#0BF1C3" /> // → var(--brand-accent)
116+
tagColor: "#ef4444" // → var(--status-danger)
117+
```
118+
119+
### Container widths
120+
121+
- text content: `max-w-4xl` (`var(--container-text)`)
122+
- feature / wide: `max-w-[1400px]` (`var(--container-wide)`)
123+
- NEVER: `max-w-5xl`, `max-w-7xl` (too narrow/inconsistent for sections)
124+
125+
### Dark mode border tokens (governance — 2026-05-12)
126+
127+
- Default page-level border = `--border` — auto resolves light/dark via wildcard rule in `packages/design/tokens/styles.css`.
128+
- For explicit borders prefer semantic tokens:
129+
- `border-neutral-6` — subtle border
130+
- `border-neutral-7` — default border
131+
- `border-neutral-8` — hovered border
132+
- Dark mode neutral-6/7/8 reference `nebutra-gray.*` (pure neutral, no hue) — added to fix slate blue-tint clash. Light mode still uses slate.
133+
- NEVER hardcode `border-white/X` in dark contexts — use semantic tokens so theme switching stays correct.
134+
- The `var(--brand-gradient)` is for **CTAs and meaningful highlights only** — not decorative dividers / hairlines.
135+
136+
## Animation Rules
137+
138+
```tsx
139+
import { AnimateIn, AnimateInGroup } from "@nebutra/ui/components";
140+
141+
// Single
142+
<AnimateIn preset="emerge"><Component /></AnimateIn>
143+
144+
// Scroll-triggered
145+
<AnimateIn preset="emerge" inView><Section /></AnimateIn>
146+
147+
// Staggered list
148+
<AnimateInGroup stagger="normal" className="grid grid-cols-3 gap-6">
149+
{items.map((it) => <AnimateIn key={it.id} preset="fadeUp"><Card /></AnimateIn>)}
150+
</AnimateInGroup>
151+
```
152+
153+
Presets: `emerge` (default), `flow`, `fade`, `fadeUp`, `scale`.
154+
❌ NEVER use raw `motion.div` with hardcoded `initial`/`animate` values — import from `packages/design/brand/src/motion.ts` or use `AnimateIn`.
155+
156+
## Component Variants — CVA
157+
158+
```tsx
159+
import { cva, type VariantProps } from "class-variance-authority";
160+
import { cn } from "@nebutra/ui/utils";
161+
162+
const cardVariants = cva("rounded-lg border bg-white shadow-sm", {
163+
variants: { size: { sm: "p-4", md: "p-6", lg: "p-8" } },
164+
defaultVariants: { size: "md" },
165+
});
166+
```
167+
168+
## Accessibility
169+
170+
Every interactive component must have:
171+
- `type="button"` on all `<button>` elements
172+
- `aria-label` on icon-only buttons
173+
- `role` where semantic HTML can't express the intent
174+
- Focus rings: `focus:outline-none focus:ring-2 focus:ring-[var(--blue-9)] focus:ring-offset-1`
175+
176+
## Next.js 16 Rules
177+
178+
- Default to **Server Components**; only `'use client'` for interactivity
179+
- Use `proxy.ts` NOT `middleware.ts` (renamed in Next.js 16)
180+
- Request APIs are async: `await cookies()`, `await headers()`, `await params`
181+
- Cache Components: `'use cache'` (replaces PPR)
182+
- Mutations via Server Actions, NOT Route Handlers
183+
- Client data fetching: TanStack Query + typed API client
184+
185+
## Backend Language Policy (ADR 2026-05-10 — TS-by-Default)
186+
187+
New backend work goes in **TypeScript** (`backends/gateway/` or `packages/<category>/<name>/`) by default.
188+
189+
A new Python service is acceptable ONLY when its `README.md` cites at least one of:
190+
1. Batch / queued work too long for edge (>5s typical)
191+
2. ML / scientific compute (transformers, vLLM, etc.)
192+
3. Specialized libraries with no comparable TS port
193+
194+
CRUD, webhooks, billing, content management, blockchain reads, third-party API proxies → **TS**, no exceptions.
195+
196+
### Canonical implementations — do not duplicate
197+
198+
| Domain | Canonical |
199+
|---|---|
200+
| Billing / subscriptions | `packages/commerce/billing` (TS, multi-provider) |
201+
| Content management | `apps/studio` (Sanity) |
202+
| Auth / identity | `packages/iam/auth` + `apps/idp` |
203+
| Webhooks | `packages/integrations/webhooks` |
204+
| Edge AI (interactive) | `packages/ai/agents` (Vercel AI SDK) |
205+
206+
## Provider-Agnostic Packages (auto-detect via env)
207+
208+
| Package | Providers |
209+
|---|---|
210+
| `@nebutra/auth` | Clerk \| Better Auth \| NextAuth |
211+
| `@nebutra/billing` | Stripe \| Polar \| LemonSqueezy \| ChinaPay \| Manual |
212+
| `@nebutra/queue` | QStash \| BullMQ \| memory |
213+
| `@nebutra/search` | Meilisearch \| Typesense \| Algolia |
214+
| `@nebutra/notifications` | Novu \| direct dispatchers |
215+
| `@nebutra/webhooks` | Svix \| custom |
216+
| `@nebutra/uploads` | S3 multipart \| Tus \| presigned |
217+
| `@nebutra/design-sync` | Figma \| Penpot \| git-only |
218+
219+
`<NAME>_PROVIDER` env var overrides auto-detection. Application code stays the same across providers.
220+
221+
## Multi-Tenancy (`@nebutra/tenant`)
222+
223+
```ts
224+
import { tenantMiddleware, fromHeader } from "@nebutra/tenant/middleware";
225+
import { getCurrentTenant, withRls } from "@nebutra/tenant";
226+
227+
app.use("*", tenantMiddleware({ resolvers: [fromHeader("x-tenant-id")] }));
228+
const tenant = getCurrentTenant(); // { tenantId, plan, ... }
229+
const db = withRls(prisma, tenant.tenantId);
230+
```
231+
232+
## Permissions (`@nebutra/permissions`)
233+
234+
```ts
235+
// API middleware (Hono)
236+
import { requirePermission } from "@nebutra/permissions";
237+
app.delete("/api/projects/:id", requirePermission("delete", "Project"), handler);
238+
239+
// React UI gates
240+
import { Can } from "@nebutra/permissions/react";
241+
<Can action="edit" resource="Document" subject={doc}><EditButton /></Can>
242+
```
243+
244+
## Testing Requirements
245+
246+
- Minimum **80% coverage** (lines/functions), 70% branches
247+
- Vitest unit: `packages/*/src/**/*.test.ts`
248+
- Playwright E2E: `e2e/*.spec.ts`
249+
- Architecture tests: `pnpm test:arch`
250+
- Load tests: `tests/load/` (k6)
251+
252+
## What NEVER to Do
253+
254+
- `@primer/react` (removed from repo)
255+
- `console.log` in production code (use `@nebutra/logger`)
256+
- Hardcoded secrets (use env vars + `@nebutra/vault` for customer secrets)
257+
- Hardcoded brand hex (use `var(--brand-primary)` / `var(--brand-accent)` / `var(--brand-gradient)`)
258+
- Hardcoded status hex (use `var(--status-danger|warning|success|info)`)
259+
- Raw `motion.div` with hardcoded animation values (use `AnimateIn`)
260+
- New components without a Storybook story
261+
- Mutations via Route Handlers (use Server Actions)
262+
- `middleware.ts` in Next.js 16 (use `proxy.ts`)
263+
- Duplicating canonical implementations in Python (see canonical table above)
264+
- Hand-crafted components when Geist / 21st.dev / HeroUI / Radix has it
265+
- `border-white/X` for dark-mode borders (use semantic neutral tokens)
266+
- Decorative use of `var(--brand-gradient)` for hairlines / dividers
267+
268+
## Dev Commands
269+
270+
```bash
271+
pnpm dev # all apps
272+
pnpm dev:dashboard # web + backends/gateway
273+
pnpm dev:marketing # landing + studio
274+
pnpm typecheck # TypeScript across workspace
275+
pnpm lint / pnpm lint:fix # Biome
276+
pnpm test / pnpm e2e # Vitest / Playwright
277+
pnpm db:generate / pnpm db:studio # Prisma
278+
pnpm infra:up # Docker infrastructure
279+
pnpm --filter @nebutra/design-tokens build # rebuild DTCG tokens
280+
pnpm --filter @nebutra/storybook dev # Storybook (design tokens browser)
281+
node scripts/generate-palette.mjs --primary=#HEX --secondary=#HEX # rebrand
282+
```

.czrc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"path": "cz-conventional-changelog",
3+
"types": {
4+
"feat": {
5+
"description": "A new feature",
6+
"title": "Features"
7+
},
8+
"fix": {
9+
"description": "A bug fix",
10+
"title": "Bug Fixes"
11+
},
12+
"docs": {
13+
"description": "Documentation only changes",
14+
"title": "Documentation"
15+
},
16+
"style": {
17+
"description": "Changes that do not affect the meaning of the code",
18+
"title": "Styles"
19+
},
20+
"refactor": {
21+
"description": "A code change that neither fixes a bug nor adds a feature",
22+
"title": "Code Refactoring"
23+
},
24+
"perf": {
25+
"description": "A code change that improves performance",
26+
"title": "Performance Improvements"
27+
},
28+
"test": {
29+
"description": "Adding missing tests or correcting existing tests",
30+
"title": "Tests"
31+
},
32+
"build": {
33+
"description": "Changes that affect the build system or external dependencies",
34+
"title": "Builds"
35+
},
36+
"ci": {
37+
"description": "Changes to CI configuration files and scripts",
38+
"title": "Continuous Integration"
39+
},
40+
"chore": {
41+
"description": "Other changes that don't modify src or test files",
42+
"title": "Chores"
43+
},
44+
"revert": {
45+
"description": "Reverts a previous commit",
46+
"title": "Reverts"
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)