@webjsdev/cli 0.10.69 → 0.10.71

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.
@@ -1,52 +1,50 @@
1
1
  # AGENTS.md for {{APP_NAME}}
2
2
 
3
- This is a WebJs app: server-rendered pages, web components for interactivity,
4
- server actions, Drizzle, and no build step. WebJs is its own framework, not
5
- React, Next.js or Lit, so write it from the patterns in this file rather than
6
- from that memory. Read this whole file before you edit anything.
3
+ This is a WebJs app: AI-first, web-components-first, buildless, and
4
+ progressively enhanced. Read this whole file before you edit anything, then
5
+ follow it. The steps here are required, not optional.
6
+
7
+ ## Gather context BEFORE you build (required)
8
+
9
+ WebJs is its own framework. It is not React, Next, or Lit, so writing code from
10
+ that muscle memory produces broken WebJs code. Before you write or change
11
+ anything, gather context from these sources. Do not skip a step to save time.
12
+ This is what separates a working app from a broken one.
13
+
14
+ 1. **Read the skill.** Start with `.agents/skills/webjs/SKILL.md`, then load the
15
+ `references/*.md` files it routes to for the surface you are touching. The
16
+ skill is the guide to building a WebJs app: it helps you choose the right
17
+ layer, reach for the right export, and avoid the mistakes Next.js or Lit
18
+ habits cause. Reading it is never wasted work: it survives the
19
+ gallery-clearing step in the playbook below.
20
+ 2. **Study the shipped examples, then build on a clean slate.** The template
21
+ playbook below says what ships and the exact order to follow. The workflow
22
+ rules (git, tests, review) are in `.agents/rules/workflow.md`; follow them
23
+ too.
24
+ 3. **Read the framework source for exact contracts.** WebJs is 100% buildless
25
+ native ES modules, so the source you run IS the source you read. For one
26
+ export's signature and doc comment run `npx webjs source <Export>` (for
27
+ example `npx webjs source createAuth`); it reads the installed package and
28
+ prints the declaration, not the file. When you need the behaviour behind a
29
+ signature, open the package source under `node_modules/@webjsdev/*` directly
30
+ (each package ships its own `AGENTS.md`). The full hosted docs are at
31
+ https://webjs.dev/docs.
7
32
 
8
33
  {{PLAYBOOK}}
9
34
 
10
- ## Rules that hold everywhere
11
-
12
- - **Type every boundary from its source.** A row is
13
- `typeof posts.$inferSelect` (exported from `db/schema.server.ts`, carried
14
- into browser code with `import type`), an action's input is a named
15
- `interface`, a routing file uses `PageProps<'/posts/[id]'>` / `LayoutProps` /
16
- `RouteHandlerContext` from `@webjsdev/core`, and a component prop that holds
17
- an object is `prop<Post>(Object)`. Never reach for `any` or `as any`, and
18
- keep `unknown` for an untrusted payload you narrow on the next line.
19
- - **Server-only code stays behind `.server.ts`.** A file WITH `'use server'`
20
- exposes its exported async functions as actions; a file WITHOUT it is a
21
- server-only utility that only other server code may import. Never add
22
- `'use server'` to a file only server code imports (the DB connection, the
23
- schema).
24
- - **Store data with Drizzle** in the wired-up database (`db/`), never in a
25
- JSON file, an in-memory array or Map, or localStorage. Every schema change is
26
- `npm run db:generate` then `npm run db:migrate`, and the generated
27
- migrations are committed.
28
- - **TypeScript is erasable:** no `enum`, no `namespace`, no constructor
29
- parameter properties, no decorators. Never put a backtick inside an
30
- `html` template body, even in a comment.
31
- - **Errors tell you the fix.** `npm run check` and `npm run typecheck` name
32
- the file, the rule and the fix; do what they say rather than searching.
33
-
34
- ## Git
35
-
36
- Commit per logical unit (CLAUDE.md has the rule). When you build a whole app
37
- from a spec in one session, the build is one unit: work on a feature branch
38
- (commits to `main` are refused), and commit once at the end after the checks
39
- pass (`git add -A && git commit -m "<imperative subject>"`). Team workflow
40
- (pull requests, CI, worktrees) is in `.agents/rules/workflow.md`.
41
-
42
- ## When you need more
43
-
44
- The reference set is `.agents/skills/webjs/` (`SKILL.md` routes to
45
- `references/*.md`). Open one only for a surface this file does not show:
46
- streaming and Suspense (`client-router-and-streaming.md`), optimistic UI
47
- (`optimistic-ui.md`), caching, rate limits, file uploads, env vars
48
- (`built-ins.md`), OAuth providers and sessions (`auth-and-sessions.md`),
49
- browser and e2e tests (`testing.md`), deeper component topics such as slots,
50
- shadow DOM, context and directives (`components.md`). The exact framework
51
- source is under `node_modules/@webjsdev/*`, and the hosted docs are at
52
- https://webjs.dev/docs.
35
+ ## Type everything (all templates)
36
+
37
+ Derive the type at every boundary from its source. Never reach for `any`, and
38
+ never `unknown` where a real type exists. The rule is step 8 of the skill's "Default
39
+ Workflow"; the full ladder, with an end-to-end example, is
40
+ `.agents/skills/webjs/references/typescript.md`.
41
+
42
+ Keep server-only code (database drivers, secrets, `node:*` builtins) in
43
+ `.server.ts` modules. The two kinds (with and without `'use server'`) are the
44
+ skill's "Core WebJs Rules" 1 and 2.
45
+
46
+ ## Data (all templates)
47
+
48
+ Use the wired-up database (Drizzle) for every piece of data the app stores;
49
+ the playbook above has the modeling step. Never store app data in a JSON file,
50
+ an in-memory array, or localStorage.
@@ -3,19 +3,16 @@
3
3
  # Committing per logical unit (this OVERRIDES Claude Code's default)
