sanoma 0.2.0 → 0.4.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.
Files changed (53) hide show
  1. package/README.md +81 -25
  2. package/dist/check.d.ts +10 -5
  3. package/dist/check.js +77 -17
  4. package/dist/check.js.map +1 -1
  5. package/dist/cli.js +63 -23
  6. package/dist/cli.js.map +1 -1
  7. package/dist/config.d.ts +5 -0
  8. package/dist/config.js +29 -3
  9. package/dist/config.js.map +1 -1
  10. package/dist/data.d.ts +1 -0
  11. package/dist/data.js +4 -0
  12. package/dist/data.js.map +1 -0
  13. package/dist/dev.d.ts +3 -1
  14. package/dist/dev.js +5 -2
  15. package/dist/dev.js.map +1 -1
  16. package/dist/env.js +2 -3
  17. package/dist/env.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/init.d.ts +19 -2
  22. package/dist/init.js +57 -2
  23. package/dist/init.js.map +1 -1
  24. package/dist/oxlint-plugin.d.ts +7 -1
  25. package/dist/oxlint-plugin.js +11 -4
  26. package/dist/oxlint-plugin.js.map +1 -1
  27. package/dist/resources.d.ts +1 -1
  28. package/dist/resources.js +3 -2
  29. package/dist/resources.js.map +1 -1
  30. package/dist/serve.d.ts +18 -12
  31. package/dist/serve.js +118 -26
  32. package/dist/serve.js.map +1 -1
  33. package/dist/site-lint.d.ts +33 -0
  34. package/dist/site-lint.js +70 -0
  35. package/dist/site-lint.js.map +1 -0
  36. package/dist/sites.d.ts +7 -0
  37. package/dist/sites.js +11 -0
  38. package/dist/sites.js.map +1 -0
  39. package/oxlint.json +117 -22
  40. package/package.json +19 -9
  41. package/site.d.ts +3 -0
  42. package/site.js +3 -0
  43. package/template/.env.example +2 -3
  44. package/template/AGENTS.md +14 -7
  45. package/template/package.json +2 -2
  46. package/template/policies/policy.cedar +17 -0
  47. package/template/resources/data.ts +21 -0
  48. package/template/resources/people.ts +20 -0
  49. package/template/sanoma.config.ts +0 -2
  50. package/template/scenarios/publish-post/publish.feature +16 -6
  51. package/template/tsconfig.json +1 -1
  52. package/template/workflows/publish-post.ts +2 -4
  53. package/template/policies/policy.ts +0 -19
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sanoma
2
2
 
3
- One command over a company repo: `sanoma` runs its workflows and the app, `sanoma check` checks it, `sanoma env` writes its `.env.example`, `sanoma ledger export` exports a run. It also carries the surface a workflow or policy imports (`defineWorkflow`, `definePolicy`, the decisions, `defineConfig` and the types), so a repo depends on `sanoma` and its connectors, and writes no `worker.ts`, `app.ts`, compose file or vitest config.
3
+ One command over a company repo: `sanoma` runs its workflows and the app, `sanoma check` checks it, `sanoma env` writes its `.env.example`, `sanoma ledger export` exports a run. It also carries the surface a workflow imports (`defineWorkflow`, `defineConfig` and the types), so a repo depends on `sanoma` and its connectors, and writes no `worker.ts`, `app.ts`, compose file or vitest config.
4
4
 
5
5
  ## Start a company
6
6
 
@@ -9,7 +9,7 @@ mkdir acme && cd acme
9
9
  npx sanoma
10
10
  ```
11
11
 
12
- In an empty directory (dotfiles aside), `sanoma` starts a company there, then runs it: it copies the template this package ships (`template/`: `sanoma.config.ts`, a `publish-post` workflow with its scenarios, a policy, an empty `resources/` tree, `AGENTS.md`, `.env.example`), names the package after the directory, writes `.env` with the default `SANOMA_DATABASE_URL` and a new `SANOMA_SECRETS_KEY` (keeping what a `.env` there already sets), commits what it wrote (never a dotfile that was already there) as the first commit of a git repository on `main`, "Start a Sanoma company", as your git user, then installs with the package manager that ran it (`npm_config_user_agent`; pnpm when it names none) and adds the lockfile to that commit. The `sanoma` it installed then serves the company. Without git or a git user it stops before writing anything; a failed install leaves the commit, to install and run `sanoma` again in. A directory holding anything else and no `sanoma.config.ts` is refused, as for every command.
12
+ In an empty directory (dotfiles aside), `sanoma` starts a company there, then runs it: it copies the template this package ships (`template/`: `sanoma.config.ts`, a `publish-post` workflow with its scenarios, `policies/policy.cedar`, `resources/people.ts` with you as its first person (your GitHub login as `gh` is signed in, else this machine's user name, named as git's `user.name`), an empty `resources/` tree, `AGENTS.md`, `.env.example`), names the package after the directory, writes `.env` with the default `SANOMA_DATABASE_URL` and a new `SANOMA_SECRETS_KEY` (keeping what a `.env` there already sets), commits what it wrote (never a dotfile that was already there) as the first commit of a git repository on `main`, "Start a Sanoma company", as your git user, then installs with the package manager that ran it (`npm_config_user_agent`; pnpm when it names none) and adds the lockfile to that commit. The `sanoma` it installed then serves the company. Without git or a git user it stops before writing anything; a failed install leaves the commit, to install and run `sanoma` again in. A directory holding anything else and no `sanoma.config.ts` is refused, as for every command.
13
13
 
14
14
  ## Install
15
15
 
@@ -19,12 +19,12 @@ npm install sanoma @sanoma-ai/connector-ghost
19
19
 
20
20
  `sanoma` brings `@sanoma-ai/workflows`, `@sanoma-ai/app`, `zod`, `typescript`, `@types/node` and `oxlint` with it: a repo installs nothing else but its connectors. Node's types reach the repo's `tsc` through `sanoma` itself (its declarations reference them, resolved from where it is installed), under pnpm, npm or a link alike, so a repo lists no `@types/node`. A repo that lists its own of another major gets two sets of Node's declarations, which conflict: keep one, by matching sanoma's or letting the installer dedupe them. A tsconfig project that imports nothing from `sanoma` (a scripts directory with a tsconfig of its own, say) gets none this way: it sets `"types": ["node"]` and lists `@types/node` itself. Node 24.2 or later, but not 25 (the bin uses `import.meta.main`, and Cucumber, which runs the scenarios, does not support 25); Docker for the Postgres it starts when none answers.
21
21
 
22
- A repo holds `sanoma.config.ts` at its root, with `workflows/`, `policies/`, optional `resources/` (data files) and `scenarios/` (feature files) beside it, and a `tsconfig.json` that extends the one this package ships:
22
+ A repo holds `sanoma.config.ts` at its root, with `workflows/`, optional `policies/` (Cedar files), `resources/` (data files, the people among them) and `scenarios/` (feature files) beside it, and a `tsconfig.json` that extends the one this package ships:
23
23
 
24
24
  ```json
