@jskit-ai/agent-docs 0.1.331 → 0.1.333

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 (92) hide show
  1. package/guide/agent/app-extras/realtime.md +11 -3
  2. package/guide/agent/app-setup/authentication.md +135 -32
  3. package/guide/agent/app-setup/initial-scaffolding.md +10 -9
  4. package/guide/agent/app-setup/more-than-one-server.md +111 -0
  5. package/guide/agent/app-setup/multi-homing.md +2 -2
  6. package/guide/agent/app-setup/package-with-nix.md +60 -15
  7. package/guide/agent/app-setup/upgrading-jskit.md +36 -1
  8. package/guide/agent/framework/crud-form-actions.md +18 -7
  9. package/guide/agent/framework/environments.md +174 -0
  10. package/guide/agent/framework/material-3.md +9 -3
  11. package/guide/agent/framework/quality-pass.md +8 -2
  12. package/guide/agent/framework/sanity-checks.md +3 -3
  13. package/guide/agent/framework/security-pass.md +7 -5
  14. package/guide/agent/index.md +6 -2
  15. package/package.json +1 -1
  16. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  17. package/patterns/minimal-foundation/example/.env.example +8 -0
  18. package/patterns/minimal-foundation/example/AGENTS.md +7 -5
  19. package/patterns/minimal-foundation/example/bin/develop.js +2 -0
  20. package/patterns/minimal-foundation/example/package.json +7 -7
  21. package/patterns/shell-foundation/example/.env.example +8 -0
  22. package/patterns/shell-foundation/example/AGENTS.md +7 -5
  23. package/patterns/shell-foundation/example/bin/develop.js +2 -0
  24. package/patterns/shell-foundation/example/package.json +8 -8
  25. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  26. package/reference/autogen/KERNEL_MAP.md +10 -11
  27. package/reference/autogen/PATTERN_INDEX.md +38 -38
  28. package/reference/autogen/packages/auth-core.md +15 -2
  29. package/reference/autogen/packages/auth-provider-local-core.md +48 -13
  30. package/reference/autogen/packages/auth-provider-local-db-core.md +15 -0
  31. package/reference/autogen/packages/auth-provider-oidc-core.md +1 -1
  32. package/reference/autogen/packages/auth-provider-supabase-core.md +2 -2
  33. package/reference/autogen/packages/auth-web.md +26 -0
  34. package/reference/autogen/packages/connectors-core.md +2 -2
  35. package/reference/autogen/packages/http-web.md +2 -0
  36. package/reference/autogen/packages/kernel.md +32 -27
  37. package/reference/autogen/packages/oidc-issuer-core.md +4 -4
  38. package/reference/autogen/packages/payments-core.md +1 -1
  39. package/reference/autogen/packages/shell-web.md +40 -13
  40. package/reference/autogen/packages/storage-runtime.md +6 -0
  41. package/reference/autogen/packages/workspaces-core.md +4 -4
  42. package/reference/autogen/tooling/jskit-catalog.md +6 -1
  43. package/skills/jskit/SKILL.md +2 -1
  44. package/skills/jskit/references/crud-form-actions.md +18 -7
  45. package/skills/jskit/references/environments.md +169 -0
  46. package/skills/jskit/references/heuristics/INDEX.md +1 -1
  47. package/skills/jskit/references/heuristics/client-requests.md +1 -1
  48. package/skills/jskit/references/heuristics/crud-authoring.md +3 -2
  49. package/skills/jskit/references/heuristics/live-actions.md +4 -1
  50. package/skills/jskit/references/heuristics/ui-contract.md +9 -1
  51. package/skills/jskit/references/material-3.md +9 -3
  52. package/skills/jskit/references/multi-homing.md +2 -2
  53. package/skills/jskit/references/package-with-nix.md +60 -15
  54. package/skills/jskit/references/pattern-index.md +38 -38
  55. package/skills/jskit/references/patterns/app/minimal-foundation/example/.env.example +8 -0
  56. package/skills/jskit/references/patterns/app/minimal-foundation/example/AGENTS.md +7 -5
  57. package/skills/jskit/references/patterns/app/minimal-foundation/example/bin/develop.js +2 -0
  58. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +7 -7
  59. package/skills/jskit/references/patterns/app/shell-foundation/example/.env.example +8 -0
  60. package/skills/jskit/references/patterns/app/shell-foundation/example/AGENTS.md +7 -5
  61. package/skills/jskit/references/patterns/app/shell-foundation/example/bin/develop.js +2 -0
  62. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +8 -8
  63. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  64. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
  65. package/skills/jskit/references/patterns/auth/auth-surface/PATTERN.md +10 -8
  66. package/skills/jskit/references/patterns/auth/auth-surface/example/src/pages/auth/email-change.vue +17 -0
  67. package/skills/jskit/references/patterns/auth/auth-surface/example/src/views/auth/EmailChangeView.vue +12 -0
  68. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  69. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  70. package/skills/jskit/references/patterns/connectors/api-key-connection/PATTERN.md +4 -1
  71. package/skills/jskit/references/patterns/connectors/api-key-connection/example/connections.js +3 -3
  72. package/skills/jskit/references/patterns/connectors/calendar-cli/example/.env.example +1 -0
  73. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -4
  74. package/skills/jskit/references/patterns/connectors/calendar-cli/example/scripts/calendar.js +3 -1
  75. package/skills/jskit/references/patterns/connectors/firebase-messaging/example/server/notifications.js +3 -3
  76. package/skills/jskit/references/patterns/connectors/oauth-connection/PATTERN.md +3 -1
  77. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
  78. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
  79. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
  80. package/skills/jskit/references/patterns/realtime/realtime-application/example/.env.example +1 -0
  81. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  82. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  83. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsNotificationsSection.vue +3 -1
  84. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsPreferencesSection.vue +3 -1
  85. package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsProfileSection.vue +4 -1
  86. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
  87. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
  88. package/skills/jskit/references/quality-pass.md +8 -2
  89. package/skills/jskit/references/sanity-checks.md +3 -3
  90. package/skills/jskit/references/security-pass.md +7 -5
  91. package/guide/agent/framework/side-effects.md +0 -77
  92. package/skills/jskit/references/side-effects.md +0 -72
