create-hozu 0.7.0 → 0.8.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.
@@ -3,24 +3,12 @@
3
3
  A web app built with Hozu (`@hozu/*`). Hozu is not in your training data.
4
4
 
5
5
  ## Before writing code
6
- - __READ__
7
- - Changing existing code: read `__SKILL__/changing.md` first.
6
+ - __READ__ It has the change loop, the commands and the rules no diagnostic checks.
8
7
  - The files in `__SKILL__/` are the whole API. Do not read the framework source in `node_modules/@hozu`.
9
-
10
- ## The loop
11
- ```
12
- __RUN__ hozu add feature tasks --page / --with detail,toggle,filter,remove # then edit the texts it lists
13
- # add auth to the list for sign-in and per-user data
14
- __RUN__ hozu map # outline of the app with file:line, before a change
15
- __RUN__ hozu check # after every change: types, rules, contracts
16
- __RUN__ hozu check --update-lock # only to accept a clean, intended behaviour change
17
- __RUN__ hozu get / --select button --forms # try pages without a server: text, attributes, forms
18
- __RUN__ hozu post / --field title=Ship --next / # submit a form like a browser
19
- __RUN__ hozu browse / --do 'click Save' # real browser, no server: errors, widgets, text after steps
20
- ```
21
8
  __NOTE__
22
9
  ## Rules
23
10
  - After `hozu add feature`, do not print the generated files: edit the texts it lists; `hozu map` shows the rest.
24
11
  - Apply the fix each diagnostic gives; do not work around a rule.
25
- - Every behaviour change comes with a contract change.
26
- - Do not edit `__SKILL__/`: `__RUN__ hozu skill` rewrites it for the installed Hozu version.
12
+ - `__RUN__ hozu get` and `__RUN__ hozu browse` run the same app as `npm start`; do not start a server to check.
13
+ - Do not edit `__SKILL__/` or the text between the `hozu` markers: `__RUN__ hozu skill` rewrites both for the
14
+ installed Hozu version.
package/skill/changing.md DELETED
@@ -1,45 +0,0 @@
1
- # Changing a Hozu app
2
-
3
- Keep the loop short: map once, edit everything, check once, verify once.
4
-
5
- ## 1. Read
6
- - The change request.
7
- - `pnpm exec hozu map`: every route, query, mutation, event, state, view and contract, each with its `file:line`.
8
- Open only the lines the change touches. *model* is `model.ts` (schemas, events, effects, `fn`s, the machine),
9
- *views* is `views.ts` (views, contracts); `feature.ts` lists both modules, so new exports need no registration.
10
- - The API is in `SKILL.md`. `hozu docs recipes` has worked steps for an enum field in the add form, a bulk action
11
- button, a detail field and a detail page; `hozu docs <topic>` for anything else.
12
-
13
- ## 2. What to touch
14
- | Change | Touch |
15
- |---|---|
16
- | New UI-only state (a tab) | model: the context field and its initial value, an event, an `on` whose `assign` sets it → views: the control (no contract: it only copies a value). |
17
- | Filter / sort / page in the URL | the route's `search` schema (with a default) → links with `ui.link(route, params, { key: value })` → read `search.key` in the view. If the page also filters as you type, `seed: ({ search }) => ({ key: search.key })` on the view and read `ctx.key` only. |
18
- | A per-item action stored on the server (pin, archive, star) | model: a field on the item, an event, a mutation that `invalidates` the list tag, `on(Event, { target: 'pinning', assign: (e) => { ctx.target = e.id } })` and a state with `invoke` → views: the per-item form from `hozu docs patterns` → server: store it and sort in the list resolver. These transitions only copy values: no contract. |
19
- | A control that works in every mode | `machine({ on: [...] })` instead of repeating it per state. |
20
- | New page | `routes.ts` → a view with `route` in `views.ts` → `ui.page(...)` in `hozu.config.ts` (`head`, and `entries` when the route has params). |
21
-
22
- Whenever the machine changes:
23
- - A transition that decides something (a guard, `navigate`, or a `fn` in its values) needs a contract; HZ016
24
- prints each missing one ready to paste. Transitions that only copy values are reviewed through the lock.
25
- - States with `invoke` drop unhandled events by themselves. Other states must handle or `ignore` every event their
26
- visible controls send; HZ005 prints the missing entries.
27
-
28
- ## 3. Check (once, after all edits)
29
- ```
30
- pnpm exec hozu check
31
- ```
32
- Fix what it reports. When the behaviour change is intended, run `pnpm exec hozu check --update-lock`: HZ018 shows
33
- each changed transition as `was: … now: …`, and accepting it updates the lock.
34
-
35
- ## 4. Verify (once, no server needed)
36
- - **Pages:** `pnpm exec hozu get / /items/i1` prints the status, title, alerts and visible text.
37
- - **Attributes and forms:** `--select button` (or `'[role=alert]'`, `a[href]`, `#id`) prints elements with their
38
- attributes, e.g. `aria-pressed`; `--forms` lists each form's fields and buttons. Never start a server for this.
39
- - **Forms:** `pnpm exec hozu post / --field title=A --field priority=high --next /items` fills the form like a
40
- browser (other fields keep their defaults). It follows the redirect, then runs the next steps in the same
41
- process.
42
- - **Chaining:** chain what must share data, e.g. `--next 'POST / title=a'` (fields as `a=1&b=2`) or
43
- `--next /items/i3`.
44
- - **A form with only a button:** `--button 'Clear done'`, or `--next 'POST / @Clear done'`. With one form per item,
45
- `--field id=t2` picks the item's form.
@@ -1,14 +0,0 @@
1
- import { createServer } from '@hozu/adapter-node'
2
- import { buildProject } from '@hozu/core/ir'
3
- import { compileStyles } from '@hozu/css'
4
- import project from './hozu.config.ts'
5
- import { createResolvers } from './server.ts'
6
-
7
- const port = Number(process.env.PORT ?? 3000)
8
- const build = buildProject(project, { sources: false })
9
-
10
- createServer({
11
- build,
12
- styles: await compileStyles(build),
13
- resolvers: createResolvers(),
14
- }).listen(port, () => console.log(`Bookmarks on http://localhost:${port}`))
@@ -1,14 +0,0 @@
1
- import { createServer } from '@hozu/adapter-node'
2
- import { buildProject } from '@hozu/core/ir'
3
- import { compileStyles } from '@hozu/css'
4
- import project from './hozu.config.ts'
5
- import { createResolvers } from './server.ts'
6
-
7
- const port = Number(process.env.PORT ?? 3000)
8
- const build = buildProject(project, { sources: false })
9
-
10
- createServer({
11
- build,
12
- styles: await compileStyles(build),
13
- resolvers: createResolvers(),
14
- }).listen(port, () => console.log(`__NAME__ on http://localhost:${port}`))
@@ -1,6 +0,0 @@
1
- import { resolvers } from '@hozu/data'
2
- import project from './hozu.config.ts'
3
-
4
- export function createResolvers() {
5
- return resolvers(project, () => [])
6
- }