@warlock.js/grimoire 5.57.0 → 5.58.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.
- package/CHANGELOG.md +20 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +2 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/render.mjs +10 -0
- package/esm/book/render.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +2 -2
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +53 -38
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +4 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/criteria.mjs +21 -2
- package/esm/check/rules/criteria.mjs.map +1 -1
- package/esm/check/rules/screenshots.mjs +57 -0
- package/esm/check/rules/screenshots.mjs.map +1 -0
- package/esm/codes/codes.d.mts +12 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +6 -0
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/book.d.mts +2 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/bookmap.d.mts +19 -1
- package/esm/contracts/bookmap.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +11 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/test-results.d.mts +34 -0
- package/esm/contracts/test-results.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +44 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/data.mjs +94 -3
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/index.d.mts +26 -0
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +88 -5
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts +14 -0
- package/esm/devtools/product-map.d.mts.map +1 -0
- package/esm/devtools/product-map.mjs +385 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +85 -13
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +10 -6
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/graph/index.d.mts +10 -1
- package/esm/graph/index.d.mts.map +1 -1
- package/esm/graph/index.mjs +3 -2
- package/esm/graph/index.mjs.map +1 -1
- package/esm/index.d.mts +4 -4
- package/esm/paths/index.d.mts +2 -0
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +3 -1
- package/esm/paths/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +169 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +7 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +12 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts +7 -2
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs +79 -12
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/vitest/index.d.mts +6 -0
- package/esm/vitest/index.d.mts.map +1 -1
- package/esm/vitest/index.mjs +22 -6
- package/esm/vitest/index.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +6 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/mcp-tools.mjs +48 -12
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +4 -2
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/written/apps.mjs +4 -2
- package/esm/written/apps.mjs.map +1 -1
- package/esm/written/features.mjs +119 -6
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/markdown.mjs +66 -1
- package/esm/written/markdown.mjs.map +1 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +1 -1
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/llms-full.txt +76 -3
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +5 -0
- package/skills/describe-an-app/SKILL.md +12 -0
- package/skills/record-a-change/SKILL.md +8 -0
- package/skills/use-the-grimoire/SKILL.md +14 -1
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +4 -0
- package/ui/grimoire-view.js +1016 -178
- package/ui/grimoire.css +427 -2
- package/ui/product-map.css +636 -0
- package/ui/product-map.js +817 -0
|
@@ -79,11 +79,19 @@ npx warlock grimoire check
|
|
|
79
79
|
| A step names a route, page, mail or job that does not exist | Fix the name in the flow, or the code |
|
|
80
80
|
| A criterion has no test | Write the test, or say in the task why not |
|
|
81
81
|
| A test points at a criterion that does not exist | Fix the `@proves` line |
|
|
82
|
+
| Proofs exist but no test results were found (`GR4009`) | Record results, see below |
|
|
83
|
+
| A proving test the reporter could not match (`GR4010`) | Fix the `@proves` line or the test name |
|
|
82
84
|
| A file has no header, or no feature | `document-a-file` |
|
|
83
85
|
| A file in the feature's folders that no flow reaches | Describe the behaviour in a flow, or delete dead code |
|
|
84
86
|
| A README `updated` older than its newest changelog entry | Reshape the README |
|
|
85
87
|
| A changelog version that does not fit the word (`added` with `2.1`) | Fix the version |
|
|
86
88
|
|
|
89
|
+
**Recording results.** The check and the devtools tab read test results from
|
|
90
|
+
`grimoire/book/test-results.json`, written by the Grimoire Vitest reporter when the tests run. That
|
|
91
|
+
folder is not committed, so run the tests with the reporter in CI and ship the results file with the
|
|
92
|
+
deploy. To write it elsewhere, pass `grimoireReporter({ file })` and point the devtools panel at it
|
|
93
|
+
with the `testResultsFile` option.
|
|
94
|
+
|
|
87
95
|
Fix every line it prints. Do not finish with problems you caused. Findings on a flow or feature
|
|
88
96
|
with `status: proposed` print with `(expected)` and do not fail the check: leave them until the
|
|
89
97
|
code exists.
|
|
@@ -120,6 +120,11 @@ From `@warlock.js/grimoire` (no dependency on core or web):
|
|
|
120
120
|
release between `COLLECTED_START_MARKER` and `COLLECTED_END_MARKER`.
|
|
121
121
|
- `scanProofs` and `scanProofsInText` read `// @proves` lines; `criterionStatus` turns test
|
|
122
122
|
results into a criterion's status; `CASE_QUESTIONS` lists the questions every flow answers.
|
|
123
|
+
- Flow steps list `entries` (every file the step starts from), `direct` (their direct imports), `files` (what
|
|
124
|
+
runs: type-only imports are not followed) and `typeOnlyFiles` (reached only through type-only imports).
|
|
125
|
+
`importClosure(graph, start, { skipTypeOnly: true })` leaves type-only edges out. `warlock scry --flow --json`
|
|
126
|
+
keeps every list; the MCP tool `grimoire_flow` and the devtools flow route send counts and the first 50 direct
|
|
127
|
+
imports per step, and list one step's files on request (`files: "reachable"` or `"type-only"` with `step`).
|
|
123
128
|
- Helpers: `loadBook`, `readFrontMatter`, `fileGraph`, `importClosure`, `importerClosure`,
|
|
124
129
|
`bookEntryPath`, `bookEntryPaths`, `toPosixPath`, `GRIMOIRE_DIR`, `GRIMOIRE_PATHS`,
|
|
125
130
|
`GRIMOIRE_IGNORE_RULES` (the `.gitignore` lines) and `BOOK_SCHEMA_VERSION`.
|
|
@@ -131,9 +136,17 @@ the `grimoire` and `scry` commands for `cli.commands` in `warlock.config.ts`;
|
|
|
131
136
|
|
|
132
137
|
From `@warlock.js/grimoire/vitest`: `grimoireReporter` records the last result of every test marked
|
|
133
138
|
`// @proves` into `grimoire/book/test-results.json`. Add it to the Vitest `reporters` list.
|
|
139
|
+
`grimoireReporter({ file })` writes to another path (for a deploy that ships CI results); `readTestResults(root, file?)`
|
|
140
|
+
reads it, and the panel option `testResultsFile` and `openGrimoire` option `testResultsFile` point the tab at it.
|
|
141
|
+
The check warns with `GR4009` when `@proves` lines exist and no results were found, and with `GR4010` when the
|
|
142
|
+
reporter could not match a proving test.
|
|
134
143
|
|
|
135
144
|
From `@warlock.js/grimoire/devtools`: `grimoireDevtoolsPanel` (the default export) is the Grimoire
|
|
136
145
|
tab for `@warlock.js/devtools`, listed in `panels` of `src/config/devtools.ts`;
|
|
137
146
|
`exportGrimoireSite` writes the same view as a static site.
|
|
138
147
|
The tab keeps its snapshot until the book changes in production and refreshes it in the background in
|
|
139
|
-
development;
|
|
148
|
+
development; the results file's modified time is part of the change stamp, so new results show without a restart.
|
|
149
|
+
The tab also has a Product map: the features, flows, apps, releases and planned work in plain words, from the written
|
|
150
|
+
files (summaries, `audience`, `## Why`, `## Story`) and the images in `grimoire/screenshots/`. Its routes are
|
|
151
|
+
`/product`, `/product/features/:feature` and `/product/flows/:feature/:flow`; `/check/groups` and `/check?code=`
|
|
152
|
+
give the check by code and a page of one code's findings. Set `ttlMs` with `panels: [["@warlock.js/grimoire/devtools", { ttlMs: 60_000 }]]`.
|
|
@@ -62,12 +62,17 @@ version: 3.0
|
|
|
62
62
|
updated: 2026-11-16
|
|
63
63
|
apps: [web-client, mobile]
|
|
64
64
|
folders: [src/app/catalog, src/web/$sites/client/products]
|
|
65
|
+
audience: [shoppers, store staff]
|
|
65
66
|
---
|
|
66
67
|
|
|
67
68
|
# Product catalog
|
|
68
69
|
|
|
69
70
|
Customers browse products, search them and see what is new.
|
|
70
71
|
|
|
72
|
+
## Why
|
|
73
|
+
|
|
74
|
+
Shoppers decide what to buy from the catalog, so it has to be quick to browse and clear about what is new.
|
|
75
|
+
|
|
71
76
|
## Flows
|
|
72
77
|
|
|
73
78
|
- browse-products list and filter products
|
|
@@ -79,6 +84,9 @@ Customers browse products, search them and see what is new.
|
|
|
79
84
|
- affected by orders/place-order (lowers stock)
|
|
80
85
|
```
|
|
81
86
|
|
|
87
|
+
`audience` (optional) lists who the feature is for, in plain words. `## Why` (optional) says why the
|
|
88
|
+
feature exists in a few sentences. Without `audience`, readers use the `who` of the flows.
|
|
89
|
+
|
|
82
90
|
`id` never changes. `folders` are the folders whose files belong to this feature. An entry with a
|
|
83
91
|
code-file extension names one file (`src/web/components/client/home/pricing-table.tsx`), for a
|
|
84
92
|
feature that owns a few files in a folder shared with others. A file entry wins over the folder
|
|
@@ -100,6 +108,15 @@ who: customer
|
|
|
100
108
|
|
|
101
109
|
# Save a product to the wishlist
|
|
102
110
|
|
|
111
|
+
A customer saves a product they like and finds it again later on their wishlist.
|
|
112
|
+
|
|
113
|
+
## Story
|
|
114
|
+
|
|
115
|
+
1. The customer opens a product and taps "Save for later".
|
|
116
|
+
2. The product shows a filled heart.
|
|
117
|
+