25
25
  {
26
26
  "extends": "sanoma/tsconfig.json",
27
- "include": ["sanoma.config.ts", "workflows", "policies", "resources"]
27
+ "include": ["sanoma.config.ts", "workflows", "resources"]
28
28
  }
29
29
  ```
30
30
 
@@ -32,17 +32,15 @@ A repo holds `sanoma.config.ts` at its root, with `workflows/`, `policies/`, opt
32
32
  // sanoma.config.ts
33
33
  import { ghost } from "@sanoma-ai/connector-ghost";
34
34
  import { defineConfig } from "sanoma";
35
- import policy from "./policies/policy.ts";
36
35
  import publish from "./workflows/publish.ts";
37
36
 
38
37
  export default defineConfig({
39
38
  workflows: [publish],
40
39
  connectors: [ghost],
41
- policy,
42
40
  });
43
41
  ```
44
42
 
45
- Each connector carries its driver and its fake, so the config names neither. The rest is the repo's layout: the app's name is `package.json`'s `name`, the scenarios are `scenarios/` and the data files `resources/`, beside `sanoma.config.ts`. The ledger is Postgres's, on the config's database; `ledger: jsonlLedger(dir)` keeps it in files instead.
43
+ Each connector carries its driver and its fake, so the config names neither. The rest is the repo's layout: the app's name is `package.json`'s `name`, the scenarios are `scenarios/`, the data files `resources/` and the policies `policies/**/*.cedar`, beside `sanoma.config.ts` (see [People and policies](#people-and-policies)). The ledger is Postgres's, on the config's database; `ledger: jsonlLedger(dir)` keeps it in files instead.
46
44
 
47
45
  ```ts
48
46
  // workflows/publish.ts
@@ -58,22 +56,58 @@ export default defineWorkflow({
58
56
  });
59
57
  ```
60
58
 