@@ -11,9 +11,15 @@ description: Customize shared CRUD form actions and local validation guidance.
11
11
  its default content. The slot exposes `screen`, `mode`, `formRuntime`,
12
12
  `formState`, `addEdit`, `saveLabel`, the resolved
13
13
  `cancelTo` route target, and `submit`. Custom actions call `submit()` and bind
14
- their disabled state to `addEdit.isSubmitDisabled`. Keyboard submission uses
15
- the same runtime. `addEdit.isSaving` stays true through the request and
16
- asynchronous `onSaveSuccess` callback; duplicate
14
+ their disabled state to `addEdit.isSubmitDisabled` and their pending state to
15
+ `addEdit.isSubmitPending` (the save, or the record's reload after it, is
16
+ running). `ShellPageAction` takes both and keeps keyboard focus while it is
17
+ pending; a plain button, when possible, takes
18
+ `v-pending="addEdit.isSubmitPending"` and
19
+ `:disabled="addEdit.isSubmitDisabled && !addEdit.isSubmitPending"`, since a
20
+ focused button that becomes disabled drops focus to the page body. Keyboard
21
+ submission uses the same runtime. `addEdit.isSaving` stays true through the
22
+ request and asynchronous `onSaveSuccess` callback; duplicate
17
23
  submissions remain blocked during both.
18
24
 
19
25
  `useAddEdit()` and the `addEdit` runtime exposed by `useCrudAddEdit()` and
@@ -42,9 +48,13 @@ Inside `CrudAddEditScreen`, alongside the existing `fields` slot:
42
48
  <template #actions="{ addEdit, submit, saveLabel, cancelTo }">
43
49
  <v-btn v-if="cancelTo" variant="outlined" :to="cancelTo">Cancel</v-btn>
44
50
  <div>
45
- <v-btn :disabled="addEdit.isSubmitDisabled" @click="submit">
46
- {{ addEdit.isSaving ? "Saving…" : saveLabel }}
47
- </v-btn>
51
+ <ShellPageAction
52
+ primary
53
+ :label="addEdit.isSaving ? 'Saving…' : saveLabel"
54
+ :disabled="addEdit.isSubmitDisabled"
55
+ :pending="addEdit.isSubmitPending"
56
+ @click="submit"
57
+ />
48
58
  <p v-if="addEdit.validationAttempted" aria-live="polite">
49
59
  {{ Object.values(addEdit.validationErrors).join(" ") }}
50
60
  </p>
@@ -58,7 +68,8 @@ to clear the successfully saved model, call `screen.addEdit.resetValidation()`,
58
68
  and prepare the next entry. This callback replaces default success navigation
59
69
  and invalidation; perform those there when needed. Clear the model only in
60
70
  `onSaveSuccess`: `submit()` also resolves after invalid or failed submissions.
61
- Guard action selection with `isSubmitDisabled` and restore the default action
71
+ Guard action selection with `isSubmitDisabled` (true while pending too) and
72
+ restore the default action
62
73
  after each attempt so keyboard submission uses normal Save. Track the clicked
