@warlock.js/grimoire 5.63.0 → 5.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +24 -2
- package/esm/book/build.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +11 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/api-snapshot.mjs +39 -0
- package/esm/check/rules/api-snapshot.mjs.map +1 -0
- package/esm/check/rules/code-rules.mjs +45 -0
- package/esm/check/rules/code-rules.mjs.map +1 -0
- package/esm/check/rules/drift.mjs +54 -0
- package/esm/check/rules/drift.mjs.map +1 -0
- package/esm/check/rules/focused-tests.mjs +39 -0
- package/esm/check/rules/focused-tests.mjs.map +1 -0
- package/esm/check/rules/shows.mjs +52 -0
- package/esm/check/rules/shows.mjs.map +1 -0
- package/esm/codes/codes.d.mts +48 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +26 -1
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/guard.d.mts +104 -0
- package/esm/contracts/guard.d.mts.map +1 -0
- package/esm/contracts/index.mjs +5 -0
- package/esm/contracts/matrix.d.mts +75 -0
- package/esm/contracts/matrix.d.mts.map +1 -0
- package/esm/contracts/scry.d.mts +21 -0
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/settings.d.mts +71 -0
- package/esm/contracts/settings.d.mts.map +1 -0
- package/esm/contracts/settings.mjs +67 -0
- package/esm/contracts/settings.mjs.map +1 -0
- package/esm/contracts/shots.d.mts +146 -0
- package/esm/contracts/shots.d.mts.map +1 -0
- package/esm/contracts/snapshot.d.mts +10 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +13 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs +7 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/approvals.mjs +59 -0
- package/esm/devtools/approvals.mjs.map +1 -0
- package/esm/devtools/data.mjs +2 -0
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/graphs.mjs +13 -3
- package/esm/devtools/graphs.mjs.map +1 -1
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +32 -2
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/matrix.mjs +207 -0
- package/esm/devtools/matrix.mjs.map +1 -0
- package/esm/devtools/product-map.d.mts.map +1 -1
- package/esm/devtools/product-map.mjs +87 -1
- package/esm/devtools/product-map.mjs.map +1 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +12 -3
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +5 -1
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/git/index.d.mts +20 -0
- package/esm/git/index.d.mts.map +1 -0
- package/esm/git/index.mjs +280 -0
- package/esm/git/index.mjs.map +1 -0
- package/esm/guard/api.mjs +70 -0
- package/esm/guard/api.mjs.map +1 -0
- package/esm/guard/assertions.mjs +18 -0
- package/esm/guard/assertions.mjs.map +1 -0
- package/esm/guard/collect.mjs +139 -0
- package/esm/guard/collect.mjs.map +1 -0
- package/esm/guard/format.mjs +27 -0
- package/esm/guard/format.mjs.map +1 -0
- package/esm/guard/glob.mjs +79 -0
- package/esm/guard/glob.mjs.map +1 -0
- package/esm/guard/index.mjs +9 -0
- package/esm/guard/rules.mjs +310 -0
- package/esm/guard/rules.mjs.map +1 -0
- package/esm/guard/scope.mjs +95 -0
- package/esm/guard/scope.mjs.map +1 -0
- package/esm/index.d.mts +10 -3
- package/esm/index.mjs +6 -2
- package/esm/paths/index.d.mts +15 -1
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +27 -3
- package/esm/paths/index.mjs.map +1 -1
- package/esm/proves/index.mjs +2 -1
- package/esm/proves/scan-proofs.mjs +1 -1
- package/esm/proves/scan-proofs.mjs.map +1 -1
- package/esm/proves/scan-shows.d.mts +21 -0
- package/esm/proves/scan-shows.d.mts.map +1 -0
- package/esm/proves/scan-shows.mjs +168 -0
- package/esm/proves/scan-shows.mjs.map +1 -0
- package/esm/releases/index.d.mts.map +1 -1
- package/esm/releases/index.mjs +5 -3
- package/esm/releases/index.mjs.map +1 -1
- package/esm/releases/stamp.mjs +121 -0
- package/esm/releases/stamp.mjs.map +1 -0
- package/esm/rules/focused.mjs +26 -0
- package/esm/rules/focused.mjs.map +1 -0
- package/esm/rules/index.mjs +88 -0
- package/esm/rules/index.mjs.map +1 -0
- package/esm/rules/logical-css.mjs +112 -0
- package/esm/rules/logical-css.mjs.map +1 -0
- package/esm/rules/no-js-imports.mjs +22 -0
- package/esm/rules/no-js-imports.mjs.map +1 -0
- package/esm/rules/scan.mjs +196 -0
- package/esm/rules/scan.mjs.map +1 -0
- package/esm/rules/specific-errors.mjs +51 -0
- package/esm/rules/specific-errors.mjs.map +1 -0
- package/esm/rules/type-discriminator.mjs +27 -0
- package/esm/rules/type-discriminator.mjs.map +1 -0
- package/esm/scry/also-changes.mjs +106 -0
- package/esm/scry/also-changes.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +22 -0
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +7 -2
- package/esm/scry/query.mjs.map +1 -1
- package/esm/scry/search.d.mts.map +1 -1
- package/esm/scry/search.mjs +43 -11
- package/esm/scry/search.mjs.map +1 -1
- package/esm/shots/approve.mjs +195 -0
- package/esm/shots/approve.mjs.map +1 -0
- package/esm/shots/drift.mjs +174 -0
- package/esm/shots/drift.mjs.map +1 -0
- package/esm/shots/png.mjs +166 -0
- package/esm/shots/png.mjs.map +1 -0
- package/esm/shots/state.mjs +43 -0
- package/esm/shots/state.mjs.map +1 -0
- package/esm/shots/store.mjs +66 -0
- package/esm/shots/store.mjs.map +1 -0
- package/esm/shots/touched.mjs +38 -0
- package/esm/shots/touched.mjs.map +1 -0
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +15 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/api-command.mjs +41 -0
- package/esm/warlock/api-command.mjs.map +1 -0
- package/esm/warlock/approve-command.mjs +80 -0
- package/esm/warlock/approve-command.mjs.map +1 -0
- package/esm/warlock/commands.d.mts +1 -1
- package/esm/warlock/commands.d.mts.map +1 -1
- package/esm/warlock/commands.mjs +61 -8
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/guard-command.mjs +116 -0
- package/esm/warlock/guard-command.mjs.map +1 -0
- package/esm/warlock/index.d.mts +2 -1
- package/esm/warlock/index.mjs +2 -1
- package/esm/warlock/languages.mjs +75 -0
- package/esm/warlock/languages.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +2 -2
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/warlock/release-command.mjs +65 -0
- package/esm/warlock/release-command.mjs.map +1 -0
- package/esm/warlock/shows.d.mts +35 -0
- package/esm/warlock/shows.d.mts.map +1 -0
- package/esm/warlock/shows.mjs +195 -0
- package/esm/warlock/shows.mjs.map +1 -0
- package/esm/workspace/cache.mjs +4 -1
- package/esm/workspace/cache.mjs.map +1 -1
- package/esm/workspace/derived.mjs +11 -6
- package/esm/workspace/derived.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +8 -1
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/workspace/stored.mjs +4 -1
- package/esm/workspace/stored.mjs.map +1 -1
- package/esm/written/features.mjs +21 -5
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/index.mjs +2 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +16 -3
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/esm/written/settings.d.mts +11 -0
- package/esm/written/settings.d.mts.map +1 -0
- package/esm/written/settings.mjs +88 -0
- package/esm/written/settings.mjs.map +1 -0
- package/llms-full.txt +276 -39
- package/llms.txt +2 -0
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +4 -0
- package/skills/describe-an-app/SKILL.md +4 -1
- package/skills/guard-a-change/SKILL.md +85 -0
- package/skills/index.md +7 -3
- package/skills/record-a-change/SKILL.md +52 -16
- package/skills/review-a-change/SKILL.md +53 -0
- package/skills/use-the-grimoire/SKILL.md +21 -18
- package/skills/write-a-feature/SKILL.md +42 -1
- package/ui/grimoire-view.js +756 -40
- package/ui/grimoire.css +303 -28
- package/ui/product-map.css +43 -7
- package/ui/product-map.js +212 -37
package/llms-full.txt
CHANGED
|
@@ -14,21 +14,25 @@ description: "Grimoire (experimental), the project map for Warlock.js apps: `war
|
|
|
14
14
|
|
|
15
15
|
The Grimoire is experimental: its file structure and commands may still change.
|
|
16
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
|
|
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, apart from the changelog stamp you ask for with `warlock grimoire release --stamp`.
|
|
18
18
|
|
|
19
19
|
## The 80% path
|
|
20
20
|
|
|
21
21
|
1. Before searching the code, ask the map: `use-the-grimoire.md`.
|
|
22
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`.
|
|
23
|
+
3. After the change, tie tests to criteria (`@proves`, and `@shows` for what the user sees), 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
24
|
4. Pages, blocks, conditions and mobile screens: `describe-an-app.md`.
|
|
25
25
|
5. The header and export comments the book copies from a file: `document-a-file.md`.
|
|
26
26
|
6. A project with code but no `grimoire/` folder: `backfill-a-grimoire.md`.
|
|
27
|
+
7. Keep a change inside its task (features, `Files:`, locked tests, protected areas) and run `warlock grimoire guard` before you stop: `guard-a-change.md`.
|
|
28
|
+
8. Review a change from its task and its diff only, never from the author's summary: `review-a-change.md`.
|
|
27
29
|
|
|
28
30
|
## Conventions and pitfalls
|
|
29
31
|
|
|
30
32
|
- Never edit `grimoire/book/`, `index.json`, `bookmap.json` or `*.bookmap.json`.
|
|
31
|
-
-
|
|
33
|
+
- `warlock grimoire release <version> --stamp` moves every `## Unreleased` entry under the release and writes a missing release file; without `--stamp` it only writes the collected list.
|
|
34
|
+
- Every project has a design-system feature first (`grimoire/features/design-system/`); flows with a page step name it in `affects`.
|
|
35
|
+
- Only the owner approves a changed screenshot or a removed criterion (`warlock grimoire approve`); list every change that is not approved in your report.
|
|
32
36
|
- A finding marked `(expected)` belongs to `proposed` work and does not fail `warlock grimoire check`.
|
|
33
37
|
- Mobile screens are listed from file names only with file-based routing; declare them when navigation is in code.
|
|
34
38
|
- Do not invent intent: write `Unknown:` and ask the owner.
|
|
@@ -71,6 +75,10 @@ Start from the modules: a module is usually one feature. Then adjust.
|
|
|
71
75
|
- Mail, notifications, search: the machinery is a feature; each mail or notification belongs to
|
|
72
76
|
the feature that sends it.
|
|
73
77
|
|
|
78
|
+
In a project with a UI, write the `design-system` feature first (`write-a-feature`), as `inferred`:
|
|
79
|
+
direction, components, error messages. Add `grimoire/settings.md` with the app's `languages`; the
|
|
80
|
+
Warlock adapter would read `app.localeCodes` anyway, but the file makes the choice visible.
|
|
81
|
+
|
|
74
82
|
Write the proposal as a table for the owner **before** writing files:
|
|
75
83
|
|
|
76
84
|
| Feature | Folders | Flows you see | Apps | Unsure about |
|
|
@@ -317,7 +325,10 @@ flow: catalog/new-arrivals
|
|
|
317
325
|
Keep image files in `grimoire/screenshots/` (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`), for example
|
|
318
326
|
`grimoire/screenshots/web/home.png`. Write an image line `` anywhere in a page, screen
|
|
319
327
|
or block file, with the path relative to the Markdown file or starting with `/grimoire/screenshots/`.
|
|
320
|
-
The Product map shows these as "where you see it".
|
|
328
|
+
The Product map shows these as "where you see it". These are images you attach by hand. The
|
|
329
|
+
captures of `@shows` scenes (one per criterion and language) and their approved versions are made by
|
|
330
|
+
Warlock under `grimoire/screenshots/captured/` and `approved/`: never write those paths into a page
|
|
331
|
+
or block file. An image outside the folder is a warning
|
|
321
332
|
(`GR1029`); a missing file is a warning (`GR2014`).
|
|
322
333
|
|
|
323
334
|
## Where a difference between apps goes
|
|
@@ -430,6 +441,95 @@ them. `npx warlock grimoire check` reports a file with no header and a file with
|
|
|
430
441
|
- Do not copy the flow's text into the file. The flow lives in `grimoire/features/`.
|
|
431
442
|
|
|
432
443
|
|
|
444
|
+
## guard-a-change `@warlock.js/grimoire/skills/guard-a-change/SKILL.md`
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
name: guard-a-change
|
|
448
|
+
description: "Keep a change inside its task and prove it with `warlock grimoire guard`: files outside the task, deleted proving tests, removed criteria, locked tests, protected areas, the public API snapshot, the code rules and a task id in every commit. Use before you stop work on a task, in CI, and when `GR7006`-`GR7013`, `GR3007`-`GR3010`, `GR4011`, `GR4012` or `GR9008` appear."
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
# Guard a change
|
|
452
|
+
|
|
453
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
454
|
+
|
|
455
|
+
Agents drift: they remove, change or add things nobody asked for. The guard compares your diff with the task and says what the task did not ask for. Run it before you stop.
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
npx warlock grimoire guard # the one task in progress
|
|
459
|
+
npx warlock grimoire guard T-12 # a task by number (T-12, 12 and T-012 match the same task)
|
|
460
|
+
npx warlock grimoire guard T-12 --base origin/main
|
|
461
|
+
npx warlock grimoire guard --base origin/main --commits origin/main..HEAD # CI
|
|
462
|
+
npx warlock grimoire guard --hook # agent hook: findings on stderr, exit code 2 on an error
|
|
463
|
+
npx warlock grimoire guard --json
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
It never boots the app. The change is the diff from the base (default: where your branch left the default branch) to the working tree, including staged, unstaged and untracked files. Exit code 0 means no error, 1 an error, and with `--hook` 2 (and 0 when it cannot run, such as no task, or when the hook already sent you back once: then finish and list what is left in your report).
|
|
467
|
+
|
|
468
|
+
## What it checks
|
|
469
|
+
|
|
470
|
+
| Code | What |
|
|
471
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
472
|
+
| `GR7006` | A changed file is outside the task: not owned by its feature (or `Features:`), not a file its flow reaches, not a test proving its criteria, not in `Files:`. |
|
|
473
|
+
| `GR7007` | A flow, criterion or case in `grimoire/features/` is gone and `Removes:` does not name it. |
|
|
474
|
+
| `GR7008` | A `@proves` test is gone and no other test proves that criterion, and `Removes:` does not name it. |
|
|
475
|
+
| `GR7009` | A file in `Locked:` was changed, renamed or deleted. |
|
|
476
|
+
| `GR7010` | A changed test has fewer assertions than at the base (`expect(`, `expect.soft(`, `assert(`, `assert.x(`, `.should(`; a warning). |
|
|
477
|
+
| `GR7011` | A protected area changed and the task's `Touches:` does not name it. |
|
|
478
|
+
| `GR7012` | A commit of `--commits` names no task (`T-12`), or a task that has no file. Merge commits are skipped. |
|
|
479
|
+
| `GR7013` | `grimoire check` warns when the routes differ from the approved API (the guard raises `GR7011` for `public-api`). |
|
|
480
|
+
| `GR3007`-`GR3010` | The code rules, on the lines the change adds. |
|
|
481
|
+
| `GR4011`, `GR4012` | An added `.only` or `.skip` (both errors in the guard). |
|
|
482
|
+
| `GR9008` | No task: pass one, name it in a commit, or have exactly one task `in progress`. |
|
|
483
|
+
| `GR9009` | Git could not answer: run in a repository, pass a base that exists, fetch the full history in CI. |
|
|
484
|
+
|
|
485
|
+
It also prints the changes that are not approved (`not approved: <n> changes`, from the approved baseline and the screenshots). They do not fail the guard; list them in your report.
|
|
486
|
+
|
|
487
|
+
## The task body fields
|
|
488
|
+
|
|
489
|
+
```md
|
|
490
|
+
- Files: src/app/shared/utils/money.ts, src/config/catalog.ts
|
|
491
|
+
- Features: orders, catalog/wishlist
|
|
492
|
+
- Locked: src/app/catalog/tests/wishlist.test.ts
|
|
493
|
+
- Touches: migrations, dependencies
|
|
494
|
+
- Removes: catalog/wishlist AC-3, catalog/wishlist case duplicate
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Add a line only when the owner agreed; otherwise change the code. A path with no wildcard matches itself and everything under it; `**` crosses folders, `*` stays inside one.
|
|
498
|
+
|
|
499
|
+
## Protected areas
|
|
500
|
+
|
|
501
|
+
`migrations`, `auth`, `config`, `lockfile`, `dependencies` and `public-api` (`DEFAULT_PROTECTED_AREAS`). `dependencies` fires only when a `package.json` adds or changes a dependency entry, not for every edit of the file. `public-api` is the difference between the routes and `grimoire/approved/api.json`; approve a deliberate change with `npx warlock grimoire approve api` (it reads the cached route facts, so run `warlock grimoire build` first). Add or replace areas in `grimoire/settings.md`:
|
|
502
|
+
|
|
503
|
+
```md
|
|
504
|
+
---
|
|
505
|
+
protected:
|
|
506
|
+
- payments src/app/payments/** src/config/payments.ts
|
|
507
|
+
---
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
## The code rules
|
|
511
|
+
|
|
512
|
+
`rules:` in `grimoire/settings.md` names the rules `grimoire check` runs on every file (`CODE_RULES`: `logical-css`, `specific-errors`, `type-discriminator`, `no-js-imports`). With no `rules:` key, `check` runs none and the guard runs all four on added lines; `rules: []` turns them off.
|
|
513
|
+
|
|
514
|
+
| Rule | Code | Flags | Write instead |
|
|
515
|
+
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
516
|
+
| `logical-css` | `GR3007` | `margin-left`, `padding-right`, `left:`, `text-align: left`, `float: right`, `border-left`, Tailwind `ml-4` `pr-2` `left-0` `text-left` `rounded-l-lg` `border-r` (with variants and `-` prefixes), style keys `marginLeft`, `textAlign: "left"` | `margin-inline-start`, `inset-inline-start`, `text-align: start`, `ms-4`, `pe-2`, `start-0`, `text-start`, `rounded-s-lg` |
|
|
517
|
+
| `specific-errors` | `GR3008` | a string that is only "Something went wrong", "An error occurred", "Unknown error", "حدث خطأ ما"…, in code and locale files (`error` and `oops` alone in locale values) | say what failed and what to do next, mapped from the error code |
|
|
518
|
+
| `type-discriminator` | `GR3009` | `kind: "a"`, `kind?: "a" \| "b"` | `type: "a"` |
|
|
519
|
+
| `no-js-imports` | `GR3010` | relative `import`/`export … from`/`import()` paths ending `.js`, `.jsx`, `.mjs`, `.cjs` | `./orders.service` |
|
|
520
|
+
|
|
521
|
+
Escape hatch, in a comment on the line or the line above, with a reason: `grimoire-allow logical-css: the code block reads left to right`. Spec files, `node_modules`, `dist` and `grimoire/` are skipped. The scanner reads text, not a syntax tree: JSX text with an apostrophe, regular expressions and your own assertion helpers are read loosely, and editors show no squiggles for these rules.
|
|
522
|
+
|
|
523
|
+
## When it fails
|
|
524
|
+
|
|
525
|
+
1. Read each finding: the file and line, then the task it is outside of.
|
|
526
|
+
2. Undo what the task did not ask for. Do not edit a locked test, delete a proving test, or add `.skip`.
|
|
527
|
+
3. If the file really belongs to the task, add it to `Files:` (or the feature to `Features:`) and say why in the task body, with the owner's agreement.
|
|
528
|
+
4. Run the guard again until it prints `guard: ok`.
|
|
529
|
+
|
|
530
|
+
In CI the scaffold's `.github/workflows/grimoire-guard.yml` runs it on every pull request; the `Stop` hook in `.claude/settings.json` runs `warlock grimoire guard --hook` when an agent finishes.
|
|
531
|
+
|
|
532
|
+
|
|
433
533
|
## record-a-change `@warlock.js/grimoire/skills/record-a-change/SKILL.md`
|
|
434
534
|
|
|
435
535
|
---
|
|
@@ -454,6 +554,26 @@ it("returns the global list when the customer has no country", async () => {
|
|
|
454
554
|
});
|
|
455
555
|
```
|
|
456
556
|
|
|
557
|
+
A criterion about what a user sees is shown instead, by a browser scene in `e2e/*.e2e.ts`. Put the
|
|
558
|
+
comment directly above a `shows()` call that repeats the same criterion:
|
|
559
|
+
|
|
560
|
+
```ts
|
|
561
|
+
import { shows } from "@warlock.js/grimoire/warlock";
|
|
562
|
+
|
|
563
|
+
// @shows contact/send-message AC-3
|
|
564
|
+
await shows(context, "contact/send-message AC-3", async ({ page, language, path }) => {
|
|
565
|
+
await page.mockRequests([{ url: "/api/contact", fail: "unreachable" }]);
|
|
566
|
+
await page.goto(path("/"));
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
`shows()` runs the scene once per language and saves a screenshot each (`GRIMOIRE_SHOTS=all`
|
|
571
|
+
captures every flow, not only the touched ones). A scene that throws fails that language. The owner
|
|
572
|
+
approves the images with `warlock grimoire approve`; list every `GR4017` (image changed), `GR4018`
|
|
573
|
+
(flow, criterion, case or proof changed) and `GR4019` (rejected change still there) of the check in
|
|
574
|
+
your report, and never edit `grimoire/approved/` yourself. From code, `scanShows` reads the `@shows`
|
|
575
|
+
lines of the test files and `resolveSettings` fills the defaults of `grimoire/settings.md`.
|
|
576
|
+
|
|
457
577
|
- End-to-end tests prove a flow's steps. Unit tests prove a business rule ("a reset code expires
|
|
458
578
|
after 10 minutes").
|
|
459
579
|
- One test may prove one criterion. If it needs two tags, split the test.
|
|
@@ -502,6 +622,8 @@ Add two lines: how it was verified (which tests, which criteria) and anything le
|
|
|
502
622
|
something is left open, open a new task for it; do not leave it only in the done file. A task
|
|
503
623
|
that needs the owner's answer gets `status: waiting for approval` and a `Decision needed:` line.
|
|
504
624
|
|
|
625
|
+
Name the task id (`T-12`) in every commit message of the change; `warlock grimoire guard --commits <range>` fails a commit that names none.
|
|
626
|
+
|
|
505
627
|
## 5. Check
|
|
506
628
|
|
|
507
629
|
```bash
|
|
@@ -528,16 +650,30 @@ folder is not committed, so run the tests with the reporter in CI and ship the r
|
|
|
528
650
|
deploy. To write it elsewhere, pass `grimoireReporter({ file })` and point the devtools panel at it
|
|
529
651
|
with the `testResultsFile` option.
|
|
530
652
|
|
|
653
|
+
Then check the change against its task, before you stop:
|
|
654
|
+
|
|
655
|
+
```bash
|
|
656
|
+
npx warlock grimoire guard T-12
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
It lists files outside the task, deleted proving tests, removed criteria or cases, edited locked tests, protected areas the task does not name, and the code rules on the lines you added. Fix the code rather than widening the task; add a `Files:`, `Touches:` or `Removes:` line only when the owner agreed (`guard-a-change`).
|
|
660
|
+
|
|
531
661
|
Fix every line it prints. Do not finish with problems you caused. Findings on a flow or feature
|
|
532
662
|
with `status: proposed` print with `(expected)` and do not fail the check: leave them until the
|
|
533
663
|
code exists.
|
|
534
664
|
|
|
535
665
|
## 6. At release time
|
|
536
666
|
|
|
537
|
-
|
|
667
|
+
Run the stamp from the app's release flow, after the version is set in `package.json`:
|
|
538
668
|
|
|
539
|
-
|
|
540
|
-
|
|
669
|
+
```bash
|
|
670
|
+
npx warlock grimoire release --stamp
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
It does three things, in this order, and prints what it did (`stamped catalog, orders → 1.4.1 (2026-11-20)`):
|
|
674
|
+
|
|
675
|
+
1. **Stamps the changelogs.** In each feature that has entries under `## Unreleased`, it moves them under a
|
|
676
|
+
heading with the release number and date, and leaves an empty `## Unreleased` above:
|
|
541
677
|
|
|
542
678
|
```md
|
|
543
679
|
## Unreleased
|
|
@@ -548,7 +684,9 @@ Warlock does not edit your files at release. You do three things, in this order:
|
|
|
548
684
|
instead of the global one (AC-2)
|
|
549
685
|
```
|
|
550
686
|
|
|
551
|
-
2. **
|
|
687
|
+
2. **Writes the release file** `grimoire/releases/1.4.1.md` when it is missing, with its front matter, a
|
|
688
|
+
`# Release 1.4.1` heading and a one-line brief that names the changed features. An existing release file is kept.
|
|
689
|
+
**Rewrite the brief in the owner's words**: two or three sentences on what the release means to users.
|
|
552
690
|
|
|
553
691
|
```md
|
|
554
692
|
---
|
|
@@ -561,18 +699,14 @@ Warlock does not edit your files at release. You do three things, in this order:
|
|
|
561
699
|
Customers with no country on their account see new arrivals again.
|
|
562
700
|
```
|
|
563
701
|
|
|
564
|
-
|
|
702
|
+
3. **Collects the list** between the markers under your brief. Run `npx warlock grimoire release 1.4.1` again after
|
|
703
|
+
any change to a changelog or the brief: the result is the same every time. It also says how many entries are
|
|
704
|
+
still unreleased. Do not write that list yourself.
|
|
565
705
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
It writes the entries you stamped with that release between the markers under your brief, and
|
|
573
|
-
changes nothing else. It also says how many entries are still unreleased. Do not write that list
|
|
574
|
-
yourself, and run the command again after any change to a changelog: the result is the same
|
|
575
|
-
every time.
|
|
706
|
+
The version is the app's `package.json` version unless you pass one (`release 1.4.1 --stamp`); the date is today unless
|
|
707
|
+
the release file has one or you pass `--date yyyy-mm-dd`. The stamp is the only edit Warlock makes to your files, and
|
|
708
|
+
only with `--stamp`. Without it you move the entries and write the release file by hand, as above, and run
|
|
709
|
+
`npx warlock grimoire release 1.4.1`.
|
|
576
710
|
|
|
577
711
|
`npx warlock grimoire check` reports a listed entry that has no changelog entry stamped with that
|
|
578
712
|
release and date, and a release section with no release file.
|
|
@@ -580,7 +714,66 @@ release and date, and a release section with no release file.
|
|
|
580
714
|
## Report to the owner
|
|
581
715
|
|
|
582
716
|
Say what changed in plain words, the feature version, which criteria are proven, what the check
|
|
583
|
-
reported, and what is left open with its task id.
|
|
717
|
+
reported, and what is left open with its task id. Paste the result of `npx warlock grimoire guard`,
|
|
718
|
+
and list every change that is not approved (`warlock grimoire check` `GR4017`, `GR4018`, `GR4019`) by
|
|
719
|
+
its id; leave none out.
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
## review-a-change `@warlock.js/grimoire/skills/review-a-change/SKILL.md`
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
name: review-a-change
|
|
726
|
+
description: "Review a change as an independent reviewer who sees only the task and the diff, never the author's summary, and answers one question: list every change the task did not ask for. Use when asked to review work an agent or a colleague finished, before a merge."
|
|
727
|
+
---
|
|
728
|
+
|
|
729
|
+
# Review a change
|
|
730
|
+
|
|
731
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
732
|
+
|
|
733
|
+
The reviewer is independent. It reads two things only: the task file and the diff. It does not read the author's summary, the commit messages' explanations or the author's report; they describe what the author meant, not what changed.
|
|
734
|
+
|
|
735
|
+
## Input
|
|
736
|
+
|
|
737
|
+
1. The task file (`grimoire/tasks/open/T-12-….md` or `grimoire/tasks/done/…`), including its `Files:`, `Features:`, `Locked:`, `Touches:` and `Removes:` lines.
|
|
738
|
+
2. The diff: `git diff <base>...HEAD`, where `<base>` is the branch the change merges into (`origin/main`).
|
|
739
|
+
|
|
740
|
+
## The question
|
|
741
|
+
|
|
742
|
+
Ask exactly this, and answer it before anything else:
|
|
743
|
+
|
|
744
|
+
> List every change the task did not ask for.
|
|
745
|
+
|
|
746
|
+
Go file by file through the diff. For each hunk say which sentence or acceptance criterion of the task asks for it. A hunk no sentence asks for goes on the list: an unasked file, a removed or reworded criterion, a deleted or weakened test, a renamed export, a changed dependency, a new behaviour, a refactor. "Harmless" and "an improvement" are not reasons to leave it out.
|
|
747
|
+
|
|
748
|
+
## Then
|
|
749
|
+
|
|
750
|
+
1. Run the guard and paste its output:
|
|
751
|
+
|
|
752
|
+
```bash
|
|
753
|
+
npx warlock grimoire guard <task> --base <base>
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
2. List every drift item that is not approved, by id, from `npx warlock grimoire check` (`GR4017` capture differs, `GR4018` structure changed, `GR4019` rejected change still there). Leave none out and do not approve any: only the owner approves.
|
|
757
|
+
3. Say whether the change is ready: yes only when the list of unasked changes is empty (or each item is named in the task and approved by the owner), the guard prints `guard: ok`, and no drift item is open.
|
|
758
|
+
|
|
759
|
+
## Report shape
|
|
760
|
+
|
|
761
|
+
```md
|
|
762
|
+
Unasked changes
|
|
763
|
+
|
|
764
|
+
- <file>: <what changed>, no sentence of the task asks for it
|
|
765
|
+
|
|
766
|
+
Guard
|
|
767
|
+
<the pasted output>
|
|
768
|
+
|
|
769
|
+
Not approved
|
|
770
|
+
|
|
771
|
+
- <drift item id>
|
|
772
|
+
|
|
773
|
+
Verdict: ready | not ready, because …
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
An empty "Unasked changes" section says "none" and the reviewer says which files it read.
|
|
584
777
|
|
|
585
778
|
|
|
586
779
|
## use-the-grimoire `@warlock.js/grimoire/skills/use-the-grimoire/SKILL.md`
|
|
@@ -613,9 +806,7 @@ edits a file you wrote either.
|
|
|
613
806
|
|
|
614
807
|
## Start of every task
|
|
615
808
|
|
|
616
|
-
1.
|
|
617
|
-
|
|
618
|
-
Pass the whole task sentence (the commit title or the bug report), not two keywords:
|
|
809
|
+
1. `scry --search "<the whole request>"`: pass the whole task sentence (the commit title or the bug report), not two keywords.
|
|
619
810
|
|
|
620
811
|
```bash
|
|
621
812
|
npx warlock scry --search "new arrivals are empty for customers with no country"
|
|
@@ -623,22 +814,27 @@ edits a file you wrote either.
|
|
|
623
814
|
|
|
624
815
|
```text
|
|
625
816
|
21.4 flow catalog/new-arrivals New arrivals
|
|
626
|
-
12.9 block web-client/home/new-arrivals catalog/new-arrivals
|
|
627
|
-
11.3 route GET /api/products/new-arrivals catalog.new-arrivals
|
|
628
817
|
9.8 file src/app/catalog/services/new-arrivals.service.ts Lists the newest products sold in the customer's country.
|
|
818
|
+
changes with the top hits:
|
|
819
|
+
src/app/catalog/repositories/products.repository.ts imported by new-arrivals.service.ts
|
|
820
|
+
src/app/catalog/tests/new-arrivals.test.ts test
|
|
821
|
+
next: warlock scry --impact src/app/catalog/services/new-arrivals.service.ts
|
|
629
822
|
```
|
|
630
823
|
|
|
631
|
-
The number in front is the score: hits are in score order, best first, whatever
|
|
824
|
+
The number in front is the score: hits are in score order, best first, whatever the type.
|
|
632
825
|
|
|
633
|
-
2.
|
|
634
|
-
|
|
826
|
+
2. `scry --impact <top file>` (the `next:` line) and read the `changes with` lines: they are the files that usually change
|
|
827
|
+
with it (what it imports and what imports it inside the same feature, and its tests).
|
|
828
|
+
3. Use grep only for literal text, or when the answer says `weak match`.
|
|
829
|
+
4. Read the feature's `README.md`, then the flow file. They say what the behaviour should be.
|
|
830
|
+
5. Ask for the flow's book map. It lists the files behind each step, the tests that prove each
|
|
635
831
|
criterion and the pages that show the flow.
|
|
636
832
|
|
|
637
833
|
```bash
|
|
638
834
|
npx warlock scry --flow catalog/new-arrivals
|
|
639
835
|
```
|
|
640
836
|
|
|
641
|
-
|
|
837
|
+
6. Read only those files. Do not read a whole module to find one function.
|
|
642
838
|
|
|
643
839
|
## Questions the book answers
|
|
644
840
|
|
|
@@ -661,7 +857,7 @@ build, then ask again. A project with no book stops with `GR9007`. A note
|
|
|
661
857
|
|
|
662
858
|
Add `--json` for machine-readable output; a failed call then prints `{ "type": "error", "code", "message", "fix" }` on stdout and exits 1 (the scry MCP tools return the same JSON as their error text). `--impact` lists API routes, pages, flows and features,
|
|
663
859
|
including features that only borrow the file; each list has a count and stops at 20 lines, and `--all`
|
|
664
|
-
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Read the flows it names and run their tests after
|
|
860
|
+
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Specs, locale files and type files rank below code of an equal match. Search reads Arabic and accented Latin text too: accents, Arabic vowel marks, hamza forms and the leading article `ال` do not matter (`شحنة` finds `الشحنة`, `cafe` finds `café`). The answer's `alsoChanges` list (`changes with the top hits:`, at most 10 files) and `next` line come from the top three hits; `weak: true` (the line `weak match: …`) says no hit holds most of the request's words. Read the flows it names and run their tests after
|
|
665
861
|
your change.
|
|
666
862
|
|
|
667
863
|
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|
|
@@ -669,14 +865,14 @@ in `grimoire/book/app/auth/controllers/login.controller.json`.
|
|
|
669
865
|
|
|
670
866
|
## Commands
|
|
671
867
|
|
|
672
|
-
| Command | Does
|
|
673
|
-
| ------------------------------------------- |
|
|
674
|
-
| `warlock grimoire build` | Builds or refreshes the book (and its derived data). Run it after you finish editing; `scry` only reads and never builds
|
|
675
|
-
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`); skipped when the folder is already current (`--force` writes it)
|
|
676
|
-
| `warlock grimoire build --site --product` | Writes the business export: the Product map only, no file paths, test names or per-file answers
|
|
677
|
-
| `warlock grimoire check` | Reports broken names, untested criteria, files with no owner. Exit 1 on an error; `--all` lists every warning
|
|
678
|
-
| `warlock grimoire release <release>` | Writes the collected list into `grimoire/releases/<release>.md`
|
|
679
|
-
| `warlock explain GR2001` | Explains a finding code
|
|
868
|
+
| Command | Does |
|
|
869
|
+
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
870
|
+
| `warlock grimoire build` | Builds or refreshes the book (and its derived data). Run it after you finish editing; `scry` only reads and never builds |
|
|
871
|
+
| `warlock grimoire build --site [--out dir]` | Also writes the book as a static site (default `grimoire/book/site`); skipped when the folder is already current (`--force` writes it) |
|
|
872
|
+
| `warlock grimoire build --site --product` | Writes the business export: the Product map only, no file paths, test names or per-file answers |
|
|
873
|
+
| `warlock grimoire check` | Reports broken names, untested criteria, files with no owner. Exit 1 on an error; `--all` lists every warning |
|
|
874
|
+
| `warlock grimoire release <release>` | Writes the collected list into `grimoire/releases/<release>.md`; with `--stamp` it first moves `## Unreleased` entries under the version |
|
|
875
|
+
| `warlock explain GR2001` | Explains a finding code |
|
|
680
876
|
|
|
681
877
|
Every finding has a code (`GR2001`) and a fix hint. A finding marked `(expected)` belongs to work
|
|
682
878
|
that is still `proposed`; it does not fail the check.
|
|
@@ -823,6 +1019,24 @@ status: waiting for approval
|
|
|
823
1019
|
- Decision needed: one wishlist per customer, or several named lists?
|
|
824
1020
|
```
|
|
825
1021
|
|
|
1022
|
+
The guard (`warlock grimoire guard`, see `guard-a-change`) reads these optional body lines, comma-separated:
|
|
1023
|
+
|
|
1024
|
+
```md
|
|
1025
|
+
- Files: src/app/shared/utils/money.ts, src/config/catalog.ts
|
|
1026
|
+
- Features: orders, catalog/wishlist
|
|
1027
|
+
- Locked: src/app/catalog/tests/wishlist.test.ts
|
|
1028
|
+
- Touches: migrations, dependencies
|
|
1029
|
+
- Removes: catalog/wishlist AC-3, catalog/wishlist case duplicate
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
- `Files:` lists files (globs allowed) outside the task's feature that the change must touch.
|
|
1033
|
+
- `Features:` names more features (`orders`) or flows (`catalog/wishlist`) the change may touch.
|
|
1034
|
+
- `Locked:` names the acceptance tests the planner wrote first. Whoever builds the task never edits them.
|
|
1035
|
+
- `Touches:` names the protected areas the task may change: `migrations`, `auth`, `config`, `lockfile`, `dependencies`, `public-api`, or an area of `grimoire/settings.md`.
|
|
1036
|
+
- `Removes:` names the flow, criterion or case that is allowed to go (`<feature>/<flow>`, `<feature>/<flow> AC-3`, `<feature>/<flow> case duplicate`).
|
|
1037
|
+
|
|
1038
|
+
Write the acceptance tests first, with their `@proves` lines, and list them in `Locked:` before handing the task to an implementer. The task's `feature` and `flow` already put that feature's files and the flow's files in scope; add `Files:` for the rest at the start, not after the guard fails.
|
|
1039
|
+
|
|
826
1040
|
A task that waits for the owner's answer has `status: waiting for approval` and a `Decision needed:` line.
|
|
827
1041
|
The other statuses are `open`, `approved`, `in progress`, `blocked`, `done` and `dropped`; any other
|
|
828
1042
|
word is an error (`GR1004`).
|
|
@@ -832,6 +1046,16 @@ word is an error (`GR1004`).
|
|
|
832
1046
|
`grimoire/features/catalog/versions/v3.md`: why, what changes (which flows are new or changed),
|
|
833
1047
|
and what is out of scope. Keep it to one screen.
|
|
834
1048
|
|
|
1049
|
+
## Write `design-system` first
|
|
1050
|
+
|
|
1051
|
+
In a project that has a UI, create the `design-system` feature before any other. Its flows are the
|
|
1052
|
+
rules every screen follows: `direction` (inputs and text follow the reading direction, a page is
|
|
1053
|
+
mirrored in Arabic), `components` (every component renders in each language), `error-messages`
|
|
1054
|
+
(every error says what failed and what to do next), plus spacing and colours (contrast) when the
|
|
1055
|
+
project has rules for them. Every flow with a `page` step names `design-system` under
|
|
1056
|
+
`## Affects and affected by` (`- affects design-system`), so a change to a screen is checked against it.
|
|
1057
|
+
Its criteria are shown with `@shows` scenes (`record-a-change`).
|
|
1058
|
+
|
|
835
1059
|
## 3. Write or update the feature README
|
|
836
1060
|
|
|
837
1061
|
```md
|
|
@@ -919,6 +1143,8 @@ A customer saves a product they like and finds it again later on their wishlist.
|
|
|
919
1143
|
- expiry does not apply: saved products do not expire
|
|
920
1144
|
- double submit two taps save once
|
|
921
1145
|
- outside service down does not apply: no outside service is called
|
|
1146
|
+
- server unreachable the save button shows "Could not reach the server, check your connection" (AC-5)
|
|
1147
|
+
- server error the product stays unsaved and the message says what failed (AC-5)
|
|
922
1148
|
|
|
923
1149
|
## Acceptance criteria
|
|
924
1150
|
|
|
@@ -926,6 +1152,7 @@ A customer saves a product they like and finds it again later on their wishlist.
|
|
|
926
1152
|
- AC-2 saving twice keeps one entry
|
|
927
1153
|
- AC-3 a guest is sent to sign in and returns to the product
|
|
928
1154
|
- AC-4 [mobile] the product card has a save button
|
|
1155
|
+
- AC-5 a failed save says what failed and what to do next
|
|
929
1156
|
```
|
|
930
1157
|
|
|
931
1158
|
**Summary.** The paragraph under the `# Title`: one or two plain sentences saying who does what and
|
|
@@ -955,10 +1182,20 @@ When two sites, or a site and the mobile app, have a page with the same path, na
|
|
|
955
1182
|
the path in brackets: `page /support [web-admin]`. The step then looks in that app only (its
|
|
956
1183
|
pages, or its screens for a mobile app). Without brackets it looks in the apps the feature lists.
|
|
957
1184
|
|
|
1185
|
+
**Screenshots of a flow.** Criteria about what a user sees are shown in each language of the app
|
|
1186
|
+
(`languages` in `grimoire/settings.md`), so one criterion gives one screenshot per language. Write a
|
|
1187
|
+
criterion once; do not write one per language. A flow with nothing to look at (no screen, or a
|
|
1188
|
+
screen that cannot be captured) says `screenshots: false` in its front matter. `screenshots` is
|
|
1189
|
+
`false` or absent; the modes `changed`, `all` and `off` live in the settings
|
|
1190
|
+
(`SCREENSHOT_MODES`, default `DEFAULT_GRIMOIRE_SETTINGS.screenshots`, `changed`).
|
|
1191
|
+
|
|
958
1192
|
**Cases.** End a case line with `(AC-n)` (or `(AC-1, AC-2)`) to link it to the criterion that
|
|
959
1193
|
proves it; a number the flow does not have is an error (`GR2013`). Answer all eight questions (invalid input, not allowed, not found, duplicate, limits,
|
|
960
1194
|
expiry, double submit, outside service down), each with a case or "does not apply" and the
|
|
961
|
-
reason. A flow
|
|
1195
|
+
reason. A flow with a `page` step also answers the two UI questions (`UI_CASE_QUESTIONS`):
|
|
1196
|
+
`server unreachable` (what the user sees when the request never arrives) and `server error`
|
|
1197
|
+
(when the server answers with a failure); the screen of each is shown with a scene that mocks
|
|
1198
|
+
the request. A flow that skips one gets a finding, except that a flow with no writes (only pages and
|
|
962
1199
|
`GET` routes) may leave out `duplicate` and `double submit`. Do not invent cases beyond the questions unless the owner described one.
|
|
963
1200
|
|
|
964
1201
|
**Criteria.** One per case that changes what the user gets. Number them `AC-1`, `AC-2`, … and
|
package/llms.txt
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
- [backfill-a-grimoire](@warlock.js/grimoire/skills/backfill-a-grimoire/SKILL.md): 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.
|
|
11
11
|
- [describe-an-app](@warlock.js/grimoire/skills/describe-an-app/SKILL.md): 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.
|
|
12
12
|
- [document-a-file](@warlock.js/grimoire/skills/document-a-file/SKILL.md): 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.
|
|
13
|
+
- [guard-a-change](@warlock.js/grimoire/skills/guard-a-change/SKILL.md): Keep a change inside its task and prove it with `warlock grimoire guard`: files outside the task, deleted proving tests, removed criteria, locked tests, protected areas, the public API snapshot, the code rules and a task id in every commit. Use before you stop work on a task, in CI, and when `GR7006`-`GR7013`, `GR3007`-`GR3010`, `GR4011`, `GR4012` or `GR9008` appear.
|
|
13
14
|
- [record-a-change](@warlock.js/grimoire/skills/record-a-change/SKILL.md): 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.
|
|
15
|
+
- [review-a-change](@warlock.js/grimoire/skills/review-a-change/SKILL.md): Review a change as an independent reviewer who sees only the task and the diff, never the author's summary, and answers one question: list every change the task did not ask for. Use when asked to review work an agent or a colleague finished, before a merge.
|
|
14
16
|
- [use-the-grimoire](@warlock.js/grimoire/skills/use-the-grimoire/SKILL.md): 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.
|
|
15
17
|
- [write-a-feature](@warlock.js/grimoire/skills/write-a-feature/SKILL.md): 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.
|
package/package.json
CHANGED
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"environment": "server"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@warlock.js/core": "5.
|
|
30
|
-
"@warlock.js/web": "5.
|
|
29
|
+
"@warlock.js/core": "5.64.0",
|
|
30
|
+
"@warlock.js/web": "5.64.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
"@warlock.js/web": {
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"version": "5.
|
|
37
|
+
"version": "5.64.0",
|
|
38
38
|
"type": "module",
|
|
39
39
|
"main": "./esm/index.mjs",
|
|
40
40
|
"module": "./esm/index.mjs",
|
|
@@ -33,6 +33,10 @@ Start from the modules: a module is usually one feature. Then adjust.
|
|
|
33
33
|
- Mail, notifications, search: the machinery is a feature; each mail or notification belongs to
|
|
34
34
|
the feature that sends it.
|
|
35
35
|
|
|
36
|
+
In a project with a UI, write the `design-system` feature first (`write-a-feature`), as `inferred`:
|
|
37
|
+
direction, components, error messages. Add `grimoire/settings.md` with the app's `languages`; the
|
|
38
|
+
Warlock adapter would read `app.localeCodes` anyway, but the file makes the choice visible.
|
|
39
|
+
|
|
36
40
|
Write the proposal as a table for the owner **before** writing files:
|
|
37
41
|
|
|
38
42
|
| Feature | Folders | Flows you see | Apps | Unsure about |
|
|
@@ -142,7 +142,10 @@ flow: catalog/new-arrivals
|
|
|
142
142
|
Keep image files in `grimoire/screenshots/` (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`), for example
|
|
143
143
|
`grimoire/screenshots/web/home.png`. Write an image line `` anywhere in a page, screen
|
|
144
144
|
or block file, with the path relative to the Markdown file or starting with `/grimoire/screenshots/`.
|
|
145
|
-
The Product map shows these as "where you see it".
|
|
145
|
+
The Product map shows these as "where you see it". These are images you attach by hand. The
|
|
146
|
+
captures of `@shows` scenes (one per criterion and language) and their approved versions are made by
|
|
147
|
+
Warlock under `grimoire/screenshots/captured/` and `approved/`: never write those paths into a page
|
|
148
|
+
or block file. An image outside the folder is a warning
|
|
146
149
|
(`GR1029`); a missing file is a warning (`GR2014`).
|
|
147
150
|
|
|
148
151
|
## Where a difference between apps goes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: guard-a-change
|
|
3
|
+
description: "Keep a change inside its task and prove it with `warlock grimoire guard`: files outside the task, deleted proving tests, removed criteria, locked tests, protected areas, the public API snapshot, the code rules and a task id in every commit. Use before you stop work on a task, in CI, and when `GR7006`-`GR7013`, `GR3007`-`GR3010`, `GR4011`, `GR4012` or `GR9008` appear."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Guard a change
|
|
7
|
+
|
|
8
|
+
The Grimoire is experimental: its file structure and commands may still change.
|
|
9
|
+
|
|
10
|
+
Agents drift: they remove, change or add things nobody asked for. The guard compares your diff with the task and says what the task did not ask for. Run it before you stop.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx warlock grimoire guard # the one task in progress
|
|
14
|
+
npx warlock grimoire guard T-12 # a task by number (T-12, 12 and T-012 match the same task)
|
|
15
|
+
npx warlock grimoire guard T-12 --base origin/main
|
|
16
|
+
npx warlock grimoire guard --base origin/main --commits origin/main..HEAD # CI
|
|
17
|
+
npx warlock grimoire guard --hook # agent hook: findings on stderr, exit code 2 on an error
|
|
18
|
+
npx warlock grimoire guard --json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
It never boots the app. The change is the diff from the base (default: where your branch left the default branch) to the working tree, including staged, unstaged and untracked files. Exit code 0 means no error, 1 an error, and with `--hook` 2 (and 0 when it cannot run, such as no task, or when the hook already sent you back once: then finish and list what is left in your report).
|
|
22
|
+
|
|
23
|
+
## What it checks
|
|
24
|
+
|
|
25
|
+
| Code | What |
|
|
26
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| `GR7006` | A changed file is outside the task: not owned by its feature (or `Features:`), not a file its flow reaches, not a test proving its criteria, not in `Files:`. |
|
|
28
|
+
| `GR7007` | A flow, criterion or case in `grimoire/features/` is gone and `Removes:` does not name it. |
|
|
29
|
+
| `GR7008` | A `@proves` test is gone and no other test proves that criterion, and `Removes:` does not name it. |
|
|
30
|
+
| `GR7009` | A file in `Locked:` was changed, renamed or deleted. |
|
|
31
|
+
| `GR7010` | A changed test has fewer assertions than at the base (`expect(`, `expect.soft(`, `assert(`, `assert.x(`, `.should(`; a warning). |
|
|
32
|
+
| `GR7011` | A protected area changed and the task's `Touches:` does not name it. |
|
|
33
|
+
| `GR7012` | A commit of `--commits` names no task (`T-12`), or a task that has no file. Merge commits are skipped. |
|
|
34
|
+
| `GR7013` | `grimoire check` warns when the routes differ from the approved API (the guard raises `GR7011` for `public-api`). |
|
|
35
|
+
| `GR3007`-`GR3010` | The code rules, on the lines the change adds. |
|
|
36
|
+
| `GR4011`, `GR4012` | An added `.only` or `.skip` (both errors in the guard). |
|
|
37
|
+
| `GR9008` | No task: pass one, name it in a commit, or have exactly one task `in progress`. |
|
|
38
|
+
| `GR9009` | Git could not answer: run in a repository, pass a base that exists, fetch the full history in CI. |
|
|
39
|
+
|
|
40
|
+
It also prints the changes that are not approved (`not approved: <n> changes`, from the approved baseline and the screenshots). They do not fail the guard; list them in your report.
|
|
41
|
+
|
|
42
|
+
## The task body fields
|
|
43
|
+
|
|
44
|
+
```md
|
|
45
|
+
- Files: src/app/shared/utils/money.ts, src/config/catalog.ts
|
|
46
|
+
- Features: orders, catalog/wishlist
|
|
47
|
+
- Locked: src/app/catalog/tests/wishlist.test.ts
|
|
48
|
+
- Touches: migrations, dependencies
|
|
49
|
+
- Removes: catalog/wishlist AC-3, catalog/wishlist case duplicate
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Add a line only when the owner agreed; otherwise change the code. A path with no wildcard matches itself and everything under it; `**` crosses folders, `*` stays inside one.
|
|
53
|
+
|
|
54
|
+
## Protected areas
|
|
55
|
+
|
|
56
|
+
`migrations`, `auth`, `config`, `lockfile`, `dependencies` and `public-api` (`DEFAULT_PROTECTED_AREAS`). `dependencies` fires only when a `package.json` adds or changes a dependency entry, not for every edit of the file. `public-api` is the difference between the routes and `grimoire/approved/api.json`; approve a deliberate change with `npx warlock grimoire approve api` (it reads the cached route facts, so run `warlock grimoire build` first). Add or replace areas in `grimoire/settings.md`:
|
|
57
|
+
|
|
58
|
+
```md
|
|
59
|
+
---
|
|
60
|
+
protected:
|
|
61
|
+
- payments src/app/payments/** src/config/payments.ts
|
|
62
|
+
---
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## The code rules
|
|
66
|
+
|
|
67
|
+
`rules:` in `grimoire/settings.md` names the rules `grimoire check` runs on every file (`CODE_RULES`: `logical-css`, `specific-errors`, `type-discriminator`, `no-js-imports`). With no `rules:` key, `check` runs none and the guard runs all four on added lines; `rules: []` turns them off.
|
|
68
|
+
|
|
69
|
+
| Rule | Code | Flags | Write instead |
|
|
70
|
+
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `logical-css` | `GR3007` | `margin-left`, `padding-right`, `left:`, `text-align: left`, `float: right`, `border-left`, Tailwind `ml-4` `pr-2` `left-0` `text-left` `rounded-l-lg` `border-r` (with variants and `-` prefixes), style keys `marginLeft`, `textAlign: "left"` | `margin-inline-start`, `inset-inline-start`, `text-align: start`, `ms-4`, `pe-2`, `start-0`, `text-start`, `rounded-s-lg` |
|
|
72
|
+
| `specific-errors` | `GR3008` | a string that is only "Something went wrong", "An error occurred", "Unknown error", "حدث خطأ ما"…, in code and locale files (`error` and `oops` alone in locale values) | say what failed and what to do next, mapped from the error code |
|
|
73
|
+
| `type-discriminator` | `GR3009` | `kind: "a"`, `kind?: "a" \| "b"` | `type: "a"` |
|
|
74
|
+
| `no-js-imports` | `GR3010` | relative `import`/`export … from`/`import()` paths ending `.js`, `.jsx`, `.mjs`, `.cjs` | `./orders.service` |
|
|
75
|
+
|
|
76
|
+
Escape hatch, in a comment on the line or the line above, with a reason: `grimoire-allow logical-css: the code block reads left to right`. Spec files, `node_modules`, `dist` and `grimoire/` are skipped. The scanner reads text, not a syntax tree: JSX text with an apostrophe, regular expressions and your own assertion helpers are read loosely, and editors show no squiggles for these rules.
|
|
77
|
+
|
|
78
|
+
## When it fails
|
|
79
|
+
|
|
80
|
+
1. Read each finding: the file and line, then the task it is outside of.
|
|
81
|
+
2. Undo what the task did not ask for. Do not edit a locked test, delete a proving test, or add `.skip`.
|
|
82
|
+
3. If the file really belongs to the task, add it to `Files:` (or the feature to `Features:`) and say why in the task body, with the owner's agreement.
|
|
83
|
+
4. Run the guard again until it prints `guard: ok`.
|
|
84
|
+
|
|
85
|
+
In CI the scaffold's `.github/workflows/grimoire-guard.yml` runs it on every pull request; the `Stop` hook in `.claude/settings.json` runs `warlock grimoire guard --hook` when an agent finishes.
|