4
4
 
5
5
  Claude Code's built-in default is to NEVER commit unless the user explicitly
6
- asks. **For this project that default does NOT apply.** Commit per logical
7
- unit (one feature, one fix, one rename, one doc rewrite) as soon as it is
8
- complete and its checks pass, WITHOUT being asked, then push when there is a
9
- remote. Git history is the user's revert and cherry-pick safety net.
6
+ asks. **For this project that default does NOT apply.** Commit and push per
7
+ logical unit (one feature, one fix, one rename, one doc rewrite) as soon as it
8
+ is complete, WITHOUT being asked. Do not save all the work for one commit at the
9
+ end. A finished implementation with zero commits is a mistake here, because git
10
+ history is the user's revert and cherry-pick safety net.
10
11
 
11
- - Building a whole app from a spec in one session is ONE unit: build it,
12
- verify it, then commit once. Later changes are one commit each.
13
- - Never commit to `main`. Work on a feature branch (the pre-commit hook
14
- refuses `main`).
15
- - Imperative subject under 72 characters. No AI-attribution trailers
16
- (`Co-Authored-By`, `Generated by`).
17
-
18
- Two hooks back this up: `.claude/hooks/nudge-uncommitted.sh` reminds you while
19
- uncommitted changes pile up on a branch that already has commits, and
20
- `.claude/hooks/commit-before-stop.sh` stops you from ending a turn with
21
- uncommitted work on a feature branch.
12
+ The full git contract (branches, commit messages, attribution) is
13
+ `.agents/rules/workflow.md` "Git rules"; the
14
+ `.claude/hooks/guard-branch-context.sh` hook refuses a commit on `main`. Two hooks back this up: the
15
+ `.claude/hooks/nudge-uncommitted.sh` PostToolUse hook reminds you while
16
+ uncommitted changes pile up during work, and the
17
+ `.claude/hooks/commit-before-stop.sh` Stop hook stops you from ending a turn
18
+ with a pile of uncommitted work still on a feature branch.
@@ -1,35 +1,18 @@
1
1
  # Conventions for {{APP_NAME}}
2
2
 
3
- The conventions for building a WebJs app live in **`AGENTS.md`**, which shows
4
- every common pattern as a worked example. The deeper reference set is
5
- `.agents/skills/webjs/` (`SKILL.md` routes to `references/*.md`), for the rarer
6
- surfaces. This file is the short version.
3
+ The conventions for building a WebJs app live in the agent skill. **Read
4
+ `AGENTS.md` first, then `.agents/skills/webjs/SKILL.md`** (it routes to focused
5
+ references under `.agents/skills/webjs/references/`, loaded on demand). This file
6
+ only says where each rule lives, so no rule is stated twice.
7
7
 