63
74
  button separately to keep guidance beside it while fields are corrected.
64
75
 
@@ -0,0 +1,174 @@
1
+ <!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/framework/environments.md`. Do not edit manually. -->
2
+
3
+ ---
4
+ title: Environments
5
+ description: APP_ENV says where an application runs, development, test, staging or production, and decides everything that depends on it; NODE_ENV only picks optimised builds.
6
+ ---
7
+
8
+ # Environments
9
+
10
+ Where an application runs is one environment variable, `APP_ENV`, with four
11
+ values. Everything JSKIT does differently by place reads it: what the
12
+ application sends, the development shortcuts, the security headers and the
13
+ banner on each page. `NODE_ENV` decides nothing else: it only picks optimised
14
+ builds, and staging and production set it to `production`.
15
+
16
+ | `APP_ENV` | Where | Email and SMS | Push, webhooks, connector writes | Payments | Development shortcuts | Banner |
17
+ | --- | --- | --- | --- | --- | --- | --- |
18
+ | `development` | a developer's machine, a session, a preview | logged | logged | sandbox only | allowed | "Development" |
19
+ | `test` | automated test runs | logged | logged | sandbox only | allowed | "Test" |
20
+ | `staging` | a deployed copy for checking the application | only to `STAGING_EMAIL_TO` and `STAGING_SMS_TO`; logged when unset | logged | sandbox only | refused | "Staging" |
21
+ | `production` | the application serving real people | sent | sent | live | refused | none |
22
+
23
+ The development shortcuts are dev sign-in (`AUTH_DEV_BYPASS_ENABLED`), cookies
24
+ without `Secure`, links in answers (`AUTH_LOCAL_RECOVERY_DEV_OUTPUT`), a first
25
+ account without a setup code, test databases, and a server that refuses to
26
+ start over a role grant no action requires (staging and production log it
27
+ instead). Staging and production add HSTS and the content security policy, and
28
+ need production's secrets, such as `AUTH_LOCAL_SESSION_SECRET` and a sender for
29
+ the emails they send.
30
+
31
+ ## Who sets what
32
+
33
+ The host sets `APP_ENV`; a request never chooses it. JSKIT's own commands set
34
+ it where they own the run.
35
+
36
+ | Who | `APP_ENV` | `NODE_ENV` | `STAGING_EMAIL_TO`, `STAGING_SMS_TO` |
37
+ | --- | --- | --- | --- |
38
+ | `npm run develop`, `npm run dev` on a developer's machine | `development`, set by the scripts | unset | unset |
39
+ | A hosted session or preview | `development` | unset | unset |
40
+ | `jskit test` and the browser test servers | `test`, set by JSKIT | anything | unset |
41
+ | A build-check machine that starts the packaged build to see it start and answer health | `staging` | `production` | unset, so everything is logged |
42
+ | A staging server | `staging` | `production` | the testers' inbox and phone |
43
+ | A production server | `production` | `production` | ignored |
44
+
45
+ A server started with `npm start` reads `APP_ENV` from its environment, or from
46
+ `.env` (`APP_ENV=development` on a developer's machine; the foundations'
47
+ `.env.example` says so). A host puts both variables in the server's
48
+ environment, beside its other settings:
49
+
50
+ ```sh
51
+ APP_ENV=staging NODE_ENV=production STAGING_EMAIL_TO=qa@example.com npm start
52
+ ```
53
+
54
+ `jskit test` and the browser test servers run as `APP_ENV=test` whatever the
55
+ shell says, and refuse to run where `APP_ENV` is `staging` or `production`.
56
+
57
+ ## Starting refuses what is not clear
58
+
59
+ A server stops at startup, saying what to do, when:
60
+
61
+ - `APP_ENV` is missing: `APP_ENV is not set. Set APP_ENV to development, test,
62
+ staging or production: development on a developer's machine or in a preview,
63
+ staging or production (with NODE_ENV=production) on a server.`
64
+ - `APP_ENV` is anything else: `APP_ENV is "dev", which is not an environment
65
+ JSKIT knows. Set APP_ENV to development, test, staging or production.`
66
+ - `APP_ENV` is `staging` or `production` and `NODE_ENV` is not `production`:
67
+ `APP_ENV is staging, so NODE_ENV must be production, and it is not set. Set
68
+ NODE_ENV=production: it only picks optimised builds, and APP_ENV decides
69
+ everything else.`
70
+ - `SIDE_EFFECTS`, which `APP_ENV` replaced, is set: `SIDE_EFFECTS was replaced
71
+ by APP_ENV: remove SIDE_EFFECTS. APP_ENV=production acts for real; staging
72
+ sends email and SMS only to STAGING_EMAIL_TO and STAGING_SMS_TO; development
73
+ and test only log.`
74
+ - A development-only setting is set in staging or production, for example
75
+ `AUTH_LOCAL_RECOVERY_DEV_OUTPUT is for development only and APP_ENV is
76
+ staging. Remove it from the staging environment.`
77
+
78
+ It then logs one line saying where it runs and what that means, such as
79
+ `APP_ENV is staging: email goes only to qa@example.com (STAGING_EMAIL_TO), SMS
80
+ is logged (STAGING_SMS_TO is not set); …`.
81
+
82
+ ## Staging's test addresses
83
+
84
+ Staging is production's code and settings with nobody real at the other end.
85
+ `STAGING_EMAIL_TO` is one address, such as the testers' shared inbox; every
86
+ email goes there instead of to its recipient. The email's first line, in its
87
+ text and HTML, says `Staging: this email was for ada@example.com.`, it carries
88
+ an `X-Staging-Original-To` header, and the log says
89
+ `Staging: the password reset email to ada@example.com was sent to
90
+ qa@example.com (STAGING_EMAIL_TO) instead.` `STAGING_SMS_TO` is one phone
91
+ number, and SMS goes there the same way. Unset, each is logged as development
92
+ logs it, with what a tester needs, such as its link. Push notifications,
93
+ webhooks and connector writes are always logged in staging, and live payments
94
+ are refused there, as everywhere but production.
95
+
96
+ ## What JSKIT does
97
+
98
+ - Every HTML page the server sends, and every page the Vite development server
99
+ sends, names its environment in a `jskit-app-environment` meta tag. The
100
+ shell (`@jskit-ai/shell-web`) shows a small "Development", "Test" or
101
+ "Staging" banner from it, with no application code, and none in production.
102
+ The banner never takes a click or a tap. Screen readers read it as a note,
103
+ with a sentence such as "Development: emails and messages are logged, not
104
+ sent; payments use the sandbox." as its description. It has no label, so a
105
+ browser test's `getByLabel("Email")` never finds it.
106
+ - Local-password emails (confirmation and password reset) with an installed
107
+ sender go out as the table says. In staging the sender gets
108
+ `STAGING_EMAIL_TO` as `email` and the person's address as `originalEmail`,
109
+ which its email should show (`markStagingEmail` does). An application that
110
+ confirms new accounts at once while its email isn't set up uses
111
+ `auth.local.confirmation-mode`, which applies everywhere (see
112
+ [Authentication](/guide/app-setup/authentication)).
113
+ - Workspace invitations with a provided mailer go out as the table says, the
114
+ staging copy marked with whom it was for. A logged invitation answers
115
+ `status: "simulated"`, and the inviter copies the link.
116
+ - Accounts-hub email goes out as the table says.
117
+ - Connector operations that act on the world (send an email or message, post,
118
+ book or cancel, charge, invoice, trigger another system's events) are marked
119
+ `sideEffect`. Outside production they are checked like real ones, then
120
+ logged, and `invoke` answers `{ simulated: true }`. Reads run for real.
121
+ `createConnectorsFeature` reads `APP_ENV` itself; give
122
+ `createConnectionService` and `createPaymentCheckoutService`
123
+ `appEnv: appEnvironment(env)`, which they require.
124
+ - Payment checkout and the billing portal in the live payment environment are
125
+ refused outside production with `payment_sandbox_only`; the sandbox
126
+ environment works everywhere.
127
+
128
+ Supabase sends its own authentication emails from Supabase's servers; JSKIT
129
+ cannot redirect them. Point development and staging at a separate Supabase
130
+ project.
131
+
132
+ ## The application's own side effects
133
+
134
+ Code the application writes that reaches the world follows the same rule. Send
135
+ email and SMS through `deliverMessage`, which sends, redirects or logs each as
136
+ `APP_ENV` says; log anything else outside production with `logSideEffect`.
137
+
138
+ ```js
139
+ import { deliverMessage, logSideEffect, markStagingEmail } from "@jskit-ai/kernel/server/runtime/appEnvironment";
140
+ import { appEnvironment } from "@jskit-ai/kernel/shared/support/appEnvironment";
141
+
142
+ function sendReminder({ env, logger, mailer }, message) {
143
+ return deliverMessage({
144
+ env,
145
+ logger,
146
+ channel: "email",
147
+ to: message.to,
148
+ summary: `the reminder to ${message.to}`,
149
+ details: { subject: message.subject },
150
+ send: (to, { originalTo }) => mailer.send(markStagingEmail({ ...message, to }, originalTo))
151
+ });
152
+ }
153
+
154
+ async function notifyDevice({ env, logger, push }, notification) {
155
+ const appEnv = appEnvironment(env);
156
+ if (appEnv !== "production") {
157
+ logSideEffect(logger, appEnv, {
158
+ kind: "push notification",
159
+ summary: `the reminder to device ${notification.deviceId}`,
160
+ details: { deviceId: notification.deviceId }
161
+ });
162
+ return { simulated: true };
163
+ }
164
+ return push.send(notification);
165
+ }
166
+ ```
167
+
168
+ - Read `env` from the `runtime.env` capability, never a request.
169
+ - A configured driver or key (`EMAIL_DRIVER=ses`, a live payment key) does not
170
+ make anything real; only `APP_ENV=production` does.
171
+ - Test each environment the code treats differently. A test that proves a real
172
+ sender against a fake transport passes `APP_ENV: "production"` (and
173
+ `NODE_ENV: "production"` when it starts a whole server), and a staging test
174
+ sets `STAGING_EMAIL_TO` and checks that only that address received it.
@@ -274,8 +274,9 @@ dialog, chip or FAB.
274
274
  (`@jskit-ai/shell-web/client/components/ShellPageActions`), each a
275
275
  `ShellPageAction` with `icon`, `label` (also its accessible name and compact
276
276
  tooltip), and `primary`, `to`, `replace`, `href` (with `download` for a
277
- file, such as a CSV export), `disabled`, `loading` or `color` (`error` for a
278
- destructive one); attributes such as `target` reach its button. On compact
277
+ file, such as a CSV export), `disabled`, `pending`, `loading` or `color`
278
+ (`error` for a destructive one); attributes such as `target` reach its
279
+ button. On compact
279
280
  widths the bar shows the single `primary` action (a form's Save) and puts
280
281
  the other actions, and the top-right items that don't fit beside the title,
281
282
  in its "More actions" menu, where `overflow` actions always are; medium and
@@ -367,7 +368,12 @@ dialog, chip or FAB.
367
368
  loading uses Material skeletons that reserve the final content geometry;
368
369
  never use a generic spinner or circular progress indicator, and never let
369
370
  content jump when data arrives. An action without a loading content region
370
- uses a stable disabled/pending label and shared feedback, not a spinner.
371
+ uses a stable pending label ("Saving…") and shared feedback, not a spinner.
372
+ - While a command runs, mark its button pending rather than `disabled` when
373
+ possible: `pending` on `ShellPageAction` and `ShellPrimaryAction`,
374
+ `v-pending` on other buttons. It keeps keyboard focus, reads as unavailable
375
+ and ignores a second press; a focused button that becomes `disabled` drops
376
+ focus to the page body. Keep `disabled` for an action that cannot run.
371
377
  - Keep failures at their semantic owner. A resource that cannot render uses a
372
378
  stable in-page error and retry state; field validation stays beside the
373
379
  field. A user-triggered command uses JSKIT's shared action
@@ -17,8 +17,8 @@ in a JSKIT app. The rules it applies are already in [Material 3](/guide/framewor
17
17
  ## States on every screen
18
18
 
19
19
  - **Loading:** Material skeletons with the geometry of the content they stand
20
- for, never a spinner; an action keeps a stable label while it runs and
21
- cannot be sent twice ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
20
+ for, never a spinner; an action keeps a stable label and its keyboard focus
21
+ while it runs, and cannot be sent twice ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
22
22
  Ordinary reads stop after 30 seconds, so a slow read ends in its error state.
23
23
  - **Empty:** a list's empty state carries an icon, a line saying what would be
24
24
  there and one action, such as New; with filters or a search applied it
@@ -60,6 +60,12 @@ in a JSKIT app. The rules it applies are already in [Material 3](/guide/framewor
60
60
  width.
61
61
  - **Double submit:** click Save twice quickly; the command's pending state
62
62
  must send one request.
63
+ - **Keyboard through a running command:** Tab to Save (or Send, "Load more",
64
+ a dialog's confirm), press Enter and answer the request late
65
+ (`page.route`). Focus should stay on the button while it runs, and move to
66
+ the field a refusal marks. Focus on the page body there usually means the
67
+ button was `disabled` while it ran; mark it pending instead when possible
68
+ ([Material 3 rules](/guide/framework/material-3#components-state-and-feedback)).
63
69
  - **Session and tabs:** sign out in another tab and come back; let the session
64
70
  expire mid-form. The auth guard sends the person to sign-in and back.
65
71
  - **Time:** dates follow [strict temporal values](/guide/framework/crud-operations#strict-temporal-values);
@@ -167,9 +167,9 @@ A consolidation drops behaviour there without a failing build.
167
167
 
168
168
  ### Production settings
169
169
 
170
- - `NODE_ENV=production` is JSKIT's only production switch. Without it a
171
- deployed server runs as development: no first-account setup code, and
172
- development-only settings accepted.
170
+ - A deployed server sets `APP_ENV=staging` or `production` and
171
+ `NODE_ENV=production` ([Environments](/guide/framework/environments)); only
172
+ then does local auth ask for a setup code and refuse development settings.
173
173
  - On an empty production database, local auth asks for the first account's
174
174
  setup code, so whoever reaches a new deployment first cannot own it ([The
175
175
  first account in
@@ -94,10 +94,12 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
94
94
 
95
95
  ## Production settings and secrets
96
96
 
97
- - `NODE_ENV=production`, set by the Deployment's Serve step, is JSKIT's only
98
- production switch. There local auth requires `AUTH_LOCAL_SESSION_SECRET`,
99
- refuses `AUTH_DEV_BYPASS_ENABLED` and `AUTH_LOCAL_RECOVERY_DEV_OUTPUT`, and
100
- refuses to start without a confirmation sender while anyone may register
97
+ - `APP_ENV=staging` or `APP_ENV=production`, with `NODE_ENV=production`, set by
98
+ the Deployment's Serve step, makes a server deployed
99
+ ([Environments](/guide/framework/environments)). There local auth requires
100
+ `AUTH_LOCAL_SESSION_SECRET`, refuses `AUTH_DEV_BYPASS_ENABLED` and
101
+ `AUTH_LOCAL_RECOVERY_DEV_OUTPUT`, and refuses to start without a confirmation
102
+ sender while anyone may register
101
103
  ([Production settings](/guide/framework/sanity-checks#production-settings)).
102
104
  - On an empty production database the first account needs the setup code
103
105
  (403 `auth.local.setup.codeRequired`), so whoever reaches a new deployment
@@ -130,7 +132,7 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
130
132
  workspace), a write without `csrf-token`, and one request past each
131
133
  `rateLimit` (429). A body that does not validate, sent without a session,
132
134
  must get the refusal, not field errors.
133
- - Production settings: start the server with `NODE_ENV=production` and the
135
+ - Production settings: start the server with `APP_ENV=staging`, `NODE_ENV=production` and the
134
136
  test database, and check that it stops without `AUTH_LOCAL_SESSION_SECRET`,
135
137
  that registering asks for the setup code, and the response headers.
136
138
  - Run `npm audit` and `npm run verify`.
@@ -13,6 +13,9 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
13
13
  - [Upgrade JSKIT](/guide/app-setup/upgrading-jskit)
14
14
  - [Package an app with Nix](/guide/app-setup/package-with-nix): for a host that
15
15
  runs apps only as Nix packages, built with no network access
16
+ - [Run on more than one server](/guide/app-setup/more-than-one-server): files,
17
+ live updates, sessions, scheduled work and migrations when several copies
18
+ run behind a load balancer
16
19
  - [Move an app to the Material 3 defaults](/guide/app-setup/material-3-migration)
17
20
  - [Migrate an existing application](/guide/app-setup/existing-application-migration)
18
21
  - [A more interesting shell](/guide/app-setup/a-more-interesting-shell)
@@ -57,8 +60,9 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
57
60
  - [Sanity checks](/guide/framework/sanity-checks): JSKIT's own pitfalls, and
58
61
  the JSKIT calls that check data access, tests, a refactor, a screen or a
59
62
  deployment before calling it done
60
- - [Side effects and test copies](/guide/framework/side-effects): read before
61
- code that sends email, messages or payments, or calls another system
63
+ - [Environments](/guide/framework/environments): read before code that sends
64
+ email, messages or payments, calls another system, or depends on where the
65
+ app runs (`APP_ENV`)
62
66
  - [Translating a JSKIT app](/guide/framework/translation)
63
67
  - [Complete source pattern library](/patterns/)
64
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.331",
3
+ "version": "0.1.333",
4
4
  "description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
5
5
  "type": "module",
6
6
  "files": [
@@ -5,7 +5,7 @@
5
5
  "private": true,
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@jskit-ai/kernel": "0.2.26",
8
+ "@jskit-ai/kernel": "0.2.27",
9
9
  "json-rest-schema": "^1.0.20"
10
10
  },
11
11
  "exports": {
@@ -0,0 +1,8 @@
1
+ # Where this app runs: development, test, staging or production (the JSKIT Environments guide).
2
+ # `npm run develop`, `npm run dev` and `jskit test` set it themselves; `npm start` reads it here or from the host.
3
+ # Staging and production also need NODE_ENV=production.
4
+ APP_ENV=development
5
+
6
+ # Staging only: the one address every email goes to, and the one number every SMS goes to. Unset, each is logged.
7
+ # STAGING_EMAIL_TO=
8
+ # STAGING_SMS_TO=
@@ -26,11 +26,13 @@ factory or client provider), read the client features guide at
26
26
  Simple, direct code comes first: never add a layer, wrapper, registry or tiny
27
27
  module only to satisfy a rule. `npm run lint` checks its rules too.
28
28
 
29
- Before writing code that sends email, SMS, push notifications or payments, or
30
- calls another system, read the side effects guide at
31
- `https://mobily-enterprises.github.io/jskit-ai/guide/framework/side-effects`.
32
- Unless `SIDE_EFFECTS` is exactly `live`, the app is a test copy: it simulates
33
- them and logs them instead.
29
+ Before writing code that sends email, SMS, push notifications or payments,
30
+ calls another system, or depends on where the app runs, read the environments
31
+ guide at
32
+ `https://mobily-enterprises.github.io/jskit-ai/guide/framework/environments`.
33
+ `APP_ENV` (development, test, staging or production) decides all of it: only
34
+ production sends for real, staging sends email and SMS only to its test
35
+ addresses, and `NODE_ENV` only picks optimised builds.
34
36
 
