@warlock.js/grimoire 0.0.0-stage → 5.55.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 +46 -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 +35 -0
- package/esm/devtools/index.d.mts.map +1 -0
- package/esm/devtools/index.mjs +102 -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/llms-full.txt
ADDED
|
@@ -0,0 +1,869 @@
|
|
|
1
|
+
# Warlock Grimoire — full skills
|
|
2
|
+
|
|
3
|
+
> Package: `@warlock.js/grimoire`
|
|
4
|
+
|
|
5
|
+
> Generated artifact. Concatenates every SKILL.md and reference file under `@warlock.js/grimoire/skills/`. Re-run `node scripts/generate-llms.mjs` after any change.
|
|
6
|
+
|
|
7
|
+
## Package orientation
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
description: "Grimoire (experimental), the project map for Warlock.js apps: `warlock scry` and `warlock grimoire build|check|release` over a `grimoire/` folder of generated book entries and agent-written features, flows, apps, tasks and releases. Topics: use the map before searching code, write a feature, record a change and release, describe sites and mobile screens, document a file, backfill an existing app. Use at the start of every task in a project that has `grimoire/`."
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# @warlock.js/grimoire
|
|
14
|
+
|
|
15
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
16
|
+
|
|
17
|
+
`grimoire/` is the map of a Warlock.js project. Warlock writes the **book** (one entry per source file, the routes, the pages and the mobile screens, in `grimoire/book/`, not in git). Agents write what the product does (`grimoire/features/`), where users meet it (`grimoire/apps/`), the work (`grimoire/tasks/`) and the releases (`grimoire/releases/`). Warlock never edits a file an agent wrote.
|
|
18
|
+
|
|
19
|
+
## The 80% path
|
|
20
|
+
|
|
21
|
+
1. Before searching the code, ask the map: `use-the-grimoire.md`.
|
|
22
|
+
2. A new behaviour starts as a task, a brief, a feature README and a flow, before code: `write-a-feature.md`.
|
|
23
|
+
3. After the change, tie tests to criteria, reshape the README, add the changelog entry, close the task, run the check, and at release time stamp the changelogs and write the brief: `record-a-change.md`.
|
|
24
|
+
4. Pages, blocks, conditions and mobile screens: `describe-an-app.md`.
|
|
25
|
+
5. The header and export comments the book copies from a file: `document-a-file.md`.
|
|
26
|
+
6. A project with code but no `grimoire/` folder: `backfill-a-grimoire.md`.
|
|
27
|
+
|
|
28
|
+
## Conventions and pitfalls
|
|
29
|
+
|
|
30
|
+
- Never edit `grimoire/book/`, `index.json`, `bookmap.json` or `*.bookmap.json`.
|
|
31
|
+
- You write release numbers and dates into changelogs and the release brief; `warlock grimoire release` only writes the collected list.
|
|
32
|
+
- A finding marked `(expected)` belongs to `proposed` work and does not fail `warlock grimoire check`.
|
|
33
|
+
- Mobile screens are listed from file names only with file-based routing; declare them when navigation is in code.
|
|
34
|
+
- Do not invent intent: write `Unknown:` and ask the owner.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## backfill-a-grimoire `@warlock.js/grimoire/skills/backfill-a-grimoire/SKILL.md`
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
name: backfill-a-grimoire
|
|
41
|
+
description: "Write the Grimoire for a project that already has code but no `grimoire/` folder: build the book, propose features from the modules and routes, write them as inferred, and bring the owner the questions only they can answer. Use once per existing project, or when a large undescribed area is found."
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
# Backfill a Grimoire
|
|
45
|
+
|
|
46
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
47
|
+
|
|
48
|
+
The code exists; the description does not. You will infer intent from code, and inference can be
|
|
49
|
+
plausible and wrong. So everything you write here is marked **inferred** until the owner confirms
|
|
50
|
+
it, and you bring them questions instead of guessing.
|
|
51
|
+
|
|
52
|
+
## 1. Build the book
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx warlock grimoire build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
It needs no writing. Read the module summaries (`grimoire/book/app/<module>/index.md`), the
|
|
59
|
+
route list (`grimoire/book/app/routes.json`) and each site's page list.
|
|
60
|
+
|
|
61
|
+
## 2. Propose the features
|
|
62
|
+
|
|
63
|
+
Start from the modules: a module is usually one feature. Then adjust.
|
|
64
|
+
|
|
65
|
+
- Two modules that cannot be described without each other → one feature with both `folders`.
|
|
66
|
+
- A module that does two unrelated things → two features; tag the files of the smaller one.
|
|
67
|
+
- A folder shared by several features (a `components` folder with files of each) → list the files
|
|
68
|
+
each feature owns in its `folders`, one entry per file (`folders: [src/app/auth, src/web/components/login-form.tsx]`),
|
|
69
|
+
instead of tagging them in the code. A file entry wins over a folder of another feature.
|
|
70
|
+
- Plumbing (config, shared utilities, the base layout) → no feature.
|
|
71
|
+
- Mail, notifications, search: the machinery is a feature; each mail or notification belongs to
|
|
72
|
+
the feature that sends it.
|
|
73
|
+
|
|
74
|
+
Write the proposal as a table for the owner **before** writing files:
|
|
75
|
+
|
|
76
|
+
| Feature | Folders | Flows you see | Apps | Unsure about |
|
|
77
|
+
| ------- | ------------ | ------------------------------ | ------------------ | -------------------------- |
|
|
78
|
+
| auth | src/app/auth | sign-up, login, reset-password | web-client, mobile | is phone login still used? |
|
|
79
|
+
|
|
80
|
+
Wait for the owner's answer on the list. Features are the frame for everything else; a wrong
|
|
81
|
+
frame costs the most to fix.
|
|
82
|
+
|
|
83
|
+
## 3. Write each feature as inferred
|
|
84
|
+
|
|
85
|
+
Follow `write-a-feature` for the shapes, with these differences:
|
|
86
|
+
|
|
87
|
+
```md
|
|
88
|
+
---
|
|
89
|
+
id: auth
|
|
90
|
+
title: Accounts
|
|
91
|
+
status: shipped
|
|
92
|
+
origin: inferred
|
|
93
|
+
version: 1.0
|
|
94
|
+
updated: 2026-11-16
|
|
95
|
+
apps: [web-client, mobile]
|
|
96
|
+
folders: [src/app/auth]
|
|
97
|
+
---
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `origin: inferred` on the README and on each flow. The owner changes it to `confirmed`.
|
|
101
|
+
- Start every feature at `1.0`. Do not reconstruct history; the changelog gets one line under `## Unreleased`
|
|
102
|
+
in the feature's own `CHANGELOG.md` (`grimoire/features/auth/CHANGELOG.md`), never in the README:
|
|
103
|
+
|
|
104
|
+
```md
|
|
105
|
+
## Unreleased
|
|
106
|
+
|
|
107
|
+
- 1.0 added described from the existing code
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- **Steps:** take them from the routes and pages, in the order a user meets them. A mail is a
|
|
111
|
+
`*.mail.ts` or `*.email.ts` file (or a file in `mails/` or `emails/`), a job is a queue job or a
|
|
112
|
+
scheduled task. When two sites or apps have a page with one path, write the app after it:
|
|
113
|
+
`page /support [web-admin]`.
|
|
114
|
+
- **Flows:** a flow starts from a route, a page, a job or an event. Logic with no entry point of
|
|
115
|
+
its own (a guard, a calculation) is not a flow: write it in the cases or criteria of the flow
|
|
116
|
+
that reaches it.
|
|
117
|
+
- **Cases:** answer the eight questions from what the code does. When the code answers a
|
|
118
|
+
question by doing nothing, that is still what happens: write it as a case with the result
|
|
119
|
+
(`duplicate saved twice`, `double submit two accounts`). List a question under
|
|
120
|
+
`## Not handled` only when the behaviour is a gap the owner should decide, in the same form as a
|
|
121
|
+
case (the question, then what happens today):
|
|
122
|
+
|
|
123
|
+
```md
|
|
124
|
+
## Not handled
|
|
125
|
+
|
|
126
|
+
- double submit two quick taps create two accounts
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **Read-only flows:** a flow that only reads answers the questions that cannot happen with one
|
|
130
|
+
line each, `does not apply: read-only`. That is expected, not a finding.
|
|
131
|
+
- **Criteria:** one per case. Tag the existing tests with `@proves` where a test clearly proves
|
|
132
|
+
one. Do not write new tests during a backfill.
|
|
133
|
+
- **Intent you cannot see:** write `Unknown: why does a VIP skip the stock check?` in the flow.
|
|
134
|
+
Never invent a reason.
|
|
135
|
+
|
|
136
|
+
## 4. Describe the apps
|
|
137
|
+
|
|
138
|
+
One folder per site and mobile app (`describe-an-app`). Declare the conditions you find in the
|
|
139
|
+
code (roles, permissions, membership checks). Write page files only for pages that combine
|
|
140
|
+
several features or change with the user. When the mobile app defines navigation in code, declare
|
|
141
|
+
its screens yourself; they are listed from file names only with file-based routing.
|
|
142
|
+
|
|
143
|
+
## 5. Check and hand over
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npx warlock grimoire check
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Fix what it reports about your own files. A backfilled project reports many warnings (criteria with
|
|
150
|
+
no test, files with no header); fix errors first and list the warnings for the owner. Then give the owner one list:
|
|
151
|
+
|
|
152
|
+
- features and flows written, all inferred;
|
|
153
|
+
- every `Unknown:` and `Not handled` line, as questions;
|
|
154
|
+
- files that belong to no feature;
|
|
155
|
+
- files inside a feature that no flow reaches (undescribed behaviour or dead code);
|
|
156
|
+
- criteria with no test.
|
|
157
|
+
|
|
158
|
+
Open one task per question that needs a decision, with `status: waiting for approval` and a
|
|
159
|
+
`Decision needed:` line (see `write-a-feature`; any other word is `GR1004`). Mark every task you open
|
|
160
|
+
for the owner this way, also when the owner is away. Do not fix code during a backfill; open a task
|
|
161
|
+
for each bug you notice.
|
|
162
|
+
|
|
163
|
+
## Size
|
|
164
|
+
|
|
165
|
+
Work one feature at a time and finish it before starting the next. A large project takes several
|
|
166
|
+
sessions; the task list says where you stopped.
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
## describe-an-app `@warlock.js/grimoire/skills/describe-an-app/SKILL.md`
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
name: describe-an-app
|
|
173
|
+
description: "Describe where users meet the product in `grimoire/apps/`: one folder per site or mobile app, its named conditions (guest, customer, membership, preferences), shared layouts, and the pages or screens whose blocks point to feature flows. Use when adding a page, a screen or a block, or when what a page shows depends on who is looking."
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
# Describe an app
|
|
177
|
+
|
|
178
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
179
|
+
|
|
180
|
+
Features say what the product does. Apps say where a user sees it. One folder per site or mobile
|
|
181
|
+
app:
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
grimoire/apps/
|
|
185
|
+
web-client/
|
|
186
|
+
README.md the app and its conditions
|
|
187
|
+
layouts/site.md blocks every page of this layout shares
|
|
188
|
+
pages/home/README.md purpose, layout, blocks
|
|
189
|
+
pages/home/blocks/new-arrivals.md only when the block has page-specific detail
|
|
190
|
+
web-admin/
|
|
191
|
+
mobile/
|
|
192
|
+
screens/home/README.md declared by you when navigation is in code
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Write a file only when it says something the code or a feature flow does not already say. A page
|
|
196
|
+
with one purpose, no variation and no blocks from other features needs no file.
|
|
197
|
+
|
|
198
|
+
## The app README
|
|
199
|
+
|
|
200
|
+
```md
|
|
201
|
+
---
|
|
202
|
+
id: web-client
|
|
203
|
+
type: site
|
|
204
|
+
root: src/web/$sites/client
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
# The shop website
|
|
208
|
+
|
|
209
|
+
## Conditions
|
|
210
|
+
|
|
211
|
+
- guest not signed in
|
|
212
|
+
- customer signed in
|
|
213
|
+
- vip customer with the vip membership
|
|
214
|
+
- pref:personalised the customer left personalised content on
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`origin` is optional (`inferred` or `confirmed`), on the README and on layouts, pages and screens,
|
|
218
|
+
as on features. Mark files you wrote from the code `inferred`.
|
|
219
|
+
|
|
220
|
+
Every page and block of this app uses these names and no others in **Who sees it**. Add a condition here before
|
|
221
|
+
using it. Name roles and permissions exactly as the access configuration does, so a reader can
|
|
222
|
+
find them in the code.
|
|
223
|
+
|
|
224
|
+
A mobile app in the same repository is one more app: `type: mobile`, `root: mobile`.
|
|
225
|
+
|
|
226
|
+
## Mobile screens
|
|
227
|
+
|
|
228
|
+
How a screen gets into the book depends on how the app navigates:
|
|
229
|
+
|
|
230
|
+
| The mobile app | Screens come from | You write |
|
|
231
|
+
| -------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
|
|
232
|
+
| File-based routing (Expo Router) | The route file names under its `app` folder (`collectMobileFacts`) | A screen file only when it says something the route does not |
|
|
233
|
+
| Navigation defined in code | Nowhere: the book cannot read it | One file per screen you describe, in `grimoire/apps/<app>/screens/<screen>/README.md` |
|
|
234
|
+
|
|
235
|
+
A declared screen has a `route` (or a `screen` name) in its front matter:
|
|
236
|
+
|
|
237
|
+
```md
|
|
238
|
+
---
|
|
239
|
+
screen: order-tracking
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
# Order tracking
|
|
243
|
+
|
|
244
|
+
## Blocks
|
|
245
|
+
|
|
246
|
+
| Block | Flow | Who sees it | Changes with |
|
|
247
|
+
| ------------- | ------------------ | ----------- | ------------ |
|
|
248
|
+
| Courier stage | orders/track-order | customer | — |
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
When the app uses file-based routing, `warlock grimoire check` reports a screen whose route has no
|
|
252
|
+
file. When navigation is in code, declare every screen a flow names; the check cannot verify it.
|
|
253
|
+
|
|
254
|
+
## A page or screen
|
|
255
|
+
|
|
256
|
+
```md
|
|
257
|
+
---
|
|
258
|
+
route: /
|
|
259
|
+
layout: site
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
# Home
|
|
263
|
+
|
|
264
|
+
The first page a visitor sees.
|
|
265
|
+
|
|
266
|
+
## Blocks
|
|
267
|
+
|
|
268
|
+
| Block | Flow | Who sees it | Changes with |
|
|
269
|
+
| ----------------- | ----------------------- | ----------- | ---------------------- |
|
|
270
|
+
| Featured products | catalog/browse-products | everyone | vip: member prices |
|
|
271
|
+
| New arrivals | catalog/new-arrivals | everyone | the customer's country |
|
|
272
|
+
| Recent orders | orders/place-order | customer | — |
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- **One row per part of the page**, not one description per kind of user. Three roles and two
|
|
276
|
+
preferences are a few rows, not six pages.
|
|
277
|
+
- **Flow** is `feature/flow`. The rule for what the block shows lives there. Do not restate it.
|
|
278
|
+
- **Who sees it** uses the app's condition names, and the check reports a name the README does
|
|
279
|
+
not declare (`GR5002`). **Changes with** is free text: it is not checked, but starting an item
|
|
280
|
+
with a condition name (`vip: member prices`) keeps it readable.
|
|
281
|
+
- Do not list blocks that come from the layout.
|
|
282
|
+
|
|
283
|
+
## A layout
|
|
284
|
+
|
|
285
|
+
`layouts/site.md` has the same Blocks table for what every page of that layout shares (header,
|
|
286
|
+
cart count, notifications bell, footer). Write it once; pages inherit it.
|
|
287
|
+
|
|
288
|
+
## A block file
|
|
289
|
+
|
|
290
|
+
Only when the block has something to say about this page in particular:
|
|
291
|
+
|
|
292
|
+
```md
|
|
293
|
+
---
|
|
294
|
+
flow: catalog/new-arrivals
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
# New arrivals on the home page
|
|
298
|
+
|
|
299
|
+
- position second row, under Featured products
|
|
300
|
+
- shows a grid of up to 20 products
|
|
301
|
+
- phones one row that scrolls sideways
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Where a difference between apps goes
|
|
305
|
+
|
|
306
|
+
| The difference | Goes in |
|
|
307
|
+
| -------------------------------------------------------------- | ----------------------------------- |
|
|
308
|
+
| What the user gets (mobile uses the device location) | The flow, under `## Differs by app` |
|
|
309
|
+
| How it looks or where it sits (a row on mobile, a grid on web) | That app's block file |
|
|
310
|
+
|
|
311
|
+
## How a page is reached, and what it requires
|
|
312
|
+
|
|
313
|
+
Do not write these. The book lists how a page is reached (links and redirects it can read) and
|
|
314
|
+
what it requires (middleware and permissions). Write an entry point yourself only when the book
|
|
315
|
+
cannot see it, such as a link in an email:
|
|
316
|
+
|
|
317
|
+
```md
|
|
318
|
+
## Also reached from
|
|
319
|
+
|
|
320
|
+
- mail order-confirmation
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Check
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
npx warlock grimoire check
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
It reports a block that points to a flow that does not exist, a condition that is not declared in
|
|
330
|
+
the app README, a page whose route is gone, a screen with no route (file-based apps), and a
|
|
331
|
+
feature that lists an app with no folder here. Its codes are `GR5001` to `GR5009`;
|
|
332
|
+
`npx warlock explain GR5003` describes one.
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
## document-a-file `@warlock.js/grimoire/skills/document-a-file/SKILL.md`
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
name: document-a-file
|
|
339
|
+
description: "Write the one-sentence header and the public-export comments the Grimoire copies into its book, and tag a file with `@feature` when it lives outside its feature's folders. Use whenever you create a source file or change what one is for."
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
# Document a file
|
|
343
|
+
|
|
344
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
345
|
+
|
|
346
|
+
Warlock copies two things from each source file into the book: the sentence at the top, and the
|
|
347
|
+
comment above each public export. They are the only words in the book that you write, and they
|
|
348
|
+
are what another agent reads to decide whether to open the file.
|
|
349
|
+
|
|
350
|
+
## The header: one sentence, first thing in the file
|
|
351
|
+
|
|
352
|
+
Say why the file exists, from the product's side.
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
/** Lists the newest products sold in the customer's country. */
|
|
356
|
+
|
|
357
|
+
export const NEW_ARRIVALS_LIMIT = 20;
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
- One sentence. If you need two, the file probably does two things.
|
|
361
|
+
- Say what it is for, not what kind of file it is. The book already knows it is a service.
|
|
362
|
+
- Change it when the file's purpose changes. A stale header misleads every reader after you.
|
|
363
|
+
|
|
364
|
+
| Write | Not |
|
|
365
|
+
| ------------------------------------------ | ------------------------------------ |
|
|
366
|
+
| `Creates a post for the signed-in author.` | `Controller for posts.` |
|
|
367
|
+
| `Sends the order confirmation email.` | `This file contains the mail class.` |
|
|
368
|
+
| `Decides the price a VIP customer pays.` | `Helper functions.` |
|
|
369
|
+
|
|
370
|
+
## Public exports: one line each
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
/** Returns up to 20 products, newest first. */
|
|
374
|
+
export async function listNewArrivals(country?: string) {
|
|
375
|
+
// …
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
- Comment only what other files import. Private helpers need no comment.
|
|
380
|
+
- Say what the caller gets or what happens. Do not repeat the name ("Lists new arrivals").
|
|
381
|
+
- Put limits and units in the line when they exist ("up to 20", "in minutes").
|
|
382
|
+
|
|
383
|
+
## The feature tag: only for exceptions
|
|
384
|
+
|
|
385
|
+
A file belongs to the feature whose `folders` contain it. Add a tag only when the file lives
|
|
386
|
+
somewhere else:
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
/**
|
|
390
|
+
* Deletes accounts that were never verified, seven days after sign-up.
|
|
391
|
+
* @feature auth
|
|
392
|
+
*/
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
One feature per file. A file used by several features still has one owner; the book lists the
|
|
396
|
+
others as borrowing it. Do not tag shared plumbing (config, generic utilities, the base layout).
|
|
397
|
+
|
|
398
|
+
## Check your work
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
npx warlock scry src/app/catalog/services/new-arrivals.service.ts
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
The `about` line and each export's line should read well on their own, without the code beside
|
|
405
|
+
them. `npx warlock grimoire check` reports a file with no header and a file with no feature.
|
|
406
|
+
|
|
407
|
+
## Do not
|
|
408
|
+
|
|
409
|
+
- Do not write a comment on every function, field or parameter.
|
|
410
|
+
- Do not describe the implementation ("uses a loop to…").
|
|
411
|
+
- Do not copy the flow's text into the file. The flow lives in `grimoire/features/`.
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
## record-a-change `@warlock.js/grimoire/skills/record-a-change/SKILL.md`
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
name: record-a-change
|
|
418
|
+
description: "Finish a change the Grimoire way: tie each test to the acceptance criterion it proves, reshape the feature README, add the changelog entry with the right version, move the task to done, run `warlock grimoire check`, and write the release brief. Use after building any change, including a bug fix."
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
# Record a change
|
|
422
|
+
|
|
423
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
424
|
+
|
|
425
|
+
A change is finished when the code, the tests and the description agree. Do these in order.
|
|
426
|
+
|
|
427
|
+
## 1. Tie tests to criteria
|
|
428
|
+
|
|
429
|
+
Put a line above each test that proves a criterion:
|
|
430
|
+
|
|
431
|
+
```ts
|
|
432
|
+
// @proves catalog/new-arrivals AC-2
|
|
433
|
+
it("returns the global list when the customer has no country", async () => {
|
|
434
|
+
// …
|
|
435
|
+
});
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
- End-to-end tests prove a flow's steps. Unit tests prove a business rule ("a reset code expires
|
|
439
|
+
after 10 minutes").
|
|
440
|
+
- One test may prove one criterion. If it needs two tags, split the test.
|
|
441
|
+
- A bug fix gets a test that fails without the fix. If no criterion covers the bug, the flow was
|
|
442
|
+
missing a case: add the case and the criterion first.
|
|
443
|
+
|
|
444
|
+
## 2. Reshape the README and the flow
|
|
445
|
+
|
|
446
|
+
Edit them so they describe the feature **as it is now**, as if it had always been this way. Do
|
|
447
|
+
not append "Update:" notes; history goes in the changelog. Set `updated` to today and `version`
|
|
448
|
+
to the new version. Set a flow's `status` to `shipped` once its code and tests exist.
|
|
449
|
+
|
|
450
|
+
## 3. Add the changelog entry
|
|
451
|
+
|
|
452
|
+
`grimoire/features/catalog/CHANGELOG.md`, newest first, under `## Unreleased`. Warlock never edits
|
|
453
|
+
this file; you write every line of it, including the release number and date when the release ships
|
|
454
|
+
(step 6):
|
|
455
|
+
|
|
456
|
+
```md
|
|
457
|
+
## Unreleased
|
|
458
|
+
|
|
459
|
+
- 2.1 fixed new-arrivals: a customer with no country saw an empty list
|
|
460
|
+
instead of the global one (AC-2)
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
| The change | Version | Word |
|
|
464
|
+
| ------------------------------------- | ------------------------- | --------- |
|
|
465
|
+
| A new flow or a new capability | next whole number (`3.0`) | `added` |
|
|
466
|
+
| Behaviour of an existing flow changes | next decimal (`2.1`) | `changed` |
|
|
467
|
+
| The code did not match the flow | next decimal (`2.1`) | `fixed` |
|
|
468
|
+
| A flow is retired | next whole number | `removed` |
|
|
469
|
+
|
|
470
|
+
One line per change, written for someone who uses the product. Name the flow, and the criterion
|
|
471
|
+
when there is one. While the change is unreleased, write no date and no release number.
|
|
472
|
+
|
|
473
|
+
## 4. Close the task
|
|
474
|
+
|
|
475
|
+
Move the file from `grimoire/tasks/open/` to `grimoire/tasks/done/<yyyy-mm>/` and set:
|
|
476
|
+
|
|
477
|
+
```md
|
|
478
|
+
status: done
|
|
479
|
+
shipped: catalog 2.1
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Add two lines: how it was verified (which tests, which criteria) and anything left open. If
|
|
483
|
+
something is left open, open a new task for it; do not leave it only in the done file. A task
|
|
484
|
+
that needs the owner's answer gets `status: waiting for approval` and a `Decision needed:` line.
|
|
485
|
+
|
|
486
|
+
## 5. Check
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
npx warlock grimoire check
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
| It reports | Do |
|
|
493
|
+
| ------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
494
|
+
| A step names a route, page, mail or job that does not exist | Fix the name in the flow, or the code |
|
|
495
|
+
| A criterion has no test | Write the test, or say in the task why not |
|
|
496
|
+
| A test points at a criterion that does not exist | Fix the `@proves` line |
|
|
497
|
+
| A file has no header, or no feature | `document-a-file` |
|
|
498
|
+
| A file in the feature's folders that no flow reaches | Describe the behaviour in a flow, or delete dead code |
|
|
499
|
+
| A README `updated` older than its newest changelog entry | Reshape the README |
|
|
500
|
+
| A changelog version that does not fit the word (`added` with `2.1`) | Fix the version |
|
|
501
|
+
|
|
502
|
+
Fix every line it prints. Do not finish with problems you caused. Findings on a flow or feature
|
|
503
|
+
with `status: proposed` print with `(expected)` and do not fail the check: leave them until the
|
|
504
|
+
code exists.
|
|
505
|
+
|
|
506
|
+
## 6. At release time
|
|
507
|
+
|
|
508
|
+
Warlock does not edit your files at release. You do three things, in this order:
|
|
509
|
+
|
|
510
|
+
1. **Stamp the changelogs.** In each feature that changed, move the `## Unreleased` entries under a
|
|
511
|
+
heading with the release number and date:
|
|
512
|
+
|
|
513
|
+
```md
|
|
514
|
+
## Unreleased
|
|
515
|
+
|
|
516
|
+
## 1.4.1 (2026-11-20)
|
|
517
|
+
|
|
518
|
+
- 2.1 fixed new-arrivals: a customer with no country saw an empty list
|
|
519
|
+
instead of the global one (AC-2)
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
2. **Write the release brief.** Create `grimoire/releases/1.4.1.md`:
|
|
523
|
+
|
|
524
|
+
```md
|
|
525
|
+
---
|
|
526
|
+
release: 1.4.1
|
|
527
|
+
date: 2026-11-20
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
# Release 1.4.1
|
|
531
|
+
|
|
532
|
+
Customers with no country on their account see new arrivals again.
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
Two or three sentences on what the release means to users.
|
|
536
|
+
|
|
537
|
+
3. **Collect the list.**
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
npx warlock grimoire release 1.4.1
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
It writes the entries you stamped with that release between the markers under your brief, and
|
|
544
|
+
changes nothing else. It also says how many entries are still unreleased. Do not write that list
|
|
545
|
+
yourself, and run the command again after any change to a changelog: the result is the same
|
|
546
|
+
every time.
|
|
547
|
+
|
|
548
|
+
`npx warlock grimoire check` reports a listed entry that has no changelog entry stamped with that
|
|
549
|
+
release and date, and a release section with no release file.
|
|
550
|
+
|
|
551
|
+
## Report to the owner
|
|
552
|
+
|
|
553
|
+
Say what changed in plain words, the feature version, which criteria are proven, what the check
|
|
554
|
+
reported, and what is left open with its task id.
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
## use-the-grimoire `@warlock.js/grimoire/skills/use-the-grimoire/SKILL.md`
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
name: use-the-grimoire
|
|
561
|
+
description: "Find the right files before changing a Warlock.js project by asking the Grimoire (experimental): `warlock scry` for a file, a route, a feature, a flow or the impact of a change, and the `grimoire/` folder for what the product does. Use at the start of every task, before searching the code."
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
# Use the Grimoire
|
|
565
|
+
|
|
566
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
567
|
+
|
|
568
|
+
`grimoire/` is the map of this project. Read it before you search the code: it tells you where
|
|
569
|
+
things are, what a feature is meant to do, and what a change will touch.
|
|
570
|
+
|
|
571
|
+
| Folder | Holds | Written by |
|
|
572
|
+
| -------------------- | ------------------------------------------------------- | ---------------------------------------------- |
|
|
573
|
+
| `grimoire/book/` | One entry per source file, plus routes and pages | Warlock (never edit) |
|
|
574
|
+
| `grimoire/features/` | What the product does: features, flows, cases, criteria | You and other agents |
|
|
575
|
+
| `grimoire/apps/` | Where users meet it: sites, mobile apps, pages, blocks | You and other agents |
|
|
576
|
+
| `grimoire/tasks/` | Open and finished work | You and other agents |
|
|
577
|
+
| `grimoire/releases/` | What each release shipped | You write the brief, Warlock collects the list |
|
|
578
|
+
|
|
579
|
+
Files named `index.json`, `bookmap.json` or ending in `.bookmap.json` are Warlock's. A feature's
|
|
580
|
+
`bookmap.json` says what the feature owns and borrows, and each flow's `*.bookmap.json` says which
|
|
581
|
+
files sit behind each step and which tests prove each criterion. They are rebuilt on demand and are
|
|
582
|
+
not in git. Never edit them; change the code or the written files and they follow. Warlock never
|
|
583
|
+
edits a file you wrote either.
|
|
584
|
+
|
|
585
|
+
## Start of every task
|
|
586
|
+
|
|
587
|
+
1. Find the feature and flow the task is about.
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
npx warlock scry --search "new arrivals"
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
```text
|
|
594
|
+
flow catalog/new-arrivals New arrivals
|
|
595
|
+
block web-client/home/new-arrivals catalog/new-arrivals
|
|
596
|
+
route GET /api/products/new-arrivals
|
|
597
|
+
file src/app/catalog/services/new-arrivals.service.ts Lists the newest products sold in the customer's country.
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
2. Read the feature's `README.md`, then the flow file. They say what the behaviour should be.
|
|
601
|
+
3. Ask for the flow's book map. It lists the files behind each step, the tests that prove each
|
|
602
|
+
criterion and the pages that show the flow.
|
|
603
|
+
|
|
604
|
+
```bash
|
|
605
|
+
npx warlock scry --flow catalog/new-arrivals
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
4. Read only those files. Do not read a whole module to find one function.
|
|
609
|
+
|
|
610
|
+
## Questions the book answers
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
npx warlock scry src/app/catalog/services/new-arrivals.service.ts # what is this file?
|
|
614
|
+
npx warlock scry --impact src/app/catalog/models/product.model.ts # what breaks if I change it?
|
|
615
|
+
npx warlock scry --route "POST /api/orders" # what is behind this URL?
|
|
616
|
+
npx warlock scry --feature catalog # the whole feature
|
|
617
|
+
npx warlock scry --flow catalog/new-arrivals # one flow, step by step
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
Add `--json` for machine-readable output. `--impact` lists API routes, pages, flows and features,
|
|
621
|
+
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 exact matches first. Read the flows it names and run their tests after
|
|
623
|
+
your change.
|
|
624
|
+
|
|
625
|
+
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|
|
626
|
+
in `grimoire/book/app/auth/controllers/login.controller.json`.
|
|
627
|
+
|
|
628
|
+
## Commands
|
|
629
|
+
|
|
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 check` | Reports broken names, untested criteria, files with no owner. Exit 1 on an error; `--all` lists every warning |
|
|
635
|
+
| `warlock grimoire release <release>` | Writes the collected list into `grimoire/releases/<release>.md` |
|
|
636
|
+
| `warlock explain GR2001` | Explains a finding code |
|
|
637
|
+
|
|
638
|
+
Every finding has a code (`GR2001`) and a fix hint. A finding marked `(expected)` belongs to work
|
|
639
|
+
that is still `proposed`; it does not fail the check.
|
|
640
|
+
|
|
641
|
+
## What to trust
|
|
642
|
+
|
|
643
|
+
- **Exports, imports, importers, routes, middleware, pages:** read from the code. Trust them.
|
|
644
|
+
- **Files behind a route:** every file the handler can reach through imports. It is not the exact
|
|
645
|
+
call path; open the handler to see which ones it really uses.
|
|
646
|
+
- **Reached from:** only links and redirects written as plain values. `unknown` means look.
|
|
647
|
+
- **Written files:** they say what should happen. When the code disagrees with a flow, do not
|
|
648
|
+
pick one silently. Say which is wrong, and fix it or ask the owner.
|
|
649
|
+
|
|
650
|
+
## When there is nothing to find
|
|
651
|
+
|
|
652
|
+
- No flow matches the task: the behaviour is undescribed. Describe it first with
|
|
653
|
+
`write-a-feature`, then change the code.
|
|
654
|
+
- The command says the book is missing or stale: it rebuilds on its own. If it reports problems,
|
|
655
|
+
read them; `npx warlock grimoire check` prints the same list.
|
|
656
|
+
- The project has code but no `grimoire/` folder: use `backfill-a-grimoire`.
|
|
657
|
+
|
|
658
|
+
## See also
|
|
659
|
+
|
|
660
|
+
`write-a-feature`, `record-a-change`, `describe-an-app`, `document-a-file`, `backfill-a-grimoire`.
|
|
661
|
+
|
|
662
|
+
## From code
|
|
663
|
+
|
|
664
|
+
The same answers are available as functions, for tools that build on the Grimoire.
|
|
665
|
+
|
|
666
|
+
From `@warlock.js/grimoire` (no dependency on core or web):
|
|
667
|
+
|
|
668
|
+
- `openGrimoire` loads everything once (it runs `parseGrimoire`, `buildBook`, `matchApps`,
|
|
669
|
+
`resolveOwnership`, `scanProofs`, `readTestResults`, `buildCollectedFiles`, then `writeBook`
|
|
670
|
+
and `writeCollectedFiles`), and returns a snapshot.
|
|
671
|
+
- `scry` answers a query from the snapshot; `formatScryResult` prints it; `parseScryQuery` reads
|
|
672
|
+
CLI arguments into a query.
|
|
673
|
+
- `checkGrimoire` runs every rule; `formatCheckReport` prints the report. Each finding has a code
|
|
674
|
+
from `GRIMOIRE_CODES` (also `GRIMOIRE_CODE_LIST`); `explainGrimoireCode`, `isGrimoireCode` and
|
|
675
|
+
`grimoireCodeDocsUrl` (based on `GRIMOIRE_CODES_DOCS_URL`) describe it, and rules build
|
|
676
|
+
findings with `createFinding`. Commands throw `GrimoireError` with a code.
|
|
677
|
+
- `collectRelease`, `renderCollectedList` and `writeRelease` gather the changelog entries of a
|
|
678
|
+
release between `COLLECTED_START_MARKER` and `COLLECTED_END_MARKER`.
|
|
679
|
+
- `scanProofs` and `scanProofsInText` read `// @proves` lines; `criterionStatus` turns test
|
|
680
|
+
results into a criterion's status; `CASE_QUESTIONS` lists the questions every flow answers.
|
|
681
|
+
- Helpers: `loadBook`, `readFrontMatter`, `fileGraph`, `importClosure`, `importerClosure`,
|
|
682
|
+
`bookEntryPath`, `bookEntryPaths`, `toPosixPath`, `GRIMOIRE_DIR`, `GRIMOIRE_PATHS`,
|
|
683
|
+
`GRIMOIRE_IGNORE_RULES` (the `.gitignore` lines) and `BOOK_SCHEMA_VERSION`.
|
|
684
|
+
|
|
685
|
+
From `@warlock.js/grimoire/warlock` (needs `@warlock.js/core`): `registerGrimoireCommands` returns
|
|
686
|
+
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;
|
|
688
|
+
`collectMobileFacts` lists mobile screens from Expo Router file names.
|
|
689
|
+
|
|
690
|
+
From `@warlock.js/grimoire/vitest`: `grimoireReporter` records the last result of every test marked
|
|
691
|
+
`// @proves` into `grimoire/book/test-results.json`. Add it to the Vitest `reporters` list.
|
|
692
|
+
|
|
693
|
+
From `@warlock.js/grimoire/devtools`: `grimoireDevtoolsPanel` (the default export) is the Grimoire
|
|
694
|
+
tab for `@warlock.js/devtools`, listed in `panels` of `src/config/devtools.ts`;
|
|
695
|
+
`exportGrimoireSite` writes the same view as a static site.
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
## write-a-feature `@warlock.js/grimoire/skills/write-a-feature/SKILL.md`
|
|
699
|
+
|
|
700
|
+
---
|
|
701
|
+
name: write-a-feature
|
|
702
|
+
description: "Describe a new feature, or a new version of one, in `grimoire/features/` before writing code: the task, the brief, the README front matter, each flow with its steps, cases and acceptance criteria. Use when the owner asks for something the product does not do yet."
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
# Write a feature
|
|
706
|
+
|
|
707
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
708
|
+
|
|
709
|
+
Describe the behaviour first, then build it. The description is the brief the owner approves and
|
|
710
|
+
the thing your tests will prove.
|
|
711
|
+
|
|
712
|
+
## Is it a feature, a flow, or a change?
|
|
713
|
+
|
|
714
|
+
- **A feature** is something a user or another system can do, named from their side (`auth`,
|
|
715
|
+
`catalog`, `orders`). It has roughly two to ten flows.
|
|
716
|
+
- **A flow** is one path through it (`sign-up`, `google-login`, `new-arrivals`).
|
|
717
|
+
- **A new capability** in an existing feature is a new whole-number version (`2.0`) with its
|
|
718
|
+
own brief. **A small change or a fix** is a decimal (`2.1`) and needs no brief: go to
|
|
719
|
+
`record-a-change`.
|
|
720
|
+
- A notification, mail or job belongs to the feature whose business reason creates it. "Your
|
|
721
|
+
order shipped" belongs to `orders`, not to `notifications`.
|
|
722
|
+
|
|
723
|
+
## 1. Open a task
|
|
724
|
+
|
|
725
|
+
`grimoire/tasks/open/T-014-wishlist.md`:
|
|
726
|
+
|
|
727
|
+
```md
|
|
728
|
+
---
|
|
729
|
+
id: T-014
|
|
730
|
+
type: feature
|
|
731
|
+
feature: catalog
|
|
732
|
+
apps: [web-client, mobile]
|
|
733
|
+
status: waiting for approval
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
# Let customers save products to a wishlist
|
|
737
|
+
|
|
738
|
+
- Asked by: the owner, 2026-11-16
|
|
739
|
+
- Why: customers ask to keep products for later
|
|
740
|
+
- Brief: features/catalog/versions/v3.md
|
|
741
|
+
- Decision needed: one wishlist per customer, or several named lists?
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
A task that waits for the owner's answer has `status: waiting for approval` and a `Decision needed:` line.
|
|
745
|
+
The other statuses are `open`, `approved`, `in progress`, `blocked`, `done` and `dropped`; any other
|
|
746
|
+
word is an error (`GR1004`).
|
|
747
|
+
|
|
748
|
+
## 2. Write the brief
|
|
749
|
+
|
|
750
|
+
`grimoire/features/catalog/versions/v3.md`: why, what changes (which flows are new or changed),
|
|
751
|
+
and what is out of scope. Keep it to one screen.
|
|
752
|
+
|
|
753
|
+
## 3. Write or update the feature README
|
|
754
|
+
|
|
755
|
+
```md
|
|
756
|
+
---
|
|
757
|
+
id: catalog
|
|
758
|
+
title: Product catalog
|
|
759
|
+
status: proposed
|
|
760
|
+
version: 3.0
|
|
761
|
+
updated: 2026-11-16
|
|
762
|
+
apps: [web-client, mobile]
|
|
763
|
+
folders: [src/app/catalog, src/web/$sites/client/products]
|
|
764
|
+
---
|
|
765
|
+
|
|
766
|
+
# Product catalog
|
|
767
|
+
|
|
768
|
+
Customers browse products, search them and see what is new.
|
|
769
|
+
|
|
770
|
+
## Flows
|
|
771
|
+
|
|
772
|
+
- browse-products list and filter products
|
|
773
|
+
- new-arrivals the newest products sold in the customer's country
|
|
774
|
+
- wishlist save a product for later
|
|
775
|
+
|
|
776
|
+
## Affects and affected by
|
|
777
|
+
|
|
778
|
+
- affected by orders/place-order (lowers stock)
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
`id` never changes. `folders` are the folders whose files belong to this feature. An entry with a
|
|
782
|
+
code-file extension names one file (`src/web/components/client/home/pricing-table.tsx`), for a
|
|
783
|
+
feature that owns a few files in a folder shared with others. A file entry wins over the folder
|
|
784
|
+
of another feature; each file has one owner. `apps` must
|
|
785
|
+
exist under `grimoire/apps/`. A feature whose folders hold no file yet is fine while it is
|
|
786
|
+
`proposed`.
|
|
787
|
+
|
|
788
|
+
## 4. Write each flow
|
|
789
|
+
|
|
790
|
+
`grimoire/features/catalog/flows/wishlist.md`:
|
|
791
|
+
|
|
792
|
+
```md
|
|
793
|
+
---
|
|
794
|
+
id: wishlist
|
|
795
|
+
since: 3.0
|
|
796
|
+
status: proposed
|
|
797
|
+
who: customer
|
|
798
|
+
---
|
|
799
|
+
|
|
800
|
+
# Save a product to the wishlist
|
|
801
|
+
|
|
802
|
+
## Steps
|
|
803
|
+
|
|
804
|
+
1. page /products/:id
|
|
805
|
+
2. route POST /wishlist
|
|
806
|
+
3. notification wishlist-price-drop
|
|
807
|
+
4. page /wishlist
|
|
808
|
+
|
|
809
|
+
## Differs by app
|
|
810
|
+
|
|
811
|
+
- mobile the save button is also on the product card in lists
|
|
812
|
+
|
|
813
|
+
## Cases
|
|
814
|
+
|
|
815
|
+
- invalid input a product id that is not an id → 422
|
|
816
|
+
- not allowed guest → sent to sign in, then back to the product
|
|
817
|
+
- not found the product does not exist → 404
|
|
818
|
+
- duplicate already saved → stays saved, no error
|
|
819
|
+
- limits at most 200 products
|
|
820
|
+
- expiry does not apply: saved products do not expire
|
|
821
|
+
- double submit two taps save once
|
|
822
|
+
- outside service down does not apply: no outside service is called
|
|
823
|
+
|
|
824
|
+
## Acceptance criteria
|
|
825
|
+
|
|
826
|
+
- AC-1 a saved product appears on /wishlist
|
|
827
|
+
- AC-2 saving twice keeps one entry
|
|
828
|
+
- AC-3 a guest is sent to sign in and returns to the product
|
|
829
|
+
- AC-4 [mobile] the product card has a save button
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
**Steps.** Each step has a kind and the name used in code: `page`, `route`, `mail`,
|
|
833
|
+
`notification`, `job`, `event`, `outside service`. Use `affects` for an effect on another
|
|
834
|
+
feature (`affects catalog/stock`). Warlock checks every name exists. A mail is a `*.mail.ts` or
|
|
835
|
+
`*.email.ts` file, or a file in a `mails/` or `emails/` folder; a job is a queue job
|
|
836
|
+
(`defineJob()`) or a scheduled task, by its name in code.
|
|
837
|
+
|
|
838
|
+
When two sites, or a site and the mobile app, have a page with the same path, name the app after
|
|
839
|
+
the path in brackets: `page /support [web-admin]`. The step then looks in that app only (its
|
|
840
|
+
pages, or its screens for a mobile app). Without brackets it looks in the apps the feature lists.
|
|
841
|
+
|
|
842
|
+
**Cases.** Answer all eight questions (invalid input, not allowed, not found, duplicate, limits,
|
|
843
|
+
expiry, double submit, outside service down), each with a case or "does not apply" and the
|
|
844
|
+
reason. A flow that skips one gets a finding. Do not invent cases beyond the questions unless the owner described one.
|
|
845
|
+
|
|
846
|
+
**Criteria.** One per case that changes what the user gets. Number them `AC-1`, `AC-2`, … and
|
|
847
|
+
never renumber. Scope one to an app with `[app-id]`.
|
|
848
|
+
|
|
849
|
+
**App differences.** What the user gets differs → here, under the app's name. How it looks or
|
|
850
|
+
where it sits → the app's block file (`describe-an-app`).
|
|
851
|
+
|
|
852
|
+
## 5. Stop for approval
|
|
853
|
+
|
|
854
|
+
For a new feature or a whole-number version, stop here. Tell the owner the task id and the brief
|
|
855
|
+
path, list the decisions you need, and wait. Do not write code first.
|
|
856
|
+
|
|
857
|
+
## 6. Check
|
|
858
|
+
|
|
859
|
+
```bash
|
|
860
|
+
npx warlock grimoire check
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
Until the code exists it reports the routes and pages you named as missing. Findings on a flow or
|
|
864
|
+
feature with `status: proposed` print with `(expected)` and do not fail the check; everything else
|
|
865
|
+
it reports must be fixed.
|
|
866
|
+
|
|
867
|
+
Then build, and follow `record-a-change`.
|
|
868
|
+
|
|
869
|
+
|