rulebookguard 0.11.0 → 0.13.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.
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: rules
3
+ description: Business rules protocol for repositories with a rulebookguard.config.yaml. Use before changing code that may implement a business rule, when a rulebookguard hook injects rules for a file, or when asked to add, change or retire a business rule.
4
+ ---
5
+
6
+ # Business rules (rulebookguard)
7
+
8
+ In this repository the business rules in the rulebook (`rulesDir` in `rulebookguard.config.yaml`, `docs/rules` by default) are the source of truth. Code implements them and tests verify them. Never infer a business rule from the code alone when a rule file exists.
9
+
10
+ ## Before changing code
11
+
12
+ 1. Before editing a file, a hook or a steering file may add the active rules anchored to it; if neither did, ask the `rules_for` tool (or `rulebookguard for <path>`). When a hook lists rule texts as omitted, read each rule with the `rules_show` tool (or `rulebookguard show <id>`).
13
+ 2. For a file you have not edited yet, or a broader change, ask the `rules_for` tool (or `rulebookguard for <path>`).
14
+ For a change that is not tied to one file, read the rulebook by levels: the `contexts` tool, then `rules_list` for the contexts involved, then `rules_show` for the relevant rules. `rules_search` finds rules by words.
15
+ 3. Keep the change consistent with every rule listed. If the change would alter what a rule says, stop and tell the user which rule conflicts and how; do not change the behavior silently.
16
+
17
+ ## Changing a rule
18
+
19
+ Only when the user asks for the behavior change:
20
+
21
+ 1. Edit the rule file first: its summary, body and examples. A new rule starts with `rulebookguard new <context>` as `proposed`; it becomes `active` only when the user confirms it.
22
+ 2. Update or add the tests that verify it. A test links to a rule by sitting between a `@rule <ID>` comment right above it and an `@endrule <ID>` comment right after it; the link lives only in the test.
23
+ 3. Change the code until those tests pass. If the rule already has `@implements <ID>` … `@endimplements <ID>` regions, keep the enforcing code inside them. Add a new region only when the user asks for one, in a file the rule anchors: regions are optional.
24
+ 4. Run `rulebookguard lint` or the `lint` tool, and `rulebookguard lint --base <base branch>` before opening a pull request. A changed rule whose tagging tests did not change fails as `pending-implementation`.
25
+
26
+ Retire a rule by setting `status: deprecated` and removing its `@rule`/`@endrule` tags and its `@implements`/`@endimplements` regions; a replacement rule names it in `supersedes`.
27
+
28
+ A rule that needs another one in force lists it in `dependsOn`; two rules that cannot both be active list each other in `conflictsWith`. `lint` rejects unknown ids, `dependsOn` cycles and two active rules in conflict.
@@ -1,148 +0,0 @@
1
- {
2
- "name": "rulebookguard",
3
- "version": "0.11.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "rulebookguard",
9
- "version": "0.11.0",
10
- "license": "MIT",
11
- "dependencies": {
12
- "@modelcontextprotocol/server": "2.3.1",
13
- "ajv": "8.20.0",
14
- "picomatch": "4.0.7",
15
- "yaml": "2.9.1",
16
- "zod": "4.6.7"
17
- },
18
- "bin": {
19
- "rulebookguard": "dist/cli.mjs"
20
- },
21
- "engines": {
22
- "node": ">=22"
23
- },
24
- "peerDependencies": {
25
- "@rulebookguard/site": "^0.11.0"
26
- },
27
- "peerDependenciesMeta": {
28
- "@rulebookguard/site": {
29
- "optional": true
30
- }
31
- }
32
- },
33
- "node_modules/@modelcontextprotocol/core": {
34
- "version": "2.3.1",
35
- "resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.3.1.tgz",
36
- "integrity": "sha512-laVmIhPGpWi7rG9q+0UigblRN0Hws/Yjlb6qLFtVqryXVLkc4h+yN8z731POD2LnAGQlFe7/tXhUm7Bi0YB91g==",
37
- "license": "Apache-2.0",
38
- "dependencies": {
39
- "zod": "^4.2.0"
40
- },
41
- "engines": {
42
- "node": ">=20"
43
- }
44
- },
45
- "node_modules/@modelcontextprotocol/server": {
46
- "version": "2.3.1",
47
- "resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.3.1.tgz",
48
- "integrity": "sha512-e59MfWuSssj6DoQ96JCTqdW1AXT5/XtnTl0WWd6MU1Ka434fFUGGosCLJbGNySDhHGvxQWoRWK137FXYFkYNWw==",
49
- "license": "Apache-2.0",
50
- "dependencies": {
51
- "@modelcontextprotocol/core": "2.3.1",
52
- "zod": "^4.2.0"
53
- },
54
- "engines": {
55
- "node": ">=20"
56
- }
57
- },
58
- "node_modules/ajv": {
59
- "version": "8.20.0",
60
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
61
- "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
62
- "license": "MIT",
63
- "dependencies": {
64
- "fast-deep-equal": "^3.1.3",
65
- "fast-uri": "^3.0.1",
66
- "json-schema-traverse": "^1.0.0",
67
- "require-from-string": "^2.0.2"
68
- },
69
- "funding": {
70
- "type": "github",
71
- "url": "https://github.com/sponsors/epoberezkin"
72
- }
73
- },
74
- "node_modules/fast-deep-equal": {
75
- "version": "3.1.3",
76
- "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
77
- "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
78
- "license": "MIT"
79
- },
80
- "node_modules/fast-uri": {
81
- "version": "3.1.9",
82
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
83
- "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
84
- "funding": [
85
- {
86
- "type": "github",
87
- "url": "https://github.com/sponsors/fastify"
88
- },
89
- {
90
- "type": "opencollective",
91
- "url": "https://opencollective.com/fastify"
92
- }
93
- ],
94
- "license": "BSD-3-Clause"
95
- },
96
- "node_modules/json-schema-traverse": {
97
- "version": "1.0.0",
98
- "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
99
- "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
100
- "license": "MIT"
101
- },
102
- "node_modules/picomatch": {
103
- "version": "4.0.7",
104
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
105
- "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
106
- "license": "MIT",
107
- "engines": {
108
- "node": ">=12"
109
- },
110
- "funding": {
111
- "url": "https://github.com/sponsors/jonschlinkert"
112
- }
113
- },
114
- "node_modules/require-from-string": {
115
- "version": "2.0.2",
116
- "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
117
- "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
118
- "license": "MIT",
119
- "engines": {
120
- "node": ">=0.10.0"
121
- }
122
- },
123
- "node_modules/yaml": {
124
- "version": "2.9.1",
125
- "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
126
- "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
127
- "license": "ISC",
128
- "bin": {
129
- "yaml": "bin.mjs"
130
- },
131
- "engines": {
132
- "node": ">= 14.6"
133
- },
134
- "funding": {
135
- "url": "https://github.com/sponsors/eemeli"
136
- }
137
- },
138
- "node_modules/zod": {
139
- "version": "4.6.7",
140
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
141
- "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
142
- "license": "MIT",
143
- "funding": {
144
- "url": "https://github.com/sponsors/colinhacks"
145
- }
146
- }
147
- }
148
- }