@warlock.js/grimoire 5.57.0 → 5.59.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 +44 -0
- package/esm/apps/check-apps.mjs +11 -5
- package/esm/apps/check-apps.mjs.map +1 -1
- 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 +7 -5
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +85 -39
- 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 +28 -1
- 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/scry.d.mts +26 -6
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +14 -1
- 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 +116 -5
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/feature-map.mjs +149 -0
- package/esm/devtools/feature-map.mjs.map +1 -0
- package/esm/devtools/index.d.mts +28 -2
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +111 -7
- 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 +460 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts +43 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +190 -22
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +24 -7
- 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 +5 -5
- package/esm/ownership/index.d.mts.map +1 -1
- package/esm/ownership/index.mjs +60 -1
- package/esm/ownership/index.mjs.map +1 -1
- 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 +170 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +19 -2
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +159 -24
- 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/actions.mjs +15 -7
- package/esm/warlock/actions.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +42 -4
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/commands.mjs +7 -2
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/logo.mjs +12 -0
- package/esm/warlock/logo.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +51 -15
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/cache.mjs +194 -0
- package/esm/workspace/cache.mjs.map +1 -0
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +7 -3
- 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 +108 -12
- 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 +10 -0
- package/skills/use-the-grimoire/SKILL.md +44 -10
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +61 -6
- package/ui/grimoire-view.js +2133 -316
- package/ui/grimoire.css +1030 -24
- package/ui/product-map.css +785 -0
- package/ui/product-map.js +1265 -0
package/llms-full.txt
CHANGED
|
@@ -98,6 +98,11 @@ folders: [src/app/auth]
|
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
- `origin: inferred` on the README and on each flow. The owner changes it to `confirmed`.
|
|
101
|
+
- **Summaries and stories in plain words.** Write the paragraph under each flow's title (what a user
|
|
102
|
+
does and gets, in one or two sentences) and, where the route and page names make the path clear,
|
|
103
|
+
a `## Story` of numbered sentences in the user's words. Add `audience` and a short `## Why` to
|
|
104
|
+
the README when the code shows who uses the feature and for what. Mark all of it inferred and
|
|
105
|
+
leave a screenshot out unless you can capture it; the owner confirms the wording.
|
|
101
106
|
- Start every feature at `1.0`. Do not reconstruct history; the changelog gets one line under `## Unreleased`
|
|
102
107
|
in the feature's own `CHANGELOG.md` (`grimoire/features/auth/CHANGELOG.md`), never in the README:
|
|
103
108
|
|
|
@@ -263,6 +268,8 @@ layout: site
|
|
|
263
268
|
|
|
264
269
|
The first page a visitor sees.
|
|
265
270
|
|
|
271
|
+

|
|
272
|
+
|
|
266
273
|
## Blocks
|
|
267
274
|
|
|
268
275
|
| Block | Flow | Who sees it | Changes with |
|
|
@@ -296,11 +303,21 @@ flow: catalog/new-arrivals
|
|
|
296
303
|
|
|
297
304
|
# New arrivals on the home page
|
|
298
305
|
|
|
306
|
+