|
|
118
|
+
3. Later, the customer opens their wishlist and sees the product there.
|
|
119
|
+
|
|
103
120
|
## Steps
|
|
104
121
|
|
|
105
122
|
1. page /products/:id
|
|
@@ -116,7 +133,7 @@ who: customer
|
|
|
116
133
|
- invalid input a product id that is not an id → 422
|
|
117
134
|
- not allowed guest → sent to sign in, then back to the product
|
|
118
135
|
- not found the product does not exist → 404
|
|
119
|
-
- duplicate already saved → stays saved, no error
|
|
136
|
+
- duplicate already saved → stays saved, no error (AC-2)
|
|
120
137
|
- limits at most 200 products
|
|
121
138
|
- expiry does not apply: saved products do not expire
|
|
122
139
|
- double submit two taps save once
|
|
@@ -130,6 +147,23 @@ who: customer
|
|
|
130
147
|
- AC-4 [mobile] the product card has a save button
|
|
131
148
|
```
|
|
132
149
|
|
|
150
|
+
**Summary.** The paragraph under the `# Title`: one or two plain sentences saying who does what and
|
|
151
|
+
what they get. A flow with none gets a warning (`GR1030`).
|
|
152
|
+
|
|
153
|
+
**Story.** Optional. Numbered sentences in the user's words, without file names or code, for readers
|
|
154
|
+
who do not read code. Indent a second line to continue a sentence. An image line
|
|
155
|
+
`` under a step attaches a screenshot to it.
|
|
156
|
+
|
|
157
|
+
**Screenshots.** Keep image files in `grimoire/screenshots/` (any subfolders; `.png`, `.jpg`,
|
|
158
|
+
`.jpeg`, `.webp` or `.gif`). Write the path relative to the Markdown file, so it also shows on a git
|
|
159
|
+
host (`../../../screenshots/web/wishlist-saved.png` from a flow file), or start it with
|
|
160
|
+
`/grimoire/screenshots/`. An image outside that folder is a warning (`GR1029`), a missing file too
|
|
161
|
+
(`GR2014`).
|
|
162
|
+
|
|
163
|
+
**Product map.** The Grimoire tab has a Product map for readers who are not developers. They see the
|
|
164
|
+
flow summary, the feature's why and audience, the story in plain words and the screenshots there,
|
|
165
|
+
so write them for a person who has never opened the code.
|
|
166
|
+
|
|
133
167
|
**Steps.** Each step has a kind and the name used in code: `page`, `route`, `mail`,
|
|
134
168
|
`notification`, `job`, `event`, `outside service`. Use `affects` for an effect on another
|
|
135
169
|
feature (`affects catalog/stock`). Warlock checks every name exists. A mail is a `*.mail.ts` or
|
|
@@ -140,7 +174,8 @@ When two sites, or a site and the mobile app, have a page with the same path, na
|
|
|
140
174
|
the path in brackets: `page /support [web-admin]`. The step then looks in that app only (its
|
|
141
175
|
pages, or its screens for a mobile app). Without brackets it looks in the apps the feature lists.
|
|
142
176
|
|
|
143
|
-
**Cases.**
|
|
177
|
+
**Cases.** End a case line with `(AC-n)` (or `(AC-1, AC-2)`) to link it to the criterion that
|
|
178
|
+
proves it; a number the flow does not have is an error (`GR2013`). Answer all eight questions (invalid input, not allowed, not found, duplicate, limits,
|
|
144
179
|
expiry, double submit, outside service down), each with a case or "does not apply" and the
|
|
145
180
|
reason. A flow that skips one gets a finding. Do not invent cases beyond the questions unless the owner described one.
|
|
146
181
|
|
package/ui/grimoire-static.js
CHANGED
|
@@ -104,6 +104,10 @@ function grimoireStaticContext(data, root, rerender) {
|
|
|
104
104
|
else location.hash = next;
|
|
105
105
|
},
|
|
106
106
|
refresh: rerender,
|
|
107
|
+
// Screenshots sit next to index.html, in the same folder layout as grimoire/screenshots/.
|
|
108
|
+
file: (src) => `screenshots/${String(src).split("/").map(encodeURIComponent).join("/")}`,
|
|
109
|
+
shared: false,
|
|
110
|
+
share: null,
|
|
107
111
|
el,
|
|
108
112
|
svg: (tag, attrs = {}, children = []) =>
|
|
109
113
|
build(document.createElementNS(GRIMOIRE_STATIC_SVG, tag), attrs, children),
|