35
37
  Before implementation, read the narrow relevant source pattern completely. If
36
38
  its owner package is installed, prefer that version-matched package-owned copy.
@@ -27,6 +27,8 @@ function waitForChild(child) {
27
27
  });
28
28
  }
29
29
 
30
+ // The development launcher runs the app in development, whatever .env or the shell says (the Environments guide).
31
+ process.env.APP_ENV = "development";
30
32
  const previewHost = String(process.env.HOST || "").trim() || "0.0.0.0";
31
33
  const previewPort = requiredPort(process.env.PORT || String(DEFAULT_PORT));
32
34
  let apiServer = null;
@@ -16,9 +16,9 @@
16
16
  "server:home": "SERVER_SURFACE=home node ./bin/server.js",
17
17
  "start": "node ./bin/server.js",
18
18
  "develop": "node ./bin/develop.js",
19
- "dev": "vite",
20
- "dev:all": "vite",
21
- "dev:home": "VITE_SURFACE=home vite",
19
+ "dev": "APP_ENV=development vite",
20
+ "dev:all": "APP_ENV=development vite",
21
+ "dev:home": "APP_ENV=development VITE_SURFACE=home vite",
22
22
  "build": "vite build",
23
23
  "build:all": "vite build",
24
24
  "build:home": "VITE_SURFACE=home vite build",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.26",