8
- ## The essentials
9
-
10
- - **`app/` is routing only.** Only routing files live there (page, layout, route,
11
- middleware, metadata routes). Feature logic goes in `modules/<feature>/`
12
- (`actions/`, `queries/`, `components/`, `utils/`); shared UI primitives go in
13
- top-level `components/`; browser-safe helpers in `lib/utils/`.
14
- - **Server-only code goes behind `.server.ts`.** Reach it from a page or component
15
- through a `'use server'` action, never by importing a server-only utility
16
- directly into browser-bound code.
17
- - **Use the wired-up database (Drizzle).** Define real models in
18
- `db/schema.server.ts`, then `npm run db:generate` and `npm run db:migrate`.
19
- Never persist to a JSON file, an in-memory array or Map, or localStorage.
20
- - **The scaffold ships a demo showcase.** A full-stack app ships a UI feature
21
- gallery (`app/features/`, `app/examples/todo`); the api template ships a
22
- backend-features showcase (`app/api/features/`), with logic in `modules/`.
23
- When you build a real app, run `npm run gallery:clear` first to shed the
24
- showcase, then grow the app in place. `AGENTS.md` has the template-specific
25
- build steps.
26
- - **Derive types at every boundary.** Rows from `$inferSelect`, action inputs
27
- from an `interface`, routing files from `PageProps` / `LayoutProps`. Never
28
- `any`, and never `unknown` where a real type exists.
29
- - **Progressive enhancement is the default.** Pages render as HTML, `<a>`
30
- navigates, a `<form action=${importedAction}>` submits, all with JavaScript off; opt into
31
- interactivity per behaviour inside a component.
32
- - **Commit per logical unit** as soon as it is complete, and never push to `main`.
33
-
34
- Everything else (the module architecture, the `ActionResult` envelope, styling,
35
- testing, the client router, optimistic UI) is in the skill's references.
8
+ - **Build order** (study the showcase: a full-stack app's gallery under
9
+ `app/features/` and `app/examples/todo`, the api template's
10
+ `app/api/features/`; then `npm run gallery:clear`, data, UI, verify):
11
+ the playbook in `AGENTS.md`.
12
+ - **Data** (the wired-up Drizzle database, never a JSON file, an in-memory
13
+ array or Map, or localStorage): `AGENTS.md`, "Data".
14
+ - **Layout** (`app/` is routing only, logic in `modules/<feature>/`): the
15
+ skill's "Project Layout".
16
+ - **Server boundary, progressive enhancement, typing**: the skill's "What WebJs
17
+ Is", "Core WebJs Rules", and "Default Workflow".
18
+ - **Git, tests, and `npm run ci`**: `.agents/rules/workflow.md`.
@@ -30,8 +30,14 @@ WORKDIR /app
30
30
  # Install deps first so this layer is cached unless the manifests change.
31
31
  # package-lock.json is optional (it's absent when the app was scaffolded with
32
32
  # --no-install); the glob keeps the COPY working with or without it.
33
+ # Production dependencies only: the image never runs the type checker, the
34
+ # test runner or the browser tests, and leaving them out keeps it a fraction
35
+ # of the size. What the boot itself runs (drizzle-kit for `webjs db migrate`,
36
+ # the Tailwind CLI for the CSS compile) is a production dependency for that
37
+ # reason. The npm cache is emptied in the same layer: it is a second copy of
38
+ # every package fetched and would otherwise ship in the image.
33
39
  COPY package.json package-lock.json* ./
34
- RUN npm install --no-audit --no-fund
40
+ RUN npm install --omit=dev --no-audit --no-fund && npm cache clean --force
35
41
 
36
42
  # App source. node_modules and local state are excluded via .dockerignore.
37
43
  COPY . .
@@ -44,20 +44,12 @@ cross-origin access use the `cors()` middleware from `@webjsdev/server`; with
44
44
 
45
45
  ### 5. Verify before you call it done
46
46
 
47
- Run `npm run ci` and fix what it reports. It is one command for every gate,
48
- the step list declared in `package.json` under `webjs.ci`, with a result line
49
- per step:
50
-
51
- - `webjs check` (correctness: no browser-import or boundary violation).
52
- - `webjs doctor` (project health). It fails on whatever `package.json`
53
- `webjs.doctor.gate` marks `error`, plus the two hard toolchain checks that
54
- are fatal with no gate entry, `NODE_VERSION` and `TSCONFIG_ERASABLE`.
55
- - `webjs typecheck` (zero type errors).
56
- - A dependency audit.
57
- - The test layers for the endpoints and modules you built.
58
-
59
- The GitHub workflow runs the same list, so a green local run predicts CI.
60
- While iterating, `npm run ci -- --only Tests` runs one layer.
47
+ Run `npm run ci` and fix what it reports. It runs every gate declared under
48
+ `webjs.ci` in `package.json` (`webjs check`, `webjs doctor`, `webjs typecheck`,
49
+ a dependency audit, then the test layers for the endpoints and modules you
50
+ built), and the GitHub workflow runs the
51
+ same list; `.agents/rules/workflow.md` has what each gate checks. While
52
+ iterating, `npm run ci -- --only Tests` runs one layer.
61
53
 
62
54
  Then boot `npm run dev` and probe each endpoint for the expected status and JSON
63
55
  shape.