@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.
- package/bin/webjs.js +38 -0
- package/lib/app-icon.js +0 -10
- package/lib/create.js +20 -14
- package/lib/dev-reload.js +3 -1
- package/lib/doctor/codes.js +1 -0
- package/lib/doctor/probes/app-icon.js +5 -10
- package/lib/doctor/probes/dark-theme.js +91 -0
- package/lib/doctor/runner.js +2 -0
- package/lib/runtime-rewrite.js +18 -18
- package/package.json +3 -3
- package/templates/.agents/rules/workflow.md +9 -24
- package/templates/.agents/skills/webjs/SKILL.md +9 -17
- package/templates/.agents/skills/webjs/references/built-ins.md +3 -1
- package/templates/.agents/skills/webjs/references/runtime.md +5 -3
- package/templates/.agents/skills/webjs/references/styling.md +1 -1
- package/templates/.claude/hooks/nudge-uncommitted.sh +0 -7
- package/templates/AGENTS.md +45 -47
- package/templates/CLAUDE.md +12 -15
- package/templates/CONVENTIONS.md +15 -32
- package/templates/Dockerfile +7 -1
- package/templates/partials/agents-playbook-api.md +6 -14
- package/templates/partials/agents-playbook-fullstack.md +120 -566
- package/templates/scripts/clear-gallery.mjs +3 -3
package/templates/AGENTS.md
CHANGED
|
@@ -1,52 +1,50 @@
|
|
|
1
1
|
# AGENTS.md for {{APP_NAME}}
|
|
2
2
|
|
|
3
|
-
This is a WebJs app:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
package/templates/CLAUDE.md
CHANGED
|
@@ -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
|
|
7
|
-
unit (one feature, one fix, one rename, one doc rewrite) as soon as it
|
|
8
|
-
complete
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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.
|
package/templates/CONVENTIONS.md
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
# Conventions for {{APP_NAME}}
|
|
2
2
|
|
|
3
|
-
The conventions for building a WebJs app live in
|
|
4
|
-
|
|
5
|
-
`.agents/skills/webjs
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- **
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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`.
|
package/templates/Dockerfile
CHANGED
|
@@ -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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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.
|