@jimhoyd/urlcode 0.4.0-alpha.3 → 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 (65) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +20 -15
  3. package/ROADMAP.md +16 -11
  4. package/dist/BUILD-MANIFEST.json +16 -15
  5. package/dist/authoring.js +15 -1
  6. package/dist/capability-query.js +0 -1
  7. package/dist/catalog.js +0 -1
  8. package/dist/cli.js +23 -7
  9. package/dist/config.js +1 -1
  10. package/dist/explain.js +1 -1
  11. package/dist/http-response.js +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/init-with.js +36 -11
  14. package/dist/manifest.js +1 -1
  15. package/dist/mcp-authoring.js +2 -2
  16. package/dist/mcp.js +1 -1
  17. package/dist/policies/cache.js +2 -2
  18. package/dist/project-dependencies.js +305 -0
  19. package/dist/runtime.js +1 -1
  20. package/dist/trusted-functions.js +4 -5
  21. package/dist/types/authoring.d.ts +9 -1
  22. package/dist/types/capability-query.d.ts +0 -1
  23. package/dist/types/catalog.d.ts +0 -4
  24. package/dist/types/config.d.ts +1 -9
  25. package/dist/types/explain.d.ts +0 -1
  26. package/dist/types/http-response.d.ts +0 -1
  27. package/dist/types/index.d.ts +1 -0
  28. package/dist/types/init-with.d.ts +7 -13
  29. package/dist/types/manifest.d.ts +0 -1
  30. package/dist/types/project-dependencies.d.ts +78 -0
  31. package/dist/types/trusted-functions.d.ts +1 -4
  32. package/docs/AI-AUTHORING.md +5 -1
  33. package/docs/AWS.md +9 -0
  34. package/docs/CI-FOLLOWUP-2026-09-19.md +1 -1
  35. package/docs/CODEBASE-AUDIT-2026-09-20.md +6 -0
  36. package/docs/COMPOSING-A-SITE.md +278 -0
  37. package/docs/DEVELOPMENT-PIPELINE.md +208 -119
  38. package/docs/EXTENSIONS.md +36 -6
  39. package/docs/FRAMEWORK.md +45 -30
  40. package/docs/INSTALL.md +13 -8
  41. package/docs/MIDDLEWARE.md +10 -4
  42. package/docs/OPEN-DECISIONS.md +46 -6
  43. package/docs/READINESS.md +4 -3
  44. package/docs/README.md +3 -4
  45. package/docs/RELEASE-0.4.1.md +73 -0
  46. package/docs/RELEASE-SECURITY.md +27 -12
  47. package/docs/SPECIFICATION.md +5 -1
  48. package/docs/SPIKE-CORE-LAYERING.md +1 -1
  49. package/docs/STARTERS.md +17 -5
  50. package/docs/TOOLING.md +6 -4
  51. package/docs/VERCEL.md +10 -2
  52. package/docs/VERSION-ALIGNMENT.md +42 -8
  53. package/docs/archive/2026-09-19/ROADMAP.md +1 -0
  54. package/docs/archive/2026-09-19/SPIKE-EXTENSION-MODEL.md +1 -0
  55. package/docs/{SPIKE-LAMBDA-COMPILE.md → archive/2026-09-19/SPIKE-LAMBDA-COMPILE.md} +168 -12
  56. package/docs/archive/2026-09-19/SPIKE-MONOREPO.md +2 -0
  57. package/docs/archive/README.md +1 -0
  58. package/docs/yaml/functions.md +10 -2
  59. package/docs/yaml/middleware.md +5 -3
  60. package/examples/cookbook/middleware/envelope.mjs +4 -2
  61. package/llms-full.txt +387 -44
  62. package/llms.txt +1 -0
  63. package/package.json +8 -5
  64. package/packaging/claude-plugin/.claude-plugin/plugin.json +1 -1
  65. package/recipes/middleware/middleware/envelope.mjs +4 -2
package/llms-full.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- Generated by scripts/build-llms-full.ts (npm run docs:llms). Do not edit; edit the source documents. -->
2
- <!-- Consolidated URLCode authoring reference: 15 documents, about 48,160 tokens (estimate: characters / 4). -->
2
+ <!-- Consolidated URLCode authoring reference: 16 documents, about 52,663 tokens (estimate: characters / 4). -->
3
3
 
4
4
  # URLCode
5
5
 