|
|
307
|
+
|
|
299
308
|
- position second row, under Featured products
|
|
300
309
|
- shows a grid of up to 20 products
|
|
301
310
|
- phones one row that scrolls sideways
|
|
302
311
|
```
|
|
303
312
|
|
|
313
|
+
## Screenshots
|
|
314
|
+
|
|
315
|
+
Keep image files in `grimoire/screenshots/` (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`), for example
|
|
316
|
+
`grimoire/screenshots/web/home.png`. Write an image line `` anywhere in a page, screen
|
|
317
|
+
or block file, with the path relative to the Markdown file or starting with `/grimoire/screenshots/`.
|
|
318
|
+
The Product map shows these as "where you see it". An image outside the folder is a warning
|
|
319
|
+
(`GR1029`); a missing file is a warning (`GR2014`).
|
|
320
|
+
|
|
304
321
|
## Where a difference between apps goes
|
|
305
322
|
|
|
306
323
|
| The difference | Goes in |
|
|
@@ -494,11 +511,21 @@ npx warlock grimoire check
|
|
|
494
511
|
| A step names a route, page, mail or job that does not exist | Fix the name in the flow, or the code |
|
|
495
512
|
| A criterion has no test | Write the test, or say in the task why not |
|
|
496
513
|
| A test points at a criterion that does not exist | Fix the `@proves` line |
|
|
514
|
+
| Proofs exist but no test results were found (`GR4009`) | Record results, see below |
|
|
515
|
+
| A proving test the reporter could not match (`GR4010`) | Fix the `@proves` line or the test name |
|
|
497
516
|
| A file has no header, or no feature | `document-a-file` |
|
|
498
517
|
| A file in the feature's folders that no flow reaches | Describe the behaviour in a flow, or delete dead code |
|
|
499
518
|
| A README `updated` older than its newest changelog entry | Reshape the README |
|
|
500
519
|
| A changelog version that does not fit the word (`added` with `2.1`) | Fix the version |
|
|
501
520
|
|
|
521
|
+
Migrations, seeds, commands, the main file, layouts, roots and test helpers only specs import are never reported (`GR3006`); a route step reaches the middleware its route names. Do not try to describe those in a flow.
|
|
522
|
+
|
|
523
|
+
**Recording results.** The check and the devtools tab read test results from
|
|
524
|
+
`grimoire/book/test-results.json`, written by the Grimoire Vitest reporter when the tests run. That
|
|
525
|
+
folder is not committed, so run the tests with the reporter in CI and ship the results file with the
|
|
526
|
+
deploy. To write it elsewhere, pass `grimoireReporter({ file })` and point the devtools panel at it
|
|
527
|
+
with the `testResultsFile` option.
|
|
528
|
+
|
|
502
529
|
Fix every line it prints. Do not finish with problems you caused. Findings on a flow or feature
|
|
503
530
|
with `status: proposed` print with `(expected)` and do not fail the check: leave them until the
|
|
504
531
|
code exists.
|
|
@@ -619,7 +646,7 @@ npx warlock scry --flow catalog/new-arrivals # one flow,
|
|
|
619
646
|
|
|
620
647
|
Add `--json` for machine-readable output. `--impact` lists API routes, pages, flows and features,
|
|
621
648
|
including features that only borrow the file; each list has a count and stops at 20 lines, and `--all`
|
|
622
|
-
prints every line. `--search` ranks
|
|
649
|
+
prints every line. `--search` also reads a flow's summary, story, cases and criteria (`AC-5` works), ranks features and flows above files, and groups hits by type; a hit found by written text shows the part that matched in brackets. Read the flows it names and run their tests after
|
|
623
650
|
your change.
|
|
624
651
|
|
|
625
652
|
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|
|
@@ -627,13 +654,14 @@ in `grimoire/book/app/auth/controllers/login.controller.json`.
|
|
|
627
654
|
|
|
628
655
|
## Commands
|
|
629
656
|
|
|
630
|
-
| Command | Does
|
|
631
|
-
| ------------------------------------------- |
|
|
632
|
-
| `warlock grimoire build` | Builds or refreshes the book. `scry` and `check` do it when it is stale
|
|
633
|
-
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`)
|
|
634
|
-
| `warlock grimoire
|
|
635
|
-
| `warlock grimoire
|
|
636
|
-
| `warlock
|
|
657
|
+
| Command | Does |
|
|
658
|
+
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
659
|
+
| `warlock grimoire build` | Builds or refreshes the book. `scry` and `check` do it when it is stale |
|
|
660
|
+
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`); skipped when the folder is already current (`--force` writes it) |
|
|
661
|
+
| `warlock grimoire build --site --product` | Writes the business export: the Product map only, no file paths, test names or per-file answers |
|
|
662
|
+
| `warlock grimoire check` | Reports broken names, untested criteria, files with no owner. Exit 1 on an error; `--all` lists every warning |
|
|
663
|
+
| `warlock grimoire release <release>` | Writes the collected list into `grimoire/releases/<release>.md` |
|
|
664
|
+
| `warlock explain GR2001` | Explains a finding code |
|
|
637
665
|
|
|
638
666
|
Every finding has a code (`GR2001`) and a fix hint. A finding marked `(expected)` belongs to work
|
|
639
667
|
that is still `proposed`; it does not fail the check.
|
|
@@ -641,6 +669,8 @@ that is still `proposed`; it does not fail the check.
|
|
|
641
669
|
## What to trust
|
|
642
670
|
|
|
643
671
|
- **Exports, imports, importers, routes, middleware, pages:** read from the code. Trust them.
|
|
672
|
+
- **Route middleware:** a route step also reaches the middleware files the matched route names (not the routes file's other imports). Roles that run by being present (migration, seed, command, main, layout, root) and spec-only helpers are not listed as unreached.
|
|
673
|
+
- **Without route facts** (`routes: missing`): route, mail, notification, job and event steps are `found: null` (not checked), not resolved and not failed; `GR5008` skips mail and notification entries.
|
|
644
674
|
- **Files behind a route:** every file the handler can reach through imports. It is not the exact
|
|
645
675
|
call path; open the handler to see which ones it really uses.
|
|
646
676
|
- **Reached from:** only links and redirects written as plain values. `unknown` means look.
|
|
@@ -678,23 +708,54 @@ From `@warlock.js/grimoire` (no dependency on core or web):
|
|
|
678
708
|
release between `COLLECTED_START_MARKER` and `COLLECTED_END_MARKER`.
|
|
679
709
|
- `scanProofs` and `scanProofsInText` read `// @proves` lines; `criterionStatus` turns test
|
|
680
710
|
results into a criterion's status; `CASE_QUESTIONS` lists the questions every flow answers.
|
|
711
|
+
- Flow steps list `entries` (every file the step starts from), `direct` (their direct imports), `files` (what
|
|
712
|
+
runs: type-only imports are not followed) and `typeOnlyFiles` (reached only through type-only imports).
|
|
713
|
+
`importClosure(graph, start, { skipTypeOnly: true })` leaves type-only edges out. `warlock scry --flow --json`
|
|
714
|
+
keeps every list; the MCP tool `grimoire_flow` and the devtools flow route send counts and the first 50 direct
|
|
715
|
+
imports per step, and list one step's files on request (`files: "reachable"` or `"type-only"` with `step`).
|
|
681
716
|
- Helpers: `loadBook`, `readFrontMatter`, `fileGraph`, `importClosure`, `importerClosure`,
|
|
682
717
|
`bookEntryPath`, `bookEntryPaths`, `toPosixPath`, `GRIMOIRE_DIR`, `GRIMOIRE_PATHS`,
|
|
683
718
|
`GRIMOIRE_IGNORE_RULES` (the `.gitignore` lines) and `BOOK_SCHEMA_VERSION`.
|
|
684
719
|
|
|
685
720
|
From `@warlock.js/grimoire/warlock` (needs `@warlock.js/core`): `registerGrimoireCommands` returns
|
|
686
721
|
the `grimoire` and `scry` commands for `cli.commands` in `warlock.config.ts`;
|
|
687
|
-
`createWarlockAdapter` builds the adapter that feeds the book from the inspect report
|
|
722
|
+
`createWarlockAdapter` builds the adapter that feeds the book from the inspect report (it also supplies the
|
|
723
|
+
optional `host()` described below);
|
|
688
724
|
`collectMobileFacts` lists mobile screens from Expo Router file names.
|
|
689
725
|
|
|
726
|
+
A custom `BookAdapter` may add `host(root)`, returning `{ name, version, logo, app }` (the framework's name,
|
|
727
|
+
installed version and a small `data:` logo, and the app's own `{ name, version }`), or `null`. The tab shows the
|
|
728
|
+
framework logo and version in its header and the app name and version at the bottom, in the static export and
|
|
729
|
+
in the shared Product map too; an adapter without `host()` shows nothing. The summary and product answers carry it
|
|
730
|
+
as `host` (`null` when absent); the feature answer's `flows` also carry `steps`, `cases`, `criteria`, `tested` and
|
|
731
|
+
`findings` counts.
|
|
732
|
+
|
|
733
|
+
The devtools feature route (`/features/:feature`) adds three fields for the tabbed page: `map` (the feature map:
|
|
734
|
+
`columns` are each site and mobile app the flows touch, titled by the app's heading, then `api`, then `background`;
|
|
735
|
+
`rows` has one entry per flow with `cells` keyed by column id, each cell a list of chips `{ step, type, label, found,
|
|
736
|
+
app, page, method, path, file }` taken from the steps the book already resolved), `fileGroups` (the own files by module)
|
|
737
|
+
and `proofs` (each flow's criteria with their tests). Each product map feature card carries `strip`: `flows`
|
|
738
|
+
`{ total, shipped }`, `criteria` `{ total, proven, failing, measured }` (`measured` is `false` when tagged tests have no
|
|
739
|
+
recorded results), `screenshots` `{ places, present }` and `findings` `{ errors, warnings }`. The feature and flow pages
|
|
740
|
+
have tabs with their own hash routes: `feature/<id>[/flows|files|findings|tests]` and
|
|
741
|
+
`flow/<feature>/<flow>[/proof|files|findings]`.
|
|
742
|
+
|
|
690
743
|
From `@warlock.js/grimoire/vitest`: `grimoireReporter` records the last result of every test marked
|
|
691
744
|
`// @proves` into `grimoire/book/test-results.json`. Add it to the Vitest `reporters` list.
|
|
745
|
+
`grimoireReporter({ file })` writes to another path (for a deploy that ships CI results); `readTestResults(root, file?)`
|
|
746
|
+
reads it, and the panel option `testResultsFile` and `openGrimoire` option `testResultsFile` point the tab at it.
|
|
747
|
+
The check warns with `GR4009` when `@proves` lines exist and no results were found, and with `GR4010` when the
|
|
748
|
+
reporter could not match a proving test.
|
|
692
749
|
|
|
693
750
|
From `@warlock.js/grimoire/devtools`: `grimoireDevtoolsPanel` (the default export) is the Grimoire
|
|
694
751
|
tab for `@warlock.js/devtools`, listed in `panels` of `src/config/devtools.ts`;
|
|
695
752
|
`exportGrimoireSite` writes the same view as a static site.
|
|
696
753
|
The tab keeps its snapshot until the book changes in production and refreshes it in the background in
|
|
697
|
-
development;
|
|
754
|
+
development; the results file's modified time is part of the change stamp, so new results show without a restart.
|
|
755
|
+
The tab also has a Product map: the features, flows, apps, releases and planned work in plain words, from the written
|
|
756
|
+
files (summaries, `audience`, `## Why`, `## Story`) and the images in `grimoire/screenshots/`. Its routes are
|
|
757
|
+
`/product`, `/product/features/:feature` and `/product/flows/:feature/:flow`; `/check/groups` and `/check?code=`
|
|
758
|
+
give the check by code and a page of one code's findings. Set `ttlMs` with `panels: [["@warlock.js/grimoire/devtools", { ttlMs: 60_000 }]]`.
|
|
698
759
|
|
|
699
760
|
|
|
700
761
|
## write-a-feature `@warlock.js/grimoire/skills/write-a-feature/SKILL.md`
|
|
@@ -763,12 +824,17 @@ version: 3.0
|
|
|
763
824
|
updated: 2026-11-16
|
|
764
825
|
apps: [web-client, mobile]
|
|
765
826
|
folders: [src/app/catalog, src/web/$sites/client/products]
|
|
827
|
+
audience: [shoppers, store staff]
|
|
766
828
|
---
|
|
767
829
|
|
|
768
830
|
# Product catalog
|
|
769
831
|
|
|
770
832
|
Customers browse products, search them and see what is new.
|
|
771
833
|
|
|
834
|
+
## Why
|
|
835
|
+
|
|
836
|
+
Shoppers decide what to buy from the catalog, so it has to be quick to browse and clear about what is new.
|
|
837
|
+
|
|
772
838
|
## Flows
|
|
773
839
|
|
|
774
840
|
- browse-products list and filter products
|
|
@@ -780,6 +846,9 @@ Customers browse products, search them and see what is new.
|
|
|
780
846
|
- affected by orders/place-order (lowers stock)
|
|
781
847
|
```
|
|
782
848
|
|
|
849
|
+
`audience` (optional) lists who the feature is for, in plain words. `## Why` (optional) says why the
|
|
850
|
+
feature exists in a few sentences. Without `audience`, readers use the `who` of the flows.
|
|
851
|
+
|
|
783
852
|
`id` never changes. `folders` are the folders whose files belong to this feature. An entry with a
|
|
784
853
|
code-file extension names one file (`src/web/components/client/home/pricing-table.tsx`), for a
|
|
785
854
|
feature that owns a few files in a folder shared with others. A file entry wins over the folder
|
|
@@ -801,6 +870,15 @@ who: customer
|
|
|
801
870
|
|
|
802
871
|
# Save a product to the wishlist
|
|
803
872
|
|
|
873
|
+
A customer saves a product they like and finds it again later on their wishlist.
|
|
874
|
+
|
|
875
|
+
## Story
|
|
876
|
+
|
|
877
|
+
1. The customer opens a product and taps "Save for later".
|
|
878
|
+
2. The product shows a filled heart.
|
|
879
|
+

|
|
880
|
+
3. Later, the customer opens their wishlist and sees the product there.
|
|
881
|
+
|
|
804
882
|
## Steps
|
|
805
883
|
|
|
806
884
|
1. page /products/:id
|
|
@@ -817,7 +895,7 @@ who: customer
|
|
|
817
895
|
- invalid input a product id that is not an id → 422
|
|
818
896
|
- not allowed guest → sent to sign in, then back to the product
|
|
819
897
|
- not found the product does not exist → 404
|
|
820
|
-
- duplicate already saved → stays saved, no error
|
|
898
|
+
- duplicate already saved → stays saved, no error (AC-2)
|
|
821
899
|
- limits at most 200 products
|
|
822
900
|
- expiry does not apply: saved products do not expire
|
|
823
901
|
- double submit two taps save once
|
|
@@ -831,6 +909,23 @@ who: customer
|
|
|
831
909
|
- AC-4 [mobile] the product card has a save button
|
|
832
910
|
```
|
|
833
911
|
|
|
912
|
+
**Summary.** The paragraph under the `# Title`: one or two plain sentences saying who does what and
|
|
913
|
+
what they get. A flow with none gets a warning (`GR1030`).
|
|
914
|
+
|
|
915
|
+
**Story.** Optional. Numbered sentences in the user's words, without file names or code, for readers
|
|
916
|
+
who do not read code. Indent a second line to continue a sentence. An image line
|
|
917
|
+
`` under a step attaches a screenshot to it.
|
|
918
|
+
|
|
919
|
+
**Screenshots.** Keep image files in `grimoire/screenshots/` (any subfolders; `.png`, `.jpg`,
|
|
920
|
+
`.jpeg`, `.webp` or `.gif`). Write the path relative to the Markdown file, so it also shows on a git
|
|
921
|
+
host (`../../../screenshots/web/wishlist-saved.png` from a flow file), or start it with
|
|
922
|
+
`/grimoire/screenshots/`. An image outside that folder is a warning (`GR1029`), a missing file too
|
|
923
|
+
(`GR2014`).
|
|
924
|
+
|
|
925
|
+
**Product map.** The Grimoire tab has a Product map for readers who are not developers. They see the
|
|
926
|
+
flow summary, the feature's why and audience, the story in plain words and the screenshots there,
|
|
927
|
+
so write them for a person who has never opened the code.
|
|
928
|
+
|
|
834
929
|
**Steps.** Each step has a kind and the name used in code: `page`, `route`, `mail`,
|
|
835
930
|
`notification`, `job`, `event`, `outside service`. Use `affects` for an effect on another
|
|
836
931
|
feature (`affects catalog/stock`). Warlock checks every name exists. A mail is a `*.mail.ts` or
|
|
@@ -841,7 +936,8 @@ When two sites, or a site and the mobile app, have a page with the same path, na
|
|
|
841
936
|
the path in brackets: `page /support [web-admin]`. The step then looks in that app only (its
|
|
842
937
|
pages, or its screens for a mobile app). Without brackets it looks in the apps the feature lists.
|
|
843
938
|
|
|
844
|
-
**Cases.**
|
|
939
|
+
**Cases.** End a case line with `(AC-n)` (or `(AC-1, AC-2)`) to link it to the criterion that
|
|
940
|
+
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,
|
|
845
941
|
expiry, double submit, outside service down), each with a case or "does not apply" and the
|
|
846
942
|
reason. A flow that skips one gets a finding. Do not invent cases beyond the questions unless the owner described one.
|
|
847
943
|
|
package/package.json
CHANGED
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"environment": "server"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@warlock.js/core": "5.
|
|
30
|
-
"@warlock.js/web": "5.
|
|
29
|
+
"@warlock.js/core": "5.59.0",
|
|
30
|
+
"@warlock.js/web": "5.59.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
"@warlock.js/web": {
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"version": "5.
|
|
37
|
+
"version": "5.59.0",
|
|
38
38
|
"type": "module",
|
|
39
39
|
"main": "./esm/index.mjs",
|
|
40
40
|
"module": "./esm/index.mjs",
|
|
@@ -60,6 +60,11 @@ folders: [src/app/auth]
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
- `origin: inferred` on the README and on each flow. The owner changes it to `confirmed`.
|
|
63
|
+
- **Summaries and stories in plain words.** Write the paragraph under each flow's title (what a user
|
|
64
|
+
does and gets, in one or two sentences) and, where the route and page names make the path clear,
|
|
65
|
+
a `## Story` of numbered sentences in the user's words. Add `audience` and a short `## Why` to
|
|
66
|
+
the README when the code shows who uses the feature and for what. Mark all of it inferred and
|
|
67
|
+
leave a screenshot out unless you can capture it; the owner confirms the wording.
|
|
63
68
|
- Start every feature at `1.0`. Do not reconstruct history; the changelog gets one line under `## Unreleased`
|
|
64
69
|
in the feature's own `CHANGELOG.md` (`grimoire/features/auth/CHANGELOG.md`), never in the README:
|
|
65
70
|
|
|
@@ -93,6 +93,8 @@ layout: site
|
|
|
93
93
|
|
|
94
94
|
The first page a visitor sees.
|
|
95
95
|
|
|
96
|
+

|
|
97
|
+
|
|
96
98
|
## Blocks
|
|
97
99
|
|
|
98
100
|
| Block | Flow | Who sees it | Changes with |
|
|
@@ -126,11 +128,21 @@ flow: catalog/new-arrivals
|
|
|
126
128
|
|
|
127
129
|
# New arrivals on the home page
|
|
128
130
|
|
|
131
|
+

|
|
132
|
+
|
|
129
133
|
- position second row, under Featured products
|
|
130
134
|
- shows a grid of up to 20 products
|
|
131
135
|
- phones one row that scrolls sideways
|
|
132
136
|
```
|
|
133
137
|
|
|
138
|
+
## Screenshots
|
|
139
|
+
|
|
140
|
+
Keep image files in `grimoire/screenshots/` (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`), for example
|
|
141
|
+
`grimoire/screenshots/web/home.png`. Write an image line `` anywhere in a page, screen
|
|
142
|
+
or block file, with the path relative to the Markdown file or starting with `/grimoire/screenshots/`.
|
|
143
|
+
The Product map shows these as "where you see it". An image outside the folder is a warning
|
|
144
|
+
(`GR1029`); a missing file is a warning (`GR2014`).
|
|
145
|
+
|
|
134
146
|
## Where a difference between apps goes
|
|
135
147
|
|
|
136
148
|
| The difference | Goes in |
|
|
@@ -79,11 +79,21 @@ 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
|
+
Migrations, seeds, commands, the main file, layouts, roots and test helpers only specs import are never reported (`GR3006`); a route step reaches the middleware its route names. Do not try to describe those in a flow.
|
|
90
|
+
|
|
91
|
+
**Recording results.** The check and the devtools tab read test results from
|
|
92
|
+
`grimoire/book/test-results.json`, written by the Grimoire Vitest reporter when the tests run. That
|
|
93
|
+
folder is not committed, so run the tests with the reporter in CI and ship the results file with the
|
|
94
|
+
deploy. To write it elsewhere, pass `grimoireReporter({ file })` and point the devtools panel at it
|
|
95
|
+
with the `testResultsFile` option.
|
|
96
|
+
|
|
87
97
|
Fix every line it prints. Do not finish with problems you caused. Findings on a flow or feature
|
|
88
98
|
with `status: proposed` print with `(expected)` and do not fail the check: leave them until the
|
|
89
99
|
code exists.
|
|
@@ -61,7 +61,7 @@ npx warlock scry --flow catalog/new-arrivals # one flow,
|
|
|
61
61
|
|
|
62
62
|
Add `--json` for machine-readable output. `--impact` lists API routes, pages, flows and features,
|
|
63
63
|
including features that only borrow the file; each list has a count and stops at 20 lines, and `--all`
|
|
64
|
-
prints every line. `--search` ranks
|
|
64
|
+
prints every line. `--search` also reads a flow's summary, story, cases and criteria (`AC-5` works), ranks features and flows above files, and groups hits by type; a hit found by written text shows the part that matched in brackets. Read the flows it names and run their tests after
|
|
65
65
|
your change.
|
|
66
66
|
|
|
67
67
|
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|
|
@@ -69,13 +69,14 @@ in `grimoire/book/app/auth/controllers/login.controller.json`.
|
|
|
69
69
|
|
|
70
70
|
## Commands
|
|
71
71
|
|
|
72
|
-
| Command | Does
|
|
73
|
-
| ------------------------------------------- |
|
|
74
|
-
| `warlock grimoire build` | Builds or refreshes the book. `scry` and `check` do it when it is stale
|
|
75
|
-
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`)
|
|
76
|
-
| `warlock grimoire
|
|
77
|
-
| `warlock grimoire
|
|
78
|
-
| `warlock
|
|
72
|
+
| Command | Does |
|
|
73
|
+
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `warlock grimoire build` | Builds or refreshes the book. `scry` and `check` do it when it is stale |
|
|
75
|
+
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`); skipped when the folder is already current (`--force` writes it) |
|
|
76
|
+
| `warlock grimoire build --site --product` | Writes the business export: the Product map only, no file paths, test names or per-file answers |
|
|
77
|
+
| `warlock grimoire check` | Reports broken names, untested criteria, files with no owner. Exit 1 on an error; `--all` lists every warning |
|
|
78
|
+
| `warlock grimoire release <release>` | Writes the collected list into `grimoire/releases/<release>.md` |
|
|
79
|
+
| `warlock explain GR2001` | Explains a finding code |
|
|
79
80
|
|
|
80
81
|
Every finding has a code (`GR2001`) and a fix hint. A finding marked `(expected)` belongs to work
|
|
81
82
|
that is still `proposed`; it does not fail the check.
|
|
@@ -83,6 +84,8 @@ that is still `proposed`; it does not fail the check.
|
|
|
83
84
|
## What to trust
|
|
84
85
|
|
|
85
86
|
- **Exports, imports, importers, routes, middleware, pages:** read from the code. Trust them.
|
|
87
|
+
- **Route middleware:** a route step also reaches the middleware files the matched route names (not the routes file's other imports). Roles that run by being present (migration, seed, command, main, layout, root) and spec-only helpers are not listed as unreached.
|
|
88
|
+
- **Without route facts** (`routes: missing`): route, mail, notification, job and event steps are `found: null` (not checked), not resolved and not failed; `GR5008` skips mail and notification entries.
|
|
86
89
|
- **Files behind a route:** every file the handler can reach through imports. It is not the exact
|
|
87
90
|
call path; open the handler to see which ones it really uses.
|
|
88
91
|
- **Reached from:** only links and redirects written as plain values. `unknown` means look.
|
|
@@ -120,20 +123,51 @@ From `@warlock.js/grimoire` (no dependency on core or web):
|
|
|
120
123
|
release between `COLLECTED_START_MARKER` and `COLLECTED_END_MARKER`.
|
|
121
124
|
- `scanProofs` and `scanProofsInText` read `// @proves` lines; `criterionStatus` turns test
|
|
122
125
|
results into a criterion's status; `CASE_QUESTIONS` lists the questions every flow answers.
|
|
126
|
+
- Flow steps list `entries` (every file the step starts from), `direct` (their direct imports), `files` (what
|
|
127
|
+
runs: type-only imports are not followed) and `typeOnlyFiles` (reached only through type-only imports).
|
|
128
|
+
`importClosure(graph, start, { skipTypeOnly: true })` leaves type-only edges out. `warlock scry --flow --json`
|
|
129
|
+
keeps every list; the MCP tool `grimoire_flow` and the devtools flow route send counts and the first 50 direct
|
|
130
|
+
imports per step, and list one step's files on request (`files: "reachable"` or `"type-only"` with `step`).
|
|
123
131
|
- Helpers: `loadBook`, `readFrontMatter`, `fileGraph`, `importClosure`, `importerClosure`,
|
|
124
132
|
`bookEntryPath`, `bookEntryPaths`, `toPosixPath`, `GRIMOIRE_DIR`, `GRIMOIRE_PATHS`,
|
|
125
133
|
`GRIMOIRE_IGNORE_RULES` (the `.gitignore` lines) and `BOOK_SCHEMA_VERSION`.
|
|
126
134
|
|
|
127
135
|
From `@warlock.js/grimoire/warlock` (needs `@warlock.js/core`): `registerGrimoireCommands` returns
|
|
128
136
|
the `grimoire` and `scry` commands for `cli.commands` in `warlock.config.ts`;
|
|
129
|
-
`createWarlockAdapter` builds the adapter that feeds the book from the inspect report
|
|
137
|
+
`createWarlockAdapter` builds the adapter that feeds the book from the inspect report (it also supplies the
|
|
138
|
+
optional `host()` described below);
|
|
130
139
|
`collectMobileFacts` lists mobile screens from Expo Router file names.
|
|
131
140
|
|
|
141
|
+
A custom `BookAdapter` may add `host(root)`, returning `{ name, version, logo, app }` (the framework's name,
|
|
142
|
+
installed version and a small `data:` logo, and the app's own `{ name, version }`), or `null`. The tab shows the
|
|
143
|
+
framework logo and version in its header and the app name and version at the bottom, in the static export and
|
|
144
|
+
in the shared Product map too; an adapter without `host()` shows nothing. The summary and product answers carry it
|
|
145
|
+
as `host` (`null` when absent); the feature answer's `flows` also carry `steps`, `cases`, `criteria`, `tested` and
|
|
146
|
+
`findings` counts.
|
|
147
|
+
|
|
148
|
+
The devtools feature route (`/features/:feature`) adds three fields for the tabbed page: `map` (the feature map:
|
|
149
|
+
`columns` are each site and mobile app the flows touch, titled by the app's heading, then `api`, then `background`;
|
|
150
|
+
`rows` has one entry per flow with `cells` keyed by column id, each cell a list of chips `{ step, type, label, found,
|
|
151
|
+
app, page, method, path, file }` taken from the steps the book already resolved), `fileGroups` (the own files by module)
|
|
152
|
+
and `proofs` (each flow's criteria with their tests). Each product map feature card carries `strip`: `flows`
|
|
153
|
+
`{ total, shipped }`, `criteria` `{ total, proven, failing, measured }` (`measured` is `false` when tagged tests have no
|
|
154
|
+
recorded results), `screenshots` `{ places, present }` and `findings` `{ errors, warnings }`. The feature and flow pages
|
|
155
|
+
have tabs with their own hash routes: `feature/<id>[/flows|files|findings|tests]` and
|
|
156
|
+
`flow/<feature>/<flow>[/proof|files|findings]`.
|
|
157
|
+
|
|
132
158
|
From `@warlock.js/grimoire/vitest`: `grimoireReporter` records the last result of every test marked
|
|
133
159
|
`// @proves` into `grimoire/book/test-results.json`. Add it to the Vitest `reporters` list.
|
|
160
|
+
`grimoireReporter({ file })` writes to another path (for a deploy that ships CI results); `readTestResults(root, file?)`
|
|
161
|
+
reads it, and the panel option `testResultsFile` and `openGrimoire` option `testResultsFile` point the tab at it.
|
|
162
|
+
The check warns with `GR4009` when `@proves` lines exist and no results were found, and with `GR4010` when the
|
|
163
|
+
reporter could not match a proving test.
|
|
134
164
|
|
|
135
165
|
From `@warlock.js/grimoire/devtools`: `grimoireDevtoolsPanel` (the default export) is the Grimoire
|
|
136
166
|
tab for `@warlock.js/devtools`, listed in `panels` of `src/config/devtools.ts`;
|
|
137
167
|
`exportGrimoireSite` writes the same view as a static site.
|
|
138
168
|
The tab keeps its snapshot until the book changes in production and refreshes it in the background in
|
|
139
|
-
development;
|
|
169
|
+
development; the results file's modified time is part of the change stamp, so new results show without a restart.
|
|
170
|
+
The tab also has a Product map: the features, flows, apps, releases and planned work in plain words, from the written
|
|
171
|
+
files (summaries, `audience`, `## Why`, `## Story`) and the images in `grimoire/screenshots/`. Its routes are
|
|
172
|
+
`/product`, `/product/features/:feature` and `/product/flows/:feature/:flow`; `/check/groups` and `/check?code=`
|
|
173
|
+
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
|
@@ -28,26 +28,75 @@ function grimoireStaticApi(data) {
|
|
|
28
28
|
const text = (params.get("q") ?? "").trim().toLowerCase();
|
|
29
29
|
const limit = Number(params.get("limit")) || 20;
|
|
30
30
|
const hits = [];
|
|
31
|
+
const wordsOf = (value) =>
|
|
32
|
+
value
|
|
33
|
+
.toLowerCase()
|
|
34
|
+
.split(/[^a-z0-9]+/)
|
|
35
|
+
.filter(Boolean);
|
|
36
|
+
const tokens = wordsOf(text);
|
|
31
37
|
for (const item of data.search) {
|
|
32
38
|
const id = item.id.toLowerCase();
|
|
33
39
|
const detail = (item.detail ?? "").toLowerCase();
|
|
34
|
-
const
|
|
40
|
+
const written = item.type === "feature" || item.type === "flow";
|
|
41
|
+
const body = written && item.text ? wordsOf(item.text) : [];
|
|
42
|
+
// Written text matches whole words (a short token must equal a word), so "5" finds AC-5 and not AC-15.
|
|
43
|
+
const inBody =
|
|
44
|
+
tokens.length > 0 &&
|
|
45
|
+
body.length > 0 &&
|
|
46
|
+
tokens.every((token) =>
|
|
47
|
+
body.some((word) => (token.length >= 3 ? word.startsWith(token) : word === token)),
|
|
48
|
+
);
|
|
49
|
+
let score =
|
|
35
50
|
id === text
|
|
36
51
|
? 4
|
|
37
52
|
: id.startsWith(text)
|
|
38
53
|
? 3
|
|
39
54
|
: id.includes(text)
|
|
40
55
|
? 2
|
|
41
|
-
: detail.includes(text)
|
|
56
|
+
: detail.includes(text) || inBody
|
|
42
57
|
? 1
|
|
43
58
|
: 0;
|
|
44
|
-
|
|
59
|
+
// Written content ranks above files and exports of the same match.
|
|
60
|
+
if (text && score && written) score += 2;
|
|
61
|
+
if (text && score) hits.push({ ...item, text: undefined, score });
|
|
45
62
|
}
|
|
46
63
|
hits.sort((left, right) => right.score - left.score || left.id.localeCompare(right.id));
|
|
64
|
+
// Features and flows keep a share of the limit, so files never push them out; the list is grouped by type.
|
|
65
|
+
const order = [
|
|
66
|
+
"feature",
|
|
67
|
+
"flow",
|
|
68
|
+
"block",
|
|
69
|
+
"page",
|
|
70
|
+
"screen",
|
|
71
|
+
"route",
|
|
72
|
+
"mail",
|
|
73
|
+
"job",
|
|
74
|
+
"file",
|
|
75
|
+
"export",
|
|
76
|
+
"task",
|
|
77
|
+
];
|
|
78
|
+
const writtenHits = hits
|
|
79
|
+
.filter((hit) => hit.type === "feature" || hit.type === "flow")
|
|
80
|
+
.slice(0, Math.max(1, Math.ceil(limit * 0.75)));
|
|
81
|
+
const chosen = new Set(writtenHits);
|
|
82
|
+
for (const hit of hits) {
|
|
83
|
+
if (chosen.size >= limit) break;
|
|
84
|
+
chosen.add(hit);
|
|
85
|
+
}
|
|
86
|
+
const counts = {};
|
|
87
|
+
for (const hit of hits) counts[hit.type] = (counts[hit.type] ?? 0) + 1;
|
|
47
88
|
return {
|
|
48
89
|
type: "search",
|
|
49
90
|
text,
|
|
50
|
-
|
|
91
|
+
counts,
|
|
92
|
+
hits: [...chosen]
|
|
93
|
+
.sort(
|
|
94
|
+
(left, right) =>
|
|
95
|
+
order.indexOf(left.type) - order.indexOf(right.type) ||
|
|
96
|
+
right.score - left.score ||
|
|
97
|
+
left.id.localeCompare(right.id),
|
|
98
|
+
)
|
|
99
|
+
.map(({ text: _text, ...hit }) => hit),
|
|
51
100
|
routes: data.routes.summary?.routes ?? "cached",
|
|
52
101
|
notes: [],
|
|
53
102
|
};
|
|
@@ -80,8 +129,10 @@ function grimoireStaticContext(data, root, rerender) {
|
|
|
80
129
|
if (value == null) continue;
|
|
81
130
|
if (key === "class") node.setAttribute("class", value);
|
|
82
131
|
else if (key === "text") node.textContent = value;
|
|
83
|
-
else if (
|
|
84
|
-
|
|
132
|
+
else if (/^on[a-z]+$/i.test(key)) {
|
|
133
|
+
// Only a real function becomes a listener; a string `on*` attribute is never set (it would be script).
|
|
134
|
+
if (typeof value === "function") node.addEventListener(key.slice(2).toLowerCase(), value);
|
|
135
|
+
} else node.setAttribute(key, value);
|
|
85
136
|
}
|
|
86
137
|
};
|
|
87
138
|
const build = (node, attrs, children) => {
|
|
@@ -104,6 +155,10 @@ function grimoireStaticContext(data, root, rerender) {
|
|
|
104
155
|
else location.hash = next;
|
|
105
156
|
},
|
|
106
157
|
refresh: rerender,
|
|
158
|
+
// Screenshots sit next to index.html, in the same folder layout as grimoire/screenshots/.
|
|
159
|
+
file: (src) => `screenshots/${String(src).split("/").map(encodeURIComponent).join("/")}`,
|
|
160
|
+
shared: false,
|
|
161
|
+
share: null,
|
|
107
162
|
el,
|
|
108
163
|
svg: (tag, attrs = {}, children = []) =>
|
|
109
164
|
build(document.createElementNS(GRIMOIRE_STATIC_SVG, tag), attrs, children),
|