38
- "@jskit-ai/material-web": "0.1.8",
37
+ "@jskit-ai/kernel": "0.2.27",
38
+ "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
41
41
  "pino": "^10.3.1",
@@ -44,13 +44,13 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.26",
47
+ "@jskit-ai/http-runtime": "0.2.27",
48
48
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
49
49
  "@vue/devtools-api": "^8.2.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/config-eslint": "0.1.252",
53
- "@jskit-ai/jskit-catalog": "0.2.83",
53
+ "@jskit-ai/jskit-catalog": "0.2.85",
54
54
  "@playwright/test": "1.61.1",
55
55
  "@vitejs/plugin-vue": "^6.0.7",
56
56
  "eslint": "^10.8.0",
@@ -0,0 +1,8 @@
1
+ # Where this app runs: development, test, staging or production (the JSKIT Environments guide).
2
+ # `npm run develop`, `npm run dev` and `jskit test` set it themselves; `npm start` reads it here or from the host.
3
+ # Staging and production also need NODE_ENV=production.
4
+ APP_ENV=development
5
+
6
+ # Staging only: the one address every email goes to, and the one number every SMS goes to. Unset, each is logged.
7
+ # STAGING_EMAIL_TO=
8
+ # STAGING_SMS_TO=
@@ -26,11 +26,13 @@ factory or client provider), read the client features guide at
26
26
  Simple, direct code comes first: never add a layer, wrapper, registry or tiny
