@warlock.js/grimoire 0.0.0-stage → 5.56.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 +52 -0
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/esm/apps/check-apps.mjs +207 -0
- package/esm/apps/check-apps.mjs.map +1 -0
- package/esm/apps/index.mjs +4 -0
- package/esm/apps/match-apps.d.mts +12 -0
- package/esm/apps/match-apps.d.mts.map +1 -0
- package/esm/apps/match-apps.mjs +30 -0
- package/esm/apps/match-apps.mjs.map +1 -0
- package/esm/book/build.d.mts +14 -0
- package/esm/book/build.d.mts.map +1 -0
- package/esm/book/build.mjs +300 -0
- package/esm/book/build.mjs.map +1 -0
- package/esm/book/index.mjs +5 -0
- package/esm/book/io.mjs +162 -0
- package/esm/book/io.mjs.map +1 -0
- package/esm/book/normalize.mjs +71 -0
- package/esm/book/normalize.mjs.map +1 -0
- package/esm/book/render.mjs +262 -0
- package/esm/book/render.mjs.map +1 -0
- package/esm/book/write.d.mts +12 -0
- package/esm/book/write.d.mts.map +1 -0
- package/esm/book/write.mjs +90 -0
- package/esm/book/write.mjs.map +1 -0
- package/esm/bookmap/build.d.mts +21 -0
- package/esm/bookmap/build.d.mts.map +1 -0
- package/esm/bookmap/build.mjs +272 -0
- package/esm/bookmap/build.mjs.map +1 -0
- package/esm/bookmap/index.mjs +5 -0
- package/esm/bookmap/steps.mjs +137 -0
- package/esm/bookmap/steps.mjs.map +1 -0
- package/esm/bookmap/write.d.mts +19 -0
- package/esm/bookmap/write.d.mts.map +1 -0
- package/esm/bookmap/write.mjs +118 -0
- package/esm/bookmap/write.mjs.map +1 -0
- package/esm/check/check-grimoire.d.mts +7 -0
- package/esm/check/check-grimoire.d.mts.map +1 -0
- package/esm/check/check-grimoire.mjs +98 -0
- package/esm/check/check-grimoire.mjs.map +1 -0
- package/esm/check/format-check-report.d.mts +20 -0
- package/esm/check/format-check-report.d.mts.map +1 -0
- package/esm/check/format-check-report.mjs +55 -0
- package/esm/check/format-check-report.mjs.map +1 -0
- package/esm/check/index.mjs +4 -0
- package/esm/check/rules/book-notes.mjs +18 -0
- package/esm/check/rules/book-notes.mjs.map +1 -0
- package/esm/check/rules/criteria.mjs +48 -0
- package/esm/check/rules/criteria.mjs.map +1 -0
- package/esm/check/rules/links.mjs +196 -0
- package/esm/check/rules/links.mjs.map +1 -0
- package/esm/check/rules/lookup.mjs +41 -0
- package/esm/check/rules/lookup.mjs.map +1 -0
- package/esm/check/rules/source-files.mjs +119 -0
- package/esm/check/rules/source-files.mjs.map +1 -0
- package/esm/check/rules/versions.mjs +92 -0
- package/esm/check/rules/versions.mjs.map +1 -0
- package/esm/codes/codes.d.mts +182 -0
- package/esm/codes/codes.d.mts.map +1 -0
- package/esm/codes/codes.mjs +111 -0
- package/esm/codes/codes.mjs.map +1 -0
- package/esm/codes/index.d.mts +33 -0
- package/esm/codes/index.d.mts.map +1 -0
- package/esm/codes/index.mjs +63 -0
- package/esm/codes/index.mjs.map +1 -0
- package/esm/contracts/adapter.d.mts +209 -0
- package/esm/contracts/adapter.d.mts.map +1 -0
- package/esm/contracts/book.d.mts +233 -0
- package/esm/contracts/book.d.mts.map +1 -0
- package/esm/contracts/book.mjs +7 -0
- package/esm/contracts/book.mjs.map +1 -0
- package/esm/contracts/bookmap.d.mts +175 -0
- package/esm/contracts/bookmap.d.mts.map +1 -0
- package/esm/contracts/findings.d.mts +79 -0
- package/esm/contracts/findings.d.mts.map +1 -0
- package/esm/contracts/location.d.mts +22 -0
- package/esm/contracts/location.d.mts.map +1 -0
- package/esm/contracts/releases.d.mts +53 -0
- package/esm/contracts/releases.d.mts.map +1 -0
- package/esm/contracts/scry.d.mts +143 -0
- package/esm/contracts/scry.d.mts.map +1 -0
- package/esm/contracts/snapshot.d.mts +52 -0
- package/esm/contracts/snapshot.d.mts.map +1 -0
- package/esm/contracts/test-results.d.mts +63 -0
- package/esm/contracts/test-results.d.mts.map +1 -0
- package/esm/contracts/written.d.mts +363 -0
- package/esm/contracts/written.d.mts.map +1 -0
- package/esm/contracts/written.mjs +19 -0
- package/esm/contracts/written.mjs.map +1 -0
- package/esm/devtools/data.mjs +171 -0
- package/esm/devtools/data.mjs.map +1 -0
- package/esm/devtools/graphs.mjs +142 -0
- package/esm/devtools/graphs.mjs.map +1 -0
- package/esm/devtools/index.d.mts +42 -0
- package/esm/devtools/index.d.mts.map +1 -0
- package/esm/devtools/index.mjs +103 -0
- package/esm/devtools/index.mjs.map +1 -0
- package/esm/devtools/site.d.mts +26 -0
- package/esm/devtools/site.d.mts.map +1 -0
- package/esm/devtools/site.mjs +190 -0
- package/esm/devtools/site.mjs.map +1 -0
- package/esm/devtools/snapshot-source.mjs +70 -0
- package/esm/devtools/snapshot-source.mjs.map +1 -0
- package/esm/front-matter/index.d.mts +33 -0
- package/esm/front-matter/index.d.mts.map +1 -0
- package/esm/front-matter/index.mjs +130 -0
- package/esm/front-matter/index.mjs.map +1 -0
- package/esm/graph/index.d.mts +15 -0
- package/esm/graph/index.d.mts.map +1 -0
- package/esm/graph/index.mjs +42 -0
- package/esm/graph/index.mjs.map +1 -0
- package/esm/index.d.mts +33 -0
- package/esm/index.mjs +33 -0
- package/esm/ownership/index.d.mts +8 -0
- package/esm/ownership/index.d.mts.map +1 -0
- package/esm/ownership/index.mjs +137 -0
- package/esm/ownership/index.mjs.map +1 -0
- package/esm/paths/index.d.mts +58 -0
- package/esm/paths/index.d.mts.map +1 -0
- package/esm/paths/index.mjs +137 -0
- package/esm/paths/index.mjs.map +1 -0
- package/esm/proves/index.mjs +3 -0
- package/esm/proves/scan-proofs.d.mts +22 -0
- package/esm/proves/scan-proofs.d.mts.map +1 -0
- package/esm/proves/scan-proofs.mjs +214 -0
- package/esm/proves/scan-proofs.mjs.map +1 -0
- package/esm/releases/index.d.mts +29 -0
- package/esm/releases/index.d.mts.map +1 -0
- package/esm/releases/index.mjs +157 -0
- package/esm/releases/index.mjs.map +1 -0
- package/esm/scry/format.d.mts +14 -0
- package/esm/scry/format.d.mts.map +1 -0
- package/esm/scry/format.mjs +193 -0
- package/esm/scry/format.mjs.map +1 -0
- package/esm/scry/index.mjs +5 -0
- package/esm/scry/parse.d.mts +10 -0
- package/esm/scry/parse.d.mts.map +1 -0
- package/esm/scry/parse.mjs +108 -0
- package/esm/scry/parse.mjs.map +1 -0
- package/esm/scry/query.d.mts +11 -0
- package/esm/scry/query.d.mts.map +1 -0
- package/esm/scry/query.mjs +457 -0
- package/esm/scry/query.mjs.map +1 -0
- package/esm/tasks/index.mjs +116 -0
- package/esm/tasks/index.mjs.map +1 -0
- package/esm/test-results/criterion-status.d.mts +15 -0
- package/esm/test-results/criterion-status.d.mts.map +1 -0
- package/esm/test-results/criterion-status.mjs +17 -0
- package/esm/test-results/criterion-status.mjs.map +1 -0
- package/esm/test-results/index.d.mts +8 -0
- package/esm/test-results/index.d.mts.map +1 -0
- package/esm/test-results/index.mjs +124 -0
- package/esm/test-results/index.mjs.map +1 -0
- package/esm/vitest/index.d.mts +15 -0
- package/esm/vitest/index.d.mts.map +1 -0
- package/esm/vitest/index.mjs +146 -0
- package/esm/vitest/index.mjs.map +1 -0
- package/esm/warlock/actions.mjs +265 -0
- package/esm/warlock/actions.mjs.map +1 -0
- package/esm/warlock/adapter.d.mts +28 -0
- package/esm/warlock/adapter.d.mts.map +1 -0
- package/esm/warlock/adapter.mjs +377 -0
- package/esm/warlock/adapter.mjs.map +1 -0
- package/esm/warlock/commands.d.mts +15 -0
- package/esm/warlock/commands.d.mts.map +1 -0
- package/esm/warlock/commands.mjs +199 -0
- package/esm/warlock/commands.mjs.map +1 -0
- package/esm/warlock/index.d.mts +4 -0
- package/esm/warlock/index.mjs +5 -0
- package/esm/warlock/mcp-tools.mjs +247 -0
- package/esm/warlock/mcp-tools.mjs.map +1 -0
- package/esm/warlock/mobile-facts.d.mts +32 -0
- package/esm/warlock/mobile-facts.d.mts.map +1 -0
- package/esm/warlock/mobile-facts.mjs +185 -0
- package/esm/warlock/mobile-facts.mjs.map +1 -0
- package/esm/workspace/index.d.mts +11 -0
- package/esm/workspace/index.d.mts.map +1 -0
- package/esm/workspace/index.mjs +122 -0
- package/esm/workspace/index.mjs.map +1 -0
- package/esm/written/apps.mjs +227 -0
- package/esm/written/apps.mjs.map +1 -0
- package/esm/written/features.mjs +400 -0
- package/esm/written/features.mjs.map +1 -0
- package/esm/written/fields.mjs +173 -0
- package/esm/written/fields.mjs.map +1 -0
- package/esm/written/index.mjs +3 -0
- package/esm/written/lists.mjs +68 -0
- package/esm/written/lists.mjs.map +1 -0
- package/esm/written/markdown.mjs +173 -0
- package/esm/written/markdown.mjs.map +1 -0
- package/esm/written/parse-grimoire.d.mts +20 -0
- package/esm/written/parse-grimoire.d.mts.map +1 -0
- package/esm/written/parse-grimoire.mjs +552 -0
- package/esm/written/parse-grimoire.mjs.map +1 -0
- package/esm/written/sink.mjs +65 -0
- package/esm/written/sink.mjs.map +1 -0
- package/esm/written/tasks-releases.mjs +166 -0
- package/esm/written/tasks-releases.mjs.map +1 -0
- package/llms-full.txt +869 -0
- package/llms.txt +15 -0
- package/package.json +66 -4
- package/skills/backfill-a-grimoire/SKILL.md +128 -0
- package/skills/describe-an-app/SKILL.md +162 -0
- package/skills/document-a-file/SKILL.md +75 -0
- package/skills/index.md +26 -0
- package/skills/record-a-change/SKILL.md +139 -0
- package/skills/use-the-grimoire/SKILL.md +137 -0
- package/skills/write-a-feature/SKILL.md +168 -0
- package/ui/grimoire-static.js +136 -0
- package/ui/grimoire-view.js +1005 -0
- package/ui/grimoire.css +88 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog — @warlock.js/grimoire
|
|
2
|
+
|
|
3
|
+
`@warlock.js/grimoire` is new in 5.55.0 and experimental: its file layout, `GR` codes and API may change in any release until it is marked stable.
|
|
4
|
+
|
|
5
|
+
## 5.56.0 - 2026-11-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- The Grimoire tab works in the devtools production monitor. It is read-only there: it opens the book without writing any file. `GrimoireDevtoolsPanel` gains `production`, and `GrimoirePanelContext` gains `mode`.
|
|
10
|
+
|
|
11
|
+
## 5.55.0 - 2026-11-17
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `parseGrimoire(root)` reads every agent-written file under `grimoire/`: features, changelogs, flows, version briefs, apps, layouts, pages, screens, blocks, tasks and releases. It keeps the file and line of each value, and reports a broken structure as a `GR1001`–`GR1028` finding instead of throwing. CRLF files, `*` bullets, tabs, tables without outer pipes and lists a Markdown formatter has collapsed to one space are read too. Written files are read a few at a time, and a task `Brief:` outside `grimoire/` is reported and never looked up.
|
|
16
|
+
- `buildBook()` writes the book to `grimoire/book/`: one JSON entry per source file, an `index.md` summary per module, `app/routes.json`, the page list of each site and the screen list of each mobile app.
|
|
17
|
+
- `buildBook()` hashes a source file only when its size or modification time changed. A run with no changes calls no adapter and writes nothing.
|
|
18
|
+
- `buildBook()` caches route facts. It reads the routes again only when a routes file, something it imports, a config file or a mail, job, event or notification file changes, or when called with `routes: "fresh"`.
|
|
19
|
+
- `buildBook()` writes each file atomically (book maps and indexes too), rewrites only the entries that changed and removes the entries of deleted files.
|
|
20
|
+
- `loadBook()` reads the book without an adapter.
|
|
21
|
+
- `features/<feature>/bookmap.json` lists the files a feature owns, the files it borrows, its routes, its pages per app and the files no flow reaches.
|
|
22
|
+
- `flows/<flow>.bookmap.json` lists the files behind each step, each criterion's tests with their last result, and the blocks that show the flow.
|
|
23
|
+
- `features/index.json` and `tasks/index.json` are rewritten only when their content changes.
|
|
24
|
+
- `openGrimoire()` loads the whole book in one call. Pass `write: false` to compute it in memory.
|
|
25
|
+
- `warlock grimoire check` reports names that point at nothing (routes, pages, mails, jobs, events, notifications, flows, apps and criteria), source files without a header or a feature (a `@feature` tag may have text after the id, and a `folders` entry may start with `./`), files no flow reaches, criteria without a test, `@proves` lines that name nothing, and README versions and dates that differ from the changelog.
|
|
26
|
+
- Findings on proposed work show as expected and never fail the check. Every `GR` code is listed in the docs.
|
|
27
|
+
- `warlock grimoire build` (with `--force`, and `--site [--out]` for a static site) writes the book. `--out` must be a folder inside the project, not the project folder itself (`GR9006`). Route steps in the check match like `warlock scry --route`: `:id` and `[id]` are the same, a trailing `/` is ignored and the method may be in any case. The build summary counts open and waiting tasks separately.
|
|
28
|
+
- `warlock grimoire check` exits with 1 only on unexpected errors. The text shows every error, and for each code with more than five warnings the first five and a count; `--all` lists every finding and `--json` is always complete. `build` and `check` end with the book state and the time, after the app's own boot output.
|
|
29
|
+
- `warlock scry --impact` counts each list in its heading and stops a long list at 20 lines with "… and N more"; `--all` prints every line and `--json` stays complete.
|
|
30
|
+
- `warlock scry --search` ranks exact name or path, prefix, whole word, substring, header sentence and fuzzy matches in that order, then by type.
|
|
31
|
+
- The book and its freshness fingerprint cover code files only (plus `package.json` and config files for the route cache); images, fonts and certificates are not listed.
|
|
32
|
+
- `warlock grimoire release <version>` writes the changelog entries stamped with that version between the markers of `grimoire/releases/<version>.md`. It never changes a feature changelog or a version brief, and refuses a release file with two collected lists.
|
|
33
|
+
- `warlock scry` answers file, impact, route, feature, flow and search questions, with per-criterion test status for a flow. A file answer has the same `packages` as its book entry, and its JSON includes `bookEntry`. It prints compact text, or JSON with `--json`.
|
|
34
|
+
- The `grimoire_*` MCP tools answer the same questions as `warlock scry`.
|
|
35
|
+
- File questions never boot the app. `build` and `check` read the routes again only when they changed.
|
|
36
|
+
- `registerGrimoireCommands()` registers the commands. Add it to `cli: { commands: [...] }` in `warlock.config.ts`.
|
|
37
|
+
- `warlock explain GR2001` describes any Grimoire code.
|
|
38
|
+
- `createWarlockAdapter()` builds the book from the facts of `warlock inspect`. For a mobile app it reads only the source folders, not `android/`, `ios/` or build output, and the manifest records the installed `@warlock.js/core` version, so a core upgrade rebuilds the book. Mobile screens are listed in the same order on every machine.
|
|
39
|
+
- Task and release checks report the problems in `GR6001`–`GR6003` and `GR7001`–`GR7005`.
|
|
40
|
+
- The apps check (`GR5001`–`GR5009`) covers blocks, conditions, pages, layouts, screens, entry points, uncovered sites and mobile apps.
|
|
41
|
+
- Mobile screens are read from the Expo Router file names. When a mobile app defines its navigation in code, the agent declares its screens in `grimoire/apps/<app>/screens/`.
|
|
42
|
+
- `@warlock.js/grimoire/vitest` exports a Vitest reporter. It records the last result (pass, fail or skipped) of every test marked `// @proves <feature>/<flow> AC-n` in `grimoire/book/test-results.json`, and merges the results of partial runs, keeping the results of test files that had not started when a run stopped. Proof lines are read from a few test files at a time.
|
|
43
|
+
- The reporter marks a result older than its test file as stale. `warlock grimoire check` reports failing (`GR4006`), stale (`GR4007`) and not-run (`GR4008`) criteria.
|
|
44
|
+
- A Grimoire tab for the devtools dashboard, registered with `panels: ["@warlock.js/grimoire/devtools"]`. It has one search box across flows, blocks, routes, files and tasks, and views for features, flows, pages, tasks, releases and the check report. It also shows small graphs of a file, a feature, a page and module coupling. It keeps the generated book up to date from the cached routes, never boots the app and never changes an agent-written file; requests that arrive together share one load, and a slow open is reused for a while. A task waiting for approval is listed only under "Waiting for approval".
|
|
45
|
+
- `exportGrimoireSite()` writes the same tab as one static `index.html` for people without the app running. It accepts an absolute `outDir`, and the page does not contain the project's absolute path.
|
|
46
|
+
- Six agent skills (`use-the-grimoire`, `write-a-feature`, `record-a-change`, `describe-an-app`, `document-a-file` and `backfill-a-grimoire`), a skills index, and a README that describes the install and which files Grimoire owns.
|
|
47
|
+
- A flow can name a mail by any `*.mail.ts` or `*.email.ts` file, or a file in a `mails/` or `emails/` folder. A `job` step can name a queue job (`defineJob()`), a scheduled task or a `*.job.ts` file, and `warlock scry --search` finds mails and jobs by name.
|
|
48
|
+
- A page step can name its app, `page /support [web-admin]`, for pages that share a path on two sites or a site and a mobile app. The step looks only in that app; an unknown app is `GR2008` and an app the feature does not list is `GR2009`.
|
|
49
|
+
- A feature `folders` entry with a code-file extension owns that one file. It wins over a folder of another feature, and a missing file is `GR3005`.
|
|
50
|
+
- `origin: inferred` or `confirmed` is allowed on an app README, a layout, a page and a screen, as on features and flows.
|
|
51
|
+
- `GR1004` lists the allowed task statuses, and the skills name `waiting for approval` as the status of a task that needs the owner's answer.
|
|
52
|
+
- The `backfill-a-grimoire` skill says where the changelog line goes, how to write a case the code answers by doing nothing, what starts a flow, and that "does not apply" lines in read-only flows are expected. `describe-an-app` says that "Who sees it" is checked and "Changes with" is free text.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Hassan Zohdy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @warlock.js/grimoire
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Experimental.** The structure of the written files and the commands may still change before
|
|
4
|
+
> they are declared stable.
|
|
5
|
+
|
|
6
|
+
A project map for Warlock.js apps, for AI agents and developers. Warlock writes a **book** of what
|
|
7
|
+
is in the code: one entry per source file, the routes, the pages of each site and the screens of a
|
|
8
|
+
mobile app. Agents write what the product does (**features** and their **flows**), where users
|
|
9
|
+
meet it (**apps**: sites, mobile apps, pages and blocks) and the work (**tasks** and
|
|
10
|
+
**releases**), all in a visible `grimoire/` folder. The written files point into the book by name,
|
|
11
|
+
and a read-only check reports every name that no longer exists.
|
|
12
|
+
|
|
13
|
+
New Warlock.js apps include Grimoire already. In an existing app, `warlock add grimoire` installs the
|
|
14
|
+
package, registers the commands in `warlock.config.ts`, adds the generated files to `.gitignore`,
|
|
15
|
+
mounts the devtools tab and, when the app runs Vitest, adds `grimoireReporter()`.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx warlock add grimoire
|
|
19
|
+
npx warlock grimoire build
|
|
20
|
+
npx warlock scry src/app/catalog/services/new-arrivals.service.ts
|
|
21
|
+
npx warlock grimoire check
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
grimoire/
|
|
26
|
+
book/ generated by Warlock, not in git
|
|
27
|
+
features/ what the product does: README, CHANGELOG, flows, version briefs
|
|
28
|
+
apps/ sites and mobile apps: conditions, layouts, pages, blocks
|
|
29
|
+
tasks/ open and done work, one file per task
|
|
30
|
+
releases/ one file per release: the agent's brief and the collected changes
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Entries:
|
|
34
|
+
|
|
35
|
+
- `@warlock.js/grimoire`: the framework-neutral parts (written-file parser, book, check, scry).
|
|
36
|
+
- `@warlock.js/grimoire/warlock`: the Warlock adapter and the `grimoire` and `scry` commands.
|
|
37
|
+
- `@warlock.js/grimoire/vitest`: a Vitest reporter that records which acceptance criteria pass.
|
|
38
|
+
- `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools dashboard.
|
|
39
|
+
|
|
40
|
+
Docs: https://warlock.js.org/v/latest/grimoire/
|
|
41
|
+
|
|
42
|
+
## Who writes what
|
|
43
|
+
|
|
44
|
+
| | Written by |
|
|
45
|
+
| ---------------------------------------------------------------- | --------------------------------------------------------- |
|
|
46
|
+
| `grimoire/book/`, `index.json`, `bookmap.json`, `*.bookmap.json` | Warlock. Never edit; not in git |
|
|
47
|
+
| Features, flows, apps, tasks, release briefs, changelogs | The agent (or you) |
|
|
48
|
+
| The collected list in a release file | `warlock grimoire release <version>`, between two markers |
|
|
49
|
+
|
|
50
|
+
Warlock never edits a file an agent wrote. The agent writes release numbers and dates into the
|
|
51
|
+
feature changelogs and the release brief, then runs the release command.
|
|
52
|
+
|
|
53
|
+
## Skills
|
|
54
|
+
|
|
55
|
+
The package ships skills for agents: `use-the-grimoire`, `write-a-feature`, `record-a-change`,
|
|
56
|
+
`describe-an-app`, `document-a-file` and `backfill-a-grimoire`.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { createFinding } from "../codes/index.mjs";
|
|
2
|
+
import { toPosixPath } from "../paths/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/grimoire/src/apps/check-apps.ts
|
|
5
|
+
/**
|
|
6
|
+
* GR5001–GR5009: the written apps against the sites, pages, screens, flows
|
|
7
|
+
* and conditions they mention.
|
|
8
|
+
*/
|
|
9
|
+
/** The feature and flow a block row points at, split from `<feature>/<flow>`. */
|
|
10
|
+
function flowSubject(flow) {
|
|
11
|
+
if (!flow) return {
|
|
12
|
+
feature: null,
|
|
13
|
+
flow: null
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
feature: flow.split("/")[0] ?? null,
|
|
17
|
+
flow
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The flow all blocks of a page share, else their feature when they share one, else nothing. */
|
|
21
|
+
function pageSubject(page) {
|
|
22
|
+
const refs = [...new Set(page.blocks.map((row) => row.flow).filter((ref) => ref !== null))];
|
|
23
|
+
if (refs.length === 1) return flowSubject(refs[0] ?? null);
|
|
24
|
+
const features = [...new Set(refs.map((ref) => ref.split("/")[0] ?? ""))];
|
|
25
|
+
return {
|
|
26
|
+
feature: features.length === 1 ? features[0] ?? null : null,
|
|
27
|
+
flow: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** A route as the router and the page graph compare it: `[id]` and `:id` are one parameter. */
|
|
31
|
+
function normalizeRoute(route) {
|
|
32
|
+
const trimmed = toPosixPath(route.trim()).replace(/\[\.\.\.(\w+)\]/g, ":$1*").replace(/\[(\w+)\]/g, ":$1").replace(/\/+$/, "");
|
|
33
|
+
return trimmed === "" ? "/" : trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
34
|
+
}
|
|
35
|
+
/** The id of a block file for a table row: `New arrivals` → `new-arrivals`. */
|
|
36
|
+
function blockSlug(block) {
|
|
37
|
+
return block.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
38
|
+
}
|
|
39
|
+
function pagesOf(app) {
|
|
40
|
+
return [...app.pages, ...app.screens];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* GR5001–GR5009. Read-only. Pages and screens are compared with the adapter's
|
|
44
|
+
* facts only when the app matched a site or mobile app (`GR5005` otherwise).
|
|
45
|
+
*/
|
|
46
|
+
function checkApps(snapshot) {
|
|
47
|
+
const findings = [];
|
|
48
|
+
const facts = snapshot.book.facts;
|
|
49
|
+
const flows = /* @__PURE__ */ new Set();
|
|
50
|
+
for (const feature of snapshot.written.features) for (const flow of feature.flows) flows.add(`${feature.id}/${flow.id.value}`);
|
|
51
|
+
for (const app of snapshot.written.apps) {
|
|
52
|
+
const match = snapshot.apps[app.id.value] ?? null;
|
|
53
|
+
const appId = app.id.value;
|
|
54
|
+
const declared = new Set(app.conditions.map((line) => line.name));
|
|
55
|
+
const layoutIds = new Set(app.layouts.map((layout) => layout.id));
|
|
56
|
+
const checkRow = (row) => {
|
|
57
|
+
const subject = flowSubject(row.flow);
|
|
58
|
+
if (row.flow !== null && !flows.has(row.flow)) findings.push(createFinding({
|
|
59
|
+
code: "GR5001",
|
|
60
|
+
message: `block "${row.block}" points to flow "${row.flow}", which does not exist`,
|
|
61
|
+
at: row.at,
|
|
62
|
+
app: appId,
|
|
63
|
+
...subject
|
|
64
|
+
}));
|
|
65
|
+
const used = [...row.who.conditions, ...row.changesWith.flatMap((item) => item.condition === null ? [] : [item.condition])];
|
|
66
|
+
for (const condition of new Set(used)) {
|
|
67
|
+
if (declared.has(condition)) continue;
|
|
68
|
+
findings.push(createFinding({
|
|
69
|
+
code: "GR5002",
|
|
70
|
+
message: `condition "${condition}" is not declared in the README of app "${appId}"`,
|
|
71
|
+
at: row.at,
|
|
72
|
+
app: appId,
|
|
73
|
+
...subject
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
for (const layout of app.layouts) layout.blocks.forEach(checkRow);
|
|
78
|
+
for (const page of pagesOf(app)) {
|
|
79
|
+
const subject = pageSubject(page);
|
|
80
|
+
const label = `${page.type} "${page.id}"`;
|
|
81
|
+
page.blocks.forEach(checkRow);
|
|
82
|
+
for (const block of page.blockFiles) {
|
|
83
|
+
if (block.flow !== null && !flows.has(block.flow.value)) findings.push(createFinding({
|
|
84
|
+
code: "GR5001",
|
|
85
|
+
message: `block file "${block.id}" of ${label} points to flow "${block.flow.value}", which does not exist`,
|
|
86
|
+
at: block.flow.at,
|
|
87
|
+
app: appId,
|
|
88
|
+
...flowSubject(block.flow.value)
|
|
89
|
+
}));
|
|
90
|
+
if (!page.blocks.some((row) => blockSlug(row.block) === block.id)) findings.push(createFinding({
|
|
91
|
+
code: "GR5007",
|
|
92
|
+
message: `block file "${block.id}" has no row in the Blocks table of ${label}`,
|
|
93
|
+
at: {
|
|
94
|
+
file: block.file,
|
|
95
|
+
line: 1,
|
|
96
|
+
column: null
|
|
97
|
+
},
|
|
98
|
+
app: appId,
|
|
99
|
+
...block.flow ? flowSubject(block.flow.value) : subject
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
if (page.layout !== null && !layoutIds.has(page.layout.value)) findings.push(createFinding({
|
|
103
|
+
code: "GR5004",
|
|
104
|
+
message: `${label} names layout "${page.layout.value}", but ${app.dir}/layouts/${page.layout.value}.md does not exist`,
|
|
105
|
+
at: page.layout.at,
|
|
106
|
+
app: appId,
|
|
107
|
+
...subject
|
|
108
|
+
}));
|
|
109
|
+
if (match) checkReached(page, label, subject, appId, facts, match, app.screens, findings);
|
|
110
|
+
}
|
|
111
|
+
if (app.file !== null && (!match || !match.site && !match.mobile)) {
|
|
112
|
+
findings.push(createFinding({
|
|
113
|
+
code: "GR5005",
|
|
114
|
+
message: `the root "${app.root.value}" of app "${appId}" matches no ${app.type.value === "site" ? "site" : "mobile app"} the code reports`,
|
|
115
|
+
at: app.root.at,
|
|
116
|
+
app: appId
|
|
117
|
+
}));
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (!match) continue;
|
|
121
|
+
if (match.site) {
|
|
122
|
+
const routes = new Set(facts.pages.filter((item) => item.site === match.site?.id).map((item) => normalizeRoute(item.route)));
|
|
123
|
+
for (const page of app.pages) {
|
|
124
|
+
if (!page.route || routes.has(normalizeRoute(page.route.value))) continue;
|
|
125
|
+
findings.push(createFinding({
|
|
126
|
+
code: "GR5003",
|
|
127
|
+
message: `page "${page.id}" has route "${page.route.value}", which is not a page of site "${match.site.id}"`,
|
|
128
|
+
at: page.route.at,
|
|
129
|
+
app: appId,
|
|
130
|
+
...pageSubject(page)
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (match.mobile && match.mobile.routing === "files") {
|
|
135
|
+
const routes = new Set(match.mobile.screens.map((screen) => normalizeRoute(screen.route)));
|
|
136
|
+
for (const screen of app.screens) {
|
|
137
|
+
const where = screen.route?.at ?? screen.screen?.at ?? null;
|
|
138
|
+
const route = screen.route?.value ?? null;
|
|
139
|
+
if (route !== null && routes.has(normalizeRoute(route))) continue;
|
|
140
|
+
findings.push(createFinding({
|
|
141
|
+
code: "GR5006",
|
|
142
|
+
message: route === null ? `screen "${screen.id}" has no route, and mobile app "${match.mobile.id}" uses file-based routing` : `screen "${screen.id}" has route "${route}", which is not a screen of mobile app "${match.mobile.id}"`,
|
|
143
|
+
at: where ?? {
|
|
144
|
+
file: screen.file,
|
|
145
|
+
line: 1,
|
|
146
|
+
column: null
|
|
147
|
+
},
|
|
148
|
+
app: appId,
|
|
149
|
+
...pageSubject(screen)
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
checkUncovered(snapshot, findings);
|
|
155
|
+
return findings;
|
|
156
|
+
}
|
|
157
|
+
/** GR5008: an `Also reached from` entry that names nothing the code has. */
|
|
158
|
+
function checkReached(page, label, subject, appId, facts, match, declaredScreens, findings) {
|
|
159
|
+
for (const entry of page.alsoReachedFrom) {
|
|
160
|
+
let found = true;
|
|
161
|
+
if (entry.type === "mail" || entry.type === "notification") found = facts.named.some((item) => item.type === entry.type && item.name === entry.name);
|
|
162
|
+
else if (entry.type === "page") {
|
|
163
|
+
const site = match.site;
|
|
164
|
+
const wanted = normalizeRoute(entry.name);
|
|
165
|
+
found = site !== null && facts.pages.some((item) => item.site === site.id && (normalizeRoute(item.route) === wanted || item.name === entry.name));
|
|
166
|
+
} else if (entry.type === "screen") {
|
|
167
|
+
const wanted = normalizeRoute(entry.name);
|
|
168
|
+
found = match.mobile?.screens.some((item) => normalizeRoute(item.route) === wanted) === true || declaredScreens.some((item) => item.id === entry.name || item.screen?.value === entry.name || item.route !== null && normalizeRoute(item.route.value) === wanted);
|
|
169
|
+
}
|
|
170
|
+
if (found) continue;
|
|
171
|
+
findings.push(createFinding({
|
|
172
|
+
code: "GR5008",
|
|
173
|
+
message: `${label} is reached from ${entry.type} "${entry.name}", which does not exist`,
|
|
174
|
+
at: entry.at,
|
|
175
|
+
app: appId,
|
|
176
|
+
...subject
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** GR5009: a site or mobile app the code reports that no written app describes. */
|
|
181
|
+
function checkUncovered(snapshot, findings) {
|
|
182
|
+
if (snapshot.written.apps.length === 0) return;
|
|
183
|
+
const sites = /* @__PURE__ */ new Set();
|
|
184
|
+
const mobiles = /* @__PURE__ */ new Set();
|
|
185
|
+
for (const match of Object.values(snapshot.apps)) {
|
|
186
|
+
if (match.site) sites.add(match.site.id);
|
|
187
|
+
if (match.mobile) mobiles.add(match.mobile.id);
|
|
188
|
+
}
|
|
189
|
+
for (const site of snapshot.book.facts.sites) {
|
|
190
|
+
if (sites.has(site.id)) continue;
|
|
191
|
+
findings.push(createFinding({
|
|
192
|
+
code: "GR5009",
|
|
193
|
+
message: `site "${site.id}" (${site.root}) has no folder in grimoire/apps`
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
for (const mobile of snapshot.book.facts.mobile) {
|
|
197
|
+
if (mobiles.has(mobile.id)) continue;
|
|
198
|
+
findings.push(createFinding({
|
|
199
|
+
code: "GR5009",
|
|
200
|
+
message: `mobile app "${mobile.id}" (${mobile.root}) has no folder in grimoire/apps`
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
export { checkApps };
|
|
207
|
+
//# sourceMappingURL=check-apps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/apps/check-apps.ts"],"sourcesContent":["/**\n * GR5001–GR5009: the written apps against the sites, pages, screens, flows\n * and conditions they mention.\n */\nimport { createFinding } from \"../codes\";\nimport type { BookFacts } from \"../contracts/adapter\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type { SourceLocation } from \"../contracts/location\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenBlockRow, WrittenPage } from \"../contracts/written\";\nimport { toPosixPath } from \"../paths\";\n\ntype Subject = { feature: string | null; flow: string | null };\n\n/** The feature and flow a block row points at, split from `<feature>/<flow>`. */\nfunction flowSubject(flow: string | null): Subject {\n if (!flow) return { feature: null, flow: null };\n\n return { feature: flow.split(\"/\")[0] ?? null, flow };\n}\n\n/** The flow all blocks of a page share, else their feature when they share one, else nothing. */\nfunction pageSubject(page: WrittenPage): Subject {\n const refs = [...new Set(page.blocks.map((row) => row.flow).filter((ref) => ref !== null))];\n\n if (refs.length === 1) return flowSubject(refs[0] ?? null);\n\n const features = [...new Set(refs.map((ref) => ref.split(\"/\")[0] ?? \"\"))];\n\n return { feature: features.length === 1 ? (features[0] ?? null) : null, flow: null };\n}\n\n/** A route as the router and the page graph compare it: `[id]` and `:id` are one parameter. */\nfunction normalizeRoute(route: string): string {\n const withSlash = toPosixPath(route.trim())\n .replace(/\\[\\.\\.\\.(\\w+)\\]/g, \":$1*\")\n .replace(/\\[(\\w+)\\]/g, \":$1\");\n const trimmed = withSlash.replace(/\\/+$/, \"\");\n\n return trimmed === \"\" ? \"/\" : trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\n/** The id of a block file for a table row: `New arrivals` → `new-arrivals`. */\nfunction blockSlug(block: string): string {\n return block\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction pagesOf(app: WrittenApp): WrittenPage[] {\n return [...app.pages, ...app.screens];\n}\n\n/**\n * GR5001–GR5009. Read-only. Pages and screens are compared with the adapter's\n * facts only when the app matched a site or mobile app (`GR5005` otherwise).\n */\nexport function checkApps(snapshot: GrimoireSnapshot): GrimoireFinding[] {\n const findings: GrimoireFinding[] = [];\n const facts = snapshot.book.facts;\n const flows = new Set<string>();\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) flows.add(`${feature.id}/${flow.id.value}`);\n }\n\n for (const app of snapshot.written.apps) {\n const match = snapshot.apps[app.id.value] ?? null;\n const appId = app.id.value;\n const declared = new Set(app.conditions.map((line) => line.name));\n const layoutIds = new Set(app.layouts.map((layout) => layout.id));\n\n const checkRow = (row: WrittenBlockRow): void => {\n const subject = flowSubject(row.flow);\n\n if (row.flow !== null && !flows.has(row.flow)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block \"${row.block}\" points to flow \"${row.flow}\", which does not exist`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n const used = [\n ...row.who.conditions,\n ...row.changesWith.flatMap((item) => (item.condition === null ? [] : [item.condition])),\n ];\n\n for (const condition of new Set(used)) {\n if (declared.has(condition)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5002\",\n message: `condition \"${condition}\" is not declared in the README of app \"${appId}\"`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n };\n\n for (const layout of app.layouts) layout.blocks.forEach(checkRow);\n\n for (const page of pagesOf(app)) {\n const subject = pageSubject(page);\n const label = `${page.type} \"${page.id}\"`;\n\n page.blocks.forEach(checkRow);\n\n for (const block of page.blockFiles) {\n if (block.flow !== null && !flows.has(block.flow.value)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block file \"${block.id}\" of ${label} points to flow \"${block.flow.value}\", which does not exist`,\n at: block.flow.at,\n app: appId,\n ...flowSubject(block.flow.value),\n }),\n );\n }\n\n if (!page.blocks.some((row) => blockSlug(row.block) === block.id)) {\n findings.push(\n createFinding({\n code: \"GR5007\",\n message: `block file \"${block.id}\" has no row in the Blocks table of ${label}`,\n at: { file: block.file, line: 1, column: null },\n app: appId,\n ...(block.flow ? flowSubject(block.flow.value) : subject),\n }),\n );\n }\n }\n\n if (page.layout !== null && !layoutIds.has(page.layout.value)) {\n findings.push(\n createFinding({\n code: \"GR5004\",\n message: `${label} names layout \"${page.layout.value}\", but ${app.dir}/layouts/${page.layout.value}.md does not exist`,\n at: page.layout.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n if (match) checkReached(page, label, subject, appId, facts, match, app.screens, findings);\n }\n\n // An app folder with no README is reported as GR1021 by the parser.\n if (app.file !== null && (!match || (!match.site && !match.mobile))) {\n findings.push(\n createFinding({\n code: \"GR5005\",\n message: `the root \"${app.root.value}\" of app \"${appId}\" matches no ${app.type.value === \"site\" ? \"site\" : \"mobile app\"} the code reports`,\n at: app.root.at,\n app: appId,\n }),\n );\n continue;\n }\n\n if (!match) continue;\n\n if (match.site) {\n const routes = new Set(\n facts.pages\n .filter((item) => item.site === match.site?.id)\n .map((item) => normalizeRoute(item.route)),\n );\n\n for (const page of app.pages) {\n if (!page.route || routes.has(normalizeRoute(page.route.value))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5003\",\n message: `page \"${page.id}\" has route \"${page.route.value}\", which is not a page of site \"${match.site.id}\"`,\n at: page.route.at,\n app: appId,\n ...pageSubject(page),\n }),\n );\n }\n }\n\n if (match.mobile && match.mobile.routing === \"files\") {\n const routes = new Set(match.mobile.screens.map((screen) => normalizeRoute(screen.route)));\n\n for (const screen of app.screens) {\n const where: SourceLocation | null = screen.route?.at ?? screen.screen?.at ?? null;\n const route = screen.route?.value ?? null;\n\n if (route !== null && routes.has(normalizeRoute(route))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5006\",\n message:\n route === null\n ? `screen \"${screen.id}\" has no route, and mobile app \"${match.mobile.id}\" uses file-based routing`\n : `screen \"${screen.id}\" has route \"${route}\", which is not a screen of mobile app \"${match.mobile.id}\"`,\n at: where ?? { file: screen.file, line: 1, column: null },\n app: appId,\n ...pageSubject(screen),\n }),\n );\n }\n }\n }\n\n checkUncovered(snapshot, findings);\n\n return findings;\n}\n\n/** GR5008: an `Also reached from` entry that names nothing the code has. */\nfunction checkReached(\n page: WrittenPage,\n label: string,\n subject: Subject,\n appId: string,\n facts: BookFacts,\n match: NonNullable<GrimoireSnapshot[\"apps\"][string]>,\n declaredScreens: readonly WrittenPage[],\n findings: GrimoireFinding[],\n): void {\n for (const entry of page.alsoReachedFrom) {\n let found = true;\n\n if (entry.type === \"mail\" || entry.type === \"notification\") {\n found = facts.named.some((item) => item.type === entry.type && item.name === entry.name);\n } else if (entry.type === \"page\") {\n const site = match.site;\n const wanted = normalizeRoute(entry.name);\n\n found =\n site !== null &&\n facts.pages.some(\n (item) =>\n item.site === site.id &&\n (normalizeRoute(item.route) === wanted || item.name === entry.name),\n );\n } else if (entry.type === \"screen\") {\n const wanted = normalizeRoute(entry.name);\n\n found =\n match.mobile?.screens.some((item) => normalizeRoute(item.route) === wanted) === true ||\n declaredScreens.some(\n (item) =>\n item.id === entry.name ||\n item.screen?.value === entry.name ||\n (item.route !== null && normalizeRoute(item.route.value) === wanted),\n );\n }\n\n if (found) continue;\n\n findings.push(\n createFinding({\n code: \"GR5008\",\n message: `${label} is reached from ${entry.type} \"${entry.name}\", which does not exist`,\n at: entry.at,\n app: appId,\n ...subject,\n }),\n );\n }\n}\n\n/** GR5009: a site or mobile app the code reports that no written app describes. */\nfunction checkUncovered(snapshot: GrimoireSnapshot, findings: GrimoireFinding[]): void {\n if (snapshot.written.apps.length === 0) return;\n\n const sites = new Set<string>();\n const mobiles = new Set<string>();\n\n for (const match of Object.values(snapshot.apps)) {\n if (match.site) sites.add(match.site.id);\n if (match.mobile) mobiles.add(match.mobile.id);\n }\n\n for (const site of snapshot.book.facts.sites) {\n if (sites.has(site.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `site \"${site.id}\" (${site.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n\n for (const mobile of snapshot.book.facts.mobile) {\n if (mobiles.has(mobile.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `mobile app \"${mobile.id}\" (${mobile.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;AAeA,SAAS,YAAY,MAA8B;CACjD,IAAI,CAAC,MAAM,OAAO;EAAE,SAAS;EAAM,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C,CAAC,CACH;CACF;CAEA,KAAK,MAAM,UAAU,SAAS,KAAK,MAAM,QAAQ;EAC/C,IAAI,QAAQ,IAAI,OAAO,EAAE,GAAG;EAE5B,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,eAAe,OAAO,GAAG,KAAK,OAAO,KAAK;EACrD,CAAC,CACH;CACF;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BookFacts } from "../contracts/adapter.mjs";
|
|
2
|
+
import { WrittenApp } from "../contracts/written.mjs";
|
|
3
|
+
import { AppMatch } from "../contracts/snapshot.mjs";
|
|
4
|
+
//#region ../../packages/grimoire/src/apps/match-apps.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Match each written app to the site or mobile app the adapter reports with
|
|
7
|
+
* the same root. A `site` app only matches a site and a `mobile` app only a
|
|
8
|
+
* mobile app; an app that matches nothing gets `null` (reported as `GR5005`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function matchApps(apps: readonly WrittenApp[], facts: Pick<BookFacts, "sites" | "mobile">): Record<string, AppMatch>;
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=match-apps.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-apps.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/apps/match-apps.ts"],"mappings":";;;;;;;;;wBAiBgB,UACd,eAAe,cACf,OAAO,KAAK,iCACX,eAAe"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toPosixPath } from "../paths/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/grimoire/src/apps/match-apps.ts
|
|
4
|
+
function sameRoot(left, right) {
|
|
5
|
+
const normalize = (value) => toPosixPath(value).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
6
|
+
return normalize(left) === normalize(right);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Match each written app to the site or mobile app the adapter reports with
|
|
10
|
+
* the same root. A `site` app only matches a site and a `mobile` app only a
|
|
11
|
+
* mobile app; an app that matches nothing gets `null` (reported as `GR5005`).
|
|
12
|
+
*/
|
|
13
|
+
function matchApps(apps, facts) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const app of apps) {
|
|
16
|
+
const type = app.type.value;
|
|
17
|
+
const root = app.root.value;
|
|
18
|
+
result[app.id.value] = {
|
|
19
|
+
app: app.id.value,
|
|
20
|
+
type,
|
|
21
|
+
site: type === "site" ? facts.sites.find((site) => sameRoot(site.root, root)) ?? null : null,
|
|
22
|
+
mobile: type === "mobile" ? facts.mobile.find((mobile) => sameRoot(mobile.root, root)) ?? null : null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { matchApps };
|
|
30
|
+
//# sourceMappingURL=match-apps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/apps/match-apps.ts"],"sourcesContent":["import type { BookFacts } from \"../contracts/adapter\";\nimport type { AppMatch } from \"../contracts/snapshot\";\nimport type { WrittenApp } from \"../contracts/written\";\nimport { toPosixPath } from \"../paths\";\n\nfunction sameRoot(left: string, right: string): boolean {\n const normalize = (value: string): string =>\n toPosixPath(value).replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\");\n\n return normalize(left) === normalize(right);\n}\n\n/**\n * Match each written app to the site or mobile app the adapter reports with\n * the same root. A `site` app only matches a site and a `mobile` app only a\n * mobile app; an app that matches nothing gets `null` (reported as `GR5005`).\n */\nexport function matchApps(\n apps: readonly WrittenApp[],\n facts: Pick<BookFacts, \"sites\" | \"mobile\">,\n): Record<string, AppMatch> {\n const result: Record<string, AppMatch> = {};\n\n for (const app of apps) {\n const type = app.type.value;\n const root = app.root.value;\n\n result[app.id.value] = {\n app: app.id.value,\n type,\n site:\n type === \"site\" ? (facts.sites.find((site) => sameRoot(site.root, root)) ?? null) : null,\n mobile:\n type === \"mobile\"\n ? (facts.mobile.find((mobile) => sameRoot(mobile.root, root)) ?? null)\n : null,\n };\n }\n\n return result;\n}\n"],"mappings":";;;AAKA,SAAS,SAAS,MAAc,OAAwB;CACtD,MAAM,aAAa,UACjB,YAAY,KAAK,CAAC,CAAC,QAAQ,SAAS,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAE5D,OAAO,UAAU,IAAI,MAAM,UAAU,KAAK;AAC5C;;;;;;AAOA,SAAgB,UACd,MACA,OAC0B;CAC1B,MAAM,SAAmC,CAAC;CAE1C,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,OAAO,IAAI,KAAK;EACtB,MAAM,OAAO,IAAI,KAAK;EAEtB,OAAO,IAAI,GAAG,SAAS;GACrB,KAAK,IAAI,GAAG;GACZ;GACA,MACE,SAAS,SAAU,MAAM,MAAM,MAAM,SAAS,SAAS,KAAK,MAAM,IAAI,CAAC,KAAK,OAAQ;GACtF,QACE,SAAS,WACJ,MAAM,OAAO,MAAM,WAAW,SAAS,OAAO,MAAM,IAAI,CAAC,KAAK,OAC/D;EACR;CACF;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BookAdapter } from "../contracts/adapter.mjs";
|
|
2
|
+
import { BuildBookOptions, BuildBookResult, LoadedBook } from "../contracts/book.mjs";
|
|
3
|
+
//#region ../../packages/grimoire/src/book/build.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Bring the book's facts up to date and write `manifest.json` and
|
|
6
|
+
* `.cache/facts.json`. Does not write entries (see `writeBook`).
|
|
7
|
+
*
|
|
8
|
+
* @param root Absolute project root.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildBook(root: string, adapter: BookAdapter, options?: BuildBookOptions): Promise<BuildBookResult>;
|
|
11
|
+
/** Read the book from disk without calling an adapter; `null` when it was never built. */
|
|
12
|
+
export declare function loadBook(root: string): Promise<LoadedBook | null>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=build.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/book/build.ts"],"mappings":";;;;;;;;;wBA6RsB,UACpB,cACA,SAAS,aACT,UAAS,mBACR,QAAQ;;wBAyKW,SAAS,eAAe,QAAQ"}
|