dsh-feiyu-memgate 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +73 -12
  2. package/README.md +68 -11
  3. package/README.zh.md +93 -36
  4. package/client/README.md +267 -0
  5. package/client/art/mascot-asleep.webp +0 -0
  6. package/client/art/mascot-busy.webp +0 -0
  7. package/client/art/mascot-nag.webp +0 -0
  8. package/client/art/mascot-ready.webp +0 -0
  9. package/client/art/mascot-trouble.webp +0 -0
  10. package/client/client.js +4226 -1269
  11. package/client/src/clipboard.cjs +52 -0
  12. package/client/src/constants.cjs +43 -0
  13. package/client/src/fields.cjs +960 -0
  14. package/client/src/hooks.cjs +220 -0
  15. package/client/src/i18n.cjs +444 -0
  16. package/client/src/index.cjs +69 -0
  17. package/client/src/kit/controls.cjs +189 -0
  18. package/client/src/kit/icons.cjs +40 -0
  19. package/client/src/kit/layout.cjs +124 -0
  20. package/client/src/layout.cjs +143 -0
  21. package/client/src/model/changelog.cjs +29 -0
  22. package/client/src/model/feedback.cjs +168 -0
  23. package/client/src/model/form.cjs +83 -0
  24. package/client/src/model/models.cjs +87 -0
  25. package/client/src/model/overview.cjs +111 -0
  26. package/client/src/model/page.cjs +104 -0
  27. package/client/src/model/status.cjs +57 -0
  28. package/client/src/model/trial.cjs +111 -0
  29. package/client/src/net.cjs +101 -0
  30. package/client/src/react.cjs +11 -0
  31. package/client/src/theme/page.css +1284 -0
  32. package/client/src/theme/styles.cjs +43 -0
  33. package/client/src/view/feedback.cjs +180 -0
  34. package/client/src/view/field-row.cjs +98 -0
  35. package/client/src/view/hero.cjs +54 -0
  36. package/client/src/view/markdown.cjs +96 -0
  37. package/client/src/view/models.cjs +154 -0
  38. package/client/src/view/page.cjs +199 -0
  39. package/client/src/view/settings-tab.cjs +78 -0
  40. package/client/src/view/tabs.cjs +71 -0
  41. package/client/src/view/trial.cjs +84 -0
  42. package/docs/DETAIL.en.md +55 -6
  43. package/docs/DETAIL.md +63 -14
  44. package/locale/zh.json +1 -1
  45. package/package.json +2 -1
  46. package/python/GATEWAY_VERSION.json +37 -31
  47. package/python/feiyu_memgate/backends/_sqlfile.py +293 -0
  48. package/python/feiyu_memgate/backends/base.py +121 -6
  49. package/python/feiyu_memgate/backends/embedding.py +265 -178
  50. package/python/feiyu_memgate/backends/hybrid.py +330 -83
  51. package/python/feiyu_memgate/backends/inmemory.py +115 -24
  52. package/python/feiyu_memgate/backends/openviking.py +7 -10
  53. package/python/feiyu_memgate/backends/sqlite.py +129 -145
  54. package/python/feiyu_memgate/builtins.py +1 -0
  55. package/python/feiyu_memgate/cli.py +124 -20
  56. package/python/feiyu_memgate/client/block.py +4 -2
  57. package/python/feiyu_memgate/client/http.py +106 -19
  58. package/python/feiyu_memgate/client/local.py +4 -3
  59. package/python/feiyu_memgate/config.py +118 -24
  60. package/python/feiyu_memgate/core/limits.py +2 -1
  61. package/python/feiyu_memgate/core/pool.py +29 -2
  62. package/python/feiyu_memgate/core/recall.py +179 -10
  63. package/python/feiyu_memgate/core/redact.py +4 -2
  64. package/python/feiyu_memgate/core/stages.py +52 -9
  65. package/python/feiyu_memgate/core/tidy.py +2 -1
  66. package/python/feiyu_memgate/core/watch.py +3 -2
  67. package/python/feiyu_memgate/core/write.py +9 -3
  68. package/python/feiyu_memgate/forgetting/archive.py +38 -10
  69. package/python/feiyu_memgate/forgetting/engine.py +46 -10
  70. package/python/feiyu_memgate/forgetting/stage.py +4 -2
  71. package/python/feiyu_memgate/gateway/app.py +168 -272
  72. package/python/feiyu_memgate/gateway/fields.py +121 -0
  73. package/python/feiyu_memgate/gateway/policies.py +162 -0
  74. package/python/feiyu_memgate/gateway/server.py +12 -4
  75. package/python/feiyu_memgate/gateway/tokens.py +137 -0
  76. package/python/feiyu_memgate/gateway/validate.py +120 -0
  77. package/python/feiyu_memgate/identity.py +152 -0
  78. package/python/feiyu_memgate/model.py +170 -2
  79. package/python/feiyu_memgate/registry.py +6 -3
  80. package/python/feiyu_memgate/tools/crypto.py +5 -4
  81. package/python/feiyu_memgate/tools/evaluate.py +2 -1
  82. package/python/feiyu_memgate/tools/tenants.py +2 -0
  83. package/src/block.js +9 -3
  84. package/src/capture.js +98 -0
  85. package/src/catalogue.js +4 -4
  86. package/src/changelog.js +72 -0
  87. package/src/client.js +145 -10
  88. package/src/commands.js +112 -62
  89. package/src/config.js +139 -62
  90. package/src/followup.js +139 -0
  91. package/src/gateway.js +79 -4
  92. package/src/migrate.py +54 -9
  93. package/src/mirror.py +44 -7
  94. package/src/plugin.js +416 -412
  95. package/src/pool.js +298 -0
  96. package/src/recent.js +68 -0
  97. package/src/relevance.js +80 -0
  98. package/src/routes.js +320 -0
  99. package/src/setup.js +36 -36
  100. package/src/shared.js +77 -0
  101. package/src/tiers.js +4 -4
  102. package/src/time.js +27 -0
  103. package/src/tools.js +164 -0
