@jpeakai/prose-gates 0.1.1 → 0.2.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/README.md +37 -4
- package/dist/bin.js +8472 -539
- package/dist/index.js +8500 -540
- package/dist/testing.js +18321 -0
- package/examples/plugin-skills/README.md +60 -0
- package/examples/plugin-skills/index.mjs +14 -0
- package/examples/plugin-skills/package.json +12 -0
- package/examples/plugin-skills/rules/frontmatter-description-multiline-string.mjs +63 -0
- package/examples/plugin-skills/rules/frontmatter-description-word-budget.mjs +35 -0
- package/examples/plugin-skills-typescript/README.md +42 -0
- package/examples/plugin-skills-typescript/index.ts +21 -0
- package/examples/plugin-skills-typescript/package.json +12 -0
- package/examples/plugin-skills-typescript/rules/frontmatter-description-multiline-string.ts +68 -0
- package/examples/plugin-skills-typescript/rules/frontmatter-description-word-budget.ts +40 -0
- package/examples/plugin-skills-typescript/tsconfig.json +14 -0
- package/package.json +10 -3
- package/src/bin.ts +2 -2
- package/src/check.ts +40 -13
- package/src/cli.ts +197 -28
- package/src/config.ts +119 -0
- package/src/errors.ts +191 -0
- package/src/fix/engine.ts +31 -9
- package/src/fix/promote.ts +14 -2
- package/src/fix/verify.ts +29 -0
- package/src/index.ts +38 -2
- package/src/interpunct.ts +48 -0
- package/src/model.ts +129 -12
- package/src/plugins/contract.ts +41 -0
- package/src/plugins/discover.ts +140 -0
- package/src/plugins/index.ts +103 -0
- package/src/plugins/load.ts +234 -0
- package/src/plugins/runtime.ts +15 -0
- package/src/project.ts +81 -0
- package/src/query.ts +131 -0
- package/src/rules/index.ts +31 -12
- package/src/rules/list-comma-labelled-run.ts +101 -0
- package/src/rules/list-inline-enumeration-markers.ts +127 -0
- package/src/rules/list-interpunct-joined-run.ts +68 -0
- package/src/rules/list-semicolon-delimited-run.ts +60 -0
- package/src/rules/list-stacked-interpunct-runs.ts +80 -0
- package/src/rules/punctuation-em-dash-in-prose.ts +155 -0
- package/src/rules/punctuation-interpunct-in-prose.ts +52 -0
- package/src/rules/registry.ts +133 -0
- package/src/rules/sentence-one-per-line.ts +99 -0
- package/src/rules/{pg002-length.ts → sentence-word-budget-exceeded.ts} +22 -20
- package/src/rules/types.ts +70 -25
- package/src/testing.ts +60 -0
- package/src/text.ts +50 -0
- package/src/fix/spans.ts +0 -75
- package/src/rules/interpunct.ts +0 -19
- package/src/rules/pg001-wrap.ts +0 -79
- package/src/rules/pg003-semicolon-list.ts +0 -68
- package/src/rules/pg004-em-dash.ts +0 -117
- package/src/rules/pg005-interpunct.ts +0 -43
- package/src/rules/pg006-interpunct-run.ts +0 -84
- package/src/rules/pg007-inline-enum.ts +0 -119
- package/src/rules/pg008-labelled-run.ts +0 -94
- package/src/rules/pg009-stacked-runs.ts +0 -79
package/README.md
CHANGED
|
@@ -19,18 +19,23 @@ npx -y @jpeakai/prose-gates --fix README.md # apply every fix proven safe, repo
|
|
|
19
19
|
Installed as a dev dependency, the command is `prose-gates`, and `--json` gives machine-readable output.
|
|
20
20
|
|
|
21
21
|
`--max-words N` changes the sentence budget, which defaults to 25.
|
|
22
|
+
`--config FILE` reads a config other than the one at the project root.
|
|
23
|
+
`--no-plugins` runs the built-in rules only, and `--lenient-plugins` skips a plugin that fails to load and says so.
|
|
24
|
+
`--validate-plugins` loads and checks every plugin, reports every failure, and runs no check or fix.
|
|
25
|
+
`--list-rules` prints every active rule by category, including plugin rules.
|
|
22
26
|
Exit codes are 0 for clean, 1 for findings, and 2 for a usage error.
|
|
23
27
|
|
|
24
28
|
## The rules
|
|
25
29
|
|
|
26
30
|
Nine rules in three categories.
|
|
27
31
|
[RULES.md](RULES.md) shows a failing example and the fix for each one.
|
|
32
|
+
[docs/DATA_MODEL.md](docs/DATA_MODEL.md) diagrams how a rule is checked, fixed and verified.
|
|
28
33
|
|
|
29
34
|
| Category | Rules | What it guards |
|
|
30
35
|
|---|---|---|
|
|
31
|
-
| Sentence |
|
|
32
|
-
| List |
|
|
33
|
-
| Punctuation |
|
|
36
|
+
| Sentence | sentence-one-per-line, sentence-word-budget-exceeded | How a sentence is laid out and how long it runs |
|
|
37
|
+
| List | list-semicolon-delimited-run, list-interpunct-joined-run, list-inline-enumeration-markers, list-comma-labelled-run, list-stacked-interpunct-runs | A list hidden in running prose, promoted to a real markdown list |
|
|
38
|
+
| Punctuation | punctuation-em-dash-in-prose, punctuation-interpunct-in-prose | A glyph that reads as generated text |
|
|
34
39
|
|
|
35
40
|
Every fix is verified before it is written.
|
|
36
41
|
A fix that would change a word, url or code value is a bug and fails the run.
|
|
@@ -40,6 +45,33 @@ The reasoning behind each choice is recorded in [`adrs/`](adrs/index.md).
|
|
|
40
45
|
Code blocks are exempt.
|
|
41
46
|
Fences tagged `markdown` or `md` are the exception, since they hold templates whose body is audited recursively.
|
|
42
47
|
|
|
48
|
+
## Plugins and local rules
|
|
49
|
+
|
|
50
|
+
A project adds its own rules without forking this package.
|
|
51
|
+
Both sources load on their own, with no config, and every run prints a line saying what it loaded.
|
|
52
|
+
|
|
53
|
+
- **Local rules.** A `.js`, `.mjs`, `.ts` or `.mts` file in `.prose-gates/rules/` exports one rule, and its id is `local/` followed by the file name. TypeScript needs Bun or Node 22.18 or newer.
|
|
54
|
+
- **Plugin packages.** A dependency named `prose-gates-plugin-name` or `@scope/prose-gates-plugin-name` loads under the namespace its own `meta.namespace` declares.
|
|
55
|
+
- **New categories.** A plugin declares a category of its own, such as `frontmatter`, and its rules use it.
|
|
56
|
+
- **Same treatment.** A plugin rule is switched off, given options and listed exactly like a built-in, and its fixer is verified like a built-in fixer.
|
|
57
|
+
|
|
58
|
+
A config at the project root switches rules off and sets options.
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"rules": {
|
|
63
|
+
"list-semicolon-delimited-run": "off",
|
|
64
|
+
"local/frontmatter-description-word-budget": ["error", { "keys": ["description"], "maxWords": 40 }]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Plugins are trusted code with no sandbox.
|
|
70
|
+
Running the CLI in a repository runs that repository's local rules and declared plugins, so use `--no-plugins` on one you do not trust.
|
|
71
|
+
[docs/plugins.md](docs/plugins.md) is the authoring guide, and [docs/engines.md](docs/engines.md) shows what the tree provides at each step of a check and a fix.
|
|
72
|
+
[`examples/plugin-skills`](examples/plugin-skills) and [`examples/plugin-skills-typescript`](examples/plugin-skills-typescript) hold the same working plugin in JavaScript and TypeScript.
|
|
73
|
+
It checks any `description` in a file's frontmatter at any depth, and has a fixer that rewrites a long one as a folded block.
|
|
74
|
+
|
|
43
75
|
## Consuming it
|
|
44
76
|
|
|
45
77
|
Each meta repo declares this package and runs it through a `docs-ci` target.
|
|
@@ -49,7 +81,8 @@ bun add --dev @jpeakai/prose-gates
|
|
|
49
81
|
```
|
|
50
82
|
|
|
51
83
|
npm works the same way, with `npm install --save-dev @jpeakai/prose-gates`.
|
|
52
|
-
The library exports `checkMarkdown` and `fixMarkdown
|
|
84
|
+
The library exports `checkMarkdown` and `fixMarkdown`, which return promises because a rule may be async.
|
|
85
|
+
`@jpeakai/prose-gates/testing` exports the helpers a plugin's tests use.
|
|
53
86
|
Bun imports the TypeScript source, and Node imports the bundle in `dist/`.
|
|
54
87
|
|
|
55
88
|
Generated markdown is gated too.
|