27
27
  module only to satisfy a rule. `npm run lint` checks its rules too.
28
28
 
29
- Before writing code that sends email, SMS, push notifications or payments, or
30
- calls another system, read the side effects guide at
31
- `https://mobily-enterprises.github.io/jskit-ai/guide/framework/side-effects`.
32
- Unless `SIDE_EFFECTS` is exactly `live`, the app is a test copy: it simulates
33
- them and logs them instead.
29
+ Before writing code that sends email, SMS, push notifications or payments,
30
+ calls another system, or depends on where the app runs, read the environments
31
+ guide at
32
+ `https://mobily-enterprises.github.io/jskit-ai/guide/framework/environments`.
33
+ `APP_ENV` (development, test, staging or production) decides all of it: only
34
+ production sends for real, staging sends email and SMS only to its test
35
+ addresses, and `NODE_ENV` only picks optimised builds.
34
36
 
35
37
  Before implementation, read the narrow relevant source pattern completely. If
36
38
  its owner package is installed, prefer that version-matched package-owned copy.
@@ -27,6 +27,8 @@ function waitForChild(child) {
27
27
  });
28
28
  }
29
29
 
30
+ // The development launcher runs the app in development, whatever .env or the shell says (the Environments guide).
31
+ process.env.APP_ENV = "development";
30
32
  const previewHost = String(process.env.HOST || "").trim() || "0.0.0.0";