@@ -36,7 +36,8 @@ Agents that explicitly want the complete consolidated reference in one fetch sho
36
36
  12. [Conditional routing](#conditional-routing)
37
37
  13. [Bounded proxy and webhook transport](#bounded-proxy-and-webhook-transport)
38
38
  14. [Operator-installed extensions](#operator-installed-extensions)
39
- 15. [Function execution: trusted by default, sandboxed opt-in](#function-execution-trusted-by-default-sandboxed-opt-in)
39
+ 15. [Composing a site from ui, auth and admin](#composing-a-site-from-ui-auth-and-admin)
40
+ 16. [Function execution: trusted by default, sandboxed opt-in](#function-execution-trusted-by-default-sandboxed-opt-in)
40
41
 
41
42
  ---
42
43
 
@@ -51,26 +52,26 @@ claim here is implemented in the linked repository; nothing is roadmap.
51
52
 
52
53
  ### Four packages, one project shape
53
54
 
54
- | Package | Repository | What it adds | How a project declares it |
55
+ | Package | Source | What it adds | How a project declares it |
55
56
  |---|---|---|---|
56
- | `@jimhoyd/urlcode` | [urlcode](https://github.com/jimhoyd-com/urlcode) | The runtime: YAML routes, functions and middleware (trusted by default, `sandbox: true` opt-in), pages and assets, policies, site conventions, CLI, provider adapters, the extension contract | `urlcode.yaml` with `version: "1"` |
57
- | `@jimhoyd/urlcode-ui` | [urlcode-ui](https://github.com/jimhoyd-com/urlcode-ui) | Shared presentation: escaped templates, shadcn/ui partials, one stylesheet with light and dark, themes, translations, the `ui` extension that serves the kit's assets | `extensions.ui` plus an asset mount route |
58
- | `@jimhoyd/urlcode-auth` | [urlcode-auth](https://github.com/jimhoyd-com/urlcode-auth) | Accounts: password, passkeys, OpenID Connect, email codes, TOTP, recovery, sessions, roles, registration modes, account page, operator CLI | `extensions.auth` plus an `/account/*` mount and `policies.extensions.auth` on protected routes |
59
- | `@jimhoyd/urlcode-admin` | [urlcode-admin](https://github.com/jimhoyd-com/urlcode-admin) | Administration: users, sessions, roles, audit, registration approval, two-person cases, support impersonation, health | `extensions.admin` plus an `/admin/*` mount |
60
-
61
- The core is Apache-2.0 and released. The three extension packages are
62
- Apache-2.0 and published to npm as alphas (`@jimhoyd/urlcode-ui@0.1.0-alpha.4`,
63
- `@jimhoyd/urlcode-auth@0.1.0-alpha.2`, `@jimhoyd/urlcode-admin@0.1.0-alpha.2`,
64
- on core `0.4.0-alpha.1`). An alpha on npm is a distribution channel, not an
65
- endorsement: the source is complete, but independent review, deployment
66
- evidence and an accessibility assessment are still pending
57
+ | `@jimhoyd/urlcode` | this repository | The runtime: YAML routes, functions and middleware (trusted by default, `sandbox: true` opt-in), pages and assets, policies, site conventions, CLI, provider adapters, the extension contract | `urlcode.yaml` with `version: "1"` |
58
+ | `@jimhoyd/urlcode-ui` | [`packages/ui`](https://github.com/jimhoyd-com/urlcode/blob/main/packages/ui) | Shared presentation: escaped templates, shadcn/ui partials, one stylesheet with light and dark, themes, translations, the `ui` extension that serves the kit's assets | `extensions.ui` plus an asset mount route |
59
+ | `@jimhoyd/urlcode-auth` | [`packages/auth`](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth) | Accounts: password, passkeys, OpenID Connect, email codes, TOTP, recovery, sessions, roles, registration modes, account page, operator CLI | `extensions.auth` plus an `/account/*` mount and `policies.extensions.auth` on protected routes |
60
+ | `@jimhoyd/urlcode-admin` | [`packages/admin`](https://github.com/jimhoyd-com/urlcode/blob/main/packages/admin) | Administration: users, sessions, roles, audit, registration approval, two-person cases, support impersonation, health | `extensions.admin` plus an `/admin/*` mount |
61
+
62
+ All four are Apache-2.0. The `0.4.1` release line aligns their stable versions;
63
+ check `npm run release:status` for publication progress. A stable npm channel is
64
+ not an independent assessment: review, deployment evidence and an accessibility
65
+ assessment are still pending
67
66
  ([issue 58](https://github.com/jimhoyd-com/urlcode/issues/58)). Their status
68
- files say exactly what is built: [auth](https://github.com/jimhoyd-com/urlcode-auth/blob/main/IMPLEMENTATION-STATUS.md),
69
- [admin](https://github.com/jimhoyd-com/urlcode-admin/blob/main/IMPLEMENTATION-STATUS.md),
70
- [ui](https://github.com/jimhoyd-com/urlcode-ui/blob/main/IMPLEMENTATION-STATUS.md).
71
- Which core version each package supports, how it declares that, and the order
72
- in which a core change reaches the downstream repositories are recorded in
73
- [core version alignment](https://github.com/jimhoyd-com/urlcode/blob/main/docs/VERSION-ALIGNMENT.md).
67
+ files say exactly what is built: [auth](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth/IMPLEMENTATION-STATUS.md),
68
+ [admin](https://github.com/jimhoyd-com/urlcode/blob/main/packages/admin/IMPLEMENTATION-STATUS.md),
69
+ [ui](https://github.com/jimhoyd-com/urlcode/blob/main/packages/ui/IMPLEMENTATION-STATUS.md).
70
+ The current version of each package is its own manifest, and the peer ranges it
71
+ declares are in that manifest too; do not read a version number out of this
72
+ page. How versions, channels and release tags line up is recorded in
73
+ [package and channel alignment](https://github.com/jimhoyd-com/urlcode/blob/main/docs/VERSION-ALIGNMENT.md), and `npm run
74
+ release:status` reports the live registry and tag state.
74
75
 
75
76
  ### The ladder
76
77
 
@@ -87,8 +88,10 @@ Each rung's YAML is valid on every rung above it.
87
88
  3. **Functions and middleware.** `function` routes and ordered `middleware`
88
89
  in JavaScript, trusted and in-process by default; a route declaring
89
90
  `sandbox: true` runs isolated instead (QuickJS inside WebAssembly, fresh
90
- heap per call, no Node, filesystem or network). Secrets reach a function
91
- only through an operator grant pinned to the project revision.
91
+ heap per call, no Node, filesystem or network). The `env`/`secrets` the
92
+ runtime injects into a function come only from an operator grant pinned to
93
+ the project revision; the grant governs that injected context, not the
94
+ ambient Node environment trusted in-process code can reach on its own.
92
95
  4. **Accounts.** The `auth` extension: sign-in, registration, MFA, account
93
96
  page and protected routes. The operator installs it in a host file outside
94
97
  the project; YAML only declares the mount and configuration.
@@ -105,17 +108,19 @@ was removed from core. A `urlcode-dynamic-link` package owned them the same way
105
108
  package occupies this rung today.
106
109
 
107
110
  Rungs 1 to 3 need only the core package. Rungs 4 to 6 need the extension
108
- packages, installed from npm as `0.1.0-alpha.x` prereleases, and a Node host
109
- with a patched SQLite build; see each repository's README for the exact
110
- requirement.
111
+ packages installed from npm and a Node host with a
112
+ patched SQLite build; see each package's README ([auth](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth/README.md),
113
+ [admin](https://github.com/jimhoyd-com/urlcode/blob/main/packages/admin/README.md), [ui](https://github.com/jimhoyd-com/urlcode/blob/main/packages/ui/README.md)) for the
114
+ exact requirement.
111
115
 
112
116
  ### The composition contract
113
117
 
114
- An extended project starts with the packages and one command:
118
+ After the aligned `0.4.1` packages are published, an extended project starts
119
+ with the packages and one command:
115
120
 
116
121
  ```sh
117
- npm install @jimhoyd/urlcode @jimhoyd/urlcode-ui @jimhoyd/urlcode-auth @jimhoyd/urlcode-admin
118
- urlcode init my-site --with auth,admin
122
+ npm install --save-exact @jimhoyd/urlcode@0.4.1 @jimhoyd/urlcode-ui@0.4.1 @jimhoyd/urlcode-auth@0.4.1 @jimhoyd/urlcode-admin@0.4.1
123
+ urlcode init my-site --with ui,auth,admin
119
124
  ```
120
125
 
121
126
  Installing from npm is the normal path; `scripts/pack-sources.mjs` still builds
@@ -184,7 +189,7 @@ See each package README for its complete kit registration example.
184
189
  urlcode serve --project /absolute/site --host-file /absolute/operator/host.mjs --origin https://site.example
185
190
  ```
186
191
 
187
- `urlcode init <dir> --with auth,admin` writes this layout in one step: it
192
+ `urlcode init <dir> --with ui,auth,admin` writes this layout in one step: it
188
193
  resolves each installed `@jimhoyd/urlcode-<name>` from the current directory,
189
194
  calls its `scaffold` export and merges the fragments into `app/urlcode.yaml`,
190
195
  one `host.mjs` and one `README.md`, refusing before writing anything when a
@@ -195,6 +200,17 @@ administrator from JSON on stdin. `inspectExtensionRevision(project)` prints
195
200
  the SHA-256 that `projectSha256` must carry; changing extension YAML, policies
196
201
  or mounts changes the revision and needs an explicit operator reapproval.
197
202
 
203
+ The presentation tooling composes the same way, by naming packages rather than
204
+ depending on them. `urlcode-ui` is the kit alone until
205
+ `--extensions @jimhoyd/urlcode-auth,@jimhoyd/urlcode-admin` names the packages
206
+ that ship the other namespaces: each is resolved from `--project` with Node
207
+ package resolution and imported for the namespace it exports, so `list`,
208
+ `doctor`, `eject`, `preview` and `copy --missing` cover the `auth/*` and
209
+ `admin/*` templates and copy the host registers, and a project override of an
210
+ extension template is checked against the shipped view model. A package that is
211
+ not installed is skipped. `urlcode init --with` writes the commands with the
212
+ flag already set; `@jimhoyd/urlcode-ui` still depends on neither peer.
213
+
198
214
  ### Rules an agent must follow
199
215
 
200
216
  These are the facts that keep generated projects valid. The full matrix is in
@@ -239,9 +255,9 @@ These are the facts that keep generated projects valid. The full matrix is in
239
255
  | Need | Read |
240
256
  |---|---|
241
257
  | Write or change routes | [YAML guide](https://github.com/jimhoyd-com/urlcode/blob/main/docs/YAML-GUIDE.md), [field reference](https://github.com/jimhoyd-com/urlcode/blob/main/docs/YAML-REFERENCE.md), [cookbook](https://github.com/jimhoyd-com/urlcode/blob/main/examples/cookbook/README.md) |
242
- | Add accounts | [auth README](https://github.com/jimhoyd-com/urlcode-auth#readme), [auth security](https://github.com/jimhoyd-com/urlcode-auth/blob/main/SECURITY.md) |
243
- | Add administration | [admin README](https://github.com/jimhoyd-com/urlcode-admin#readme) |
244
- | Restyle every page | [ui README](https://github.com/jimhoyd-com/urlcode-ui#readme), [ui contract](https://github.com/jimhoyd-com/urlcode-ui/blob/main/CONTRACT.md) |
258
+ | Add accounts | [auth README](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth/README.md), [auth security](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth/SECURITY.md) |
259
+ | Add administration | [admin README](https://github.com/jimhoyd-com/urlcode/blob/main/packages/admin/README.md) |
260
+ | Restyle every page | [ui README](https://github.com/jimhoyd-com/urlcode/blob/main/packages/ui/README.md), [ui contract](https://github.com/jimhoyd-com/urlcode/blob/main/packages/ui/CONTRACT.md) |
245
261
  | Write an extension | [extensions](https://github.com/jimhoyd-com/urlcode/blob/main/docs/EXTENSIONS.md), [extension model review](https://github.com/jimhoyd-com/urlcode/blob/main/docs/archive/2026-09-19/SPIKE-EXTENSION-MODEL.md) |
246
262
  | Run it | [operations](https://github.com/jimhoyd-com/urlcode/blob/main/docs/OPERATIONS.md), [install](https://github.com/jimhoyd-com/urlcode/blob/main/docs/INSTALL.md), [deployment checks](https://github.com/jimhoyd-com/urlcode/blob/main/docs/DEPLOYMENT-CHECKS.md) |
247
263
 
@@ -276,7 +292,11 @@ fields or bypass target limits or operator grants. See [the design principle](ht
276
292
  6. [Readiness](https://github.com/jimhoyd-com/urlcode/blob/main/docs/READINESS.md), [capacity](https://github.com/jimhoyd-com/urlcode/blob/main/docs/CAPACITY.md), [DDoS/recovery](https://github.com/jimhoyd-com/urlcode/blob/main/docs/RESILIENCE.md).
277
293
  7. [The framework](https://github.com/jimhoyd-com/urlcode/blob/main/docs/FRAMEWORK.md) for accounts, administration and presentation:
278
294
  `extensions.<name>` blocks and `extension` mounts are the only YAML those
279
- packages need; their configuration is documented in their own repositories.
295
+ packages need. [Composing a site](https://github.com/jimhoyd-com/urlcode/blob/main/docs/COMPOSING-A-SITE.md) is the map of what a
296
+ consumer may then change: the `config` each package accepts, the
297
+ presentation overrides under `ui/`, the project functions its lifecycle
298
+ hooks call, and when a requirement instead needs a new extension in
299
+ TypeScript.
280
300
 
281
301
  The root [llms.txt](https://github.com/jimhoyd-com/urlcode/blob/main/llms.txt) is a compact discovery index; the generated
282
302
  [llms-full.txt](https://github.com/jimhoyd-com/urlcode/blob/main/llms-full.txt) concatenates the authoring documents above in
@@ -1307,7 +1327,11 @@ entry may likewise be a string, normalized to `{source: <string>}`. Only the
1307
1327
  long form exists after loading, so `routes`, `audit`, `explain`, revision hashes
1308
1328
  and the field reference describe the expansion.
1309
1329
 
1310
- ES modules only (`.mjs` or `.js`, independent of Node package settings).
1330
+ ES modules only. `.mjs` is loaded as ESM in both modes. A `sandbox: true` route
1331
+ also reads `.js` as ESM independently of Node package settings, but a trusted
1332
+ route imports `.js` through Node's own loader, so an ESM `.js` module needs the
1333
+ nearest `package.json` to declare `"type": "module"`; under `"type": "commonjs"`
1334
+ it fails activation. Prefer `.mjs` for modules that must work in either mode.
1311
1335
  [Build-time TypeScript authoring](https://github.com/jimhoyd-com/urlcode/blob/main/docs/TYPESCRIPT-AUTHORING.md) can produce these
1312
1336
  JavaScript modules in a separate output project; serving does not transpile them.
1313
1337
  The build never imports application code into Node, uses fixed compiler settings,
@@ -1744,12 +1768,18 @@ Every middleware and the function share the same request and context. Validated
1744
1768
  with a fresh `context.state` object for this chain. State never survives the
1745
1769
  request. Header edits are visible downstream; editing the request does not
1746
1770
  reroute it or change already validated inputs. Request bodies are single-use:
1747
- reading one consumes it for downstream code. There is no `clone()` or streaming
1748
- API; pass parsed data through `context.state` when needed.
1771
+ reading one consumes it for downstream code. On a `sandbox: true` route there is
1772
+ no `clone()` or streaming API at all, so pass parsed data through
1773
+ `context.state`; a trusted route receives Node's own `Request`/`Response` and so
1774
+ does have `clone()`, but passing parsed data through `context.state` keeps the
1775
+ chain portable between the two modes.
1749
1776
 
1750
1777
  Function responses support the existing text/JSON guest API. To transform their
1751
- body, read it and return a new `Response`. Native redirect/respond/page/static/
1752
- download bodies are opaque and cannot be read through `text()` or `json()`.
1778
+ body, read it and return a new `Response`. On a `sandbox: true` route, native
1779
+ redirect/respond/page/static/download bodies are opaque and cannot be read
1780
+ through `text()` or `json()`; a trusted chain receives them as an ordinary
1781
+ `Response` and can read them, so wrapping `respond: {text: hello}` and returning
1782
+ `HELLO` works there and fails in the guest.
1753
1783
  Returning the same native response preserves original bytes, including binary
1754
1784
  files, ranges and HEAD lengths. You may add headers, but cannot change its
1755
1785
  original status or existing native headers while preserving that body. To replace
@@ -2682,7 +2712,7 @@ project customizes an extension's *look* through `urlcode-ui`'s
2682
2712
  standard, or every extension author (and every project depending on one)
2683
2713
  either reinvents it or forks the extension. `urlcode-auth` and
2684
2714
  `urlcode-admin` independently hit this gap (auth/#35, admin/#32); auth's own
2685
- [SPIKE-AUTH.md](https://github.com/jimhoyd-com/urlcode-auth/blob/main/docs/SPIKE-AUTH.md)
2715
+ [SPIKE-AUTH.md](https://github.com/jimhoyd-com/urlcode/blob/main/packages/auth/docs/SPIKE-AUTH.md)
2686
2716
  already scoped a shape for `onSignUp`/`beforeRegister`/`onDelete`.
2687
2717
 
2688
2718
  **The pattern.** An extension with lifecycle events an author judges worth
@@ -2825,16 +2855,15 @@ boundary, not a JavaScript sandbox or an independent security review.
2825
2855
 
2826
2856
  ### Scaffolding with `init --with`
2827
2857
 
2828
- `urlcode init <directory> --with auth,admin` produces the layered site the
2858
+ `urlcode init <directory> --with ui,auth,admin` produces the layered site the
2829
2859
  [framework page](https://github.com/jimhoyd-com/urlcode/blob/main/docs/FRAMEWORK.md#the-composition-contract) describes in one
2830
2860
  command: the starter under `<directory>/app/`, one `host.mjs`, one `README.md`,
2831
2861
  and each extension's own operator files. Core never bundles or imports the
2832
2862
  extension packages at build time; at run time it resolves
2833
2863
  `@jimhoyd/urlcode-<name>` for each name with Node's package resolution from
2834
- the invoking directory (so `npm install @jimhoyd/urlcode-auth` in that
2835
- directory, from npm where the packages are published as `0.1.0-alpha.x`
2836
- prereleases, is the normal path and what makes `--with auth` work), imports
2837
- the package and calls its
2864
+ the invoking directory. Install a compatible package set there, as shown in
2865
+ [the framework guide](https://github.com/jimhoyd-com/urlcode/blob/main/docs/FRAMEWORK.md#the-composition-contract), before using
2866
+ `--with ui,auth`; UI must activate before auth. Core imports the package and calls its
2838
2867
  `scaffold` export with this request:
2839
2868
 
2840
2869
  ```ts
@@ -2890,6 +2919,37 @@ Assembly rules, in `--with` order:
2890
2919
  review the project and pin it explicitly; the host is generated to require
2891
2920
  the pin, never to compute it.
2892
2921
 
2922
+ #### Recorded versions
2923
+
2924
+ `init --with` also writes `<directory>/package.json`: a private manifest that
2925
+ pins, at exactly the version that was resolved, the running runtime, every
2926
+ extension named in `--with`, and every package those extensions declare in
2927
+ `peerDependencies` (so `@jimhoyd/urlcode-ui` is pinned for an `auth,admin` site
2928
+ although nobody named it). Before anything is written, the whole set is checked
2929
+ against every declared peer range; an incompatible combination or a missing
2930
+ required peer refuses and names it, leaving no directory behind.
2931
+
2932
+ Nothing is installed. The generated site has no `node_modules` and no
2933
+ `package-lock.json` until you run `npm install` in it yourself, which the
2934
+ command and the generated README both state as the next step. Reproducibility
2935
+ comes from that install, not from generation.
2936
+
2937
+ - `--no-manifest` generates the site without a `package.json`, for a site whose
2938
+ dependencies are managed elsewhere. Plain `urlcode init` is unchanged and
2939
+ still writes no manifest; add `--manifest` to pin the runtime for a
2940
+ route-only project too.
2941
+ - `--pin <package>=<specifier>` records a specifier instead of the resolved
2942
+ version, for local tarball or offline development
2943
+ (`--pin @jimhoyd/urlcode-auth=file:/abs/urlcode-auth-0.1.0-alpha.6.tgz`). A
2944
+ package installed from a local path or tarball is detected from npm's own
2945
+ install record and pinned by that path without any flag; the README says so,
2946
+ because such a pin only reproduces where that path exists.
2947
+
2948
+ There is no upgrade command. Moving a generated project to newer versions today
2949
+ means editing its `package.json` and re-running `npm install` yourself; nothing
2950
+ in this runtime selects a newer tested set, shows the change, or updates a
2951
+ lockfile for you.
2952
+
2893
2953
  Serving the result is the usual explicit host binding:
2894
2954
 
2895
2955
  ```sh
@@ -2898,6 +2958,289 @@ urlcode validate --project app --host-file "$PWD/host.mjs" --origin https://site
2898
2958
 
2899
2959
  ---
2900
2960
 
2961
+ # Composing a site from ui, auth and admin
2962
+
2963
+ Source: https://github.com/jimhoyd-com/urlcode/blob/main/docs/COMPOSING-A-SITE.md
2964
+
2965
+ One command produces a site that already has accounts, an administration
2966
+ console and a presentation kit wired together:
2967
+
2968
+ ```sh
2969
+ npm install @jimhoyd/urlcode @jimhoyd/urlcode-ui @jimhoyd/urlcode-auth @jimhoyd/urlcode-admin
2970
+ urlcode init site --with ui,auth,admin
2971
+ ```
2972
+
2973
+ This page is the map of what you may then change, and with which tool. It
2974
+ covers three different activities that are easy to confuse:
2975
+
2976
+ | You want to | Use | Code? |
2977
+ |---|---|---|
2978
+ | Change what an extension is configured to do | the `config` block in `app/urlcode.yaml` | none |
2979
+ | Change how its screens look or read | files under `<site>/ui/` | none (templates are data) |
2980
+ | Run your own logic at one of its lifecycle points | a project function named from that `config` | first-party project JavaScript |
2981
+ | Add a capability none of the three provides | a new extension package | TypeScript against the runtime contract |
2982
+
2983
+ Work down that list, not up. The [declarative-first
2984
+ principle](https://github.com/jimhoyd-com/urlcode/blob/main/docs/PROJECT-DIRECTION.md#design-principle-declarative-first) applies
2985
+ here as much as it does to routes: reach for the next row only when the one
2986
+ above it cannot express the requirement.
2987
+
2988
+ ### What `--with ui,auth,admin` generates
2989
+
2990
+ - `site/app/` — the route project: `urlcode.yaml` with an `extensions` block
2991
+ per package, and `routes/extensions.yaml` holding `/assets/ui/*`,
2992
+ `/account/*`, `/private` and `/admin/*`.
2993
+ - `site/host.mjs` — the operator host module, the one place that holds code.
2994
+ It builds the kit with `createUiExtension`, passes the returned object into
2995
+ `authExtension` and `adminExtension`, and lists `ui.registration` first.
2996
+ - `site/ui/` — `copy/`, `templates/` and `extra.css`, the project's
2997
+ presentation overrides, beside the host and **outside** `app/`.
2998
+ - `site/operator-service.mjs`, `site/data/` — auth's operator service and its
2999
+ private key material, mode `0600`.
3000
+ - `site/README.md` — the merged next steps, environment table and the project
3001
+ revision to review and pin.
3002
+
3003
+ Nothing about that wiring is manual any more. The generated host registers
3004
+ `authCatalogue` as a copy source and both `authUiTemplates` and
3005
+ `adminUiTemplates` as template namespaces, because auth and admin render only
3006
+ through the kit and refuse to activate without their own templates present.
3007
+
3008
+ #### Supported combinations
3009
+
3010
+ `--with` order is the activation order, and the kit must be active before
3011
+ anything that renders through it.
3012
+
3013
+ | `--with` | Result |
3014
+ |---|---|
3015
+ | `ui` | Kit only; the host wires no peer catalogue or templates. |
3016
+ | `ui,auth` | Accounts on `/account/*`, rendered through the kit. |
3017
+ | `ui,auth,admin` | The full composition above. |
3018
+ | `auth` or `auth,admin` | Refused: the scaffold names the missing `ui`. |
3019
+ | `auth,admin,ui` | Refused: `ui` must come before the extensions it renders. |
3020
+ | `admin` without `auth` | Refused: admin reuses auth's service, CSRF key and revision. |
3021
+
3022
+ Every refusal happens before anything is written, and leaves no directory
3023
+ behind. There is no auth-without-ui or admin-without-ui configuration in this
3024
+ revision: the UI primitive fallback was retired, so the kit is the only render
3025
+ path (see [OPEN-DECISIONS.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/OPEN-DECISIONS.md)).
3026
+
3027
+ ### Declarative configuration
3028
+
3029
+ Each package owns one `extensions.<name>` block. The block itself is core
3030
+ schema (`version` plus `config`); what may go inside `config` is the
3031
+ package's own JSON Schema, which you can print rather than guess:
3032
+
3033
+ ```sh
3034
+ urlcode extensions --project ./site/app --host-file "$PWD/site/host.mjs" --json
3035
+ ```
3036
+
3037
+ The same report is the MCP tool `get_extensions`, and it is the authoritative
3038
+ answer for both the configuration schema and the per-route policy schema. The
3039
+ generated site starts from something like this:
3040
+
3041
+ ```yaml
3042
+ version: "1"
3043
+ extensions:
3044
+ ui:
3045
+ version: "1"
3046
+ config:
3047
+ theme:
3048
+ name: My Site
3049
+ languages: [en]
3050
+ copy: ui/copy
3051
+ templates: ui/templates
3052
+ stylesheet: ui/extra.css
3053
+ auth:
3054
+ version: "1"
3055
+ config:
3056
+ registration: "off"
3057
+ admin:
3058
+ version: "1"
3059
+ config: {}
3060
+ ```
3061
+
3062
+ Routes mount an extension, and policies require one:
3063
+
3064
+ ```yaml
3065
+ routes:
3066
+ /assets/ui/*:
3067
+ extension: ui
3068
+ methods: [GET, HEAD]
3069
+ /account/*:
3070
+ extension: auth
3071
+ methods: [GET, HEAD, POST]
3072
+ /admin/*:
3073
+ extension: admin
3074
+ methods: [GET, HEAD, POST]
3075
+ /private:
3076
+ respond:
3077
+ text: Signed in
3078
+ policies:
3079
+ extensions:
3080
+ auth: {}
3081
+ ```
3082
+
3083
+ See [EXTENSIONS.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/EXTENSIONS.md) for the `auth` route short form, extension
3084
+ middleware, and the host-file trust boundary.
3085
+
3086
+ ### Presentation overrides
3087
+
3088
+ The `ui` config's `copy`, `templates` and `stylesheet` paths point at the
3089
+ project's own directories. Nothing here forks a package.
3090
+
3091
+ | Override | File | Effect |
3092
+ |---|---|---|
3093
+ | Wording and translation | `ui/copy/<locale>.json` | Replaces catalogue ids, including ids the auth and admin packages own. Listed in `languages`. |
3094
+ | A whole screen | `ui/templates/<name>.html` | Shadows a kit or extension template of that name, for example `ui/templates/auth/sign-in.html` or `ui/templates/admin/dashboard.html`. |
3095
+ | Styling | `ui/extra.css` | Appended after the kit stylesheet; `{file, replace: true}` replaces it instead. |
3096
+ | Colours, logo, favicon, radius, font | the `theme` block | Declarative; no file needed. |
3097
+
3098
+ A template is data in the kit's own language. It cannot add a script, change
3099
+ what a form validates, or change what a page sends in headers — so an override
3100
+ cannot weaken the screen it restyles. Stylesheets containing `@import`,
3101
+ `script`, `javascript:` or `expression(` are refused.
3102
+
3103
+ Names, coverage and what the runtime will actually load:
3104
+
3105
+ ```sh
3106
+ npx urlcode-ui list --project ./site --extensions @jimhoyd/urlcode-auth,@jimhoyd/urlcode-admin
3107
+ npx urlcode-ui doctor --project ./site --extensions @jimhoyd/urlcode-auth,@jimhoyd/urlcode-admin --copy ui/copy --templates ui/templates --stylesheet ui/extra.css
3108
+ npx urlcode-ui eject auth/sign-in --out ./site/ui/templates --project ./site --extensions @jimhoyd/urlcode-auth
3109
+ npx urlcode-ui copy --missing fr --project ./site --extensions @jimhoyd/urlcode-auth --copy ui/copy --languages en,fr
3110
+ ```
3111
+
3112
+ `eject` copies the shipped source so an override starts from what ships and
3113
+ never overwrites an existing file. `ui/` lives outside `app/`, so editing copy
3114
+ or templates does **not** change the project revision and does not require
3115
+ re-pinning `PROJECT_SHA256`.
3116
+
3117
+ **Name the packages that ship the other namespaces.** `urlcode-ui` is this
3118
+ kit alone until `--extensions` names them. Each package is resolved from
3119
+ `--project` with Node package resolution and imported for the namespace it
3120
+ exports; one that is not installed there is skipped with a note, so the
3121
+ command still runs. The site's `host.mjs` is never read: it builds services
3122
+ and reads secrets at its top level, and a read-only `list` or `doctor` must
3123
+ not run it. With the packages named:
3124
+
3125
+ - `list` shows the `auth/*` and `admin/*` names beside the kit's own, each
3126
+ with its origin, and `eject auth/sign-in` copies the shipped source.
3127
+ - `doctor` reports an `expected` view model for an extension template, so its
3128
+ `behind` flag tells you when an override of one has fallen behind what
3129
+ ships. Its `extensions` field names the namespaces the report covers, so a
3130
+ report built without a peer is visible as such.
3131
+ - `preview auth/sign-in` renders the extension's own sample view model.
3132
+ - `copy --missing` skeletons cover the auth ids the account screens use.
3133
+ Admin-owned `adminUi.*` ids are deliberately not offered: admin composes
3134
+ its catalogue onto the kit's presentation rather than registering it there,
3135
+ and those translations do not currently reach the console
3136
+ ([#227](https://github.com/jimhoyd-com/urlcode/issues/227)).
3137
+
3138
+ `urlcode init <directory> --with ui,auth,admin` writes these commands into the
3139
+ generated README with the flag already set. `@jimhoyd/urlcode-ui` depends on
3140
+ neither peer; the operator names them.
3141
+
3142
+ Overrides of extension templates and of extension-owned catalogue ids reach
3143
+ the rendered screens, which is what the regression test below asserts.
3144
+
3145
+ ### Project functions: lifecycle hooks
3146
+
3147
+ A hook is your own function, named from the extension's `config`, that the
3148
+ extension calls at a lifecycle point it defines. It uses the same source shape
3149
+ a `function` route uses — a bare path, or `{source, export}` — resolved
3150
+ relative to the route project.
3151
+
3152
+ ```yaml
3153
+ extensions:
3154
+ auth:
3155
+ version: "1"
3156
+ config:
3157
+ registration: open
3158
+ hooks:
3159
+ beforeRegister:
3160
+ source: ./hooks/registration-rule.mjs
3161
+ export: default
3162
+ onSignUp: ./hooks/on-signup.mjs
3163
+ ```
3164
+
3165
+ `hooks` is not a core schema key. It is each package's own config, validated
3166
+ by that package's schema before `activate()`, which is why `get_extensions` is
3167
+ the place to check what a given version accepts.
3168
+
3169
+ Hooks are first-party project code and run **trusted and in-process**, the
3170
+ same default `function` and `middleware` routes have
3171
+ ([FUNCTION-SECURITY.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/FUNCTION-SECURITY.md)). Neither package implements
3172
+ sandboxed hook execution yet; `sandbox: true` on a hook is rejected loudly at
3173
+ activation rather than accepted and silently run trusted.
3174
+
3175
+ #### `@jimhoyd/urlcode-auth`
3176
+
3177
+ | Hook | Input | Returns | Called |
3178
+ |---|---|---|---|
3179
+ | `beforeRegister` | `{email, profile?}` | `{allow: boolean, reason?}` | Before an account is created, on `POST /account/register` and on `POST /account/signup/begin`. |
3180
+ | `onSignUp` | `{accountId, email}` | ignored | After a genuinely new account is created — on `/account/register`, and on `/account/signup/complete` only when that completion created an account rather than signing an existing one in. |
3181
+ | `onDelete` | `{accountId, email}` | ignored | After the account owner's own deletion is scheduled. Not on an administrator-initiated deletion, and not on the background purge when the grace period ends. |
3182
+
3183
+ #### `@jimhoyd/urlcode-admin`
3184
+
3185
+ | Hook | Input | Returns | Called |
3186
+ |---|---|---|---|
3187
+ | `beforeRoleChange` | `{accountId, currentRoles, requestedRoles, actorId, reason}` | `{allow: boolean, reason?}` | Before roles are applied, after the administrator's permission check. A veto means the auth service is never asked. |
3188
+ | `onRegistrationApproved` | `{requestId, accountId, email, actorId, reason}` | ignored | After a registration request is approved. |
3189
+ | `onAccountStatusChanged` | `{accountId, status, actorId, reason}` | ignored | After an account is locked or unlocked. |
3190
+
3191
+ #### Verdicts and failure
3192
+
3193
+ - **A veto is explicit.** A pre-action hook allows only by returning
3194
+ `allow: true`. `allow: false`, or no verdict at all, rejects the operation
3195
+ with `403` and the hook's own `reason`, or a generic message when it gave
3196
+ none. Nothing is written. A hook that *throws* has not returned a verdict:
3197
+ the operation is still refused, but as a generic `500`, so return a verdict
3198
+ rather than throwing when you mean to deny.
3199
+ - **Broken hooks fail at activation, not at the first request.** A missing
3200
+ module, a source path escaping the project, an export that is not a
3201
+ function, or `sandbox: true` all throw while the extension activates, naming
3202
+ the hook. The site does not start.
3203
+ - **A post-action hook cannot undo anything.** `onSignUp`,
3204
+ `onDelete`, `onRegistrationApproved` and `onAccountStatusChanged` run after
3205
+ the operation has committed. Throwing from one replaces the success response
3206
+ with a `500` while the account, approval or status change stands. There is
3207
+ no retry and no rollback. Keep them non-throwing: catch your own errors and
3208
+ queue the work instead of failing the request.
3209
+ - **A hook's message is not a channel to the browser.** Only a pre-action
3210
+ `reason` is shown. An uncaught error surfaces as a generic failure.
3211
+ - **An edited hook needs a restart.** Activation re-imports the hook's entry
3212
+ module, so a reload picks up an edit to that file — but modules it imports
3213
+ stay on Node's module cache, exactly as for trusted route functions.
3214
+
3215
+ ### TypeScript: implementing a new extension
3216
+
3217
+ Only write an extension when a capability is genuinely absent — not to
3218
+ customize one of the three above. An extension is an operator-installed
3219
+ package whose host object core activates; it is named in `host.mjs`, never
3220
+ in YAML. The contract, the activation inputs, `ExtensionActivation.root`,
3221
+ credential headers and the `projectSha256` pin are in
3222
+ [EXTENSIONS.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/EXTENSIONS.md) and [TYPESCRIPT.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/TYPESCRIPT.md); the
3223
+ `scaffold` export that makes a package work with `init --with` is in
3224
+ [EXTENSIONS.md](https://github.com/jimhoyd-com/urlcode/blob/main/docs/EXTENSIONS.md#scaffolding-with-init---with).
3225
+
3226
+ If its screens should be themeable the same way auth's and admin's are, it
3227
+ also exports a template namespace (and, if it ships English wording, a
3228
+ catalogue) for a host to pass to `createUiExtension`. That is what makes
3229
+ `ui/templates/<yourname>/<screen>.html` work in a consumer project without a
3230
+ fork.
3231
+
3232
+ ### What this page does not claim
3233
+
3234
+ The composition, the refusals and the override path are exercised by
3235
+ `test/workspace-scaffold.integration.ts`, which runs `init --with` against the
3236
+ built packages, drops a template and a copy catalogue into the generated
3237
+ `ui/` directory and asserts both reach a rendered auth screen and a rendered
3238
+ admin screen. That runs in-process against the generated host: no HTTP
3239
+ listener, TLS proxy, browser or deployed site is exercised, and no published
3240
+ npm tarball is checked against this checkout.
3241
+
3242
+ ---
3243
+
2901
3244
  # Function execution: trusted by default, sandboxed opt-in
2902
3245
 
2903
3246
  Source: https://github.com/jimhoyd-com/urlcode/blob/main/docs/FUNCTION-SECURITY.md
package/llms.txt CHANGED
@@ -67,6 +67,7 @@ fields or bypass target limits or operator grants. See [the design principle](do
67
67
 
68
68
  ## Extensions (accounts, administration, presentation)
69
69
  - [Extensions](docs/EXTENSIONS.md): `extensions.<name>` blocks, `extension` mounts, `policies.extensions`, the operator host file, `@jimhoyd/urlcode/extensions`. Project-level lifecycle hooks run trusted via plain `import()`, or sandboxed via `@jimhoyd/urlcode/sandbox`'s `SandboxPool`.
70
+ - [Composing a site](docs/COMPOSING-A-SITE.md): what `urlcode init site --with ui,auth,admin` wires, which `--with` combinations are supported, the presentation override paths under `ui/`, and per-package lifecycle hook input, verdict, timing and failure semantics. Separates declarative configuration, project functions and the TypeScript a new extension needs.
70
71
  - [urlcode-auth](packages/auth): npm: @jimhoyd/urlcode-auth; accounts, sessions, MFA, roles, account page; its own llms.txt. Lives in this repository as a workspace package.
71
72
  - [urlcode-admin](packages/admin): npm: @jimhoyd/urlcode-admin; users, sessions, roles, audit, cases; its own llms.txt. Lives in this repository as a workspace package.
72
73
  - [urlcode-ui](packages/ui): npm: @jimhoyd/urlcode-ui; escaped templates, shadcn/ui partials, themes, translations; its own llms.txt. Lives in this repository as a workspace package, not in a separate repository.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimhoyd/urlcode",
3
- "version": "0.4.0-alpha.3",
3
+ "version": "0.4.1",
4
4
  "description": "Portable runtime for programmable URL behavior",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -104,7 +104,8 @@
104
104
  "typecheck": "tsc -p tsconfig.json",
105
105
  "test": "node --conditions=development --test test/*.test.ts",
106
106
  "lint": "eslint .",
107
- "check": "node scripts/check.ts && node scripts/check-trust-model-prose.ts && node scripts/check-guidance-claims.ts && node scripts/check-release-tags.ts && node scripts/check-workspace-links.ts && node scripts/generate-yaml-reference.ts --check && node scripts/build-llms-full.ts --check && node scripts/build-cookbook-index.ts --check && node scripts/generate-claude-plugin.ts --check && npm run release:check",
107
+ "check": "npm run check:code && npm run check:docs",
108
+ "check:code": "node scripts/check.ts && node scripts/check-release-tags.ts && node scripts/check-workspace-links.ts && npm run release:check",
108
109
  "verify": "npm run lint && npm run typecheck && npm run check && npm run build && npm test && npm run verify:workspaces",
109
110
  "workspace:styles": "npm run styles --workspace @jimhoyd/urlcode-ui",
110
111
  "verify:workspaces": "npm run verify --workspace @jimhoyd/urlcode-ui && npm run verify --workspace @jimhoyd/urlcode-auth && npm run verify --workspace @jimhoyd/urlcode-admin && npm run test:workspace-integration",
@@ -128,7 +129,7 @@
128
129
  "benchmark:sandbox-vs-trusted": "node benchmarks/sandbox-vs-trusted.ts",
129
130
  "benchmark:agent": "node benchmarks/agent/run.ts",
130
131
  "sync:agents": "node scripts/sync-agent-lists.ts",
131
- "check:docs": "node scripts/check-trust-model-prose.ts && node scripts/check-guidance-claims.ts && node scripts/generate-yaml-reference.ts --check && node scripts/build-llms-full.ts --check && node scripts/build-cookbook-index.ts --check && node scripts/generate-claude-plugin.ts --check",
132
+ "check:docs": "node scripts/check-trust-model-prose.ts && node scripts/check-local-links.ts && node scripts/check-guidance-claims.ts && node scripts/generate-yaml-reference.ts --check && node scripts/build-llms-full.ts --check && node scripts/build-cookbook-index.ts --check && node scripts/generate-claude-plugin.ts --check",
132
133
  "ci:plan": "node scripts/ci-plan.ts",
133
134
  "test:package:built": "node scripts/package-smoke.ts",
134
135
  "release:status": "node scripts/release.ts status",
@@ -136,10 +137,12 @@
136
137
  "release:publish": "node scripts/release.ts publish",
137
138
  "release:run": "node scripts/release-run.ts",
138
139
  "release:peers": "node scripts/release.ts peers",
139
- "release:check": "node scripts/release.ts check",
140
+ "release:check": "node scripts/release.ts check && node scripts/release-prepare.ts --check",
140
141
  "ci:history": "node scripts/ci-history.ts",
141
142
  "ci:report": "node scripts/ci-report.ts",
142
- "test:workspace-integration": "node --test test/workspace-scaffold.integration.ts"
143
+ "test:workspace-integration": "node --test test/workspace-scaffold.integration.ts",
144
+ "release:prepare": "node scripts/release-prepare.ts",
145
+ "release:template": "node scripts/release-template.ts"
143
146
  },
144
147
  "repository": {
145
148
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "urlcode",
3
3
  "description": "Authoring and operating URLCode projects: the implemented YAML contract, capability limits, deployment and verification commands for the pinned runtime revision.",
4
- "version": "0.4.0-alpha.3",
4
+ "version": "0.4.1",
5
5
  "author": {
6
6
  "name": "jimhoyd-com",
7
7
  "url": "https://github.com/jimhoyd-com"
@@ -1,5 +1,7 @@
1
- // Wrap successful JSON function responses in a stable envelope. Native bodies are
2
- // opaque and pass through untouched; only readable JSON is rewritten.
1
+ // Wrap successful JSON function responses in a stable envelope. Only a JSON body
2
+ // this chain can actually read is rewritten; everything else passes through
3
+ // untouched -- on a `sandbox: true` route that includes every native body, which
4
+ // the guest cannot read at all.
3
5
  export default async function envelope(request, context, next) {
4
6
  const response = await next();
5
7
  if (!response.ok || !(response.headers.get('content-type') || '').startsWith('application/json')) return response;