@webjsdev/cli 0.8.1

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.
@@ -0,0 +1,91 @@
1
+ # Windsurf Rules - webjs app
2
+
3
+ You are working on a webjs app - an AI-first, no-build, web-components-first
4
+ framework. Read AGENTS.md for the full API reference and CONVENTIONS.md for
5
+ project-specific conventions before writing any code. When AGENTS.md doesn't
6
+ cover what you need, the full hosted docs are at **https://docs.webjs.com**.
7
+
8
+ ## Persistence + scaffold rules (non-negotiable)
9
+
10
+ - **Use Prisma + SQLite for data, never JSON files.** It's already wired up
11
+ (`prisma/schema.prisma`, `lib/prisma.server.ts`, `npm run db:migrate`). For ANY
12
+ data the app stores (todos, posts, messages, products, comments…),
13
+ define a Prisma model. NEVER create `data/*.json`, `db.json`, or any
14
+ JSON file as a fake database. NEVER use module-scope arrays / Maps as
15
+ a substitute. NEVER use localStorage for app data. `webjs check`'s
16
+ `no-json-data-files` rule will fail the build if you do.
17
+ - **The scaffold is reference, not the final product.** Replace
18
+ `app/page.ts`, the example `User` model, the example users module, etc.
19
+ with the app the user actually asked for. Don't ship "Hello from
20
+ <app-name>" as the deliverable.
21
+ - **Only three templates exist:** `webjs create <name>` (default
22
+ full-stack), `--template api`, `--template saas`. The CLI rejects any
23
+ other `--template` value. Pick:
24
+ - Any product UI (todo, blog, dashboard, marketplace, social…) → default
25
+ - HTTP/JSON API only, no UI → `--template api`
26
+ - Auth / login / signup / SaaS → `--template saas`
27
+
28
+ ## Before starting ANY work
29
+
30
+ FIRST, before writing any code:
31
+ 1. Check `git branch --show-current`.
32
+ - If on main/master: create a feature branch before editing.
33
+ - If on a feature branch: verify it matches the current task.
34
+ 2. Sync: `git fetch origin && git rebase origin/main` if behind.
35
+
36
+ ## Autonomous mode (sandbox / no-prompt)
37
+
38
+ If running without interactive approval, auto-decide:
39
+ - On main? Auto-create feature/<task-slug> branch
40
+ - Parent behind? Auto-rebase. Merge? Auto-merge + delete feature branches.
41
+ - Auto-generate commit messages. Fix failing tests and violations.
42
+ Quality bar stays the same - no blocking on questions.
43
+
44
+ ## Mandatory workflow (never skip)
45
+
46
+ Every code change must include:
47
+ 1. Server tests in test/<feature>/*.test.ts (node:test)
48
+ 2. Browser tests in test/<feature>/browser/*.test.js (WTR + Playwright, real Chromium)
49
+ 3. Documentation updates (AGENTS.md, docs/, website/ if they exist)
50
+ 4. Convention check: `webjs check` must pass
51
+
52
+ The user should never have to ask for tests or documentation.
53
+
54
+ ## Git rules
55
+
56
+ - COMMIT AND PUSH PER LOGICAL UNIT, NOT AT THE END. One feature, one fix,
57
+ one rename, one doc rewrite per commit. Always `git push` after
58
+ committing. This is automatic.
59
+ - HARD LIMIT: if you have 5+ unstaged files spanning different concerns,
60
+ commit before continuing. The Claude Code hook at
61
+ `.claude/hooks/nudge-uncommitted.sh` fires at threshold 4. Windsurf
62
+ users should self-enforce the same rule. Batching multiple logical units
63
+ into one commit is the failure mode this rule exists to prevent.
64
+ - Meaningful commit messages: what changed and why
65
+ - NEVER add Co-Authored-By or AI attribution trailers to commits
66
+ - NEVER use em-dashes (U+2014), a hyphen-as-pause (` - `), or a
67
+ semicolon-as-pause (` ; `) in commit messages or anywhere else.
68
+ Rewrite the sentence so no pause-punctuation crutch is needed.
69
+ Use a period, comma, colon, parentheses, or a restructured phrasing.
70
+ Plain hyphens stay fine in compound words, CLI flags, filenames,
71
+ and ranges. Semicolons stay fine inside code
72
+ - Work on feature branches, never push directly to main
73
+ - Create pull requests for review
74
+ - NEVER merge any branch without explicit user permission. Always ask:
75
+ "Ready to merge <branch> into <target>? Delete or keep <branch> after?"
76
+ Wait for approval AND the delete/keep preference. Applies to ALL merges.
77
+ - Run `webjs test` before every commit
78
+
79
+ ## Framework specifics
80
+
81
+ - No build step: ES modules served directly
82
+ - **Erasable TypeScript only.** Node 24+ strips types via `module.stripTypeScriptTypes` (whitespace replacement, byte-exact position preservation, no sourcemap). The scaffold's tsconfig.json sets `erasableSyntaxOnly: true`, so the TS compiler rejects `enum`, `namespace` with values, constructor parameter properties, legacy decorators with `emitDecoratorMetadata`, and `import = require`. Use erasable equivalents: `const X = { ... } as const` plus a derived union type instead of `enum`; explicit fields plus constructor body assignments instead of parameter properties. If `erasableSyntaxOnly` is disabled and non-erasable syntax is used, the dev server falls back to esbuild + inline sourcemap for those files (~3x wire bytes per request).
83
+ - Web components render into light DOM by default (so Tailwind / global CSS apply directly). Opt in to shadow DOM per component with `static shadow = true` when you need scoped styles (via `static styles = css\`...\``) or third-party-embed isolation. `<slot>` projection works identically in both modes (named slots, fallback content, `assignedNodes` / `slotchange`, first-wins resolution).
84
+ - Custom-element tag names are passed to `.register('tag-name')` - they are NOT a static field on the class.
85
+ - One function per server action file (*.server.ts)
86
+ - Server-only code (@prisma/client, node:*, anything that needs Node APIs) goes only in .server.{js,ts} files, route.ts handlers, or middleware.ts. Never in pages, layouts, or components. Wrap the access in a .server.{js,ts} file; the framework rewrites that import into an RPC stub for the browser. lib/ holds both server-only infra (lib/prisma.server.ts) and browser-safe utilities (lib/utils/cn.ts with cn); follow the same rule per file.
87
+ - Directives are deliberately minimal: only `unsafeHTML`, `live`, and `repeat` ship. Use plain template-literal expressions (`class=${active ? 'btn active' : 'btn'}`, `style=${'color:' + color}`, `${cond ? a : b}`) and lifecycle hooks (`this.query('#el')` in `firstUpdated`) instead of Lit's `classMap` / `styleMap` / `ref` / `when` / `choose` / `guard`.
88
+ - Use Context for cross-component data, Task for async data in components
89
+ - **Progressive enhancement is the default.** Pages AND every web component are SSR'd to real HTML. Write components so the first paint is the right content (read SSR-meaningful defaults in `constructor()`, not `connectedCallback` - the server doesn't call lifecycle hooks). Initial data for components comes from the page function (server-side fetch + pass as attribute/property), NOT from `fetch` calls in `connectedCallback`. For write-paths, prefer `<form action=...>` + server action over `fetch` + click handler - the framework upgrades plain forms to partial-swap submissions automatically.
90
+ - **Client navigation is auto-magic.** Real `<a href>` and `<form action>` get partial-swap behavior with no opt-in. Layouts persist across navigation - put shared chrome (sidenav, header) in `layout.ts`, page-specific content in `page.ts`. For validation errors, return 4xx HTML from a `route.ts` POST handler; the router renders it in place preserving the user's input. For non-layout swap regions, wrap in `<webjs-frame id="...">`. See "Client navigation patterns" in AGENTS.md.
91
+ - Full API reference in AGENTS.md