31
33
  const previewPort = requiredPort(process.env.PORT || String(DEFAULT_PORT));
32
34
  let apiServer = null;
@@ -16,9 +16,9 @@
16
16
  "server:home": "SERVER_SURFACE=home node ./bin/server.js",
17
17
  "start": "node ./bin/server.js",
18
18
  "develop": "node ./bin/develop.js",
19
- "dev": "vite",
20
- "dev:all": "vite",
21
- "dev:home": "VITE_SURFACE=home vite",
19
+ "dev": "APP_ENV=development vite",
20
+ "dev:all": "APP_ENV=development vite",
21
+ "dev:home": "APP_ENV=development VITE_SURFACE=home vite",
22
22
  "build": "vite build",
23
23
  "build:all": "vite build",
24
24
  "build:home": "VITE_SURFACE=home vite build",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.26",
38
- "@jskit-ai/material-web": "0.1.8",
37
+ "@jskit-ai/kernel": "0.2.27",
38
+ "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
41
41
  "pino": "^10.3.1",
@@ -44,14 +44,14 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.26",
48
- "@jskit-ai/shell-web": "0.2.37",
47
+ "@jskit-ai/http-runtime": "0.2.27",
48
+ "@jskit-ai/shell-web": "0.2.39",
49
49
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
50
50
  "@vue/devtools-api": "^8.2.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@jskit-ai/config-eslint": "0.1.252",