@@ -0,0 +1,267 @@
1
+ # The settings page (browser half)
2
+
3
+ `client/client.js` is the browser half of dsh-feiyu-memgate: the settings page of the plugin's row on the
4
+ Plugins page. It is a **generated file**. The source is the set of small modules under `client/src/`;
5
+ `npm run build-client` joins them into `client/client.js`. Edit the modules, never the generated file.
6
+
7
+ ## What the host loads
8
+
9
+ The host serves a package's `./client` export to the page as one script in the client module system's
10
+ lazy-CJS form: it registers the package name and a `factory(require)` with the page's module loader, and
11
+ `require` answers only the page's shared module table (`docs/cookbook/adding-a-settings-card.md`
12
+ section 5; `packages/client/modules/README.md` "What the browser loads" and "Sharing modules"). So the
13
+ script must be one file, written as plain JavaScript (React elements are built with `createElement`, no
14
+ JSX), and the only module it asks for is `react`. The page does not use the host's UI primitives: its
15
+ controls are its own (`kit/`), and its stylesheet is `theme/page.css`.
16
+
17
+ ## How the file is assembled
18
+
19
+ `scripts/build-client.mjs` reads every `*.cjs` and `*.css` file under `client/src` (sorted by path, line
20
+ endings turned into LF) and writes `client/client.js`: a header comment, the
21
+ `window.__ModuleLoader__.load({ id: 'dsh-feiyu-memgate', factory })` call, a small registry (`define`,
22
+ `load` with a cache, a `require` per module that resolves `./x` and `../x` against the requiring module's
23
+ path and passes every other name to the host's `require`), one `define` per file with its text indented,
24
+ and `return load('index.cjs')`. Nothing is transpiled and nothing is minified; the output does not depend
25
+ on the platform, the date or the path of the checkout.
26
+
27
+ A `.css` file becomes a module that exports its text as a string (`theme/styles.cjs` puts it into the
28
+ document).
29
+
30
+ Because the text of a module is indented, a module must not contain a template literal that spans lines.
31
+
32
+ ## The modules
33
+
34
+ Ids are paths relative to `client/src`.
35
+
36
+ **Wiring**
37
+
38
+ | module | holds |
39
+ |---|---|
40
+ | `index.cjs` | the entry point: `name`, `inject`, `apply(ctx)` (registers the dictionaries, the stylesheet and the page in the row slot) and the `internals` export for tests and the preview |
41
+ | `react.cjs` | the one place that asks the host for React: `{ React, h, useEffect, useRef, useState }` |
42
+
43
+ **Tables**
44
+
45
+ | module | holds |
46
+ |---|---|
47
+ | `constants.cjs` | the settings namespace, the slot key, the routes, the poll intervals, the element id prefix, the public links (among them GitHub's new-issue page) and the address of the project's feedback receiver (`FEEDBACK_ENDPOINT`, empty while there is none) |
48
+ | `fields.cjs` | **generated** by `npm run sync-client` from `src/config.js`: `FIELDS` and `INDEX` |
49
+ | `layout.cjs` | where each setting sits: `TABS` → sections → setting keys, and `placedKeys()` |
50
+ | `i18n.cjs` | the `UI` dictionary (en, zh) and `dictionaries()`, which adds the texts of the field table |
51
+ | `net.cjs` | `fetchStatus`, `fetchChangelog`, `fetchModels`, `postModels`, `tryRecall`, over one `getJson` / `postJson` pair; and `sendFeedback`, the one call that leaves the host |
52
+ | `clipboard.cjs` | `copyText`: the one place that touches the clipboard, and says whether the text arrived |
53
+
54
+ **Logic, `model/`** (pure: no React, no DOM)
55
+
56
+ | module | holds |
57
+ |---|---|
58
+ | `model/form.cjs` | the settings form as data: `at`, `checkText`, `fieldView`, `buildOps`, `saveDraft` |
59
+ | `model/page.cjs` | the settings arranged for drawing: `splitOption`, `isMet`, `sectionView`, `pageView`, `savable` |
60
+ | `model/overview.cjs` | the summary at the top of the page: `summarise` (mood, headline, line, facts), `formatCount`, `MOODS` |
61
+ | `model/status.cjs` | the status block as text rows: `stateText`, `statusRows` |
62
+ | `model/models.cjs` | the local model list as data: `pickText`, `formatSize`, `memoryText`, `modelActions`, `chainLine`, `sameProblem` |
63
+ | `model/changelog.cjs` | the changelog answer as a list of releases: `entryDate`, `releases` |
64
+ | `model/feedback.cjs` | a feedback report and the address that hands it to GitHub: `KINDS`, `environment`, `safe`, `titleOf`, `bodyOf`, `compose`, `reportText`, with the limits `MAX_TEXT` and `MAX_URL`; and for the receiver `payload`, `usableEndpoint`. Also loaded by the host half (see below) |
65
+ | `model/trial.cjs` | the answer of the try route as what the panel shows: `rows`, `summary`, `score`, `usable`, `errorKey` |
66
+
67
+ **Hooks**
68
+
69
+ | module | holds |
70
+ |---|---|
71
+ | `hooks.cjs` | `useStatus` (polled), `useChangelog` (read once), `useModels` (polled, and the clicks of the model list), `useCopy` (the clipboard, and what became of the last copy), `useTrial` (one trial recall at a time, and what became of the last), `useSend` (a report posted to the receiver, and what became of it); they own the timers and the "still mounted" flag |
72
+
73
+ **Theme, `theme/`**
74
+
75
+ | module | holds |
76
+ |---|---|
77
+ | `theme/page.css` | the stylesheet of the page, with the one block that maps the host's style variables to the page's own |
78
+ | `theme/styles.cjs` | `installStyles(document)` (adds one `<style>` with the stylesheet, returns the function that removes it), `STYLE_ID`, `cx` (joins class names) |
79
+
80
+ **Controls and parts, `kit/`** (plain functions of props, no state of their own)
81
+
82
+ | module | holds |
83
+ |---|---|
84
+ | `kit/controls.cjs` | `Button`, `Tag`, `Switch`, `TextInput`, `TextArea`, `Stepper`, `Choices` and `stepText` |
85
+ | `kit/layout.cjs` | `Tabs`, `TabPanel`, `Reveal`, `Fold`, `Group`, `Facts`, `Notice`, `Progress` |
86
+ | `kit/icons.cjs` | the few line icons: `Icon`, `ICON_NAMES` |
87
+
88
+ **Views, `view/`** (what is drawn and what the page keeps in state)
89
+
90
+ | module | holds |
91
+ |---|---|
92
+ | `view/page.cjs` | `SettingsPage` (the slot entry), `SettingsBody` (summary, tabs, panel, save bar, footer; keeps the tab, the staged edits, the phase of a save, the open groups, the feedback being written and the recall trial), `SaveBar`, `Footer` |
93
+ | `view/hero.cjs` | `Hero`: the headline, the line and the facts of the summary, with the mascot's drawing |
94
+ | `view/settings-tab.cjs` | `SettingsTab`: the sections of one settings tab, sub-rows inside a `Reveal`, folding groups in the Advanced tab |
95
+ | `view/field-row.cjs` | `FieldRow`: one setting as one row, with the control that fits its kind; `fieldId` |
96
+ | `view/tabs.cjs` | `OverviewTab` and `ChangelogTab`, two of the tabs without settings |
97
+ | `view/feedback.cjs` | `FeedbackTab`, the third, and `Nag` (the fifth drawing, `mascot-nag.webp`, with its speech bubble, beside the title; none if it cannot be loaded): what it is about, the text, the environment lines, Send, the link out to GitHub and the copy button; `emptyFeedback` |
98
+ | `view/models.cjs` | `ModelsPanel` and `ModelRow`: the local embedding models and their one button |
99
+ | `view/trial.cjs` | `TrialPanel` and `TrialRow`: the recall trial of the Retrieval tab, one line to type a sentence and the memories the gateway looked at, each with its score and, if left out, the step that removed it |
100
+ | `view/markdown.cjs` | the changelog Markdown subset, text in and React elements out: `inlineMarkdown`, `joinLines`, `renderMarkdown` |
101
+
102
+ ## The page
103
+
104
+ The Plugins page renders entries of its keyed slot `plugins.row.config` under the key
105
+ `<package name>#<row id>` and passes `view` (`'summary'` | `'page'`) and `form` (`{ state, mutate }`) for
106
+ the row's settings namespace (`packages/client/ui-plugin-manager/src/client/slot-contract.ts:160-167`,
107
+ `:190-195`; `PluginManagerPage.tsx:1568-1572`, `:714`). `view/page.cjs` exports `SettingsPage`, which
108
+ `index.cjs` registers in that slot; `apply(ctx)` also registers the dictionaries and the stylesheet.
109
+
110
+ `SettingsBody` draws, in order: the `Hero` (the state in one headline, one line and a few facts, with a
111
+ mood that picks one of four drawings of the mascot), the `Tabs` (overview, features, retrieval, advanced,
112
+ changelog, feedback), the one `TabPanel` of the selected tab, the `SaveBar` (only while edits are staged, or just
113
+ after a save) and the `Footer`. The page keeps its shape whatever the settings form is doing: while the
114
+ form is loading, unavailable or read-only, the summary, the model list, the changelog and the feedback tab
115
+ still work, and a settings tab says what is the matter instead of showing rows nobody can use.
116
+
117
+ The settings form follows the host's conventions: edits are staged, only Save writes, all staged edits go
118
+ in one `form.mutate(ops, revision)` with the revision they were made against, a changed setting shows a
119
+ tag and a reset that stages a return to the inherited value, and a secret is write-only (an empty draft
120
+ keeps the stored value). A setting with `needs` (see `src/config.js`) is drawn as a sub-row inside a
121
+ `Reveal` that is open while the setting it needs has a fitting value, judged by the value on screen, a
122
+ staged edit included. The Advanced tab's sections are folds, closed by default.
123
+
124
+ Status. The summary and the Overview tab read `GET feiyu-memgate/status` (document-relative, like the
125
+ first-party pages' host routes), which the host half serves to the owner only. It shows no secret, address
126
+ or memory: secrets arrive as booleans.
127
+
128
+ Changelog. The Changelog tab reads `GET feiyu-memgate/changelog` (owner only, like the status): the released
129
+ entries of the package's `CHANGELOG.md`. Their Markdown is drawn by a small subset (`view/markdown.cjs`)
130
+ that builds React elements from text (headings, lists, paragraphs, code, bold, https links), so no HTML
131
+ from the file can reach the page.
132
+
133
+ Feedback. The Feedback tab writes a report and either sends it to the project's receiver (Send, below) or hands it to the person's browser.
134
+ `model/feedback.cjs` builds the address of GitHub's new-issue page with the title and the text as query
135
+ parameters, and the button is a plain link to it (`target="_blank"`), so the report exists only once the
136
+ person submits it on GitHub under their own account. What is attached besides their own words is decided in
137
+ one function, `environment(status)`: version numbers and state names, each of which has to look like one
138
+ (letters, digits, dots, dashes, at most 40 characters) or becomes a question mark, so a path, an address or
139
+ a file name cannot get in whatever a later status holds. The same lines are listed on the tab under the
140
+ switch that attaches them. An address is kept under `MAX_URL` characters: a longer report is cut in the
141
+ address only, the cut is marked, and the link copies the whole report to the clipboard on the way out.
142
+ The shipped package names a receiver (`FEEDBACK_ENDPOINT`, checked by `usableEndpoint`: https, or this
143
+ computer for the preview; an empty value switches Send off and leaves the link and the copy button), so the tab is "write, then Send": one Send button, and the link
144
+ to GitHub and the copy button are shown only inside the notice of a Send that failed. Send is the only call of the
145
+ page that leaves the host: `net.cjs` `sendFeedback` posts `payload()` with `credentials: 'omit'` and no
146
+ referrer, waits `FEEDBACK_TIMEOUT_MS`, and turns every failure into a code the tab shows. The receiver is
147
+ `feedback-worker/worker.js` (a Cloudflare Worker the maintainers run, not shipped in the package); its
148
+ `validate()` and this module's `payload()` describe the same shape and are tested against each other.
149
+ The host half loads the same module for `/memgate feedback` (`src/commands.js` imports
150
+ `client/src/model/feedback.cjs`), which is why that module and `constants.cjs` must stay plain CommonJS
151
+ that runs in Node without a browser.
152
+
153
+ The mascot. The drawings are the files of `client/art/`: four moods (`mascot-<mood>.webp`) and a fifth,
154
+ `mascot-nag.webp`, for the Feedback tab. The host half serves them from its art route
155
+ (`GET feiyu-memgate/art/<file>`, `src/plugin.js`); the summary loads the one that fits the mood, the
156
+ Feedback tab shows the fifth beside its title with a speech bubble over it (the bubble is text of the page,
157
+ so it follows the language), and like the others the tab simply has no drawing, and no bubble, if it cannot
158
+ be loaded. Nothing a person needs is only in the picture.
159
+
160
+ The host half never depends on this page: without it every setting still works, through `/memgate` and
161
+ the profile's patch file.
162
+
163
+ ## Rules for the modules
164
+
165
+ - One responsibility per file. Each file starts with `'use strict'` and a header comment that says what it
166
+ is responsible for and what it must not do.
167
+ - A module gets another module with `require('./x.cjs')` or `require('../x.cjs')`: a relative path with the
168
+ `.cjs` extension. Only `react.cjs` requires `react`; no other module asks the host for anything.
169
+ - One `module.exports = { ... }` at the end of a file, with the names in the order they are defined.
170
+ - No `import` or `export` syntax, no JSX, no dependency that is not in the host's shared module table, no
171
+ template literal that spans lines.
172
+ - `fields.cjs` is generated; change the settings in `src/config.js` instead.
173
+ - Keep a comment with the code it explains.
174
+
175
+ ### Layers
176
+
177
+ The require graph has no cycle, and each layer reaches only what is listed (`tests/client-modules.test.js`
178
+ checks every line of this):
179
+
180
+ | layer | may require |
181
+ |---|---|
182
+ | `constants.cjs`, `fields.cjs`, `layout.cjs`, `react.cjs`, `clipboard.cjs` | nothing of the page |
183
+ | `i18n.cjs` | `fields.cjs` |
184
+ | `net.cjs` | `constants.cjs` |
185
+ | `hooks.cjs` | `react.cjs`, `constants.cjs`, `net.cjs`, `clipboard.cjs` (no view, kit or theme) |
186
+ | `model/*` | other `model/*` files, `fields.cjs`, `layout.cjs`, `constants.cjs` (no React, kit, view, theme or hooks) |
187
+ | `theme/*` | `theme/*` |
188
+ | `kit/*` | `kit/*`, `react.cjs`, `theme/styles.cjs` |
189
+ | `view/*` | anything but `index.cjs` |
190
+ | `index.cjs` | anything; it is the only module that requires `view/page.cjs`, and nothing requires it |
191
+
192
+ ### Design conventions
193
+
194
+ - **Tokens.** The host switches its style variables between light and dark by itself. The page reads them
195
+ through one mapping block at the top of `theme/page.css` (`.fmg-root`): `--fmg-*` variables, each with a
196
+ fallback for a host that does not define it. Every other rule uses `--fmg-*` only, and the host's
197
+ variable names (`--dsw-*`, `--dsh-*`, `--ds-*`) appear nowhere else.
198
+ - **No theme branch.** There is no light rule and no dark rule; the page's own colours are mixed from the
199
+ host's.
200
+ - **Class names** all start with `fmg-`; modifiers are `--name`. No rule reaches outside `.fmg-root`.
201
+ Every class a module uses is defined in the stylesheet and every class the stylesheet defines is used
202
+ (both are tested).
203
+ - **State is carried by ARIA and data attributes** the components set anyway (`aria-selected`,
204
+ `aria-checked`, `aria-expanded`, `aria-invalid`, `data-open`), not by extra classes. Controls are native
205
+ elements with ARIA roles: a switch is a `button` with `role="switch"`, a list of choices a radio group,
206
+ the tabs follow the tabs pattern with arrow keys.
207
+ - **No inline styles.** The one exception is the width of a progress bar's inner element.
208
+ - Every element id starts with `feiyu-memgate-` so that none can meet an id of the host's page.
209
+
210
+ ## How to add a setting
211
+
212
+ 1. Add it to `FIELDS` in `src/config.js` (key, kind, default, range, label and help in both languages;
213
+ `needs`, `unit` or `experimental` when they apply).
214
+ 2. Add its key to a section in `layout.cjs`. A setting with `needs` goes in the same section as the setting
215
+ it needs, after it.
216
+ 3. Run `npm run sync-client`. It rewrites `client/src/fields.cjs` and `client/client.js`.
217
+
218
+ `tests/client-modules.test.js` fails when a setting is not placed, is placed twice or sits before the
219
+ setting it needs; the page needs no other change.
220
+
221
+ ## How to preview
222
+
223
+ ```bash
224
+ node scripts/preview-client.mjs --react <a node_modules folder with react and react-dom 18> [--port 47931]
225
+ ```
226
+
227
+ Run it in `plugins/dsh-feiyu-memgate`, then open `http://127.0.0.1:47931/` and pick a scenario, a theme, a
228
+ language, the state of the settings form, a column width and how feedback is received in the bar on top.
229
+ The page script is assembled from `client/src` on every request, so a reload shows an edit.
230
+
231
+ The Feedback choice decides where Send goes. "As shipped" leaves it to `FEEDBACK_ENDPOINT`: with an address
232
+ there, Send really sends a report to the project's receiver. "No receiver" hides Send. The three made-up
233
+ receivers (takes it, fails, is busy) are a route of the preview server that reads nothing of what is posted.
234
+
235
+ The Recall trial choice (`trial=` in the address) decides what the try route answers: it finds memories (every
236
+ kind of row: delivered, linked, left out at each step, a moved score, a cut text, a missing text), finds
237
+ nothing, the gateway is too old, no recall is made for the sentence, or the lookup fails. The sentence typed
238
+ is not read; the memories are invented.
239
+
240
+ What is real: the page script, its stylesheet, the drawings of `client/art`, the changelog (read from
241
+ `CHANGELOG.md` like the host half does). What is made up: the status and the model list
242
+ (`scripts/preview/scenarios.mjs`), the settings form (kept in the page), and the host's style variables
243
+ (`scripts/preview/host-tokens.css`, copied values). So the preview shows layout, texts, states and both
244
+ themes; it does not show the page inside the real Plugins page. The server listens on `127.0.0.1` only and
245
+ serves nothing but the files named in the script. `tests/client-preview.test.js` checks that every made-up
246
+ scenario can be drawn by the page; it does not start the server.
247
+
248
+ ## Commands
249
+
250
+ Run them in `plugins/dsh-feiyu-memgate`.
251
+
252
+ | command | what it does |
253
+ |---|---|
254
+ | `npm run build-client` | assemble `client/client.js` from `client/src`; rewrite it when it differs |
255
+ | `npm run build-client -- --check` | exit 1 when `client/client.js` is stale; change nothing |
256
+ | `npm run sync-client` | write `client/src/fields.cjs` from `src/config.js`, then do `build-client` |
257
+ | `npm run sync-client -- --check` | exit 1 when `fields.cjs` or `client/client.js` is stale (CI runs this) |
258
+
259
+ ## Tests
260
+
261
+ | file | what it checks |
262
+ |---|---|
263
+ | `tests/client-build.test.js` | the registry and the assembly |
264
+ | `tests/client-modules.test.js` | the pure modules on their own, the rules above (headers, imports, layers, the layout table), the stylesheet against the class names the modules use, the dictionary against the keys they ask for |
265
+ | `tests/client-page.test.js` | the assembled file: what it asks of the host, `apply`, and the page drawn with a small stand-in for React (`tests/helpers/client-harness.js`); fails when either generated file is stale |
266
+ | `tests/client-preview.test.js` | the preview's made-up answers against the page |
267
+ | `tests/trial.test.js` | the recall trial: the model, the call, the panel, its place in the page and the preview's answers for it |
Binary file
Binary file
Binary file
Binary file
Binary file