61
- A workflow or policy imports from `sanoma` what the lint lets it (`defineWorkflow`, `definePolicy`, `allow`, `deny`, `approve`, `approvedFor`, `allowAll`, `mayDecide`, `errorCode`, `z`, and types); `zod` itself and `@sanoma-ai/workflows` are accepted too. The config file imports `defineConfig` (and a ledger store, `jsonlLedger`, `memoryLedger` or `postgresLedger`, when it names one) from `sanoma`, and its connectors from their packages.
59
+ A workflow imports from `sanoma` what the lint lets it (`defineWorkflow`, `mayDecide`, `errorCode`, `z`, and types); `zod` itself and `@sanoma-ai/workflows` are accepted too. The config file imports `defineConfig` (and a ledger store, `jsonlLedger`, `memoryLedger` or `postgresLedger`, when it names one) from `sanoma`, and its connectors from their packages. A site, `sites/<name>/` (pages the app serves under `/sites/<name>/`), imports `defineSite`, the app's route APIs (`Link`, `Outlet`, `useNavigate`, …) and `api`, which calls the company's operations and workflows as the person on the page ([calling operations and workflows](https://www.npmjs.com/package/@sanoma-ai/app#calling-operations-and-workflows)), from `sanoma/site`, and `createFileRoute` from `@tanstack/react-router`; the [app's README](https://www.npmjs.com/package/@sanoma-ai/app#a-sites-imports) has the whole list. A data file under `resources/` imports `secret` and `sanoma` (the people types) from `sanoma/resources`, and `resources/data.ts`, the company's [collections](../workflows/README.md#collections), imports `collection` from `sanoma/data` and nothing else:
60
+
61
+ ```ts
62
+ // resources/data.ts
63
+ import { collection } from "sanoma/data";
64
+
65
+ export const outbound = collection({
66
+ name: "outbound",
67
+ key: "company",
68
+ fields: { company: "text", stage: { enum: ["researched", "contacted", "won", "lost"] }, owner: "person" },
69
+ });
70
+ ```
71
+
72
+ Every command that loads the config imports `resources/data.ts` too, when there is one, and adds its collections to the config's `collections` (each of its exports must be one), so `sanoma.config.ts` does not list them. A workflow that calls `ctx.data.outbound.get` imports `outbound` from `../resources/data.ts` to name it in `uses`: the one file outside `workflows/` the lint lets it import.
73
+
74
+ ## People and policies
75
+
76
+ `resources/people.ts` declares who uses the company's app, the agents that act in it and the groups ([people](https://www.npmjs.com/package/@sanoma-ai/workflows#people)), and `policies/*.cedar` who may do what ([policies](https://www.npmjs.com/package/@sanoma-ai/workflows#policies)):
77
+
78
+ ```ts
79
+ // resources/people.ts
80
+ import { sanoma } from "sanoma/resources";
81
+
82
+ export const ada = sanoma.person({ id: "ada", name: "Ada Ortiz", email: "ada@acme.test", github: "ada-ortiz" });
83
+ export const bo = sanoma.person({ id: "bo" });
84
+ export const editor = sanoma.group({ name: "editor", members: [ada] });
85
+ ```
86
+
87
+ ```cedar
88
+ // policies/policy.cedar
89
+ @hold("editor")
90
+ @title("Review before it goes out")
91
+ forbid (principal, action in [Sanoma::Action::"effect:publish", Sanoma::Action::"effect:send"], resource)
92
+ unless { principal in Sanoma::Group::"editor" };
93
+ ```
94
+
95
+ Only a declared person signs in to the app (on this machine by picking their name; with GitHub sign-in by their verified email, then their `github` login), starts a run, calls an operation or decides an approval, and nobody decides an approval on a run they started while someone else in the group could (a founder alone in a group decides their own, and the ledger says so). Everything is allowed unless a `forbid` refuses it: one with `@hold` waits for that group's or person's approval, one without is denied with its `@reason`. Write them against `.sanoma/schema.cedarschema`, which `sanoma check` and `sanoma` write from the config: each operation's id as an action in its effect's group, `workflow:<name>` for a run's start, the groups the people file declares, and each operation's input as `context.input`. `sanoma check` reports a policy problem at its place and runs no scenario until there are none; `sanoma` refuses to start on one. A scenario runs as the agent `scenarios` unless it says who is acting (`Given bo is acting`), and checks the policy with `Then ghost.post.publish was held for group "editor"` and `Then <op> was denied with "<reason>"`. The app's Permissions page shows what the policies answer for each group.
62
96
 
63
97
  ## Commands
64
98
 
65
99
  Run them from the directory that holds `sanoma.config.ts`. Each loads `.env` there first, when there is one (a variable already set wins), then the config.
66
100
 
67
- | Command | What it does |
68
- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
- | `sanoma` | Makes `SANOMA_SECRETS_KEY`, which encrypts the stored credentials, when the environment and `.env` have none, appending it to `.env` with one line saying so; makes sure Postgres answers (see [Postgres](#postgres)), then starts the worker (promoted, so a local worker takes every queued run) and the app in one process, and prints `<appName> running <workflows>` and `<appName> at http://127.0.0.1:3000; ctrl-c to stop`; the worker says `sanoma: 2 of 5 connectors not configured yet: ghost, resend; …` first when some vendors' variables are missing or invalid (a call to one fails, naming them, until they are set; nothing when all are set). In [dev mode](#dev-mode) it runs them in a child it restarts. In an empty directory it first [starts a company](#start-a-company). The worker and the app are given the repo's git checkout as their `source`, which commits to the current branch. |
70
- | `sanoma worker`, `sanoma app` | One of the two alone, for a deployment that runs them apart. Neither touches Docker. |
71
- | `sanoma check` | `tsc -p tsconfig.json`; oxlint over `workflows/`, `policies/` and `resources/` with the repo's `.oxlintrc.json`, written when missing (see [the lint](#the-lint)); every problem `describeConfig` finds (an import a workflow may not make, what its graph cannot draw, a data file outside the subset: what the worker would refuse); then every scenario against the fakes, on a database of its own (`<database>_check`), each step that did not hold a problem. Prints each problem on a line, `file:line:col: message` or `scenario › step: message`, and exits 1 when there is one. No vitest. |
72
- | `sanoma env [--check]` | Writes `.env.example`: the variables `sanoma` reads, then every variable the connectors' drivers declare, by vendor, with its description; optional ones commented out. `--check` writes nothing and exits 1 with "`.env.example` is out of date: run `sanoma env`" when the file differs, for CI. |
73
- | `sanoma ledger export <runId> [--out <file>]` | A run's ledger records from the config's store (the Postgres ledger on its database when it names none), as JSON lines (the shape `jsonlLedger` keeps), to stdout or `--out`. |
74
- | `sanoma --help` | The usage. |
101
+ | Command | What it does |
102
+ | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `sanoma` | Makes `SANOMA_SECRETS_KEY`, which encrypts the stored credentials, when the environment and `.env` have none, appending it to `.env` with one line saying so; makes sure Postgres answers (see [Postgres](#postgres)), then starts the worker (promoted, so a local worker takes every queued run) and the app in one process, and prints `<appName> running <workflows>` and `<appName> at http://127.0.0.1:3000; ctrl-c to stop`; the worker says `sanoma: 2 of 5 connectors not configured yet: ghost, resend; …` first when some vendors' variables are missing or invalid (a call to one fails, naming them, until they are set; nothing when all are set). When the repo has [sites](#sites), it serves the app and the sites from a dev server that shows each edit as it is saved (see [Developing a site](#developing-a-site)). In [dev mode](#dev-mode) it runs them in a child it restarts. In an empty directory it first [starts a company](#start-a-company). The worker and the app are given the repo's git checkout as their `source`, which commits to the current branch. |
104
+ | `sanoma worker`, `sanoma app` | One of the two alone, for a deployment that runs them apart (`app` builds the app with the [sites](#sites)). Neither touches Docker. |
105
+ | `sanoma check` | Writes [`.sanoma/api.ts`](#sites) and `.sanoma/schema.cedarschema` first, each when it changed; then `tsc -p tsconfig.json`; oxlint over `workflows/`, `resources/` and `sites/` (those that exist) with the repo's `.oxlintrc.json`, written when missing (see [the lint](#the-lint)); every problem `describeConfig` finds (an import a workflow may not make, what its graph cannot draw, a data file outside the subset: what the worker would refuse; a site's call to a workflow, collection or operation the config does not have); every problem in the [policies](#people-and-policies), at its `file:line:col` with the policy's id; with [sites](#sites), the app built with them and `tsc -p sites/tsconfig.json`; then, unless the policies have a problem, every scenario against the fakes, on a database of its own (`<database>_check`), each step that did not hold a problem. Prints each problem on a line, `file:line:col: message` or `scenario › step: message`, and exits 1 when there is one. No vitest. |
106
+ | `sanoma env [--check]` | Writes `.env.example`: the variables `sanoma` reads, then every variable the connectors' drivers declare, by vendor, with its description; optional ones commented out. `--check` writes nothing and exits 1 with "`.env.example` is out of date: run `sanoma env`" when the file differs, for CI. |
107
+ | `sanoma ledger export <runId> [--out <file>]` | A run's ledger records from the config's store (the Postgres ledger on its database when it names none), as JSON lines (the shape `jsonlLedger` keeps), to stdout or `--out`. |
108
+ | `sanoma --help` | The usage. |
75
109
 
76
- Exit codes: 2 for a mistake in the call or the repo (no `sanoma.config.ts`, an unknown command or option, a bad argument), printed with the usage where it helps; 1 for failed checks and failures while running; 0 otherwise. `SANOMA_APP_PORT` is the app's port (default 3000; 0 for any free port, which the printed address reports). `SANOMA_APP_HOST` is its address (default 127.0.0.1); any other needs [GitHub sign-in](../app/README.md#github), which `SANOMA_GITHUB_CLIENT_ID`, `SANOMA_GITHUB_CLIENT_SECRET` and `SANOMA_GITHUB_REPO` turn on (all three or none, with `SANOMA_SECRETS_KEY` set; the client id and secret may instead be the stored ones the app's Go live page saved when it created the GitHub App); a mistake in them exits 2 before anything starts. On SIGINT or SIGTERM the app, then the worker, stop, and the process exits 0.
110
+ Exit codes: 2 for a mistake in the call or the repo (no `sanoma.config.ts`, an unknown command or option, a bad argument), printed with the usage where it helps; 1 for failed checks and failures while running; 0 otherwise. `SANOMA_APP_PORT` is the app's port (default 3000; 0 for any free port, which the printed address reports). `SANOMA_APP_HOST` is its address (default 127.0.0.1); any other needs [GitHub sign-in](../app/README.md#github), which `SANOMA_GITHUB_CLIENT_ID` and `SANOMA_GITHUB_CLIENT_SECRET` turn on (both or neither, with `SANOMA_SECRETS_KEY` set; on a host beyond this machine, or with one of them set, the other may be the stored one the app's Go live page saved when it created the GitHub App); a mistake in them exits 2 before anything starts, as does a problem in the policies. On SIGINT or SIGTERM the app, then the worker, stop, and the process exits 0.
77
111
 
78
112
  ## Postgres
79
113
 
@@ -85,7 +119,7 @@ The worker and the app run on `SANOMA_DATABASE_URL` (default `postgresql://postg
85
119
 
86
120
  ## The lint
87
121
 
88
- `sanoma check` lints `workflows/`, `policies/` and `resources/` with oxlint, run in the repo's root on the repo's own `.oxlintrc.json`, so an editor's oxlint reads the same file and the rules' `workflows/**` globs match against the root. `sanoma check` writes that file when there is none:
122
+ `sanoma check` lints `workflows/`, `resources/` and `sites/`, those that exist, with oxlint, run in the repo's root on the repo's own `.oxlintrc.json`, so an editor's oxlint reads the same file and the rules' `workflows/**` globs match against the root. `sanoma check` writes that file when there is none:
89
123
 
90
124
  ```json
91
125
  {
@@ -93,18 +127,40 @@ The worker and the app run on `SANOMA_DATABASE_URL` (default `postgresql://postg
93
127
  }
94
128
  ```
95
129
 
96
- `sanoma/oxlint.json` is self-contained (it extends nothing): `@sanoma-ai/workflows`'s rules (the clock, randomness, the network, the environment, the imports a workflow may make, the data-file subset, with its plugin inside `sanoma`) and the rules this repo holds its own code to. Add your own rules beside the `extends`; `sanoma check` leaves an existing file alone.
130
+ `sanoma/oxlint.json` is self-contained (it extends nothing): `@sanoma-ai/workflows`'s rules (the clock, randomness, the network, the environment, the imports a workflow may make, the data-file subset, with its plugin inside `sanoma`), a site's (client code only: no server function, `*.server.*` file or route `server` handlers, no import of the runtime, a connector, Postgres, DBOS, Node's modules or TanStack Start, no relative import out of `sites/`, no `process` or `require`; types may be imported from anywhere; `sites/__virtual.ts`, the build's listing, aside) and the rules this repo holds its own code to. Add your own rules beside the `extends`; `sanoma check` leaves an existing file alone.
131
+
132
+ ## Sites
133
+
134
+ A folder under `sites/` with a `routes/` directory is a site: TanStack Router file routes the app serves under `/sites/<name>`, in its shell (see [`@sanoma-ai/app`'s Sites](../app/README.md#sites)). A route file imports `createFileRoute` from `@tanstack/react-router`; the repo installs nothing for it but `sanoma`.
135
+
136
+ - `sanoma app` (and `sanoma` when `SANOMA_APP_HOST` is another machine's) builds the app with the repo's sites before anything starts (`building the app with 1 site (hello)`), into `.sanoma/app/build/<key>`, and serve that build. The key covers the app's version and every file under `sites/`, so a start with nothing changed reuses the build (`app build up to date`). With no site, they serve the build the app ships and write nothing under `.sanoma/` but `api.ts`. A build that fails stops the command before the worker starts.
137
+ - `.sanoma/api.ts` is the generated SDK: `sanoma check` (first, before tsc), and `sanoma`, `sanoma serve` and `sanoma app` at start, write it from the config when its text changed, with sites or without; while `sanoma` serves the sites from its dev server, it writes it again (`wrote .sanoma/api.ts`) when `sanoma.config.ts` or any TypeScript file in the repo outside `sites/`, `.sanoma/` and `node_modules/` changes. It types `api` from `sanoma/site`: `api.<workflow>` (the workflow's name in camelCase, `WorkflowFn` of its input), `api.<vendor>.<resource>.<op>` for each operation a person may call directly (a vendor's read, `OpFn` of its input) and `api.data.<collection>` (`CollectionApi` of the collection's record), each with its title and descriptions as JSDoc, so whoever writes a site sees what each call is and `tsc -p sites/tsconfig.json` refuses a call that does not fit. The sites' tsconfig is the only one that reads it: the repo's root `tsconfig.json` (Node, no DOM) must not include it. A workflow whose api name another workflow, a vendor or `data` has is left out of it, and `sanoma check` reports it. Never edit it.
138
+ - `sanoma check`, when there is a site, writes the sites' generated files, then, beside tsc, oxlint and the config, builds the app with the sites (reused when nothing changed) and runs `tsc -p sites/tsconfig.json`, which types every `Link` against every page of the app and the sites. Each of these is a problem: a type error at its `file:line:col`; two pages claiming one path (`More than one page claims /sites/hello/: …`); a site importing server code (`sites/hello/routes/index.tsx:4:28: Import denied in client environment: "@sanoma-ai/workflows"`); and a folder whose name is not one URL segment (`sites/<name>: a site's folder name is a URL segment (lowercase letters, digits and dashes)`), which the app does not mount.
139
+
140
+ ### Developing a site
141
+
142
+ `sanoma` serves the app and the sites from Vite's dev server instead of a build (`serving the app with 1 site (hello) from Vite's dev server: edits show as they are saved`), behind the same login, and writes no build:
143
+
144
+ - An edit to a site's file shows in the open page as it is saved, without a reload, the page's state kept (hot module replacement); the server's render of the page follows on the next request.
145
+ - A new page, or a new site folder, is live once its first route file is written: the route tree is regenerated and open pages reload, with no restart. A Tailwind class in a new file is styled too.
146
+ - A change to `sites/__virtual.ts` itself needs a restart: the route generator loads that file once. `sanoma` writes it; never edit it.
147
+ - `sanoma check` beside it builds the app with the same route options, so it leaves the dev server's route tree alone.
148
+ - The dev server listens on this machine only: with `SANOMA_APP_HOST` naming another, `sanoma` builds the sites and serves the build, as `sanoma app` does.
97
149
 
98
150
  ## Generated files
99
151
 
100
- | File | Written by | Commit it |
101
- | ---------------- | ---------------------------- | --------- |
102
- | `.env.example` | `sanoma env` | yes |
103
- | `.oxlintrc.json` | `sanoma check`, when missing | yes |
152
+ | File | Written by | Commit it |
153
+ | ----------------------------------------------------- | ----------------------------------------- | --------------- |
154
+ | `.env.example` | `sanoma env` | yes |
155
+ | `.oxlintrc.json` | `sanoma check`, when missing | yes |
156
+ | `sites/__virtual.ts` | `sanoma` and `sanoma check`, with sites | yes |
157
+ | `sites/tsconfig.json` | `sanoma` and `sanoma check`, when missing | yes |
158
+ | `.sanoma/api.ts` (the sites' typed `api`) | `sanoma` and `sanoma check` | no (`.sanoma/`) |
159
+ | `.sanoma/app/` (the route tree, its tsconfig, builds) | `sanoma` and `sanoma check`, with sites | no (`.sanoma/`) |
104
160
 
105
161
  ## Dev mode
106
162
 
107
- When the repo's `node_modules/sanoma` or any `node_modules/@sanoma-ai/*` is a link into a sanoma checkout (`pnpm link`), or `SANOMA_DEV_REPO` names one, `sanoma` runs `sanoma serve` in a child process and, in every linked package's directory, its `pnpm run watch` (each package's own watch build: `tsc --watch`, and `vite build --watch` too for the app). A change under any linked package's `dist/` restarts the child, after three quarters of a second of quiet, one restart at a time; a child that exits on its own is reported and started again on the next change. The child and each watch run in a process group of their own, so a terminal's ctrl-c reaches `sanoma` alone, which then ends each group (SIGTERM, SIGKILL after 5 seconds) and exits.
163
+ When the repo's `node_modules/sanoma` or any `node_modules/@sanoma-ai/*` is a link into a sanoma checkout (`pnpm link`), or `SANOMA_DEV_REPO` names one, `sanoma` runs `sanoma serve --dev` in a child process (serving the [sites](#developing-a-site) as `sanoma` does) and, in every linked package's directory, its `pnpm run watch` (each package's own watch build: `tsc --watch`, and `vite build --watch` too for the app). A change under any linked package's `dist/` restarts the child, after three quarters of a second of quiet (with sites, except the app's own pages in `dist/client` and `dist/server`: the dev server serves the app's source from the checkout and hot-updates it), one restart at a time; a child that exits on its own is reported and started again on the next change. The child and each watch run in a process group of their own, so a terminal's ctrl-c reaches `sanoma` alone, which then ends each group (SIGTERM, SIGKILL after 5 seconds) and exits.
108
164
 
109
165
  Linking some of `sanoma`, `@sanoma-ai/workflows`, `@sanoma-ai/app` and `@sanoma-ai/bridge` and not the others works, with two copies of a package in one process (the linked one, and the one an installed package depends on), and `sanoma` says which still come from their tarballs before it starts the child: `dev mode: sanoma, @sanoma-ai/app, @sanoma-ai/bridge still come from their tarballs: edits to them in the checkout will not show until you pnpm link them too`. Link all four to run the checkout alone.
110
166
 
@@ -112,6 +168,6 @@ Linking some of `sanoma`, `@sanoma-ai/workflows`, `@sanoma-ai/app` and `@sanoma-
112
168
 
113
169
  `sanoma worker` and `sanoma app` are the deployment's two processes. A host that composes its own process keeps `startWorker` from `@sanoma-ai/workflows` and `startApp` from `@sanoma-ai/app`, which the bin runs.
114
170
 
115
- [`runtime/`](runtime/Dockerfile) is the image a container host runs: Node 24, git, pnpm (corepack) and `provider-bridge`, and no company code. At start it clones `SANOMA_SOURCE` at `SANOMA_REVISION` (with `SANOMA_SOURCE_TOKEN` as an HTTP header when set), runs `pnpm install --frozen-lockfile` and `sanoma serve` on `0.0.0.0` and `PORT` (default 3000); the host passes `SANOMA_DATABASE_URL`, `SANOMA_SECRETS_KEY` and, as the app is not on loopback, the `SANOMA_GITHUB_*` sign-in variables too. Its health check is the app's `/healthz`. `provider-bridge` is built from source at a pinned commit; `--build-arg BRIDGE_FROM=release --build-arg BRIDGE_VERSION=<x.y.z>` downloads a release instead. CI builds the image and pushes it nowhere.
171
+ [`runtime/`](runtime/Dockerfile) is the image a container host runs: Node 24, git, pnpm (corepack) and `provider-bridge`, and no company code. At start it clones `SANOMA_SOURCE` at `SANOMA_REVISION` (with `SANOMA_SOURCE_TOKEN` as an HTTP header when set), runs `pnpm install --frozen-lockfile` and `sanoma serve` on `0.0.0.0` and `PORT` (default 3000); the host passes `SANOMA_DATABASE_URL`, `SANOMA_SECRETS_KEY` and, as the app is not on loopback, the `SANOMA_GITHUB_*` sign-in variables too. Its health check is the app's `/healthz`. A repo with [sites](#sites) is built at start, as `sanoma serve` does anywhere, into `.sanoma/app/` in the clone: the app listens once the build is done (the health check's start period allows 5 minutes for the clone, the install and the build); the image itself holds no build. `provider-bridge` is built from source at a pinned commit; `--build-arg BRIDGE_FROM=release --build-arg BRIDGE_VERSION=<x.y.z>` downloads a release instead. CI builds the image and pushes it nowhere; it runs no company in it, so neither a site's build.
116
172
 
117
173
  Status: early (0.x). License: FSL-1.1-ALv2.
package/dist/check.d.ts CHANGED
@@ -16,12 +16,17 @@ export interface CheckOptions {
16
16
  log: (line: string) => void;
17
17
  }
18
18
  /**
19
- * Checks a repo the way its tests would, without a test framework: `tsc -p tsconfig.json` in
19
+ * Checks a repo the way its tests would, without a test framework: what is wrong in its
20
+ * `policies/**\/*.cedar` (`policyProblems`, as `resolveConfig` reads them); the generated files written first (`writeGenerated`: `.sanoma/api.ts` and the Cedar schema,
21
+ * each when it changed); `tsc -p tsconfig.json` in
20
22
  * its root; oxlint in the root, with the repo's `.oxlintrc.json` (written when missing, to extend
21
- * this package's `oxlint.json`), over `workflows/`, `policies/` and `resources/`; every problem
23
+ * this package's `oxlint.json`), over `workflows/`, `resources/` and `sites/`; every problem
22
24
  * `describeConfig` finds in the data files and the workflows' files (the import rules and what
23
- * the outline cannot draw: what the worker refuses to start with); these three at once, their
24
- * problems in that order. Then every scenario against the fakes (`runScenarios`), each step that
25
- * did not hold a problem. `ok` when there are no problems.
25
+ * the outline cannot draw: what the worker refuses to start with), and each site's call to what
26
+ * the config does not have; with sites, their generated files written first and, beside those
27
+ * three, the app built with them and `tsc -p sites/tsconfig.json` (`checkSites`). Their problems
28
+ * in the order tsc, the sites' tsc, oxlint, the policies, the config, the folders refused as
29
+ * sites, the sites' build. Then, unless the policies do not hold, every scenario against the fakes (`runScenarios`), each step that did not hold a
30
+ * problem. `ok` when there are no problems.
26
31
  */
27
32
  export declare function check({ config, root, resolved }: Loaded, { databaseUrl, ready, log }: CheckOptions): Promise<CheckResult>;
package/dist/check.js CHANGED
@@ -3,28 +3,55 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { join, relative } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { promisify } from "node:util";
6
- import { describeConfig } from "@sanoma-ai/workflows/describe";
6
+ import { errorMessage } from "@sanoma-ai/workflows";
7
+ import { describeConfig, readPeople, schemaOf, writeGenerated, } from "@sanoma-ai/workflows/describe";
7
8
  import { problemLine } from "@sanoma-ai/workflows/shared";
8
9
  import { runScenarios } from "@sanoma-ai/workflows/scenarios";
10
+ import { runtimeFrom, siteBuild } from "./sites.js";
9
11
  /** The directories oxlint reads, those that exist. */
10
- const LINTED = ["workflows", "policies", "resources"];
12
+ const LINTED = ["workflows", "resources", "sites"];
11
13
  /**
12
- * Checks a repo the way its tests would, without a test framework: `tsc -p tsconfig.json` in
14
+ * Checks a repo the way its tests would, without a test framework: what is wrong in its
15
+ * `policies/**\/*.cedar` (`policyProblems`, as `resolveConfig` reads them); the generated files written first (`writeGenerated`: `.sanoma/api.ts` and the Cedar schema,
16
+ * each when it changed); `tsc -p tsconfig.json` in
13
17
  * its root; oxlint in the root, with the repo's `.oxlintrc.json` (written when missing, to extend
14
- * this package's `oxlint.json`), over `workflows/`, `policies/` and `resources/`; every problem
18
+ * this package's `oxlint.json`), over `workflows/`, `resources/` and `sites/`; every problem
15
19
  * `describeConfig` finds in the data files and the workflows' files (the import rules and what
16
- * the outline cannot draw: what the worker refuses to start with); these three at once, their
17
- * problems in that order. Then every scenario against the fakes (`runScenarios`), each step that
18
- * did not hold a problem. `ok` when there are no problems.
20
+ * the outline cannot draw: what the worker refuses to start with), and each site's call to what
21
+ * the config does not have; with sites, their generated files written first and, beside those
22
+ * three, the app built with them and `tsc -p sites/tsconfig.json` (`checkSites`). Their problems
23
+ * in the order tsc, the sites' tsc, oxlint, the policies, the config, the folders refused as
24
+ * sites, the sites' build. Then, unless the policies do not hold, every scenario against the fakes (`runScenarios`), each step that did not hold a
25
+ * problem. `ok` when there are no problems.
19
26
  */
20
27
  export async function check({ config, root, resolved }, { databaseUrl, ready = Promise.resolve(), log }) {
21
28
  // Awaited below when there are scenarios; otherwise its failure is nobody's.
22
29
  ready.catch(() => { });
23
- const found = await Promise.all([typecheck(root, log), lint(root, log), configProblems(config, root, log)]);
24
- const problems = found.flat();
30
+ log("config");
31
+ const policies = resolved.policyProblems;
32
+ const description = describeConfig(config);
33
+ const { wrote } = await writeGenerated(root, description, schemaOf(resolved, readPeople(root).people));
34
+ for (const file of wrote)
35
+ log(`wrote ${file}`);
36
+ const build = await siteBuild(root);
37
+ const { sites, refused } = build?.sitesOf(root) ?? { sites: [], refused: [] };
38
+ // Before tsc and oxlint read sites/, as `sanoma` writes them: only when there is a site.
39
+ if (build && sites.length)
40
+ build.writeSiteFiles(root);
41
+ const [tsc, checked, lints] = await Promise.all([
42
+ typecheck(root, log),
43
+ build && sites.length ? checkSites(build, sites, root, log) : { typed: [], built: [] },
44
+ lint(root, log),
45
+ ]);
46
+ const read = configProblems(description, root);
47
+ const unmounted = refused.map((name) => `sites/${name}: a site's folder name is a URL segment (lowercase letters, digits and dashes)`);
48
+ const problems = [...tsc, ...checked.typed, ...lints, ...policies, ...read, ...unmounted, ...checked.built];
25
49
  if (resolved.scenarios === undefined) {
26
50
  log("no scenarios: the config's root has no `scenarios/` directory");
27
51
  }
52
+ else if (policies.length) {
53
+ log("no scenarios: the policies do not hold");
54
+ }
28
55
  else {
29
56
  await ready;
30
57
  log("scenarios");
@@ -34,10 +61,41 @@ export async function check({ config, root, resolved }, { databaseUrl, ready = P
34
61
  }
35
62
  return { ok: problems.length === 0, problems };
36
63
  }
37
- /** `tsc -p tsconfig.json` in the root. */
38
- async function typecheck(root, log) {
39
- log("tsc");
40
- const tsc = await run(binOf("typescript"), ["-p", "tsconfig.json", "--pretty", "false"], root);
64
+ /**
65
+ * The sites: the app built with them (`buildApp`, reused when nothing changed), so two pages
66
+ * claiming one path or a site importing server code is a problem; then `tsc -p
67
+ * sites/tsconfig.json`, which needs the route tree the build generates (it gives every `Link` its
68
+ * type), so it runs once there is one.
69
+ */
70
+ async function checkSites(build, sites, root, log) {
71
+ log(`build ${sites.join(" ")}`);
72
+ const built = await build.buildApp(root, { runtimeFrom: runtimeFrom() }).then(() => [], (err) => buildProblems(errorMessage(err), log));
73
+ if (!existsSync(join(root, ".sanoma", "app", "routeTree.gen.ts")))
74
+ return { typed: [], built };
75
+ return { typed: await typecheck(root, log, "sites/tsconfig.json"), built };
76
+ }
77
+ /**
78
+ * A failed build's problems, one line each: every import the browser may not make, at its
79
+ * importer's `file:line:col`; anything else as its first line, the whole message logged.
80
+ */
81
+ function buildProblems(message, log) {
82
+ const denied = [
83
+ ...message.matchAll(/Import denied in client environment[\s\S]*?Importer: (\S+)[\s\S]*?Import: ("[^"\n]*")/g),
84
+ ];
85
+ if (denied.length)
86
+ return denied.map(([, at, what]) => `${at}: Import denied in client environment: ${what}`);
87
+ const lines = message
88
+ .split("\n")
89
+ .map((line) => line.trim())
90
+ .filter((line) => line && !/^Build failed with \d+ errors?:$/.test(line));
91
+ if (lines.length > 1)
92
+ log(message);
93
+ return [lines[0] ?? "the app's build failed"];
94
+ }
95
+ /** `tsc -p <project>` in the root (`tsconfig.json`, or the sites' `sites/tsconfig.json`). */
96
+ async function typecheck(root, log, project = "tsconfig.json") {
97
+ log(project === "tsconfig.json" ? "tsc" : `tsc ${project}`);
98
+ const tsc = await run(binOf("typescript"), ["-p", project, "--pretty", "false"], root);
41
99
  return tsc.code === 0 ? [] : tscProblems(tsc);
42
100
  }
43
101
  /** oxlint in the root, on its `.oxlintrc.json` (written when missing), over the directories that exist. */
@@ -52,14 +110,16 @@ async function lint(root, log) {
52
110
  }
53
111
  /**
54
112
  * `describeConfig`'s problems: the data files', then each workflow's, its file relative to the
55
- * root. A file defining several workflows gives each its problems: one line each here.
113
+ * root, then each site's (a call to what the config does not have). A file defining several
114
+ * workflows gives each its problems: one line each here.
56
115
  */
57
- async function configProblems(config, root, log) {
58
- log("config");
59
- const { problems, workflows } = describeConfig(config);
116
+ function configProblems({ problems, workflows, sites }, root) {
60
117
  const lines = new Set([
61
118
  ...problems.map(problemLine),
62
119
  ...workflows.flatMap((wf) => wf.problems.map((p) => problemLine({ file: relative(root, wf.file), ...p }))),
120
+ ...sites.flatMap((site) => site.problems.map(problemLine)),
121
+ // The people's own (an id two share, a reserved one), which admit nobody while they stand.
122
+ ...readPeople(root).problems.map(problemLine),
63
123
  ]);
64
124
  return [...lines];
65
125
  }
package/dist/check.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;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AAI,EAAE,MAAM,EAAE,MAAM,EAAO;IACnD,IAAI,WAAyB,CAAC;IAC9B,IAAI,CAAC;QACH,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAkC,CAAC,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,sBAAsB,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACpE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC1E,OAAO,GAAG,KAAK,KAAK,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjG,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/cli.js CHANGED
@@ -14,17 +14,20 @@ import { fileURLToPath, pathToFileURL } from "node:url";
14
14
  import { parseArgs } from "node:util";
15
15
  import { loadConfig, UsageError } from "./config.js";
16
16
  // Only Node's modules and ./config.ts are imported here: each command imports what it runs, so
17
- // `--help`, `env`, `ledger export` and the dev-mode parent load neither the worker nor the app.
17
+ // `--help`, `env`, `ledger export` and the dev-mode parent load neither the worker nor the app (the
18
+ // parent loads the app's Node-only build module to see whether there are sites).
18
19
  const USAGE = `usage: sanoma [command]
19
20
 
20
21
  Runs the repo in the working directory, from its sanoma.config.ts (after its .env, when there is one).
21
22
 
22
- sanoma the worker and the app; starts Postgres in Docker when nothing answers. In an
23
- empty directory, first starts a company there: the template, .env, an install
24
- and a git repository
23
+ sanoma the worker and the app; starts Postgres in Docker when nothing answers, and
24
+ serves the repo's sites/, when it has any, from a dev server that shows each
25
+ edit as it is saved. In an empty directory, first starts a company there: the
26
+ template, .env, an install and a git repository
25
27
  sanoma worker the worker alone, for a deployment
26
- sanoma app the app alone, for a deployment
27
- sanoma check typecheck, lint, read the config, run every scenario; exit 1 on a problem
28
+ sanoma app the app alone (built with the sites), for a deployment
29
+ sanoma check typecheck, lint, read the config, build and typecheck the sites, run every
30
+ scenario; exit 1 on a problem
28
31
  sanoma env [--check] write .env.example from the drivers' variables; --check exits 1 when it is out of date
29
32
  sanoma ledger export <runId> [--out <file>]
30
33
  a run's ledger records as JSON lines
@@ -63,20 +66,24 @@ export async function main(argv) {
63
66
  const { devRepo, linkedPackages } = await import("./dev.js");
64
67
  const linked = linkedPackages(process.cwd());
65
68
  const repo = devRepo(process.cwd(), linked);
66
- return repo === undefined ? serveCommand() : dev(repo, linked);
69
+ return repo === undefined ? serveCommand(true) : dev(repo, linked);
67
70
  }
68
71
  case "serve":
69
- return serveCommand();
72
+ // --dev (hidden): the child dev mode supervises, serving the sites as `sanoma` does.
73
+ return serveCommand(values.dev ?? false);
70
74
  case "worker": {
71
75
  const { runWorker } = await import("./serve.js");
72
76
  return keep(await load(), runWorker);
73
77
  }
74
78
  case "app": {
75
79
  const { runApp } = await import("./serve.js");
76
- return keep(await load(), (config) => runApp(config, { port: port() }));
80
+ return keep(await load(), (config, resolved) => runApp(config, { port: port(), log, resolved }));
77
81
  }
78
82
  case "check":
79
83
  return runCheck();
84
+ case "api":
85
+ // Hidden: the dev server runs it when the config's files change.
86
+ return writeApiCommand();
80
87
  case "env":
81
88
  return env(values.check ?? false);
82
89
  case "ledger": {
@@ -92,13 +99,27 @@ export async function main(argv) {
92
99
  const parse = (argv) => parseArgs({
93
100
  args: argv,
94
101
  allowPositionals: true,
95
- options: { help: { type: "boolean", short: "h" }, check: { type: "boolean" }, out: { type: "string" } },
102
+ options: {
103
+ help: { type: "boolean", short: "h" },
104
+ check: { type: "boolean" },
105
+ out: { type: "string" },
106
+ dev: { type: "boolean" },
107
+ },
96
108
  });
97
109
  const port = () => Number(process.env.SANOMA_APP_PORT ?? 3000);
98
- async function load() {
110
+ /**
111
+ * The config, loaded and resolved, with its policy from `policies/**\/*.cedar` (`policyAt`): a
112
+ * problem with them is a `UsageError`, so nothing starts on policies that do not hold. Without
113
+ * `policies`, they are left to the caller (`check` reports them).
114
+ */
115
+ async function load({ policies = true } = {}) {
99
116
  const loaded = await loadConfig();
100
117
  const { resolveConfig } = await import("@sanoma-ai/workflows");
101
- return { ...loaded, resolved: resolveConfig(loaded.config) };
118
+ const resolved = resolveConfig(loaded.config);
119
+ if (policies && resolved.policyProblems.length) {
120
+ throw new UsageError(`The policies do not hold:\n${resolved.policyProblems.join("\n")}`);
121
+ }
122
+ return { ...loaded, resolved };
102
123
  }
103
124
  /**
104
125
  * Starts what `start` starts over the loaded config, prints what runs (and where, when it
@@ -106,7 +127,7 @@ async function load() {
106
127
  * configured yet itself, in one line.
107
128
  */
108
129
  async function keep({ config, resolved }, start) {
109
- const started = await start(config);
130
+ const started = await start(config, resolved);
110
131
  const running = `${resolved.appName} running ${[...resolved.workflows.keys()].join(", ")}`;
111
132
  if (started.url === undefined) {
112
133
  console.log(`${running}; ctrl-c to stop`);
@@ -118,15 +139,18 @@ async function keep({ config, resolved }, start) {
118
139
  onSignal(() => started.stop());
119
140
  return new Promise(() => { });
120
141
  }
121
- /** `sanoma serve` (and `sanoma` outside dev mode): Postgres, then the worker and the app in this process. */
122
- async function serveCommand() {
142
+ /**
143
+ * `sanoma serve` (and `sanoma` outside dev mode): Postgres, then the worker and the app in this
144
+ * process. With `devServer` (`sanoma`), a repo's sites are served from Vite's dev server, not built.
145
+ */
146
+ async function serveCommand(devServer) {
123
147
  const loaded = await load();
124
148
  (await import("./key.js")).ensureSecretsKey(process.cwd(), log);
125
149
  const { appName, databaseUrl } = loaded.resolved;
126
150
  const { ensurePostgres } = await import("./postgres.js");
127
151
  await ensurePostgres(databaseUrl, { appName, log });
128
152
  const { serve } = await import("./serve.js");
129
- return keep(loaded, (config) => serve(config, { port: port() }));
153
+ return keep(loaded, (config, resolved) => serve(config, { port: port(), log, dev: devServer, resolved }));
130
154
  }
131
155
  /**
132
156
  * A company just started in `cwd`: the `sanoma` it installed serves it, in this process, so that
@@ -135,14 +159,16 @@ async function serveCommand() {
135
159
  async function serveStarted(cwd) {
136
160
  const installed = join(cwd, "node_modules/sanoma/dist/cli.js");
137
161
  if (!existsSync(installed))
138
- return serveCommand();
162
+ return serveCommand(true);
139
163
  const { main: run } = (await import(__rewriteRelativeImportExtension(pathToFileURL(installed).href)));
140
164
  return run([]);
141
165
  }
142
166
  /**
143
- * Dev mode: `sanoma serve` in a child it restarts on a new build, and each linked package's
144
- * `watch`. Each runs in a process group of its own, so a terminal's ctrl-c reaches this process
145
- * alone, and its `stop` is the one path that ends them.
167
+ * Dev mode: `sanoma serve --dev` in a child it restarts on a new build, and each linked package's
168
+ * `watch`. With sites, the child serves the app's source from Vite's dev server, which updates it
169
+ * in place: a new build of the app's pages (its `dist/client` and `dist/server`) restarts nothing.
170
+ * Each runs in a process group of its own, so a terminal's ctrl-c reaches this process alone, and
171
+ * its `stop` is the one path that ends them.
146
172
  */
147
173
  async function dev(repo, packages) {
148
174
  const { partialLink, startWatchers, supervise } = await import("./dev.js");
@@ -155,9 +181,14 @@ async function dev(repo, packages) {
155
181
  }
156
182
  const watchers = startWatchers(packages, log);
157
183
  const cli = fileURLToPath(import.meta.url);
184
+ const app = packages.find((p) => p.name === "@sanoma-ai/app");
185
+ const { siteBuild } = await import("./sites.js");
186
+ // A linked app with no build yet is not hot: every change restarts the child until it builds.
187
+ const hot = app && (await siteBuild(cwd).catch(() => undefined))?.sitesOf(cwd).sites.length;
158
188
  const child = supervise({
159
- spawn: () => spawn(process.execPath, [cli, "serve"], { cwd, env: process.env, stdio: "inherit", detached: true }),
189
+ spawn: () => spawn(process.execPath, [cli, "serve", "--dev"], { cwd, env: process.env, stdio: "inherit", detached: true }),
160
190
  watch: packages.map((p) => join(p.dir, "dist")),
191
+ ignore: hot ? [join(app.dir, "dist", "client"), join(app.dir, "dist", "server")] : [],
161
192
  log,
162
193
  });
163
194
  onSignal(async () => {
@@ -166,9 +197,18 @@ async function dev(repo, packages) {
166
197
  });
167
198
  return new Promise(() => { });
168
199
  }
200
+ /** `sanoma api` (hidden): writes the generated files from the config, as `check` and `serve` do. */
201
+ async function writeApiCommand() {
202
+ const { config, root, resolved } = await load({ policies: false });
203
+ const { describeConfig, readPeople, schemaOf, writeGenerated } = await import("@sanoma-ai/workflows/describe");
204
+ const { wrote } = await writeGenerated(root, describeConfig(config), schemaOf(resolved, readPeople(root).people));
205
+ for (const file of wrote)
206
+ log(`wrote ${file}`);
207
+ return 0;
208
+ }
169
209
  /** `sanoma check`: Postgres made to answer while tsc, oxlint and the config are read; the scenarios on `<database>_check`. */
170
210
  async function runCheck() {
171
- const loaded = await load();
211
+ const loaded = await load({ policies: false });
172
212
  const { appName, databaseUrl } = loaded.resolved;
173
213
  const [{ ensurePostgres }, { check }] = await Promise.all([import("./postgres.js"), import("./check.js")]);
174
214
  const own = new URL(databaseUrl);
@@ -182,7 +222,7 @@ async function runCheck() {
182
222
  return ok ? 0 : 1;
183
223
  }
184
224
  async function env(checkOnly) {
185
- const loaded = await load();
225
+ const loaded = await load({ policies: false });
186
226
  const { writeEnvExample } = await import("./env.js");
187
227
  const { changed } = writeEnvExample(loaded, { check: checkOnly });
188
228
  if (!checkOnly) {