54
- "@jskit-ai/jskit-catalog": "0.2.83",
54
+ "@jskit-ai/jskit-catalog": "0.2.85",
55
55
  "@playwright/test": "1.61.1",
56
56
  "@vitejs/plugin-vue": "^6.0.7",
57
57
  "eslint": "^10.8.0",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "description": "App-local runtime composition and lightweight glue.",
11
11
  "dependencies": {
12
- "@jskit-ai/kernel": "0.2.26"
12
+ "@jskit-ai/kernel": "0.2.27"
13
13
  },
14
14
  "jskit": {
15
15
  "kind": "runtime",
@@ -19,6 +19,16 @@ For the full repo inventory, read `reference/autogen/README.md` and the package
19
19
 
20
20
  ### support
21
21
 
22
+ ### `support/appEnvironment.js`
23
+ Exports
24
+ - `APP_ENV_KEY`
25
+ - `APP_ENVIRONMENTS`
26
+ - `APP_ENVIRONMENT_META_NAME`
27
+ - `appEnvironment(env)`
28
+ - `isDeployed(env)`
29
+ - `pageAppEnvironment(documentObject = globalThis.document)`
30
+ - `withAppEnvironmentMeta(html, environment)`
31
+
22
32
  ### `support/clientBuild.js`
23
33
  Exports
24
34
  - `CLIENT_BUILD_META_NAME`
@@ -170,17 +180,6 @@ Exports
170
180
  Local functions
171
181
  - `normalizePlacementRenderers(value = {})`
172
182
 
173
- ### `support/sideEffects.js`
174
- Exports
175
- - `SIDE_EFFECTS_ENV_KEY`
176
- - `SIDE_EFFECTS_LIVE`
177
- - `SIDE_EFFECTS_META_NAME`
178
- - `SIDE_EFFECTS_SIMULATE`
179
- - `pageSideEffectsMode(documentObject = globalThis.document)`
180
- - `resolveSideEffectsMode(env)`
181
- - `sideEffectsAreLive(env)`
182
- - `withSideEffectsMeta(html, mode)`
183
-
184
183
  ### `support/silentLogger.js`
185
184
  Exports
186
185
  - `silentLogger`